wp_register_persisted_preferences_meta()WP 6.1.0

Registers the user meta property for persisted preferences.

This property is used to store user preferences across page reloads and is currently used by the block editor for preferences like 'fullscreenMode' and 'fixedToolbar'.

Хуков нет.

Возвращает

null. Ничего.

Использование

wp_register_persisted_preferences_meta();

Заметки

  • Global. wpdb. $wpdb WordPress database abstraction object.

Список изменений

С версии 6.1.0 Введена.

Код wp_register_persisted_preferences_meta() WP 6.1.1

function wp_register_persisted_preferences_meta() {
	/*
	 * Create a meta key that incorporates the blog prefix so that each site
	 * on a multisite can have distinct user preferences.
	 */
	global $wpdb;
	$meta_key = $wpdb->get_blog_prefix() . 'persisted_preferences';

	register_meta(
		'user',
		$meta_key,
		array(
			'type'         => 'object',
			'single'       => true,
			'show_in_rest' => array(
				'name'   => 'persisted_preferences',
				'type'   => 'object',
				'schema' => array(
					'type'                 => 'object',
					'context'              => array( 'edit' ),
					'properties'           => array(
						'_modified' => array(
							'description' => __( 'The date and time the preferences were updated.' ),
							'type'        => 'string',
							'format'      => 'date-time',
							'readonly'    => false,
						),
					),
					'additionalProperties' => true,
				),
			),
		)
	);
}