Make WordPress Core

Ticket #18599: 18599.3.patch

File 18599.3.patch, 3.2 KB (added by SergeyBiryukov, 14 years ago)
  • wp-admin/includes/class-wp-themes-list-table.php

     
    175175?>
    176176                <a href="<?php echo $preview_link; ?>" class="<?php echo $thickbox_class; ?> screenshot">
    177177<?php if ( $screenshot ) : ?>
    178                         <img src="<?php echo $theme_root_uri . '/' . $stylesheet . '/' . $screenshot; ?>" alt="" />
     178                        <img src="<?php echo esc_url( _get_theme_screenshot_url( $stylesheet_dir, $template_dir, $screenshot ) ); ?>" alt="" />
    179179<?php endif; ?>
    180180                </a>
    181181<h3><?php
  • wp-admin/themes.php

     
    8181<h3><?php _e('Current Theme'); ?></h3>
    8282<div id="current-theme">
    8383<?php if ( $ct->screenshot ) : ?>
    84 <img src="<?php echo $ct->theme_root_uri . '/' . $ct->stylesheet . '/' . $ct->screenshot; ?>" alt="<?php _e('Current theme preview'); ?>" />
     84<img src="<?php echo esc_url( _get_theme_screenshot_url( $ct->stylesheet_dir, $ct->template_dir, $ct->screenshot ) ); ?>" alt="<?php _e('Current theme preview'); ?>" />
    8585<?php endif; ?>
    8686<h4><?php
    8787        /* translators: 1: theme title, 2: theme version, 3: theme author */
  • wp-includes/theme.php

     
    293293                $template    = $theme_data['Template'];
    294294                $stylesheet  = dirname($theme_file);
    295295
    296                 $screenshot = false;
    297                 foreach ( array('png', 'gif', 'jpg', 'jpeg') as $ext ) {
    298                         if (file_exists("$theme_root/$stylesheet/screenshot.$ext")) {
    299                                 $screenshot = "screenshot.$ext";
    300                                 break;
    301                         }
    302                 }
    303 
    304296                if ( empty($name) ) {
    305297                        $name = dirname($theme_file);
    306298                        $title = $name;
     
    393385                if ( empty($stylesheet_dir) )
    394386                        $stylesheet_dir = '/';
    395387
     388                $screenshot = false;
     389                foreach ( array('png', 'gif', 'jpg', 'jpeg') as $ext ) {
     390                        if ( file_exists("$stylesheet_dir/screenshot.$ext") || file_exists("$template_dir/screenshot.$ext") ) {
     391                                $screenshot = "screenshot.$ext";
     392                                break;
     393                        }
     394                }
     395
    396396                // Check for theme name collision.  This occurs if a theme is copied to
    397397                // a new theme directory and the theme header is not updated.  Whichever
    398398                // theme is first keeps the name.  Subsequent themes get a suffix applied.
     
    19891989
    19901990add_action( 'delete_attachment', '_delete_attachment_theme_mod' );
    19911991
     1992/**
     1993 * Retrieve screenshot URL for a theme.
     1994 *
     1995 * If a child theme screenshot is missing, the one from a parent theme is used.
     1996 *
     1997 * @access private
     1998 * @since 3.3.0
     1999 */
     2000function _get_theme_screenshot_url( $stylesheet_dir, $template_dir, $screenshot ) {
     2001        $screenshot_url = false;
     2002
     2003        if ( file_exists("$stylesheet_dir/$screenshot") )
     2004                $screenshot_url = str_replace( WP_CONTENT_DIR, content_url(), "$stylesheet_dir/$screenshot" );
     2005        elseif ( file_exists("$template_dir/$screenshot") )
     2006                $screenshot_url = str_replace( WP_CONTENT_DIR, content_url(), "$template_dir/$screenshot" );
     2007
     2008        return $screenshot_url;
     2009}
     2010
    19922011?>