Custom wp_die wrapper. Returns either the standard message for UI or the Ajax message.
Parameters
$ajax_message
string|WP_Errorrequired- Ajax return.
$message
stringoptional- UI message.
Default:
null
Source
protected function wp_die( $ajax_message, $message = null ) {
if ( $this->doing_ajax() ) {
wp_die( $ajax_message );
}
if ( ! $message ) {
$message = __( 'Something went wrong.' );
}
if ( $this->messenger_channel ) {
ob_start();
wp_enqueue_scripts();
wp_print_scripts( array( 'customize-base' ) );
$settings = array(
'messengerArgs' => array(
'channel' => $this->messenger_channel,
'url' => wp_customize_url(),
),
'error' => $ajax_message,
);
$message .= ob_get_clean();
ob_start();
?>
<script>
( function( api, settings ) {
var preview = new api.Messenger( settings.messengerArgs );
preview.send( 'iframe-loading-error', settings.error );
} )( wp.customize, <?php echo wp_json_encode( $settings ); ?> );
</script>
<?php
$message .= wp_get_inline_script_tag( wp_remove_surrounding_empty_script_tags( ob_get_clean() ) );
}
wp_die( $message );
}
Changelog
Version | Description |
---|---|
3.4.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.