WP_CLI\CommandWithUpgrade::_list PHP Method

_list() protected method

protected _list ( $_, $assoc_args )
    protected function _list($_, $assoc_args)
    {
        // Force WordPress to check for updates
        call_user_func($this->upgrade_refresh);
        $all_items = $this->get_all_items();
        if (!is_array($all_items)) {
            \WP_CLI::error("No {$this->item_type}s found.");
        }
        foreach ($all_items as $key => &$item) {
            if (empty($item['version'])) {
                $item['version'] = '';
            }
            foreach ($item as $field => &$value) {
                if ($value === true) {
                    $value = 'available';
                } else {
                    if ($value === false) {
                        $value = 'none';
                    }
                }
            }
            foreach ($this->obj_fields as $field) {
                if (isset($assoc_args[$field]) && $assoc_args[$field] != $item[$field]) {
                    unset($all_items[$key]);
                }
            }
        }
        $formatter = $this->get_formatter($assoc_args);
        $formatter->display_items($all_items);
    }

Usage Example

Example #1
0
 /**
  * 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.
  *
  * [--fields=<fields>]
  * : Limit the output to specific object fields. Defaults to name,status,update,version.
  *
  * [--format=<format>]
  * : Accepted values: table, json. Default: table
  *
  * ## EXAMPLES
  *
  *     wp theme list --status=inactive --format=csv
  *
  * @subcommand list
  */
 public function list_($_, $assoc_args)
 {
     parent::_list($_, $assoc_args);
 }
All Usage Examples Of WP_CLI\CommandWithUpgrade::_list