Changeset 6343 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/inc/template-tags.php
- Timestamp:
- 01/10/2018 07:43:34 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/inc/template-tags.php
r6284 r6343 239 239 return $message; 240 240 } 241 242 /** 243 * Displays a select element with links to previous plugin version to download. 244 * 245 * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. 246 */ 247 function the_previous_version_download( $post = null ) { 248 $post = get_post( $post ); 249 250 if ( 'publish' !== $post->post_status ) { 251 return; 252 } 253 254 $tags = (array) get_post_meta( $post->ID, 'tagged_versions', true ); 255 // Sort the versions by version. 256 usort( $tags, 'version_compare' ); 257 // We'll want to add a Development Version if it exists. 258 $tags[] = 'trunk'; 259 // Remove the current version, this may be trunk. 260 $tags = array_diff( $tags, array( get_post_meta( $post->ID, 'stable_tag', true ) ) ); 261 262 if ( empty( $tags ) ) { 263 return; 264 } 265 266 // List Trunk, followed by the most recent non-stable release. 267 $tags = array_reverse( $tags ); 268 269 echo '<h5>' . esc_html__( 'Previous Versions', 'wporg-plugins' ) . '</h5>'; 270 echo '<div class="plugin-notice notice notice-info notice-alt"><p>' . esc_html__( 'Previous versions of this plugin may not be secure or stable and are available for testing purposes only.', 'wporg-plugins' ) . '</p></div>'; 271 272 echo '<select class="previous-versions" onchange="getElementById(\'download-previous-link\').href=this.value;">'; 273 foreach ( $tags as $version ) { 274 $text = ( 'trunk' === $version ? esc_html__( 'Development Version', 'wporg-plugins' ) : $version ); 275 printf( '<option value="%s">%s</option>', esc_attr( Template::download_link( $post, $version ) ), esc_html( $text ) ); 276 } 277 echo '</select> '; 278 279 printf( 280 '<a href="%s" id="download-previous-link" class="button">%s</a>', 281 esc_url( Template::download_link( $post, reset( $tags ) ) ), 282 esc_html__( 'Download', 'wporg-plugins' ) 283 ); 284 }
Note: See TracChangeset
for help on using the changeset viewer.