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, meta boxes, hooks, 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