From bc17731c23dbdc21f359ec68f220b54c7b67f37b Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 13 May 2014 05:47:03 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@28391 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/meta-boxes.php | 29 +++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/wp-admin/includes/meta-boxes.php b/src/wp-admin/includes/meta-boxes.php index e9cb1460d9..ca574eb072 100644 --- a/src/wp-admin/includes/meta-boxes.php +++ b/src/wp-admin/includes/meta-boxes.php @@ -372,15 +372,17 @@ function post_format_meta_box( $post, $box ) { * * @param object $post */ -function post_tags_meta_box($post, $box) { - $defaults = array('taxonomy' => 'post_tag'); - if ( !isset($box['args']) || !is_array($box['args']) ) +function post_tags_meta_box( $post, $box ) { + $defaults = array( 'taxonomy' => 'post_tag' ); + if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) { $args = array(); - else + } else { $args = $box['args']; - extract( wp_parse_args($args, $defaults), EXTR_SKIP ); - $tax_name = esc_attr($taxonomy); - $taxonomy = get_taxonomy($taxonomy); + } + $r = wp_parse_args( $args, $defaults ); + $tax = $r['taxonomy']; + $tax_name = esc_attr( $tax ); + $taxonomy = get_taxonomy( $tax ); $user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms ); $comma = _x( ',', 'tag delimiter' ); ?> @@ -415,14 +417,15 @@ function post_tags_meta_box($post, $box) { * @param object $post */ function post_categories_meta_box( $post, $box ) { - $defaults = array('taxonomy' => 'category'); - if ( !isset($box['args']) || !is_array($box['args']) ) + $defaults = array( 'taxonomy' => 'category' ); + if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) { $args = array(); - else + } else { $args = $box['args']; - extract( wp_parse_args($args, $defaults), EXTR_SKIP ); - $tax = get_taxonomy($taxonomy); - + } + $r = wp_parse_args( $args, $defaults ); + $taxonomy = $r['taxonomy']; + $tax = get_taxonomy( $taxonomy ); ?>