OSDN Git Service

Support for filtering plugin and theme lists based on object attributes.
authorDaniel Bachhuber <d@danielbachhuber.com>
Fri, 22 Nov 2013 17:58:38 +0000 (09:58 -0800)
committerDaniel Bachhuber <d@danielbachhuber.com>
Fri, 22 Nov 2013 17:58:38 +0000 (09:58 -0800)
php/WP_CLI/CommandWithUpgrade.php
php/commands/plugin.php
php/commands/theme.php

index 73c2162..7ded309 100644 (file)
@@ -266,6 +266,18 @@ abstract class CommandWithUpgrade extends \WP_CLI_Command {
                        return $item;
                } );
 
+               foreach( $it as $key => $item ) {
+
+                       foreach( $this->obj_fields as $field ) {
+
+                               if ( isset( $assoc_args[$field] )
+                                       && $assoc_args[$field] != $item[$field] )
+                                       $it->offsetUnset( $key );
+
+                       }
+
+               }
+
                $formatter = $this->get_formatter( $assoc_args );
                $formatter->display_items( $it );
        }
index 3edf31c..59436c6 100644 (file)
@@ -479,6 +479,9 @@ class Plugin_Command extends \WP_CLI\CommandWithUpgrade {
         * Get a list of plugins.
         *
         * ## OPTIONS
+        * 
+        * [--<field>=<value>]
+        * : Filter results based on the value of a field.
         *
         * [--field=<field>]
         * : Prints the value of a single field for each plugin.
index 3cfdfae..1fdf3cb 100644 (file)
@@ -376,6 +376,9 @@ class Theme_Command extends \WP_CLI\CommandWithUpgrade {
         * Get a list of themes.
         *
         * ## OPTIONS
+        * 
+        * [--<field>=<value>]
+        * : Filter results based on the value of a field.
         *
         * [--field=<field>]
         * : Prints the value of a single field for each theme.