Filter hook 'widget_form_callback'

in WP Core File wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php at line 582

View Source

widget_form_callback

Filter Hook
Description
Returns the output of WP_Widget::form() when called with the provided instance. Used by encode_form_data() to preview a widget's form.

Hook Information

File Location wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php View on GitHub
Hook Type Filter
Line Number 582

Hook Parameters

Type Name Description
WP_Widget $widget_object Widget object to call widget() on.
array $instance Widget instance settings.

Usage Examples

Basic Usage
<?php
// Hook into widget_form_callback
add_filter('widget_form_callback', 'my_custom_filter', 10, 2);

function my_custom_filter($widget_object, $instance) {
    // Your custom filtering logic here
    return $widget_object;
}

Source Code Context

wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php:582 - How this hook is used in WordPress core
<?php
 577  	 */
 578  	private function get_widget_form( $widget_object, $instance ) {
 579  		ob_start();
 580  
 581  		/** This filter is documented in wp-includes/class-wp-widget.php */
 582  		$instance = apply_filters(
 583  			'widget_form_callback',
 584  			$instance,
 585  			$widget_object
 586  		);
 587  

PHP Documentation

<?php
/**
	 * Returns the output of WP_Widget::form() when called with the provided
	 * instance. Used by encode_form_data() to preview a widget's form.
	 *
	 * @since 5.8.0
	 *
	 * @param WP_Widget $widget_object Widget object to call widget() on.
	 * @param array     $instance Widget instance settings.
	 * @return string
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php
Related Hooks

Related hooks will be displayed here in future updates.