'widget_mfn_login', 'description' => __( 'Displays Login Form.', 'mfn-opts' ) );
parent::__construct( 'widget_mfn_login', __( 'Muffin Login', 'mfn-opts' ), $widget_ops );
$this->alt_option_name = 'widget_mfn_login';
}
/* ---------------------------------------------------------------------------
* Outputs the HTML for this widget.
* --------------------------------------------------------------------------- */
function widget( $args, $instance ) {
global $user_login;
if ( ! isset( $args['widget_id'] ) ) $args['widget_id'] = null;
extract( $args, EXTR_SKIP );
extract( $instance );
echo $before_widget;
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base);
if( is_user_logged_in() ){
$user = get_user_by('login', $user_login);
$title = __('Welcome','mfn-opts').' '.$user->data->display_name;
}
echo '
';
if( $title ) echo $before_title . $title . $after_title;
// validation
if( isset( $_GET['login'] ) && $_GET['login'] == 'failed'){
$errcode = $_GET['errcode'];
if( $errcode == "empty_username" || $errcode == "empty_password" ){
$error = __('Please enter Username and Password', 'mfn-opts');
}
elseif( $errcode == 'invalid_username' ){
$error = __('Invalid Username', 'mfn-opts');
}
elseif( $errcode == 'incorrect_password' ){
$error = __('Incorrect Password', 'mfn-opts');
}
echo '
'. $error .'
';
}
if( is_user_logged_in() ){
echo '
'. get_avatar( $user->ID, 64 ) .'
';
echo '
';
} else {
wp_login_form(array( 'value_remember' => 0,
'redirect' => site_url(),
// 'label_username' => __( 'Username', 'mfn-opts' ),
// 'label_password' => __( 'Password', 'mfn-opts' ),
// 'label_remember' => __( 'Remember Me', 'mfn-opts' ),
// 'label_log_in' => __( 'Log In', 'mfn-opts' ),
'remember' => false
));
echo '
';
}
echo '
'."\n";
echo $after_widget;
}
/* ---------------------------------------------------------------------------
* Deals with the settings when they are saved by the admin.
* --------------------------------------------------------------------------- */
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
// $instance['show_remember_me'] = (int) $new_instance['show_remember_me'];
$instance['show_register'] = (int) $new_instance['show_register'];
$instance['show_forgotten_password'] = (int) $new_instance['show_forgotten_password'];
return $instance;
}
/* ---------------------------------------------------------------------------
* Displays the form for this widget on the Widgets page of the WP Admin area.
* --------------------------------------------------------------------------- */
function form( $instance ) {
$title = isset( $instance['title']) ? esc_attr( $instance['title'] ) : '';
// $show_remember_me = isset( $instance['show_remember_me'] ) ? absint( $instance['show_remember_me'] ) : 0;
$show_register = isset( $instance['show_register'] ) ? absint( $instance['show_register'] ) : 0;
$show_forgotten_password = isset( $instance['show_forgotten_password'] ) ? absint( $instance['show_forgotten_password'] ) : 0;
?>
/>
/>