Generates the widget control form (Do NOT override).
Parameters
$widget_args
int|arrayoptional- Internal order number of the widget instance, or array of multi-widget arguments.
number
intNumber increment used for multiples of the same widget.
Default:
1
Source
public function form_callback( $widget_args = 1 ) {
if ( is_numeric( $widget_args ) ) {
$widget_args = array( 'number' => $widget_args );
}
$widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) );
$all_instances = $this->get_settings();
if ( -1 === $widget_args['number'] ) {
// We echo out a form where 'number' can be set later.
$this->_set( '__i__' );
$instance = array();
} else {
$this->_set( $widget_args['number'] );
$instance = $all_instances[ $widget_args['number'] ];
}
/**
* Filters the widget instance's settings before displaying the control form.
*
* Returning false effectively short-circuits display of the control form.
*
* @since 2.8.0
*
* @param array $instance The current widget instance's settings.
* @param WP_Widget $widget The current widget instance.
*/
$instance = apply_filters( 'widget_form_callback', $instance, $this );
$return = null;
if ( false !== $instance ) {
$return = $this->form( $instance );
/**
* Fires at the end of the widget control form.
*
* Use this hook to add extra fields to the widget form. The hook
* is only fired if the value passed to the 'widget_form_callback'
* hook is not false.
*
* Note: If the widget has no form, the text echoed from the default
* form method can be hidden using CSS.
*
* @since 2.8.0
*
* @param WP_Widget $widget The widget instance (passed by reference).
* @param null $return Return null if new fields are added.
* @param array $instance An array of the widget's settings.
*/
do_action_ref_array( 'in_widget_form', array( &$this, &$return, $instance ) );
}
return $return;
}
Hooks
- do_action_ref_array( ‘in_widget_form’,
WP_Widget $widget ,null $return ,array $instance ) Fires at the end of the widget control form.
- apply_filters( ‘widget_form_callback’,
array $instance ,WP_Widget $widget ) Filters the widget instance’s settings before displaying the control form.
Changelog
Version | Description |
---|---|
2.8.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.