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
This commit is contained in:
Scott Taylor 2014-05-13 05:47:03 +00:00
parent b72bd1c40f
commit bc17731c23

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">