GC_Customize_Manager::gc_die()
最后更新于:2021-11-27 02:44:16
GC_Customize_Manager::gc_die( string|GC_Error$ajax_message, string$message=null)Custom gc_die wrapper. 响应s either the standard message for UI or the Ajax message.
参数
- $ajax_message
-
(string|GC_Error) (Required) Ajax return.
- $message
-
(string) (Optional) UI message.
Default value: null
源文件
文件: gc-includes/class-gc-customize-manager.php
protected function gc_die( $ajax_message, $message = null ) {
if ( $this->doing_ajax() ) {
gc_die( $ajax_message );
}
if ( ! $message ) {
$message = __( 'Something went wrong.' );
}
if ( $this->messenger_channel ) {
ob_start();
gc_enqueue_scripts();
gc_print_scripts( array( 'customize-base' ) );
$settings = array(
'messengerArgs' => array(
'channel' => $this->messenger_channel,
'url' => gc_customize_url(),
),
'error' => $ajax_message,
);
?>
<script>
( function( api, settings ) {
var preview = new api.Messenger( settings.messengerArgs );
preview.send( 'iframe-loading-error', settings.error );
} )( gc.customize, <?php echo gc_json_encode( $settings ); ?> );
</script>
<?php
$message .= ob_get_clean();
}
gc_die( $message );
}