OSDN Git Service

don't return 'filter' object in `wp post get --format=json`
authorscribu <mail@scribu.net>
Thu, 1 Aug 2013 00:43:46 +0000 (03:43 +0300)
committerscribu <mail@scribu.net>
Thu, 1 Aug 2013 00:44:50 +0000 (03:44 +0300)
it's a transient value, not actual data

php/commands/post.php

index 8ef3c72..f368f7b 100644 (file)
@@ -37,7 +37,7 @@ class Post_Command extends \WP_CLI\CommandWithDBObject {
                }
 
                if ( isset( $assoc_args['edit'] ) ) {
-                       $input = ( isset( $assoc_args['post_content'] ) ) ?
+                       $input = isset( $assoc_args['post_content'] ) ?
                                $assoc_args['post_content'] : '';
 
                        if ( $output = $this->_edit( $input, 'WP-CLI: New Post' ) )
@@ -116,7 +116,9 @@ class Post_Command extends \WP_CLI\CommandWithDBObject {
                        break;
 
                case 'json':
-                       WP_CLI::print_value( $post, $assoc_args );
+                       $fields = get_object_vars( $post );
+                       unset( $fields['filter'] );
+                       WP_CLI::print_value( $fields, $assoc_args );
                        break;
 
                default: