WordPress.org

Make WordPress Core

Ticket #16868: theme_add_version.php.diff

File theme_add_version.php.diff, 3.4 KB (added by cais, 7 years ago)

/wp-content/theme.php diff

  • wp-includes/theme.php

     
    170170 * <b>code</b>, <b>em</b>, and <b>strong</b> elements also allowed.
    171171 *
    172172 * The style.css file must contain theme name, theme URI, and description. The
    173  * data can also contain author URI, author, template (parent template),
    174  * version, status, and finally tags. Some of these are not used by WordPress
    175  * administration panels, but are used by theme directory web sites which list
    176  * the theme.
     173 * data can also contain the WordPress version required, the version tested to,
     174 * author URI, author, template (parent template), version, status, and finally
     175 * tags. Some of these are not used by WordPress administration panels, but are
     176 * used by theme directory web sites which list the theme.
    177177 *
    178178 * @since 1.5.0
    179179 *
     
    182182 */
    183183function get_theme_data( $theme_file ) {
    184184        $default_headers = array(
     185                'Required' => 'WordPress Version Required',
     186                'Tested' => 'Tested Up To',
    185187                'Name' => 'Theme Name',
    186188                'URI' => 'Theme URI',
    187189                'Description' => 'Description',
     
    209211        );
    210212
    211213        $theme_data = get_file_data( $theme_file, $default_headers, 'theme' );
     214       
     215        $theme_data['Required'] = wp_kses( $theme_data['Required'], $themes_allowed_tags );
     216       
     217        $theme_data['Tested'] = wp_kses( $theme_data['Tested'], $themes_allowed_tags );
    212218
    213219        $theme_data['Name'] = $theme_data['Title'] = wp_kses( $theme_data['Name'], $themes_allowed_tags );
    214220
     
    284290                }
    285291
    286292                $theme_data = get_theme_data("$theme_root/$theme_file");
     293               
     294                $wp_version_required  = $theme_data['Required'];
     295                $wp_version_tested    = $theme_data['Tested'];
     296                $name                 = $theme_data['Name'];
     297                $title                = $theme_data['Title'];
     298                $description          = wptexturize($theme_data['Description']);
     299                $version              = $theme_data['Version'];
     300                $author               = $theme_data['Author'];
     301                $template             = $theme_data['Template'];
     302                $stylesheet           = dirname($theme_file);
    287303
    288                 $name        = $theme_data['Name'];
    289                 $title       = $theme_data['Title'];
    290                 $description = wptexturize($theme_data['Description']);
    291                 $version     = $theme_data['Version'];
    292                 $author      = $theme_data['Author'];
    293                 $template    = $theme_data['Template'];
    294                 $stylesheet  = dirname($theme_file);
    295 
    296304                $screenshot = false;
    297305                foreach ( array('png', 'gif', 'jpg', 'jpeg') as $ext ) {
    298306                        if (file_exists("$theme_root/$stylesheet/screenshot.$ext")) {
     
    301309                        }
    302310                }
    303311
     312                /* Test if WordPress Versions have been set for Required and Tested else set to version 0.0 */
     313                /* TO-DO: value set to '0.0' for use in comparison tests - change to 'unknown'? */
     314                if ( empty( $wp_version_required ) )
     315                        $wp_version_required = '0.0';
     316                       
     317                if ( empty( $wp_version_tested ) )
     318                        $wp_version_tested = '0.0';
     319
    304320                if ( empty($name) ) {
    305321                        $name = dirname($theme_file);
    306322                        $title = $name;
     
    417433
    418434                $theme_roots[$stylesheet] = str_replace( WP_CONTENT_DIR, '', $theme_root );
    419435                $wp_themes[$name] = array(
     436                        'Required' => $wp_version_required,
     437                        'Tested' => $wp_version_tested,
    420438                        'Name' => $name,
    421439                        'Title' => $title,
    422440                        'Description' => $description,
     
    18791897
    18801898add_action( 'delete_attachment', '_delete_attachment_theme_mod' );
    18811899
    1882 ?>
     1900?>
     1901 No newline at end of file