From 27284ab3b05f1872858333898a9a51eaaf376ee3 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Fri, 19 Apr 2024 14:13:34 -0700 Subject: [PATCH] Delay loading plugin until after_setup_theme --- plugins/speculation-rules/load.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/plugins/speculation-rules/load.php b/plugins/speculation-rules/load.php index 0dc0e4a29f..388e83aa0f 100644 --- a/plugins/speculation-rules/load.php +++ b/plugins/speculation-rules/load.php @@ -34,21 +34,14 @@ static function ( string $global_var_name, string $version, Closure $load ) { if ( isset( $GLOBALS[ $global_var_name ]['load'] ) && - ! isset( $GLOBALS[ $global_var_name ]['loaded'] ) - && $GLOBALS[ $global_var_name ]['load'] instanceof Closure ) { call_user_func( $GLOBALS[ $global_var_name ]['load'] ); - $GLOBALS[ $global_var_name ]['loaded'] = true; + unset( $GLOBALS[ $global_var_name ] ); } }; - // Handle either where the plugin is installed as a regular plugin or is embedded in another plugin or in a theme. - if ( ! did_action( 'plugins_loaded' ) ) { - add_action( 'plugins_loaded', $bootstrap, 0 ); - } - - // Handle case where plugin is embedded in a theme. + // Wait until after the plugins have loaded and the theme has loaded. add_action( 'after_setup_theme', $bootstrap, 0 ); }