File: /home/storage/162/3480162/user/htdocs/wp-content/plugins/envo-magazine-pro/lib/tabbed-login.php
<?php
/**
* Custom widgets.
*
*/
if ( !class_exists( 'envo_magazine_tabbed_login' ) ) :
/**
* Two Column News widget class.
*
*/
class envo_magazine_tabbed_login extends WP_Widget {
function __construct() {
$opts = array(
'classname' => 'tabbed-login-section',
'description' => esc_html__( 'Widget to display login/register tabs. Recommended to be used in sidebar or footer.', 'envo-magazine-pro' ),
);
parent::__construct( 'envo-magazine-tabbed-login', esc_html__( 'Envo Magazine: Tabbed login', 'envo-magazine-pro' ), $opts );
}
function widget( $args, $instance ) {
$title = apply_filters( 'widget_title', empty( $instance[ 'title' ] ) ? '' : $instance[ 'title' ], $instance, $this->id_base );
echo $args[ 'before_widget' ];
?>
<div class="section-title">
<?php
if ( !empty( $title ) ) {
echo $args[ 'before_title' ] . esc_html( $title ) . $args[ 'after_title' ];
}
?>
</div>
<?php
global $user_ID, $user_identity, $current_url;
$current_url = 'http' . (empty( $_SERVER[ 'HTTPS' ] ) ? '' : 's') . '://' . $_SERVER[ 'SERVER_NAME' ] . $_SERVER[ 'REQUEST_URI' ];
wp_get_current_user();
if ( !$user_ID ) {
?>
<div id="login-register-password">
<?php
if ( get_option( 'users_can_register' ) ) {
$layout = 'three-column-reg';
} else {
$layout = 'two-column-reg';
};
?>
<ul class="tabs_login <?php echo $layout ?>">
<li class="active_login">
<a href="#login" >
<?php esc_html_e( 'Log In', 'envo-magazine-pro' ); ?>
</a>
</li>
<?php if ( get_option( 'users_can_register' ) ) { ?>
<li>
<a href="#register">
<?php esc_html_e( 'Register', 'envo-magazine-pro' ) ?>
</a>
</li>
<?php }; ?>
<li>
<a href="#forgot_password">
<?php esc_html_e( 'Reset', 'envo-magazine-pro' ); ?>
</a>
</li>
</ul>
<div class="tab_container_login">
<div id="login" class="tab_content_login">
<?php
$register = !empty($_GET[ 'register' ]) ? $_GET[ 'register' ] : '';
$reset = !empty($_GET[ 'reset' ]) ? $_GET[ 'reset' ] : '';
if ( $register == true ) {
?>
<h4><?php esc_html_e( 'Success!', 'envo-magazine-pro' ); ?></h4>
<p><?php esc_html_e( 'Check your email for the password and then return to log in.', 'envo-magazine-pro' ); ?></p>
<?php } elseif ( $reset == true ) { ?>
<h4><?php esc_html_e( 'Success!', 'envo-magazine-pro' ); ?></h4>
<p><?php esc_html_e( 'Check your email to reset your password.', 'envo-magazine-pro' ); ?></p>
<?php } else { ?>
<h4><?php esc_html_e( 'Have an account?', 'envo-magazine-pro' ); ?></h4>
<?php } ?>
<form method="post" action="<?php bloginfo( 'url' ) ?>/wp-login.php" class="wp-user-form">
<div class="username">
<label for="user_login"><?php esc_html_e( 'Username', 'envo-magazine-pro' ); ?>: </label>
<input type="text" name="log" value="" size="20" id="user_login" tabindex="11" />
</div>
<div class="password">
<label for="user_pass"><?php esc_html_e( 'Password', 'envo-magazine-pro' ); ?>: </label>
<input type="password" name="pwd" value="" size="20" id="user_pass" tabindex="12" />
</div>
<div class="login_fields">
<div class="rememberme">
<label for="rememberme">
<input type="checkbox" name="rememberme" value="forever" checked="checked" id="rememberme" tabindex="13" /><?php esc_html_e( ' Remember me', 'envo-magazine-pro' ); ?>
</label>
</div>
<?php do_action( 'login_form' ); ?>
<input type="submit" name="user-submit" value="<?php esc_html_e( 'Login', 'envo-magazine-pro' ); ?>" tabindex="14" class="user-submit" />
<input type="hidden" name="redirect_to" value="<?php echo $current_url; ?>" />
<input type="hidden" name="user-cookie" value="1" />
</div>
</form>
</div>
<?php if ( get_option( 'users_can_register' ) ) { ?>
<div id="register" class="tab_content_login" style="display:none;">
<h4><?php esc_html_e( 'Register for this site!', 'envo-magazine-pro' ); ?></h4>
<form method="post" action="<?php echo site_url( 'wp-login.php?action=register', 'login_post' ) ?>" class="wp-user-form">
<div class="username">
<label for="user_login"><?php esc_html_e( 'Username', 'envo-magazine-pro' ); ?>: </label>
<input type="text" name="user_login" value="" size="20" id="user_register" tabindex="101" />
</div>
<div class="password">
<label for="user_email"><?php esc_html_e( 'Your Email', 'envo-magazine-pro' ); ?>: </label>
<input type="text" name="user_email" value="" size="25" id="user_email" tabindex="102" />
</div>
<div class="login_fields">
<?php do_action( 'register_form' ); ?>
<input type="submit" name="user-submit" value="<?php esc_html_e( 'Sign up!', 'envo-magazine-pro' ); ?>" class="user-submit" tabindex="103" />
<?php
$register = !empty($_GET[ 'register' ]) ? $_GET[ 'register' ] : '';
if ( $register == true ) {
echo '<p>Check your email for the password!</p>';
}
?>
<input type="hidden" name="redirect_to" value="<?php echo $current_url; ?>?register=true" />
<input type="hidden" name="user-cookie" value="1" />
</div>
</form>
</div>
<?php } else { ?>
<div id="register" class="tab_content_login" style="display:none;">
<h4><?php esc_html_e( 'Registration is disabled on this website"', 'envo-magazine-pro' ); ?></h4>
</div>
<?php } ?>
<div id="forgot_password" class="tab_content_login" style="display:none;">
<h4><?php esc_html_e( 'Lost Your Password?', 'envo-magazine-pro' ); ?></h4>
<p><?php esc_html_e( 'Enter your username or email to reset your password.', 'envo-magazine-pro' ); ?></p>
<form method="post" action="<?php echo site_url( 'wp-login.php?action=lostpassword', 'login_post' ) ?>" class="wp-user-form">
<div class="username">
<label for="user_login" class="hide"><?php esc_html_e( 'Username or Email', 'envo-magazine-pro' ); ?>: </label>
<input type="text" name="user_login" value="" size="20" id="user_lost" tabindex="1001" />
</div>
<div class="login_fields">
<?php do_action( 'login_form', 'resetpass' ); ?>
<input type="submit" name="user-submit" value="<?php esc_html_e( 'Reset my password', 'envo-magazine-pro' ); ?>" class="user-submit" tabindex="1002" />
<?php
$reset = !empty($_GET[ 'reset' ]) ? $_GET[ 'reset' ] : '';
if ( $reset == true ) {
echo '<p>' . __( 'A message was sent to your email address.', 'envo-magazine-pro' ) . '</p>';
}
?>
<input type="hidden" name="redirect_to" value="<?php echo $current_url; ?>?reset=true" />
<input type="hidden" name="user-cookie" value="1" />
</div>
</form>
</div>
</div>
</div>
<?php } else { // is logged in ?>
<div id="login-register-password" class="logged-in">
<div class="sidebox">
<h4><?php esc_html_e( 'Welcome, ', 'envo-magazine-pro' ); ?> <?php echo $user_identity; ?></h4>
<?php
if ( version_compare( $GLOBALS[ 'wp_version' ], '2.5', '>=' ) ) {
if ( get_option( 'show_avatars' ) ) {
?>
<div class="usericon">
<?php
global $userdata;
wp_get_current_user();
echo get_avatar( $userdata->ID, 50 );
?>
</div>
<?php }
}
?>
<div class="userinfo">
<p><?php esc_html_e( 'You are logged in as ', 'envo-magazine-pro' ); ?> <strong><?php echo $user_identity; ?></strong></p>
<p>
<a href="<?php echo wp_logout_url( $current_url ); ?>"><?php esc_html_e( 'Log out', 'envo-magazine-pro' ); ?></a> |
<?php
if ( current_user_can( 'manage_options' ) ) {
echo '<a href="' . admin_url() . '">' . __( 'Admin', 'envo-magazine-pro' ) . '</a>';
} else {
echo '<a href="' . admin_url() . 'profile.php">' . __( 'Profile', 'envo-magazine-pro' ) . '</a>';
}
?>
</p>
</div>
</div>
</div>
<?php } ?>
<?php
echo $args[ 'after_widget' ];
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance[ 'title' ] = sanitize_text_field( $new_instance[ 'title' ] );
return $instance;
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array(
'title' => '',
) );
?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'envo-magazine-pro' ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance[ 'title' ] ); ?>" />
</p>
<?php
}
}
endif;