Skip to content
Merged
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
7 changes: 7 additions & 0 deletions includes/class-freemius.php
Original file line number Diff line number Diff line change
Expand Up @@ -15777,6 +15777,10 @@ static function get_sites_blog_ids( $sites ) {
function get_site_info( $site = null, $load_registration = false ) {
$this->_logger->entrance();

$fs_hook_snapshot = new FS_Hook_Snapshot();
// Remove all filters from `switch_blog`.
$fs_hook_snapshot->remove( 'switch_blog' );

$switched = false;

$registration_date = null;
Expand Down Expand Up @@ -15836,6 +15840,9 @@ function get_site_info( $site = null, $load_registration = false ) {
restore_current_blog();
}

// Add the filters back to `switch_blog`.
$fs_hook_snapshot->restore( 'switch_blog' );

return $info;
}

Expand Down
45 changes: 45 additions & 0 deletions includes/class-fs-hook-snapshot.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2025, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 2.12.2
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

/**
* Class FS_Hook_Snapshot
*
* This class allows you to take a snapshot of the current actions attached to a WordPress hook, remove them, and restore them later.
*/
class FS_Hook_Snapshot {

private $removed_actions = array();

/**
* Remove all actions from a given hook and store them for later restoration.
*/
public function remove( $hook ) {
global $wp_filter;

if ( ! empty( $wp_filter ) && isset( $wp_filter[ $hook ] ) ) {
$this->removed_actions[ $hook ] = $wp_filter[ $hook ];
unset( $wp_filter[ $hook ] );
}
}

/**
* Restore previously removed actions for a given hook.
*/
public function restore( $hook ) {
global $wp_filter;

if ( ! empty( $wp_filter ) && isset( $this->removed_actions[ $hook ] ) ) {
$wp_filter[ $hook ] = $this->removed_actions[ $hook ];
unset( $this->removed_actions[ $hook ] );
}
}
}
1 change: 1 addition & 0 deletions require.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@
require_once WP_FS__DIR_INCLUDES . '/class-fs-admin-notices.php';
require_once WP_FS__DIR_INCLUDES . '/class-freemius-abstract.php';
require_once WP_FS__DIR_INCLUDES . '/sdk/Exceptions/Exception.php';
require_once WP_FS__DIR_INCLUDES . '/class-fs-hook-snapshot.php';
require_once WP_FS__DIR_INCLUDES . '/class-freemius.php';
2 changes: 1 addition & 1 deletion start.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @var string
*/
$this_sdk_version = '2.12.1';
$this_sdk_version = '2.12.1.1';

#region SDK Selection Logic --------------------------------------------------------------------

Expand Down