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:
Boone Gorges
2017-11-21 03:14:52 +00:00
parent 887214f7ce
commit 4ec5d65dcc
4 changed files with 128 additions and 39 deletions
+4
View File
@@ -297,6 +297,7 @@ function is_taxonomy_hierarchical($taxonomy) {
* @since 4.5.0 Introduced `publicly_queryable` argument.
* @since 4.7.0 Introduced `show_in_rest`, 'rest_base' and 'rest_controller_class'
* arguments to register the Taxonomy in REST API.
* @since 5.0.0 Introduced `meta_box_sanitize_cb` argument.
*
* @global array $wp_taxonomies Registered taxonomies.
*
@@ -339,6 +340,9 @@ function is_taxonomy_hierarchical($taxonomy) {
* post_categories_meta_box() is used for hierarchical taxonomies, and
* post_tags_meta_box() is used for non-hierarchical. If false, no meta
* box is shown.
* @type callable $meta_box_sanitize_cb Callback function for sanitizing taxonomy data saved from a meta
* box. If no callback is defined, an appropriate one is determined
* based on the value of `$meta_box_cb`.
* @type array $capabilities {
* Array of capabilities for this taxonomy.
*