WP_Customize_Manager::wp_die() WordPress Method

The wp_die() function is used to kill a Wordpress process. It takes an optional message and error code as its parameters. The message is displayed to the user and the error code is used in the Wordpress log.

WP_Customize_Manager::wp_die( string|WP_Error $ajax_message, string $message = null ) #

Custom wp_die wrapper. Returns either the standard message for UI or the Ajax message.


Parameters

$ajax_message

(string|WP_Error)(Required)Ajax return.

$message

(string)(Optional) UI message.

Default value: null


Top ↑

Source

File: wp-includes/class-wp-customize-manager.php

	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,
			);
			?>
			<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 .= ob_get_clean();
		}

		wp_die( $message );
	}


Top ↑

Changelog

Changelog
VersionDescription
3.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.