WP_Customize_Widgets::get_setting_args() public WP 3.9.0
Retrieves common arguments to supply when constructing a Customizer setting.
{} It's a method of the class: WP_Customize_Widgets{}
Hooks from the method
Return
Array. Possibly modified setting arguments.
Usage
$WP_Customize_Widgets = new WP_Customize_Widgets(); $WP_Customize_Widgets->get_setting_args( $id, $overrides );
- $id(string) (required)
- Widget setting ID.
- $overrides(array)
- Array of setting overrides.
Default: array()
Changelog
Since 3.9.0 | Introduced. |
Code of WP_Customize_Widgets::get_setting_args() WP Customize Widgets::get setting args WP 5.6
public function get_setting_args( $id, $overrides = array() ) {
$args = array(
'type' => 'option',
'capability' => 'edit_theme_options',
'default' => array(),
);
if ( preg_match( $this->setting_id_patterns['sidebar_widgets'], $id, $matches ) ) {
$args['sanitize_callback'] = array( $this, 'sanitize_sidebar_widgets' );
$args['sanitize_js_callback'] = array( $this, 'sanitize_sidebar_widgets_js_instance' );
$args['transport'] = current_theme_supports( 'customize-selective-refresh-widgets' ) ? 'postMessage' : 'refresh';
} elseif ( preg_match( $this->setting_id_patterns['widget_instance'], $id, $matches ) ) {
$args['sanitize_callback'] = array( $this, 'sanitize_widget_instance' );
$args['sanitize_js_callback'] = array( $this, 'sanitize_widget_js_instance' );
$args['transport'] = $this->is_widget_selective_refreshable( $matches['id_base'] ) ? 'postMessage' : 'refresh';
}
$args = array_merge( $args, $overrides );
/**
* Filters the common arguments supplied when constructing a Customizer setting.
*
* @since 3.9.0
*
* @see WP_Customize_Setting
*
* @param array $args Array of Customizer setting arguments.
* @param string $id Widget setting ID.
*/
return apply_filters( 'widget_customizer_setting_args', $args, $id );
}