Changeset 9884 for sites/trunk/wordpress.org/public_html/wp-content/plugins/phpunit-test-reporter/src/class-restapi.php
- Timestamp:
- 05/19/2020 05:33:14 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/phpunit-test-reporter/src/class-restapi.php
r6522 r9884 13 13 public static function register_routes() { 14 14 register_rest_route( 15 'wp-unit-test-api/v1', 'results', array( 15 'wp-unit-test-api/v1', 16 'results', 17 array( 16 18 'methods' => 'POST', 17 19 'callback' => array( __CLASS__, 'add_results_callback' ), … … 52 54 if ( ! is_numeric( $value ) ) { 53 55 return new WP_Error( 54 'rest_invalid', __( 'Value must be numeric.', 'ptr' ), array( 56 'rest_invalid', 57 __( 'Value must be numeric.', 'ptr' ), 58 array( 55 59 'status' => 400, 56 60 ) … … 61 65 if ( empty( $value ) || ! is_string( $value ) ) { 62 66 return new WP_Error( 63 'rest_invalid', __( 'Value must be a non-empty string.', 'ptr' ), array( 67 'rest_invalid', 68 __( 'Value must be a non-empty string.', 'ptr' ), 69 array( 64 70 'status' => 400, 65 71 ) … … 71 77 if ( null === json_decode( $value ) ) { 72 78 return new WP_Error( 73 'rest_invalid', __( 'Value must be encoded JSON.', 'ptr' ), array( 79 'rest_invalid', 80 __( 'Value must be encoded JSON.', 'ptr' ), 81 array( 74 82 'status' => 400, 75 83 ) … … 79 87 } 80 88 return new WP_Error( 81 'rest_invalid', __( 'Invalid key specified.', 'ptr' ), array( 89 'rest_invalid', 90 __( 'Invalid key specified.', 'ptr' ), 91 array( 82 92 'status' => 400, 83 93 ) … … 88 98 if ( ! current_user_can( 'edit_results' ) ) { 89 99 return new WP_Error( 90 'rest_unauthorized', __( 'Sorry, you are not allowed to create results.', 'ptr' ), array( 100 'rest_unauthorized', 101 __( 'Sorry, you are not allowed to create results.', 'ptr' ), 102 array( 91 103 'status' => is_user_logged_in() ? 403 : 401, 92 104 )
Note: See TracChangeset
for help on using the changeset viewer.