Making WordPress.org

Changeset 6023


Ignore:
Timestamp:
10/13/2017 11:59:21 AM (9 years ago)
Author:
SergeyBiryukov
Message:

Plugin Directory: Limit plugin submissions to one at a time.

Remove the upload form if the developer already has a plugin in the review queue.

Fixes #2386.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload.php

    r5511 r6023  
    3030                if ( is_user_logged_in() ) :
    3131                        include_once ABSPATH . 'wp-admin/includes/template.php';
     32
     33                        $submitted_plugins = self::get_submitted_plugins();
     34                        $submitted_counts  = (object) array_fill_keys( array( 'new', 'pending' ), 0 );
     35
     36                        $submitted_counts->total = count( $submitted_plugins );
     37
     38                        foreach ( $submitted_plugins as $key => $plugin ) {
     39                                if ( 'new' === $plugin->post_status ) {
     40                                        $submitted_plugins[ $key ]->status = __( 'Awaiting Review', 'wporg-plugins' );
     41                                        $submitted_counts->new++;
     42                                } elseif ( 'pending' === $plugin->post_status ) {
     43                                        $submitted_plugins[ $key ]->status = __( 'Being Reviewed', 'wporg-plugins' );
     44                                        $submitted_counts->pending++;
     45                                }
     46                        }
    3247
    3348                        if ( ! empty( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'wporg-plugins-upload' ) && 'upload' === $_POST['action'] ) :
     
    6681                                </div>
    6782
    68                                 <?php
    69                                 $submitted_plugins = self::get_submitted_plugins();
    70                                 $submitted_counts  = (object) array_fill_keys( array( 'new', 'pending' ), 0 );
    71 
    72                                 foreach ( $submitted_plugins as $key => $plugin ) {
    73                                         if ( 'new' === $plugin->post_status ) {
    74                                                 $submitted_plugins[ $key ]->status = __( 'Awaiting Review', 'wporg-plugins' );
    75                                                 $submitted_counts->new++;
    76                                         } elseif ( 'pending' === $plugin->post_status ) {
    77                                                 $submitted_plugins[ $key ]->status = __( 'Being Reviewed', 'wporg-plugins' );
    78                                                 $submitted_counts->pending++;
    79                                         }
    80                                 }
    81                                 ?>
    82 
    83                                 <?php if ( $submitted_counts->new + $submitted_counts->pending ) : ?>
     83                                <?php if ( $submitted_counts->total ) : ?>
    8484
    8585                                        <div class="plugin-queue-message notice notice-warning notice-alt">
    8686                                                <p><?php
    87                                                         if ( 1 === ( $submitted_counts->new + $submitted_counts->pending ) ) {
    88                                                                 _e( 'You have 1 plugin in the review queue.', 'wporg-plugins' );
     87                                                        if ( 1 === $submitted_counts->total ) {
     88                                                                _e( 'You have 1 plugin in the review queue. Please wait for it to be approved before submitting any more.', 'wporg-plugins' );
    8989                                                        } else {
    9090                                                                printf(
    9191                                                                        _n(
    92                                                                                 'You have %1$s plugins in the review queue, %2$s is being actively reviewed.',
    93                                                                                 'You have %1$s plugins in the review queue, %2$s are being actively reviewed.',
     92                                                                                'You have %1$s plugins in the review queue, %2$s is being actively reviewed. Please wait for them to be approved before submitting any more.',
     93                                                                                'You have %1$s plugins in the review queue, %2$s are being actively reviewed. Please wait for them to be approved before submitting any more.',
    9494                                                                                $submitted_counts->pending,
    9595                                                                                'wporg-plugins'
    9696                                                                        ),
    97                                                                         '<strong>' . ( $submitted_counts->new + $submitted_counts->pending ) . '</strong>',
     97                                                                        '<strong>' . $submitted_counts->total . '</strong>',
    9898                                                                        '<strong>' . $submitted_counts->pending . '</strong>'
    9999                                                                );
     
    115115                                        </div>
    116116
    117                                 <?php endif; ?>
     117                                <?php endif; // $submitted_counts->total ?>
    118118
    119                         <?php endif; ?>
     119                        <?php endif; // wp_verify_nonce() && 'upload' === $_POST['action'] ?>
    120120
    121                         <form id="upload_form" class="plugin-upload-form" enctype="multipart/form-data" method="POST" action="">
    122                                 <?php wp_nonce_field( 'wporg-plugins-upload' ); ?>
    123                                 <input type="hidden" name="action" value="upload"/>
    124                                 <?php /* <fieldset>
    125                                         <legend><?php _e( 'Select categories (up to 3)', 'wporg-plugins' ); ?></legend>
    126                                         <ul class="category-checklist">
    127                                                 <?php wp_terms_checklist( 0, array( 'taxonomy' => 'plugin_category' ) ); ?>
    128                                         </ul>
    129                                 </fieldset> */ ?>
     121                        <?php if ( ! $submitted_counts->total ) : ?>
    130122
    131                                 <input type="file" id="zip_file" class="plugin-file" name="zip_file" size="25" accept=".zip"/>
    132                                 <label class="button button-secondary" for="zip_file"><?php _e( 'Select File', 'wporg-plugins' ); ?></label>
     123                                <form id="upload_form" class="plugin-upload-form" enctype="multipart/form-data" method="POST" action="">
     124                                        <?php wp_nonce_field( 'wporg-plugins-upload' ); ?>
     125                                        <input type="hidden" name="action" value="upload"/>
     126                                        <?php /* <fieldset>
     127                                                <legend><?php _e( 'Select categories (up to 3)', 'wporg-plugins' ); ?></legend>
     128                                                <ul class="category-checklist">
     129                                                        <?php wp_terms_checklist( 0, array( 'taxonomy' => 'plugin_category' ) ); ?>
     130                                                </ul>
     131                                        </fieldset> */ ?>
    133132
    134                                 <input id="upload_button" class="button button-primary" type="submit" value="<?php esc_attr_e( 'Upload', 'wporg-plugins' ); ?>"/>
     133                                        <input type="file" id="zip_file" class="plugin-file" name="zip_file" size="25" accept=".zip"/>
     134                                        <label class="button button-secondary" for="zip_file"><?php _e( 'Select File', 'wporg-plugins' ); ?></label>
    135135
    136                                 <p>
    137                                         <small><?php printf( __( 'Maximum allowed file size: %s', 'wporg-plugins' ), esc_html( self::get_max_allowed_file_size() ) ); ?></small>
    138                                 </p>
    139                         </form>
    140                         <script>
    141                                 ( function ( $ ) {
    142                                         var $label    = $( 'label.button' ),
    143                                                 labelText = $label.text();
     136                                        <input id="upload_button" class="button button-primary" type="submit" value="<?php esc_attr_e( 'Upload', 'wporg-plugins' ); ?>"/>
    144137
    145                                         $( '#zip_file' )
    146                                                 .on( 'change', function( event ) {
    147                                                         var fileName = event.target.value.split( '\\' ).pop();
     138                                        <p>
     139                                                <small><?php printf( __( 'Maximum allowed file size: %s', 'wporg-plugins' ), esc_html( self::get_max_allowed_file_size() ) ); ?></small>
     140                                        </p>
     141                                </form>
     142                                <script>
     143                                        ( function ( $ ) {
     144                                                var $label    = $( 'label.button' ),
     145                                                        labelText = $label.text();
    148146
    149                                                         fileName ? $label.text( fileName ) : $label.text( labelText );
    150                                                 } )
    151                                                 .on( 'focus', function() { $label.addClass( 'focus' ); } )
    152                                                 .on( 'blur', function() { $label.removeClass( 'focus' ); } );
    153                                 } ( window.jQuery ) );
    154                         </script>
     147                                                $( '#zip_file' )
     148                                                        .on( 'change', function( event ) {
     149                                                                var fileName = event.target.value.split( '\\' ).pop();
     150
     151                                                                fileName ? $label.text( fileName ) : $label.text( labelText );
     152                                                        } )
     153                                                        .on( 'focus', function() { $label.addClass( 'focus' ); } )
     154                                                        .on( 'blur', function() { $label.removeClass( 'focus' ); } );
     155                                        } ( window.jQuery ) );
     156                                </script>
     157
     158                        <?php endif; // ! $submitted_counts->total ?>
    155159
    156160                <?php else : ?>
     
    158162                        <p><?php printf( __( 'Before you can upload a new plugin, <a href="%s">please log in</a>.', 'wporg-plugins' ), esc_url( 'https://login.wordpress.org/' ) ); ?></p>
    159163
    160                 <?php endif;
     164                <?php endif; // is_user_logged_in()
    161165
    162166                return ob_get_clean();
Note: See TracChangeset for help on using the changeset viewer.