Make WordPress Core

Changeset 12967


Ignore:
Timestamp:
02/05/2010 02:33:29 PM (15 years ago)
Author:
dd32
Message:

Allow viewing of Attached hierarchical Terms when the user doesnt have Manage capability of the taxonomy, Only set terms if user has Management capability. See #12035

Location:
trunk/wp-admin/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/meta-boxes.php

    r12833 r12967  
    240240    $tax_name = esc_attr(substr($box['id'], 8));
    241241    $taxonomy = get_taxonomy($tax_name);
    242     if ( !current_user_can($taxonomy->manage_cap) )
     242    if ( !current_user_can($taxonomy->manage_cap) ) // @todo: Display the terms, do not edit.
    243243        return;
    244244    $helps = isset($taxonomy->helps) ? esc_attr($taxonomy->helps) : __('Separate tags with commas.');
     
    280280    $tax = get_taxonomy($taxonomy);
    281281
    282     if ( !current_user_can($tax->manage_cap) )
    283         return;
    284282    ?>
    285283    <div id="taxonomy-<?php echo $taxonomy; ?>" class="categorydiv">
     
    297295        <div id="<?php echo $taxonomy; ?>-all" class="tabs-panel">
    298296            <ul id="<?php echo $taxonomy; ?>checklist" class="list:<?php echo $taxonomy?> categorychecklist form-no-clear">
    299                 <?php wp_terms_checklist($post->ID, array('taxonomy'=>$taxonomy, 'popular_cats'=> $popular_ids)) ?>
     297                <?php wp_terms_checklist($post->ID, array( 'taxonomy' => $taxonomy, 'popular_cats' => $popular_ids ) ) ?>
    300298            </ul>
    301299        </div>
  • trunk/wp-admin/includes/template.php

    r12966 r12967  
    475475
    476476        $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
    477         $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>';
     477        $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . (!empty($args['disabled']) ? 'disabled="disabled"' : '') . '/> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>';
    478478    }
    479479
     
    529529    $args = array('taxonomy' => $taxonomy);
    530530
     531    $tax = get_taxonomy($taxonomy);
     532    $args['disabled'] = !current_user_can($tax->manage_cap);
     533
    531534    if ( is_array( $selected_cats ) )
    532535        $args['selected_cats'] = $selected_cats;
     
    588591
    589592    $terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
     593
     594    $tax = get_taxonomy($taxonomy);
     595    if ( ! current_user_can($tax->manage_cap) )
     596        $disabled = 'disabled="disabled"';
     597    else
     598        $disabled = '';
    590599
    591600    $popular_ids = array();
     
    600609        <li id="<?php echo $id; ?>" class="popular-category">
    601610            <label class="selectit">
    602             <input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $term->term_id; ?>" />
     611            <input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $term->term_id; ?>" <?php echo $disabled ?>/>
    603612                <?php echo esc_html( apply_filters( 'the_category', $term->name ) ); ?>
    604613            </label>
Note: See TracChangeset for help on using the changeset viewer.