PluginProbe ʕ •ᴥ•ʔ
WP 2FA – Two-factor authentication for WordPress / 2.4.2
WP 2FA – Two-factor authentication for WordPress v2.4.2
1.7.1 2.0.0 2.0.1 2.1.0 2.2.0 2.2.1 2.3.0 2.4.0 2.4.1 2.4.2 2.5.0 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.8.0 2.9.0 2.9.1 2.9.2 2.9.3 3.0.0 3.0.1 3.1.0 3.1.1 3.1.1.2 trunk 1.2.0 1.3.0 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.6.0 1.6.1 1.6.2 1.7.0
wp-2fa / includes / functions / login-header.php
wp-2fa / includes / functions Last commit date
core.php 3 years ago index.php 5 years ago login-header.php 4 years ago
login-header.php
207 lines
1 <?php
2
3 /**
4 * Output the login page header.
5 *
6 * @param string $title Optional. WordPress login Page title to display in the `<title>` element.
7 * Default 'Log In'.
8 * @param string $message Optional. Message to display in header. Default empty.
9 * @param WP_Error $wp_error Optional. The error to pass. Default is a WP_Error instance.
10 */
11 function login_header( $title = 'Log In', $message = '', $wp_error = null ) {
12
13 global $error, $interim_login, $action;
14 // Don't index any of these forms.
15 add_action( 'login_head', 'wp_no_robots' );
16 add_action( 'login_head', 'wp_login_viewport_meta' );
17
18 if ( ! is_wp_error( $wp_error ) ) {
19 $wp_error = new WP_Error();
20 }
21 // Shake it!
22 $shake_error_codes = array( 'empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password' );
23 /**
24 * Filters the error codes array for shaking the login form.
25 *
26 * @since 3.0.0
27 *
28 * @param array $shake_error_codes Error codes that shake the login form.
29 */
30 $shake_error_codes = apply_filters( 'shake_error_codes', $shake_error_codes );
31 if ( $shake_error_codes && $wp_error->get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) ) {
32 add_action( 'login_head', 'wp_shake_js', 12 );
33 }
34 $login_title = get_bloginfo( 'name', 'display' );
35 /* translators: Login screen title. 1: Login screen name, 2: Network or site name */
36 $login_title = sprintf( __( '%1$s &lsaquo; %2$s &#8212; WordPress' ), $title, $login_title );
37 /**
38 * Filters the title tag content for login page.
39 *
40 * @since 4.9.0
41 *
42 * @param string $login_title The page title, with extra context added.
43 * @param string $title The original page title.
44 */
45 $login_title = apply_filters( 'login_title', $login_title, $title );
46 ?><!DOCTYPE html>
47 <!--[if IE 8]>
48 <html xmlns="http://www.w3.org/1999/xhtml" class="ie8" <?php language_attributes(); ?>>
49 <![endif]-->
50 <!--[if !(IE 8) ]><!-->
51 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
52 <!--<![endif]-->
53 <head>
54 <meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php bloginfo( 'charset' ); ?>" />
55 <title><?php echo $login_title; ?></title>
56 <?php
57 wp_enqueue_style( 'login' );
58 /*
59 * Remove all stored post data on logging out.
60 * This could be added by add_action('login_head'...) like wp_shake_js(),
61 * but maybe better if it's not removable by plugins
62 */
63 if ( 'loggedout' == $wp_error->get_error_code() ) {
64 ?>
65 <script>if("sessionStorage" in window){try{for(var key in sessionStorage){if(key.indexOf("wp-autosave-")!=-1){sessionStorage.removeItem(key)}}}catch(e){}};</script>
66 <?php
67 }
68 /**
69 * Enqueue scripts and styles for the login page.
70 *
71 * @since 3.1.0
72 */
73 do_action( 'login_enqueue_scripts' );
74 /**
75 * Fires in the login page header after scripts are enqueued.
76 *
77 * @since 2.1.0
78 */
79 do_action( 'login_head' );
80 if ( \WP2FA\Admin\Helpers\WP_Helper::is_multisite() ) {
81 $login_header_url = network_home_url();
82 $login_header_title = get_network()->site_name;
83 } else {
84 $login_header_url = __( 'https://wordpress.org/' );
85 $login_header_title = __( 'Powered by WordPress' );
86 }
87 /**
88 * Filters link URL of the header logo above login form.
89 *
90 * @since 2.1.0
91 *
92 * @param string $login_header_url Login header logo URL.
93 */
94 $login_header_url = apply_filters( 'login_headerurl', $login_header_url );
95 /**
96 * Filters the title attribute of the header logo above login form.
97 *
98 * @since 2.1.0
99 *
100 * @param string $login_header_title Login header logo title attribute.
101 */
102 $login_header_title = apply_filters( 'login_headertitle', $login_header_title );
103 /*
104 * To match the URL/title set above, Multisite sites have the blog name,
105 * while single sites get the header title.
106 */
107 if ( \WP2FA\Admin\Helpers\WP_Helper::is_multisite() ) {
108 $login_header_text = get_bloginfo( 'name', 'display' );
109 } else {
110 $login_header_text = $login_header_title;
111 }
112 $classes = array( 'login-action-' . $action, 'wp-core-ui' );
113 if ( is_rtl() ) {
114 $classes[] = 'rtl';
115 }
116 if ( $interim_login ) {
117 $classes[] = 'interim-login';
118 ?>
119 <style type="text/css">html{background-color: transparent;}</style>
120 <?php
121 if ( 'success' === $interim_login ) {
122 $classes[] = 'interim-login-success';
123 }
124 }
125 $classes[] = ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
126 /**
127 * Filters the login page body classes.
128 *
129 * @since 3.5.0
130 *
131 * @param array $classes An array of body classes.
132 * @param string $action The action that brought the visitor to the login page.
133 */
134 $classes = apply_filters( 'login_body_class', $classes, $action );
135 ?>
136 </head>
137 <body class="login <?php echo esc_attr( implode( ' ', $classes ) ); ?>">
138 <?php
139 /**
140 * Fires in the login page header after the body tag is opened.
141 *
142 * @since 4.6.0
143 */
144 do_action( 'login_header' );
145 ?>
146 <div id="login">
147 <h1><a href="<?php echo esc_url( $login_header_url ); ?>" title="<?php echo esc_attr( $login_header_title ); ?>" tabindex="-1"><?php echo $login_header_text; ?></a></h1>
148 <?php
149 unset( $login_header_url, $login_header_title );
150 /**
151 * Filters the message to display above the login form.
152 *
153 * @since 2.1.0
154 *
155 * @param string $message Login message text.
156 */
157 $message = apply_filters( 'login_message', $message );
158 if ( ! empty( $message ) ) {
159 echo $message . "\n";
160 }
161 // In case a plugin uses $error rather than the $wp_errors object.
162 if ( ! empty( $error ) ) {
163 $wp_error->add( 'error', $error );
164 unset( $error );
165 }
166 if ( $wp_error->get_error_code() ) {
167 $errors = '';
168 $messages = '';
169 foreach ( $wp_error->get_error_codes() as $code ) {
170 $severity = $wp_error->get_error_data( $code );
171 foreach ( $wp_error->get_error_messages( $code ) as $error_message ) {
172 if ( 'message' == $severity ) {
173 $messages .= ' ' . $error_message . "<br />\n";
174 } else {
175 $errors .= ' ' . $error_message . "<br />\n";
176 }
177 }
178 }
179 if ( ! empty( $errors ) ) {
180 /**
181 * Filters the error messages displayed above the login form.
182 *
183 * @since 2.1.0
184 *
185 * @param string $errors Login error message.
186 */
187 echo '<div id="login_error">' . apply_filters( 'login_errors', $errors ) . "</div>\n";
188 }
189 if ( ! empty( $messages ) ) {
190 /**
191 * Filters instructional messages displayed above the login form.
192 *
193 * @since 2.5.0
194 *
195 * @param string $messages Login messages.
196 */
197 echo '<p class="message">' . apply_filters( 'login_messages', $messages ) . "</p>\n";
198 }
199 }
200 } // End of login_header().
201
202 function wp_login_viewport_meta() {
203 ?>
204 <meta name="viewport" content="width=device-width" />
205 <?php
206 }
207