' + ocdi.texts.missing_preview_image + '
'; } else { previewImageContent = '' + ocdi.import_files[ selectedImportID ]['import_file_name'] + '
' + previewImageContent + importNoticeContent ); // Display the confirmation popup. $dialogContiner.dialog( dialogOptions ); } /** * The main AJAX call, which executes the import process. * * @param FormData data The data to be passed to the AJAX call. */ function ajaxCall( data ) { $.ajax({ method: 'POST', url: ocdi.ajax_url, data: data, contentType: false, processData: false, beforeSend: function() { $( '.js-ocdi-ajax-loader' ).show(); } }) .done( function( response ) { if ( 'undefined' !== typeof response.status && 'newAJAX' === response.status ) { ajaxCall( data ); } else if ( 'undefined' !== typeof response.status && 'customizerAJAX' === response.status ) { // Fix for data.set and data.delete, which they are not supported in some browsers. var newData = new FormData(); newData.append( 'action', 'ocdi_import_customizer_data' ); newData.append( 'security', ocdi.ajax_nonce ); // Set the wp_customize=on only if the plugin filter is set to true. if ( true === ocdi.wp_customize_on ) { newData.append( 'wp_customize', 'on' ); } ajaxCall( newData ); } else if ( 'undefined' !== typeof response.status && 'afterAllImportAJAX' === response.status ) { // Fix for data.set and data.delete, which they are not supported in some browsers. var newData = new FormData(); newData.append( 'action', 'ocdi_after_import_data' ); newData.append( 'security', ocdi.ajax_nonce ); ajaxCall( newData ); } else if ( 'undefined' !== typeof response.message ) { $( '.js-ocdi-ajax-response' ).append( '' + response.message + '
' ); $( '.js-ocdi-ajax-loader' ).hide(); // Trigger custom event, when OCDI import is complete. $( document ).trigger( 'ocdiImportComplete' ); } else { $( '.js-ocdi-ajax-response' ).append( '' + response + '
Error: ' + error.statusText + ' (' + error.status + ')' + '