[wp-trac] [WordPress Trac] #39927: Add support for CSS class and attributes in wp_login_form input fields

WordPress Trac noreply at wordpress.org
Tue Feb 21 14:23:15 UTC 2017


#39927: Add support for CSS class and attributes in wp_login_form input fields
------------------------------------+-----------------------------
 Reporter:  subrataemfluence        |      Owner:
     Type:  enhancement             |     Status:  new
 Priority:  normal                  |  Milestone:  Awaiting Review
Component:  Login and Registration  |    Version:  4.7.2
 Severity:  normal                  |   Keywords:
  Focuses:  template                |
------------------------------------+-----------------------------
 I think adding support for class and a few useful attributes like
 placeholder and required for default login form (wp_login_form).

 In `wp-includes/general-templates.php` (line 402), if we can pass `$args`
 like this it would be nice:

 {{{
 $args = array(
   ...
   'placeholder_username' => __('Your login Id'),
   'placeholder_password' => __('Your password (case sensitive)'),
   'username_required' => true,
   'password_required' => true,
   'username_css_class' => 'form_control,
   'password_css_class' => 'form-control
   'username_remove_size' => true,
   'password_remove_size' => true
 );
 }}}

 This will have the following benefits:

 1) We can use HTML5 native client side validation
 2) We can tell WordPress to use custom class name (if none is supplied,
 default would be used)
 3) Placeholder will help removing labels and save space
 4) Size attribute if set to `true` will not be used. This is useful if I
 don't need it at all.

 Based on the above values the `<form>` element also could be modified like
 this:

 {{{
 $form = '<form ...>
    <input type="text" <?php if($args["username_required"] == true) echo
 "required" ... ?>
 </form>';

 if($args['echo']){
    echo $form;
 } else {
    return $form;
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39927>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list