PluginProbe
Event Post / 4.3
Event Post v4.3
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.php

widget.php in Event Post 4.3, at inc/widget.php

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