From fd5266e0a928ee0d533741c2e748aa21f54f6e84 Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 11 Jan 2010 21:48:43 +0000 Subject: [PATCH] wp_login_form(). Props beaulebens. see #11172 git-svn-id: http://svn.automattic.com/wordpress/trunk@12696 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/general-template.php | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) 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. *