WordPress.org

Making WordPress.org

Changeset 4216


Ignore:
Timestamp:
10/11/2016 06:52:07 PM (4 years ago)
Author:
coffee2code
Message:

Forums Theme: Add notice indicating that a topic is being held for moderation.

Can display one of five possible messages:

  • For moderators, that a topic is flagged as spam.
  • For moderators, that a topic is pending.
  • For blocked users, that the topic has been held for moderation by the automated system.
  • When a topic is pending for less than 96 hours, that the topic has been held for moderation and will be reviewed.
  • When a topic is pending for more than 96 hours, that the topic has been held for moderation but that moderators should be asked (via Slack) about it.

Props SergeyBiryukov, coffee2code, Ipstenu.
Fixes #1561.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-forums
Files:
2 edited

Legend:

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

    r4211 r4216  
    232232}
    233233
     234/**
     235 * Display a notice for messages caught in the moderation queue.
     236 */
     237function wporg_support_add_moderation_notice() {
     238    $post_time       = mysql2date( 'U', get_post_field( 'post_date', get_the_ID() ) );
     239    $seconds_passed  = current_time( 'timestamp' ) - $post_time;
     240    $hours_passed    = (int) ( $seconds_passed / HOUR_IN_SECONDS );
     241    $post_status     = get_post_status();
     242    $is_moderator    = current_user_can( 'moderate' );
     243    $is_user_blocked = ! current_user_can( 'spectate' );
     244
     245    if ( in_array( $post_status, array( 'pending', 'spam' ) ) ) :
     246        $notice_class = $notice = '';
     247
     248        if ( $is_moderator ) {
     249            if ( 'spam' === $post_status ) {
     250                $notice_class = 'warning';
     251                $notice = __( 'This post has been flagged as spam.', 'wporg-forums' );
     252            } else {
     253                $notice = __( 'This post is currently pending.', 'wporg-forums' );
     254            }
     255        } elseif ( $is_user_blocked ) {
     256            // Blocked users get a generic message with no call to action or moderation timeframe.
     257            $notice = __( 'This post has been held for moderation by our automated system.', 'wporg-forums' );
     258        } elseif ( $hours_passed > 96 ) {
     259            $notice_class = 'warning';
     260            $notice       = sprintf(
     261                /* translators: %s: https://make.wordpress.org/chat/ */
     262                __( 'This post was held for moderation by our automated system but has taken longer than expected to get approved. Please come to the #forums channel on <a href="%s">WordPress Slack</a> and let us know. Provide a link to the post.', 'wporg-forums' ),
     263                'https://make.wordpress.org/chat/'
     264            );
     265        } else {
     266            $notice = sprintf(
     267                /* translators: %d: number of hours */
     268                __( 'This post has been held for moderation by our automated system. It will be reviewed within %d hours.', 'wporg-forums' ),
     269                72
     270            );
     271        }
     272
     273        if ( $notice ) :
     274            printf(
     275                '<div class="bbp-template-notice %s"><p>%s</p></div>',
     276                esc_attr( $notice_class ),
     277                $notice
     278            );
     279        endif;
     280    endif;
     281}
     282add_action( 'bbp_theme_before_topic_content', 'wporg_support_add_moderation_notice' );
     283add_action( 'bbp_theme_before_reply_content', 'wporg_support_add_moderation_notice' );
     284
    234285/** bb Base *******************************************************************/
    235286
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-forums/style.css

    r4209 r4216  
    160160#bbpress-forums div.bbp-template-notice ul li {
    161161    list-style: disc;
     162}
     163
     164.bbp-topic-content div.bbp-template-notice,
     165.bbp-reply-content div.bbp-template-notice {
     166    display: inline-block;
    162167}
    163168
Note: See TracChangeset for help on using the changeset viewer.