Make WordPress Core

Changeset 14593


Ignore:
Timestamp:
05/13/2010 04:10:17 AM (15 years ago)
Author:
nacin
Message:

Move taxonomy object properties for capabilities into a cap object. Capabilities can be specified via capabilities? (an array keyed by the generic cap name) for register_taxonomy. fixes #13358.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r14581 r14593  
    220220    $taxonomy = get_taxonomy(substr($action, 4));
    221221    check_ajax_referer( $action );
    222     if ( !current_user_can( $taxonomy->edit_cap ) )
     222    if ( !current_user_can( $taxonomy->cap->edit_terms ) )
    223223        die('-1');
    224224    $names = explode(',', $_POST['new'.$taxonomy->name]);
     
    335335    $tax = get_taxonomy($taxonomy);
    336336
    337     if ( !current_user_can( $tax->delete_cap ) )
     337    if ( !current_user_can( $tax->cap->delete_terms ) )
    338338        die('-1');
    339339
     
    567567    $x = new WP_Ajax_Response();
    568568
    569     if ( !current_user_can( $tax->edit_cap ) )
     569    if ( !current_user_can( $tax->cap->edit_terms ) )
    570570        die('-1');
    571571
     
    12051205    $tax = get_taxonomy($taxonomy);
    12061206
    1207     if ( ! current_user_can( $tax->edit_cap ) )
     1207    if ( ! current_user_can( $tax->cap->edit_terms ) )
    12081208        die( __('Cheatin’ uh?') );
    12091209
  • trunk/wp-admin/edit-tags.php

    r14139 r14593  
    4242    check_admin_referer('add-tag');
    4343
    44     if ( !current_user_can($tax->edit_cap) )
     44    if ( !current_user_can($tax->cap->edit_terms) )
    4545        wp_die(__('Cheatin’ uh?'));
    4646
     
    8080    check_admin_referer('delete-tag_' .  $tag_ID);
    8181
    82     if ( !current_user_can($tax->delete_cap) )
     82    if ( !current_user_can($tax->cap->delete_terms) )
    8383        wp_die(__('Cheatin’ uh?'));
    8484
     
    9494    check_admin_referer('bulk-tags');
    9595
    96     if ( !current_user_can($tax->delete_cap) )
     96    if ( !current_user_can($tax->cap->delete_terms) )
    9797        wp_die(__('Cheatin’ uh?'));
    9898
     
    131131    check_admin_referer('update-tag_' . $tag_ID);
    132132
    133     if ( !current_user_can($tax->edit_cap) )
     133    if ( !current_user_can($tax->cap->edit_terms) )
    134134        wp_die(__('Cheatin’ uh?'));
    135135
     
    162162
    163163wp_enqueue_script('admin-tags');
    164 if ( current_user_can($tax->edit_cap) )
     164if ( current_user_can($tax->cap->edit_terms) )
    165165    wp_enqueue_script('inline-edit-tax');
    166166
     
    319319
    320320<?php
    321 if ( current_user_can( $tax->edit_cap ) )
     321if ( current_user_can( $tax->cap->edit_terms ) )
    322322    $tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy, 'echo' => false, 'link' => 'edit' ) );
    323323else
     
    333333endif;
    334334
    335 if ( current_user_can($tax->edit_cap) ) {
     335if ( current_user_can($tax->cap->edit_terms) ) {
    336336    if ( 'category' == $taxonomy )
    337337        do_action('add_category_form_pre', (object)array('parent' => 0) );  // Back compat hook. Deprecated in preference to $taxonomy_pre_add_form
  • trunk/wp-admin/includes/meta-boxes.php

    r14585 r14593  
    250250    $help_cloud = isset( $taxonomy->help_cloud ) ? $taxonomy->help_cloud        : __('Choose from the most used tags in %s');
    251251
    252     $disabled = !current_user_can($taxonomy->assign_cap) ? 'disabled="disabled"' : '';
     252    $disabled = !current_user_can($taxonomy->cap->assign_terms) ? 'disabled="disabled"' : '';
    253253?>
    254254<div class="tagsdiv" id="<?php echo $tax_name; ?>">
     
    257257    <p><?php echo $help_nojs; ?></p>
    258258    <textarea name="<?php echo "tax_input[$tax_name]"; ?>" class="the-tags" id="tax-input[<?php echo $tax_name; ?>]" <?php echo $disabled; ?>><?php echo esc_attr(get_terms_to_edit( $post->ID, $tax_name )); ?></textarea></div>
    259     <?php if ( current_user_can($taxonomy->assign_cap) ) : ?>
     259    <?php if ( current_user_can($taxonomy->cap->assign_terms) ) : ?>
    260260    <div class="ajaxtag hide-if-no-js">
    261261        <label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $box['title']; ?></label>
     
    269269    <div class="tagchecklist"></div>
    270270</div>
    271 <?php if ( current_user_can($taxonomy->assign_cap) ) : ?>
     271<?php if ( current_user_can($taxonomy->cap->assign_terms) ) : ?>
    272272<p class="hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo $tax_name; ?>"><?php printf( $help_cloud, $box['title'] ); ?></a></p>
    273273<?php else : ?>
     
    316316            </ul>
    317317        </div>
    318     <?php if ( !current_user_can($tax->assign_cap) ) : ?>
     318    <?php if ( !current_user_can($tax->cap->assign_terms) ) : ?>
    319319    <p><em><?php _e('You cannot modify this Taxonomy.'); ?></em></p>
    320320    <?php endif; ?>
    321     <?php if ( current_user_can($tax->edit_cap) ) : ?>
     321    <?php if ( current_user_can($tax->cap->edit_terms) ) : ?>
    322322            <div id="<?php echo $taxonomy; ?>-adder" class="wp-hidden-children">
    323323                <h4><a id="<?php echo $taxonomy; ?>-add-toggle" href="#<?php echo $taxonomy; ?>-add" class="hide-if-no-js" tabindex="3"><?php printf( __( '+ Add New %s' ), $tax->singular_label ); ?></a></h4>
  • trunk/wp-admin/includes/post.php

    r14588 r14593  
    319319        foreach ( $tax_names as $tax_name ) {
    320320            $taxonomy_obj = get_taxonomy($tax_name);
    321             if(  isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->assign_cap ) )
     321            if(  isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) )
    322322                $new_terms = $tax_input[$tax_name];
    323323            else
  • trunk/wp-admin/includes/template.php

    r14588 r14593  
    2323
    2424    $tax = get_taxonomy($taxonomy);
    25     if ( ! current_user_can( $tax->edit_cap ) )
     25    if ( ! current_user_can( $tax->cap->edit_terms ) )
    2626        return;
    2727
     
    262262
    263263    $tax = get_taxonomy($taxonomy);
    264     $args['disabled'] = !current_user_can($tax->assign_cap);
     264    $args['disabled'] = !current_user_can($tax->cap->assign_terms);
    265265
    266266    if ( is_array( $selected_cats ) )
     
    325325
    326326    $tax = get_taxonomy($taxonomy);
    327     if ( ! current_user_can($tax->assign_cap) )
     327    if ( ! current_user_can($tax->cap->assign_terms) )
    328328        $disabled = 'disabled="disabled"';
    329329    else
     
    437437            switch ($column_name) {
    438438                case 'cb':
    439                     if ( current_user_can($tax->delete_cap) && $tag->term_id != $default_term )
     439                    if ( current_user_can($tax->cap->delete_terms) && $tag->term_id != $default_term )
    440440                        $out .= '<th scope="row" class="check-column"> <input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" /></th>';
    441441                    else
     
    445445                    $out .= '<td ' . $attributes . '><strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $name)) . '">' . $name . '</a></strong><br />';
    446446                    $actions = array();
    447                     if ( current_user_can($tax->edit_cap) ) {
     447                    if ( current_user_can($tax->cap->edit_terms) ) {
    448448                        $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
    449449                        $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick&nbsp;Edit') . '</a>';
    450450                    }
    451                     if ( current_user_can($tax->delete_cap) && $tag->term_id != $default_term )
     451                    if ( current_user_can($tax->cap->delete_terms) && $tag->term_id != $default_term )
    452452                        $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url("edit-tags.php?action=delete&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "'>" . __('Delete') . "</a>";
    453453
  • trunk/wp-admin/menu.php

    r14585 r14593  
    9090            continue;
    9191
    92         $submenu['edit.php'][$i++] = array( esc_attr($tax->label), $tax->manage_cap, 'edit-tags.php?taxonomy=' . $tax->name );
     92        $submenu['edit.php'][$i++] = array( esc_attr($tax->label), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name );
    9393    }
    9494    unset($tax);
     
    139139            continue;
    140140
    141         $submenu["edit.php?post_type=$ptype"][$i++] = array( esc_attr($tax->label), $tax->manage_cap, "edit-tags.php?taxonomy=$tax->name&amp;post_type=$ptype" );
     141        $submenu["edit.php?post_type=$ptype"][$i++] = array( esc_attr($tax->label), $tax->cap->manage_terms, "edit-tags.php?taxonomy=$tax->name&amp;post_type=$ptype" );
    142142    }
    143143}
  • trunk/wp-admin/press-this.php

    r14404 r14593  
    505505                    </div>
    506506
    507                     <?php if ( !current_user_can($tax->assign_cap) ) : ?>
     507                    <?php if ( !current_user_can($tax->cap->assign_terms) ) : ?>
    508508                    <p><em><?php _e('You cannot modify this Taxonomy.'); ?></em></p>
    509509                    <?php endif; ?>
    510                     <?php if ( current_user_can($tax->edit_cap) ) : ?>
     510                    <?php if ( current_user_can($tax->cap->edit_terms) ) : ?>
    511511                        <div id="category-adder" class="wp-hidden-children">
    512512                            <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php printf( __( '+ Add New %s' ), $tax->singular_label ); ?></a></h4>
  • trunk/wp-admin/tools.php

    r14315 r14593  
    3434$tags = get_taxonomy('post_tag');
    3535
    36 if ( current_user_can($cats->manage_cap) || current_user_can($tags->manage_cap) ) : ?>
     36if ( current_user_can($cats->cap->manage_terms) || current_user_can($tags->cap->manage_terms) ) : ?>
    3737<div class="tool-box">
    3838    <h3 class="title"><?php _e('Category&#47;Tag Conversion') ?></h3>
  • trunk/wp-includes/link-template.php

    r14585 r14593  
    647647    global $post_type;
    648648    $tax = get_taxonomy($taxonomy);
    649     if ( !current_user_can($tax->edit_cap) )
     649    if ( !current_user_can($tax->cap->edit_terms) )
    650650        return;
    651651
     
    669669function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) {
    670670    $tax = get_taxonomy('post_tag');
    671     if ( !current_user_can($tax->edit_cap) )
     671    if ( !current_user_can($tax->cap->edit_terms) )
    672672        return;
    673673
  • trunk/wp-includes/post.php

    r14589 r14593  
    23302330            if ( is_array($tags) ) // array = hierarchical, string = non-hierarchical.
    23312331                $tags = array_filter($tags);
    2332             if ( current_user_can($taxonomy_obj->assign_cap) )
     2332            if ( current_user_can($taxonomy_obj->cap->assign_terms) )
    23332333                wp_set_post_terms( $post_ID, $tags, $taxonomy );
    23342334        }
  • trunk/wp-includes/taxonomy.php

    r14563 r14593  
    257257                        'label' => null,
    258258                        'show_tagcloud' => null,
    259                         '_builtin' => false
     259                        '_builtin' => false,
     260                        'capabilities' => array(),
    260261                        );
    261262    $args = wp_parse_args($args, $defaults);
     
    286287        $args['label'] = $taxonomy;
    287288
    288     foreach ( array('manage_cap', 'edit_cap', 'delete_cap') as $cap ) {
    289         if ( empty($args[$cap]) )
    290             $args[$cap] = 'manage_categories';
    291     }
    292     if ( empty($args['assign_cap']) )
    293         $args['assign_cap'] = 'edit_posts';
     289    $default_caps = array(
     290        'manage_terms' => 'manage_categories',
     291        'edit_terms'   => 'manage_categories',
     292        'delete_terms' => 'manage_categories',
     293        'assign_terms' => 'edit_posts',
     294    );
     295    $args['cap'] = (object) array_merge( $default_caps, $args['capabilities'] );
     296    unset( $args['capabilities'] );
    294297
    295298    if ( empty($args['singular_label']) )
Note: See TracChangeset for help on using the changeset viewer.