WP_Customize_Widgets
- Since
- 3.9.0
- Source
wp-includes/class-wp-customize-widgets.php:19
Customize Widgets class.
Description
Implements widget management in the Customizer.
Compatibility
- WordPress
- since 3.9.0
- 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).
Hooks and filters fired · 19
Every hook that fires from inside WP_Customize_Widgets, in the order it appears in the class, grouped by the method that fires it.
WP_Customize_Widgets::customize_controls_init()
- do_action( load-widgets.php )action line 336
- do_action( widgets.php )action line 339
- do_action( sidebar_admin_setup )action line 342
WP_Customize_Widgets::customize_register()
- apply_filters( customizer_widgets_section_args )filter line 475
WP_Customize_Widgets::print_styles()
- do_action( admin_print_styles-widgets.php )action line 671
- do_action( admin_print_styles )action line 674
WP_Customize_Widgets::print_scripts()
- do_action( admin_print_scripts-widgets.php )action line 685
- do_action( admin_print_scripts )action line 688
WP_Customize_Widgets::enqueue_scripts()
- do_action( admin_enqueue_scripts )action line 707
- do_action( enqueue_block_editor_assets )action line 901
WP_Customize_Widgets::print_footer_scripts()
- do_action( admin_print_footer_scripts-widgets.php )action line 978
- do_action( admin_print_footer_scripts )action line 981
- do_action( admin_footer-widgets.php )action line 984
WP_Customize_Widgets::get_setting_args()
- apply_filters( widget_customizer_setting_args )filter line 1030
WP_Customize_Widgets::wp_ajax_update_widget()
- do_action( load-widgets.php )action line 1720
- do_action( widgets.php )action line 1723
- do_action( sidebar_admin_setup )action line 1726
Properties · 15
$managerWP_Customize_Managerpublic- WP_Customize_Manager instance.
$core_widget_id_basesarrayprotected- All id_bases for widgets defined in core.
$rendered_sidebarsarrayprotected$rendered_widgetsarrayprotected$old_sidebars_widgetsarrayprotected$selective_refreshable_widgetsarrayprotected- Mapping of widget ID base to whether it supports selective refresh.
$setting_id_patternsarrayprotected- Mapping of setting type to setting ID pattern.
$before_widget_tags_seenarrayprotected- List of the tag names seen for before_widget strings.
$sidebar_instance_countarrayprotected- Keep track of the number of times that dynamic_sidebar() was called for a given sidebar index.
$context_sidebar_instance_numberint|nullprotected- The current request's sidebar_instance_number context.
$current_dynamic_sidebar_id_stackarrayprotected- Current sidebar ID being rendered.
$rendering_widget_idstring|nullprotected- Current sidebar being rendered.
$rendering_sidebar_idstring|nullprotected- Current widget being rendered.
$_captured_optionsarrayprotected- List of captured widget option updates.
$_is_capturing_option_updatesboolprotected- Whether option capture is currently happening.
Methods · 67
- __construct()Initial loader.
- get_selective_refreshable_widgets()List whether each registered widget can be use selective refresh.
- is_widget_selective_refreshable()Determines if a widget supports selective refresh.
- get_setting_type()Retrieves the widget setting type given a setting ID.
- register_settings()Inspects the incoming customized data for any widget settings, and dynamically adds them up-front so widgets will be initialized properly.
- filter_customize_dynamic_setting_args()Determines the arguments for a dynamically-created setting.
- get_post_value()Retrieves an unslashed post value or return a default.
- override_sidebars_widgets_for_theme_switch()Override sidebars_widgets for theme switch.
- filter_customize_value_old_sidebars_widgets_data()Filters old_sidebars_widgets_data Customizer setting.
- filter_option_sidebars_widgets_for_theme_switch()Filters sidebars_widgets option for theme switch.
- customize_controls_init()Ensures all widgets get loaded into the Customizer.
- schedule_customize_register()Ensures widgets are available for all types of previews.
- customize_register()Registers Customizer settings and controls for all sidebars and widgets.
- is_panel_active()Determines whether the widgets panel is active, based on whether there are sidebars registered.
- get_setting_id()Converts a widget_id into its corresponding Customizer setting ID (option name).
- is_wide_widget()Determines whether the widget is considered "wide".
- parse_widget_id()Converts a widget ID into its id_base and number components.
- parse_widget_setting_id()Converts a widget setting ID (option path) to its id_base and number components.
- print_styles()Calls admin_print_styles-widgets.php and admin_print_styles hooks to allow custom styles from plugins.
- print_scripts()Calls admin_print_scripts-widgets.php and admin_print_scripts hooks to allow custom scripts from plugins.
- enqueue_scripts()Enqueues scripts and styles for Customizer panel and export data to JavaScript.
- output_widget_control_templates()Renders the widget form control templates into the DOM.
- print_footer_scripts()Calls admin_print_footer_scripts and admin_print_scripts hooks to allow custom scripts from plugins.
- get_setting_args()Retrieves common arguments to supply when constructing a Customizer setting.
- sanitize_sidebar_widgets()Ensures sidebar widget arrays only ever contain widget IDS.
- get_available_widgets()Builds up an index of all available widgets for use in Backbone models.
- _sort_name_callback()Naturally orders available widgets by name.
- get_widget_control()Retrieves the widget control markup.
- get_widget_control_parts()Retrieves the widget control markup parts.
- customize_preview_init()Adds hooks for the Customizer preview.
- refresh_nonces()Refreshes the nonce for widget updates.
- should_load_block_editor_scripts_and_styles()Tells the script loader to load the scripts and styles of custom blocks if the widgets block editor is enabled.
- preview_sidebars_widgets()When previewing, ensures the proper previewing widgets are used.
- customize_preview_enqueue()Enqueues scripts for the Customizer preview.
- print_preview_css()Inserts default style for highlighted widget at early point so theme stylesheet can override.
- export_preview_data()Communicates the sidebars that appeared on the page at the very end of the page, and at the very end of the wp_footer,
- tally_rendered_widgets()Tracks the widgets that were rendered.
- is_widget_rendered()Determine if a widget is rendered on the page.
- is_sidebar_rendered()Determines if a sidebar is rendered on the page.
- tally_sidebars_via_is_active_sidebar_calls()Tallies the sidebars rendered via is_active_sidebar().
- tally_sidebars_via_dynamic_sidebar_calls()Tallies the sidebars rendered via dynamic_sidebar().
- get_instance_hash_key()Retrieves MAC for a serialized widget instance string.
- sanitize_widget_instance()Sanitizes a widget instance.
- sanitize_widget_js_instance()Converts a widget instance into JSON-representable format.
- sanitize_sidebar_widgets_js_instance()Strips out widget IDs for widgets which are no longer registered.
- call_widget_update()Finds and invokes the widget update and control callbacks.
- wp_ajax_update_widget()Updates widget settings asynchronously.
- customize_dynamic_partial_args()Filters arguments for dynamic widget partials.
- selective_refresh_init()Adds hooks for selective refresh.
- filter_dynamic_sidebar_params()Inject selective refresh data attributes into widget container elements.
- filter_wp_kses_allowed_data_attributes()Ensures the HTML data-* attributes for selective refresh are allowed by kses.
- start_dynamic_sidebar()Begins keeping track of the current sidebar being rendered.
- end_dynamic_sidebar()Finishes keeping track of the current sidebar being rendered.
- filter_sidebars_widgets_for_rendering_widget()Filters sidebars_widgets to ensure the currently-rendered widget is the only widget in the current sidebar.
- render_widget_partial()Renders a specific widget using the supplied sidebar arguments.
- is_option_capture_ignored()Determines whether the captured option update should be ignored.
- get_captured_options()Retrieves captured widget option updates.
- get_captured_option()Retrieves the option that was captured from being saved.
- count_captured_options()Retrieves the number of captured widget option updates.
- start_capturing_option_updates()Begins keeping track of changes to widget options, caching new values.
- capture_filter_pre_update_option()Pre-filters captured option values before updating.
- capture_filter_pre_get_option()Pre-filters captured option values before retrieving.
- stop_capturing_option_updates()Undoes any changes to the options since options capture began.
- setup_widget_addition_previews(){@internal Missing Summary}
- prepreview_added_sidebars_widgets(){@internal Missing Summary}
- prepreview_added_widget_instance(){@internal Missing Summary}
- remove_prepreview_filters(){@internal Missing Summary}
Source code
#[AllowDynamicProperties]final class WP_Customize_Widgets { /** * WP_Customize_Manager instance. * * @since 3.9.0 * @var WP_Customize_Manager */ public $manager; /** * All id_bases for widgets defined in core. * * @since 3.9.0 * @var array */ protected $core_widget_id_bases = array( 'archives', 'calendar', 'categories', 'custom_html', 'links', 'media_audio', 'media_image', 'media_video', 'meta', 'nav_menu', 'pages', 'recent-comments', 'recent-posts', 'rss', 'search', 'tag_cloud', 'text', ); /** * @since 3.9.0 * @var array */ protected $rendered_sidebars = array(); /** * @since 3.9.0 * @var array */ protected $rendered_widgets = array(); /** * @since 3.9.0 * @var array */ protected $old_sidebars_widgets = array(); /** * Mapping of widget ID base to whether it supports selective refresh. * * @since 4.5.0 * @var array */ protected $selective_refreshable_widgets; /** * Mapping of setting type to setting ID pattern. * * @since 4.2.0 * @var array */ protected $setting_id_patterns = array( 'widget_instance' => '/^widget_(?P<id_base>.+?)(?:\[(?P<widget_number>\d+)\])?$/', 'sidebar_widgets' => '/^sidebars_widgets\[(?P<sidebar_id>.+?)\]$/', ); /** * Initial loader. * * @since 3.9.0 * * @param WP_Customize_Manager $manager Customizer bootstrap instance.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 7.0.4 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.