WordPress.org

Making WordPress.org

Changeset 4898


Ignore:
Timestamp:
02/09/2017 04:11:54 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Support Theme: After [4890], adjust the logic to only show moderation notice for archived posts to moderators.

Fixes #2489. See #2474.

File:
1 edited

Legend:

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

    r4893 r4898  
    235235    $is_moderator    = current_user_can( 'moderate' );
    236236    $is_user_blocked = ! current_user_can( 'spectate' );
    237 
    238     if ( in_array( $post_status, array( 'archived', 'pending', 'spam' ) ) ) :
    239         $notice_class = $notice = '';
    240 
    241         if ( $is_moderator ) {
    242             if ( 'spam' === $post_status ) {
    243                 $notice_class = 'warning';
    244 
    245                 $reporter = get_post_meta( get_the_ID(), '_bbp_akismet_user', true );
    246 
    247                 if ( $reporter ) {
    248                     /* translators: %s: reporter's username */
    249                     $notice = sprintf( __( 'This post has been flagged as spam by %s.', 'wporg-forums' ), $reporter );
    250                 } else {
    251                     $notice = __( 'This post has been flagged as spam.', 'wporg-forums' );
    252                 }
    253             } elseif ( 'archived' === $post_status ) {
    254                 $notice = __( 'This post is currently archived.', 'wporg-forums' );
     237    $notice_class    = '';
     238    $notice          = '';
     239
     240    if ( $is_moderator && in_array( $post_status, array( 'archived', 'pending', 'spam' ) ) ) :
     241
     242        if ( 'spam' === $post_status ) {
     243            $notice_class = 'warning';
     244
     245            $reporter = get_post_meta( get_the_ID(), '_bbp_akismet_user', true );
     246
     247            if ( $reporter ) {
     248                /* translators: %s: reporter's username */
     249                $notice = sprintf( __( 'This post has been flagged as spam by %s.', 'wporg-forums' ), $reporter );
    255250            } else {
    256                 $notice = __( 'This post is currently pending.', 'wporg-forums' );
     251                $notice = __( 'This post has been flagged as spam.', 'wporg-forums' );
    257252            }
    258         } elseif ( $is_user_blocked ) {
     253        } elseif ( 'archived' === $post_status ) {
     254            $notice = __( 'This post is currently archived.', 'wporg-forums' );
     255        } else {
     256            $notice = __( 'This post is currently pending.', 'wporg-forums' );
     257        }
     258
     259    elseif ( in_array( $post_status, array( 'pending', 'spam' ) ) ) :
     260
     261        if ( $is_user_blocked ) {
    259262            // Blocked users get a generic message with no call to action or moderation timeframe.
    260263            $notice = __( 'This post has been held for moderation by our automated system.', 'wporg-forums' );
     
    274277        }
    275278
    276         if ( $notice ) :
    277             printf(
    278                 '<div class="bbp-template-notice %s"><p>%s</p></div>',
    279                 esc_attr( $notice_class ),
    280                 $notice
    281             );
    282         endif;
    283279    endif;
     280
     281    if ( $notice ) {
     282        printf(
     283            '<div class="bbp-template-notice %s"><p>%s</p></div>',
     284            esc_attr( $notice_class ),
     285            $notice
     286        );
     287    }
    284288}
    285289add_action( 'bbp_theme_before_topic_content', 'wporg_support_add_moderation_notice' );
Note: See TracChangeset for help on using the changeset viewer.