Commit a7c2f3f85f for wordpress.org
commit a7c2f3f85f64207b924146554b5f837d683bc323
Author: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Date: Tue Nov 24 09:43:54 2026 +0000
Abilities API: Read the schema default in `core/settings-get`.
Uses the default declared in a setting's `show_in_abilities` or `show_in_rest` schema when reading a setting that was never saved, rather than only the registered `default` argument. The registered default is still used when the schema declares none.
The tests are updated to ensure schema defaults are returned for settings that were never saved.
Developed in: https://github.com/WordPress/wordpress-develop/pull/16062
Follow-up to r64311.
Reviewed by peterwilsoncc.
Props mukesh27, peterwilsoncc.
Fixes #64605.
Built from https://develop.svn.wordpress.org/trunk@65752
git-svn-id: http://core.svn.wordpress.org/trunk@64782 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/abilities/class-wp-abilities-settings.php b/wp-includes/abilities/class-wp-abilities-settings.php
index 3beb82570c..5729103846 100644
--- a/wp-includes/abilities/class-wp-abilities-settings.php
+++ b/wp-includes/abilities/class-wp-abilities-settings.php
@@ -220,7 +220,8 @@ final class WP_Abilities_Settings {
* Reads {@see get_registered_settings()} and keeps only settings flagged with a truthy
* `show_in_abilities` argument, of a type the settings endpoint supports. Each entry is
* keyed by its exposed name and carries the underlying option name, the settings group,
- * the registered default (null when there is none), and a JSON Schema describing the value.
+ * the default (the exposure schema's default when it declares one, otherwise the registered
+ * default, or null when there is none), and a JSON Schema describing the value.
*
* Two settings exposed under the same name trigger a notice, and the later one is exposed.
*
@@ -260,10 +261,14 @@ final class WP_Abilities_Settings {
);
}
+ /*
+ * As the settings endpoint does, a default declared in the exposure schema
+ * overrides the registered default.
+ */
$settings[ $exposed_name ] = array(
'option' => $option_name,
'group' => $args['group'] ?? '',
- 'default' => $args['default'] ?? null,
+ 'default' => array_key_exists( 'default', $schema ) ? $schema['default'] : ( $args['default'] ?? null ),
'schema' => $schema,
);
}
diff --git a/wp-includes/version.php b/wp-includes/version.php
index f4f71a9b16..76607c108e 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-RC2-65751';
+$wp_version = '7.2-RC2-65752';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.