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
This commit is contained in:
Scott Taylor 2014-05-13 05:48:17 +00:00
parent 9476cd33a3
commit fd9abeb0f9
1 changed files with 16 additions and 13 deletions

View File

@ -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 );
?>
<div id="taxonomy-<?php echo $taxonomy; ?>" class="categorydiv">
<ul id="<?php echo $taxonomy; ?>-tabs" class="category-tabs">