Ticket #18599: 18599.2.patch

File 18599.2.patch, 2.6 KB (added by SergeyBiryukov, 21 months 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( $theme_root, $theme_root_uri, $template, $stylesheet, $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->theme_root, $ct->theme_root_uri, $ct->template, $ct->stylesheet, $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

     
    295295 
    296296                $screenshot = false; 
    297297                foreach ( array('png', 'gif', 'jpg', 'jpeg') as $ext ) { 
    298                         if (file_exists("$theme_root/$stylesheet/screenshot.$ext")) { 
     298                        if ( file_exists("$theme_root/$stylesheet/screenshot.$ext") || file_exists("$theme_root/$template/screenshot.$ext") ) { 
    299299                                $screenshot = "screenshot.$ext"; 
    300300                                break; 
    301301                        } 
     
    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( $theme_root, $theme_root_uri, $template, $stylesheet, $screenshot ) { 
     2001        $screenshot_url = false; 
     2002 
     2003        if ( file_exists("$theme_root/$stylesheet/$screenshot") ) 
     2004                $screenshot_url = "$theme_root_uri/$stylesheet/$screenshot"; 
     2005        elseif ( file_exists("$theme_root/$template/$screenshot") ) 
     2006                $screenshot_url = "$theme_root_uri/$template/$screenshot"; 
     2007 
     2008        return $screenshot_url; 
     2009} 
     2010 
    19922011?>