Making WordPress.org


Ignore:
Timestamp:
09/08/2022 08:21:21 PM (2 years ago)
Author:
coffee2code
Message:

Photo Directory, User: Start to centralize user-related functions into the same include file.

  • Moves Admin::count_user_rejections() to count_rejected()
  • Moves Photos::count_user_published_photos() to count_published_photos()
  • Moves Photos::count_user_pending_photos() to count_pending_photos()
File:
1 edited

Legend:

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

    r11757 r12057  
    424424
    425425    /**
    426      * Returns a count of published photos for a user.
    427      *
    428      * @param int $user_id Optional. The user ID. If not defined, assumes global
    429      *                     author. Default false.
    430      * @return int
    431      */
    432     public static function count_user_published_photos( $user_id = false ) {
    433         if (  ! $user_id ) {
    434             global $authordata;
    435 
    436             $user_id = $authordata->ID;
    437         }
    438 
    439         return count_user_posts( $user_id, Registrations::get_post_type(), true );
    440     }
    441 
    442     /**
    443      * Returns a count of pending photos for a user.
    444      *
    445      * @param int $user_id Optional. The user ID. If not defined, assumes global
    446      *                     author. Default false.
    447      * @return int
    448      */
    449     public static function count_user_pending_photos( $user_id = false ) {
    450         if (  ! $user_id ) {
    451             global $authordata;
    452 
    453             $user_id = $authordata->ID;
    454         }
    455 
    456         $pending = get_posts( [
    457             'fields'         => 'ids',
    458             'posts_per_page' => -1,
    459             'author'         => $user_id,
    460             'post_status'    => 'pending',
    461             'post_type'      => Registrations::get_post_type(),
    462         ] );
    463 
    464         return count( $pending );
    465     }
    466 
    467     /**
    468426     * Returns the full photo analysis data from cache or via API call.
    469427     *
Note: See TracChangeset for help on using the changeset viewer.