1 | <?php |
||
15 | final class WP_Term { |
||
16 | |||
17 | /** |
||
18 | * Term ID. |
||
19 | * |
||
20 | * @since 4.4.0 |
||
21 | * @access public |
||
22 | * @var int |
||
23 | */ |
||
24 | public $term_id; |
||
25 | |||
26 | /** |
||
27 | * The term's name. |
||
28 | * |
||
29 | * @since 4.4.0 |
||
30 | * @access public |
||
31 | * @var string |
||
32 | */ |
||
33 | public $name = ''; |
||
34 | |||
35 | /** |
||
36 | * The term's slug. |
||
37 | * |
||
38 | * @since 4.4.0 |
||
39 | * @access public |
||
40 | * @var string |
||
41 | */ |
||
42 | public $slug = ''; |
||
43 | |||
44 | /** |
||
45 | * The term's term_group. |
||
46 | * |
||
47 | * @since 4.4.0 |
||
48 | * @access public |
||
49 | * @var string |
||
50 | */ |
||
51 | public $term_group = ''; |
||
52 | |||
53 | /** |
||
54 | * Term Taxonomy ID. |
||
55 | * |
||
56 | * @since 4.4.0 |
||
57 | * @access public |
||
58 | * @var int |
||
59 | */ |
||
60 | public $term_taxonomy_id = 0; |
||
61 | |||
62 | /** |
||
63 | * The term's taxonomy name. |
||
64 | * |
||
65 | * @since 4.4.0 |
||
66 | * @access public |
||
67 | * @var string |
||
68 | */ |
||
69 | public $taxonomy = ''; |
||
70 | |||
71 | /** |
||
72 | * The term's description. |
||
73 | * |
||
74 | * @since 4.4.0 |
||
75 | * @access public |
||
76 | * @var string |
||
77 | */ |
||
78 | public $description = ''; |
||
79 | |||
80 | /** |
||
81 | * ID of a term's parent term. |
||
82 | * |
||
83 | * @since 4.4.0 |
||
84 | * @access public |
||
85 | * @var int |
||
86 | */ |
||
87 | public $parent = 0; |
||
88 | |||
89 | /** |
||
90 | * Cached object count for this term. |
||
91 | * |
||
92 | * @since 4.4.0 |
||
93 | * @access public |
||
94 | * @var int |
||
95 | */ |
||
96 | public $count = 0; |
||
97 | |||
98 | /** |
||
99 | * Stores the term object's sanitization level. |
||
100 | * |
||
101 | * Does not correspond to a database field. |
||
102 | * |
||
103 | * @since 4.4.0 |
||
104 | * @access public |
||
105 | * @var string |
||
106 | */ |
||
107 | public $filter = 'raw'; |
||
108 | |||
109 | /** |
||
110 | * Retrieve WP_Term instance. |
||
111 | * |
||
112 | * @since 4.4.0 |
||
113 | * @access public |
||
114 | * @static |
||
115 | * |
||
116 | * @global wpdb $wpdb WordPress database abstraction object. |
||
117 | * |
||
118 | * @param int $term_id Term ID. |
||
119 | * @param string $taxonomy Optional. Limit matched terms to those matching `$taxonomy`. Only used for |
||
120 | * disambiguating potentially shared terms. |
||
121 | * @return WP_Term|WP_Error|false Term object, if found. WP_Error if `$term_id` is shared between taxonomies and |
||
122 | * there's insufficient data to distinguish which term is intended. |
||
123 | * False for other failures. |
||
124 | */ |
||
125 | public static function get_instance( $term_id, $taxonomy = null ) { |
||
195 | |||
196 | /** |
||
197 | * Constructor. |
||
198 | * |
||
199 | * @since 4.4.0 |
||
200 | * @access public |
||
201 | * |
||
202 | * @param WP_Term|object $term Term object. |
||
203 | */ |
||
204 | public function __construct( $term ) { |
||
209 | |||
210 | /** |
||
211 | * Sanitizes term fields, according to the filter type provided. |
||
212 | * |
||
213 | * @since 4.4.0 |
||
214 | * @access public |
||
215 | * |
||
216 | * @param string $filter Filter context. Accepts 'edit', 'db', 'display', 'attribute', 'js', 'raw'. |
||
217 | */ |
||
218 | public function filter( $filter ) { |
||
221 | |||
222 | /** |
||
223 | * Converts an object to array. |
||
224 | * |
||
225 | * @since 4.4.0 |
||
226 | * @access public |
||
227 | * |
||
228 | * @return array Object as array. |
||
229 | */ |
||
230 | public function to_array() { |
||
233 | |||
234 | /** |
||
235 | * Getter. |
||
236 | * |
||
237 | * @since 4.4.0 |
||
238 | * @access public |
||
239 | * |
||
240 | * @param string $key Property to get. |
||
241 | * @return mixed Property value. |
||
242 | */ |
||
243 | public function __get( $key ) { |
||
256 | } |
||
257 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: