Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



_jsonp_wp_die_handler ›

Seit5.2.0
Veraltetn/v
_jsonp_wp_die_handler ( $message, $title = '', $args = array() )
Zugriff:
  • private
Parameter: (3)
  • (string) $message Error message.
    Erforderlich: Ja
  • (string) $title Optional. Error title. Default empty.
    Erforderlich: Nein
    Standard: (leer)
  • (string|array) $args Optional. Arguments to control behavior. Default empty array.
    Erforderlich: Nein
    Standard: array()
Definiert in:
Codex:

Kills WordPress execution and displays JSONP response with an error message.

This is the handler for wp_die() when processing JSONP requests.



Quellcode

function _jsonp_wp_die_handler( $message, $title = '', $args = array() ) {
	list( $message, $title, $r ) = _wp_die_process_input( $message, $title, $args );

	$data = array(
		'code'              => $r['code'],
		'message'           => $message,
		'data'              => array(
			'status' => $r['response'],
		),
		'additional_errors' => $r['additional_errors'],
	);

	if ( ! headers_sent() ) {
		header( 'Content-Type: application/javascript; charset=utf-8' );
		header( 'X-Content-Type-Options: nosniff' );
		header( 'X-Robots-Tag: noindex' );
		if ( null !== $r['response'] ) {
			status_header( $r['response'] );
		}
		nocache_headers();
	}

	$result         = wp_json_encode( $data );
	$jsonp_callback = $_GET['_jsonp'];
	echo '/**/' . $jsonp_callback . '(' . $result . ')';
	if ( $r['exit'] ) {
		die();
	}
}