Changeset 12140
- Timestamp:
- 10/20/2022 05:10:00 PM (2 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/moderation.php
r12107 r12140 560 560 $content .= '<p>'; 561 561 $content .= sprintf( 562 _n( 'You can have up to <strong>%d</strong> photo in the moderation queue at a time. You currently have <strong>%d</strong>.', 'You can have up to <strong>%d</strong> photos in the moderation queue at a time. You currently have <strong>%d</strong>.', U ploads::MAX_PENDING_SUBMISSIONS,'wporg-photos' ),563 U ploads::MAX_PENDING_SUBMISSIONS,562 _n( 'You can have up to <strong>%d</strong> photo in the moderation queue at a time. You currently have <strong>%d</strong>.', 'You can have up to <strong>%d</strong> photos in the moderation queue at a time. You currently have <strong>%d</strong>.', User::MAX_PENDING_SUBMISSIONS,'wporg-photos' ), 563 User::MAX_PENDING_SUBMISSIONS, 564 564 count( $pending ) 565 565 ); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/uploads.php
r12110 r12140 16 16 */ 17 17 const MAX_LENGTH_DESCRIPTION = 250; 18 19 /**20 * Maximum number of pending/concurrent submissions.21 *22 * Once this threshold is met, a user will be unable to make another23 * submission until the current submission is approved or rejected.24 *25 * @var int26 */27 const MAX_PENDING_SUBMISSIONS = 5;28 18 29 19 /** … … 525 515 // Check if user has reached submission limit. 526 516 if ( $can ) { 527 $can = ! self::user_reached_concurrent_submission_limit();517 $can = ! User::has_reached_concurrent_submission_limit(); 528 518 $reason = 'concurrent-submission-limit'; 529 519 } … … 849 839 850 840 /** 851 * Determines if user has reached concurrent submission limit for pending852 * uploads (e.g. max number of photos awaiting moderation).853 *854 * @return bool True if use has exceeded pending sumission limit, else false.855 */856 public static function user_reached_concurrent_submission_limit() {857 $limit_reached = true;858 859 if ( is_user_logged_in() ) {860 $posts = get_posts( [861 'fields' => 'ids',862 'posts_per_page' => self::MAX_PENDING_SUBMISSIONS,863 'author' => get_current_user_id(),864 'post_status' => 'pending',865 'post_type' => Registrations::get_post_type(),866 ] );867 868 if ( count( $posts ) < self::MAX_PENDING_SUBMISSIONS ) {869 $limit_reached = false;870 }871 }872 873 return $limit_reached;874 }875 876 877 /**878 841 * Outputs a notice for users who are prevented from uploading and prevents 879 842 * the upload form from being output. … … 914 877 ); 915 878 916 if ( self::user_reached_concurrent_submission_limit() ) {879 if ( User::has_reached_concurrent_submission_limit() ) { 917 880 $content .= '<p>' . __( 'Thanks for your submissions! Please wait until a photo is approved by moderators before submitting again.', 'wporg-photos' ) . '</p>'; 918 881 } else { -
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/user.php
r12110 r12140 129 129 } 130 130 131 /** 132 * Determines if user has reached concurrent submission limit for pending 133 * uploads (e.g. max number of photos awaiting moderation). 134 * 135 * @param int $user_id Optional. The user ID. If not defined, assumes current 136 * user. Default false. 137 * @return bool True if user has exceeded pending sumission limit, else false. 138 */ 139 public static function has_reached_concurrent_submission_limit( $user_id = false ) { 140 $limit_reached = true; 141 142 if ( ! $user_id ) { 143 $user_id = get_current_user_id(); 144 } 145 146 if ( $user_id ) { 147 $posts = get_posts( [ 148 'fields' => 'ids', 149 'posts_per_page' => self::MAX_PENDING_SUBMISSIONS, 150 'author' => $user_id, 151 'post_status' => 'pending', 152 'post_type' => Registrations::get_post_type(), 153 ] ); 154 155 if ( count( $posts ) < self::MAX_PENDING_SUBMISSIONS ) { 156 $limit_reached = false; 157 } 158 } 159 160 return $limit_reached; 161 } 162 131 163 } 132 164
Note: See TracChangeset
for help on using the changeset viewer.