PluginProbe
Autoptimize / trunk
Autoptimize vtrunk
3.1.16 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 All 108 releases
autoptimize / classes / critcss-inc / admin_settings_impexp.js.php

admin_settings_impexp.js.php in Autoptimize trunk, at classes/critcss-inc/admin_settings_impexp.js.php

69 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Javascript to import and export AO CCSS settings.
4 */
5
6 ?>
7 // Export and download settings
8 function exportSettings( idToEdit ) {
9 console.log('Exporting...');
10 var data = {
11 'action': 'ao_ccss_export',
12 'ao_ccss_export_nonce': '<?php echo wp_create_nonce( 'ao_ccss_export_nonce' ); ?>',
13 };
14
15 jQuery.post(ajaxurl, data, function(response) {
16 response_array=JSON.parse(response);
17 if (response_array['code'] == 200) {
18 <?php
19 if ( is_multisite() ) {
20 $blog_id = '/' . get_current_blog_id() . '/';
21 } else {
22 $blog_id = '/';
23 }
24 ?>
25 export_url = '<?php echo content_url(); ?>/uploads/ao_ccss' + '<?php echo $blog_id; ?>' + response_array['file'];
26 msg = "Download export-file from: <a href=\"" + export_url + "\" target=\"_blank\">"+ export_url + "</a>";
27 } else {
28 msg = response_array['msg'];
29 }
30 jQuery("#importdialog").html(msg);
31 jQuery("#importdialog").dialog({
32 autoOpen: true,
33 height: 210,
34 width: 700,
35 title: "<?php esc_html_e( 'Export settings result', 'autoptimize' ); ?>",
36 modal: true,
37 buttons: {
38 OK: function() {
39 jQuery( this ).dialog( "close" );
40 }
41 }
42 });
43 });
44 }
45
46 // Upload and import settings
47 function upload(){
48 var fd = new FormData();
49 var file = jQuery(document).find('#settingsfile');
50 var settings_file = file[0].files[0];
51 fd.append('file', settings_file);
52 fd.append('action', 'ao_ccss_import');
53 fd.append('ao_ccss_import_nonce', '<?php echo wp_create_nonce( 'ao_ccss_import_nonce' ); ?>');
54
55 jQuery.ajax({
56 url: ajaxurl,
57 type: 'POST',
58 data: fd,
59 contentType: false,
60 processData: false,
61 success: function(response) {
62 response_array=JSON.parse(response);
63 if (response_array['code'] == 200) {
64 window.location.reload();
65 }
66 }
67 });
68 }
69