PluginProbe
Event Post / trunk
Event Post vtrunk
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 / widget.map.php

widget.map.php in Event Post trunk, at inc/widget.map.php

240 lines 10.3 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 *
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 global $EventPost;
38 extract( $args );
39 $instance = wp_parse_args((array) $local_instance, $this->defaults);
40
41 global $EventPost;
42 $events = $EventPost->get_events(
43 array(
44 'nb' => $instance['numberposts'],
45 'future' => $instance['future'],
46 'past' => $instance['past'],
47 'geo' => 1,
48 'cat' => $instance['cat'],
49 'tag' => $instance['tag']
50 )
51 );
52 if (sizeof($events) > 0) {
53 echo $args['before_widget'];
54 if (!empty($instance['widgettitle'])) {
55 echo $args['before_title'];
56 echo $instance['widgettitle'];
57 echo $args['after_title'];
58 }
59 $atts = array(
60 'events' => $events,
61 'width' => $instance['width'],
62 'height' => $instance['height'],
63 'zoom' => $instance['zoom'],
64 'geo' => 1,
65 'class' => 'eventpost_widget',
66 'thumbnail' => $instance['thumbnail'],
67 'thumbnail_size' => $instance['thumbnail_size'],
68 'excerpt' => $instance['excerpt'],
69 'tile' => $instance['tile']
70 );
71 foreach($EventPost->map_interactions as $int_key=>$int_name){
72 $atts[$int_key]=$instance[$int_key];
73 }
74 echo $EventPost->list_events($atts, 'event_geolist', 'widget');
75 echo $args['after_widget'];
76 }
77 }
78 /**
79 *
80 * @global object $EventPost
81 * @param array $new_instance
82 * @param array $old_instance
83 * @return array
84 */
85 function update($new_instance, $old_instance) {
86 global $EventPost;
87 foreach($EventPost->map_interactions as $int_key=>$int_name){
88 if(!isset($new_instance[$int_key])){
89 $new_instance[$int_key]=false;
90 }
91 }
92 return $new_instance;
93 }
94 /**
95 *
96 * @global object $EventPost
97 * @param array $instance
98 */
99 function form($local_instance) {
100 global $EventPost;
101 $instance = wp_parse_args( (array) $local_instance, $this->defaults );
102
103 $cats = get_categories();
104 $tags = get_tags();
105 $thumbnail_sizes = $EventPost->get_thumbnail_sizes();
106 ?>
107 <input type="hidden" id="<?php echo $this->get_field_id('widgettitle'); ?>-title" value="<?php echo $instance['widgettitle']; ?>">
108 <p>
109 <label for="<?php echo $this->get_field_id('widgettitle'); ?>"><?php _e('Title','event-post'); ?>
110 <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']; ?>" />
111 </label>
112 </p>
113
114 <p style="margin-top:10px;">
115 <label for="<?php echo $this->get_field_id('numberposts'); ?>"><?php _e('Number of posts','event-post'); ?>
116 <input id="<?php echo $this->get_field_id('numberposts'); ?>" name="<?php echo $this->get_field_name('numberposts'); ?>" type="number" value="<?php echo $instance['numberposts']; ?>" />
117 </label> <?php _e('(-1 is no limit)','event-post'); ?>
118 </p>
119
120
121 <p style="margin-top:10px;">
122 <label for="<?php echo $this->get_field_id('future'); ?>">
123 <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); ?> />
124 <?php _e('Display future events','event-post'); ?>
125 </label>
126 </p>
127 <p style="margin-top:10px;">
128 <label for="<?php echo $this->get_field_id('past'); ?>">
129 <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); ?> />
130 <?php _e('Display past events','event-post'); ?>
131 </label>
132 </p>
133
134 <p>
135 <label for="<?php echo $this->get_field_id('cat'); ?>">
136 <span class="dashicons dashicons-category"></span>
137 <?php _e('Only in:','event-post'); ?>
138 <select class="widefat" id="<?php echo $this->get_field_id('cat'); ?>" name="<?php echo $this->get_field_name('cat'); ?>">
139 <option value=''><?php _e('All categories','event-post') ?></option>
140 <?php
141 $cats = get_categories();
142 foreach($cats as $_cat){ ?>
143 <option value="<?=$_cat->slug?>" <?php selected($instance['cat'], $_cat->slug , true); ?>><?=$_cat->cat_name?></option>
144 <?php } ?>
145 </select>
146 </label>
147 </p>
148
149 <p>
150 <label for="<?php echo $this->get_field_id('tag'); ?>">
151 <span class="dashicons dashicons-tag"></span>
152 <?php _e('Only in:','event-post'); ?>
153 <select class="widefat" id="<?php echo $this->get_field_id('tag'); ?>" name="<?php echo $this->get_field_name('tag'); ?>">
154 <option value=''><?php _e('All tags','event-post') ?></option>
155 <?php
156 $tags = get_tags();
157 foreach($tags as $_tag){?>
158 <option value="<?=$_tag->slug?>" <?php selected($instance['tag'], $_tag->slug , true); ?>><?=$_tag->name?></option>
159 <?php } ?>
160 </select>
161 </label>
162 </p>
163
164 <hr>
165 <p style="margin-top:10px;">
166 <label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Width','event-post'); ?>
167 <input id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" value="<?php echo $instance['width']; ?>" />
168 </label> (px, %)
169 </p>
170 <p style="margin-top:10px;">
171 <label for="<?php echo $this->get_field_id('height'); ?>"><?php _e('Height','event-post'); ?>
172 <input id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" value="<?php echo $instance['height']; ?>" />
173 </label> (px, %)
174 </p>
175 <p style="margin-top:10px;">
176 <label for="<?php echo $this->get_field_id('zoom'); ?>"><?php _e('Force zoom','event-post'); ?>
177 <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"/>
178 </label>
179 </p>
180
181 <p style="margin-top:10px;">
182 <label for="<?php echo $this->get_field_id('thumbnail'); ?>">
183 <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); ?>/>
184 <?php _e('Show thumbnails','event-post'); ?>
185 </label>
186 </p>
187 <p>
188 <label for="<?php echo $this->get_field_id('thumbnail_size'); ?>">
189 <?php _e('Thumbnail size:','event-post'); ?>
190 <select class="widefat" id="<?php echo $this->get_field_id('thumbnail_size'); ?>" name="<?php echo $this->get_field_name('thumbnail_size'); ?>">
191 <option value=''></option>
192 <?php foreach($thumbnail_sizes as $size){?>
193 <option value="<?php echo $size; ?>" <?php selected($size, $instance['thumbnail_size'], true); ?>><?php echo $size; ?></option>
194 <?php } ?>
195 </select>
196 </label>
197 </p>
198 <p style="margin-top:10px;">
199 <label for="<?php echo $this->get_field_id('excerpt'); ?>">
200 <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); ?> />
201 <?php _e('Show excerpt','event-post'); ?>
202 </label>
203 </p>
204
205 <p style="margin-top:10px;">
206 <label for="<?php echo $this->get_field_id('tile'); ?>">
207 <?php _e('Map background', 'event-post'); ?>
208 <select id="<?php echo $this->get_field_id('tile'); ?>" name="<?php echo $this->get_field_name('tile'); ?>">
209 <?php
210 foreach ($EventPost->maps as $id => $map):
211 ?>
212 <option value="<?php
213 if ($EventPost->settings['tile'] != $map['id']) {
214 echo $map['id'];
215 }
216 ?>" <?php selected($instance['tile'], $id, true);?>>
217 <?php echo $map['name']; ?><?php
218 if ($EventPost->settings['tile'] == $map['id']) {
219 echo' (default)';
220 }
221 ?>
222 </option>
223 <?php endforeach; ?>
224 </select>
225 </label>
226 </p>
227 <hr>
228 <?php foreach($EventPost->map_interactions as $int_key=>$int_name): ?>
229 <p>
230 <label for="<?php echo $this->get_field_id($int_key); ?>">
231 <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); ?>/>
232 <?php printf(__('Activate %s interaction','event-post'), $int_name); ?>
233 </label>
234 </p>
235 <?php endforeach; ?>
236 <?php
237 }
238
239 }
240