diff --git a/src/wp-includes/class-fix-wpcli.php b/src/wp-includes/class-fix-wpcli.php index 37dfb21100..22c1c04cc7 100644 --- a/src/wp-includes/class-fix-wpcli.php +++ b/src/wp-includes/class-fix-wpcli.php @@ -19,15 +19,31 @@ class Fix_WPCLI { * @since CP-1.5.0 */ public function __construct() { + WP_CLI::add_hook( 'after_wp_load', array( __CLASS__, 'add_cp_version_to_scope' ) ); WP_CLI::add_hook( 'before_invoke:core check-update', array( __CLASS__, 'correct_core_check_update' ) ); } + /** + * Add $cp_version to scope. + * + * @since CP-1.7.3 + */ + public static function add_cp_version_to_scope() { + // Add $cp_version to scope. + if ( ! isset( $GLOBALS['cp_version'] ) ) { + global $cp_version; + require ABSPATH . WPINC . '/version.php'; + } + } + /** * Fix wp core check-update command. * * @since CP-1.5.0 */ public static function correct_core_check_update() { + // Add $cp_version to scope. + global $cp_version; // Check for updates. Bail on error. // When playing with versions, an empty array is returned if it's not on api. @@ -71,12 +87,6 @@ public static function correct_core_check_update() { $major = preg_match( '/ --major */', $current_command ); - // Put $cp_version into scope. - if ( ! isset( $GLOBALS['cp_version'] ) ) { - global $cp_version; - require ABSPATH . WPINC . '/version.php'; - } - // Prepare output array. $table_output = array(); @@ -112,7 +122,6 @@ public static function correct_core_check_update() { // Exit to prevent the core check-update command to continue his work. exit; } - } new Fix_WPCLI();