| 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 1 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 __('Before We Import Your Demo', 'wpdirectorykit'); ?></h2> |
| 26 |
<p><?php echo __('To ensure the best experience, installing the following plugins is strongly recommended, and in some cases required.', 'wpdirectorykit'); ?></p> |
| 27 |
</div> |
| 28 |
<?php foreach($theme_plugins as $theme_plugin): ?> |
| 29 |
|
| 30 |
<label slug="<?php echo esc_attr($theme_plugin['slug']); ?>" source="<?php echo isset($theme_plugin['source'])?esc_attr($theme_plugin['source']):''; ?>" |
| 31 |
class="plugin-item plugin-item-<?php echo esc_attr($theme_plugin['slug']); ?> <?php echo is_plugin_active( $theme_plugin['slug'].'/'.$theme_plugin['slug'].'.php' )?'plugin_active':'';?>plugin-item--active plugin-item--required" for="wdk-<?php echo esc_attr($theme_plugin['slug']); ?>-plugin"> |
| 32 |
<div class="plugin-item-content"> |
| 33 |
<div class="plugin-item-content-title"> |
| 34 |
<h3><img src="<?php echo WPDIRECTORYKIT_URL; ?>admin/img/loader.svg" class="wdk-loading wdk-loading-md hidden" alt="Loading..."><?php echo esc_html($theme_plugin['name']); ?></h3> |
| 35 |
</div> |
| 36 |
<div class="plugin-item-error js-wdk-plugin-item-error"></div> |
| 37 |
<div class="plugin-item-info js-wdk-plugin-item-info"></div> |
| 38 |
</div> |
| 39 |
<span class="plugin-item-checkbox"> |
| 40 |
<?php if(is_plugin_active( $theme_plugin['slug'].'/'.$theme_plugin['slug'].'.php' )): ?> |
| 41 |
<span class="green"><?php echo __('Already active', 'wpdirectorykit'); ?><span> |
| 42 |
<?php else: ?> |
| 43 |
<input type="checkbox" id="wdk-<?php echo esc_attr($theme_plugin['slug']); ?>-plugin" name="<?php echo esc_attr($theme_plugin['slug']); ?>" <?php echo is_plugin_active( $theme_plugin['slug'].'/'.$theme_plugin['slug'].'.php' )?'':'checked="checked"';?>> |
| 44 |
<?php endif; ?> |
| 45 |
</span> |
| 46 |
</label> |
| 47 |
|
| 48 |
<?php endforeach; ?> |
| 49 |
</div> |
| 50 |
</div> |
| 51 |
<p class="wdk_button-container"> |
| 52 |
<a href="<?php echo admin_url('tools.php?page=wdk_demo_import&function=step_2');?>" class="install_button wdk_button button button-hero button-primary"><?php echo __('Continue & Import','wpdirectorykit'); ?></a> |
| 53 |
</p> |
| 54 |
</div> |
| 55 |
<br/> |
| 56 |
<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> |
| 57 |
</div> |
| 58 |
|
| 59 |
<script> |
| 60 |
|
| 61 |
jQuery( document ).ready(function($) { |
| 62 |
|
| 63 |
$('.install_button').click(function (event) { |
| 64 |
|
| 65 |
// Don't follow the link |
| 66 |
event.preventDefault(); |
| 67 |
|
| 68 |
if($(this)[0].hasAttribute("disabled")) |
| 69 |
{ |
| 70 |
alert('Wait until proccess complete or if takes to long (more then 10 mins) then refresh'); |
| 71 |
return false; |
| 72 |
} |
| 73 |
|
| 74 |
$(this).attr('disabled','disabled'); |
| 75 |
|
| 76 |
$.ajaxSetup({async: false}); |
| 77 |
|
| 78 |
var is_failed=false; |
| 79 |
|
| 80 |
$( ".plugin-item" ).each(function() { |
| 81 |
var slug = $( this ).attr('slug'); |
| 82 |
var source = $( this ).attr('source'); |
| 83 |
|
| 84 |
if (typeof source == "undefined" ) { |
| 85 |
source = ''; |
| 86 |
} |
| 87 |
|
| 88 |
if(!$(this).find('input[type="checkbox"]').is(':checked')) |
| 89 |
return; |
| 90 |
|
| 91 |
var ajax_nonce = '<?php echo wp_create_nonce( 'updates' ); ?>'; |
| 92 |
|
| 93 |
var that = $(this); |
| 94 |
|
| 95 |
var ajax_param = { |
| 96 |
"page": 'wdk_backendajax', |
| 97 |
"function": 'plugin_upgrader', |
| 98 |
"action": 'wdk_public_action', |
| 99 |
"slug": slug, |
| 100 |
"source": source, |
| 101 |
"_wpnonce": '<?php echo esc_js(wp_create_nonce( 'wdk-plugin_upgrader'));?>', |
| 102 |
}; |
| 103 |
|
| 104 |
that.attr("disabled", "disabled"); |
| 105 |
/*that.unbind('click');*/ |
| 106 |
|
| 107 |
var ajax_indicator = $(this).find('.wdk-loading'); |
| 108 |
ajax_indicator.show(); |
| 109 |
that.addClass('active'); |
| 110 |
var jqxhr = $.post( "<?php echo admin_url( 'admin-ajax.php' ); ?>", ajax_param, function(data) { |
| 111 |
|
| 112 |
if(data.success == true) |
| 113 |
{ |
| 114 |
that.find('h3').css('color', 'green'); |
| 115 |
} else if(typeof(data.slug) != "undefined") { |
| 116 |
that.after("<div class=\"alert alert-danger\" role=\"alert\"><?php echo __('Error:', 'wpdirectorykit'); ?> <b style=\"color:red;\">"+data.slug+" "+data.message+"</b></div>"); |
| 117 |
} |
| 118 |
else |
| 119 |
{ |
| 120 |
that.after("<div class=\"alert alert-danger\" role=\"alert\"><?php echo __('Error:', 'wpdirectorykit'); ?> <b style=\"color:red;\">"+data+"</b></div>"); |
| 121 |
} |
| 122 |
|
| 123 |
}) |
| 124 |
.done(function(data) { |
| 125 |
}) |
| 126 |
.fail(function(data) { |
| 127 |
|
| 128 |
if(typeof(data.responseText) != "undefined") |
| 129 |
{ |
| 130 |
that.after("<div class=\"alert alert-danger\" role=\"alert\"><?php echo __('Error:', 'wpdirectorykit'); ?> <b style=\"color:red;\">"+data.responseText+"</b></div>"); |
| 131 |
} |
| 132 |
else |
| 133 |
{ |
| 134 |
that.after("<div class=\"alert alert-danger\" role=\"alert\"><?php echo __('Error:', 'wpdirectorykit'); ?> <b style=\"color:red;\">"+data+"</b></div>"); |
| 135 |
} |
| 136 |
|
| 137 |
is_failed=true; |
| 138 |
}) |
| 139 |
.always(function(data) { |
| 140 |
ajax_indicator.hide(); |
| 141 |
that.removeClass('active'); |
| 142 |
}); |
| 143 |
|
| 144 |
}); |
| 145 |
|
| 146 |
$.ajaxSetup({async: true}); |
| 147 |
|
| 148 |
if(is_failed == false) |
| 149 |
window.location.replace($(this).attr('href')); |
| 150 |
else |
| 151 |
$(this).removeAttr('disabled'); |
| 152 |
}); |
| 153 |
}); |
| 154 |
|
| 155 |
|
| 156 |
</script> |
| 157 |
|
| 158 |
<style> |
| 159 |
|
| 160 |
.wdk-install-plugins-content-header { |
| 161 |
padding: 30px; |
| 162 |
border-bottom: 1px solid #dddddd; |
| 163 |
} |
| 164 |
|
| 165 |
.inside .plugin-item{ |
| 166 |
display: -webkit-box; |
| 167 |
display: -ms-flexbox; |
| 168 |
display: flex; |
| 169 |
-webkit-box-pack: justify; |
| 170 |
-ms-flex-pack: justify; |
| 171 |
justify-content: space-between; |
| 172 |
-webkit-box-align: center; |
| 173 |
-ms-flex-align: center; |
| 174 |
align-items: center; |
| 175 |
margin: 0 30px; |
| 176 |
padding: 0px 0; |
| 177 |
border-bottom: 1px solid #eeeeee; |
| 178 |
} |
| 179 |
|
| 180 |
.wdk-loading-md { |
| 181 |
width: 32px; |
| 182 |
height: 32px; |
| 183 |
} |
| 184 |
|
| 185 |
.wdk-loading { |
| 186 |
-webkit-animation: 0.65s linear infinite wdk-rotation; |
| 187 |
animation: 0.65s linear infinite wdk-rotation; |
| 188 |
height:18px; |
| 189 |
margin-right: 5px; |
| 190 |
} |
| 191 |
|
| 192 |
.wdk-loading.hidden |
| 193 |
{ |
| 194 |
display:none; |
| 195 |
} |
| 196 |
|
| 197 |
@keyframes wdk-rotation { |
| 198 |
from { |
| 199 |
transform: rotate(0deg); |
| 200 |
} |
| 201 |
to { |
| 202 |
transform: rotate(359deg); |
| 203 |
} |
| 204 |
} |
| 205 |
|
| 206 |
span.green |
| 207 |
{ |
| 208 |
color: green; |
| 209 |
} |
| 210 |
|
| 211 |
</style> |
| 212 |
|
| 213 |
<?php $this->view('general/footer', $data); ?> |