Changeset 10798
- Timestamp:
- 03/17/2009 12:59:42 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/widgets.php
r10631 r10798 74 74 $already_done = array(); 75 75 76 foreach ( $wp_registered_widget_ controls as $name => $control ) {76 foreach ( $wp_registered_widget_updates as $name => $control ) { 77 77 if ( in_array( $control['callback'], $already_done ) ) 78 78 continue; -
trunk/wp-includes/default-widgets.php
r10797 r10798 217 217 218 218 $instance = $old_instance; 219 $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') ); 219 220 $instance['title'] = strip_tags($new_instance['title']); 220 221 $instance['count'] = $new_instance['count'] ? 1 : 0; -
trunk/wp-includes/widgets.php
r10795 r10798 17 17 18 18 /** @ignore */ 19 global $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_controls ;19 global $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates; 20 20 21 21 /** … … 42 42 */ 43 43 $wp_registered_widget_controls = array(); 44 $wp_registered_widget_updates = array(); 44 45 45 46 /** … … 153 154 } 154 155 155 function _get_control_callback() { 156 return array(&$this, 'control_callback'); 156 function _get_update_callback() { 157 return array(&$this, 'update_callback'); 158 } 159 160 function _get_form_callback() { 161 return array(&$this, 'form_callback'); 157 162 } 158 163 … … 172 177 } 173 178 174 /** Deal with changed settings and generate the control form.179 /** Deal with changed settings. 175 180 * Do NOT over-ride this function. */ 176 function control_callback( $widget_args = 1 ) {181 function update_callback( $widget_args = 1 ) { 177 182 global $wp_registered_widgets; 178 183 … … 224 229 $this->updated = true; 225 230 } 226 227 // Here we echo out the form 231 } 232 233 /** Generate the control form. 234 * Do NOT over-ride this function. */ 235 function form_callback( $widget_args = 1 ) { 236 if ( is_numeric($widget_args) ) 237 $widget_args = array( 'number' => $widget_args ); 238 239 $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); 240 $all_instances = $this->get_settings(); 241 228 242 if ( -1 == $widget_args['number'] ) { 229 243 // We echo out a form where 'number' can be set later via JS … … 241 255 function _register_one($number = -1) { 242 256 wp_register_sidebar_widget( $this->id, $this->name, $this->_get_display_callback(), $this->widget_options, array( 'number' => $number ) ); 243 wp_register_widget_control( $this->id, $this->name, $this->_get_control_callback(), $this->control_options, array( 'number' => $number ) ); 257 _register_widget_update_callback( $this->id, $this->name, $this->_get_update_callback(), $this->control_options, array( 'number' => $number ) ); 258 _register_widget_form_callback( $this->id, $this->name, $this->_get_form_callback(), $this->control_options, array( 'number' => $number ) ); 244 259 } 245 260 … … 490 505 */ 491 506 function wp_register_widget_control($id, $name, $control_callback, $options = array()) { 492 global $wp_registered_widget_controls ;507 global $wp_registered_widget_controls, $wp_registered_widget_updates; 493 508 494 509 $id = strtolower($id); … … 496 511 if ( empty($control_callback) ) { 497 512 unset($wp_registered_widget_controls[$id]); 513 unset($wp_registered_widget_updates[$id]); 498 514 return; 499 515 } … … 511 527 'id' => $id, 512 528 'callback' => $control_callback, 529 'params' => array_slice(func_get_args(), 4) 530 ); 531 $widget = array_merge($widget, $options); 532 533 $wp_registered_widget_controls[$id] = $wp_registered_widget_updates[$id] = $widget; 534 } 535 536 function _register_widget_update_callback($id, $name, $update_callback, $options = array()) { 537 global $wp_registered_widget_updates; 538 539 $id = strtolower($id); 540 541 if ( empty($update_callback) ) { 542 unset($wp_registered_widget_updates[$id]); 543 return; 544 } 545 546 if ( isset($wp_registered_widget_updates[$id]) && !did_action( 'widgets_init' ) ) 547 return; 548 549 $defaults = array('width' => 250, 'height' => 200 ); // height is never used 550 $options = wp_parse_args($options, $defaults); 551 $options['width'] = (int) $options['width']; 552 $options['height'] = (int) $options['height']; 553 554 $widget = array( 555 'name' => $name, 556 'id' => $id, 557 'callback' => $update_callback, 558 'params' => array_slice(func_get_args(), 4) 559 ); 560 $widget = array_merge($widget, $options); 561 562 $wp_registered_widget_updates[$id] = $widget; 563 } 564 565 function _register_widget_form_callback($id, $name, $form_callback, $options = array()) { 566 global $wp_registered_widget_controls; 567 568 $id = strtolower($id); 569 570 if ( empty($form_callback) ) { 571 unset($wp_registered_widget_controls[$id]); 572 return; 573 } 574 575 if ( isset($wp_registered_widget_controls[$id]) && !did_action( 'widgets_init' ) ) 576 return; 577 578 $defaults = array('width' => 250, 'height' => 200 ); // height is never used 579 $options = wp_parse_args($options, $defaults); 580 $options['width'] = (int) $options['width']; 581 $options['height'] = (int) $options['height']; 582 583 $widget = array( 584 'name' => $name, 585 'id' => $id, 586 'callback' => $form_callback, 513 587 'params' => array_slice(func_get_args(), 4) 514 588 );
Note: See TracChangeset
for help on using the changeset viewer.