[wp-trac] [WordPress Trac] #13937: Pass list of arguments as array in add_meta_box()
WordPress Trac
wp-trac at lists.automattic.com
Sun Jun 20 21:42:37 UTC 2010
#13937: Pass list of arguments as array in add_meta_box()
--------------------------+-------------------------------------------------
Reporter: scribu | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 3.1
Component: General | Version:
Severity: minor | Keywords: has-patch
--------------------------+-------------------------------------------------
Comment(by johnbillion):
Hmm, I think this might need a little more thought. Query string style
parameters can't be used with this, only an associative array.
Maybe `wp_parse_args` could be extended with a third parameter, which is
the list of parameter names (as passed as the second argument to
`wp_numeric_to_associative` in Scribu's patch). Inside `wp_parse_args` we
could check if the first parameter is a numerically indexed array and if
so assign it named keys using `wp_numeric_to_associative`.
Sorry for the following paste but I'm sitting in bed on my tiny little
netbook with nothing except a text editor installed on it.
{{{
function add_meta_box( $args ) {
if ( func_num_args() > 1 ) {
_deprecated_argument( __FUNCTION__, '3.1', __('Passing individual
arguments is deprecated. Use an associative array of arguments instead.')
);
$args = func_get_args();
}
$defaults = array(
'id' => '',
'title' => '',
'callback' => '',
'callback_args' => null,
'page' => '',
'context' => 'advanced',
'priority' => 'default',
);
extract( wp_parse_args( $args, $defaults, array( 'id', 'title',
'callback', 'page', 'context', 'priority', 'callback_args' ) ), EXTR_SKIP
);
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/13937#comment:7>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list