Skip to content

Commit 84671a8

Browse files
DanieleFreemiusDanieleAlessandra
authored andcommitted
Moved get_all_modules_sites method from FS_DebugManager class back to Freemius class
1 parent 9f33005 commit 84671a8

File tree

3 files changed

+61
-55
lines changed

3 files changed

+61
-55
lines changed

includes/class-freemius.php

+59-1
Original file line numberDiff line numberDiff line change
@@ -3701,6 +3701,64 @@ static function _load_textdomain() {
37013701

37023702
#endregion
37033703

3704+
#----------------------------------------------------------------------------------
3705+
#region Debugging
3706+
#----------------------------------------------------------------------------------
3707+
3708+
/**
3709+
* Moved back here from the FS_DebugManager class.
3710+
*
3711+
* @author Leo Fajardo (@leorw)
3712+
*
3713+
* @return array
3714+
*
3715+
* @since 2.5.0
3716+
*/
3717+
static function get_all_modules_sites() {
3718+
self::get_static_logger()->entrance();
3719+
3720+
$sites_by_type = array(
3721+
WP_FS__MODULE_TYPE_PLUGIN => array(),
3722+
WP_FS__MODULE_TYPE_THEME => array(),
3723+
);
3724+
3725+
$module_types = array_keys( $sites_by_type );
3726+
3727+
if ( ! is_multisite() ) {
3728+
foreach ( $module_types as $type ) {
3729+
$sites_by_type[ $type ] = self::get_all_sites( $type );
3730+
3731+
foreach ( $sites_by_type[ $type ] as $slug => $install ) {
3732+
$sites_by_type[ $type ][ $slug ] = array( $install );
3733+
}
3734+
}
3735+
} else {
3736+
$sites = self::get_sites();
3737+
3738+
foreach ( $sites as $site ) {
3739+
$blog_id = self::get_site_blog_id( $site );
3740+
3741+
foreach ( $module_types as $type ) {
3742+
$installs = self::get_all_sites( $type, $blog_id );
3743+
3744+
foreach ( $installs as $slug => $install ) {
3745+
if ( ! isset( $sites_by_type[ $type ][ $slug ] ) ) {
3746+
$sites_by_type[ $type ][ $slug ] = array();
3747+
}
3748+
3749+
$install->blog_id = $blog_id;
3750+
3751+
$sites_by_type[ $type ][ $slug ][] = $install;
3752+
}
3753+
}
3754+
}
3755+
}
3756+
3757+
return $sites_by_type;
3758+
}
3759+
3760+
#endregion
3761+
37043762
#----------------------------------------------------------------------------------
37053763
#region Connectivity Issues
37063764
#----------------------------------------------------------------------------------
@@ -22601,7 +22659,7 @@ private function complete_change_owner() {
2260122659
$this->_set_account( $user, $this->_site );
2260222660

2260322661
$remove_user = true;
22604-
$all_modules_sites = FS_DebugManager::get_all_modules_sites();
22662+
$all_modules_sites = self::get_all_modules_sites();
2260522663

2260622664
foreach ( $all_modules_sites as $sites_by_module_type ) {
2260722665
foreach ( $sites_by_module_type as $sites_by_slug ) {

includes/managers/class-fs-clone-manager.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ private function find_network_subsite_clone_install( Freemius $instance ) {
333333
}
334334

335335
if ( ! isset( $this->all_installs ) ) {
336-
$this->all_installs = FS_DebugManager::get_all_modules_sites();
336+
$this->all_installs = Freemius::get_all_modules_sites();
337337
}
338338

339339
// Check if there's another blog that has the same site.

includes/managers/class-fs-debug-manager.php

+1-53
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static function _debug_page_actions() {
158158
static function _debug_page_render() {
159159
Freemius::get_static_logger()->entrance();
160160

161-
$all_modules_sites = self::get_all_modules_sites();
161+
$all_modules_sites = Freemius::get_all_modules_sites();
162162

163163
$licenses_by_module_type = self::get_all_licenses_by_module_type();
164164

@@ -381,58 +381,6 @@ private static function get_all_licenses_by_module_type() {
381381
return $licenses_by_module_type;
382382
}
383383

384-
/**
385-
* Moved from the Freemius class.
386-
*
387-
* @author Leo Fajardo (@leorw)
388-
*
389-
* @return array
390-
*
391-
* @since 2.5.0
392-
*/
393-
static function get_all_modules_sites() {
394-
Freemius::get_static_logger()->entrance();
395-
396-
$sites_by_type = array(
397-
WP_FS__MODULE_TYPE_PLUGIN => array(),
398-
WP_FS__MODULE_TYPE_THEME => array(),
399-
);
400-
401-
$module_types = array_keys( $sites_by_type );
402-
403-
if ( ! is_multisite() ) {
404-
foreach ( $module_types as $type ) {
405-
$sites_by_type[ $type ] = Freemius::get_all_sites( $type );
406-
407-
foreach ( $sites_by_type[ $type ] as $slug => $install ) {
408-
$sites_by_type[ $type ][ $slug ] = array( $install );
409-
}
410-
}
411-
} else {
412-
$sites = Freemius::get_sites();
413-
414-
foreach ( $sites as $site ) {
415-
$blog_id = Freemius::get_site_blog_id( $site );
416-
417-
foreach ( $module_types as $type ) {
418-
$installs = Freemius::get_all_sites( $type, $blog_id );
419-
420-
foreach ( $installs as $slug => $install ) {
421-
if ( ! isset( $sites_by_type[ $type ][ $slug ] ) ) {
422-
$sites_by_type[ $type ][ $slug ] = array();
423-
}
424-
425-
$install->blog_id = $blog_id;
426-
427-
$sites_by_type[ $type ][ $slug ][] = $install;
428-
}
429-
}
430-
}
431-
}
432-
433-
return $sites_by_type;
434-
}
435-
436384
/**
437385
* Delete user.
438386
*

0 commit comments

Comments
 (0)