Skip to:
Content

BuddyPress.org

Ticket #8100: 8100.patch

File 8100.patch, 7.7 KB (added by imath, 5 years ago)
  • src/bp-core/bp-core-blocks.php

    diff --git src/bp-core/bp-core-blocks.php src/bp-core/bp-core-blocks.php
    index 7e5f8d2bd..cc5d93c12 100644
    add_filter( 'widget_block_dynamic_classname', 'bp_widget_block_dynamic_classname 
    221221 * @return string         HTML output.
    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
    232242        $action_output = '';
    function bp_block_render_login_form_block( $attributes = array() ) { 
    260270        $block_args = bp_parse_args(
    261271                $attributes,
    262272                array(
    263                         'title' => '',
     273                        'title'         => '',
     274                        'forgotPwdLink' => false,
    264275                )
    265276        );
    266277
    function bp_block_render_login_form_block( $attributes = array() ) { 
    338349                }
    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();
    343356                        /**
    function bp_block_render_login_form_block( $attributes = array() ) { 
    357370
    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                );
    370384
  • src/bp-core/classes/class-bp-core.php

    diff --git src/bp-core/classes/class-bp-core.php src/bp-core/classes/class-bp-core.php
    index 2a8e56faf..e2ee0bcde 100644
    class BP_Core extends BP_Component { 
    397397                                        'style'              => 'bp-login-form-block',
    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' => '',
    403403                                                ),
     404                                                'forgotPwdLink' => array(
     405                                                        'type'    => 'boolean',
     406                                                        'default' => false,
     407                                                ),
    404408                                        ),
    405409                                        'render_callback'    => 'bp_block_render_login_form_block',
    406410                                ),
  • src/bp-core/css/blocks/login-form-rtl.css

    diff --git src/bp-core/css/blocks/login-form-rtl.css src/bp-core/css/blocks/login-form-rtl.css
    index f25ff8d9b..9c7a95e7d 100644
     
    3434        margin-right: 1em;
    3535        vertical-align: super;
    3636}
     37
     38#bp-login-widget-form .bp-login-widget-pwd-link {
     39        font-size: 80%;
     40}
  • src/bp-core/css/blocks/login-form.css

    diff --git src/bp-core/css/blocks/login-form.css src/bp-core/css/blocks/login-form.css
    index a86ac020f..b2ffafdc4 100644
     
    3434        margin-left: 1em;
    3535        vertical-align: super;
    3636}
     37
     38#bp-login-widget-form .bp-login-widget-pwd-link {
     39        font-size: 80%;
     40}
  • src/bp-core/js/blocks/login-form.js

    diff --git src/bp-core/js/blocks/login-form.js src/bp-core/js/blocks/login-form.js
    index 303925005..5f9eb3d0a 100644
    var _wp = wp, 
    134134    Disabled = _wp$components.Disabled,
    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,
    139140    createElement = _wp$element.createElement,
    var _bp = bp, 
    148149var editLoginForm = function editLoginForm(_ref) {
    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'),
    154156    initialOpen: true
    var editLoginForm = function editLoginForm(_ref) { 
    160162        title: text
    161163      });
    162164    }
     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
     171      });
     172    }
    163173  }))), createElement(Disabled, null, createElement(ServerSideRender, {
    164174    block: "bp/login-form",
    165175    attributes: attributes
    registerBlockType('bp/login-form', { 
    243253    title: {
    244254      type: 'string',
    245255      default: ''
     256    },
     257    forgotPwdLink: {
     258      type: 'boolean',
     259      default: false
    246260    }
    247261  },
    248262  edit: _edit.default,
  • src/bp-core/sass/blocks/login-form.scss

    diff --git src/bp-core/sass/blocks/login-form.scss src/bp-core/sass/blocks/login-form.scss
    index f92840150..b69bff291 100644
     
    4040                margin-left: 1em;
    4141                vertical-align: super;
    4242        }
     43
     44        .bp-login-widget-pwd-link {
     45                font-size: 80%;
     46        }
    4347}
  • src/js/bp-core/js/blocks/login-form.js

    diff --git src/js/bp-core/js/blocks/login-form.js src/js/bp-core/js/blocks/login-form.js
    index 61092ff62..7091fa366 100644
    registerBlockType( 'bp/login-form', { 
    3030                        type: 'string',
    3131                        default: '',
    3232                },
     33                forgotPwdLink: {
     34                        type: 'boolean',
     35                        default: false,
     36                },
    3337        },
    3438        edit: editLoginForm,
    3539        transforms: transforms,
  • src/js/bp-core/js/blocks/login-form/edit.js

    diff --git src/js/bp-core/js/blocks/login-form/edit.js src/js/bp-core/js/blocks/login-form/edit.js
    index 9c124885f..7734dc7d8 100644
    const { 
    99                Disabled,
    1010                PanelBody,
    1111                TextControl,
     12                ToggleControl,
    1213        },
    1314        element: {
    1415                Fragment,
    const { 
    2930} = bp;
    3031
    3132const editLoginForm = ( { attributes, setAttributes } ) => {
    32         const { title } = attributes;
     33        const { title,forgotPwdLink } = attributes;
    3334
    3435        return (
    3536                <Fragment>
    const editLoginForm = ( { attributes, setAttributes } ) => { 
    4243                                                        setAttributes( { title: text } );
    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>
    4755                        <Disabled>