Making WordPress.org

Ticket #5179: 5179.diff

File 5179.diff, 3.9 KB (added by Ipstenu, 5 years ago)
  • trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-review-tools.php

     
    77
    88namespace WordPressdotorg\Plugin_Directory\Admin\Metabox;
    99
     10use WordPressdotorg\Plugin_Directory\Template;
    1011use WordPressdotorg\Plugin_Directory\Tools;
    1112
    1213/**
     
    110111                        'suppress_filters' => false,
    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                 } );
     114                if ( in_array( $post->post_status, [ 'draft', 'pending', 'new' ], true ) ) {
    120115
    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                 }
     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                        } );
    126123
    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';
     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                        }
    132129
    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>';
     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';
    136135
    137                 if ( in_array( $post->post_status, [ 'draft', 'pending', 'new' ], true ) ) {
     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   = [];
    140142
     
    178180
    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;
    186188                                } else {
     
    187189                                        $slug = str_replace( '-', ' ', $post->post_name );
    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(
    193195                                                'As of %s, %s had %s+ active installs.',
     
    274276                                <li><a href='https://plugins.trac.wordpress.org/log/<?php echo esc_attr( $post->post_name ); ?>/'>Development Log</a></li>
    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
    279282                }