Ticket #8964: 8964-3.diff
File 8964-3.diff, 2.7 KB (added by , 16 years ago) |
---|
-
wp-admin/includes/plugin.php
67 67 */ 68 68 function get_plugin_data( $plugin_file, $markup = true, $translate = true ) { 69 69 // We don't need to write to the file, so just open for reading. 70 $fp = fopen( $plugin_file, 'r');70 $fp = fopen( $plugin_file, 'r' ); 71 71 72 72 // Pull only the first 8kiB of the file in. 73 73 $plugin_data = fread( $fp, 8192 ); 74 74 75 75 // PHP will close file handle, but we are good citizens. 76 fclose( $fp);76 fclose( $fp ); 77 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 ); 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( 'extra_plugin_headers', array() ); 86 89 87 foreach ( array( 'name', 'uri', 'version', 'description', 'author_name', 'author_uri', 'text_domain', 'domain_path' ) as $field ) { 90 $extra_headers = array_flip( $extra_headers ); 91 foreach( $extra_headers as $key=>$value ) { 92 $extra_headers[$key] = $key; 93 } 94 95 $all_headers = array_merge($extra_headers, $default_headers); 96 97 foreach ( $all_headers as $field => $regex ) { 98 preg_match( '/' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $plugin_data, ${$field}); 88 99 if ( !empty( ${$field} ) ) 89 ${$field} = _cleanup_header_comment( ${$field}[1]);100 ${$field} = _cleanup_header_comment( ${$field}[1] ); 90 101 else 91 102 ${$field} = ''; 92 103 } 93 104 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 ); 105 $plugin_data = compact( array_keys( $all_headers ) ); 106 99 107 if ( $markup || $translate ) 100 $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate);108 $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate ); 101 109 102 110 return $plugin_data; 103 111 }