diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index a28d6ce8c..236c00a2f 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -196,6 +196,58 @@ function wp_login_url($redirect = '') { return apply_filters('login_url', $login_url, $redirect); } +/** + * Provides a simple login form for use anywhere within WordPress. By default, it echos + * the HTML immediately. Pass array('echo'=>false) to return the string instead. + * + * @since x.x + * @param array $args Configuration options to modify the form output + * @return Void, or string containing the form + */ +function wp_login_form( $args = array() ) { + $defaults = array( 'echo' => true, + 'redirect' => site_url( $_SERVER['REQUEST_URI'] ), // Default redirect is back to the current page + 'form_id' => 'loginform', + 'label_username' => __( 'Username' ), + 'label_password' => __( 'Password' ), + 'label_remember' => __( 'Remember Me' ), + 'label_log_in' => __( 'Log In' ), + 'id_username' => 'user_login', + 'id_password' => 'user_pass', + 'id_remember' => 'rememberme', + 'id_submit' => 'wp-submit', + 'remember' => true, + 'value_username' => '', + 'value_remember' => false, // Set this to true to default the "Remember me" checkbox to checked + ); + $args = wp_parse_args( $args, apply_filters( 'login_form_defaults', $defaults ) ); + + $form = ' +
+ ' . do_action( 'login_form_top' ) . ' +

+ + +

+

+ + +

+ ' . do_action( 'login_form_middle' ) . ' + ' . ( $args['remember'] ? '

' : '' ) . ' +

+ + +

+ ' . do_action( 'login_form_bottom' ) . ' +
'; + + if ( $args['echo'] ) + echo $form; + else + return $form; +} + /** * Returns the Lost Password URL. *