PluginProbe
Event Post / 5.10.1
Event Post v5.10.1
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 5.6.1 All 46 releases
event-post / inc / deprecated / widget.map.php

widget.map.php in Event Post 5.10.1, at inc/deprecated/widget.map.php

248 lines 10.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The Map widget
4 * Displays a map of geolocalized posts
5 * @deprecated
6 * @package event-post
7 */
8 class EventPost_Map extends WP_Widget {
9 var $defaults;
10 function __construct() {
11 global $EventPost;
12 parent::__construct(false, __( 'Events Map', 'event-post' ),array('description'=>__( 'Map of events posts', 'event-post' )));
13 $this->defaults = array(
14 'numberposts' => '',
15 'widgettitle' => '',
16 'cat' => '',
17 'tag' => '',
18 'height' => '',
19 'width' => '',
20 'future' => 0,
21 'past' => 0,
22 'thumbnail' => 0,
23 'thumbnail_size' => '',
24 'excerpt' => 0,
25 'tile' => $EventPost->settings['tile'],
26 'zoom' => '',
27 );
28 // UI options
29 foreach($EventPost->map_interactions as $int_key=>$int_name){
30 $this->defaults[$int_key]=true;
31 }
32 }
33 public function EventPost_Map(){
34 $this->__construct();
35 }
36 function widget($args, $local_instance) {
37 if(!defined('ALLOW_DEPRECATED') || !ALLOW_DEPRECATED) {
38 _deprecated_function(__FUNCTION__, '5.9.0', __('Legacy widgets have been deprecated. Consider using blocks instead.', 'event-post'));
39 }
40 global $EventPost;
41 extract( $args );
42 $instance = wp_parse_args((array) $local_instance, $this->defaults);
43
44 $numberposts = intval($instance['numberposts']);
45 $future = intval($instance['future']);
46 $past = intval($instance['past']);
47 $cat = sanitize_text_field($instance['cat']);
48 $tag = sanitize_text_field($instance['tag']);
49
50 $events = $EventPost->get_events(
51 array(
52 'nb' => $numberposts,
53 'future' => $future,
54 'past' => $past,
55 'geo' => 1,
56 'cat' => $cat,
57 'tag' => $tag
58 )
59 );
60 if (sizeof($events) > 0) {
61 echo $args['before_widget'];
62 if (!empty($instance['widgettitle'])) {
63 echo $args['before_title'];
64 echo $instance['widgettitle'];
65 echo $args['after_title'];
66 }
67 $atts = array(
68 'events' => $events,
69 'width' => esc_attr($instance['width']),
70 'height' => esc_attr($instance['height']),
71 'zoom' => esc_attr($instance['zoom']),
72 'geo' => 1,
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 'tile' => esc_attr($instance['tile'])
78 );
79 foreach($EventPost->map_interactions as $int_key=>$int_name){
80 $atts[$int_key] = isset($instance[$int_key]) ? esc_attr($instance[$int_key]) : '';
81 }
82 echo $EventPost->list_events($atts, 'event_geolist', 'widget');
83 echo $args['after_widget'];
84 }
85 }
86 /**
87 *
88 * @global object $EventPost
89 * @param array $new_instance
90 * @param array $old_instance
91 * @return array
92 */
93 function update($new_instance, $old_instance) {
94 global $EventPost;
95 foreach($EventPost->map_interactions as $int_key=>$int_name){
96 if(!isset($new_instance[$int_key])){
97 $new_instance[$int_key]=false;
98 }
99 }
100 return $new_instance;
101 }
102 /**
103 *
104 * @global object $EventPost
105 * @param array $instance
106 */
107 function form($local_instance) {
108 global $EventPost;
109 $instance = wp_parse_args( (array) $local_instance, $this->defaults );
110
111 $cats = get_categories();
112 $tags = get_tags();
113 $thumbnail_sizes = $EventPost->get_thumbnail_sizes();
114 ?>
115 <input type="hidden" id="<?php echo $this->get_field_id('widgettitle'); ?>-title" value="<?php echo $instance['widgettitle']; ?>">
116 <p>
117 <label for="<?php echo $this->get_field_id('widgettitle'); ?>"><?php _e('Title','event-post'); ?>
118 <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']; ?>" />
119 </label>
120 </p>
121
122 <p style="margin-top:10px;">
123 <label for="<?php echo $this->get_field_id('numberposts'); ?>"><?php _e('Number of posts','event-post'); ?>
124 <input id="<?php echo $this->get_field_id('numberposts'); ?>" name="<?php echo $this->get_field_name('numberposts'); ?>" type="number" value="<?php echo $instance['numberposts']; ?>" />
125 </label> <?php _e('(-1 is no limit)','event-post'); ?>
126 </p>
127
128
129 <p style="margin-top:10px;">
130 <label for="<?php echo $this->get_field_id('future'); ?>">
131 <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); ?> />
132 <?php _e('Display future events','event-post'); ?>
133 </label>
134 </p>
135 <p style="margin-top:10px;">
136 <label for="<?php echo $this->get_field_id('past'); ?>">
137 <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); ?> />
138 <?php _e('Display past events','event-post'); ?>
139 </label>
140 </p>
141
142 <p>
143 <label for="<?php echo $this->get_field_id('cat'); ?>">
144 <span class="dashicons dashicons-category"></span>
145 <?php _e('Only in:','event-post'); ?>
146 <select class="widefat" id="<?php echo $this->get_field_id('cat'); ?>" name="<?php echo $this->get_field_name('cat'); ?>">
147 <option value=''><?php _e('All categories','event-post') ?></option>
148 <?php
149 $cats = get_categories();
150 foreach($cats as $_cat){ ?>
151 <option value="<?=$_cat->slug?>" <?php selected($instance['cat'], $_cat->slug , true); ?>><?=$_cat->cat_name?></option>
152 <?php } ?>
153 </select>
154 </label>
155 </p>
156
157 <p>
158 <label for="<?php echo $this->get_field_id('tag'); ?>">
159 <span class="dashicons dashicons-tag"></span>
160 <?php _e('Only in:','event-post'); ?>
161 <select class="widefat" id="<?php echo $this->get_field_id('tag'); ?>" name="<?php echo $this->get_field_name('tag'); ?>">
162 <option value=''><?php _e('All tags','event-post') ?></option>
163 <?php
164 $tags = get_tags();
165 foreach($tags as $_tag){?>
166 <option value="<?=$_tag->slug?>" <?php selected($instance['tag'], $_tag->slug , true); ?>><?=$_tag->name?></option>
167 <?php } ?>
168 </select>
169 </label>
170 </p>
171
172 <hr>
173 <p style="margin-top:10px;">
174 <label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Width','event-post'); ?>
175 <input id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" value="<?php echo $instance['width']; ?>" />
176 </label> (px, %)
177 </p>
178 <p style="margin-top:10px;">
179 <label for="<?php echo $this->get_field_id('height'); ?>"><?php _e('Height','event-post'); ?>
180 <input id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" value="<?php echo $instance['height']; ?>" />
181 </label> (px, %)
182 </p>
183 <p style="margin-top:10px;">
184 <label for="<?php echo $this->get_field_id('zoom'); ?>"><?php _e('Force zoom','event-post'); ?>
185 <input id="<?php echo $this->get_field_id('zoom'); ?>" name="<?php echo $this->get_field_name('zoom'); ?>" value="<?php echo $instance['zoom']; ?>" type="number" min="3" max="20" size="2"/>
186 </label>
187 </p>
188
189 <p style="margin-top:10px;">
190 <label for="<?php echo $this->get_field_id('thumbnail'); ?>">
191 <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); ?>/>
192 <?php _e('Show thumbnails','event-post'); ?>
193 </label>
194 </p>
195 <p>
196 <label for="<?php echo $this->get_field_id('thumbnail_size'); ?>">
197 <?php _e('Thumbnail size:','event-post'); ?>
198 <select class="widefat" id="<?php echo $this->get_field_id('thumbnail_size'); ?>" name="<?php echo $this->get_field_name('thumbnail_size'); ?>">
199 <option value=''></option>
200 <?php foreach($thumbnail_sizes as $size){?>
201 <option value="<?php echo $size; ?>" <?php selected($size, $instance['thumbnail_size'], true); ?>><?php echo $size; ?></option>
202 <?php } ?>
203 </select>
204 </label>
205 </p>
206 <p style="margin-top:10px;">
207 <label for="<?php echo $this->get_field_id('excerpt'); ?>">
208 <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); ?> />
209 <?php _e('Show excerpt','event-post'); ?>
210 </label>
211 </p>
212
213 <p style="margin-top:10px;">
214 <label for="<?php echo $this->get_field_id('tile'); ?>">
215 <?php _e('Map background', 'event-post'); ?>
216 <select id="<?php echo $this->get_field_id('tile'); ?>" name="<?php echo $this->get_field_name('tile'); ?>">
217 <?php
218 foreach ($EventPost->maps as $id => $map):
219 ?>
220 <option value="<?php
221 if ($EventPost->settings['tile'] != $map['id']) {
222 echo $map['id'];
223 }
224 ?>" <?php selected($instance['tile'], $id, true);?>>
225 <?php echo $map['name']; ?><?php
226 if ($EventPost->settings['tile'] == $map['id']) {
227 echo' (default)';
228 }
229 ?>
230 </option>
231 <?php endforeach; ?>
232 </select>
233 </label>
234 </p>
235 <hr>
236 <?php foreach($EventPost->map_interactions as $int_key=>$int_name): ?>
237 <p>
238 <label for="<?php echo $this->get_field_id($int_key); ?>">
239 <input id="<?php echo $this->get_field_id($int_key); ?>" name="<?php echo $this->get_field_name($int_key); ?>" type="checkbox" value="1" <?php checked($instance[$int_key], true , true); ?>/>
240 <?php printf(__('Activate %s interaction','event-post'), $int_name); ?>
241 </label>
242 </p>
243 <?php endforeach; ?>
244 <?php
245 }
246
247 }
248