diff -r c7c34916027a -r 177826044cd9 wp/wp-includes/class-wp-taxonomy.php --- a/wp/wp-includes/class-wp-taxonomy.php Mon Oct 14 18:06:33 2019 +0200 +++ b/wp/wp-includes/class-wp-taxonomy.php Mon Oct 14 18:28:13 2019 +0200 @@ -128,6 +128,14 @@ public $meta_box_cb = null; /** + * The callback function for sanitizing taxonomy data saved from a meta box. + * + * @since 5.1.0 + * @var callable + */ + public $meta_box_sanitize_cb = null; + + /** * An array of object types this taxonomy is registered for. * * @since 4.7.0 @@ -139,7 +147,7 @@ * Capabilities for this taxonomy. * * @since 4.7.0 - * @var array + * @var object */ public $cap; @@ -238,9 +246,9 @@ * * @since 4.4.0 * - * @param array $args Array of arguments for registering a taxonomy. - * @param string $taxonomy Taxonomy key. - * @param array $object_type Array of names of object types for the taxonomy. + * @param array $args Array of arguments for registering a taxonomy. + * @param string $taxonomy Taxonomy key. + * @param string[] $object_type Array of names of object types for the taxonomy. */ $args = apply_filters( 'register_taxonomy_args', $args, $this->name, (array) $object_type ); @@ -257,6 +265,7 @@ 'show_in_quick_edit' => null, 'show_admin_column' => false, 'meta_box_cb' => null, + 'meta_box_sanitize_cb' => null, 'capabilities' => array(), 'rewrite' => true, 'query_var' => $this->name, @@ -286,11 +295,14 @@ } if ( false !== $args['rewrite'] && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) { - $args['rewrite'] = wp_parse_args( $args['rewrite'], array( - 'with_front' => true, - 'hierarchical' => false, - 'ep_mask' => EP_NONE, - ) ); + $args['rewrite'] = wp_parse_args( + $args['rewrite'], + array( + 'with_front' => true, + 'hierarchical' => false, + 'ep_mask' => EP_NONE, + ) + ); if ( empty( $args['rewrite']['slug'] ) ) { $args['rewrite']['slug'] = sanitize_title_with_dashes( $this->name ); @@ -345,12 +357,26 @@ $args['name'] = $this->name; + // Default meta box sanitization callback depends on the value of 'meta_box_cb'. + if ( null === $args['meta_box_sanitize_cb'] ) { + switch ( $args['meta_box_cb'] ) { + case 'post_categories_meta_box': + $args['meta_box_sanitize_cb'] = 'taxonomy_meta_box_sanitize_cb_checkboxes'; + break; + + case 'post_tags_meta_box': + default: + $args['meta_box_sanitize_cb'] = 'taxonomy_meta_box_sanitize_cb_input'; + break; + } + } + foreach ( $args as $property_name => $property_value ) { $this->$property_name = $property_value; } $this->labels = get_taxonomy_labels( $this ); - $this->label = $this->labels->name; + $this->label = $this->labels->name; } /**