PluginProbe
Event Post / 3.9
Event Post v3.9
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 3.9, at widget.map.php

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