Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php (revision 13536)
+++ wp-includes/functions.php (working copy)
@@ -3998,13 +3998,19 @@
* @param string $file Path to the file
* @param bool $markup If the returned data should have HTML markup applied
* @param string $context If specified adds filter hook "extra_<$context>_headers"
+ * @param int $max_bytes Maximum bytes to read in file. Defaults to 8192 = 8kB
*/
-function get_file_data( $file, $default_headers, $context = '' ) {
+function get_file_data( $file, $default_headers, $context = '', $max_bytes = 8192 ) {
+ $max_bytes = apply_filters('get_max_' . $context . '_file_bytes', $max_bytes);
+
+ if ( !$max_bytes )
+ return $default_headers;
+
// We don't need to write to the file, so just open for reading.
$fp = fopen( $file, 'r' );
- // Pull only the first 8kiB of the file in.
- $file_data = fread( $fp, 8192 );
+ // Pull only the beginning start of the file.
+ $file_data = fread( $fp, $max_bytes );
// PHP will close file handle, but we are good citizens.
fclose( $fp );
Index: wp-admin/includes/plugin.php
===================================================================
--- wp-admin/includes/plugin.php (revision 13536)
+++ wp-admin/includes/plugin.php (working copy)
@@ -42,6 +42,7 @@
* from the author.
* 'Author' - The author's name
* 'AuthorURI' - The authors web site address.
+ * 'DonateURI' - Web address to donate to the plugin author.
* 'Version' - The plugin version number.
* 'PluginURI' - Plugin web site address.
* 'TextDomain' - Plugin's text domain for localization.
@@ -78,6 +79,7 @@
'Description' => 'Description',
'Author' => 'Author',
'AuthorURI' => 'Author URI',
+ 'DonateURI' => 'Donate URI',
'TextDomain' => 'Text Domain',
'DomainPath' => 'Domain Path',
'Network' => 'Network',
@@ -98,6 +100,20 @@
//For backward compatibility by default Title is the same as Name.
$plugin_data['Title'] = $plugin_data['Name'];
+ if ( empty($plugin_data['DonateURI']) ) {
+ // Read info in from readme.txt
+ $readme_headers = array(
+ 'DonateURI' => '',
+ );
+
+ $readme_file = plugin_dir_path( $plugin_file ) . 'readme.txt';
+ if ( file_exists( $readme_file ) ) {
+ $readme_data = get_file_data( $readme_file, $readme_headers, 'readme', 1024 );
+ unset($plugin_data['DonateURI']);
+ $plugin_data = array_merge( $readme_data, $plugin_data );
+ }
+ }
+
if ( $markup || $translate )
$plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate );
@@ -113,10 +129,17 @@
else
load_plugin_textdomain($plugin_data['TextDomain'], false, dirname($plugin_file));
- foreach ( array('Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version') as $field )
+ foreach ( array('Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version', 'DonateURI') as $field )
$plugin_data[ $field ] = translate($plugin_data[ $field ], $plugin_data['TextDomain']);
}
+ // Sanitize urls
+ foreach ( array('PluginURI', 'AuthorURI', 'DonateURI') as $field ) {
+ if ( !empty($plugin_data[$field]) )
+ $plugin_data[$field] = esc_url($plugin_data[$field]);
+ }
+
+
//Apply Markup
if ( $markup ) {
if ( ! empty($plugin_data['PluginURI']) && ! empty($plugin_data['Name']) )
Index: wp-admin/plugins.php
===================================================================
--- wp-admin/plugins.php (revision 13536)
+++ wp-admin/plugins.php (working copy)
@@ -620,7 +620,9 @@
}
if ( ! empty($plugin_data['PluginURI']) )
$plugin_meta[] = '' . __('Visit plugin site') . '';
-
+ if ( ! empty($plugin_data['DonateURI']) )
+ $plugin_meta[] = '' . __('Donate') . '';
+
$plugin_meta = apply_filters('plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $context);
echo implode(' | ', $plugin_meta);
echo "