Making WordPress.org

Changeset 5511


Ignore:
Timestamp:
05/24/2017 10:41:12 PM (9 years ago)
Author:
tellyworth
Message:

Plugin directory: list author's pending plugins on Add page, to reduce duplicate uploads.

Fixes #2594

File:
1 edited

Legend:

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

    r5318 r5511  
    33
    44class Upload {
     5
     6        /**
     7         * Retrieves plugins in the queue submitted by the current user.
     8         *
     9         * @return array An array of user's plugins.
     10         */
     11        public static function get_submitted_plugins() {
     12                $plugins = get_posts( array(
     13                        'post_type'      => 'plugin',
     14                        'post_status'    => array( 'new', 'pending' ),
     15                        'author'         => get_current_user_id(),
     16                        'orderby'        => 'title',
     17                        'order'          => 'ASC',
     18                        'posts_per_page' => -1,
     19                ) );
     20
     21                return $plugins;
     22        }
    523
    624        /**
     
    3048
    3149                                <div class="plugin-queue-message notice notice-info notice-alt">
    32                                         <p>
    33                                                 <?php
    34                                                 printf( _n( 'Currently there is %1$s plugin in the review queue.', 'Currently there are %1$s plugins in the review queue, %2$s of which are awaiting their initial review.', ( $plugins->new + $plugins->pending ), 'wporg-plugins' ),
    35                                                         '<strong>' . ( $plugins->new + $plugins->pending ) . '</strong>',
    36                                                         '<strong>' . $plugins->new . '</strong>'
    37                                                 );
    38                                                 ?>
    39                                         </p>
     50                                        <p><?php
     51                                                if ( 1 === ( $plugins->new + $plugins->pending ) ) {
     52                                                         _e( 'Currently there is 1 plugin in the review queue.', 'wporg-plugins' );
     53                                                } else {
     54                                                        printf(
     55                                                                _n(
     56                                                                        'Currently there are %1$s plugins in the review queue, %2$s of which is awaiting its initial review.',
     57                                                                        'Currently there are %1$s plugins in the review queue, %2$s of which are awaiting their initial review.',
     58                                                                        $plugins->new,
     59                                                                        'wporg-plugins'
     60                                                                ),
     61                                                                '<strong>' . ( $plugins->new + $plugins->pending ) . '</strong>',
     62                                                                '<strong>' . $plugins->new . '</strong>'
     63                                                        );
     64                                                }
     65                                        ?></p>
    4066                                </div>
     67
     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 ) : ?>
     84
     85                                        <div class="plugin-queue-message notice notice-warning notice-alt">
     86                                                <p><?php
     87                                                        if ( 1 === ( $submitted_counts->new + $submitted_counts->pending ) ) {
     88                                                                _e( 'You have 1 plugin in the review queue.', 'wporg-plugins' );
     89                                                        } else {
     90                                                                printf(
     91                                                                        _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.',
     94                                                                                $submitted_counts->pending,
     95                                                                                'wporg-plugins'
     96                                                                        ),
     97                                                                        '<strong>' . ( $submitted_counts->new + $submitted_counts->pending ) . '</strong>',
     98                                                                        '<strong>' . $submitted_counts->pending . '</strong>'
     99                                                                );
     100                                                        }
     101                                                ?></p>
     102
     103                                                <ul><?php
     104                                                        foreach ( $submitted_plugins as $plugin ) {
     105                                                                echo '<li>' . esc_html( $plugin->post_title ) . ' &#8212; ' . $plugin->status . "</li>\n";
     106                                                        }
     107                                                ?></ul>
     108
     109                                                <p><?php
     110                                                        /* translators: %s: plugins@wordpress.org */
     111                                                        printf( __( 'Please wait at least 7 business days before asking for an update status from <a href="mailto:%1$s">%1$s</a>.', 'wporg-plugins' ),
     112                                                                'plugins@wordpress.org'
     113                                                        );
     114                                                ?></p>
     115                                        </div>
     116
     117                                <?php endif; ?>
    41118
    42119                        <?php endif; ?>
Note: See TracChangeset for help on using the changeset viewer.