[wp-trac] [WordPress Trac] #8964: Allow adding headers to get_plugin_data
WordPress Trac
wp-trac at lists.automattic.com
Wed Jul 22 04:22:47 UTC 2009
#8964: Allow adding headers to get_plugin_data
-------------------------+--------------------------------------------------
Reporter: strider72 | Owner: westi
Type: enhancement | Status: accepted
Priority: normal | Milestone: 2.9
Component: Plugins | Version:
Severity: normal | Keywords: has-patch tested commit early
-------------------------+--------------------------------------------------
Comment(by strider72):
Aha! Denis, your updated patch leaves out a *very* important line:
{{{
// Use keys to reduce conflicts and make conflicts easier to find.
foreach ( $extra_headers as $key=>$value ) { $extra_headers[$key] = $key;
}
}}}
This goes just *before* the array_merge. What this does is (by design)
completely ignores the value, and uses only the array keys. Thus you
can't have the conflicts that you are concerned about. The key of the new
parameter in plugin_data is *always* the exact same as the name of the
header.
As I looks at that code, however, I see a way to make it better. Try this
instead -- again just before the array_merge:
{{{
$extra_headers = array_unique( $extra_headers );
$extra_headers = array_combine ( $extra_headers, $extra_headers );
}}}
This is an improvement from the plugin author's standpoint. Rather than
adding a key, e.g. {{{ $extra_headers['New Header'] = true; }}} they just
have to add a value: {{{ $extra_headers[] = 'New Header'; }}}
Array_unique removes duplicate values, and then the array_combine takes
all the values and sets those as both Key and Value for each element.
Perfect! :)
--
Ticket URL: <http://core.trac.wordpress.org/ticket/8964#comment:25>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list