diff --git a/src/wp-includes/option.php b/src/wp-includes/option.php index abc7b6f91d..866cbcc480 100644 --- a/src/wp-includes/option.php +++ b/src/wp-includes/option.php @@ -1819,6 +1819,27 @@ function register_initial_settings() { 'description' => __( 'Blog pages show at most.' ), 'default' => 10, ) ); + + register_setting( 'discussion', 'default_ping_status', array( + 'show_in_rest' => array( + 'schema' => array( + 'enum' => array( 'open', 'closed' ), + ), + ), + 'type' => 'string', + 'description' => __( 'Allow link notifications from other blogs (pingbacks and trackbacks) on new articles.' ), + ) ); + + register_setting( 'discussion', 'default_comment_status', array( + 'show_in_rest' => array( + 'schema' => array( + 'enum' => array( 'open', 'closed' ), + ), + ), + 'type' => 'string', + 'description' => __( 'Allow people to post comments on new articles.' ), + ) ); + } /** diff --git a/tests/phpunit/tests/rest-api/rest-settings-controller.php b/tests/phpunit/tests/rest-api/rest-settings-controller.php index 530a5398ff..f3d7b0a12c 100644 --- a/tests/phpunit/tests/rest-api/rest-settings-controller.php +++ b/tests/phpunit/tests/rest-api/rest-settings-controller.php @@ -57,6 +57,8 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase 'default_category', 'default_post_format', 'posts_per_page', + 'default_ping_status', + 'default_comment_status', ), array_keys( $data ) ); } @@ -228,6 +230,16 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase $this->assertEquals( 10, $data['posts_per_page'] ); } + public function test_update_item_with_invalid_enum() { + update_option( 'posts_per_page', 9 ); + + wp_set_current_user( $this->administrator ); + $request = new WP_REST_Request( 'PUT', '/wp/v2/settings' ); + $request->set_param( 'default_ping_status', 'open&closed' ); + $response = $this->server->dispatch( $request ); + $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); + } + public function test_delete_item() { }