diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index 9319ea17a..282c422f3 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -60,7 +60,7 @@ public function __construct( Plugin_Context $plugin_context ) { * : The plugin to check. Plugin name. * * [--checks=] - * : Only runs checks provided as an argument in comma-separated values, e.g. enqueued-scripts, escaping. Otherwise runs all checks. + * : Only runs checks provided as an argument in comma-separated values, e.g. i18n_usage, late_escaping. Otherwise runs all checks. * * [--format=] * : Format to display the results. Options are table, csv, and json. The default will be a table. @@ -87,10 +87,14 @@ public function __construct( Plugin_Context $plugin_context ) { * [--include-experimental] * : Include experimental checks. * + * [--exclude-directories=] + * : Additional directories to exclude from checks + * By default, `.git`, `vendor` and `node_modules` directories are excluded. + * * ## EXAMPLES * * wp plugin check akismet - * wp plugin check akismet --checks=escaping + * wp plugin check akismet --checks=late_escaping * wp plugin check akismet --format=json * * @subcommand check @@ -128,6 +132,15 @@ public function check( $args, $assoc_args ) { // Create the categories array from CLI arguments. $categories = isset( $options['categories'] ) ? wp_parse_list( $options['categories'] ) : array(); + $excluded_directories = isset( $options['exclude-directories'] ) ? wp_parse_list( $options['exclude-directories'] ) : array(); + + add_filter( + 'wp_plugin_check_ignore_directories', + static function ( $dirs ) use ( $excluded_directories ) { + return array_unique( array_merge( $dirs, $excluded_directories ) ); + } + ); + // Get the CLI Runner. $runner = Plugin_Request_Utility::get_runner();