Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/28/2024 12:23:47 PM (3 years ago)
Author:
imath
Message:

Core: improve PHP code standards using WPCS

See #7228 (trunk)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-optouts-list-table.php

    r13469 r13818  
    129129                         * @since 8.0.0
    130130                         *
    131                          * @param string $url_base       Current URL base for view.
    132                          * @param array  $active_filters Current filters being requested.
     131                         * @param string $url_base Current URL base for view.
    133132                         */
    134                         do_action( 'bp_optouts_list_table_get_views', $url_base, $this->active_filters ); ?>
     133                        do_action( 'bp_optouts_list_table_get_views', $url_base ); ?>
    135134                </ul>
    136135        <?php
    … …  
    225224                $style = '';
    226225                foreach ( $this->items as $optout ) {
    227                         $style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"';
     226                        $style = 'alt' == $style ? '' : 'alt';
     227
     228                        // Escapes are made into `self::single_row()`.
     229                        // phpcs:ignore WordPress.Security.EscapeOutput
    228230                        echo "\n\t" . $this->single_row( $optout, $style );
    229231                }
    … …  
    244246         */
    245247        public function single_row( $optout = null, $style = '', $role = '', $numposts = 0 ) {
    246                 echo '<tr' . $style . ' id="optout-' . intval( $optout->id ) . '">';
     248                if ( '' === $style ) {
     249                        echo '<tr id="optout-' . intval( $optout->id ) . '">';
     250                } else {
     251                        echo '<tr class="alternate" id="optout-' . intval( $optout->id ) . '">';
     252                }
     253
     254                // BuddyPress relies on WordPress's `WP_Users_List_Table::single_row_columns()`.
     255                // phpcs:ignore WordPress.Security.EscapeOutput
    247256                echo $this->single_row_columns( $optout );
    248257                echo '</tr>';
    … …  
    307316                $actions = apply_filters( 'bp_optouts_management_row_actions', $actions, $optout );
    308317
     318                // BuddyPress relies on WordPress's `WP_Users_List_Table::row_actions()`.
     319                // phpcs:ignore WordPress.Security.EscapeOutput
    309320                echo $this->row_actions( $actions );
    310321        }
    … …  
    318329         */
    319330        public function column_username( $optout = null ) {
    320                 $avatar = get_avatar( $optout->user_id, 32 );
     331                $avatar  = get_avatar( $optout->user_id, 32 );
    321332                $inviter = get_user_by( 'id', $optout->user_id );
     333
    322334                if ( ! $inviter ) {
    323335                        return;
    324336                }
     337
    325338                $user_link = bp_members_get_user_url( $optout->user_id );
    326                 echo $avatar . sprintf( '<strong><a href="%1$s" class="edit">%2$s</a></strong><br/>', esc_url( $user_link ), esc_html( $inviter->user_login ) );
     339
     340                echo wp_kses(
     341                        $avatar,
     342                        array(
     343                                'img' => array(
     344                                        'alt'    => true,
     345                                        'src'    => true,
     346                                        'srcset' => true,
     347                                        'class'  => true,
     348                                        'height' => true,
     349                                        'width'  => true,
     350                                )
     351                        )
     352                );
     353                printf( '<strong><a href="%1$s" class="edit">%2$s</a></strong><br/>', esc_url( $user_link ), esc_html( $inviter->user_login ) );
    327354        }
    328355
    … …  
    336363        public function column_user_registered( $optout = null ) {
    337364                $inviter = get_user_by( 'id', $optout->user_id );
     365
    338366                if ( ! $inviter ) {
    339367                        return;
    340368                }
     369
    341370                echo esc_html( mysql2date( 'Y/m/d g:i:s a', $inviter->user_registered  ) );
    342371        }
    … …  
    362391        public function column_email_type_description( $optout = null ) {
    363392                $type_term = get_term_by( 'slug', $optout->email_type, 'bp-email-type' );
     393
    364394                if ( $type_term ) {
    365395                        echo esc_html( $type_term->description );
Note: See TracChangeset for help on using the changeset viewer.