WordPress.org

Make WordPress Core

Changeset 12938


Ignore:
Timestamp:
02/03/10 19:50:37 (4 years ago)
Author:
ryan
Message:

Add taxonomies arg to register_post_type() for registering built-in taxonomies for the post type. Props technosailor. see #9674

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r12937 r12938  
    710710 * supports - An alias for calling add_post_type_support() directly. See add_post_type_support() for Documentation. Defaults to none. 
    711711 * 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. 
     712 * 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(). 
    712713 * 
    713714 * @package WordPress 
     
    726727 
    727728    // Args prefixed with an underscore are reserved for internal use. 
    728     $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); 
     729    $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() ); 
    729730    $args = wp_parse_args($args, $defaults); 
    730731    $args = (object) $args; 
     
    789790 
    790791    $wp_post_types[$post_type] = $args; 
     792 
     793    foreach ( $args->taxonomies as $taxonomy ) { 
     794        register_taxonomy_for_object_type( $taxonomy, $post_type ); 
     795    } 
    791796 
    792797    return $args; 
Note: See TracChangeset for help on using the changeset viewer.