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

返回介绍

get_all_user_settings()

发布于 2017-09-10 字数1833 浏览 824 评论 0

get_all_user_settings()

Retrieve all user interface settings.


描述


返回值

(array) the last saved user settings or empty array.


源代码

File: wp-includes/option.php

function get_all_user_settings() {
	global $_updated_user_settings;

	if ( ! $user_id = get_current_user_id() ) {
		return array();
	}

	if ( isset( $_updated_user_settings ) && is_array( $_updated_user_settings ) ) {
		return $_updated_user_settings;
	}

	$user_settings = array();

	if ( isset( $_COOKIE['wp-settings-' . $user_id] ) ) {
		$cookie = preg_replace( '/[^A-Za-z0-9=&_-]/', '', $_COOKIE['wp-settings-' . $user_id] );

		if ( strpos( $cookie, '=' ) ) { // '=' cannot be 1st char
			parse_str( $cookie, $user_settings );
		}
	} else {
		$option = get_user_option( 'user-settings', $user_id );

		if ( $option && is_string( $option ) ) {
			parse_str( $option, $user_settings );
		}
	}

	$_updated_user_settings = $user_settings;
	return $user_settings;
}

更新日志

Version 描述
2.7.0 Introduced.

相关函数

Uses

  • wp-includes/user.php:
    get_current_user_id()
  • wp-includes/user.php:
    get_user_option()

Used By

  • wp-includes/option.php:
    get_user_setting()
  • wp-includes/option.php:
    set_user_setting()
  • wp-includes/option.php:
    delete_user_setting()

User Contributed Notes

发布评论

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

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