| @@ -14,9 +14,9 @@ | ||
| 14 | 14 | * Freemius SDK Version. |
| 15 | 15 | * |
| 16 | 16 | * @var string |
| 17 | 17 | */ |
| 18 | - $this_sdk_version = '2.4.5'; | |
| 18 | + $this_sdk_version = '2.6.2'; | |
| 19 | 19 | |
| 20 | 20 | #region SDK Selection Logic -------------------------------------------------------------------- |
| 21 | 21 | |
| 22 | 22 | /** |
| @@ -45,8 +45,36 @@ | ||
| 45 | 45 | * @since 1.2.2.6 |
| 46 | 46 | */ |
| 47 | 47 | $file_path = fs_normalize_path( __FILE__ ); |
| 48 | 48 | $fs_root_path = dirname( $file_path ); |
| 49 | + | |
| 50 | + // @todo: Remove this code after a few months when WP 6.3 usage is low enough. | |
| 51 | + global $wp_version; | |
| 52 | + | |
| 53 | + if ( | |
| 54 | + ! function_exists( 'wp_get_current_user' ) && | |
| 55 | + /** | |
| 56 | + * `get_stylesheet()` will rely on `wp_get_current_user()` when it is being filtered by `theme-previews.php`. That happens only when the site editor is loaded or when the site editor is sending REST requests. | |
| 57 | + * @see theme-previews.php:wp_get_theme_preview_path() | |
| 58 | + * | |
| 59 | + * @todo This behavior is already fixed in the core (WP 6.3.2+), and this code can be removed after a few months when WP 6.3 usage is low enough. | |
| 60 | + * @since WP 6.3.0 | |
| 61 | + */ | |
| 62 | + version_compare( $wp_version, '6.3', '>=' ) && | |
| 63 | + version_compare( $wp_version, '6.3.1', '<=' ) && | |
| 64 | + ( | |
| 65 | + 'site-editor.php' === basename( $_SERVER['SCRIPT_FILENAME'] ) || | |
| 66 | + ( | |
| 67 | + function_exists( 'wp_is_json_request' ) && | |
| 68 | + wp_is_json_request() && | |
| 69 | + ! empty( $_GET['wp_theme_preview'] ) | |
| 70 | + ) | |
| 71 | + ) | |
| 72 | + ) { | |
| 73 | + // Requiring this file since the call to get_stylesheet() below can trigger a call to wp_get_current_user() when previewing a theme. | |
| 74 | + require_once ABSPATH . 'wp-includes/pluggable.php'; | |
| 75 | + } | |
| 76 | + | |
| 49 | 77 | /** |
| 50 | 78 | * Get the themes directory where the active theme is located (not passing the stylesheet will make WordPress |
| 51 | 79 | * assume that the themes directory is inside `wp-content`. |
| 52 | 80 | * |
| @@ -67,9 +95,13 @@ | ||
| 67 | 95 | } |
| 68 | 96 | |
| 69 | 97 | if ( ! isset( $fs_active_plugins ) ) { |
| 70 | 98 | // Load all Freemius powered active plugins. |
| 71 | - $fs_active_plugins = get_option( 'fs_active_plugins', new stdClass() ); | |
| 99 | + $fs_active_plugins = get_option( 'fs_active_plugins' ); | |
| 100 | + | |
| 101 | + if ( ! is_object( $fs_active_plugins ) ) { | |
| 102 | + $fs_active_plugins = new stdClass(); | |
| 103 | + } | |
| 72 | 104 | |
| 73 | 105 | if ( ! isset( $fs_active_plugins->plugins ) ) { |
| 74 | 106 | $fs_active_plugins->plugins = array(); |
| 75 | 107 | } |