~canonical-sysadmins/wordpress/4.1.3

« back to all changes in this revision

Viewing changes to wp-includes/widgets.php

  • Committer: Nick Moffitt
  • Date: 2015-01-15 11:05:37 UTC
  • mfrom: (1.1.1 wp4-upstream)
  • Revision ID: nick.moffitt@canonical.com-20150115110537-8bp1y42eyg0jsa7c
Tags: 4.1
MergeĀ upstreamĀ versionĀ 4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 */
24
24
class WP_Widget {
25
25
 
26
 
        public $id_base;                        // Root id for all widgets of this type.
27
 
        public $name;                           // Name for this widget type.
28
 
        public $widget_options; // Option array passed to wp_register_sidebar_widget()
29
 
        public $control_options;        // Option array passed to wp_register_widget_control()
30
 
 
31
 
        public $number = false; // Unique ID number of the current instance.
32
 
        public $id = false;             // Unique ID string of the current instance (id_base-number)
33
 
        public $updated = false;        // Set true when we update the data after a POST submit - makes sure we don't do it twice.
 
26
        /**
 
27
         * Root ID for all widgets of this type.
 
28
         *
 
29
         * @since 2.8.0
 
30
         * @access public
 
31
         * @var mixed|string
 
32
         */
 
33
        public $id_base;
 
34
 
 
35
        /**
 
36
         * Name for this widget type.
 
37
         *
 
38
         * @since 2.8.0
 
39
         * @access public
 
40
         * @var string
 
41
         */
 
42
        public $name;
 
43
 
 
44
        /**
 
45
         * Option array passed to {@see wp_register_sidebar_widget()}.
 
46
         *
 
47
         * @since 2.8.0
 
48
         * @access public
 
49
         * @var array
 
50
         */
 
51
        public $widget_options;
 
52
 
 
53
        /**
 
54
         * Option array passed to {@see wp_register_widget_control()}.
 
55
         *
 
56
         * @since 2.8.0
 
57
         * @access public
 
58
         * @var array
 
59
         */
 
60
        public $control_options;
 
61
 
 
62
        /**
 
63
         * Unique ID number of the current instance.
 
64
         *
 
65
         * @since 2.8.0
 
66
         * @access public
 
67
         * @var bool|int
 
68
         */
 
69
        public $number = false;
 
70
 
 
71
        /**
 
72
         * Unique ID string of the current instance (id_base-number).
 
73
         *
 
74
         * @since 2.8.0
 
75
         * @access public
 
76
         * @var bool|string
 
77
         */
 
78
        public $id = false;
 
79
 
 
80
        /**
 
81
         * Whether the widget data has been updated.
 
82
         *
 
83
         * Set to true when the data is updated after a POST submit - ensures it does
 
84
         * not happen twice.
 
85
         *
 
86
         * @since 2.8.0
 
87
         * @access public
 
88
         * @var bool
 
89
         */
 
90
        public $updated = false;
34
91
 
35
92
        // Member functions that you must over-ride.
36
93
 
37
 
        /** Echo the widget content.
 
94
        /**
 
95
         * Echo the widget content.
38
96
         *
39
97
         * Subclasses should over-ride this function to generate their widget code.
40
98
         *
41
 
         * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
42
 
         * @param array $instance The settings for the particular instance of the widget
 
99
         * @since 2.8.0
 
100
         * @access public
 
101
         *
 
102
         * @param array $args     Display arguments including before_title, after_title,
 
103
         *                        before_widget, and after_widget.
 
104
         * @param array $instance The settings for the particular instance of the widget.
43
105
         */
44
 
