Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/23/2024 09:39:11 PM (2 years ago)
Author:
imath
Message:

Members component: improve PHP code standards using WPCS

See #7228 (trunk)

File:
1 edited

Legend:

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

    r13499 r13799  
    216216            }
    217217
    218             /* translators: %s: url to site settings */
    219             printf( __( 'Registration is disabled. %s', 'buddypress' ), $link );
     218            printf(
     219                /* translators: %s: url to site settings */
     220                esc_html__( 'Registration is disabled. %s', 'buddypress' ),
     221                // The link has been escaped at line 213 & 215.
     222                // phpcs:ignore WordPress.Security.EscapeOutput
     223                $link
     224            );
    220225        }
    221226
     
    249254            }
    250255
    251             $style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"';
     256            $style = 'alt' === $style ? '' : 'alt';
     257
     258            // Escapes are made into `self::single_row()`.
     259            // phpcs:ignore WordPress.Security.EscapeOutput
    252260            echo "\n\t" . $this->single_row( $signup_object, $style );
    253261        }
     
    268276     */
    269277    public function single_row( $signup_object = null, $style = '', $role = '', $numposts = 0 ) {
    270         echo '<tr' . $style . ' id="signup-' . esc_attr( $signup_object->id ) . '">';
     278        if ( '' === $style ) {
     279            echo '<tr id="signup-' . esc_attr( $signup_object->id ) . '">';
     280        } else {
     281            echo '<tr class="alternate" id="signup-' . esc_attr( $signup_object->id ) . '">';
     282        }
     283
     284        // BuddyPress relies on WordPress's `WP_Users_List_Table::single_row_columns()`.
     285        // phpcs:ignore WordPress.Security.EscapeOutput
    271286        echo $this->single_row_columns( $signup_object );
    272287        echo '</tr>';
     
    282297    public function column_cb( $signup_object = null ) {
    283298    ?>
    284         <label class="screen-reader-text" for="signup_<?php echo intval( $signup_object->id ); ?>"><?php
    285             /* translators: accessibility text */
    286             printf( esc_html__( 'Select user: %s', 'buddypress' ), $signup_object->user_login );
    287         ?></label>
     299        <label class="screen-reader-text" for="signup_<?php echo intval( $signup_object->id ); ?>">
     300            <?php
     301            printf(
     302                /* translators: accessibility text */
     303                esc_html__( 'Select user: %s', 'buddypress' ),
     304                esc_html( $signup_object->user_login )
     305            );
     306            ?>
     307        </label>
    288308        <input type="checkbox" id="signup_<?php echo intval( $signup_object->id ) ?>" name="allsignups[]" value="<?php echo esc_attr( $signup_object->id ) ?>" />
    289309        <?php
     
    330350        );
    331351
    332         echo $avatar . sprintf( '<strong><a href="%1$s" class="edit">%2$s</a></strong><br/>', esc_url( $activate_link ), $signup_object->user_login );
     352        echo wp_kses(
     353            $avatar,
     354            array(
     355                'img' => array(
     356                    'alt'    => true,
     357                    'src'    => true,
     358                    'srcset' => true,
     359                    'class'  => true,
     360                    'height' => true,
     361                    'width'  => true,
     362                )
     363            )
     364        );
     365        printf( '<strong><a href="%1$s" class="edit">%2$s</a></strong><br/>', esc_url( $activate_link ), esc_html( $signup_object->user_login ) );
    333366
    334367        $actions = array();
    335368
    336         $actions['activate'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $activate_link ), __( 'Activate', 'buddypress' ) );
    337         $actions['resend']   = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $email_link ), __( 'Email', 'buddypress' ) );
     369        $actions['activate'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $activate_link ), esc_html__( 'Activate', 'buddypress' ) );
     370        $actions['resend']   = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $email_link ), esc_html__( 'Email', 'buddypress' ) );
    338371
    339372        if ( current_user_can( 'delete_users' ) ) {
    340             $actions['delete'] = sprintf( '<a href="%1$s" class="delete">%2$s</a>', esc_url( $delete_link ), __( 'Delete', 'buddypress' ) );
     373            $actions['delete'] = sprintf( '<a href="%1$s" class="delete">%2$s</a>', esc_url( $delete_link ), esc_html__( 'Delete', 'buddypress' ) );
    341374        }
    342375
     
    351384        $actions = apply_filters( 'bp_members_ms_signup_row_actions', $actions, $signup_object );
    352385
     386        // BuddyPress relies on WordPress's `WP_Users_List_Table::row_actions()`.
     387        // phpcs:ignore WordPress.Security.EscapeOutput
    353388        echo $this->row_actions( $actions );
    354389    }
     
    407442     */
    408443    public function column_registered( $signup_object = null ) {
    409         echo mysql2date( 'Y/m/d g:i:s a', $signup_object->registered );
     444        echo esc_html( mysql2date( 'Y/m/d g:i:s a', $signup_object->registered ) );
    410445    }
    411446
     
    419454    public function column_date_sent( $signup_object = null ) {
    420455        if ( $signup_object->count_sent > 0 ) {
    421             echo mysql2date( 'Y/m/d g:i:s a', $signup_object->date_sent );
     456            echo esc_html( mysql2date( 'Y/m/d g:i:s a', $signup_object->date_sent ) );
    422457        } else {
    423             $message = __( 'Not yet notified', 'buddypress' );
     458            $message = esc_html__( 'Not yet notified', 'buddypress' );
    424459
    425460            /**
Note: See TracChangeset for help on using the changeset viewer.