Changeset 14723
- Timestamp:
- 03/17/2026 01:52:57 PM (12 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload.php
r14717 r14723 2 2 namespace WordPressdotorg\Plugin_Directory\Shortcodes; 3 3 use WordPressdotorg\Plugin_Directory\Template; 4 use Two_Factor_Core; 5 use function WordPressdotorg\Two_Factor\{ user_requires_2fa, get_onboarding_account_url }; 4 use function WordPressdotorg\Two_Factor\get_onboarding_account_url; 6 5 7 6 class Upload { … … 63 62 } 64 63 65 // Require 2FA for plugin authors on upload. 66 if ( 67 function_exists( 'WordPressdotorg\Two_Factor\user_requires_2fa' ) && 68 class_exists( 'Two_Factor_Core' ) && 69 user_requires_2fa( wp_get_current_user() ) && 70 ! Two_Factor_Core::is_user_using_two_factor( get_current_user_id() ) 71 ) { 64 // Check 2FA before proceeding. 65 $preconditions = Upload_Handler::accepting_uploads(); 66 if ( is_wp_error( $preconditions ) && '2fa_required' === $preconditions->get_error_code() ) { 72 67 return '<div class="notice notice-error notice-alt"><p>' . sprintf( 73 68 /* translators: Setup 2FA url */ 74 69 __( 'Before you can upload a new plugin, <a href="%s">please enable two-factor authentication</a>.', 'wporg-plugins' ), 75 esc_url( get_onboarding_account_url())70 esc_url( function_exists( 'WordPressdotorg\Two_Factor\get_onboarding_account_url' ) ? get_onboarding_account_url() : 'https://profiles.wordpress.org/me/profile/security' ) 76 71 ) . '</p></div>'; 77 72 } … … 84 79 $upload_result = false; 85 80 86 /*87 * Determine the maximum number of plugins a user can have in the queue.88 *89 * Plugin owners with more than 1m active installs can have up to 10 plugins in the queue.90 *91 * @see https://meta.trac.wordpress.org/ticket/7664192 */93 $maximum_plugins_in_queue = 1;94 $user_active_installs = array_sum(95 wp_list_pluck(96 get_posts( [97 'author' => get_current_user_id(),98 'post_type' => 'plugin',99 'post_status' => 'publish', // Only count published plugins.100 'numberposts' => -1101 ] ),102 '_active_installs'103 )104 );105 if ( $user_active_installs > 1000000 /* 1m+ */ ) {106 $maximum_plugins_in_queue = 10;107 }108 109 81 list( $submitted_plugins, $submitted_counts ) = self::get_submitted_plugins(); 110 $can_submit_new_plugin = $submitted_counts->total < $maximum_plugins_in_queue;82 $can_submit_new_plugin = ! is_wp_error( $preconditions ); 111 83 112 84 if ( … … 139 111 // Refresh the lists. 140 112 list( $submitted_plugins, $submitted_counts ) = self::get_submitted_plugins(); 141 $can_submit_new_plugin = $submitted_counts->total < $maximum_plugins_in_queue;113 $can_submit_new_plugin = ! is_wp_error( Upload_Handler::has_queue_capacity() ); 142 114 143 115 if ( ! empty( $message ) ) { … … 388 360 <?php endif; // ! is_wp_error( $upload_result ) 389 361 390 if ( defined( 'WPORG_ON_HOLIDAY' ) && WPORG_ON_HOLIDAY) {362 if ( is_wp_error( $preconditions ) && 'submissions_paused' === $preconditions->get_error_code() ) { 391 363 printf( 392 364 '<div class="notice notice-error notice-alt"><p>%s</p></div>', … … 396 368 ) 397 369 ); 398 } else if ( function_exists( 'is_email_address_unsafe' ) /* multisite-only */ && is_email_address_unsafe( wp_get_current_user()->user_email) ) {370 } else if ( is_wp_error( $preconditions ) && 'unsafe_email' === $preconditions->get_error_code() ) { 399 371 echo '<div class="notice notice-error notice-alt"><p>' . 400 372 sprintf( … … 406 378 407 379 } else if ( $can_submit_new_plugin && ( ! $upload_result || is_wp_error( $upload_result ) ) ) : 408 if ( $maximum_plugins_in_queue > 1 && $submitted_counts->total ) {409 printf(410 '<div class="notice notice-info notice-alt"><p>%s</p></div>',411 sprintf(412 /* translators: %s: Maximum number of plugins in the queue. */413 __( 'You can have up to %s plugins in the queue at a time. You may submit an additional plugin for review below.', 'wporg-plugins' ),414 '<strong>' . number_format_i18n( $maximum_plugins_in_queue ) . '</strong>'415 )416 );417 }418 380 419 381 ?>
Note: See TracChangeset
for help on using the changeset viewer.