Making WordPress.org

Ticket #2594: 2594.2.patch

File 2594.2.patch, 4.2 KB (added by SergeyBiryukov, 6 years ago)

Refreshed after [5318]

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

     
    44class Upload {
    55
    66        /**
     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                global $wpdb;
     13
     14                $query = "SELECT post_title, post_status FROM {$wpdb->posts} WHERE post_type = 'plugin'";
     15                $query .= $wpdb->prepare( " AND post_status IN ( 'new', 'pending' ) AND post_author = %d", get_current_user_id() );
     16                $query .= ' ORDER BY post_title';
     17
     18                return $wpdb->get_results( $query );
     19        }
     20
     21        /**
    722         * Renders the upload shortcode.
    823         */
    924        public static function display() {
     
    2944                                ?>
    3045
    3146                                <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>
     47                                        <p><?php
     48                                                if ( 1 === ( $plugins->new + $plugins->pending ) ) {
     49                                                         _e( 'Currently there is 1 plugin in the review queue.', 'wporg-plugins' );
     50                                                } else {
     51                                                        printf(
     52                                                                _n(
     53                                                                        'Currently there are %1$s plugins in the review queue, %2$s of which is awaiting its initial review.',
     54                                                                        'Currently there are %1$s plugins in the review queue, %2$s of which are awaiting their initial review.',
     55                                                                        $plugins->new,
     56                                                                        'wporg-plugins'
     57                                                                ),
     58                                                                '<strong>' . ( $plugins->new + $plugins->pending ) . '</strong>',
     59                                                                '<strong>' . $plugins->new . '</strong>'
     60                                                        );
     61                                                }
     62                                        ?></p>
    4063                                </div>
    4164
     65                                <?php
     66                                $submitted_plugins = self::get_submitted_plugins();
     67                                $submitted_counts  = (object) array_fill_keys( array( 'new', 'pending' ), 0 );
     68
     69                                foreach ( $submitted_plugins as $key => $plugin ) {
     70                                        if ( 'new' === $plugin->post_status ) {
     71                                                $submitted_plugins[ $key ]->status = __( 'Awaiting Review', 'wporg-plugins' );
     72                                                $submitted_counts->new++;
     73                                        } elseif ( 'pending' === $plugin->post_status ) {
     74                                                $submitted_plugins[ $key ]->status = __( 'Being Reviewed', 'wporg-plugins' );
     75                                                $submitted_counts->pending++;
     76                                        }
     77                                }
     78                                ?>
     79
     80                                <?php if ( $submitted_counts->new + $submitted_counts->pending ) : ?>
     81
     82                                        <div class="plugin-queue-message notice notice-warning notice-alt">
     83                                                <p><?php
     84                                                        if ( 1 === ( $submitted_counts->new + $submitted_counts->pending ) ) {
     85                                                                _e( 'You have 1 plugin in the review queue.', 'wporg-plugins' );
     86                                                        } else {
     87                                                                printf(
     88                                                                        _n(
     89                                                                                'You have %1$s plugins in the review queue, %2$s is being actively reviewed.',
     90                                                                                'You have %1$s plugins in the review queue, %2$s are being actively reviewed.',
     91                                                                                $submitted_counts->pending,
     92                                                                                'wporg-plugins'
     93                                                                        ),
     94                                                                        '<strong>' . ( $submitted_counts->new + $submitted_counts->pending ) . '</strong>',
     95                                                                        '<strong>' . $submitted_counts->pending . '</strong>'
     96                                                                );
     97                                                        }
     98                                                ?></p>
     99
     100                                                <ul><?php
     101                                                        foreach ( $submitted_plugins as $plugin ) {
     102                                                                echo '<li>' . esc_html( $plugin->post_title ) . ' &#8212; ' . $plugin->status . '</li>';
     103                                                        }
     104                                                ?></ul>
     105
     106                                                <p><?php
     107                                                        /* translators: %s: plugins@wordpress.org */
     108                                                        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' ),
     109                                                                'plugins@wordpress.org'
     110                                                        );
     111                                                ?></p>
     112                                        </div>
     113
     114                                <?php endif; ?>
     115
    42116                        <?php endif; ?>
    43117
    44118                        <form id="upload_form" class="plugin-upload-form" enctype="multipart/form-data" method="POST" action="">