wp_login_form()
wp_login_form( array $args = array() )
提供一个简单的登录表单供WordPress中的任何地方使用。
Provides a simple login form for use anywhere within WordPress.
说明(Description)
默认情况下,回显登录表单HTML。为$echo传递一个假值以返回它。
源码(Source)
/** * Provides a simple login form for use anywhere within WordPress. By default, it echoes * the HTML immediately. Pass array('echo'=>false) to return the string instead. * * @since 3.0.0 * * @param array $args Configuration options to modify the form output. * @return string|void String when retrieving. */ function wp_login_form( $args = array() ) { $defaults = array( 'echo' => true, 'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_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 ); /** * Filter the default login form output arguments. * * @since 3.0.0 * * @see wp_login_form() * * @param array $defaults An array of default login form arguments. */ $args = wp_parse_args( $args, apply_filters( 'login_form_defaults', $defaults ) ); /** * Filter content to display at the top of the login form. * * The filter evaluates just following the opening form tag element. * * @since 3.0.0 * * @param string $content Content to display. Default empty. * @param array $args Array of login form arguments. */ $login_form_top = apply_filters( 'login_form_top', '', $args ); /** * Filter content to display in the middle of the login form. * * The filter evaluates just following the location where the 'login-password' * field is displayed. * * @since 3.0.0 * * @param string $content Content to display. Default empty. * @param array $args Array of login form arguments. */ $login_form_middle = apply_filters( 'login_form_middle', '', $args ); /** * Filter content to display at the bottom of the login form. * * The filter evaluates just preceding the closing form tag element. * * @since 3.0.0 * * @param string $content Content to display. Default empty. * @param array $args Array of login form arguments. */ $login_form_bottom = apply_filters( 'login_form_bottom', '', $args ); $form = ' ' . $login_form_top . ' ' . esc_html( $args['label_username'] ) . ' ' . esc_html( $args['label_password'] ) . ' ' . $login_form_middle . ' ' . ( $args['remember'] ? ' ' . esc_html( $args['label_remember'] ) . '' : '' ) . ' ' . $login_form_bottom . ' '; if ( $args['echo'] ) echo $form; else return $form; }
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
3.0.0 | wp-includes/general-template.php | 12 | 2 |
笔记(Notes)
此示例显示一个登录表单。
wp_login_form() 为WP2原创文章,链接:https://www.wp2.cn/functions/wp_login_form/