OSDN Git Service

Revert parts of 3500a184e5ca652370fdaa7e2c2217290fadf69c.
authorDaniel Bachhuber <d@danielbachhuber.com>
Wed, 8 May 2013 23:01:19 +0000 (16:01 -0700)
committerDaniel Bachhuber <d@danielbachhuber.com>
Wed, 8 May 2013 23:01:19 +0000 (16:01 -0700)
Changing the order in which arguments are passed will break community use of this helper function.

See https://github.com/wp-cli/wp-cli/commit/3500a184e5ca652370fdaa7e2c2217290fadf69c#commitcomment-3174323

php/commands/post.php
php/commands/role.php
php/commands/term.php
php/commands/user.php
php/utils.php

index d9d182f..7952a8b 100644 (file)
@@ -123,7 +123,7 @@ class Post_Command extends \WP_CLI\CommandWithDBObject {
                                $items[] = $item;
                        }
 
-                       \WP_CLI\Utils\format_items( $items, $format, array( 'Field', 'Value' ) );
+                       \WP_CLI\Utils\format_items( $format, $items, array( 'Field', 'Value' ) );
                        break;
 
                case 'json':
@@ -200,7 +200,7 @@ class Post_Command extends \WP_CLI\CommandWithDBObject {
 
                $query = new WP_Query( $query_args );
 
-               WP_CLI\Utils\format_items( $query->posts, $values['format'], $values['fields'] );
+               WP_CLI\Utils\format_items( $values['format'], $query->posts, $values['fields'] );
        }
 
        /**
index 2f88e4d..bfd974b 100644 (file)
@@ -40,7 +40,7 @@ class Role_Command extends WP_CLI_Command {
                        $output_roles[] = $output_role;
                }
 
-               WP_CLI\Utils\format_items( $output_roles, $params['format'], $fields );
+               WP_CLI\Utils\format_items( $params['format'], $output_roles, $fields );
        }
 
        /**
index 5c9c724..5cbaf0a 100644 (file)
@@ -41,7 +41,7 @@ class Term_Command extends WP_CLI_Command {
                if ( 'ids' == $assoc_args['format'] )
                        $terms = wp_list_pluck( $terms, 'term_id' );
 
-               WP_CLI\Utils\format_items( $terms, $assoc_args['format'], $fields, $terms );
+               WP_CLI\Utils\format_items( $assoc_args['format'], $terms, $fields );
        }
 
        /**
index 1880a29..23b68f3 100644 (file)
@@ -53,7 +53,7 @@ class User_Command extends \WP_CLI\CommandWithDBObject {
                        }
                }
 
-               WP_CLI\Utils\format_items( $users, $params['format'], $fields );
+               WP_CLI\Utils\format_items( $params['format'], $users, $fields );
        }
 
        /**
index acb259d..39ff8e7 100644 (file)
@@ -255,11 +255,11 @@ function recursive_unserialize_replace( $from = '', $to = '', $data = '', $seria
 /**
  * Output items in a table, JSON, or CSV
  *
+ * @param string        $format     Format to use: 'table', 'json', 'csv', 'ids'
  * @param array         $items      Data to output
- * @param string        $format     Format to use: 'table', 'json', 'csv'
  * @param array|string  $fields     Named fields for each item of data. Can be array or comma-separated list
  */
-function format_items( $items, $format, $fields ) {
+function format_items( $format, $items, $fields ) {
        if ( 'ids' == $format )
                \WP_CLI::out( implode( ' ', $items ) );