Version Description
Download this release
Release Info
Developer | Nikschavan |
Plugin | |
Version | 1.1.8 |
Comparing to | |
See all releases |
Code changes from version 1.1.7 to 1.1.8
- astra-sites.php +54 -54
- inc/assets/css/admin.css +457 -397
- inc/assets/js/admin-page.js +1359 -1359
- inc/assets/js/astra-sites-api.js +57 -57
- inc/assets/js/astra-sites-notices.js +20 -20
- inc/assets/js/eventsource.js +673 -673
- inc/assets/js/eventsource.min.js +5 -5
- inc/assets/js/render-grid.js +518 -518
- inc/classes/class-astra-sites-page.php +270 -270
- inc/importers/batch-processing/class-astra-sites-batch-processing-elementor.php +326 -324
- inc/importers/batch-processing/helpers/class-wp-async-request.php +164 -164
- inc/importers/batch-processing/helpers/class-wp-background-process.php +513 -513
- inc/importers/class-astra-sites-helper.php +307 -307
- inc/importers/class-widgets-importer.php +278 -278
- inc/importers/wxr-importer/class-astra-wxr-importer.php +331 -320
- inc/importers/wxr-importer/class-logger.php +140 -140
- inc/importers/wxr-importer/class-wp-importer-logger-serversentevents.php +46 -46
- inc/importers/wxr-importer/class-wxr-import-info.php +20 -20
- inc/importers/wxr-importer/class-wxr-importer.php +2298 -2298
- inc/includes/admin-page.php +286 -286
- languages/astra-sites.pot +623 -623
- readme.txt +168 -162
astra-sites.php
CHANGED
@@ -1,54 +1,54 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Plugin Name: Astra Starter Sites
|
4 |
-
* Plugin URI: http://www.wpastra.com/pro/
|
5 |
-
* Description: Import free sites build with Astra theme.
|
6 |
-
* Version: 1.1.
|
7 |
-
* Author: Brainstorm Force
|
8 |
-
* Author URI: http://www.brainstormforce.com
|
9 |
-
* Text Domain: astra-sites
|
10 |
-
*
|
11 |
-
* @package Astra Sites
|
12 |
-
*/
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Set constants.
|
16 |
-
*/
|
17 |
-
if ( ! defined( 'ASTRA_SITES_NAME' ) ) {
|
18 |
-
define( 'ASTRA_SITES_NAME', __( 'Astra Sites', 'astra-sites' ) );
|
19 |
-
}
|
20 |
-
|
21 |
-
if ( ! defined( 'ASTRA_SITES_VER' ) ) {
|
22 |
-
define( 'ASTRA_SITES_VER', '1.1.
|
23 |
-
}
|
24 |
-
|
25 |
-
if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
|
26 |
-
define( 'ASTRA_SITES_FILE', __FILE__ );
|
27 |
-
}
|
28 |
-
|
29 |
-
if ( ! defined( 'ASTRA_SITES_BASE' ) ) {
|
30 |
-
define( 'ASTRA_SITES_BASE', plugin_basename( ASTRA_SITES_FILE ) );
|
31 |
-
}
|
32 |
-
|
33 |
-
if ( ! defined( 'ASTRA_SITES_DIR' ) ) {
|
34 |
-
define( 'ASTRA_SITES_DIR', plugin_dir_path( ASTRA_SITES_FILE ) );
|
35 |
-
}
|
36 |
-
|
37 |
-
if ( ! defined( 'ASTRA_SITES_URI' ) ) {
|
38 |
-
define( 'ASTRA_SITES_URI', plugins_url( '/', ASTRA_SITES_FILE ) );
|
39 |
-
}
|
40 |
-
|
41 |
-
if ( ! function_exists( 'astra_sites_setup' ) ) :
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Astra Sites Setup
|
45 |
-
*
|
46 |
-
* @since 1.0.5
|
47 |
-
*/
|
48 |
-
function astra_sites_setup() {
|
49 |
-
require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites.php';
|
50 |
-
}
|
51 |
-
|
52 |
-
add_action( 'plugins_loaded', 'astra_sites_setup' );
|
53 |
-
|
54 |
-
endif;
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: Astra Starter Sites
|
4 |
+
* Plugin URI: http://www.wpastra.com/pro/
|
5 |
+
* Description: Import free sites build with Astra theme.
|
6 |
+
* Version: 1.1.8
|
7 |
+
* Author: Brainstorm Force
|
8 |
+
* Author URI: http://www.brainstormforce.com
|
9 |
+
* Text Domain: astra-sites
|
10 |
+
*
|
11 |
+
* @package Astra Sites
|
12 |
+
*/
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Set constants.
|
16 |
+
*/
|
17 |
+
if ( ! defined( 'ASTRA_SITES_NAME' ) ) {
|
18 |
+
define( 'ASTRA_SITES_NAME', __( 'Astra Sites', 'astra-sites' ) );
|
19 |
+
}
|
20 |
+
|
21 |
+
if ( ! defined( 'ASTRA_SITES_VER' ) ) {
|
22 |
+
define( 'ASTRA_SITES_VER', '1.1.8' );
|
23 |
+
}
|
24 |
+
|
25 |
+
if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
|
26 |
+
define( 'ASTRA_SITES_FILE', __FILE__ );
|
27 |
+
}
|
28 |
+
|
29 |
+
if ( ! defined( 'ASTRA_SITES_BASE' ) ) {
|
30 |
+
define( 'ASTRA_SITES_BASE', plugin_basename( ASTRA_SITES_FILE ) );
|
31 |
+
}
|
32 |
+
|
33 |
+
if ( ! defined( 'ASTRA_SITES_DIR' ) ) {
|
34 |
+
define( 'ASTRA_SITES_DIR', plugin_dir_path( ASTRA_SITES_FILE ) );
|
35 |
+
}
|
36 |
+
|
37 |
+
if ( ! defined( 'ASTRA_SITES_URI' ) ) {
|
38 |
+
define( 'ASTRA_SITES_URI', plugins_url( '/', ASTRA_SITES_FILE ) );
|
39 |
+
}
|
40 |
+
|
41 |
+
if ( ! function_exists( 'astra_sites_setup' ) ) :
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Astra Sites Setup
|
45 |
+
*
|
46 |
+
* @since 1.0.5
|
47 |
+
*/
|
48 |
+
function astra_sites_setup() {
|
49 |
+
require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites.php';
|
50 |
+
}
|
51 |
+
|
52 |
+
add_action( 'plugins_loaded', 'astra_sites_setup' );
|
53 |
+
|
54 |
+
endif;
|
inc/assets/css/admin.css
CHANGED
@@ -1,397 +1,457 @@
|
|
1 |
-
.wrap .status,
|
2 |
-
.wrap .site-type {
|
3 |
-
position: absolute;
|
4 |
-
z-index: 1;
|
5 |
-
color: #fff;
|
6 |
-
padding: 0.5em 1em;
|
7 |
-
top: -0.5em;
|
8 |
-
text-transform: uppercase;
|
9 |
-
}
|
10 |
-
.wrap .status,
|
11 |
-
.wrap .site-type.premium {
|
12 |
-
background: #0073aa;
|
13 |
-
}
|
14 |
-
.wrap .status {
|
15 |
-
left: -0.5em;
|
16 |
-
}
|
17 |
-
.wrap .site-type.premium {
|
18 |
-
right: -0.5em;
|
19 |
-
}
|
20 |
-
|
21 |
-
.wrap .status.publish,
|
22 |
-
.wrap .site-type.free {
|
23 |
-
display: none;
|
24 |
-
}
|
25 |
-
|
26 |
-
.install-theme-info .site-type {
|
27 |
-
display: none;
|
28 |
-
}
|
29 |
-
|
30 |
-
.theme {
|
31 |
-
position: relative;
|
32 |
-
}
|
33 |
-
.wrap .astra-sites-preview .site-type.premium {
|
34 |
-
display: block;
|
35 |
-
display: none;
|
36 |
-
position: relative;
|
37 |
-
margin: 0.5em 0em 1em 0em;
|
38 |
-
top: 0;
|
39 |
-
left: 0;
|
40 |
-
text-align: center;
|
41 |
-
}
|
42 |
-
|
43 |
-
.theme-details-read-more.open {
|
44 |
-
margin: 0.5em 0 0 0;
|
45 |
-
}
|
46 |
-
|
47 |
-
.astra-sites-preview .theme-screenshot {
|
48 |
-
width: 100%;
|
49 |
-
}
|
50 |
-
|
51 |
-
.install-theme-info .site-type.premium {
|
52 |
-
display: none;
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Required Plugins
|
57 |
-
*/
|
58 |
-
.required-plugins.loading {
|
59 |
-
text-align: center;
|
60 |
-
}
|
61 |
-
.required-plugins button {
|
62 |
-
float: right;
|
63 |
-
}
|
64 |
-
.required-plugins .plugin-card {
|
65 |
-
float: none;
|
66 |
-
width: 100%;
|
67 |
-
border: none;
|
68 |
-
margin: 0 0 0.8em 0;
|
69 |
-
display: flex;
|
70 |
-
justify-content: space-between;
|
71 |
-
align-items: center;
|
72 |
-
transition: background ease 0.8s;
|
73 |
-
}
|
74 |
-
.required-plugins .plugin-card.plugin-card-update-failed {
|
75 |
-
flex-wrap: wrap;
|
76 |
-
}
|
77 |
-
.required-plugins .spinner {
|
78 |
-
float: none;
|
79 |
-
margin: 0;
|
80 |
-
}
|
81 |
-
|
82 |
-
.expanded .wp-full-overlay-footer {
|
83 |
-
height: 111px;
|
84 |
-
}
|
85 |
-
|
86 |
-
.wp-full-overlay-footer .view-site,
|
87 |
-
.wp-full-overlay-footer .go-pro,
|
88 |
-
.wp-full-overlay-footer .astra-demo-import {
|
89 |
-
width: 100%;
|
90 |
-
text-align: center;
|
91 |
-
}
|
92 |
-
|
93 |
-
.wp-core-ui .wp-full-overlay-footer .button.button-hero,
|
94 |
-
.wp-core-ui .wp-full-overlay-footer .button-group.button-hero .button {
|
95 |
-
padding: 0 10px 1px;
|
96 |
-
}
|
97 |
-
|
98 |
-
.wp-full-overlay-footer .installing:before {
|
99 |
-
vertical-align: text-bottom;
|
100 |
-
}
|
101 |
-
|
102 |
-
.required-plugins-wrap h4 {
|
103 |
-
margin: 1em 0 0.5em 0;
|
104 |
-
padding: 0.5em 0;
|
105 |
-
transition: all ease 0.3s;
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Read more link
|
110 |
-
*/
|
111 |
-
.wp-core-ui .theme-details-read-more:focus,
|
112 |
-
.wp-core-ui .theme-details-read-more:hover {
|
113 |
-
outline: none;
|
114 |
-
box-shadow: none;
|
115 |
-
}
|
116 |
-
.wp-core-ui .theme-details-read-more {
|
117 |
-
margin: 10px 0;
|
118 |
-
display: none;
|
119 |
-
text-decoration: none;
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Go pro.
|
124 |
-
*/
|
125 |
-
.wp-core-ui .go-pro.button[disabled] {
|
126 |
-
background-color: #fcb92c !important;
|
127 |
-
color: white !important;
|
128 |
-
box-shadow: 1px 0 #eab23a !important;
|
129 |
-
text-shadow: 1px 0 #6b4e13 !important;
|
130 |
-
border-color: #e2a932 !important;
|
131 |
-
cursor: pointer;
|
132 |
-
}
|
133 |
-
.wp-core-ui .view-site .dashicons,
|
134 |
-
.wp-core-ui .go-pro .dashicons {
|
135 |
-
font-size: 1rem;
|
136 |
-
vertical-align: middle;
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* Errors
|
141 |
-
*/
|
142 |
-
.plugin-card-update-failed .notice {
|
143 |
-
margin-top: 1.5em;
|
144 |
-
}
|
145 |
-
|
146 |
-
.no-themes {
|
147 |
-
margin-top: 40px;
|
148 |
-
}
|
149 |
-
|
150 |
-
.no-themes p {
|
151 |
-
font-size: 15px;
|
152 |
-
}
|
153 |
-
|
154 |
-
.no-themes .left-margin {
|
155 |
-
margin-left: 30px;
|
156 |
-
}
|
157 |
-
|
158 |
-
/**
|
159 |
-
*
|
160 |
-
*/
|
161 |
-
.astra-sites-preview .wp-full-overlay-sidebar-content {
|
162 |
-
bottom: 100px;
|
163 |
-
}
|
164 |
-
|
165 |
-
.footer-import-button-wrap {
|
166 |
-
padding: 10px 20px;
|
167 |
-
}
|
168 |
-
|
169 |
-
.footer-import-button-wrap .button {
|
170 |
-
margin: 0;
|
171 |
-
}
|
172 |
-
|
173 |
-
.astra-sites-preview.expanded .wp-full-overlay-footer {
|
174 |
-
left: initial;
|
175 |
-
}
|
176 |
-
|
177 |
-
/**
|
178 |
-
* Menu Page
|
179 |
-
*/
|
180 |
-
.astra-sites-title {
|
181 |
-
float: left;
|
182 |
-
font-size: 23px;
|
183 |
-
font-weight: 400;
|
184 |
-
margin: 0 0 6px 0px;
|
185 |
-
padding: 0;
|
186 |
-
line-height: 29px;
|
187 |
-
}
|
188 |
-
|
189 |
-
#astra-sites-menu-page {
|
190 |
-
margin-top: 10px;
|
191 |
-
}
|
192 |
-
|
193 |
-
/**
|
194 |
-
* API Error
|
195 |
-
*/
|
196 |
-
.astra-api-error {
|
197 |
-
margin: 0 0 0.5em 0;
|
198 |
-
}
|
199 |
-
|
200 |
-
/**
|
201 |
-
* Grid
|
202 |
-
*/
|
203 |
-
.wp-filter .search-form {
|
204 |
-
margin-left: 1em;
|
205 |
-
}
|
206 |
-
.wp-filter .search-form input[type="search"] {
|
207 |
-
width: 200px;
|
208 |
-
font-size: 13px;
|
209 |
-
padding: 5px 10px;
|
210 |
-
}
|
211 |
-
.section-left {
|
212 |
-
display: inline-block;
|
213 |
-
}
|
214 |
-
.section-right {
|
215 |
-
float: right;
|
216 |
-
}
|
217 |
-
.filter-count {
|
218 |
-
min-width: 3em;
|
219 |
-
}
|
220 |
-
.astra-site-preview-on {
|
221 |
-
overflow: hidden;
|
222 |
-
}
|
223 |
-
|
224 |
-
#astra-sites-menu-page .notice {
|
225 |
-
margin-left: 0;
|
226 |
-
width: auto;
|
227 |
-
float: none;
|
228 |
-
}
|
229 |
-
.filters-wrap {
|
230 |
-
display: inline-block;
|
231 |
-
}
|
232 |
-
.spinner-wrap {
|
233 |
-
text-align: center;
|
234 |
-
}
|
235 |
-
.spinner-wrap .spinner {
|
236 |
-
float: none;
|
237 |
-
}
|
238 |
-
.hide-me {
|
239 |
-
display: none !important;
|
240 |
-
}
|
241 |
-
#astra-sites-admin {
|
242 |
-
height: 100vh;
|
243 |
-
}
|
244 |
-
.install-theme-info > .notice {
|
245 |
-
margin: 5px 0 10px 0;
|
246 |
-
}
|
247 |
-
|
248 |
-
.astra-sites-suggestions:before {
|
249 |
-
border: 5px dashed #ccc;
|
250 |
-
position: absolute;
|
251 |
-
left: 0;
|
252 |
-
right: 0;
|
253 |
-
top: 0;
|
254 |
-
bottom: 0px;
|
255 |
-
}
|
256 |
-
|
257 |
-
.astra-sites-suggestions {
|
258 |
-
min-height: 280px;
|
259 |
-
border: none !important;
|
260 |
-
}
|
261 |
-
|
262 |
-
.astra-sites-suggestions a {
|
263 |
-
border: none;
|
264 |
-
outline: none;
|
265 |
-
}
|
266 |
-
|
267 |
-
.astra-sites-suggestions .inner {
|
268 |
-
border: 6px solid #24282e !important;
|
269 |
-
padding: 27% 10% 50% 10%;
|
270 |
-
text-align: center;
|
271 |
-
position: absolute;
|
272 |
-
left: 0;
|
273 |
-
right: 0;
|
274 |
-
top: 0;
|
275 |
-
background: #33383d;
|
276 |
-
bottom: 0;
|
277 |
-
color: #eee;
|
278 |
-
cursor: auto;
|
279 |
-
}
|
280 |
-
|
281 |
-
.astra-sites-suggestions .inner a {
|
282 |
-
color: #00b9eb;
|
283 |
-
}
|
284 |
-
|
285 |
-
.astra-sites-suggestions p {
|
286 |
-
font-size: 1rem;
|
287 |
-
margin: 0;
|
288 |
-
}
|
289 |
-
|
290 |
-
.astra-notice {
|
291 |
-
margin: 2em 2em 0em 0em;
|
292 |
-
}
|
293 |
-
|
294 |
-
.no-themes .description {
|
295 |
-
display: block;
|
296 |
-
}
|
297 |
-
|
298 |
-
/**
|
299 |
-
* Responsive Button UI
|
300 |
-
*/
|
301 |
-
.astra-sites-preview .wp-full-overlay-footer .devices button.active:before,
|
302 |
-
.astra-sites-preview .wp-full-overlay-footer .devices button:hover:before {
|
303 |
-
color: #0073aa;
|
304 |
-
}
|
305 |
-
.astra-sites-preview .wp-full-overlay-footer .devices button:before {
|
306 |
-
color: #c1c1c1;
|
307 |
-
}
|
308 |
-
.astra-sites-preview .wp-full-overlay-footer .devices button:hover {
|
309 |
-
background-color: transparent;
|
310 |
-
}
|
311 |
-
.astra-sites-preview .wp-full-overlay-footer .devices button {
|
312 |
-
border: none;
|
313 |
-
}
|
314 |
-
.astra-sites-preview .wp-full-overlay-footer .devices button:focus,
|
315 |
-
.astra-sites-preview .wp-full-overlay-footer .devices button.active:hover {
|
316 |
-
border-bottom-color: transparent;
|
317 |
-
background-color: transparent;
|
318 |
-
}
|
319 |
-
.not-click-able {
|
320 |
-
pointer-events: none !important;
|
321 |
-
}
|
322 |
-
body.page-builder-selected .select-page-builder,
|
323 |
-
body.loading-content .select-page-builder {
|
324 |
-
display: none;
|
325 |
-
}
|
326 |
-
.select-page-builder .up-arrow {
|
327 |
-
-webkit-transform: rotate(90deg);
|
328 |
-
-moz-transform: rotate(90deg);
|
329 |
-
-ms-transform: rotate(90deg);
|
330 |
-
transform: rotate(90deg);
|
331 |
-
display: inline-block;
|
332 |
-
font-size: 1.5em;
|
333 |
-
color: #797979;
|
334 |
-
vertical-align: middle;
|
335 |
-
margin-right: 10px;
|
336 |
-
-webkit-transition: all linear 0.6s;
|
337 |
-
-moz-transition: all linear 0.6s;
|
338 |
-
-ms-transition: all linear 0.6s;
|
339 |
-
transition: all linear 0.6s;
|
340 |
-
-webkit-animation-duration: 1s;
|
341 |
-
animation-duration: 1s;
|
342 |
-
-webkit-animation-fill-mode: both;
|
343 |
-
animation-fill-mode: both;
|
344 |
-
-webkit-animation-timing-function: ease-in-out;
|
345 |
-
animation-timing-function: ease-in-out;
|
346 |
-
animation-iteration-count: infinite;
|
347 |
-
-webkit-animation-iteration-count: infinite;
|
348 |
-
animation-name: bounce;
|
349 |
-
-moz-animation-name: bounce;
|
350 |
-
}
|
351 |
-
.select-page-builder {
|
352 |
-
margin-left: 6em;
|
353 |
-
}
|
354 |
-
|
355 |
-
.select-page-builder img {
|
356 |
-
max-width: 100%;
|
357 |
-
}
|
358 |
-
|
359 |
-
.select-page-builder h3 {
|
360 |
-
margin: 0;
|
361 |
-
font-size: 2em;
|
362 |
-
display: flex;
|
363 |
-
align-items: baseline;
|
364 |
-
position: absolute;
|
365 |
-
padding: 40px 0;
|
366 |
-
margin-left: 170px;
|
367 |
-
}
|
368 |
-
.select-page-builder {
|
369 |
-
margin: -20px 0 0 -5px;
|
370 |
-
position: absolute;
|
371 |
-
}
|
372 |
-
|
373 |
-
@keyframes bounce {
|
374 |
-
0%,
|
375 |
-
100%,
|
376 |
-
20%,
|
377 |
-
50%,
|
378 |
-
80% {
|
379 |
-
-webkit-transform: translateY(-0px) rotate(90deg);
|
380 |
-
-moz-transform: translateY(-0px) rotate(90deg);
|
381 |
-
-ms-transform: translateY(-0px) rotate(90deg);
|
382 |
-
transform: translateY(-0px) rotate(90deg);
|
383 |
-
}
|
384 |
-
40% {
|
385 |
-
-webkit-transform: translateY(-2px) rotate(90deg);
|
386 |
-
-moz-transform: translateY(-2px) rotate(90deg);
|
387 |
-
-ms-transform: translateY(-2px) rotate(90deg);
|
388 |
-
transform: translateY(-2px) rotate(90deg);
|
389 |
-
}
|
390 |
-
60% {
|
391 |
-
-webkit-transform: translateY(-1px) rotate(90deg);
|
392 |
-
-moz-transform: translateY(-1px) rotate(90deg);
|
393 |
-
-ms-transform: translateY(-1px) rotate(90deg);
|
394 |
-
transform: translateY(-1px) rotate(90deg);
|
395 |
-
}
|
396 |
-
}
|
397 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
.wrap .status,
|
2 |
+
.wrap .site-type {
|
3 |
+
position: absolute;
|
4 |
+
z-index: 1;
|
5 |
+
color: #fff;
|
6 |
+
padding: 0.5em 1em;
|
7 |
+
top: -0.5em;
|
8 |
+
text-transform: uppercase;
|
9 |
+
}
|
10 |
+
.wrap .status,
|
11 |
+
.wrap .site-type.premium {
|
12 |
+
background: #0073aa;
|
13 |
+
}
|
14 |
+
.wrap .status {
|
15 |
+
left: -0.5em;
|
16 |
+
}
|
17 |
+
.wrap .site-type.premium {
|
18 |
+
right: -0.5em;
|
19 |
+
}
|
20 |
+
|
21 |
+
.wrap .status.publish,
|
22 |
+
.wrap .site-type.free {
|
23 |
+
display: none;
|
24 |
+
}
|
25 |
+
|
26 |
+
.install-theme-info .site-type {
|
27 |
+
display: none;
|
28 |
+
}
|
29 |
+
|
30 |
+
.theme {
|
31 |
+
position: relative;
|
32 |
+
}
|
33 |
+
.wrap .astra-sites-preview .site-type.premium {
|
34 |
+
display: block;
|
35 |
+
display: none;
|
36 |
+
position: relative;
|
37 |
+
margin: 0.5em 0em 1em 0em;
|
38 |
+
top: 0;
|
39 |
+
left: 0;
|
40 |
+
text-align: center;
|
41 |
+
}
|
42 |
+
|
43 |
+
.theme-details-read-more.open {
|
44 |
+
margin: 0.5em 0 0 0;
|
45 |
+
}
|
46 |
+
|
47 |
+
.astra-sites-preview .theme-screenshot {
|
48 |
+
width: 100%;
|
49 |
+
}
|
50 |
+
|
51 |
+
.install-theme-info .site-type.premium {
|
52 |
+
display: none;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Required Plugins
|
57 |
+
*/
|
58 |
+
.required-plugins.loading {
|
59 |
+
text-align: center;
|
60 |
+
}
|
61 |
+
.required-plugins button {
|
62 |
+
float: right;
|
63 |
+
}
|
64 |
+
.required-plugins .plugin-card {
|
65 |
+
float: none;
|
66 |
+
width: 100%;
|
67 |
+
border: none;
|
68 |
+
margin: 0 0 0.8em 0;
|
69 |
+
display: flex;
|
70 |
+
justify-content: space-between;
|
71 |
+
align-items: center;
|
72 |
+
transition: background ease 0.8s;
|
73 |
+
}
|
74 |
+
.required-plugins .plugin-card.plugin-card-update-failed {
|
75 |
+
flex-wrap: wrap;
|
76 |
+
}
|
77 |
+
.required-plugins .spinner {
|
78 |
+
float: none;
|
79 |
+
margin: 0;
|
80 |
+
}
|
81 |
+
|
82 |
+
.expanded .wp-full-overlay-footer {
|
83 |
+
height: 111px;
|
84 |
+
}
|
85 |
+
|
86 |
+
.wp-full-overlay-footer .view-site,
|
87 |
+
.wp-full-overlay-footer .go-pro,
|
88 |
+
.wp-full-overlay-footer .astra-demo-import {
|
89 |
+
width: 100%;
|
90 |
+
text-align: center;
|
91 |
+
}
|
92 |
+
|
93 |
+
.wp-core-ui .wp-full-overlay-footer .button.button-hero,
|
94 |
+
.wp-core-ui .wp-full-overlay-footer .button-group.button-hero .button {
|
95 |
+
padding: 0 10px 1px;
|
96 |
+
}
|
97 |
+
|
98 |
+
.wp-full-overlay-footer .installing:before {
|
99 |
+
vertical-align: text-bottom;
|
100 |
+
}
|
101 |
+
|
102 |
+
.required-plugins-wrap h4 {
|
103 |
+
margin: 1em 0 0.5em 0;
|
104 |
+
padding: 0.5em 0;
|
105 |
+
transition: all ease 0.3s;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Read more link
|
110 |
+
*/
|
111 |
+
.wp-core-ui .theme-details-read-more:focus,
|
112 |
+
.wp-core-ui .theme-details-read-more:hover {
|
113 |
+
outline: none;
|
114 |
+
box-shadow: none;
|
115 |
+
}
|
116 |
+
.wp-core-ui .theme-details-read-more {
|
117 |
+
margin: 10px 0;
|
118 |
+
display: none;
|
119 |
+
text-decoration: none;
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Go pro.
|
124 |
+
*/
|
125 |
+
.wp-core-ui .go-pro.button[disabled] {
|
126 |
+
background-color: #fcb92c !important;
|
127 |
+
color: white !important;
|
128 |
+
box-shadow: 1px 0 #eab23a !important;
|
129 |
+
text-shadow: 1px 0 #6b4e13 !important;
|
130 |
+
border-color: #e2a932 !important;
|
131 |
+
cursor: pointer;
|
132 |
+
}
|
133 |
+
.wp-core-ui .view-site .dashicons,
|
134 |
+
.wp-core-ui .go-pro .dashicons {
|
135 |
+
font-size: 1rem;
|
136 |
+
vertical-align: middle;
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Errors
|
141 |
+
*/
|
142 |
+
.plugin-card-update-failed .notice {
|
143 |
+
margin-top: 1.5em;
|
144 |
+
}
|
145 |
+
|
146 |
+
.no-themes {
|
147 |
+
margin-top: 40px;
|
148 |
+
}
|
149 |
+
|
150 |
+
.no-themes p {
|
151 |
+
font-size: 15px;
|
152 |
+
}
|
153 |
+
|
154 |
+
.no-themes .left-margin {
|
155 |
+
margin-left: 30px;
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
*
|
160 |
+
*/
|
161 |
+
.astra-sites-preview .wp-full-overlay-sidebar-content {
|
162 |
+
bottom: 100px;
|
163 |
+
}
|
164 |
+
|
165 |
+
.footer-import-button-wrap {
|
166 |
+
padding: 10px 20px;
|
167 |
+
}
|
168 |
+
|
169 |
+
.footer-import-button-wrap .button {
|
170 |
+
margin: 0;
|
171 |
+
}
|
172 |
+
|
173 |
+
.astra-sites-preview.expanded .wp-full-overlay-footer {
|
174 |
+
left: initial;
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Menu Page
|
179 |
+
*/
|
180 |
+
.astra-sites-title {
|
181 |
+
float: left;
|
182 |
+
font-size: 23px;
|
183 |
+
font-weight: 400;
|
184 |
+
margin: 0 0 6px 0px;
|
185 |
+
padding: 0;
|
186 |
+
line-height: 29px;
|
187 |
+
}
|
188 |
+
|
189 |
+
#astra-sites-menu-page {
|
190 |
+
margin-top: 10px;
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* API Error
|
195 |
+
*/
|
196 |
+
.astra-api-error {
|
197 |
+
margin: 0 0 0.5em 0;
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Grid
|
202 |
+
*/
|
203 |
+
.wp-filter .search-form {
|
204 |
+
margin-left: 1em;
|
205 |
+
}
|
206 |
+
.wp-filter .search-form input[type="search"] {
|
207 |
+
width: 200px;
|
208 |
+
font-size: 13px;
|
209 |
+
padding: 5px 10px;
|
210 |
+
}
|
211 |
+
.section-left {
|
212 |
+
display: inline-block;
|
213 |
+
}
|
214 |
+
.section-right {
|
215 |
+
float: right;
|
216 |
+
}
|
217 |
+
.filter-count {
|
218 |
+
min-width: 3em;
|
219 |
+
}
|
220 |
+
.astra-site-preview-on {
|
221 |
+
overflow: hidden;
|
222 |
+
}
|
223 |
+
|
224 |
+
#astra-sites-menu-page .notice {
|
225 |
+
margin-left: 0;
|
226 |
+
width: auto;
|
227 |
+
float: none;
|
228 |
+
}
|
229 |
+
.filters-wrap {
|
230 |
+
display: inline-block;
|
231 |
+
}
|
232 |
+
.spinner-wrap {
|
233 |
+
text-align: center;
|
234 |
+
}
|
235 |
+
.spinner-wrap .spinner {
|
236 |
+
float: none;
|
237 |
+
}
|
238 |
+
.hide-me {
|
239 |
+
display: none !important;
|
240 |
+
}
|
241 |
+
#astra-sites-admin {
|
242 |
+
height: 100vh;
|
243 |
+
}
|
244 |
+
.install-theme-info > .notice {
|
245 |
+
margin: 5px 0 10px 0;
|
246 |
+
}
|
247 |
+
|
248 |
+
.astra-sites-suggestions:before {
|
249 |
+
border: 5px dashed #ccc;
|
250 |
+
position: absolute;
|
251 |
+
left: 0;
|
252 |
+
right: 0;
|
253 |
+
top: 0;
|
254 |
+
bottom: 0px;
|
255 |
+
}
|
256 |
+
|
257 |
+
.astra-sites-suggestions {
|
258 |
+
min-height: 280px;
|
259 |
+
border: none !important;
|
260 |
+
}
|
261 |
+
|
262 |
+
.astra-sites-suggestions a {
|
263 |
+
border: none;
|
264 |
+
outline: none;
|
265 |
+
}
|
266 |
+
|
267 |
+
.astra-sites-suggestions .inner {
|
268 |
+
border: 6px solid #24282e !important;
|
269 |
+
padding: 27% 10% 50% 10%;
|
270 |
+
text-align: center;
|
271 |
+
position: absolute;
|
272 |
+
left: 0;
|
273 |
+
right: 0;
|
274 |
+
top: 0;
|
275 |
+
background: #33383d;
|
276 |
+
bottom: 0;
|
277 |
+
color: #eee;
|
278 |
+
cursor: auto;
|
279 |
+
}
|
280 |
+
|
281 |
+
.astra-sites-suggestions .inner a {
|
282 |
+
color: #00b9eb;
|
283 |
+
}
|
284 |
+
|
285 |
+
.astra-sites-suggestions p {
|
286 |
+
font-size: 1rem;
|
287 |
+
margin: 0;
|
288 |
+
}
|
289 |
+
|
290 |
+
.astra-notice {
|
291 |
+
margin: 2em 2em 0em 0em;
|
292 |
+
}
|
293 |
+
|
294 |
+
.no-themes .description {
|
295 |
+
display: block;
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* Responsive Button UI
|
300 |
+
*/
|
301 |
+
.astra-sites-preview .wp-full-overlay-footer .devices button.active:before,
|
302 |
+
.astra-sites-preview .wp-full-overlay-footer .devices button:hover:before {
|
303 |
+
color: #0073aa;
|
304 |
+
}
|
305 |
+
.astra-sites-preview .wp-full-overlay-footer .devices button:before {
|
306 |
+
color: #c1c1c1;
|
307 |
+
}
|
308 |
+
.astra-sites-preview .wp-full-overlay-footer .devices button:hover {
|
309 |
+
background-color: transparent;
|
310 |
+
}
|
311 |
+
.astra-sites-preview .wp-full-overlay-footer .devices button {
|
312 |
+
border: none;
|
313 |
+
}
|
314 |
+
.astra-sites-preview .wp-full-overlay-footer .devices button:focus,
|
315 |
+
.astra-sites-preview .wp-full-overlay-footer .devices button.active:hover {
|
316 |
+
border-bottom-color: transparent;
|
317 |
+
background-color: transparent;
|
318 |
+
}
|
319 |
+
.not-click-able {
|
320 |
+
pointer-events: none !important;
|
321 |
+
}
|
322 |
+
body.page-builder-selected .select-page-builder,
|
323 |
+
body.loading-content .select-page-builder {
|
324 |
+
display: none;
|
325 |
+
}
|
326 |
+
.select-page-builder .up-arrow {
|
327 |
+
-webkit-transform: rotate(90deg);
|
328 |
+
-moz-transform: rotate(90deg);
|
329 |
+
-ms-transform: rotate(90deg);
|
330 |
+
transform: rotate(90deg);
|
331 |
+
display: inline-block;
|
332 |
+
font-size: 1.5em;
|
333 |
+
color: #797979;
|
334 |
+
vertical-align: middle;
|
335 |
+
margin-right: 10px;
|
336 |
+
-webkit-transition: all linear 0.6s;
|
337 |
+
-moz-transition: all linear 0.6s;
|
338 |
+
-ms-transition: all linear 0.6s;
|
339 |
+
transition: all linear 0.6s;
|
340 |
+
-webkit-animation-duration: 1s;
|
341 |
+
animation-duration: 1s;
|
342 |
+
-webkit-animation-fill-mode: both;
|
343 |
+
animation-fill-mode: both;
|
344 |
+
-webkit-animation-timing-function: ease-in-out;
|
345 |
+
animation-timing-function: ease-in-out;
|
346 |
+
animation-iteration-count: infinite;
|
347 |
+
-webkit-animation-iteration-count: infinite;
|
348 |
+
animation-name: bounce;
|
349 |
+
-moz-animation-name: bounce;
|
350 |
+
}
|
351 |
+
.select-page-builder {
|
352 |
+
margin-left: 6em;
|
353 |
+
}
|
354 |
+
|
355 |
+
.select-page-builder img {
|
356 |
+
max-width: 100%;
|
357 |
+
}
|
358 |
+
|
359 |
+
.select-page-builder h3 {
|
360 |
+
margin: 0;
|
361 |
+
font-size: 2em;
|
362 |
+
display: flex;
|
363 |
+
align-items: baseline;
|
364 |
+
position: absolute;
|
365 |
+
padding: 40px 0;
|
366 |
+
margin-left: 170px;
|
367 |
+
}
|
368 |
+
.select-page-builder {
|
369 |
+
margin: -20px 0 0 -5px;
|
370 |
+
position: absolute;
|
371 |
+
}
|
372 |
+
|
373 |
+
@keyframes bounce {
|
374 |
+
0%,
|
375 |
+
100%,
|
376 |
+
20%,
|
377 |
+
50%,
|
378 |
+
80% {
|
379 |
+
-webkit-transform: translateY(-0px) rotate(90deg);
|
380 |
+
-moz-transform: translateY(-0px) rotate(90deg);
|
381 |
+
-ms-transform: translateY(-0px) rotate(90deg);
|
382 |
+
transform: translateY(-0px) rotate(90deg);
|
383 |
+
}
|
384 |
+
40% {
|
385 |
+
-webkit-transform: translateY(-2px) rotate(90deg);
|
386 |
+
-moz-transform: translateY(-2px) rotate(90deg);
|
387 |
+
-ms-transform: translateY(-2px) rotate(90deg);
|
388 |
+
transform: translateY(-2px) rotate(90deg);
|
389 |
+
}
|
390 |
+
60% {
|
391 |
+
-webkit-transform: translateY(-1px) rotate(90deg);
|
392 |
+
-moz-transform: translateY(-1px) rotate(90deg);
|
393 |
+
-ms-transform: translateY(-1px) rotate(90deg);
|
394 |
+
transform: translateY(-1px) rotate(90deg);
|
395 |
+
}
|
396 |
+
}
|
397 |
+
|
398 |
+
/**
|
399 |
+
* Processing Animation
|
400 |
+
*/
|
401 |
+
.astra-demo-import.button.updating-message:before,
|
402 |
+
.astra-demo-import.button.installing:before {
|
403 |
+
-webkit-animation: cssAnimation .72s ease infinite;
|
404 |
+
-moz-animation: cssAnimation .72s ease infinite;
|
405 |
+
-o-animation: cssAnimation .72s ease infinite;
|
406 |
+
-ms-animation: cssAnimation .72s ease infinite;
|
407 |
+
animation: cssAnimation .72s ease infinite;
|
408 |
+
}
|
409 |
+
|
410 |
+
@-webkit-keyframes cssAnimation {
|
411 |
+
from {
|
412 |
+
-webkit-transform: rotate(0);
|
413 |
+
-moz-transform: rotate(0);
|
414 |
+
-o-transform: rotate(0);
|
415 |
+
-ms-transform: rotate(0);
|
416 |
+
transform: rotate(0);
|
417 |
+
}
|
418 |
+
to {
|
419 |
+
-webkit-transform: rotate(360deg);
|
420 |
+
-moz-transform: rotate(360deg);
|
421 |
+
-o-transform: rotate(360deg);
|
422 |
+
-ms-transform: rotate(360deg);
|
423 |
+
transform: rotate(360deg);
|
424 |
+
}
|
425 |
+
}
|
426 |
+
@-moz-keyframes cssAnimation {
|
427 |
+
from {
|
428 |
+
-webkit-transform: rotate(0);
|
429 |
+
-moz-transform: rotate(0);
|
430 |
+
-o-transform: rotate(0);
|
431 |
+
-ms-transform: rotate(0);
|
432 |
+
transform: rotate(0);
|
433 |
+
}
|
434 |
+
to {
|
435 |
+
-webkit-transform: rotate(360deg);
|
436 |
+
-moz-transform: rotate(360deg);
|
437 |
+
-o-transform: rotate(360deg);
|
438 |
+
-ms-transform: rotate(360deg);
|
439 |
+
transform: rotate(360deg);
|
440 |
+
}
|
441 |
+
}
|
442 |
+
@-o-keyframes cssAnimation {
|
443 |
+
from {
|
444 |
+
-webkit-transform: rotate(0);
|
445 |
+
-moz-transform: rotate(0);
|
446 |
+
-o-transform: rotate(0);
|
447 |
+
-ms-transform: rotate(0);
|
448 |
+
transform: rotate(0);
|
449 |
+
}
|
450 |
+
to {
|
451 |
+
-webkit-transform: rotate(360deg);
|
452 |
+
-moz-transform: rotate(360deg);
|
453 |
+
-o-transform: rotate(360deg);
|
454 |
+
-ms-transform: rotate(360deg);
|
455 |
+
transform: rotate(360deg);
|
456 |
+
}
|
457 |
+
}
|
inc/assets/js/admin-page.js
CHANGED
@@ -1,1360 +1,1360 @@
|
|
1 |
-
/**
|
2 |
-
* AJAX Request Queue
|
3 |
-
*
|
4 |
-
* - add()
|
5 |
-
* - remove()
|
6 |
-
* - run()
|
7 |
-
* - stop()
|
8 |
-
*
|
9 |
-
* @since 1.0.0
|
10 |
-
*/
|
11 |
-
var AstraSitesAjaxQueue = (function() {
|
12 |
-
|
13 |
-
var requests = [];
|
14 |
-
|
15 |
-
return {
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Add AJAX request
|
19 |
-
*
|
20 |
-
* @since 1.0.0
|
21 |
-
*/
|
22 |
-
add: function(opt) {
|
23 |
-
requests.push(opt);
|
24 |
-
},
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Remove AJAX request
|
28 |
-
*
|
29 |
-
* @since 1.0.0
|
30 |
-
*/
|
31 |
-
remove: function(opt) {
|
32 |
-
if( jQuery.inArray(opt, requests) > -1 )
|
33 |
-
requests.splice($.inArray(opt, requests), 1);
|
34 |
-
},
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Run / Process AJAX request
|
38 |
-
*
|
39 |
-
* @since 1.0.0
|
40 |
-
*/
|
41 |
-
run: function() {
|
42 |
-
var self = this,
|
43 |
-
oriSuc;
|
44 |
-
|
45 |
-
if( requests.length ) {
|
46 |
-
oriSuc = requests[0].complete;
|
47 |
-
|
48 |
-
requests[0].complete = function() {
|
49 |
-
if( typeof(oriSuc) === 'function' ) oriSuc();
|
50 |
-
requests.shift();
|
51 |
-
self.run.apply(self, []);
|
52 |
-
};
|
53 |
-
|
54 |
-
jQuery.ajax(requests[0]);
|
55 |
-
|
56 |
-
} else {
|
57 |
-
|
58 |
-
self.tid = setTimeout(function() {
|
59 |
-
self.run.apply(self, []);
|
60 |
-
}, 1000);
|
61 |
-
}
|
62 |
-
},
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Stop AJAX request
|
66 |
-
*
|
67 |
-
* @since 1.0.0
|
68 |
-
*/
|
69 |
-
stop: function() {
|
70 |
-
|
71 |
-
requests = [];
|
72 |
-
clearTimeout(this.tid);
|
73 |
-
}
|
74 |
-
};
|
75 |
-
|
76 |
-
}());
|
77 |
-
|
78 |
-
(function($){
|
79 |
-
|
80 |
-
var AstraSSEImport = {
|
81 |
-
complete: {
|
82 |
-
posts: 0,
|
83 |
-
media: 0,
|
84 |
-
users: 0,
|
85 |
-
comments: 0,
|
86 |
-
terms: 0,
|
87 |
-
},
|
88 |
-
|
89 |
-
updateDelta: function (type, delta) {
|
90 |
-
this.complete[ type ] += delta;
|
91 |
-
|
92 |
-
var self = this;
|
93 |
-
requestAnimationFrame(function () {
|
94 |
-
self.render();
|
95 |
-
});
|
96 |
-
},
|
97 |
-
updateProgress: function ( type, complete, total ) {
|
98 |
-
var text = complete + '/' + total;
|
99 |
-
|
100 |
-
if( 'undefined' !== type && 'undefined' !== text ) {
|
101 |
-
total = parseInt( total, 10 );
|
102 |
-
if ( 0 === total || isNaN( total ) ) {
|
103 |
-
total = 1;
|
104 |
-
}
|
105 |
-
var percent = parseInt( complete, 10 ) / total;
|
106 |
-
var progress = Math.round( percent * 100 ) + '%';
|
107 |
-
var progress_bar = percent * 100;
|
108 |
-
}
|
109 |
-
},
|
110 |
-
render: function () {
|
111 |
-
var types = Object.keys( this.complete );
|
112 |
-
var complete = 0;
|
113 |
-
var total = 0;
|
114 |
-
|
115 |
-
for (var i = types.length - 1; i >= 0; i--) {
|
116 |
-
var type = types[i];
|
117 |
-
this.updateProgress( type, this.complete[ type ], this.data.count[ type ] );
|
118 |
-
|
119 |
-
complete += this.complete[ type ];
|
120 |
-
total += this.data.count[ type ];
|
121 |
-
}
|
122 |
-
|
123 |
-
this.updateProgress( 'total', complete, total );
|
124 |
-
}
|
125 |
-
};
|
126 |
-
|
127 |
-
AstraSitesAdmin = {
|
128 |
-
|
129 |
-
log_file : '',
|
130 |
-
customizer_data : '',
|
131 |
-
wxr_url : '',
|
132 |
-
options_data : '',
|
133 |
-
widgets_data : '',
|
134 |
-
|
135 |
-
init: function()
|
136 |
-
{
|
137 |
-
this._resetPagedCount();
|
138 |
-
this._bind();
|
139 |
-
},
|
140 |
-
|
141 |
-
/**
|
142 |
-
* Debugging.
|
143 |
-
*
|
144 |
-
* @param {mixed} data Mixed data.
|
145 |
-
*/
|
146 |
-
_log: function( data ) {
|
147 |
-
|
148 |
-
if( astraSitesAdmin.debug ) {
|
149 |
-
|
150 |
-
var date = new Date();
|
151 |
-
var time = date.toLocaleTimeString();
|
152 |
-
|
153 |
-
if (typeof data == 'object') {
|
154 |
-
console.log('%c ' + JSON.stringify( data ) + ' ' + time, 'background: #ededed; color: #444');
|
155 |
-
} else {
|
156 |
-
console.log('%c ' + data + ' ' + time, 'background: #ededed; color: #444');
|
157 |
-
}
|
158 |
-
|
159 |
-
|
160 |
-
}
|
161 |
-
},
|
162 |
-
|
163 |
-
/**
|
164 |
-
* Binds events for the Astra Sites.
|
165 |
-
*
|
166 |
-
* @since 1.0.0
|
167 |
-
* @access private
|
168 |
-
* @method _bind
|
169 |
-
*/
|
170 |
-
_bind: function()
|
171 |
-
{
|
172 |
-
$( document ).on('click' , '.devices button', AstraSitesAdmin._previewDevice);
|
173 |
-
$( document ).on('click' , '.theme-browser .theme-screenshot, .theme-browser .more-details, .theme-browser .install-theme-preview', AstraSitesAdmin._preview);
|
174 |
-
$( document ).on('click' , '.next-theme', AstraSitesAdmin._nextTheme);
|
175 |
-
$( document ).on('click' , '.previous-theme', AstraSitesAdmin._previousTheme);
|
176 |
-
$( document ).on('click' , '.collapse-sidebar', AstraSitesAdmin._collapse);
|
177 |
-
$( document ).on('click' , '.astra-demo-import', AstraSitesAdmin._importDemo);
|
178 |
-
$( document ).on('click' , '.install-now', AstraSitesAdmin._installNow);
|
179 |
-
$( document ).on('click' , '.close-full-overlay', AstraSitesAdmin._fullOverlay);
|
180 |
-
$( document ).on('click' , '.activate-now', AstraSitesAdmin._activateNow);
|
181 |
-
$( document ).on('wp-plugin-installing' , AstraSitesAdmin._pluginInstalling);
|
182 |
-
$( document ).on('wp-plugin-install-error' , AstraSitesAdmin._installError);
|
183 |
-
$( document ).on('wp-plugin-install-success' , AstraSitesAdmin._installSuccess);
|
184 |
-
|
185 |
-
$( document ).on('astra-sites-import-set-site-data-done' , AstraSitesAdmin._importCustomizerSettings );
|
186 |
-
$( document ).on('astra-sites-import-customizer-settings-done' , AstraSitesAdmin._importPrepareXML );
|
187 |
-
$( document ).on('astra-sites-import-xml-done' , AstraSitesAdmin._importSiteOptions );
|
188 |
-
$( document ).on('astra-sites-import-options-done' , AstraSitesAdmin._importWidgets );
|
189 |
-
$( document ).on('astra-sites-import-widgets-done' , AstraSitesAdmin._importEnd );
|
190 |
-
},
|
191 |
-
|
192 |
-
/**
|
193 |
-
* 5. Import Complete.
|
194 |
-
*/
|
195 |
-
_importEnd: function( event ) {
|
196 |
-
|
197 |
-
$.ajax({
|
198 |
-
url : astraSitesAdmin.ajaxurl,
|
199 |
-
type : 'POST',
|
200 |
-
dataType: 'json',
|
201 |
-
data : {
|
202 |
-
action : 'astra-sites-import-end',
|
203 |
-
},
|
204 |
-
beforeSend: function() {
|
205 |
-
$('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importComplete );
|
206 |
-
}
|
207 |
-
})
|
208 |
-
.fail(function( jqXHR ){
|
209 |
-
AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
|
210 |
-
AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
|
211 |
-
})
|
212 |
-
.done(function ( data ) {
|
213 |
-
|
214 |
-
// 5. Fail - Import Complete.
|
215 |
-
if( false === data.success ) {
|
216 |
-
AstraSitesAdmin._importFailMessage( data.data );
|
217 |
-
AstraSitesAdmin._log( data.data );
|
218 |
-
} else {
|
219 |
-
|
220 |
-
// 5. Pass - Import Complete.
|
221 |
-
AstraSitesAdmin._importSuccessMessage();
|
222 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.success + ' ' + astraSitesAdmin.siteURL );
|
223 |
-
}
|
224 |
-
});
|
225 |
-
},
|
226 |
-
|
227 |
-
/**
|
228 |
-
* 4. Import Widgets.
|
229 |
-
*/
|
230 |
-
_importWidgets: function( event ) {
|
231 |
-
|
232 |
-
$.ajax({
|
233 |
-
url : astraSitesAdmin.ajaxurl,
|
234 |
-
type : 'POST',
|
235 |
-
dataType: 'json',
|
236 |
-
data : {
|
237 |
-
action : 'astra-sites-import-widgets',
|
238 |
-
widgets_data : AstraSitesAdmin.widgets_data,
|
239 |
-
},
|
240 |
-
beforeSend: function() {
|
241 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.importWidgets );
|
242 |
-
$('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importingWidgets );
|
243 |
-
},
|
244 |
-
})
|
245 |
-
.fail(function( jqXHR ){
|
246 |
-
AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
|
247 |
-
AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
|
248 |
-
})
|
249 |
-
.done(function ( widgets_data ) {
|
250 |
-
|
251 |
-
// 4. Fail - Import Widgets.
|
252 |
-
if( false === widgets_data.success ) {
|
253 |
-
AstraSitesAdmin._importFailMessage( widgets_data.data );
|
254 |
-
AstraSitesAdmin._log( widgets_data.data );
|
255 |
-
|
256 |
-
} else {
|
257 |
-
|
258 |
-
// 4. Pass - Import Widgets.
|
259 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.importWidgetsSuccess );
|
260 |
-
$(document).trigger( 'astra-sites-import-widgets-done' );
|
261 |
-
}
|
262 |
-
});
|
263 |
-
},
|
264 |
-
|
265 |
-
/**
|
266 |
-
* 3. Import Site Options.
|
267 |
-
*/
|
268 |
-
_importSiteOptions: function( event ) {
|
269 |
-
|
270 |
-
$.ajax({
|
271 |
-
url : astraSitesAdmin.ajaxurl,
|
272 |
-
type : 'POST',
|
273 |
-
dataType: 'json',
|
274 |
-
data : {
|
275 |
-
action : 'astra-sites-import-options',
|
276 |
-
options_data : AstraSitesAdmin.options_data,
|
277 |
-
},
|
278 |
-
beforeSend: function() {
|
279 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.importOptions );
|
280 |
-
$('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importingOptions );
|
281 |
-
},
|
282 |
-
})
|
283 |
-
.fail(function( jqXHR ){
|
284 |
-
AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
|
285 |
-
AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
|
286 |
-
})
|
287 |
-
.done(function ( options_data ) {
|
288 |
-
|
289 |
-
// 3. Fail - Import Site Options.
|
290 |
-
if( false === options_data.success ) {
|
291 |
-
AstraSitesAdmin._log( options_data );
|
292 |
-
AstraSitesAdmin._importFailMessage( options_data.data );
|
293 |
-
AstraSitesAdmin._log( options_data.data );
|
294 |
-
|
295 |
-
} else {
|
296 |
-
|
297 |
-
// 3. Pass - Import Site Options.
|
298 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.importOptionsSuccess );
|
299 |
-
$(document).trigger( 'astra-sites-import-options-done' );
|
300 |
-
}
|
301 |
-
});
|
302 |
-
},
|
303 |
-
|
304 |
-
/**
|
305 |
-
* 2. Prepare XML Data.
|
306 |
-
*/
|
307 |
-
_importPrepareXML: function( event ) {
|
308 |
-
|
309 |
-
$.ajax({
|
310 |
-
url : astraSitesAdmin.ajaxurl,
|
311 |
-
type : 'POST',
|
312 |
-
dataType: 'json',
|
313 |
-
data : {
|
314 |
-
action : 'astra-sites-import-prepare-xml',
|
315 |
-
wxr_url : AstraSitesAdmin.wxr_url,
|
316 |
-
},
|
317 |
-
beforeSend: function() {
|
318 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.importXMLPrepare );
|
319 |
-
$('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importXMLPreparing );
|
320 |
-
},
|
321 |
-
})
|
322 |
-
.fail(function( jqXHR ){
|
323 |
-
AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
|
324 |
-
AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
|
325 |
-
})
|
326 |
-
.done(function ( xml_data ) {
|
327 |
-
|
328 |
-
// 2. Fail - Prepare XML Data.
|
329 |
-
if( false === xml_data.success ) {
|
330 |
-
AstraSitesAdmin._log( xml_data );
|
331 |
-
AstraSitesAdmin._importFailMessage( xml_data.data );
|
332 |
-
AstraSitesAdmin._log( xml_data.data );
|
333 |
-
|
334 |
-
} else {
|
335 |
-
|
336 |
-
// 2. Pass - Prepare XML Data.
|
337 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.importXMLPrepareSuccess );
|
338 |
-
|
339 |
-
// Import XML though Event Source.
|
340 |
-
AstraSSEImport.data = xml_data.data;
|
341 |
-
AstraSSEImport.render();
|
342 |
-
|
343 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.importXML );
|
344 |
-
$('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importingXML );
|
345 |
-
|
346 |
-
var evtSource = new EventSource( AstraSSEImport.data.url );
|
347 |
-
evtSource.onmessage = function ( message ) {
|
348 |
-
var data = JSON.parse( message.data );
|
349 |
-
switch ( data.action ) {
|
350 |
-
case 'updateDelta':
|
351 |
-
AstraSSEImport.updateDelta( data.type, data.delta );
|
352 |
-
break;
|
353 |
-
|
354 |
-
case 'complete':
|
355 |
-
evtSource.close();
|
356 |
-
|
357 |
-
// 2. Pass - Import XML though "Source Event".
|
358 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.importXMLSuccess );
|
359 |
-
AstraSitesAdmin._log( '----- SSE - XML import Complete -----' );
|
360 |
-
|
361 |
-
$(document).trigger( 'astra-sites-import-xml-done' );
|
362 |
-
|
363 |
-
break;
|
364 |
-
}
|
365 |
-
};
|
366 |
-
evtSource.addEventListener( 'log', function ( message ) {
|
367 |
-
var data = JSON.parse( message.data );
|
368 |
-
AstraSitesAdmin._log( data.level + ' ' + data.message );
|
369 |
-
});
|
370 |
-
}
|
371 |
-
});
|
372 |
-
},
|
373 |
-
|
374 |
-
/**
|
375 |
-
* 1. Import Customizer Options.
|
376 |
-
*/
|
377 |
-
_importCustomizerSettings: function( event ) {
|
378 |
-
|
379 |
-
$.ajax({
|
380 |
-
url : astraSitesAdmin.ajaxurl,
|
381 |
-
type : 'POST',
|
382 |
-
dataType: 'json',
|
383 |
-
data : {
|
384 |
-
action : 'astra-sites-import-customizer-settings',
|
385 |
-
customizer_data : AstraSitesAdmin.customizer_data,
|
386 |
-
},
|
387 |
-
beforeSend: function() {
|
388 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.importCustomizer );
|
389 |
-
$('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importingCustomizer );
|
390 |
-
},
|
391 |
-
})
|
392 |
-
.fail(function( jqXHR ){
|
393 |
-
AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
|
394 |
-
AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
|
395 |
-
})
|
396 |
-
.done(function ( customizer_data ) {
|
397 |
-
|
398 |
-
// 1. Fail - Import Customizer Options.
|
399 |
-
if( false === customizer_data.success ) {
|
400 |
-
AstraSitesAdmin._importFailMessage( customizer_data.data );
|
401 |
-
AstraSitesAdmin._log( customizer_data.data );
|
402 |
-
} else {
|
403 |
-
|
404 |
-
// 1. Pass - Import Customizer Options.
|
405 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.importCustomizerSuccess );
|
406 |
-
|
407 |
-
$(document).trigger( 'astra-sites-import-customizer-settings-done' );
|
408 |
-
}
|
409 |
-
});
|
410 |
-
},
|
411 |
-
|
412 |
-
/**
|
413 |
-
* Import Success Button.
|
414 |
-
*
|
415 |
-
* @param {string} data Error message.
|
416 |
-
*/
|
417 |
-
_importSuccessMessage: function() {
|
418 |
-
|
419 |
-
$('.astra-demo-import').removeClass('updating-message installing')
|
420 |
-
.removeAttr('data-import')
|
421 |
-
.addClass('view-site')
|
422 |
-
.removeClass('astra-demo-import')
|
423 |
-
.text( astraSitesAdmin.strings.viewSite )
|
424 |
-
.attr('target', '_blank')
|
425 |
-
.append('<i class="dashicons dashicons-external"></i>')
|
426 |
-
.attr('href', astraSitesAdmin.siteURL );
|
427 |
-
},
|
428 |
-
|
429 |
-
/**
|
430 |
-
* Preview Device
|
431 |
-
*/
|
432 |
-
_previewDevice: function( event ) {
|
433 |
-
var device = $( event.currentTarget ).data( 'device' );
|
434 |
-
|
435 |
-
$('.theme-install-overlay')
|
436 |
-
.removeClass( 'preview-desktop preview-tablet preview-mobile' )
|
437 |
-
.addClass( 'preview-' + device )
|
438 |
-
.data( 'current-preview-device', device );
|
439 |
-
|
440 |
-
AstraSitesAdmin._tooglePreviewDeviceButtons( device );
|
441 |
-
},
|
442 |
-
|
443 |
-
/**
|
444 |
-
* Toggle Preview Buttons
|
445 |
-
*/
|
446 |
-
_tooglePreviewDeviceButtons: function( newDevice ) {
|
447 |
-
var $devices = $( '.wp-full-overlay-footer .devices' );
|
448 |
-
|
449 |
-
$devices.find( 'button' )
|
450 |
-
.removeClass( 'active' )
|
451 |
-
.attr( 'aria-pressed', false );
|
452 |
-
|
453 |
-
$devices.find( 'button.preview-' + newDevice )
|
454 |
-
.addClass( 'active' )
|
455 |
-
.attr( 'aria-pressed', true );
|
456 |
-
},
|
457 |
-
|
458 |
-
/**
|
459 |
-
* Import Error Button.
|
460 |
-
*
|
461 |
-
* @param {string} data Error message.
|
462 |
-
*/
|
463 |
-
_importFailMessage: function( message, from ) {
|
464 |
-
|
465 |
-
$('.astra-demo-import')
|
466 |
-
.addClass('go-pro button-primary')
|
467 |
-
.removeClass('updating-message installing')
|
468 |
-
.removeAttr('data-import')
|
469 |
-
.attr('target', '_blank')
|
470 |
-
.append('<i class="dashicons dashicons-external"></i>')
|
471 |
-
.removeClass('astra-demo-import');
|
472 |
-
|
473 |
-
// Add the doc link due to import log file not generated.
|
474 |
-
if( 'undefined' === from ) {
|
475 |
-
|
476 |
-
$('.wp-full-overlay-header .go-pro').text( astraSitesAdmin.strings.importFailedBtnSmall );
|
477 |
-
$('.wp-full-overlay-footer .go-pro').text( astraSitesAdmin.strings.importFailedBtnLarge );
|
478 |
-
$('.go-pro').attr('href', astraSitesAdmin.log.serverConfiguration );
|
479 |
-
|
480 |
-
// Add the import log file link.
|
481 |
-
} else {
|
482 |
-
|
483 |
-
$('.wp-full-overlay-header .go-pro').text( astraSitesAdmin.strings.importFailBtn );
|
484 |
-
$('.wp-full-overlay-footer .go-pro').text( astraSitesAdmin.strings.importFailBtnLarge )
|
485 |
-
|
486 |
-
// Add the import log file link.
|
487 |
-
if( 'undefined' !== AstraSitesAdmin.log_file_url ) {
|
488 |
-
$('.go-pro').attr('href', AstraSitesAdmin.log_file_url );
|
489 |
-
} else {
|
490 |
-
$('.go-pro').attr('href', astraSitesAdmin.log.serverConfiguration );
|
491 |
-
}
|
492 |
-
}
|
493 |
-
|
494 |
-
var output = '<div class="astra-api-error notice notice-error notice-alt is-dismissible">';
|
495 |
-
output += ' <p>'+message+'</p>';
|
496 |
-
output += ' <button type="button" class="notice-dismiss">';
|
497 |
-
output += ' <span class="screen-reader-text">'+commonL10n.dismiss+'</span>';
|
498 |
-
output += ' </button>';
|
499 |
-
output += '</div>';
|
500 |
-
|
501 |
-
// Fail Notice.
|
502 |
-
$('.install-theme-info').append( output );
|
503 |
-
|
504 |
-
|
505 |
-
// !important to add trigger.
|
506 |
-
// Which reinitialize the dismiss error message events.
|
507 |
-
$(document).trigger('wp-updates-notice-added');
|
508 |
-
},
|
509 |
-
|
510 |
-
|
511 |
-
/**
|
512 |
-
* Install Now
|
513 |
-
*/
|
514 |
-
_installNow: function(event)
|
515 |
-
{
|
516 |
-
event.preventDefault();
|
517 |
-
|
518 |
-
var $button = jQuery( event.target ),
|
519 |
-
$document = jQuery(document);
|
520 |
-
|
521 |
-
if ( $button.hasClass( 'updating-message' ) || $button.hasClass( 'button-disabled' ) ) {
|
522 |
-
return;
|
523 |
-
}
|
524 |
-
|
525 |
-
if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked ) {
|
526 |
-
wp.updates.requestFilesystemCredentials( event );
|
527 |
-
|
528 |
-
$document.on( 'credential-modal-cancel', function() {
|
529 |
-
var $message = $( '.install-now.updating-message' );
|
530 |
-
|
531 |
-
$message
|
532 |
-
.removeClass( 'updating-message' )
|
533 |
-
.text( wp.updates.l10n.installNow );
|
534 |
-
|
535 |
-
wp.a11y.speak( wp.updates.l10n.updateCancel, 'polite' );
|
536 |
-
} );
|
537 |
-
}
|
538 |
-
|
539 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.installingPlugin + ' ' + $button.data( 'slug' ) );
|
540 |
-
|
541 |
-
wp.updates.installPlugin( {
|
542 |
-
slug: $button.data( 'slug' )
|
543 |
-
} );
|
544 |
-
},
|
545 |
-
|
546 |
-
/**
|
547 |
-
* Install Success
|
548 |
-
*/
|
549 |
-
_installSuccess: function( event, response ) {
|
550 |
-
|
551 |
-
event.preventDefault();
|
552 |
-
|
553 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.installed + ' ' + response.slug );
|
554 |
-
|
555 |
-
var $message = jQuery( '.plugin-card-' + response.slug ).find( '.button' );
|
556 |
-
var $siteOptions = jQuery( '.wp-full-overlay-header').find('.astra-site-options').val();
|
557 |
-
var $enabledExtensions = jQuery( '.wp-full-overlay-header').find('.astra-enabled-extensions').val();
|
558 |
-
|
559 |
-
// Transform the 'Install' button into an 'Activate' button.
|
560 |
-
var $init = $message.data('init');
|
561 |
-
|
562 |
-
$message.removeClass( 'install-now installed button-disabled updated-message' )
|
563 |
-
.addClass('updating-message')
|
564 |
-
.html( astraSitesAdmin.strings.btnActivating );
|
565 |
-
|
566 |
-
// Reset not installed plugins list.
|
567 |
-
var pluginsList = astraSitesAdmin.requiredPlugins.notinstalled;
|
568 |
-
astraSitesAdmin.requiredPlugins.notinstalled = AstraSitesAdmin._removePluginFromQueue( response.slug, pluginsList );
|
569 |
-
|
570 |
-
// WordPress adds "Activate" button after waiting for 1000ms. So we will run our activation after that.
|
571 |
-
setTimeout( function() {
|
572 |
-
|
573 |
-
$.ajax({
|
574 |
-
url: astraSitesAdmin.ajaxurl,
|
575 |
-
type: 'POST',
|
576 |
-
data: {
|
577 |
-
'action' : 'astra-required-plugin-activate',
|
578 |
-
'init' : $init,
|
579 |
-
'options' : $siteOptions,
|
580 |
-
'enabledExtensions' : $enabledExtensions,
|
581 |
-
},
|
582 |
-
})
|
583 |
-
.done(function (result) {
|
584 |
-
|
585 |
-
if( result.success ) {
|
586 |
-
|
587 |
-
var pluginsList = astraSitesAdmin.requiredPlugins.inactive;
|
588 |
-
|
589 |
-
// Reset not installed plugins list.
|
590 |
-
astraSitesAdmin.requiredPlugins.inactive = AstraSitesAdmin._removePluginFromQueue( response.slug, pluginsList );
|
591 |
-
|
592 |
-
$message.removeClass( 'button-primary install-now activate-now updating-message' )
|
593 |
-
.attr('disabled', 'disabled')
|
594 |
-
.addClass('disabled')
|
595 |
-
.text( astraSitesAdmin.strings.btnActive );
|
596 |
-
|
597 |
-
// Enable Demo Import Button
|
598 |
-
AstraSitesAdmin._enable_demo_import_button();
|
599 |
-
|
600 |
-
} else {
|
601 |
-
|
602 |
-
$message.removeClass( 'updating-message' );
|
603 |
-
|
604 |
-
}
|
605 |
-
|
606 |
-
});
|
607 |
-
|
608 |
-
}, 1200 );
|
609 |
-
|
610 |
-
},
|
611 |
-
|
612 |
-
/**
|
613 |
-
* Plugin Installation Error.
|
614 |
-
*/
|
615 |
-
_installError: function( event, response ) {
|
616 |
-
|
617 |
-
var $card = jQuery( '.plugin-card-' + response.slug );
|
618 |
-
|
619 |
-
AstraSitesAdmin._log( response.errorMessage + ' ' + response.slug );
|
620 |
-
|
621 |
-
$card
|
622 |
-
.removeClass( 'button-primary' )
|
623 |
-
.addClass( 'disabled' )
|
624 |
-
.html( wp.updates.l10n.installFailedShort );
|
625 |
-
|
626 |
-
AstraSitesAdmin._importFailMessage( response.errorMessage );
|
627 |
-
},
|
628 |
-
|
629 |
-
/**
|
630 |
-
* Installing Plugin
|
631 |
-
*/
|
632 |
-
_pluginInstalling: function(event, args) {
|
633 |
-
event.preventDefault();
|
634 |
-
|
635 |
-
var $card = jQuery( '.plugin-card-' + args.slug );
|
636 |
-
var $button = $card.find( '.button' );
|
637 |
-
|
638 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.installingPlugin + ' ' + args.slug );
|
639 |
-
|
640 |
-
$card.addClass('updating-message');
|
641 |
-
$button.addClass('already-started');
|
642 |
-
|
643 |
-
},
|
644 |
-
|
645 |
-
/**
|
646 |
-
* Render Demo Preview
|
647 |
-
*/
|
648 |
-
_activateNow: function( eventn ) {
|
649 |
-
|
650 |
-
event.preventDefault();
|
651 |
-
|
652 |
-
var $button = jQuery( event.target ),
|
653 |
-
$init = $button.data( 'init' ),
|
654 |
-
$slug = $button.data( 'slug' );
|
655 |
-
|
656 |
-
if ( $button.hasClass( 'updating-message' ) || $button.hasClass( 'button-disabled' ) ) {
|
657 |
-
return;
|
658 |
-
}
|
659 |
-
|
660 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.activating + ' ' + $slug );
|
661 |
-
|
662 |
-
$button.addClass('updating-message button-primary')
|
663 |
-
.html( astraSitesAdmin.strings.btnActivating );
|
664 |
-
|
665 |
-
var $siteOptions = jQuery( '.wp-full-overlay-header').find('.astra-site-options').val();
|
666 |
-
var $enabledExtensions = jQuery( '.wp-full-overlay-header').find('.astra-enabled-extensions').val();
|
667 |
-
|
668 |
-
$.ajax({
|
669 |
-
url: astraSitesAdmin.ajaxurl,
|
670 |
-
type: 'POST',
|
671 |
-
data: {
|
672 |
-
'action' : 'astra-required-plugin-activate',
|
673 |
-
'init' : $init,
|
674 |
-
'options' : $siteOptions,
|
675 |
-
'enabledExtensions' : $enabledExtensions,
|
676 |
-
},
|
677 |
-
})
|
678 |
-
.done(function (result) {
|
679 |
-
|
680 |
-
if( result.success ) {
|
681 |
-
|
682 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.activated + ' ' + $slug );
|
683 |
-
|
684 |
-
var pluginsList = astraSitesAdmin.requiredPlugins.inactive;
|
685 |
-
|
686 |
-
// Reset not installed plugins list.
|
687 |
-
astraSitesAdmin.requiredPlugins.inactive = AstraSitesAdmin._removePluginFromQueue( $slug, pluginsList );
|
688 |
-
|
689 |
-
$button.removeClass( 'button-primary install-now activate-now updating-message' )
|
690 |
-
.attr('disabled', 'disabled')
|
691 |
-
.addClass('disabled')
|
692 |
-
.text( astraSitesAdmin.strings.btnActive );
|
693 |
-
|
694 |
-
// Enable Demo Import Button
|
695 |
-
AstraSitesAdmin._enable_demo_import_button();
|
696 |
-
|
697 |
-
}
|
698 |
-
|
699 |
-
})
|
700 |
-
.fail(function () {
|
701 |
-
});
|
702 |
-
|
703 |
-
},
|
704 |
-
|
705 |
-
/**
|
706 |
-
* Full Overlay
|
707 |
-
*/
|
708 |
-
_fullOverlay: function (event) {
|
709 |
-
event.preventDefault();
|
710 |
-
|
711 |
-
jQuery('.theme-install-overlay').css('display', 'none');
|
712 |
-
jQuery('.theme-install-overlay').remove();
|
713 |
-
jQuery('.theme-preview-on').removeClass('theme-preview-on');
|
714 |
-
jQuery('html').removeClass('astra-site-preview-on');
|
715 |
-
},
|
716 |
-
|
717 |
-
/**
|
718 |
-
* Bulk Plugin Active & Install
|
719 |
-
*/
|
720 |
-
_bulkPluginInstallActivate: function()
|
721 |
-
{
|
722 |
-
if( 0 === astraSitesAdmin.requiredPlugins.length ) {
|
723 |
-
return;
|
724 |
-
}
|
725 |
-
|
726 |
-
jQuery('.required-plugins')
|
727 |
-
.find('.install-now')
|
728 |
-
.addClass( 'updating-message' )
|
729 |
-
.removeClass( 'install-now' )
|
730 |
-
.text( wp.updates.l10n.installing );
|
731 |
-
|
732 |
-
jQuery('.required-plugins')
|
733 |
-
.find('.activate-now')
|
734 |
-
.addClass('updating-message')
|
735 |
-
.removeClass( 'activate-now' )
|
736 |
-
.html( astraSitesAdmin.strings.btnActivating );
|
737 |
-
|
738 |
-
var not_installed = astraSitesAdmin.requiredPlugins.notinstalled || '';
|
739 |
-
var activate_plugins = astraSitesAdmin.requiredPlugins.inactive || '';
|
740 |
-
|
741 |
-
// First Install Bulk.
|
742 |
-
if( not_installed.length > 0 ) {
|
743 |
-
AstraSitesAdmin._installAllPlugins( not_installed );
|
744 |
-
}
|
745 |
-
|
746 |
-
// Second Activate Bulk.
|
747 |
-
if( activate_plugins.length > 0 ) {
|
748 |
-
AstraSitesAdmin._activateAllPlugins( activate_plugins );
|
749 |
-
}
|
750 |
-
|
751 |
-
},
|
752 |
-
|
753 |
-
/**
|
754 |
-
* Activate All Plugins.
|
755 |
-
*/
|
756 |
-
_activateAllPlugins: function( activate_plugins ) {
|
757 |
-
|
758 |
-
// Activate ALl Plugins.
|
759 |
-
AstraSitesAjaxQueue.stop();
|
760 |
-
AstraSitesAjaxQueue.run();
|
761 |
-
|
762 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.bulkActivation );
|
763 |
-
|
764 |
-
$.each( activate_plugins, function(index, single_plugin) {
|
765 |
-
|
766 |
-
var $card = jQuery( '.plugin-card-' + single_plugin.slug ),
|
767 |
-
$button = $card.find('.button'),
|
768 |
-
$siteOptions = jQuery( '.wp-full-overlay-header').find('.astra-site-options').val(),
|
769 |
-
$enabledExtensions = jQuery( '.wp-full-overlay-header').find('.astra-enabled-extensions').val();
|
770 |
-
|
771 |
-
$button.addClass('updating-message');
|
772 |
-
|
773 |
-
AstraSitesAjaxQueue.add({
|
774 |
-
url: astraSitesAdmin.ajaxurl,
|
775 |
-
type: 'POST',
|
776 |
-
data: {
|
777 |
-
'action' : 'astra-required-plugin-activate',
|
778 |
-
'init' : single_plugin.init,
|
779 |
-
'options' : $siteOptions,
|
780 |
-
'enabledExtensions' : $enabledExtensions,
|
781 |
-
},
|
782 |
-
success: function( result ){
|
783 |
-
|
784 |
-
if( result.success ) {
|
785 |
-
|
786 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.activate + ' ' + single_plugin.slug );
|
787 |
-
|
788 |
-
var $card = jQuery( '.plugin-card-' + single_plugin.slug );
|
789 |
-
var $button = $card.find( '.button' );
|
790 |
-
if( ! $button.hasClass('already-started') ) {
|
791 |
-
var pluginsList = astraSitesAdmin.requiredPlugins.inactive;
|
792 |
-
|
793 |
-
// Reset not installed plugins list.
|
794 |
-
astraSitesAdmin.requiredPlugins.inactive = AstraSitesAdmin._removePluginFromQueue( single_plugin.slug, pluginsList );
|
795 |
-
}
|
796 |
-
|
797 |
-
$button.removeClass( 'button-primary install-now activate-now updating-message' )
|
798 |
-
.attr('disabled', 'disabled')
|
799 |
-
.addClass('disabled')
|
800 |
-
.text( astraSitesAdmin.strings.btnActive );
|
801 |
-
|
802 |
-
// Enable Demo Import Button
|
803 |
-
AstraSitesAdmin._enable_demo_import_button();
|
804 |
-
} else {
|
805 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.activationError + ' - ' + single_plugin.slug );
|
806 |
-
}
|
807 |
-
}
|
808 |
-
});
|
809 |
-
});
|
810 |
-
},
|
811 |
-
|
812 |
-
/**
|
813 |
-
* Install All Plugins.
|
814 |
-
*/
|
815 |
-
_installAllPlugins: function( not_installed ) {
|
816 |
-
|
817 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.bulkInstall );
|
818 |
-
|
819 |
-
$.each( not_installed, function(index, single_plugin) {
|
820 |
-
|
821 |
-
var $card = jQuery( '.plugin-card-' + single_plugin.slug ),
|
822 |
-
$button = $card.find('.button');
|
823 |
-
|
824 |
-
if( ! $button.hasClass('already-started') ) {
|
825 |
-
|
826 |
-
// Add each plugin activate request in Ajax queue.
|
827 |
-
// @see wp-admin/js/updates.js
|
828 |
-
wp.updates.queue.push( {
|
829 |
-
action: 'install-plugin', // Required action.
|
830 |
-
data: {
|
831 |
-
slug: single_plugin.slug
|
832 |
-
}
|
833 |
-
} );
|
834 |
-
}
|
835 |
-
});
|
836 |
-
|
837 |
-
// Required to set queue.
|
838 |
-
wp.updates.queueChecker();
|
839 |
-
},
|
840 |
-
|
841 |
-
/**
|
842 |
-
* Fires when a nav item is clicked.
|
843 |
-
*
|
844 |
-
* @since 1.0
|
845 |
-
* @access private
|
846 |
-
* @method _importDemo
|
847 |
-
*/
|
848 |
-
_importDemo: function()
|
849 |
-
{
|
850 |
-
var $this = jQuery(this),
|
851 |
-
$theme = $this.closest('.astra-sites-preview').find('.wp-full-overlay-header'),
|
852 |
-
apiURL = $theme.data('demo-api') || '',
|
853 |
-
plugins = $theme.data('required-plugins');
|
854 |
-
|
855 |
-
var disabled = $this.attr('data-import');
|
856 |
-
|
857 |
-
if ( typeof disabled !== 'undefined' && disabled === 'disabled' || $this.hasClass('disabled') ) {
|
858 |
-
|
859 |
-
$('.astra-demo-import').addClass('updating-message installing')
|
860 |
-
.text( wp.updates.l10n.installing );
|
861 |
-
|
862 |
-
/**
|
863 |
-
* Process Bulk Plugin Install & Activate
|
864 |
-
*/
|
865 |
-
AstraSitesAdmin._bulkPluginInstallActivate();
|
866 |
-
|
867 |
-
return;
|
868 |
-
}
|
869 |
-
|
870 |
-
// Proceed?
|
871 |
-
if( ! confirm( astraSitesAdmin.strings.importWarning ) ) {
|
872 |
-
return;
|
873 |
-
}
|
874 |
-
|
875 |
-
// Remove all notices before import start.
|
876 |
-
$('.install-theme-info > .notice').remove();
|
877 |
-
|
878 |
-
$('.astra-demo-import').attr('data-import', 'disabled')
|
879 |
-
.addClass('updating-message installing')
|
880 |
-
.text( astraSitesAdmin.strings.importingDemo );
|
881 |
-
|
882 |
-
$this.closest('.theme').focus();
|
883 |
-
|
884 |
-
var $theme = $this.closest('.astra-sites-preview').find('.wp-full-overlay-header');
|
885 |
-
|
886 |
-
var apiURL = $theme.data('demo-api') || '';
|
887 |
-
|
888 |
-
// Site Import by API URL.
|
889 |
-
if( apiURL ) {
|
890 |
-
AstraSitesAdmin._importSite( apiURL );
|
891 |
-
}
|
892 |
-
|
893 |
-
},
|
894 |
-
|
895 |
-
/**
|
896 |
-
* Start Import Process by API URL.
|
897 |
-
*
|
898 |
-
* @param {string} apiURL Site API URL.
|
899 |
-
*/
|
900 |
-
_importSite: function( apiURL ) {
|
901 |
-
|
902 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.api + ' : ' + apiURL );
|
903 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.importing );
|
904 |
-
|
905 |
-
$('.button-hero.astra-demo-import').text( astraSitesAdmin.log.gettingData );
|
906 |
-
|
907 |
-
// 1. Request Site Import
|
908 |
-
$.ajax({
|
909 |
-
url : astraSitesAdmin.ajaxurl,
|
910 |
-
type : 'POST',
|
911 |
-
dataType: 'json',
|
912 |
-
data : {
|
913 |
-
'action' : 'astra-sites-import-set-site-data',
|
914 |
-
'api_url' : apiURL,
|
915 |
-
},
|
916 |
-
})
|
917 |
-
.fail(function( jqXHR ){
|
918 |
-
AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
|
919 |
-
AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
|
920 |
-
})
|
921 |
-
.done(function ( demo_data ) {
|
922 |
-
|
923 |
-
// 1. Fail - Request Site Import
|
924 |
-
if( false === demo_data.success ) {
|
925 |
-
|
926 |
-
AstraSitesAdmin._importFailMessage( demo_data.data );
|
927 |
-
|
928 |
-
} else {
|
929 |
-
|
930 |
-
// Set log file URL.
|
931 |
-
if( 'log_file' in demo_data.data ){
|
932 |
-
AstraSitesAdmin.log_file_url = decodeURIComponent( demo_data.data.log_file ) || '';
|
933 |
-
}
|
934 |
-
|
935 |
-
// 1. Pass - Request Site Import
|
936 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.processingRequest );
|
937 |
-
|
938 |
-
AstraSitesAdmin.customizer_data = JSON.stringify( demo_data.data['astra-site-customizer-data'] ) || '';
|
939 |
-
AstraSitesAdmin.wxr_url = encodeURI( demo_data.data['astra-site-wxr-path'] ) || '';
|
940 |
-
AstraSitesAdmin.options_data = JSON.stringify( demo_data.data['astra-site-options-data'] ) || '';
|
941 |
-
AstraSitesAdmin.widgets_data = JSON.stringify( demo_data.data['astra-site-widgets-data'] ) || '';
|
942 |
-
|
943 |
-
$(document).trigger( 'astra-sites-import-set-site-data-done' );
|
944 |
-
}
|
945 |
-
|
946 |
-
});
|
947 |
-
|
948 |
-
},
|
949 |
-
|
950 |
-
/**
|
951 |
-
* Collapse Sidebar.
|
952 |
-
*/
|
953 |
-
_collapse: function() {
|
954 |
-
event.preventDefault();
|
955 |
-
|
956 |
-
overlay = jQuery('.wp-full-overlay');
|
957 |
-
|
958 |
-
if (overlay.hasClass('expanded')) {
|
959 |
-
overlay.removeClass('expanded');
|
960 |
-
overlay.addClass('collapsed');
|
961 |
-
return;
|
962 |
-
}
|
963 |
-
|
964 |
-
if (overlay.hasClass('collapsed')) {
|
965 |
-
overlay.removeClass('collapsed');
|
966 |
-
overlay.addClass('expanded');
|
967 |
-
return;
|
968 |
-
}
|
969 |
-
},
|
970 |
-
|
971 |
-
/**
|
972 |
-
* Previous Theme.
|
973 |
-
*/
|
974 |
-
_previousTheme: function (event) {
|
975 |
-
event.preventDefault();
|
976 |
-
|
977 |
-
currentDemo = jQuery('.theme-preview-on');
|
978 |
-
currentDemo.removeClass('theme-preview-on');
|
979 |
-
prevDemo = currentDemo.prev('.theme');
|
980 |
-
prevDemo.addClass('theme-preview-on');
|
981 |
-
|
982 |
-
AstraSitesAdmin._renderDemoPreview(prevDemo);
|
983 |
-
},
|
984 |
-
|
985 |
-
/**
|
986 |
-
* Next Theme.
|
987 |
-
*/
|
988 |
-
_nextTheme: function (event) {
|
989 |
-
event.preventDefault();
|
990 |
-
currentDemo = jQuery('.theme-preview-on')
|
991 |
-
currentDemo.removeClass('theme-preview-on');
|
992 |
-
nextDemo = currentDemo.next('.theme');
|
993 |
-
nextDemo.addClass('theme-preview-on');
|
994 |
-
|
995 |
-
AstraSitesAdmin._renderDemoPreview( nextDemo );
|
996 |
-
},
|
997 |
-
|
998 |
-
/**
|
999 |
-
* Individual Site Preview
|
1000 |
-
*
|
1001 |
-
* On click on image, more link & preview button.
|
1002 |
-
*/
|
1003 |
-
_preview: function( event ) {
|
1004 |
-
|
1005 |
-
event.preventDefault();
|
1006 |
-
|
1007 |
-
var self = jQuery(this).parents('.theme');
|
1008 |
-
self.addClass('theme-preview-on');
|
1009 |
-
|
1010 |
-
jQuery('html').addClass('astra-site-preview-on');
|
1011 |
-
|
1012 |
-
AstraSitesAdmin._renderDemoPreview( self );
|
1013 |
-
},
|
1014 |
-
|
1015 |
-
/**
|
1016 |
-
* Check Next Previous Buttons.
|
1017 |
-
*/
|
1018 |
-
_checkNextPrevButtons: function() {
|
1019 |
-
currentDemo = jQuery('.theme-preview-on');
|
1020 |
-
nextDemo = currentDemo.nextAll('.theme').length;
|
1021 |
-
prevDemo = currentDemo.prevAll('.theme').length;
|
1022 |
-
|
1023 |
-
if (nextDemo == 0) {
|
1024 |
-
jQuery('.next-theme').addClass('disabled');
|
1025 |
-
} else if (nextDemo != 0) {
|
1026 |
-
jQuery('.next-theme').removeClass('disabled');
|
1027 |
-
}
|
1028 |
-
|
1029 |
-
if (prevDemo == 0) {
|
1030 |
-
jQuery('.previous-theme').addClass('disabled');
|
1031 |
-
} else if (prevDemo != 0) {
|
1032 |
-
jQuery('.previous-theme').removeClass('disabled');
|
1033 |
-
}
|
1034 |
-
|
1035 |
-
return;
|
1036 |
-
},
|
1037 |
-
|
1038 |
-
/**
|
1039 |
-
* Render Demo Preview
|
1040 |
-
*/
|
1041 |
-
_renderDemoPreview: function(anchor) {
|
1042 |
-
|
1043 |
-
var demoId = anchor.data('id') || '',
|
1044 |
-
apiURL = anchor.data('demo-api') || '',
|
1045 |
-
demoType = anchor.data('demo-type') || '',
|
1046 |
-
demoURL = anchor.data('demo-url') || '',
|
1047 |
-
screenshot = anchor.data('screenshot') || '',
|
1048 |
-
demo_name = anchor.data('demo-name') || '',
|
1049 |
-
demo_slug = anchor.data('demo-slug') || '',
|
1050 |
-
content = anchor.data('content') || '',
|
1051 |
-
requiredPlugins = anchor.data('required-plugins') || '',
|
1052 |
-
astraSiteOptions = anchor.find('.astra-site-options').val() || '';
|
1053 |
-
astraEnabledExtensions = anchor.find('.astra-enabled-extensions').val() || '';
|
1054 |
-
|
1055 |
-
AstraSitesAdmin._log( astraSitesAdmin.log.preview + ' "' + demo_name + '" URL : ' + demoURL );
|
1056 |
-
|
1057 |
-
var template = wp.template('astra-site-preview');
|
1058 |
-
|
1059 |
-
templateData = [{
|
1060 |
-
id : demoId,
|
1061 |
-
astra_demo_type : demoType,
|
1062 |
-
astra_demo_url : demoURL,
|
1063 |
-
demo_api : apiURL,
|
1064 |
-
screenshot : screenshot,
|
1065 |
-
demo_name : demo_name,
|
1066 |
-
slug : demo_slug,
|
1067 |
-
content : content,
|
1068 |
-
required_plugins : JSON.stringify(requiredPlugins),
|
1069 |
-
astra_site_options : astraSiteOptions,
|
1070 |
-
astra_enabled_extensions : astraEnabledExtensions,
|
1071 |
-
}];
|
1072 |
-
|
1073 |
-
// delete any earlier fullscreen preview before we render new one.
|
1074 |
-
jQuery('.theme-install-overlay').remove();
|
1075 |
-
|
1076 |
-
jQuery('#astra-sites-menu-page').append(template(templateData[0]));
|
1077 |
-
jQuery('.theme-install-overlay').css('display', 'block');
|
1078 |
-
AstraSitesAdmin._checkNextPrevButtons();
|
1079 |
-
|
1080 |
-
var desc = jQuery('.theme-details');
|
1081 |
-
var descHeight = parseInt( desc.outerHeight() );
|
1082 |
-
var descBtn = jQuery('.theme-details-read-more');
|
1083 |
-
|
1084 |
-
if( $.isArray( requiredPlugins ) ) {
|
1085 |
-
|
1086 |
-
if( descHeight >= 55 ) {
|
1087 |
-
|
1088 |
-
// Show button.
|
1089 |
-
descBtn.css( 'display', 'inline-block' );
|
1090 |
-
|
1091 |
-
// Set height upto 3 line.
|
1092 |
-
desc.css( 'height', 57 );
|
1093 |
-
|
1094 |
-
// Button Click.
|
1095 |
-
descBtn.click(function(event) {
|
1096 |
-
|
1097 |
-
if( descBtn.hasClass('open') ) {
|
1098 |
-
desc.animate({ height: 57 },
|
1099 |
-
300, function() {
|
1100 |
-
descBtn.removeClass('open');
|
1101 |
-
descBtn.html( astraSitesAdmin.strings.DescExpand );
|
1102 |
-
});
|
1103 |
-
} else {
|
1104 |
-
desc.animate({ height: descHeight },
|
1105 |
-
300, function() {
|
1106 |
-
descBtn.addClass('open');
|
1107 |
-
descBtn.html( astraSitesAdmin.strings.DescCollapse );
|
1108 |
-
});
|
1109 |
-
}
|
1110 |
-
|
1111 |
-
});
|
1112 |
-
}
|
1113 |
-
|
1114 |
-
// or
|
1115 |
-
var $pluginsFilter = jQuery( '#plugin-filter' ),
|
1116 |
-
data = {
|
1117 |
-
action : 'astra-required-plugins',
|
1118 |
-
_ajax_nonce : astraSitesAdmin._ajax_nonce,
|
1119 |
-
required_plugins : requiredPlugins
|
1120 |
-
};
|
1121 |
-
|
1122 |
-
// Add disabled class from import button.
|
1123 |
-
$('.astra-demo-import')
|
1124 |
-
.addClass('disabled not-click-able')
|
1125 |
-
.removeAttr('data-import');
|
1126 |
-
|
1127 |
-
jQuery('.required-plugins').addClass('loading').html('<span class="spinner is-active"></span>');
|
1128 |
-
|
1129 |
-
// Required Required.
|
1130 |
-
$.ajax({
|
1131 |
-
url : astraSitesAdmin.ajaxurl,
|
1132 |
-
type : 'POST',
|
1133 |
-
data : data,
|
1134 |
-
})
|
1135 |
-
.fail(function( jqXHR ){
|
1136 |
-
|
1137 |
-
// Remove loader.
|
1138 |
-
jQuery('.required-plugins').removeClass('loading').html('');
|
1139 |
-
|
1140 |
-
AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText, 'plugins' );
|
1141 |
-
AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
|
1142 |
-
})
|
1143 |
-
.done(function ( response ) {
|
1144 |
-
|
1145 |
-
// Release disabled class from import button.
|
1146 |
-
$('.astra-demo-import')
|
1147 |
-
.removeClass('disabled not-click-able')
|
1148 |
-
.attr('data-import', 'disabled');
|
1149 |
-
|
1150 |
-
// Remove loader.
|
1151 |
-
jQuery('.required-plugins').removeClass('loading').html('');
|
1152 |
-
|
1153 |
-
/**
|
1154 |
-
* Count remaining plugins.
|
1155 |
-
* @type number
|
1156 |
-
*/
|
1157 |
-
var remaining_plugins = 0;
|
1158 |
-
|
1159 |
-
/**
|
1160 |
-
* Not Installed
|
1161 |
-
*
|
1162 |
-
* List of not installed required plugins.
|
1163 |
-
*/
|
1164 |
-
if ( typeof response.data.notinstalled !== 'undefined' ) {
|
1165 |
-
|
1166 |
-
// Add not have installed plugins count.
|
1167 |
-
remaining_plugins += parseInt( response.data.notinstalled.length );
|
1168 |
-
|
1169 |
-
jQuery( response.data.notinstalled ).each(function( index, plugin ) {
|
1170 |
-
|
1171 |
-
var output = '<div class="plugin-card ';
|
1172 |
-
output += ' plugin-card-'+plugin.slug+'"';
|
1173 |
-
output += ' data-slug="'+plugin.slug+'"';
|
1174 |
-
output += ' data-init="'+plugin.init+'">';
|
1175 |
-
output += ' <span class="title">'+plugin.name+'</span>';
|
1176 |
-
output += ' <button class="button install-now"';
|
1177 |
-
output += ' data-init="' + plugin.init + '"';
|
1178 |
-
output += ' data-slug="' + plugin.slug + '"';
|
1179 |
-
output += ' data-name="' + plugin.name + '">';
|
1180 |
-
output += wp.updates.l10n.installNow;
|
1181 |
-
output += ' </button>';
|
1182 |
-
// output += ' <span class="dashicons-no dashicons"></span>';
|
1183 |
-
output += '</div>';
|
1184 |
-
|
1185 |
-
jQuery('.required-plugins').append(output);
|
1186 |
-
|
1187 |
-
});
|
1188 |
-
}
|
1189 |
-
|
1190 |
-
/**
|
1191 |
-
* Inactive
|
1192 |
-
*
|
1193 |
-
* List of not inactive required plugins.
|
1194 |
-
*/
|
1195 |
-
if ( typeof response.data.inactive !== 'undefined' ) {
|
1196 |
-
|
1197 |
-
// Add inactive plugins count.
|
1198 |
-
remaining_plugins += parseInt( response.data.inactive.length );
|
1199 |
-
|
1200 |
-
jQuery( response.data.inactive ).each(function( index, plugin ) {
|
1201 |
-
|
1202 |
-
var output = '<div class="plugin-card ';
|
1203 |
-
output += ' plugin-card-'+plugin.slug+'"';
|
1204 |
-
output += ' data-slug="'+plugin.slug+'"';
|
1205 |
-
output += ' data-init="'+plugin.init+'">';
|
1206 |
-
output += ' <span class="title">'+plugin.name+'</span>';
|
1207 |
-
output += ' <button class="button activate-now button-primary"';
|
1208 |
-
output += ' data-init="' + plugin.init + '"';
|
1209 |
-
output += ' data-slug="' + plugin.slug + '"';
|
1210 |
-
output += ' data-name="' + plugin.name + '">';
|
1211 |
-
output += wp.updates.l10n.activatePlugin;
|
1212 |
-
output += ' </button>';
|
1213 |
-
// output += ' <span class="dashicons-no dashicons"></span>';
|
1214 |
-
output += '</div>';
|
1215 |
-
|
1216 |
-
jQuery('.required-plugins').append(output);
|
1217 |
-
|
1218 |
-
});
|
1219 |
-
}
|
1220 |
-
|
1221 |
-
/**
|
1222 |
-
* Active
|
1223 |
-
*
|
1224 |
-
* List of not active required plugins.
|
1225 |
-
*/
|
1226 |
-
if ( typeof response.data.active !== 'undefined' ) {
|
1227 |
-
|
1228 |
-
jQuery( response.data.active ).each(function( index, plugin ) {
|
1229 |
-
|
1230 |
-
var output = '<div class="plugin-card ';
|
1231 |
-
output += ' plugin-card-'+plugin.slug+'"';
|
1232 |
-
output += ' data-slug="'+plugin.slug+'"';
|
1233 |
-
output += ' data-init="'+plugin.init+'">';
|
1234 |
-
output += ' <span class="title">'+plugin.name+'</span>';
|
1235 |
-
output += ' <button class="button disabled"';
|
1236 |
-
output += ' data-slug="' + plugin.slug + '"';
|
1237 |
-
output += ' data-name="' + plugin.name + '">';
|
1238 |
-
output += astraSitesAdmin.strings.btnActive;
|
1239 |
-
output += ' </button>';
|
1240 |
-
// output += ' <span class="dashicons-yes dashicons"></span>';
|
1241 |
-
output += '</div>';
|
1242 |
-
|
1243 |
-
jQuery('.required-plugins').append(output);
|
1244 |
-
|
1245 |
-
});
|
1246 |
-
}
|
1247 |
-
|
1248 |
-
/**
|
1249 |
-
* Enable Demo Import Button
|
1250 |
-
* @type number
|
1251 |
-
*/
|
1252 |
-
astraSitesAdmin.requiredPlugins = response.data;
|
1253 |
-
AstraSitesAdmin._enable_demo_import_button();
|
1254 |
-
|
1255 |
-
});
|
1256 |
-
|
1257 |
-
} else {
|
1258 |
-
|
1259 |
-
// Enable Demo Import Button
|
1260 |
-
AstraSitesAdmin._enable_demo_import_button( demoType );
|
1261 |
-
jQuery('.required-plugins-wrap').remove();
|
1262 |
-
}
|
1263 |
-
|
1264 |
-
return;
|
1265 |
-
},
|
1266 |
-
|
1267 |
-
/**
|
1268 |
-
* Enable Demo Import Button.
|
1269 |
-
*/
|
1270 |
-
_enable_demo_import_button: function( type ) {
|
1271 |
-
|
1272 |
-
type = ( undefined !== type ) ? type : 'free';
|
1273 |
-
|
1274 |
-
switch( type ) {
|
1275 |
-
|
1276 |
-
case 'free':
|
1277 |
-
var all_buttons = parseInt( jQuery( '.plugin-card .button' ).length ) || 0,
|
1278 |
-
disabled_buttons = parseInt( jQuery( '.plugin-card .button.disabled' ).length ) || 0;
|
1279 |
-
|
1280 |
-
if( all_buttons === disabled_buttons ) {
|
1281 |
-
|
1282 |
-
jQuery('.astra-demo-import')
|
1283 |
-
.removeAttr('data-import')
|
1284 |
-
.removeClass('installing updating-message')
|
1285 |
-
.addClass('button-primary')
|
1286 |
-
.text( astraSitesAdmin.strings.importDemo );
|
1287 |
-
}
|
1288 |
-
|
1289 |
-
break;
|
1290 |
-
|
1291 |
-
case 'upgrade':
|
1292 |
-
var demo_slug = jQuery('.wp-full-overlay-header').attr('data-demo-slug');
|
1293 |
-
|
1294 |
-
jQuery('.astra-demo-import')
|
1295 |
-
.addClass('go-pro button-primary')
|
1296 |
-
.removeClass('astra-demo-import')
|
1297 |
-
.attr('target', '_blank')
|
1298 |
-
.attr('href', astraSitesAdmin.getUpgradeURL + demo_slug )
|
1299 |
-
.text( astraSitesAdmin.getUpgradeText )
|
1300 |
-
.append('<i class="dashicons dashicons-external"></i>');
|
1301 |
-
break;
|
1302 |
-
|
1303 |
-
default:
|
1304 |
-
var demo_slug = jQuery('.wp-full-overlay-header').attr('data-demo-slug');
|
1305 |
-
|
1306 |
-
jQuery('.astra-demo-import')
|
1307 |
-
.addClass('go-pro button-primary')
|
1308 |
-
.removeClass('astra-demo-import')
|
1309 |
-
.attr('target', '_blank')
|
1310 |
-
.attr('href', astraSitesAdmin.getProURL )
|
1311 |
-
.text( astraSitesAdmin.getProText )
|
1312 |
-
.append('<i class="dashicons dashicons-external"></i>');
|
1313 |
-
break;
|
1314 |
-
}
|
1315 |
-
|
1316 |
-
},
|
1317 |
-
|
1318 |
-
/**
|
1319 |
-
* Update Page Count.
|
1320 |
-
*/
|
1321 |
-
_updatedPagedCount: function() {
|
1322 |
-
paged = parseInt(jQuery('body').attr('data-astra-demo-paged'));
|
1323 |
-
jQuery('body').attr('data-astra-demo-paged', paged + 1);
|
1324 |
-
window.setTimeout(function () {
|
1325 |
-
jQuery('body').data('scrolling', false);
|
1326 |
-
}, 800);
|
1327 |
-
},
|
1328 |
-
|
1329 |
-
/**
|
1330 |
-
* Reset Page Count.
|
1331 |
-
*/
|
1332 |
-
_resetPagedCount: function() {
|
1333 |
-
|
1334 |
-
$('body').addClass('loading-content');
|
1335 |
-
$('body').attr('data-astra-demo-last-request', '1');
|
1336 |
-
$('body').attr('data-astra-demo-paged', '1');
|
1337 |
-
$('body').attr('data-astra-demo-search', '');
|
1338 |
-
$('body').attr('data-scrolling', false);
|
1339 |
-
|
1340 |
-
},
|
1341 |
-
|
1342 |
-
/**
|
1343 |
-
* Remove plugin from the queue.
|
1344 |
-
*/
|
1345 |
-
_removePluginFromQueue: function( removeItem, pluginsList ) {
|
1346 |
-
return jQuery.grep(pluginsList, function( value ) {
|
1347 |
-
return value.slug != removeItem;
|
1348 |
-
});
|
1349 |
-
}
|
1350 |
-
|
1351 |
-
};
|
1352 |
-
|
1353 |
-
/**
|
1354 |
-
* Initialize AstraSitesAdmin
|
1355 |
-
*/
|
1356 |
-
$(function(){
|
1357 |
-
AstraSitesAdmin.init();
|
1358 |
-
});
|
1359 |
-
|
1360 |
Â
})(jQuery);
|
1 |
+
/**
|
2 |
+
* AJAX Request Queue
|
3 |
+
*
|
4 |
+
* - add()
|
5 |
+
* - remove()
|
6 |
+
* - run()
|
7 |
+
* - stop()
|
8 |
+
*
|
9 |
+
* @since 1.0.0
|
10 |
+
*/
|
11 |
+
var AstraSitesAjaxQueue = (function() {
|
12 |
+
|
13 |
+
var requests = [];
|
14 |
+
|
15 |
+
return {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Add AJAX request
|
19 |
+
*
|
20 |
+
* @since 1.0.0
|
21 |
+
*/
|
22 |
+
add: function(opt) {
|
23 |
+
requests.push(opt);
|
24 |
+
},
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Remove AJAX request
|
28 |
+
*
|
29 |
+
* @since 1.0.0
|
30 |
+
*/
|
31 |
+
remove: function(opt) {
|
32 |
+
if( jQuery.inArray(opt, requests) > -1 )
|
33 |
+
requests.splice($.inArray(opt, requests), 1);
|
34 |
+
},
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Run / Process AJAX request
|
38 |
+
*
|
39 |
+
* @since 1.0.0
|
40 |
+
*/
|
41 |
+
run: function() {
|
42 |
+
var self = this,
|
43 |
+
oriSuc;
|
44 |
+
|
45 |
+
if( requests.length ) {
|
46 |
+
oriSuc = requests[0].complete;
|
47 |
+
|
48 |
+
requests[0].complete = function() {
|
49 |
+
if( typeof(oriSuc) === 'function' ) oriSuc();
|
50 |
+
requests.shift();
|
51 |
+
self.run.apply(self, []);
|
52 |
+
};
|
53 |
+
|
54 |
+
jQuery.ajax(requests[0]);
|
55 |
+
|
56 |
+
} else {
|
57 |
+
|
58 |
+
self.tid = setTimeout(function() {
|
59 |
+
self.run.apply(self, []);
|
60 |
+
}, 1000);
|
61 |
+
}
|
62 |
+
},
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Stop AJAX request
|
66 |
+
*
|
67 |
+
* @since 1.0.0
|
68 |
+
*/
|
69 |
+
stop: function() {
|
70 |
+
|
71 |
+
requests = [];
|
72 |
+
clearTimeout(this.tid);
|
73 |
+
}
|
74 |
+
};
|
75 |
+
|
76 |
+
}());
|
77 |
+
|
78 |
+
(function($){
|
79 |
+
|
80 |
+
var AstraSSEImport = {
|
81 |
+
complete: {
|
82 |
+
posts: 0,
|
83 |
+
media: 0,
|
84 |
+
users: 0,
|
85 |
+
comments: 0,
|
86 |
+
terms: 0,
|
87 |
+
},
|
88 |
+
|
89 |
+
updateDelta: function (type, delta) {
|
90 |
+
this.complete[ type ] += delta;
|
91 |
+
|
92 |
+
var self = this;
|
93 |
+
requestAnimationFrame(function () {
|
94 |
+
self.render();
|
95 |
+
});
|
96 |
+
},
|
97 |
+
updateProgress: function ( type, complete, total ) {
|
98 |
+
var text = complete + '/' + total;
|
99 |
+
|
100 |
+
if( 'undefined' !== type && 'undefined' !== text ) {
|
101 |
+
total = parseInt( total, 10 );
|
102 |
+
if ( 0 === total || isNaN( total ) ) {
|
103 |
+
total = 1;
|
104 |
+
}
|
105 |
+
var percent = parseInt( complete, 10 ) / total;
|
106 |
+
var progress = Math.round( percent * 100 ) + '%';
|
107 |
+
var progress_bar = percent * 100;
|
108 |
+
}
|
109 |
+
},
|
110 |
+
render: function () {
|
111 |
+
var types = Object.keys( this.complete );
|
112 |
+
var complete = 0;
|
113 |
+
var total = 0;
|
114 |
+
|
115 |
+
for (var i = types.length - 1; i >= 0; i--) {
|
116 |
+
var type = types[i];
|
117 |
+
this.updateProgress( type, this.complete[ type ], this.data.count[ type ] );
|
118 |
+
|
119 |
+
complete += this.complete[ type ];
|
120 |
+
total += this.data.count[ type ];
|
121 |
+
}
|
122 |
+
|
123 |
+
this.updateProgress( 'total', complete, total );
|
124 |
+
}
|
125 |
+
};
|
126 |
+
|
127 |
+
AstraSitesAdmin = {
|
128 |
+
|
129 |
+
log_file : '',
|
130 |
+
customizer_data : '',
|
131 |
+
wxr_url : '',
|
132 |
+
options_data : '',
|
133 |
+
widgets_data : '',
|
134 |
+
|
135 |
+
init: function()
|
136 |
+
{
|
137 |
+
this._resetPagedCount();
|
138 |
+
this._bind();
|
139 |
+
},
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Debugging.
|
143 |
+
*
|
144 |
+
* @param {mixed} data Mixed data.
|
145 |
+
*/
|
146 |
+
_log: function( data ) {
|
147 |
+
|
148 |
+
if( astraSitesAdmin.debug ) {
|
149 |
+
|
150 |
+
var date = new Date();
|
151 |
+
var time = date.toLocaleTimeString();
|
152 |
+
|
153 |
+
if (typeof data == 'object') {
|
154 |
+
console.log('%c ' + JSON.stringify( data ) + ' ' + time, 'background: #ededed; color: #444');
|
155 |
+
} else {
|
156 |
+
console.log('%c ' + data + ' ' + time, 'background: #ededed; color: #444');
|
157 |
+
}
|
158 |
+
|
159 |
+
|
160 |
+
}
|
161 |
+
},
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Binds events for the Astra Sites.
|
165 |
+
*
|
166 |
+
* @since 1.0.0
|
167 |
+
* @access private
|
168 |
+
* @method _bind
|
169 |
+
*/
|
170 |
+
_bind: function()
|
171 |
+
{
|
172 |
+
$( document ).on('click' , '.devices button', AstraSitesAdmin._previewDevice);
|
173 |
+
$( document ).on('click' , '.theme-browser .theme-screenshot, .theme-browser .more-details, .theme-browser .install-theme-preview', AstraSitesAdmin._preview);
|
174 |
+
$( document ).on('click' , '.next-theme', AstraSitesAdmin._nextTheme);
|
175 |
+
$( document ).on('click' , '.previous-theme', AstraSitesAdmin._previousTheme);
|
176 |
+
$( document ).on('click' , '.collapse-sidebar', AstraSitesAdmin._collapse);
|
177 |
+
$( document ).on('click' , '.astra-demo-import', AstraSitesAdmin._importDemo);
|
178 |
+
$( document ).on('click' , '.install-now', AstraSitesAdmin._installNow);
|
179 |
+
$( document ).on('click' , '.close-full-overlay', AstraSitesAdmin._fullOverlay);
|
180 |
+
$( document ).on('click' , '.activate-now', AstraSitesAdmin._activateNow);
|
181 |
+
$( document ).on('wp-plugin-installing' , AstraSitesAdmin._pluginInstalling);
|
182 |
+
$( document ).on('wp-plugin-install-error' , AstraSitesAdmin._installError);
|
183 |
+
$( document ).on('wp-plugin-install-success' , AstraSitesAdmin._installSuccess);
|
184 |
+
|
185 |
+
$( document ).on('astra-sites-import-set-site-data-done' , AstraSitesAdmin._importCustomizerSettings );
|
186 |
+
$( document ).on('astra-sites-import-customizer-settings-done' , AstraSitesAdmin._importPrepareXML );
|
187 |
+
$( document ).on('astra-sites-import-xml-done' , AstraSitesAdmin._importSiteOptions );
|
188 |
+
$( document ).on('astra-sites-import-options-done' , AstraSitesAdmin._importWidgets );
|
189 |
+
$( document ).on('astra-sites-import-widgets-done' , AstraSitesAdmin._importEnd );
|
190 |
+
},
|
191 |
+
|
192 |
+
/**
|
193 |
+
* 5. Import Complete.
|
194 |
+
*/
|
195 |
+
_importEnd: function( event ) {
|
196 |
+
|
197 |
+
$.ajax({
|
198 |
+
url : astraSitesAdmin.ajaxurl,
|
199 |
+
type : 'POST',
|
200 |
+
dataType: 'json',
|
201 |
+
data : {
|
202 |
+
action : 'astra-sites-import-end',
|
203 |
+
},
|
204 |
+
beforeSend: function() {
|
205 |
+
$('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importComplete );
|
206 |
+
}
|
207 |
+
})
|
208 |
+
.fail(function( jqXHR ){
|
209 |
+
AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
|
210 |
+
AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
|
211 |
+
})
|
212 |
+
.done(function ( data ) {
|
213 |
+
|
214 |
+
// 5. Fail - Import Complete.
|
215 |
+
if( false === data.success ) {
|
216 |
+
AstraSitesAdmin._importFailMessage( data.data );
|
217 |
+
AstraSitesAdmin._log( data.data );
|
218 |
+
} else {
|
219 |
+
|
220 |
+
// 5. Pass - Import Complete.
|
221 |
+
AstraSitesAdmin._importSuccessMessage();
|
222 |
+
AstraSitesAdmin._log( astraSitesAdmin.log.success + ' ' + astraSitesAdmin.siteURL );
|
223 |
+
}
|
224 |
+
});
|
225 |
+
},
|
226 |
+
|
227 |
+
/**
|
228 |
+
* 4. Import Widgets.
|
229 |
+
*/
|
230 |
+
_importWidgets: function( event ) {
|
231 |
+
|
232 |
+
$.ajax({
|
233 |
+
url : astraSitesAdmin.ajaxurl,
|
234 |
+
type : 'POST',
|
235 |
+
dataType: 'json',
|
236 |
+
data : {
|
237 |
+
action : 'astra-sites-import-widgets',
|
238 |
+
widgets_data : AstraSitesAdmin.widgets_data,
|
239 |
+
},
|
240 |
+
beforeSend: function() {
|
241 |
+
AstraSitesAdmin._log( astraSitesAdmin.log.importWidgets );
|
242 |
+
$('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importingWidgets );
|
243 |
+
},
|
244 |
+
})
|
245 |
+
.fail(function( jqXHR ){
|
246 |
+
AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
|
247 |
+
AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
|
248 |
+
})
|
249 |
+
.done(function ( widgets_data ) {
|
250 |
+
|
251 |
+
// 4. Fail - Import Widgets.
|
252 |
+
if( false === widgets_data.success ) {
|
253 |
+
AstraSitesAdmin._importFailMessage( widgets_data.data );
|
254 |
+
AstraSitesAdmin._log( widgets_data.data );
|
255 |
+
|
256 |
+
} else {
|
257 |
+
|
258 |
+
// 4. Pass - Import Widgets.
|
259 |
+
AstraSitesAdmin._log( astraSitesAdmin.log.importWidgetsSuccess );
|
260 |
+
$(document).trigger( 'astra-sites-import-widgets-done' );
|
261 |
+
}
|
262 |
+
});
|
263 |
+
},
|
264 |
+
|
265 |
+
/**
|
266 |
+
* 3. Import Site Options.
|
267 |
+
*/
|
268 |
+
_importSiteOptions: function( event ) {
|
269 |
+
|
270 |
+
$.ajax({
|
271 |
+
url : astraSitesAdmin.ajaxurl,
|
272 |
+
type : 'POST',
|
273 |
+
dataType: 'json',
|
274 |
+
data : {
|
275 |
+
action : 'astra-sites-import-options',
|
276 |
+
options_data : AstraSitesAdmin.options_data,
|
277 |
+
},
|
278 |
+
beforeSend: function() {
|
279 |
+
AstraSitesAdmin._log( astraSitesAdmin.log.importOptions );
|
280 |
+
$('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importingOptions );
|
281 |
+
},
|
282 |
+
})
|
283 |
+
.fail(function( jqXHR ){
|
284 |
+
AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
|
285 |
+
AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
|
286 |
+
})
|
287 |
+
.done(function ( options_data ) {
|
288 |
+
|
289 |
+
// 3. Fail - Import Site Options.
|
290 |
+
if( false === options_data.success ) {
|
291 |
+
AstraSitesAdmin._log( options_data );
|
292 |
+
AstraSitesAdmin._importFailMessage( options_data.data );
|
293 |
+
AstraSitesAdmin._log( options_data.data );
|
294 |
+
|
295 |
+
} else {
|
296 |
+
|
297 |
+
// 3. Pass - Import Site Options.
|
298 |
+
AstraSitesAdmin._log( astraSitesAdmin.log.importOptionsSuccess );
|
299 |
+
$(document).trigger( 'astra-sites-import-options-done' );
|
300 |
+
}
|
301 |
+
});
|
302 |
+
},
|
303 |
+
|
304 |
+
/**
|
305 |
+
* 2. Prepare XML Data.
|
306 |
+
*/
|
307 |
+
_importPrepareXML: function( event ) {
|
308 |
+
|
309 |
+
$.ajax({
|
310 |
+
url : astraSitesAdmin.ajaxurl,
|
311 |
+
type : 'POST',
|
312 |
+
dataType: 'json',
|
313 |
+
data : {
|
314 |
+
action : 'astra-sites-import-prepare-xml',
|
315 |
+
wxr_url : AstraSitesAdmin.wxr_url,
|
316 |
+
},
|
317 |
+
beforeSend: function() {
|
318 |
+
AstraSitesAdmin._log( astraSitesAdmin.log.importXMLPrepare );
|
319 |
+
$('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importXMLPreparing );
|
320 |
+
},
|
321 |
+
})
|
322 |
+
.fail(function( jqXHR ){
|
323 |
+
AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
|
324 |
+
AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
|
325 |
+
})
|
326 |
+
.done(function ( xml_data ) {
|
327 |
+
|
328 |
+
// 2. Fail - Prepare XML Data.
|
329 |
+
if( false === xml_data.success ) {
|
330 |
+
AstraSitesAdmin._log( xml_data );
|
331 |
+
AstraSitesAdmin._importFailMessage( xml_data.data );
|
332 |
+
AstraSitesAdmin._log( xml_data.data );
|
333 |
+
|
334 |
+
} else {
|
335 |
+
|
336 |
+
// 2. Pass - Prepare XML Data.
|
337 |
+
AstraSitesAdmin._log( astraSitesAdmin.log.importXMLPrepareSuccess );
|
338 |
+
|
339 |
+
// Import XML though Event Source.
|
340 |
+
AstraSSEImport.data = xml_data.data;
|
341 |
+
AstraSSEImport.render();
|
342 |
+
|
343 |
+
AstraSitesAdmin._log( astraSitesAdmin.log.importXML );
|
344 |
+
$('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importingXML );
|
345 |
+
|
346 |
+
var evtSource = new EventSource( AstraSSEImport.data.url );
|
347 |
+
evtSource.onmessage = function ( message ) {
|
348 |
+
var data = JSON.parse( message.data );
|
349 |
+
switch ( data.action ) {
|
350 |
+
case 'updateDelta':
|
351 |
+
AstraSSEImport.updateDelta( data.type, data.delta );
|
352 |
+
break;
|
353 |
+
|
354 |
+
case 'complete':
|
355 |
+
evtSource.close();
|
356 |
+
|
357 |
+
// 2. Pass - Import XML though "Source Event".
|
358 |
+
AstraSitesAdmin._log( astraSitesAdmin.log.importXMLSuccess );
|
359 |
+
AstraSitesAdmin._log( '----- SSE - XML import Complete -----' );
|
360 |
+
|
361 |
+
$(document).trigger( 'astra-sites-import-xml-done' );
|
362 |
+
|
363 |
+
break;
|
364 |
+
}
|
365 |
+
};
|
366 |
+
evtSource.addEventListener( 'log', function ( message ) {
|
367 |
+
var data = JSON.parse( message.data );
|
368 |
+
AstraSitesAdmin._log( data.level + ' ' + data.message );
|
369 |
+
});
|
370 |
+
}
|
371 |
+
});
|
372 |
+
},
|
373 |
+
|
374 |
+
/**
|
375 |
+
* 1. Import Customizer Options.
|
376 |
+
*/
|
377 |
+
_importCustomizerSettings: function( event ) {
|
378 |
+
|
379 |
+
$.ajax({
|
380 |
+
url : astraSitesAdmin.ajaxurl,
|
381 |
+
type : 'POST',
|
382 |
+
dataType: 'json',
|
383 |
+
data : {
|
384 |
+
action : 'astra-sites-import-customizer-settings',
|
385 |
+
customizer_data : AstraSitesAdmin.customizer_data,
|
386 |
+
},
|
387 |
+
beforeSend: function() {
|
388 |
+
AstraSitesAdmin._log( astraSitesAdmin.log.importCustomizer );
|
389 |
+
$('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importingCustomizer );
|
390 |
+
},
|
391 |
+
})
|
392 |
+
.fail(function( jqXHR ){
|
393 |
+
AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
|
394 |
+
AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
|
395 |
+
})
|
396 |
+
.done(function ( customizer_data ) {
|
397 |
+
|
398 |
+
// 1. Fail - Import Customizer Options.
|
399 |
+
if( false === customizer_data.success ) {
|
400 |
+
AstraSitesAdmin._importFailMessage( customizer_data.data );
|
401 |
+
AstraSitesAdmin._log( customizer_data.data );
|
402 |
+
} else {
|
403 |
+
|
404 |
+
// 1. Pass - Import Customizer Options.
|
405 |
+
AstraSitesAdmin._log( astraSitesAdmin.log.importCustomizerSuccess );
|
406 |
+
|
407 |
+
$(document).trigger( 'astra-sites-import-customizer-settings-done' );
|
408 |
+
}
|
409 |
+
});
|
410 |
+
},
|
411 |
+
|
412 |
+
/**
|
413 |
+
* Import Success Button.
|
414 |
+
*
|
415 |
+
* @param {string} data Error message.
|
416 |
+
*/
|
417 |
+
_importSuccessMessage: function() {
|
418 |
+
|
419 |
+
$('.astra-demo-import').removeClass('updating-message installing')
|
420 |
+
.removeAttr('data-import')
|
421 |
+
.addClass('view-site')
|
422 |
+
.removeClass('astra-demo-import')
|
423 |
+
.text( astraSitesAdmin.strings.viewSite )
|
424 |
+
.attr('target', '_blank')
|
425 |
+
.append('<i class="dashicons dashicons-external"></i>')
|
426 |
+
.attr('href', astraSitesAdmin.siteURL );
|
427 |
+
},
|
428 |
+
|
429 |
+
/**
|
430 |
+
* Preview Device
|
431 |
+
*/
|
432 |
+
_previewDevice: function( event ) {
|
433 |
+
var device = $( event.currentTarget ).data( 'device' );
|
434 |
+
|
435 |
+
$('.theme-install-overlay')
|
436 |
+
.removeClass( 'preview-desktop preview-tablet preview-mobile' )
|
437 |
+
.addClass( 'preview-' + device )
|
438 |
+
.data( 'current-preview-device', device );
|
439 |
+
|
440 |
+
AstraSitesAdmin._tooglePreviewDeviceButtons( device );
|
441 |
+
},
|
442 |
+
|
443 |
+
/**
|
444 |
+
* Toggle Preview Buttons
|
445 |
+
*/
|
446 |
+
_tooglePreviewDeviceButtons: function( newDevice ) {
|
447 |
+
var $devices = $( '.wp-full-overlay-footer .devices' );
|
448 |
+
|
449 |
+
$devices.find( 'button' )
|
450 |
+
.removeClass( 'active' )
|
451 |
+
.attr( 'aria-pressed', false );
|
452 |
+
|
453 |
+
$devices.find( 'button.preview-' + newDevice )
|
454 |
+
.addClass( 'active' )
|
455 |
+
.attr( 'aria-pressed', true );
|
456 |
+
},
|
457 |
+
|
458 |
+
/**
|
459 |
+
* Import Error Button.
|
460 |
+
*
|
461 |
+
* @param {string} data Error message.
|
462 |
+
*/
|
463 |
+
_importFailMessage: function( message, from ) {
|
464 |
+
|
465 |
+
$('.astra-demo-import')
|
466 |
+
.addClass('go-pro button-primary')
|
467 |
+
.removeClass('updating-message installing')
|
468 |
+
.removeAttr('data-import')
|
469 |
+
.attr('target', '_blank')
|
470 |
+
.append('<i class="dashicons dashicons-external"></i>')
|
471 |
+
.removeClass('astra-demo-import');
|
472 |
+
|
473 |
+
// Add the doc link due to import log file not generated.
|
474 |
+
if( 'undefined' === from ) {
|
475 |
+
|
476 |
+
$('.wp-full-overlay-header .go-pro').text( astraSitesAdmin.strings.importFailedBtnSmall );
|
477 |
+
$('.wp-full-overlay-footer .go-pro').text( astraSitesAdmin.strings.importFailedBtnLarge );
|
478 |
+
$('.go-pro').attr('href', astraSitesAdmin.log.serverConfiguration );
|
479 |
+
|
480 |
+
// Add the import log file link.
|
481 |
+
} else {
|
482 |
+
|
483 |
+
$('.wp-full-overlay-header .go-pro').text( astraSitesAdmin.strings.importFailBtn );
|
484 |
+
$('.wp-full-overlay-footer .go-pro').text( astraSitesAdmin.strings.importFailBtnLarge )
|
485 |
+
|
486 |
+
// Add the import log file link.
|
487 |
+
if( 'undefined' !== AstraSitesAdmin.log_file_url ) {
|
488 |
+
$('.go-pro').attr('href', AstraSitesAdmin.log_file_url );
|
489 |
+
} else {
|
490 |
+
$('.go-pro').attr('href', astraSitesAdmin.log.serverConfiguration );
|
491 |
+
}
|
492 |
+
}
|
493 |
+
|
494 |
+
var output = '<div class="astra-api-error notice notice-error notice-alt is-dismissible">';
|
495 |
+
output += ' <p>'+message+'</p>';
|
496 |
+
output += ' <button type="button" class="notice-dismiss">';
|
497 |
+
output += ' <span class="screen-reader-text">'+commonL10n.dismiss+'</span>';
|
498 |
+
output += ' </button>';
|
499 |
+
output += '</div>';
|
500 |
+
|
501 |
+
// Fail Notice.
|
502 |
+
$('.install-theme-info').append( output );
|
503 |
+
|
504 |
+
|
505 |
+
// !important to add trigger.
|
506 |
+
// Which reinitialize the dismiss error message events.
|
507 |
+
$(document).trigger('wp-updates-notice-added');
|
508 |
+
},
|
509 |
+
|
510 |
+
|
511 |
+
/**
|
512 |
+
* Install Now
|
513 |
+
*/
|
514 |
+
_installNow: function(event)
|
515 |
+
{
|
516 |
+
event.preventDefault();
|
517 |
+
|
518 |
+
var $button = jQuery( event.target ),
|
519 |
+
$document = jQuery(document);
|
520 |
+
|
521 |
+
if ( $button.hasClass( 'updating-message' ) || $button.hasClass( 'button-disabled' ) ) {
|
522 |
+
return;
|
523 |
+
}
|
524 |
+
|
525 |
+
if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked ) {
|
526 |
+
wp.updates.requestFilesystemCredentials( event );
|