WP_Customize_Widgets::get_selective_refreshable_widgets() WordPress Method

The WP_Customize_Widgets::get_selective_refreshable_widgets() method allows you to get an array of widgets that are eligible for selective refresh. This can be useful if you want to selectively refresh widgets in your customizer without having to refresh the entire page.

WP_Customize_Widgets::get_selective_refreshable_widgets() #

List whether each registered widget can be use selective refresh.


Description

If the theme does not support the customize-selective-refresh-widgets feature, then this will always return an empty array.


Top ↑

Return

(array) Mapping of id_base to support. If theme doesn't support selective refresh, an empty array is returned.


Top ↑

Source

File: wp-includes/class-wp-customize-widgets.php

	public function get_selective_refreshable_widgets() {
		global $wp_widget_factory;
		if ( ! current_theme_supports( 'customize-selective-refresh-widgets' ) ) {
			return array();
		}
		if ( ! isset( $this->selective_refreshable_widgets ) ) {
			$this->selective_refreshable_widgets = array();
			foreach ( $wp_widget_factory->widgets as $wp_widget ) {
				$this->selective_refreshable_widgets[ $wp_widget->id_base ] = ! empty( $wp_widget->widget_options['customize_selective_refresh'] );
			}
		}
		return $this->selective_refreshable_widgets;
	}


Top ↑

Changelog

Changelog
VersionDescription
4.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More