diff --git a/cli.php b/cli.php index c8aa56e62..fcd9cdb4b 100644 --- a/cli.php +++ b/cli.php @@ -8,6 +8,7 @@ * @since n.e.x.t */ +use WordPress\Plugin_Check\Checker\CLI_Runner; use WordPress\Plugin_Check\Plugin_Context; use WordPress\Plugin_Check\CLI\Plugin_Check_Command; @@ -44,15 +45,7 @@ WP_CLI::add_hook( 'before_wp_load', function() { - if ( empty( $_SERVER['argv'] ) || 3 > count( $_SERVER['argv'] ) ) { - return; - } - - if ( - 'wp' === substr( $_SERVER['argv'][0], -2 ) && - 'plugin' === $_SERVER['argv'][1] && - 'check' === $_SERVER['argv'][2] - ) { + if ( CLI_Runner::is_plugin_check() ) { if ( ! file_exists( ABSPATH . 'wp-content/object-cache.php' ) ) { if ( ! copy( __DIR__ . '/object-cache.copy.php', ABSPATH . 'wp-content/object-cache.php' ) ) { WP_CLI::error( 'Unable to copy object-cache.php file.' ); diff --git a/includes/Checker/AJAX_Runner.php b/includes/Checker/AJAX_Runner.php index 7ebd3b8fe..69b4daa08 100644 --- a/includes/Checker/AJAX_Runner.php +++ b/includes/Checker/AJAX_Runner.php @@ -31,7 +31,7 @@ class AJAX_Runner extends Abstract_Check_Runner { * * @return bool Returns true if is an AJAX request for the plugin check else false. */ - public function is_plugin_check() { + public static function is_plugin_check() { if ( ! wp_doing_ajax() ) { return false; } diff --git a/includes/Checker/Abstract_Check_Runner.php b/includes/Checker/Abstract_Check_Runner.php index b225588b6..58f6c9045 100644 --- a/includes/Checker/Abstract_Check_Runner.php +++ b/includes/Checker/Abstract_Check_Runner.php @@ -65,7 +65,7 @@ abstract class Abstract_Check_Runner implements Check_Runner { * * @return bool Returns true if the check is for plugin else false. */ - abstract public function is_plugin_check(); + abstract public static function is_plugin_check(); /** * Returns the plugin parameter based on the request. diff --git a/includes/Checker/CLI_Runner.php b/includes/Checker/CLI_Runner.php index 50b6a2a43..debfe557c 100644 --- a/includes/Checker/CLI_Runner.php +++ b/includes/Checker/CLI_Runner.php @@ -31,7 +31,7 @@ class CLI_Runner extends Abstract_Check_Runner { * * @return bool Returns true if is an CLI request for the plugin check else false. */ - public function is_plugin_check() { + public static function is_plugin_check() { if ( empty( $_SERVER['argv'] ) || 3 > count( $_SERVER['argv'] ) ) { return false; } diff --git a/includes/Checker/Check_Runner.php b/includes/Checker/Check_Runner.php index bec52f227..27390283e 100644 --- a/includes/Checker/Check_Runner.php +++ b/includes/Checker/Check_Runner.php @@ -23,7 +23,7 @@ interface Check_Runner { * * @return boolean Returns true if the check is for plugin else false. */ - public function is_plugin_check(); + public static function is_plugin_check(); /** * Prepares the environment for running the requested checks.