WordPress.org

Make WordPress Core

Changeset 23352


Ignore:
Timestamp:
01/28/13 03:23:01 (15 months ago)
Author:
SergeyBiryukov
Message:

Consistently use a helper function instead of directly printing the disabled attribute.

Remove an erroneous esc_attr() call.

fixes #23194.

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

Legend:

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

    r23083 r23352  
    340340    $tax_name = esc_attr($taxonomy); 
    341341    $taxonomy = get_taxonomy($taxonomy); 
    342     $disabled = !current_user_can($taxonomy->cap->assign_terms) ? 'disabled="disabled"' : ''; 
     342    $user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms ); 
    343343    $comma = _x( ',', 'tag delimiter' ); 
    344344?> 
     
    347347    <div class="nojs-tags hide-if-js"> 
    348348    <p><?php echo $taxonomy->labels->add_or_remove_items; ?></p> 
    349     <textarea name="<?php echo "tax_input[$tax_name]"; ?>" rows="3" cols="20" class="the-tags" id="tax-input-<?php echo $tax_name; ?>" <?php echo $disabled; ?>><?php echo str_replace( ',', $comma . ' ', get_terms_to_edit( $post->ID, $tax_name ) ); // textarea_escaped by esc_attr() ?></textarea></div> 
    350     <?php if ( current_user_can($taxonomy->cap->assign_terms) ) : ?> 
     349    <textarea name="<?php echo "tax_input[$tax_name]"; ?>" rows="3" cols="20" class="the-tags" id="tax-input-<?php echo $tax_name; ?>" <?php disabled( ! $user_can_assign_terms ); ?>><?php echo str_replace( ',', $comma . ' ', get_terms_to_edit( $post->ID, $tax_name ) ); // textarea_escaped by esc_attr() ?></textarea></div> 
     350    <?php if ( $user_can_assign_terms ) : ?> 
    351351    <div class="ajaxtag hide-if-no-js"> 
    352352        <label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $box['title']; ?></label> 
     
    355355        <input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" /></p> 
    356356    </div> 
    357     <p class="howto"><?php echo esc_attr( $taxonomy->labels->separate_items_with_commas ); ?></p> 
     357    <p class="howto"><?php echo $taxonomy->labels->separate_items_with_commas; ?></p> 
    358358    <?php endif; ?> 
    359359    </div> 
    360360    <div class="tagchecklist"></div> 
    361361</div> 
    362 <?php if ( current_user_can($taxonomy->cap->assign_terms) ) : ?> 
     362<?php if ( $user_can_assign_terms ) : ?> 
    363363<p class="hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->choose_from_most_used; ?></a></p> 
    364364<?php endif; ?> 
  • trunk/wp-admin/includes/template.php

    r23351 r23352  
    177177 
    178178    $tax = get_taxonomy($taxonomy); 
    179     if ( ! current_user_can($tax->cap->assign_terms) ) 
    180         $disabled = 'disabled="disabled"'; 
    181     else 
    182         $disabled = ''; 
    183179 
    184180    $popular_ids = array(); 
     
    193189        <li id="<?php echo $id; ?>" class="popular-category"> 
    194190            <label class="selectit"> 
    195             <input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $term->term_id; ?>" <?php echo $disabled ?>/> 
     191            <input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $term->term_id; ?>" <?php disabled( ! current_user_can( $tax->cap->assign_terms ) ); ?> /> 
    196192                <?php echo esc_html( apply_filters( 'the_category', $term->name ) ); ?> 
    197193            </label> 
Note: See TracChangeset for help on using the changeset viewer.