WordPress.org

Make WordPress Core

Changeset 11095


Ignore:
Timestamp:
04/27/2009 10:56:29 AM (9 years ago)
Author:
azaozz
Message:

Add hooks to WP_Widget, props ceenz, fixes #9651, see #8441

File:
1 edited

Legend:

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

    r11090 r11095  
    165165        $settings = $this->get_settings();
    166166
    167         if ( array_key_exists( $this->number, $settings ) )
    168             $this->widget($args, $settings[$this->number]);
     167        if ( array_key_exists( $this->number, $settings ) ) {
     168            $settings = $settings[$this->number];
     169            // filters the widget's settings, return false to stop displaying the widget
     170            $settings = apply_filters('widget_display_callback', $settings, &$this);   
     171            if ( false !== $settings )
     172                $this->widget($args, $settings);
     173        }
    169174    }
    170175
     
    223228                        $instance = $this->update($new_instance, array());
    224229
     230                    // filters the widget's settings before saving, return false to cancel saving (keep the old settings if updating)
     231                    $instance = apply_filters('widget_update_callback', $instance, $new_instance, &$this);
    225232                    if ( false !== $instance )
    226233                        $all_instances[$number] = $instance;
     
    251258        }
    252259
    253         return $this->form($instance);
     260        // filters the widget admin form before displaying, return false to stop displaying it
     261        $instance = apply_filters('widget_form_callback', $instance, &$this);
     262        if ( false !== $instance )
     263            $this->form($instance);
    254264    }
    255265
Note: See TracChangeset for help on using the changeset viewer.