Make WordPress Core

Ticket #30315: 30315.diff

File 30315.diff, 4.3 KB (added by ericlewis, 10 years ago)
  • wp-includes/widgets.php

    diff --git wp-includes/widgets.php wp-includes/widgets.php
    index f3ca44a..45bb43e 100644
    class WP_Widget { 
    122122                return 'widget-' . $this->id_base . '-' . $this->number . '-' . $field_name;
    123123        }
    124124
    125         // Private Functions. Don't worry about these.
    126 
     125        /**
     126         * Register all widget instances of this widget class.
     127         *
     128         * @access private
     129         */
    127130        public function _register() {
    128131                $settings = $this->get_settings();
    129132                $empty = true;
    class WP_Widget { 
    146149                }
    147150        }
    148151
     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         */
    149160        public function _set($number) {
    150161                $this->number = $number;
    151162                $this->id = $this->id_base . '-' . $number;
    class WP_Widget { 
    362373                return $return;
    363374        }
    364375
    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         */
    366384        public function _register_one($number = -1) {
    367385                wp_register_sidebar_widget(     $this->id, $this->name, $this->_get_display_callback(), $this->widget_options, array( 'number' => $number ) );
    368386                _register_widget_update_callback( $this->id_base, $this->_get_update_callback(), $this->control_options, array( 'number' => -1 ) );
    369387                _register_widget_form_callback( $this->id, $this->name, $this->_get_form_callback(), $this->control_options, array( 'number' => $number ) );
    370388        }
    371389
     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         */
    372395        public function save_settings($settings) {
    373396                $settings['_multiwidget'] = 1;
    374397                update_option( $this->option_name, $settings );
    375398        }
    376399
     400        /**
     401         * Get the settings for all instances of the widget class.
     402         *
     403         * @return array Multi-dimensional array of widget instance settings.
     404         */
    377405        public function get_settings() {
     406
    378407                $settings = get_option($this->option_name);
    379408
    380409                if ( false === $settings && isset($this->alt_option_name) )
    class WP_Widget_Factory { 
    407436                add_action( 'widgets_init', array( $this, '_register_widgets' ), 100 );
    408437        }
    409438
     439        /**
     440         * Register a widget class.
     441         *
     442         * @param  mixed $widget_class A subclass of WP_Widget.
     443         */
    410444        public function register($widget_class) {
    411445                $this->widgets[$widget_class] = new $widget_class();
    412446        }
    413447
     448        /**
     449         * Unregister a widget class.
     450         *
     451         * @param  mixed $widget_class A subclass of WP_Widget.
     452         */
    414453        public function unregister($widget_class) {
    415454                if ( isset($this->widgets[$widget_class]) )
    416455                        unset($this->widgets[$widget_class]);
    global $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_co 
    448487$wp_registered_sidebars = array();
    449488
    450489/**
    451  * Stores the registered widgets.
     490 * Stores instances of widgets.
    452491 *
    453492 * @global array $wp_registered_widgets
    454493 * @since 2.2.0
    function unregister_sidebar( $name ) { 
    683722}
    684723
    685724/**
    686  * Register widget for use in sidebars.
     725 * Register an instance of a widget.
    687726 *
    688727 * The default widget option is 'classname' that can be overridden.
    689728 *
    function unregister_sidebar( $name ) { 
    698737 * @param int|string $id Widget ID.
    699738 * @param string $name Widget display title.
    700739 * @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 * }
    702746 * @param mixed $params,... Widget parameters to add to widget.
    703747 * @return null Will return if $output_callback is empty after removing widget.
    704748 */
    function is_active_sidebar( $index ) { 
    12021246/* Internal Functions */
    12031247
    12041248/**
    1205  * Retrieve full list of sidebars and their widgets.
     1249 * Retrieve full list of sidebars and their widget instance IDs.
    12061250 *
    12071251 * Will upgrade sidebar widget list, if needed. Will also save updated list, if
    12081252 * needed.