woo_widget_cssclass = 'widget_login'; $this->woo_widget_description = __( 'Display a login area and "My Account" links in the sidebar.', 'woocommerce' ); $this->woo_widget_idbase = 'woocommerce_login'; $this->woo_widget_name = __('WooCommerce Login', 'woocommerce' ); /* Widget settings. */ $widget_ops = array( 'classname' => $this->woo_widget_cssclass, 'description' => $this->woo_widget_description ); /* Create the widget. */ $this->WP_Widget('woocommerce_login', $this->woo_widget_name, $widget_ops); } /** @see WP_Widget */ function widget( $args, $instance ) { global $woocommerce; extract($args); // Don't show if on the account page since that has a login if (is_account_page() && !is_user_logged_in()) return; $logged_out_title = (!empty($instance['logged_out_title'])) ? $instance['logged_out_title'] : __('Customer Login', 'woocommerce'); $logged_in_title = (!empty($instance['logged_in_title'])) ? $instance['logged_in_title'] : __('Welcome %s', 'woocommerce'); echo $before_widget; if (is_user_logged_in()) { $user = get_user_by('id', get_current_user_id()); if ( $logged_in_title ) echo $before_title . sprintf( $logged_in_title, ucwords($user->display_name) ) . $after_title; do_action('woocommerce_login_widget_logged_in_before_links'); $links = apply_filters( 'woocommerce_login_widget_logged_in_links', array( __('My account', 'woocommerce') => get_permalink(woocommerce_get_page_id('myaccount')), __('Change my password', 'woocommerce') => get_permalink(woocommerce_get_page_id('change_password')), __('Logout', 'woocommerce') => wp_logout_url(home_url()) )); if (sizeof($links>0)) : echo '
ID) ) { $secure_cookie = true; force_ssl_admin(true); } } } if ( !$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && ( 0 !== strpos($redirect_to, 'https') ) && ( 0 === strpos($redirect_to, 'http') ) ) $secure_cookie = false; // Login $user = wp_signon('', $secure_cookie); // Redirect filter if ( $secure_cookie && false !== strpos($redirect_to, 'wp-admin') ) $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to); // Check the username if ( !$_POST['log'] ) : $user = new WP_Error(); $user->add('empty_username', '' . __('ERROR', 'woocommerce') . ': ' . __('Please enter a username.', 'woocommerce')); elseif ( !$_POST['pwd'] ) : $user = new WP_Error(); $user->add('empty_username', '' . __('ERROR', 'woocommerce') . ': ' . __('Please enter your password.', 'woocommerce')); endif; // Redirect if successful if ( !is_wp_error($user) ) : wp_safe_redirect( $redirect_to ); exit; endif; $login_errors = $user; } }