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.php

widget.php in Event Post 3.9, at widget.php

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