Changeset 14523 for sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-wporg-themes-repo-package.php
- Timestamp:
- 09/04/2025 04:46:46 AM (3 months ago)
- 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 17 17 18 18 /** 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 /** 19 28 * Construct a new Package for the given post ID or object. 20 29 * 21 30 * @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. 22 32 */ 23 public function __construct( $wp_post = 0 ) {33 public function __construct( $wp_post = 0, $version = false ) { 24 34 global $post; 25 35 if ( ! $wp_post ) { … … 53 63 } 54 64 } 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 } 55 72 } 56 73 … … 61 78 */ 62 79 public function screenshot_url() { 63 $screen = 'screenshot.png'; 64 $version = $this->latest_version(); 80 $screen = 'screenshot.png'; 65 81 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 ]; 68 84 } 69 85 70 86 return sprintf( 'https://i0.wp.com/themes.svn.wordpress.org/%1$s/%2$s/%3$s', 71 87 $this->wp_post->post_name, 72 $ version,88 $this->version, 73 89 $screen 74 90 ); … … 109 125 * @return string 110 126 */ 111 public function download_url( $version = 'latest-stable' ) { 127 public function download_url( $version = false ) { 128 $version = $version ?: $this->version; 112 129 if ( 'latest-stable' === $version ) { 113 130 $version = $this->latest_version(); … … 137 154 */ 138 155 public function __get( $name ) { 139 $version = $this->latest_version();140 156 switch ( $name ) { 141 157 case 'version' : 142 158 return $version; 143 159 case 'theme-url' : 144 return $this->wp_post->_theme_url[ $ version ] ?? '';160 return $this->wp_post->_theme_url[ $this->version ] ?? ''; 145 161 case 'author-url' : 146 return $this->wp_post->_author_url[ $ version ] ?? '';162 return $this->wp_post->_author_url[ $this->version ] ?? ''; 147 163 case 'ticket' : 148 return $this->wp_post->_ticket_id[ $ version ] ?? '';164 return $this->wp_post->_ticket_id[ $this->version ] ?? ''; 149 165 case 'requires': 150 return $this->wp_post->_requires[ $ version ] ?? '';166 return $this->wp_post->_requires[ $this->version ] ?? ''; 151 167 case 'requires-php': 152 return $this->wp_post->_requires_php[ $ version ] ?? '';168 return $this->wp_post->_requires_php[ $this->version ] ?? ''; 153 169 default: 154 170 return $this->wp_post->$name;
Note: See TracChangeset
for help on using the changeset viewer.