| 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 ( 'draft', '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 | /** |
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->draft + $plugins->pending ), 'wporg-plugins' ), |
35 | | '<strong>' . ( $plugins->draft + $plugins->pending ) . '</strong>', |
36 | | '<strong>' . $plugins->draft . '</strong>' |
37 | | ); |
| 49 | if ( 1 === ( $plugins->draft + $plugins->pending ) ) { |
| 50 | _e( 'Currently there is 1 plugin in the review queue.', 'wporg-plugins' ); |
| 51 | } else { |
| 52 | printf( |
| 53 | _n( |
| 54 | 'Currently there are %1$s plugins in the review queue, %2$s of which is awaiting its initial review.', |
| 55 | 'Currently there are %1$s plugins in the review queue, %2$s of which are awaiting their initial review.', |
| 56 | $plugins->draft, |
| 57 | 'wporg-plugins' |
| 58 | ), |
| 59 | '<strong>' . ( $plugins->draft + $plugins->pending ) . '</strong>', |
| 60 | '<strong>' . $plugins->draft . '</strong>' |
| 61 | ); |
| 62 | } |
42 | | if ( '/plugins-wp' === parse_url( home_url(), PHP_URL_PATH ) ) { |
43 | | echo '<div class="notice notice-error notice-alt"> |
44 | | <p>Please submit all new plugin requests through the existing form <a href="https://wordpress.org/plugins/add/">available here</a>, You\'re currently viewing the beta version of the upcoming plugin directory, and this form is only for testing purposes.</p> |
45 | | </div>'; |
| 68 | $submitted_plugins = self::get_submitted_plugins(); |
| 69 | $submitted_counts = (object) array_fill_keys( array( 'draft', 'pending' ), 0 ); |
| 70 | |
| 71 | foreach ( $submitted_plugins as $key => $plugin ) { |
| 72 | if ( 'draft' === $plugin->post_status ) { |
| 73 | $submitted_plugins[ $key ]->status = __( 'Awaiting Review', 'wporg-plugins' ); |
| 74 | $submitted_counts->draft++; |
| 75 | } elseif ( 'pending' === $plugin->post_status ) { |
| 76 | $submitted_plugins[ $key ]->status = __( 'Being Reviewed', 'wporg-plugins' ); |
| 77 | $submitted_counts->pending++; |
| 78 | } |
| 82 | <?php if ( $submitted_counts->draft + $submitted_counts->pending ) : ?> |
| 83 | |
| 84 | <div class="plugin-queue-message notice notice-warning notice-alt"> |
| 85 | <p> |
| 86 | <?php |
| 87 | if ( 1 === ( $submitted_counts->draft + $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->draft + $submitted_counts->pending ) . '</strong>', |
| 98 | '<strong>' . $submitted_counts->pending . '</strong>' |
| 99 | ); |
| 100 | } |
| 101 | ?> |
| 102 | </p> |
| 103 | <ul> |
| 104 | <?php |
| 105 | foreach ( $submitted_plugins as $plugin ) { |
| 106 | echo '<li>' . esc_html( $plugin->post_title ) . ' — ' . $plugin->status . '</li>'; |
| 107 | } |
| 108 | ?> |
| 109 | </ul> |
| 110 | <p><?php |
| 111 | /* translators: %s: plugins@wordpress.org */ |
| 112 | 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' ), |
| 113 | 'plugins@wordpress.org' |
| 114 | ); |
| 115 | ?></p> |
| 116 | </div> |
| 117 | |
| 118 | <?php endif; ?> |
| 119 | |