Make WordPress Core

Ticket #6007: 6007.diff

File 6007.diff, 12.2 KB (added by nacin, 13 years ago)
  • wp-includes/theme.php

     
    187187                'Description' => 'Description',
    188188                'Author' => 'Author',
    189189                'AuthorURI' => 'Author URI',
     190                'TextDomain' => 'Text Domain',
     191                'DomainPath' => 'Domain Path',
    190192                'Version' => 'Version',
    191193                'Template' => 'Template',
    192194                'Status' => 'Status',
    193195                'Tags' => 'Tags'
    194196                );
    195197
    196         $themes_allowed_tags = array(
    197                 'a' => array(
    198                         'href' => array(),'title' => array()
    199                         ),
    200                 'abbr' => array(
    201                         'title' => array()
    202                         ),
    203                 'acronym' => array(
    204                         'title' => array()
    205                         ),
    206                 'code' => array(),
    207                 'em' => array(),
    208                 'strong' => array()
    209         );
    210 
    211198        $theme_data = get_file_data( $theme_file, $default_headers, 'theme' );
    212199
    213         $theme_data['Name'] = $theme_data['Title'] = wp_kses( $theme_data['Name'], $themes_allowed_tags );
     200        $allowed_tags = $allowed_tags_in_links = array(
     201                'abbr'    => array( 'title' => true ),
     202                'acronym' => array( 'title' => true ),
     203                'code'    => true,
     204                'em'      => true,
     205                'strong'  => true,
     206        );
     207        $allowed_tags['a'] = array( 'href' => true, 'title' => true );
    214208
    215         $theme_data['URI'] = esc_url( $theme_data['URI'] );
     209        // Sanitized all displayed data.
    216210
    217         $theme_data['Description'] = wptexturize( wp_kses( $theme_data['Description'], $themes_allowed_tags ) );
     211        // Author and Name are marked up inside <a> tags. Don't allow these.
     212        $theme_data['Author']      = wp_kses( $theme_data['Author'], $allowed_tags_in_links );
     213        $theme_data['AuthorName']  = $theme_data['Author'];
    218214
    219         $theme_data['AuthorURI'] = esc_url( $theme_data['AuthorURI'] );
     215        $theme_data['Name']        = wp_kses( $theme_data['Name'],   $allowed_tags_in_links );
     216        $theme_data['Title']       = $theme_data['Name'];
    220217
    221         $theme_data['Template'] = wp_kses( $theme_data['Template'], $themes_allowed_tags );
     218        $theme_data['Description'] = wp_kses( $theme_data['Description'], $allowed_tags );
     219        $theme_data['Version']     = wp_kses( $theme_data['Version'],     $allowed_tags );
     220        $theme_data['Template']    = wp_kses( $theme_data['Template'],    $allowed_tags );
     221        $theme_data['Status']      = wp_kses( $theme_data['Status'],      $allowed_tags );
    222222
    223         $theme_data['Version'] = wp_kses( $theme_data['Version'], $themes_allowed_tags );
    224 
    225         if ( $theme_data['Status'] == '' )
     223        if ( ! $theme_data['Status'] )
    226224                $theme_data['Status'] = 'publish';
    227         else
    228                 $theme_data['Status'] = wp_kses( $theme_data['Status'], $themes_allowed_tags );
    229225
    230         if ( $theme_data['Tags'] == '' )
     226        $theme_data['URI']         = esc_url( $theme_data['URI'] );
     227        $theme_data['AuthorURI']   = esc_url( $theme_data['AuthorURI'] );
     228
     229        if ( is_string( $theme_data['Tags'] ) )
     230                $theme_data['Tags'] = array_map( 'trim', explode( ',', strip_tags( $theme_data['Tags'] ) ) );
     231        elseif ( ! $theme_data['Tags'] )
    231232                $theme_data['Tags'] = array();
    232         else
    233                 $theme_data['Tags'] = array_map( 'trim', explode( ',', wp_kses( $theme_data['Tags'], array() ) ) );
    234233
    235         if ( $theme_data['Author'] == '' ) {
    236                 $theme_data['Author'] = $theme_data['AuthorName'] = __('Anonymous');
     234        // Apply markup
     235        $theme_data['Description'] = wptexturize( $theme_data['Description'] );
     236
     237        if ( $theme_data['Author'] ) {
     238                if ( $theme_data['AuthorURI'] )
     239                        $theme_data['Author'] = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $theme_data['AuthorURI'], esc_attr__( 'Visit author homepage' ), $theme_data['Author'] );
    237240        } else {
    238                 $theme_data['AuthorName'] = wp_kses( $theme_data['Author'], $themes_allowed_tags );
    239                 if ( empty( $theme_data['AuthorURI'] ) ) {
    240                         $theme_data['Author'] = $theme_data['AuthorName'];
    241                 } else {
    242                         $theme_data['Author'] = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $theme_data['AuthorURI'], esc_attr__( 'Visit author homepage' ), $theme_data['AuthorName'] );
    243                 }
     241                $theme_data['Author'] = $theme_data['AuthorName'] = __( 'Anonymous' );
    244242        }
    245243
    246244        return $theme_data;
     
    287285
    288286                $name        = $theme_data['Name'];
    289287                $title       = $theme_data['Title'];
    290                 $description = wptexturize($theme_data['Description']);
     288                $description = $theme_data['Description'];
    291289                $version     = $theme_data['Version'];
    292290                $author      = $theme_data['Author'];
    293291                $template    = $theme_data['Template'];
     
    437435                        'Tags' => $theme_data['Tags'],
    438436                        'Theme Root' => $theme_root,
    439437                        'Theme Root URI' => str_replace( WP_CONTENT_DIR, content_url(), $theme_root ),
     438                        'TextDomain' => $theme_data['TextDomain'],
     439                        'DomainPath' => $theme_data['DomainPath'],
    440440                );
    441441        }
    442442
  • wp-content/themes/twentyten/style.css

     
    77License: GNU General Public License
    88License URI: license.txt
    99Tags: black, blue, white, two-columns, fixed-width, custom-header, custom-background, threaded-comments, sticky-post, translation-ready, microformats, rtl-language-support, editor-style, custom-menu
     10Text Domain: twentyten
     11Domain Path: /languages
    1012*/
    1113
    1214
  • wp-admin/includes/file.php

     
    3434        'video.php' => __('Video Attachment Template'),
    3535        'audio.php' => __('Audio Attachment Template'),
    3636        'application.php' => __('Application Attachment Template'),
    37         'my-hacks.php' => __( 'my-hacks.php (legacy hacks support)' ),
    3837        '.htaccess' => __( '.htaccess (for rewrite rules )' ),
    3938        // Deprecated files
     39        'my-hacks.php' => __( 'my-hacks.php (legacy hacks support)' ),
    4040        'wp-layout.css' => __( 'Stylesheet' ),
    4141        'wp-comments.php' => __( 'Comments Template' ),
    4242        'wp-comments-popup.php' => __( 'Popup Comments Template' ),
     
    5151 * @uses _cleanup_header_comment
    5252 * @uses $wp_file_descriptions
    5353 * @param string $file Filesystem path or filename
     54 * @param array $theme_data Optional. Theme data
    5455 * @return string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist
    5556 */
    56 function get_file_description( $file ) {
     57function get_file_description( $file, $theme_data = null ) {
    5758        global $wp_file_descriptions;
    5859
    59         if ( isset( $wp_file_descriptions[basename( $file )] ) ) {
    60                 return $wp_file_descriptions[basename( $file )];
    61         }
    62         elseif ( file_exists( $file ) && is_file( $file ) ) {
     60        if ( isset( $wp_file_descriptions[ basename( $file ) ] ) ) {
     61                return $wp_file_descriptions[ basename( $file ) ];
     62        } elseif ( file_exists( $file ) && is_file( $file ) ) {
    6363                $template_data = implode( '', file( $file ) );
    64                 if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ))
    65                         return sprintf( __( '%s Page Template' ), _cleanup_header_comment($name[1]) );
     64                if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) ) {
     65                        $page_template = _cleanup_header_comment( $name[1] );
     66                        if ( ! empty( $theme_data['TextDomain'] ) )
     67                                $page_template = translate( $page_template, $theme_data['TextDomain'] );
     68                        return sprintf( __( '%s Page Template' ), $page_template );
     69                }
    6670        }
    6771
    68         return basename( $file );
     72        return trim( basename( $file ) );
    6973}
    7074
    7175/**
  • wp-admin/includes/theme.php

     
    177177        $themes = get_themes();
    178178        $theme = get_current_theme();
    179179        $templates = $themes[$theme]['Template Files'];
     180        $textdomain = $themes[$theme]['TextDomain'];
    180181        $page_templates = array();
    181182
    182183        if ( is_array( $templates ) ) {
     
    194195
    195196                        $template_data = implode( '', file( $template ));
    196197
    197                         $name = '';
    198198                        if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) )
    199                                 $name = _cleanup_header_comment($name[1]);
     199                                $name = trim( _cleanup_header_comment( $name[1] ) );
     200                        else
     201                                continue;
    200202
    201                         if ( !empty( $name ) ) {
    202                                 $page_templates[trim( $name )] = $basename;
    203                         }
     203                        if ( $textdomain )
     204                                $name = translate( $name, $textdomain );
     205
     206                        if ( $name )
     207                                $page_templates[ $name ] = $basename;
    204208                }
    205209        }
    206210
  • wp-admin/includes/class-wp-plugins-list-table.php

     
    345345                                $description = '<p><strong>' . $dropins[ $plugin_file ][0] . ' <span class="attention">' . __('Inactive:') . '</span></strong> ' . sprintf( __( 'Requires <code>%s</code> in <code>wp-config.php</code>.' ), "define('" . $dropins[ $plugin_file ][1] . "', true);" ) . '</p>';
    346346                        }
    347347                        if ( $plugin_data['Description'] )
    348                                 $description .= '<p>' . $plugin_data['Description'] . '</p>';
     348                                $description .= '<p>' . wptexturize( $plugin_data['Description'] ) . '</p>';
    349349                } else {
    350350                        $is_active_for_network = is_plugin_active_for_network($plugin_file);
    351351                        if ( $screen->is_network )
     
    389389                $checkbox_id =  "checkbox_" . md5($plugin_data['Name']);
    390390                $checkbox = in_array( $status, array( 'mustuse', 'dropins' ) ) ? '' : "<input type='checkbox' name='checked[]' value='" . esc_attr( $plugin_file ) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $plugin_data['Name'] . "</label>";
    391391                if ( 'dropins' != $context ) {
    392                         $description = '<p>' . ( $plugin_data['Description'] ? $plugin_data['Description'] : '&nbsp;' ) . '</p>';
     392                        $description = '<p>' . ( $plugin_data['Description'] ? wptexturize( $plugin_data['Description'] ) : '&nbsp;' ) . '</p>';
    393393                        $plugin_name = $plugin_data['Name'];
    394394                }
    395395
  • wp-admin/theme-editor.php

     
    138138 <div id="message" class="updated"><p><?php _e('File edited successfully.') ?></p></div>
    139139<?php endif;
    140140
    141 $description = get_file_description($file);
     141$description = get_file_description( $file, $themes[ $theme ] );
    142142$desc_header = ( $description != $file_show ) ? "$description <span>($file_show)</span>" : $file_show;
    143143
    144144$is_child_theme = $themes[$theme]['Template'] != $themes[$theme]['Stylesheet'];
     
    187187                if ( $is_child_theme && strpos( $template_file, trailingslashit( $template_dir ) ) === 0 )
    188188                        continue;
    189189
    190                 $description = trim( get_file_description($template_file) );
     190                $description = get_file_description( $template_file, $themes[ $theme ] );
    191191                $template_show = basename($template_file);
    192192                $filedesc = ( $description != $template_file ) ? "$description<br /><span class='nonessential'>($template_show)</span>" : "$description";
    193193                $filedesc = ( $template_file == $file ) ? "<span class='highlight'>$description<br /><span class='nonessential'>($template_show)</span></span>" : $filedesc;
     
    209209                if ( $is_child_theme && strpos( $style_file, trailingslashit( $template_dir ) ) === 0 )
    210210                        continue;
    211211
    212                 $description = trim( get_file_description($style_file) );
     212                $description = get_file_description( $style_file, $themes[ $theme ] );
    213213                $style_show = basename($style_file);
    214214                $filedesc = ( $description != $style_file ) ? "$description<br /><span class='nonessential'>($style_show)</span>" : "$description";
    215215                $filedesc = ( $style_file == $file ) ? "<span class='highlight'>$description<br /><span class='nonessential'>($style_show)</span></span>" : $filedesc;
  • wp-admin/themes.php

     
    137137        }
    138138        echo implode ( ' | ', $options );
    139139
    140         if ( $ct->tags ) : ?>
    141         <p><?php _e('Tags:'); ?> <?php echo join(', ', $ct->tags); ?></p>
    142         <?php endif; ?>
     140        if ( $ct->tags )  {
     141                $f = array();
     142                $feature_list = get_theme_feature_list();
     143                foreach ( $feature_list as $feature_group => $features ) {
     144                        foreach ( $features as $tag => $translated ) {
     145                                if ( in_array( $tag, $ct->tags ) )
     146                                        $f[] = $translated;
     147                        }
     148                }
     149                /* translators: %l is a placeholder for wp_sprintf(). (Lowercase L.) */
     150                echo '<p>' . wp_sprintf( __( 'Features: %l.' ), $f ) . '</p>';
     151                unset( $f, $feature_list, $tag, $translated, $feature_group, $features );
     152        }
     153?>
    143154</div>
    144155<?php theme_update_available($ct); ?>
    145156