wp_ajax_widgets_order() - WordPress 函数参考中文文档

返回介绍

wp_ajax_widgets_order()

发布于 2017-09-11 字数 1558 浏览 965 评论 0

wp_ajax_widgets_order()

Ajax handler for saving the widgets order.


描述


源代码

File: wp-admin/includes/ajax-actions.php

function wp_ajax_widgets_order() {
	check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' );

	if ( !current_user_can('edit_theme_options') )
		wp_die( -1 );

	unset( $_POST['savewidgets'], $_POST['action'] );

	// Save widgets order for all sidebars.
	if ( is_array($_POST['sidebars']) ) {
		$sidebars = array();
		foreach ( $_POST['sidebars'] as $key => $val ) {
			$sb = array();
			if ( !empty($val) ) {
				$val = explode(',', $val);
				foreach ( $val as $k => $v ) {
					if ( strpos($v, 'widget-') === false )
continue;

					$sb[$k] = substr($v, strpos($v, '_') + 1);
				}
			}
			$sidebars[$key] = $sb;
		}
		wp_set_sidebars_widgets($sidebars);
		wp_die( 1 );
	}

	wp_die( -1 );
}

更新日志

Version 描述
3.1.0 Introduced.

相关函数

Uses

  • wp-includes/capabilities.php:
    current_user_can()
  • wp-includes/pluggable.php:
    check_ajax_referer()
  • wp-includes/functions.php:
    wp_die()
  • wp-includes/widgets.php:
    wp_set_sidebars_widgets()

User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!