From d989b8e402932c9f039e1586bad2414d533a8262 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Sun, 3 Dec 2017 22:28:33 +0000 Subject: [PATCH] REST API: Include permalink_structure in the settings route. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are situations where the REST API client wants to be able to read and set the permalink_structure option. Though this doesn’t fix the use case of front-end rendered unauthenticated websites, it still has utility as a setting in it’s own right. Props aduth. See #41014. git-svn-id: https://develop.svn.wordpress.org/trunk@42359 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/option.php | 5 +++++ tests/phpunit/tests/rest-api/rest-settings-controller.php | 1 + 2 files changed, 6 insertions(+) diff --git a/src/wp-includes/option.php b/src/wp-includes/option.php index 265b0bdbe0..f8f3180d5c 100644 --- a/src/wp-includes/option.php +++ b/src/wp-includes/option.php @@ -2020,6 +2020,11 @@ function register_initial_settings() { ) ); + register_setting( 'permalink', 'permalink_structure', array( + 'show_in_rest' => true, + 'type' => 'string', + 'description' => __( 'Custom URL structure for permalinks and archives.' ), + ) ); } /** diff --git a/tests/phpunit/tests/rest-api/rest-settings-controller.php b/tests/phpunit/tests/rest-api/rest-settings-controller.php index 1be304dd92..dcf2d57af3 100644 --- a/tests/phpunit/tests/rest-api/rest-settings-controller.php +++ b/tests/phpunit/tests/rest-api/rest-settings-controller.php @@ -72,6 +72,7 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase 'posts_per_page', 'default_ping_status', 'default_comment_status', + 'permalink_structure', ); if ( ! is_multisite() ) {