mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Introduce meta_box_sanitize_cb taxonomy argument.
The `meta_box_cb` argument was introduced in [25572] to allow plugin authors to provide a custom callback for rendering their taxonomy's meta box on the post edit screen. However, the routine used to handle the saving of these custom taxonomy meta boxes was not customizable, but was instead based simply on whether the taxonomy was hierarchicaly. See [13535]. The new `meta_box_sanitize_cb` argument defaults to the "tag" routine for non-hierarchical taxonomies and the "category" routine for hierarchical ones, thereby maintaining the current default behavior. Developers can override this when the data passed from their `meta_box_cb` differs. Props boonebgorges, ZaneMatthew, stephenharris. Fixes #36514. git-svn-id: https://develop.svn.wordpress.org/trunk@42211 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -127,6 +127,15 @@ final class WP_Taxonomy {
|
||||
*/
|
||||
public $meta_box_cb = null;
|
||||
|
||||
/**
|
||||
* The callback function for sanitizing taxonomy data saved from a meta box.
|
||||
*
|
||||
* @since 5.0.0
|
||||
* @access public
|
||||
* @var callable
|
||||
*/
|
||||
public $meta_box_sanitize_cb = null;
|
||||
|
||||
/**
|
||||
* An array of object types this taxonomy is registered for.
|
||||
*
|
||||
@@ -257,6 +266,7 @@ final class WP_Taxonomy {
|
||||
'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,
|
||||
@@ -345,6 +355,20 @@ final class WP_Taxonomy {
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user