Title: WP_Taxonomy in 4.7
Author: Pascal Birchler
Published: October 29, 2016

---

 [  ](https://profiles.wordpress.org/swissspidy/) [Pascal Birchler](https://profiles.wordpress.org/swissspidy/)
1:35 pm _on_ October 29, 2016     
Tags: [4.7 ( 124 )](https://make.wordpress.org/core/tag/4-7/),
[dev-notes ( 647 )](https://make.wordpress.org/core/tag/dev-notes/)   

# WP_Taxonomy in 4.7

Similar to how WordPress 4.6 introduced [`WP_Post_Type`](https://make.wordpress.org/core/2016/07/13/wp_post_type-in-4-6/),
version 4.7 will introduce a new `WP_Taxonomy` class. This changes the global `$
wp_taxonomies` to an array of `WP_Taxonomy` objects.

`WP_Taxonomy` provides methods to handle rewrite rules and hooksHooks In WordPress
theme and development, hooks are functions that can be applied to an action or a
Filter in WordPress. Actions are functions performed when a certain event occurs
in WordPress. Filters allow you to modify certain functions. Arguments used to hook
both filters and actions look the same.. These methods are used internally by [`register_taxonomy()`](https://developer.wordpress.org/reference/functions/register_taxonomy/)
and [`unregister_taxonomy()`](https://developer.wordpress.org/reference/functions/unregister_taxonomy/).
Each 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).
argument is now a property of `WP_Taxonomy`.

The following function has been changed to return a `WP_Taxonomy` object:

 * `get_taxonomy()`

The following hook parameters are now a `WP_Taxonomy` object:

 * The second parameter `$taxonomy` of `xmlrpc_prepare_taxonomy`.
 * The second parameter `$tax` of `term_search_min_chars`.

The following function accepts a `WP_Taxonomy` object now:

 * `get_taxonomy_labels()`

Just like with `WP_Post_Type`, introducing such a class makes further improvements
much more feasible.

For more background on the change, see [#36224](https://core.trac.wordpress.org/ticket/36224).

[#4-7](https://make.wordpress.org/core/tag/4-7/), [#dev-notes](https://make.wordpress.org/core/tag/dev-notes/)

### Share this:

 * [  Threads ](https://make.wordpress.org/core/2016/10/29/wp_taxonomy-in-4-7/?share=threads)
 * [  Mastodon ](https://make.wordpress.org/core/2016/10/29/wp_taxonomy-in-4-7/?share=mastodon)
 * [  Bluesky ](https://make.wordpress.org/core/2016/10/29/wp_taxonomy-in-4-7/?share=bluesky)
 * [  X ](https://make.wordpress.org/core/2016/10/29/wp_taxonomy-in-4-7/?share=x)
 * [  Facebook ](https://make.wordpress.org/core/2016/10/29/wp_taxonomy-in-4-7/?share=facebook)
 * [  LinkedIn ](https://make.wordpress.org/core/2016/10/29/wp_taxonomy-in-4-7/?share=linkedin)

 1.  ![](https://secure.gravatar.com/avatar/2aef477570c5121f58c3369e7b99feb3e633d7a652791a3007c224d629ad65e8?
     s=32&d=mm&r=g)
 2.   [Martin Sotirov](https://profiles.wordpress.org/martinsotirov/)  10:33 am _on_
     October 30, 2016
 3.  What’s the point of having a procedural APIAPI An API or Application Programming
     Interface is a software intermediary that allows programs to interact with each
     other and share data in limited, clearly defined ways. (register_taxonomy(…)) 
     which wraps around a class, whose methods itself wrap around more procedural code
     and global state?
 4.  I honestly don’t see the point of making procedural code pretend like it’s OOP
     just for documentation purposes.
 5.  Is there some overarching plan behind these changes (WP_Taxonomy, WP_Post_Type
     etc.)? It’s an honest question, I’m not trolling.
 6.   * ![](https://secure.gravatar.com/avatar/b01ec0896d3867ba97ca655f843bce74d396f9018a844d665e5e513297930de1?
        s=32&d=mm&r=g)
      *  [Rami Yushuvaev](https://profiles.wordpress.org/ramiy/)  11:33 am _on_ October
        30, 2016
      * Martin, you need to consider backwards-compatibility issues.
      * Many plugins use those functions. This way, the pluginPlugin A plugin is a 
        piece of software containing a group of functions that can be added to a WordPress
        website. They can extend functionality or add new features to your WordPress
        websites. WordPress plugins are written in the PHP programming language and
        integrate seamlessly with WordPress. These can be free in the WordPress.org
        Plugin Directory [https://wordpress.org/plugins/](https://wordpress.org/plugins/)
        or can be cost-based plugin from a third-party. the uses those functions won’t
        break the site when upgrading to 4.7. It will work on sites using old WordPress
        versions and new versions. The only difference is that in new WordPress those
        functions will wrapper the new class.
      * ![](https://secure.gravatar.com/avatar/1718b7c2f2afc31b4e94805b6f1f6ae2b802cc4c696f99b11fde2186006c82c9?
        s=32&d=mm&r=g)
      *  [Pascal Birchler](https://profiles.wordpress.org/swissspidy/)  2:07 pm _on_
        October 30, 2016
      * > Is there some overarching plan behind these changes (WP_Taxonomy, WP_Post_Type
        etc.)? It’s an honest question, I’m not trolling.
      * Yes. As stated in the post, “introducing such a class makes further improvements
        much more feasible.”
      * Nobody really likes a class that wraps around a bunch of procedural code and
        modifies the global state. We just need to take one step at the time to improve
        these things. BC is obviously a big concern here.
      * [#37667](https://core.trac.wordpress.org/ticket/37667) is a good example of
        what’s possible when there’s a foundation to build upon.
 7.  ![](https://secure.gravatar.com/avatar/191a5715ee9d255a813f8a14b67af7bb97b16b0583ec04fd1f1236a80d6f17c1?
     s=32&d=mm&r=g)
 8.   [thefuxia](https://profiles.wordpress.org/thefuxia/)  11:45 pm _on_ October 30,
     2016
 9.  And again the same bugs: `final` without an interface, public properties, completely
     unreliable due its mutability … are you aware how much technical debt you have
     added over the last few releases with these anti-OOP classes? This is really sad
     to watch.
 10.  * ![](https://secure.gravatar.com/avatar/725ed6a2f4e920e3d8bd01548a172ebe4fc91dccd3c6c6e83d6f389175dd99d8?
        s=32&d=mm&r=g)
      *  [Jip Moors](https://profiles.wordpress.org/jipmoors/)  8:09 am _on_ October
        31, 2016
      * I understand where you are coming from, but this is not meant as the perfect
        solution for the future.
         There has been discussion about this and the reasons
        and decision can be found here: [https://core.trac.wordpress.org/ticket/36224#comment:22](https://core.trac.wordpress.org/ticket/36224#comment:22)
      * “We are not attempting to impose any actual OOP architecture.” – @boonebgorges
      * If you have ideas or constructive feedback on how to approach improving things,
        please feel free to join in the discussion (on tracTrac An open source project
        by Edgewall Software that serves as a bug tracker and project management tool
        for WordPress. or slackSlack Slack is a Collaborative Group Chat Platform [https://slack.com/](https://slack.com/).
        The WordPress community has its own Slack Channel at [https://make.wordpress.org/chat/](https://make.wordpress.org/chat/)).
        Preferably during development or conceptual stages.
         - ![](https://secure.gravatar.com/avatar/191a5715ee9d255a813f8a14b67af7bb97b16b0583ec04fd1f1236a80d6f17c1?
           s=32&d=mm&r=g)
         -  [thefuxia](https://profiles.wordpress.org/thefuxia/)  3:23 am _on_ November
           2, 2016
         - I have spoken about these issues again and again. I’m tired of these fruitless
           discussions. `set_props()` and public properties ( instead of the backwards-
           compatible `__set()` and `__get()`) are plain bugs. It doesn’t matter whether
           the WP coreCore Core is the set of software required to run WordPress. The
           Core Development Team builds WordPress. devs like OOP or not. Plugins and
           themes are written in OOP nowadays, and code like this prevents good code–
           intentionally.
         - The next time when someone asks why developers today don’t want to work 
           with WP just look at this code. I don’t understand the rationale behind 
           this. Is there any?
 11. ![](https://secure.gravatar.com/avatar/43d0aa8581d3dee2b5d34706634764378cd905cdf42270665df5ca3fc11380f8?
     s=32&d=mm&r=g)
 12.  [John Parris](https://profiles.wordpress.org/mindctrl/)  12:20 pm _on_ November
     1, 2016
 13. I’m with @thefuxia on the public properties and mutability of the class. Once 
     this is in the wild and people start accessing those properties directly and/or
     changing them, we’re stuck with having to maintain this for a long time. Is there
     a reason they have to be public?

Comments are closed.

# Post navigation

[← Fine grained capabilities for taxonomy terms in 4.7](https://make.wordpress.org/core/2016/10/28/fine-grained-capabilities-for-taxonomy-terms-in-4-7/)

[Preferred Languages Chat Summary: October 26 →](https://make.wordpress.org/core/2016/10/29/preferred-languages-chat-summary-october-26/)