From d491a56710a15a7b086e768da43857791ddb1c93 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 3 Feb 2010 19:50:37 +0000 Subject: [PATCH] Add taxonomies arg to register_post_type() for registering built-in taxonomies for the post type. Props technosailor. see #9674 git-svn-id: https://develop.svn.wordpress.org/trunk@12938 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/post.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 23e6ebd3de..675aa35b14 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -709,6 +709,7 @@ function get_post_types( $args = array(), $output = 'names' ) { * hierarchical - Whether the post type is hierarchical. Defaults to false. * supports - An alias for calling add_post_type_support() directly. See add_post_type_support() for Documentation. Defaults to none. * register_meta_box_cb - Provide a callback function that will be called when setting up the meta boxes for the edit form. Do remove_meta_box() and add_meta_box() calls in the callback. + * taxonomies - An array of taxonomy identifiers that will be registered for the post type. Default is no taxonomies. Taxonomies can be registered later with register_taxonomy() or register_taxonomy_for_object_type(). * * @package WordPress * @subpackage Post @@ -725,7 +726,7 @@ function register_post_type($post_type, $args = array()) { $wp_post_types = array(); // Args prefixed with an underscore are reserved for internal use. - $defaults = array('label' => false, 'publicly_queryable' => null, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, '_show' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null); + $defaults = array('label' => false, 'publicly_queryable' => null, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, '_show' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null, 'taxonomies' => array() ); $args = wp_parse_args($args, $defaults); $args = (object) $args; @@ -789,6 +790,10 @@ function register_post_type($post_type, $args = array()) { $wp_post_types[$post_type] = $args; + foreach ( $args->taxonomies as $taxonomy ) { + register_taxonomy_for_object_type( $taxonomy, $post_type ); + } + return $args; }