返回介绍

wp_get_sidebars_widgets()

发布于 2017-09-11 12:08:54 字数 3233 浏览 899 评论 0 收藏 0

Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

wp_get_sidebars_widgets( bool $deprecated = true )

Retrieve full list of sidebars and their widget instance IDs.


description

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


参数

$deprecated

(bool) (Optional) Not used (argument deprecated).

Default value: true


返回值

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


源代码

File: wp-includes/widgets.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 );
}

更新日志

Versiondescription
2.2.0Introduced.

相关函数

Uses

  • wp-includes/load.php: is_admin()
  • wp-includes/functions.php: _deprecated_argument()
  • wp-includes/plugin.php: apply_filters()
  • wp-includes/option.php: get_option()
  • wp-includes/widgets.php: sidebars_widgets

Used By

  • wp-admin/includes/ajax-actions.php: wp_ajax_delete_inactive_widgets()
  • wp-admin/includes/ajax-actions.php: wp_ajax_save_widget()
  • wp-includes/widgets.php: _wp_sidebars_changed()
  • wp-includes/widgets.php: dynamic_sidebar()
  • wp-includes/widgets.php: is_active_widget()
  • wp-includes/widgets.php: is_active_sidebar()
  • wp-includes/class-wp-customize-widgets.php: WP_Customize_Widgets::override_sidebars_widgets_for_theme_switch()
  • wp-includes/class-wp-customize-widgets.php: WP_Customize_Widgets::customize_register()
  • Show 3 more used by Hide more used by

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文