1: <?php
2: /**
3: * @deprecated
4: * @package event-post
5: */
6: class EventPost_Search extends WP_Widget {
7: var $defaults;
8: function __construct() {
9: parent::__construct(false, __( 'Events Search Form', 'event-post' ),array('description'=>__( 'List of future events posts', 'event-post' )));
10: $this->defaults = array(
11: 'numberposts' => '',
12: 'widgettitle' => '',
13: 'cat' => '',
14: 'tag' => '',
15: 'future' => 0,
16: 'past' => 0,
17: 'thumbnail' => 0,
18: 'thumbnail_size' => '',
19: 'excerpt' => 0,
20: 'feed' => 0,
21: 'order' => 'ASC',
22: 'excerpt' => '',
23: 'excerpt' => '',
24: 'excerpt' => '',
25: );
26:
27: }
28: function EventPost_Search(){
29: $this->__construct();
30: }
31: function widget($args, $local_instance) {
32: if(!defined('ALLOW_DEPRECATED') || !ALLOW_DEPRECATED) {
33: _deprecated_function(__FUNCTION__, '5.9.0', __('Legacy widgets have been deprecated. Consider using blocks instead.', 'event-post'));
34: }
35: extract( $args );
36: $instance = wp_parse_args( (array) $local_instance, $this->defaults );
37:
38: global $EventPost;
39: $numberposts = intval($instance['numberposts']);
40: $future = intval($instance['future']);
41: $past = intval($instance['past']);
42: $cat = sanitize_text_field($instance['cat']);
43: $tag = sanitize_text_field($instance['tag']);
44: $order = sanitize_text_field($instance['order']);
45:
46: $events = $EventPost->get_events(
47: array(
48: 'nb'=>$numberposts,
49: 'future'=>$future,
50: 'past'=>$past,
51: 'geo'=>0,
52: 'cat'=>$cat,
53: 'tag'=>$tag,
54: 'order'=>$order
55: )
56: );
57: if(count($events)==0){
58: return;
59: }
60:
61: echo $args['before_widget'];
62: if(!empty($instance['widgettitle'])){
63: echo $args['before_title'];
64: echo esc_html($instance['widgettitle']);
65: if(!empty($instance['cat']) && $instance['feed']){
66: $rss_link = admin_url('admin-ajax.php') . '?action=EventPostFeed&cat=' . $instance['cat'];
67: echo' <a href="' . esc_url($rss_link) . '" title="'.sprintf(__('feed of %s', 'event-post'), esc_attr($instance['cat'])).'"><span class="dashicons dashicons-rss"></span></a>';
68: }
69: echo $args['after_title'];
70: }
71: $atts=array(
72: 'events' => $events,
73: 'class' => 'eventpost_widget',
74: 'thumbnail' => esc_attr($instance['thumbnail']),
75: 'thumbnail_size' => esc_attr($instance['thumbnail_size']),
76: 'excerpt' => esc_attr($instance['excerpt']),
77: 'order' => $order
78: );
79: echo $EventPost->list_events($atts, 'event_list', 'widget');
80: echo $args['after_widget'];
81: }
82:
83: function update($new_instance, $old_instance) {
84: return $new_instance;
85: }
86:
87: function form($local_instance) {
88: global $EventPost;
89: $instance = wp_parse_args( (array) $local_instance, $this->defaults );
90:
91: $cats = get_categories();
92: $tags = get_tags();
93: $thumbnail_sizes = $EventPost->get_thumbnail_sizes();
94: ?>
95: <input type="hidden" id="<?php echo $this->get_field_id('widgettitle'); ?>-title" value="<?php echo $instance['widgettitle']; ?>">
96: <p>
97: <label for="<?php echo $this->get_field_id('widgettitle'); ?>"><?php _e('Title','event-post'); ?>
98: <input class="widefat" id="<?php echo $this->get_field_id('widgettitle'); ?>" name="<?php echo $this->get_field_name('widgettitle'); ?>" type="text" value="<?php echo $instance['widgettitle']; ?>" />
99: </label>
100: </p>
101:
102: <p style="margin-top:10px;">
103: <label for="<?php echo $this->get_field_id('numberposts'); ?>"><?php _e('Number of posts','event-post'); ?>
104: <input id="<?php echo $this->get_field_id('numberposts'); ?>" name="<?php echo $this->get_field_name('numberposts'); ?>" type="number" value="<?php echo $instance['numberposts']; ?>" />
105: </label> <?php _e('(-1 is no limit)','event-post'); ?>
106: </p>
107:
108:
109: <p style="margin-top:10px;">
110: <label for="<?php echo $this->get_field_id('future'); ?>">
111: <input id="<?php echo $this->get_field_id('future'); ?>" name="<?php echo $this->get_field_name('future'); ?>" type="checkbox" value="1" <?php checked($instance['future'], true, true); ?> />
112: <?php _e('Display future events','event-post'); ?>
113: </label>
114: </p>
115: <p style="margin-top:10px;">
116: <label for="<?php echo $this->get_field_id('past'); ?>">
117: <input id="<?php echo $this->get_field_id('past'); ?>" name="<?php echo $this->get_field_name('past'); ?>" type="checkbox" value="1" <?php checked($instance['past'], true, true); ?> />
118: <?php _e('Display past events','event-post'); ?>
119: </label>
120: </p>
121:
122: <p>
123: <label for="<?php echo $this->get_field_id('cat'); ?>">
124: <span class="dashicons dashicons-category"></span>
125: <?php _e('Only in:','event-post'); ?>
126: <select class="widefat" id="<?php echo $this->get_field_id('cat'); ?>" name="<?php echo $this->get_field_name('cat'); ?>">
127: <option value=''><?php _e('All categories','event-post') ?></option>
128: <?php foreach($cats as $_cat){ ?>
129: <option value="<?php echo $_cat->slug; ?>" <?php selected($_cat->slug, $instance['cat'], true); ?>><?php echo $_cat->cat_name; ?></option>
130: <?php } ?>
131: </select>
132: </label>
133: </p>
134:
135: <p style="margin-top:10px;">
136: <label for="<?php echo $this->get_field_id('feed'); ?>">
137: <input id="<?php echo $this->get_field_id('feed'); ?>" name="<?php echo $this->get_field_name('feed'); ?>" type="checkbox" value="1" <?php checked($instance['feed'], true, true); ?> />
138: <?php _e('Show category ICS link','event-post'); ?>
139: </label>
140: </p>
141: <hr>
142:
143: <p>
144: <label for="<?php echo $this->get_field_id('tag'); ?>">
145: <span class="dashicons dashicons-tag"></span>
146: <?php _e('Only in:','event-post'); ?>
147: <select class="widefat" id="<?php echo $this->get_field_id('tag'); ?>" name="<?php echo $this->get_field_name('tag'); ?>">
148: <option value=''><?php _e('All tags','event-post') ?></option>
149: <?php foreach($tags as $_tag){?>
150: <option value="<?php echo $_tag->slug; ?>" <?php selected($_tag->slug, $instance['tag'], true); ?>><?php echo $_tag->name; ?></option>
151: <?php } ?>
152: </select>
153: </label>
154: </p>
155:
156: <hr>
157: <p style="margin-top:10px;">
158: <label for="<?php echo $this->get_field_id('thumbnail'); ?>">
159: <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); ?> />
160: <?php _e('Show thumbnails','event-post'); ?>
161: </label>
162: </p>
163: <p>
164: <label for="<?php echo $this->get_field_id('thumbnail_size'); ?>">
165: <?php _e('Thumbnail size:','event-post'); ?>
166: <select class="widefat" id="<?php echo $this->get_field_id('thumbnail_size'); ?>" name="<?php echo $this->get_field_name('thumbnail_size'); ?>">
167: <option value=''></option>
168: <?php foreach($thumbnail_sizes as $size){?>
169: <option value="<?php echo $size; ?>" <?php selected($size, $instance['thumbnail_size'], true); ?>><?php echo $size; ?></option>
170: <?php } ?>
171: </select>
172: </label>
173: </p>
174:
175:
176: <p style="margin-top:10px;">
177: <label for="<?php echo $this->get_field_id('excerpt'); ?>">
178: <input id="<?php echo $this->get_field_id('excerpt'); ?>" name="<?php echo $this->get_field_name('excerpt'); ?>" type="checkbox" value="1" <?php checked($instance['excerpt'], true, true); ?> />
179: <?php _e('Show excerpt','event-post'); ?>
180: </label>
181: </p>
182:
183: <p>
184: <label for="<?php echo $this->get_field_id('order'); ?>">
185: <?php _e('Order:','event-post'); ?>
186: <select class="widefat" id="<?php echo $this->get_field_id('order'); ?>" name="<?php echo $this->get_field_name('order'); ?>">
187: <option value='DESC' <?php selected('DESC', $instance['order'], true); ?>><?php _e('Reverse chronological','event-post') ?></option>
188: <option value='ASC' <?php selected('ASC', $instance['order'], true); ?>><?php _e('Chronological','event-post') ?></option>
189: </select>
190: </label>
191: </p>
192: <?php
193: }
194:
195: }
196: