Astra Starter Sites - Version 1.3.5

Version Description

Download this release

Release Info

Developer patilvikasj
Plugin Icon Astra Starter Sites
Version 1.3.5
Comparing to
See all releases

Code changes from version 1.3.4 to 1.3.5

Files changed (34) hide show
  1. astra-sites.php +54 -54
  2. inc/assets/css/admin.css +149 -21
  3. inc/assets/images/beaver-builder.png +0 -0
  4. inc/assets/images/brizy.jpg +0 -0
  5. inc/assets/images/elementor.jpg +0 -0
  6. inc/assets/images/gutenberg.jpg +0 -0
  7. inc/assets/js/admin-page.js +181 -143
  8. inc/assets/js/astra-sites-api.js +27 -31
  9. inc/assets/js/astra-sites-notices.js +0 -21
  10. inc/assets/js/fetch.umd.js +531 -0
  11. inc/assets/js/install-theme.js +23 -3
  12. inc/assets/js/render-grid.js +118 -16
  13. inc/classes/class-astra-sites-importer-log.php +1 -190
  14. inc/classes/class-astra-sites-importer.php +25 -28
  15. inc/classes/class-astra-sites-notices.php +0 -214
  16. inc/classes/class-astra-sites-page.php +86 -12
  17. inc/classes/class-astra-sites-white-label.php +1 -1
  18. inc/classes/class-astra-sites.php +40 -25
  19. inc/classes/compatibility/astra-pro/class-astra-sites-compatibility-astra-pro.php +3 -3
  20. inc/importers/batch-processing/class-astra-sites-batch-processing-beaver-builder.php +2 -2
  21. inc/importers/batch-processing/class-astra-sites-batch-processing-brizy.php +1 -1
  22. inc/importers/batch-processing/class-astra-sites-batch-processing-elementor.php +0 -2
  23. inc/importers/batch-processing/class-astra-sites-batch-processing-gutenberg.php +2 -2
  24. inc/importers/batch-processing/class-astra-sites-batch-processing-misc.php +2 -2
  25. inc/importers/batch-processing/class-astra-sites-batch-processing-widgets.php +1 -1
  26. inc/importers/batch-processing/class-astra-sites-batch-processing.php +3 -2
  27. inc/importers/batch-processing/helpers/class-astra-sites-image-importer.php +5 -25
  28. inc/importers/batch-processing/helpers/class-wp-background-process-astra.php +5 -1
  29. inc/importers/wxr-importer/class-astra-wxr-importer.php +5 -0
  30. inc/includes/admin-page.php +15 -5
  31. inc/lib/astra-notices/class-astra-notices.php +334 -0
  32. inc/lib/astra-notices/notices.js +94 -0
  33. languages/astra-sites.pot +178 -155
  34. readme.txt +7 -1
astra-sites.php CHANGED
@@ -1,54 +1,54 @@
1
- <?php
2
- /**
3
- * Plugin Name: Astra Starter Sites – Elementor, Beaver Builder & Gutenberg Templates
4
- * Plugin URI: http://www.wpastra.com/pro/
5
- * Description: Import free sites build with Astra theme.
6
- * Version: 1.3.4
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.3.4' );
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 – Elementor, Beaver Builder & Gutenberg Templates
4
+ * Plugin URI: http://www.wpastra.com/pro/
5
+ * Description: Import free sites build with Astra theme.
6
+ * Version: 1.3.5
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.3.5' );
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
@@ -503,9 +503,8 @@ body.loading-content .select-page-builder {
503
margin-bottom: 1em;
504
}
505
506
- .astra-sites-welcome p.description {
507
font-size: 1rem;
508
- margin-bottom: 2em;
509
}
510
511
.astra-sites-welcome select {
@@ -513,24 +512,15 @@ body.loading-content .select-page-builder {
513
height: 100%;
514
}
515
516
- .astra-sites-welcome p.submit {
517
text-align: center;
518
margin: 0;
519
padding: 0;
520
margin-left: .5em;
521
}
522
523
- .astra-sites-welcome .fields {
524
- display: flex;
525
- vertical-align: middle;
526
- align-items: center;
527
- justify-content: center;
528
- }
529
-
530
- .astra-sites-welcome #submit {
531
- line-height: 1;
532
- padding: .5rem 1rem;
533
- height: auto;
534
}
535
536
.astra-site-page-builder {
@@ -559,7 +549,7 @@ body.loading-content .select-page-builder {
559
margin: 0;
560
}
561
562
- #astra-site-import-process-wrap {
563
display: flex;
564
align-items: center;
565
margin-top: -2px;
@@ -568,7 +558,16 @@ body.loading-content .select-page-builder {
568
border-radius: 3px;
569
overflow: hidden;
570
}
571
- #astra-site-import-process-wrap progress {
572
padding: 0px;
573
border: 0 none;
574
background: #0085bd;
@@ -577,10 +576,15 @@ body.loading-content .select-page-builder {
577
flex: 1;
578
}
579
580
- #astra-site-import-process-wrap progress::-webkit-progress-value {
581
background: #00679b;
582
}
583
- #astra-site-import-process-wrap progress::-webkit-progress-bar {
584
background: transparent;
585
}
586
@@ -603,9 +607,19 @@ body.loading-content .select-page-builder {
603
pointer-events: none;
604
}
605
606
.astra-sites-tooltip-icon .dashicons {
607
- color: #5d5d5d;
608
- font-size: 18px;
609
}
610
611
#astra-sites-welcome-form-inline {
@@ -652,4 +666,118 @@ body.loading-content .select-page-builder {
652
width: 100%;
653
border: none;
654
margin: 0;
655
- }
503
margin-bottom: 1em;
504
}
505
506
+ .astra-sites-welcome p {
507
font-size: 1rem;
508
}
509
510
.astra-sites-welcome select {
512
height: 100%;
513
}
514
515
+ .astra-sites-welcome .submit {
516
text-align: center;
517
margin: 0;
518
padding: 0;
519
margin-left: .5em;
520
}
521
522
+ .astra-sites-welcome .disabled {
523
+ pointer-events: none;
524
}
525
526
.astra-site-page-builder {
549
margin: 0;
550
}
551
552
+ .astra-site-import-process-wrap {
553
display: flex;
554
align-items: center;
555
margin-top: -2px;
558
border-radius: 3px;
559
overflow: hidden;
560
}
561
+
562
+ .astra-sites-result-preview .astra-site-import-process-wrap progress {
563
+ background: #eeeeee;
564
+ }
565
+
566
+ .astra-sites-result-preview .astra-site-import-process-wrap progress::-webkit-progress-value {
567
+ background: #0185ba;
568
+ }
569
+
570
+ .astra-site-import-process-wrap progress {
571
padding: 0px;
572
border: 0 none;
573
background: #0085bd;
576
flex: 1;
577
}
578
579
+ .astra-sites-result-preview .dashicons {
580
+ vertical-align: text-bottom;
581
+ }
582
+
583
+ .astra-site-import-process-wrap progress::-webkit-progress-value {
584
background: #00679b;
585
}
586
+
587
+ .astra-site-import-process-wrap progress::-webkit-progress-bar {
588
background: transparent;
589
}
590
607
pointer-events: none;
608
}
609
610
+ .astra-sites-preview input[type="checkbox"].disabled {
611
+ background: #eeeeee;
612
+ opacity: 1;
613
+ color: #fff;
614
+ box-shadow: none;
615
+ border-color: #b4b9be;
616
+ }
617
+
618
.astra-sites-tooltip-icon .dashicons {
619
+ color: #757575;
620
+ font-size: 15px;
621
+ vertical-align: middle;
622
+ height: auto;
623
}
624
625
#astra-sites-welcome-form-inline {
666
width: 100%;
667
border: none;
668
margin: 0;
669
+ }
670
+
671
+ #astra-sites-welcome-form #submit {
672
+ padding: 0em 4rem;
673
+ }
674
+
675
+ .page-builders li {
676
+ cursor: pointer;
677
+ display: inline-block;
678
+ padding: 1em;
679
+ }
680
+
681
+ .page-builders [type=radio] {
682
+ position: absolute;
683
+ opacity: 0;
684
+ width: 0;
685
+ height: 0;
686
+ }
687
+
688
+ .page-builders [type=radio] + img {
689
+ cursor: pointer;
690
+ opacity: .9;
691
+ border: 3px solid transparent;
692
+ border-radius: 10px;
693
+ transition: all linear 0.2s;
694
+ }
695
+
696
+ .page-builders [type=radio]:hover + img,
697
+ .page-builders [type=radio]:checked + img {
698
+ opacity: 1;
699
+ }
700
+
701
+ .astra-sites-page-builder-notice {
702
+ text-align: center;
703
+ margin: 1em 0 2em 0;
704
+ }
705
+
706
+ .current-importing-status-wrap {
707
+ font-size: 1rem;
708
+ }
709
+
710
+ .current-importing-status-wrap hr {
711
+ border-color: #f1f1f1;
712
+ }
713
+
714
+ .astra-sites-result-preview {
715
+ position: absolute;
716
+ left: 0;
717
+ right: 0;
718
+ top: 0;
719
+ bottom: 0;
720
+ background: #fff;
721
+ overflow-y: auto;
722
+ }
723
+
724
+ .astra-sites-result-preview .button {
725
+ margin-top: 1em;
726
+ }
727
+
728
+ .astra-sites-result-preview .inner {
729
+ margin: 0 auto;
730
+ max-width: 700px;
731
+ padding: 5em 0;
732
+ }
733
+
734
+ .astra-sites-result-preview h2 {
735
+ font-size: 2rem;
736
+ }
737
+
738
+ .astra-sites-result-preview p {
739
+ font-size: 1rem;
740
+ }
741
+
742
+ .current-importing-status {
743
+ font-size: 1rem;
744
+ background: #eeeeee;
745
+ padding: 1em 1.5em;
746
+ }
747
+
748
+ .current-importing-status-title {
749
+ margin-bottom: .5em;
750
+ }
751
+
752
+ .appearance_page_astra-sites .rotating {
753
+ height: auto;
754
+ animation: rotation 2s infinite linear;
755
+ width: auto;
756
+ color: #c1c1c1;
757
+ }
758
+
759
+ @-webkit-keyframes rotation {
760
+ from {
761
+ -webkit-transform: rotate(0deg);
762
+ }
763
+ to {
764
+ -webkit-transform: rotate(359deg);
765
+ }
766
+ }
767
+ .import-time {
768
+ display: inline-block;
769
+ background: #0185ba;
770
+ color: #fff;
771
+ padding: 2px 10px;
772
+ border-radius: 3px;
773
+ animation: astra-scale 0.5s alternate infinite ease-in;
774
+ }
775
+
776
+ @keyframes astra-scale {
777
+ 0% {transform: scale(1);}
778
+ 100% {transform: scale(1.03);}
779
+ }
780
+
781
+ .current-importing-status p {
782
+ margin: 0;
783
+ }
inc/assets/images/beaver-builder.png ADDED
Binary file
inc/assets/images/brizy.jpg ADDED
Binary file
inc/assets/images/elementor.jpg ADDED
Binary file
inc/assets/images/gutenberg.jpg ADDED
Binary file
inc/assets/js/admin-page.js CHANGED
@@ -107,8 +107,11 @@ var AstraSitesAjaxQueue = (function() {
107
var progress_bar = percent * 100;
108
109
if( progress_bar <= 100 ) {
110
- document.getElementById( 'astra-site-import-process' ).value = progress_bar;
111
- $('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importingXML + ' '+progress );
112
}
113
}
114
},
@@ -153,6 +156,8 @@ var AstraSitesAjaxQueue = (function() {
153
wpforms_url : '',
154
options_data : '',
155
widgets_data : '',
156
157
init: function()
158
{
@@ -182,6 +187,20 @@ var AstraSitesAjaxQueue = (function() {
182
}
183
},
184
185
/**
186
* Binds events for the Astra Sites.
187
*
@@ -192,6 +211,9 @@ var AstraSitesAjaxQueue = (function() {
192
_bind: function()
193
{
194
$( document ).on( 'click' , '.astra-sites-reset-data .checkbox', AstraSitesAdmin._toggle_reset_notice );
195
$( document ).on('change' , '#astra-sites-welcome-form-inline select', AstraSitesAdmin._change_page_builder);
196
$( document ).on('click' , '.astra-sites-tooltip-icon', AstraSitesAdmin._toggle_tooltip);
197
$( document ).on('click' , '.astra-sites-advanced-options-button', AstraSitesAdmin._toggle_advanced_options);
@@ -232,6 +254,19 @@ var AstraSitesAjaxQueue = (function() {
232
233
},
234
235
_change_page_builder: function() {
236
$(this).closest('form').submit();
237
},
@@ -267,15 +302,14 @@ var AstraSitesAjaxQueue = (function() {
267
action : 'astra-sites-reset-customizer-data'
268
},
269
beforeSend: function() {
270
- AstraSitesAdmin._log( 'Reseting Customizer Data' );
271
- $('.button-hero.astra-demo-import').text( 'Reseting Customizer Data' );
272
},
273
})
274
.fail(function( jqXHR ){
275
- AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
276
- AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
277
})
278
.done(function ( data ) {
279
$(document).trigger( 'astra-sites-reset-customizer-data-done' );
280
});
281
},
@@ -289,17 +323,14 @@ var AstraSitesAjaxQueue = (function() {
289
action : 'astra-sites-reset-site-options'
290
},
291
beforeSend: function() {
292
- AstraSitesAdmin._log( 'Reseting Site Options' );
293
- $('.button-hero.astra-demo-import').text( 'Reseting Site Options' );
294
},
295
})
296
.fail(function( jqXHR ){
297
- AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
298
- AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
299
})
300
.done(function ( data ) {
301
-
302
-
303
$(document).trigger( 'astra-sites-reset-site-options-done' );
304
});
305
},
@@ -313,16 +344,14 @@ var AstraSitesAjaxQueue = (function() {
313
action : 'astra-sites-reset-widgets-data'
314
},
315
beforeSend: function() {
316
- AstraSitesAdmin._log( 'Reseting Widgets' );
317
- $('.button-hero.astra-demo-import').text( 'Reseting Widgets' );
318
},
319
})
320
.fail(function( jqXHR ){
321
- AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
322
- AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
323
})
324
.done(function ( data ) {
325
- AstraSitesAdmin._log( data );
326
$(document).trigger( 'astra-sites-reset-widgets-data-done' );
327
});
328
},
@@ -332,11 +361,10 @@ var AstraSitesAjaxQueue = (function() {
332
333
AstraSitesAdmin.reset_remaining_posts = AstraSitesAdmin.site_imported_data['reset_posts'].length;
334
335
- // Delete all posts.
336
- // AstraSitesAjaxQueue.stop();
337
- // AstraSitesAjaxQueue.run();
338
-
339
$.each( AstraSitesAdmin.site_imported_data['reset_posts'], function(index, post_id) {
340
AstraSitesAjaxQueue.add({
341
url: astraSitesAdmin.ajaxurl,
342
type: 'POST',
@@ -349,8 +377,9 @@ var AstraSitesAjaxQueue = (function() {
349
if( AstraSitesAdmin.reset_processed_posts < AstraSitesAdmin.site_imported_data['reset_posts'].length ) {
350
AstraSitesAdmin.reset_processed_posts+=1;
351
}
352
-
353
- $('.button-hero.astra-demo-import').text( 'Deleting Item ' + AstraSitesAdmin.reset_processed_posts + ' of ' + AstraSitesAdmin.site_imported_data['reset_posts'].length );
354
AstraSitesAdmin.reset_remaining_posts-=1;
355
if( 0 == AstraSitesAdmin.reset_remaining_posts ) {
356
$(document).trigger( 'astra-sites-delete-posts-done' );
@@ -369,14 +398,11 @@ var AstraSitesAjaxQueue = (function() {
369
370
_reset_wp_forms: function() {
371
372
- AstraSitesAdmin._log( AstraSitesAdmin.site_imported_data['reset_wp_forms'] );
373
- AstraSitesAdmin._log( AstraSitesAdmin.site_imported_data['reset_wp_forms'].length );
374
-
375
if( AstraSitesAdmin.site_imported_data['reset_wp_forms'].length ) {
376
AstraSitesAdmin.reset_remaining_wp_forms = AstraSitesAdmin.site_imported_data['reset_wp_forms'].length;
377
378
$.each( AstraSitesAdmin.site_imported_data['reset_wp_forms'], function(index, post_id) {
379
- AstraSitesAdmin._log( 'WP Form ID: ' + post_id );
380
AstraSitesAjaxQueue.add({
381
url: astraSitesAdmin.ajaxurl,
382
type: 'POST',
@@ -385,13 +411,13 @@ var AstraSitesAjaxQueue = (function() {
385
post_id : post_id,
386
},
387
success: function( result ){
388
- AstraSitesAdmin._log( 'WP Forms Results' );
389
- AstraSitesAdmin._log( result );
390
if( AstraSitesAdmin.reset_processed_wp_forms < AstraSitesAdmin.site_imported_data['reset_wp_forms'].length ) {
391
AstraSitesAdmin.reset_processed_wp_forms+=1;
392
}
393
394
- $('.button-hero.astra-demo-import').text( 'Deleting Form ' + AstraSitesAdmin.reset_processed_wp_forms + ' of ' + AstraSitesAdmin.site_imported_data['reset_wp_forms'].length );
395
AstraSitesAdmin.reset_remaining_wp_forms-=1;
396
if( 0 == AstraSitesAdmin.reset_remaining_wp_forms ) {
397
$(document).trigger( 'astra-sites-delete-wp-forms-done' );
@@ -409,13 +435,12 @@ var AstraSitesAjaxQueue = (function() {
409
410
_reset_terms: function() {
411
412
- AstraSitesAdmin._log( AstraSitesAdmin.site_imported_data['reset_terms'] );
413
- AstraSitesAdmin._log( AstraSitesAdmin.site_imported_data['reset_terms'].length );
414
415
if( AstraSitesAdmin.site_imported_data['reset_terms'].length ) {
416
AstraSitesAdmin.reset_remaining_terms = AstraSitesAdmin.site_imported_data['reset_terms'].length;
417
418
$.each( AstraSitesAdmin.site_imported_data['reset_terms'], function(index, term_id) {
419
AstraSitesAjaxQueue.add({
420
url: astraSitesAdmin.ajaxurl,
421
type: 'POST',
@@ -427,10 +452,10 @@ var AstraSitesAjaxQueue = (function() {
427
if( AstraSitesAdmin.reset_processed_terms < AstraSitesAdmin.site_imported_data['reset_terms'].length ) {
428
AstraSitesAdmin.reset_processed_terms+=1;
429
}
430
- AstraSitesAdmin._log( result );
431
- $('.button-hero.astra-demo-import').text( 'Deleting Term ' + AstraSitesAdmin.reset_processed_terms + ' of ' + AstraSitesAdmin.site_imported_data['reset_terms'].length );
432
AstraSitesAdmin.reset_remaining_terms-=1;
433
- AstraSitesAdmin._log( AstraSitesAdmin.reset_remaining_terms );
434
if( 0 == AstraSitesAdmin.reset_remaining_terms ) {
435
$(document).trigger( 'astra-sites-delete-terms-done' );
436
}
@@ -471,18 +496,16 @@ var AstraSitesAjaxQueue = (function() {
471
action : 'astra-sites-backup-settings',
472
},
473
beforeSend: function() {
474
- AstraSitesAdmin._log( astraSitesAdmin.log.importWPForms );
475
- $('.button-hero.astra-demo-import').text( astraSitesAdmin.log.backupCustomizer );
476
},
477
})
478
.fail(function( jqXHR ){
479
- AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
480
- AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
481
})
482
.done(function ( data ) {
483
484
// 1. Pass - Import Customizer Options.
485
- AstraSitesAdmin._log( astraSitesAdmin.log.backupCustomizerSuccess );
486
487
// Custom trigger.
488
$(document).trigger( trigger_name );
@@ -506,13 +529,11 @@ var AstraSitesAjaxQueue = (function() {
506
customizer_data : AstraSitesAdmin.current_site['astra-site-customizer-data'],
507
},
508
beforeSend: function() {
509
- AstraSitesAdmin._log( astraSitesAdmin.log.importCustomizer );
510
- $('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importingCustomizer );
511
},
512
})
513
.fail(function( jqXHR ){
514
- AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
515
- AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
516
})
517
.done(function ( customizer_data ) {
518
@@ -520,12 +541,11 @@ var AstraSitesAjaxQueue = (function() {
520
521
// 1. Fail - Import Customizer Options.
522
if( false === customizer_data.success ) {
523
- AstraSitesAdmin._importFailMessage( customizer_data.data );
524
- AstraSitesAdmin._log( customizer_data.data );
525
} else {
526
527
// 1. Pass - Import Customizer Options.
528
- AstraSitesAdmin._log( astraSitesAdmin.log.importCustomizerSuccess );
529
530
$(document).trigger( 'astra-sites-import-customizer-settings-done' );
531
}
@@ -545,27 +565,55 @@ var AstraSitesAjaxQueue = (function() {
545
action : 'astra-sites-import-end',
546
},
547
beforeSend: function() {
548
- $('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importComplete );
549
}
550
})
551
.fail(function( jqXHR ){
552
- AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
553
- AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
554
})
555
.done(function ( data ) {
556
557
// 5. Fail - Import Complete.
558
if( false === data.success ) {
559
- AstraSitesAdmin._importFailMessage( data.data );
560
- AstraSitesAdmin._log( data.data );
561
} else {
562
563
$('body').removeClass('importing-site');
564
$('.previous-theme, .next-theme').removeClass('disabled');
565
566
// 5. Pass - Import Complete.
567
- AstraSitesAdmin._importSuccessMessage();
568
- AstraSitesAdmin._log( astraSitesAdmin.log.success + ' ' + astraSitesAdmin.siteURL );
569
}
570
});
571
},
@@ -584,25 +632,22 @@ var AstraSitesAjaxQueue = (function() {
584
widgets_data : AstraSitesAdmin.widgets_data,
585
},
586
beforeSend: function() {
587
- AstraSitesAdmin._log( astraSitesAdmin.log.importWidgets );
588
- $('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importingWidgets );
589
},
590
})
591
.fail(function( jqXHR ){
592
- AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
593
- AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
594
})
595
.done(function ( widgets_data ) {
596
597
// 4. Fail - Import Widgets.
598
if( false === widgets_data.success ) {
599
- AstraSitesAdmin._importFailMessage( widgets_data.data );
600
- AstraSitesAdmin._log( widgets_data.data );
601
602
} else {
603
604
// 4. Pass - Import Widgets.
605
- AstraSitesAdmin._log( astraSitesAdmin.log.importWidgetsSuccess );
606
$(document).trigger( 'astra-sites-import-widgets-done' );
607
}
608
});
@@ -626,27 +671,21 @@ var AstraSitesAjaxQueue = (function() {
626
options_data : AstraSitesAdmin.options_data,
627
},
628
beforeSend: function() {
629
- AstraSitesAdmin._log( astraSitesAdmin.log.importOptions );
630
- $('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importingOptions );
631
$('.astra-demo-import .percent').html('');
632
},
633
})
634
.fail(function( jqXHR ){
635
- AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
636
- AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
637
})
638
.done(function ( options_data ) {
639
640
// 3. Fail - Import Site Options.
641
if( false === options_data.success ) {
642
- AstraSitesAdmin._log( options_data );
643
- AstraSitesAdmin._importFailMessage( options_data.data );
644
- AstraSitesAdmin._log( options_data.data );
645
-
646
} else {
647
648
// 3. Pass - Import Site Options.
649
- AstraSitesAdmin._log( astraSitesAdmin.log.importOptionsSuccess );
650
$(document).trigger( 'astra-sites-import-options-done' );
651
}
652
});
@@ -670,58 +709,50 @@ var AstraSitesAjaxQueue = (function() {
670
wxr_url : AstraSitesAdmin.current_site['astra-site-wxr-path'],
671
},
672
beforeSend: function() {
673
- $('#astra-site-import-process-wrap').show();
674
- AstraSitesAdmin._log( astraSitesAdmin.log.importXMLPrepare );
675
- $('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importXMLPreparing );
676
},
677
})
678
.fail(function( jqXHR ){
679
- AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
680
- AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
681
})
682
.done(function ( xml_data ) {
683
684
-
685
// 2. Fail - Prepare XML Data.
686
if( false === xml_data.success ) {
687
- AstraSitesAdmin._log( xml_data );
688
var error_msg = xml_data.data.error || xml_data.data;
689
- AstraSitesAdmin._importFailMessage( error_msg );
690
- AstraSitesAdmin._log( error_msg );
691
692
} else {
693
694
// 2. Pass - Prepare XML Data.
695
- AstraSitesAdmin._log( astraSitesAdmin.log.importXMLPrepareSuccess );
696
697
// Import XML though Event Source.
698
AstraSSEImport.data = xml_data.data;
699
AstraSSEImport.render();
700
701
- AstraSitesAdmin._log( astraSitesAdmin.log.importXML );
702
- $('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importingXML );
703
704
var evtSource = new EventSource( AstraSSEImport.data.url );
705
evtSource.onmessage = function ( message ) {
706
var data = JSON.parse( message.data );
707
switch ( data.action ) {
708
case 'updateDelta':
709
AstraSSEImport.updateDelta( data.type, data.delta );
710
break;
711
712
case 'complete':
713
evtSource.close();
714
715
- // 2. Pass - Import XML though "Source Event".
716
- AstraSitesAdmin._log( astraSitesAdmin.log.importXMLSuccess );
717
- AstraSitesAdmin._log( '----- SSE - XML import Complete -----' );
718
719
- document.getElementById( 'astra-site-import-process' ).value = 100;
720
721
-
722
- $('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importingXML + ' (100%)' );
723
-
724
- $('#astra-site-import-process-wrap').hide();
725
726
$(document).trigger( 'astra-sites-import-xml-done' );
727
@@ -730,7 +761,13 @@ var AstraSitesAjaxQueue = (function() {
730
};
731
evtSource.addEventListener( 'log', function ( message ) {
732
var data = JSON.parse( message.data );
733
- AstraSitesAdmin._log( data.level + ' ' + data.message );
734
});
735
}
736
});
@@ -776,25 +813,20 @@ var AstraSitesAjaxQueue = (function() {
776
wpforms_url : AstraSitesAdmin.wpforms_url,
777
},
778
beforeSend: function() {
779
- AstraSitesAdmin._log( astraSitesAdmin.log.importWPForms );
780
- $('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importingWPForms );
781
},
782
})
783
.fail(function( jqXHR ){
784
- AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
785
- AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
786
})
787
.done(function ( forms ) {
788
789
// 1. Fail - Import WPForms Options.
790
if( false === forms.success ) {
791
- AstraSitesAdmin._importFailMessage( forms.data );
792
- AstraSitesAdmin._log( forms.data );
793
} else {
794
795
// 1. Pass - Import Customizer Options.
796
- AstraSitesAdmin._log( astraSitesAdmin.log.importWPFormsSuccess );
797
-
798
$(document).trigger( 'astra-sites-import-wpforms-done' );
799
}
800
});
@@ -817,25 +849,19 @@ var AstraSitesAjaxQueue = (function() {
817
customizer_data : AstraSitesAdmin.customizer_data,
818
},
819
beforeSend: function() {
820
- AstraSitesAdmin._log( astraSitesAdmin.log.importCustomizer );
821
- $('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importingCustomizer );
822
},
823
})
824
.fail(function( jqXHR ){
825
- AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
826
- AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
827
})
828
.done(function ( customizer_data ) {
829
830
// 1. Fail - Import Customizer Options.
831
if( false === customizer_data.success ) {
832
- AstraSitesAdmin._importFailMessage( customizer_data.data );
833
- AstraSitesAdmin._log( customizer_data.data );
834
} else {
835
836
// 1. Pass - Import Customizer Options.
837
- AstraSitesAdmin._log( astraSitesAdmin.log.importCustomizerSuccess );
838
-
839
$(document).trigger( 'astra-sites-import-customizer-settings-done' );
840
}
841
});
@@ -850,7 +876,7 @@ var AstraSitesAjaxQueue = (function() {
850
*
851
* @param {string} data Error message.
852
*/
853
- _importSuccessMessage: function() {
854
855
$('.astra-demo-import').removeClass('updating-message installing')
856
.removeAttr('data-import')
@@ -937,7 +963,6 @@ var AstraSitesAjaxQueue = (function() {
937
// Fail Notice.
938
$('.install-theme-info').append( output );
939
940
-
941
// !important to add trigger.
942
// Which reinitialize the dismiss error message events.
943
$(document).trigger('wp-updates-notice-added');
@@ -958,6 +983,8 @@ var AstraSitesAjaxQueue = (function() {
958
return;
959
}
960
961
if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked ) {
962
wp.updates.requestFilesystemCredentials( event );
963
@@ -972,13 +999,29 @@ var AstraSitesAjaxQueue = (function() {
972
} );
973
}
974
975
- AstraSitesAdmin._log( astraSitesAdmin.log.installingPlugin + ' ' + $button.data( 'slug' ) );
976
977
wp.updates.installPlugin( {
978
slug: $button.data( 'slug' )
979
} );
980
},
981
982
/**
983
* Install Success
984
*/
@@ -986,9 +1029,9 @@ var AstraSitesAjaxQueue = (function() {
986
987
event.preventDefault();
988
989
- AstraSitesAdmin._log( astraSitesAdmin.log.installed + ' ' + response.slug );
990
991
var $siteOptions = $( '.wp-full-overlay-header').find('.astra-site-options').val();
992
var $enabledExtensions = $( '.wp-full-overlay-header').find('.astra-enabled-extensions').val();
993
994
// Transform the 'Install' button into an 'Activate' button.
@@ -1001,6 +1044,8 @@ var AstraSitesAjaxQueue = (function() {
1001
// WordPress adds "Activate" button after waiting for 1000ms. So we will run our activation after that.
1002
setTimeout( function() {
1003
1004
$.ajax({
1005
url: astraSitesAdmin.ajaxurl,
1006
type: 'POST',
@@ -1014,6 +1059,7 @@ var AstraSitesAjaxQueue = (function() {
1014
.done(function (result) {
1015
1016
if( result.success ) {
1017
1018
var pluginsList = astraSitesAdmin.requiredPlugins.inactive;
1019
@@ -1037,14 +1083,14 @@ var AstraSitesAjaxQueue = (function() {
1037
1038
var $card = $( '.plugin-card-' + response.slug );
1039
1040
- AstraSitesAdmin._log( response.errorMessage + ' ' + response.slug );
1041
1042
$card
1043
.removeClass( 'button-primary' )
1044
.addClass( 'disabled' )
1045
.html( wp.updates.l10n.installFailedShort );
1046
1047
- AstraSitesAdmin._importFailMessage( response.errorMessage );
1048
},
1049
1050
/**
@@ -1055,7 +1101,7 @@ var AstraSitesAjaxQueue = (function() {
1055
1056
var $card = $( '.plugin-card-' + args.slug );
1057
1058
- AstraSitesAdmin._log( astraSitesAdmin.log.installingPlugin + ' ' + args.slug );
1059
1060
$card.addClass('updating-message');
1061
@@ -1071,12 +1117,13 @@ var AstraSitesAjaxQueue = (function() {
1071
var $button = jQuery( event.target ),
1072
$init = $button.data( 'init' ),
1073
$slug = $button.data( 'slug' );
1074
1075
if ( $button.hasClass( 'updating-message' ) || $button.hasClass( 'button-disabled' ) ) {
1076
return;
1077
}
1078
1079
- AstraSitesAdmin._log( astraSitesAdmin.log.activating + ' ' + $slug );
1080
1081
$button.addClass('updating-message button-primary')
1082
.html( astraSitesAdmin.strings.btnActivating );
@@ -1098,7 +1145,7 @@ var AstraSitesAjaxQueue = (function() {
1098
1099
if( result.success ) {
1100
1101
- AstraSitesAdmin._log( astraSitesAdmin.log.activated + ' ' + $slug );
1102
1103
var pluginsList = astraSitesAdmin.requiredPlugins.inactive;
1104
@@ -1174,7 +1221,7 @@ var AstraSitesAjaxQueue = (function() {
1174
*/
1175
_activateAllPlugins: function( activate_plugins ) {
1176
1177
- AstraSitesAdmin._log( astraSitesAdmin.log.bulkActivation );
1178
1179
$.each( activate_plugins, function(index, single_plugin) {
1180
@@ -1182,6 +1229,7 @@ var AstraSitesAjaxQueue = (function() {
1182
$siteOptions = $( '.wp-full-overlay-header').find('.astra-site-options').val(),
1183
$enabledExtensions = $( '.wp-full-overlay-header').find('.astra-enabled-extensions').val();
1184
1185
AstraSitesAjaxQueue.add({
1186
url: astraSitesAdmin.ajaxurl,
1187
type: 'POST',
@@ -1195,8 +1243,6 @@ var AstraSitesAjaxQueue = (function() {
1195
1196
if( result.success ) {
1197
1198
- AstraSitesAdmin._log( astraSitesAdmin.log.activate + ' ' + single_plugin.slug );
1199
-
1200
var pluginsList = astraSitesAdmin.requiredPlugins.inactive;
1201
1202
// Reset not installed plugins list.
@@ -1205,7 +1251,6 @@ var AstraSitesAjaxQueue = (function() {
1205
// Enable Demo Import Button
1206
AstraSitesAdmin._enable_demo_import_button();
1207
} else {
1208
- AstraSitesAdmin._log( astraSitesAdmin.log.activationError + ' - ' + single_plugin.slug );
1209
}
1210
}
1211
});
@@ -1218,10 +1263,12 @@ var AstraSitesAjaxQueue = (function() {
1218
*/
1219
_installAllPlugins: function( not_installed ) {
1220
1221
- AstraSitesAdmin._log( astraSitesAdmin.log.bulkInstall );
1222
1223
$.each( not_installed, function(index, single_plugin) {
1224
1225
var $card = $( '.plugin-card-' + single_plugin.slug );
1226
1227
// Add each plugin activate request in Ajax queue.
@@ -1248,6 +1295,10 @@ var AstraSitesAjaxQueue = (function() {
1248
_importDemo: function(event) {
1249
event.preventDefault();
1250
1251
var disabled = $(this).attr('data-import');
1252
1253
if ( typeof disabled !== 'undefined' && disabled === 'disabled' || $this.hasClass('disabled') ) {
@@ -1255,6 +1306,10 @@ var AstraSitesAjaxQueue = (function() {
1255
$('.astra-demo-import').addClass('updating-message installing')
1256
.text( wp.updates.l10n.installing );
1257
1258
/**
1259
* Process Bulk Plugin Install & Activate
1260
*/
@@ -1291,10 +1346,7 @@ var AstraSitesAjaxQueue = (function() {
1291
*/
1292
_importSite: function( apiURL ) {
1293
1294
- AstraSitesAdmin._log( astraSitesAdmin.log.api + ' : ' + apiURL );
1295
- AstraSitesAdmin._log( astraSitesAdmin.log.importing );
1296
-
1297
- $('.button-hero.astra-demo-import').text( astraSitesAdmin.log.gettingData );
1298
1299
// 1. Request Site Import
1300
$.ajax({
@@ -1307,15 +1359,13 @@ var AstraSitesAjaxQueue = (function() {
1307
},
1308
})
1309
.fail(function( jqXHR ){
1310
- AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
1311
- AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText );
1312
})
1313
.done(function ( demo_data ) {
1314
1315
// 1. Fail - Request Site Import
1316
if( false === demo_data.success ) {
1317
1318
- AstraSitesAdmin._importFailMessage( demo_data.data );
1319
1320
} else {
1321
@@ -1325,8 +1375,6 @@ var AstraSitesAjaxQueue = (function() {
1325
}
1326
1327
// 1. Pass - Request Site Import
1328
- AstraSitesAdmin._log( astraSitesAdmin.log.processingRequest );
1329
-
1330
AstraSitesAdmin.customizer_data = JSON.stringify( demo_data.data['astra-site-customizer-data'] ) || '';
1331
AstraSitesAdmin.wxr_url = encodeURI( demo_data.data['astra-site-wxr-path'] ) || '';
1332
AstraSitesAdmin.wpforms_url = encodeURI( demo_data.data['astra-site-wpforms-path'] ) || '';
@@ -1402,8 +1450,6 @@ var AstraSitesAjaxQueue = (function() {
1402
if( AstraSitesAPI._stored_data ) {
1403
var site_data = AstraSitesAdmin._get_site_details( site_id );
1404
1405
-
1406
-
1407
if( site_data ) {
1408
// Set current site details.
1409
AstraSitesAdmin.current_site = site_data;
@@ -1516,9 +1562,6 @@ var AstraSitesAjaxQueue = (function() {
1516
astraSiteOptions = anchor.find('.astra-site-options').val() || '';
1517
astraEnabledExtensions = anchor.find('.astra-enabled-extensions').val() || '';
1518
1519
- AstraSitesAdmin._log( astraSitesAdmin.log.preview + ' "' + demo_name + '" URL : ' + demoURL );
1520
-
1521
-
1522
var template = wp.template('astra-site-preview');
1523
1524
templateData = [{
@@ -1535,8 +1578,6 @@ var AstraSitesAjaxQueue = (function() {
1535
astra_enabled_extensions : astraEnabledExtensions,
1536
}];
1537
1538
- // return;
1539
-
1540
// delete any earlier fullscreen preview before we render new one.
1541
$('.theme-install-overlay').remove();
1542
@@ -1557,7 +1598,6 @@ var AstraSitesAjaxQueue = (function() {
1557
},
1558
})
1559
.done(function ( response ) {
1560
- AstraSitesAdmin._log( response );
1561
if( response.success ) {
1562
AstraSitesAdmin.site_imported_data = response.data;
1563
}
@@ -1619,8 +1659,6 @@ var AstraSitesAjaxQueue = (function() {
1619
// Remove loader.
1620
$('.required-plugins').removeClass('loading').html('');
1621
1622
- AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText, 'plugins' );
1623
- AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
1624
})
1625
.done(function ( response ) {
1626
@@ -1651,7 +1689,7 @@ var AstraSitesAjaxQueue = (function() {
1651
remaining_plugins += parseInt( response.data.notinstalled.length );
1652
1653
$( response.data.notinstalled ).each(function( index, plugin ) {
1654
- $('.required-plugins-list').append('<li class="plugin-card plugin-card-'+plugin.slug+'" data-slug="'+plugin.slug+'" data-init="'+plugin.init+'">'+plugin.name+'</li>');
1655
});
1656
}
1657
@@ -1666,7 +1704,7 @@ var AstraSitesAjaxQueue = (function() {
1666
remaining_plugins += parseInt( response.data.inactive.length );
1667
1668
$( response.data.inactive ).each(function( index, plugin ) {
1669
- $('.required-plugins-list').append('<li class="plugin-card plugin-card-'+plugin.slug+'" data-slug="'+plugin.slug+'" data-init="'+plugin.init+'">'+plugin.name+'</li>');
1670
});
1671
}
1672
@@ -1678,7 +1716,7 @@ var AstraSitesAjaxQueue = (function() {
1678
if ( typeof response.data.active !== 'undefined' ) {
1679
1680
$( response.data.active ).each(function( index, plugin ) {
1681
- $('.required-plugins-list').append('<li class="plugin-card plugin-card-'+plugin.slug+'" data-slug="'+plugin.slug+'" data-init="'+plugin.init+'">'+plugin.name+'</li>');
1682
});
1683
}
1684
107
var progress_bar = percent * 100;
108
109
if( progress_bar <= 100 ) {
110
+ var process_bars = document.getElementsByClassName( 'astra-site-import-process' );
111
+ for ( var i = 0; i < process_bars.length; i++ ) {
112
+ process_bars[i].value = progress_bar;
113
+ }
114
+ AstraSitesAdmin._log_title( 'Importing Content.. ' + progress );
115
}
116
}
117
},
156
wpforms_url : '',
157
options_data : '',
158
widgets_data : '',
159
+ import_start_time : '',
160
+ import_end_time : '',
161
162
init: function()
163
{
187
}
188
},
189
190
+ _log_title: function( data, append ) {
191
+
192
+ var markup = '<p>' + data + '</p>';
193
+ if (typeof data == 'object' ) {
194
+ var markup = '<p>' + JSON.stringify( data ) + '</p>';
195
+ }
196
+
197
+ if ( append ) {
198
+ $('.current-importing-status-title').append( markup );
199
+ } else {
200
+ $('.current-importing-status-title').html( markup );
201
+ }
202
+ },
203
+
204
/**
205
* Binds events for the Astra Sites.
206
*
211
_bind: function()
212
{
213
$( document ).on( 'click' , '.astra-sites-reset-data .checkbox', AstraSitesAdmin._toggle_reset_notice );
214
+ $( document ).on( 'click' , '.page-builders li', AstraSitesAdmin._toggle_reset_notice );
215
+ $( document ).on('click' , '#astra-sites-welcome-form .submit', AstraSitesAdmin._show_page_builder_notice);
216
+ $( document ).on('click' , '#astra-sites-welcome-form li', AstraSitesAdmin._show_next_button);
217
$( document ).on('change' , '#astra-sites-welcome-form-inline select', AstraSitesAdmin._change_page_builder);
218
$( document ).on('click' , '.astra-sites-tooltip-icon', AstraSitesAdmin._toggle_tooltip);
219
$( document ).on('click' , '.astra-sites-advanced-options-button', AstraSitesAdmin._toggle_advanced_options);
254
255
},
256
257
+ _show_next_button: function() {
258
+ $( this ).parents('.page-builders').find('img').removeClass('wp-ui-highlight');
259
+ $( this ).find('img').addClass('wp-ui-highlight');
260
+
261
+ $('#submit').parent().removeClass('submit');
262
+ $('#submit').removeClass('disabled');
263
+ $('.astra-sites-page-builder-notice').hide();
264
+ },
265
+
266
+ _show_page_builder_notice: function() {
267
+ $('.astra-sites-page-builder-notice').show();
268
+ },
269
+
270
_change_page_builder: function() {
271
$(this).closest('form').submit();
272
},
302
action : 'astra-sites-reset-customizer-data'
303
},
304
beforeSend: function() {
305
+ AstraSitesAdmin._log_title( 'Reseting Customizer Data..' );
306
},
307
})
308
.fail(function( jqXHR ){
309
+ AstraSitesAdmin._log_title( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText, true );
310
})
311
.done(function ( data ) {
312
+ AstraSitesAdmin._log_title( 'Complete Resetting Customizer Data..' );
313
$(document).trigger( 'astra-sites-reset-customizer-data-done' );
314
});
315
},
323
action : 'astra-sites-reset-site-options'
324
},
325
beforeSend: function() {
326
+ AstraSitesAdmin._log_title( 'Reseting Site Options..' );
327
},
328
})
329
.fail(function( jqXHR ){
330
+ AstraSitesAdmin._log_title( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText, true );
331
})
332
.done(function ( data ) {
333
+ AstraSitesAdmin._log_title( 'Complete Reseting Site Options..' );
334
$(document).trigger( 'astra-sites-reset-site-options-done' );
335
});
336
},
344
action : 'astra-sites-reset-widgets-data'
345
},
346
beforeSend: function() {
347
+ AstraSitesAdmin._log_title( 'Reseting Widgets..' );
348
},
349
})
350
.fail(function( jqXHR ){
351
+ AstraSitesAdmin._log_title( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText, true );
352
})
353
.done(function ( data ) {
354
+ AstraSitesAdmin._log_title( 'Complete Reseting Widgets..' );
355
$(document).trigger( 'astra-sites-reset-widgets-data-done' );
356
});
357
},
361
362
AstraSitesAdmin.reset_remaining_posts = AstraSitesAdmin.site_imported_data['reset_posts'].length;
363
364
$.each( AstraSitesAdmin.site_imported_data['reset_posts'], function(index, post_id) {
365
+
366
+ AstraSitesAdmin._log_title( 'Deleting Posts..' );
367
+
368
AstraSitesAjaxQueue.add({
369
url: astraSitesAdmin.ajaxurl,
370
type: 'POST',
377
if( AstraSitesAdmin.reset_processed_posts < AstraSitesAdmin.site_imported_data['reset_posts'].length ) {
378
AstraSitesAdmin.reset_processed_posts+=1;
379
}
380
+
381
+ AstraSitesAdmin._log_title( 'Deleting Post ' + AstraSitesAdmin.reset_processed_posts + ' of ' + AstraSitesAdmin.site_imported_data['reset_posts'].length + '<br/>' + result.data );
382
+
383
AstraSitesAdmin.reset_remaining_posts-=1;
384
if( 0 == AstraSitesAdmin.reset_remaining_posts ) {
385
$(document).trigger( 'astra-sites-delete-posts-done' );
398
399
_reset_wp_forms: function() {
400
401
if( AstraSitesAdmin.site_imported_data['reset_wp_forms'].length ) {
402
AstraSitesAdmin.reset_remaining_wp_forms = AstraSitesAdmin.site_imported_data['reset_wp_forms'].length;
403
404
$.each( AstraSitesAdmin.site_imported_data['reset_wp_forms'], function(index, post_id) {
405
+ AstraSitesAdmin._log_title( 'Deleting WP Forms..' );
406
AstraSitesAjaxQueue.add({
407
url: astraSitesAdmin.ajaxurl,
408
type: 'POST',
411
post_id : post_id,
412
},
413
success: function( result ){
414
+
415
if( AstraSitesAdmin.reset_processed_wp_forms < AstraSitesAdmin.site_imported_data['reset_wp_forms'].length ) {
416
AstraSitesAdmin.reset_processed_wp_forms+=1;
417
}
418
419
+ AstraSitesAdmin._log_title( 'Deleting Form ' + AstraSitesAdmin.reset_processed_wp_forms + ' of ' + AstraSitesAdmin.site_imported_data['reset_wp_forms'].length + '<br/>' + result.data );
420
+
421
AstraSitesAdmin.reset_remaining_wp_forms-=1;
422
if( 0 == AstraSitesAdmin.reset_remaining_wp_forms ) {
423
$(document).trigger( 'astra-sites-delete-wp-forms-done' );
435
436
_reset_terms: function() {
437
438
439
if( AstraSitesAdmin.site_imported_data['reset_terms'].length ) {
440
AstraSitesAdmin.reset_remaining_terms = AstraSitesAdmin.site_imported_data['reset_terms'].length;
441
442
$.each( AstraSitesAdmin.site_imported_data['reset_terms'], function(index, term_id) {
443
+ AstraSitesAdmin._log_title( 'Deleting Terms..' );
444
AstraSitesAjaxQueue.add({
445
url: astraSitesAdmin.ajaxurl,
446
type: 'POST',
452
if( AstraSitesAdmin.reset_processed_terms < AstraSitesAdmin.site_imported_data['reset_terms'].length ) {
453
AstraSitesAdmin.reset_processed_terms+=1;
454
}
455
+
456
+ AstraSitesAdmin._log_title( 'Deleting Term ' + AstraSitesAdmin.reset_processed_terms + ' of ' + AstraSitesAdmin.site_imported_data['reset_terms'].length + '<br/>' + result.data );
457
+
458
AstraSitesAdmin.reset_remaining_terms-=1;
459
if( 0 == AstraSitesAdmin.reset_remaining_terms ) {
460
$(document).trigger( 'astra-sites-delete-terms-done' );
461
}
496
action : 'astra-sites-backup-settings',
497
},
498
beforeSend: function() {
499
+ AstraSitesAdmin._log_title( 'Processing Customizer Settings Backup..' );
500
},
501
})
502
.fail(function( jqXHR ){
503
+ AstraSitesAdmin._log_title( jqXHR.status + ' ' + jqXHR.responseText, true );
504
})
505
.done(function ( data ) {
506
507
// 1. Pass - Import Customizer Options.
508
+ AstraSitesAdmin._log_title( 'Customizer Settings Backup Done..' );
509
510
// Custom trigger.
511
$(document).trigger( trigger_name );
529
customizer_data : AstraSitesAdmin.current_site['astra-site-customizer-data'],
530
},
531
beforeSend: function() {
532
+ AstraSitesAdmin._log_title( 'Importing Customizer Settings..' );
533
},
534
})
535
.fail(function( jqXHR ){
536
+ AstraSitesAdmin._log_title( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText, true );
537
})
538
.done(function ( customizer_data ) {
539
541
542
// 1. Fail - Import Customizer Options.
543
if( false === customizer_data.success ) {
544
+ AstraSitesAdmin._log_title( customizer_data.data );
545
} else {
546
547
// 1. Pass - Import Customizer Options.
548
+ AstraSitesAdmin._log_title( 'Imported Customizer Settings..' );
549
550
$(document).trigger( 'astra-sites-import-customizer-settings-done' );
551
}
565
action : 'astra-sites-import-end',
566
},
567
beforeSend: function() {
568
+ AstraSitesAdmin._log_title( 'Import Complete!' );
569
}
570
})
571
.fail(function( jqXHR ){
572
+ AstraSitesAdmin._log_title( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText, true );
573
})
574
.done(function ( data ) {
575
576
// 5. Fail - Import Complete.
577
if( false === data.success ) {
578
+ AstraSitesAdmin._log_title( data.data );
579
} else {
580
581
$('body').removeClass('importing-site');
582
$('.previous-theme, .next-theme').removeClass('disabled');
583
584
+ var date = new Date();
585
+
586
+ AstraSitesAdmin.import_end_time = new Date();
587
+ var diff = ( AstraSitesAdmin.import_end_time.getTime() - AstraSitesAdmin.import_start_time.getTime() );
588
+
589
+ var time = '';
590
+ var seconds = Math.floor( diff / 1000 );
591
+ var minutes = Math.floor( seconds / 60 );
592
+ var hours = Math.floor( minutes / 60 );
593
+
594
+ minutes = minutes - ( hours * 60 );
595
+ seconds = seconds - ( minutes * 60 );
596
+
597
+ if( hours ) {
598
+ time += hours + ' Hours ';
599
+ }
600
+ if( minutes ) {
601
+ time += minutes + ' Minutes ';
602
+ }
603
+ if( seconds ) {
604
+ time += seconds + ' Seconds';
605
+ }
606
+
607
+ var output = '<h2>Done 🎉</h2>';
608
+ output += '<p>Your starter site has been imported successfully in '+time+'! Now go ahead, customize the text, images, and design to make it yours!</p>';
609
+ output += '<p>You can now start making changes according to your requirements.</p>';
610
+ output += '<p><a class="button button-primary button-hero" href="'+astraSitesAdmin.siteURL+'" target="_blank">View Site <i class="dashicons dashicons-external"></i></a></p>';
611
+
612
+ $('.rotating,.current-importing-status-wrap,.notice-warning').remove();
613
+ $('.astra-sites-result-preview .inner').html(output);
614
+
615
// 5. Pass - Import Complete.
616
+ AstraSitesAdmin._importSuccessButton();
617
}
618
});
619
},
632
widgets_data : AstraSitesAdmin.widgets_data,
633
},
634
beforeSend: function() {
635
+ AstraSitesAdmin._log_title( 'Importing Widgets..' );
636
},
637
})
638
.fail(function( jqXHR ){
639
+ AstraSitesAdmin._log_title( jqXHR.status + ' ' + jqXHR.responseText, true );
640
})
641
.done(function ( widgets_data ) {
642
643
// 4. Fail - Import Widgets.
644
if( false === widgets_data.success ) {
645
+ AstraSitesAdmin._log_title( widgets_data.data );
646
647
} else {
648
649
// 4. Pass - Import Widgets.
650
+ AstraSitesAdmin._log_title( 'Imported Widgets!' );
651
$(document).trigger( 'astra-sites-import-widgets-done' );
652
}
653
});
671
options_data : AstraSitesAdmin.options_data,
672
},
673
beforeSend: function() {
674
+ AstraSitesAdmin._log_title( 'Importing Options..' );
675
$('.astra-demo-import .percent').html('');
676
},
677
})
678
.fail(function( jqXHR ){
679
+ AstraSitesAdmin._log_title( jqXHR.status + ' ' + jqXHR.responseText, true );
680
})
681
.done(function ( options_data ) {
682
683
// 3. Fail - Import Site Options.
684
if( false === options_data.success ) {
685
+ AstraSitesAdmin._log_title( options_data );
686
} else {
687
688
// 3. Pass - Import Site Options.
689
$(document).trigger( 'astra-sites-import-options-done' );
690
}
691
});
709
wxr_url : AstraSitesAdmin.current_site['astra-site-wxr-path'],
710
},
711
beforeSend: function() {
712
+ $('.astra-site-import-process-wrap').show();
713
+ AstraSitesAdmin._log_title( 'Importing Content..' );
714
},
715
})
716
.fail(function( jqXHR ){
717
+ AstraSitesAdmin._log_title( jqXHR.status + ' ' + jqXHR.responseText, true );
718
})
719
.done(function ( xml_data ) {
720
721
// 2. Fail - Prepare XML Data.
722
if( false === xml_data.success ) {
723
+ AstraSitesAdmin._log_title( xml_data );
724
var error_msg = xml_data.data.error || xml_data.data;
725
+ AstraSitesAdmin._log_title( error_msg );
726
727
} else {
728
729
// 2. Pass - Prepare XML Data.
730
731
// Import XML though Event Source.
732
AstraSSEImport.data = xml_data.data;
733
AstraSSEImport.render();
734
735
+ $('.current-importing-status-description').html('').show();
736
+
737
+ $('.astra-sites-result-preview .inner').append('<div class="astra-site-import-process-wrap"><progress class="astra-site-import-process" max="100" value="0"></progress></div>');
738
739
var evtSource = new EventSource( AstraSSEImport.data.url );
740
evtSource.onmessage = function ( message ) {
741
var data = JSON.parse( message.data );
742
switch ( data.action ) {
743
case 'updateDelta':
744
+
745
AstraSSEImport.updateDelta( data.type, data.delta );
746
break;
747
748
case 'complete':
749
evtSource.close();
750
751
+ $('.current-importing-status-description').hide();
752
753
+ document.getElementsByClassName("astra-site-import-process").value = '100';
754
755
+ $('.astra-site-import-process-wrap').hide();
756
757
$(document).trigger( 'astra-sites-import-xml-done' );
758
761
};
762
evtSource.addEventListener( 'log', function ( message ) {
763
var data = JSON.parse( message.data );
764
+ var message = data.message || '';
765
+ if( message ) {
766
+ message = message.replace(/"/g, function(letter) {
767
+ return '';
768
+ });
769
+ $('.current-importing-status-description').html( message );
770
+ }
771
});
772
}
773
});
813
wpforms_url : AstraSitesAdmin.wpforms_url,
814
},
815
beforeSend: function() {
816
+ AstraSitesAdmin._log_title( 'Importing WP Forms..' );
817
},
818
})
819
.fail(function( jqXHR ){
820
+ AstraSitesAdmin._log_title( jqXHR.status + ' ' + jqXHR.responseText, true );
821
})
822
.done(function ( forms ) {
823
824
// 1. Fail - Import WPForms Options.
825
if( false === forms.success ) {
826
+ AstraSitesAdmin._log_title( forms.data );
827
} else {
828
829
// 1. Pass - Import Customizer Options.
830
$(document).trigger( 'astra-sites-import-wpforms-done' );
831
}
832
});
849
customizer_data : AstraSitesAdmin.customizer_data,
850
},
851
beforeSend: function() {
852
},
853
})
854
.fail(function( jqXHR ){
855
+ AstraSitesAdmin._log_title( jqXHR.status + ' ' + jqXHR.responseText, true );
856
})
857
.done(function ( customizer_data ) {
858
859
// 1. Fail - Import Customizer Options.
860
if( false === customizer_data.success ) {
861
+ AstraSitesAdmin._log_title( customizer_data.data );
862
} else {
863
864
// 1. Pass - Import Customizer Options.
865
$(document).trigger( 'astra-sites-import-customizer-settings-done' );
866
}
867
});
876
*
877
* @param {string} data Error message.
878
*/
879
+ _importSuccessButton: function() {
880
881
$('.astra-demo-import').removeClass('updating-message installing')
882
.removeAttr('data-import')
963
// Fail Notice.
964
$('.install-theme-info').append( output );
965
966
// !important to add trigger.
967
// Which reinitialize the dismiss error message events.
968
$(document).trigger('wp-updates-notice-added');
983
return;
984
}
985
986
+ AstraSitesAdmin._log_title( 'Installing Plugin..' );
987
+
988
if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked ) {
989
wp.updates.requestFilesystemCredentials( event );
990
999
} );
1000
}
1001
1002
+ AstraSitesAdmin._log_title( 'Installing ' + AstraSitesAdmin.ucwords( $button.data( 'name' ) ) );
1003
1004
wp.updates.installPlugin( {
1005
slug: $button.data( 'slug' )
1006
} );
1007
},
1008
1009
+ ucwords: function( str ) {
1010
+ if( ! str ) {
1011
+ return '';
1012
+ }
1013
+
1014
+ str = str.toLowerCase().replace(/\b[a-z]/g, function(letter) {
1015
+ return letter.toUpperCase();
1016
+ });
1017
+
1018
+ str = str.replace(/-/g, function(letter) {
1019
+ return ' ';
1020
+ });
1021
+
1022
+ return str;
1023
+ },
1024
+
1025
/**
1026
* Install Success
1027
*/
1029
1030
event.preventDefault();
1031
1032
1033
var $siteOptions = $( '.wp-full-overlay-header').find('.astra-site-options').val();
1034
+
1035
var $enabledExtensions = $( '.wp-full-overlay-header').find('.astra-enabled-extensions').val();
1036
1037
// Transform the 'Install' button into an 'Activate' button.
1044
// WordPress adds "Activate" button after waiting for 1000ms. So we will run our activation after that.
1045
setTimeout( function() {
1046
1047
+ AstraSitesAdmin._log_title( 'Activating Plugin..' );
1048
+
1049
$.ajax({
1050
url: astraSitesAdmin.ajaxurl,
1051
type: 'POST',
1059
.done(function (result) {
1060
1061
if( result.success ) {
1062
+ AstraSitesAdmin._log_title( 'Activating Plugin ' + AstraSitesAdmin.ucwords(response.name) );
1063
1064
var pluginsList = astraSitesAdmin.requiredPlugins.inactive;
1065
1083
1084
var $card = $( '.plugin-card-' + response.slug );
1085
1086
+ AstraSitesAdmin._log_title( response.errorMessage + ' ' + AstraSitesAdmin.ucwords(response.name) );
1087
+
1088
1089
$card
1090
.removeClass( 'button-primary' )
1091
.addClass( 'disabled' )
1092
.html( wp.updates.l10n.installFailedShort );
1093
1094
},
1095
1096
/**
1101
1102
var $card = $( '.plugin-card-' + args.slug );
1103
1104
+ AstraSitesAdmin._log_title( 'Installing ' + AstraSitesAdmin.ucwords(args.name ));
1105
1106
$card.addClass('updating-message');
1107
1117
var $button = jQuery( event.target ),
1118
$init = $button.data( 'init' ),
1119
$slug = $button.data( 'slug' );
1120
+ $name = $button.data( 'name' );
1121
1122
if ( $button.hasClass( 'updating-message' ) || $button.hasClass( 'button-disabled' ) ) {
1123
return;
1124
}
1125
1126
+ AstraSitesAdmin._log_title( 'Activating plugin ' + AstraSitesAdmin.ucwords( $name ) );
1127
1128
$button.addClass('updating-message button-primary')
1129
.html( astraSitesAdmin.strings.btnActivating );
1145
1146
if( result.success ) {
1147
1148
+ AstraSitesAdmin._log_title( 'Activated ' + AstraSitesAdmin.ucwords($name) );
1149
1150
var pluginsList = astraSitesAdmin.requiredPlugins.inactive;
1151
1221
*/
1222
_activateAllPlugins: function( activate_plugins ) {
1223
1224
+ AstraSitesAdmin._log_title( 'Activating Plugins..' );
1225
1226
$.each( activate_plugins, function(index, single_plugin) {
1227
1229
$siteOptions = $( '.wp-full-overlay-header').find('.astra-site-options').val(),
1230
$enabledExtensions = $( '.wp-full-overlay-header').find('.astra-enabled-extensions').val();
1231
1232
+
1233
AstraSitesAjaxQueue.add({
1234
url: astraSitesAdmin.ajaxurl,
1235
type: 'POST',
1243
1244
if( result.success ) {
1245
1246
var pluginsList = astraSitesAdmin.requiredPlugins.inactive;
1247
1248
// Reset not installed plugins list.
1251
// Enable Demo Import Button
1252
AstraSitesAdmin._enable_demo_import_button();
1253
} else {
1254
}
1255
}
1256
});
1263
*/
1264
_installAllPlugins: function( not_installed ) {
1265
1266
+ AstraSitesAdmin._log_title( 'Installing Plugins..' );
1267
1268
$.each( not_installed, function(index, single_plugin) {
1269
1270
+ AstraSitesAdmin._log_title( 'Installing ' + AstraSitesAdmin.ucwords( single_plugin.name ));
1271
+
1272
var $card = $( '.plugin-card-' + single_plugin.slug );
1273
1274
// Add each plugin activate request in Ajax queue.
1295
_importDemo: function(event) {
1296
event.preventDefault();
1297
1298
+ var date = new Date();
1299
+
1300
+ AstraSitesAdmin.import_start_time = new Date();
1301
+
1302
var disabled = $(this).attr('data-import');
1303
1304
if ( typeof disabled !== 'undefined' && disabled === 'disabled' || $this.hasClass('disabled') ) {
1306
$('.astra-demo-import').addClass('updating-message installing')
1307
.text( wp.updates.l10n.installing );
1308
1309
+ $('.astra-sites-result-preview').show();
1310
+ var output = '<div class="current-importing-status-title"></div><div class="current-importing-status-description"></div>';
1311
+ $('.current-importing-status').html( output );
1312
+
1313
/**
1314
* Process Bulk Plugin Install & Activate
1315
*/
1346
*/
1347
_importSite: function( apiURL ) {
1348
1349
+ AstraSitesAdmin._log_title( 'Started Importing..' );
1350
1351
// 1. Request Site Import
1352
$.ajax({
1359
},
1360
})
1361
.fail(function( jqXHR ){
1362
+ AstraSitesAdmin._log_title( jqXHR.status + ' ' + jqXHR.responseText + ' ' + jqXHR.statusText, true );
1363
})
1364
.done(function ( demo_data ) {
1365
1366
// 1. Fail - Request Site Import
1367
if( false === demo_data.success ) {
1368
1369
1370
} else {
1371
1375
}
1376
1377
// 1. Pass - Request Site Import
1378
AstraSitesAdmin.customizer_data = JSON.stringify( demo_data.data['astra-site-customizer-data'] ) || '';
1379
AstraSitesAdmin.wxr_url = encodeURI( demo_data.data['astra-site-wxr-path'] ) || '';
1380
AstraSitesAdmin.wpforms_url = encodeURI( demo_data.data['astra-site-wpforms-path'] ) || '';
1450
if( AstraSitesAPI._stored_data ) {
1451
var site_data = AstraSitesAdmin._get_site_details( site_id );
1452
1453
if( site_data ) {
1454
// Set current site details.
1455
AstraSitesAdmin.current_site = site_data;
1562
astraSiteOptions = anchor.find('.astra-site-options').val() || '';
1563
astraEnabledExtensions = anchor.find('.astra-enabled-extensions').val() || '';
1564
1565
var template = wp.template('astra-site-preview');
1566
1567
templateData = [{
1578
astra_enabled_extensions : astraEnabledExtensions,
1579
}];
1580
1581
// delete any earlier fullscreen preview before we render new one.
1582
$('.theme-install-overlay').remove();
1583
1598
},
1599
})
1600
.done(function ( response ) {
1601
if( response.success ) {
1602
AstraSitesAdmin.site_imported_data = response.data;
1603
}
1659
// Remove loader.
1660
$('.required-plugins').removeClass('loading').html('');
1661
1662
})
1663
.done(function ( response ) {
1664
1689
remaining_plugins += parseInt( response.data.notinstalled.length );
1690
1691
$( response.data.notinstalled ).each(function( index, plugin ) {
1692
+ $('.required-plugins-list').append('<li class="plugin-card plugin-card-'+plugin.slug+'" data-slug="'+plugin.slug+'" data-init="'+plugin.init+'" data-name="'+plugin.name+'">'+plugin.name+'</li>');
1693
});
1694
}
1695
1704
remaining_plugins += parseInt( response.data.inactive.length );
1705
1706
$( response.data.inactive ).each(function( index, plugin ) {
1707
+ $('.required-plugins-list').append('<li class="plugin-card plugin-card-'+plugin.slug+'" data-slug="'+plugin.slug+'" data-init="'+plugin.init+'" data-name="'+plugin.name+'">'+plugin.name+'</li>');
1708
});
1709
}
1710
1716
if ( typeof response.data.active !== 'undefined' ) {
1717
1718
$( response.data.active ).each(function( index, plugin ) {
1719
+ $('.required-plugins-list').append('<li class="plugin-card plugin-card-'+plugin.slug+'" data-slug="'+plugin.slug+'" data-init="'+plugin.init+'" data-name="'+plugin.name+'">'+plugin.name+'</li>');
1720
});
1721
}
1722
inc/assets/js/astra-sites-api.js CHANGED
@@ -12,54 +12,50 @@
12
/**
13
* API Request
14
*/
15
- _api_request: function( args ) {
16
17
- // Set API Request Data.
18
- var data = {
19
- url: AstraSitesAPI._api_url + args.slug,
20
};
21
22
if( astraRenderGrid.headers ) {
23
- data.headers = astraRenderGrid.headers;
24
}
25
26
- $.ajax( data )
27
- .done(function( items, status, XHR ) {
28
-
29
- if( 'success' === status && XHR.getResponseHeader('x-wp-total') ) {
30
-
31
- if( args.id ) {
32
- AstraSitesAPI._stored_data[ args.id ] = $.merge( AstraSitesAPI._stored_data[ args.id ], items );
33
- }
34
-
35
- var data = {
36
- args : args,
37
items : items,
38
- items_count : XHR.getResponseHeader('x-wp-total') || 0,
39
- };
40
-
41
- if( 'undefined' !== args.trigger && '' !== args.trigger ) {
42
- $(document).trigger( args.trigger, [data] );
43
- }
44
-
45
} else {
46
$(document).trigger( 'astra-sites-api-request-error' );
47
}
48
-
49
})
50
- .fail(function( jqXHR, textStatus ) {
51
52
- $(document).trigger( 'astra-sites-api-request-fail', [jqXHR, textStatus, args] );
53
54
- })
55
- .always(function() {
56
57
- $(document).trigger( 'astra-sites-api-request-always' );
58
59
- });
60
61
},
62
63
};
64
65
- })(jQuery);
12
/**
13
* API Request
14
*/
15
+ _api_request: function( args, callback ) {
16
17
+ var params = {
18
+ method: 'GET',
19
+ cache: 'default',
20
};
21
22
if( astraRenderGrid.headers ) {
23
+ params['headers'] = astraRenderGrid.headers;
24
}
25
26
+ fetch( AstraSitesAPI._api_url + args.slug, params).then(response => {
27
+ if ( response.status === 200 ) {
28
+ return response.json().then(items => ({
29
items : items,
30
+ items_count : response.headers.get( 'x-wp-total' ),
31
+ item_pages : response.headers.get( 'x-wp-totalpages' ),
32
+ }))
33
} else {
34
$(document).trigger( 'astra-sites-api-request-error' );
35
+ return response.json();
36
}
37
})
38
+ .then(data => {
39
+ if( 'object' === typeof data ) {
40
+ data['args'] = args;
41
+ if( data.args.id ) {
42
+ AstraSitesAPI._stored_data[ args.id ] = $.merge( AstraSitesAPI._stored_data[ data.args.id ], data.items );
43
+ }
44
45
+ if( 'undefined' !== typeof args.trigger && '' !== args.trigger ) {
46
+ $(document).trigger( args.trigger, [data] );
47
+ }
48
49
+ if( callback && typeof callback == "function"){
50
+ callback( data );
51
+ }
52
+ }
53
54
55
+ });
56
57
},
58
59
};
60
61
+ })(jQuery);
inc/assets/js/astra-sites-notices.js DELETED
@@ -1,21 +0,0 @@
1
- jQuery(document).ready(function ($) {
2
-
3
- jQuery( '.astra-notice.is-dismissible .notice-dismiss' ).on( 'click', function() {
4
- var $id = jQuery( this ).attr( 'id' ) || '';
5
- var $time = jQuery( this ).attr( 'dismissible-time' ) || '';
6
- var $meta = jQuery( this ).attr( 'dismissible-meta' ) || '';
7
-
8
- jQuery.ajax({
9
- url: ajaxurl,
10
- type: 'POST',
11
- data: {
12
- action : 'astra-notices',
13
- id : $id,
14
- meta : $meta,
15
- time : $time,
16
- },
17
- });
18
-
19
- });
20
-
21
- });
inc/assets/js/fetch.umd.js ADDED
@@ -0,0 +1,531 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
+ (factory((global.WHATWGFetch = {})));
5
+ }(this, (function (exports) { 'use strict';
6
+
7
+ var support = {
8
+ searchParams: 'URLSearchParams' in self,
9
+ iterable: 'Symbol' in self && 'iterator' in Symbol,
10
+ blob:
11
+ 'FileReader' in self &&
12
+ 'Blob' in self &&
13
+ (function() {
14
+ try {
15
+ new Blob();
16
+ return true
17
+ } catch (e) {
18
+ return false
19
+ }
20
+ })(),
21
+ formData: 'FormData' in self,
22
+ arrayBuffer: 'ArrayBuffer' in self
23
+ };
24
+
25
+ function isDataView(obj) {
26
+ return obj && DataView.prototype.isPrototypeOf(obj)
27
+ }
28
+
29
+ if (support.arrayBuffer) {
30
+ var viewClasses = [
31
+ '[object Int8Array]',
32
+ '[object Uint8Array]',
33
+ '[object Uint8ClampedArray]',
34
+ '[object Int16Array]',
35
+ '[object Uint16Array]',
36
+ '[object Int32Array]',
37
+ '[object Uint32Array]',
38
+ '[object Float32Array]',
39
+ '[object Float64Array]'
40
+ ];
41
+
42
+ var isArrayBufferView =
43
+ ArrayBuffer.isView ||
44
+ function(obj) {
45
+ return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
46
+ };
47
+ }
48
+
49
+ function normalizeName(name) {
50
+ if (typeof name !== 'string') {
51
+ name = String(name);
52
+ }
53
+ if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) {
54
+ throw new TypeError('Invalid character in header field name')
55
+ }
56
+ return name.toLowerCase()
57
+ }
58
+
59
+ function normalizeValue(value) {
60
+ if (typeof value !== 'string') {
61
+ value = String(value);
62
+ }
63
+ return value
64
+ }
65
+
66
+ // Build a destructive iterator for the value list
67
+ function iteratorFor(items) {
68
+ var iterator = {
69
+ next: function() {
70
+ var value = items.shift();
71
+ return {done: value === undefined, value: value}
72
+ }
73
+ };
74
+
75
+ if (support.iterable) {
76
+ iterator[Symbol.iterator] = function() {
77
+ return iterator
78
+ };
79
+ }
80
+
81
+ return iterator
82
+ }
83
+
84
+ function Headers(headers) {
85
+ this.map = {};
86
+
87
+ if (headers instanceof Headers) {
88
+ headers.forEach(function(value, name) {
89
+ this.append(name, value);
90
+ }, this);
91
+ } else if (Array.isArray(headers)) {
92
+ headers.forEach(function(header) {
93
+ this.append(header[0], header[1]);
94
+ }, this);
95
+ } else if (headers) {
96
+ Object.getOwnPropertyNames(headers).forEach(function(name) {
97
+ this.append(name, headers[name]);
98
+ }, this);
99
+ }
100
+ }
101
+
102
+ Headers.prototype.append = function(name, value) {
103
+ name = normalizeName(name);
104
+ value = normalizeValue(value);
105
+ var oldValue = this.map[name];
106
+ this.map[name] = oldValue ? oldValue + ', ' + value : value;
107
+ };
108
+
109
+ Headers.prototype['delete'] = function(name) {
110
+ delete this.map[normalizeName(name)];
111
+ };
112
+
113
+ Headers.prototype.get = function(name) {
114
+ name = normalizeName(name);
115
+ return this.has(name) ? this.map[name] : null
116
+ };
117
+
118
+ Headers.prototype.has = function(name) {
119
+ return this.map.hasOwnProperty(normalizeName(name))
120
+ };
121
+
122
+ Headers.prototype.set = function(name, value) {
123
+ this.map[normalizeName(name)] = normalizeValue(value);
124
+ };
125
+
126
+ Headers.prototype.forEach = function(callback, thisArg) {
127
+ for (var name in this.map) {
128
+ if (this.map.hasOwnProperty(name)) {
129
+ callback.call(thisArg, this.map[name], name, this);
130
+ }
131
+ }
132
+ };
133
+
134
+ Headers.prototype.keys = function() {
135
+ var items = [];
136
+ this.forEach(function(value, name) {
137
+ items.push(name);
138
+ });
139
+ return iteratorFor(items)
140
+ };
141
+
142
+ Headers.prototype.values = function() {
143
+ var items = [];
144
+ this.forEach(function(value) {
145
+ items.push(value);
146
+ });
147
+ return iteratorFor(items)
148
+ };
149
+
150
+ Headers.prototype.entries = function() {
151
+ var items = [];
152
+ this.forEach(function(value, name) {
153
+ items.push([name, value]);
154
+ });
155
+ return iteratorFor(items)
156
+ };
157
+
158
+ if (support.iterable) {
159
+ Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
160
+ }
161
+
162
+ function consumed(body) {
163
+ if (body.bodyUsed) {
164
+ return Promise.reject(new TypeError('Already read'))
165
+ }
166
+ body.bodyUsed = true;
167
+ }
168
+
169
+ function fileReaderReady(reader) {
170
+ return new Promise(function(resolve, reject) {
171
+ reader.onload = function() {
172
+ resolve(reader.result);
173
+ };
174
+ reader.onerror = function() {
175
+ reject(reader.error);
176
+ };
177
+ })
178
+ }
179
+
180
+ function readBlobAsArrayBuffer(blob) {
181
+ var reader = new FileReader();
182
+ var promise = fileReaderReady(reader);
183
+ reader.readAsArrayBuffer(blob);
184
+ return promise
185
+ }
186
+
187
+ function readBlobAsText(blob) {
188
+ var reader = new FileReader();
189
+ var promise = fileReaderReady(reader);
190
+ reader.readAsText(blob);
191
+ return promise
192
+ }
193
+
194
+ function readArrayBufferAsText(buf) {
195
+ var view = new Uint8Array(buf);
196
+ var chars = new Array(view.length);
197
+
198
+ for (var i = 0; i < view.length; i++) {
199
+ chars[i] = String.fromCharCode(view[i]);
200
+ }
201
+ return chars.join('')
202
+ }
203
+
204
+ function bufferClone(buf) {
205
+ if (buf.slice) {
206
+ return buf.slice(0)
207
+ } else {
208
+ var view = new Uint8Array(buf.byteLength);
209
+ view.set(new Uint8Array(buf));
210
+ return view.buffer
211
+ }
212
+ }
213
+
214
+ function Body() {
215
+ this.bodyUsed = false;
216
+
217
+ this._initBody = function(body) {
218
+ this._bodyInit = body;
219
+ if (!body) {
220
+ this._bodyText = '';
221
+ } else if (typeof body === 'string') {
222
+ this._bodyText = body;
223
+ } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
224
+ this._bodyBlob = body;
225
+ } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
226
+ this._bodyFormData = body;
227
+ } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
228
+ this._bodyText = body.toString();
229
+ } else if (support.arrayBuffer && support.blob && isDataView(body)) {
230
+ this._bodyArrayBuffer = bufferClone(body.buffer);
231
+ // IE 10-11 can't handle a DataView body.
232
+ this._bodyInit = new Blob([this._bodyArrayBuffer]);
233
+ } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
234
+ this._bodyArrayBuffer = bufferClone(body);
235
+ } else {
236
+ this._bodyText = body = Object.prototype.toString.call(body);
237
+ }
238
+
239
+ if (!this.headers.get('content-type')) {
240
+ if (typeof body === 'string') {
241
+ this.headers.set('content-type', 'text/plain;charset=UTF-8');
242
+ } else if (this._bodyBlob && this._bodyBlob.type) {
243
+ this.headers.set('content-type', this._bodyBlob.type);
244
+ } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
245
+ this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
246
+ }
247
+ }
248
+ };
249
+
250
+ if (support.blob) {
251
+ this.blob = function() {
252
+ var rejected = consumed(this);
253
+ if (rejected) {
254
+ return rejected
255
+ }
256
+
257
+ if (this._bodyBlob) {
258
+ return Promise.resolve(this._bodyBlob)
259
+ } else if (this._bodyArrayBuffer) {
260
+ return Promise.resolve(new Blob([this._bodyArrayBuffer]))
261
+ } else if (this._bodyFormData) {
262
+ throw new Error('could not read FormData body as blob')
263
+ } else {
264
+ return Promise.resolve(new Blob([this._bodyText]))
265
+ }
266
+ };
267
+
268
+ this.arrayBuffer = function() {
269
+ if (this._bodyArrayBuffer) {
270
+ return consumed(this) || Promise.resolve(this._bodyArrayBuffer)
271
+ } else {
272
+ return this.blob().then(readBlobAsArrayBuffer)
273
+ }
274
+ };
275
+ }
276
+
277
+ this.text = function() {
278
+ var rejected = consumed(this);
279
+ if (rejected) {
280
+ return rejected
281
+ }
282
+
283
+ if (this._bodyBlob) {
284
+ return readBlobAsText(this._bodyBlob)
285
+ } else if (this._bodyArrayBuffer) {
286
+ return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
287
+ } else if (this._bodyFormData) {
288
+ throw new Error('could not read FormData body as text')
289
+ } else {
290
+ return Promise.resolve(this._bodyText)
291
+ }
292
+ };
293
+
294
+ if (support.formData) {
295
+ this.formData = function() {
296
+ return this.text().then(decode)
297
+ };
298
+ }
299
+
300
+ this.json = function() {
301
+ return this.text().then(JSON.parse)
302
+ };
303
+
304
+ return this
305
+ }
306
+
307
+ // HTTP methods whose capitalization should be normalized
308
+ var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];
309
+
310
+ function normalizeMethod(method) {
311
+ var upcased = method.toUpperCase();
312
+ return methods.indexOf(upcased) > -1 ? upcased : method
313
+ }
314
+
315
+ function Request(input, options) {
316
+ options = options || {};
317
+ var body = options.body;
318
+
319
+ if (input instanceof Request) {
320
+ if (input.bodyUsed) {
321
+ throw new TypeError('Already read')
322
+ }
323
+ this.url = input.url;
324
+ this.credentials = input.credentials;
325
+ if (!options.headers) {
326
+ this.headers = new Headers(input.headers);
327
+ }
328
+ this.method = input.method;
329
+ this.mode = input.mode;
330
+ this.signal = input.signal;
331
+ if (!body && input._bodyInit != null) {
332
+ body = input._bodyInit;
333
+ input.bodyUsed = true;
334
+ }
335
+ } else {
336
+ this.url = String(input);
337
+ }
338
+
339
+ this.credentials = options.credentials || this.credentials || 'same-origin';
340
+ if (options.headers || !this.headers) {
341
+ this.headers = new Headers(options.headers);
342
+ }
343
+ this.method = normalizeMethod(options.method || this.method || 'GET');
344
+ this.mode = options.mode || this.mode || null;
345
+ this.signal = options.signal || this.signal;
346
+ this.referrer = null;
347
+
348
+ if ((this.method === 'GET' || this.method === 'HEAD') && body) {
349
+ throw new TypeError('Body not allowed for GET or HEAD requests')
350
+ }
351
+ this._initBody(body);
352
+ }
353
+
354
+ Request.prototype.clone = function() {
355
+ return new Request(this, {body: this._bodyInit})
356
+ };
357
+
358
+ function decode(body) {
359
+ var form = new FormData();
360
+ body
361
+ .trim()
362
+ .split('&')
363
+ .forEach(function(bytes) {
364
+ if (bytes) {
365
+ var split = bytes.split('=');
366
+ var name = split.shift().replace(/\+/g, ' ');
367
+ var value = split.join('=').replace(/\+/g, ' ');
368
+ form.append(decodeURIComponent(name), decodeURIComponent(value));
369
+ }
370
+ });
371
+ return form
372
+ }
373
+
374
+ function parseHeaders(rawHeaders) {
375
+ var headers = new Headers();
376
+ // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
377
+ // https://tools.ietf.org/html/rfc7230#section-3.2
378
+ var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
379
+ preProcessedHeaders.split(/\r?\n/).forEach(function(line) {
380
+ var parts = line.split(':');
381
+ var key = parts.shift().trim();
382
+ if (key) {
383
+ var value = parts.join(':').trim();
384
+ headers.append(key, value);
385
+ }
386
+ });
387
+ return headers
388
+ }
389
+
390
+ Body.call(Request.prototype);
391
+
392
+ function Response(bodyInit, options) {
393
+ if (!options) {
394
+ options = {};
395
+ }
396
+
397
+ this.type = 'default';
398
+ this.status = options.status === undefined ? 200 : options.status;
399
+ this.ok = this.status >= 200 && this.status < 300;
400
+ this.statusText = 'statusText' in options ? options.statusText : 'OK';
401
+ this.headers = new Headers(options.headers);
402
+ this.url = options.url || '';
403
+ this._initBody(bodyInit);
404
+ }
405
+
406
+ Body.call(Response.prototype);
407
+
408
+ Response.prototype.clone = function() {
409
+ return new Response(this._bodyInit, {
410
+ status: this.status,
411
+ statusText: this.statusText,
412
+ headers: new Headers(this.headers),
413
+ url: this.url
414
+ })
415
+ };
416
+
417
+ Response.error = function() {
418
+ var response = new Response(null, {status: 0, statusText: ''});
419
+ response.type = 'error';
420
+ return response
421
+ };
422
+
423
+ var redirectStatuses = [301, 302, 303, 307, 308];
424
+
425
+ Response.redirect = function(url, status) {
426
+ if (redirectStatuses.indexOf(status) === -1) {
427
+ throw new RangeError('Invalid status code')
428
+ }
429
+
430
+ return new Response(null, {status: status, headers: {location: url}})
431
+ };
432
+
433
+ exports.DOMException = self.DOMException;
434
+ try {
435
+ new exports.DOMException();
436
+ } catch (err) {
437
+ exports.DOMException = function(message, name) {
438
+ this.message = message;
439
+ this.name = name;
440
+ var error = Error(message);
441
+ this.stack = error.stack;
442
+ };
443
+ exports.DOMException.prototype = Object.create(Error.prototype);
444
+ exports.DOMException.prototype.constructor = exports.DOMException;
445
+ }
446
+
447
+ function fetch(input, init) {
448
+ return new Promise(function(resolve, reject) {
449
+ var request = new Request(input, init);
450
+
451
+ if (request.signal && request.signal.aborted) {
452
+ return reject(new exports.DOMException('Aborted', 'AbortError'))
453
+ }
454
+
455
+ var xhr = new XMLHttpRequest();
456
+
457
+ function abortXhr() {
458
+ xhr.abort();
459
+ }
460
+
461
+ xhr.onload = function() {
462
+ var options = {
463
+ status: xhr.status,
464
+ statusText: xhr.statusText,
465
+ headers: parseHeaders(xhr.getAllResponseHeaders() || '')
466
+ };
467
+ options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
468
+ var body = 'response' in xhr ? xhr.response : xhr.responseText;
469
+ resolve(new Response(body, options));
470
+ };
471
+
472
+ xhr.onerror = function() {
473
+ reject(new TypeError('Network request failed'));
474
+ };
475
+
476
+ xhr.ontimeout = function() {
477
+ reject(new TypeError('Network request failed'));
478
+ };
479
+
480
+ xhr.onabort = function() {
481
+ reject(new exports.DOMException('Aborted', 'AbortError'));
482
+ };
483
+
484
+ xhr.open(request.method, request.url, true);
485
+
486
+ if (request.credentials === 'include') {
487
+ xhr.withCredentials = true;
488
+ } else if (request.credentials === 'omit') {
489
+ xhr.withCredentials = false;
490
+ }
491
+
492
+ if ('responseType' in xhr && support.blob) {
493
+ xhr.responseType = 'blob';
494
+ }
495
+
496
+ request.headers.forEach(function(value, name) {
497
+ xhr.setRequestHeader(name, value);
498
+ });
499
+
500
+ if (request.signal) {
501
+ request.signal.addEventListener('abort', abortXhr);
502
+
503
+ xhr.onreadystatechange = function() {
504
+ // DONE (success or failure)
505
+ if (xhr.readyState === 4) {
506
+ request.signal.removeEventListener('abort', abortXhr);
507
+ }
508
+ };
509
+ }
510
+
511
+ xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
512
+ })
513
+ }
514
+
515
+ fetch.polyfill = true;
516
+
517
+ if (!self.fetch) {
518
+ self.fetch = fetch;
519
+ self.Headers = Headers;
520
+ self.Request = Request;
521
+ self.Response = Response;
522
+ }
523
+
524
+ exports.Headers = Headers;
525
+ exports.Request = Request;
526
+ exports.Response = Response;
527
+ exports.fetch = fetch;
528
+
529
+ Object.defineProperty(exports, '__esModule', { value: true });
530
+
531
+ })));
inc/assets/js/install-theme.js CHANGED
@@ -6,6 +6,7 @@
6
* Init
7
*/
8
init: function() {
9
this._bind();
10
},
11
@@ -24,6 +25,28 @@
24
$( document ).on('wp-theme-install-success' , AstraSitesInstallTheme._activateTheme);
25
},
26
27
/**
28
* Activate Theme
29
*
@@ -76,9 +99,6 @@
76
_install_and_activate: function(event ) {
77
event.preventDefault();
78
var theme_slug = $(this).data('theme-slug') || '';
79
- console.log( theme_slug );
80
- console.log( 'yes' );
81
-
82
var btn = $( event.target );
83
84
if ( btn.hasClass( 'processing' ) ) {
6
* Init
7
*/
8
init: function() {
9
+ this._auto_close_notice();
10
this._bind();
11
},
12
25
$( document ).on('wp-theme-install-success' , AstraSitesInstallTheme._activateTheme);
26
},
27
28
+ /**
29
+ * Close Getting Started Notice
30
+ *
31
+ * @param {object} event
32
+ * @return void
33
+ */
34
+ _auto_close_notice: function() {
35
+
36
+ if( $( '.astra-sites-getting-started-btn' ).length ) {
37
+ $.ajax({
38
+ url: AstraSitesInstallThemeVars.ajaxurl,
39
+ type: 'POST',
40
+ data: {
41
+ 'action' : 'astra-sites-getting-started-notice'
42
+ },
43
+ })
44
+ .done(function (result) {
45
+ });
46
+ }
47
+
48
+ },
49
+
50
/**
51
* Activate Theme
52
*
99
_install_and_activate: function(event ) {
100
event.preventDefault();
101
var theme_slug = $(this).data('theme-slug') || '';
102
var btn = $( event.target );
103
104
if ( btn.hasClass( 'processing' ) ) {
inc/assets/js/render-grid.js CHANGED
@@ -18,6 +18,7 @@
18
_api_params : {},
19
_breakpoint : 768,
20
_has_default_page_builder : false,
21
22
init: function()
23
{
@@ -190,7 +191,7 @@
190
191
_apiAddParam_per_page: function() {
192
// Add 'per_page'
193
- var per_page_val = 15;
194
if( astraRenderGrid.sites && astraRenderGrid.sites["par-page"] ) {
195
per_page_val = parseInt( astraRenderGrid.sites["par-page"] );
196
}
@@ -272,8 +273,8 @@
272
AstraRender._apiAddParam_search();
273
AstraRender._apiAddParam_per_page();
274
AstraRender._apiAddParam_astra_site_category();
275
- AstraRender._apiAddParam_astra_site_page_builder();
276
AstraRender._apiAddParam_page();
277
AstraRender._apiAddParam_site_url();
278
AstraRender._apiAddParam_purchase_key();
279
@@ -380,20 +381,85 @@
380
*/
381
_loadPageBuilders: function() {
382
383
- /**
384
- * Page Builder
385
- */
386
- var category_slug = 'astra-site-page-builder';
387
- var category = {
388
- slug : category_slug + AstraRender._getPageBuilderParams(),
389
- id : category_slug,
390
- class : category_slug,
391
- trigger : 'astra-api-page-builder-loaded',
392
- wrapper_class : 'filter-links',
393
- show_all : false,
394
- };
395
-
396
- AstraSitesAPI._api_request( category );