WordPress.org

Make WordPress Core

Changeset 28391


Ignore:
Timestamp:
05/13/2014 05:47:03 AM (7 years ago)
Author:
wonderboymusic
Message:

Eliminate use of extract() in post_tags_meta_box() and post_categories_meta_box().

Both functions only need to read taxonomy, yet they extract every available variable from $box['args']. Even if those variables were useful, there is no attempt to pass them to anything, and scope in PHP does not allow them to be scooped up by inner functions without being passed directly.

See #22400.

File:
1 edited

Legend:

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

    r28298 r28391  
    373373 * @param object $post
    374374 */
    375 function post_tags_meta_box($post, $box) {
    376     $defaults = array('taxonomy' => 'post_tag');
    377     if ( !isset($box['args']) || !is_array($box['args']) )
     375function post_tags_meta_box( $post, $box ) {
     376    $defaults = array( 'taxonomy' => 'post_tag' );
     377    if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) {
    378378        $args = array();
    379     else
     379    } else {
    380380        $args = $box['args'];
    381     extract( wp_parse_args($args, $defaults), EXTR_SKIP );
    382     $tax_name = esc_attr($taxonomy);
    383     $taxonomy = get_taxonomy($taxonomy);
     381    }
     382    $r = wp_parse_args( $args, $defaults );
     383    $tax = $r['taxonomy'];
     384    $tax_name = esc_attr( $tax );
     385    $taxonomy = get_taxonomy( $tax );
    384386    $user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms );
    385387    $comma = _x( ',', 'tag delimiter' );
     
    416418 */
    417419function post_categories_meta_box( $post, $box ) {
    418     $defaults = array('taxonomy' => 'category');
    419     if ( !isset($box['args']) || !is_array($box['args']) )
     420    $defaults = array( 'taxonomy' => 'category' );
     421    if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) {
    420422        $args = array();
    421     else
     423    } else {
    422424        $args = $box['args'];
    423     extract( wp_parse_args($args, $defaults), EXTR_SKIP );
    424     $tax = get_taxonomy($taxonomy);
    425 
     425    }
     426    $r = wp_parse_args( $args, $defaults );
     427    $taxonomy = $r['taxonomy'];
     428    $tax = get_taxonomy( $taxonomy );
    426429    ?>
    427430    <div id="taxonomy-<?php echo $taxonomy; ?>" class="categorydiv">
Note: See TracChangeset for help on using the changeset viewer.