Make WordPress Core


Ignore:
Timestamp:
05/19/2014 03:42:00 PM (12 years ago)
Author:
wonderboymusic
Message:

Add public access modifier to methods/members of WP_Widget and WP_Widget_Factory.

See #27881, #22234.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/widgets.php

    r28338 r28527  
    2424class WP_Widget {
    2525
    26         var $id_base;                   // Root id for all widgets of this type.
    27         var $name;                              // Name for this widget type.
    28         var $widget_options;    // Option array passed to wp_register_sidebar_widget()
    29         var $control_options;   // Option array passed to wp_register_widget_control()
    30 
    31         var $number = false;    // Unique ID number of the current instance.
    32         var $id = false;                // Unique ID string of the current instance (id_base-number)
    33         var $updated = false;   // Set true when we update the data after a POST submit - makes sure we don't do it twice.
     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.
    3434
    3535        // Member functions that you must over-ride.
    … …  
    4242         * @param array $instance The settings for the particular instance of the widget
    4343         */
    44         function widget($args, $instance) {
     44        public function widget($args, $instance) {
    4545                die('function WP_Widget::widget() must be over-ridden in a sub-class.');
    4646        }
    … …  
    5656         * @return array Settings to save or bool false to cancel saving
    5757         */
    58         function update($new_instance, $old_instance) {
     58        public function update($new_instance, $old_instance) {
    5959                return $new_instance;
    6060        }
    … …  
    6464         * @param array $instance Current settings
    6565         */
    66         function form($instance) {
     66        public function form($instance) {
    6767                echo '<p class="no-options-widget">' . __('There are no options for this widget.') . '</p>';
    6868                return 'noform';
    … …  
    8484         *       - height: currently not used but may be needed in the future
    8585         */
    86         function __construct( $id_base, $name, $widget_options = array(), $control_options = array() ) {
     86        public function __construct( $id_base, $name, $widget_options = array(), $control_options = array() ) {
    8787                $this->id_base = empty($id_base) ? preg_replace( '/(wp_)?widget_/', '', strtolower(get_class($this)) ) : strtolower($id_base);
    8888                $this->name = $name;
    … …  
    9595         * PHP4 constructor
    9696         */
    97         function WP_Widget( $id_base, $name, $widget_options = array(), $control_options = array() ) {
     97        public function WP_Widget( $id_base, $name, $widget_options = array(), $control_options = array() ) {
    9898                WP_Widget::__construct( $id_base, $name, $widget_options, $control_options );
    9999        }
    … …  
    107107         * @return string Name attribute for $field_name
    108108         */
    109         function get_field_name($field_name) {
     109        public function get_field_name($field_name) {
    110110                return 'widget-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']';
    111111        }
    … …  
    119119         * @return string ID attribute for $field_name
    120120         */
    121         function get_field_id($field_name) {
     121        public function get_field_id($field_name) {
    122122                return 'widget-' . $this->id_base . '-' . $this->number . '-' . $field_name;
    123123        }
    … …  
    125125        // Private Functions. Don't worry about these.
    126126
    127         function _register() {
     127        public function _register() {
    128128                $settings = $this->get_settings();
    129129                $empty = true;
    … …  
    147147        }
    148148
    149         function _set($number) {
     149        public function _set($number) {
    150150                $this->number = $number;
    151151                $this->id = $this->id_base . '-' . $number;
    152152        }
    153153
    154         function _get_display_callback() {
     154        public function _get_display_callback() {
    155155                return array($this, 'display_callback');
    156156        }
    157157
    158         function _get_update_callback() {
     158        public function _get_update_callback() {
    159159                return array($this, 'update_callback');
    160160        }
    161161
    162         function _get_form_callback() {
     162        public function _get_form_callback() {
    163163                return array($this, 'form_callback');
    164164        }
    … …  
    174174         * @return bool True if Customizer is on, false if not.
    175175         */
    176         function is_preview() {
     176        public function is_preview() {
    177177                global $wp_customize;
    178178                return ( isset( $wp_customize ) && $wp_customize->is_preview() ) ;
    … …  
    182182         *      Just finds the instance and calls widget().
    183183         *      Do NOT over-ride this function. */
    184         function display_callback( $args, $widget_args = 1 ) {
     184        public function display_callback( $args, $widget_args = 1 ) {
    185185                if ( is_numeric($widget_args) )
    186186                        $widget_args = array( 'number' => $widget_args );
    … …  
    230230         * @param mixed $deprecated Not used.
    231231         */
    232         function update_callback( $deprecated = 1 ) {
     232        public function update_callback( $deprecated = 1 ) {
    233233                global $wp_registered_widgets;
    234234
    … …  
    310310         * Do NOT over-ride this function.
    311311         */
    312         function form_callback( $widget_args = 1 ) {
     312        public function form_callback( $widget_args = 1 ) {
    313313                if ( is_numeric($widget_args) )
    314314                        $widget_args = array( 'number' => $widget_args );
    … …  
    364364
    365365        /** Helper function: Registers a single instance. */
    366         function _register_one($number = -1) {
     366        public function _register_one($number = -1) {
    367367                wp_register_sidebar_widget(     $this->id, $this->name, $this->_get_display_callback(), $this->widget_options, array( 'number' => $number ) );
    368368                _register_widget_update_callback( $this->id_base, $this->_get_update_callback(), $this->control_options, array( 'number' => -1 ) );
    … …  
    370370        }
    371371
    372         function save_settings($settings) {
     372        public function save_settings($settings) {
    373373                $settings['_multiwidget'] = 1;
    374374                update_option( $this->option_name, $settings );
    375375        }
    376376
    377         function get_settings() {
     377        public function get_settings() {
    378378                $settings = get_option($this->option_name);
    379379
    … …  
    402402 */
    403403class WP_Widget_Factory {
    404         var $widgets = array();
    405 
    406         function WP_Widget_Factory() {
     404        public $widgets = array();
     405
     406        public function WP_Widget_Factory() {
    407407                add_action( 'widgets_init', array( $this, '_register_widgets' ), 100 );
    408408        }
    409409
    410         function register($widget_class) {
     410        public function register($widget_class) {
    411411                $this->widgets[$widget_class] = new $widget_class();
    412412        }
    413413
    414         function unregister($widget_class) {
     414        public function unregister($widget_class) {
    415415                if ( isset($this->widgets[$widget_class]) )
    416416                        unset($this->widgets[$widget_class]);
    417417        }
    418418
    419         function _register_widgets() {
     419        public function _register_widgets() {
    420420                global $wp_registered_widgets;
    421421                $keys = array_keys($this->widgets);
Note: See TracChangeset for help on using the changeset viewer.