Ticket #22400: 22400.default-widgets.php.3.diff
File 22400.default-widgets.php.3.diff, 21.0 KB (added by , 9 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. … … 35 34 $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby']; 36 35 $exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude']; 37 36 38 if ( $sortby == 'menu_order' )37 if ( 'menu_order' == $sortby ) { 39 38 $sortby = 'menu_order, post_title'; 39 } 40 40 41 41 /** 42 42 * Filter the arguments for the Pages widget. … … 54 54 'exclude' => $exclude 55 55 ) ) ); 56 56 57 if ( !empty( $out ) ) { 58 echo $before_widget; 59 if ( $title) 60 echo $before_title . $title . $after_title; 57 if ( ! empty( $out ) ) { 58 echo $args['before_widget']; 59 if ( $title ) { 60 echo $args['before_title'] . $title . $args['after_title']; 61 } 61 62 ?> 62 63 <ul> 63 64 <?php echo $out; ?> 64 65 </ul> 65 66 <?php 66 echo $a fter_widget;67 echo $args['after_widget']; 67 68 } 68 69 } 69 70 … … 119 120 } 120 121 121 122 function widget( $args, $instance ) { 122 extract($args, EXTR_SKIP);123 123 124 124 $show_description = isset($instance['description']) ? $instance['description'] : false; 125 125 $show_name = isset($instance['name']) ? $instance['name'] : false; … … 127 127 $show_images = isset($instance['images']) ? $instance['images'] : true; 128 128 $category = isset($instance['category']) ? $instance['category'] : false; 129 129 $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name'; 130 $order = $orderby == 'rating'? 'DESC' : 'ASC';130 $order = ( 'rating' == $orderby ) ? 'DESC' : 'ASC'; 131 131 $limit = isset( $instance['limit'] ) ? $instance['limit'] : -1; 132 132 133 $before_widget = preg_replace( '/id="[^"]*"/','id="%id"', $before_widget);133 $before_widget = preg_replace( '/id="[^"]*"/', 'id="%id"', $args['before_widget'] ); 134 134 135 135 /** 136 136 * Filter the arguments for the Links widget. … … 142 142 * @param array $args An array of arguments to retrieve the links list. 143 143 */ 144 144 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' => $after_widget,145 'title_before' => $args['before_title'], 'title_after' => $args['after_title'], 146 'category_before' => $args['before_widget'], 'category_after' => $args['after_widget'], 147 147 'show_images' => $show_images, 'show_description' => $show_description, 148 148 'show_name' => $show_name, 'show_rating' => $show_rating, 149 149 'category' => $category, 'class' => 'linkcat widget', … … 156 156 $new_instance = (array) $new_instance; 157 157 $instance = array( 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0 ); 158 158 foreach ( $instance as $field => $val ) { 159 if ( isset( $new_instance[$field]) )159 if ( isset( $new_instance[ $field ] ) ) { 160 160 $instance[$field] = 1; 161 } 161 162 } 162 163 163 164 $instance['orderby'] = 'name'; 164 if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) ) 165 if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) ) { 165 166 $instance['orderby'] = $new_instance['orderby']; 167 } 166 168 167 169 $instance['category'] = intval( $new_instance['category'] ); 168 170 $instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1; … … 229 231 } 230 232 231 233 function widget( $args, $instance ) { 232 extract($args);233 234 234 235 /** This filter is documented in wp-includes/default-widgets.php */ 235 236 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); 236 237 237 echo $before_widget; 238 if ( $title ) 239 echo $before_title . $title . $after_title; 238 echo $args['before_widget']; 239 if ( $title ) { 240 echo $args['before_title'] . $title . $args['after_title']; 241 } 240 242 241 243 // Use current theme search form if it exists 242 244 get_search_form(); 243 245 244 echo $a fter_widget;246 echo $args['after_widget']; 245 247 } 246 248 247 249 function form( $instance ) { … … 274 276 } 275 277 276 278 function widget( $args, $instance ) { 277 extract($args);278 279 $c = ! empty( $instance['count'] ) ? '1' : '0'; 279 280 $d = ! empty( $instance['dropdown'] ) ? '1' : '0'; 280 281 281 282 /** 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 );283 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Archives' ) : $instance['title'], $instance, $this->id_base ); 283 284 284 echo $before_widget; 285 if ( $title ) 286 echo $before_title . $title . $after_title; 285 echo $args['before_widget']; 286 if ( $title ) { 287 echo $args['before_title'] . $title . $args['after_title']; 288 } 287 289 288 290 if ( $d ) { 289 291 ?> … … 330 332 <?php 331 333 } 332 334 333 echo $a fter_widget;335 echo $args['after_widget']; 334 336 } 335 337 336 338 function update( $new_instance, $old_instance ) { … … 374 376 } 375 377 376 378 function widget( $args, $instance ) { 377 extract($args);378 379 379 380 /** This filter is documented in wp-includes/default-widgets.php */ 380 381 $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Meta' ) : $instance['title'], $instance, $this->id_base ); 381 382 382 echo $before_widget; 383 if ( $title ) 384 echo $before_title . $title . $after_title; 383 echo $args['before_widget']; 384 if ( $title ) { 385 echo $args['before_title'] . $title . $args['after_title']; 386 } 385 387 ?> 386 388 <ul> 387 389 <?php wp_register(); ?> … … 406 408 ?> 407 409 </ul> 408 410 <?php 409 echo $a fter_widget;411 echo $args['after_widget']; 410 412 } 411 413 412 414 function update( $new_instance, $old_instance ) { … … 438 440 } 439 441 440 442 function widget( $args, $instance ) { 441 extract($args);442 443 443 444 /** This filter is documented in wp-includes/default-widgets.php */ 444 445 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); 445 446 446 echo $before_widget; 447 if ( $title ) 448 echo $before_title . $title . $after_title; 447 echo $args['before_widget']; 448 if ( $title ) { 449 echo $args['before_title'] . $title . $args['after_title']; 450 } 449 451 echo '<div id="calendar_wrap">'; 450 452 get_calendar(); 451 453 echo '</div>'; 452 echo $a fter_widget;454 echo $args['after_widget']; 453 455 } 454 456 455 457 function update( $new_instance, $old_instance ) { … … 483 485 } 484 486 485 487 function widget( $args, $instance ) { 486 extract($args);487 488 488 489 /** This filter is documented in wp-includes/default-widgets.php */ 489 490 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); … … 497 498 * @param WP_Widget $instance WP_Widget instance. 498 499 */ 499 500 $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; } ?>501 echo $args['before_widget']; 502 if ( ! empty( $title ) ) { echo $args['before_title'] . $title . $args['after_title']; } ?> 502 503 <div class="textwidget"><?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div> 503 504 <?php 504 echo $a fter_widget;505 echo $args['after_widget']; 505 506 } 506 507 507 508 function update( $new_instance, $old_instance ) { 508 509 $instance = $old_instance; 509 510 $instance['title'] = strip_tags($new_instance['title']); 510 if ( current_user_can('unfiltered_html') ) 511 if ( current_user_can('unfiltered_html') ) { 511 512 $instance['text'] = $new_instance['text']; 512 else513 } else { 513 514 $instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) ); // wp_filter_post_kses() expects slashed 515 } 514 516 $instance['filter'] = isset($new_instance['filter']); 515 517 return $instance; 516 518 } … … 543 545 } 544 546 545 547 function widget( $args, $instance ) { 546 extract( $args );547 548 548 549 /** This filter is documented in wp-includes/default-widgets.php */ 549 550 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base ); … … 552 553 $h = ! empty( $instance['hierarchical'] ) ? '1' : '0'; 553 554 $d = ! empty( $instance['dropdown'] ) ? '1' : '0'; 554 555 555 echo $before_widget; 556 if ( $title ) 557 echo $before_title . $title . $after_title; 556 echo $args['before_widget']; 557 if ( $title ) { 558 echo $args['before_title'] . $title . $args['after_title']; 559 } 558 560 559 561 $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h); 560 562 … … 605 607 <?php 606 608 } 607 609 608 echo $a fter_widget;610 echo $args['after_widget']; 609 611 } 610 612 611 613 function update( $new_instance, $old_instance ) { … … 679 681 } 680 682 681 683 ob_start(); 682 extract($args);683 684 684 685 $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' ); 685 686 … … 687 688 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); 688 689 689 690 $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; 690 if ( ! $number ) 691 if ( ! $number ) { 691 692 $number = 5; 693 } 692 694 $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false; 693 695 694 696 /** … … 709 711 710 712 if ($r->have_posts()) : 711 713 ?> 712 <?php echo $ before_widget; ?>713 <?php if ( $title ) echo $before_title . $title . $after_title;?>714 <?php echo $args['before_widget']; ?> 715 <?php if ( $title ) { echo $args['before_title'] . $title . $args['after_title']; } ?> 714 716 <ul> 715 717 <?php while ( $r->have_posts() ) : $r->the_post(); ?> 716 718 <li> … … 721 723 </li> 722 724 <?php endwhile; ?> 723 725 </ul> 724 <?php echo $a fter_widget; ?>726 <?php echo $args['after_widget']; ?> 725 727 <?php 726 728 // Reset the global $the_post as this query will have stomped on it 727 729 wp_reset_postdata(); … … 744 746 $this->flush_widget_cache(); 745 747 746 748 $alloptions = wp_cache_get( 'alloptions', 'options' ); 747 if ( isset( $alloptions['widget_recent_entries']) )749 if ( isset( $alloptions['widget_recent_entries'] ) ) { 748 750 delete_option('widget_recent_entries'); 751 } 749 752 750 753 return $instance; 751 754 } … … 783 786 parent::__construct('recent-comments', __('Recent Comments'), $widget_ops); 784 787 $this->alt_option_name = 'widget_recent_comments'; 785 788 786 if ( is_active_widget( false, false, $this->id_base) )789 if ( is_active_widget( false, false, $this->id_base ) ) { 787 790 add_action( 'wp_head', array($this, 'recent_comments_style') ); 791 } 788 792 789 793 add_action( 'comment_post', array($this, 'flush_widget_cache') ); 790 794 add_action( 'edit_comment', array($this, 'flush_widget_cache') ); … … 802 806 * @param string $id_base The widget ID. 803 807 */ 804 808 if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876 805 || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) 809 || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) { 806 810 return; 811 } 807 812 ?> 808 813 <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style> 809 814 <?php … … 832 837 return; 833 838 } 834 839 835 extract($args, EXTR_SKIP);836 840 $output = ''; 837 841 838 842 $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments' ); … … 841 845 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); 842 846 843 847 $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; 844 if ( ! $number ) 848 if ( ! $number ) { 845 849 $number = 5; 850 } 846 851 847 852 /** 848 853 * Filter the arguments for the Recent Comments widget. … … 859 864 'post_status' => 'publish' 860 865 ) ) ); 861 866 862 $output .= $before_widget; 863 if ( $title ) 864 $output .= $before_title . $title . $after_title; 867 $output .= $args['before_widget']; 868 if ( $title ) { 869 $output .= $args['before_title'] . $title . $args['after_title']; 870 } 865 871 866 872 $output .= '<ul id="recentcomments">'; 867 873 if ( $comments ) { … … 874 880 } 875 881 } 876 882 $output .= '</ul>'; 877 $output .= $a fter_widget;883 $output .= $args['after_widget']; 878 884 879 885 echo $output; 880 886 … … 891 897 $this->flush_widget_cache(); 892 898 893 899 $alloptions = wp_cache_get( 'alloptions', 'options' ); 894 if ( isset( $alloptions['widget_recent_comments']) )900 if ( isset( $alloptions['widget_recent_comments'] ) ) { 895 901 delete_option('widget_recent_comments'); 902 } 896 903 897 904 return $instance; 898 905 } … … 928 935 if ( isset($instance['error']) && $instance['error'] ) 929 936 return; 930 937 931 extract($args, EXTR_SKIP);932 933 938 $url = ! empty( $instance['url'] ) ? $instance['url'] : ''; 934 while ( stristr( $url, 'http') != $url )939 while ( stristr( $url, 'http' ) != $url ) { 935 940 $url = substr($url, 1); 941 } 936 942 937 if ( empty( $url) )943 if ( empty( $url ) ) { 938 944 return; 945 } 939 946 940 947 // self-url destruction sequence 941 if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) ) 948 if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) ) { 942 949 return; 950 } 943 951 944 952 $rss = fetch_feed($url); 945 953 $title = $instance['title']; … … 948 956 949 957 if ( ! is_wp_error($rss) ) { 950 958 $desc = esc_attr(strip_tags(@html_entity_decode($rss->get_description(), ENT_QUOTES, get_option('blog_charset')))); 951 if ( empty( $title) )959 if ( empty( $title ) ) { 952 960 $title = esc_html(strip_tags($rss->get_title())); 961 } 953 962 $link = esc_url(strip_tags($rss->get_permalink())); 954 while ( stristr( $link, 'http') != $link )963 while ( stristr( $link, 'http' ) != $link ) { 955 964 $link = substr($link, 1); 965 } 956 966 } 957 967 958 if ( empty( $title) )968 if ( empty( $title ) ) { 959 969 $title = empty($desc) ? __('Unknown Feed') : $desc; 970 } 960 971 961 972 /** This filter is documented in wp-includes/default-widgets.php */ 962 973 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); … … 963 974 964 975 $url = esc_url(strip_tags($url)); 965 976 $icon = includes_url('images/rss.png'); 966 if ( $title ) 977 if ( $title ) { 967 978 $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>"; 979 } 968 980 969 echo $before_widget; 970 if ( $title ) 971 echo $before_title . $title . $after_title; 981 echo $args['before_widget']; 982 if ( $title ) { 983 echo $args['before_title'] . $title . $args['after_title']; 984 } 972 985 wp_widget_rss_output( $rss, $instance ); 973 echo $a fter_widget;986 echo $args['after_widget']; 974 987 975 if ( ! is_wp_error( $rss) )988 if ( ! is_wp_error( $rss ) ) { 976 989 $rss->__destruct(); 990 } 977 991 unset($rss); 978 992 } 979 993 … … 984 998 985 999 function form($instance) { 986 1000 987 if ( empty( $instance) )1001 if ( empty( $instance ) ) { 988 1002 $instance = array( 'title' => '', 'url' => '', 'items' => 10, 'error' => false, 'show_summary' => 0, 'show_author' => 0, 'show_date' => 0 ); 1003 } 989 1004 $instance['number'] = $this->number; 990 1005 991 1006 wp_widget_rss_form( $instance ); … … 1011 1026 } 1012 1027 1013 1028 if ( is_wp_error($rss) ) { 1014 if ( is_admin() || current_user_can( 'manage_options') )1029 if ( is_admin() || current_user_can( 'manage_options' ) ) { 1015 1030 echo '<p>' . sprintf( __('<strong>RSS Error</strong>: %s'), $rss->get_error_message() ) . '</p>'; 1031 } 1016 1032 return; 1017 1033 } 1018 1034 1019 1035 $default_args = array( 'show_author' => 0, 'show_date' => 0, 'show_summary' => 0 ); 1020 1036 $args = wp_parse_args( $args, $default_args ); 1021 extract( $args, EXTR_SKIP );1022 1037 1023 $items = (int) $ items;1024 if ( $items < 1 || 20 < $items ) 1038 $items = (int) $args['items']; 1039 if ( $items < 1 || 20 < $items ) { 1025 1040 $items = 10; 1026 $show_summary = (int) $show_summary; 1027 $show_author = (int) $show_author; 1028 $show_date = (int) $show_date; 1041 } 1042 $show_summary = (int) $args['show_summary']; 1043 $show_author = (int) $args['show_author']; 1044 $show_date = (int) $args['show_date']; 1029 1045 1030 1046 if ( !$rss->get_item_quantity() ) { 1031 1047 echo '<ul><li>' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '</li></ul>'; … … 1037 1053 echo '<ul>'; 1038 1054 foreach ( $rss->get_items(0, $items) as $item ) { 1039 1055 $link = $item->get_link(); 1040 while ( stristr( $link, 'http') != $link )1056 while ( stristr( $link, 'http' ) != $link ) { 1041 1057 $link = substr($link, 1); 1058 } 1042 1059 $link = esc_url(strip_tags($link)); 1043 1060 $title = esc_attr(strip_tags($item->get_title())); 1044 if ( empty( $title) )1061 if ( empty( $title ) ) { 1045 1062 $title = __('Untitled'); 1063 } 1046 1064 1047 1065 $desc = @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ); 1048 1066 $desc = esc_attr( strip_tags( $desc ) ); … … 1110 1128 1111 1129 $default_inputs = array( 'url' => true, 'title' => true, 'items' => true, 'show_summary' => true, 'show_author' => true, 'show_date' => true ); 1112 1130 $inputs = wp_parse_args( $inputs, $default_inputs ); 1113 extract( $args );1114 extract( $inputs, EXTR_SKIP );1115 1131 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 ) 1132 $number = esc_attr( $inputs['number'] ); 1133 $title = esc_attr( $inputs['title'] ); 1134 $url = esc_url( $inputs['url'] ); 1135 $items = (int) $inputs['items']; 1136 if ( $items < 1 || 20 < $items ) { 1121 1137 $items = 10; 1122 $show_summary = (int) $show_summary; 1123 $show_author = (int) $show_author; 1124 $show_date = (int) $show_date; 1138 } 1139 $show_summary = (int) $inputs['show_summary']; 1140 $show_author = (int) $inputs['show_author']; 1141 $show_date = (int) $inputs['show_date']; 1125 1142 1126 if ( ! empty($error) )1143 if ( ! empty( $error ) ) { 1127 1144 echo '<p class="widget-error"><strong>' . sprintf( __('RSS Error: %s'), $error) . '</strong></p>'; 1145 } 1128 1146 1129 1147 if ( $inputs['url'] ) : 1130 1148 ?> … … 1137 1155 <p><label for="rss-items-<?php echo $number; ?>"><?php _e('How many items would you like to display?'); ?></label> 1138 1156 <select id="rss-items-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][items]"> 1139 1157 <?php 1140 for ( $i = 1; $i <= 20; ++$i ) 1158 for ( $i = 1; $i <= 20; ++$i ) { 1141 1159 echo "<option value='$i' " . selected( $items, $i, false ) . ">$i</option>"; 1160 } 1142 1161 ?> 1143 1162 </select></p> 1144 1163 <?php endif; if ( $inputs['show_summary'] ) : ?> … … 1180 1199 */ 1181 1200 function wp_widget_rss_process( $widget_rss, $check_feed = true ) { 1182 1201 $items = (int) $widget_rss['items']; 1183 if ( $items < 1 || 20 < $items ) 1202 if ( $items < 1 || 20 < $items ) { 1184 1203 $items = 10; 1204 } 1185 1205 $url = esc_url_raw( strip_tags( $widget_rss['url'] ) ); 1186 1206 $title = isset( $widget_rss['title'] ) ? trim( strip_tags( $widget_rss['title'] ) ) : ''; 1187 1207 $show_summary = isset( $widget_rss['show_summary'] ) ? (int) $widget_rss['show_summary'] : 0; … … 1220 1240 } 1221 1241 1222 1242 function widget( $args, $instance ) { 1223 extract($args);1224 1243 $current_taxonomy = $this->_get_current_taxonomy($instance); 1225 1244 if ( !empty($instance['title']) ) { 1226 1245 $title = $instance['title']; … … 1236 1255 /** This filter is documented in wp-includes/default-widgets.php */ 1237 1256 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); 1238 1257 1239 echo $before_widget; 1240 if ( $title ) 1241 echo $before_title . $title . $after_title; 1258 echo $args['before_widget']; 1259 if ( $title ) { 1260 echo $args['before_title'] . $title . $args['after_title']; 1261 } 1242 1262 echo '<div class="tagcloud">'; 1243 1263 1244 1264 /** … … 1256 1276 ) ) ); 1257 1277 1258 1278 echo "</div>\n"; 1259 echo $a fter_widget;1279 echo $args['after_widget']; 1260 1280 } 1261 1281 1262 1282 function update( $new_instance, $old_instance ) { … … 1274 1294 <select class="widefat" id="<?php echo $this->get_field_id('taxonomy'); ?>" name="<?php echo $this->get_field_name('taxonomy'); ?>"> 1275 1295 <?php foreach ( get_taxonomies() as $taxonomy ) : 1276 1296 $tax = get_taxonomy($taxonomy); 1277 if ( ! $tax->show_tagcloud || empty($tax->labels->name) )1297 if ( ! $tax->show_tagcloud || empty( $tax->labels->name ) ) { 1278 1298 continue; 1299 } 1279 1300 ?> 1280 1301 <option value="<?php echo esc_attr($taxonomy) ?>" <?php selected($taxonomy, $current_taxonomy) ?>><?php echo $tax->labels->name; ?></option> 1281 1302 <?php endforeach; ?> … … 1283 1304 } 1284 1305 1285 1306 function _get_current_taxonomy($instance) { 1286 if ( ! empty($instance['taxonomy']) && taxonomy_exists($instance['taxonomy']) )1307 if ( ! empty( $instance['taxonomy'] ) && taxonomy_exists( $instance['taxonomy'] ) ) { 1287 1308 return $instance['taxonomy']; 1309 } 1288 1310 1289 1311 return 'post_tag'; 1290 1312 } … … 1306 1328 // Get menu 1307 1329 $nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false; 1308 1330 1309 if ( ! $nav_menu )1331 if ( ! $nav_menu ) { 1310 1332 return; 1333 } 1311 1334 1312 1335 /** This filter is documented in wp-includes/default-widgets.php */ 1313 1336 $instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); … … 1314 1337 1315 1338 echo $args['before_widget']; 1316 1339 1317 if ( ! empty($instance['title']) )1340 if ( ! empty( $instance['title'] ) ) { 1318 1341 echo $args['before_title'] . $instance['title'] . $args['after_title']; 1342 } 1319 1343 1320 1344 wp_nav_menu( array( 'fallback_cb' => '', 'menu' => $nav_menu ) ); 1321 1345 … … 1371 1395 * @since 2.2.0 1372 1396 */ 1373 1397 function wp_widgets_init() { 1374 if ( ! is_blog_installed() )1398 if ( ! is_blog_installed() ) { 1375 1399 return; 1400 } 1376 1401 1377 1402 register_widget('WP_Widget_Pages'); 1378 1403 … … 1380 1405 1381 1406 register_widget('WP_Widget_Archives'); 1382 1407 1383 if ( get_option( 'link_manager_enabled' ) ) 1408 if ( get_option( 'link_manager_enabled' ) ) { 1384 1409 register_widget('WP_Widget_Links'); 1410 } 1385 1411 1386 1412 register_widget('WP_Widget_Meta'); 1387 1413