Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add examples and update the documentation to the wp post term #398

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
20 changes: 19 additions & 1 deletion src/Post_Term_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,27 @@
*
* ## EXAMPLES
*
* # Set post terms
* # Set category post term `test` to the post ID 123
* $ wp post term set 123 test category
* Success: Set term.
*
* # Set category post terms `test` and `apple` to the post ID 123
* $ wp post term set 123 test apple category
* Success: Set terms.
*
* # List category post terms for the post ID 123
* $ wp post term list 123 category --fields=term_id,slug
* +---------+-------+
* | term_id | slug |
* +---------+-------+
* | 2 | apple |
* | 3 | test |
* +----------+------+
*
* # Remove category post terms `test` and `apple` for the post ID 123
* $ wp post term remove 123 category test apple
* Success: Removed terms.
*
*/
class Post_Term_Command extends CommandWithTerms {
protected $obj_type = 'post';
Expand Down
11 changes: 7 additions & 4 deletions src/WP_CLI/CommandWithTerms.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,12 @@ public function list_( $args, $assoc_args ) {
* : The name of the term's taxonomy.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we update this one too? Are there others in the file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. By default, the slug is the taxonomy key but it can be different. I've updated the doc of the command set that was using slug instead of name to the taxonomy option.

*
* [<term>...]
* : The name of the term or terms to be removed from the object.
* : The slug of the term or terms (space-separated) to be removed from the object.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* : The slug of the term or terms (space-separated) to be removed from the object.
* : The slug of the term or terms to be removed from the object.

"(space-separated)" isn't necessary here because it's the same behavior across all commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @danielbachhuber

I've added space-separated through all commands so the user can have this information without having to visit another page. Do you think this is not necessary because of the examples added in the wp post term page?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think this is not necessary because of the examples added in the wp post term page?

Yes, and that it's standard behavior across all WP-CLI commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Removed.

*
* [--by=<field>]
* : Explicitly handle the term value as a slug or id.
* ---
* default: slug
* options:
* - slug
* - id
Expand Down Expand Up @@ -211,11 +212,12 @@ public function remove( $args, $assoc_args ) {
* : The name of the taxonomy type to be added.
*
* <term>...
* : The slug of the term or terms to be added.
* : The slug of the term or terms (space-separated) to be added.
*
* [--by=<field>]
* : Explicitly handle the term value as a slug or id.
* ---
* default: slug
* options:
* - slug
* - id
Expand Down Expand Up @@ -253,14 +255,15 @@ public function add( $args, $assoc_args ) {
* : The ID of the object.
*
* <taxonomy>
* : The name of the taxonomy type to be updated.
* : The slug of the taxonomy type to be updated.
*
* <term>...
* : The slug of the term or terms to be updated.
* : The slug of the term or terms (space-separated) to be updated.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* : The slug of the term or terms (space-separated) to be updated.
* : The slug of the term or terms to be updated.

*
* [--by=<field>]
* : Explicitly handle the term value as a slug or id.
* ---
* default: slug
* options:
* - slug
* - id
Expand Down