You appear to be a bot. Output may be restricted
Description
traps wp_die()
calls and outputs a JSON response instead.
The result is always output, never returned.
Usage
WPCOM_JSON_API::trap_wp_die( $error_code, $http_status );
Parameters
- $error_code
- ( string|null ) optional – Call with string to start the trapping. Call with null to stop.
- $http_status
- ( int ) optional default: 400 – HTTP status code, 400 by default.
Returns
void
Source
File name: jetpack/class.json-api.php
Lines:
1 to 27 of 27
function trap_wp_die( $error_code = null, $http_status = 400 ) { if ( is_null( $error_code ) ) { $this->trapped_error = null; // Stop trapping remove_filter( 'wp_die_handler', array( $this, 'wp_die_handler_callback' ) ); return; } // If API called via PHP, bail: don't do our custom wp_die(). Do the normal wp_die(). if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { if ( ! defined( 'REST_API_REQUEST' ) || ! REST_API_REQUEST ) { return; } } else { if ( ! defined( 'XMLRPC_REQUEST' ) || ! XMLRPC_REQUEST ) { return; } } $this->trapped_error = array( 'status' => $http_status, 'code' => $error_code, 'message' => '', ); // Start trapping add_filter( 'wp_die_handler', array( $this, 'wp_die_handler_callback' ) ); }