Skip to content

Commit

Permalink
Added a late initialization step. (#14199)
Browse files Browse the repository at this point in the history
* Added a late initialization step.

This will allow us to migrate code that has been working before plugins are loaded to this later stage where plugin code is available and the autoloader has a way to figure out the latest version of bundled libraries.

* Fix a typo and remove an extra space to clear a phpcs warning.


Co-authored-by: Kim Brown <50059399+kbrown9@users.noreply.github.com>
  • Loading branch information
2 people authored and jeherve committed Dec 10, 2019
1 parent 8caedab commit 0b00c12
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion class.jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,8 @@ private function __construct() {
add_action( 'init', array( 'Jetpack_Keyring_Service_Helper', 'init' ), 9, 0 );
}

add_action( 'plugins_loaded', array( $this, 'after_plugins_loaded' ) );
add_action( 'plugins_loaded', array( $this, 'after_plugins_loaded' ) );
add_action( 'plugins_loaded', array( $this, 'late_initialization' ), 90 );

add_filter(
'jetpack_connection_secret_generator',
Expand Down Expand Up @@ -755,6 +756,24 @@ function after_plugins_loaded() {
}
}

/**
* Runs on plugins_loaded. Use this to add code that needs to be executed later than other
* initialization code.
*
* @action plugins_loaded
*/
public function late_initialization() {
/**
* Fires when Jetpack is fully loaded and ready. This is the point where it's safe
* to instantiate classes from packages and namespaces that are managed by the Jetpack Autoloader.
*
* @since 8.1.0
*
* @param Jetpack $jetpack the main plugin class object.
*/
do_action( 'jetpack_loaded', $this );
}

/**
* Sets up the XMLRPC request handlers.
*
Expand Down

0 comments on commit 0b00c12

Please sign in to comment.