Making WordPress.org


Ignore:
Timestamp:
05/01/2020 06:09:06 AM (6 years ago)
Author:
dd32
Message:

Plugin Directory: Review Tooling: Add a quick download link to the review tools.

Props Ipstenu.
Fixes #5179.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-review-tools.php

    r9671 r9804  
    88namespace WordPressdotorg\Plugin_Directory\Admin\Metabox;
    99
     10use WordPressdotorg\Plugin_Directory\Template;
    1011use WordPressdotorg\Plugin_Directory\Tools;
    1112
     
    111112                ] );
    112113
    113                 $zip_files = array();
    114                 foreach ( get_attached_media( 'application/zip', $post ) as $zip_file ) {
    115                         $zip_files[ $zip_file->post_date ] = array( wp_get_attachment_url( $zip_file->ID ), $zip_file );
    116                 }
    117                 uksort( $zip_files, function ( $a, $b ) {
    118                         return strtotime( $a ) < strtotime( $b );
    119                 } );
    120 
    121                 $zip_url = get_post_meta( $post->ID, '_submitted_zip', true );
    122                 if ( $zip_url ) {
    123                         // Back-compat only.
    124                         $zip_files['User provided URL'] = array( $zip_url, null );
    125                 }
    126 
    127                 echo '<p><strong>Zip files:</strong></p>';
    128                 echo '<ul class="plugin-zip-files">';
    129                 foreach ( $zip_files as $zip_date => $zip ) {
    130                         list( $zip_url, $zip_file ) = $zip;
    131                         $zip_size                   = is_object( $zip_file ) ? size_format( filesize( get_attached_file( $zip_file->ID ) ), 1 ) : 'unknown size';
    132 
    133                         printf( '<li>%s <a href="%s">%s</a> (%s)</li>', esc_html( $zip_date ), esc_url( $zip_url ), esc_html( $zip_url ), esc_html( $zip_size ) );
    134                 }
    135                 echo '</ul>';
    136 
    137114                if ( in_array( $post->post_status, [ 'draft', 'pending', 'new' ], true ) ) {
     115
     116                        $zip_files = array();
     117                        foreach ( get_attached_media( 'application/zip', $post ) as $zip_file ) {
     118                                $zip_files[ $zip_file->post_date ] = array( wp_get_attachment_url( $zip_file->ID ), $zip_file );
     119                        }
     120                        uksort( $zip_files, function ( $a, $b ) {
     121                                return strtotime( $a ) < strtotime( $b );
     122                        } );
     123
     124                        $zip_url = get_post_meta( $post->ID, '_submitted_zip', true );
     125                        if ( $zip_url ) {
     126                                // Back-compat only.
     127                                $zip_files['User provided URL'] = array( $zip_url, null );
     128                        }
     129
     130                        echo '<p><strong>Zip files:</strong></p>';
     131                        echo '<ul class="plugin-zip-files">';
     132                        foreach ( $zip_files as $zip_date => $zip ) {
     133                                list( $zip_url, $zip_file ) = $zip;
     134                                $zip_size                   = is_object( $zip_file ) ? size_format( filesize( get_attached_file( $zip_file->ID ) ), 1 ) : 'unknown size';
     135
     136                                printf( '<li>%s <a href="%s">%s</a> (%s)</li>', esc_html( $zip_date ), esc_url( $zip_url ), esc_html( $zip_url ), esc_html( $zip_size ) );
     137                        }
     138                        echo '</ul>';
     139
    138140                        $slug_restricted = [];
    139141                        $slug_reserved   = [];
     
    179181                        // Check Active_Installs, prior to sync?
    180182                        if ( function_exists( 'wporg_stats_get_plugin_name_install_count' ) ) {
    181                
     183
    182184                                $title_matches = wporg_stats_get_plugin_name_install_count( $post->post_title );
    183                
     185
    184186                                if ( $post->post_name == sanitize_title( $post->post_title ) ) {
    185187                                        $slug_matches = false;
     
    188190                                        $slug_matches = wporg_stats_get_plugin_name_install_count( $slug );
    189191                                }
    190                
     192
    191193                                if ( $title_matches ) {
    192194                                        array_push( self::$flagged['high'], sprintf(
     
    275277                                <li><a href='https://plugins.svn.wordpress.org/<?php echo esc_attr( $post->post_name ); ?>/'>Subversion Repository</a></li>
    276278                                <li><a href='https://plugins.trac.wordpress.org/browser/<?php echo esc_attr( $post->post_name ); ?>/'>Browse in Trac</a></li>
     279                                <li><a href='<?php echo esc_url( Template::download_link() ); ?>'>Download Current Version</a></li>
    277280                        </ul>
    278281                        <?php
Note: See TracChangeset for help on using the changeset viewer.