Skip to:
Content

BuddyPress.org

Changeset 13806


Ignore:
Timestamp:
04/25/2024 05:14:05 PM (23 months ago)
Author:
imath
Message:

xProfile component: improve PHP code standards using WPCS

See #7228 (trunk)

Location:
trunk/src/bp-xprofile
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/bp-xprofile-activity.php

    r13503 r13806  
    274274    ?>
    275275
    276     <option value="updated_profile"><?php _e( 'Profile Updates', 'buddypress' ) ?></option>
     276    <option value="updated_profile"><?php esc_html_e( 'Profile Updates', 'buddypress' ) ?></option>
    277277
    278278    <?php
  • trunk/src/bp-xprofile/bp-xprofile-admin.php

    r13797 r13806  
    151151
    152152    <div class="wrap">
    153         <h1 class="wp-heading-inline"><?php _ex( 'Profile Fields', 'Settings page header', 'buddypress'); ?></h1>
    154 
    155             <a id="add_group" class="page-title-action" href="<?php echo esc_url( $add_group_url ); ?>"><?php _e( 'Add New Field Group', 'buddypress' ); ?></a>
     153        <h1 class="wp-heading-inline"><?php echo esc_html_x( 'Profile Fields', 'Settings page header', 'buddypress'); ?></h1>
     154
     155            <a id="add_group" class="page-title-action" href="<?php echo esc_url( $add_group_url ); ?>"><?php esc_html_e( 'Add New Field Group', 'buddypress' ); ?></a>
    156156
    157157        <hr class="wp-header-end">
     
    167167                $type = ( $type == 'error' ) ? 'error' : 'updated'; ?>
    168168
    169                 <div id="message" class="<?php echo $type; ?> fade notice is-dismissible">
     169                <div id="message" class="<?php echo esc_attr( $type ); ?> fade notice is-dismissible">
    170170                    <p><?php echo esc_html( $message ); ?></p>
    171171                </div>
     
    186186
    187187                                <?php if ( ! $group->can_delete ) : ?>
    188                                     <?php _e( '(Primary)', 'buddypress'); ?>
     188                                    <?php esc_html_e( '(Primary)', 'buddypress'); ?>
    189189                                <?php endif; ?>
    190190
     
    235235                        <div class="tab-toolbar">
    236236                            <div class="tab-toolbar-left">
    237                                 <a class="button-primary" href="<?php echo esc_url( $add_field_url ); ?>"><?php _e( 'Add New Field', 'buddypress' ); ?></a>
    238                                 <a class="button edit" href="<?php echo esc_url( $edit_group_url ); ?>"><?php _ex( 'Edit Group', 'Edit Profile Fields Group', 'buddypress' ); ?></a>
     237                                <a class="button-primary" href="<?php echo esc_url( $add_field_url ); ?>"><?php esc_html_e( 'Add New Field', 'buddypress' ); ?></a>
     238                                <a class="button edit" href="<?php echo esc_url( $edit_group_url ); ?>"><?php echo esc_html_x( 'Edit Group', 'Edit Profile Fields Group', 'buddypress' ); ?></a>
    239239
    240240                                <?php if ( $group->can_delete ) : ?>
    241241
    242242                                    <div class="delete-button">
    243                                         <a class="confirm submitdelete deletion ajax-option-delete" href="<?php echo esc_url( $delete_group_url ); ?>"><?php _ex( 'Delete Group', 'Delete Profile Fields Group', 'buddypress' ); ?></a>
     243                                        <a class="confirm submitdelete deletion ajax-option-delete" href="<?php echo esc_url( $delete_group_url ); ?>"><?php echo esc_html_x( 'Delete Group', 'Delete Profile Fields Group', 'buddypress' ); ?></a>
    244244                                    </div>
    245245
     
    274274                            /** This filter is documented in bp-xprofile/bp-xprofile-template.php */
    275275                            /* translators: accessibility text */
    276                             printf( esc_html__( 'Fields for "%s" Group', 'buddypress' ), apply_filters( 'bp_get_the_profile_group_name', $group->name ) );
     276                            printf( esc_html__( 'Fields for "%s" Group', 'buddypress' ), esc_html( apply_filters( 'bp_get_the_profile_group_name', $group->name ) ) );
    277277                            ?></legend>
    278278
     
    300300                            else : // !$group->fields ?>
    301301
    302                                 <p class="nodrag nofields"><?php _e( 'There are no fields in this group.', 'buddypress' ); ?></p>
     302                                <p class="nodrag nofields"><?php esc_html_e( 'There are no fields in this group.', 'buddypress' ); ?></p>
    303303
    304304                            <?php endif; // End $group->fields. ?>
     
    310310                <?php endforeach; else : ?>
    311311
    312                     <div id="message" class="error notice is-dismissible"><p><?php _ex( 'You have no groups.', 'You have no profile fields groups.', 'buddypress' ); ?></p></div>
    313                     <p><a href="<?php echo esc_url( $add_group_url ); ?>"><?php _ex( 'Add New Group', 'Add New Profile Fields Group', 'buddypress' ); ?></a></p>
     312                    <div id="message" class="error notice is-dismissible"><p><?php echo esc_html_x( 'You have no groups.', 'You have no profile fields groups.', 'buddypress' ); ?></p></div>
     313                    <p><a href="<?php echo esc_url( $add_group_url ); ?>"><?php echo esc_html_x( 'Add New Group', 'Add New Profile Fields Group', 'buddypress' ); ?></a></p>
    314314
    315315                <?php endif; ?>
     
    360360                                }
    361361
     362                                // Escaping is done in `xprofile_admin_field()`.
     363                                // phpcs:ignore WordPress.Security.EscapeOutput
    362364                                echo $signup_fields[ $ordered_signup_field_id ];
    363365                            }
     
    397399                                /* translators: %s is the link to the registration settings. */
    398400                                esc_html__( '* Fields in this group will appear on the registration page as soon as users will be able to register to your site.%s', 'buddypress' ),
     401                                // phpcs:ignore WordPress.Security.EscapeOutput
    399402                                $settings_link
    400403                            );
     
    804807                /* translators: %s is the field type name. */
    805808                esc_html__( 'Delete %s', 'buddypress' ),
    806                 $field_type
     809                esc_html( $field_type )
    807810            );
    808811            ?>
     
    10711074    ?>
    10721075
    1073     <fieldset id="<?php echo esc_attr( $fieldset_id ); ?>" class="sortable<?php echo ' ' . $field->type; if ( ! empty( $class ) ) echo ' ' . $class; ?>">
     1076    <fieldset id="<?php echo esc_attr( $fieldset_id ); ?>" class="sortable<?php echo ' ' . esc_attr( $field->type ); if ( ! empty( $class ) ) echo ' ' . esc_attr( $class ); ?>">
    10741077        <legend>
    10751078            <span>
     
    10811084                    <span class="bp-signup-field-label"><?php esc_html_e( '(Sign-up)', 'buddypress' );?></span>
    10821085                <?php endif; ?>
    1083                 <?php if ( bp_get_member_types() ) : echo $field->get_member_type_label(); endif; ?>
     1086                <?php if ( bp_get_member_types() ) : echo wp_kses( $field->get_member_type_label(), array( 'span' => array( 'class' => true ) ) ); endif; ?>
    10841087
    10851088                <?php
     
    11241127
    11251128            <div class="actions">
    1126                 <a class="button edit" href="<?php echo esc_url( $field_edit_url ); ?>"><?php _ex( 'Edit', 'Edit field link', 'buddypress' ); ?></a>
     1129                <a class="button edit" href="<?php echo esc_url( $field_edit_url ); ?>"><?php echo esc_html_x( 'Edit', 'Edit field link', 'buddypress' ); ?></a>
    11271130
    11281131                <?php if ( $field->can_delete && ! $is_signup ) : ?>
    11291132
    11301133                    <div class="delete-button">
    1131                         <a class="confirm submit-delete deletion" href="<?php echo esc_url( wp_nonce_url( $field_delete_url, 'bp_xprofile_delete_field-' . $field->id, 'bp_xprofile_delete_field' ) ); ?>"><?php _ex( 'Delete', 'Delete field link', 'buddypress' ); ?></a>
     1134                        <a class="confirm submit-delete deletion" href="<?php echo esc_url( wp_nonce_url( $field_delete_url, 'bp_xprofile_delete_field-' . $field->id, 'bp_xprofile_delete_field' ) ); ?>"><?php echo esc_html_x( 'Delete', 'Delete field link', 'buddypress' ); ?></a>
    11321135                    </div>
    11331136
  • trunk/src/bp-xprofile/bp-xprofile-filters.php

    r13484 r13806  
    564564 *
    565565 * @since 2.0.0
    566  * 
     566 *
    567567 * @global wpdb $wpdb WordPress database object.
    568568 *
     
    729729
    730730    if ( 1 === $args['profile_group_id'] || array_diff_key( $expected_args, $needed_args ) ) {
    731         _doing_it_wrong( 'bp_has_profile()', __( 'The argument of this function into your custom `members/register.php` template should be bp_xprofile_signup_args()', 'buddypress' ), '8.0.0' );
     731        _doing_it_wrong( 'bp_has_profile()', esc_html__( 'The argument of this function into your custom `members/register.php` template should be bp_xprofile_signup_args()', 'buddypress' ), '8.0.0' );
    732732        $args = $expected_args;
    733733    }
  • trunk/src/bp-xprofile/bp-xprofile-template.php

    r13528 r13806  
    146146 */
    147147function bp_field_css_class( $class = false ) {
     148    // phpcs:ignore WordPress.Security.EscapeOutput
    148149    echo bp_get_field_css_class( $class );
    149150}
     
    200201         * @param array $css_classes Array of classes to be applied to field. Passed by reference.
    201202         */
    202         $css_classes = apply_filters_ref_array( 'bp_field_css_classes', array( &$css_classes ) );
     203        $css_classes = array_map( 'sanitize_html_class', apply_filters_ref_array( 'bp_field_css_classes', array( &$css_classes ) ) );
    203204
    204205        /**
     
    268269 */
    269270function bp_the_profile_group_id() {
    270     echo bp_get_the_profile_group_id();
     271    echo intval( bp_get_the_profile_group_id() );
    271272}
    272273
     
    299300 */
    300301function bp_the_profile_group_name() {
    301     echo bp_get_the_profile_group_name();
     302    echo esc_html( bp_get_the_profile_group_name() );
    302303}
    303304
     
    330331 */
    331332function bp_the_profile_group_slug() {
    332     echo bp_get_the_profile_group_slug();
     333    echo esc_url( bp_get_the_profile_group_slug() );
    333334}
    334335
     
    361362 */
    362363function bp_the_profile_group_description() {
     364    // Escaping is made in `bp-xprofile/bp-xprofile-filters.php`.
     365    // phpcs:ignore WordPress.Security.EscapeOutput
    363366    echo bp_get_the_profile_group_description();
    364367}
     
    392395 */
    393396function bp_the_profile_group_edit_form_action() {
    394     echo bp_get_the_profile_group_edit_form_action();
     397    echo esc_url( bp_get_the_profile_group_edit_form_action() );
    395398}
    396399
     
    427430 */
    428431function bp_the_profile_group_field_ids() {
    429     echo bp_get_the_profile_group_field_ids();
     432    echo esc_attr( bp_get_the_profile_group_field_ids() );
    430433}
    431434
     
    459462 */
    460463function bp_the_profile_field_ids() {
    461     echo bp_get_the_profile_field_ids();
     464    echo esc_attr( bp_get_the_profile_field_ids() );
    462465}
    463466    /**
     
    531534 */
    532535function bp_the_profile_field_id() {
    533     echo bp_get_the_profile_field_id();
     536    echo intval( bp_get_the_profile_field_id() );
    534537}
    535538
     
    562565 */
    563566function bp_the_profile_field_name() {
     567    // Escaping is made in `bp-xprofile/bp-xprofile-filters.php`.
     568    // phpcs:ignore WordPress.Security.EscapeOutput
    564569    echo bp_get_the_profile_field_name();
    565570}
     
    593598 */
    594599function bp_the_profile_field_value() {
     600    // Escaping is made in `bp_xprofile_escape_field_data()`.
     601    // phpcs:ignore WordPress.Security.EscapeOutput
    595602    echo bp_get_the_profile_field_value();
    596603}
     
    628635 */
    629636function bp_the_profile_field_edit_value() {
     637    // Escaping is made in `bp_xprofile_escape_field_data()`.
     638    // phpcs:ignore WordPress.Security.EscapeOutput
    630639    echo bp_get_the_profile_field_edit_value();
    631640}
     
    678687 */
    679688function bp_the_profile_field_type() {
    680     echo bp_get_the_profile_field_type();
     689    echo esc_html( bp_get_the_profile_field_type() );
    681690}
    682691
     
    709718 */
    710719function bp_the_profile_field_description() {
     720    // Escaping is made in `bp-xprofile/bp-xprofile-filters.php`.
     721    // phpcs:ignore WordPress.Security.EscapeOutput
    711722    echo bp_get_the_profile_field_description();
    712723}
     
    740751 */
    741752function bp_the_profile_field_input_name() {
    742     echo bp_get_the_profile_field_input_name();
     753    echo esc_attr( bp_get_the_profile_field_input_name() );
    743754}
    744755
     
    794805 */
    795806function bp_the_profile_field_options( $args = array() ) {
     807    // Escaping is made in `BP_XProfile_Field_Type->edit_field_options_html()`.
     808    // phpcs:ignore WordPress.Security.EscapeOutput
    796809    echo bp_get_the_profile_field_options( $args );
    797810}
     
    852865 * Render whether or not a profile field is required.
    853866 *
     867 * @todo deprecate (not used internaly) + it doesn't make much sense to output a boolean.
     868 *
    854869 * @since 1.1.0
    855870 */
    856871function bp_the_profile_field_is_required() {
     872    // phpcs:ignore WordPress.Security.EscapeOutput
    857873    echo bp_get_the_profile_field_is_required();
    858874}
     
    894910 */
    895911function bp_the_profile_field_visibility_level() {
    896     echo bp_get_the_profile_field_visibility_level();
     912    echo esc_html( bp_get_the_profile_field_visibility_level() );
    897913}
    898914
     
    934950 */
    935951function bp_the_profile_field_visibility_level_label() {
    936     echo bp_get_the_profile_field_visibility_level_label();
     952    echo esc_html( bp_get_the_profile_field_visibility_level_label() );
    937953}
    938954
     
    9991015 */
    10001016function bp_profile_field_data( $args = '' ) {
     1017    // Escaping is made in `bp-xprofile/bp-xprofile-filters.php`.
     1018    // phpcs:ignore WordPress.Security.EscapeOutput
    10011019    echo bp_get_profile_field_data( $args );
    10021020}
     
    10881106 */
    10891107function bp_profile_group_tabs() {
     1108    // phpcs:ignore WordPress.Security.EscapeOutput
    10901109    echo bp_get_profile_group_tabs();
    10911110
     
    11661185        return bp_get_profile_group_name();
    11671186    } else {
    1168         echo bp_get_profile_group_name();
     1187        echo esc_html( bp_get_profile_group_name() );
    11691188    }
    11701189}
     
    12101229
    12111230    if ( empty( $last_updated ) ) {
    1212         _e( 'Profile not recently updated.', 'buddypress' );
     1231        esc_html_e( 'Profile not recently updated.', 'buddypress' );
    12131232    } else {
    1214         echo $last_updated;
     1233        echo esc_html( $last_updated );
    12151234    }
    12161235}
     
    12521271 */
    12531272function bp_current_profile_group_id() {
    1254     echo bp_get_current_profile_group_id();
     1273    echo intval( bp_get_current_profile_group_id() );
    12551274}
    12561275
     
    13071326 */
    13081327function bp_profile_visibility_radio_buttons( $args = '' ) {
     1328    // phpcs:ignore WordPress.Security.EscapeOutput
    13091329    echo bp_profile_get_visibility_radio_buttons( $args );
    13101330}
     
    13511371            ob_start();
    13521372
    1353             // Output anything before.
     1373            // phpcs:ignore WordPress.Security.EscapeOutput
    13541374            echo $r['before']; ?>
    13551375
     
    13581378                <?php foreach( bp_xprofile_get_visibility_levels() as $level ) : ?>
    13591379
    1360                     <?php printf( $r['before_radio'], esc_attr( $level['id'] ) ); ?>
     1380                    <?php
     1381                        // phpcs:ignore WordPress.Security.EscapeOutput
     1382                        printf( $r['before_radio'], esc_attr( $level['id'] ) );
     1383                    ?>
    13611384
    13621385                    <label for="<?php echo esc_attr( 'see-field_' . $r['field_id'] . '_' . $level['id'] ); ?>">
     
    13651388                    </label>
    13661389
    1367                     <?php echo $r['after_radio']; ?>
     1390                    <?php
     1391                        // phpcs:ignore WordPress.Security.EscapeOutput
     1392                        echo $r['after_radio'];
     1393                    ?>
    13681394
    13691395                <?php endforeach; ?>
     
    13711397            <?php endif;
    13721398
    1373             // Output anything after.
     1399            // phpcs:ignore WordPress.Security.EscapeOutput
    13741400            echo $r['after'];
    13751401
     
    13981424 */
    13991425function bp_profile_settings_visibility_select( $args = '' ) {
     1426    // phpcs:ignore WordPress.Security.EscapeOutput
    14001427    echo bp_profile_get_settings_visibility_select( $args );
    14011428}
     
    14481475            ob_start();
    14491476
    1450             // Output anything before.
     1477            // phpcs:ignore WordPress.Security.EscapeOutput
    14511478            echo $r['before']; ?>
    14521479
    14531480            <?php if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?>
    14541481
    1455             <?php echo $r['before_controls']; ?>
     1482            <?php
     1483                // phpcs:ignore WordPress.Security.EscapeOutput
     1484                echo $r['before_controls'];
     1485            ?>
    14561486
    14571487                <label for="<?php echo esc_attr( 'field_' . $r['field_id'] ) ; ?>_visibility" class="<?php echo esc_attr( $r['label_class'] ); ?>"><?php
    14581488                    /* translators: accessibility text */
    1459                     _e( 'Select visibility', 'buddypress' );
     1489                    esc_html_e( 'Select visibility', 'buddypress' );
    14601490                ?></label>
    14611491                <select class="<?php echo esc_attr( $r['class'] ); ?>" name="<?php echo esc_attr( 'field_' . $r['field_id'] ) ; ?>_visibility" id="<?php echo esc_attr( 'field_' . $r['field_id'] ) ; ?>_visibility">
     
    14691499                </select>
    14701500
    1471             <?php echo $r['after_controls']; ?>
     1501            <?php
     1502                // phpcs:ignore WordPress.Security.EscapeOutput
     1503                echo $r['after_controls'];
     1504            ?>
    14721505
    14731506            <?php else : ?>
     
    14771510            <?php endif;
    14781511
    1479             // Output anything after.
     1512            // phpcs:ignore WordPress.Security.EscapeOutput
    14801513            echo $r['after'];
    14811514
     
    15021535 */
    15031536function bp_the_profile_field_required_label() {
     1537    // phpcs:ignore WordPress.Security.EscapeOutput
    15041538    echo bp_get_the_profile_field_required_label();
    15051539}
     
    15161550
    15171551        if ( bp_get_the_profile_field_is_required() ) {
    1518             $translated_string = __( '(required)', 'buddypress' );
     1552            $translated_string = esc_html__( '(required)', 'buddypress' );
    15191553
    15201554            $retval = ' <span class="bp-required-field-label">';
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-data-template.php

    r13484 r13806  
    132132        // Backward compatibility with old method of passing arguments.
    133133        if ( ! is_array( $args ) || count( $function_args ) > 1 ) {
    134             _deprecated_argument( __METHOD__, '2.3.0', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
     134            _deprecated_argument( __METHOD__, '2.3.0', sprintf( esc_html__( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
    135135
    136136            $old_args_keys = array(
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-checkbox-acceptance.php

    r13372 r13806  
    153153        <?php if ( $page instanceof WP_Post ) : ?>
    154154            <label for="<?php bp_the_profile_field_input_name(); ?>">
    155                 <input <?php echo $this->get_edit_field_html_elements( $r ); ?>>
     155                <input <?php $this->output_edit_field_html_elements( $r ); ?>>
    156156                <?php
    157157                printf(
     
    189189                <p>
    190190                    <?php
     191                    // Escaping is done in `wp_dropdown_pages()`.
     192                    // phpcs:ignore WordPress.Security.EscapeOutput
    191193                    echo wp_dropdown_pages(
    192194                        array(
     
    298300        }
    299301
    300         /**
    301          * Filter here to edit the HTML output.
    302          *
    303          * @since 8.0.0
    304          *
    305          * @param string $html                The HTML output.
    306          * @param int    $field_id            The field ID.
    307          * @param array  $r                   The edit field HTML elements data.
    308          * @param int    $checkbox_acceptance The field value.
    309          */
    310         echo apply_filters( 'bp_get_the_profile_field_checkbox_acceptance', $html, $field_id, $checkbox_acceptance );
     302        // phpcs:ignore WordPress.Security.EscapeOutput
     303        echo apply_filters(
     304            /**
     305             * Filter here to edit the HTML output.
     306             *
     307             * @since 8.0.0
     308             *
     309             * @param string $html                The HTML output.
     310             * @param int    $field_id            The field ID.
     311             * @param array  $r                   The edit field HTML elements data.
     312             * @param int    $checkbox_acceptance The field value.
     313             */
     314            'bp_get_the_profile_field_checkbox_acceptance',
     315            $html,
     316            $field_id,
     317            $checkbox_acceptance
     318        );
    311319    }
    312320
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-checkbox.php

    r13394 r13806  
    177177        }
    178178
    179         printf( '<div id="%1$s" class="input-options checkbox-options">%2$s</div>',
     179        printf(
     180            '<div id="%1$s" class="input-options checkbox-options">%2$s</div>',
    180181            esc_attr( 'field_' . $this->field_obj->id ),
     182            // phpcs:ignore WordPress.Security.EscapeOutput
    181183            $html
    182184        );
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-datebox.php

    r13394 r13806  
    118118                    esc_html_e( 'Day', 'buddypress' );
    119119                ?></label>
    120                 <select <?php echo $this->get_edit_field_html_elements( $day_r ); ?>>
     120                <select <?php $this->output_edit_field_html_elements( $day_r ); ?>>
    121121                    <?php bp_the_profile_field_options( array(
    122122                        'type'    => 'day',
     
    128128                    esc_html_e( 'Month', 'buddypress' );
    129129                ?></label>
    130                 <select <?php echo $this->get_edit_field_html_elements( $month_r ); ?>>
     130                <select <?php $this->output_edit_field_html_elements( $month_r ); ?>>
    131131                    <?php bp_the_profile_field_options( array(
    132132                        'type'    => 'month',
     
    138138                    esc_html_e( 'Year', 'buddypress' );
    139139                ?></label>
    140                 <select <?php echo $this->get_edit_field_html_elements( $year_r ); ?>>
     140                <select <?php $this->output_edit_field_html_elements( $year_r ); ?>>
    141141                    <?php bp_the_profile_field_options( array(
    142142                        'type'    => 'year',
     
    216216        switch ( $args['type'] ) {
    217217            case 'day':
    218                 $html = sprintf( '<option value="" %1$s>%2$s</option>', selected( $day, 0, false ), /* translators: no option picked in select box */ __( '----', 'buddypress' ) );
     218                $html = sprintf( '<option value="" %1$s>%2$s</option>', selected( $day, 0, false ), /* translators: no option picked in select box */ esc_html__( '----', 'buddypress' ) );
    219219
    220220                for ( $i = 1; $i < 32; ++$i ) {
     
    225225            case 'month':
    226226                $months = array(
    227                     __( 'January',   'buddypress' ),
    228                     __( 'February',  'buddypress' ),
    229                     __( 'March',     'buddypress' ),
    230                     __( 'April',     'buddypress' ),
    231                     __( 'May',       'buddypress' ),
    232                     __( 'June',      'buddypress' ),
    233                     __( 'July',      'buddypress' ),
    234                     __( 'August',    'buddypress' ),
    235                     __( 'September', 'buddypress' ),
    236                     __( 'October',   'buddypress' ),
    237                     __( 'November',  'buddypress' ),
    238                     __( 'December',  'buddypress' ),
     227                    esc_html__( 'January',   'buddypress' ),
     228                    esc_html__( 'February',  'buddypress' ),
     229                    esc_html__( 'March',     'buddypress' ),
     230                    esc_html__( 'April',     'buddypress' ),
     231                    esc_html__( 'May',       'buddypress' ),
     232                    esc_html__( 'June',      'buddypress' ),
     233                    esc_html__( 'July',      'buddypress' ),
     234                    esc_html__( 'August',    'buddypress' ),
     235                    esc_html__( 'September', 'buddypress' ),
     236                    esc_html__( 'October',   'buddypress' ),
     237                    esc_html__( 'November',  'buddypress' ),
     238                    esc_html__( 'December',  'buddypress' ),
    239239                );
    240240
    241                 $html = sprintf( '<option value="" %1$s>%2$s</option>', selected( $month, 0, false ), /* translators: no option picked in select box */ __( '----', 'buddypress' ) );
     241                $html = sprintf( '<option value="" %1$s>%2$s</option>', selected( $month, 0, false ), /* translators: no option picked in select box */ esc_html__( '----', 'buddypress' ) );
    242242
    243243                for ( $i = 0; $i < 12; ++$i ) {
     
    247247
    248248            case 'year':
    249                 $html = sprintf( '<option value="" %1$s>%2$s</option>', selected( $year, 0, false ), /* translators: no option picked in select box */ __( '----', 'buddypress' ) );
     249                $html = sprintf( '<option value="" %1$s>%2$s</option>', selected( $year, 0, false ), /* translators: no option picked in select box */ esc_html__( '----', 'buddypress' ) );
    250250
    251251                $settings = $this->get_field_settings( $this->field_obj->id );
     
    265265        }
    266266
    267         /**
    268          * Filters the output for the profile field datebox.
    269          *
    270          * @since 1.1.0
    271          *
    272          * @param string $html  HTML output for the field.
    273          * @param string $value Which date type is being rendered for.
    274          * @param string $day   Date formatted for the current day.
    275          * @param string $month Date formatted for the current month.
    276          * @param string $year  Date formatted for the current year.
    277          * @param int    $id    ID of the field object being rendered.
    278          * @param string $date  Current date.
    279          */
    280         echo apply_filters( 'bp_get_the_profile_field_datebox', $html, $args['type'], $day, $month, $year, $this->field_obj->id, $date );
     267        // phpcs:ignore WordPress.Security.EscapeOutput
     268        echo apply_filters(
     269            /**
     270             * Filters the output for the profile field datebox.
     271             *
     272             * @since 1.1.0
     273             *
     274             * @param string $html  HTML output for the field.
     275             * @param string $value Which date type is being rendered for.
     276             * @param string $day   Date formatted for the current day.
     277             * @param string $month Date formatted for the current month.
     278             * @param string $year  Date formatted for the current year.
     279             * @param int    $id    ID of the field object being rendered.
     280             * @param string $date  Current date.
     281             */
     282            'bp_get_the_profile_field_datebox',
     283            $html,
     284            $args['type'],
     285            $day,
     286            $month,
     287            $year,
     288            $this->field_obj->id,
     289            $date
     290        );
    281291    }
    282292
     
    320330            esc_html_e( 'Day', 'buddypress' );
    321331        ?></label>
    322         <select <?php echo $this->get_edit_field_html_elements( $day_r ); ?>>
     332        <select <?php $this->output_edit_field_html_elements( $day_r ); ?>>
    323333            <?php bp_the_profile_field_options( array( 'type' => 'day' ) ); ?>
    324334        </select>
     
    327337            esc_html_e( 'Month', 'buddypress' );
    328338        ?></label>
    329         <select <?php echo $this->get_edit_field_html_elements( $month_r ); ?>>
     339        <select <?php $this->output_edit_field_html_elements( $month_r ); ?>>
    330340            <?php bp_the_profile_field_options( array( 'type' => 'month' ) ); ?>
    331341        </select>
     
    334344            esc_html_e( 'Year', 'buddypress' );
    335345        ?></label>
    336         <select <?php echo $this->get_edit_field_html_elements( $year_r ); ?>>
     346        <select <?php $this->output_edit_field_html_elements( $year_r ); ?>>
    337347            <?php bp_the_profile_field_options( array( 'type' => 'year' ) ); ?>
    338348        </select>
     
    490500                            <label for="date-format-<?php echo esc_attr( $format ); ?>">
    491501                                <input type="radio" name="field-settings[date_format]" id="date-format-<?php echo esc_attr( $format ); ?>" value="<?php echo esc_attr( $format ); ?>" <?php checked( $format, $settings['date_format'] ); ?> />
    492                                 <span class="date-format-label"><?php echo date_i18n( $format ); ?></span>
     502                                <span class="date-format-label"><?php echo esc_html( date_i18n( $format ) ); ?></span>
    493503                                <code><?php echo esc_html( $format ); ?></code>
    494504                            </label>
     
    518528                        <input type="text" name="field-settings[date_format_custom]" id="date-format-custom-value" class="date-format-custom-value" value="<?php echo esc_attr( $settings['date_format_custom'] ); ?>" aria-describedby="date-format-custom-example" /> <span class="screen-reader-text"><?php esc_html_e( 'Example:', 'buddypress' ); ?></span><span class="date-format-custom-example" id="date-format-custom-sample"><?php if ( $settings['date_format_custom'] ) : ?><?php echo esc_html( date_i18n( $settings['date_format_custom'] ) ); endif; ?></span><span class="spinner" id="date-format-custom-spinner" aria-hidden="true"></span>
    519529
    520                         <p><a href="https://codex.wordpress.org/Formatting_Date_and_Time"><?php esc_html_e( 'Documentation on date and time formatting', 'buddypress' ); ?></a></p>
     530                        <p><a href="https://wordpress.org/documentation/article/customize-date-and-time-format/"><?php esc_html_e( 'Documentation on date and time formatting', 'buddypress' ); ?></a></p>
    521531                    </div>
    522532
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-multiselectbox.php

    r13394 r13806  
    8787        do_action( bp_get_the_profile_field_errors_action() ); ?>
    8888
    89         <select <?php echo $this->get_edit_field_html_elements( $r ); ?> aria-labelledby="<?php bp_the_profile_field_input_name(); ?>-1" aria-describedby="<?php bp_the_profile_field_input_name(); ?>-3">
     89        <select <?php $this->output_edit_field_html_elements( $r ); ?> aria-labelledby="<?php bp_the_profile_field_input_name(); ?>-1" aria-describedby="<?php bp_the_profile_field_input_name(); ?>-3">
    9090            <?php bp_the_profile_field_options( array(
    9191                'user_id' => $user_id,
     
    105105
    106106            $js_clear = sprintf( 'javascript:%1$s( \'%2$s[]\' );', $clear, esc_js( bp_get_the_profile_field_input_name() ) );
     107
     108            // phpcs:disable WordPress.Security.EscapeOutput
    107109        ?>
    108110
     
    111113            </a>
    112114
    113         <?php endif; ?>
    114     <?php
     115        <?php endif;
     116        // phpcs:enable
    115117    }
    116118
     
    182184        }
    183185
     186        // phpcs:ignore WordPress.Security.EscapeOutput
    184187        echo $html;
    185188    }
     
    207210            esc_html_e( 'Select', 'buddypress' );
    208211        ?></label>
    209         <select <?php echo $this->get_edit_field_html_elements( $r ); ?>>
     212        <select <?php $this->output_edit_field_html_elements( $r ); ?>>
    210213            <?php bp_the_profile_field_options(); ?>
    211214        </select>
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-number.php

    r13372 r13806  
    7979        do_action( bp_get_the_profile_field_errors_action() ); ?>
    8080
    81         <input <?php echo $this->get_edit_field_html_elements( $r ); ?> aria-labelledby="<?php bp_the_profile_field_input_name(); ?>-1" aria-describedby="<?php bp_the_profile_field_input_name(); ?>-3">
     81        <input <?php $this->output_edit_field_html_elements( $r ); ?> aria-labelledby="<?php bp_the_profile_field_input_name(); ?>-1" aria-describedby="<?php bp_the_profile_field_input_name(); ?>-3">
    8282
    8383        <?php if ( bp_get_the_profile_field_description() ) : ?>
     
    110110            esc_html_e( 'Number field', 'buddypress' );
    111111        ?></label>
    112         <input <?php echo $this->get_edit_field_html_elements( $r ); ?>>
     112        <input <?php $this->output_edit_field_html_elements( $r ); ?>>
    113113    <?php
    114114    }
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-radiobutton.php

    r13392 r13806  
    8989
    9090                $js_clear = sprintf( 'javascript:%1$s( \'%2$s\' );', $clear, esc_js( bp_get_the_profile_field_input_name() ) );
     91
     92                // phpcs:disable WordPress.Security.EscapeOutput
    9193            ?>
    9294
     
    9597                </a>
    9698
    97             <?php endif; ?>
    98 
    99         <?php
     99            <?php endif;
     100            // phpcs:enable
    100101    }
    101102
     
    162163        }
    163164
    164         printf( '<div id="%1$s" class="input-options radio-button-options">%2$s</div>',
     165        printf(
     166            '<div id="%1$s" class="input-options radio-button-options">%2$s</div>',
    165167            esc_attr( 'field_' . $this->field_obj->id ),
     168            // phpcs:ignore WordPress.Security.EscapeOutput
    166169            $html
    167170        );
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-selectbox.php

    r13393 r13806  
    7575        do_action( bp_get_the_profile_field_errors_action() ); ?>
    7676
    77         <select <?php echo $this->get_edit_field_html_elements( $raw_properties ); ?> aria-labelledby="<?php bp_the_profile_field_input_name(); ?>-1" aria-describedby="<?php bp_the_profile_field_input_name(); ?>-3">
     77        <select <?php $this->output_edit_field_html_elements( $raw_properties ); ?> aria-labelledby="<?php bp_the_profile_field_input_name(); ?>-1" aria-describedby="<?php bp_the_profile_field_input_name(); ?>-3">
    7878            <?php bp_the_profile_field_options( array( 'user_id' => $user_id ) ); ?>
    7979        </select>
     
    153153        }
    154154
     155        // phpcs:ignore WordPress.Security.EscapeOutput
    155156        echo $html;
    156157    }
     
    172173            esc_html_e( 'Select', 'buddypress' );
    173174        ?></label>
    174         <select <?php echo $this->get_edit_field_html_elements( $raw_properties ); ?>>
     175        <select <?php $this->output_edit_field_html_elements( $raw_properties ); ?>>
    175176            <?php bp_the_profile_field_options(); ?>
    176177        </select>
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-telephone.php

    r13372 r13806  
    8080        do_action( bp_get_the_profile_field_errors_action() ); ?>
    8181
    82         <input <?php echo $this->get_edit_field_html_elements( $r ); ?> aria-labelledby="<?php bp_the_profile_field_input_name(); ?>-1" aria-describedby="<?php bp_the_profile_field_input_name(); ?>-3">
     82        <input <?php $this->output_edit_field_html_elements( $r ); ?> aria-labelledby="<?php bp_the_profile_field_input_name(); ?>-1" aria-describedby="<?php bp_the_profile_field_input_name(); ?>-3">
    8383
    8484        <?php if ( bp_get_the_profile_field_description() ) : ?>
     
    111111            esc_html_e( 'Phone Number', 'buddypress' );
    112112        ?></label>
    113         <input <?php echo $this->get_edit_field_html_elements( $r ); ?>>
     113        <input <?php $this->output_edit_field_html_elements( $r ); ?>>
    114114
    115115        <?php
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-textarea.php

    r13372 r13806  
    8383            ?>
    8484
    85             <textarea <?php echo $this->get_edit_field_html_elements( $r ); ?> aria-labelledby="<?php bp_the_profile_field_input_name(); ?>-1" aria-describedby="<?php bp_the_profile_field_input_name(); ?>-3"><?php bp_the_profile_field_edit_value(); ?></textarea>
     85            <textarea <?php $this->output_edit_field_html_elements( $r ); ?> aria-labelledby="<?php bp_the_profile_field_input_name(); ?>-1" aria-describedby="<?php bp_the_profile_field_input_name(); ?>-3"><?php bp_the_profile_field_edit_value(); ?></textarea>
    8686
    8787            <?php
     
    148148            ?>
    149149
    150             <textarea <?php echo $this->get_edit_field_html_elements( $r ); ?>></textarea>
     150            <textarea <?php $this->output_edit_field_html_elements( $r ); ?>></textarea>
    151151
    152152            <?php
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-textbox.php

    r13372 r13806  
    7878        do_action( bp_get_the_profile_field_errors_action() ); ?>
    7979
    80         <input <?php echo $this->get_edit_field_html_elements( $r ); ?> aria-labelledby="<?php bp_the_profile_field_input_name(); ?>-1" aria-describedby="<?php bp_the_profile_field_input_name(); ?>-3">
     80        <input <?php $this->output_edit_field_html_elements( $r ); ?> aria-labelledby="<?php bp_the_profile_field_input_name(); ?>-1" aria-describedby="<?php bp_the_profile_field_input_name(); ?>-3">
    8181
    8282        <?php if ( bp_get_the_profile_field_description() ) : ?>
     
    110110            esc_html_e( 'Textbox', 'buddypress' );
    111111        ?></label>
    112         <input <?php echo $this->get_edit_field_html_elements( $r ); ?>>
     112        <input <?php $this->output_edit_field_html_elements( $r ); ?>>
    113113
    114114        <?php
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-url.php

    r13372 r13806  
    9090        do_action( bp_get_the_profile_field_errors_action() ); ?>
    9191
    92         <input <?php echo $this->get_edit_field_html_elements( $r ); ?> aria-labelledby="<?php bp_the_profile_field_input_name(); ?>-1" aria-describedby="<?php bp_the_profile_field_input_name(); ?>-3">
     92        <input <?php $this->output_edit_field_html_elements( $r ); ?> aria-labelledby="<?php bp_the_profile_field_input_name(); ?>-1" aria-describedby="<?php bp_the_profile_field_input_name(); ?>-3">
    9393
    9494        <?php if ( bp_get_the_profile_field_description() ) : ?>
     
    123123            esc_html_e( 'URL', 'buddypress' );
    124124        ?></label>
    125         <input <?php echo $this->get_edit_field_html_elements( $r ); ?>>
     125        <input <?php $this->output_edit_field_html_elements( $r ); ?>>
    126126
    127127        <?php
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-wordpress-biography.php

    r13372 r13806  
    119119            )
    120120        );
     121
     122        // phpcs:disable WordPress.Security.EscapeOutput
    121123        ?>
    122124
    123         <textarea <?php echo $this->get_edit_field_html_elements( $r ); ?>><?php
     125        <textarea <?php $this->output_edit_field_html_elements( $r ); ?>><?php
    124126            echo $this->sanitize_for_output( bp_get_user_meta( $user_id, $this->wp_user_key, true ), $user_id );
    125127        ?></textarea>
    126128
    127129        <?php
     130        // phpcs:enable
    128131    }
    129132
     
    147150        ?>
    148151
    149         <textarea <?php echo $this->get_edit_field_html_elements( $r ); ?>></textarea>
     152        <textarea <?php $this->output_edit_field_html_elements( $r ); ?>></textarea>
    150153
    151154        <?php
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-wordpress-textbox.php

    r13372 r13806  
    180180        do_action( bp_get_the_profile_field_errors_action() ); ?>
    181181
    182         <input <?php echo $this->get_edit_field_html_elements( $r ); ?> aria-labelledby="<?php bp_the_profile_field_input_name(); ?>-1" aria-describedby="<?php bp_the_profile_field_input_name(); ?>-3">
     182        <input <?php $this->output_edit_field_html_elements( $r ); ?> aria-labelledby="<?php bp_the_profile_field_input_name(); ?>-1" aria-describedby="<?php bp_the_profile_field_input_name(); ?>-3">
    183183
    184184        <?php if ( bp_get_the_profile_field_description() ) : ?>
     
    211211            esc_html_e( 'WordPress field', 'buddypress' );
    212212        ?></label>
    213         <input <?php echo $this->get_edit_field_html_elements( $r ); ?>>
     213        <input <?php $this->output_edit_field_html_elements( $r ); ?>>
    214214
    215215        <?php
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type.php

    r13399 r13806  
    431431                            <label for="<?php echo esc_attr( "{$type}_option{$default_name}" ); ?>">
    432432                                <input type="<?php echo esc_attr( $control_type ); ?>" id="<?php echo esc_attr( "{$type}_option{$default_name}" ); ?>" name="<?php echo esc_attr( "isDefault_{$type}_option{$default_name}" ); ?>" <?php checked( $options[ $i ]->is_default_option, true ); ?> value="<?php echo esc_attr( $j ); ?>" />
    433                                 <?php _e( 'Default Value', 'buddypress' ); ?>
     433                                <?php esc_html_e( 'Default Value', 'buddypress' ); ?>
    434434                            </label>
    435435
     
    566566        return bp_get_form_field_attributes( sanitize_key( bp_get_the_profile_field_name() ), $r );
    567567    }
     568
     569    /**
     570     * Output a sanitized and escaped string of the edit field's HTML elements and attributes.
     571     *
     572     * @since 12.4.1
     573     *
     574     * @param array $properties Optional key/value array of attributes for this edit field.
     575     */
     576    protected function output_edit_field_html_elements( array $properties = array() ) {
     577        // Escaping is done in `bp_get_form_field_attributes()`.
     578        // phpcs:ignore WordPress.Security.EscapeOutput
     579        echo $this->get_edit_field_html_elements( $properties );
     580    }
    568581}
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-field.php

    r13792 r13806  
    16011601
    16021602        <div id="field-type-member-types" class="postbox">
    1603             <h2><?php _e( 'Member Types', 'buddypress' ); ?></h2>
     1603            <h2><?php esc_html_e( 'Member Types', 'buddypress' ); ?></h2>
    16041604            <div class="inside">
    1605                 <p class="description"><?php _e( 'This field should be available to:', 'buddypress' ); ?></p>
     1605                <p class="description"><?php esc_html_e( 'This field should be available to:', 'buddypress' ); ?></p>
    16061606
    16071607                <ul>
    16081608                    <?php foreach ( $member_types as $member_type ) : ?>
    16091609                    <li>
    1610                         <label for="member-type-<?php echo $member_type->labels['name']; ?>">
    1611                             <input name="member-types[]" id="member-type-<?php echo $member_type->labels['name']; ?>" class="member-type-selector" type="checkbox" value="<?php echo $member_type->name; ?>" <?php checked( in_array( $member_type->name, $field_member_types ) ); ?>/>
    1612                             <?php echo $member_type->labels['name']; ?>
     1610                        <label for="member-type-<?php echo esc_attr( $member_type->labels['name'] ); ?>">
     1611                            <input name="member-types[]" id="member-type-<?php echo esc_attr( $member_type->labels['name'] ); ?>" class="member-type-selector" type="checkbox" value="<?php echo esc_attr( $member_type->name ); ?>" <?php checked( in_array( $member_type->name, $field_member_types ) ); ?>/>
     1612                            <?php echo esc_html( $member_type->labels['name'] ); ?>
    16131613                        </label>
    16141614                    </li>
     
    16181618                        <label for="member-type-none">
    16191619                            <input name="member-types[]" id="member-type-none" class="member-type-selector" type="checkbox" value="null" <?php checked( in_array( 'null', $field_member_types ) ); ?>/>
    1620                             <?php _e( 'Users with no member type', 'buddypress' ); ?>
     1620                            <?php esc_html_e( 'Users with no member type', 'buddypress' ); ?>
    16211621                        </label>
    16221622                    </li>
    16231623
    16241624                </ul>
    1625                 <p class="description member-type-none-notice<?php if ( ! empty( $field_member_types ) ) : ?> hide<?php endif; ?>"><?php _e( 'Unavailable to all members.', 'buddypress' ) ?></p>
     1625                <p class="description member-type-none-notice<?php if ( ! empty( $field_member_types ) ) : ?> hide<?php endif; ?>"><?php esc_html_e( 'Unavailable to all members.', 'buddypress' ) ?></p>
    16261626            </div>
    16271627
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-user-admin.php

    r13756 r13806  
    326326                        <?php
    327327                        printf(
    328                             __( 'This field can be seen by: %s', 'buddypress' ),
    329                             '<span class="current-visibility-level">' . bp_get_the_profile_field_visibility_level_label() . '</span>'
     328                            esc_html__( 'This field can be seen by: %s', 'buddypress' ),
     329                            '<span class="current-visibility-level">' . esc_html( bp_get_the_profile_field_visibility_level_label() ) . '</span>'
    330330                        );
    331331                        ?>
     
    343343                        <div class="field-visibility-settings" id="field-visibility-settings-<?php bp_the_profile_field_id() ?>">
    344344                            <fieldset>
    345                                 <legend><?php _e( 'Who can see this field?', 'buddypress' ); ?></legend>
     345                                <legend><?php esc_html_e( 'Who can see this field?', 'buddypress' ); ?></legend>
    346346
    347347                                <?php bp_profile_visibility_radio_buttons(); ?>
     
    379379    public function user_admin_spammer_metabox( $user = null ) {
    380380    ?>
    381         <p><?php printf( __( '%s has been marked as a spammer. All BuddyPress data associated with the user has been removed', 'buddypress' ), esc_html( bp_core_get_user_displayname( $user->ID ) ) ) ;?></p>
     381        <p><?php printf( esc_html__( '%s has been marked as a spammer. All BuddyPress data associated with the user has been removed', 'buddypress' ), esc_html( bp_core_get_user_displayname( $user->ID ) ) ) ;?></p>
    382382    <?php
    383383    }
Note: See TracChangeset for help on using the changeset viewer.