From fd9abeb0f9b310436daab5a34d7bd2c17b43f296 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 13 May 2014 05:48:17 +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. Built from https://develop.svn.wordpress.org/trunk@28391 git-svn-id: http://core.svn.wordpress.org/trunk@28219 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/meta-boxes.php | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/wp-admin/includes/meta-boxes.php b/wp-admin/includes/meta-boxes.php index e9cb1460d9..ca574eb072 100644 --- a/wp-admin/includes/meta-boxes.php +++ b/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 ); ?>