get_all_user_settings

函数
get_all_user_settings ( No parameters )
返回值
  • (array) The last saved user settings or empty array.
定义位置
相关方法
delete_all_user_settingswp_set_all_user_settingsget_user_settingset_user_settingwp_user_settings
引入
2.7.0
弃用
-

get_all_user_settings: 这个函数返回一个所有用户设置的数组。

检索所有的用户界面设置。

function get_all_user_settings() {
	global $_updated_user_settings;

	$user_id = get_current_user_id();
	if ( ! $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;
}

常见问题

FAQs
查看更多 >