Skip to:
Content

BuddyPress.org

Ticket #5914: 5914.02.patch

File 5914.02.patch, 8.7 KB (added by r-a-y, 5 years ago)
  • src/bp-blogs/bp-blogs-template.php

     
    12231223        if ( !is_subdomain_install() )
    12241224                echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span> <input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="63" /><br />';
    12251225        else
    1226                 echo '<input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="63" /> <span class="suffix_address">.' . bp_blogs_get_subdomain_base() . '</span><br />';
     1226                echo '<input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="63" ' . bp_get_form_field_attributes( 'blogname' ) . '/> <span class="suffix_address">.' . bp_blogs_get_subdomain_base() . '</span><br />';
    12271227
    12281228        if ( !is_user_logged_in() ) {
    12291229                print '(<strong>' . __( 'Your address will be ' , 'buddypress');
  • src/bp-core/bp-core-template.php

     
    492492}
    493493
    494494/**
     495 * Output the attributes for a form field.
     496 *
     497 * @since BuddyPress (2.2.0)
     498 *
     499 * @param string $name       The field name to output attributes for.
     500 * @param array  $attributes Array of existing attributes to add.
     501 */
     502function bp_form_field_attributes( $name = '', $attributes = array() ) {
     503        echo bp_get_form_field_attributes( $name, $attributes );
     504}
     505        /**
     506         * Get the attributes for a form field.
     507         *
     508         * Primarily to add better support for touchscreen devices, but plugin devs
     509         * can use the 'bp_get_form_field_extra_attributes' filter for further
     510         * manipulation.
     511         *
     512         * @since BuddyPress (2.2.0)
     513         *
     514         * @param string $name       The field name to get attributes for.
     515         * @param array  $attributes Array of existing attributes to add.
     516         * @return string
     517         */
     518        function bp_get_form_field_attributes( $name = '', $attributes = array() ) {
     519                $retval = '';
     520
     521                if ( empty( $attributes ) ) {
     522                        $attributes = array();
     523                }
     524
     525                $name = strtolower( $name );
     526
     527                switch ( $name ) {
     528                        case 'username' :
     529                        case 'blogname' :
     530                                $attributes['autocomplete']   = 'off';
     531                                $attributes['autocapitalize'] = 'none';
     532                                break;
     533
     534                        case 'email' :
     535                                if ( wp_is_mobile() ) {
     536                                        $attributes['autocapitalize'] = 'none';
     537                                }
     538                                break;
     539
     540                        case 'password' :
     541                                $attributes['spellcheck']   = 'false';
     542                                $attributes['autocomplete'] = 'off';
     543
     544                                if ( wp_is_mobile() ) {
     545                                        $attributes['autocorrect']    = 'false';
     546                                        $attributes['autocapitalize'] = 'none';
     547                                }
     548                                break;
     549                }
     550
     551                /**
     552                 * Filter the attributes for a field before rendering output.
     553                 *
     554                 * @since BuddyPress (2.2.0)
     555                 *
     556                 * @param array  $attributes The field attributes
     557                 * @param string $name       The field name
     558                 */
     559                $attributes = (array) apply_filters( 'bp_get_form_field_attributes', $attributes, $name );
     560
     561                $attributes = array_unique( $attributes );
     562
     563                foreach( $attributes as $attr => $value ) {
     564                        $retval .= sprintf( ' %s="%s"', sanitize_key( $attr ), esc_attr( $value ) );
     565                }
     566
     567                return $retval;
     568        }
     569
     570/**
    495571 * Create and output a button.
    496572 *
    497573 * @see bp_get_button()
  • src/bp-templates/bp-legacy/buddypress/members/register.php

     
    3131
    3232                                <label for="signup_username"><?php _e( 'Username', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
    3333                                <?php do_action( 'bp_signup_username_errors' ); ?>
    34                                 <input type="text" name="signup_username" id="signup_username" value="<?php bp_signup_username_value(); ?>" />
     34                                <input type="text" name="signup_username" id="signup_username" value="<?php bp_signup_username_value(); ?>" <?php bp_form_field_attributes( 'username' ); ?>/>
    3535
    3636                                <label for="signup_email"><?php _e( 'Email Address', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
    3737                                <?php do_action( 'bp_signup_email_errors' ); ?>
    38                                 <input type="email" name="signup_email" id="signup_email" value="<?php bp_signup_email_value(); ?>" />
     38                                <input type="email" name="signup_email" id="signup_email" value="<?php bp_signup_email_value(); ?>" <?php bp_form_field_attributes( 'email' ); ?>/>
    3939
    4040                                <label for="signup_password"><?php _e( 'Choose a Password', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
    4141                                <?php do_action( 'bp_signup_password_errors' ); ?>
    42                                 <input type="password" name="signup_password" id="signup_password" value="" class="password-entry" />
     42                                <input type="password" name="signup_password" id="signup_password" value="" class="password-entry" <?php bp_form_field_attributes( 'password' ); ?>/>
    4343                                <div id="pass-strength-result"></div>
    4444
    4545                                <label for="signup_password_confirm"><?php _e( 'Confirm Password', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
    4646                                <?php do_action( 'bp_signup_password_confirm_errors' ); ?>
    47                                 <input type="password" name="signup_password_confirm" id="signup_password_confirm" value="" class="password-entry-confirm" />
     47                                <input type="password" name="signup_password_confirm" id="signup_password_confirm" value="" class="password-entry-confirm" <?php bp_form_field_attributes( 'password' ); ?>/>
    4848
    4949                                <?php do_action( 'bp_account_details_fields' ); ?>
    5050
  • src/bp-templates/bp-legacy/buddypress/members/single/settings/general.php

     
    55        <?php if ( !is_super_admin() ) : ?>
    66
    77                <label for="pwd"><?php _e( 'Current Password <span>(required to update email or change current password)</span>', 'buddypress' ); ?></label>
    8                 <input type="password" name="pwd" id="pwd" size="16" value="" class="settings-input small" /> &nbsp;<a href="<?php echo wp_lostpassword_url(); ?>" title="<?php esc_attr_e( 'Password Lost and Found', 'buddypress' ); ?>"><?php _e( 'Lost your password?', 'buddypress' ); ?></a>
     8                <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 wp_lostpassword_url(); ?>" title="<?php esc_attr_e( 'Password Lost and Found', 'buddypress' ); ?>"><?php _e( 'Lost your password?', 'buddypress' ); ?></a>
    99
    1010        <?php endif; ?>
    1111
    1212        <label for="email"><?php _e( 'Account Email', 'buddypress' ); ?></label>
    13         <input type="email" name="email" id="email" value="<?php echo bp_get_displayed_user_email(); ?>" class="settings-input" />
     13        <input type="email" name="email" id="email" value="<?php echo bp_get_displayed_user_email(); ?>" class="settings-input" <?php bp_form_field_attributes( 'email' ); ?>/>
    1414
    1515        <label for="pass1"><?php _e( 'Change Password <span>(leave blank for no change)</span>', 'buddypress' ); ?></label>
    16         <input type="password" name="pass1" id="pass1" size="16" value="" class="settings-input small password-entry" /> &nbsp;<?php _e( 'New Password', 'buddypress' ); ?><br />
     16        <input type="password" name="pass1" id="pass1" size="16" value="" class="settings-input small password-entry" <?php bp_form_field_attributes( 'password' ); ?>/> &nbsp;<?php _e( 'New Password', 'buddypress' ); ?><br />
    1717        <div id="pass-strength-result"></div>
    18         <input type="password" name="pass2" id="pass2" size="16" value="" class="settings-input small password-entry-confirm" /> &nbsp;<?php _e( 'Repeat New Password', 'buddypress' ); ?>
     18        <input type="password" name="pass2" id="pass2" size="16" value="" class="settings-input small password-entry-confirm" <?php bp_form_field_attributes( 'password' ); ?>/> &nbsp;<?php _e( 'Repeat New Password', 'buddypress' ); ?>
    1919
    2020        <?php do_action( 'bp_core_general_settings_before_submit' ); ?>
    2121
  • src/bp-xprofile/bp-xprofile-classes.php

     
    36243624                 * @param array  $r     Array of parsed arguments.
    36253625                 * @param string $value Class name for the current class instance.
    36263626                 */
    3627                 $r    = (array) apply_filters( 'bp_xprofile_field_edit_html_elements', $r, get_class( $this ) );
     3627                $r = (array) apply_filters( 'bp_xprofile_field_edit_html_elements', $r, get_class( $this ) );
    36283628
    3629                 foreach ( $r as $name => $value ) {
    3630                         $html .= sprintf( '%s="%s" ', sanitize_key( $name ), esc_attr( $value ) );
    3631                 }
    3632 
    3633                 return $html;
     3629                return bp_get_form_field_attributes( sanitize_key( bp_get_the_profile_field_name() ), $r );
    36343630        }
    36353631}
    36363632