diff --git wp-includes/widgets.php wp-includes/widgets.php
index f3ca44a..45bb43e 100644
|
|
|
class WP_Widget { |
| 122 | 122 | return 'widget-' . $this->id_base . '-' . $this->number . '-' . $field_name; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | | // Private Functions. Don't worry about these. |
| 126 | | |
| | 125 | /** |
| | 126 | * Register all widget instances of this widget class. |
| | 127 | * |
| | 128 | * @access private |
| | 129 | */ |
| 127 | 130 | public function _register() { |
| 128 | 131 | $settings = $this->get_settings(); |
| 129 | 132 | $empty = true; |
| … |
… |
class WP_Widget { |
| 146 | 149 | } |
| 147 | 150 | } |
| 148 | 151 | |
| | 152 | /** |
| | 153 | * Set the internal order number for the widget instance. |
| | 154 | * |
| | 155 | * @access private |
| | 156 | * |
| | 157 | * @param int $number The unique order number of this widget instance |
| | 158 | * compared to other instances of the same class. |
| | 159 | */ |
| 149 | 160 | public function _set($number) { |
| 150 | 161 | $this->number = $number; |
| 151 | 162 | $this->id = $this->id_base . '-' . $number; |
| … |
… |
class WP_Widget { |
| 362 | 373 | return $return; |
| 363 | 374 | } |
| 364 | 375 | |
| 365 | | /** Helper function: Registers a single instance. */ |
| | 376 | /** |
| | 377 | * Register an instance of the widget class. |
| | 378 | * |
| | 379 | * @access private |
| | 380 | * |
| | 381 | * @param integer $number The unique order number of this widget instance |
| | 382 | * compared to other instances of the same class. |
| | 383 | */ |
| 366 | 384 | public function _register_one($number = -1) { |
| 367 | 385 | wp_register_sidebar_widget( $this->id, $this->name, $this->_get_display_callback(), $this->widget_options, array( 'number' => $number ) ); |
| 368 | 386 | _register_widget_update_callback( $this->id_base, $this->_get_update_callback(), $this->control_options, array( 'number' => -1 ) ); |
| 369 | 387 | _register_widget_form_callback( $this->id, $this->name, $this->_get_form_callback(), $this->control_options, array( 'number' => $number ) ); |
| 370 | 388 | } |
| 371 | 389 | |
| | 390 | /** |
| | 391 | * Save the settings for all instances of the widget class. |
| | 392 | * |
| | 393 | * @param array $settings Multi-dimensional array of widget instance settings. |
| | 394 | */ |
| 372 | 395 | public function save_settings($settings) { |
| 373 | 396 | $settings['_multiwidget'] = 1; |
| 374 | 397 | update_option( $this->option_name, $settings ); |
| 375 | 398 | } |
| 376 | 399 | |
| | 400 | /** |
| | 401 | * Get the settings for all instances of the widget class. |
| | 402 | * |
| | 403 | * @return array Multi-dimensional array of widget instance settings. |
| | 404 | */ |
| 377 | 405 | public function get_settings() { |
| | 406 | |
| 378 | 407 | $settings = get_option($this->option_name); |
| 379 | 408 | |
| 380 | 409 | if ( false === $settings && isset($this->alt_option_name) ) |
| … |
… |
class WP_Widget_Factory { |
| 407 | 436 | add_action( 'widgets_init', array( $this, '_register_widgets' ), 100 ); |
| 408 | 437 | } |
| 409 | 438 | |
| | 439 | /** |
| | 440 | * Register a widget class. |
| | 441 | * |
| | 442 | * @param mixed $widget_class A subclass of WP_Widget. |
| | 443 | */ |
| 410 | 444 | public function register($widget_class) { |
| 411 | 445 | $this->widgets[$widget_class] = new $widget_class(); |
| 412 | 446 | } |
| 413 | 447 | |
| | 448 | /** |
| | 449 | * Unregister a widget class. |
| | 450 | * |
| | 451 | * @param mixed $widget_class A subclass of WP_Widget. |
| | 452 | */ |
| 414 | 453 | public function unregister($widget_class) { |
| 415 | 454 | if ( isset($this->widgets[$widget_class]) ) |
| 416 | 455 | unset($this->widgets[$widget_class]); |
| … |
… |
global $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_co |
| 448 | 487 | $wp_registered_sidebars = array(); |
| 449 | 488 | |
| 450 | 489 | /** |
| 451 | | * Stores the registered widgets. |
| | 490 | * Stores instances of widgets. |
| 452 | 491 | * |
| 453 | 492 | * @global array $wp_registered_widgets |
| 454 | 493 | * @since 2.2.0 |
| … |
… |
function unregister_sidebar( $name ) { |
| 683 | 722 | } |
| 684 | 723 | |
| 685 | 724 | /** |
| 686 | | * Register widget for use in sidebars. |
| | 725 | * Register an instance of a widget. |
| 687 | 726 | * |
| 688 | 727 | * The default widget option is 'classname' that can be overridden. |
| 689 | 728 | * |
| … |
… |
function unregister_sidebar( $name ) { |
| 698 | 737 | * @param int|string $id Widget ID. |
| 699 | 738 | * @param string $name Widget display title. |
| 700 | 739 | * @param callback $output_callback Run when widget is called. |
| 701 | | * @param array|string $options Optional. Widget Options. |
| | 740 | * @param array $options { |
| | 741 | * An array of supplementary widget options for the instance. Optional. |
| | 742 | * |
| | 743 | * @type string $classname Classname for the widget's HTML container. |
| | 744 | * Optional. Defaults to the output callback. |
| | 745 | * } |
| 702 | 746 | * @param mixed $params,... Widget parameters to add to widget. |
| 703 | 747 | * @return null Will return if $output_callback is empty after removing widget. |
| 704 | 748 | */ |
| … |
… |
function is_active_sidebar( $index ) { |
| 1202 | 1246 | /* Internal Functions */ |
| 1203 | 1247 | |
| 1204 | 1248 | /** |
| 1205 | | * Retrieve full list of sidebars and their widgets. |
| | 1249 | * Retrieve full list of sidebars and their widget instance IDs. |
| 1206 | 1250 | * |
| 1207 | 1251 | * Will upgrade sidebar widget list, if needed. Will also save updated list, if |
| 1208 | 1252 | * needed. |