'widget_user_login', 'description' => __( 'Displays a handy login form for users', 'jigoshop' ) ); parent::__construct( 'user-login', __( 'Jigoshop: Login', 'jigoshop' ), $options ); } /** * Widget * * Display the widget in the sidebar * Save output to the cache if empty * * @param array sidebar arguments * @param array instance */ public function widget( $args, $instance ) { extract( $args ); // Print the widget wrapper echo $before_widget; if( is_user_logged_in() ) { // Get current user instance global $current_user; // Print title $title = ( $instance['title_user'] ) ? $instance['title_user'] : __( 'Hey %s!', 'jigoshop' ); echo $before_title . sprintf( $title, ucwords( $current_user->display_name ) ) . $after_title; // Create the default set of links $links = apply_filters( 'jigoshop_widget_logout_user_links' , array( __( 'My Account', 'jigoshop' ) => get_permalink( jigoshop_get_page_id('myaccount') ), __( 'Change Password', 'jigoshop' ) => get_permalink( jigoshop_get_page_id('change_password') ), __( 'Logout', 'jigoshop' ) => wp_logout_url( home_url() ), )); } else { // Print title $title = ( $instance['title_guest'] ) ? $instance['title_guest'] : __( 'Login', 'jigoshop' ); echo $before_title . $title . $after_title; do_action( 'jigoshop_widget_login_before_form' ); // Get redirect URI $redirect_to = apply_filters( 'jigoshop_widget_login_redirect', get_permalink( jigoshop_get_page_id('myaccount') ) ); $user_login = isset( $user_login ) ? $user_login : null; echo "
"; do_action( 'jigoshop_widget_login_after_form' ); $links = apply_filters( 'jigoshop_widget_login_user_links', array() ); } // Loop & print out the links if( $links ) { echo " "; } // Print closing widget wrapper echo $after_widget; } /** * Update * * Handles the processing of information entered in the wordpress admin * Flushes the cache & removes entry from options array * * @param array new instance * @param array old instance * @return array instance */ public function update( $new_instance, $old_instance ) { $instance = $old_instance; // Save the new values $instance['title_guest'] = strip_tags( $new_instance['title_guest'] ); $instance['title_user'] = strip_tags( $new_instance['title_user'] ); return $instance; } /** * Form * * Displays the form for the wordpress admin * * @param array instance */ public function form( $instance ) { // Get instance data $title_guest = isset( $instance['title_guest'] ) ? esc_attr( $instance['title_guest'] ) : null; $title_user = isset( $instance['title_user'] ) ? esc_attr( $instance['title_user'] ) : null; // Title for Guests echo ""; // Title for Users echo "
"; } } // class Jigoshop_Widget_Recent_Products