Making WordPress.org


Ignore:
Timestamp:
01/10/2018 07:43:34 PM (7 years ago)
Author:
obenland
Message:

Plugins: Don't show previous versions if there are none.

Props swissspidy for initial patch.
Fixes #3368.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/section-advanced.php

    r6284 r6343  
    3434    </table>
    3535
    36     <?php
    37     if ( 'publish' === $post->post_status ) {
    38         $tags = (array) get_post_meta( $post->ID, 'tagged_versions', true );
    39         // Sort the versions by version.
    40         usort( $tags, 'version_compare' );
    41         // We'll want to add a Development Version if it exists.
    42         $tags[] = 'trunk';
    43 
    44         // Remove the current version, this may be trunk.
    45         $tags = array_diff( $tags, array( get_post_meta( $post->ID, 'stable_tag', true ) ) );
    46 
    47         // List Trunk, followed by the most recent non-stable release.
    48         $tags = array_reverse( $tags );
    49 
    50         echo '<h5>' . esc_html__( 'Previous Versions', 'wporg-plugins' ) . '</h5>';
    51         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>';
    52 
    53         echo '<select class="previous-versions" onchange="getElementById(\'download-previous-link\').href=this.value;">';
    54         foreach ( $tags as $version ) {
    55             $text = ( 'trunk' === $version ? esc_html__( 'Development Version', 'wporg-plugins' ) : $version );
    56             printf( '<option value="%s">%s</option>', esc_attr( Template::download_link( $post, $version ) ), esc_html( $text ) );
    57         }
    58         echo '</select> ';
    59 
    60         printf(
    61             '<a href="%s" id="download-previous-link" class="button">%s</a>',
    62             esc_url( Template::download_link( $post, reset( $tags ) ) ),
    63             esc_html__( 'Download', 'wporg-plugins' )
    64         );
    65     }
    66     ?>
     36    <?php the_previous_version_download(); ?>
    6737</div>
Note: See TracChangeset for help on using the changeset viewer.