Changeset 27870
- Timestamp:
- 03/31/2014 07:29:29 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/widgets.php
r27543 r27870 177 177 if ( array_key_exists( $this->number, $instance ) ) { 178 178 $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 ); 181 192 if ( false !== $instance ) 182 193 $this->widget($args, $instance); … … 233 244 $instance = $this->update($new_instance, $old_instance); 234 245 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 ); 237 260 if ( false !== $instance ) 238 261 $all_instances[$number] = $instance; … … 246 269 } 247 270 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 */ 250 276 function form_callback( $widget_args = 1 ) { 251 277 if ( is_numeric($widget_args) ) … … 264 290 } 265 291 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 ); 268 303 269 304 $return = null; 270 305 if ( false !== $instance ) { 271 306 $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 ) ); 275 325 } 276 326 return $return; … … 573 623 add_theme_support('widgets'); 574 624 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 */ 575 632 do_action( 'register_sidebar', $sidebar ); 576 633 … … 646 703 647 704 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 */ 648 713 do_action( 'wp_register_sidebar_widget', $widget ); 649 714 $wp_registered_widgets[$id] = $widget; … … 702 767 */ 703 768 function 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 */ 704 777 do_action( 'wp_unregister_sidebar_widget', $id ); 705 778 … … 1129 1202 unset($sidebars_widgets['array_version']); 1130 1203 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 ); 1132 1212 return $sidebars_widgets; 1133 1213 } … … 1225 1305 1226 1306 /** 1227 * Output an arbitrary widget as a template tag 1307 * Output an arbitrary widget as a template tag. 1228 1308 * 1229 1309 * @since 2.8.0 … … 1247 1327 $instance = wp_parse_args($instance); 1248 1328 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 */ 1249 1338 do_action( 'the_widget', $widget, $instance, $args ); 1250 1339
Note: See TracChangeset
for help on using the changeset viewer.