| @@ -1,81 +1,123 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -/** | |
| 4 | - * Welcart_login Class | |
| 5 | - */ | |
| 6 | -class Welcart_login extends WP_Widget { | |
| 7 | - /** constructor */ | |
| 8 | - function Welcart_login() { | |
| 9 | - parent::WP_Widget(false, $name = 'Welcart '.__('Log-in', 'usces')); | |
| 10 | - } | |
| 11 | - | |
| 12 | - /** @see WP_Widget::widget */ | |
| 13 | - function widget($args, $instance) { | |
| 14 | - extract( $args ); | |
| 15 | - $title = ( !isset($instance['title']) || WCUtils::is_blank($instance['title'])) ? 'Welcart '.__('Log-in', 'usces') : $instance['title']; | |
| 16 | - $icon = ( !isset($instance['icon']) || WCUtils::is_blank($instance['icon'])) ? 1 : (int)$instance['icon']; | |
| 17 | - //if($icon == 1) $before_title = '<div class="widget_title"><img src="' . USCES_PLUGIN_URL . '/images/find.png" alt="' . $title . '" width="24" height="24" />'; | |
| 18 | - $img_path = file_exists(get_stylesheet_directory().'/images/login.png') ? get_stylesheet_directory_uri().'/images/login.png' : USCES_FRONT_PLUGIN_URL . '/images/login.png'; | |
| 19 | - if($icon == 1) $before_title .= '<img src="' . $img_path . '" alt="' . $title . '" />'; | |
| 20 | - ?> | |
| 21 | - <?php echo $before_widget; ?> | |
| 22 | - <?php echo $before_title | |
| 23 | - . esc_html($title) | |
| 24 | - . $after_title; ?> | |
| 25 | - | |
| 26 | - <ul class="ucart_login_body ucart_widget_body"><li> | |
| 27 | - | |
| 28 | - <?php ob_start(); ?> | |
| 29 | - | |
| 30 | - <div class="loginbox"> | |
| 31 | - <?php if ( ! usces_is_login() ) { ?> | |
| 32 | - <form name="loginwidget" id="loginformw" action="<?php echo USCES_MEMBER_URL; ?>" method="post"> | |
| 33 | - <p> | |
| 34 | - <label><?php _e('e-mail adress', 'usces'); ?><br /> | |
| 35 | - <input type="text" name="loginmail" id="loginmailw" class="loginmail" value="<?php usces_remembername(); ?>" size="20" /></label><br /> | |
| 36 | - <label><?php _e('password', 'usces'); ?><br /> | |
| 37 | - <input type="password" name="loginpass" id="loginpassw" class="loginpass" size="20" /></label><br /> | |
| 38 | - <label><input name="rememberme" type="checkbox" id="remembermew" value="forever" /> <?php _e('Remember Me', 'usces'); ?></label></p> | |
| 39 | - <p class="submit"> | |
| 40 | - <input type="submit" name="member_login" id="member_loginw" value="<?php _e('Log-in', 'usces'); ?>" /> | |
| 41 | - </p> | |
| 42 | - <?php echo apply_filters('usces_filter_login_inform', NULL); ?> | |
| 43 | - </form> | |
| 44 | - <a href="<?php echo USCES_LOSTMEMBERPASSWORD_URL; ?>" title="<?php _e('Pssword Lost and Found', 'usces'); ?>"><?php _e('Lost your password?', 'usces'); ?></a><br /> | |
| 45 | - <a href="<?php echo USCES_NEWMEMBER_URL; ?>" title="<?php _e('New enrollment for membership.', 'usces'); ?>"><?php _e('New enrollment for membership.', 'usces'); ?></a> | |
| 46 | - <?php }else{ ?> | |
| 47 | - <div><?php echo sprintf(__('Mr/Mrs %s', 'usces'), usces_the_member_name('return')); ?></div> | |
| 48 | - <?php echo usces_loginout(); ?><br /> | |
| 49 | - <a href="<?php echo USCES_MEMBER_URL; ?>" class="login_widget_mem_info_a"><?php _e('Membership information','usces') ?></a> | |
| 50 | - <?php } ?> | |
| 51 | - </div> | |
| 52 | - | |
| 53 | - <?php | |
| 54 | - $loginbox = ob_get_contents(); | |
| 55 | - ob_end_clean(); | |
| 56 | - echo apply_filters('usces_filter_login_widget', $loginbox, $args, $instance); | |
| 57 | - ?> | |
| 58 | - | |
| 59 | - </li></ul> | |
| 60 | - | |
| 61 | - <?php echo $after_widget; ?> | |
| 62 | - <?php | |
| 63 | - } | |
| 64 | - | |
| 65 | - /** @see WP_Widget::update */ | |
| 66 | - function update($new_instance, $old_instance) { | |
| 67 | - return $new_instance; | |
| 68 | - } | |
| 69 | - | |
| 70 | - /** @see WP_Widget::form */ | |
| 71 | - function form($instance) { | |
| 72 | - $title = (!isset($instance['title']) || WCUtils::is_blank($instance['title']) ) ? 'Welcart '.__('Log-in', 'usces') : esc_attr($instance['title']); | |
| 73 | - $icon = (!isset($instance['icon']) || WCUtils::is_blank($instance['icon']) ) ? 1 : (int)$instance['icon']; | |
| 74 | - ?> | |
| 75 | - <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p> | |
| 76 | - <p><label for="<?php echo $this->get_field_id('icon'); ?>"><?php _e('display of icon', 'usces'); ?>: <select class="widefat" id="<?php echo $this->get_field_id('icon'); ?>" name="<?php echo $this->get_field_name('icon'); ?>"><option value="1"<?php if($icon == 1){echo ' selected="selected"';} ?>><?php _e('Indication', 'usces'); ?></option><option value="2"<?php if($icon == 2){echo ' selected="selected"';} ?>><?php _e('Non-indication', 'usces'); ?></option></select></label></p> | |
| 77 | - <?php | |
| 78 | - } | |
| 79 | - | |
| 80 | -} | |
| 81 | -?> | |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Welcart Login Widget | |
| 4 | + * | |
| 5 | + * @package Welcart | |
| 6 | + */ | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * Welcart_login Class | |
| 10 | + */ | |
| 11 | +class Welcart_login extends WP_Widget { | |
| 12 | + | |
| 13 | + /** | |
| 14 | + * Constructor. | |
| 15 | + */ | |
| 16 | + public function __construct() { | |
| 17 | + $widget_ops = array( | |
| 18 | + 'classname' => 'widget_welcart_login', | |
| 19 | + 'description' => __( 'Display member login form.', 'usces' ), | |
| 20 | + ); | |
| 21 | + parent::__construct( 'welcart_login', 'Welcart ' . __( 'Log-in', 'usces' ), $widget_ops ); | |
| 22 | + } | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * Echoes the widget content. | |
| 26 | + * | |
| 27 | + * @see WP_Widget::widget | |
| 28 | + * @param array $args Display arguments including 'before_title', 'after_title', | |
| 29 | + * 'before_widget', and 'after_widget'. | |
| 30 | + * @param array $instance The settings for the particular instance of the widget. | |
| 31 | + */ | |
| 32 | + public function widget( $args, $instance ) { | |
| 33 | + global $usces; | |
| 34 | + extract( $args ); | |
| 35 | + $title = $instance['title']; | |
| 36 | + $icon = ( ! isset( $instance['icon'] ) || WCUtils::is_blank( $instance['icon'] ) ) ? 1 : (int) $instance['icon']; | |
| 37 | + $img_path = file_exists( get_stylesheet_directory() . '/images/login.png' ) ? get_stylesheet_directory_uri() . '/images/login.png' : USCES_FRONT_PLUGIN_URL . '/images/login.png'; | |
| 38 | + if ( 1 === $icon ) { | |
| 39 | + $before_title .= '<img src="' . $img_path . '" alt="' . $title . '" />'; | |
| 40 | + } | |
| 41 | + | |
| 42 | + wel_esc_script_e( $before_widget ); | |
| 43 | + if ( ! empty( $title ) ) { | |
| 44 | + wel_esc_script_e( $before_title . esc_html( $title ) . $after_title ); | |
| 45 | + } | |
| 46 | + ?> | |
| 47 | + | |
| 48 | + <ul class="ucart_login_body ucart_widget_body"><li> | |
| 49 | + | |
| 50 | + <?php ob_start(); ?> | |
| 51 | + | |
| 52 | + <div class="loginbox"> | |
| 53 | + <?php if ( ! usces_is_login() ) : ?> | |
| 54 | + <form name="loginwidget" id="loginformw" action="<?php echo esc_url( USCES_MEMBER_URL ); ?>" method="post"> | |
| 55 | + <p> | |
| 56 | + <label><?php esc_html_e( 'e-mail adress', 'usces' ); ?><br /> | |
| 57 | + <input type="text" name="loginmail" id="loginmailw" class="loginmail" value="<?php usces_remembername(); ?>" size="20" /></label><br /> | |
| 58 | + <label><?php esc_html_e( 'password', 'usces' ); ?><br /> | |
| 59 | + <input type="password" name="loginpass" id="loginpassw" class="loginpass" size="20" autocomplete="off" /></label><br /> | |
| 60 | + <label><input name="rememberme" type="checkbox" id="remembermew" value="forever" /> <?php esc_html_e( 'Remember Me', 'usces' ); ?></label></p> | |
| 61 | + <p class="submit"> | |
| 62 | + <input type="submit" name="member_login" id="member_loginw" value="<?php esc_attr_e( 'Log-in', 'usces' ); ?>" /> | |
| 63 | + </p> | |
| 64 | + <?php | |
| 65 | + echo apply_filters( 'usces_filter_login_inform', null ); | |
| 66 | + $noncekey = $usces->member_nonce_key( 'post_member' ); | |
| 67 | + wp_nonce_field( $noncekey, 'wel_nonce' ); | |
| 68 | + ?> | |
| 69 | + </form> | |
| 70 | + <a href="<?php echo esc_url( USCES_LOSTMEMBERPASSWORD_URL ); ?>" title="<?php esc_attr_e( 'Pssword Lost and Found', 'usces' ); ?>"><?php esc_html_e( 'Lost your password?', 'usces' ); ?></a><br /> | |
| 71 | + <a href="<?php echo esc_url( USCES_NEWMEMBER_URL ); ?>" title="<?php esc_attr_e( 'New enrollment for membership.', 'usces' ); ?>"><?php esc_html_e( 'New enrollment for membership.', 'usces' ); ?></a> | |
| 72 | + <?php | |
| 73 | + else : | |
| 74 | + ?> | |
| 75 | + <div><?php echo sprintf( _x( '%s', 'honorific', 'usces' ), usces_the_member_name( 'return' ) ); ?></div> | |
| 76 | + <?php wel_esc_script_e( usces_loginout() ); ?><br /> | |
| 77 | + <a href="<?php echo esc_url( USCES_MEMBER_URL ); ?>" class="login_widget_mem_info_a"><?php esc_html_e( 'Membership information', 'usces' ); ?></a> | |
| 78 | + <?php endif; ?> | |
| 79 | + </div> | |
| 80 | + | |
| 81 | + <?php | |
| 82 | + $loginbox = ob_get_contents(); | |
| 83 | + ob_end_clean(); | |
| 84 | + echo apply_filters( 'usces_filter_login_widget', $loginbox, $args, $instance ); | |
| 85 | + ?> | |
| 86 | + | |
| 87 | + </li></ul> | |
| 88 | + | |
| 89 | + <?php | |
| 90 | + wel_esc_script_e( $after_widget ); | |
| 91 | + } | |
| 92 | + | |
| 93 | + /** | |
| 94 | + * Updates a particular instance of a widget. | |
| 95 | + * | |
| 96 | + * @see WP_Widget::update | |
| 97 | + * @param array $new_instance New settings for this instance as input by the user via | |
| 98 | + * WP_Widget::form(). | |
| 99 | + * @param array $old_instance Old settings for this instance. | |
| 100 | + * @return array Settings to save or bool false to cancel saving. | |
| 101 | + */ | |
| 102 | + public function update( $new_instance, $old_instance ) { | |
| 103 | + return $new_instance; | |
| 104 | + } | |
| 105 | + | |
| 106 | + /** | |
| 107 | + * Outputs the settings update form. | |
| 108 | + * | |
| 109 | + * @see WP_Widget::form | |
| 110 | + * @param array $instance Current settings. | |
| 111 | + */ | |
| 112 | + public function form( $instance ) { | |
| 113 | + $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; | |
| 114 | + $icon = ( ! isset( $instance['icon'] ) || WCUtils::is_blank( $instance['icon'] ) ) ? 1 : (int) $instance['icon']; | |
| 115 | + ?> | |
| 116 | + <p><label for="<?php wel_esc_script_e( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'usces' ); ?> <input class="widefat" id="<?php wel_esc_script_e( $this->get_field_id( 'title' ) ); ?>" name="<?php wel_esc_script_e( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php wel_esc_script_e( $title ); ?>" /></label></p> | |
| 117 | + <p><label for="<?php wel_esc_script_e( $this->get_field_id( 'icon' ) ); ?>"><?php esc_html_e( 'display of icon', 'usces' ); ?>: <select class="widefat" id="<?php wel_esc_script_e( $this->get_field_id( 'icon' ) ); ?>" name="<?php wel_esc_script_e( $this->get_field_name( 'icon' ) ); ?>"> | |
| 118 | + <option value="1"<?php selected( $icon, 1 ); ?>><?php esc_html_e( 'Indication', 'usces' ); ?></option> | |
| 119 | + <option value="2"<?php selected( $icon, 2 ); ?>><?php esc_html_e( 'Non-indication', 'usces' ); ?></option></select></label> | |
| 120 | + </p> | |
| 121 | + <?php | |
| 122 | + } | |
| 123 | +} | |