REST API: Add the `default_comment_status` and `default_ping_status` options to the setting endpoint.
Props joehoyle. See #38490. git-svn-id: https://develop.svn.wordpress.org/trunk@38971 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
0888864e29
commit
8c0d5292a2
|
@ -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.' ),
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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() {
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue