From 717c00fcfe609921643f5f8229aa12c926f4c7f2 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 27 Sep 2022 15:21:48 +0000 Subject: [PATCH] Users: Correctly pass the `context` property for persisted preferences. The user meta `context` property in `wp_register_persisted_preferences_meta()` was incorrectly configured. It should be part of the `schema` array, not the `show_in_rest` array. Follow-up to [54182]. Props talldanwp, dd32. Fixes #56665. See #56467. git-svn-id: https://develop.svn.wordpress.org/trunk@54329 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/user.php | 8 ++++---- .../tests/user/wpRegisterPersistedPreferencesMeta.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php index 0368e21753..499fd9c83a 100644 --- a/src/wp-includes/user.php +++ b/src/wp-includes/user.php @@ -4990,11 +4990,11 @@ function wp_register_persisted_preferences_meta() { 'type' => 'object', 'single' => true, 'show_in_rest' => array( - 'name' => 'persisted_preferences', - 'type' => 'object', - 'context' => array( 'edit' ), - 'schema' => 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.' ), diff --git a/tests/phpunit/tests/user/wpRegisterPersistedPreferencesMeta.php b/tests/phpunit/tests/user/wpRegisterPersistedPreferencesMeta.php index 5c136070d5..c3c4bd7a09 100644 --- a/tests/phpunit/tests/user/wpRegisterPersistedPreferencesMeta.php +++ b/tests/phpunit/tests/user/wpRegisterPersistedPreferencesMeta.php @@ -36,11 +36,11 @@ class Tests_User_WpRegisterPersistedPreferencesMeta extends WP_UnitTestCase { 'sanitize_callback' => null, 'auth_callback' => '__return_true', 'show_in_rest' => array( - 'name' => 'persisted_preferences', - 'type' => 'object', - 'context' => array( 'edit' ), - 'schema' => 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.' ),