WordPress.org

Make WordPress Core

Ticket #12130: 12130-read-from-readme.txt

File 12130-read-from-readme.txt, 2.3 KB (added by westi, 4 years ago)

Read in the donate uri from readme.txt and return is as part of plugin data

Line 
1### Eclipse Workspace Patch 1.0
2#P wordpress-trunk
3Index: wp-admin/includes/plugin.php
4===================================================================
5--- wp-admin/includes/plugin.php        (revision 12995)
6+++ wp-admin/includes/plugin.php        (working copy)
7@@ -42,6 +42,7 @@
8  *             from the author.
9  *             'Author' - The author's name
10  *             'AuthorURI' - The authors web site address.
11+ *             'DonateURI' - Web address to donate to the plugin author.
12  *             'Version' - The plugin version number.
13  *             'PluginURI' - Plugin web site address.
14  *             'TextDomain' - Plugin's text domain for localization.
15@@ -98,6 +99,17 @@
16        //For backward compatibility by default Title is the same as Name.
17        $plugin_data['Title'] = $plugin_data['Name'];
18 
19+       // Read info in from readme.txt
20+       $readme_headers = array(
21+               'DonateURI' => 'Donate link',
22+       );
23+
24+       $readme_file = plugin_dir_path( $plugin_file ) . 'readme.txt';
25+       if ( file_exists( $readme_file ) ) {
26+               $readme_data = get_file_data( $readme_file, $readme_headers, 'readme' );
27+               $plugin_data = array_merge( $readme_data, $plugin_data);
28+       }
29+
30        if ( $markup || $translate )
31                $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate );
32 
33@@ -113,7 +125,7 @@
34                else
35                        load_plugin_textdomain($plugin_data['TextDomain'], false, dirname($plugin_file));
36 
37-               foreach ( array('Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version') as $field )
38+               foreach ( array('Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version', 'DonateURI') as $field )
39                        $plugin_data[ $field ] = translate($plugin_data[ $field ], $plugin_data['TextDomain']);
40        }
41 
42Index: wp-admin/plugins.php
43===================================================================
44--- wp-admin/plugins.php        (revision 12995)
45+++ wp-admin/plugins.php        (working copy)
46@@ -536,7 +536,9 @@
47                }
48                if ( ! empty($plugin_data['PluginURI']) )
49                        $plugin_meta[] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . __( 'Visit plugin site' ) . '">' . __('Visit plugin site') . '</a>';
50-
51+               if ( ! empty($plugin_data['DonateURI']) )
52+                       $plugin_meta[] = '<a href="' . $plugin_data['DonateURI'] . '" title="' . __( 'Donate' ) . '">' . __('Donate') . '</a>';
53+                       
54                $plugin_meta = apply_filters('plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $context);
55                echo implode(' | ', $plugin_meta);
56                echo "</td>