Changeset 12616 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-user-moderation/inc/class-plugin.php
- Timestamp:
- 06/02/2023 02:48:25 PM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-user-moderation/inc/class-plugin.php
r12012 r12616 25 25 // Meta key to store moderation date on flag/unflag actions. 26 26 const MODERATION_DATE_META = '_wporg_bbp_moderation_date'; 27 28 /** 29 * @var array Array of user id's and their most recent posting history. 30 */ 31 private $user_history = array(); 27 32 28 33 /** … … 341 346 return $caps; 342 347 } 348 349 /** 350 * Return recent posting history for a given user id. 351 * 352 * Returns the last archived post, and the number of pending and approved posts since the 353 * last archived posts original publication date. 354 * 355 * @param int $user_id User id to look up. 356 * @return array 357 */ 358 function get_user_posting_history( $user_id ) { 359 global $wpdb; 360 361 if ( ! isset( $this->user_history[ $user_id ] ) ) { 362 $details = [ 363 'posts_since_archive' => array(), 364 'pending_posts' => array(), 365 'last_archived_post' => get_posts( array( 366 'post_type' => [ 'topic', 'reply' ], 367 'posts_per_page' => 1, 368 'post_status' => 'archived', 369 'author' => $user_id, 370 ) ), 371 ]; 372 373 if ( $details['last_archived_post'] ) { 374 $details['posts_since_archive'] = $wpdb->get_var( $wpdb->prepare( 375 "SELECT COUNT(DISTINCT `ID`) FROM {$wpdb->posts} WHERE ( `post_type` = 'topic' OR `post_type` = 'reply') AND `post_status` = 'publish' AND `post_author` = %d AND `post_date_gmt` >= %s", 376 $user_id, 377 $details['last_archived_post'][0]->post_modified_gmt 378 ) ); 379 380 $details['pending_posts'] = $wpdb->get_var( $wpdb->prepare( 381 "SELECT COUNT(DISTINCT `ID`) FROM {$wpdb->posts} WHERE ( `post_type` = 'topic' OR `post_type` = 'reply') AND `post_status` = 'pending' AND `post_author` = %d", 382 $user_id 383 ) ); 384 } 385 386 $this->user_history[ $user_id ] = $details; 387 } 388 389 return $this->user_history[ $user_id ]; 390 } 343 391 }
Note: See TracChangeset
for help on using the changeset viewer.