Changeset 48361
- Timestamp:
- 07/07/2020 04:59:51 AM (4 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r48359 r48361 4039 4039 */ 4040 4040 function wp_send_json( $response, $status_code = null ) { 4041 if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { 4042 _doing_it_wrong( __FUNCTION__, __( 'Return a WP_REST_Response or WP_Error object from your callback when using the REST API.' ), '5.5.0' ); 4043 } 4044 4041 4045 if ( ! headers_sent() ) { 4042 4046 header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) ); -
trunk/src/wp-includes/rest-api.php
r48357 r48361 185 185 add_action( 'deprecated_argument_run', 'rest_handle_deprecated_argument', 10, 3 ); 186 186 add_filter( 'deprecated_argument_trigger_error', '__return_false' ); 187 add_action( 'doing_it_wrong_run', 'rest_handle_doing_it_wrong', 10, 3 ); 188 add_filter( 'doing_it_wrong_trigger_error', '__return_false' ); 187 189 } 188 190 … … 596 598 597 599 header( sprintf( 'X-WP-DeprecatedParam: %s', $string ) ); 600 } 601 602 /** 603 * Handles _doing_it_wrong errors. 604 * 605 * @since 5.5.0 606 * 607 * @param string $function The function that was called. 608 * @param string $message A message explaining what has been done incorrectly. 609 * @param string|null $version The version of WordPress where the message was added. 610 */ 611 function rest_handle_doing_it_wrong( $function, $message, $version ) { 612 if ( ! WP_DEBUG || headers_sent() ) { 613 return; 614 } 615 616 if ( is_null( $version ) ) { 617 /* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message */ 618 $string = __( '%1$s (%2$s)' ); 619 $string = sprintf( $string, $function, $message ); 620 } else { 621 /* translators: Developer debugging message. 1: PHP function name, 2: Version information message, 3: Explanatory message. */ 622 $string = __( '%1$s (since %2$s; %3$s)' ); 623 $string = sprintf( $string, $function, $version, $message ); 624 } 625 626 header( sprintf( 'X-WP-DoingItWrong: %s', $string ) ); 598 627 } 599 628
Note: See TracChangeset
for help on using the changeset viewer.