Changeset 12057
- Timestamp:
- 09/08/2022 08:21:21 PM (2 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/admin.php
r11715 r12057 54 54 // Modify admin menu links for photo posts. 55 55 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 int63 */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_id72 ) );73 56 } 74 57 … … 533 516 . sprintf( 534 517 __( '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() ) 536 519 ) 537 520 . "</div>\n"; 538 521 539 522 // Show number of pending photos if there are any. 540 $pending_count = Photo::count_user_pending_photos();523 $pending_count = User::count_pending_photos(); 541 524 if ( $pending_count ) { 542 525 $pending_link = add_query_arg( [ … … 763 746 764 747 $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 ); 766 749 $account_created = explode( ' ', $author->user_registered )[0]; 767 750 ?> … … 801 784 ?></li> 802 785 <li><?php 803 $rejected_count = self::count_user_rejections( $author->ID );786 $rejected_count = User::count_rejected_photos( $author->ID ); 804 787 $link_args = [ 805 788 'post_type' => Registrations::get_post_type(), … … 816 799 ?></li> 817 800 <li><?php 818 $pending_count = Photo::count_user_pending_photos( $author->ID );801 $pending_count = User::count_pending_photos( $author->ID ); 819 802 $link_args = [ 820 803 'post_type' => Registrations::get_post_type(), -
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/badges.php
r11880 r12057 36 36 } elseif ( 'publish' === $old_status && 'publish' !== $new_status ) { 37 37 // If the user now has no published Photos, remove the badge. 38 if ( ! Photo::count_user_published_photos( $post->post_author ) ) {38 if ( ! User::count_published_photos( $post->post_author ) ) { 39 39 remove_badge( 'photo-contributor', $post->post_author ); 40 40 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/moderation.php
r11679 r12057 463 463 464 464 // Flag if this is user's first submission. 465 $published_photos_count = Photo::count_user_published_photos( $post->post_author );465 $published_photos_count = User::count_published_photos( $post->post_author ); 466 466 if ( ! $published_photos_count ) { 467 467 $flags[ 'no published photo' ] = 'possible'; -
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/photo.php
r11757 r12057 424 424 425 425 /** 426 * Returns a count of published photos for a user.427 *428 * @param int $user_id Optional. The user ID. If not defined, assumes global429 * author. Default false.430 * @return int431 */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 global446 * author. Default false.447 * @return int448 */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 /**468 426 * Returns the full photo analysis data from cache or via API call. 469 427 * -
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/photo-directory.php
r11879 r12057 28 28 require_once __DIR__ . '/inc/template-tags.php'; 29 29 require_once __DIR__ . '/inc/uploads.php'; 30 require_once __DIR__ . '/inc/user.php'; 30 31 require_once __DIR__ . '/inc/google-cloud-storage-stream-metadata.php'; 31 32 require_once __DIR__ . '/inc/google-cloud-storage.php';
Note: See TracChangeset
for help on using the changeset viewer.