PluginProbe
Event Post / 6.1.2
Event Post v6.1.2
6.1.2 6.1.1 6.1.0 6.0.1 6.0.0 5.12.0 trunk 3.9 4.0 4.2 4.3 4.4 4.5 5.0 5.1 5.10.0 5.10.1 5.10.2 5.10.3 5.10.4 5.11.0 5.11.1 5.2 5.5 5.6 All 47 releases
event-post / inc / deprecated / widget.cal.php

widget.cal.php in Event Post 6.1.2, at inc/deprecated/widget.cal.php

164 lines 7.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The calendar widget
4 * @deprecated
5 * @package event-post
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) exit;
9
10 class EventPost_Cal extends WP_Widget {
11 var $defaults;
12 function __construct() {
13 parent::__construct(false, __( 'Events Calendar', 'event-post' ),array('description'=>__( 'Calendar presentation of events posts', 'event-post' )));
14 $this->defaults = array(
15 'title' => '',
16 'cat' => '',
17 'date' => date('Y-n'),
18 'mf' => 0,
19 'choose' => 1,
20 'colored' => 1,
21 'display_title' => 0,
22 'thumbnail' => 0,
23 'thumbnail_size' => '',
24 );
25 }
26 public function eventpostcal_widget(){
27 $this->__construct();
28 }
29 function widget($args, $local_instance) {
30 if(!defined('ALLOW_DEPRECATED') || !ALLOW_DEPRECATED) {
31 _deprecated_function(__FUNCTION__, '5.9.0', __('Legacy widgets have been deprecated. Consider using blocks instead.', 'event-post'));
32 }
33 extract( $args );
34 $instance = wp_parse_args((array) $local_instance, $this->defaults);
35
36 $date = !empty($instance['date'])?date('Y-n',strtotime(esc_attr($instance['date']))):date('Y-n');
37 $cat = sanitize_text_field($instance['cat']);
38 $mf = intval($instance['mf']);
39 $choose = intval($instance['choose']);
40 $colored = intval($instance['colored']);
41 $display_title = intval($instance['display_title']);
42 $thumbnail = sanitize_text_field($instance['thumbnail']);
43 $thumbnail_size = $thumbnail ? sanitize_text_field($instance['thumbnail_size']) : '';
44
45 global $EventPost;
46 $events = $EventPost->get_events(
47 array(
48 'nb'=>-1,
49 'future'=>1,
50 'past'=>1,
51 'geo'=>0,
52 'cat'=>$cat
53 )
54 );
55 if(count($events)==0){
56 return;
57 }
58 echo $args['before_widget'];
59 if(!empty($instance['title'])){
60 echo $args['before_title'];
61 echo $instance['title'];
62 echo $args['after_title'];
63 }
64 echo '<div class="eventpost_calendar" data-cat="'.$cat.'" data-date="'.$date.'" data-mf="'.$mf.'" data-dp="'.$choose.'" data-color="'.$colored.'" data-title="'.$display_title.'" data-thumbnail="'.($thumbnail?$thumbnail_size:'').'"></div>';
65 echo $args['after_widget'];
66 }
67
68 function update($new_instance, $old_instance) {
69 return $new_instance;
70 }
71
72 function form($local_instance) {
73 global $EventPost;
74 $instance = wp_parse_args( (array) $local_instance, $this->defaults );
75
76 $cats = get_categories();
77 $thumbnail_sizes = $EventPost->get_thumbnail_sizes();
78 ?>
79 <input type="hidden" id="<?php echo $this->get_field_id('title'); ?>-title" value="<?php echo $instance['title']; ?>">
80 <p>
81 <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title','event-post'); ?>
82 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" />
83 </label>
84 </p>
85
86 <p>
87 <label for="<?php echo $this->get_field_id('cat'); ?>"><?php _e('Only in:','event-post'); ?>
88 <select id="<?php echo $this->get_field_id('cat'); ?>" name="<?php echo $this->get_field_name('cat'); ?>">
89 <option value=''><?php _e('All','event-post') ?></option>
90 <?php foreach($cats as $cat){ ?>
91 <option value="<?php echo $cat->slug; ?>" <?php selected($cat->slug, $instance['cat'], true); ?>><?php echo $cat->cat_name; ?></option>
92 <?php } ?>
93 </select>
94 </label>
95 </p>
96
97 <p>
98 <label for="<?php echo $this->get_field_id('date'); ?>"><?php _e('Date','event-post'); ?>
99 <select id="<?php echo $this->get_field_id('date'); ?>" name="<?php echo $this->get_field_name('date'); ?>">
100 <option value='' <?php selected($instance['date'], '', true); ?>><?php _e('Current','event-post'); ?></option>
101 <option value='-1 Month' <?php selected($instance['date'], '-1 Month', true); ?>><?php _e('-1 Month','event-post'); ?></option>
102 <option value='-2 Months' <?php selected($instance['date'], '-2 Months', true); ?>><?php _e('-2 Months','event-post'); ?></option>
103 <option value='+1 Month' <?php selected($instance['date'],'+1 Month', true); ?>><?php _e('+1 Month','event-post'); ?></option>
104 <option value='+2 Months' <?php selected($instance['date'], '+2 Months', true); ?>><?php _e('+2 Months','event-post'); ?></option>
105 </select>
106 </label>
107 </p>
108
109 <p>
110 <label for="<?php echo $this->get_field_id('mf'); ?>"><?php _e('Weeks start on','event-post'); ?>
111 <select id="<?php echo $this->get_field_id('mf'); ?>" name="<?php echo $this->get_field_name('mf'); ?>">
112 <option value="0" <?php selected($instance['mf'], 0, true); ?>><?php _e('Sunday','event-post'); ?></option>
113 <option value="1" <?php selected($instance['mf'], 1, true); ?>><?php _e('Monday','event-post'); ?></option>
114 </select>
115 </label>
116 </p>
117
118 <p>
119 <label for="<?php echo $this->get_field_id('choose'); ?>"><?php _e('Date picker','event-post'); ?>
120 <select id="<?php echo $this->get_field_id('choose'); ?>" name="<?php echo $this->get_field_name('choose'); ?>">
121 <option value="0" <?php selected($instance['choose'], 0, true); ?>><?php _e('No','event-post'); ?></option>
122 <option value="1" <?php selected($instance['choose'], 1, true); ?>><?php _e('Yes','event-post'); ?></option>
123 </select>
124 </label>
125 </p>
126
127 <p>
128 <label for="<?php echo $this->get_field_id('colored'); ?>"><?php _e('Colored days','event-post'); ?>
129 <select id="<?php echo $this->get_field_id('colored'); ?>" name="<?php echo $this->get_field_name('colored'); ?>">
130 <option value="0" <?php selected($instance['colored'], 0, true); ?>><?php _e('No','event-post'); ?></option>
131 <option value="1" <?php selected($instance['colored'], 1, true); ?>><?php _e('Yes','event-post'); ?></option>
132 </select>
133 </label>
134 </p>
135
136 <p style="margin-top:10px;">
137 <label for="<?php echo $this->get_field_id('display_title'); ?>">
138 <input id="<?php echo $this->get_field_id('display_title'); ?>" name="<?php echo $this->get_field_name('display_title'); ?>" type="checkbox" value="1" <?php checked($instance['display_title'], true , true); ?>/>
139 <?php _e('Display title','event-post'); ?>
140 </label>
141 </p>
142
143 <p style="margin-top:10px;">
144 <label for="<?php echo $this->get_field_id('thumbnail'); ?>">
145 <input id="<?php echo $this->get_field_id('thumbnail'); ?>" name="<?php echo $this->get_field_name('thumbnail'); ?>" type="checkbox" value="1" <?php checked($instance['thumbnail'], true , true); ?>/>
146 <?php _e('Show thumbnails','event-post'); ?>
147 </label>
148 </p>
149 <p>
150 <label for="<?php echo $this->get_field_id('thumbnail_size'); ?>">
151 <?php _e('Thumbnail size:','event-post'); ?>
152 <select class="widefat" id="<?php echo $this->get_field_id('thumbnail_size'); ?>" name="<?php echo $this->get_field_name('thumbnail_size'); ?>">
153 <option value=''></option>
154 <?php foreach($thumbnail_sizes as $size){?>
155 <option value="<?php echo $size; ?>" <?php selected($size, $instance['thumbnail_size'], true); ?>><?php echo $size; ?></option>
156 <?php } ?>
157 </select>
158 </label>
159 </p>
160 <?php
161 }
162
163 }
164