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

返回介绍

wp_ajax_save_user_color_scheme()

发布于 2017-09-11 字数1704 浏览 871 评论 0

wp_ajax_save_user_color_scheme()

Ajax handler for auto-saving the selected color scheme for a user’s own profile.


描述


源代码

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

function wp_ajax_save_user_color_scheme() {
	global $_wp_admin_css_colors;

	check_ajax_referer( 'save-color-scheme', 'nonce' );

	$color_scheme = sanitize_key( $_POST['color_scheme'] );

	if ( ! isset( $_wp_admin_css_colors[ $color_scheme ] ) ) {
		wp_send_json_error();
	}

	$previous_color_scheme = get_user_meta( get_current_user_id(), 'admin_color', true );
	update_user_meta( get_current_user_id(), 'admin_color', $color_scheme );

	wp_send_json_success( array(
		'previousScheme' => 'admin-color-' . $previous_color_scheme,
		'currentScheme'  => 'admin-color-' . $color_scheme
	) );
}

更新日志

Version 描述
3.8.0 Introduced.

相关函数

Uses

  • wp-includes/formatting.php:
    sanitize_key()
  • wp-includes/pluggable.php:
    check_ajax_referer()
  • wp-includes/functions.php:
    wp_send_json_error()
  • wp-includes/functions.php:
    wp_send_json_success()
  • wp-includes/user.php:
    get_user_meta()
  • wp-includes/user.php:
    update_user_meta()
  • wp-includes/user.php:
    get_current_user_id()
  • Show 2 more uses
    Hide more uses


User Contributed Notes

发布评论

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

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