Making WordPress.org


Ignore:
Timestamp:
12/08/2017 05:37:23 PM (9 years ago)
Author:
obenland
Message:

Plugins: Simplify template logic.

Moves most of the logic into template tags to make the single-plugin template it bit easier to understand.

Props joostdevalk.
Fixes #3310.

File:
1 edited

Legend:

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

    r6249 r6251  
    99
    1010namespace WordPressdotorg\Plugin_Directory\Theme;
    11 use WordPressdotorg\Plugin_Directory\Plugin_Directory;
    1211use WordPressdotorg\Plugin_Directory\Template;
     12
     13global $post;
    1314?>
    1415
    1516<div id="admin" class="section">
    16     <?php
    17     $status  = get_post_status();
    18     if ( in_array( $status, array( 'closed', 'disabled' ) ) ) {
    19             echo '<div class="plugin-notice notice notice-error notice-alt"><p>' . __( 'This plugin has been closed and is no longer available for download.', 'wporg-plugins' ) . '</p></div>';
    20             if ( get_current_user_id() == get_post()->post_author ) {
    21                     echo '<div class="plugin-notice notice notice-info notice-alt"><p>' .
    22                                         sprintf(
    23                                         /* translators: 1: plugins@wordpress.org */
    24                                                 __( 'If you did not request this change, please contact <a href="mailto:%1$s">%1$s</a> for a status. All developers with commit access are contacted when a plugin is closed, with the reasons why, so check your spam email too.', 'wporg-plugins' ),
    25                                                 'plugins@wordpress.org'
    26                                         ) . '</p></div><!-- .plugin-notice -->';
    27             }
    28     }
     17        <?php the_closed_plugin_notice(); ?>
    2918
    30     ?>
    3119        <h2><?php _e( 'Plugin Stats', 'wporg-plugins' ); ?></h2>
    3220
    … …  
    4634
    4735        <?php
    48 
     36        if ( 'publish' === $post->post_status ) {
    4937                $tags = (array) get_post_meta( $post->ID, 'tagged_versions', true );
    50                 // Sort the versions by version
     38                // Sort the versions by version.
    5139                usort( $tags, 'version_compare' );
    52                 // We'll want to add a Development Version if it exists
     40                // We'll want to add a Development Version if it exists.
    5341                $tags[] = 'trunk';
    5442
    … …  
    5947                $tags = array_reverse( $tags );
    6048
    61                 if ( $tags && 'publish' === get_post_status() ) {
    62                         echo '<h5>' . __( 'Previous Versions', 'wporg-plugins' ) . '</h5>';
     49                echo '<h5>' . __( 'Previous Versions', 'wporg-plugins' ) . '</h5>';
     50                echo '<div class="plugin-notice notice notice-info notice-alt"><p>' . __( 'Previous versions of this plugin may not be secure or stable and are available for testing purposes only.', 'wporg-plugins' ) . '</p></div>';
    6351
    64                         echo '<div class="plugin-notice notice notice-info notice-alt"><p>' . __( 'Previous versions of this plugin may not be secure or stable and are available for testing purposes only.', 'wporg-plugins' ) . '</p></div>';
     52                echo '<select class="previous-versions" onchange="getElementById(\'download-previous-link\').href=this.value;">';
     53                foreach ( $tags as $version ) {
     54                        $text = ( 'trunk' == $version ? __( 'Development Version', 'wporg-plugins' ) : $version );
     55                        printf( '<option value="%s">%s</option>', esc_attr( Template::download_link( $post, $version ) ), esc_html( $text ) );
     56                }
     57                echo '</select> ';
    6558
    66                         echo '<select class="previous-versions" onchange="getElementById(\'download-previous-link\').href=this.value;">';
    67                         foreach ( $tags as $version ) {
    68                                 $text = ( 'trunk' == $version ? __( 'Development Version', 'wporg-plugins' ) : $version );
    69                                 printf( '<option value="%s">%s</option>', esc_attr( Template::download_link( $post, $version ) ), esc_html( $text ) );
    70                         }
    71                         echo '</select> ';
    72 
    73                         printf(
    74                                 '<a href="%s" id="download-previous-link" class="button">%s</a>',
    75                                 esc_url( Template::download_link( $post, reset( $tags ) ) ),
    76                                 __( 'Download', 'wporg-plugins' )
    77                         );
    78                 }
    79 
     59                printf(
     60                        '<a href="%s" id="download-previous-link" class="button">%s</a>',
     61                        esc_url( Template::download_link( $post, reset( $tags ) ) ),
     62                        __( 'Download', 'wporg-plugins' )
     63                );
     64        }
    8065        ?>
    8166</div>
Note: See TracChangeset for help on using the changeset viewer.