Make WordPress Core


Ignore:
Timestamp:
03/31/2014 07:29:29 AM (12 years ago)
Author:
DrewAPicture
Message:

Inline documentation for hooks in wp-includes/widgets.php.

Props eliorivero and Nessworthy for the initial patches. Props kpdesign.
Fixes #27129.

File:
1 edited

Legend:

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

    r27543 r27870  
    177177                if ( array_key_exists( $this->number, $instance ) ) {
    178178                        $instance = $instance[$this->number];
    179                         // filters the widget's settings, return false to stop displaying the widget
    180                         $instance = apply_filters('widget_display_callback', $instance, $this, $args);
     179
     180                        /**
     181                         * Filter the settings for a particular widget instance.
     182                         *
     183                         * Returning false will effectively short-circuit display of the widget.
     184                         *
     185                         * @since 2.8.0
     186                         *
     187                         * @param array     $instance The current widget instance's settings.
     188                         * @param WP_Widget $this     The current widget instance.
     189                         * @param array     $args     An array of default widget arguments.
     190                         */
     191                        $instance = apply_filters( 'widget_display_callback', $instance, $this, $args );
    181192                        if ( false !== $instance )
    182193                                $this->widget($args, $instance);
     
    233244                                $instance = $this->update($new_instance, $old_instance);
    234245
    235                                 // filters the widget's settings before saving, return false to cancel saving (keep the old settings if updating)
    236                                 $instance = apply_filters('widget_update_callback', $instance, $new_instance, $old_instance, $this);
     246                                /**
     247                                 * Filter a widget's settings before saving.
     248                                 *
     249                                 * Returning false will effectively short-circuit the widget's ability
     250                                 * to update settings.
     251                                 *
     252                                 * @since 2.8.0
     253                                 *
     254                                 * @param array     $instance     The current widget instance's settings.
     255                                 * @param array     $new_instance Array of new widget settings.
     256                                 * @param array     $old_instance Array of old widget settings.
     257                                 * @param WP_Widget $this         The current widget instance.
     258                                 */
     259                                $instance = apply_filters( 'widget_update_callback', $instance, $new_instance, $old_instance, $this );
    237260                                if ( false !== $instance )
    238261                                        $all_instances[$number] = $instance;
     
    246269        }
    247270
    248         /** Generate the control form.
    249          *      Do NOT over-ride this function. */
     271        /**
     272         * Generate the control form.
     273         *
     274         * Do NOT over-ride this function.
     275         */
    250276        function form_callback( $widget_args = 1 ) {
    251277                if ( is_numeric($widget_args) )
     
    264290                }
    265291
    266                 // filters the widget admin form before displaying, return false to stop displaying it
    267                 $instance = apply_filters('widget_form_callback', $instance, $this);
     292                /**
     293                 * Filter the widget instance's settings before displaying the control form.
     294                 *
     295                 * Returning false effectively short-circuits display of the control form.
     296                 *
     297                 * @since 2.8.0
     298                 *
     299                 * @param array     $instance The current widget instance's settings.
     300                 * @param WP_Widget $this     The current widget instance.
     301                 */
     302                $instance = apply_filters( 'widget_form_callback', $instance, $this );
    268303
    269304                $return = null;
    270305                if ( false !== $instance ) {
    271306                        $return = $this->form($instance);
    272                         // add extra fields in the widget form - be sure to set $return to null if you add any
    273                         // if the widget has no form the text echoed from the default form method can be hidden using css
    274                         do_action_ref_array( 'in_widget_form', array(&$this, &$return, $instance) );
     307
     308                        /**
     309                         * Fires at the end of the widget control form.
     310                         *
     311                         * Use this hook to add extra fields to the widget form. The hook
     312                         * is only fired if the value passed to the 'widget_form_callback'
     313                         * hook is not false.
     314                         *
     315                         * Note: If the widget has no form, the text echoed from the default
     316                         * form method can be hidden using CSS.
     317                         *
     318                         * @since 2.8.0
     319                         *
     320                         * @param WP_Widget $this     The widget instance, passed by reference.
     321                         * @param null      $return   Return null if new fields are added.
     322                         * @param array     $instance An array of the widget's settings.
     323                         */
     324                        do_action_ref_array( 'in_widget_form', array( &$this, &$return, $instance ) );
    275325                }
    276326                return $return;
     
    573623        add_theme_support('widgets');
    574624
     625        /**
     626         * Fires once a sidebar has been registered.
     627         *
     628         * @since 3.0.0
     629         *
     630         * @param array $sidebar Parsed arguments for the registered sidebar.
     631         */
    575632        do_action( 'register_sidebar', $sidebar );
    576633
     
    646703
    647704        if ( is_callable($output_callback) && ( !isset($wp_registered_widgets[$id]) || did_action( 'widgets_init' ) ) ) {
     705
     706                /**
     707                 * Fires once for each registered widget.
     708                 *
     709                 * @since 3.0.0
     710                 *
     711                 * @param array $widget An array of default widget arguments.
     712                 */
    648713                do_action( 'wp_register_sidebar_widget', $widget );
    649714                $wp_registered_widgets[$id] = $widget;
     
    702767 */
    703768function wp_unregister_sidebar_widget($id) {
     769
     770        /**
     771         * Fires just before a widget is removed from a sidebar.
     772         *
     773         * @since 3.0.0
     774         *
     775         * @param int $id The widget ID.
     776         */
    704777        do_action( 'wp_unregister_sidebar_widget', $id );
    705778
     
    11291202                unset($sidebars_widgets['array_version']);
    11301203
    1131         $sidebars_widgets = apply_filters('sidebars_widgets', $sidebars_widgets);
     1204        /**
     1205         * Filter the list of sidebars and their widgets.
     1206         *
     1207         * @since 2.7.0
     1208         *
     1209         * @param array $sidebars_widgets An associative array of sidebars and their widgets.
     1210         */
     1211        $sidebars_widgets = apply_filters( 'sidebars_widgets', $sidebars_widgets );
    11321212        return $sidebars_widgets;
    11331213}
     
    12251305
    12261306/**
    1227  * Output an arbitrary widget as a template tag
     1307 * Output an arbitrary widget as a template tag.
    12281308 *
    12291309 * @since 2.8.0
     
    12471327        $instance = wp_parse_args($instance);
    12481328
     1329        /**
     1330         * Fires before rendering the requested widget.
     1331         *
     1332         * @since 3.0.0
     1333         *
     1334         * @param string $widget   The widget's class name.
     1335         * @param array  $instance The current widget instance's settings.
     1336         * @param array  $args     An array of the widget's sidebar arguments.
     1337         */
    12491338        do_action( 'the_widget', $widget, $instance, $args );
    12501339
Note: See TracChangeset for help on using the changeset viewer.