| @@ -17,9 +17,9 @@ | ||
| 17 | 17 | */ |
| 18 | 18 | function login_header_otp( $title = 'Log In', $message = '', $show_logo = true, $wp_error = '' ) { |
| 19 | 19 | global $error, $interim_login, $action; |
| 20 | 20 | |
| 21 | - if ( empty( $wp_error ) ) { | |
| 21 | + if ( ! ( $wp_error instanceof WP_Error ) ) { | |
| 22 | 22 | $wp_error = new WP_Error(); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | // Shake it! |
| @@ -195,14 +195,14 @@ | ||
| 195 | 195 | * |
| 196 | 196 | * @since 2.1.0 |
| 197 | 197 | */ |
| 198 | 198 | $message = apply_filters( 'login_message', $message ); |
| 199 | - if ( ! empty( $message ) ) { | |
| 199 | + if ( is_string( $message ) && '' !== trim( $message ) ) { | |
| 200 | 200 | echo wp_kses_post( $message ); |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | // In case a plugin uses $error rather than the $wp_errors object. |
| 204 | - if ( ! empty( $error ) ) { | |
| 204 | + if ( $error instanceof WP_Error ) { | |
| 205 | 205 | $wp_error->add( 'error', $error ); |
| 206 | 206 | unset( $error ); |
| 207 | 207 | } |
| 208 | 208 | |
| @@ -218,9 +218,9 @@ | ||
| 218 | 218 | $errors .= ' ' . $error_message . "<br />\n"; |
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | - if ( ! empty( $errors ) ) { | |
| 222 | + if ( '' !== $errors ) { | |
| 223 | 223 | /** |
| 224 | 224 | * Filters the error messages displayed above the login form. |
| 225 | 225 | * |
| 226 | 226 | * @param string $errors Login error message. |
| @@ -228,9 +228,9 @@ | ||
| 228 | 228 | * @since 2.1.0 |
| 229 | 229 | */ |
| 230 | 230 | echo wp_kses_post( sprintf( '<div id="login_error" class="notice notice-error">%s</div>', apply_filters( 'login_errors', $errors ) ) ); |
| 231 | 231 | } |
| 232 | - if ( ! empty( $messages ) ) { | |
| 232 | + if ( '' !== $messages ) { | |
| 233 | 233 | /** |
| 234 | 234 | * Filters instructional messages displayed above the login form. |
| 235 | 235 | * |
| 236 | 236 | * @param string $messages Login messages. |
| @@ -268,9 +268,9 @@ | ||
| 268 | 268 | ); |
| 269 | 269 | } else { |
| 270 | 270 | login_header_otp( '', '', $show_logo, $error ); |
| 271 | 271 | |
| 272 | - if ( ! empty( $providers ) ) { | |
| 272 | + if ( is_array( $providers ) && array() !== $providers ) { | |
| 273 | 273 | $nonce = wp_create_nonce( 'verify_otp' ); |
| 274 | 274 | foreach ( $providers as $slug => $provider ) { |
| 275 | 275 | ?> |
| 276 | 276 | <form method="post" class="wpdef-2fa-form" id="wpdef-2fa-form-<?php echo esc_attr( $slug ); ?>" action=" |
| @@ -293,9 +293,9 @@ | ||
| 293 | 293 | <input type="hidden" name="password" value="<?php echo esc_attr( $password ); ?>"/> |
| 294 | 294 | <input type="hidden" name="requested_user" value="<?php echo esc_attr( $user_id ); ?>"/> |
| 295 | 295 | <input type="hidden" id="_wpnonce_<?php echo esc_attr( $slug ); ?>" name="_wpnonce" value="<?php echo esc_attr( $nonce ); ?>" /> |
| 296 | 296 | <?php |
| 297 | - if ( ! empty( defender_get_data_from_request( 'interim-login', 'r' ) ) ) { | |
| 297 | + if ( '1' === defender_get_data_from_request( 'interim-login', 'r' ) ) { | |
| 298 | 298 | ?> |
| 299 | 299 | <input type="hidden" name="interim-login" value="1"/> |
| 300 | 300 | <?php |
| 301 | 301 | } |
| @@ -319,16 +319,18 @@ | ||
| 319 | 319 | </ul> |
| 320 | 320 | </div> |
| 321 | 321 | <?php } ?> |
| 322 | 322 | <?php } ?> |
| 323 | - <?php if ( $custom_graphic ) { ?> | |
| 323 | + <?php | |
| 324 | + if ( $custom_graphic ) { | |
| 325 | + ?> | |
| 324 | 326 | <style type="text/css"> |
| 325 | 327 | body.login div#login h1 a { |
| 326 | 328 | background-image: url("<?php echo esc_url_raw( $custom_graphic ); ?>"); |
| 327 | 329 | } |
| 328 | 330 | </style> |
| 329 | - <?php } ?> | |
| 330 | - <?php | |
| 331 | + <?php | |
| 332 | + } | |
| 331 | 333 | $totp_script = <<<END |
| 332 | 334 | <script> |
| 333 | 335 | jQuery(function ($) { |
| 334 | 336 | function two_factor_providers(defaultSlug) { |
| @@ -423,9 +425,9 @@ | ||
| 423 | 425 | */ |
| 424 | 426 | echo $totp_script; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 425 | 427 | } |
| 426 | 428 | ); |
| 427 | - ?> | |
| 429 | + ?> | |
| 428 | 430 | <?php |
| 429 | 431 | } |
| 430 | 432 | ?> |
| 431 | 433 | |
| @@ -461,9 +463,9 @@ | ||
| 461 | 463 | |
| 462 | 464 | </div> |
| 463 | 465 | |
| 464 | 466 | <?php |
| 465 | - if ( ! empty( $input_id ) ) : | |
| 467 | + if ( '' !== trim( $input_id ) ) : | |
| 466 | 468 | ?> |
| 467 | 469 | <script type="text/javascript"> |
| 468 | 470 | try { |
| 469 | 471 | document.getElementById('<?php echo esc_js( $input_id ); ?>').focus(); |