| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) |
| 3 |
exit; |
| 4 |
?> |
| 5 |
<div class="imh-6310"> |
| 6 |
<h1>Plugin Export / Import <span class="imh-6310-pro">(Pro)</span></h1> |
| 7 |
|
| 8 |
<button class="imh-6310-btn-primary" id="export-image-map-hotspot-data">Export Plugin Data</button> |
| 9 |
<button class="imh-6310-btn-primary" id="import-image-map-hotspot-data">Import Plugin Data</button> |
| 10 |
<?php |
| 11 |
|
| 12 |
wp_enqueue_media(); |
| 13 |
|
| 14 |
|
| 15 |
if (!empty($_POST['update'])) { |
| 16 |
$nonce = $_REQUEST['_wpnonce']; |
| 17 |
if (!wp_verify_nonce($nonce, 'imh-6310-nonce-update')) { |
| 18 |
die('You do not have sufficient permissions to access this page.'); |
| 19 |
} else { |
| 20 |
if($_POST['file_url'] && substr($_POST['file_url'], -3) == 'txt'){ |
| 21 |
imh_6310_import_full_plugin($_POST['file_url']); |
| 22 |
} else{ |
| 23 |
echo "<p style='color: red; font-size: 14px;'>Can't import data. Please upload valid file.</p>"; |
| 24 |
} |
| 25 |
} |
| 26 |
} |
| 27 |
?> |
| 28 |
<form action="" method="post"> |
| 29 |
<?php wp_nonce_field("imh-6310-nonce-update") ?> |
| 30 |
<div class="imh-6310-modal-body-form"> |
| 31 |
<table width="100%" cellpadding="10" cellspacing="0" class="import-file" style="display: none"> |
| 32 |
<tr> |
| 33 |
<td width="70px"><b>File URL</b></td> |
| 34 |
<td> |
| 35 |
<input type="text" required name="file_url" id="file-url" class="imh-6310-form-input" style="width: 300px;"> |
| 36 |
<input type="button" id="upload-csv-file" value="Upload file" class="imh-6310-btn-default"> |
| 37 |
</td> |
| 38 |
</tr> |
| 39 |
<tr> |
| 40 |
<td colspan="3"> |
| 41 |
<input type="submit" name="update" class="imh-6310-btn-primary imh-6310-margin-right-10" value="Import Data" onclick="return confirm('If you import you will lose all of your previous data of this plugin. Do you want to continue?');" /> |
| 42 |
</td> |
| 43 |
</tr> |
| 44 |
</table> |
| 45 |
</div> |
| 46 |
<br class="imh-6310-clear" /> |
| 47 |
</form> |
| 48 |
<script> |
| 49 |
jQuery(document).ready(function() { |
| 50 |
/* ######### Media Start ########### */ |
| 51 |
jQuery("body").on("click", "#import-image-map-hotspot-data", function(e) { |
| 52 |
jQuery('.import-file').removeClass('imh-6310-hide'); |
| 53 |
}); |
| 54 |
|
| 55 |
jQuery('body').on('click', '#export-image-map-hotspot-data', function(){ |
| 56 |
if (!confirm("Do you want to export service box full plugin?")){ |
| 57 |
return false; |
| 58 |
} else{ |
| 59 |
window.open(jQuery('#export-image-map-hotspot-plugin').attr('href'), '_blank'); |
| 60 |
} |
| 61 |
}); |
| 62 |
|
| 63 |
jQuery("body").on("click", "#upload-csv-file", function(e) { |
| 64 |
e.preventDefault(); |
| 65 |
var image = wp.media({ |
| 66 |
title: 'Upload File', |
| 67 |
multiple: false |
| 68 |
}).open() |
| 69 |
.on('select', function(e) { |
| 70 |
var uploaded_image = image.state().get('selection').first(); |
| 71 |
var image_url = uploaded_image.toJSON().url; |
| 72 |
jQuery("#file-url").val(image_url); |
| 73 |
}); |
| 74 |
|
| 75 |
jQuery("#imh_6310_add_new_media").css({ |
| 76 |
"overflow-x": "hidden", |
| 77 |
"overflow-y": "auto" |
| 78 |
}); |
| 79 |
}); |
| 80 |
}); |
| 81 |
</script> |