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