WP_Customize_Widgets::get_setting_args( string $id, array $overrides = array() ): array
- Since
- 3.9.0
- Source
wp-includes/class-wp-customize-widgets.php:996
Compatibility
- WordPress
- since 3.9.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$idstring- Widget setting ID.
$overridesarrayoptional- Array of setting overrides.Default:
array()
Return value
array- Possibly modified setting arguments.
Performance profile
How much work a call to WP_Customize_Widgets::get_setting_args() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 7
- Plugin surface
- 1 hook
- Called by
- 2
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5. The body compiles to 84.
Third-party callbacks on 'widget_customizer_setting_args' run inside this call, and their cost is not bounded by anything here.
2 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()called directly
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Customize_Widgets::get_setting_args() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 7 | ->sanitize_widget_js_instance() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 84 | 7 | 4 | |
| 8.5 | 84 | 7 | 4 | |
| 8.4 | 84 | 7 | 4 | 2 fewer instructions than PHP 8.3 |
| 8.3 | 86 | 8 | 4 | |
| 8.2 | 86 | 8 | 4 | |
| 8.1 | 86 | 8 | 4 | 16 more instructions than PHP 7.4 |
| 7.4 | 70 | 30–49 | 4 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 1
One hook fires while WP_Customize_Widgets::get_setting_args() runs, in this order:
- apply_filters( widget_customizer_setting_args )filterline 1030 (+34 into the body)
Filters the common arguments supplied when constructing a Customizer setting.
Uses · 5
- current_theme_supports()Checks a theme's support for a given feature.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- WP_Customize_Widgets::sanitize_widget_instance()Sanitizes a widget instance.
- WP_Customize_Widgets::sanitize_widget_js_instance()Converts a widget instance into JSON-representable format.
- WP_Customize_Widgets::is_widget_selective_refreshable()Determines if a widget supports selective refresh.
Used by · 2
- WP_Customize_Widgets::customize_register()Registers Customizer settings and controls for all sidebars and widgets.
- WP_Customize_Widgets::filter_customize_dynamic_setting_args()Determines the arguments for a dynamically-created setting.
Source code
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 ) ) { $id_base = $matches['id_base']; $args['sanitize_callback'] = function ( $value ) use ( $id_base ) { return $this->sanitize_widget_instance( $value, $id_base ); }; $args['sanitize_js_callback'] = function ( $value ) use ( $id_base ) { return $this->sanitize_widget_js_instance( $value, $id_base ); }; $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 ); }Changelog
Introduced in 3.9.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-includes/class-wp-customize-widgets.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.