Making WordPress.org


Ignore:
Timestamp:
06/02/2023 02:48:25 PM (3 years ago)
Author:
Clorith
Message:

Support Forums: Show context information about pending posts.

When viewing queues of pending posts, a moderator is expected to check a users history to make sure they un-flag users in as timely a manner as possible. Doing so generally requires going in and checking the users posting history manually via their profiles.

This change reduces the workload of moderators by providing a lot of this information within context of a pending post.

Fixes #6809.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php

    r12598 r12616  
    604604                        $moderator       = get_user_meta( $post->post_author, $plugin_instance::MODERATOR_META, true );
    605605                        $moderation_date = get_user_meta( $post->post_author, $plugin_instance::MODERATION_DATE_META, true );
     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_modified_time( 'U', true, $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 = human_time_diff( strtotime( $user_posting_history['last_archived_post'][0]->post_modified_gmt ) );
     619
     620                                        $lines = array();
     621
     622                                        if ( $last_archive_time < DAY_IN_SECONDS ) {
     623                                                $lines[] = sprintf(
     624                                                        // translators: %s: Time since the last archived post.
     625                                                        __( 'The user last had content archived %s.', 'wporg-forums' ),
     626                                                        sprintf(
     627                                                                '<span title="%s">%s</span>',
     628                                                                esc_attr(
     629                                                                        sprintf(
     630                                                                                // translators: %s: The original date and time when the users last archived post was.
     631                                                                                __( 'Last archived post is from %s', 'wporg-forums' ),
     632                                                                                $user_posting_history['last_archived_post'][0]->post_modified_gmt
     633                                                                        )
     634                                                                ),
     635                                                                __( 'today', 'wporg-forums' )
     636                                                        )
     637                                                );
     638                                        } else {
     639                                                $lines[] = sprintf(
     640                                                        // translators: %s: Time since the last archived post.
     641                                                        __( 'The user last had content archived %s.', 'wporg-forums' ),
     642                                                        sprintf(
     643                                                                '<span title="%s">%s</span>',
     644                                                                esc_attr(
     645                                                                        sprintf(
     646                                                                                // translators: %s: The original date and time when the users last archived post was.
     647                                                                                __( 'Last archived post is from %s', 'wporg-forums' ),
     648                                                                                $user_posting_history['last_archived_post'][0]->post_modified_gmt
     649                                                                        )
     650                                                                ),
     651                                                                sprintf(
     652                                                                        // translators: %d: Amount of days since the last archived post.
     653                                                                        _n(
     654                                                                                '%d day ago',
     655                                                                                '%d days ago',
     656                                                                                ceil( ( $last_archive_time - time() ) / DAY_IN_SECONDS ),
     657                                                                                'wporg-forums'
     658                                                                        ),
     659                                                                        esc_html( $last_archive_elapsed )
     660                                                                )
     661                                                        )
     662                                                );
     663                                        }
     664
     665                                        $lines[] = sprintf(
     666                                                // translators: %d: The amount of approved posts since the last archived entry.
     667                                                _n(
     668                                                        'The user has had %d approved post since their last archived content.',
     669                                                        'The user has had %d approved posts since their last archived content.',
     670                                                        absint( $user_posting_history['posts_since_archive'] ),
     671                                                        'wporg-forums'
     672                                                ),
     673                                                esc_html( $user_posting_history['posts_since_archive'] )
     674                                        );
     675                                        $lines[] = sprintf(
     676                                                // translators: %d: The amount of approved posts since the last archived entry.
     677                                                _n(
     678                                                        'The user has %d pending post at this time.',
     679                                                        'The user has %d pending posts at this time.',
     680                                                        absint( $user_posting_history['pending_posts'] ),
     681                                                        'wporg-forums'
     682                                                ),
     683                                                esc_html( $user_posting_history['pending_posts'] )
     684                                        );
     685
     686                                        $notices[] = implode( '<br>', $lines );
     687                                }
     688                        }
    606689
    607690                        if ( $is_user_flagged ) {
Note: See TracChangeset for help on using the changeset viewer.