Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions features/comment.feature
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ Feature: Manage WordPress comments
#comment-1
"""

When I run `wp comment get 1 --field=url`
Then STDOUT should contain:
"""
#comment-1
"""

Scenario: List the URLs of comments
When I run `wp comment create --comment_post_ID=1 --porcelain`
Then save STDOUT as {COMMENT_ID}
Expand Down
6 changes: 6 additions & 0 deletions features/post.feature
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ Feature: Manage WordPress posts
https://example.com/?p={POST_ID}
"""

When I run `wp post get 1 --field=url`
Then STDOUT should be:
"""
https://example.com/?p=1
"""

Scenario: Update a post from file or STDIN
Given a content.html file:
"""
Expand Down
6 changes: 6 additions & 0 deletions features/term.feature
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ Feature: Manage WordPress terms
https://example.com/?cat=2
"""

When I run `wp term get category 1 --field=url`
Then STDOUT should be:
"""
https://example.com/?cat=1
"""

Scenario: Make sure WordPress receives the slashed data it expects
When I run `wp term create category 'My\Term' --description='My\Term\Description' --porcelain`
Then save STDOUT as {TERM_ID}
Expand Down
4 changes: 4 additions & 0 deletions src/Comment_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ public function get( $args, $assoc_args ) {
WP_CLI::error( 'Invalid comment ID.' );
}

if ( ! isset( $comment->url ) ) {
$comment->url = get_comment_link( $comment );
}

if ( empty( $assoc_args['fields'] ) ) {
$comment_array = get_object_vars( $comment );
$assoc_args['fields'] = array_keys( $comment_array );
Expand Down
4 changes: 4 additions & 0 deletions src/Post_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,10 @@ public function get( $args, $assoc_args ) {
$post_arr = get_object_vars( $post );
unset( $post_arr['filter'] );

if ( ! isset( $post_arr['url'] ) ) {
$post_arr['url'] = get_permalink( $post->ID );
}

if ( empty( $assoc_args['fields'] ) ) {
$assoc_args['fields'] = array_keys( $post_arr );
}
Expand Down
4 changes: 4 additions & 0 deletions src/Term_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ public function get( $args, $assoc_args ) {
WP_CLI::error( "Term doesn't exist." );
}

if ( ! isset( $term->url ) ) {
$term->url = get_term_link( $term );
}

if ( empty( $assoc_args['fields'] ) ) {
$term_array = get_object_vars( $term );
$assoc_args['fields'] = array_keys( $term_array );
Expand Down