Making WordPress.org

Changeset 7101


Ignore:
Timestamp:
04/12/2018 12:54:25 PM (8 years ago)
Author:
SergeyBiryukov
Message:

Plugin Directory, Author Card: Display user notes from support forums.

Fixes #3566.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-author-card.php

    r6287 r7101  
    109109                <?php endif; ?>
    110110
     111                <div class="profile-user-notes">
     112                        <?php
     113                        if ( defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) ) {
     114                                $user     = new \WP_User( $author, '', WPORG_SUPPORT_FORUMS_BLOGID );
     115                                $statuses = array();
     116
     117                                if ( ! empty( $user->allcaps['bbp_blocked'] ) ) {
     118                                        $statuses[] = array(
     119                                                'text' => __( 'banned', 'wporg-plugins' ),
     120                                                'desc' => __( 'User is banned from logging into WordPress.org', 'wporg-plugins' ),
     121                                        );
     122                                }
     123
     124                                if ( (bool) get_user_meta( $user->ID, 'is_bozo', true ) ) {
     125                                        $statuses[] = array(
     126                                                'text' => __( 'flagged', 'wporg-plugins' ),
     127                                                'desc' => __( 'User is flagged in the support forums', 'wporg-plugins' ),
     128                                        );
     129                                }
     130
     131                                if ( $statuses ) {
     132                                        $labels = array();
     133                                        foreach ( $statuses as $status ) {
     134                                                $labels[] = sprintf(
     135                                                        '<strong><span title="%s">%s</span></strong>',
     136                                                        esc_attr( $status['desc'] ),
     137                                                        $status['text']
     138                                                );
     139                                        }
     140                                        /* translators: %s: comma-separated list of negative user status labels */
     141                                        echo '<p>' . sprintf( __( 'This user is: %s', 'wporg-plugins' ), implode( ', ', $labels ) ) . '</p>';
     142                                }
     143                        }
     144
     145                        $user_notes = get_user_meta( $user->ID, '_wporg_bbp_user_notes', true );
     146
     147                        if ( $user_notes ) {
     148                                _e( 'User notes:', 'wporg-plugins' );
     149                                echo '<ul>';
     150                                foreach ( $user_notes as $note ) {
     151                                        $note_meta = sprintf(
     152                                                /* translators: 1: user note author's display name, 2: date */
     153                                                __( 'By %1$s on %2$s</a>', 'wporg-plugins' ),
     154                                                $note->moderator,
     155                                                $note->date
     156                                        );
     157
     158                                        $note_html  = apply_filters( 'comment_text', $note->text, null, array() );
     159                                        $note_html .= sprintf( '<p class="textright">%s</p>' . "\n", $note_meta );
     160
     161                                        echo '<li>' . $note_html . '</li>';
     162                                }
     163                                echo '</ul>';
     164                        }
     165                        ?>
     166                </div>
     167
    111168                <?php
    112                 if ( defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) ) {
    113                         $user     = new \WP_User( $author, '', WPORG_SUPPORT_FORUMS_BLOGID );
    114                         $statuses = array();
    115 
    116                         if ( ! empty( $user->allcaps['bbp_blocked'] ) ) {
    117                                 $statuses[] = array(
    118                                         'text' => __( 'banned', 'wporg-plugins' ),
    119                                         'desc' => __( 'User is banned from logging into WordPress.org', 'wporg-plugins' ),
    120                                 );
    121                         }
    122 
    123                         if ( (bool) get_user_meta( $user->ID, 'is_bozo', true ) ) {
    124                                 $statuses[] = array(
    125                                         'text' => __( 'flagged', 'wporg-plugins' ),
    126                                         'desc' => __( 'User is flagged in the support forums', 'wporg-plugins' ),
    127                                 );
    128                         }
    129 
    130                         if ( $statuses ) {
    131                                 $labels = array();
    132                                 foreach ( $statuses as $status ) {
    133                                         $labels[] = sprintf(
    134                                                 '<strong><span title="%s">%s</span></strong>',
    135                                                 esc_attr( $status['desc'] ),
    136                                                 $status['text']
    137                                         );
    138                                 }
    139                                 /* translators: %s: comma-separated list of negative user status labels */
    140                                 echo '<p>' . sprintf( __( 'This user is: %s', 'wporg-plugins' ), implode( ', ', $labels ) ) . '</p>';
    141                         }
    142                 }
    143 
    144169                $post_ids = get_posts( array(
    145170                        'fields'         => 'ids',
Note: See TracChangeset for help on using the changeset viewer.