PluginProbe
Event Post / 4.2
Event Post v4.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 5.6.1 All 46 releases
event-post / widget.map.php

widget.map.php in Event Post 4.2, at widget.map.php

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