WP_Customize_Widgets::preview_sidebars_widgets() WordPress Method

The WP_Customize_Widgets::preview_sidebars_widgets() method is used to preview how widgets will be displayed in sidebars on the front-end of a WordPress site. This is useful for making sure that widgets are properly aligned and sized before they are published.

WP_Customize_Widgets::preview_sidebars_widgets( array $sidebars_widgets ) #

When previewing, ensures the proper previewing widgets are used.


Description

Because wp_get_sidebars_widgets() gets called early at ‘init’ (via wp_convert_widget_settings()) and can set global variable $_wp_sidebars_widgets to the value of get_option( 'sidebars_widgets' ) before the Customizer preview filter is added, it has to be reset after the filter has been added.


Top ↑

Parameters

$sidebars_widgets

(array)(Required)List of widgets for the current sidebar.


Top ↑

Return

(array)


Top ↑

Source

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

	public function preview_sidebars_widgets( $sidebars_widgets ) {
		$sidebars_widgets = get_option( 'sidebars_widgets', array() );

		unset( $sidebars_widgets['array_version'] );
		return $sidebars_widgets;
	}


Top ↑

Changelog

Changelog
VersionDescription
3.9.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