Changeset 13784
- Timestamp:
- 06/07/2024 04:40:29 AM (9 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/user.php
r12889 r13784 118 118 * Returns a count of rejected photos for a user. 119 119 * 120 * @param int $user_id Optional. The user ID. If not defined, assumes global 121 * author. Default false. 122 * @return int 123 */ 124 public static function count_rejected_photos( $user_id = false ) { 120 * @param int $user_id Optional. The user ID. If not defined, 121 * assumes global author. Default false. 122 * @param bool $exclude_submission_errors Optional. Should photos rejected due 123 * to the 'submission-error' reason be 124 * excluded from the count? Default true. 125 * @return int 126 */ 127 public static function count_rejected_photos( $user_id = false, $exclude_submission_errors = true ) { 125 128 global $wpdb; 126 129 127 if ( 130 if ( ! $user_id ) { 128 131 global $authordata; 129 132 … … 135 138 } 136 139 137 return (int) $wpdb->get_var( $wpdb->prepare( 138 "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = %s AND post_status = %s AND post_author = %d", 139 Registrations::get_post_type(), 140 Rejection::get_post_status(), 141 $user_id 142 ) ); 140 $args = [ 141 'post_type' => Registrations::get_post_type(), 142 'post_status' => Rejection::get_post_status(), 143 'author' => $user_id, 144 'fields' => 'ids', 145 'posts_per_page' => -1, 146 ]; 147 148 if ( $exclude_submission_errors ) { 149 $args['meta_query'] = [ 150 [ 151 'key' => 'rejected_reason', 152 'value' => 'submission-error', 153 'compare' => '!=', 154 ], 155 ]; 156 } 157 158 $query = new \WP_Query( $args ); 159 return $query->found_posts; 143 160 } 144 161
Note: See TracChangeset
for help on using the changeset viewer.