Skip to content

Commit

Permalink
Delay loading plugin until after_setup_theme
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Apr 19, 2024
1 parent 7b3ee06 commit 27284ab
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions plugins/speculation-rules/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down

0 comments on commit 27284ab

Please sign in to comment.