File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -370,3 +370,37 @@ Feature: Manage WordPress posts
370370 | {POST_ID } | key1 | value1 |
371371 | {POST_ID } | key2 | value2b |
372372 | {POST_ID } | key3 | value3 |
373+
374+ @less-than-wp-4.4
375+ Scenario : Creating/updating posts with meta keys for WP < 4.4 has no effect so should give warning
376+ When I try `wp post create --post_title='Test Post' --post_content='Test post content' --meta_input='{"key1":"value1","key2":"value2"}' --porcelain`
377+ Then the return code should be 0
378+ And STDOUT should be a number
379+ And save STDOUT as {POST_ID}
380+ And STDERR should be:
381+ """
382+ Warning: The 'meta_input' field was only introduced in WordPress 4.4 so will have no effect.
383+ """
384+
385+ When I run `wp post meta list {POST_ID} --format=count`
386+ Then STDOUT should be:
387+ """
388+ 0
389+ """
390+
391+ When I try `wp post update {POST_ID} --meta_input='{"key2":"value2b","key3":"value3"}' `
392+ Then the return code should be 0
393+ And STDERR should be:
394+ """
395+ Warning: The 'meta_input' field was only introduced in WordPress 4.4 so will have no effect.
396+ """
397+ And STDOUT should be:
398+ """
399+ Success: Updated post {POST_ID}.
400+ """
401+
402+ When I run `wp post meta list {POST_ID} --format=count`
403+ Then STDOUT should be:
404+ """
405+ 0
406+ """
Original file line number Diff line number Diff line change @@ -166,6 +166,10 @@ public function create( $args, $assoc_args ) {
166166 $ assoc_args ['post_category ' ] = $ this ->get_category_ids ( $ assoc_args ['post_category ' ] );
167167 }
168168
169+ if ( isset ( $ assoc_args ['meta_input ' ] ) && \WP_CLI \Utils \wp_version_compare ( '4.4 ' , '< ' ) ) {
170+ WP_CLI ::warning ( "The 'meta_input' field was only introduced in WordPress 4.4 so will have no effect. " );
171+ }
172+
169173 $ array_arguments = array ( 'meta_input ' );
170174 $ assoc_args = \WP_CLI \Utils \parse_shell_arrays ( $ assoc_args , $ array_arguments );
171175
@@ -296,6 +300,10 @@ public function update( $args, $assoc_args ) {
296300 $ assoc_args ['post_category ' ] = $ this ->get_category_ids ( $ assoc_args ['post_category ' ] );
297301 }
298302
303+ if ( isset ( $ assoc_args ['meta_input ' ] ) && \WP_CLI \Utils \wp_version_compare ( '4.4 ' , '< ' ) ) {
304+ WP_CLI ::warning ( "The 'meta_input' field was only introduced in WordPress 4.4 so will have no effect. " );
305+ }
306+
299307 $ array_arguments = array ( 'meta_input ' );
300308 $ assoc_args = \WP_CLI \Utils \parse_shell_arrays ( $ assoc_args , $ array_arguments );
301309
You can’t perform that action at this time.
0 commit comments