wp_get_sidebars_widgets()获取侧边栏

目录

描述

Retrieve full list of sidebars and their widgets.

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

wp_get_sidebars_widgets() 描述

参数

$deprecated

(boolean) (可选) Not used (deprecated).

默认值: true

wp_get_sidebars_widgets() 参数

返回值

(array

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

Example:

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */

array(4) {
  ["wp_inactive_widgets"]=>
  array(0) {
  }
  ["sidebar-1"]=>
  array(5) {
    [0]=>
    string(8) "search-2"
    [1]=>
    string(14) "recent-posts-2"
    [2]=>
    string(17) "recent-comments-2"
    [3]=>
    string(10) "archives-2"
    [4]=>
    string(12) "categories-2"
    [5]=>
    string(6) "meta-2"
  }
  ["sidebar-2"]=>
  array(0) {
  }
  ["sidebar-3"]=>
  array(0) {
  }
}

wp_get_sidebars_widgets() 返回值

注意

wp_get_sidebars_widgets() 注意

历史

添加于 版本: 2.2

wp_get_sidebars_widgets() 历史

源文件

wp_get_sidebars_widgets() 函数的代码位于 wp-includes/widgets.php

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Retrieve full list of sidebars and their widget instance IDs.
 *
 * Will upgrade sidebar widget list, if needed. Will also save updated list, if
 * needed.
 *
 * @since 2.2.0
 * @access private
 *
 * @global array $_wp_sidebars_widgets
 * @global array $sidebars_widgets
 *
 * @param bool $deprecated Not used (argument deprecated).
 * @return array Upgraded list of widgets to version 3 array format when called from the admin.
 */
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']);

	/**
	 * Filter 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 );
}

wp_get_sidebars_widgets() 源文件

相关