Title: Improved taxonomy metabox sanitization in 5.1
Author: Boone Gorges
Published: January 23, 2019

---

 [  ](https://profiles.wordpress.org/boonebgorges/) [Boone Gorges](https://profiles.wordpress.org/boonebgorges/)
1:54 pm _on_ January 23, 2019     
Tags: [5.1 ( 24 )](https://make.wordpress.org/core/tag/5-1/),
[dev-notes ( 647 )](https://make.wordpress.org/core/tag/dev-notes/), [taxonomy ( 16 )](https://make.wordpress.org/core/tag/taxonomy/)

# Improved taxonomy metabox sanitization in 5.1

WordPress 5.1 will feature a new parameter for `register_taxonomy()`, `'meta_box_sanitize_cb'`,
which increases flexibility when using coreCore Core is the set of software required
to run WordPress. The Core Development Team builds WordPress. UIUI User interface
for custom taxonomies.

Custom taxonomies can specify which metaboxMetabox A post metabox is a draggable
box shown on the post editing screen. Its purpose is to allow the user to select
or enter information in addition to the main post content. This information should
be related to the post in some way. UI they’d like to use in the Classic Editor 
by providing a `meta_box_cb` parameter when registering their taxonomies. This meant,
for example, that a hierarchical taxonomyTaxonomy A taxonomy is a way to group things
together. In WordPress, some common taxonomies are category, link, tag, or post 
format. [https://codex.wordpress.org/Taxonomies#Default_Taxonomies](https://codex.wordpress.org/Taxonomies#Default_Taxonomies).
can choose to use the `post_tags_meta_box()` UI instead of `post_categories_meta_box()`,
which is the default. Prior to 5.1, this customization wasn’t fully functional; 
while the UI could be swapped out in this way, the data submitted when saving posts
was always processed according to whether the taxonomy was registered as hierarchical.
This led to scenarios where custom taxonomy values weren’t properly parsed when 
saving a post.

In 5.1, this behavior is changed in the following ways:

 * The POST controller logic that was previously hardcoded in `edit_post()` has 
   been abstracted into the new `taxonomy_meta_box_sanitize_cb_checkboxes()`and `
   taxonomy_meta_box_sanitize_cb_input()`functions.
 * WP will try to select an appropriate `_sanitize_` callback based on the `meta_box_cb`
   associated with the taxonomy. This will fix the underlying bugbug A bug is an
   error or unexpected result. Performance improvements, code optimization, and 
   are considered enhancements, not defects. After feature freeze, only bugs are
   dealt with, with regressions (adverse changes from the previous version) being
   the highest priority. for existing taxonomies.
 * Developers who need more control over the processing of their metabox data can
   provide a custom `meta_box_sanitize_cb` when registering their taxonomies.

For more information, see [#36514](https://core.trac.wordpress.org/ticket/36514)
and [[42211]](https://core.trac.wordpress.org/changeset/42211).

[#5-1](https://make.wordpress.org/core/tag/5-1/), [#dev-notes](https://make.wordpress.org/core/tag/dev-notes/),
[#taxonomy](https://make.wordpress.org/core/tag/taxonomy/)

### Share this:

 * [  Threads ](https://make.wordpress.org/core/2019/01/23/improved-taxonomy-metabox-sanitization-in-5-1/?share=threads)
 * [  Mastodon ](https://make.wordpress.org/core/2019/01/23/improved-taxonomy-metabox-sanitization-in-5-1/?share=mastodon)
 * [  Bluesky ](https://make.wordpress.org/core/2019/01/23/improved-taxonomy-metabox-sanitization-in-5-1/?share=bluesky)
 * [  X ](https://make.wordpress.org/core/2019/01/23/improved-taxonomy-metabox-sanitization-in-5-1/?share=x)
 * [  Facebook ](https://make.wordpress.org/core/2019/01/23/improved-taxonomy-metabox-sanitization-in-5-1/?share=facebook)
 * [  LinkedIn ](https://make.wordpress.org/core/2019/01/23/improved-taxonomy-metabox-sanitization-in-5-1/?share=linkedin)

 1. ![](https://secure.gravatar.com/avatar/7c9f1110d4461bea9644f874501cb1bc6e47a136a0d617bd8885708a67af79ee?
    s=32&d=mm&r=g)
 2.  [David Decker](https://profiles.wordpress.org/daveshine/)  3:59 pm _on_ January
    23, 2019
 3. This is awesome! I really like it when such kind of changes and improvements happen
    in new WP versions! 🙂
     Thanks for your hard work!
 4. ![](https://secure.gravatar.com/avatar/4af11be69440adfd3efc174660a0b52abb9c17748e77e8e8112a24d032e38570?
    s=32&d=mm&r=g)
 5.  [jnorell](https://profiles.wordpress.org/jnorell/)  11:06 pm _on_ March 8, 2019
 6. Probably worth a mention that this only works in classic editor right now, due 
    this bugbug A bug is an error or unexpected result. Performance improvements, code
    optimization, and are considered enhancements, not defects. After feature freeze,
    only bugs are dealt with, with regressions (adverse changes from the previous version)
    being the highest priority. in GutenbergGutenberg The Gutenberg project is the 
    new Editor Interface for WordPress. The editor improves the process and experience
    of creating new content, making writing rich content much simpler. It uses ‘blocks’
    to add richness rather than shortcodes, custom HTML etc.
     [https://wordpress.org/gutenberg/](https://wordpress.org/gutenberg/):
    [https://github.com/WordPress/gutenberg/issues/13816](https://github.com/WordPress/gutenberg/issues/13816)

Comments are closed.

# Post navigation

[← JavaScript chat summary, January 22nd, 2019](https://make.wordpress.org/core/2019/01/23/javascript-chat-summary-january-22nd-2019/)

[LIKE support for meta keys in 5.1 →](https://make.wordpress.org/core/2019/01/23/like-support-for-meta-keys-in-5-1/)