| 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 = 'post_member' . $usces->get_uscesid( false ); |
| 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 |
} |
| 124 |
|