Skip to:
Content

BuddyPress.org

Ticket #8582: 8582.7.patch

File 8582.7.patch, 35.1 KB (added by imath, 3 years ago)
  • src/bp-core/admin/js/bp-thickbox.js

    diff --git src/bp-core/admin/js/bp-thickbox.js src/bp-core/admin/js/bp-thickbox.js
    index e69de29bb..0bafd38fa 100644
     
     1/**
     2 * Improves the Thickbox library for BuddyPress needs.
     3 *
     4 * @since 10.0.0
     5 */
     6( function( $ ) {
     7        window.bpAdjustThickbox = function( label, padding ) {
     8                $( '#TB_window' ).attr( {
     9                                                        'role': 'dialog',
     10                                                        'aria-label': label
     11                                                } )
     12                                                .addClass( 'plugin-details-modal' )
     13                                                .removeClass( 'thickbox-loading' );
     14
     15
     16                if ( ! padding ) {
     17                        padding = 0;
     18                }
     19
     20                $( '#TB_ajaxContent' ).prop( 'style', 'height: 100%; width: auto; padding: ' + padding + '; border: none;' );
     21
     22                try {
     23                        var tabbables = $( ':tabbable', '#TB_ajaxContent' ), lastTabbable = tabbables.last();
     24
     25                        // Move the focus to the Modal's close button once the last Hello link was tabbed out.
     26                        $( '#TB_window' ).on( 'keydown', function( event ) {
     27                                var keyCode;
     28
     29                                if ( event.key !== undefined ) {
     30                                        keyCode = event.key;
     31                                } else {
     32                                        // event.keyCode is deprecated.
     33                                        keyCode = event.keyCode;
     34                                }
     35
     36                                if ( 9 === keyCode && ! event.shiftKey && $( lastTabbable ).prop( 'classList' ).value === $( event.target ).prop( 'classList' ).value ) {
     37                                        event.preventDefault();
     38
     39                                        $( '#TB_closeWindowButton' ).trigger( 'focus' );
     40                                }
     41
     42                                if ( 9 === keyCode && event.shiftKey && 'TB_closeWindowButton' === $( event.target ).prop( 'id' ) ) {
     43                                        event.preventDefault();
     44
     45                                        $( lastTabbable ).trigger( 'focus' );
     46                                }
     47                        } );
     48                } catch ( error ) {
     49                        return;
     50                }
     51        };
     52} ( jQuery ) );
  • src/bp-core/admin/js/hello.js

    diff --git src/bp-core/admin/js/hello.js src/bp-core/admin/js/hello.js
    index 47c996579..77461a559 100644
     
    1919                }
    2020
    2121                window.tb_show( 'BuddyPress', '#TB_inline?inlineId=bp-hello-container' );
    22 
    23                 $( '#TB_window' ).attr( {
    24                                                         'role': 'dialog',
    25                                                         'aria-label': bpHelloStrings.modalLabel
    26                                                 } )
    27                                                 .addClass( 'plugin-details-modal' )
    28                                                 .removeClass( 'thickbox-loading' );
    29 
    30                 $( '#TB_ajaxContent' ).prop( 'style', 'height: 100%; width: auto; padding: 0; border: none;' );
    31 
    32                 var tabbables = $( ':tabbable', '#TB_ajaxContent' ), lastTabbable = tabbables.last();
    33 
    34                 // Move the focus to the Modal's close button once the last Hello link was tabbed out.
    35                 $( '#TB_window' ).on( 'keydown', function( event ) {
    36                         if ( 9 === event.keyCode && ! event.shiftKey && $( lastTabbable ).prop( 'classList' ).value === $( event.target ).prop( 'classList' ).value ) {
    37                                 event.preventDefault();
    38 
    39                                 $( '#TB_closeWindowButton' ).focus();
    40                         }
    41 
    42                         if ( 9 === event.keyCode && event.shiftKey && 'TB_closeWindowButton' === $( event.target ).prop( 'id' ) ) {
    43                                 event.preventDefault();
    44 
    45                                 $( lastTabbable ).focus();
    46                         }
    47                 } );
     22                window.bpAdjustThickbox( bpHelloStrings.modalLabel );
    4823        };
    4924
    5025        /**
  • src/bp-core/classes/class-bp-admin.php

    diff --git src/bp-core/classes/class-bp-admin.php src/bp-core/classes/class-bp-admin.php
    index 24d3678ee..0fe584430 100644
    class BP_Admin { 
    12881288                                'footer'       => true,
    12891289                        ),
    12901290
     1291                        // 10.0
     1292                        'bp-thickbox' => array(
     1293                                'file'         => "{$url}bp-thickbox{$min}.js",
     1294                                'dependencies' => array( 'thickbox' ),
     1295                                'footer'       => true,
     1296                        ),
     1297
    12911298                        // 3.0
    12921299                        'bp-hello-js' => array(
    12931300                                'file'         => "{$url}hello{$min}.js",
    1294                                 'dependencies' => array( 'thickbox', 'wp-api-request' ),
     1301                                'dependencies' => array( 'bp-thickbox', 'wp-api-request' ),
    12951302                                'footer'       => true,
    12961303                        ),
    12971304                ) );
  • src/bp-members/admin/js/signup-preview.js

    diff --git src/bp-members/admin/js/signup-preview.js src/bp-members/admin/js/signup-preview.js
    index e69de29bb..15c200ea7 100644
     
     1/* global bpSignupPreview */
     2/**
     3 * Opens a modal to preview a signup/membership request.
     4 *
     5 * @since 10.0.0
     6 */
     7( function( $ ) {
     8        // Bail if not set or if Thickbox is not available.
     9        if ( typeof bpSignupPreview === 'undefined' || 'function' !== typeof window.tb_show ) {
     10                return;
     11        }
     12
     13        $( function() {
     14                $( '.bp-thickbox' ).on( 'click', function( e ) {
     15                        e.preventDefault();
     16
     17                        var fragment = $( e.target ).prop( 'href' ).split( '#TB_inline&' )[1];
     18
     19                        window.tb_show( 'BuddyPress', '#TB_inline?' + fragment );
     20                        window.bpAdjustThickbox( bpSignupPreview.modalLabel, '1em' );
     21                } );
     22        } );
     23}( jQuery ) );
  • src/bp-members/bp-members-admin.php

    diff --git src/bp-members/bp-members-admin.php src/bp-members/bp-members-admin.php
    index 1b80fe190..3aa4e01d7 100644
    function bp_members_type_admin_updated_messages( $messages = array() ) { 
    112112        return $messages;
    113113}
    114114add_filter( 'term_updated_messages', 'bp_members_type_admin_updated_messages' );
     115
     116/**
     117 * Formats xprofile field data about a signup/membership request for display.
     118 *
     119 * Operates recursively on arrays, which are then imploded with commas.
     120 *
     121 * @since 10.0.0
     122 *
     123 * @param string|array $value Field value.
     124 */
     125function bp_members_admin_format_xprofile_field_for_display( $value ) {
     126        if ( is_array( $value ) ) {
     127                $value = array_map( 'bp_signup_format_xprofile_field_for_display', $value );
     128                $value = implode( ', ', $value );
     129        } else {
     130                $value = stripslashes( $value );
     131                $value = esc_html( $value );
     132        }
     133
     134        return $value;
     135}
     136
     137/**
     138 * Outputs Informations about a signup/membership request into a modal inside the Signups Admin Screen.
     139 *
     140 * @since 10.0.0
     141 *
     142 * @param array $signup_field_labels The Signup field labels.
     143 * @param object|null $signup_object The signup data object.
     144 */
     145function bp_members_admin_preview_signup_profile_info( $signup_field_labels = array(), $signup_object = null ) {
     146        if ( ! isset( $signup_object->meta ) || ! $signup_field_labels ) {
     147                return;
     148        }
     149
     150        // Init ids.
     151        $profile_field_ids = array();
     152
     153        // Get all xprofile field IDs except field 1.
     154        if ( ! empty( $signup_object->meta['profile_field_ids'] ) ) {
     155                $profile_field_ids = array_flip( explode( ',', $signup_object->meta['profile_field_ids'] ) );
     156                unset( $profile_field_ids[1] );
     157        }
     158        ?>
     159        <div id="signup-info-modal-<?php echo $signup_object->id; ?>" style="display:none;">
     160                <h1><?php printf( '%1$s (%2$s)', esc_html( $signup_object->user_name ), esc_html( $signup_object->user_email ) ); ?></h1>
     161                <h2><?php esc_html_e( 'Extended Profile Information', 'buddypress' ); ?></h2>
     162
     163                <table class="signup-profile-data-drawer wp-list-table widefat fixed striped">
     164                        <?php if ( 1 <= count( $profile_field_ids ) ): foreach ( array_keys( $profile_field_ids ) as $profile_field_id ) :
     165                                $field_value = isset( $signup_object->meta[ "field_{$profile_field_id}" ] ) ? $signup_object->meta[ "field_{$profile_field_id}" ] : ''; ?>
     166                                <tr>
     167                                        <td class="column-fields"><?php echo esc_html( $signup_field_labels[ $profile_field_id ] ); ?></td>
     168                                        <td><?php echo bp_members_admin_format_xprofile_field_for_display( $field_value ); ?></td>
     169                                </tr>
     170                        <?php endforeach; else:  ?>
     171                                <tr>
     172                                        <td><?php esc_html_e( 'There is no additional information to display.', 'buddypress' ); ?></td>
     173                                </tr>
     174                        <?php endif; ?>
     175                </table>
     176        </div>
     177        <?php
     178}
  • src/bp-members/bp-members-functions.php

    diff --git src/bp-members/bp-members-functions.php src/bp-members/bp-members-functions.php
    index 141c545fa..9a389cdda 100644
    function bp_core_signup_disable_inactive( $user = null, $username = '', $passwor 
    24492449         * when membership requests are enabled.
    24502450         */
    24512451        if ( bp_get_membership_requests_required() ) {
    2452                 return new WP_Error( 'bp_account_not_activated', __( '<strong>Error</strong>: Your membership request has not yet been approved.', 'buddypress' ) );
     2452                $error_message = sprintf(
     2453                        '<strong>%1$s</strong> %2$s',
     2454                        esc_html_x( 'Error:', 'Warning used into the WP Login screen', 'buddypress' ),
     2455                        esc_html_x( 'Your membership request has not yet been approved.', 'Error message used into the WP Login screen', 'buddypress' )
     2456                );
    24532457        } else {
    24542458                // Set up the feedback message.
    24552459                $signup_id = $signup['signups'][0]->signup_id;
    function bp_core_signup_disable_inactive( $user = null, $username = '', $passwor 
    24642468                        'bp-resend-activation'
    24652469                );
    24662470
    2467                 $resend_string = '<br /><br />';
    2468 
    2469                 /* translators: %s: the activation url */
    2470                 $resend_string .= sprintf( __( 'If you have not received an email yet, <a href="%s">click here to resend it</a>.', 'buddypress' ), esc_url( $resend_url ) );
    2471 
    2472                 return new WP_Error( 'bp_account_not_activated', __( '<strong>Error</strong>: Your account has not been activated. Check your email for the activation link.', 'buddypress' ) . $resend_string );
     2471                $error_message = sprintf(
     2472                        '<strong>%1$s</strong> %2$s<br /><br />%3$s',
     2473                        esc_html_x( 'Error:', 'Warning used into the WP Login screen', 'buddypress' ),
     2474                        esc_html_x( 'Your account has not been activated. Check your email for the activation link.', 'Error message used into the WP Login screen', 'buddypress' ),
     2475                        sprintf(
     2476                                /* translators: %s: the link to resend the activation email. */
     2477                                esc_html_x( 'If you have not received an email yet, %s.', 'WP Login screen message', 'buddypress' ),
     2478                                sprintf(
     2479                                        '<a href="%1$s">%2$s</a>',
     2480                                        esc_url( $resend_url ),
     2481                                        esc_html_x( 'click here to resend it', 'Text of the link to resend the activation email', 'buddypress' )
     2482                                )
     2483                        )
     2484                );
    24732485        }
     2486
     2487        return new WP_Error( 'bp_account_not_activated', $error_message );
    24742488}
    24752489add_filter( 'authenticate', 'bp_core_signup_disable_inactive', 30, 3 );
    24762490
    function bp_get_members_invitation_from_request() { 
    37083722 * @return bool|BP_Signup $signup Found signup, returns first found
    37093723 *                                if more than one is found.
    37103724 */
    3711 function bp_members_get_signup_by( $field = 'activation_key', $value ) {
     3725function bp_members_get_signup_by( $field = 'activation_key', $value = '' ) {
    37123726        switch ( $field ) {
    37133727                case 'activation_key':
    37143728                case 'user_email':
  • src/bp-members/bp-members-invitations.php

    diff --git src/bp-members/bp-members-invitations.php src/bp-members/bp-members-invitations.php
    index 7e95c791d..1924710cc 100644
    function bp_members_invitations_maybe_bypass_request_approval( $send, $details ) 
    212212                        'invite_sent'   => 'sent'
    213213                )
    214214        );
     215
    215216        // If pending invitations exist, send the verification mail.
    216217        if ( $invites ) {
    217218                $send = true;
    218219        }
     220
    219221        return $send;
    220222}
    221223add_filter( 'bp_members_membership_requests_bypass_manual_approval', 'bp_members_invitations_maybe_bypass_request_approval', 10, 2 );
  • src/bp-members/bp-members-membership-requests.php

    diff --git src/bp-members/bp-members-membership-requests.php src/bp-members/bp-members-membership-requests.php
    index 2f217db7b..e1ab537ad 100644
    add_filter( 'bp_core_signup_send_activation_key', 'bp_members_membership_request 
    8484function bp_members_membership_requests_notify_site_admins( $signup ) {
    8585
    8686        // Notify all site admins so the request can be handled.
    87         $admins_query = new WP_User_Query( array(
    88                 'role'   => 'administrator',
    89                 'fields' => 'ids'
    90         ) );
    91         $admin_ids   = $admins_query->get_results();
     87        $admin_ids = get_users(
     88                array(
     89                        'fields' => 'ids',
     90                        'role'   => 'administrator',
     91                )
     92        );
    9293
    9394        foreach ( $admin_ids as $admin_id ) {
    9495                // Trigger a BuddyPress Notification.
    9596                if ( bp_is_active( 'notifications' ) ) {
    96                         bp_notifications_add_notification( array(
    97                                 'user_id'           => $admin_id,
    98                                 'item_id'           => $signup->signup_id,
    99                                 'component_name'    => buddypress()->members->id,
    100                                 'component_action'  => 'membership_request_submitted',
    101                                 'date_notified'     => bp_core_current_time(),
    102                                 'is_new'            => 1,
    103                         ) );
     97                        bp_notifications_add_notification(
     98                                array(
     99                                        'user_id'          => $admin_id,
     100                                        'item_id'          => $signup->signup_id,
     101                                        'component_name'   => buddypress()->members->id,
     102                                        'component_action' => 'membership_request_submitted',
     103                                        'date_notified'    => bp_core_current_time(),
     104                                        'is_new'           => 1,
     105                                )
     106                        );
    104107                }
    105108
    106109                // Bail if member opted out of receiving this email.
    function bp_members_membership_requests_notify_site_admins( $signup ) { 
    112115                        'user_id'           => $admin_id,
    113116                        'notification_type' => 'members-membership-request',
    114117                );
    115                 $manage_url = add_query_arg( array(
    116                         'mod_req'   => 1,
    117                         'page'      => 'bp-signups',
    118                         'signup_id' => $signup->signup_id,
    119                         'action'    => 'resend',
    120                 ), bp_get_admin_url( 'users.php' ) );
     118
     119                $manage_url = add_query_arg(
     120                        array(
     121                                'mod_req'   => 1,
     122                                'page'      => 'bp-signups',
     123                                'signup_id' => $signup->signup_id,
     124                                'action'    => 'resend',
     125                        ),
     126                        bp_get_admin_url( 'users.php' )
     127                );
     128
    121129                $args  = array(
    122130                        'tokens' => array(
    123131                                'admin.id'                   => $admin_id,
    function bp_members_membership_requests_notify_site_admins( $signup ) { 
    126134                                'unsubscribe'                => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ),
    127135                        ),
    128136                );
     137
    129138                bp_send_email( 'members-membership-request', (int) $admin_id, $args );
    130139        }
    131 
    132140}
    133141add_action( 'bp_members_membership_request_submitted', 'bp_members_membership_requests_notify_site_admins' );
    134142
    function bp_members_membership_requests_send_rejection_mail( $signup_ids ) { 
    146154                        'include' => $signup_ids,
    147155                )
    148156        );
     157
    149158        if ( empty( $signups['signups'] ) ) {
    150159                return;
    151160        }
     161
    152162        foreach ( $signups['signups'] as $signup ) {
    153163                if ( ! empty( $signup->user_email ) ) {
    154164                        bp_send_email( 'members-membership-request-rejected', $signup->user_email );
    function bp_members_membership_requests_filter_signup_row_actions( $actions, $si 
    222232
    223233        $resend_label = ( 0 === $signup_object->count_sent ) ? __( 'Approve Request', 'buddypress' ) : __( 'Resend Approval', 'buddypress' );
    224234
    225         $actions['resend'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $email_link ), $resend_label );
     235        $actions['resend'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $email_link ), esc_html( $resend_label ) );
    226236
    227237        // Add a link to view profile info when membership requests and xprofile are active.
    228238        if ( bp_is_active( 'xprofile' ) ) {
    function bp_members_membership_requests_filter_signup_row_actions( $actions, $si 
    234244                        bp_get_admin_url( 'users.php' )
    235245                );
    236246
    237                 $actions['profile'] = sprintf( '<a href="%1$s" class="thickbox">%2$s</a>', esc_url( $profile_link ), __( 'Profile Info', 'buddypress' ) );
     247                $actions['profile'] = sprintf( '<a href="%1$s" class="bp-thickbox">%2$s</a>', esc_url( $profile_link ), esc_html__( 'Profile Info', 'buddypress' ) );
    238248        }
    239249
    240250        return $actions;
    add_filter( 'bp_members_ms_signup_row_actions', 'bp_members_membership_requests_ 
    246256 *
    247257 * @since 10.0.0
    248258 *
    249  * @param array  $actions       Array of actions and corresponding links.
     259 * @param array $actions Array of actions and corresponding links.
     260 * @return array         List of actions and corresponding links.
    250261 */
    251262function bp_members_membership_requests_filter_signup_bulk_actions( $actions ) {
    252263        // Rename the "email" resend option when membership requests are active.
    253         $actions['resend'] = _x( 'Approve', 'Pending signup action', 'buddypress' );
     264        $actions['resend'] = esc_html_x( 'Approve', 'Pending signup action', 'buddypress' );
    254265        return $actions;
    255266}
    256267add_filter( 'bp_members_ms_signup_bulk_actions', 'bp_members_membership_requests_filter_signup_bulk_actions' );
    add_filter( 'bp_members_ms_signup_bulk_actions', 'bp_members_membership_requests 
    260271 *
    261272 * @since 10.0.0
    262273 *
    263 * @param array $value Array of columns to display.
     274 * @param array $columns Array of columns to display.
     275 * @return array List of columns to display.
    264276 */
    265277function bp_members_membership_requests_filter_signup_table_date_sent_header( $columns ) {
    266         $columns['date_sent'] = __( 'Approved', 'buddypress' );
     278        $columns['date_sent'] = esc_html__( 'Approved', 'buddypress' );
    267279        return $columns;
    268280}
    269281add_filter( 'bp_members_signup_columns', 'bp_members_membership_requests_filter_signup_table_date_sent_header' );
    add_filter( 'bp_members_ms_signup_columns', 'bp_members_membership_requests_filt 
    276288 *
    277289 * @param string      $message "Not yet sent" message.
    278290 * @param object|null $signup  Signup object instance.
     291 * @return string              "Not yet approved" message, if needed. Unchanged message otherwise.
    279292 */
    280293function bp_members_membership_requests_filter_signup_table_unsent_message( $message, $signup ) {
    281294        if ( 0 === $signup->count_sent ) {
    282                 $message = __( 'Not yet approved', 'buddypress' );
     295                $message = esc_html__( 'Not yet approved', 'buddypress' );
    283296        }
     297
    284298        return $message;
    285299}
    286300add_filter( 'bp_members_signup_date_sent_unsent_message', 'bp_members_membership_requests_filter_signup_table_unsent_message', 10, 2 );
    add_filter( 'bp_members_ms_signup_date_sent_unsent_message', 'bp_members_members 
    288302
    289303/**
    290304 * Filter/add "Request Membership" links in the following locations:
    291  * BP login widget
    292  * sidebar register link
    293  * WP Toolbar
    294  * WP login form
     305 * - BP login widget,
     306 * - Sidebar register link,
     307 * - WP Toolbar,
     308 * - WP login form.
    295309 *********************************************************************/
    296310
    297311/**
    add_action( 'bp_login_widget_form', 'bp_members_membership_requests_add_link_to_ 
    315329 * @since 10.0.0
    316330 *
    317331 * @param string $link The HTML code for the link to the Registration or Admin page.
     332 * @return string      An empty string or the HTML code for the link to the Membership request page.
    318333 */
    319334function bp_members_membership_requests_filter_sidebar_register_link( $link ) {
    320335        // $link should be an empty string when public registration is disabled.
    321336        if ( ! is_user_logged_in() && empty( $link ) ) {
    322                 // @TODO: How can we know what before and after tags should be?
    323                 $link = '<li><a href="' . esc_url( wp_registration_url() ) . '">' . __( 'Request Membership' ) . '</a><li>';
     337                $link = '<a href="' . esc_url( wp_registration_url() ) . '">' . esc_html__( 'Request Membership', 'buddypress' ) . '</a>';
    324338        }
     339
    325340        return $link;
    326341}
    327342add_filter( 'register', 'bp_members_membership_requests_filter_sidebar_register_link' );
    function bp_members_membership_requests_add_toolbar_link( $wp_admin_bar ) { 
    341356
    342357        $args = array(
    343358                'id'    => 'bp-request-membership',
    344                 'title' => __( 'Request Membership' ),
     359                'title' => __( 'Request Membership', 'buddypress' ),
    345360                'href'  => wp_registration_url(),
    346361                'meta'  => array(
    347362                        'class' => 'buddypress-request-membership',
    348                         'title' => __( 'Request Membership' )
     363                        'title' => __( 'Request Membership', 'buddypress' ),
    349364                ),
    350365        );
     366
    351367        $wp_admin_bar->add_node( $args );
    352368}
    353369add_action( 'admin_bar_menu', 'bp_members_membership_requests_add_toolbar_link', 21 );
    add_action( 'admin_bar_menu', 'bp_members_membership_requests_add_toolbar_link', 
    358374 * @since 10.0.0
    359375 *
    360376 * @param string $link HTML link to the home URL of the current site.
     377 * @return string      HTML link to the home URL of the current site and the one to request a membership.
    361378 */
    362379function bp_members_membership_requests_add_link_wp_login( $link ) {
    363         return $link . '&ensp;|&ensp;' . '<a href="' . esc_url( wp_registration_url() ) . '">' . __( 'Request Membership' ) . '</a>';
     380        $link_separator = apply_filters( 'login_link_separator', ' | ' );
     381
     382        return $link . $link_separator . '<a href="' . esc_url( wp_registration_url() ) . '">' . esc_html__( 'Request Membership', 'buddypress' ) . '</a>';
    364383}
    365384add_action( 'login_site_html_link', 'bp_members_membership_requests_add_link_wp_login' );
  • src/bp-members/bp-members-notifications.php

    diff --git src/bp-members/bp-members-notifications.php src/bp-members/bp-members-notifications.php
    index 34c2677e9..b84a0938a 100644
    function bp_members_mark_read_accepted_invitation_notification() { 
    191191                        'is_new' => false,
    192192                ),
    193193                array(
    194                         'user_id'           => bp_loggedin_user_id(),
    195                         'item_id'           => bp_displayed_user_id(),
    196                         'component_action'  => 'accepted_invitation',
     194                        'user_id'          => bp_loggedin_user_id(),
     195                        'item_id'          => bp_displayed_user_id(),
     196                        'component_action' => 'accepted_invitation',
    197197                )
    198198        );
    199199}
  • src/bp-members/classes/class-bp-members-admin.php

    diff --git src/bp-members/classes/class-bp-members-admin.php src/bp-members/classes/class-bp-members-admin.php
    index 7c352d0c1..6c94cf20c 100644
    class BP_Members_Admin { 
    16931693                 */
    16941694                $allowed_actions = apply_filters( 'bp_signups_admin_allowed_actions', array( 'do_delete', 'do_activate', 'do_resend' ) );
    16951695
    1696                 // Prepare the display of the Community Profile screen.
     1696                // Prepare the display of the Signups screen.
    16971697                if ( ! in_array( $doaction, $allowed_actions ) || ( -1 == $doaction ) ) {
    16981698
    16991699                        if ( is_network_admin() ) {
    class BP_Members_Admin { 
    17151715                                '<p>' . __( 'Using the search form, you can find pending accounts more easily. The Username and Email fields will be included in the search.', 'buddypress' ) . '</p>'
    17161716                        ) );
    17171717
    1718                         $signup_help_content = '<p>' . __( 'Hovering over a row in the pending accounts list will display action links that allow you to manage pending accounts. You can perform the following actions:', 'buddypress' ) . '</p>';
     1718                        $signup_help_content = '<p>' . esc_html__( 'Hovering over a row in the pending accounts list will display action links that allow you to manage pending accounts. You can perform the following actions:', 'buddypress' ) . '</p>';
    17191719
    17201720                        if ( bp_get_membership_requests_required() ) {
    1721                                 $signup_help_content .= '<ul><li>' . __( '"Activate" will activate the user immediately without requiring that they validate their email.', 'buddypress' ) .'</li>' .
    1722                                         '<li>' . __( '"Approve Request"/"Resend Apprival" takes you to the confirmation screen before being able to send the activation link to the desired pending request. You can only send the activation email once per day.', 'buddypress' ) . '</li>';
     1721                                $signup_help_content .= '<ul><li>' . esc_html__( '"Activate" will activate the user immediately without requiring that they validate their email.', 'buddypress' ) .'</li>' .
     1722                                        '<li>' . esc_html__( '"Approve Request" or "Resend Approval" takes you to the confirmation screen before being able to send the activation link to the desired pending request. You can only send the activation email once per day.', 'buddypress' ) . '</li>';
    17231723
    17241724                                if ( bp_is_active( 'xprofile' ) ) {
    1725                                         $signup_help_content .= '<li>' . __( '"Profile Info" will display extended profile information for the request.', 'buddypress' ) . '</li>';
     1725                                        $signup_help_content .= '<li>' . esc_html__( '"Profile Info" will display extended profile information for the request.', 'buddypress' ) . '</li>';
    17261726                                }
    17271727
    1728                                 $signup_help_content .= '<li>' . __( '"Delete" allows you to delete a pending account from your site. You will be asked to confirm this deletion.', 'buddypress' ) . '</li></ul>';
     1728                                $signup_help_content .= '<li>' . esc_html__( '"Delete" allows you to delete a pending account from your site. You will be asked to confirm this deletion.', 'buddypress' ) . '</li></ul>';
    17291729                        } else {
    1730                                 $signup_help_content .= '<ul><li>' . __( '"Email" takes you to the confirmation screen before being able to send the activation link to the desired pending account. You can only send the activation email once per day.', 'buddypress' ) . '</li>' .
     1730                                $signup_help_content .= '<ul><li>' . esc_html__( '"Email" takes you to the confirmation screen before being able to send the activation link to the desired pending account. You can only send the activation email once per day.', 'buddypress' ) . '</li>' .
    17311731                                        '<li>' . __( '"Delete" allows you to delete a pending account from your site. You will be asked to confirm this deletion.', 'buddypress' ) . '</li></ul>';
    17321732                        }
    17331733
    1734                         $signup_help_content .= '<p>' . __( 'By clicking on a Username you will be able to activate a pending account from the confirmation screen.', 'buddypress' ) . '</p>' .
     1734                        $signup_help_content .= '<p>' . esc_html__( 'By clicking on a Username you will be able to activate a pending account from the confirmation screen.', 'buddypress' ) . '</p>' .
    17351735                                '<p>' . __( 'Bulk actions allow you to perform these 3 actions for the selected rows.', 'buddypress' ) . '</p>';
    17361736
    17371737                        get_current_screen()->add_help_tab( array(
    class BP_Members_Admin { 
    17421742
    17431743                        // Help panel - sidebar links.
    17441744                        get_current_screen()->set_help_sidebar(
    1745                                 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
     1745                                '<p><strong>' . esc_html__( 'For more information:', 'buddypress' ) . '</strong></p>' .
    17461746                                '<p>' . __( '<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
    17471747                        );
    17481748
    class BP_Members_Admin { 
    17561756                                'heading_list'       => __( 'Pending users list', 'buddypress' ),
    17571757                        ) );
    17581758
     1759                        // Use thickbox to display the extended profile information.
     1760                        if ( bp_is_active( 'xprofile' ) ) {
     1761                                wp_enqueue_style( 'thickbox' );
     1762                                wp_enqueue_script(
     1763                                        'bp-signup-preview',
     1764                                        $this->js_url . 'signup-preview' . bp_core_get_minified_asset_suffix() . '.js',
     1765                                        array( 'bp-thickbox', 'jquery' ),
     1766                                        bp_get_version(),
     1767                                        true
     1768                                );
     1769                                wp_localize_script(
     1770                                        'bp-signup-preview',
     1771                                        'bpSignupPreview',
     1772                                        array(
     1773                                                'modalLabel' => __( 'Profile info preview', 'buddypress' ),
     1774                                        )
     1775                                );
     1776                        }
     1777
    17591778                } else {
    17601779                        if ( ! empty( $_REQUEST['signup_ids' ] ) ) {
    17611780                                $signups = wp_parse_id_list( $_REQUEST['signup_ids' ] );
    class BP_Members_Admin { 
    23512370                                                                                $field_value = isset( $signup->meta[ "field_{$pid}" ] ) ? $signup->meta[ "field_{$pid}" ] : ''; ?>
    23522371                                                                                <tr>
    23532372                                                                                        <td class="column-fields"><?php echo esc_html( $fdata[ $pid ] ); ?></td>
    2354                                                                                         <td><?php echo $this->format_xprofile_field_for_display( $field_value ); ?></td>
     2373                                                                                        <td><?php echo bp_members_admin_format_xprofile_field_for_display( $field_value ); ?></td>
    23552374                                                                                </tr>
    23562375
    23572376                                                                        <?php endforeach;  ?>
    class BP_Members_Admin { 
    26572676         * Operates recursively on arrays, which are then imploded with commas.
    26582677         *
    26592678         * @since 2.8.0
     2679         * @deprecated 10.0.0
    26602680         *
    26612681         * @param string|array $value Field value.
    26622682         * @return string
    26632683         */
    26642684        protected function format_xprofile_field_for_display( $value ) {
    2665                 if ( is_array( $value ) ) {
    2666                         $value = array_map( array( $this, 'format_xprofile_field_for_display' ), $value );
    2667                         $value = implode( ', ', $value );
    2668                 } else {
    2669                         $value = stripslashes( $value );
    2670                         $value = esc_html( $value );
    2671                 }
     2685                _deprecated_function( __METHOD__, '10.0.0', 'bp_members_admin_format_xprofile_field_for_display' );
    26722686
    2673                 return $value;
     2687                return bp_members_admin_format_xprofile_field_for_display( $value );
    26742688        }
    26752689
    26762690        /**
  • src/bp-members/classes/class-bp-members-component.php

    diff --git src/bp-members/classes/class-bp-members-component.php src/bp-members/classes/class-bp-members-component.php
    index 135fb10ca..dca58193e 100644
    class BP_Members_Component extends BP_Component { 
    4040                        array(
    4141                                'adminbar_myaccount_order' => 20,
    4242                                'search_query_arg'         => 'members_search',
    43                                 'features'                 => array( 'invitations', 'membership_requests' )
     43                                'features'                 => array( 'invitations', 'membership_requests' ),
    4444                        )
    4545                );
    4646        }
  • src/bp-members/classes/class-bp-members-list-table.php

    diff --git src/bp-members/classes/class-bp-members-list-table.php src/bp-members/classes/class-bp-members-list-table.php
    index d9922b1fe..0dcf21d7c 100644
    class BP_Members_List_Table extends WP_Users_List_Table { 
    2626         */
    2727        public $signup_counts = 0;
    2828
     29        /**
     30         * Signup profile fields.
     31         *
     32         * @since 10.0.0
     33         *
     34         * @var array
     35         */
     36        public $signup_field_labels = array();
     37
    2938        /**
    3039         * Constructor.
    3140         *
    class BP_Members_List_Table extends WP_Users_List_Table { 
    113122
    114123                // Reset the screen id.
    115124                $this->screen->id = $reset_screen_id;
    116 
    117                 // Use thickbox to display the extended profile information.
    118                 if ( bp_is_active( 'xprofile' ) ) {
    119                         add_thickbox();
    120                 }
    121125        }
    122126
    123127        /**
    class BP_Members_List_Table extends WP_Users_List_Table { 
    364368
    365369                $profile_field_ids = array();
    366370
    367                 // Prefetch registration field data.
    368                 $fdata = array();
    369                 $field_groups = bp_xprofile_get_groups( array(
    370                         'exclude_fields'    => 1,
    371                         'update_meta_cache' => false,
    372                         'fetch_fields'      => true,
    373                 ) );
    374 
    375                 foreach( $field_groups as $fg ) {
    376                         foreach( $fg->fields as $f ) {
    377                                 $fdata[ $f->id ] = $f->name;
     371                // Fetch registration field data once only.
     372                if ( ! $this->signup_field_labels ) {
     373                        $field_groups = bp_xprofile_get_groups(
     374                                array(
     375                                        'fetch_fields'       => true,
     376                                        'signup_fields_only' => true,
     377                                )
     378                        );
     379
     380                        foreach( $field_groups as $field_group ) {
     381                                foreach( $field_group->fields as $field ) {
     382                                        $this->signup_field_labels[ $field->id ] = $field->name;
     383                                }
    378384                        }
    379385                }
    380386
    381                 // Get all xprofile field IDs except field 1.
    382                 if ( ! empty( $signup_object->meta['profile_field_ids'] ) ) {
    383                         $profile_field_ids = array_flip( explode( ',', $signup_object->meta['profile_field_ids'] ) );
    384                         unset( $profile_field_ids[1] );
    385                 }
    386                 ?>
    387                 <div id="signup-info-modal-<?php echo $signup_object->id; ?>" style="display:none;">
    388                         <h1><?php printf( esc_html__( '%1$s (%2$s)', 'buddypress' ), esc_html( $signup_object->user_name ), esc_html( $signup_object->user_email ) ); ?></h1>
    389                         <h2><?php echo esc_html__( 'Extended Profile Information', 'buddypress' ); ?></h2>
    390 
    391                         <table class="signup-profile-data-drawer wp-list-table widefat fixed striped">
    392                                 <?php if ( 1 <= count( $profile_field_ids ) ): foreach ( $profile_field_ids as $pid => $noop ) :
    393                                         $field_value = isset( $signup_object->meta[ "field_{$pid}" ] ) ? $signup_object->meta[ "field_{$pid}" ] : ''; ?>
    394                                         <tr>
    395                                                 <td class="column-fields"><?php echo esc_html( $fdata[ $pid ] ); ?></td>
    396                                                 <td><?php echo $this->format_xprofile_field_for_display( $field_value ); ?></td>
    397                                         </tr>
    398                                 <?php endforeach; else:  ?>
    399                                         <tr>
    400                                                 <td><?php esc_html_e( 'There is no additional information to display.', 'buddypress' ); ?></td>
    401                                         </tr>
    402                                 <?php endif; ?>
    403                         </table>
    404                 </div>
    405                 <?php
     387                bp_members_admin_preview_signup_profile_info( $this->signup_field_labels, $signup_object );
    406388        }
    407389
    408390        /**
    class BP_Members_List_Table extends WP_Users_List_Table { 
    424406         * @param object|null $signup_object The signup data object.
    425407         */
    426408        public function column_registered( $signup_object = null ) {
    427                 echo mysql2date( 'Y/m/d', $signup_object->registered );
     409                echo mysql2date( 'Y/m/d g:i:s a', $signup_object->registered );
    428410        }
    429411
    430412        /**
    class BP_Members_List_Table extends WP_Users_List_Table { 
    436418         */
    437419        public function column_date_sent( $signup_object = null ) {
    438420                if ( $signup_object->count_sent > 0 ) {
    439                         echo mysql2date( 'Y/m/d', $signup_object->date_sent );
     421                        echo mysql2date( 'Y/m/d g:i:s a', $signup_object->date_sent );
    440422                } else {
    441423                        $message = __( 'Not yet notified', 'buddypress' );
    442424
    class BP_Members_List_Table extends WP_Users_List_Table { 
    487469                 */
    488470                return apply_filters( 'bp_members_signup_custom_column', '', $column_name, $signup_object );
    489471        }
    490 
    491         /**
    492          * Formats a signup's xprofile field data for display.
    493          *
    494          * Operates recursively on arrays, which are then imploded with commas.
    495          *
    496          * @since 10.0.0
    497          * @see BP_Members_Admin::format_xprofile_field_for_display()
    498          *
    499          * @param string|array $value Field value.
    500          * @return string
    501          */
    502         protected function format_xprofile_field_for_display( $value ) {
    503                 if ( is_array( $value ) ) {
    504                         $value = array_map( array( $this, 'format_xprofile_field_for_display' ), $value );
    505                         $value = implode( ', ', $value );
    506                 } else {
    507                         $value = stripslashes( $value );
    508                         $value = esc_html( $value );
    509                 }
    510 
    511                 return $value;
    512         }
    513472}
  • src/bp-members/classes/class-bp-members-ms-list-table.php

    diff --git src/bp-members/classes/class-bp-members-ms-list-table.php src/bp-members/classes/class-bp-members-ms-list-table.php
    index 662146c78..318506ae1 100644
    class BP_Members_MS_List_Table extends WP_MS_Users_List_Table { 
    350350
    351351                $profile_field_ids = array();
    352352
    353                 // Prefetch registration field data.
    354                 $fdata = array();
    355                 $field_groups = bp_xprofile_get_groups( array(
    356                         'exclude_fields'    => 1,
    357                         'update_meta_cache' => false,
    358                         'fetch_fields'      => true,
    359                 ) );
    360 
    361                 foreach( $field_groups as $fg ) {
    362                         foreach( $fg->fields as $f ) {
    363                                 $fdata[ $f->id ] = $f->name;
     353                // Fetch registration field data once only.
     354                if ( ! $this->signup_field_labels ) {
     355                        $field_groups = bp_xprofile_get_groups(
     356                                array(
     357                                        'fetch_fields'       => true,
     358                                        'signup_fields_only' => true,
     359                                )
     360                        );
     361
     362                        foreach( $field_groups as $field_group ) {
     363                                foreach( $field_group->fields as $field ) {
     364                                        $this->signup_field_labels[ $field->id ] = $field->name;
     365                                }
    364366                        }
    365367                }
    366368
    367                 // Get all xprofile field IDs except field 1.
    368                 if ( ! empty( $signup_object->meta['profile_field_ids'] ) ) {
    369                         $profile_field_ids = array_flip( explode( ',', $signup_object->meta['profile_field_ids'] ) );
    370                         unset( $profile_field_ids[1] );
    371                 }
    372                 ?>
    373                 <div id="signup-info-modal-<?php echo $signup_object->id; ?>" style="display:none;">
    374                         <h1><?php printf( esc_html__( '%1$s (%2$s)', 'buddypress' ), esc_html( $signup_object->user_name ), esc_html( $signup_object->user_email ) ); ?></h1>
    375                         <h2><?php echo esc_html__( 'Extended Profile Information', 'buddypress' ); ?></h2>
    376 
    377                         <table class="signup-profile-data-drawer wp-list-table widefat fixed striped">
    378                                 <?php if ( 1 <= count( $profile_field_ids ) ): foreach ( $profile_field_ids as $pid => $noop ) :
    379                                         $field_value = isset( $signup_object->meta[ "field_{$pid}" ] ) ? $signup_object->meta[ "field_{$pid}" ] : ''; ?>
    380                                         <tr>
    381                                                 <td class="column-fields"><?php echo esc_html( $fdata[ $pid ] ); ?></td>
    382                                                 <td><?php echo $this->format_xprofile_field_for_display( $field_value ); ?></td>
    383                                         </tr>
    384                                 <?php endforeach;else:  ?>
    385                                         <tr>
    386                                                 <td><?php esc_html_e( 'There is no additional information to display.', 'buddypress' ); ?></td>
    387                                         </tr>
    388                                 <?php endif; ?>
    389                         </table>
    390                 </div>
    391                 <?php
     369                bp_members_admin_preview_signup_profile_info( $this->signup_field_labels, $signup_object );
    392370        }
    393371
    394372        /**
    class BP_Members_MS_List_Table extends WP_MS_Users_List_Table { 
    489467                 */
    490468                return apply_filters( 'bp_members_ms_signup_custom_column', '', $column_name, $signup_object );
    491469        }
    492 
    493         /**
    494          * Formats a signup's xprofile field data for display.
    495          *
    496          * Operates recursively on arrays, which are then imploded with commas.
    497          *
    498          * @since 10.0.0
    499          * @see BP_Members_Admin::format_xprofile_field_for_display()
    500          *
    501          * @param string|array $value Field value.
    502          * @return string
    503          */
    504         protected function format_xprofile_field_for_display( $value ) {
    505                 if ( is_array( $value ) ) {
    506                         $value = array_map( array( $this, 'format_xprofile_field_for_display' ), $value );
    507                         $value = implode( ', ', $value );
    508                 } else {
    509                         $value = stripslashes( $value );
    510                         $value = esc_html( $value );
    511                 }
    512 
    513                 return $value;
    514         }
    515470}