equal
deleted
inserted
replaced
126 * @var bool|callable |
126 * @var bool|callable |
127 */ |
127 */ |
128 public $meta_box_cb = null; |
128 public $meta_box_cb = null; |
129 |
129 |
130 /** |
130 /** |
|
131 * The callback function for sanitizing taxonomy data saved from a meta box. |
|
132 * |
|
133 * @since 5.1.0 |
|
134 * @var callable |
|
135 */ |
|
136 public $meta_box_sanitize_cb = null; |
|
137 |
|
138 /** |
131 * An array of object types this taxonomy is registered for. |
139 * An array of object types this taxonomy is registered for. |
132 * |
140 * |
133 * @since 4.7.0 |
141 * @since 4.7.0 |
134 * @var array |
142 * @var array |
135 */ |
143 */ |
137 |
145 |
138 /** |
146 /** |
139 * Capabilities for this taxonomy. |
147 * Capabilities for this taxonomy. |
140 * |
148 * |
141 * @since 4.7.0 |
149 * @since 4.7.0 |
142 * @var array |
150 * @var object |
143 */ |
151 */ |
144 public $cap; |
152 public $cap; |
145 |
153 |
146 /** |
154 /** |
147 * Rewrites information for this taxonomy. |
155 * Rewrites information for this taxonomy. |
236 /** |
244 /** |
237 * Filters the arguments for registering a taxonomy. |
245 * Filters the arguments for registering a taxonomy. |
238 * |
246 * |
239 * @since 4.4.0 |
247 * @since 4.4.0 |
240 * |
248 * |
241 * @param array $args Array of arguments for registering a taxonomy. |
249 * @param array $args Array of arguments for registering a taxonomy. |
242 * @param string $taxonomy Taxonomy key. |
250 * @param string $taxonomy Taxonomy key. |
243 * @param array $object_type Array of names of object types for the taxonomy. |
251 * @param string[] $object_type Array of names of object types for the taxonomy. |
244 */ |
252 */ |
245 $args = apply_filters( 'register_taxonomy_args', $args, $this->name, (array) $object_type ); |
253 $args = apply_filters( 'register_taxonomy_args', $args, $this->name, (array) $object_type ); |
246 |
254 |
247 $defaults = array( |
255 $defaults = array( |
248 'labels' => array(), |
256 'labels' => array(), |
255 'show_in_nav_menus' => null, |
263 'show_in_nav_menus' => null, |
256 'show_tagcloud' => null, |
264 'show_tagcloud' => null, |
257 'show_in_quick_edit' => null, |
265 'show_in_quick_edit' => null, |
258 'show_admin_column' => false, |
266 'show_admin_column' => false, |
259 'meta_box_cb' => null, |
267 'meta_box_cb' => null, |
|
268 'meta_box_sanitize_cb' => null, |
260 'capabilities' => array(), |
269 'capabilities' => array(), |
261 'rewrite' => true, |
270 'rewrite' => true, |
262 'query_var' => $this->name, |
271 'query_var' => $this->name, |
263 'update_count_callback' => '', |
272 'update_count_callback' => '', |
264 'show_in_rest' => false, |
273 'show_in_rest' => false, |
284 // Force query_var to false for non-public taxonomies. |
293 // Force query_var to false for non-public taxonomies. |
285 $args['query_var'] = false; |
294 $args['query_var'] = false; |
286 } |
295 } |
287 |
296 |
288 if ( false !== $args['rewrite'] && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) { |
297 if ( false !== $args['rewrite'] && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) { |
289 $args['rewrite'] = wp_parse_args( $args['rewrite'], array( |
298 $args['rewrite'] = wp_parse_args( |
290 'with_front' => true, |
299 $args['rewrite'], |
291 'hierarchical' => false, |
300 array( |
292 'ep_mask' => EP_NONE, |
301 'with_front' => true, |
293 ) ); |
302 'hierarchical' => false, |
|
303 'ep_mask' => EP_NONE, |
|
304 ) |
|
305 ); |
294 |
306 |
295 if ( empty( $args['rewrite']['slug'] ) ) { |
307 if ( empty( $args['rewrite']['slug'] ) ) { |
296 $args['rewrite']['slug'] = sanitize_title_with_dashes( $this->name ); |
308 $args['rewrite']['slug'] = sanitize_title_with_dashes( $this->name ); |
297 } |
309 } |
298 } |
310 } |
343 } |
355 } |
344 } |
356 } |
345 |
357 |
346 $args['name'] = $this->name; |
358 $args['name'] = $this->name; |
347 |
359 |
|
360 // Default meta box sanitization callback depends on the value of 'meta_box_cb'. |
|
361 if ( null === $args['meta_box_sanitize_cb'] ) { |
|
362 switch ( $args['meta_box_cb'] ) { |
|
363 case 'post_categories_meta_box': |
|
364 $args['meta_box_sanitize_cb'] = 'taxonomy_meta_box_sanitize_cb_checkboxes'; |
|
365 break; |
|
366 |
|
367 case 'post_tags_meta_box': |
|
368 default: |
|
369 $args['meta_box_sanitize_cb'] = 'taxonomy_meta_box_sanitize_cb_input'; |
|
370 break; |
|
371 } |
|
372 } |
|
373 |
348 foreach ( $args as $property_name => $property_value ) { |
374 foreach ( $args as $property_name => $property_value ) { |
349 $this->$property_name = $property_value; |
375 $this->$property_name = $property_value; |
350 } |
376 } |
351 |
377 |
352 $this->labels = get_taxonomy_labels( $this ); |
378 $this->labels = get_taxonomy_labels( $this ); |
353 $this->label = $this->labels->name; |
379 $this->label = $this->labels->name; |
354 } |
380 } |
355 |
381 |
356 /** |
382 /** |
357 * Adds the necessary rewrite rules for the taxonomy. |
383 * Adds the necessary rewrite rules for the taxonomy. |
358 * |
384 * |