WP_Post_Type in 4.6

WordPress 4.6 will introduce a new WP_Post_Type class. This changes the global $wp_post_types to an array of WP_Post_Type objects. WP_Post_Type provides methods to handle post type supports, rewrite rules, metaMeta Meta is a term that refers to the inside workings of a group. For us, this is the team that works on internal WordPress sites like WordCamp Central and Make WordPress. boxes, 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., and taxonomies. These methods are used internally by register_post_type() and unregister_post_type(). Each post type argument is now a property of WP_Post_Type.

The following functions have been changed to return a WP_Post_Type object:

  • register_post_type()
  • get_post_type_object()

The following hook parameters are now a WP_Post_Type object:

  • The second parameter $post_type of xmlrpc_prepare_post_type.
  • The second parameter $post_type_object of registered_post_type.
  • The third parameter $post_type of nav_menu_items_{$post_type_name}.

The following function accepts a WP_Post_Type object now too:

  • is_post_type_viewable()

For more background on the change, see #36217.

Note that there are plans to introduce a WP_Taxonomy class as well, see #36224.

#4-6, #dev-notes, #posts