Ticket #6809: 6809.patch
File 6809.patch, 6.1 KB (added by , 21 months ago) |
---|
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-user-moderation/inc/class-plugin.php
Subject: [PATCH] Support Forums: Show additional metadata for pending posts. Introduce additional details for reviewers looking at pending posts to help in providing swift assessment for unflagging users. This gives them a quick overview of how long it's been since the user had any content archived, how many approved posts they've had since then, and how much is currently still pending review. diff --git a/sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-user-moderation/inc/class-plugin.php b/sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-user-moderation/inc/class-plugin.php
a b 25 25 // Meta key to store moderation date on flag/unflag actions. 26 26 const MODERATION_DATE_META = '_wporg_bbp_moderation_date'; 27 27 28 /** 29 * @var array Array of user id's and their most recent posting history. 30 */ 31 private $user_history = array(); 32 28 33 /** 29 34 * Always return the same instance of this plugin. 30 35 * … … 340 345 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` >= %s", 376 $user_id, 377 $details['last_archived_post'][0]->post_date 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 AND `post_date` >= %s", 382 $user_id, 383 $details['last_archived_post'][0]->post_date 384 ) ); 385 } 386 387 $this->user_history[ $user_id ] = $details; 388 } 389 390 return $this->user_history[ $user_id ]; 391 } 343 392 } -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php
diff --git a/sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php b/sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php
a b 604 604 $moderator = get_user_meta( $post->post_author, $plugin_instance::MODERATOR_META, true ); 605 605 $moderation_date = get_user_meta( $post->post_author, $plugin_instance::MODERATION_DATE_META, true ); 606 606 607 // Include contextual information to pending entries, to help speed up unflagging events. 608 if ( 'pending' === $post->post_status ) { 609 $user_posting_history = $plugin_instance->get_user_posting_history( $post->post_author ); 610 611 if ( ! $user_posting_history['last_archived_post'] ) { 612 $notices[] = __( 'The user has no previously archived posts.' ,'wporg-forums' ); 613 } else { 614 // Get a DateTime object for when the last archived post was created. 615 $last_archive_time = get_post_datetime( $user_posting_history['last_archived_post'][0] ); 616 617 // Generate a differential time between the last archived post, and the current date and time. 618 $last_archive_elapsed = $last_archive_time->diff( new DateTime( 'now' ) ); 619 620 $lines = array( 621 sprintf( 622 // translators: %s: Time since the last archived post. 623 'The user last had content archived %s.', 624 sprintf( 625 '<span title="%s">%s</span>', 626 esc_attr( 627 sprintf( 628 // translators: %s: The original date and time when the users last archived post was. 629 __( 'Last archived post is from %s', 'wporg-forums' ), 630 $user_posting_history['last_archived_post'][0]->post_date 631 ) 632 ), 633 sprintf( 634 // translators: %d: Amount of days since the last archived post. 635 _n( 636 '%d day ago', 637 '%d days ago', 638 $last_archive_elapsed->format( '%d' ), 639 'wporg-forums' 640 ), 641 esc_html( $last_archive_elapsed->format( '%d' ) ) 642 ) 643 ) 644 ), 645 sprintf( 646 // translators: %d: The amount of approved posts since the last archived entry. 647 _n( 648 'The user has had %d approved post since their last archived content.', 649 'The user has had %d approved posts since their last archived content.', 650 absint( $user_posting_history['posts_since_archive'] ), 651 'wporg-forums' 652 ), 653 esc_html( $user_posting_history['posts_since_archive'] ) 654 ), 655 sprintf( 656 // translators: %d: The amount of approved posts since the last archived entry. 657 _n( 658 'The user has %d pending post at this time.', 659 'The user has %d pending posts at this time.', 660 absint( $user_posting_history['pending_posts'] ), 661 'wporg-forums' 662 ), 663 esc_html( $user_posting_history['pending_posts'] ) 664 ), 665 ); 666 667 $notices[] = implode( '<br>', $lines ); 668 } 669 } 670 607 671 if ( $is_user_flagged ) { 608 672 if ( $moderator && $moderation_date ) { 609 673 $notices[] = sprintf(