Make WordPress Core

Ticket #8964: 8964.diff

File 8964.diff, 2.0 KB (added by Denis-de-Bernardy, 16 years ago)

improved patch, updated against 11255

  • wp-admin/includes/plugin.php

     
    7575        // PHP will close file handle, but we are good citizens.
    7676        fclose($fp);
    7777
    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 ) {
     78        $default_headers = array(
     79                'Name'=>'Plugin Name',
     80                'PluginURI'=>'Plugin URI',
     81                'Version'=>'Version',
     82                'Description'=>'Description',
     83                'Author'=>'Author',
     84                'AuthorURI'=>'Author URI',
     85                'TextDomain'=>'Text Domain',
     86                'DomainPath'=>'Domain Path'
     87                );
     88        $extra_headers = apply_filters( 'plugin_headers', array());
     89        $all_headers = array_merge($extra_headers, $default_headers);
     90       
     91        foreach ( $all_headers as $field => $regex ) {
     92                preg_match('/' . preg_quote($regex, '/') . ':(.*)$/mi', $plugin_data, ${$field});
     93               
    8894                if ( !empty( ${$field} ) )
    8995                        ${$field} = _cleanup_header_comment(${$field}[1]);
    9096                else
    9197                        ${$field} = '';
    9298        }
    9399
    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                                 );
     100        $plugin_data = compact(array_keys($all_headers));
     101       
    99102        if ( $markup || $translate )
    100103                $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup, $translate);
    101104