Have WP_Theme::get_screenshot() default to an absolute URI. Allow 'relative' to be requested. see #20103, see #19816.

git-svn-id: http://svn.automattic.com/wordpress/trunk@20043 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2012-02-29 20:31:56 +00:00
parent 5a4f7349e8
commit 8ba92a52f8
4 changed files with 14 additions and 14 deletions

View File

@ -152,8 +152,8 @@ class WP_Themes_List_Table extends WP_List_Table {
$actions = implode ( ' | ', $actions );
?>
<a href="<?php echo $preview_link; ?>" class="thickbox thickbox-preview screenshot">
<?php if ( $theme->get_screenshot() ) : ?>
<img src="<?php echo esc_url( $theme->get_screenshot( 'absolute' ) ); ?>" alt="" />
<?php if ( $screenshot = $theme->get_screenshot() ) : ?>
<img src="<?php echo esc_url( $screenshot ); ?>" alt="" />
<?php endif; ?>
</a>
<h3><?php

View File

@ -99,8 +99,8 @@ if ( ! is_multisite() && current_user_can( 'install_themes' ) ) : ?>
<?php $ct = wp_get_theme(); ?>
<h3><?php _e( 'Current Theme' ); ?></h3>
<div id="current-theme">
<?php if ( $ct->get_screenshot() ) : ?>
<img src="<?php echo $ct->get_screenshot( 'absolute' ); ?>" alt="<?php esc_attr_e( 'Current theme preview'); ?>" />
<?php if ( $screenshot = $ct->get_screenshot() ) : ?>
<img src="<?php echo esc_url( $screenshot ); ?>" alt="<?php esc_attr_e( 'Current theme preview'); ?>" />
<?php endif; ?>
<h4><?php
/* translators: 1: theme title, 2: theme version, 3: theme author */

View File

@ -280,7 +280,7 @@ final class WP_Theme implements ArrayAccess {
case 'stylesheet' :
return $this->get_stylesheet();
case 'screenshot' :
return $this->get_screenshot();
return $this->get_screenshot( 'relative' );
// 'author' and 'description' did not previously return translated data.
case 'description' :
return $this->display('Description');
@ -360,7 +360,7 @@ final class WP_Theme implements ArrayAccess {
case 'Stylesheet Dir' :
return $this->get_stylesheet_directory();
case 'Screenshot' :
return $this->get_screenshot();
return $this->get_screenshot( 'relative' );
case 'Tags' :
return $this->get('Tags');
case 'Theme Root' :
@ -792,15 +792,15 @@ final class WP_Theme implements ArrayAccess {
* @since 3.4.0
* @access public
*
* @param string $uri Type of URL to include, either relative or absolute. Defaults to relative.
* @param string $uri Type of URL to include, either 'relative' or an absolute URI. Defaults to absolute URI.
* @return mixed Screenshot file. False if the theme does not have a screenshot.
*/
public function get_screenshot( $uri = 'relative' ) {
public function get_screenshot( $uri = 'uri' ) {
$screenshot = $this->cache_get( 'screenshot' );
if ( $screenshot ) {
if ( 'absolute' == $uri )
return $this->get_stylesheet_directory_uri() . '/' . $screenshot;
return $screenshot;
if ( 'relative' == $uri )
return $screenshot;
return $this->get_stylesheet_directory_uri() . '/' . $screenshot;
} elseif ( 0 === $screenshot ) {
return false;
}
@ -840,7 +840,7 @@ final class WP_Theme implements ArrayAccess {
// This will set the screenshot cache.
// If there is no screenshot, the screenshot_count cache will also be set.
if ( ! $screenshot = $this->get_screenshot() )
if ( ! $screenshot = $this->get_screenshot( 'relative' ) )
return 0;
$prefix = $this->get_stylesheet() . '/screenshot-';
@ -868,7 +868,7 @@ final class WP_Theme implements ArrayAccess {
if ( ! $count = $this->get_screenshot_count() )
return array();
$screenshots = array( $this->get_screenshot() );
$screenshots = array( $this->get_screenshot( 'relative' ) );
for ( $i = 2; $i <= $count; $i++ )
$screenshots[] = 'screenshot-' . $i . '.png';
return $screenshots;

View File

@ -28,7 +28,7 @@ wp_enqueue_style( 'customize-controls' );
do_action( 'customize_controls_enqueue_scripts' );
$theme = wp_get_theme();
$screenshot = $theme->get_screenshot( 'absolute' );
$screenshot = $theme->get_screenshot();
// Let's roll.
@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));