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