| 1 |
<?php |
| 2 |
/** |
| 3 |
* The template for Settings. |
| 4 |
* |
| 5 |
* This is the template that edit form settings |
| 6 |
* |
| 7 |
*/ |
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; // Exit if accessed directly. |
| 11 |
} |
| 12 |
?> |
| 13 |
<!-- This file should primarily consist of HTML with a little bit of PHP. --> |
| 14 |
|
| 15 |
<div class="wrap wdk-wrap"> |
| 16 |
<h1 class="wp-heading-inline"><?php echo __('WDK Demo Import', 'wpdirectorykit'); ?></h1> |
| 17 |
<br /><br /> |
| 18 |
<div class="wdk-body"> |
| 19 |
<div class="postbox" style="display: block;"> |
| 20 |
<div class="postbox-header"> |
| 21 |
<h3><?php echo __('Step 2 Import for theme:', 'wpdirectorykit'); ?> <?php echo esc_html($current_theme->get( 'Name' )); ?></h3> |
| 22 |
</div> |
| 23 |
<div class="inside"> |
| 24 |
<div class="wdk-install-plugins-content-header"> |
| 25 |
<h2><?php echo __('Importing Demo Content', 'wpdirectorykit'); ?></h2> |
| 26 |
<p><?php echo __('Now we importing demo content like Pages/Posts/Menus and Listings', 'wpdirectorykit'); ?></p> |
| 27 |
</div> |
| 28 |
<label slug="" source="" class="plugin-item install_content"> |
| 29 |
<div class="plugin-item-content"> |
| 30 |
<div class="plugin-item-content-title"> |
| 31 |
<h3><img src="<?php echo WPDIRECTORYKIT_URL; ?>admin/img/loader.svg" class="wdk-loading wdk-loading-md hidden" alt="Loading..."><?php echo __('Importing Pages/Posts/Menus','wpdirectorykit'); ?></h3> |
| 32 |
</div> |
| 33 |
<div class="plugin-item-error js-wdk-plugin-item-error"></div> |
| 34 |
<div class="plugin-item-info js-wdk-plugin-item-info"></div> |
| 35 |
</div> |
| 36 |
</label> |
| 37 |
|
| 38 |
<label slug="" source="" class="plugin-item install_listings"> |
| 39 |
<div class="plugin-item-content"> |
| 40 |
<div class="plugin-item-content-title"> |
| 41 |
<h3><img src="<?php echo WPDIRECTORYKIT_URL; ?>admin/img/loader.svg" class="wdk-loading wdk-loading-md hidden" alt="Loading..."><?php echo __('Importing Listings and Configurations','wpdirectorykit'); ?></h3> |
| 42 |
</div> |
| 43 |
<div class="plugin-item-error js-wdk-plugin-item-error"></div> |
| 44 |
<div class="plugin-item-info js-wdk-plugin-item-info"></div> |
| 45 |
</div> |
| 46 |
</label> |
| 47 |
</div> |
| 48 |
</div> |
| 49 |
<p class="wdk_button-container"> |
| 50 |
<a href="<?php echo get_home_url();?>" class="install_button wdk_button button button-hero button-primary" disabled="disabled"><?php echo __('Visit Website', 'wpdirectorykit'); ?></a> |
| 51 |
</p> |
| 52 |
</div> |
| 53 |
<br/> |
| 54 |
<div class="alert alert-info" role="alert"><a href="<?php echo esc_html($current_theme->get( 'ThemeURI' )); ?>" target="_blank"><?php echo __('Theme Data will be downloaded from API:','wpdirectorykit'); ?> <?php echo esc_html($current_theme->get( 'AuthorURI' )); ?> <?php echo __('On any trouble contact us via website contact page.','wpdirectorykit'); ?></a></div> |
| 55 |
</div> |
| 56 |
|
| 57 |
<script> |
| 58 |
|
| 59 |
jQuery( document ).ready(function($) { |
| 60 |
|
| 61 |
function install_content(){ |
| 62 |
|
| 63 |
var ajax_nonce = '<?php echo wp_create_nonce( 'updates' ); ?>'; |
| 64 |
|
| 65 |
var that = $('.install_content'); |
| 66 |
|
| 67 |
var ajax_param = { |
| 68 |
"page": 'wdk_backendajax', |
| 69 |
"function": 'install_content', |
| 70 |
"action": 'wdk_public_action', |
| 71 |
"_wpnonce": '<?php echo esc_js(wp_create_nonce( 'wdk-install_content'));?>', |
| 72 |
}; |
| 73 |
|
| 74 |
var ajax_indicator = that.find('.wdk-loading'); |
| 75 |
ajax_indicator.show(); |
| 76 |
|
| 77 |
var jqxhr = $.post( "<?php echo admin_url( 'admin-ajax.php' ); ?>", ajax_param, function(data) |
| 78 |
{ |
| 79 |
if(data.success == true) |
| 80 |
{ |
| 81 |
that.find('h3').css('color', 'green'); |
| 82 |
} else if(typeof(data.message) != "undefined") { |
| 83 |
that.after("<div class=\"alert alert-danger\" role=\"alert\"><?php echo __('Error:', 'wpdirectorykit'); ?> <b style=\"color:red;\">"+data.message+"</b></div>"); |
| 84 |
} |
| 85 |
else |
| 86 |
{ |
| 87 |
that.after("<div class=\"alert alert-danger\" role=\"alert\"><?php echo __('Error:', 'wpdirectorykit'); ?> <b style=\"color:red;\">"+data+"</b></div>"); |
| 88 |
} |
| 89 |
|
| 90 |
}) |
| 91 |
.done(function(data) { |
| 92 |
}) |
| 93 |
.fail(function(data) { |
| 94 |
//console.log(data.responseText); |
| 95 |
|
| 96 |
if(typeof(data.responseText) != "undefined") |
| 97 |
{ |
| 98 |
that.after("<div class=\"alert alert-danger\" role=\"alert\"><?php echo __('Error:', 'wpdirectorykit'); ?> <b style=\"color:red;\">"+data.responseText+"</b></div>"); |
| 99 |
} |
| 100 |
else |
| 101 |
{ |
| 102 |
that.after("<div class=\"alert alert-danger\" role=\"alert\"><?php echo __('Error:', 'wpdirectorykit'); ?> <b style=\"color:red;\">"+data+"</b></div>"); |
| 103 |
} |
| 104 |
|
| 105 |
//alert( "Error: " + data ); |
| 106 |
is_failed=true; |
| 107 |
}) |
| 108 |
.always(function(data) { |
| 109 |
ajax_indicator.hide(); |
| 110 |
that.removeClass('active'); |
| 111 |
}); |
| 112 |
|
| 113 |
} |
| 114 |
|
| 115 |
function install_listings(){ |
| 116 |
|
| 117 |
var ajax_nonce = '<?php echo wp_create_nonce( 'updates' ); ?>'; |
| 118 |
|
| 119 |
var that = $('.install_listings'); |
| 120 |
|
| 121 |
var ajax_param = { |
| 122 |
"page": 'wdk_backendajax', |
| 123 |
"function": 'install_listings', |
| 124 |
"action": 'wdk_public_action', |
| 125 |
"_wpnonce": '<?php echo esc_js(wp_create_nonce( 'wdk-install_listings'));?>', |
| 126 |
}; |
| 127 |
|
| 128 |
var ajax_indicator = that.find('.wdk-loading'); |
| 129 |
ajax_indicator.show(); |
| 130 |
|
| 131 |
var jqxhr = $.post( "<?php echo admin_url( 'admin-ajax.php' ); ?>", ajax_param, function(data) |
| 132 |
{ |
| 133 |
if(data.success == true) |
| 134 |
{ |
| 135 |
that.find('h3').css('color', 'green'); |
| 136 |
} else if(typeof(data.message) != "undefined") { |
| 137 |
that.after("<div class=\"alert alert-danger\" role=\"alert\"><?php echo __('Error:', 'wpdirectorykit'); ?> <b style=\"color:red;\">"+data.message+"</b></div>"); |
| 138 |
} |
| 139 |
else |
| 140 |
{ |
| 141 |
that.after("<div class=\"alert alert-danger\" role=\"alert\"><?php echo __('Error:', 'wpdirectorykit'); ?> <b style=\"color:red;\">"+data+"</b></div>"); |
| 142 |
} |
| 143 |
|
| 144 |
}) |
| 145 |
.done(function(data) { |
| 146 |
}) |
| 147 |
.fail(function(data) { |
| 148 |
if(typeof(data.responseText) != "undefined") |
| 149 |
{ |
| 150 |
that.after("<div class=\"alert alert-danger\" role=\"alert\"><?php echo __('Error:', 'wpdirectorykit'); ?> <b style=\"color:red;\">"+data.responseText+"</b></div>"); |
| 151 |
} |
| 152 |
else |
| 153 |
{ |
| 154 |
that.after("<div class=\"alert alert-danger\" role=\"alert\"><?php echo __('Error:', 'wpdirectorykit'); ?> <b style=\"color:red;\">"+data+"</b></div>"); |
| 155 |
} |
| 156 |
is_failed=true; |
| 157 |
}) |
| 158 |
.always(function(data) { |
| 159 |
ajax_indicator.hide(); |
| 160 |
that.removeClass('active'); |
| 161 |
}); |
| 162 |
|
| 163 |
} |
| 164 |
|
| 165 |
$.ajaxSetup({async: false}); |
| 166 |
|
| 167 |
install_content(); |
| 168 |
|
| 169 |
install_listings(); |
| 170 |
|
| 171 |
$('.install_button').removeAttr('disabled'); |
| 172 |
|
| 173 |
$.ajaxSetup({async: true}); |
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
/* |
| 188 |
$('.install_button').click(function (event) { |
| 189 |
|
| 190 |
// Don't follow the link |
| 191 |
event.preventDefault(); |
| 192 |
|
| 193 |
if($(this)[0].hasAttribute("disabled")) |
| 194 |
{ |
| 195 |
alert('Wait until proccess complete or if takes to long (more then 10 mins) then refresh'); |
| 196 |
return false; |
| 197 |
} |
| 198 |
|
| 199 |
$(this).attr('disabled','disabled'); |
| 200 |
|
| 201 |
var is_failed=false; |
| 202 |
|
| 203 |
$( ".plugin-item" ).each(function() { |
| 204 |
var slug = $( this ).attr('slug'); |
| 205 |
var source = $( this ).attr('source'); |
| 206 |
|
| 207 |
if (typeof source == "undefined" ) { |
| 208 |
source = ''; |
| 209 |
} |
| 210 |
|
| 211 |
if(!$(this).find('input[type="checkbox"]').is(':checked')) |
| 212 |
return; |
| 213 |
|
| 214 |
var ajax_nonce = '<?php echo wp_create_nonce( 'updates' ); ?>'; |
| 215 |
|
| 216 |
var that = $(this); |
| 217 |
|
| 218 |
var ajax_param = { |
| 219 |
"page": 'wdk_backendajax', |
| 220 |
"function": 'plugin_upgrader', |
| 221 |
"action": 'wdk_public_action', |
| 222 |
"slug": slug, |
| 223 |
"source": source, |
| 224 |
}; |
| 225 |
|
| 226 |
that.attr("disabled", "disabled"); |
| 227 |
|
| 228 |
that.addClass('active'); |
| 229 |
var jqxhr = $.post( "<?php echo admin_url( 'admin-ajax.php' ); ?>", ajax_param, function(data) { |
| 230 |
|
| 231 |
if(data.success == true) |
| 232 |
{ |
| 233 |
that.find('h3').css('color', 'green'); |
| 234 |
} else { |
| 235 |
that.after("<div class=\"alert alert-danger\" role=\"alert\"><?php echo __('Error:', 'wpdirectorykit'); ?> <b style=\"color:red;\">"+data.slug+" "+data.message+"</b></div>"); |
| 236 |
} |
| 237 |
|
| 238 |
}) |
| 239 |
.done(function(data) { |
| 240 |
}) |
| 241 |
.fail(function(data) { |
| 242 |
that.after("<div class=\"alert alert-danger\" role=\"alert\"><?php echo __('Error:', 'wpdirectorykit'); ?> <b style=\"color:red;\">"+data+"</b></div>"); |
| 243 |
is_failed=true; |
| 244 |
}) |
| 245 |
.always(function(data) { |
| 246 |
ajax_indicator.hide(); |
| 247 |
that.removeClass('active'); |
| 248 |
}); |
| 249 |
|
| 250 |
}); |
| 251 |
|
| 252 |
$.ajaxSetup({async: true}); |
| 253 |
|
| 254 |
if(is_failed == false) |
| 255 |
window.location.replace($(this).attr('href')); |
| 256 |
else |
| 257 |
$(this).removeAttr('disabled'); |
| 258 |
});*/ |
| 259 |
}); |
| 260 |
|
| 261 |
|
| 262 |
</script> |
| 263 |
|
| 264 |
<style> |
| 265 |
|
| 266 |
.wdk-install-plugins-content-header { |
| 267 |
padding: 30px; |
| 268 |
border-bottom: 1px solid #dddddd; |
| 269 |
} |
| 270 |
|
| 271 |
.inside .plugin-item{ |
| 272 |
display: -webkit-box; |
| 273 |
display: -ms-flexbox; |
| 274 |
display: flex; |
| 275 |
-webkit-box-pack: justify; |
| 276 |
-ms-flex-pack: justify; |
| 277 |
justify-content: space-between; |
| 278 |
-webkit-box-align: center; |
| 279 |
-ms-flex-align: center; |
| 280 |
align-items: center; |
| 281 |
margin: 0 30px; |
| 282 |
padding: 0px 0; |
| 283 |
border-bottom: 1px solid #eeeeee; |
| 284 |
} |
| 285 |
|
| 286 |
.wdk-loading-md { |
| 287 |
width: 32px; |
| 288 |
height: 32px; |
| 289 |
} |
| 290 |
|
| 291 |
.wdk-loading { |
| 292 |
-webkit-animation: 0.65s linear infinite wdk-rotation; |
| 293 |
animation: 0.65s linear infinite wdk-rotation; |
| 294 |
height:18px; |
| 295 |
margin-right: 5px; |
| 296 |
} |
| 297 |
|
| 298 |
.wdk-loading.hidden |
| 299 |
{ |
| 300 |
display:none; |
| 301 |
} |
| 302 |
|
| 303 |
@keyframes wdk-rotation { |
| 304 |
from { |
| 305 |
transform: rotate(0deg); |
| 306 |
} |
| 307 |
to { |
| 308 |
transform: rotate(359deg); |
| 309 |
} |
| 310 |
} |
| 311 |
|
| 312 |
span.green |
| 313 |
{ |
| 314 |
color: green; |
| 315 |
} |
| 316 |
|
| 317 |
</style> |
| 318 |
|
| 319 |
<?php $this->view('general/footer', $data); ?> |