Ticket #22400: widgets.diff
| File widgets.diff, 11.6 KB (added by , 12 years ago) |
|---|
-
src/wp-includes/default-widgets.php
19 19 } 20 20 21 21 function widget( $args, $instance ) { 22 extract( $args );23 22 24 23 /** 25 24 * Filter the widget title. … … 54 53 'exclude' => $exclude 55 54 ) ) ); 56 55 57 if ( !empty( $out ) ) { 58 echo $before_widget; 59 if ( $title) 60 echo $before_title . $title . $after_title; 56 if ( ! empty( $out ) ) { 57 echo $args['before_widget']; 58 if ( $title ) { 59 echo $args['before_title'] . $title . $args['after_title']; 60 } 61 61 ?> 62 62 <ul> 63 63 <?php echo $out; ?> 64 64 </ul> 65 65 <?php 66 echo $a fter_widget;66 echo $args['after_widget']; 67 67 } 68 68 } 69 69 … … 119 119 } 120 120 121 121 function widget( $args, $instance ) { 122 extract($args, EXTR_SKIP);123 122 124 123 $show_description = isset($instance['description']) ? $instance['description'] : false; 125 124 $show_name = isset($instance['name']) ? $instance['name'] : false; … … 130 129 $order = $orderby == 'rating' ? 'DESC' : 'ASC'; 131 130 $limit = isset( $instance['limit'] ) ? $instance['limit'] : -1; 132 131 133 $before_widget = preg_replace( '/id="[^"]*"/','id="%id"', $before_widget);132 $before_widget = preg_replace( '/id="[^"]*"/', 'id="%id"', $args['before_widget'] ); 134 133 135 134 /** 136 135 * Filter the arguments for the Links widget. … … 142 141 * @param array $args An array of arguments to retrieve the links list. 143 142 */ 144 143 wp_list_bookmarks( apply_filters( 'widget_links_args', array( 145 'title_before' => $ before_title, 'title_after' => $after_title,146 'category_before' => $before_widget, 'category_after' => $a fter_widget,144 'title_before' => $args['before_title'], 'title_after' => $args['after_title'], 145 'category_before' => $before_widget, 'category_after' => $args['after_widget'], 147 146 'show_images' => $show_images, 'show_description' => $show_description, 148 147 'show_name' => $show_name, 'show_rating' => $show_rating, 149 148 'category' => $category, 'class' => 'linkcat widget', … … 229 228 } 230 229 231 230 function widget( $args, $instance ) { 232 extract($args);233 231 234 232 /** This filter is documented in wp-includes/default-widgets.php */ 235 233 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); 236 234 237 echo $before_widget; 238 if ( $title ) 239 echo $before_title . $title . $after_title; 235 echo $args['before_widget']; 236 if ( $title ) { 237 echo $args['before_title'] . $title . $args['after_title']; 238 } 240 239 241 240 // Use current theme search form if it exists 242 241 get_search_form(); 243 242 244 echo $a fter_widget;243 echo $args['after_widget']; 245 244 } 246 245 247 246 function form( $instance ) { … … 274 273 } 275 274 276 275 function widget( $args, $instance ) { 277 extract($args);278 276 $c = ! empty( $instance['count'] ) ? '1' : '0'; 279 277 $d = ! empty( $instance['dropdown'] ) ? '1' : '0'; 280 278 281 279 /** This filter is documented in wp-includes/default-widgets.php */ 282 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Archives' ) : $instance['title'], $instance, $this->id_base );280 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Archives' ) : $instance['title'], $instance, $this->id_base ); 283 281 284 echo $before_widget; 285 if ( $title ) 286 echo $before_title . $title . $after_title; 282 echo $args['before_widget']; 283 if ( $title ) { 284 echo $args['before_title'] . $title . $args['after_title']; 285 } 287 286 288 287 if ( $d ) { 289 288 ?> … … 330 329 <?php 331 330 } 332 331 333 echo $a fter_widget;332 echo $args['after_widget']; 334 333 } 335 334 336 335 function update( $new_instance, $old_instance ) { … … 374 373 } 375 374 376 375 function widget( $args, $instance ) { 377 extract($args);378 376 379 377 /** This filter is documented in wp-includes/default-widgets.php */ 380 378 $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Meta' ) : $instance['title'], $instance, $this->id_base ); 381 379 382 echo $before_widget; 383 if ( $title ) 384 echo $before_title . $title . $after_title; 380 echo $args['before_widget']; 381 if ( $title ) { 382 echo $args['before_title'] . $title . $args['after_title']; 383 } 385 384 ?> 386 385 <ul> 387 386 <?php wp_register(); ?> … … 406 405 ?> 407 406 </ul> 408 407 <?php 409 echo $a fter_widget;408 echo $args['after_widget']; 410 409 } 411 410 412 411 function update( $new_instance, $old_instance ) { … … 438 437 } 439 438 440 439 function widget( $args, $instance ) { 441 extract($args);442 440 443 441 /** This filter is documented in wp-includes/default-widgets.php */ 444 442 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); 445 443 446 echo $before_widget; 447 if ( $title ) 448 echo $before_title . $title . $after_title; 444 echo $args['before_widget']; 445 if ( $title ) { 446 echo $args['before_title'] . $title . $args['after_title']; 447 } 449 448 echo '<div id="calendar_wrap">'; 450 449 get_calendar(); 451 450 echo '</div>'; 452 echo $a fter_widget;451 echo $args['after_widget']; 453 452 } 454 453 455 454 function update( $new_instance, $old_instance ) { … … 483 482 } 484 483 485 484 function widget( $args, $instance ) { 486 extract($args);487 485 488 486 /** This filter is documented in wp-includes/default-widgets.php */ 489 487 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); … … 497 495 * @param WP_Widget $instance WP_Widget instance. 498 496 */ 499 497 $text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance ); 500 echo $before_widget; 501 if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?> 498 echo $args['before_widget']; 499 if ( ! empty( $title ) ) { 500 echo $args['before_title'] . $title . $args['after_title']; 501 } ?> 502 502 <div class="textwidget"><?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div> 503 503 <?php 504 echo $a fter_widget;504 echo $args['after_widget']; 505 505 } 506 506 507 507 function update( $new_instance, $old_instance ) { … … 543 543 } 544 544 545 545 function widget( $args, $instance ) { 546 extract( $args );547 546 548 547 /** This filter is documented in wp-includes/default-widgets.php */ 549 548 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base ); … … 552 551 $h = ! empty( $instance['hierarchical'] ) ? '1' : '0'; 553 552 $d = ! empty( $instance['dropdown'] ) ? '1' : '0'; 554 553 555 echo $before_widget; 556 if ( $title ) 557 echo $before_title . $title . $after_title; 554 echo $args['before_widget']; 555 if ( $title ) { 556 echo $args['before_title'] . $title . $args['after_title']; 557 } 558 558 559 559 $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h); 560 560 … … 605 605 <?php 606 606 } 607 607 608 echo $a fter_widget;608 echo $args['after_widget']; 609 609 } 610 610 611 611 function update( $new_instance, $old_instance ) { … … 679 679 } 680 680 681 681 ob_start(); 682 extract($args);683 682 684 683 $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' ); 685 684 … … 709 708 710 709 if ($r->have_posts()) : 711 710 ?> 712 <?php echo $before_widget; ?> 713 <?php if ( $title ) echo $before_title . $title . $after_title; ?> 711 <?php echo $args['before_widget']; ?> 712 <?php if ( $title ) { 713 echo $args['before_title'] . $title . $args['after_title']; 714 } ?> 714 715 <ul> 715 716 <?php while ( $r->have_posts() ) : $r->the_post(); ?> 716 717 <li> … … 721 722 </li> 722 723 <?php endwhile; ?> 723 724 </ul> 724 <?php echo $a fter_widget; ?>725 <?php echo $args['after_widget']; ?> 725 726 <?php 726 727 // Reset the global $the_post as this query will have stomped on it 727 728 wp_reset_postdata(); … … 832 833 return; 833 834 } 834 835 835 extract($args, EXTR_SKIP);836 836 $output = ''; 837 837 838 838 $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments' ); … … 859 859 'post_status' => 'publish' 860 860 ) ) ); 861 861 862 $output .= $before_widget; 863 if ( $title ) 864 $output .= $before_title . $title . $after_title; 862 $output .= $args['before_widget']; 863 if ( $title ) { 864 $output .= $args['before_title'] . $title . $args['after_title']; 865 } 865 866 866 867 $output .= '<ul id="recentcomments">'; 867 868 if ( $comments ) { … … 874 875 } 875 876 } 876 877 $output .= '</ul>'; 877 $output .= $a fter_widget;878 $output .= $args['after_widget']; 878 879 879 880 echo $output; 880 881 … … 928 929 if ( isset($instance['error']) && $instance['error'] ) 929 930 return; 930 931 931 extract($args, EXTR_SKIP);932 933 932 $url = ! empty( $instance['url'] ) ? $instance['url'] : ''; 934 933 while ( stristr($url, 'http') != $url ) 935 934 $url = substr($url, 1); … … 966 965 if ( $title ) 967 966 $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>"; 968 967 969 echo $before_widget; 970 if ( $title ) 971 echo $before_title . $title . $after_title; 968 echo $args['before_widget']; 969 if ( $title ) { 970 echo $args['before_title'] . $title . $args['after_title']; 971 } 972 972 wp_widget_rss_output( $rss, $instance ); 973 echo $a fter_widget;973 echo $args['after_widget']; 974 974 975 975 if ( ! is_wp_error($rss) ) 976 976 $rss->__destruct(); … … 1018 1018 1019 1019 $default_args = array( 'show_author' => 0, 'show_date' => 0, 'show_summary' => 0 ); 1020 1020 $args = wp_parse_args( $args, $default_args ); 1021 extract( $args, EXTR_SKIP );1022 1021 1023 $items = (int) $ items;1022 $items = (int) $args['items']; 1024 1023 if ( $items < 1 || 20 < $items ) 1025 1024 $items = 10; 1026 $show_summary = (int) $ show_summary;1027 $show_author = (int) $ show_author;1028 $show_date = (int) $ show_date;1025 $show_summary = (int) $args['show_summary']; 1026 $show_author = (int) $args['show_author']; 1027 $show_date = (int) $args['show_date']; 1029 1028 1030 1029 if ( !$rss->get_item_quantity() ) { 1031 1030 echo '<ul><li>' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '</li></ul>'; … … 1110 1109 1111 1110 $default_inputs = array( 'url' => true, 'title' => true, 'items' => true, 'show_summary' => true, 'show_author' => true, 'show_date' => true ); 1112 1111 $inputs = wp_parse_args( $inputs, $default_inputs ); 1113 extract( $args );1114 extract( $inputs, EXTR_SKIP );1115 1112 1116 $number = esc_attr( $ number);1117 $title = esc_attr( $ title);1118 $url = esc_url( $ url);1119 $items = (int) $i tems;1120 if ( $items < 1 || 20 < $items ) 1113 $number = esc_attr( $inputs['number'] ); 1114 $title = esc_attr( $inputs['title'] ); 1115 $url = esc_url( $inputs['url'] ); 1116 $items = (int) $inputs['items']; 1117 if ( $items < 1 || 20 < $items ) { 1121 1118 $items = 10; 1122 $show_summary = (int) $show_summary; 1123 $show_author = (int) $show_author; 1124 $show_date = (int) $show_date; 1119 } 1120 $show_summary = (int) $inputs['show_summary']; 1121 $show_author = (int) $inputs['show_author']; 1122 $show_date = (int) $inputs['show_date']; 1125 1123 1126 1124 if ( !empty($error) ) 1127 1125 echo '<p class="widget-error"><strong>' . sprintf( __('RSS Error: %s'), $error) . '</strong></p>'; … … 1220 1218 } 1221 1219 1222 1220 function widget( $args, $instance ) { 1223 extract($args);1224 1221 $current_taxonomy = $this->_get_current_taxonomy($instance); 1225 1222 if ( !empty($instance['title']) ) { 1226 1223 $title = $instance['title']; … … 1236 1233 /** This filter is documented in wp-includes/default-widgets.php */ 1237 1234 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); 1238 1235 1239 echo $before_widget; 1240 if ( $title ) 1241 echo $before_title . $title . $after_title; 1236 echo $args['before_widget']; 1237 if ( $title ) { 1238 echo $args['before_title'] . $title . $args['after_title']; 1239 } 1242 1240 echo '<div class="tagcloud">'; 1243 1241 1244 1242 /** … … 1256 1254 ) ) ); 1257 1255 1258 1256 echo "</div>\n"; 1259 echo $a fter_widget;1257 echo $args['after_widget']; 1260 1258 } 1261 1259 1262 1260 function update( $new_instance, $old_instance ) {