Make WordPress Core


Ignore:
Timestamp:
01/26/2010 11:32:04 AM (16 years ago)
Author:
dd32
Message:

First scratch at Taxonomy Capabilities. See #12035

File:
1 edited

Legend:

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

    r12818 r12833  
    1616 */
    1717function create_initial_taxonomies() {
    18     register_taxonomy( 'category', 'post', array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'label' => __('Categories'), 'query_var' => false, 'rewrite' => false) ) ;
    19     register_taxonomy( 'post_tag', 'post', array('hierarchical' => false, 'update_count_callback' => '_update_post_term_count', 'label' => __('Post Tags'), 'query_var' => false, 'rewrite' => false) ) ;
    20     register_taxonomy( 'link_category', 'link', array('hierarchical' => false, 'label' => __('Categories'), 'query_var' => false, 'rewrite' => false) ) ;
     18    register_taxonomy( 'category', 'post', array(   'hierarchical' => true,
     19                                                    'update_count_callback' => '_update_post_term_count',
     20                                                    'label' => __('Categories'),
     21                                                    'query_var' => false,
     22                                                    'rewrite' => false,
     23                                                    'edit_cap' => 'no_priv'
     24                                                ) ) ;
     25
     26    register_taxonomy( 'post_tag', 'post', array(
     27                                                    'hierarchical' => false,
     28                                                    'update_count_callback' => '_update_post_term_count',
     29                                                    'label' => __('Post Tags'),
     30                                                    'query_var' => false,
     31                                                    'rewrite' => false
     32                                                ) ) ;
     33
     34    register_taxonomy( 'link_category', 'link', array(  'hierarchical' => false,
     35                                                        'label' => __('Categories'),
     36                                                        'query_var' => false,
     37                                                        'rewrite' => false
     38                                                    ) ) ;
    2139}
    2240add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority
     
    168186    global $wp_taxonomies, $wp_rewrite, $wp;
    169187
    170     if (!is_array($wp_taxonomies))
     188    if ( ! is_array($wp_taxonomies) )
    171189        $wp_taxonomies = array();
    172190
     
    190208        $wp_rewrite->add_rewrite_tag("%$taxonomy%", '([^/]+)', $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=$term");
    191209        $wp_rewrite->add_permastruct($taxonomy, "/{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite']['with_front']);
     210    }
     211
     212    foreach ( array('manage_cap', 'edit_cap', 'delete_cap') as $cap ) {
     213        if ( empty($args[$cap]) )
     214            $args[$cap] = 'manage_categories';
    192215    }
    193216
Note: See TracChangeset for help on using the changeset viewer.