        public function widget($args, $instance) {
 
106
        public function widget( $args, $instance ) {
45
107
                die('function WP_Widget::widget() must be over-ridden in a sub-class.');
46
108
        }
47
109
 
48
 
        /** Update a particular instance.
49
 
         *
50
 
         * This function should check that $new_instance is set correctly.
51
 
         * The newly calculated value of $instance should be returned.
52
 
         * If "false" is returned, the instance won't be saved/updated.
53
 
         *
54
 
         * @param array $new_instance New settings for this instance as input by the user via form()
55
 
         * @param array $old_instance Old settings for this instance
56
 
         * @return array Settings to save or bool false to cancel saving
 
110
        /**
 
111
         * Update a particular instance.
 
112
         *
 
113
         * This function should check that $new_instance is set correctly. The newly-calculated
 
114
         * value of `$instance` should be returned. If false is returned, the instance won't be
 
115
         * saved/updated.
 
116
         *
 
117
         * @since 2.8.0
 
118
         * @access public
 
119
         *
 
120
         * @param array $new_instance New settings for this instance as input by the user via
 
121
         *                            {@see WP_Widget::form()}.
 
122
         * @param array $old_instance Old settings for this instance.
 
123
         * @return array Settings to save or bool false to cancel saving.
57
124
         */
58
 
        public function update($new_instance, $old_instance) {
 
125
        public function update( $new_instance, $old_instance ) {
59
126
                return $new_instance;
60
127
        }
61
128
 
62
 
        /** Echo the settings update form
63
 
         *
64
 
         * @param array $instance Current settings
 
129
        /**
 
130
         * Output the settings update form.
 
131
         *
 
132
         * @since 2.8.0
 
133
         * @access public
 
134
         *
 
135
         * @param array $instance Current settings.
 
136
         * @return string Default return is 'noform'.
65
137
         */
66
138
        public function form($instance) {
67
139
                echo '<p class="no-options-widget">' . __('There are no options for this widget.') . '</p>';
71
143
        // Functions you'll need to call.
72
144
 
73
145
        /**
74
 
         * PHP5 constructor
75
 
         *
76
 
         * @param string $id_base Optional Base ID for the widget, lower case,
77
 
         * if left empty a portion of the widget's class name will be used. Has to be unique.
78
 
         * @param string $name Name for the widget displayed on the configuration page.
79
 
         * @param array $widget_options Optional Passed to wp_register_sidebar_widget()
80
 
         *       - description: shown on the configuration page
81
 
         *       - classname
82
 
         * @param array $control_options Optional Passed to wp_register_widget_control()
83
 
         *       - width: required if more than 250px
84
 
         *       - height: currently not used but may be needed in the future
 
146
         * PHP5 constructor.
 
147
         *
 
148
         * @since 2.8.0
 
149
         * @access public
 
150
         *
 
151
         * @param string $id_base         Optional Base ID for the widget, lowercase and unique. If left empty,
 
152
         *                                a portion of the widget's class name will be used Has to be unique.
 
153
         * @param string $name            Name for the widget displayed on the configuration page.
 
154
         * @param array  $widget_options  Optional. Widget options. See {@see wp_register_sidebar_widget()} for
 
155
         *                                information on accepted arguments. Default empty array.
 
156
         * @param array  $control_options Optional. Widget control options. See {@see wp_register_widget_control()}
 
157
         *                                for information on accepted arguments. Default empty array.
85
158
         */
86
159
        public function __construct( $id_base, $name, $widget_options = array(), $control_options = array() ) {
87
160
                $this->id_base = empty($id_base) ? preg_replace( '/(wp_)?widget_/', '', strtolower(get_class($this)) ) : strtolower($id_base);
93
166
 
94
167
        /**
95
168
         * PHP4 constructor
 
169
         * 
 
170
         * @param string $id_base
 
171
         * @param string $name
 
172
         * @param array  $widget_options
 
173
         * @param array  $control_options
96
174
         */
97
175
        public function WP_Widget( $id_base, $name, $widget_options = array(), $control_options = array() ) {
98
176
                WP_Widget::__construct( $id_base, $name, $widget_options, $control_options );
111
189
        }
112
190
 
113
191
        /**
114
 
         * Constructs id attributes for use in form() fields
115
 
         *
116
 
         * This function should be used in form() methods to create id attributes for fields to be saved by update()
117
 
         *
118
 
         * @param string $field_name Field name
119
 
         * @return string ID attribute for $field_name
 
192
         * Constructs id attributes for use in {@see WP_Widget::form()} fields.
 
193
         *
 
194
         * This function should be used in form() methods to create id attributes
 
195
         * for fields to be saved by {@see WP_Widget::update()}.
 
196
         *
 
197
         * @since 2.8.0
 
198
         * @access public
 
199
         *
 
200
         * @param string $field_name Field name.
 
201
         * @return string ID attribute for `$field_name`.
120
202
         */
121
 
        public function get_field_id($field_name) {
 
203
        public function get_field_id( $field_name ) {
122
204
                return 'widget-' . $this->id_base . '-' . $this->number . '-' . $field_name;
123
205
        }
124
206
 
125
 
        // Private Functions. Don't worry about these.
126
 
 
 
207
        /**
 
208
         * Register all widget instances of this widget class.
 
209
         *
 
210
         * @since 2.8.0
 
211
         * @access private
 
212
         */
127
213
        public function _register() {
128
214
                $settings = $this->get_settings();
129
215
                $empty = true;
146
232
                }
147
233
        }
148
234
 
 
235
        /**
 
236
         * Set the internal order number for the widget instance.
 
237
         *
 
238
         * @since 2.8.0
 
239
         * @access private
 
240
         *
 
241
         * @param int $number The unique order number of this widget instance compared to other
 
242
         *                    instances of the same class.
 
243
         */
149
244
        public function _set($number) {
150
245
                $this->number = $number;
151
246
                $this->id = $this->id_base . '-' . $number;
164
259
        }
165
260
 
166
261
        /**
167
 
         * Determine if we're in the Customizer; if true, then the object cache gets
168
 
         * suspended and widgets should check this to decide whether they should
169
 
         * store anything persistently to the object cache, to transients, or
170
 
         * anywhere else.
 
262
         * Determine whether the current request is inside the Customizer preview.
 
263
         *
 
264
         * If true -- the current request is inside the Customizer preview, then
 
265
         * the object cache gets suspended and widgets should check this to decide
 
266
         * whether they should store anything persistently to the object cache,
 
267
         * to transients, or anywhere else.
171
268
         *
172
269
         * @since 3.9.0
 
270
         * @access public
173
271
         *
174
 
         * @return bool True if Customizer is on, false if not.
 
272
         * @return bool True if within the Customizer preview, false if not.
175
273
         */
176
274
        public function is_preview() {
177
275
                global $wp_customize;
178
276
                return ( isset( $wp_customize ) && $wp_customize->is_preview() ) ;
179
277
        }
180
278
 
181
 
        /** Generate the actual widget content.
182
 
         *      Just finds the instance and calls widget().
183
 
         *      Do NOT over-ride this function. */
 
279
        /**
 
280
         * Generate the actual widget content (Do NOT override).
 
281
         *
 
282
         * Finds the instance and calls {@see WP_Widget::widget()}.
 
283
         *
 
284
         * @since 2.8.0
 
285
         * @access public
 
286
         *
 
287
         * @param array     $args        Display arguments. See {@see WP_Widget::widget()} for information
 
288
         *                               on accepted arguments.
 
289
         * @param int|array $widget_args {
 
290
         *     Optional. Internal order number of the widget instance, or array of multi-widget arguments.
 
291
         *     Default 1.
 
292
         *
 
293
         *     @type int $number Number increment used for multiples of the same widget.
 
294
         * }
 
295
         */
184
296
        public function display_callback( $args, $widget_args = 1 ) {
185
297
                if ( is_numeric($widget_args) )
186
298
                        $widget_args = array( 'number' => $widget_args );
223
335
        }
224
336
 
225
337
        /**
226
 
         * Deal with changed settings.
227
 
         *
228
 
         * Do NOT over-ride this function.
229
 
         *
230
 
         * @param mixed $deprecated Not used.
 
338
         * Deal with changed settings (Do NOT override).
 
339
         *
 
340
         * @since 2.8.0
 
341
         * @access public
 
342
         *
 
343
         * @param int $deprecated Not used.
231
344
         */
232
345
        public function update_callback( $deprecated = 1 ) {
233
346
                global $wp_registered_widgets;
305
418
        }
306
419
 
307
420
        /**
308
 
         * Generate the control form.
309
 
         *
310
 
         * Do NOT over-ride this function.
 
421
         * Generate the widget control form (Do NOT override).
 
422
         *
 
423
         * @since 2.8.0
 
424
         * @access public
 
425
         *
 
426
         * @param int|array $widget_args Widget instance number or array of widget arguments.
311
427
         */
312
428
        public function form_callback( $widget_args = 1 ) {
313
429
                if ( is_numeric($widget_args) )
362
478
                return $return;
363
479
        }
364
480
 
365
 
        /** Helper function: Registers a single instance. */
366
 
        public function _register_one($number = -1) {
 
481
        /**
 
482
         * Register an instance of the widget class.
 
483
         *
 
484
         * @since 2.8.0
 
485
         * @access private
 
486
         *
 
487
         * @param integer $number Optional. The unique order number of this widget instance
 
488
         *                        compared to other instances of the same class. Default -1.
 
489
         */
 
490
        public function _register_one( $number = -1 ) {
367
491
                wp_register_sidebar_widget(     $this->id, $this->name, $this->_get_display_callback(), $this->widget_options, array( 'number' => $number ) );
368
492
                _register_widget_update_callback( $this->id_base, $this->_get_update_callback(), $this->control_options, array( 'number' => -1 ) );
369
493
                _register_widget_form_callback( $this->id, $this->name, $this->_get_form_callback(), $this->control_options, array( 'number' => $number ) );
370
494
        }
371
495
 
372
 
        public function save_settings($settings) {
 
496
        /**
 
497
         * Save the settings for all instances of the widget class.
 
498
         *
 
499
         * @since 2.8.0
 
500
         * @access public
 
501
         *
 
502
         * @param array $settings Multi-dimensional array of widget instance settings.
 
503
         */
 
504
        public function save_settings( $settings ) {
373
505
                $settings['_multiwidget'] = 1;
374
506
                update_option( $this->option_name, $settings );
375
507
        }
376
508
 
 
509
        /**
 
510
         * Get the settings for all instances of the widget class.
 
511
         *
 
512
         * @since 2.8.0
 
513
         * @access public
 
514
         *
 
515
         * @return array Multi-dimensional array of widget instance settings.
 
516
         */
377
517
        public function get_settings() {
 
518
 
378
519
                $settings = get_option($this->option_name);
379
520
 
380
521
                if ( false === $settings && isset($this->alt_option_name) )
407
548
                add_action( 'widgets_init', array( $this, '_register_widgets' ), 100 );
408
549
        }
409
550
 
410
 
        public function register($widget_class) {
 
551
        /**
 
552
         * Register a widget subclass.
 
553
         *
 
554
         * @since 2.8.0
 
555
         * @access public
 
556
         *
 
557
         * @param string $widget_class The name of a {@see WP_Widget} subclass.
 
558
         */
 
559
        public function register( $widget_class ) {
411
560
                $this->widgets[$widget_class] = new $widget_class();
412
561
        }
413
562
 
414
 
        public function unregister($widget_class) {
 
563
        /**
 
564
         * Un-register a widget subclass.
 
565
         *
 
566
         * @since 2.8.0
 
567
         * @access public
 
568
         *
 
569
         * @param string $widget_class The name of a {@see WP_Widget} subclass.
 
570
         */
 
571
        public function unregister( $widget_class ) {
415
572
                if ( isset($this->widgets[$widget_class]) )
416
573
                        unset($this->widgets[$widget_class]);
417
574
        }
418
575
 
 
576
        /**
 
577
         * Utility method for adding widgets to the registered widgets global.
 
578
         *
 
579
         * @since 2.8.0
 
580
         * @access public
 
581
         */
419
582
        public function _register_widgets() {
420
583
                global $wp_registered_widgets;
421
584
                $keys = array_keys($this->widgets);
543
706
 *
544
707
 * If you wanted to quickly create multiple sidebars for a theme or internally.
545
708
 * This function will allow you to do so. If you don't pass the 'name' and/or
546
 
 * 'id' in $args, then they will be built for you.
547
 
 *
548
 
 * The default for the name is "Sidebar #", with '#' being replaced with the
549
 
 * number the sidebar is currently when greater than one. If first sidebar, the
550
 
 * name will be just "Sidebar". The default for id is "sidebar-" followed by the
551
 
 * number the sidebar creation is currently at. If the id is provided, and multiple
552
 
 * sidebars are being defined, the id will have "-2" appended, and so on.
 
709
 * 'id' in `$args`, then they will be built for you.
553
710
 *
554
711
 * @since 2.2.0
555
712
 *
556
713
 * @see register_sidebar() The second parameter is documented by register_sidebar() and is the same here.
557
 
 * @uses parse_str() Converts a string to an array to be used in the rest of the function.
558
 
 * @uses register_sidebar() Sends single sidebar information [name, id] to this
559
 
 *      function to handle building the sidebar.
560
 
 *
561
 
 * @param int $number Number of sidebars to create.
562
 
 * @param string|array $args Builds Sidebar based off of 'name' and 'id' values.
 
714
 *
 
715
 * @param int          $number Optional. Number of sidebars to create. Default 1.
 
716
 * @param array|string $args {
 
717
 *     Optional. Array or string of arguments for building a sidebar.
 
718
 *
 
719
 *     @type string $id   The base string of the unique identifier for each sidebar. If provided, and multiple
 
720
 *                        sidebars are being defined, the id will have "-2" appended, and so on.
 
721
 *                        Default 'sidebar-' followed by the number the sidebar creation is currently at.
 
722
 *     @type string $name The name or title for the sidebars displayed in the admin dashboard. If registering
 
723
 *                        more than one sidebar, include '%d' in the string as a placeholder for the uniquely
 
724
 *                        assigned number for each sidebar.
 
725
 *                        Default 'Sidebar' for the first sidebar, otherwise 'Sidebar %d'.
 
726
 * }
563
727
 */
564
 
function register_sidebars($number = 1, $args = array()) {
 
728
function register_sidebars( $number = 1, $args = array() ) {
565
729
        global $wp_registered_sidebars;
566
730
        $number = (int) $number;
567
731
 
608
772
 * If theme support for 'widgets' has not yet been added when this function is
609
773
 * called, it will be automatically enabled through the use of add_theme_support()
610
774
 *
611
 
 * Arguments passed as a string should be separated by '&':
612
 
 *
613
 
 *     e.g. 'name=Sidebar&id=my_prefix_sidebar'
614
 
 *
615
 
 * The same arguments passed as an array:
616
 
 *
617
 
 *     array(
618
 
 *         'name' => 'Sidebar',
619
 
 *         'id'   => 'my_prefix_sidebar',
620
 
 *     )
621
 
 *
622
 
 * Arguments:
623
 
 *     name          - The name or title of the sidebar displayed in the admin dashboard.
624
 
 *     id            - The unique identifier by which the sidebar will be called.
625
 
 *     before_widget - HTML content that will be prepended to each widget's HTML output
626
 
 *                     when assigned to this sidebar.
627
 
 *     after_widget  - HTML content that will be appended to each widget's HTML output
628
 
 *                     when assigned to this sidebar.
629
 
 *     before_title  - HTML content that will be prepended to the sidebar title when displayed.
630
 
 *     after_title   - HTML content that will be appended to the sidebar title when displayed.
631
 
 *
632
775
 * @since 2.2.0
633
 
 * @uses $wp_registered_sidebars Stores the new sidebar in this array by sidebar ID.
634
 
 * @uses add_theme_support() to ensure widget support has been added.
635
 
 *
636
 
 * @param string|array $args Arguments for the sidebar being registered.
 
776
 *
 
777
 * @global array $wp_registered_sidebars Stores the new sidebar in this array by sidebar ID.
 
778
 *
 
779
 * @param array|string $args {
 
780
 *     Optional. Array or string of arguments for the sidebar being registered.
 
781
 *
 
782
 *     @type string $name          The name or title of the sidebar displayed in the Widgets
 
783
 *                                 interface. Default 'Sidebar $instance'.
 
784
 *     @type string $id            The unique identifier by which the sidebar will be called.
 
785
 *                                 Default 'sidebar-$instance'.
 
786
 *     @type string $description   Description of the sidebar, displayed in the Widgets interface.
 
787
 *                                 Default empty string.
 
788
 *     @type string $class         Extra CSS class to assign to the sidebar in the Widgets interface.
 
789
 *                                 Default empty.
 
790
 *     @type string $before_widget HTML content to prepend to each widget's HTML output when
 
791
 *                                 assigned to this sidebar. Default is an opening list item element.
 
792
 *     @type string $after_widget  HTML content to append to each widget's HTML output when
 
793
 *                                 assigned to this sidebar. Default is a closing list item element.
 
794
 *     @type string $before_title  HTML content to prepend to the sidebar title when displayed.
 
795
 *                                 Default is an opening h2 element.
 
796
 *     @type string $after_title   HTML content to append to the sidebar title when displayed.
 
797
 *                                 Default is a closing h2 element.
 
798
 * }
637
799
 * @return string Sidebar ID added to $wp_registered_sidebars global.
638
800
 */
639
801
function register_sidebar($args = array()) {
687
849
}
688
850
 
689
851
/**
690
 
 * Register widget for use in sidebars.
 
852
 * Register an instance of a widget.
691
853
 *
692
854
 * The default widget option is 'classname' that can be overridden.
693
855
 *
694
 
 * The function can also be used to un-register widgets when $output_callback
 
856
 * The function can also be used to un-register widgets when `$output_callback`
695
857
 * parameter is an empty string.
696
858
 *
697
859
 * @since 2.2.0
698
860
 *
699
 
 * @uses $wp_registered_widgets Uses stored registered widgets.
700
 
 * @uses $wp_register_widget_defaults Retrieves widget defaults.
701
 
 *
702
 
 * @param int|string $id Widget ID.
703
 
 * @param string $name Widget display title.
704
 
 * @param callback $output_callback Run when widget is called.
705
 
 * @param array|string $options Optional. Widget Options.
706
 
 * @param mixed $params,... Widget parameters to add to widget.
707
 
 * @return null Will return if $output_callback is empty after removing widget.
 
861
 * @global array $wp_registered_widgets       Uses stored registered widgets.
 
862
 * @global array $wp_register_widget_defaults Retrieves widget defaults.
 
863
 *
 
864
 * @param int|string $id              Widget ID.
 
865
 * @param string     $name            Widget display title.
 
866
 * @param callback   $output_callback Run when widget is called.
 
867
 * @param array      $options {
 
868
 *     Optional. An array of supplementary widget options for the instance.
 
869
 *
 
870
 *     @type string $classname   Class name for the widget's HTML container. Default is a shortened
 
871
 *                               version of the output callback name.
 
872
 *     @type string $description Widget description for display in the widget administration
 
873
 *                               panel and/or theme.
 
874
 * }
 
875
 * @return null Will return if `$output_callback` is empty after removing widget.
708
876
 */
709
 
function wp_register_sidebar_widget($id, $name, $output_callback, $options = array()) {
 
877
function wp_register_sidebar_widget( $id, $name, $output_callback, $options = array() ) {
710
878
        global $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates, $_wp_deprecated_widgets_callbacks;
711
879
 
712
880
        $id = strtolower($id);
781
949
 *
782
950
 * @since 2.9.0
783
951
 *
784
 
 * @param int|string $id sidebar ID.
 
952
 * @param string $id sidebar ID.
785
953
 * @return string Sidebar description, if available. Null on failure to retrieve description.
786
954
 */
787
955
function wp_sidebar_description( $id ) {
824
992
 * control form, but try hard to use the default width. The 'id_base' is for
825
993
 * multi-widgets (widgets which allow multiple instances such as the text
826
994
 * widget), an id_base must be provided. The widget id will end up looking like
827
 
 * {$id_base}-{$unique_number}.
 
995
 * `{$id_base}-{$unique_number}`.
828
996
 *
829
997
 * @since 2.2.0
830
998
 *
831
 
 * @param int|string $id Sidebar ID.
832
 
 * @param string $name Sidebar display name.
833
 
 * @param callback $control_callback Run when sidebar is displayed.
834
 
 * @param array|string $options Optional. Widget options. See above long description.
835
 
 * @param mixed $params,... Optional. Additional parameters to add to widget.
 
999
 * @todo Document `$options` as a hash notation, re: WP_Widget::__construct() cross-reference.
 
1000
 * @todo `$params` parameter?
 
1001
 *
 
1002
 * @param int|string   $id               Sidebar ID.
 
1003
 * @param string       $name             Sidebar display name.
 
1004
 * @param callback     $control_callback Run when sidebar is displayed.
 
1005
 * @param array|string $options          Optional. Widget options. See description above. Default empty array.
836
1006
 */
837
 
function wp_register_widget_control($id, $name, $control_callback, $options = array()) {
 
1007
function wp_register_widget_control( $id, $name, $control_callback, $options = array() ) {
838
1008
        global $wp_registered_widget_controls, $wp_registered_widget_updates, $wp_registered_widgets, $_wp_deprecated_widgets_callbacks;
839
1009
 
840
1010
        $id = strtolower($id);
881
1051
        $wp_registered_widget_updates[$id_base] = $widget;
882
1052
}
883
1053
 
 
1054
/**
 
1055
 *
 
1056
 * @global array $wp_registered_widget_updates
 
1057
 * @param string   $id_base
 
1058
 * @param callable $update_callback
 
1059
 * @param array    $options
 
1060
 */
884
1061
function _register_widget_update_callback($id_base, $update_callback, $options = array()) {
885
1062
        global $wp_registered_widget_updates;
886
1063
 
899
1076
        $wp_registered_widget_updates[$id_base] = $widget;
900
1077
}
901
1078
 
 
1079
/**
 
1080
 *
 
1081
 * @global array $wp_registered_widget_controls
 
1082
 * @param int|string $id
 
1083
 * @param string     $name
 
1084
 * @param callable   $form_callback
 
1085
 * @param array      $options
 
1086
 * @return null
 
1087
 */
902
1088
function _register_widget_form_callback($id, $name, $form_callback, $options = array()) {
903
1089
        global $wp_registered_widget_controls;
904
1090
 
932
1118
 * Remove control callback for widget.
933
1119
 *
934
1120
 * @since 2.2.0
935
 
 * @uses wp_register_widget_control() Unregisters by using empty callback.
936
1121
 *
937
1122
 * @param int|string $id Widget ID.
938
1123
 */
1184
1369
 *
1185
1370
 * @since 2.8.0
1186
1371
 *
1187
 
 * @param mixed $index Sidebar name, id or number to check.
 
1372
 * @param string|int $index Sidebar name, id or number to check.
1188
1373
 * @return bool true if the sidebar is in use, false otherwise.
1189
1374
 */
1190
1375
function is_active_sidebar( $index ) {
1207
1392
/* Internal Functions */
1208
1393
 
1209
1394
/**
1210
 
 * Retrieve full list of sidebars and their widgets.
 
1395
 * Retrieve full list of sidebars and their widget instance IDs.
1211
1396
 *
1212
1397
 * Will upgrade sidebar widget list, if needed. Will also save updated list, if
1213
1398
 * needed.
1215
1400
 * @since 2.2.0
1216
1401
 * @access private
1217
1402
 *
1218
 
 * @param bool $deprecated Not used (deprecated).
 
1403
 * @param bool $deprecated Not used (argument deprecated).
1219
1404
 * @return array Upgraded list of widgets to version 3 array format when called from the admin.
1220
1405
 */
1221
 
function wp_get_sidebars_widgets($deprecated = true) {
 
1406
function wp_get_sidebars_widgets( $deprecated = true ) {
1222
1407
        if ( $deprecated !== true )
1223
1408
                _deprecated_argument( __FUNCTION__, '2.8.1' );
1224
1409
 
1287
1472
 *
1288
1473
 * @since 2.8.0
1289
1474
 *
 
1475
 * @param string $base_name
 
1476
 * @param string $option_name
 
1477
 * @param array  $settings
1290
1478
 * @return array
1291
1479
 */
1292
1480
function wp_convert_widget_settings($base_name, $option_name, $settings) {
1345
1533
 *
1346
1534
 * @since 2.8.0
1347
1535
 *
1348
 
 * @param string $widget the widget's PHP class name (see default-widgets.php)
1349
 
 * @param array $instance the widget's instance settings
1350
 
 * @param array $args the widget's sidebar args
1351
 
 * @return void
1352
 
 **/
1353
 
function the_widget($widget, $instance = array(), $args = array()) {
 
1536
 * @param string $widget   The widget's PHP class name (see default-widgets.php).
 
1537
 * @param array  $instance Optional. The widget's instance settings. Default empty array.
 
1538
 * @param array  $args {
 
1539
 *     Optional. Array of arguments to configure the display of the widget.
 
1540
 *
 
1541
 *     @type string $before_widget HTML content that will be prepended to the widget's HTML output.
 
1542
 *                                 Default `<div class="widget %s">`, where `%s` is the widget's class name.
 
1543
 *     @type string $after_widget  HTML content that will be appended to the widget's HTML output.
 
1544
 *                                 Default `</div>`.
 
1545
 *     @type string $before_title  HTML content that will be prepended to the widget's title when displayed.
 
1546
 *                                 Default `<h2 class="widgettitle">`.
 
1547
 *     @type string $after_title   HTML content that will be appended to the widget's title when displayed.
 
1548
 *                                 Default `</h2>`.
 
1549
 * }
 
1550
 */
 
1551
function the_widget( $widget, $instance = array(), $args = array() ) {
1354
1552
        global $wp_widget_factory;
1355
1553
 
1356
1554
        $widget_obj = $wp_widget_factory->widgets[$widget];
1405
1603
 *
1406
1604
 * @since 2.8.0
1407
1605
 *
1408
 
 * @param mixed $theme_changed Whether the theme was changed as a boolean. A value
1409
 
 *                             of 'customize' defers updates for the customizer.
 
1606
 * @param string|bool $theme_changed Whether the theme was changed as a boolean. A value
 
1607
 *                                   of 'customize' defers updates for the Customizer.
1410
1608
 * @return array
1411
1609
 */
1412
1610
function retrieve_widgets( $theme_changed = false ) {