WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/15/2009 09:07:00 PM (12 years ago)
Author:
westi
Message:

Allow for plugins to enhance the number of metadata fields captured from plugin and theme headers. See #8964 props strider72.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/plugin.php

    r12042 r12044  
    6767 */
    6868function get_plugin_data( $plugin_file, $markup = true, $translate = true ) {
    69     // We don't need to write to the file, so just open for reading.
    70     $fp = fopen($plugin_file, 'r');
    71 
    72     // Pull only the first 8kiB of the file in.
    73     $plugin_data = fread( $fp, 8192 );
    74 
    75     // PHP will close file handle, but we are good citizens.
    76     fclose($fp);
    77 
    78     preg_match( '|Plugin Name:(.*)$|mi', $plugin_data, $name );
    79     preg_match( '|Plugin URI:(.*)$|mi', $plugin_data, $uri );
    80     preg_match( '|Version:(.*)|i', $plugin_data, $version );
    81     preg_match( '|Description:(.*)$|mi', $plugin_data, $description );
    82     preg_match( '|Author:(.*)$|mi', $plugin_data, $author_name );
    83     preg_match( '|Author URI:(.*)$|mi', $plugin_data, $author_uri );
    84     preg_match( '|Text Domain:(.*)$|mi', $plugin_data, $text_domain );
    85     preg_match( '|Domain Path:(.*)$|mi', $plugin_data, $domain_path );
    86 
    87     foreach ( array( 'name', 'uri', 'version', 'description', 'author_name', 'author_uri', 'text_domain', 'domain_path' ) as $field ) {
    88         if ( !empty( ${$field} ) )
    89             ${$field} = _cleanup_header_comment(${$field}[1]);
    90         else
    91             ${$field} = '';
    92     }
    93 
    94     $plugin_data = array(
    95                 'Name' => $name, 'Title' => $name, 'PluginURI' => $uri, 'Description' => $description,
    96                 'Author' => $author_name, 'AuthorURI' => $author_uri, 'Version' => $version,
    97                 'TextDomain' => $text_domain, 'DomainPath' => $domain_path
    98                 );
     69
     70    $default_headers = array(
     71        'Name' => 'Plugin Name',
     72        'PluginURI' => 'Plugin URI',
     73        'Version' => 'Version',
     74        'Description' => 'Description',
     75        'Author' => 'Author',
     76        'AuthorURI' => 'Author URI',
     77        'TextDomain' => 'Text Domain',
     78        'DomainPath' => 'Domain Path'
     79        );
     80
     81    $plugin_data = get_file_data( $plugin_file, $default_headers, 'plugin' );
     82
    9983    if ( $markup || $translate )
    100         $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup, $translate);
     84        $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate );
    10185
    10286    return $plugin_data;
Note: See TracChangeset for help on using the changeset viewer.