[wp-trac] [WordPress Trac] #8964: Allow adding headers to get_plugin_data

WordPress Trac wp-trac at lists.automattic.com
Mon Jan 26 05:16:59 GMT 2009


#8964: Allow adding headers to get_plugin_data
-------------------------+--------------------------------------------------
 Reporter:  strider72    |       Owner:                           
     Type:  enhancement  |      Status:  new                      
 Priority:  normal       |   Milestone:  2.8                      
Component:  Plugins      |     Version:                           
 Severity:  normal       |    Keywords:  has-patch plugins filters
-------------------------+--------------------------------------------------
 It would be nice for plugin authors if we could add headers to what is
 searched for in get_plugin_data.  The attached patch integrates this as a
 straightforward filter.

 For example, an author might add a header that states the minimum WP
 version, or perhaps a URL for version checking.  With this filter he could
 just drop that info into an easily accessed plugin header instead of hard-
 coding it somewhere further down.  (Beyond simple location, this much
 simplifies certain processes, such as a plugin with which other plugins
 can make themselves compatible.)

 The attached patch modifies get_plugin_data().  Default output is
 identical to existing, but you can now do the following filter:

 {{{
 function filter_plugin_data_headers( $extra_params, $plugin_file ) {
         if ( __FILE__ == $plugin_file ) {
                 $extra_params['NewHeader'] = 'New Plugin Header';
         }
         return $extra_params;
 }
 add_filter( 'plugin_data_headers', 'filter_plugin_data_headers', 10, 2 );
 }}}

 In the above, the plugin could have:

 {{{
 New Plugin Header: just testing
 }}}

 and get_plugin_data() would return "just testing" as
 {{{$plugin_data['NewHeader']}}}

 NOTE: This is explicitly written so that a plugin can *not* overwrite
 existing standard headers.  That is, it is not possible to overwrite the
 Name, Description, etc. of another plugin, as that might pose the risk for
 mischief.  You can only use this to add a new header, which will be
 returned as part of the get_plugin_data array.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/8964>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list