PluginProbe
Event Post / 6.0.0
Event Post v6.0.0
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 / deprecated / widget.php

widget.php in Event Post 6.0.0, at inc/deprecated/widget.php

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