Make WordPress Core

Ticket #12130: 12130.3.diff

File 12130.3.diff, 3.9 KB (added by Denis-de-Bernardy, 15 years ago)
  • wp-includes/functions.php

     
    39983998 * @param string $file Path to the file
    39993999 * @param bool $markup If the returned data should have HTML markup applied
    40004000 * @param string $context If specified adds filter hook "extra_<$context>_headers"
     4001 * @param int $max_bytes Maximum bytes to read in file. Defaults to 8192 = 8kB
    40014002 */
    4002 function get_file_data( $file, $default_headers, $context = '' ) {
     4003function get_file_data( $file, $default_headers, $context = '', $max_bytes = 8192 ) {
     4004        $max_bytes = apply_filters('get_max_' . $context . '_file_bytes', $max_bytes);
     4005
    40034006        // We don't need to write to the file, so just open for reading.
    40044007        $fp = fopen( $file, 'r' );
    40054008
    4006         // Pull only the first 8kiB of the file in.
    4007         $file_data = fread( $fp, 8192 );
     4009        // Pull only the beginning start of the file.
     4010        $file_data = fread( $fp, $max_bytes );
    40084011
    40094012        // PHP will close file handle, but we are good citizens.
    40104013        fclose( $fp );
  • wp-admin/includes/plugin.php

     
    4242 *              from the author.
    4343 *              'Author' - The author's name
    4444 *              'AuthorURI' - The authors web site address.
     45 *              'DonateURI' - Web address to donate to the plugin author.
    4546 *              'Version' - The plugin version number.
    4647 *              'PluginURI' - Plugin web site address.
    4748 *              'TextDomain' - Plugin's text domain for localization.
     
    7879                'Description' => 'Description',
    7980                'Author' => 'Author',
    8081                'AuthorURI' => 'Author URI',
     82                'DonateURI' => 'Donate URI',
    8183                'TextDomain' => 'Text Domain',
    8284                'DomainPath' => 'Domain Path',
    8385                'Network' => 'Network',
     
    98100        //For backward compatibility by default Title is the same as Name.
    99101        $plugin_data['Title'] = $plugin_data['Name'];
    100102
     103        if ( empty($plugin_data['DonateURI']) ) {
     104                // Read info in from readme.txt
     105                $readme_headers = array(
     106                        'DonateURI' => 'Donate URI',
     107                );
     108
     109                $readme_file = plugin_dir_path( $plugin_file ) . 'readme.txt';
     110                if ( file_exists( $readme_file ) ) {
     111                        $readme_data = get_file_data( $readme_file, $readme_headers, 'readme', 1024 );
     112                        $plugin_data = array_merge( $readme_data, $plugin_data);
     113                }
     114        }
     115
    101116        if ( $markup || $translate )
    102117                $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate );
    103118
     
    113128                else
    114129                        load_plugin_textdomain($plugin_data['TextDomain'], false, dirname($plugin_file));
    115130
    116                 foreach ( array('Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version') as $field )
     131                foreach ( array('Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version', 'DonateURI') as $field )
    117132                        $plugin_data[ $field ] = translate($plugin_data[ $field ], $plugin_data['TextDomain']);
    118133        }
    119134
     135        // Sanitize urls
     136        foreach ( array('PluginURI', 'AuthorURI', 'DonateURI') as $field ) {
     137                if ( !empty($plugin_data[$field]) )
     138                        $plugin_data[$field] = esc_url($plugin_data[$field]);
     139        }
     140               
     141
    120142        //Apply Markup
    121143        if ( $markup ) {
    122144                if ( ! empty($plugin_data['PluginURI']) && ! empty($plugin_data['Name']) )
  • wp-admin/plugins.php

     
    620620                }
    621621                if ( ! empty($plugin_data['PluginURI']) )
    622622                        $plugin_meta[] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . __( 'Visit plugin site' ) . '">' . __('Visit plugin site') . '</a>';
    623 
     623                if ( ! empty($plugin_data['DonateURI']) )
     624                        $plugin_meta[] = '<a href="' . $plugin_data['DonateURI'] . '" title="' . __( 'Donate' ) . '">' . __('Donate') . '</a>';
     625                       
    624626                $plugin_meta = apply_filters('plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $context);
    625627                echo implode(' | ', $plugin_meta);
    626628                echo "</td>