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

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

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