Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 59 additions & 1 deletion includes/class-freemius.php
Original file line number Diff line number Diff line change
Expand Up @@ -3701,6 +3701,64 @@ static function _load_textdomain() {

#endregion

#----------------------------------------------------------------------------------
#region Debugging
#----------------------------------------------------------------------------------

/**
* Moved back here from the FS_DebugManager class.
*
* @author Leo Fajardo (@leorw)
*
* @return array
*
* @since 2.5.0
*/
static function get_all_modules_sites() {
self::get_static_logger()->entrance();

$sites_by_type = array(
WP_FS__MODULE_TYPE_PLUGIN => array(),
WP_FS__MODULE_TYPE_THEME => array(),
);

$module_types = array_keys( $sites_by_type );

if ( ! is_multisite() ) {
foreach ( $module_types as $type ) {
$sites_by_type[ $type ] = self::get_all_sites( $type );

foreach ( $sites_by_type[ $type ] as $slug => $install ) {
$sites_by_type[ $type ][ $slug ] = array( $install );
}
}
} else {
$sites = self::get_sites();

foreach ( $sites as $site ) {
$blog_id = self::get_site_blog_id( $site );

foreach ( $module_types as $type ) {
$installs = self::get_all_sites( $type, $blog_id );

foreach ( $installs as $slug => $install ) {
if ( ! isset( $sites_by_type[ $type ][ $slug ] ) ) {
$sites_by_type[ $type ][ $slug ] = array();
}

$install->blog_id = $blog_id;

$sites_by_type[ $type ][ $slug ][] = $install;
}
}
}
}

return $sites_by_type;
}

#endregion

#----------------------------------------------------------------------------------
#region Connectivity Issues
#----------------------------------------------------------------------------------
Expand Down Expand Up @@ -22601,7 +22659,7 @@ private function complete_change_owner() {
$this->_set_account( $user, $this->_site );

$remove_user = true;
$all_modules_sites = FS_DebugManager::get_all_modules_sites();
$all_modules_sites = self::get_all_modules_sites();

foreach ( $all_modules_sites as $sites_by_module_type ) {
foreach ( $sites_by_module_type as $sites_by_slug ) {
Expand Down
2 changes: 1 addition & 1 deletion includes/managers/class-fs-clone-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ private function find_network_subsite_clone_install( Freemius $instance ) {
}

if ( ! isset( $this->all_installs ) ) {
$this->all_installs = FS_DebugManager::get_all_modules_sites();
$this->all_installs = Freemius::get_all_modules_sites();
}

// Check if there's another blog that has the same site.
Expand Down
54 changes: 1 addition & 53 deletions includes/managers/class-fs-debug-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static function _debug_page_actions() {
static function _debug_page_render() {
Freemius::get_static_logger()->entrance();

$all_modules_sites = self::get_all_modules_sites();
$all_modules_sites = Freemius::get_all_modules_sites();

$licenses_by_module_type = self::get_all_licenses_by_module_type();

Expand Down Expand Up @@ -381,58 +381,6 @@ private static function get_all_licenses_by_module_type() {
return $licenses_by_module_type;
}

/**
* Moved from the Freemius class.
*
* @author Leo Fajardo (@leorw)
*
* @return array
*
* @since 2.5.0
*/
static function get_all_modules_sites() {
Freemius::get_static_logger()->entrance();

$sites_by_type = array(
WP_FS__MODULE_TYPE_PLUGIN => array(),
WP_FS__MODULE_TYPE_THEME => array(),
);

$module_types = array_keys( $sites_by_type );

if ( ! is_multisite() ) {
foreach ( $module_types as $type ) {
$sites_by_type[ $type ] = Freemius::get_all_sites( $type );

foreach ( $sites_by_type[ $type ] as $slug => $install ) {
$sites_by_type[ $type ][ $slug ] = array( $install );
}
}
} else {
$sites = Freemius::get_sites();

foreach ( $sites as $site ) {
$blog_id = Freemius::get_site_blog_id( $site );

foreach ( $module_types as $type ) {
$installs = Freemius::get_all_sites( $type, $blog_id );

foreach ( $installs as $slug => $install ) {
if ( ! isset( $sites_by_type[ $type ][ $slug ] ) ) {
$sites_by_type[ $type ][ $slug ] = array();
}

$install->blog_id = $blog_id;

$sites_by_type[ $type ][ $slug ][] = $install;
}
}
}
}

return $sites_by_type;
}

/**
* Delete user.
*
Expand Down