-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathTerm_Meta_Command.php
More file actions
40 lines (37 loc) · 917 Bytes
/
Term_Meta_Command.php
File metadata and controls
40 lines (37 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
* Manage term custom fields.
*
* ## EXAMPLES
*
* # Set term meta
* $ wp term meta set 123 bio "Mary is a WordPress developer."
* Success: Updated custom field 'bio'.
*
* # Get term meta
* $ wp term meta get 123 bio
* Mary is a WordPress developer.
*
* # Update term meta
* $ wp term meta update 123 bio "Mary is an awesome WordPress developer."
* Success: Updated custom field 'bio'.
*
* # Delete term meta
* $ wp term meta delete 123 bio
* Success: Deleted custom field.
*/
class Term_Meta_Command extends \WP_CLI\CommandWithMeta {
protected $meta_type = 'term';
/**
* Check that the term ID exists
*
* @param int
*/
protected function check_object_id( $object_id ) {
$term = get_term( $object_id );
if ( ! $term ) {
WP_CLI::error( "Could not find the term with ID {$object_id}." );
}
return $term->term_id;
}
}