REST API: Add missing options to the settings endpoint.

This adds the `show_on_front`, `page_on_front`, and `page_for_posts` options to the settings endpoint that were missed during WP 6.0 backports.

Related PR from Gutenberg repository:
* [https://github.com/WordPress/gutenberg/pull/38607 #38607 Page for Posts: Display notice in template panel]

Props Mamaduka, spacedmonkey, gziolo, jameskoster.
See #56058.

git-svn-id: https://develop.svn.wordpress.org/trunk@53588 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2022-06-29 13:46:37 +00:00
parent aaa4d1a4a7
commit a0b53ac1db
3 changed files with 52 additions and 0 deletions

View File

@ -2063,6 +2063,7 @@ function set_site_transient( $transient, $value, $expiration = 0 ) {
* does not encompass all settings available in WordPress.
*
* @since 4.7.0
* @since 6.1.0 The `show_on_front`, `page_on_front`, and `page_for_posts` options were added.
*/
function register_initial_settings() {
register_setting(
@ -2220,6 +2221,36 @@ function register_initial_settings() {
)
);
register_setting(
'reading',
'show_on_front',
array(
'show_in_rest' => true,
'type' => 'string',
'description' => __( 'What to show on the front page' ),
)
);
register_setting(
'reading',
'page_on_front',
array(
'show_in_rest' => true,
'type' => 'number',
'description' => __( 'The ID of the page that should be displayed on the front page' ),
)
);
register_setting(
'reading',
'page_for_posts',
array(
'show_in_rest' => true,
'type' => 'number',
'description' => __( 'The ID of the page that should display the latest posts' ),
)
);
register_setting(
'discussion',
'default_ping_status',

View File

@ -106,6 +106,9 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase
'default_category',
'default_post_format',
'posts_per_page',
'show_on_front',
'page_on_front',
'page_for_posts',
'default_ping_status',
'default_comment_status',
'site_icon', // Registered in wp-includes/blocks/site-logo.php

View File

@ -9628,6 +9628,21 @@ mockedApiResponse.Schema = {
"type": "integer",
"required": false
},
"show_on_front": {
"description": "What to show on the front page",
"type": "string",
"required": false
},
"page_on_front": {
"description": "The ID of the page that should be displayed on the front page",
"type": "number",
"required": false
},
"page_for_posts": {
"description": "The ID of the page that should display the latest posts",
"type": "number",
"required": false
},
"default_ping_status": {
"description": "Allow link notifications from other blogs (pingbacks and trackbacks) on new articles.",
"type": "string",
@ -12283,6 +12298,9 @@ mockedApiResponse.settings = {
"default_category": 1,
"default_post_format": "0",
"posts_per_page": 10,
"show_on_front": "posts",
"page_on_front": 0,
"page_for_posts": 0,
"default_ping_status": "open",
"default_comment_status": "open",
"site_logo": null,