1 | Index: src/wp-includes/default-widgets.php |
---|
2 | =================================================================== |
---|
3 | --- src/wp-includes/default-widgets.php (revision 28398) |
---|
4 | +++ src/wp-includes/default-widgets.php (working copy) |
---|
5 | @@ -19,7 +19,6 @@ |
---|
6 | } |
---|
7 | |
---|
8 | function widget( $args, $instance ) { |
---|
9 | - extract( $args ); |
---|
10 | |
---|
11 | /** |
---|
12 | * Filter the widget title. |
---|
13 | @@ -50,20 +50,21 @@ |
---|
14 | 'exclude' => $exclude |
---|
15 | ) ) ); |
---|
16 | |
---|
17 | - if ( !empty( $out ) ) { |
---|
18 | - echo $before_widget; |
---|
19 | - if ( $title) |
---|
20 | - echo $before_title . $title . $after_title; |
---|
21 | + if ( ! empty( $out ) ) { |
---|
22 | + echo $args['before_widget']; |
---|
23 | + if ( $title ) { |
---|
24 | + echo $args['before_title'] . $title . $args['after_title']; |
---|
25 | + } |
---|
26 | ?> |
---|
27 | <ul> |
---|
28 | <?php echo $out; ?> |
---|
29 | </ul> |
---|
30 | <?php |
---|
31 | - echo $after_widget; |
---|
32 | + echo $args['after_widget']; |
---|
33 | } |
---|
34 | } |
---|
35 | |
---|
36 | @@ -119,7 +120,6 @@ |
---|
37 | } |
---|
38 | |
---|
39 | function widget( $args, $instance ) { |
---|
40 | - extract($args, EXTR_SKIP); |
---|
41 | |
---|
42 | $show_description = isset($instance['description']) ? $instance['description'] : false; |
---|
43 | $show_name = isset($instance['name']) ? $instance['name'] : false; |
---|
44 | @@ -127,10 +127,10 @@ |
---|
45 | $order = $orderby == 'rating' ? 'DESC' : 'ASC'; |
---|
46 | $limit = isset( $instance['limit'] ) ? $instance['limit'] : -1; |
---|
47 | |
---|
48 | - $before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget); |
---|
49 | + $before_widget = preg_replace( '/id="[^"]*"/', 'id="%id"', $args['before_widget'] ); |
---|
50 | |
---|
51 | /** |
---|
52 | * Filter the arguments for the Links widget. |
---|
53 | @@ -142,8 +142,8 @@ |
---|
54 | * @param array $args An array of arguments to retrieve the links list. |
---|
55 | */ |
---|
56 | wp_list_bookmarks( apply_filters( 'widget_links_args', array( |
---|
57 | - 'title_before' => $before_title, 'title_after' => $after_title, |
---|
58 | - 'category_before' => $before_widget, 'category_after' => $after_widget, |
---|
59 | + 'title_before' => $args['before_title'], 'title_after' => $args['after_title'], |
---|
60 | + 'category_before' => $before_widget, 'category_after' => $args['after_widget'], |
---|
61 | 'show_images' => $show_images, 'show_description' => $show_description, |
---|
62 | 'show_name' => $show_name, 'show_rating' => $show_rating, |
---|
63 | 'category' => $category, 'class' => 'linkcat widget', |
---|
64 | @@ -156,13 +156,15 @@ |
---|
65 | $new_instance = (array) $new_instance; |
---|
66 | $instance = array( 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0 ); |
---|
67 | foreach ( $instance as $field => $val ) { |
---|
68 | - if ( isset($new_instance[$field]) ) |
---|
69 | + if ( isset($new_instance[$field]) ) { |
---|
70 | $instance[$field] = 1; |
---|
71 | + } |
---|
72 | } |
---|
73 | |
---|
74 | $instance['orderby'] = 'name'; |
---|
75 | - if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) ) |
---|
76 | + if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) ) { |
---|
77 | $instance['orderby'] = $new_instance['orderby']; |
---|
78 | + } |
---|
79 | |
---|
80 | $instance['category'] = intval( $new_instance['category'] ); |
---|
81 | $instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1; |
---|
82 | @@ -229,19 +231,19 @@ |
---|
83 | } |
---|
84 | |
---|
85 | function widget( $args, $instance ) { |
---|
86 | - extract($args); |
---|
87 | |
---|
88 | /** This filter is documented in wp-includes/default-widgets.php */ |
---|
89 | $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); |
---|
90 | |
---|
91 | - echo $before_widget; |
---|
92 | - if ( $title ) |
---|
93 | - echo $before_title . $title . $after_title; |
---|
94 | + echo $args['before_widget']; |
---|
95 | + if ( $title ) { |
---|
96 | + echo $args['before_title'] . $title . $args['after_title']; |
---|
97 | + } |
---|
98 | |
---|
99 | // Use current theme search form if it exists |
---|
100 | get_search_form(); |
---|
101 | |
---|
102 | - echo $after_widget; |
---|
103 | + echo $args['after_widget']; |
---|
104 | } |
---|
105 | |
---|
106 | function form( $instance ) { |
---|
107 | @@ -274,16 +276,16 @@ |
---|
108 | } |
---|
109 | |
---|
110 | function widget( $args, $instance ) { |
---|
111 | - extract($args); |
---|
112 | $c = ! empty( $instance['count'] ) ? '1' : '0'; |
---|
113 | $d = ! empty( $instance['dropdown'] ) ? '1' : '0'; |
---|
114 | |
---|
115 | /** This filter is documented in wp-includes/default-widgets.php */ |
---|
116 | - $title = apply_filters( 'widget_title', empty($instance['title'] ) ? __( 'Archives' ) : $instance['title'], $instance, $this->id_base ); |
---|
117 | + $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Archives' ) : $instance['title'], $instance, $this->id_base ); |
---|
118 | |
---|
119 | - echo $before_widget; |
---|
120 | - if ( $title ) |
---|
121 | - echo $before_title . $title . $after_title; |
---|
122 | + echo $args['before_widget']; |
---|
123 | + if ( $title ) { |
---|
124 | + echo $args['before_title'] . $title . $args['after_title']; |
---|
125 | + } |
---|
126 | |
---|
127 | if ( $d ) { |
---|
128 | ?> |
---|
129 | @@ -330,7 +332,7 @@ |
---|
130 | <?php |
---|
131 | } |
---|
132 | |
---|
133 | - echo $after_widget; |
---|
134 | + echo $args['after_widget']; |
---|
135 | } |
---|
136 | |
---|
137 | function update( $new_instance, $old_instance ) { |
---|
138 | @@ -374,14 +376,14 @@ |
---|
139 | } |
---|
140 | |
---|
141 | function widget( $args, $instance ) { |
---|
142 | - extract($args); |
---|
143 | |
---|
144 | /** This filter is documented in wp-includes/default-widgets.php */ |
---|
145 | $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Meta' ) : $instance['title'], $instance, $this->id_base ); |
---|
146 | |
---|
147 | - echo $before_widget; |
---|
148 | - if ( $title ) |
---|
149 | - echo $before_title . $title . $after_title; |
---|
150 | + echo $args['before_widget']; |
---|
151 | + if ( $title ) { |
---|
152 | + echo $args['before_title'] . $title . $args['after_title']; |
---|
153 | + } |
---|
154 | ?> |
---|
155 | <ul> |
---|
156 | <?php wp_register(); ?> |
---|
157 | @@ -406,7 +408,7 @@ |
---|
158 | ?> |
---|
159 | </ul> |
---|
160 | <?php |
---|
161 | - echo $after_widget; |
---|
162 | + echo $args['after_widget']; |
---|
163 | } |
---|
164 | |
---|
165 | function update( $new_instance, $old_instance ) { |
---|
166 | @@ -438,18 +440,18 @@ |
---|
167 | } |
---|
168 | |
---|
169 | function widget( $args, $instance ) { |
---|
170 | - extract($args); |
---|
171 | |
---|
172 | /** This filter is documented in wp-includes/default-widgets.php */ |
---|
173 | $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); |
---|
174 | |
---|
175 | - echo $before_widget; |
---|
176 | - if ( $title ) |
---|
177 | - echo $before_title . $title . $after_title; |
---|
178 | + echo $args['before_widget']; |
---|
179 | + if ( $title ) { |
---|
180 | + echo $args['before_title'] . $title . $args['after_title']; |
---|
181 | + } |
---|
182 | echo '<div id="calendar_wrap">'; |
---|
183 | get_calendar(); |
---|
184 | echo '</div>'; |
---|
185 | - echo $after_widget; |
---|
186 | + echo $args['after_widget']; |
---|
187 | } |
---|
188 | |
---|
189 | function update( $new_instance, $old_instance ) { |
---|
190 | @@ -483,7 +485,6 @@ |
---|
191 | } |
---|
192 | |
---|
193 | function widget( $args, $instance ) { |
---|
194 | - extract($args); |
---|
195 | |
---|
196 | /** This filter is documented in wp-includes/default-widgets.php */ |
---|
197 | $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); |
---|
198 | @@ -497,20 +498,21 @@ |
---|
199 | * @param WP_Widget $instance WP_Widget instance. |
---|
200 | */ |
---|
201 | $text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance ); |
---|
202 | - echo $before_widget; |
---|
203 | - if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?> |
---|
204 | + echo $args['before_widget']; |
---|
205 | + if ( ! empty( $title ) ) { echo $args['before_title'] . $title . $args['after_title']; } ?> |
---|
206 | <div class="textwidget"><?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div> |
---|
207 | <?php |
---|
208 | - echo $after_widget; |
---|
209 | + echo $args['after_widget']; |
---|
210 | } |
---|
211 | |
---|
212 | function update( $new_instance, $old_instance ) { |
---|
213 | $instance = $old_instance; |
---|
214 | $instance['title'] = strip_tags($new_instance['title']); |
---|
215 | - if ( current_user_can('unfiltered_html') ) |
---|
216 | + if ( current_user_can( 'unfiltered_html' ) ) { |
---|
217 | $instance['text'] = $new_instance['text']; |
---|
218 | - else |
---|
219 | + } else { |
---|
220 | $instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) ); // wp_filter_post_kses() expects slashed |
---|
221 | + } |
---|
222 | $instance['filter'] = isset($new_instance['filter']); |
---|
223 | return $instance; |
---|
224 | } |
---|
225 | @@ -543,7 +545,6 @@ |
---|
226 | } |
---|
227 | |
---|
228 | function widget( $args, $instance ) { |
---|
229 | - extract( $args ); |
---|
230 | |
---|
231 | /** This filter is documented in wp-includes/default-widgets.php */ |
---|
232 | $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base ); |
---|
233 | @@ -552,9 +553,10 @@ |
---|
234 | $h = ! empty( $instance['hierarchical'] ) ? '1' : '0'; |
---|
235 | $d = ! empty( $instance['dropdown'] ) ? '1' : '0'; |
---|
236 | |
---|
237 | - echo $before_widget; |
---|
238 | - if ( $title ) |
---|
239 | - echo $before_title . $title . $after_title; |
---|
240 | + echo $args['before_widget']; |
---|
241 | + if ( $title ) { |
---|
242 | + echo $args['before_title'] . $title . $args['after_title']; |
---|
243 | + } |
---|
244 | |
---|
245 | $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h); |
---|
246 | |
---|
247 | @@ -605,7 +607,7 @@ |
---|
248 | <?php |
---|
249 | } |
---|
250 | |
---|
251 | - echo $after_widget; |
---|
252 | + echo $args['after_widget']; |
---|
253 | } |
---|
254 | |
---|
255 | function update( $new_instance, $old_instance ) { |
---|
256 | @@ -679,7 +681,6 @@ |
---|
257 | } |
---|
258 | |
---|
259 | ob_start(); |
---|
260 | - extract($args); |
---|
261 | |
---|
262 | $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' ); |
---|
263 | |
---|
264 | @@ -687,8 +688,9 @@ |
---|
265 | $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
---|
266 | |
---|
267 | $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; |
---|
268 | - if ( ! $number ) |
---|
269 | + if ( ! $number ) { |
---|
270 | $number = 5; |
---|
271 | + } |
---|
272 | $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false; |
---|
273 | |
---|
274 | /** |
---|
275 | @@ -709,8 +711,8 @@ |
---|
276 | |
---|
277 | if ($r->have_posts()) : |
---|
278 | ?> |
---|
279 | - <?php echo $before_widget; ?> |
---|
280 | - <?php if ( $title ) echo $before_title . $title . $after_title; ?> |
---|
281 | + <?php echo $args['before_widget']; ?> |
---|
282 | + <?php if ( $title ) { echo $args['before_title'] . $title . $args['after_title']; } ?> |
---|
283 | <ul> |
---|
284 | <?php while ( $r->have_posts() ) : $r->the_post(); ?> |
---|
285 | <li> |
---|
286 | @@ -721,7 +723,7 @@ |
---|
287 | </li> |
---|
288 | <?php endwhile; ?> |
---|
289 | </ul> |
---|
290 | - <?php echo $after_widget; ?> |
---|
291 | + <?php echo $args['after_widget']; ?> |
---|
292 | <?php |
---|
293 | // Reset the global $the_post as this query will have stomped on it |
---|
294 | wp_reset_postdata(); |
---|
295 | @@ -744,8 +746,9 @@ |
---|
296 | $this->flush_widget_cache(); |
---|
297 | |
---|
298 | $alloptions = wp_cache_get( 'alloptions', 'options' ); |
---|
299 | - if ( isset($alloptions['widget_recent_entries']) ) |
---|
300 | + if ( isset( $alloptions['widget_recent_entries'] ) ) { |
---|
301 | delete_option('widget_recent_entries'); |
---|
302 | + } |
---|
303 | |
---|
304 | return $instance; |
---|
305 | } |
---|
306 | @@ -783,8 +786,9 @@ |
---|
307 | parent::__construct('recent-comments', __('Recent Comments'), $widget_ops); |
---|
308 | $this->alt_option_name = 'widget_recent_comments'; |
---|
309 | |
---|
310 | - if ( is_active_widget(false, false, $this->id_base) ) |
---|
311 | + if ( is_active_widget( false, false, $this->id_base ) ) { |
---|
312 | add_action( 'wp_head', array($this, 'recent_comments_style') ); |
---|
313 | + } |
---|
314 | |
---|
315 | add_action( 'comment_post', array($this, 'flush_widget_cache') ); |
---|
316 | add_action( 'edit_comment', array($this, 'flush_widget_cache') ); |
---|
317 | @@ -802,8 +806,9 @@ |
---|
318 | * @param string $id_base The widget ID. |
---|
319 | */ |
---|
320 | if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876 |
---|
321 | - || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) |
---|
322 | + || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) { |
---|
323 | return; |
---|
324 | + } |
---|
325 | ?> |
---|
326 | <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style> |
---|
327 | <?php |
---|
328 | @@ -832,7 +837,6 @@ |
---|
329 | return; |
---|
330 | } |
---|
331 | |
---|
332 | - extract($args, EXTR_SKIP); |
---|
333 | $output = ''; |
---|
334 | |
---|
335 | $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments' ); |
---|
336 | @@ -841,8 +845,9 @@ |
---|
337 | $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
---|
338 | |
---|
339 | $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; |
---|
340 | - if ( ! $number ) |
---|
341 | + if ( ! $number ) { |
---|
342 | $number = 5; |
---|
343 | + } |
---|
344 | |
---|
345 | /** |
---|
346 | * Filter the arguments for the Recent Comments widget. |
---|
347 | @@ -859,9 +864,10 @@ |
---|
348 | 'post_status' => 'publish' |
---|
349 | ) ) ); |
---|
350 | |
---|
351 | - $output .= $before_widget; |
---|
352 | - if ( $title ) |
---|
353 | - $output .= $before_title . $title . $after_title; |
---|
354 | + $output .= $args['before_widget']; |
---|
355 | + if ( $title ) { |
---|
356 | + $output .= $args['before_title'] . $title . $args['after_title']; |
---|
357 | + } |
---|
358 | |
---|
359 | $output .= '<ul id="recentcomments">'; |
---|
360 | if ( $comments ) { |
---|
361 | @@ -874,7 +880,7 @@ |
---|
362 | } |
---|
363 | } |
---|
364 | $output .= '</ul>'; |
---|
365 | - $output .= $after_widget; |
---|
366 | + $output .= $args['after_widget']; |
---|
367 | |
---|
368 | echo $output; |
---|
369 | |
---|
370 | @@ -891,8 +897,9 @@ |
---|
371 | $this->flush_widget_cache(); |
---|
372 | |
---|
373 | $alloptions = wp_cache_get( 'alloptions', 'options' ); |
---|
374 | - if ( isset($alloptions['widget_recent_comments']) ) |
---|
375 | + if ( isset( $alloptions['widget_recent_comments'] ) ) { |
---|
376 | delete_option('widget_recent_comments'); |
---|
377 | + } |
---|
378 | |
---|
379 | return $instance; |
---|
380 | } |
---|
381 | @@ -928,18 +935,19 @@ |
---|
382 | if ( isset($instance['error']) && $instance['error'] ) |
---|
383 | return; |
---|
384 | |
---|
385 | - extract($args, EXTR_SKIP); |
---|
386 | - |
---|
387 | $url = ! empty( $instance['url'] ) ? $instance['url'] : ''; |
---|
388 | - while ( stristr($url, 'http') != $url ) |
---|
389 | + while ( stristr( $url, 'http' ) != $url ) { |
---|
390 | $url = substr($url, 1); |
---|
391 | + } |
---|
392 | |
---|
393 | - if ( empty($url) ) |
---|
394 | + if ( empty( $url ) ) { |
---|
395 | return; |
---|
396 | + } |
---|
397 | |
---|
398 | // self-url destruction sequence |
---|
399 | - if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) ) |
---|
400 | + if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) ) { |
---|
401 | return; |
---|
402 | + } |
---|
403 | |
---|
404 | $rss = fetch_feed($url); |
---|
405 | $title = $instance['title']; |
---|
406 | @@ -948,15 +956,18 @@ |
---|
407 | |
---|
408 | if ( ! is_wp_error($rss) ) { |
---|
409 | $desc = esc_attr(strip_tags(@html_entity_decode($rss->get_description(), ENT_QUOTES, get_option('blog_charset')))); |
---|
410 | - if ( empty($title) ) |
---|
411 | + if ( empty($title) ) { |
---|
412 | $title = esc_html(strip_tags($rss->get_title())); |
---|
413 | + } |
---|
414 | $link = esc_url(strip_tags($rss->get_permalink())); |
---|
415 | - while ( stristr($link, 'http') != $link ) |
---|
416 | + while ( stristr( $link, 'http' ) != $link ) { |
---|
417 | $link = substr($link, 1); |
---|
418 | + } |
---|
419 | } |
---|
420 | |
---|
421 | - if ( empty($title) ) |
---|
422 | + if ( empty( $title ) ) { |
---|
423 | $title = empty($desc) ? __('Unknown Feed') : $desc; |
---|
424 | + } |
---|
425 | |
---|
426 | /** This filter is documented in wp-includes/default-widgets.php */ |
---|
427 | $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
---|
428 | @@ -963,17 +974,20 @@ |
---|
429 | |
---|
430 | $url = esc_url(strip_tags($url)); |
---|
431 | $icon = includes_url('images/rss.png'); |
---|
432 | - if ( $title ) |
---|
433 | + if ( $title ) { |
---|
434 | $title = "<a class='rsswidget' href='$url' title='" . esc_attr__( 'Syndicate this content' ) ."'><img style='border:0' width='14' height='14' src='$icon' alt='RSS' /></a> <a class='rsswidget' href='$link' title='$desc'>$title</a>"; |
---|
435 | + } |
---|
436 | |
---|
437 | - echo $before_widget; |
---|
438 | - if ( $title ) |
---|
439 | - echo $before_title . $title . $after_title; |
---|
440 | + echo $args['before_widget']; |
---|
441 | + if ( $title ) { |
---|
442 | + echo $args['before_title'] . $title . $args['after_title']; |
---|
443 | + } |
---|
444 | wp_widget_rss_output( $rss, $instance ); |
---|
445 | - echo $after_widget; |
---|
446 | + echo $args['after_widget']; |
---|
447 | |
---|
448 | - if ( ! is_wp_error($rss) ) |
---|
449 | + if ( ! is_wp_error( $rss ) ) { |
---|
450 | $rss->__destruct(); |
---|
451 | + } |
---|
452 | unset($rss); |
---|
453 | } |
---|
454 | |
---|
455 | @@ -984,8 +998,9 @@ |
---|
456 | |
---|
457 | function form($instance) { |
---|
458 | |
---|
459 | - if ( empty($instance) ) |
---|
460 | + if ( empty( $instance ) ) { |
---|
461 | $instance = array( 'title' => '', 'url' => '', 'items' => 10, 'error' => false, 'show_summary' => 0, 'show_author' => 0, 'show_date' => 0 ); |
---|
462 | + } |
---|
463 | $instance['number'] = $this->number; |
---|
464 | |
---|
465 | wp_widget_rss_form( $instance ); |
---|
466 | @@ -1011,21 +1026,22 @@ |
---|
467 | } |
---|
468 | |
---|
469 | if ( is_wp_error($rss) ) { |
---|
470 | - if ( is_admin() || current_user_can('manage_options') ) |
---|
471 | + if ( is_admin() || current_user_can('manage_options') ) { |
---|
472 | echo '<p>' . sprintf( __('<strong>RSS Error</strong>: %s'), $rss->get_error_message() ) . '</p>'; |
---|
473 | + } |
---|
474 | return; |
---|
475 | } |
---|
476 | |
---|
477 | $default_args = array( 'show_author' => 0, 'show_date' => 0, 'show_summary' => 0 ); |
---|
478 | $args = wp_parse_args( $args, $default_args ); |
---|
479 | - extract( $args, EXTR_SKIP ); |
---|
480 | |
---|
481 | - $items = (int) $items; |
---|
482 | - if ( $items < 1 || 20 < $items ) |
---|
483 | + $items = (int) $args['items']; |
---|
484 | + if ( $items < 1 || 20 < $items ) { |
---|
485 | $items = 10; |
---|
486 | - $show_summary = (int) $show_summary; |
---|
487 | - $show_author = (int) $show_author; |
---|
488 | - $show_date = (int) $show_date; |
---|
489 | + } |
---|
490 | + $show_summary = (int) $args['show_summary']; |
---|
491 | + $show_author = (int) $args['show_author']; |
---|
492 | + $show_date = (int) $args['show_date']; |
---|
493 | |
---|
494 | if ( !$rss->get_item_quantity() ) { |
---|
495 | echo '<ul><li>' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '</li></ul>'; |
---|
496 | @@ -1037,12 +1053,14 @@ |
---|
497 | echo '<ul>'; |
---|
498 | foreach ( $rss->get_items(0, $items) as $item ) { |
---|
499 | $link = $item->get_link(); |
---|
500 | - while ( stristr($link, 'http') != $link ) |
---|
501 | + while ( stristr( $link, 'http' ) != $link ) { |
---|
502 | $link = substr($link, 1); |
---|
503 | + } |
---|
504 | $link = esc_url(strip_tags($link)); |
---|
505 | $title = esc_attr(strip_tags($item->get_title())); |
---|
506 | - if ( empty($title) ) |
---|
507 | + if ( empty( $title ) ) { |
---|
508 | $title = __('Untitled'); |
---|
509 | + } |
---|
510 | |
---|
511 | $desc = @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ); |
---|
512 | $desc = esc_attr( strip_tags( $desc ) ); |
---|
513 | @@ -1110,21 +1128,21 @@ |
---|
514 | |
---|
515 | $default_inputs = array( 'url' => true, 'title' => true, 'items' => true, 'show_summary' => true, 'show_author' => true, 'show_date' => true ); |
---|
516 | $inputs = wp_parse_args( $inputs, $default_inputs ); |
---|
517 | - extract( $args ); |
---|
518 | - extract( $inputs, EXTR_SKIP ); |
---|
519 | |
---|
520 | - $number = esc_attr( $number ); |
---|
521 | - $title = esc_attr( $title ); |
---|
522 | - $url = esc_url( $url ); |
---|
523 | - $items = (int) $items; |
---|
524 | - if ( $items < 1 || 20 < $items ) |
---|
525 | + $number = esc_attr( $inputs['number'] ); |
---|
526 | + $title = esc_attr( $inputs['title'] ); |
---|
527 | + $url = esc_url( $inputs['url'] ); |
---|
528 | + $items = (int) $inputs['items']; |
---|
529 | + if ( $items < 1 || 20 < $items ) { |
---|
530 | $items = 10; |
---|
531 | - $show_summary = (int) $show_summary; |
---|
532 | - $show_author = (int) $show_author; |
---|
533 | - $show_date = (int) $show_date; |
---|
534 | + } |
---|
535 | + $show_summary = (int) $inputs['show_summary']; |
---|
536 | + $show_author = (int) $inputs['show_author']; |
---|
537 | + $show_date = (int) $inputs['show_date']; |
---|
538 | |
---|
539 | - if ( !empty($error) ) |
---|
540 | + if ( ! empty( $error ) ) { |
---|
541 | echo '<p class="widget-error"><strong>' . sprintf( __('RSS Error: %s'), $error) . '</strong></p>'; |
---|
542 | + } |
---|
543 | |
---|
544 | if ( $inputs['url'] ) : |
---|
545 | ?> |
---|
546 | @@ -1137,8 +1155,9 @@ |
---|
547 | <p><label for="rss-items-<?php echo $number; ?>"><?php _e('How many items would you like to display?'); ?></label> |
---|
548 | <select id="rss-items-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][items]"> |
---|
549 | <?php |
---|
550 | - for ( $i = 1; $i <= 20; ++$i ) |
---|
551 | + for ( $i = 1; $i <= 20; ++$i ) { |
---|
552 | echo "<option value='$i' " . selected( $items, $i, false ) . ">$i</option>"; |
---|
553 | + } |
---|
554 | ?> |
---|
555 | </select></p> |
---|
556 | <?php endif; if ( $inputs['show_summary'] ) : ?> |
---|
557 | @@ -1180,8 +1199,9 @@ |
---|
558 | */ |
---|
559 | function wp_widget_rss_process( $widget_rss, $check_feed = true ) { |
---|
560 | $items = (int) $widget_rss['items']; |
---|
561 | - if ( $items < 1 || 20 < $items ) |
---|
562 | + if ( $items < 1 || 20 < $items ) { |
---|
563 | $items = 10; |
---|
564 | + } |
---|
565 | $url = esc_url_raw( strip_tags( $widget_rss['url'] ) ); |
---|
566 | $title = isset( $widget_rss['title'] ) ? trim( strip_tags( $widget_rss['title'] ) ) : ''; |
---|
567 | $show_summary = isset( $widget_rss['show_summary'] ) ? (int) $widget_rss['show_summary'] : 0; |
---|
568 | @@ -1220,7 +1240,6 @@ |
---|
569 | } |
---|
570 | |
---|
571 | function widget( $args, $instance ) { |
---|
572 | - extract($args); |
---|
573 | $current_taxonomy = $this->_get_current_taxonomy($instance); |
---|
574 | if ( !empty($instance['title']) ) { |
---|
575 | $title = $instance['title']; |
---|
576 | @@ -1236,9 +1255,10 @@ |
---|
577 | /** This filter is documented in wp-includes/default-widgets.php */ |
---|
578 | $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
---|
579 | |
---|
580 | - echo $before_widget; |
---|
581 | - if ( $title ) |
---|
582 | - echo $before_title . $title . $after_title; |
---|
583 | + echo $args['before_widget']; |
---|
584 | + if ( $title ) { |
---|
585 | + echo $args['before_title'] . $title . $args['after_title']; |
---|
586 | + } |
---|
587 | echo '<div class="tagcloud">'; |
---|
588 | |
---|
589 | /** |
---|
590 | @@ -1256,7 +1276,7 @@ |
---|
591 | ) ) ); |
---|
592 | |
---|
593 | echo "</div>\n"; |
---|
594 | - echo $after_widget; |
---|
595 | + echo $args['after_widget']; |
---|
596 | } |
---|
597 | |
---|
598 | function update( $new_instance, $old_instance ) { |
---|
599 | @@ -1274,8 +1294,9 @@ |
---|
600 | <select class="widefat" id="<?php echo $this->get_field_id('taxonomy'); ?>" name="<?php echo $this->get_field_name('taxonomy'); ?>"> |
---|
601 | <?php foreach ( get_taxonomies() as $taxonomy ) : |
---|
602 | $tax = get_taxonomy($taxonomy); |
---|
603 | - if ( !$tax->show_tagcloud || empty($tax->labels->name) ) |
---|
604 | + if ( ! $tax->show_tagcloud || empty( $tax->labels->name ) ) { |
---|
605 | continue; |
---|
606 | + } |
---|
607 | ?> |
---|
608 | <option value="<?php echo esc_attr($taxonomy) ?>" <?php selected($taxonomy, $current_taxonomy) ?>><?php echo $tax->labels->name; ?></option> |
---|
609 | <?php endforeach; ?> |
---|
610 | @@ -1283,8 +1304,9 @@ |
---|
611 | } |
---|
612 | |
---|
613 | function _get_current_taxonomy($instance) { |
---|
614 | - if ( !empty($instance['taxonomy']) && taxonomy_exists($instance['taxonomy']) ) |
---|
615 | + if ( ! empty( $instance['taxonomy'] ) && taxonomy_exists( $instance['taxonomy'] ) ) { |
---|
616 | return $instance['taxonomy']; |
---|
617 | + } |
---|
618 | |
---|
619 | return 'post_tag'; |
---|
620 | } |
---|
621 | @@ -1306,8 +1328,9 @@ |
---|
622 | // Get menu |
---|
623 | $nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false; |
---|
624 | |
---|
625 | - if ( !$nav_menu ) |
---|
626 | + if ( ! $nav_menu ) { |
---|
627 | return; |
---|
628 | + } |
---|
629 | |
---|
630 | /** This filter is documented in wp-includes/default-widgets.php */ |
---|
631 | $instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); |
---|
632 | @@ -1314,8 +1337,9 @@ |
---|
633 | |
---|
634 | echo $args['before_widget']; |
---|
635 | |
---|
636 | - if ( !empty($instance['title']) ) |
---|
637 | + if ( ! empty( $instance['title'] ) ) { |
---|
638 | echo $args['before_title'] . $instance['title'] . $args['after_title']; |
---|
639 | + } |
---|
640 | |
---|
641 | wp_nav_menu( array( 'fallback_cb' => '', 'menu' => $nav_menu ) ); |
---|
642 | |
---|
643 | @@ -1371,8 +1395,9 @@ |
---|
644 | * @since 2.2.0 |
---|
645 | */ |
---|
646 | function wp_widgets_init() { |
---|
647 | - if ( !is_blog_installed() ) |
---|
648 | + if ( ! is_blog_installed() ) { |
---|
649 | return; |
---|
650 | + } |
---|
651 | |
---|
652 | register_widget('WP_Widget_Pages'); |
---|
653 | |
---|
654 | @@ -1380,8 +1405,9 @@ |
---|
655 | |
---|
656 | register_widget('WP_Widget_Archives'); |
---|
657 | |
---|
658 | - if ( get_option( 'link_manager_enabled' ) ) |
---|
659 | + if ( get_option( 'link_manager_enabled' ) ) { |
---|
660 | register_widget('WP_Widget_Links'); |
---|
661 | + } |
---|
662 | |
---|
663 | register_widget('WP_Widget_Meta'); |
---|