Making WordPress.org


Ignore:
Timestamp:
09/08/2022 08:21:21 PM (23 months 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/admin.php

    r11715 r12057  
    5454        // Modify admin menu links for photo posts.
    5555        add_action( 'admin_menu',                              [ __CLASS__, 'modify_admin_menu_links' ] );
    56     }
    57 
    58     /**
    59      * Returns the count of the number of photo submissions from a user that were rejected.
    60      *
    61      * @param int $user_id The user ID.
    62      * @return int
    63      */
    64     public static function count_user_rejections( $user_id ) {
    65         global $wpdb;
    66 
    67         return (int) $wpdb->get_var( $wpdb->prepare(
    68             "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = %s AND post_status = %s AND post_author = %d",
    69             Registrations::get_post_type(),
    70             Rejection::get_post_status(),
    71             $user_id
    72         ) );
    7356    }
    7457
     
    533516        . sprintf(
    534517            __( 'Approved: <strong>%s</strong>', 'wporg-photos' ),
    535             sprintf( '<a href="%s">%d</a>', $approved_link, Photo::count_user_published_photos() )
     518            sprintf( '<a href="%s">%d</a>', $approved_link, User::count_published_photos() )
    536519        )
    537520        . "</div>\n";
    538521
    539522        // Show number of pending photos if there are any.
    540         $pending_count = Photo::count_user_pending_photos();
     523        $pending_count = User::count_pending_photos();
    541524        if ( $pending_count ) {
    542525            $pending_link = add_query_arg( [
     
    763746
    764747        $author = get_user_by( 'id', $post->post_author );
    765         $photos_count = Photo::count_user_published_photos( $author->ID );
     748        $photos_count = User::count_published_photos( $author->ID );
    766749        $account_created = explode( ' ', $author->user_registered )[0];
    767750        ?>
     
    801784                    ?></li>
    802785                    <li><?php
    803                         $rejected_count = self::count_user_rejections( $author->ID );
     786                        $rejected_count = User::count_rejected_photos( $author->ID );
    804787                        $link_args = [
    805788                            'post_type'   => Registrations::get_post_type(),
     
    816799                    ?></li>
    817800                    <li><?php
    818                         $pending_count = Photo::count_user_pending_photos( $author->ID );
     801                        $pending_count = User::count_pending_photos( $author->ID );
    819802                        $link_args = [
    820803                            'post_type'   => Registrations::get_post_type(),
Note: See TracChangeset for help on using the changeset viewer.