Ticket #4280: 4280.diff
| File 4280.diff, 31.8 KB (added by , 17 years ago) |
|---|
-
wp-admin/includes/widgets.php
21 21 $no_widgets_shown = true; 22 22 $already_shown = array(); 23 23 foreach ( $wp_registered_widgets as $name => $widget ) : 24 if ( 'all' == $show &&in_array( $widget['callback'], $already_shown ) ) // We already showed this multi-widget24 if ( in_array( $widget['callback'], $already_shown ) ) // We already showed this multi-widget 25 25 continue; 26 26 27 27 if ( $search_terms ) { … … 47 47 continue; 48 48 49 49 ob_start(); 50 $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template' , '_show' => $show ), 1 => $widget['params'][0]) );50 $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template' ) ) ); 51 51 $sidebar_args = call_user_func_array( 'wp_widget_control', $args ); 52 52 $widget_control_template = ob_get_contents(); 53 53 ob_end_clean(); … … 61 61 'key' => false, 62 62 'edit' => false 63 63 ); 64 if ( 'all' == $show &&$is_multi ) {64 if ( $is_multi ) { 65 65 // it's a multi-widget. We only need to show it in the list once. 66 66 $already_shown[] = $widget['callback']; 67 $num = (int)array_pop( explode( '-', $widget['id'] ) );67 $num = array_pop( explode( '-', $widget['id'] ) ); 68 68 $id_base = $wp_registered_widget_controls[$widget['id']]['id_base']; 69 69 // so that we always add a new one when clicking "add" 70 70 while ( isset($wp_registered_widgets["$id_base-$num"]) ) … … 76 76 } 77 77 $add_query['add'] = $widget['id']; 78 78 $action = 'add'; 79 $add_url = clean_url( wp_nonce_url( add_query_arg( $add_query ), "add-widget_$widget[id]" ));79 $add_url = wp_nonce_url( add_query_arg( $add_query ), "add-widget_$widget[id]" ); 80 80 } else { 81 81 $action = 'edit'; 82 82 $edit_url = clean_url( add_query_arg( array( … … 92 92 93 93 $no_widgets_shown = false; 94 94 95 96 if ( 'all' != $show && $sidebar_args['_widget_title'] )97 $widget_title = $sidebar_args['_widget_title'];98 else99 $widget_title = $widget['name'];100 95 ?> 101 96 102 97 <li id="widget-list-item-<?php echo attribute_escape( $widget['id'] ); ?>" class="widget-list-item"> 103 98 <h4 class="widget-title widget-draggable"> 104 99 105 < span><?php echo $widget_title; ?></span>100 <?php echo wp_specialchars( $widget['name'] ); ?> 106 101 107 102 <?php if ( 'add' == $action ) : ?> 108 103 … … 116 111 117 112 <?php endif; ?> 118 113 119 <br class="clear" />120 121 114 </h4> 122 115 123 116 … … 199 192 200 193 $id_format = $widget['id']; 201 194 // We aren't showing a widget control, we're outputing a template for a mult-widget control 202 if ( ' all' == $sidebar_args['_show'] && 'template' == $sidebar_args['_display'] && isset($control['params'][0]['number']) ) {195 if ( 'template' == $sidebar_args['_display'] && isset($control['params'][0]['number']) ) { 203 196 // number == -1 implies a template where id numbers are replaced by a generic '%i%' 204 197 $control['params'][0]['number'] = -1; 205 198 // if given, id_base means widget id's should be constructed like {$id_base}-{$id_number} … … 209 202 210 203 $widget_title = ''; 211 204 // We grab the normal widget output to find the widget's title 212 if ( ( 'all' != $sidebar_args['_show'] || 'template' != $sidebar_args['_display'] ) &&is_callable( $widget['_callback'] ) ) {205 if ( is_callable( $widget['_callback'] ) ) { 213 206 ob_start(); 214 207 $args = func_get_args(); 215 208 call_user_func_array( $widget['_callback'], $args ); … … 219 212 $wp_registered_widgets[$widget_id]['callback'] = $wp_registered_widgets[$widget_id]['_callback']; 220 213 unset($wp_registered_widgets[$widget_id]['_callback']); 221 214 222 if ( $widget_title && $widget_title != $sidebar_args['widget_name'])215 if ( $widget_title ) 223 216 $widget_title = sprintf( _c('%1$s: %2$s|1: widget name, 2: widget title' ), $sidebar_args['widget_name'], $widget_title ); 224 217 else 225 218 $widget_title = wp_specialchars( strip_tags( $sidebar_args['widget_name'] ) ); 226 219 227 $sidebar_args['_widget_title'] = $widget_title;228 229 220 if ( empty($sidebar_args['_display']) || 'template' != $sidebar_args['_display'] ) 230 221 echo $sidebar_args['before_widget']; 231 222 ?> 232 <div class="widget-top"> 233 <h4 class="widget-title"><span><?php echo $widget_title ?></span> 223 <h4 class="widget-title"><?php echo $widget_title ?> 234 224 235 225 <?php if ( $edit ) : ?> 236 226 237 <a class="widget-action widget-control-edit" href="<?php echo clean_url( remove_query_arg( array( 'edit', 'key' )) ); ?>"><?php _e('Cancel'); ?></a>227 <a class="widget-action widget-control-edit" href="<?php echo remove_query_arg( array( 'edit', 'key' ) ); ?>"><?php _e('Cancel'); ?></a> 238 228 239 229 <?php else : ?> 240 230 … … 242 232 243 233 <?php endif; ?> 244 234 245 <br class="clear" />235 </h4> 246 236 247 </h4></div>248 249 237 <div class="widget-control"<?php if ( $edit ) echo ' style="display: block;"'; ?>> 250 238 <!--allen's change begins--> 251 239 <?php 240 global $wpdb,$post,$wp_registered_widget_controls; 252 241 if ( $control ) 253 242 call_user_func_array( $control['callback'], $control['params'] ); 254 243 else … … 257 246 258 247 <input type="hidden" name="widget-id[]" value="<?php echo $id_format; ?>" /> 259 248 <input type="hidden" class="widget-width" value="<?php echo $control['width']; ?>" /> 249 <?php 250 $widget_display_options=get_option('widget_display_option'); 251 $widget_dipslay_array=array_keys((array)$widget_display_options); 252 foreach($widget_dipslay_array as $widget_display) { 253 $display_checked[$widget_display]="checked='checked'"; 254 } 255 foreach ((array)$widget_display_options as $widget_display_key=>$widget_display_on) { 256 if (!is_array($widget_display_options[$id_format.'-display'])) { 257 $all_checked='1'; 258 }else{ 259 $all_checked='0'; 260 } 261 if (($widget_display_key==$id_format.'-display') && (!$all_checked)) { 262 if (is_array($widget_display_options[$widget_display_key]['page_id'])) 263 $widget_dipslay_pages=array_keys($widget_display_options[$widget_display_key]['page_id']); 264 if (is_array($widget_display_options[$widget_display_key]['post_id'])) 265 $widget_dipslay_posts=array_keys($widget_display_options[$widget_display_key]['post_id']); 266 } 267 } 268 ?> 269 <p><label for="<?php echo $id_format; ?>-title"><?php _e('Display on:'); ?> </label><br> 270 <input <?php echo $display_checked[$id_format."-display-frontpage"];?> id="<?php echo $id_format; ?>-display-frontpage" name="<?php echo $id_format; ?>-display-frontpage" type="checkbox" /><label for="<?php echo $id_format; ?>-display-frontpage"><?php _e('Front Page'); ?></label><br> 271 <input <?php echo $display_checked[$id_format."-display-category"];?> id="<?php echo $id_format; ?>-display-category" name="<?php echo $id_format; ?>-display-category" type="checkbox" /><label for="<?php echo $id_format; ?>-display-category"><?php _e('Category'); ?></label><br> 272 <input <?php echo $display_checked[$id_format."-display-archive"];?> id="<?php echo $id_format; ?>-display-archive" name="<?php echo $id_format; ?>-display-archive" type="checkbox" /><label for="<?php echo $id_format; ?>-display-archive"><?php _e('Archives'); ?></label><br> 273 <input <?php echo $display_checked[$id_format."-display-search"];?> id="<?php echo $id_format; ?>-display-search" name="<?php echo $id_format; ?>-display-search" type="checkbox" /><label for="<?php echo $id_format; ?>-display-search"><?php _e('Search Results'); ?></label><br> 274 <?php _e('Static pages'); ?><br> 260 275 276 <?php 277 // echo ("<pre>".print_r(get_option("widget_display_option"),1)."</pre>"); 278 $type='page'; 279 $posts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'page' ORDER BY menu_order"); 280 ?> 281 <div id="<?php echo($type); ?>-ids" class="checkbox-list" style="height:100px;overflow:auto;border:1px solid #999999;background-color:white;padding:0 0 0 3px;margin:-3px 0 3px 0px;"> 282 <a style="cursor:pointer;" onclick="jQuery('input[@id^=\'display-<?php echo($type); ?>-<?php echo $id_format; ?>-id-ids\'][@type=\'checkbox\']').each(function() {this.checked = true; });">Check All</a> 283 | 284 <a style="cursor:pointer;" onclick="jQuery('input[@id^=\'display-<?php echo($type); ?>-<?php echo $id_format; ?>-id-ids\'][@type=\'checkbox\']').each(function() {this.checked = false; });">Uncheck All</a> 285 <?php foreach($posts as $post): 286 if (is_array($widget_dipslay_pages)) { 287 if ($all_checked=='1') { 288 $checked="checked='checked'"; 289 } else { 290 if (in_array($post->ID,$widget_dipslay_pages)) 291 $checked="checked='checked'"; 292 else 293 $checked=""; 294 } 295 } 296 ?> 297 298 <p><input <?php echo $checked ?> id="display-<?php echo($type); ?>-<?php echo $id_format; ?>-id-ids-<?php echo($post->ID); ?>" name="<?php echo $id_format; ?>-display[<?php echo($type); ?>_id][<?php echo($post->ID); ?>]" type="checkbox"<?php checked($module->display[$type . '_id']['ids'][$post->ID], true); ?> /> <label for="display-<?php echo($type); ?>-id-ids-<?php echo($post->ID); ?>"><?php the_title(); ?></label></p> 299 <?php endforeach; ?> 300 </div> 301 <?php _e('Single posts'); ?><br> 302 <?php 303 $type='post'; 304 $posts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_type != 'page' ORDER BY post_date_gmt DESC"); 305 306 ?> 307 <div id="<?php echo($type); ?>-ids" class="checkbox-list" style="height:100px;overflow:auto;border:1px solid #999999;background-color:white;padding:0 0 0 3px;margin:3px 0 3px 0px;"> 308 <a style="cursor:pointer;" onclick="jQuery('input[@id^=\'display-<?php echo($type); ?>-<?php echo $id_format; ?>-id-ids\'][@type=\'checkbox\']').each(function() {this.checked = true; });">Check All</a> 309 | 310 <a style="cursor:pointer;" onclick="jQuery('input[@id^=\'display-<?php echo($type); ?>-<?php echo $id_format; ?>-id-ids\'][@type=\'checkbox\']').each(function() {this.checked = false; });">Uncheck All</a> 311 <?php foreach($posts as $post): 312 if (is_array($widget_dipslay_posts)) { 313 if ($all_checked=='1') { 314 $checked=""; 315 } else { 316 if (in_array($post->ID,$widget_dipslay_posts)) 317 $checked="checked='checked'"; 318 else 319 $checked=""; 320 } 321 } 322 323 // 324 325 ?> 326 <p><input <?php echo $checked;?> id="display-<?php echo($type); ?>-<?php echo $id_format; ?>-id-ids-<?php echo($post->ID); ?>" name="<?php echo $id_format; ?>-display[<?php echo($type); ?>_id][<?php echo($post->ID); ?>]" type="checkbox"<?php checked($module->display[$type . '_id']['ids'][$post->ID], true); ?> /> <label for="display-<?php echo($type); ?>-id-ids-<?php echo($post->ID); ?>"><?php the_title(); ?></label></p> 327 <?php endforeach; ?> 328 </div> 329 </p> 330 <!--allen's change ends--> 261 331 <div class="widget-control-actions"> 262 332 263 333 <?php if ( $control ) : ?> … … 282 352 if ( false === $end = strpos( $string, '%END_OF_TITLE%' ) ) 283 353 return ''; 284 354 $string = substr( $string, $beg + 14 , $end - $beg - 14); 285 $string = str_replace( ' ', ' ', $string ); 286 return trim( wp_specialchars( strip_tags( $string ) ) ); 355 return wp_specialchars( strip_tags( $string ) ); 287 356 } 288 357 289 ?> 358 ?> 359 No newline at end of file -
wp-admin/widgets.php
7 7 wp_die( __( 'Cheatin’ uh?' )); 8 8 9 9 wp_enqueue_script( array( 'wp-lists', 'admin-widgets' ) ); 10 wp_admin_css( 'widgets' );11 10 12 11 do_action( 'sidebar_admin_setup' ); 13 12 14 13 $title = __( 'Widgets' ); 15 14 $parent_file = 'themes.php'; 16 15 16 add_action( 'admin_head', 'widget_css' ); 17 function widget_css() { 18 wp_admin_css( 'css/widgets' ); 19 } 20 17 21 // $sidebar = What sidebar are we editing? 18 22 if ( isset($_GET['sidebar']) && isset($wp_registered_sidebars[$_GET['sidebar']]) ) { 19 23 $sidebar = attribute_escape( $_GET['sidebar'] ); 20 24 } elseif ( is_array($wp_registered_sidebars) && !empty($wp_registered_sidebars) ) { 21 25 // By default we look at the first defined sidebar 22 $sidebar = array_shift( $keys =array_keys($wp_registered_sidebars) );26 $sidebar = array_shift( array_keys($wp_registered_sidebars) ); 23 27 } else { 24 28 // If no sidebars, die. 25 29 require_once( 'admin-header.php' ); … … 52 56 // We're updating a sidebar 53 57 if ( $http_post && isset($sidebars_widgets[$_POST['sidebar']]) ) { 54 58 check_admin_referer( 'edit-sidebar_' . $_POST['sidebar'] ); 55 59 $temp_display_keys=array_keys($_POST); 60 foreach($temp_display_keys as $name => $key) { 61 if (preg_match(':display:',$key)) { 62 $display_info[$key]=$_POST[$key]; 63 } 64 } 65 update_option('widget_display_option',$display_info); 56 66 /* Hack #1 57 67 * The widget_control is overloaded. It updates the widget's options AND echoes out the widget's HTML form. 58 68 * Since we want to update before sending out any headers, we have to catch it with an output buffer, … … 92 102 exit; 93 103 } 94 104 95 96 97 98 105 // What widget (if any) are we editing 99 106 $edit_widget = -1; 100 107 … … 135 142 136 143 <ul class="widget-control-list"> 137 144 <li class="widget-list-control-item"> 138 <div class="widget-top">139 145 <h4 class="widget-title"><?php echo $control['name']; ?></h4> 140 </div>141 146 <div class="widget-control" style="display: block;"> 142 147 <?php 143 148 call_user_func_array( $control_callback, $control['params'] ); … … 235 240 236 241 <h2><?php _e( 'Widgets' ); ?></h2> 237 242 <p id="widget-search"> 238 <label class="hidden" for="widget-search-input"><?php _e( 'Search Widgets' ); ?>:</label>239 243 <input type="text" id="widget-search-input" name="s" value="<?php echo attribute_escape( $widget_search ); ?>" /> 240 244 <input type="submit" class="button" value="<?php _e( 'Search Widgets' ); ?>" /> 241 245 </p> 242 246 243 247 <div class="widget-liquid-left-holder"> 244 248 <div id="available-widgets-filter" class="widget-liquid-left"> 245 <h3>< label for="show"><?php _e('Available Widgets'); ?></label></h3>249 <h3><?php _e('Available Widgets'); ?></h3> 246 250 <div class="nav"> 247 <select name="show" id="show">251 <select name="show"> 248 252 <?php foreach ( $show_values as $show_value => $show_text ) : $show_value = attribute_escape( $show_value ); ?> 249 253 <option value='<?php echo $show_value; ?>'<?php selected( $show_value, $show ); ?>><?php echo wp_specialchars( $show_text ); ?></option> 250 254 <?php endforeach; ?> … … 258 262 </div> 259 263 260 264 <div id="available-sidebars" class="widget-liquid-right"> 261 <h3>< label for="sidebar-selector"><?php _e('Current Widgets'); ?></label></h3>265 <h3><?php _e('Current Widgets'); ?></h3> 262 266 263 267 <div class="nav"> 264 268 <select id="sidebar-selector" name="sidebar"> … … 318 322 </form> 319 323 320 324 </div> 321 322 325 <?php do_action( 'sidebar_admin_page' ); ?> 323 324 <br class="clear" /> 325 326 <?php require_once( 'admin-footer.php' ); ?> 327 326 <?php require_once( 'admin-footer.php' ); ?> 327 No newline at end of file -
wp-includes/widgets.php
95 95 function wp_register_sidebar_widget($id, $name, $output_callback, $options = array()) { 96 96 global $wp_registered_widgets; 97 97 98 $id = strtolower($id);99 100 98 if ( empty($output_callback) ) { 101 99 unset($wp_registered_widgets[$id]); 102 100 return; … … 166 164 */ 167 165 function wp_register_widget_control($id, $name, $control_callback, $options = array()) { 168 166 global $wp_registered_widget_controls; 169 170 $id = strtolower($id);171 167 172 168 if ( empty($control_callback) ) { 173 169 unset($wp_registered_widget_controls[$id]); … … 202 198 } 203 199 204 200 function dynamic_sidebar($index = 1) { 205 global $wp_registered_sidebars, $wp_registered_widgets ;206 201 global $wp_registered_sidebars, $wp_registered_widgets,$wp_query; 202 207 203 if ( is_int($index) ) { 208 204 $index = "sidebar-$index"; 209 205 } else { … … 215 211 } 216 212 } 217 213 } 218 219 214 $sidebars_widgets = wp_get_sidebars_widgets(); 220 221 215 if ( empty($wp_registered_sidebars[$index]) || !array_key_exists($index, $sidebars_widgets) || !is_array($sidebars_widgets[$index]) || empty($sidebars_widgets[$index]) ) 222 216 return false; 223 217 … … 229 223 array( array_merge( $sidebar, array('widget_id' => $id, 'widget_name' => $wp_registered_widgets[$id]['name']) ) ), 230 224 (array) $wp_registered_widgets[$id]['params'] 231 225 ); 232 226 227 228 // allen's change begins 229 $widget_display_options=get_option('widget_display_option'); 230 $display_registered_widgets = $sidebars_widgets[$index]; 231 232 if (is_front_page()) 233 $current_page='frontpage'; 234 else if ((is_home()) && (!is_front_page)) 235 $current_page='blog'; 236 else if(is_category()) 237 $current_page='category'; 238 else if(is_archive()) 239 $current_page='archive'; 240 else if(is_search()) 241 $current_page='search'; 242 else if(is_page()) { 243 $current_page='pages'; 244 $display_id=$wp_query->get_queried_object_id(); 245 } else if(is_tag()) { 246 $current_page='tag'; 247 } else if(is_single()) { 248 $current_page='post'; 249 $display_id=$wp_query->get_queried_object_id(); 250 } 251 if (array_key_exists($id."-display-".$current_page, (array)$widget_display_options)){ 252 $display='1'; 253 } else { 254 $display='0'; 255 } 256 if (($current_page=='pages') && ($display_id!='')) { 257 $dispaly_pages=$widget_display_options[$id."-display"]['page_id']; 258 if (is_array($dispaly_pages)){ 259 if (array_key_exists($display_id,$dispaly_pages)) { 260 $display='1'; 261 } else { 262 $display='0'; 263 } 264 } 265 } 266 267 if (($current_page=='post') && ($display_id!='')) { 268 // exit("<pre>".print_r($widget_display_options[$id."-display"]['post_id'],1)."</pre>"); 269 $dispaly_pages=$widget_display_options[$id."-display"]['post_id']; 270 if (is_array($dispaly_pages)){ 271 if (array_key_exists($display_id, (array)$dispaly_pages)) { 272 $display='1'; 273 } else { 274 $display='0'; 275 } 276 } else { 277 $display='0'; 278 } 279 } 280 281 // allen's change ends 233 282 // Substitute HTML id and class attributes into before_widget 234 283 $classname_ = ''; 235 284 foreach ( (array) $wp_registered_widgets[$id]['classname'] as $cn ) { … … 242 291 $params[0]['before_widget'] = sprintf($params[0]['before_widget'], $id, $classname_); 243 292 244 293 $params = apply_filters( 'dynamic_sidebar_params', $params ); 294 295 if ((!is_admin()) && !$display){ 296 297 } else { 298 $callback = $wp_registered_widgets[$id]['callback']; 299 if ( is_callable($callback) ) { 300 call_user_func_array($callback, $params); 301 $did_one = true; 302 } 303 } 245 304 246 $callback = $wp_registered_widgets[$id]['callback'];247 248 if ( is_callable($callback) ) {249 call_user_func_array($callback, $params);250 $did_one = true;251 }252 305 } 253 306 254 307 return $did_one; … … 310 363 $_sidebars_widgets[$index][$i] = $id; 311 364 continue; 312 365 } 313 314 $found = false;315 316 foreach ( $wp_registered_widgets as $widget_id => $widget ) {317 if ( strtolower($widget['name']) == strtolower($name) ) {318 $_sidebars_widgets[$index][$i] = $widget['id'];319 $found = true;320 break;321 } elseif ( sanitize_title($widget['name']) == sanitize_title($name) ) {322 $_sidebars_widgets[$index][$i] = $widget['id'];323 $found = true;324 break;325 }326 }327 328 if ( $found )329 continue;330 331 366 unset($_sidebars_widgets[$index][$i]); 332 367 } 333 368 $_sidebars_widgets['array_version'] = 2; … … 385 420 extract( $args ); 386 421 $options = get_option( 'widget_pages' ); 387 422 388 $title = empty( $options['title'] ) ? __( 'Pages' ) : apply_filters('widget_title', $options['title']);423 $title = empty( $options['title'] ) ? __( 'Pages' ) : $options['title']; 389 424 $sortby = empty( $options['sortby'] ) ? 'menu_order' : $options['sortby']; 390 425 $exclude = empty( $options['exclude'] ) ? '' : $options['exclude']; 391 426 … … 450 485 451 486 function wp_widget_links($args) { 452 487 extract($args, EXTR_SKIP); 453 454 $before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget); 455 wp_list_bookmarks(apply_filters('widget_links_args', array( 488 wp_list_bookmarks(array( 456 489 'title_before' => $before_title, 'title_after' => $after_title, 457 490 'category_before' => $before_widget, 'category_after' => $after_widget, 458 491 'show_images' => true, 'class' => 'linkcat widget' 459 )) );492 )); 460 493 } 461 494 462 495 function wp_widget_search($args) { … … 465 498 <?php echo $before_widget; ?> 466 499 <form id="searchform" method="get" action="<?php bloginfo('home'); ?>"> 467 500 <div> 468 <label class="hidden" for="s"><?php _e('Search for:'); ?></label>469 501 <input type="text" name="s" id="s" size="15" /><br /> 470 502 <input type="submit" value="<?php echo attribute_escape(__('Search')); ?>" /> 471 503 </div> … … 479 511 $options = get_option('widget_archives'); 480 512 $c = $options['count'] ? '1' : '0'; 481 513 $d = $options['dropdown'] ? '1' : '0'; 482 $title = empty($options['title']) ? __('Archives') : apply_filters('widget_title', $options['title']);514 $title = empty($options['title']) ? __('Archives') : $options['title']; 483 515 484 516 echo $before_widget; 485 517 echo $before_title . $title . $after_title; … … 527 559 function wp_widget_meta($args) { 528 560 extract($args); 529 561 $options = get_option('widget_meta'); 530 $title = empty($options['title']) ? __('Meta') : apply_filters('widget_title', $options['title']);562 $title = empty($options['title']) ? __('Meta') : $options['title']; 531 563 ?> 532 564 <?php echo $before_widget; ?> 533 565 <?php echo $before_title . $title . $after_title; ?> … … 561 593 function wp_widget_calendar($args) { 562 594 extract($args); 563 595 $options = get_option('widget_calendar'); 564 $title = apply_filters('widget_title', $options['title']);596 $title = $options['title']; 565 597 if ( empty($title) ) 566 598 $title = ' '; 567 599 echo $before_widget . $before_title . $title . $after_title; … … 570 602 echo '</div>'; 571 603 echo $after_widget; 572 604 } 605 573 606 function wp_widget_calendar_control() { 574 607 $options = $newoptions = get_option('widget_calendar'); 575 608 if ( $_POST["calendar-submit"] ) { 576 609 $newoptions['title'] = strip_tags(stripslashes($_POST["calendar-title"])); 610 $newoptions['displayon'] = $_POST['calendar-display-frontpage']; 577 611 } 578 612 if ( $options != $newoptions ) { 579 613 $options = $newoptions; … … 581 615 } 582 616 $title = attribute_escape($options['title']); 583 617 ?> 584 <p><label for="calendar-title"><?php _e('Title:'); ?> <input class="widefat" id="calendar-title" name="calendar-title" type="text" value="<?php echo $title; ?>" /></label></p>585 <input type="hidden" id="calendar-submit" name="calendar-submit" value="1" />618 <p><label for="calendar-title"><?php _e('Title:'); ?> <input class="widefat" id="calendar-title" name="calendar-title" type="text" value="<?php echo $title; ?>" /></label></p> 619 <input type="hidden" id="calendar-submit" name="calendar-submit" value="1" /> 586 620 <?php 587 621 } 588 622 … … 598 632 if ( !isset($options[$number]) ) 599 633 return; 600 634 601 $title = apply_filters('widget_title', $options[$number]['title']);635 $title = $options[$number]['title']; 602 636 $text = apply_filters( 'widget_text', $options[$number]['text'] ); 603 637 ?> 604 638 <?php echo $before_widget; ?> … … 639 673 } 640 674 641 675 foreach ( (array) $_POST['widget-text'] as $widget_number => $widget_text ) { 642 if ( !isset($widget_text['text']) && isset($options[$widget_number]) ) // user clicked cancel643 continue;644 676 $title = strip_tags(stripslashes($widget_text['title'])); 645 677 if ( current_user_can('unfiltered_html') ) 646 678 $text = stripslashes( $widget_text['text'] ); … … 665 697 <p> 666 698 <input class="widefat" id="text-title-<?php echo $number; ?>" name="widget-text[<?php echo $number; ?>][title]" type="text" value="<?php echo $title; ?>" /> 667 699 <textarea class="widefat" rows="16" cols="20" id="text-text-<?php echo $number; ?>" name="widget-text[<?php echo $number; ?>][text]"><?php echo $text; ?></textarea> 668 <input type="hidden" name="widget-text[<?php echo $number; ?>][submit]" value="1" />700 <input type="hidden" id="text-submit-<?php echo $number; ?>" name="text-submit-<?php echo $number; ?>" value="1" /> 669 701 </p> 670 702 <?php 671 703 } … … 710 742 $h = $options[$number]['hierarchical'] ? '1' : '0'; 711 743 $d = $options[$number]['dropdown'] ? '1' : '0'; 712 744 713 $title = empty($options[$number]['title']) ? __('Categories') : apply_filters('widget_title', $options[$number]['title']);745 $title = empty($options[$number]['title']) ? __('Categories') : $options[$number]['title']; 714 746 715 747 echo $before_widget; 716 748 echo $before_title . $title . $after_title; 717 749 718 $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h);750 $cat_args = "orderby=name&show_count={$c}&hierarchical={$h}"; 719 751 720 752 if ( $d ) { 721 $cat_args['show_option_none'] = __('Select Category'); 722 wp_dropdown_categories($cat_args); 753 wp_dropdown_categories($cat_args . '&show_option_none= ' . __('Select Category')); 723 754 ?> 724 755 725 756 <script type='text/javascript'> … … 738 769 } else { 739 770 ?> 740 771 <ul> 741 <?php 742 $cat_args['title_li'] = ''; 743 wp_list_categories($cat_args); 744 ?> 772 <?php wp_list_categories($cat_args . '&title_li='); ?> 745 773 </ul> 746 774 <?php 747 775 } … … 781 809 } 782 810 783 811 foreach ( (array) $_POST['widget-categories'] as $widget_number => $widget_cat ) { 784 if ( !isset($widget_cat['title']) && isset($options[$widget_number]) ) // user clicked cancel785 continue;786 812 $title = trim(strip_tags(stripslashes($widget_cat['title']))); 787 813 $count = isset($widget_cat['count']); 788 814 $hierarchical = isset($widget_cat['hierarchical']); … … 831 857 </label> 832 858 </p> 833 859 834 <input type="hidden" name="widget-categories[<?php echo $number; ?>][submit]" value="1" />860 <input type="hidden" id="categories-submit-<?php echo $number; ?>" name="categories-submit-<?php echo $number; ?>" value="1" /> 835 861 <?php 836 862 } 837 863 … … 891 917 } 892 918 893 919 function wp_widget_recent_entries($args) { 894 if ( '%BEG_OF_TITLE%' != $args['before_title'] ) { 895 if ( $output = wp_cache_get('widget_recent_entries', 'widget') ) 896 return print($output); 897 ob_start(); 898 } 920 if ( $output = wp_cache_get('widget_recent_entries', 'widget') ) 921 return print($output); 899 922 923 ob_start(); 900 924 extract($args); 901 925 $options = get_option('widget_recent_entries'); 902 $title = empty($options['title']) ? __('Recent Posts') : apply_filters('widget_title', $options['title']);926 $title = empty($options['title']) ? __('Recent Posts') : $options['title']; 903 927 if ( !$number = (int) $options['number'] ) 904 928 $number = 10; 905 929 else if ( $number < 1 ) … … 907 931 else if ( $number > 15 ) 908 932 $number = 15; 909 933 910 $r = new WP_Query( array('showposts' => $number, 'what_to_show' => 'posts', 'nopaging' => 0, 'post_status' => 'publish'));934 $r = new WP_Query("showposts=$number&what_to_show=posts&nopaging=0&post_status=publish"); 911 935 if ($r->have_posts()) : 912 936 ?> 913 937 <?php echo $before_widget; ?> … … 921 945 <?php 922 946 wp_reset_query(); // Restore global post data stomped by the_post(). 923 947 endif; 924 925 if ( '%BEG_OF_TITLE%' != $args['before_title'] ) 926 wp_cache_add('widget_recent_entries', ob_get_flush(), 'widget'); 948 wp_cache_add('widget_recent_entries', ob_get_flush(), 'widget'); 927 949 } 928 950 929 951 function wp_flush_widget_recent_entries() { … … 964 986 global $wpdb, $comments, $comment; 965 987 extract($args, EXTR_SKIP); 966 988 $options = get_option('widget_recent_comments'); 967 $title = empty($options['title']) ? __('Recent Comments') : apply_filters('widget_title', $options['title']);989 $title = empty($options['title']) ? __('Recent Comments') : $options['title']; 968 990 if ( !$number = (int) $options['number'] ) 969 991 $number = 5; 970 992 else if ( $number < 1 ) … … 1070 1092 $title = $desc; 1071 1093 if ( empty($title) ) 1072 1094 $title = __('Unknown Feed'); 1073 $title = apply_filters('widget_title', $title );1074 1095 $url = clean_url(strip_tags($url)); 1075 1096 if ( file_exists(dirname(__FILE__) . '/rss.png') ) 1076 $icon = str_replace(ABSPATH, site_url() .'/', dirname(__FILE__)) . '/rss.png';1097 $icon = str_replace(ABSPATH, get_option('siteurl').'/', dirname(__FILE__)) . '/rss.png'; 1077 1098 else 1078 $icon = includes_url('images/rss.png');1099 $icon = get_option('siteurl').'/wp-includes/images/rss.png'; 1079 1100 $title = "<a class='rsswidget' href='$url' title='" . attribute_escape(__('Syndicate this content')) ."'><img style='background:orange;color:white;border:none;' width='14' height='14' src='$icon' alt='RSS' /></a> <a class='rsswidget' href='$link' title='$desc'>$title</a>"; 1080 1101 1081 1102 echo $before_widget; … … 1150 1171 1151 1172 if ( $date ) { 1152 1173 if ( $date_stamp = strtotime( $date ) ) 1153 $date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date_stamp ) . '</span>';1174 $date = '<span class="rss-date">' . gmdate( get_option( 'date_format' ), $date_stamp ) . '</span>'; 1154 1175 else 1155 1176 $date = ''; 1156 1177 } … … 1208 1229 } 1209 1230 1210 1231 foreach( (array) $_POST['widget-rss'] as $widget_number => $widget_rss ) { 1211 if ( !isset($widget_rss['url']) && isset($options[$widget_number]) ) // user clicked cancel1212 continue;1213 1232 $widget_rss = stripslashes_deep( $widget_rss ); 1214 1233 $url = sanitize_url(strip_tags($widget_rss['url'])); 1215 1234 $options[$widget_number] = wp_widget_rss_process( $widget_rss, !isset($urls[$url]) ); … … 1294 1313 <?php _e('Display item date?'); ?> 1295 1314 </label> 1296 1315 </p> 1297 <input type="hidden" name="widget-rss[<?php echo $number; ?>][submit]" value="1" />1316 <input type="hidden" id="rss-submit-<?php echo $number; ?>" name="rss-submit-<?php echo $number; ?>" value="1" /> 1298 1317 <?php 1299 1318 endif; 1300 1319 foreach ( array_keys($default_inputs) as $input ) : … … 1363 1382 function wp_widget_tag_cloud($args) { 1364 1383 extract($args); 1365 1384 $options = get_option('widget_tag_cloud'); 1366 $title = empty($options['title']) ? __('Tags') : apply_filters('widget_title', $options['title']);1385 $title = empty($options['title']) ? __('Tags') : $options['title']; 1367 1386 1368 1387 echo $before_widget; 1369 1388 echo $before_title . $title . $after_title; … … 1392 1411 <?php 1393 1412 } 1394 1413 1414 1395 1415 function wp_widgets_init() { 1396 1416 if ( !is_blog_installed() ) 1397 1417 return; … … 1404 1424 wp_register_sidebar_widget('calendar', __('Calendar'), 'wp_widget_calendar', $widget_ops); 1405 1425 wp_register_widget_control('calendar', __('Calendar'), 'wp_widget_calendar_control' ); 1406 1426 1427 1407 1428 $widget_ops = array('classname' => 'widget_archive', 'description' => __( "A monthly archive of your blog's posts") ); 1408 1429 wp_register_sidebar_widget('archives', __('Archives'), 'wp_widget_archives', $widget_ops); 1409 1430 wp_register_widget_control('archives', __('Archives'), 'wp_widget_archives_control' ); … … 1500 1521 1501 1522 foreach ( (array) $_POST['widget-many'] as $widget_number => $widget_many_instance ) { 1502 1523 // compile data from $widget_many_instance 1503 if ( !isset($widget_many_instance['something']) && isset($options[$widget_number]) ) // user clicked cancel1504 continue;1505 1524 $something = wp_specialchars( $widget_many_instance['something'] ); 1506 1525 $options[$widget_number] = array( 'something' => $something ); // Even simple widgets should store stuff in array, rather than in scalar 1507 1526 } 1508 1527 1509 update_option('widget_ many', $options);1528 update_option('widget_text', $options); 1510 1529 1511 1530 $updated = true; // So that we don't go through this more than once 1512 1531 } … … 1525 1544 ?> 1526 1545 <p> 1527 1546 <input class="widefat" id="widget-many-something-<?php echo $number; ?>" name="widget-many[<?php echo $number; ?>][something]" type="text" value="<?php echo $data; ?>" /> 1528 <input type="hidden" id="widget-many-submit-<?php echo $number; ?>" name="widget-many [<?php echo $number; ?>][submit]" value="1" />1547 <input type="hidden" id="widget-many-submit-<?php echo $number; ?>" name="widget-many-<?php echo $number; ?>" value="1" /> 1529 1548 </p> 1530 1549 <?php 1531 1550 } … … 1548 1567 // $id should look like {$id_base}-{$o} 1549 1568 $id = "many-$o"; // Never never never translate an id 1550 1569 $registered = true; 1551 wp_register_sidebar_widget( $id, $name, 'w idget_many', $widget_ops, array( 'number' => $o ) );1552 wp_register_widget_control( $id, $name, 'w idget_many_control', $control_ops, array( 'number' => $o ) );1570 wp_register_sidebar_widget( $id, $name, 'wp_widget_text', $widget_ops, array( 'number' => $o ) ); 1571 wp_register_widget_control( $id, $name, 'wp_widget_text_control', $control_ops, array( 'number' => $o ) ); 1553 1572 } 1554 1573 1555 1574 // If there are none, we register the widget's existance with a generic template … … 1564 1583 1565 1584 */ 1566 1585 1567 ?> 1586 ?> 1587 No newline at end of file