| 1 |
<?php |
| 2 |
/** |
| 3 |
* Login page |
| 4 |
* |
| 5 |
* @package UpStream |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
if ( is_archive() && ( empty( $_SESSION ) || empty( $_SESSION['upstream'] ) || empty( $_SESSION['upstream']['user_id'] ) ) && ! is_user_logged_in() ) { |
| 13 |
wp_redirect( wp_login_url( get_post_type_archive_link( 'project' ) ) ); |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
$header_text = upstream_login_heading(); |
| 18 |
$plugin_options = get_option( 'upstream_general' ); |
| 19 |
|
| 20 |
$should_display_client_logo = isset( $plugin_options['login_client_logo'] ) ? (bool) $plugin_options['login_client_logo'] : false; |
| 21 |
if ( $should_display_client_logo ) { |
| 22 |
$client_logo_url = upstream_client_logo(); |
| 23 |
} |
| 24 |
|
| 25 |
$should_display_project_name = isset( $plugin_options['login_project_name'] ) ? $plugin_options['login_project_name'] : false; |
| 26 |
if ( $should_display_project_name ) { |
| 27 |
$header_text .= ! empty( $header_text ) ? '<br /><small>' . esc_html( get_the_title() ) . '</small>' : esc_html( get_the_title() ); |
| 28 |
} |
| 29 |
|
| 30 |
$login = new UpStream_Login(); |
| 31 |
$post_data = isset( $_POST ) ? wp_unslash( $_POST ) : array(); |
| 32 |
$nonce = isset( $post_data['upstream_login_nonce'] ) ? $post_data['upstream_login_nonce'] : null; |
| 33 |
$up_user_email = ''; |
| 34 |
|
| 35 |
if ( wp_verify_nonce( $nonce, 'upstream-login-nonce' ) && isset( $post_data['user_email'] ) ) { |
| 36 |
$up_user_email = sanitize_email( $post_data['user_email'] ); |
| 37 |
} |
| 38 |
|
| 39 |
?> |
| 40 |
|
| 41 |
<?php upstream_get_template_part( 'global/header.php' ); ?> |
| 42 |
|
| 43 |
<div class="col-xs-12 col-sm-4 col-sm-offset-4 text-center"> |
| 44 |
<?php if ( $should_display_client_logo && ! empty( $client_logo_url ) ) : ?> |
| 45 |
<img src="<?php echo esc_url( $client_logo_url ); ?>"/> |
| 46 |
<?php endif; ?> |
| 47 |
|
| 48 |
<div class="account-wall"> |
| 49 |
<?php if ( ! empty( $header_text ) ) : ?> |
| 50 |
<header> |
| 51 |
<h3 class="text-center"><?php echo esc_html( $header_text ); ?></h3> |
| 52 |
</header> |
| 53 |
<?php endif; ?> |
| 54 |
|
| 55 |
<?php do_action( 'upstream_login_before_form' ); ?> |
| 56 |
|
| 57 |
<form class="loginform" action="" method="POST"> |
| 58 |
<input type="text" class="form-control" placeholder="<?php esc_attr_e( 'Your Email', 'upstream' ); ?>" |
| 59 |
name="user_email" required |
| 60 |
value="<?php echo esc_attr( $up_user_email ); ?>" <?php echo empty( $up_user_email ) ? 'autofocus' : ''; ?> /> |
| 61 |
<input type="password" class="form-control" placeholder="<?php esc_attr_e( 'Password', 'upstream' ); ?>" |
| 62 |
name="user_password" required <?php echo ! empty( $up_user_email ) ? 'autofocus' : ''; ?> /> |
| 63 |
|
| 64 |
<input type="hidden" name="upstream_login_nonce" |
| 65 |
value="<?php echo esc_attr( wp_create_nonce( 'upstream-login-nonce' ) ); ?>"/> |
| 66 |
|
| 67 |
<input type="submit" class="btn btn-lg btn-primary btn-block" value="<?php esc_attr_e( 'Sign In', 'upstream' ); ?>" |
| 68 |
name="login"/> |
| 69 |
</form> |
| 70 |
|
| 71 |
<?php do_action( 'upstream_login_after_form' ); ?> |
| 72 |
|
| 73 |
<div class="text-center"> |
| 74 |
<?php echo esc_html( upstream_login_text() ); ?> |
| 75 |
</div> |
| 76 |
</div> |
| 77 |
|
| 78 |
<?php if ( $login->has_feedback_message() ) : ?> |
| 79 |
<div class="alert alert-danger"> |
| 80 |
<?php echo esc_html( $login->get_feedback_message() ); ?> |
| 81 |
</div> |
| 82 |
<?php endif; ?> |
| 83 |
</div> |
| 84 |
|