Skip to:
Content

BuddyPress.org

Changeset 12397


Ignore:
Timestamp:
05/18/2019 06:57:54 AM (6 years ago)
Author:
imath
Message:

BP Nouveau: use the same control than WP to set the user password

On the BuddyPress registration page and on the general settings user’s page, BP Nouveau is now using the same control WordPress is using to let users choose their password. By default it generates a strong password to make the user aware of the importance of its robustness. The user can still edit it and if the password is too weak, the submit button is disabled until the user activates the checkbox to force the use of a weak password.

Developers, please note the src/bp-templates/bp-nouveau/js/password-verify.js is now deprecated and will be deleted in version 6.0.0. If you were using the bp-nouveau-password-verify script handle as a dependency of your script(s), please stop doing so before the 6.0.0 release.

Fixes #8092

Location:
trunk/src/bp-templates/bp-nouveau
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-nouveau/buddypress-functions.php

    r12240 r12397  
    325325        // Add The password verify if needed.
    326326        if ( bp_is_active( 'settings' ) || bp_get_signup_allowed() ) {
     327            /**
     328             * BP Nouveau is now directly using the `wp-admin/js/user-profile.js` script.
     329             *
     330             * Setting the user password is now more consistent with how WordPress handles it.
     331             *
     332             * @deprecated 5.0.0
     333             */
    327334            $scripts['bp-nouveau-password-verify'] = array(
    328335                'file'         => 'js/password-verify%s.js',
     
    373380
    374381        if ( bp_is_register_page() || bp_is_user_settings_general() ) {
    375             wp_enqueue_script( 'bp-nouveau-password-verify' );
     382            wp_enqueue_script( 'user-profile' );
    376383        }
    377384
  • trunk/src/bp-templates/bp-nouveau/buddypress/members/single/settings/general.php

    r12156 r12397  
    44 *
    55 * @since 3.0.0
    6  * @version 3.1.0
     6 * @version 5.0.0
    77 */
    88
     
    1010
    1111<h2 class="screen-heading general-settings-screen">
    12     <?php _e( 'Email & Password', 'buddypress' ); ?>
     12    <?php esc_html_e( 'Email & Password', 'buddypress' ); ?>
    1313</h2>
    1414
    1515<p class="info email-pwd-info">
    16     <?php _e( 'Update your email and or password.', 'buddypress' ); ?>
     16    <?php esc_html_e( 'Update your email and or password.', 'buddypress' ); ?>
    1717</p>
    1818
    19 <form action="<?php echo esc_url( bp_displayed_user_domain() . bp_get_settings_slug() . '/general' ); ?>" method="post" class="standard-form" id="settings-form">
     19<form action="<?php echo esc_url( bp_displayed_user_domain() . bp_get_settings_slug() . '/general' ); ?>" method="post" class="standard-form" id="your-profile">
    2020
    2121    <?php if ( ! is_super_admin() ) : ?>
    2222
    23         <label for="pwd"><?php _e( 'Current Password <span>(required to update email or change current password)</span>', 'buddypress' ); ?></label>
    24         <input type="password" name="pwd" id="pwd" size="16" value="" class="settings-input small" <?php bp_form_field_attributes( 'password' ); ?>/> &nbsp;<a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php esc_html_e( 'Lost your password?', 'buddypress' ); ?></a>
     23        <label for="pwd"><?php printf( esc_html__( 'Current Password %s', 'buddypress' ), '<span>' . esc_html__( '(required to update email or change current password)', 'buddypress' ) . '</span>' ); ?></label>
     24        <input type="password" name="pwd" id="pwd" value="" size="24" class="settings-input small" <?php bp_form_field_attributes( 'password' ); ?>/> &nbsp;<a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php esc_html_e( 'Lost your password?', 'buddypress' ); ?></a>
    2525
    2626    <?php endif; ?>
    2727
    28     <label for="email"><?php _e( 'Account Email', 'buddypress' ); ?></label>
     28    <label for="email"><?php esc_html_e( 'Account Email', 'buddypress' ); ?></label>
    2929    <input type="email" name="email" id="email" value="<?php echo esc_attr( bp_get_displayed_user_email() ); ?>" class="settings-input" <?php bp_form_field_attributes( 'email' ); ?>/>
    3030
    3131    <div class="info bp-feedback">
    3232        <span class="bp-icon" aria-hidden="true"></span>
    33         <p class="text"><?php esc_html_e( 'Leave password fields blank for no change', 'buddypress' ); ?></p>
     33        <p class="text"><?php esc_html_e( 'Click on the "Generate Password" button to change your password.', 'buddypress' ); ?></p>
    3434    </div>
    3535
    36     <label for="pass1"><?php esc_html_e( 'Add Your New Password', 'buddypress' ); ?></label>
    37     <input type="password" name="pass1" id="pass1" size="16" value="" class="settings-input small password-entry" <?php bp_form_field_attributes( 'password' ); ?>/>
     36    <div class="user-pass1-wrap">
     37        <button type="button" class="button wp-generate-pw">
     38            <?php esc_html_e( 'Generate Password', 'buddypress' ); ?>
     39        </button>
    3840
    39     <label for="pass2" class="repeated-pwd"><?php esc_html_e( 'Repeat Your New Password', 'buddypress' ); ?></label>
    40     <input type="password" name="pass2" id="pass2" size="16" value="" class="settings-input small password-entry-confirm" <?php bp_form_field_attributes( 'password' ); ?>/>
     41        <div class="wp-pwd">
     42            <label for="pass1"><?php esc_html_e( 'Add Your New Password', 'buddypress' ); ?></label>
     43            <span class="password-input-wrapper">
     44                <input type="password" name="pass1" id="pass1" size="24" class="settings-input small password-entry" value="" <?php bp_form_field_attributes( 'password', array( 'data-pw' => wp_generate_password( 24 ), 'aria-describedby' => 'pass-strength-result' ) ); ?> />
     45            </span>
     46            <button type="button" class="button wp-hide-pw" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password', 'buddypress' ); ?>">
     47                <span class="dashicons dashicons-hidden" aria-hidden="true"></span>
     48                <span class="text bp-screen-reader-text"><?php esc_html_e( 'Hide', 'buddypress' ); ?></span>
     49            </button>
     50            <button type="button" class="button wp-cancel-pw" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change', 'buddypress' ); ?>">
     51                <span class="text"><?php esc_html_e( 'Cancel', 'buddypress' ); ?></span>
     52            </button>
     53            <div id="pass-strength-result" aria-live="polite"></div>
     54        </div>
     55    </div>
    4156
    42     <div id="pass-strength-result"></div>
     57    <div class="user-pass2-wrap">
     58        <label class="label" for="pass2"><?php esc_html_e( 'Repeat Your New Password', 'buddypress' ); ?></label>
     59        <input name="pass2" type="password" id="pass2" size="24" class="settings-input small password-entry-confirm" value="" <?php bp_form_field_attributes( 'password' ); ?> />
     60    </div>
     61
     62    <div class="pw-weak">
     63        <label>
     64            <input type="checkbox" name="pw_weak" class="pw-checkbox" />
     65            <span id="pw-weak-text-label"><?php esc_html_e( 'Confirm use of potentially weak password', 'buddypress' ); ?></span>
     66        </label>
     67    </div>
    4368
    4469    <?php bp_nouveau_submit_button( 'members-general-settings' ); ?>
  • trunk/src/bp-templates/bp-nouveau/common-styles/_bp-mixins.scss

    r12082 r12397  
    533533}
    534534
     535@mixin pwd-strong-colors($color: inherit, $background: null, $border: null) {
     536
     537    @if $background {
     538        $background: $background;
     539    } @else {
     540        $background: $background-strong;
     541    }
     542
     543    background-color: $background;
     544
     545    @if $border {
     546        $border: $border;
     547    } @else {
     548        $border: $border-strong;
     549    }
     550
     551    border-color: $border;
     552
     553    color: $color;
     554}
     555
    535556// BP Tooltips
    536557
  • trunk/src/bp-templates/bp-nouveau/common-styles/_bp-variables.scss

    r12082 r12397  
    7070$background-short:  #ffa0a0 !default;
    7171$border-short:      #f04040 !default;
    72 $background-good:   #66d66e !default;
    73 $border-good:       #438c48 !default;
     72$background-good:   #ffec8b !default;
     73$border-good:       #fc0 !default;
     74$background-strong: #66d66e !default;
     75$border-strong:     #438c48 !default;
    7476$background-bad:    #ffb78c !default;
    7577$border-bad:        #ff853c !default;
  • trunk/src/bp-templates/bp-nouveau/common-styles/_bp_forms.scss

    r12082 r12397  
    133133        }
    134134
    135         input:not(.button-small),
     135        input:not(.small),
    136136        textarea {
    137137            width: 100%;
  • trunk/src/bp-templates/bp-nouveau/common-styles/_bp_info_messages.scss

    r12082 r12397  
    260260        &.bad {
    261261
    262             @include pwd-bad-colors($color: $white);
     262            @include pwd-bad-colors($color: $black);
    263263        }
    264264
    265265        &.short {
    266266
    267             @include pwd-short-colors($color: $white);
     267            @include pwd-short-colors($color: $black);
     268        }
     269
     270        &.good {
     271
     272            @include pwd-good-colors($color: $black);
    268273        }
    269274
    270275        &.strong {
    271276
    272             @include pwd-good-colors($color: $white);
     277            @include pwd-strong-colors($color: $black);
    273278        }
    274279
  • trunk/src/bp-templates/bp-nouveau/common-styles/_bp_registration.scss

    r12082 r12397  
    5252        }
    5353
     54        .wp-pwd button {
     55            vertical-align: middle;
     56        }
     57
     58        #pass1,
     59        #pass1-text,
     60        #pass-strength-result {
     61            width: 10em;
     62        }
     63
     64        #pass1 {
     65            display: inline-block;
     66            margin-bottom: inherit;
     67        }
     68
     69        #pass1-text,
     70        .pw-weak {
     71            display: none;
     72        }
     73
     74        .show-password {
     75
     76            #pass1-text {
     77                display: inline-block;
     78                margin-bottom: inherit;
     79            }
     80
     81            #pass1 {
     82                display: none;
     83            }
     84        }
     85
     86        .description.indicator-hint {
     87
     88            @include font-size(14);
     89        }
     90
     91        #submit:disabled {
     92            color: $light-text;
     93            opacity: 0.4;
     94        }
     95
    5496        .password-entry,
    5597        .password-entry-confirm {
     
    59101
    60102} // close .register-page
     103
     104body.buddypress.register.js {
     105
     106    .user-pass2-wrap {
     107        display: none;
     108    }
     109}
     110
     111body.buddypress.register.no-js {
     112
     113    .wp-hide-pw {
     114        display: none;
     115    }
     116}
    61117
    62118// Flex layout containers for registration sections
     
    102158
    103159            .default-profile {
     160                min-width: 14em;
    104161                flex: 1;
    105162                padding-right: $pad-med;
  • trunk/src/bp-templates/bp-nouveau/common-styles/_bp_user_settings.scss

    r12394 r12397  
    2929
    3030/*__ General __*/
     31body.buddypress.settings {
    3132
     33    .wp-pwd button {
     34        vertical-align: middle;
     35    }
     36
     37    #pass1,
     38    #pass1-text,
     39    #pass-strength-result {
     40        width: 16em;
     41    }
     42
     43    #pass1 {
     44        display: inline-block;
     45        margin-bottom: inherit;
     46    }
     47
     48    #pass1-text,
     49    .pw-weak,
     50    #pass-strength-result {
     51        display: none;
     52    }
     53
     54    .show-password {
     55
     56        #pass1-text {
     57            display: inline-block;
     58            margin-bottom: inherit;
     59        }
     60
     61        #pass1 {
     62            display: none;
     63        }
     64    }
     65
     66    #your-profile {
     67
     68        #submit:disabled {
     69            color: $light-text;
     70            opacity: 0.4;
     71        }
     72    }
     73}
     74
     75body.buddypress.settings.js {
     76
     77    .wp-pwd,
     78    .user-pass2-wrap {
     79        display: none;
     80    }
     81}
     82
     83body.buddypress.settings.no-js {
     84
     85    .wp-generate-pw,
     86    .wp-cancel-pw,
     87    .wp-hide-pw {
     88        display: none;
     89    }
     90}
    3291
    3392// Email notifications
  • trunk/src/bp-templates/bp-nouveau/css/buddypress-rtl.css

    r12394 r12397  
    19471947}
    19481948
     1949.register-page .signup-form .wp-pwd button {
     1950    vertical-align: middle;
     1951}
     1952
     1953.register-page .signup-form #pass1,
     1954.register-page .signup-form #pass1-text,
     1955.register-page .signup-form #pass-strength-result {
     1956    width: 10em;
     1957}
     1958
     1959.register-page .signup-form #pass1 {
     1960    display: inline-block;
     1961    margin-bottom: inherit;
     1962}
     1963
     1964.register-page .signup-form #pass1-text,
     1965.register-page .signup-form .pw-weak {
     1966    display: none;
     1967}
     1968
     1969.register-page .signup-form .show-password #pass1-text {
     1970    display: inline-block;
     1971    margin-bottom: inherit;
     1972}
     1973
     1974.register-page .signup-form .show-password #pass1 {
     1975    display: none;
     1976}
     1977
     1978.register-page .signup-form .description.indicator-hint {
     1979    font-size: 14px;
     1980}
     1981
     1982.register-page .signup-form #submit:disabled {
     1983    color: #767676;
     1984    opacity: 0.4;
     1985}
     1986
    19491987.register-page .signup-form .password-entry,
    19501988.register-page .signup-form .password-entry-confirm {
    19511989    border: 1px solid #eee;
     1990}
     1991
     1992body.buddypress.register.js .user-pass2-wrap {
     1993    display: none;
     1994}
     1995
     1996body.buddypress.register.no-js .wp-hide-pw {
     1997    display: none;
    19521998}
    19531999
     
    19732019@media screen and (min-width: 46.8em) {
    19742020    .buddypress-wrap.extended-default-reg .register-page .default-profile {
     2021        min-width: 14em;
    19752022        flex: 1;
    19762023        padding-left: 1em;
     
    32213268
    32223269/*__ General __*/
     3270body.buddypress.settings .wp-pwd button {
     3271    vertical-align: middle;
     3272}
     3273
     3274body.buddypress.settings #pass1,
     3275body.buddypress.settings #pass1-text,
     3276body.buddypress.settings #pass-strength-result {
     3277    width: 16em;
     3278}
     3279
     3280body.buddypress.settings #pass1 {
     3281    display: inline-block;
     3282    margin-bottom: inherit;
     3283}
     3284
     3285body.buddypress.settings #pass1-text,
     3286body.buddypress.settings .pw-weak,
     3287body.buddypress.settings #pass-strength-result {
     3288    display: none;
     3289}
     3290
     3291body.buddypress.settings .show-password #pass1-text {
     3292    display: inline-block;
     3293    margin-bottom: inherit;
     3294}
     3295
     3296body.buddypress.settings .show-password #pass1 {
     3297    display: none;
     3298}
     3299
     3300body.buddypress.settings #your-profile #submit:disabled {
     3301    color: #767676;
     3302    opacity: 0.4;
     3303}
     3304
     3305body.buddypress.settings.js .wp-pwd,
     3306body.buddypress.settings.js .user-pass2-wrap {
     3307    display: none;
     3308}
     3309
     3310body.buddypress.settings.no-js .wp-generate-pw,
     3311body.buddypress.settings.no-js .wp-cancel-pw,
     3312body.buddypress.settings.no-js .wp-hide-pw {
     3313    display: none;
     3314}
     3315
    32233316/*__ Email notifications __*/
    32243317/*__ Profile visibility __*/
     
    33363429}
    33373430
    3338 .buddypress-wrap .standard-form input:not(.button-small),
     3431.buddypress-wrap .standard-form input:not(.small),
    33393432.buddypress-wrap .standard-form textarea {
    33403433    width: 100%;
     
    43554448    background-color: #ffb78c;
    43564449    border-color: #ff853c;
    4357     color: #fff;
     4450    color: #333;
    43584451}
    43594452
     
    43614454    background-color: #ffa0a0;
    43624455    border-color: #f04040;
    4363     color: #fff;
     4456    color: #333;
     4457}
     4458
     4459.buddypress-wrap #pass-strength-result.good {
     4460    background-color: #ffec8b;
     4461    border-color: #fc0;
     4462    color: #333;
    43644463}
    43654464
     
    43674466    background-color: #66d66e;
    43684467    border-color: #438c48;
    4369     color: #fff;
     4468    color: #333;
    43704469}
    43714470
  • trunk/src/bp-templates/bp-nouveau/css/buddypress.css

    r12394 r12397  
    19471947}
    19481948
     1949.register-page .signup-form .wp-pwd button {
     1950    vertical-align: middle;
     1951}
     1952
     1953.register-page .signup-form #pass1,
     1954.register-page .signup-form #pass1-text,
     1955.register-page .signup-form #pass-strength-result {
     1956    width: 10em;
     1957}
     1958
     1959.register-page .signup-form #pass1 {
     1960    display: inline-block;
     1961    margin-bottom: inherit;
     1962}
     1963
     1964.register-page .signup-form #pass1-text,
     1965.register-page .signup-form .pw-weak {
     1966    display: none;
     1967}
     1968
     1969.register-page .signup-form .show-password #pass1-text {
     1970    display: inline-block;
     1971    margin-bottom: inherit;
     1972}
     1973
     1974.register-page .signup-form .show-password #pass1 {
     1975    display: none;
     1976}
     1977
     1978.register-page .signup-form .description.indicator-hint {
     1979    font-size: 14px;
     1980}
     1981
     1982.register-page .signup-form #submit:disabled {
     1983    color: #767676;
     1984    opacity: 0.4;
     1985}
     1986
    19491987.register-page .signup-form .password-entry,
    19501988.register-page .signup-form .password-entry-confirm {
    19511989    border: 1px solid #eee;
     1990}
     1991
     1992body.buddypress.register.js .user-pass2-wrap {
     1993    display: none;
     1994}
     1995
     1996body.buddypress.register.no-js .wp-hide-pw {
     1997    display: none;
    19521998}
    19531999
     
    19732019@media screen and (min-width: 46.8em) {
    19742020    .buddypress-wrap.extended-default-reg .register-page .default-profile {
     2021        min-width: 14em;
    19752022        flex: 1;
    19762023        padding-right: 1em;
     
    32213268
    32223269/*__ General __*/
     3270body.buddypress.settings .wp-pwd button {
     3271    vertical-align: middle;
     3272}
     3273
     3274body.buddypress.settings #pass1,
     3275body.buddypress.settings #pass1-text,
     3276body.buddypress.settings #pass-strength-result {
     3277    width: 16em;
     3278}
     3279
     3280body.buddypress.settings #pass1 {
     3281    display: inline-block;
     3282    margin-bottom: inherit;
     3283}
     3284
     3285body.buddypress.settings #pass1-text,
     3286body.buddypress.settings .pw-weak,
     3287body.buddypress.settings #pass-strength-result {
     3288    display: none;
     3289}
     3290
     3291body.buddypress.settings .show-password #pass1-text {
     3292    display: inline-block;
     3293    margin-bottom: inherit;
     3294}
     3295
     3296body.buddypress.settings .show-password #pass1 {
     3297    display: none;
     3298}
     3299
     3300body.buddypress.settings #your-profile #submit:disabled {
     3301    color: #767676;
     3302    opacity: 0.4;
     3303}
     3304
     3305body.buddypress.settings.js .wp-pwd,
     3306body.buddypress.settings.js .user-pass2-wrap {
     3307    display: none;
     3308}
     3309
     3310body.buddypress.settings.no-js .wp-generate-pw,
     3311body.buddypress.settings.no-js .wp-cancel-pw,
     3312body.buddypress.settings.no-js .wp-hide-pw {
     3313    display: none;
     3314}
     3315
    32233316/*__ Email notifications __*/
    32243317/*__ Profile visibility __*/
     
    33363429}
    33373430
    3338 .buddypress-wrap .standard-form input:not(.button-small),
     3431.buddypress-wrap .standard-form input:not(.small),
    33393432.buddypress-wrap .standard-form textarea {
    33403433    width: 100%;
     
    43554448    background-color: #ffb78c;
    43564449    border-color: #ff853c;
    4357     color: #fff;
     4450    color: #333;
    43584451}
    43594452
     
    43614454    background-color: #ffa0a0;
    43624455    border-color: #f04040;
    4363     color: #fff;
     4456    color: #333;
     4457}
     4458
     4459.buddypress-wrap #pass-strength-result.good {
     4460    background-color: #ffec8b;
     4461    border-color: #fc0;
     4462    color: #333;
    43644463}
    43654464
     
    43674466    background-color: #66d66e;
    43684467    border-color: #438c48;
    4369     color: #fff;
     4468    color: #333;
    43704469}
    43714470
  • trunk/src/bp-templates/bp-nouveau/includes/functions.php

    r12156 r12397  
    11621162                'class'          => '',
    11631163            ),
    1164             'signup_password' => array(
    1165                 'label'          => __( 'Choose a Password', 'buddypress' ),
    1166                 'required'       => true,
    1167                 'value'          => '',
    1168                 'attribute_type' => 'password',
    1169                 'type'           => 'password',
    1170                 'class'          => 'password-entry',
    1171             ),
    1172             'signup_password_confirm' => array(
    1173                 'label'          => __( 'Confirm Password', 'buddypress' ),
    1174                 'required'       => true,
    1175                 'value'          => '',
    1176                 'attribute_type' => 'password',
    1177                 'type'           => 'password',
    1178                 'class'          => 'password-entry-confirm',
    1179             ),
     1164            'signup_password' => array(),
     1165            'signup_password_confirm' => array(),
    11801166        ),
    11811167        'blog_details' => array(
     
    12571243            'attributes' => array(
    12581244                'name'  => 'signup_submit',
    1259                 'id'    => 'signup_submit',
     1245                'id'    => 'submit',
    12601246                'value' => __( 'Complete Sign Up', 'buddypress' ),
    12611247            ),
  • trunk/src/bp-templates/bp-nouveau/includes/template-tags.php

    r12322 r12397  
    23102310
    23112311    foreach ( $fields as $name => $attributes ) {
    2312         list( $label, $required, $value, $attribute_type, $type, $class ) = array_values( $attributes );
    2313 
    2314         // Text fields are using strings, radios are using their inputs
    2315         $label_output = '<label for="%1$s">%2$s</label>';
    2316         $id           = $name;
    2317         $classes      = '';
    2318 
    2319         if ( $required ) {
    2320             /* translators: Do not translate placeholders. 2 = form field name, 3 = "(required)". */
    2321             $label_output = __( '<label for="%1$s">%2$s %3$s</label>', 'buddypress' );
    2322         }
    2323 
    2324         // Output the label for regular fields
    2325         if ( 'radio' !== $type ) {
     2312        if ( 'signup_password' === $name ) {
     2313            ?>
     2314            <label for="pass1"><?php esc_html_e( 'Choose a Password (required)', 'buddypress' ); ?></label>
     2315            <div class="user-pass1-wrap">
     2316                <div class="wp-pwd">
     2317                    <div class="password-input-wrapper">
     2318                        <input type="password" data-reveal="1" name="signup_password" id="pass1" class="password-entry" size="24" value="" <?php bp_form_field_attributes( 'password', array( 'data-pw' => wp_generate_password( 12 ), 'aria-describedby' => 'pass-strength-result' ) ); ?> />
     2319                        <button type="button" class="button wp-hide-pw">
     2320                            <span class="dashicons dashicons-hidden" aria-hidden="true"></span>
     2321                        </button>
     2322                    </div>
     2323                    <div id="pass-strength-result" aria-live="polite"><?php esc_html_e( 'Strength indicator', 'buddypress' ); ?></div>
     2324                </div>
     2325                <div class="pw-weak">
     2326                    <label>
     2327                        <input type="checkbox" name="pw_weak" class="pw-checkbox" />
     2328                        <?php esc_html_e( 'Confirm use of weak password', 'buddypress' ); ?>
     2329                    </label>
     2330                </div>
     2331            </div>
     2332            <?php
     2333        } elseif ( 'signup_password_confirm' === $name ) {
     2334            ?>
     2335            <p class="user-pass2-wrap">
     2336                <label for="pass2"><?php esc_html_e( 'Confirm new password', 'buddypress' ); ?></label><br />
     2337                <input type="password" name="signup_password_confirm" id="pass2" class="password-entry-confirm" size="24" value="" <?php bp_form_field_attributes( 'password' ); ?> />
     2338            </p>
     2339
     2340            <p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p>
     2341            <?php
     2342        } else {
     2343            list( $label, $required, $value, $attribute_type, $type, $class ) = array_values( $attributes );
     2344
     2345            // Text fields are using strings, radios are using their inputs
     2346            $label_output = '<label for="%1$s">%2$s</label>';
     2347            $id           = $name;
     2348            $classes      = '';
     2349
    23262350            if ( $required ) {
    2327                 printf( $label_output, esc_attr( $name ), esc_html( $label ), __( '(required)', 'buddypress' ) );
    2328             } else {
    2329                 printf( $label_output, esc_attr( $name ), esc_html( $label ) );
     2351                /* translators: Do not translate placeholders. 2 = form field name, 3 = "(required)". */
     2352                $label_output = __( '<label for="%1$s">%2$s %3$s</label>', 'buddypress' );
    23302353            }
    23312354
    2332             if ( ! empty( $value ) && is_callable( $value ) ) {
    2333                 $value = call_user_func( $value );
     2355            // Output the label for regular fields
     2356            if ( 'radio' !== $type ) {
     2357                if ( $required ) {
     2358                    printf( $label_output, esc_attr( $name ), esc_html( $label ), __( '(required)', 'buddypress' ) );
     2359                } else {
     2360                    printf( $label_output, esc_attr( $name ), esc_html( $label ) );
     2361                }
     2362
     2363                if ( ! empty( $value ) && is_callable( $value ) ) {
     2364                    $value = call_user_func( $value );
     2365                }
     2366
     2367            // Handle the specific case of Site's privacy differently
     2368            } elseif ( 'signup_blog_privacy_private' !== $name ) {
     2369                ?>
     2370                    <span class="label">
     2371                        <?php esc_html_e( 'I would like my site to appear in search engines, and in public listings around this network.', 'buddypress' ); ?>
     2372                    </span>
     2373                <?php
    23342374            }
    23352375
    2336         // Handle the specific case of Site's privacy differently
    2337         } elseif ( 'signup_blog_privacy_private' !== $name ) {
    2338             ?>
    2339                 <span class="label">
    2340                     <?php esc_html_e( 'I would like my site to appear in search engines, and in public listings around this network.', 'buddypress' ); ?>
    2341                 </span>
    2342             <?php
    2343         }
    2344 
    2345         // Set the additional attributes
    2346         if ( $attribute_type ) {
    2347             $existing_attributes = array();
    2348 
    2349             if ( ! empty( $required ) ) {
    2350                 $existing_attributes = array( 'aria-required' => 'true' );
     2376            // Set the additional attributes
     2377            if ( $attribute_type ) {
     2378                $existing_attributes = array();
     2379
     2380                if ( ! empty( $required ) ) {
     2381                    $existing_attributes = array( 'aria-required' => 'true' );
     2382
     2383                    /**
     2384                     * The blog section is hidden, so let's avoid a browser warning
     2385                     * and deal with the Blog section in Javascript.
     2386                     */
     2387                    if ( $section !== 'blog_details' ) {
     2388                        $existing_attributes['required'] = 'required';
     2389                    }
     2390                }
     2391
     2392                $attribute_type = ' ' . bp_get_form_field_attributes( $attribute_type, $existing_attributes );
     2393            }
     2394
     2395            // Specific case for Site's privacy
     2396            if ( 'signup_blog_privacy_public' === $name || 'signup_blog_privacy_private' === $name ) {
     2397                $name      = 'signup_blog_privacy';
     2398                $submitted = bp_get_signup_blog_privacy_value();
     2399
     2400                if ( ! $submitted ) {
     2401                    $submitted = 'public';
     2402                }
     2403
     2404                $attribute_type = ' ' . checked( $value, $submitted, false );
     2405            }
     2406
     2407            // Do not run function to display errors for the private radio.
     2408            if ( 'private' !== $value ) {
    23512409
    23522410                /**
    2353                  * The blog section is hidden, so let's avoid a browser warning
    2354                  * and deal with the Blog section in Javascript.
     2411                 * Fetch & display any BP member registration field errors.
     2412                 *
     2413                 * Passes BP signup errors to Nouveau's template function to
     2414                 * render suitable markup for error string.
    23552415                 */
    2356                 if ( $section !== 'blog_details' ) {
    2357                     $existing_attributes['required'] = 'required';
     2416                if ( isset( buddypress()->signup->errors[ $name ] ) ) {
     2417                    nouveau_error_template( buddypress()->signup->errors[ $name ] );
     2418                    $invalid = 'invalid';
    23582419                }
    23592420            }
    23602421
    2361             $attribute_type = ' ' . bp_get_form_field_attributes( $attribute_type, $existing_attributes );
    2362         }
    2363 
    2364         // Specific case for Site's privacy
    2365         if ( 'signup_blog_privacy_public' === $name || 'signup_blog_privacy_private' === $name ) {
    2366             $name      = 'signup_blog_privacy';
    2367             $submitted = bp_get_signup_blog_privacy_value();
    2368 
    2369             if ( ! $submitted ) {
    2370                 $submitted = 'public';
     2422            if ( isset( $invalid ) && isset( buddypress()->signup->errors[ $name ] ) ) {
     2423                if ( ! empty( $class ) ) {
     2424                    $class = $class . ' ' . $invalid;
     2425                } else {
     2426                    $class = $invalid;
     2427                }
    23712428            }
    23722429
    2373             $attribute_type = ' ' . checked( $value, $submitted, false );
    2374         }
    2375 
    2376         // Do not run function to display errors for the private radio.
    2377         if ( 'private' !== $value ) {
    2378 
    2379             /**
    2380              * Fetch & display any BP member registration field errors.
    2381              *
    2382              * Passes BP signup errors to Nouveau's template function to
    2383              * render suitable markup for error string.
    2384              */
    2385             if ( isset( buddypress()->signup->errors[ $name ] ) ) {
    2386                 nouveau_error_template( buddypress()->signup->errors[ $name ] );
    2387                 $invalid = 'invalid';
    2388             }
    2389         }
    2390 
    2391         if ( isset( $invalid ) && isset( buddypress()->signup->errors[ $name ] ) ) {
    2392             if ( ! empty( $class ) ) {
    2393                 $class = $class . ' ' . $invalid;
    2394             } else {
    2395                 $class = $invalid;
    2396             }
    2397         }
    2398 
    2399         if ( $class ) {
    2400             $class = sprintf(
    2401                 ' class="%s"',
    2402                 esc_attr( join( ' ', array_map( 'sanitize_html_class', explode( ' ', $class ) ) ) )
    2403             );
    2404         }
    2405 
    2406         // Set the input.
    2407         $field_output = sprintf(
    2408             '<input type="%1$s" name="%2$s" id="%3$s" %4$s value="%5$s" %6$s />',
    2409             esc_attr( $type ),
    2410             esc_attr( $name ),
    2411             esc_attr( $id ),
    2412             $class,  // Constructed safely above.
    2413             esc_attr( $value ),
    2414             $attribute_type // Constructed safely above.
    2415         );
    2416 
    2417         // Not a radio, let's output the field
    2418         if ( 'radio' !== $type ) {
    2419             if ( 'signup_blog_url' !== $name ) {
    2420                 print( $field_output );  // Constructed safely above.
    2421 
    2422             // If it's the signup blog url, it's specific to Multisite config.
    2423             } elseif ( is_subdomain_install() ) {
    2424                 // Constructed safely above.
    2425                 printf(
    2426                     '%1$s %2$s . %3$s',
    2427                     is_ssl() ? 'https://' : 'http://',
    2428                     $field_output,
    2429                     bp_signup_get_subdomain_base()
    2430                 );
    2431 
    2432             // Subfolders!
    2433             } else {
    2434                 printf(
    2435                     '%1$s %2$s',
    2436                     home_url( '/' ),
    2437                     $field_output  // Constructed safely above.
     2430            if ( $class ) {
     2431                $class = sprintf(
     2432                    ' class="%s"',
     2433                    esc_attr( join( ' ', array_map( 'sanitize_html_class', explode( ' ', $class ) ) ) )
    24382434                );
    24392435            }
    24402436
    2441         // It's a radio, let's output the field inside the label
    2442         } else {
    2443             // $label_output and $field_output are constructed safely above.
    2444             printf( $label_output, esc_attr( $name ), $field_output . ' ' . esc_html( $label ) );
    2445         }
    2446 
    2447         // Password strength is restricted to the signup_password field
    2448         if ( 'signup_password' === $name ) :
    2449         ?>
    2450             <div id="pass-strength-result"></div>
    2451         <?php
    2452         endif;
     2437            // Set the input.
     2438            $field_output = sprintf(
     2439                '<input type="%1$s" name="%2$s" id="%3$s" %4$s value="%5$s" %6$s />',
     2440                esc_attr( $type ),
     2441                esc_attr( $name ),
     2442                esc_attr( $id ),
     2443                $class,  // Constructed safely above.
     2444                esc_attr( $value ),
     2445                $attribute_type // Constructed safely above.
     2446            );
     2447
     2448            // Not a radio, let's output the field
     2449            if ( 'radio' !== $type ) {
     2450                if ( 'signup_blog_url' !== $name ) {
     2451                    print( $field_output );  // Constructed safely above.
     2452
     2453                // If it's the signup blog url, it's specific to Multisite config.
     2454                } elseif ( is_subdomain_install() ) {
     2455                    // Constructed safely above.
     2456                    printf(
     2457                        '%1$s %2$s . %3$s',
     2458                        is_ssl() ? 'https://' : 'http://',
     2459                        $field_output,
     2460                        bp_signup_get_subdomain_base()
     2461                    );
     2462
     2463                // Subfolders!
     2464                } else {
     2465                    printf(
     2466                        '%1$s %2$s',
     2467                        home_url( '/' ),
     2468                        $field_output  // Constructed safely above.
     2469                    );
     2470                }
     2471
     2472            // It's a radio, let's output the field inside the label
     2473            } else {
     2474                // $label_output and $field_output are constructed safely above.
     2475                printf( $label_output, esc_attr( $name ), $field_output . ' ' . esc_html( $label ) );
     2476            }
     2477        }
    24532478    }
    24542479
  • trunk/src/bp-templates/bp-nouveau/js/password-verify.js

    r12082 r12397  
    22/* Password Verify */
    33/* global pwsL10n */
    4 /* @version 3.0.0 */
     4/* @since 3.0.0 */
     5/* @version 5.0.0 */
    56( function( $ ){
     7    /**
     8     * Function to inform the user about the strength of its password.
     9     *
     10     * @deprecated since version 5.0.0.
     11     */
    612    function check_pass_strength() {
    713        var pass1 = $( '.password-entry' ).val(),
     
    4147        $( '.password-entry' ).val( '' ).keyup( check_pass_strength );
    4248        $( '.password-entry-confirm' ).val( '' ).keyup( check_pass_strength );
     49
     50        // Display a deprecated warning.
     51        console.warn( 'The bp-nouveau/js/password-verify.js script is deprecated since 5.0.0 and will be deleted in version 6.0.0.' );
    4352    } );
    4453
Note: See TracChangeset for help on using the changeset viewer.