WordPress at a glance

wp_get_sidebars_widgets() WP 1.0

Retrieve full list of sidebars and their widget instance IDs.

Will upgrade sidebar widget list, if needed. Will also save updated list, if needed.

  • Global. Array. $_wp_sidebars_widgets
  • Global. Array. $sidebars_widgets
✈ 1 time = 0.00007s = very fast | 50000 times = 3.69s = fast | PHP 7.1.1, WP 4.7.2
Hooks from function:
Return

Array. Upgraded list of widgets to version 3 array format when called from the admin.

Usage

wp_get_sidebars_widgets( $deprecated );
$deprecated(true/false)
Not used (argument deprecated).
Default: true

Code of wp_get_sidebars_widgets: wp-includes/widgets.php VER 5.0.1

<?php
function wp_get_sidebars_widgets( $deprecated = true ) {
	if ( $deprecated !== true )
		_deprecated_argument( __FUNCTION__, '2.8.1' );

	global $_wp_sidebars_widgets, $sidebars_widgets;

	// If loading from front page, consult $_wp_sidebars_widgets rather than options
	// to see if wp_convert_widget_settings() has made manipulations in memory.
	if ( !is_admin() ) {
		if ( empty($_wp_sidebars_widgets) )
			$_wp_sidebars_widgets = get_option('sidebars_widgets', array());

		$sidebars_widgets = $_wp_sidebars_widgets;
	} else {
		$sidebars_widgets = get_option('sidebars_widgets', array());
	}

	if ( is_array( $sidebars_widgets ) && isset($sidebars_widgets['array_version']) )
		unset($sidebars_widgets['array_version']);

	/**
	 * Filters the list of sidebars and their widgets.
	 *
	 * @since 2.7.0
	 *
	 * @param array $sidebars_widgets An associative array of sidebars and their widgets.
	 */
	return apply_filters( 'sidebars_widgets', $sidebars_widgets );
}

Related Functions

From tag: Sidebar (widgets)

No comments
    Hello, !     Log In . Register