~canonical-sysadmins/wordpress/5.1

« back to all changes in this revision

Viewing changes to wp-includes/class-wp-taxonomy.php

  • Committer: Barry Price
  • Date: 2019-02-22 03:51:26 UTC
  • mfrom: (1.2.12 upstream)
  • Revision ID: barry.price@canonical.com-20190222035126-o28k38qs8jfyjsxt
Merge WP5.1 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
128
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
139
         * An array of object types this taxonomy is registered for.
132
140
         *
133
141
         * @since 4.7.0
139
147
         * Capabilities for this taxonomy.
140
148
         *
141
149
         * @since 4.7.0
142
 
         * @var array
 
150
         * @var object
143
151
         */
144
152
        public $cap;
145
153
 
238
246
                 *
239
247
                 * @since 4.4.0
240
248
                 *
241
 
                 * @param array  $args        Array of arguments for registering a taxonomy.
242
 
                 * @param string $taxonomy    Taxonomy key.
243
 
                 * @param array  $object_type Array of names of object types for the taxonomy.
 
249
                 * @param array    $args        Array of arguments for registering a taxonomy.
 
250
                 * @param string   $taxonomy    Taxonomy key.
 
251
                 * @param string[] $object_type Array of names of object types for the taxonomy.
244
252
                 */
245
253
                $args = apply_filters( 'register_taxonomy_args', $args, $this->name, (array) $object_type );
246
254
 
257
265
                        'show_in_quick_edit'    => null,
258
266
                        'show_admin_column'     => false,
259
267
                        'meta_box_cb'           => null,
 
268
                        'meta_box_sanitize_cb'  => null,
260
269
                        'capabilities'          => array(),
261
270
                        'rewrite'               => true,
262
271
                        'query_var'             => $this->name,
286
295
                }
287
296
 
288
297
                if ( false !== $args['rewrite'] && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) {
289
 
                        $args['rewrite'] = wp_parse_args( $args['rewrite'], array(
290
 
                                'with_front'   => true,
291
 
                                'hierarchical' => false,
292
 
                                'ep_mask'      => EP_NONE,
293
 
                        ) );
 
298
                        $args['rewrite'] = wp_parse_args(
 
299
                                $args['rewrite'],
 
300
                                array(
 
301
                                        'with_front'   => true,
 
302
                                        'hierarchical' => false,
 
303
                                        'ep_mask'      => EP_NONE,
 
304
                                )
 
305
                        );
294
306
 
295
307
                        if ( empty( $args['rewrite']['slug'] ) ) {
296
308
                                $args['rewrite']['slug'] = sanitize_title_with_dashes( $this->name );
345
357
 
346
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
374
                foreach ( $args as $property_name => $property_value ) {
349
375
                        $this->$property_name = $property_value;
350
376
                }
351
377
 
352
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
        /**