Making WordPress.org


Ignore:
Timestamp:
09/04/2025 04:46:46 AM (3 months ago)
Author:
dd32
Message:

Theme Directory: Upgrade the blueprint used for Theme Review live previews.

This removes the blueprint from being static in the trac ticket, allowing for future maintenance not to break older links.

Fixes #8077.
Merges https://github.com/WordPress/wordpress.org/pull/506.
See https://github.com/WordPress/wordpress-playground/issues/2548.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-wporg-themes-repo-package.php

    r13853 r14523  
    1717
    1818    /**
     19     * Holds the Version string for this instance of the class.
     20     *
     21     * NOTE: This may not be the latest version of the theme.
     22     *
     23     * @var string
     24     */
     25    public $version = '';
     26
     27    /**
    1928     * Construct a new Package for the given post ID or object.
    2029     *
    2130     * @param WP_Post|int|slug $wp_post The Post object, Post ID, or theme slug of the package.
     31     * @param string|bool $version Optional. The version string, or false for latest version.
    2232     */
    23     public function __construct( $wp_post = 0 ) {
     33    public function __construct( $wp_post = 0, $version = false ) {
    2434        global $post;
    2535        if ( ! $wp_post ) {
     
    5363            }
    5464        }
     65
     66        $this->version = $version;
     67        if ( $this->wp_post ) {
     68            if ( ! $version || 'latest' === $version || 'latest-stable' === $version ) {
     69                $this->version = $this->latest_version();
     70            }
     71        }
    5572    }
    5673
     
    6178     */
    6279    public function screenshot_url() {
    63         $screen  = 'screenshot.png';
    64         $version = $this->latest_version();
     80        $screen = 'screenshot.png';
    6581
    66         if ( ! empty( $this->wp_post->_screenshot[ $version ] ) ) {
    67             $screen = $this->wp_post->_screenshot[ $version ];
     82        if ( ! empty( $this->wp_post->_screenshot[ $this->version ] ) ) {
     83            $screen = $this->wp_post->_screenshot[ $this->version ];
    6884        }
    6985
    7086        return sprintf( 'https://i0.wp.com/themes.svn.wordpress.org/%1$s/%2$s/%3$s',
    7187            $this->wp_post->post_name,
    72             $version,
     88            $this->version,
    7389            $screen
    7490        );
     
    109125     * @return string
    110126     */
    111     public function download_url( $version = 'latest-stable' ) {
     127    public function download_url( $version = false ) {
     128        $version = $version ?: $this->version;
    112129        if ( 'latest-stable' === $version ) {
    113130            $version = $this->latest_version();
     
    137154     */
    138155    public function __get( $name ) {
    139         $version = $this->latest_version();
    140156        switch ( $name ) {
    141157            case 'version' :
    142158                return $version;
    143159            case 'theme-url' :
    144                 return $this->wp_post->_theme_url[ $version ] ?? '';
     160                return $this->wp_post->_theme_url[ $this->version ] ?? '';
    145161            case 'author-url' :
    146                 return $this->wp_post->_author_url[ $version ] ?? '';
     162                return $this->wp_post->_author_url[ $this->version ] ?? '';
    147163            case 'ticket' :
    148                 return $this->wp_post->_ticket_id[ $version ] ?? '';
     164                return $this->wp_post->_ticket_id[ $this->version ] ?? '';
    149165            case 'requires':
    150                 return $this->wp_post->_requires[ $version ] ?? '';
     166                return $this->wp_post->_requires[ $this->version ] ?? '';
    151167            case 'requires-php':
    152                 return $this->wp_post->_requires_php[ $version ] ?? '';
     168                return $this->wp_post->_requires_php[ $this->version ] ?? '';
    153169            default:
    154170                return $this->wp_post->$name;
Note: See TracChangeset for help on using the changeset viewer.