Making WordPress.org


Ignore:
Timestamp:
06/04/2024 02:10:08 AM (8 months ago)
Author:
dd32
Message:

Plugin Directory: Upload: Allow plugin authors with 1m+ installs to have multiple plugins in queue.

See #7664.

File:
1 edited

Legend:

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

    r13747 r13769  
    6363        $upload_result = false;
    6464
     65        /*
     66         * Determine the maximum number of plugins a user can have in the queue.
     67         *
     68         * Plugin owners with more than 1m active installs can have up to 10 plugins in the queue.
     69         *
     70         * @see https://meta.trac.wordpress.org/ticket/76641
     71         */
     72        $maximum_plugins_in_queue = 1;
     73        $user_active_installs     = array_sum(
     74            wp_list_pluck(
     75                get_posts( [
     76                    'author'      => get_current_user_id(),
     77                    'post_type'   => 'plugin',
     78                    'post_status' => 'publish', // Only count published plugins.
     79                    'numberposts' => -1
     80                ] ),
     81                '_active_installs'
     82            )
     83        );
     84        if ( $user_active_installs > 1000000 /* 1m+ */ ) {
     85            $maximum_plugins_in_queue = 10;
     86        }
     87
    6588        list( $submitted_plugins, $submitted_counts ) = self::get_submitted_plugins();
     89        $can_submit_new_plugin                        = $submitted_counts->total < $maximum_plugins_in_queue;
    6690
    6791        if (
     
    7094            (
    7195                // New submission.
    72                 ! $submitted_counts->total &&
    7396                empty( $_POST['plugin_id'] ) &&
    74                 wp_verify_nonce( $_POST['_wpnonce'], 'wporg-plugins-upload' ) &&
    75                 'upload' === $_POST['action']
     97                'upload' === $_POST['action'] &&
     98                $can_submit_new_plugin &&
     99                wp_verify_nonce( $_POST['_wpnonce'], 'wporg-plugins-upload' )
    76100            ) || (
    77101                // Existing submission
     
    94118            // Refresh the lists.
    95119            list( $submitted_plugins, $submitted_counts ) = self::get_submitted_plugins();
     120            $can_submit_new_plugin                        = $submitted_counts->total < $maximum_plugins_in_queue;
    96121
    97122            if ( ! empty( $message ) ) {
     
    100125        }
    101126
    102         if ( ! is_wp_error( $upload_result ) || $submitted_counts->total ) :
     127        if ( ! is_wp_error( $upload_result ) || $submitted_counts->total /* has a plugin in the review queue */ ) :
    103128            $plugins       = wp_count_posts( 'plugin', 'readable' );
    104129            $oldest_plugin = get_posts( [ 'post_type' => 'plugin', 'post_status' => 'new', 'order' => 'ASC', 'orderby' => 'post_date_gmt', 'numberposts' => 1 ] );
     
    359384                    "</p></div>\n";
    360385
    361         } else if ( ! $submitted_counts->total && ( ! $upload_result || is_wp_error( $upload_result ) ) ) : ?>
     386        } else if ( $can_submit_new_plugin && ( ! $upload_result || is_wp_error( $upload_result ) ) ) :
     387            if ( $maximum_plugins_in_queue > 1 && $submitted_counts->total ) {
     388                printf(
     389                    '<div class="notice notice-info notice-alt"><p>%s</p></div>',
     390                    sprintf(
     391                        /* translators: %s: Maximum number of plugins in the queue. */
     392                        __( 'You can have up to %s plugins in the queue at a time. You may submit an additional plugin for review below.', 'wporg-plugins' ),
     393                        '<strong>' . number_format_i18n( $maximum_plugins_in_queue ) . '</strong>'
     394                    )
     395                );
     396            }
     397
     398            ?>
    362399            <form id="upload_form" class="plugin-upload-form" enctype="multipart/form-data" method="POST" action="">
    363400                <?php wp_nonce_field( 'wporg-plugins-upload' ); ?>
     
    461498                <input id="upload_button" class="wp-block-button__link" type="submit" value="<?php esc_attr_e( 'Upload', 'wporg-plugins' ); ?>"/>
    462499            </form>
    463         <?php endif; // ! $submitted_counts->total
     500        <?php endif; // $can_submit_new_plugin
    464501
    465502        return ob_get_clean();
Note: See TracChangeset for help on using the changeset viewer.