Commit 3a0e96c09b for wordpress.org
commit 3a0e96c09bd493bc75fd5a097c7dfd064164f070
Author: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Date: Mon Nov 30 15:00:57 2026 +0000
REST API: Limit the `show_on_front` and `start_of_week` settings to the values they accept.
Adds an `enum` with `posts` and `page` to the schema of the `show_on_front` setting, and a `minimum` of 0 and a `maximum` of 6 to the schema of the `start_of_week` setting. A value outside them now fails with `rest_invalid_param` and nothing is saved. Before, the request succeeded: `show_on_front` was saved as `posts` and `start_of_week` was saved as sent.
A stored value outside them is returned as `null` by the settings route, like any stored value that does not match its schema. The schema is shared with the settings abilities, which get the same limits.
Developed in https://github.com/WordPress/wordpress-develop/pull/16207.
Props jorgefilipecosta, westonruter, abhishekfdd.
Fixes #66804.
Built from https://develop.svn.wordpress.org/trunk@65828
git-svn-id: http://core.svn.wordpress.org/trunk@64857 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/option.php b/wp-includes/option.php
index e53aedeb47..bf463d9847 100644
--- a/wp-includes/option.php
+++ b/wp-includes/option.php
@@ -2846,7 +2846,12 @@ function register_initial_settings() {
'general',
'start_of_week',
array(
- 'show_in_rest' => true,
+ 'show_in_rest' => array(
+ 'schema' => array(
+ 'minimum' => 0,
+ 'maximum' => 6,
+ ),
+ ),
'show_in_abilities' => true,
'type' => 'integer',
'description' => __( 'A day number of the week that the week should start on.' ),
@@ -2918,7 +2923,11 @@ function register_initial_settings() {
'reading',
'show_on_front',
array(
- 'show_in_rest' => true,
+ 'show_in_rest' => array(
+ 'schema' => array(
+ 'enum' => array( 'posts', 'page' ),
+ ),
+ ),
'show_in_abilities' => true,
'type' => 'string',
'label' => __( 'Show on front' ),
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 4bc99262c2..9ce5123066 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.3-alpha-65826';
+$wp_version = '7.3-alpha-65828';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.