Making WordPress.org

Changeset 13790


Ignore:
Timestamp:
06/07/2024 05:29:29 AM (4 months ago)
Author:
coffee2code
Message:

Photo Directory, User: Increase concurrent submission limit to 10 for frequent contributors (those with 30+ published photos).

Props ChrisEdwardsCE, topher1kenobe, coffee2code.
Fixes #6524.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/user.php

    r13788 r13790  
    1111
    1212    /**
    13      * Maximum number of pending/concurrent submissions.
     13     * Maximum number of pending/concurrent submissions for infrequent contributors.
    1414     *
    1515     * Once this threshold is met, a user will be unable to make another
     
    2424
    2525    /**
    26      * The number of published posts before a given user is permitted to toggle
    27      * all of the confirmation checkboxes when submitting a photo.
    28      *
     26     * Maximum number of pending/concurrent submissions for frequent contributors.
     27     *
     28     * Once this threshold is met, a user will be unable to make another
     29     * submission until a current submission is approved or rejected.
     30     *
     31     * @see `get_concurrent_submission_limit()` for actually retrieving the maximum
     32     * pending submissions for a user, since it can vary based on the user and may
     33     * be filtered.
    2934     * @var int
    3035     */
     36    const MAX_PENDING_SUBMISSIONS_FREQUENT = 10;
     37
     38    /**
     39     * The number of published photos before a given user is granted additional
     40     * privileges.
     41     *
     42     * Includes, but not necessarily limited to:
     43     * - Increased pending submissions limit.
     44     * - Ability to toggle all of the confirmation checkboxes when submitting a photo.
     45     *
     46     * @var int
     47     */
    3148    const TOGGLE_ALL_THRESHOLD = 30;
    3249
     50    /**
     51     * Initializes class.
     52     */
    3353    public static function init() {
    3454    }
     
    344364
    345365    /**
     366     * Determines if a user is considered a frequent contributor.
     367     *
     368     * @param int $user_id Optional. The user ID. If not defined, assumes current
     369     *                     user. Default false.
     370     * @return bool True if user is considered a frequent contributor, else false.
     371     */
     372    public static function is_frequent_contributor( $user_id = false ) {
     373        $is_frequent = false;
     374
     375        if ( ! $user_id ) {
     376            $user_id = get_current_user_id();
     377        }
     378
     379        if ( $user_id && self::count_published_photos( $user_id ) >= self::TOGGLE_ALL_THRESHOLD ) {
     380            $is_frequent = true;
     381        }
     382
     383        return $is_frequent;
     384    }
     385
     386    /**
    346387     * Determines if a user is eligible to toggle all confirmation checkboxes on
    347388     * the photo upload form.
     
    362403     */
    363404    public static function can_toggle_confirmation_checkboxes( $user_id = false ) {
    364         $can = false;
    365 
    366         if ( ! $user_id ) {
    367             $user_id = get_current_user_id();
    368         }
    369 
    370         if ( $user_id && self::count_published_photos( $user_id ) >= self::TOGGLE_ALL_THRESHOLD ) {
    371             $can = true;
    372         }
    373 
    374         return $can;
     405        return self::is_frequent_contributor( $user_id );
    375406    }
    376407
     
    391422        }
    392423
    393         return apply_filters( 'wporg_photos_max_concurrent_submissions', self::MAX_PENDING_SUBMISSIONS, $user_id );
     424        $limit = self::is_frequent_contributor( $user_id )
     425            ? self::MAX_PENDING_SUBMISSIONS_FREQUENT
     426            : self::MAX_PENDING_SUBMISSIONS;
     427
     428        return apply_filters( 'wporg_photos_max_concurrent_submissions', $limit, $user_id );
    394429    }
    395430
Note: See TracChangeset for help on using the changeset viewer.