| 1 |
<?php |
| 2 |
/** |
| 3 |
* Welcart Calendar Widget |
| 4 |
* |
| 5 |
* @package Welcart |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Welcart_calendar Class |
| 10 |
* |
| 11 |
* @see WP_Widget |
| 12 |
*/ |
| 13 |
class Welcart_calendar extends WP_Widget { |
| 14 |
|
| 15 |
/** |
| 16 |
* Constructor. |
| 17 |
*/ |
| 18 |
public function __construct() { |
| 19 |
$widget_ops = array( |
| 20 |
'classname' => 'widget_welcart_calendar', |
| 21 |
'description' => __( 'Display business day calendar.', 'usces' ), |
| 22 |
); |
| 23 |
parent::__construct( 'welcart_calendar', 'Welcart ' . __( 'Calendar', 'usces' ), $widget_ops ); |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Echoes the widget content. |
| 28 |
* |
| 29 |
* @see WP_Widget::widget |
| 30 |
* @param array $args Display arguments including 'before_title', 'after_title', |
| 31 |
* 'before_widget', and 'after_widget'. |
| 32 |
* @param array $instance The settings for the particular instance of the widget. |
| 33 |
*/ |
| 34 |
public function widget( $args, $instance ) { |
| 35 |
extract( $args ); |
| 36 |
$title = $instance['title']; |
| 37 |
$icon = ( ! isset( $instance['icon'] ) || WCUtils::is_blank( $instance['icon'] ) ) ? 1 : (int) $instance['icon']; |
| 38 |
$img_path = file_exists( get_stylesheet_directory() . '/images/calendar.png' ) ? get_stylesheet_directory_uri() . '/images/calendar.png' : USCES_FRONT_PLUGIN_URL . '/images/calendar.png'; |
| 39 |
if ( 1 === $icon ) { |
| 40 |
$before_title .= '<img src="' . $img_path . '" alt="' . $title . '" />'; |
| 41 |
} |
| 42 |
|
| 43 |
wel_esc_script_e( $before_widget ); |
| 44 |
if ( ! empty( $title ) ) { |
| 45 |
wel_esc_script_e( $before_title . esc_html( $title ) . $after_title ); |
| 46 |
} |
| 47 |
?> |
| 48 |
|
| 49 |
<ul class="ucart_calendar_body ucart_widget_body"><li> |
| 50 |
<?php usces_the_calendar(); ?> |
| 51 |
</li></ul> |
| 52 |
|
| 53 |
<?php |
| 54 |
wel_esc_script_e( $after_widget ); |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* Updates a particular instance of a widget. |
| 59 |
* |
| 60 |
* @see WP_Widget::update |
| 61 |
* @param array $new_instance New settings for this instance as input by the user via |
| 62 |
* WP_Widget::form(). |
| 63 |
* @param array $old_instance Old settings for this instance. |
| 64 |
* @return array Settings to save or bool false to cancel saving. |
| 65 |
*/ |
| 66 |
public function update( $new_instance, $old_instance ) { |
| 67 |
return $new_instance; |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* Outputs the settings update form. |
| 72 |
* |
| 73 |
* @see WP_Widget::form |
| 74 |
* @param array $instance Current settings. |
| 75 |
*/ |
| 76 |
public function form( $instance ) { |
| 77 |
$title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; |
| 78 |
$icon = ( ! isset( $instance['icon'] ) || WCUtils::is_blank( $instance['icon'] ) ) ? 1 : (int) $instance['icon']; |
| 79 |
?> |
| 80 |
<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> |
| 81 |
<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' ) ); ?>"> |
| 82 |
<option value="1"<?php selected( $icon, 1 ); ?>><?php esc_html_e( 'Indication', 'usces' ); ?></option> |
| 83 |
<option value="2"<?php selected( $icon, 2 ); ?>><?php esc_html_e( 'Non-indication', 'usces' ); ?></option></select></label> |
| 84 |
</p> |
| 85 |
<p><?php esc_html_e( "The setting of the business day, In a 'business day setting' page of the admin screen.", 'usces' ); ?></p> |
| 86 |
<?php |
| 87 |
} |
| 88 |
} |
| 89 |
|