Skip to:
Content

BuddyPress.org

Changeset 13111


Ignore:
Timestamp:
09/19/2021 01:02:18 PM (5 years ago)
Author:
imath
Message:

BP Blocks: add a link to reset the user password into the Login Form

  • add a setting to let the Admin choose whether to show this link from the block’s inspector settings.
  • Include this link under the "Log In" button if this setting is active.

Props ellucinda

Fixes #8100

Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-blocks.php

    r13108 r13111  
    222222 */
    223223function bp_blocks_get_login_widget_registration_link( $content = '', $args = array() ) {
    224     if ( isset( $args['form_id'] ) && 'bp-login-widget-form' === $args['form_id'] && bp_get_signup_allowed() ) {
    225         $content .= sprintf(
    226             '<p class="bp-login-widget-register-link"><a href="%1$s">%2$s</a></p>',
    227             esc_url( bp_get_signup_page() ),
    228             esc_html__( 'Register', 'buddypress' )
    229         );
     224    if ( isset( $args['form_id'] ) && 'bp-login-widget-form' === $args['form_id'] ) {
     225        if ( bp_get_signup_allowed() ) {
     226            $content .= sprintf(
     227                '<p class="bp-login-widget-register-link"><a href="%1$s">%2$s</a></p>',
     228                esc_url( bp_get_signup_page() ),
     229                esc_html__( 'Register', 'buddypress' )
     230            );
     231        }
     232
     233        if ( isset( $args['include_pwd_link'] ) && true === $args['include_pwd_link'] ) {
     234            $content .= sprintf(
     235                '<p class="bp-login-widget-pwd-link"><a href="%1$s">%2$s</a></p>',
     236                esc_url( wp_lostpassword_url( bp_get_root_domain() ) ),
     237                esc_html__( 'Lost your password?', 'buddypress' )
     238            );
     239        }
    230240    }
    231241
     
    261271        $attributes,
    262272        array(
    263             'title' => '',
     273            'title'         => '',
     274            'forgotPwdLink' => false,
    264275        )
    265276    );
     
    339350    } else {
    340351        $action_output = '';
     352        $pwd_link      = (bool) $block_args['forgotPwdLink'];
     353
    341354        if ( has_action( 'bp_before_login_widget_loggedout' ) ) {
    342355            ob_start();
     
    358371        $widget_content .= wp_login_form(
    359372            array(
    360                 'echo'           => false,
    361                 'form_id'        => 'bp-login-widget-form',
    362                 'id_username'    => 'bp-login-widget-user-login',
    363                 'label_username' => __( 'Username', 'buddypress' ),
    364                 'id_password'    => 'bp-login-widget-user-pass',
    365                 'label_password' => __( 'Password', 'buddypress' ),
    366                 'id_remember'    => 'bp-login-widget-rememberme',
    367                 'id_submit'      => 'bp-login-widget-submit',
     373                'echo'             => false,
     374                'form_id'          => 'bp-login-widget-form',
     375                'id_username'      => 'bp-login-widget-user-login',
     376                'label_username'   => __( 'Username', 'buddypress' ),
     377                'id_password'      => 'bp-login-widget-user-pass',
     378                'label_password'   => __( 'Password', 'buddypress' ),
     379                'id_remember'      => 'bp-login-widget-rememberme',
     380                'id_submit'        => 'bp-login-widget-submit',
     381                'include_pwd_link' => $pwd_link,
    368382            )
    369383        );
  • trunk/src/bp-core/classes/class-bp-core.php

    r13006 r13111  
    398398                    'style_url'          => plugins_url( 'css/blocks/login-form.css', dirname( __FILE__ ) ),
    399399                    'attributes'         => array(
    400                         'title' => array(
     400                        'title'         => array(
    401401                            'type'    => 'string',
    402402                            'default' => '',
     403                        ),
     404                        'forgotPwdLink' => array(
     405                            'type'    => 'boolean',
     406                            'default' => false,
    403407                        ),
    404408                    ),
  • trunk/src/bp-core/css/blocks/login-form-rtl.css

    r12999 r13111  
    3535    vertical-align: super;
    3636}
     37
     38#bp-login-widget-form .bp-login-widget-pwd-link {
     39    font-size: 80%;
     40}
  • trunk/src/bp-core/css/blocks/login-form.css

    r12999 r13111  
    3535    vertical-align: super;
    3636}
     37
     38#bp-login-widget-form .bp-login-widget-pwd-link {
     39    font-size: 80%;
     40}
  • trunk/src/bp-core/js/blocks/login-form.js

    r12999 r13111  
    135135    PanelBody = _wp$components.PanelBody,
    136136    TextControl = _wp$components.TextControl,
     137    ToggleControl = _wp$components.ToggleControl,
    137138    _wp$element = _wp.element,
    138139    Fragment = _wp$element.Fragment,
     
    149150  var attributes = _ref.attributes,
    150151      setAttributes = _ref.setAttributes;
    151   var title = attributes.title;
     152  var title = attributes.title,
     153      forgotPwdLink = attributes.forgotPwdLink;
    152154  return createElement(Fragment, null, createElement(InspectorControls, null, createElement(PanelBody, {
    153155    title: __('Settings', 'buddypress'),
     
    159161      setAttributes({
    160162        title: text
     163      });
     164    }
     165  }), createElement(ToggleControl, {
     166    label: __('Include the link to reset the user password', 'buddypress'),
     167    checked: !!forgotPwdLink,
     168    onChange: function onChange() {
     169      setAttributes({
     170        forgotPwdLink: !forgotPwdLink
    161171      });
    162172    }
     
    244254      type: 'string',
    245255      default: ''
     256    },
     257    forgotPwdLink: {
     258      type: 'boolean',
     259      default: false
    246260    }
    247261  },
  • trunk/src/bp-core/sass/blocks/login-form.scss

    r12999 r13111  
    4141        vertical-align: super;
    4242    }
     43
     44    .bp-login-widget-pwd-link {
     45        font-size: 80%;
     46    }
    4347}
  • trunk/src/js/bp-core/js/blocks/login-form.js

    r12999 r13111  
    3131            default: '',
    3232        },
     33        forgotPwdLink: {
     34            type: 'boolean',
     35            default: false,
     36        },
    3337    },
    3438    edit: editLoginForm,
  • trunk/src/js/bp-core/js/blocks/login-form/edit.js

    r12999 r13111  
    1010        PanelBody,
    1111        TextControl,
     12        ToggleControl,
    1213    },
    1314    element: {
     
    3031
    3132const editLoginForm = ( { attributes, setAttributes } ) => {
    32     const { title } = attributes;
     33    const { title,forgotPwdLink } = attributes;
    3334
    3435    return (
     
    4344                        } }
    4445                    />
     46                    <ToggleControl
     47                        label={ __( 'Include the link to reset the user password', 'buddypress' ) }
     48                        checked={ !! forgotPwdLink }
     49                        onChange={ () => {
     50                            setAttributes( { forgotPwdLink: ! forgotPwdLink } );
     51                        } }
     52                    />
    4553                </PanelBody>
    4654            </InspectorControls>
Note: See TracChangeset for help on using the changeset viewer.