Make WordPress Core

Changeset 52947


Ignore:
Timestamp:
03/17/2022 10:19:58 PM (3 years ago)
Author:
audrasjb
Message:

Themes: Add version to theme screenshot URL for better browser cache handling.

This change appends the theme version number to the URL of screenshots that appear in various place of the WordPress Admin. As a result, browsers will be able to refresh the screenshot as needed when the theme is updated.

Props codente, desrosj, audrasjb, SergeyBiryukov.
Fixes #53370.

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-theme-install-list-table.php

    r52204 r52947  
    360360        ?>
    361361        <a class="screenshot install-theme-preview" href="<?php echo esc_url( $preview_url ); ?>" title="<?php echo esc_attr( $preview_title ); ?>">
    362             <img src="<?php echo esc_url( $theme->screenshot_url ); ?>" width="150" alt="" />
     362            <img src="<?php echo esc_url( $theme->screenshot_url . '?ver=' . $theme->version ); ?>" width="150" alt="" />
    363363        </a>
    364364
     
    503503            </span>
    504504            <?php if ( isset( $theme->screenshot_url ) ) : ?>
    505                 <img class="theme-screenshot" src="<?php echo esc_url( $theme->screenshot_url ); ?>" alt="" />
     505                <img class="theme-screenshot" src="<?php echo esc_url( $theme->screenshot_url . '?ver=' . $theme->version ); ?>" alt="" />
    506506            <?php endif; ?>
    507507            <div class="theme-details">
  • trunk/src/wp-admin/includes/theme.php

    r52610 r52947  
    824824                <div class="theme-screenshots">
    825825                <# if ( data.screenshot && data.screenshot[0] ) { #>
    826                     <div class="screenshot"><img src="{{ data.screenshot[0] }}" alt="" /></div>
     826                    <div class="screenshot"><img src="{{ data.screenshot[0] }}?ver={{ data.version }}" alt="" /></div>
    827827                <# } else { #>
    828828                    <div class="screenshot blank"></div>
  • trunk/src/wp-admin/theme-install.php

    r52819 r52947  
    283283    <# if ( data.screenshot_url ) { #>
    284284        <div class="theme-screenshot">
    285             <img src="{{ data.screenshot_url }}" alt="" />
     285            <img src="{{ data.screenshot_url }}?ver={{ data.version }}" alt="" />
    286286        </div>
    287287    <# } else { #>
     
    457457                    </span>
    458458
    459                     <img class="theme-screenshot" src="{{ data.screenshot_url }}" alt="" />
     459                    <img class="theme-screenshot" src="{{ data.screenshot_url }}?ver={{ data.version }}" alt="" />
    460460
    461461                    <div class="theme-details">
  • trunk/src/wp-admin/themes.php

    r52580 r52947  
    389389    <?php if ( ! empty( $theme['screenshot'][0] ) ) { ?>
    390390        <div class="theme-screenshot">
    391             <img src="<?php echo esc_attr( $theme['screenshot'][0] ); ?>" alt="" />
     391            <img src="<?php echo esc_attr( $theme['screenshot'][0] . '?ver=' . $theme['version'] ); ?>" alt="" />
    392392        </div>
    393393    <?php } else { ?>
     
    740740    <# if ( data.screenshot[0] ) { #>
    741741        <div class="theme-screenshot">
    742             <img src="{{ data.screenshot[0] }}" alt="" />
     742            <img src="{{ data.screenshot[0] }}?ver={{ data.version }}" alt="" />
    743743        </div>
    744744    <# } else { #>
     
    948948            <div class="theme-screenshots">
    949949            <# if ( data.screenshot[0] ) { #>
    950                 <div class="screenshot"><img src="{{ data.screenshot[0] }}" alt="" /></div>
     950                <div class="screenshot"><img src="{{ data.screenshot[0] }}?ver={{ data.version }}" alt="" /></div>
    951951            <# } else { #>
    952952                <div class="screenshot blank"></div>
  • trunk/src/wp-admin/update-core.php

    r52644 r52947  
    756756        </td>
    757757        <td class="plugin-title"><p>
    758             <img src="<?php echo esc_url( $theme->get_screenshot() ); ?>" width="85" height="64" class="updates-table-screenshot" alt="" />
     758            <img src="<?php echo esc_url( $theme->get_screenshot() . '?ver=' . $theme->version ); ?>" width="85" height="64" class="updates-table-screenshot" alt="" />
    759759            <strong><?php echo $theme->display( 'Name' ); ?></strong>
    760760            <?php
  • trunk/src/wp-includes/customize/class-wp-customize-theme-control.php

    r52371 r52947  
    7575            <# if ( data.theme.screenshot && data.theme.screenshot[0] ) { #>
    7676                <div class="theme-screenshot">
    77                     <img data-src="{{ data.theme.screenshot[0] }}" alt="" />
     77                    <img data-src="{{ data.theme.screenshot[0] }}?ver={{ data.theme.version }}" alt="" />
    7878                </div>
    7979            <# } else { #>
Note: See TracChangeset for help on using the changeset viewer.