Making WordPress.org

Changeset 14183


Ignore:
Timestamp:
11/20/2024 09:31:05 PM (7 weeks ago)
Author:
coffee2code
Message:

Photo Directory, User: Adapt count_published_photos_for_today() into count_photos_for_today() which can accommodate any post status(es).

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc
Files:
2 edited

Legend:

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

    r14067 r14183  
    828828
    829829        // Show number of photos approved on this calendar day.
    830         $approved_today_count = User::count_published_photos_for_today();
     830        $approved_today_count = User::count_photos_for_today( 'publish' );
    831831        if ( $approved_today_count ) {
    832832            $approved_today_link = add_query_arg( [
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/user.php

    r13790 r14183  
    7676
    7777    /**
    78      * Returns a count of photos published by a user on this calendar day.
    79      *
    80      * @param int $user_id Optional. The user ID. If not defined, assumes global
    81      *                     author. Default false.
    82      * @return int
    83      */
    84     public static function count_published_photos_for_today( $user_id = false ) {
     78     * Returns a count of photos of a given post status(es) by a user on this calendar day.
     79     *
     80     * @param string|string[] $post_status Optional. The post status(es) of photos to find.
     81     *                                     Default 'publish'.
     82     * @param int             $user_id     Optional. The user ID. If not defined, assumes
     83     *                                     global author. Default false.
     84     * @return int
     85     */
     86    public static function count_photos_for_today( $post_status = 'publish', $user_id = false ) {
    8587        if (  ! $user_id ) {
    8688            global $authordata;
     
    99101        $args = [
    100102            'post_type'      => Registrations::get_post_type(),
    101             'post_status'    => 'publish',
     103            'post_status'    => $post_status,
    102104            'author'         => $user_id,
    103105            'date_query'     => [
Note: See TracChangeset for help on using the changeset viewer.