Astra Starter Sites - Version 1.1.0

Version Description

Download this release

Release Info

Developer Nikschavan
Plugin Icon Astra Starter Sites
Version 1.1.0
Comparing to
See all releases

Code changes from version 1.0.14 to 1.1.0

astra-sites.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /**
3
- * Plugin Name: Astra Sites - Lite
4
  * Plugin URI: http://www.wpastra.com/pro/
5
  * Description: Import free sites build with Astra theme.
6
- * Version: 1.0.14
7
  * Author: Brainstorm Force
8
  * Author URI: http://www.brainstormforce.com
9
  * Text Domain: astra-sites
@@ -19,7 +19,7 @@ if ( ! defined( 'ASTRA_SITES_NAME' ) ) {
19
  }
20
 
21
  if ( ! defined( 'ASTRA_SITES_VER' ) ) {
22
- define( 'ASTRA_SITES_VER', '1.0.14' );
23
  }
24
 
25
  if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
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.0
7
  * Author: Brainstorm Force
8
  * Author URI: http://www.brainstormforce.com
9
  * Text Domain: astra-sites
19
  }
20
 
21
  if ( ! defined( 'ASTRA_SITES_VER' ) ) {
22
+ define( 'ASTRA_SITES_VER', '1.1.0' );
23
  }
24
 
25
  if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
inc/assets/css/admin.css CHANGED
@@ -90,6 +90,11 @@
90
  text-align: center;
91
  }
92
 
 
 
 
 
 
93
  .wp-full-overlay-footer .installing:before {
94
  vertical-align: text-bottom;
95
  }
@@ -236,6 +241,9 @@
236
  #astra-sites-admin {
237
  height: 100vh;
238
  }
 
 
 
239
 
240
  .astra-sites-suggestions:before {
241
  border: 5px dashed #ccc;
@@ -285,4 +293,26 @@
285
 
286
  .no-themes .description {
287
  display: block;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  }
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
  }
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;
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
  }
inc/assets/js/admin-page.js CHANGED
@@ -74,16 +74,92 @@ var AstraSitesAjaxQueue = (function() {
74
  };
75
 
76
  }());
 
77
  (function($){
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  AstraSitesAdmin = {
80
 
 
 
 
 
 
 
81
  init: function()
82
  {
83
  this._resetPagedCount();
84
  this._bind();
85
  },
86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  /**
88
  * Binds events for the Astra Sites.
89
  *
@@ -105,6 +181,244 @@ var AstraSitesAjaxQueue = (function() {
105
  $( document ).on('wp-plugin-installing' , AstraSitesAdmin._pluginInstalling);
106
  $( document ).on('wp-plugin-install-error' , AstraSitesAdmin._installError);
107
  $( document ).on('wp-plugin-install-success' , AstraSitesAdmin._installSuccess);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  },
109
 
110
  /**
@@ -136,6 +450,59 @@ var AstraSitesAjaxQueue = (function() {
136
  .attr( 'aria-pressed', true );
137
  },
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  /**
140
  * Install Now
141
  */
@@ -164,8 +531,10 @@ var AstraSitesAjaxQueue = (function() {
164
  } );
165
  }
166
 
 
 
167
  wp.updates.installPlugin( {
168
- slug: $button.data( 'slug' )
169
  } );
170
  },
171
 
@@ -176,6 +545,8 @@ var AstraSitesAjaxQueue = (function() {
176
 
177
  event.preventDefault();
178
 
 
 
179
  var $message = jQuery( '.plugin-card-' + response.slug ).find( '.button' );
180
  var $siteOptions = jQuery( '.wp-full-overlay-header').find('.astra-site-options').val();
181
  var $enabledExtensions = jQuery( '.wp-full-overlay-header').find('.astra-enabled-extensions').val();
@@ -194,7 +565,7 @@ var AstraSitesAjaxQueue = (function() {
194
  // WordPress adds "Activate" button after waiting for 1000ms. So we will run our activation after that.
195
  setTimeout( function() {
196
 
197
- jQuery.ajax({
198
  url: astraSitesAdmin.ajaxurl,
199
  type: 'POST',
200
  data: {
@@ -240,6 +611,8 @@ var AstraSitesAjaxQueue = (function() {
240
 
241
  var $card = jQuery( '.plugin-card-' + response.slug );
242
 
 
 
243
  $card
244
  .addClass( 'button-primary' )
245
  .html( wp.updates.l10n.installNow );
@@ -254,6 +627,8 @@ var AstraSitesAjaxQueue = (function() {
254
  var $card = jQuery( '.plugin-card-' + args.slug );
255
  var $button = $card.find( '.button' );
256
 
 
 
257
  $card.addClass('updating-message');
258
  $button.addClass('already-started');
259
 
@@ -274,13 +649,15 @@ var AstraSitesAjaxQueue = (function() {
274
  return;
275
  }
276
 
 
 
277
  $button.addClass('updating-message button-primary')
278
  .html( astraSitesAdmin.strings.btnActivating );
279
 
280
  var $siteOptions = jQuery( '.wp-full-overlay-header').find('.astra-site-options').val();
281
  var $enabledExtensions = jQuery( '.wp-full-overlay-header').find('.astra-enabled-extensions').val();
282
 
283
- jQuery.ajax({
284
  url: astraSitesAdmin.ajaxurl,
285
  type: 'POST',
286
  data: {
@@ -294,6 +671,8 @@ var AstraSitesAjaxQueue = (function() {
294
 
295
  if( result.success ) {
296
 
 
 
297
  var pluginsList = astraSitesAdmin.requiredPlugins.inactive;
298
 
299
  // Reset not installed plugins list.
@@ -368,10 +747,13 @@ var AstraSitesAjaxQueue = (function() {
368
  */
369
  _activateAllPlugins: function( activate_plugins ) {
370
 
371
- // Process of cloud templates - (download, remove & fetch).
 
372
  AstraSitesAjaxQueue.run();
373
 
374
- jQuery.each( activate_plugins, function(index, single_plugin) {
 
 
375
 
376
  var $card = jQuery( '.plugin-card-' + single_plugin.slug ),
377
  $button = $card.find('.button'),
@@ -384,15 +766,17 @@ var AstraSitesAjaxQueue = (function() {
384
  url: astraSitesAdmin.ajaxurl,
385
  type: 'POST',
386
  data: {
387
- 'action' : 'astra-required-plugin-activate',
388
- 'init' : single_plugin.init,
389
- 'options' : $siteOptions,
390
  'enabledExtensions' : $enabledExtensions,
391
  },
392
  success: function( result ){
393
 
394
  if( result.success ) {
395
 
 
 
396
  var $card = jQuery( '.plugin-card-' + single_plugin.slug );
397
  var $button = $card.find( '.button' );
398
  if( ! $button.hasClass('already-started') ) {
@@ -409,6 +793,8 @@ var AstraSitesAjaxQueue = (function() {
409
 
410
  // Enable Demo Import Button
411
  AstraSitesAdmin._enable_demo_import_button();
 
 
412
  }
413
  }
414
  });
@@ -419,8 +805,10 @@ var AstraSitesAjaxQueue = (function() {
419
  * Install All Plugins.
420
  */
421
  _installAllPlugins: function( not_installed ) {
 
 
422
 
423
- jQuery.each( not_installed, function(index, single_plugin) {
424
 
425
  var $card = jQuery( '.plugin-card-' + single_plugin.slug ),
426
  $button = $card.find('.button');
@@ -476,6 +864,9 @@ var AstraSitesAjaxQueue = (function() {
476
  return;
477
  }
478
 
 
 
 
479
  $('.astra-demo-import').attr('data-import', 'disabled')
480
  .addClass('updating-message installing')
481
  .text( astraSitesAdmin.strings.importingDemo );
@@ -485,57 +876,68 @@ var AstraSitesAjaxQueue = (function() {
485
  var $theme = $this.closest('.astra-sites-preview').find('.wp-full-overlay-header');
486
 
487
  var apiURL = $theme.data('demo-api') || '';
 
 
 
 
 
 
 
488
 
 
 
 
 
 
 
 
 
 
 
 
 
 
489
  $.ajax({
490
- url: astraSitesAdmin.ajaxurl,
491
- type: 'POST',
492
- dataType: 'json',
493
- data: {
494
- action: 'astra-import-demo',
495
- api_url: apiURL
496
  },
497
  })
498
- .done(function ( demos ) {
499
-
500
- // Success?
501
- if( demos.success ) {
502
- jQuery('.astra-demo-import').removeClass('updating-message installing')
503
- .removeAttr('data-import')
504
- .addClass('view-site')
505
- .removeClass('astra-demo-import')
506
- .text( astraSitesAdmin.strings.viewSite )
507
- .attr('target', '_blank')
508
- .append('<i class="dashicons dashicons-external"></i>')
509
- .attr('href', astraSitesAdmin.siteURL );
 
 
 
 
 
510
 
511
  } else {
512
 
513
- var output = '<div class="astra-api-error notice notice-error notice-alt is-dismissible">';
514
- output += ' <p>'+demos.message+'</p>';
515
- output += ' <button type="button" class="notice-dismiss">';
516
- output += ' <span class="screen-reader-text">'+commonL10n.dismiss+'</span>';
517
- output += ' </button>';
518
- output += '</div>';
519
 
520
- jQuery('.install-theme-info').prepend( output );
 
 
 
521
 
522
- // !important to add trigger.
523
- // Which reinitialize the dismiss error message events.
524
- jQuery(document).trigger('wp-updates-notice-added');
525
  }
526
-
527
- })
528
- .fail(function ( demos ) {
529
- jQuery('.astra-demo-import').removeClass('updating-message installing')
530
- .removeAttr('data-import')
531
- .addClass('view-site')
532
- .removeClass('astra-demo-import')
533
- .attr('target', '_blank')
534
- .attr('href', astraSitesAdmin.strings.importFailedURL );
535
-
536
- jQuery('.wp-full-overlay-header .view-site').text( astraSitesAdmin.strings.importFailedBtnSmall ).append('<i class="dashicons dashicons-external"></i>');
537
- jQuery('.footer-import-button-wrap .view-site').text( astraSitesAdmin.strings.importFailedBtnLarge ).append('<i class="dashicons dashicons-external"></i>');
538
  });
 
539
  },
540
 
541
  /**
@@ -643,6 +1045,8 @@ var AstraSitesAjaxQueue = (function() {
643
  astraSiteOptions = anchor.find('.astra-site-options').val() || '';
644
  astraEnabledExtensions = anchor.find('.astra-enabled-extensions').val() || '';
645
 
 
 
646
  var template = wp.template('astra-site-preview');
647
 
648
  templateData = [{
@@ -670,7 +1074,7 @@ var AstraSitesAjaxQueue = (function() {
670
  var descHeight = parseInt( desc.outerHeight() );
671
  var descBtn = jQuery('.theme-details-read-more');
672
 
673
- if( jQuery.isArray( requiredPlugins ) ) {
674
 
675
  if( descHeight >= 55 ) {
676
 
@@ -703,13 +1107,28 @@ var AstraSitesAjaxQueue = (function() {
703
  // or
704
  var $pluginsFilter = jQuery( '#plugin-filter' ),
705
  data = {
706
- _ajax_nonce : astraSitesAdmin._ajax_nonce,
 
707
  required_plugins : requiredPlugins
708
  };
709
 
710
  jQuery('.required-plugins').addClass('loading').html('<span class="spinner is-active"></span>');
711
 
712
- wp.ajax.post( 'astra-required-plugins', data ).done( function( response ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
713
 
714
  // Remove loader.
715
  jQuery('.required-plugins').removeClass('loading').html('');
@@ -725,12 +1144,12 @@ var AstraSitesAjaxQueue = (function() {
725
  *
726
  * List of not installed required plugins.
727
  */
728
- if ( typeof response.notinstalled !== 'undefined' ) {
729
 
730
  // Add not have installed plugins count.
731
- remaining_plugins += parseInt( response.notinstalled.length );
732
 
733
- jQuery( response.notinstalled ).each(function( index, plugin ) {
734
 
735
  var output = '<div class="plugin-card ';
736
  output += ' plugin-card-'+plugin.slug+'"';
@@ -756,12 +1175,12 @@ var AstraSitesAjaxQueue = (function() {
756
  *
757
  * List of not inactive required plugins.
758
  */
759
- if ( typeof response.inactive !== 'undefined' ) {
760
 
761
  // Add inactive plugins count.
762
- remaining_plugins += parseInt( response.inactive.length );
763
 
764
- jQuery( response.inactive ).each(function( index, plugin ) {
765
 
766
  var output = '<div class="plugin-card ';
767
  output += ' plugin-card-'+plugin.slug+'"';
@@ -787,9 +1206,9 @@ var AstraSitesAjaxQueue = (function() {
787
  *
788
  * List of not active required plugins.
789
  */
790
- if ( typeof response.active !== 'undefined' ) {
791
 
792
- jQuery( response.active ).each(function( index, plugin ) {
793
 
794
  var output = '<div class="plugin-card ';
795
  output += ' plugin-card-'+plugin.slug+'"';
@@ -813,10 +1232,10 @@ var AstraSitesAjaxQueue = (function() {
813
  * Enable Demo Import Button
814
  * @type number
815
  */
816
- astraSitesAdmin.requiredPlugins = response;
817
  AstraSitesAdmin._enable_demo_import_button();
818
 
819
- } );
820
 
821
  } else {
822
 
@@ -831,7 +1250,9 @@ var AstraSitesAjaxQueue = (function() {
831
  /**
832
  * Enable Demo Import Button.
833
  */
834
- _enable_demo_import_button: function( type = 'free' ) {
 
 
835
 
836
  switch( type ) {
837
 
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
  *
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
+ data : {
201
+ action : 'astra-sites-import-end',
202
+ },
203
+ beforeSend: function() {
204
+ $('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importComplete );
205
+ }
206
+ })
207
+ .fail(function( jqXHR ){
208
+ AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
209
+ AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
210
+ })
211
+ .done(function ( data ) {
212
+
213
+ // 5. Fail - Import Complete.
214
+ if( false === data.success ) {
215
+ AstraSitesAdmin._importFailMessage( data.data );
216
+ AstraSitesAdmin._log( data.data );
217
+ } else {
218
+
219
+ // 5. Pass - Import Complete.
220
+ AstraSitesAdmin._importSuccessMessage();
221
+ AstraSitesAdmin._log( astraSitesAdmin.log.success + ' ' + astraSitesAdmin.siteURL );
222
+ }
223
+ });
224
+ },
225
+
226
+ /**
227
+ * 4. Import Widgets.
228
+ */
229
+ _importWidgets: function( event ) {
230
+
231
+ $.ajax({
232
+ url : astraSitesAdmin.ajaxurl,
233
+ type : 'POST',
234
+ data : {
235
+ action : 'astra-sites-import-widgets',
236
+ widgets_data : AstraSitesAdmin.widgets_data,
237
+ },
238
+ beforeSend: function() {
239
+ AstraSitesAdmin._log( astraSitesAdmin.log.importWidgets );
240
+ $('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importingWidgets );
241
+ },
242
+ })
243
+ .fail(function( jqXHR ){
244
+ AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
245
+ AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
246
+ })
247
+ .done(function ( widgets_data ) {
248
+
249
+ // 4. Fail - Import Widgets.
250
+ if( false === widgets_data.success ) {
251
+ AstraSitesAdmin._importFailMessage( widgets_data.data );
252
+ AstraSitesAdmin._log( widgets_data.data );
253
+
254
+ } else {
255
+
256
+ // 4. Pass - Import Widgets.
257
+ AstraSitesAdmin._log( astraSitesAdmin.log.importWidgetsSuccess );
258
+ $(document).trigger( 'astra-sites-import-widgets-done' );
259
+ }
260
+ });
261
+ },
262
+
263
+ /**
264
+ * 3. Import Site Options.
265
+ */
266
+ _importSiteOptions: function( event ) {
267
+
268
+ $.ajax({
269
+ url : astraSitesAdmin.ajaxurl,
270
+ type : 'POST',
271
+ data : {
272
+ action : 'astra-sites-import-options',
273
+ options_data : AstraSitesAdmin.options_data,
274
+ },
275
+ beforeSend: function() {
276
+ AstraSitesAdmin._log( astraSitesAdmin.log.importOptions );
277
+ $('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importingOptions );
278
+ },
279
+ })
280
+ .fail(function( jqXHR ){
281
+ AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
282
+ AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
283
+ })
284
+ .done(function ( options_data ) {
285
+
286
+ // 3. Fail - Import Site Options.
287
+ if( false === options_data.success ) {
288
+ AstraSitesAdmin._log( options_data );
289
+ AstraSitesAdmin._importFailMessage( options_data.data );
290
+ AstraSitesAdmin._log( options_data.data );
291
+
292
+ } else {
293
+
294
+ // 3. Pass - Import Site Options.
295
+ AstraSitesAdmin._log( astraSitesAdmin.log.importOptionsSuccess );
296
+ $(document).trigger( 'astra-sites-import-options-done' );
297
+ }
298
+ });
299
+ },
300
+
301
+ /**
302
+ * 2. Prepare XML Data.
303
+ */
304
+ _importPrepareXML: function( event ) {
305
+
306
+ $.ajax({
307
+ url : astraSitesAdmin.ajaxurl,
308
+ type : 'POST',
309
+ data : {
310
+ action : 'astra-sites-import-prepare-xml',
311
+ wxr_url : AstraSitesAdmin.wxr_url,
312
+ },
313
+ beforeSend: function() {
314
+ AstraSitesAdmin._log( astraSitesAdmin.log.importXMLPrepare );
315
+ $('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importXMLPreparing );
316
+ },
317
+ })
318
+ .fail(function( jqXHR ){
319
+ AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
320
+ AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
321
+ })
322
+ .done(function ( xml_data ) {
323
+
324
+ // 2. Fail - Prepare XML Data.
325
+ if( false === xml_data.success ) {
326
+ AstraSitesAdmin._log( xml_data );
327
+ AstraSitesAdmin._importFailMessage( xml_data.data );
328
+ AstraSitesAdmin._log( xml_data.data );
329
+
330
+ } else {
331
+
332
+ // 2. Pass - Prepare XML Data.
333
+ AstraSitesAdmin._log( astraSitesAdmin.log.importXMLPrepareSuccess );
334
+
335
+ // Import XML though Event Source.
336
+ AstraSSEImport.data = xml_data.data;
337
+ AstraSSEImport.render();
338
+
339
+ AstraSitesAdmin._log( astraSitesAdmin.log.importXML );
340
+ $('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importingXML );
341
+
342
+ var evtSource = new EventSource( AstraSSEImport.data.url );
343
+ evtSource.onmessage = function ( message ) {
344
+ var data = JSON.parse( message.data );
345
+ switch ( data.action ) {
346
+ case 'updateDelta':
347
+ AstraSSEImport.updateDelta( data.type, data.delta );
348
+ break;
349
+
350
+ case 'complete':
351
+ evtSource.close();
352
+
353
+ // 2. Pass - Import XML though "Source Event".
354
+ AstraSitesAdmin._log( astraSitesAdmin.log.importXMLSuccess );
355
+ AstraSitesAdmin._log( '----- SSE - XML import Complete -----' );
356
+
357
+ $(document).trigger( 'astra-sites-import-xml-done' );
358
+
359
+ break;
360
+ }
361
+ };
362
+ evtSource.addEventListener( 'log', function ( message ) {
363
+ var data = JSON.parse( message.data );
364
+ AstraSitesAdmin._log( data.level + ' ' + data.message );
365
+ });
366
+ }
367
+ });
368
+ },
369
+
370
+ /**
371
+ * 1. Import Customizer Options.
372
+ */
373
+ _importCustomizerSettings: function( event ) {
374
+
375
+ $.ajax({
376
+ url : astraSitesAdmin.ajaxurl,
377
+ type : 'POST',
378
+ data : {
379
+ action : 'astra-sites-import-customizer-settings',
380
+ customizer_data : AstraSitesAdmin.customizer_data,
381
+ },
382
+ beforeSend: function() {
383
+ AstraSitesAdmin._log( astraSitesAdmin.log.importCustomizer );
384
+ $('.button-hero.astra-demo-import').text( astraSitesAdmin.log.importingCustomizer );
385
+ },
386
+ })
387
+ .fail(function( jqXHR ){
388
+ AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
389
+ AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
390
+ })
391
+ .done(function ( customizer_data ) {
392
+
393
+ // 1. Fail - Import Customizer Options.
394
+ if( false === customizer_data.success ) {
395
+ AstraSitesAdmin._importFailMessage( customizer_data.data );
396
+ AstraSitesAdmin._log( customizer_data.data );
397
+ } else {
398
+
399
+ // 1. Pass - Import Customizer Options.
400
+ AstraSitesAdmin._log( astraSitesAdmin.log.importCustomizerSuccess );
401
+
402
+ $(document).trigger( 'astra-sites-import-customizer-settings-done' );
403
+ }
404
+ });
405
+ },
406
+
407
+ /**
408
+ * Import Success Button.
409
+ *
410
+ * @param {string} data Error message.
411
+ */
412
+ _importSuccessMessage: function() {
413
+
414
+ $('.astra-demo-import').removeClass('updating-message installing')
415
+ .removeAttr('data-import')
416
+ .addClass('view-site')
417
+ .removeClass('astra-demo-import')
418
+ .text( astraSitesAdmin.strings.viewSite )
419
+ .attr('target', '_blank')
420
+ .append('<i class="dashicons dashicons-external"></i>')
421
+ .attr('href', astraSitesAdmin.siteURL );
422
  },
423
 
424
  /**
450
  .attr( 'aria-pressed', true );
451
  },
452
 
453
+ /**
454
+ * Import Error Button.
455
+ *
456
+ * @param {string} data Error message.
457
+ */
458
+ _importFailMessage: function( message, from ) {
459
+
460
+ $('.astra-demo-import')
461
+ .addClass('go-pro button-primary')
462
+ .removeClass('updating-message installing')
463
+ .removeAttr('data-import')
464
+ .attr('target', '_blank')
465
+ .append('<i class="dashicons dashicons-external"></i>')
466
+ .removeClass('astra-demo-import');
467
+
468
+ // Add the doc link due to import log file not generated.
469
+ if( 'undefined' === from ) {
470
+
471
+ $('.wp-full-overlay-header .go-pro').text( astraSitesAdmin.strings.importFailedBtnSmall );
472
+ $('.wp-full-overlay-footer .go-pro').text( astraSitesAdmin.strings.importFailedBtnLarge );
473
+ $('.go-pro').attr('href', astraSitesAdmin.log.serverConfiguration );
474
+
475
+ // Add the import log file link.
476
+ } else {
477
+
478
+ $('.wp-full-overlay-header .go-pro').text( astraSitesAdmin.strings.importFailBtn );
479
+ $('.wp-full-overlay-footer .go-pro').text( astraSitesAdmin.strings.importFailBtnLarge )
480
+
481
+ // Add the import log file link.
482
+ if( 'undefined' !== AstraSitesAdmin.log_file_url ) {
483
+ $('.go-pro').attr('href', AstraSitesAdmin.log_file_url );
484
+ } else {
485
+ $('.go-pro').attr('href', astraSitesAdmin.log.serverConfiguration );
486
+ }
487
+ }
488
+
489
+ var output = '<div class="astra-api-error notice notice-error notice-alt is-dismissible">';
490
+ output += ' <p>'+message+'</p>';
491
+ output += ' <button type="button" class="notice-dismiss">';
492
+ output += ' <span class="screen-reader-text">'+commonL10n.dismiss+'</span>';
493
+ output += ' </button>';
494
+ output += '</div>';
495
+
496
+ // Fail Notice.
497
+ $('.install-theme-info').append( output );
498
+
499
+
500
+ // !important to add trigger.
501
+ // Which reinitialize the dismiss error message events.
502
+ $(document).trigger('wp-updates-notice-added');
503
+ },
504
+
505
+
506
  /**
507
  * Install Now
508
  */
531
  } );
532
  }
533
 
534
+ AstraSitesAdmin._log( astraSitesAdmin.log.installingPlugin + ' ' + $button.data( 'slug' ) );
535
+
536
  wp.updates.installPlugin( {
537
+ slug: $button.data( 'slug' )
538
  } );
539
  },
540
 
545
 
546
  event.preventDefault();
547
 
548
+ AstraSitesAdmin._log( astraSitesAdmin.log.installed + ' ' + response.slug );
549
+
550
  var $message = jQuery( '.plugin-card-' + response.slug ).find( '.button' );
551
  var $siteOptions = jQuery( '.wp-full-overlay-header').find('.astra-site-options').val();
552
  var $enabledExtensions = jQuery( '.wp-full-overlay-header').find('.astra-enabled-extensions').val();
565
  // WordPress adds "Activate" button after waiting for 1000ms. So we will run our activation after that.
566
  setTimeout( function() {
567
 
568
+ $.ajax({
569
  url: astraSitesAdmin.ajaxurl,
570
  type: 'POST',
571
  data: {
611
 
612
  var $card = jQuery( '.plugin-card-' + response.slug );
613
 
614
+ AstraSitesAdmin._log( astraSitesAdmin.log.installError + ' ' + response.slug );
615
+
616
  $card
617
  .addClass( 'button-primary' )
618
  .html( wp.updates.l10n.installNow );
627
  var $card = jQuery( '.plugin-card-' + args.slug );
628
  var $button = $card.find( '.button' );
629
 
630
+ AstraSitesAdmin._log( astraSitesAdmin.log.installingPlugin + ' ' + args.slug );
631
+
632
  $card.addClass('updating-message');
633
  $button.addClass('already-started');
634
 
649
  return;
650
  }
651
 
652
+ AstraSitesAdmin._log( astraSitesAdmin.log.activating + ' ' + $slug );
653
+
654
  $button.addClass('updating-message button-primary')
655
  .html( astraSitesAdmin.strings.btnActivating );
656
 
657
  var $siteOptions = jQuery( '.wp-full-overlay-header').find('.astra-site-options').val();
658
  var $enabledExtensions = jQuery( '.wp-full-overlay-header').find('.astra-enabled-extensions').val();
659
 
660
+ $.ajax({
661
  url: astraSitesAdmin.ajaxurl,
662
  type: 'POST',
663
  data: {
671
 
672
  if( result.success ) {
673
 
674
+ AstraSitesAdmin._log( astraSitesAdmin.log.activated + ' ' + $slug );
675
+
676
  var pluginsList = astraSitesAdmin.requiredPlugins.inactive;
677
 
678
  // Reset not installed plugins list.
747
  */
748
  _activateAllPlugins: function( activate_plugins ) {
749
 
750
+ // Activate ALl Plugins.
751
+ AstraSitesAjaxQueue.stop();
752
  AstraSitesAjaxQueue.run();
753
 
754
+ AstraSitesAdmin._log( astraSitesAdmin.log.bulkActivation );
755
+
756
+ $.each( activate_plugins, function(index, single_plugin) {
757
 
758
  var $card = jQuery( '.plugin-card-' + single_plugin.slug ),
759
  $button = $card.find('.button'),
766
  url: astraSitesAdmin.ajaxurl,
767
  type: 'POST',
768
  data: {
769
+ 'action' : 'astra-required-plugin-activate',
770
+ 'init' : single_plugin.init,
771
+ 'options' : $siteOptions,
772
  'enabledExtensions' : $enabledExtensions,
773
  },
774
  success: function( result ){
775
 
776
  if( result.success ) {
777
 
778
+ AstraSitesAdmin._log( astraSitesAdmin.log.activate + ' ' + single_plugin.slug );
779
+
780
  var $card = jQuery( '.plugin-card-' + single_plugin.slug );
781
  var $button = $card.find( '.button' );
782
  if( ! $button.hasClass('already-started') ) {
793
 
794
  // Enable Demo Import Button
795
  AstraSitesAdmin._enable_demo_import_button();
796
+ } else {
797
+ AstraSitesAdmin._log( astraSitesAdmin.log.activationError + ' - ' + single_plugin.slug );
798
  }
799
  }
800
  });
805
  * Install All Plugins.
806
  */
807
  _installAllPlugins: function( not_installed ) {
808
+
809
+ AstraSitesAdmin._log( astraSitesAdmin.log.bulkInstall );
810
 
811
+ $.each( not_installed, function(index, single_plugin) {
812
 
813
  var $card = jQuery( '.plugin-card-' + single_plugin.slug ),
814
  $button = $card.find('.button');
864
  return;
865
  }
866
 
867
+ // Remove all notices before import start.
868
+ $('.install-theme-info > .notice').remove();
869
+
870
  $('.astra-demo-import').attr('data-import', 'disabled')
871
  .addClass('updating-message installing')
872
  .text( astraSitesAdmin.strings.importingDemo );
876
  var $theme = $this.closest('.astra-sites-preview').find('.wp-full-overlay-header');
877
 
878
  var apiURL = $theme.data('demo-api') || '';
879
+
880
+ // Site Import by API URL.
881
+ if( apiURL ) {
882
+ AstraSitesAdmin._importSite( apiURL );
883
+ }
884
+
885
+ },
886
 
887
+ /**
888
+ * Start Import Process by API URL.
889
+ *
890
+ * @param {string} apiURL Site API URL.
891
+ */
892
+ _importSite: function( apiURL ) {
893
+
894
+ AstraSitesAdmin._log( astraSitesAdmin.log.api + ' : ' + apiURL );
895
+ AstraSitesAdmin._log( astraSitesAdmin.log.importing );
896
+
897
+ $('.button-hero.astra-demo-import').text( astraSitesAdmin.log.gettingData );
898
+
899
+ // 1. Request Site Import
900
  $.ajax({
901
+ url : astraSitesAdmin.ajaxurl,
902
+ type : 'POST',
903
+ data : {
904
+ 'action' : 'astra-sites-import-set-site-data',
905
+ 'api_url' : apiURL,
 
906
  },
907
  })
908
+ .fail(function( jqXHR ){
909
+ AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText );
910
+ AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
911
+ })
912
+ .done(function ( demo_data ) {
913
+
914
+ /**
915
+ * Set log file URL
916
+ */
917
+ if( astraSitesAdmin.debug && ( undefined !== demo_data.data.log_file.abs_url || null !== demo_data.data.log_file.abs_url ) ) {
918
+ AstraSitesAdmin.log_file_url = decodeURIComponent( demo_data.data.log_file.url ) || '';
919
+ }
920
+
921
+ // 1. Fail - Request Site Import
922
+ if( false === demo_data.success ) {
923
+
924
+ AstraSitesAdmin._importFailMessage( demo_data.data );
925
 
926
  } else {
927
 
928
+ // 1. Pass - Request Site Import
929
+ AstraSitesAdmin._log( astraSitesAdmin.log.processingRequest );
 
 
 
 
930
 
931
+ AstraSitesAdmin.customizer_data = JSON.stringify( demo_data.data['astra-site-customizer-data'] ) || '';
932
+ AstraSitesAdmin.wxr_url = encodeURI( demo_data.data['astra-site-wxr-path'] ) || '';
933
+ AstraSitesAdmin.options_data = JSON.stringify( demo_data.data['astra-site-options-data'] ) || '';
934
+ AstraSitesAdmin.widgets_data = JSON.stringify( demo_data.data['astra-site-widgets-data'] ) || '';
935
 
936
+ $(document).trigger( 'astra-sites-import-set-site-data-done' );
 
 
937
  }
938
+
 
 
 
 
 
 
 
 
 
 
 
939
  });
940
+
941
  },
942
 
943
  /**
1045
  astraSiteOptions = anchor.find('.astra-site-options').val() || '';
1046
  astraEnabledExtensions = anchor.find('.astra-enabled-extensions').val() || '';
1047
 
1048
+ AstraSitesAdmin._log( astraSitesAdmin.log.preview + ' "' + demo_name + '" URL : ' + demoURL );
1049
+
1050
  var template = wp.template('astra-site-preview');
1051
 
1052
  templateData = [{
1074
  var descHeight = parseInt( desc.outerHeight() );
1075
  var descBtn = jQuery('.theme-details-read-more');
1076
 
1077
+ if( $.isArray( requiredPlugins ) ) {
1078
 
1079
  if( descHeight >= 55 ) {
1080
 
1107
  // or
1108
  var $pluginsFilter = jQuery( '#plugin-filter' ),
1109
  data = {
1110
+ action : 'astra-required-plugins',
1111
+ _ajax_nonce : astraSitesAdmin._ajax_nonce,
1112
  required_plugins : requiredPlugins
1113
  };
1114
 
1115
  jQuery('.required-plugins').addClass('loading').html('<span class="spinner is-active"></span>');
1116
 
1117
+ // Required Required.
1118
+ $.ajax({
1119
+ url : astraSitesAdmin.ajaxurl,
1120
+ type : 'POST',
1121
+ data : data,
1122
+ })
1123
+ .fail(function( jqXHR ){
1124
+
1125
+ // Remove loader.
1126
+ jQuery('.required-plugins').removeClass('loading').html('');
1127
+
1128
+ AstraSitesAdmin._importFailMessage( jqXHR.status + ' ' + jqXHR.responseText, 'plugins' );
1129
+ AstraSitesAdmin._log( jqXHR.status + ' ' + jqXHR.responseText );
1130
+ })
1131
+ .done(function ( response ) {
1132
 
1133
  // Remove loader.
1134
  jQuery('.required-plugins').removeClass('loading').html('');
1144
  *
1145
  * List of not installed required plugins.
1146
  */
1147
+ if ( typeof response.data.notinstalled !== 'undefined' ) {
1148
 
1149
  // Add not have installed plugins count.
1150
+ remaining_plugins += parseInt( response.data.notinstalled.length );
1151
 
1152
+ jQuery( response.data.notinstalled ).each(function( index, plugin ) {
1153
 
1154
  var output = '<div class="plugin-card ';
1155
  output += ' plugin-card-'+plugin.slug+'"';
1175
  *
1176
  * List of not inactive required plugins.
1177
  */
1178
+ if ( typeof response.data.inactive !== 'undefined' ) {
1179
 
1180
  // Add inactive plugins count.
1181
+ remaining_plugins += parseInt( response.data.inactive.length );
1182
 
1183
+ jQuery( response.data.inactive ).each(function( index, plugin ) {
1184
 
1185
  var output = '<div class="plugin-card ';
1186
  output += ' plugin-card-'+plugin.slug+'"';
1206
  *
1207
  * List of not active required plugins.
1208
  */
1209
+ if ( typeof response.data.active !== 'undefined' ) {
1210
 
1211
+ jQuery( response.data.active ).each(function( index, plugin ) {
1212
 
1213
  var output = '<div class="plugin-card ';
1214
  output += ' plugin-card-'+plugin.slug+'"';
1232
  * Enable Demo Import Button
1233
  * @type number
1234
  */
1235
+ astraSitesAdmin.requiredPlugins = response.data;
1236
  AstraSitesAdmin._enable_demo_import_button();
1237
 
1238
+ });
1239
 
1240
  } else {
1241
 
1250
  /**
1251
  * Enable Demo Import Button.
1252
  */
1253
+ _enable_demo_import_button: function( type ) {
1254
+
1255
+ type = ( undefined !== type ) ? type : 'free';
1256
 
1257
  switch( type ) {
1258
 
inc/assets/js/eventsource.js ADDED
@@ -0,0 +1,673 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /** @license
2
+ * eventsource.js
3
+ * Available under MIT License (MIT)
4
+ * https://github.com/Yaffle/EventSource/
5
+ */
6
+
7
+ /*jslint indent: 2, vars: true, plusplus: true */
8
+ /*global setTimeout, clearTimeout */
9
+
10
+ (function (global) {
11
+ "use strict";
12
+
13
+ var setTimeout = global.setTimeout;
14
+ var clearTimeout = global.clearTimeout;
15
+ var XMLHttpRequest = global.XMLHttpRequest;
16
+ var XDomainRequest = global.XDomainRequest;
17
+ var NativeEventSource = global.EventSource;
18
+ var document = global.document;
19
+
20
+ if (Object.create == null) {
21
+ Object.create = function (C) {
22
+ function F(){}
23
+ F.prototype = C;
24
+ return new F();
25
+ };
26
+ }
27
+
28
+ var k = function () {
29
+ };
30
+
31
+ function XHRWrapper(xhr) {
32
+ this.withCredentials = false;
33
+ this.responseType = "";
34
+ this.readyState = 0;
35
+ this.status = 0;
36
+ this.statusText = "";
37
+ this.responseText = "";
38
+ this.onprogress = k;
39
+ this.onreadystatechange = k;
40
+ this._contentType = "";
41
+ this._xhr = xhr;
42
+ this._sendTimeout = 0;
43
+ this._abort = k;
44
+ }
45
+
46
+ XHRWrapper.prototype.open = function (method, url) {
47
+ this._abort(true);
48
+
49
+ var that = this;
50
+ var xhr = this._xhr;
51
+ var state = 1;
52
+ var timeout = 0;
53
+
54
+ this._abort = function (silent) {
55
+ if (that._sendTimeout !== 0) {
56
+ clearTimeout(that._sendTimeout);
57
+ that._sendTimeout = 0;
58
+ }
59
+ if (state === 1 || state === 2 || state === 3) {
60
+ state = 4;
61
+ xhr.onload = k;
62
+ xhr.onerror = k;
63
+ xhr.onabort = k;
64
+ xhr.onprogress = k;
65
+ xhr.onreadystatechange = k;
66
+ // IE 8 - 9: XDomainRequest#abort() does not fire any event
67
+ // Opera < 10: XMLHttpRequest#abort() does not fire any event
68
+ xhr.abort();
69
+ if (timeout !== 0) {
70
+ clearTimeout(timeout);
71
+ timeout = 0;
72
+ }
73
+ if (!silent) {
74
+ that.readyState = 4;
75
+ that.onreadystatechange();
76
+ }
77
+ }
78
+ state = 0;
79
+ };
80
+
81
+ var onStart = function () {
82
+ if (state === 1) {
83
+ //state = 2;
84
+ var status = 0;
85
+ var statusText = "";
86
+ var contentType = undefined;
87
+ if (!("contentType" in xhr)) {
88
+ try {
89
+ status = xhr.status;
90
+ statusText = xhr.statusText;
91
+ contentType = xhr.getResponseHeader("Content-Type");
92
+ } catch (error) {
93
+ // IE < 10 throws exception for `xhr.status` when xhr.readyState === 2 || xhr.readyState === 3
94
+ // Opera < 11 throws exception for `xhr.status` when xhr.readyState === 2
95
+ // https://bugs.webkit.org/show_bug.cgi?id=29121
96
+ status = 0;
97
+ statusText = "";
98
+ contentType = undefined;
99
+ // Firefox < 14, Chrome ?, Safari ?
100
+ // https://bugs.webkit.org/show_bug.cgi?id=29658
101
+ // https://bugs.webkit.org/show_bug.cgi?id=77854
102
+ }
103
+ } else {
104
+ status = 200;
105
+ statusText = "OK";
106
+ contentType = xhr.contentType;
107
+ }
108
+ if (status !== 0) {
109
+ state = 2;
110
+ that.readyState = 2;
111
+ that.status = status;
112
+ that.statusText = statusText;
113
+ that._contentType = contentType;
114
+ that.onreadystatechange();
115
+ }
116
+ }
117
+ };
118
+ var onProgress = function () {
119
+ onStart();
120
+ if (state === 2 || state === 3) {
121
+ state = 3;
122
+ var responseText = "";
123
+ try {
124
+ responseText = xhr.responseText;
125
+ } catch (error) {
126
+ // IE 8 - 9 with XMLHttpRequest
127
+ }
128
+ that.readyState = 3;
129
+ that.responseText = responseText;
130
+ that.onprogress();
131
+ }
132
+ };
133
+ var onFinish = function () {
134
+ // Firefox 52 fires "readystatechange" (xhr.readyState === 4) without final "readystatechange" (xhr.readyState === 3)
135
+ // IE 8 fires "onload" without "onprogress"
136
+ onProgress();
137
+ if (state === 1 || state === 2 || state === 3) {
138
+ state = 4;
139
+ if (timeout !== 0) {
140
+ clearTimeout(timeout);
141
+ timeout = 0;
142
+ }
143
+ that.readyState = 4;
144
+ that.onreadystatechange();
145
+ }
146
+ };
147
+ var onReadyStateChange = function () {
148
+ if (xhr != undefined) { // Opera 12
149
+ if (xhr.readyState === 4) {
150
+ onFinish();
151
+ } else if (xhr.readyState === 3) {
152
+ onProgress();
153
+ } else if (xhr.readyState === 2) {
154
+ onStart();
155
+ }
156
+ }
157
+ };
158
+ var onTimeout = function () {
159
+ timeout = setTimeout(function () {
160
+ onTimeout();
161
+ }, 500);
162
+ if (xhr.readyState === 3) {
163
+ onProgress();
164
+ }
165
+ };
166
+
167
+ // XDomainRequest#abort removes onprogress, onerror, onload
168
+ xhr.onload = onFinish;
169
+ xhr.onerror = onFinish;
170
+ // improper fix to match Firefox behaviour, but it is better than just ignore abort
171
+ // see https://bugzilla.mozilla.org/show_bug.cgi?id=768596
172
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=880200
173
+ // https://code.google.com/p/chromium/issues/detail?id=153570
174
+ // IE 8 fires "onload" without "onprogress
175
+ xhr.onabort = onFinish;
176
+
177
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=736723
178
+ if (!("sendAsBinary" in XMLHttpRequest.prototype) && !("mozAnon" in XMLHttpRequest.prototype)) {
179
+ xhr.onprogress = onProgress;
180
+ }
181
+
182
+ // IE 8 - 9 (XMLHTTPRequest)
183
+ // Opera < 12
184
+ // Firefox < 3.5
185
+ // Firefox 3.5 - 3.6 - ? < 9.0
186
+ // onprogress is not fired sometimes or delayed
187
+ // see also #64
188
+ xhr.onreadystatechange = onReadyStateChange;
189
+
190
+ if ("contentType" in xhr) {
191
+ url += (url.indexOf("?", 0) === -1 ? "?" : "&") + "padding=true";
192
+ }
193
+ xhr.open(method, url, true);
194
+
195
+ if ("readyState" in xhr) {
196
+ // workaround for Opera 12 issue with "progress" events
197
+ // #91
198
+ timeout = setTimeout(function () {
199
+ onTimeout();
200
+ }, 0);
201
+ }
202
+ };
203
+ XHRWrapper.prototype.abort = function () {
204
+ this._abort(false);
205
+ };
206
+ XHRWrapper.prototype.getResponseHeader = function (name) {
207
+ return this._contentType;
208
+ };
209
+ XHRWrapper.prototype.setRequestHeader = function (name, value) {
210
+ var xhr = this._xhr;
211
+ if ("setRequestHeader" in xhr) {
212
+ xhr.setRequestHeader(name, value);
213
+ }
214
+ };
215
+ XHRWrapper.prototype.send = function () {
216
+ // loading indicator in Safari < ? (6), Chrome < 14, Firefox
217
+ if (!("ontimeout" in XMLHttpRequest.prototype) &&
218
+ document != undefined &&
219
+ document.readyState != undefined &&
220
+ document.readyState !== "complete") {
221
+ var that = this;
222
+ that._sendTimeout = setTimeout(function () {
223
+ that._sendTimeout = 0;
224
+ that.send();
225
+ }, 4);
226
+ return;
227
+ }
228
+
229
+ var xhr = this._xhr;
230
+ // withCredentials should be set after "open" for Safari and Chrome (< 19 ?)
231
+ xhr.withCredentials = this.withCredentials;
232
+ xhr.responseType = this.responseType;
233
+ try {
234
+ // xhr.send(); throws "Not enough arguments" in Firefox 3.0
235
+ xhr.send(undefined);
236
+ } catch (error1) {
237
+ // Safari 5.1.7, Opera 12
238
+ throw error1;
239
+ }
240
+ };
241
+
242
+ function XHRTransport(xhr) {
243
+ this._xhr = new XHRWrapper(xhr);
244
+ }
245
+
246
+ XHRTransport.prototype.open = function (onStartCallback, onProgressCallback, onFinishCallback, url, withCredentials, headers) {
247
+ var xhr = this._xhr;
248
+ xhr.open("GET", url);
249
+ var offset = 0;
250
+ xhr.onprogress = function () {
251
+ var responseText = xhr.responseText;
252
+ var chunk = responseText.slice(offset);
253
+ offset += chunk.length;
254
+ onProgressCallback(chunk);
255
+ };
256
+ xhr.onreadystatechange = function () {
257
+ if (xhr.readyState === 2) {
258
+ var status = xhr.status;
259
+ var statusText = xhr.statusText;
260
+ var contentType = xhr.getResponseHeader("Content-Type");
261
+ onStartCallback(status, statusText, contentType);
262
+ } else if (xhr.readyState === 4) {
263
+ onFinishCallback();
264
+ }
265
+ };
266
+ xhr.withCredentials = withCredentials;
267
+ xhr.responseType = "text";
268
+ for (var name in headers) {
269
+ if (Object.prototype.hasOwnProperty.call(headers, name)) {
270
+ xhr.setRequestHeader(name, headers[name]);
271
+ }
272
+ }
273
+ xhr.send();
274
+ };
275
+
276
+ XHRTransport.prototype.cancel = function () {
277
+ var xhr = this._xhr;
278
+ xhr.abort();
279
+ };
280
+
281
+ function EventTarget() {
282
+ this._listeners = Object.create(null);
283
+ }
284
+
285
+ function throwError(e) {
286
+ setTimeout(function () {
287
+ throw e;
288
+ }, 0);
289
+ }
290
+
291
+ EventTarget.prototype.dispatchEvent = function (event) {
292
+ event.target = this;
293
+ var typeListeners = this._listeners[event.type];
294
+ if (typeListeners != undefined) {
295
+ var length = typeListeners.length;
296
+ for (var i = 0; i < length; i += 1) {
297
+ var listener = typeListeners[i];
298
+ try {
299
+ if (typeof listener.handleEvent === "function") {
300
+ listener.handleEvent(event);
301
+ } else {
302
+ listener.call(this, event);
303
+ }
304
+ } catch (e) {
305
+ throwError(e);
306
+ }
307
+ }
308
+ }
309
+ };
310
+ EventTarget.prototype.addEventListener = function (type, listener) {
311
+ type = String(type);
312
+ var listeners = this._listeners;
313
+ var typeListeners = listeners[type];
314
+ if (typeListeners == undefined) {
315
+ typeListeners = [];
316
+ listeners[type] = typeListeners;
317
+ }
318
+ var found = false;
319
+ for (var i = 0; i < typeListeners.length; i += 1) {
320
+ if (typeListeners[i] === listener) {
321
+ found = true;
322
+ }
323
+ }
324
+ if (!found) {
325
+ typeListeners.push(listener);
326
+ }
327
+ };
328
+ EventTarget.prototype.removeEventListener = function (type, listener) {
329
+ type = String(type);
330
+ var listeners = this._listeners;
331
+ var typeListeners = listeners[type];
332
+ if (typeListeners != undefined) {
333
+ var filtered = [];
334
+ for (var i = 0; i < typeListeners.length; i += 1) {
335
+ if (typeListeners[i] !== listener) {
336
+ filtered.push(typeListeners[i]);
337
+ }
338
+ }
339
+ if (filtered.length === 0) {
340
+ delete listeners[type];
341
+ } else {
342
+ listeners[type] = filtered;
343
+ }
344
+ }
345
+ };
346
+
347
+ function Event(type) {
348
+ this.type = type;
349
+ this.target = undefined;
350
+ }
351
+
352
+ function MessageEvent(type, options) {
353
+ Event.call(this, type);
354
+ this.data = options.data;
355
+ this.lastEventId = options.lastEventId;
356
+ }
357
+
358
+ MessageEvent.prototype = Object.create(Event.prototype);
359
+
360
+ var WAITING = -1;
361
+ var CONNECTING = 0;
362
+ var OPEN = 1;
363
+ var CLOSED = 2;
364
+
365
+ var AFTER_CR = -1;
366
+ var FIELD_START = 0;
367
+ var FIELD = 1;
368
+ var VALUE_START = 2;
369
+ var VALUE = 3;
370
+
371
+ var contentTypeRegExp = /^text\/event\-stream;?(\s*charset\=utf\-8)?$/i;
372
+
373
+ var MINIMUM_DURATION = 1000;
374
+ var MAXIMUM_DURATION = 18000000;
375
+
376
+ var parseDuration = function (value, def) {
377
+ var n = parseInt(value, 10);
378
+ if (n !== n) {
379
+ n = def;
380
+ }
381
+ return clampDuration(n);
382
+ };
383
+ var clampDuration = function (n) {
384
+ return Math.min(Math.max(n, MINIMUM_DURATION), MAXIMUM_DURATION);
385
+ };
386
+
387
+ var fire = function (that, f, event) {
388
+ try {
389
+ if (typeof f === "function") {
390
+ f.call(that, event);
391
+ }
392
+ } catch (e) {
393
+ throwError(e);
394
+ }
395
+ };
396
+
397
+ function EventSourcePolyfill(url, options) {
398
+ EventTarget.call(this);
399
+
400
+ this.onopen = undefined;
401
+ this.onmessage = undefined;
402
+ this.onerror = undefined;
403
+
404
+ this.url = undefined;
405
+ this.readyState = undefined;
406
+ this.withCredentials = undefined;
407
+
408
+ this._close = undefined;
409
+
410
+ start(this, url, options);
411
+ }
412
+
413
+ function start(es, url, options) {
414
+ url = String(url);
415
+ var withCredentials = options != undefined && Boolean(options.withCredentials);
416
+
417
+ var initialRetry = clampDuration(1000);
418
+ var heartbeatTimeout = clampDuration(45000);
419
+
420
+ var lastEventId = "";
421
+ var retry = initialRetry;
422
+ var wasActivity = false;
423
+ var headers = options != undefined && options.headers != undefined ? JSON.parse(JSON.stringify(options.headers)) : undefined;
424
+ var CurrentTransport = options != undefined && options.Transport != undefined ? options.Transport : (XDomainRequest != undefined ? XDomainRequest : XMLHttpRequest);
425
+ var transport = new XHRTransport(new CurrentTransport());
426
+ var timeout = 0;
427
+ var currentState = WAITING;
428
+ var dataBuffer = "";
429
+ var lastEventIdBuffer = "";
430
+ var eventTypeBuffer = "";
431
+
432
+ var textBuffer = "";
433
+ var state = FIELD_START;
434
+ var fieldStart = 0;
435
+ var valueStart = 0;
436
+
437
+ var onStart = function (status, statusText, contentType) {
438
+ if (currentState === CONNECTING) {
439
+ if (status === 200 && contentType != undefined && contentTypeRegExp.test(contentType)) {
440
+ currentState = OPEN;
441
+ wasActivity = true;
442
+ retry = initialRetry;
443
+ es.readyState = OPEN;
444
+ var event = new Event("open");
445
+ es.dispatchEvent(event);
446
+ fire(es, es.onopen, event);
447
+ } else {
448
+ var message = "";
449
+ if (status !== 200) {
450
+ if (statusText) {
451
+ statusText = statusText.replace(/\s+/g, " ");
452
+ }
453
+ message = "EventSource's response has a status " + status + " " + statusText + " that is not 200. Aborting the connection.";
454
+ } else {
455
+ message = "EventSource's response has a Content-Type specifying an unsupported type: " + (contentType == undefined ? "-" : contentType.replace(/\s+/g, " ")) + ". Aborting the connection.";
456
+ }
457
+ throwError(new Error(message));
458
+ close();
459
+ var event = new Event("error");
460
+ es.dispatchEvent(event);
461
+ fire(es, es.onerror, event);
462
+ }
463
+ }
464
+ };
465
+
466
+ var onProgress = function (textChunk) {
467
+ if (currentState === OPEN) {
468
+ var n = -1;
469
+ for (var i = 0; i < textChunk.length; i += 1) {
470
+ var c = textChunk.charCodeAt(i);
471
+ if (c === "\n".charCodeAt(0) || c === "\r".charCodeAt(0)) {
472
+ n = i;
473
+ }
474
+ }
475
+ var chunk = (n !== -1 ? textBuffer : "") + textChunk.slice(0, n + 1);
476
+ textBuffer = (n === -1 ? textBuffer : "") + textChunk.slice(n + 1);
477
+ if (chunk !== "") {
478
+ wasActivity = true;
479
+ }
480
+ for (var position = 0; position < chunk.length; position += 1) {
481
+ var c = chunk.charCodeAt(position);
482
+ if (state === AFTER_CR && c === "\n".charCodeAt(0)) {
483
+ state = FIELD_START;
484
+ } else {
485
+ if (state === AFTER_CR) {
486
+ state = FIELD_START;
487
+ }
488
+ if (c === "\r".charCodeAt(0) || c === "\n".charCodeAt(0)) {
489
+ if (state !== FIELD_START) {
490
+ if (state === FIELD) {
491
+ valueStart = position + 1;
492
+ }
493
+ var field = chunk.slice(fieldStart, valueStart - 1);
494
+ var value = chunk.slice(valueStart + (valueStart < position && chunk.charCodeAt(valueStart) === " ".charCodeAt(0) ? 1 : 0), position);
495
+ if (field === "data") {
496
+ dataBuffer += "\n";
497
+ dataBuffer += value;
498
+ } else if (field === "id") {
499
+ lastEventIdBuffer = value;
500
+ } else if (field === "event") {
501
+ eventTypeBuffer = value;
502
+ } else if (field === "retry") {
503
+ initialRetry = parseDuration(value, initialRetry);
504
+ retry = initialRetry;
505
+ } else if (field === "heartbeatTimeout") {
506
+ heartbeatTimeout = parseDuration(value, heartbeatTimeout);
507
+ if (timeout !== 0) {
508
+ clearTimeout(timeout);
509
+ timeout = setTimeout(function () {
510
+ onTimeout();
511
+ }, heartbeatTimeout);
512
+ }
513
+ }
514
+ }
515
+ if (state === FIELD_START) {
516
+ if (dataBuffer !== "") {
517
+ lastEventId = lastEventIdBuffer;
518
+ if (eventTypeBuffer === "") {
519
+ eventTypeBuffer = "message";
520
+ }
521
+ var event = new MessageEvent(eventTypeBuffer, {
522
+ data: dataBuffer.slice(1),
523
+ lastEventId: lastEventIdBuffer
524
+ });
525
+ es.dispatchEvent(event);
526
+ if (eventTypeBuffer === "message") {
527
+ fire(es, es.onmessage, event);
528
+ }
529
+ if (currentState === CLOSED) {
530
+ return;
531
+ }
532
+ }
533
+ dataBuffer = "";
534
+ eventTypeBuffer = "";
535
+ }
536
+ state = c === "\r".charCodeAt(0) ? AFTER_CR : FIELD_START;
537
+ } else {
538
+ if (state === FIELD_START) {
539
+ fieldStart = position;
540
+ state = FIELD;
541
+ }
542
+ if (state === FIELD) {
543
+ if (c === ":".charCodeAt(0)) {
544
+ valueStart = position + 1;
545
+ state = VALUE_START;
546
+ }
547
+ } else if (state === VALUE_START) {
548
+ state = VALUE;
549
+ }
550
+ }
551
+ }
552
+ }
553
+ }
554
+ };
555
+
556
+ var onFinish = function () {
557
+ if (currentState === OPEN || currentState === CONNECTING) {
558
+ currentState = WAITING;
559
+ if (timeout !== 0) {
560
+ clearTimeout(timeout);
561
+ timeout = 0;
562
+ }
563
+ timeout = setTimeout(function () {
564
+ onTimeout();
565
+ }, retry);
566
+ retry = clampDuration(Math.min(initialRetry * 16, retry * 2));
567
+
568
+ es.readyState = CONNECTING;
569
+ var event = new Event("error");
570
+ es.dispatchEvent(event);
571
+ fire(es, es.onerror, event);
572
+ }
573
+ };
574
+
575
+ var close = function () {
576
+ currentState = CLOSED;
577
+ transport.cancel();
578
+ if (timeout !== 0) {
579
+ clearTimeout(timeout);
580
+ timeout = 0;
581
+ }
582
+ es.readyState = CLOSED;
583
+ };
584
+
585
+ var onTimeout = function () {
586
+ timeout = 0;
587
+
588
+ if (currentState !== WAITING) {
589
+ if (!wasActivity) {
590
+ throwError(new Error("No activity within " + heartbeatTimeout + " milliseconds. Reconnecting."));
591
+ transport.cancel();
592
+ } else {
593
+ wasActivity = false;
594
+ timeout = setTimeout(function () {
595
+ onTimeout();
596
+ }, heartbeatTimeout);
597
+ }
598
+ return;
599
+ }
600
+
601
+ wasActivity = false;
602
+ timeout = setTimeout(function () {
603
+ onTimeout();
604
+ }, heartbeatTimeout);
605
+
606
+ currentState = CONNECTING;
607
+ dataBuffer = "";
608
+ eventTypeBuffer = "";
609
+ lastEventIdBuffer = lastEventId;
610
+ textBuffer = "";
611
+ fieldStart = 0;
612
+ valueStart = 0;
613
+ state = FIELD_START;
614
+
615
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=428916
616
+ // Request header field Last-Event-ID is not allowed by Access-Control-Allow-Headers.
617
+ var requestURL = url;
618
+ if (url.slice(0, 5) !== "data:" &&
619
+ url.slice(0, 5) !== "blob:") {
620
+ requestURL = url + (url.indexOf("?", 0) === -1 ? "?" : "&") + "lastEventId=" + encodeURIComponent(lastEventId);
621
+ }
622
+ var requestHeaders = {};
623
+ requestHeaders["Accept"] = "text/event-stream";
624
+ if (headers != undefined) {
625
+ for (var name in headers) {
626
+ if (Object.prototype.hasOwnProperty.call(headers, name)) {
627
+ requestHeaders[name] = headers[name];
628
+ }
629
+ }
630
+ }
631
+ try {
632
+ transport.open(onStart, onProgress, onFinish, requestURL, withCredentials, requestHeaders);
633
+ } catch (error) {
634
+ close();
635
+ throw error;
636
+ }
637
+ };
638
+
639
+ es.url = url;
640
+ es.readyState = CONNECTING;
641
+ es.withCredentials = withCredentials;
642
+ es._close = close;
643
+
644
+ onTimeout();
645
+ }
646
+
647
+ EventSourcePolyfill.prototype = Object.create(EventTarget.prototype);
648
+ EventSourcePolyfill.prototype.CONNECTING = CONNECTING;
649
+ EventSourcePolyfill.prototype.OPEN = OPEN;
650
+ EventSourcePolyfill.prototype.CLOSED = CLOSED;
651
+ EventSourcePolyfill.prototype.close = function () {
652
+ this._close();
653
+ };
654
+
655
+ EventSourcePolyfill.CONNECTING = CONNECTING;
656
+ EventSourcePolyfill.OPEN = OPEN;
657
+ EventSourcePolyfill.CLOSED = CLOSED;
658
+ EventSourcePolyfill.prototype.withCredentials = undefined;
659
+
660
+ global.EventSourcePolyfill = EventSourcePolyfill;
661
+ global.NativeEventSource = NativeEventSource;
662
+
663
+ if (XMLHttpRequest != undefined && (NativeEventSource == undefined || !("withCredentials" in NativeEventSource.prototype))) {
664
+ // Why replace a native EventSource ?
665
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=444328
666
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=831392
667
+ // https://code.google.com/p/chromium/issues/detail?id=260144
668
+ // https://code.google.com/p/chromium/issues/detail?id=225654
669
+ // ...
670
+ global.EventSource = EventSourcePolyfill;
671
+ }
672
+
673
+ }(typeof window !== 'undefined' ? window : this));
inc/assets/js/eventsource.min.js ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ /** @license
2
+ * eventsource.js
3
+ * Available under MIT License (MIT)
4
+ * https://github.com/Yaffle/EventSource/
5
+ */
6
+ !function(a){"use strict";function b(a){this.withCredentials=!1,this.responseType="",this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=p,this.onreadystatechange=p,this._contentType="",this._xhr=a,this._sendTimeout=0,this._abort=p}function c(a){this._xhr=new b(a)}function d(){this._listeners=Object.create(null)}function e(a){j(function(){throw a},0)}function f(a){this.type=a,this.target=void 0}function g(a,b){f.call(this,a),this.data=b.data,this.lastEventId=b.lastEventId}function h(a,b){d.call(this),this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this._close=void 0,i(this,a,b)}function i(a,b,d){b=String(b);var h=void 0!=d&&Boolean(d.withCredentials),i=D(1e3),n=D(45e3),o="",p=i,A=!1,B=void 0!=d&&void 0!=d.headers?JSON.parse(JSON.stringify(d.headers)):void 0,F=void 0!=d&&void 0!=d.Transport?d.Transport:void 0!=m?m:l,G=new c(new F),H=0,I=q,J="",K="",L="",M="",N=v,O=0,P=0,Q=function(b,c,d){if(I===r)if(200===b&&void 0!=d&&z.test(d)){I=s,A=!0,p=i,a.readyState=s;var g=new f("open");a.dispatchEvent(g),E(a,a.onopen,g)}else{var h="";200!==b?(c&&(c=c.replace(/\s+/g," ")),h="EventSource's response has a status "+b+" "+c+" that is not 200. Aborting the connection."):h="EventSource's response has a Content-Type specifying an unsupported type: "+(void 0==d?"-":d.replace(/\s+/g," "))+". Aborting the connection.",e(new Error(h)),T();var g=new f("error");a.dispatchEvent(g),E(a,a.onerror,g)}},R=function(b){if(I===s){for(var c=-1,d=0;d<b.length;d+=1){var e=b.charCodeAt(d);(e==="\n".charCodeAt(0)||e==="\r".charCodeAt(0))&&(c=d)}var f=(-1!==c?M:"")+b.slice(0,c+1);M=(-1===c?M:"")+b.slice(c+1),""!==f&&(A=!0);for(var h=0;h<f.length;h+=1){var e=f.charCodeAt(h);if(N===u&&e==="\n".charCodeAt(0))N=v;else if(N===u&&(N=v),e==="\r".charCodeAt(0)||e==="\n".charCodeAt(0)){if(N!==v){N===w&&(P=h+1);var l=f.slice(O,P-1),m=f.slice(P+(h>P&&f.charCodeAt(P)===" ".charCodeAt(0)?1:0),h);"data"===l?(J+="\n",J+=m):"id"===l?K=m:"event"===l?L=m:"retry"===l?(i=C(m,i),p=i):"heartbeatTimeout"===l&&(n=C(m,n),0!==H&&(k(H),H=j(function(){U()},n)))}if(N===v){if(""!==J){o=K,""===L&&(L="message");var q=new g(L,{data:J.slice(1),lastEventId:K});if(a.dispatchEvent(q),"message"===L&&E(a,a.onmessage,q),I===t)return}J="",L=""}N=e==="\r".charCodeAt(0)?u:v}else N===v&&(O=h,N=w),N===w?e===":".charCodeAt(0)&&(P=h+1,N=x):N===x&&(N=y)}}},S=function(){if(I===s||I===r){I=q,0!==H&&(k(H),H=0),H=j(function(){U()},p),p=D(Math.min(16*i,2*p)),a.readyState=r;var b=new f("error");a.dispatchEvent(b),E(a,a.onerror,b)}},T=function(){I=t,G.cancel(),0!==H&&(k(H),H=0),a.readyState=t},U=function(){if(H=0,I!==q)return void(A?(A=!1,H=j(function(){U()},n)):(e(new Error("No activity within "+n+" milliseconds. Reconnecting.")),G.cancel()));A=!1,H=j(function(){U()},n),I=r,J="",L="",K=o,M="",O=0,P=0,N=v;var a=b;"data:"!==b.slice(0,5)&&"blob:"!==b.slice(0,5)&&(a=b+(-1===b.indexOf("?",0)?"?":"&")+"lastEventId="+encodeURIComponent(o));var c={};if(c.Accept="text/event-stream",void 0!=B)for(var d in B)Object.prototype.hasOwnProperty.call(B,d)&&(c[d]=B[d]);try{G.open(Q,R,S,a,h,c)}catch(f){throw T(),f}};a.url=b,a.readyState=r,a.withCredentials=h,a._close=T,U()}var j=a.setTimeout,k=a.clearTimeout,l=a.XMLHttpRequest,m=a.XDomainRequest,n=a.EventSource,o=a.document;null==Object.create&&(Object.create=function(a){function b(){}return b.prototype=a,new b});var p=function(){};b.prototype.open=function(a,b){this._abort(!0);var c=this,d=this._xhr,e=1,f=0;this._abort=function(a){0!==c._sendTimeout&&(k(c._sendTimeout),c._sendTimeout=0),(1===e||2===e||3===e)&&(e=4,d.onload=p,d.onerror=p,d.onabort=p,d.onprogress=p,d.onreadystatechange=p,d.abort(),0!==f&&(k(f),f=0),a||(c.readyState=4,c.onreadystatechange())),e=0};var g=function(){if(1===e){var a=0,b="",f=void 0;if("contentType"in d)a=200,b="OK",f=d.contentType;else try{a=d.status,b=d.statusText,f=d.getResponseHeader("Content-Type")}catch(g){a=0,b="",f=void 0}0!==a&&(e=2,c.readyState=2,c.status=a,c.statusText=b,c._contentType=f,c.onreadystatechange())}},h=function(){if(g(),2===e||3===e){e=3;var a="";try{a=d.responseText}catch(b){}c.readyState=3,c.responseText=a,c.onprogress()}},i=function(){h(),(1===e||2===e||3===e)&&(e=4,0!==f&&(k(f),f=0),c.readyState=4,c.onreadystatechange())},m=function(){void 0!=d&&(4===d.readyState?i():3===d.readyState?h():2===d.readyState&&g())},n=function(){f=j(function(){n()},500),3===d.readyState&&h()};d.onload=i,d.onerror=i,d.onabort=i,"sendAsBinary"in l.prototype||"mozAnon"in l.prototype||(d.onprogress=h),d.onreadystatechange=m,"contentType"in d&&(b+=(-1===b.indexOf("?",0)?"?":"&")+"padding=true"),d.open(a,b,!0),"readyState"in d&&(f=j(function(){n()},0))},b.prototype.abort=function(){this._abort(!1)},b.prototype.getResponseHeader=function(a){return this._contentType},b.prototype.setRequestHeader=function(a,b){var c=this._xhr;"setRequestHeader"in c&&c.setRequestHeader(a,b)},b.prototype.send=function(){if(!("ontimeout"in l.prototype)&&void 0!=o&&void 0!=o.readyState&&"complete"!==o.readyState){var a=this;return void(a._sendTimeout=j(function(){a._sendTimeout=0,a.send()},4))}var b=this._xhr;b.withCredentials=this.withCredentials,b.responseType=this.responseType;try{b.send(void 0)}catch(c){throw c}},c.prototype.open=function(a,b,c,d,e,f){var g=this._xhr;g.open("GET",d);var h=0;g.onprogress=function(){var a=g.responseText,c=a.slice(h);h+=c.length,b(c)},g.onreadystatechange=function(){if(2===g.readyState){var b=g.status,d=g.statusText,e=g.getResponseHeader("Content-Type");a(b,d,e)}else 4===g.readyState&&c()},g.withCredentials=e,g.responseType="text";for(var i in f)Object.prototype.hasOwnProperty.call(f,i)&&g.setRequestHeader(i,f[i]);g.send()},c.prototype.cancel=function(){var a=this._xhr;a.abort()},d.prototype.dispatchEvent=function(a){a.target=this;var b=this._listeners[a.type];if(void 0!=b)for(var c=b.length,d=0;c>d;d+=1){var f=b[d];try{"function"==typeof f.handleEvent?f.handleEvent(a):f.call(this,a)}catch(g){e(g)}}},d.prototype.addEventListener=function(a,b){a=String(a);var c=this._listeners,d=c[a];void 0==d&&(d=[],c[a]=d);for(var e=!1,f=0;f<d.length;f+=1)d[f]===b&&(e=!0);e||d.push(b)},d.prototype.removeEventListener=function(a,b){a=String(a);var c=this._listeners,d=c[a];if(void 0!=d){for(var e=[],f=0;f<d.length;f+=1)d[f]!==b&&e.push(d[f]);0===e.length?delete c[a]:c[a]=e}},g.prototype=Object.create(f.prototype);var q=-1,r=0,s=1,t=2,u=-1,v=0,w=1,x=2,y=3,z=/^text\/event\-stream;?(\s*charset\=utf\-8)?$/i,A=1e3,B=18e6,C=function(a,b){var c=parseInt(a,10);return c!==c&&(c=b),D(c)},D=function(a){return Math.min(Math.max(a,A),B)},E=function(a,b,c){try{"function"==typeof b&&b.call(a,c)}catch(d){e(d)}};h.prototype=Object.create(d.prototype),h.prototype.CONNECTING=r,h.prototype.OPEN=s,h.prototype.CLOSED=t,h.prototype.close=function(){this._close()},h.CONNECTING=r,h.OPEN=s,h.CLOSED=t,h.prototype.withCredentials=void 0,a.EventSourcePolyfill=h,a.NativeEventSource=n,void 0==l||void 0!=n&&"withCredentials"in n.prototype||(a.EventSource=h)}("undefined"!=typeof window?window:this);
inc/classes/class-astra-sites-importer-log.php ADDED
@@ -0,0 +1,494 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Astra Sites Importer Log
4
+ *
5
+ * @since 1.1.0
6
+ * @package Astra Sites
7
+ */
8
+
9
+ defined( 'ABSPATH' ) or exit;
10
+
11
+ if ( ! class_exists( 'Astra_Sites_Importer_Log' ) ) :
12
+
13
+ /**
14
+ * Astra Sites Importer
15
+ */
16
+ class Astra_Sites_Importer_Log {
17
+
18
+ /**
19
+ * Instance
20
+ *
21
+ * @since 1.1.0
22
+ * @var (Object) Class object
23
+ */
24
+ private static $_instance = null;
25
+
26
+ /**
27
+ * Log File
28
+ *
29
+ * @since 1.1.0
30
+ * @var (Object) Class object
31
+ */
32
+ private static $log_file = null;
33
+
34
+ /**
35
+ * Set Instance
36
+ *
37
+ * @since 1.1.0
38
+ *
39
+ * @return object Class object.
40
+ */
41
+ public static function get_instance() {
42
+ if ( ! isset( self::$_instance ) ) {
43
+ self::$_instance = new self;
44
+ }
45
+
46
+ return self::$_instance;
47
+ }
48
+
49
+ /**
50
+ * Constructor.
51
+ *
52
+ * @since 1.1.0
53
+ */
54
+ private function __construct() {
55
+
56
+ // Check file read/write permissions.
57
+ add_action( 'admin_init', array( $this, 'has_file_read_write' ) );
58
+
59
+ }
60
+
61
+ /**
62
+ * Check file read/write permissions and process.
63
+ *
64
+ * @since 1.1.0
65
+ * @return null
66
+ */
67
+ function has_file_read_write() {
68
+
69
+ // Get user credentials for WP file-system API.
70
+ $astra_sites_import = wp_nonce_url( admin_url( 'themes.php?page=astra-sites' ), 'astra-import' );
71
+ if ( false === ( $creds = request_filesystem_credentials( $astra_sites_import, '', false, false, null ) ) ) {
72
+ return;
73
+ }
74
+
75
+ // Set log file.
76
+ self::set_log_file();
77
+
78
+ // Initial AJAX Import Hooks.
79
+ add_action( 'astra_sites_import_start', array( $this, 'start' ), 10, 2 );
80
+ add_action( 'astra_sites_import_customizer_settings', array( $this, 'start_customizer' ) );
81
+ add_action( 'astra_sites_import_prepare_xml_data', array( $this, 'start_xml' ) );
82
+ add_action( 'astra_sites_import_options', array( $this, 'start_options' ) );
83
+ add_action( 'astra_sites_import_widgets', array( $this, 'start_widgets' ) );
84
+ add_action( 'astra_sites_import_complete', array( $this, 'start_end' ) );
85
+
86
+ // Hooks in between the process of import.
87
+ add_filter( 'wie_import_results', array( $this, 'widgets_data' ) );
88
+ add_action( 'astra_sites_import_xml_log', array( $this, 'xml_log' ), 10, 3 );
89
+ }
90
+
91
+ /**
92
+ * Add log file URL in UI response.
93
+ *
94
+ * @since 1.1.0
95
+ */
96
+ public static function add_log_file_url() {
97
+
98
+ $upload_dir = self::log_dir();
99
+ $upload_path = trailingslashit( $upload_dir['url'] );
100
+ $file_abs_url = get_option( 'astra_sites_recent_import_log_file', self::$log_file );
101
+ $file_url = $upload_path . basename( $file_abs_url );
102
+
103
+ return array(
104
+ 'abs_url' => $file_abs_url,
105
+ 'url' => $file_url,
106
+ );
107
+ }
108
+
109
+ /**
110
+ * XML Log.
111
+ *
112
+ * @since 1.1.0
113
+ * @param string $level Level (Debug, Info etc.).
114
+ * @param string $message Message.
115
+ * @param string $context Context.
116
+ * @return void
117
+ */
118
+ function xml_log( $level = '', $message = '', $context = '' ) {
119
+ Astra_Sites_Importer_Log::add( $message );
120
+ }
121
+
122
+ /**
123
+ * Current Time for log.
124
+ *
125
+ * @since 1.1.0
126
+ * @return string Current time with time zone.
127
+ */
128
+ public static function current_time() {
129
+ return date( 'H:i:s' ) . ' ' . date_default_timezone_get();
130
+ }
131
+
132
+ /**
133
+ * Import Start
134
+ *
135
+ * @since 1.1.0
136
+ * @param array $data Import Data.
137
+ * @param string $demo_api_uri Import site API URL.
138
+ * @return void
139
+ */
140
+ function start( $data = array(), $demo_api_uri = '' ) {
141
+
142
+ Astra_Sites_Importer_Log::add( '# System Details: ' );
143
+ Astra_Sites_Importer_Log::add( "Debug Mode \t\t: " . self::get_debug_mode() );
144
+ Astra_Sites_Importer_Log::add( "Operating System \t: " . self::get_os() );
145
+ Astra_Sites_Importer_Log::add( "Software \t\t: " . self::get_software() );
146
+ Astra_Sites_Importer_Log::add( "MySQL version \t\t: " . self::get_mysql_version() );
147
+ Astra_Sites_Importer_Log::add( "PHP Version \t\t: " . self::get_php_version() );
148
+ Astra_Sites_Importer_Log::add( "PHP Max Input Vars \t: " . self::get_php_max_input_vars() );
149
+ Astra_Sites_Importer_Log::add( "PHP Max Post Size \t: " . self::get_php_max_post_size() );
150
+ Astra_Sites_Importer_Log::add( "PHP Extension GD \t: " . self::get_php_extension_gd() );
151
+ Astra_Sites_Importer_Log::add( "PHP Max Execution Time \t: " . self::get_max_execution_time() );
152
+ Astra_Sites_Importer_Log::add( "Max Upload Size \t: " . size_format( wp_max_upload_size() ) );
153
+ Astra_Sites_Importer_Log::add( "Memory Limit \t\t: " . self::get_memory_limit() );
154
+ Astra_Sites_Importer_Log::add( "Timezone \t\t: " . self::get_timezone() );
155
+ Astra_Sites_Importer_Log::add( PHP_EOL . '-----' . PHP_EOL );
156
+ Astra_Sites_Importer_Log::add( 'Importing Started! - ' . self::current_time() );
157
+
158
+ Astra_Sites_Importer_Log::add( '---' . PHP_EOL );
159
+ Astra_Sites_Importer_Log::add( 'WHY IMPORT PROCESS CAN FAIL? READ THIS - ' );
160
+ Astra_Sites_Importer_Log::add( 'https://wpastra.com/docs/?p=1314&utm_source=demo-import-panel&utm_campaign=import-error&utm_medium=wp-dashboard' . PHP_EOL );
161
+ Astra_Sites_Importer_Log::add( '---' . PHP_EOL );
162
+
163
+ }
164
+
165
+ /**
166
+ * Start Customizer Import
167
+ *
168
+ * @since 1.1.0
169
+ * @return void
170
+ */
171
+ function start_customizer() {
172
+ Astra_Sites_Importer_Log::add( PHP_EOL . '1. Imported "Customizer Settings" - ' . self::current_time() );
173
+ Astra_Sites_Importer_Log::add( PHP_EOL . '---' );
174
+ }
175
+
176
+ /**
177
+ * Start XML Import
178
+ *
179
+ * @since 1.1.0
180
+ * @return void
181
+ */
182
+ function start_xml() {
183
+ Astra_Sites_Importer_Log::add( PHP_EOL . '2. Importing "XML" - ' . self::current_time() );
184
+ }
185
+
186
+ /**
187
+ * Start Options Import
188
+ *
189
+ * @since 1.1.0
190
+ * @return void
191
+ */
192
+ function start_options() {
193
+ Astra_Sites_Importer_Log::add( PHP_EOL . '---' );
194
+ Astra_Sites_Importer_Log::add( PHP_EOL . '3. Imported "Site Options" - ' . self::current_time() );
195
+ Astra_Sites_Importer_Log::add( PHP_EOL . '---' );
196
+ }
197
+
198
+ /**
199
+ * Start Widgets Import
200
+ *
201
+ * @since 1.1.0
202
+ * @return void
203
+ */
204
+ function start_widgets() {
205
+ Astra_Sites_Importer_Log::add( PHP_EOL . '4. Importing "Widgets" - ' . self::current_time() );
206
+ }
207
+
208
+ /**
209
+ * End Import Process
210
+ *
211
+ * @since 1.1.0
212
+ * @return void
213
+ */
214
+ function start_end() {
215
+ Astra_Sites_Importer_Log::add( PHP_EOL . '---' );
216
+ Astra_Sites_Importer_Log::add( PHP_EOL . 'Import Complete! - ' . self::current_time() );
217
+
218
+ // Delete Log file.
219
+ delete_option( 'astra_sites_recent_import_log_file' );
220
+ }
221
+
222
+ /**
223
+ * Log Widget Import Data.
224
+ *
225
+ * @since 1.1.0
226
+ * @param array $results Widget import info in array.
227
+ * @return void
228
+ */
229
+ function widgets_data( $results = array() ) {
230
+
231
+ if ( is_array( $results ) ) {
232
+ foreach ( $results as $sidebar_key => $widgets ) {
233
+ Astra_Sites_Importer_Log::add( 'Sidebar: ' . $sidebar_key );
234
+ foreach ( $widgets['widgets'] as $widget_key => $widget ) {
235
+ if ( isset( $widget['name'] ) && isset( $widget['message'] ) ) {
236
+ Astra_Sites_Importer_Log::add( 'Widget: "' . $widget['name'] . '" - ' . $widget['message'] );
237
+ }
238
+ }
239
+ }
240
+ }
241
+ }
242
+
243
+ /**
244
+ * Get an instance of WP_Filesystem_Direct.
245
+ *
246
+ * @since 1.1.0
247
+ * @return object A WP_Filesystem_Direct instance.
248
+ */
249
+ static public function get_filesystem() {
250
+ global $wp_filesystem;
251
+
252
+ require_once ABSPATH . '/wp-admin/includes/file.php';
253
+
254
+ WP_Filesystem();
255
+
256
+ return $wp_filesystem;
257
+ }
258
+
259
+ /**
260
+ * Get Log File
261
+ *
262
+ * @since 1.1.0
263
+ * @return string log file URL.
264
+ */
265
+ public static function get_log_file() {
266
+ return self::$log_file;
267
+ }
268
+
269
+ /**
270
+ * Log file directory
271
+ *
272
+ * @since 1.1.0
273
+ * @param string $dir_name Directory Name.
274
+ * @return array Uploads directory array.
275
+ */
276
+ public static function log_dir( $dir_name = 'astra-sites' ) {
277
+
278
+ $upload_dir = wp_upload_dir();
279
+
280
+ // Build the paths.
281
+ $dir_info = array(
282
+ 'path' => $upload_dir['basedir'] . '/' . $dir_name . '/',
283
+ 'url' => $upload_dir['baseurl'] . '/' . $dir_name . '/',
284
+ );
285
+
286
+ // Create the upload dir if it doesn't exist.
287
+ if ( ! file_exists( $dir_info['path'] ) ) {
288
+
289
+ // Create the directory.
290
+ mkdir( $dir_info['path'] );
291
+
292
+ // Add an index file for security.
293
+ file_put_contents( $dir_info['path'] . 'index.html', '' );
294
+ }
295
+
296
+ return $dir_info;
297
+ }
298
+
299
+ /**
300
+ * Set log file
301
+ *
302
+ * @since 1.1.0
303
+ */
304
+ public static function set_log_file() {
305
+
306
+ $upload_dir = self::log_dir();
307
+
308
+ $upload_path = trailingslashit( $upload_dir['path'] );
309
+
310
+ // File format e.g. 'import-31-Oct-2017-06-39-12.txt'.
311
+ self::$log_file = $upload_path . 'import-' . date( 'd-M-Y-h-i-s' ) . '.txt';
312
+
313
+ if ( ! get_option( 'astra_sites_recent_import_log_file', false ) ) {
314
+ update_option( 'astra_sites_recent_import_log_file', self::$log_file );
315
+ }
316
+ }
317
+
318
+ /**
319
+ * Write content to a file.
320
+ *
321
+ * @since 1.1.0
322
+ * @param string $content content to be saved to the file.
323
+ */
324
+ public static function add( $content ) {
325
+
326
+ if ( get_option( 'astra_sites_recent_import_log_file', false ) ) {
327
+ $log_file = get_option( 'astra_sites_recent_import_log_file', self::$log_file );
328
+ } else {
329
+ $log_file = self::$log_file;
330
+ }
331
+
332
+ $existing_data = '';
333
+ if ( file_exists( $log_file ) ) {
334
+ $existing_data = self::get_filesystem()->get_contents( $log_file );
335
+ }
336
+
337
+ // Style separator.
338
+ $separator = PHP_EOL;
339
+
340
+ self::get_filesystem()->put_contents( $log_file, $existing_data . $separator . $content, FS_CHMOD_FILE );
341
+ }
342
+
343
+ /**
344
+ * Debug Mode
345
+ *
346
+ * @since 1.1.0
347
+ * @return string Enabled for Debug mode ON and Disabled for Debug mode Off.
348
+ */
349
+ public static function get_debug_mode() {
350
+ if ( WP_DEBUG ) {
351
+ return __( 'Enabled', 'astra-sites' );
352
+ }
353
+
354
+ return __( 'Disabled', 'astra-sites' );
355
+ }
356
+
357
+ /**
358
+ * Memory Limit
359
+ *
360
+ * @since 1.1.0
361
+ * @return string Memory limit.
362
+ */
363
+ public static function get_memory_limit() {
364
+
365
+ $required_memory = '64M';
366
+ $memory_limit_in_bytes_current = wp_convert_hr_to_bytes( WP_MEMORY_LIMIT );
367
+ $memory_limit_in_bytes_required = wp_convert_hr_to_bytes( $required_memory );
368
+
369
+ if ( $memory_limit_in_bytes_current < $memory_limit_in_bytes_required ) {
370
+ return sprintf(
371
+ /* translators: %1$s Memory Limit, %2$s Recommended memory limit. */
372
+ _x( 'Current memory limit %1$s. We recommend setting memory to at least %2$s.', 'Recommended Memory Limit', 'astra-sites' ),
373
+ WP_MEMORY_LIMIT,
374
+ $required_memory
375
+ );
376
+ }
377
+
378
+ return WP_MEMORY_LIMIT;
379
+ }
380
+
381
+ /**
382
+ * Timezone
383
+ *
384
+ * @since 1.1.0
385
+ * @see https://codex.wordpress.org/Option_Reference/
386
+ *
387
+ * @return string Current timezone.
388
+ */
389
+ public static function get_timezone() {
390
+ $timezone = get_option( 'timezone_string' );
391
+
392
+ if ( ! $timezone ) {
393
+ return get_option( 'gmt_offset' );
394
+ }
395
+
396
+ return $timezone;
397
+ }
398
+
399
+ /**
400
+ * Operating System
401
+ *
402
+ * @since 1.1.0
403
+ * @return string Current Operating System.
404
+ */
405
+ public static function get_os() {
406
+ return PHP_OS;
407
+ }
408
+
409
+ /**
410
+ * Server Software
411
+ *
412
+ * @since 1.1.0
413
+ * @return string Current Server Software.
414
+ */
415
+ public static function get_software() {
416
+ return $_SERVER['SERVER_SOFTWARE'];
417
+ }
418
+
419
+ /**
420
+ * MySql Version
421
+ *
422
+ * @since 1.1.0
423
+ * @return string Current MySql Version.
424
+ */
425
+ public static function get_mysql_version() {
426
+ global $wpdb;
427
+ return $wpdb->db_version();
428
+ }
429
+
430
+ /**
431
+ * PHP Version
432
+ *
433
+ * @since 1.1.0
434
+ * @return string Current PHP Version.
435
+ */
436
+ public static function get_php_version() {
437
+ if ( version_compare( PHP_VERSION, '5.4', '<' ) ) {
438
+ return _x( 'We recommend to use php 5.4 or higher', 'PHP Version', 'astra-sites' );
439
+ }
440
+ return PHP_VERSION;
441
+ }
442
+
443
+ /**
444
+ * PHP Max Input Vars
445
+ *
446
+ * @since 1.1.0
447
+ * @return string Current PHP Max Input Vars
448
+ */
449
+ public static function get_php_max_input_vars() {
450
+ return ini_get( 'max_input_vars' );
451
+ }
452
+
453
+ /**
454
+ * PHP Max Post Size
455
+ *
456
+ * @since 1.1.0
457
+ * @return string Current PHP Max Post Size
458
+ */
459
+ public static function get_php_max_post_size() {
460
+ return ini_get( 'post_max_size' );
461
+ }
462
+
463
+ /**
464
+ * PHP Max Execution Time
465
+ *
466
+ * @since 1.1.0
467
+ * @return string Current Max Execution Time
468
+ */
469
+ public static function get_max_execution_time() {
470
+ return ini_get( 'max_execution_time' );
471
+ }
472
+
473
+ /**
474
+ * PHP GD Extension
475
+ *
476
+ * @since 1.1.0
477
+ * @return string Current PHP GD Extension
478
+ */
479
+ public static function get_php_extension_gd() {
480
+ if ( extension_loaded( 'gd' ) ) {
481
+ return __( 'Yes', 'astra-sites' );
482
+ }
483
+
484
+ return __( 'No', 'astra-sites' );
485
+ }
486
+
487
+ }
488
+
489
+ /**
490
+ * Kicking this off by calling 'get_instance()' method
491
+ */
492
+ Astra_Sites_Importer_Log::get_instance();
493
+
494
+ endif;
inc/classes/class-astra-sites-importer.php CHANGED
@@ -21,7 +21,7 @@ if ( ! class_exists( 'Astra_Sites_Importer' ) ) :
21
  * @since 1.0.0
22
  * @var (Object) Class object
23
  */
24
- private static $_instance = null;
25
 
26
  /**
27
  * Set Instance
@@ -43,7 +43,9 @@ if ( ! class_exists( 'Astra_Sites_Importer' ) ) :
43
  *
44
  * @since 1.0.0
45
  */
46
- private function __construct() {
 
 
47
 
48
  require_once ASTRA_SITES_DIR . 'inc/importers/class-astra-sites-helper.php';
49
  require_once ASTRA_SITES_DIR . 'inc/importers/class-widgets-importer.php';
@@ -51,154 +53,166 @@ if ( ! class_exists( 'Astra_Sites_Importer' ) ) :
51
  require_once ASTRA_SITES_DIR . 'inc/importers/wxr-importer/class-astra-wxr-importer.php';
52
  require_once ASTRA_SITES_DIR . 'inc/importers/class-astra-site-options-import.php';
53
 
 
 
 
 
 
 
 
 
 
 
 
54
  require_once ASTRA_SITES_DIR . 'inc/importers/batch-processing/class-astra-sites-batch-processing.php';
55
 
56
- add_action( 'wp_ajax_astra-import-demo', array( $this, 'demo_ajax_import' ) );
57
  add_action( 'astra_sites_image_import_complete', array( $this, 'clear_cache' ) );
58
 
59
  }
60
 
61
  /**
62
- * Ajax callback for demo import action.
63
  *
64
- * @since 1.0.0
 
65
  */
66
- public function demo_ajax_import() {
67
-
68
- $report = array(
69
- 'success' => false,
70
- 'message' => '',
71
- );
72
 
73
  if ( ! current_user_can( 'customize' ) ) {
74
- $report['message'] = __( 'You have not "customize" access to import the astra site.', 'astra-sites' );
75
- wp_send_json( $report );
76
  }
77
 
78
  $demo_api_uri = isset( $_POST['api_url'] ) ? esc_url( $_POST['api_url'] ) : '';
79
- $this->import_demo( $demo_api_uri );
80
 
81
- $report['success'] = true;
82
- $report['message'] = __( 'Demo Imported Successfully.', 'astra-sites' );
83
- wp_send_json( $report );
84
 
85
- }
86
 
 
 
 
 
 
 
87
 
88
- /**
89
- * Import the demo.
90
- *
91
- * @since 1.0.0
92
- *
93
- * @param (String) $demo_api_uri API URL for the single demo.
94
- */
95
- public function import_demo( $demo_api_uri ) {
96
 
97
- $demo_data = self::get_astra_single_demo( $demo_api_uri );
 
 
98
 
99
- // Import Enabled Extensions.
100
- $this->import_astra_enabled_extension( $demo_data['astra-enabled-extensions'] );
101
 
102
- // Import Customizer Settings.
103
- $this->import_customizer_settings( $demo_data['astra-site-customizer-data'] );
 
 
 
 
 
104
 
105
- // Import XML.
106
- $this->import_wxr( $demo_data['astra-site-wxr-path'] );
107
 
108
- // Import WordPress site options.
109
- $this->import_site_options( $demo_data['astra-site-options-data'] );
110
 
111
- // Import Custom 404 extension options.
112
- $this->import_custom_404_extension_options( $demo_data['astra-custom-404'] );
113
 
114
- // Import Widgets data.
115
- $this->import_widgets( $demo_data['astra-site-widgets-data'] );
116
 
117
- // Clear Cache.
118
- $this->clear_cache();
 
119
 
120
- do_action( 'astra_sites_import_complete', $demo_data );
121
  }
122
 
123
  /**
124
- * Import widgets and assign to correct sidebars.
125
- *
126
- * @since 1.0.0
127
  *
128
- * @param (Object) $data Widgets data.
 
129
  */
130
- public function import_widgets( $data ) {
131
 
132
- // bail if widgets data is not available.
133
- if ( null == $data ) {
134
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  }
136
 
137
- $widgets_importer = Astra_Widget_Importer::instance();
138
- $widgets_importer->import_widgets_data( $data );
139
  }
140
 
141
  /**
142
- * Import custom 404 section.
143
- *
144
- * @since 1.0.0
145
  *
146
- * @param (Array) $options_404 404 Extensions settings from the demo.
 
147
  */
148
- public function import_custom_404_extension_options( $options_404 ) {
149
- if ( is_callable( 'Astra_Admin_Helper::update_admin_settings_option' ) ) {
150
- Astra_Admin_Helper::update_admin_settings_option( '_astra_ext_custom_404', $options_404 );
 
 
 
 
 
 
 
 
 
151
  }
152
- }
153
 
154
- /**
155
- * Import site options - Front Page, Menus, Blog page etc.
156
- *
157
- * @since 1.0.0
158
- *
159
- * @param (Array) $options Array of required site options from the demo.
160
- */
161
- public function import_site_options( $options ) {
162
- $options_importer = Astra_Site_Options_Import::instance();
163
- $options_importer->import_options( $options );
164
  }
165
 
166
  /**
167
- * Download and import the XML from the demo.
168
- *
169
- * @since 1.0.0
170
  *
171
- * @param (String) $wxr_url URL of the xml export of the demo to be imported.
 
172
  */
173
- public function import_wxr( $wxr_url ) {
174
- $wxr_importer = Astra_WXR_Importer::instance();
175
- $xml_path = $wxr_importer->download_xml( $wxr_url );
176
- $wxr_importer->import_xml( $xml_path['file'] );
177
- }
 
 
 
 
 
 
 
 
178
 
179
- /**
180
- * Import Customizer data.
181
- *
182
- * @since 1.0.0
183
- *
184
- * @param (Array) $customizer_data Customizer data for the demo to be imported.
185
- */
186
- public function import_customizer_settings( $customizer_data ) {
187
- $customizer_import = Astra_Customizer_Import::instance();
188
- $customizer_data = $customizer_import->import( $customizer_data );
189
  }
190
 
191
  /**
192
- * Import settings enabled astra extensions from the demo.
193
  *
194
- * @since 1.0.0
195
- *
196
- * @param (Array) $saved_extensions Array of enabled extensions.
197
  */
198
- public function import_astra_enabled_extension( $saved_extensions ) {
199
- if ( is_callable( 'Astra_Admin_Helper::update_admin_settings_option' ) ) {
200
- Astra_Admin_Helper::update_admin_settings_option( '_astra_ext_enabled_extensions', $saved_extensions );
201
- }
202
  }
203
 
204
  /**
@@ -244,20 +258,27 @@ if ( ! class_exists( 'Astra_Sites_Importer' ) ) :
244
  // API Call.
245
  $response = wp_remote_get( $demo_api_uri, $api_args );
246
 
247
- if ( ! is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) === 200 ) {
248
-
249
- $result = json_decode( wp_remote_retrieve_body( $response ), true );
250
-
251
- if ( ! isset( $result['code'] ) ) {
252
- $remote_args['id'] = $result['id'];
253
- $remote_args['astra-site-widgets-data'] = json_decode( $result['astra-site-widgets-data'] );
254
- $remote_args['astra-site-customizer-data'] = $result['astra-site-customizer-data'];
255
- $remote_args['astra-site-options-data'] = $result['astra-site-options-data'];
256
- $remote_args['astra-site-wxr-path'] = $result['astra-site-wxr-path'];
257
- $remote_args['astra-enabled-extensions'] = $result['astra-enabled-extensions'];
258
- $remote_args['astra-custom-404'] = $result['astra-custom-404'];
259
- $remote_args['required-plugins'] = $result['required-plugins'];
260
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
  }
262
 
263
  // Merge remote demo and defaults.
21
  * @since 1.0.0
22
  * @var (Object) Class object
23
  */
24
+ public static $_instance = null;
25
 
26
  /**
27
  * Set Instance
43
  *
44
  * @since 1.0.0
45
  */
46
+ public function __construct() {
47
+
48
+ require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-importer-log.php';
49
 
50
  require_once ASTRA_SITES_DIR . 'inc/importers/class-astra-sites-helper.php';
51
  require_once ASTRA_SITES_DIR . 'inc/importers/class-widgets-importer.php';
53
  require_once ASTRA_SITES_DIR . 'inc/importers/wxr-importer/class-astra-wxr-importer.php';
54
  require_once ASTRA_SITES_DIR . 'inc/importers/class-astra-site-options-import.php';
55
 
56
+ // Import AJAX.
57
+ add_action( 'wp_ajax_astra-sites-import-set-site-data', array( $this, 'import_start' ) );
58
+ add_action( 'wp_ajax_astra-sites-import-customizer-settings', array( $this, 'import_customizer_settings' ) );
59
+ add_action( 'wp_ajax_astra-sites-import-prepare-xml', array( $this, 'prepare_xml_data' ) );
60
+ add_action( 'wp_ajax_astra-sites-import-options', array( $this, 'import_options' ) );
61
+ add_action( 'wp_ajax_astra-sites-import-widgets', array( $this, 'import_widgets' ) );
62
+ add_action( 'wp_ajax_astra-sites-import-end', array( $this, 'import_end' ) );
63
+
64
+ // Hooks in AJAX.
65
+ add_action( 'astra_sites_import_complete', array( $this, 'clear_cache' ) );
66
+
67
  require_once ASTRA_SITES_DIR . 'inc/importers/batch-processing/class-astra-sites-batch-processing.php';
68
 
 
69
  add_action( 'astra_sites_image_import_complete', array( $this, 'clear_cache' ) );
70
 
71
  }
72
 
73
  /**
74
+ * Start Site Import
75
  *
76
+ * @since 1.1.0
77
+ * @return void
78
  */
79
+ function import_start() {
 
 
 
 
 
80
 
81
  if ( ! current_user_can( 'customize' ) ) {
82
+ wp_send_json_error( __( 'You have not "customize" access to import the Astra site.', 'astra-sites' ) );
 
83
  }
84
 
85
  $demo_api_uri = isset( $_POST['api_url'] ) ? esc_url( $_POST['api_url'] ) : '';
 
86
 
87
+ if ( ! empty( $demo_api_uri ) ) {
 
 
88
 
89
+ $demo_data = self::get_astra_single_demo( $demo_api_uri );
90
 
91
+ if ( is_wp_error( $demo_data ) ) {
92
+ wp_send_json_error( $demo_data->get_error_message() );
93
+ } else {
94
+ $demo_data['log_file'] = Astra_Sites_Importer_Log::add_log_file_url();
95
+ do_action( 'astra_sites_import_start', $demo_data, $demo_api_uri );
96
+ }
97
 
98
+ wp_send_json_success( $demo_data );
 
 
 
 
 
 
 
99
 
100
+ } else {
101
+ wp_send_json_error( __( 'Request site API URL is empty. Try again!', 'astra-sites' ) );
102
+ }
103
 
104
+ }
 
105
 
106
+ /**
107
+ * Import Customizer Settings.
108
+ *
109
+ * @since 1.0.14
110
+ * @return void
111
+ */
112
+ function import_customizer_settings() {
113
 
114
+ do_action( 'astra_sites_import_customizer_settings' );
 
115
 
116
+ $customizer_data = ( isset( $_POST['customizer_data'] ) ) ? (array) json_decode( stripcslashes( $_POST['customizer_data'] ), 1 ) : '';
 
117
 
118
+ if ( isset( $customizer_data ) ) {
 
119
 
120
+ Astra_Customizer_Import::instance()->import( $customizer_data );
121
+ wp_send_json_success( $customizer_data );
122
 
123
+ } else {
124
+ wp_send_json_error( __( 'Customizer data is empty!', 'astra-sites' ) );
125
+ }
126
 
 
127
  }
128
 
129
  /**
130
+ * Prepare XML Data.
 
 
131
  *
132
+ * @since 1.1.0
133
+ * @return void
134
  */
135
+ function prepare_xml_data() {
136
 
137
+ do_action( 'astra_sites_import_prepare_xml_data' );
138
+
139
+ $wxr_url = ( isset( $_REQUEST['wxr_url'] ) ) ? urldecode( $_REQUEST['wxr_url'] ) : '';
140
+
141
+ if ( isset( $wxr_url ) ) {
142
+
143
+ // Download XML file.
144
+ $xml_path = Astra_Sites_Helper::download_file( $wxr_url );
145
+
146
+ if ( $xml_path['success'] ) {
147
+
148
+ if ( isset( $xml_path['data']['file'] ) ) {
149
+ $data = Astra_WXR_Importer::instance()->get_xml_data( $xml_path['data']['file'] );
150
+ $data['xml'] = $xml_path['data'];
151
+ wp_send_json_success( $data );
152
+ } else {
153
+ wp_send_json_error( __( 'There was an error downloading the XML file.', 'astra-sites' ) );
154
+ }
155
+ } else {
156
+ wp_send_json_error( $xml_path['data'] );
157
+ }
158
+ } else {
159
+ wp_send_json_error( __( 'Invalid site XML file!', 'astra-sites' ) );
160
  }
161
 
 
 
162
  }
163
 
164
  /**
165
+ * Import Options.
 
 
166
  *
167
+ * @since 1.0.14
168
+ * @return void
169
  */
170
+ function import_options() {
171
+
172
+ do_action( 'astra_sites_import_options' );
173
+
174
+ $options_data = ( isset( $_POST['options_data'] ) ) ? (array) json_decode( stripcslashes( $_POST['options_data'] ), 1 ) : '';
175
+
176
+ if ( isset( $options_data ) ) {
177
+ $options_importer = Astra_Site_Options_Import::instance();
178
+ $options_importer->import_options( $options_data );
179
+ wp_send_json_success( $options_data );
180
+ } else {
181
+ wp_send_json_error( __( 'Site options are empty!', 'astra-sites' ) );
182
  }
 
183
 
 
 
 
 
 
 
 
 
 
 
184
  }
185
 
186
  /**
187
+ * Import Widgets.
 
 
188
  *
189
+ * @since 1.0.14
190
+ * @return void
191
  */
192
+ function import_widgets() {
193
+
194
+ do_action( 'astra_sites_import_widgets' );
195
+
196
+ $widgets_data = ( isset( $_POST['widgets_data'] ) ) ? (object) json_decode( stripcslashes( $_POST['widgets_data'] ) ) : '';
197
+
198
+ if ( isset( $widgets_data ) ) {
199
+ $widgets_importer = Astra_Widget_Importer::instance();
200
+ $status = $widgets_importer->import_widgets_data( $widgets_data );
201
+ wp_send_json_success( $widgets_data );
202
+ } else {
203
+ wp_send_json_error( __( 'Widget data is empty!', 'astra-sites' ) );
204
+ }
205
 
 
 
 
 
 
 
 
 
 
 
206
  }
207
 
208
  /**
209
+ * Import End.
210
  *
211
+ * @since 1.0.14
212
+ * @return void
 
213
  */
214
+ function import_end() {
215
+ do_action( 'astra_sites_import_complete' );
 
 
216
  }
217
 
218
  /**
258
  // API Call.
259
  $response = wp_remote_get( $demo_api_uri, $api_args );
260
 
261
+ if ( is_wp_error( $response ) || ( isset( $response->status ) && 0 == $response->status ) ) {
262
+ if ( isset( $response->status ) ) {
263
+ $data = json_decode( $response, true );
264
+ } else {
265
+ return new WP_Error( 'api_invalid_response_code', $response->get_error_message() );
 
 
 
 
 
 
 
 
266
  }
267
+ } else {
268
+ $data = json_decode( wp_remote_retrieve_body( $response ), true );
269
+ }
270
+
271
+ $data = json_decode( wp_remote_retrieve_body( $response ), true );
272
+
273
+ if ( ! isset( $data['code'] ) ) {
274
+ $remote_args['id'] = $data['id'];
275
+ $remote_args['astra-site-widgets-data'] = json_decode( $data['astra-site-widgets-data'] );
276
+ $remote_args['astra-site-customizer-data'] = $data['astra-site-customizer-data'];
277
+ $remote_args['astra-site-options-data'] = $data['astra-site-options-data'];
278
+ $remote_args['astra-site-wxr-path'] = $data['astra-site-wxr-path'];
279
+ $remote_args['astra-enabled-extensions'] = $data['astra-enabled-extensions'];
280
+ $remote_args['astra-custom-404'] = $data['astra-custom-404'];
281
+ $remote_args['required-plugins'] = $data['required-plugins'];
282
  }
283
 
284
  // Merge remote demo and defaults.
inc/classes/class-astra-sites-notices.php CHANGED
@@ -150,6 +150,8 @@ if ( ! class_exists( 'Astra_Sites_Notices' ) ) :
150
  }
151
 
152
  // Notice ID.
 
 
153
  if ( ! isset( $notice['id'] ) ) {
154
  $notice_id = 'astra-sites-notices-id-' . $key;
155
  $notice['id'] = $notice_id;
150
  }
151
 
152
  // Notice ID.
153
+ $notice_id = 'astra-sites-notices-id-' . $key;
154
+ $notice['id'] = $notice_id;
155
  if ( ! isset( $notice['id'] ) ) {
156
  $notice_id = 'astra-sites-notices-id-' . $key;
157
  $notice['id'] = $notice_id;
inc/classes/class-astra-sites.php CHANGED
@@ -151,6 +151,12 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
151
  return;
152
  }
153
 
 
 
 
 
 
 
154
  // API.
155
  wp_register_script( 'astra-sites-api', ASTRA_SITES_URI . 'inc/assets/js/astra-sites-api.js', array( 'jquery' ), ASTRA_SITES_VER, true );
156
 
@@ -198,6 +204,7 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
198
  $data = apply_filters(
199
  'astra_sites_localize_vars',
200
  array(
 
201
  'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
202
  'siteURL' => site_url(),
203
  'getProText' => __( 'Purchase', 'astra-sites' ),
@@ -213,14 +220,51 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
213
  'viewSite' => __( 'Done! View Site', 'astra-sites' ),
214
  'btnActivating' => __( 'Activating', 'astra-sites' ) . '&hellip;',
215
  'btnActive' => __( 'Active', 'astra-sites' ),
 
 
216
  'importDemo' => __( 'Import This Site', 'astra-sites' ),
217
- 'importingDemo' => __( 'Importing Demo', 'astra-sites' ),
218
  'DescExpand' => __( 'Read more', 'astra-sites' ) . '&hellip;',
219
  'DescCollapse' => __( 'Hide', 'astra-sites' ),
220
  'responseError' => __( 'There was a problem receiving a response from server.', 'astra-sites' ),
221
  'searchNoFound' => __( 'No Demos found, Try a different search.', 'astra-sites' ),
222
  'importWarning' => __( "Executing Demo Import will make your site similar as ours. Please bear in mind -\n\n1. It is recommended to run import on a fresh WordPress installation.\n\n2. Importing site does not delete any pages or posts. However, it can overwrite your existing content.\n\n3. Copyrighted media will not be imported. Instead it will be replaced with placeholders.", 'astra-sites' ),
223
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
  )
225
  );
226
 
151
  return;
152
  }
153
 
154
+ global $is_IE;
155
+
156
+ if ( $is_IE ) {
157
+ wp_enqueue_script( 'astra-sites-eventsource', ASTRA_SITES_URI . 'inc/assets/js/eventsource.min.js', array( 'jquery', 'wp-util', 'updates' ), ASTRA_SITES_VER, true );
158
+ }
159
+
160
  // API.
161
  wp_register_script( 'astra-sites-api', ASTRA_SITES_URI . 'inc/assets/js/astra-sites-api.js', array( 'jquery' ), ASTRA_SITES_VER, true );
162
 
204
  $data = apply_filters(
205
  'astra_sites_localize_vars',
206
  array(
207
+ 'debug' => ( ( defined( 'WP_DEBUG' ) && WP_DEBUG ) || isset( $_GET['debug'] ) ) ? true : false,
208
  'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
209
  'siteURL' => site_url(),
210
  'getProText' => __( 'Purchase', 'astra-sites' ),
220
  'viewSite' => __( 'Done! View Site', 'astra-sites' ),
221
  'btnActivating' => __( 'Activating', 'astra-sites' ) . '&hellip;',
222
  'btnActive' => __( 'Active', 'astra-sites' ),
223
+ 'importFailBtn' => __( 'Import failed.', 'astra-sites' ),
224
+ 'importFailBtnLarge' => __( 'Import failed. See error log.', 'astra-sites' ),
225
  'importDemo' => __( 'Import This Site', 'astra-sites' ),
226
+ 'importingDemo' => __( 'Importing..', 'astra-sites' ),
227
  'DescExpand' => __( 'Read more', 'astra-sites' ) . '&hellip;',
228
  'DescCollapse' => __( 'Hide', 'astra-sites' ),
229
  'responseError' => __( 'There was a problem receiving a response from server.', 'astra-sites' ),
230
  'searchNoFound' => __( 'No Demos found, Try a different search.', 'astra-sites' ),
231
  'importWarning' => __( "Executing Demo Import will make your site similar as ours. Please bear in mind -\n\n1. It is recommended to run import on a fresh WordPress installation.\n\n2. Importing site does not delete any pages or posts. However, it can overwrite your existing content.\n\n3. Copyrighted media will not be imported. Instead it will be replaced with placeholders.", 'astra-sites' ),
232
  ),
233
+ 'log' => array(
234
+ 'installingPlugin' => __( 'Installing plugin ', 'astra-sites' ),
235
+ 'installed' => __( 'Successfully plugin installed!', 'astra-sites' ),
236
+ 'installError' => __( 'There was an error while installing the plugin ', 'astra-sites' ),
237
+ 'activating' => __( 'Activating plugin ', 'astra-sites' ),
238
+ 'activated' => __( 'Successfully plugin activated ', 'astra-sites' ),
239
+ 'bulkActivation' => __( 'Bulk plugin activation...', 'astra-sites' ),
240
+ 'activate' => __( 'Successfully plugin activate - ', 'astra-sites' ),
241
+ 'activationError' => __( 'Error! While activating plugin - ', 'astra-sites' ),
242
+ 'bulkInstall' => __( 'Bulk plugin installation...', 'astra-sites' ),
243
+ 'api' => __( 'Site API ', 'astra-sites' ),
244
+ 'importing' => __( 'Importing..', 'astra-sites' ),
245
+ 'processingRequest' => __( 'Processing requests...', 'astra-sites' ),
246
+ 'importCustomizer' => __( '1) Importing "Customizer Settings"...', 'astra-sites' ),
247
+ 'importCustomizerSuccess' => __( 'Successfully imported customizer settings!', 'astra-sites' ),
248
+ 'importXMLPrepare' => __( '2) Preparing "XML" Data...', 'astra-sites' ),
249
+ 'importXMLPrepareSuccess' => __( 'Successfully set XML data!', 'astra-sites' ),
250
+ 'importXML' => __( '3) Importing "XML"...', 'astra-sites' ),
251
+ 'importXMLSuccess' => __( 'Successfully imported XML!', 'astra-sites' ),
252
+ 'importOptions' => __( '4) Importing "Options"...', 'astra-sites' ),
253
+ 'importOptionsSuccess' => __( 'Successfully imported Options!', 'astra-sites' ),
254
+ 'importWidgets' => __( '5) Importing "Widgets"...', 'astra-sites' ),
255
+ 'importWidgetsSuccess' => __( 'Successfully imported Widgets!', 'astra-sites' ),
256
+ 'serverConfiguration' => esc_url( 'https://wpastra.com/docs/?p=1314&utm_source=demo-import-panel&utm_campaign=import-error&utm_medium=wp-dashboard' ),
257
+ 'success' => __( 'Site imported successfully! visit : ', 'astra-sites' ),
258
+ 'gettingData' => __( 'Getting Site Information..', 'astra-sites' ),
259
+ 'importingCustomizer' => __( 'Importing Customizer Settings..', 'astra-sites' ),
260
+ 'importXMLPreparing' => __( 'Setting up import data..', 'astra-sites' ),
261
+ 'importingXML' => __( 'Importing Pages, Posts & Media..', 'astra-sites' ),
262
+ 'importingOptions' => __( 'Importing Site Options..', 'astra-sites' ),
263
+ 'importingWidgets' => __( 'Importing Widgets..', 'astra-sites' ),
264
+ 'importComplete' => __( 'Import Complete..', 'astra-sites' ),
265
+ 'preview' => __( 'Previewing ', 'astra-sites' ),
266
+ 'importLogText' => __( 'See Error Log &rarr;', 'astra-sites' ),
267
+ ),
268
  )
269
  );
270
 
inc/classes/compatibility/astra-pro/class-astra-sites-compatibility-astra-pro.php CHANGED
@@ -46,6 +46,8 @@ if ( ! class_exists( 'Astra_Sites_Compatibility_Astra_Pro' ) ) :
46
  */
47
  public function __construct() {
48
  add_action( 'astra_sites_after_plugin_activation', array( $this, 'astra_pro' ), 10, 2 );
 
 
49
  }
50
 
51
  /**
@@ -76,6 +78,39 @@ if ( ! class_exists( 'Astra_Sites_Compatibility_Astra_Pro' ) ) :
76
 
77
  }
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
80
 
81
  /**
46
  */
47
  public function __construct() {
48
  add_action( 'astra_sites_after_plugin_activation', array( $this, 'astra_pro' ), 10, 2 );
49
+ add_action( 'astra_sites_import_start', array( $this, 'import_enabled_extension' ), 10, 2 );
50
+ add_action( 'astra_sites_import_start', array( $this, 'import_custom_404' ), 10, 2 );
51
  }
52
 
53
  /**
78
 
79
  }
80
 
81
+ /**
82
+ * Import custom 404 section.
83
+ *
84
+ * @since 1.0.0
85
+ * @param array $demo_data Site all data render from API call.
86
+ * @param array $demo_api_uri Demo URL.
87
+ */
88
+ public function import_custom_404( $demo_data = array(), $demo_api_uri = '' ) {
89
+
90
+ if ( isset( $demo_data['astra-custom-404'] ) ) {
91
+ if ( is_callable( 'Astra_Admin_Helper::update_admin_settings_option' ) ) {
92
+ $options_404 = $demo_data['astra-custom-404'];
93
+ Astra_Admin_Helper::update_admin_settings_option( '_astra_ext_custom_404', $options_404 );
94
+ }
95
+ }
96
+ }
97
+
98
+ /**
99
+ * Import settings enabled Astra extensions from the demo.
100
+ *
101
+ * @since 1.0.0
102
+ * @param array $demo_data Site all data render from API call.
103
+ * @param array $demo_api_uri Demo URL.
104
+ */
105
+ public function import_enabled_extension( $demo_data = array(), $demo_api_uri = '' ) {
106
+
107
+ if ( isset( $demo_data['astra-enabled-extensions'] ) ) {
108
+ if ( is_callable( 'Astra_Admin_Helper::update_admin_settings_option' ) ) {
109
+ Astra_Admin_Helper::update_admin_settings_option( '_astra_ext_enabled_extensions', $demo_data['astra-enabled-extensions'] );
110
+ }
111
+ }
112
+ }
113
+
114
  }
115
 
116
  /**
inc/importers/batch-processing/helpers/class-astra-sites-image-importer.php CHANGED
@@ -161,8 +161,6 @@ if ( ! class_exists( 'Astra_Sites_Image_Importer' ) ) :
161
  );
162
  $this->already_imported_ids[ $attachment['id'] ] = $new_attachment;
163
 
164
- Astra_Sites_Image_Importer::log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
165
-
166
  return $new_attachment;
167
  }
168
 
@@ -228,6 +226,8 @@ if ( ! class_exists( 'Astra_Sites_Image_Importer' ) ) :
228
  'url' => $upload['url'],
229
  );
230
 
 
 
231
  $this->already_imported_ids[ $attachment['id'] ] = $new_attachment;
232
 
233
  return $new_attachment;
161
  );
162
  $this->already_imported_ids[ $attachment['id'] ] = $new_attachment;
163
 
 
 
164
  return $new_attachment;
165
  }
166
 
226
  'url' => $upload['url'],
227
  );
228
 
229
+ Astra_Sites_Image_Importer::log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
230
+
231
  $this->already_imported_ids[ $attachment['id'] ] = $new_attachment;
232
 
233
  return $new_attachment;
inc/importers/wxr-importer/class-astra-wxr-importer.php CHANGED
@@ -43,21 +43,92 @@ class Astra_WXR_Importer {
43
  * @since 1.0.0
44
  */
45
  private function __construct() {
46
- $this->includes();
 
 
 
 
 
 
 
 
 
47
 
48
  add_filter( 'upload_mimes', array( $this, 'custom_upload_mimes' ) );
49
- add_filter( 'wxr_importer.pre_process.user', array( $this, 'avoid_user' ), 10, 2 );
 
50
  }
51
 
52
  /**
53
- * Pre-process user data.
54
  *
55
- * @since 1.0.3
56
- * @param array $data User data. (Return empty to skip.).
57
- * @param array $meta Meta data.
58
  */
59
- function avoid_user( $data, $meta ) {
60
- return '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  }
62
 
63
  /**
@@ -76,56 +147,166 @@ class Astra_WXR_Importer {
76
  }
77
 
78
  /**
79
- * Include required files.
80
  *
81
  * @since 1.0.0
 
 
82
  */
83
- private function includes() {
84
- if ( ! class_exists( 'WP_Importer' ) ) {
85
- defined( 'WP_LOAD_IMPORTERS' ) || define( 'WP_LOAD_IMPORTERS', true );
86
- require ABSPATH . '/wp-admin/includes/class-wp-importer.php';
87
- }
88
- require_once ASTRA_SITES_DIR . 'inc/importers/wxr-importer/class-wxr-importer.php';
89
- require_once ASTRA_SITES_DIR . 'inc/importers/wxr-importer/class-logger.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  }
91
 
92
  /**
93
- * Start the xml import.
94
  *
95
- * @since 1.0.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  *
97
- * @param (String) $path Absolute path to the XML file.
 
98
  */
99
- public function import_xml( $path ) {
100
  $options = array(
101
  'fetch_attachments' => true,
102
- 'default_author' => 0,
103
  );
104
- $logger = new WP_Importer_Logger();
105
  $importer = new WXR_Importer( $options );
 
 
106
  $importer->set_logger( $logger );
107
- $result = $importer->import( $path );
108
  }
109
 
110
  /**
111
- * Download and save XML file to uploads directory.
112
  *
113
- * @since 1.0.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  *
115
- * @param (String) $url URL of the xml file.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  *
117
- * @return (Array) Attachment array of the downloaded xml file.
118
  */
119
- public function download_xml( $url ) {
 
 
 
 
 
 
 
 
120
 
121
- // Download XML file.
122
- $response = Astra_Sites_Helper::download_file( $url );
 
 
 
 
 
 
 
 
 
 
 
 
123
 
124
- // Is Success?
125
- if ( $response['success'] ) {
126
- return $response['data'];
127
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
 
 
 
 
 
129
  }
130
 
131
  }
 
 
43
  * @since 1.0.0
44
  */
45
  private function __construct() {
46
+
47
+ if ( ! class_exists( 'WP_Importer' ) ) {
48
+ defined( 'WP_LOAD_IMPORTERS' ) || define( 'WP_LOAD_IMPORTERS', true );
49
+ require ABSPATH . '/wp-admin/includes/class-wp-importer.php';
50
+ }
51
+
52
+ require_once ASTRA_SITES_DIR . 'inc/importers/wxr-importer/class-logger.php';
53
+ require_once ASTRA_SITES_DIR . 'inc/importers/wxr-importer/class-wp-importer-logger-serversentevents.php';
54
+ require_once ASTRA_SITES_DIR . 'inc/importers/wxr-importer/class-wxr-importer.php';
55
+ require_once ASTRA_SITES_DIR . 'inc/importers/wxr-importer/class-wxr-import-info.php';
56
 
57
  add_filter( 'upload_mimes', array( $this, 'custom_upload_mimes' ) );
58
+ add_action( 'wp_ajax_astra-wxr-import', array( $this, 'sse_import' ) );
59
+ add_filter( 'wxr_importer.pre_process.user', '__return_null' );
60
  }
61
 
62
  /**
63
+ * Constructor.
64
  *
65
+ * @since 1.1.0
 
 
66
  */
67
+ function sse_import() {
68
+
69
+ // Start the event stream.
70
+ header( 'Content-Type: text/event-stream' );
71
+
72
+ // Turn off PHP output compression.
73
+ $previous = error_reporting( error_reporting() ^ E_WARNING );
74
+ ini_set( 'output_buffering', 'off' );
75
+ ini_set( 'zlib.output_compression', false );
76
+ error_reporting( $previous );
77
+
78
+ if ( $GLOBALS['is_nginx'] ) {
79
+ // Setting this header instructs Nginx to disable fastcgi_buffering
80
+ // and disable gzip for this request.
81
+ header( 'X-Accel-Buffering: no' );
82
+ header( 'Content-Encoding: none' );
83
+ }
84
+
85
+ $xml_url = urldecode( $_REQUEST['xml_url'] );
86
+ if ( empty( $xml_url ) ) {
87
+ exit;
88
+ }
89
+
90
+ // 2KB padding for IE
91
+ echo ':' . str_repeat( ' ', 2048 ) . "\n\n";
92
+
93
+ // Time to run the import!
94
+ set_time_limit( 0 );
95
+
96
+ // Ensure we're not buffered.
97
+ wp_ob_end_flush_all();
98
+ flush();
99
+
100
+ // Are we allowed to create users?
101
+ add_filter( 'wxr_importer.pre_process.user', '__return_null' );
102
+
103
+ // Keep track of our progress.
104
+ add_action( 'wxr_importer.processed.post', array( $this, 'imported_post' ), 10, 2 );
105
+ add_action( 'wxr_importer.process_failed.post', array( $this, 'imported_post' ), 10, 2 );
106
+ add_action( 'wxr_importer.process_already_imported.post', array( $this, 'already_imported_post' ), 10, 2 );
107
+ add_action( 'wxr_importer.process_skipped.post', array( $this, 'already_imported_post' ), 10, 2 );
108
+ add_action( 'wxr_importer.processed.comment', array( $this, 'imported_comment' ) );
109
+ add_action( 'wxr_importer.process_already_imported.comment', array( $this, 'imported_comment' ) );
110
+ add_action( 'wxr_importer.processed.term', array( $this, 'imported_term' ) );
111
+ add_action( 'wxr_importer.process_failed.term', array( $this, 'imported_term' ) );
112
+ add_action( 'wxr_importer.process_already_imported.term', array( $this, 'imported_term' ) );
113
+ add_action( 'wxr_importer.processed.user', array( $this, 'imported_user' ) );
114
+ add_action( 'wxr_importer.process_failed.user', array( $this, 'imported_user' ) );
115
+ // Flush once more.
116
+ flush();
117
+
118
+ $importer = $this->get_importer();
119
+ $response = $importer->import( $xml_url );
120
+
121
+ // Let the browser know we're done.
122
+ $complete = array(
123
+ 'action' => 'complete',
124
+ 'error' => false,
125
+ );
126
+ if ( is_wp_error( $response ) ) {
127
+ $complete['error'] = $response->get_error_message();
128
+ }
129
+
130
+ $this->emit_sse_message( $complete );
131
+ exit;
132
  }
133
 
134
  /**
147
  }
148
 
149
  /**
150
+ * Start the xml import.
151
  *
152
  * @since 1.0.0
153
+ *
154
+ * @param (String) $path Absolute path to the XML file.
155
  */
156
+ public function get_xml_data( $path ) {
157
+
158
+ $args = array(
159
+ 'action' => 'astra-wxr-import',
160
+ 'id' => '1',
161
+ 'xml_url' => $path,
162
+ );
163
+ $url = add_query_arg( urlencode_deep( $args ), admin_url( 'admin-ajax.php' ) );
164
+
165
+ $data = $this->get_data( $path );
166
+
167
+ return array(
168
+ 'count' => array(
169
+ 'posts' => $data->post_count,
170
+ 'media' => $data->media_count,
171
+ 'users' => count( $data->users ),
172
+ 'comments' => $data->comment_count,
173
+ 'terms' => $data->term_count,
174
+ ),
175
+ 'url' => $url,
176
+ 'strings' => array(
177
+ 'complete' => __( 'Import complete!', 'astra-sites' ),
178
+ ),
179
+ );
180
  }
181
 
182
  /**
183
+ * Get XML data.
184
  *
185
+ * @since 1.1.0
186
+ * @param string $url Downloaded XML file absolute URL.
187
+ * @return array XML file data.
188
+ */
189
+ function get_data( $url ) {
190
+ $importer = $this->get_importer();
191
+ $data = $importer->get_preliminary_information( $url );
192
+ if ( is_wp_error( $data ) ) {
193
+ return $data;
194
+ }
195
+ return $data;
196
+ }
197
+
198
+ /**
199
+ * Get Importer
200
  *
201
+ * @since 1.1.0
202
+ * @return object Importer object.
203
  */
204
+ public function get_importer() {
205
  $options = array(
206
  'fetch_attachments' => true,
207
+ 'default_author' => get_current_user_id(),
208
  );
 
209
  $importer = new WXR_Importer( $options );
210
+ $logger = new WP_Importer_Logger_ServerSentEvents();
211
+
212
  $importer->set_logger( $logger );
213
+ return $importer;
214
  }
215
 
216
  /**
217
+ * Send message when a post has been imported.
218
  *
219
+ * @since 1.1.0
220
+ * @param int $id Post ID.
221
+ * @param array $data Post data saved to the DB.
222
+ */
223
+ public function imported_post( $id, $data ) {
224
+ $this->emit_sse_message(
225
+ array(
226
+ 'action' => 'updateDelta',
227
+ 'type' => ( 'attachment' === $data['post_type'] ) ? 'media' : 'posts',
228
+ 'delta' => 1,
229
+ )
230
+ );
231
+ }
232
+
233
+ /**
234
+ * Send message when a post is marked as already imported.
235
  *
236
+ * @since 1.1.0
237
+ * @param array $data Post data saved to the DB.
238
+ */
239
+ public function already_imported_post( $data ) {
240
+ $this->emit_sse_message(
241
+ array(
242
+ 'action' => 'updateDelta',
243
+ 'type' => ( 'attachment' === $data['post_type'] ) ? 'media' : 'posts',
244
+ 'delta' => 1,
245
+ )
246
+ );
247
+ }
248
+
249
+ /**
250
+ * Send message when a comment has been imported.
251
  *
252
+ * @since 1.1.0
253
  */
254
+ public function imported_comment() {
255
+ $this->emit_sse_message(
256
+ array(
257
+ 'action' => 'updateDelta',
258
+ 'type' => 'comments',
259
+ 'delta' => 1,
260
+ )
261
+ );
262
+ }
263
 
264
+ /**
265
+ * Send message when a term has been imported.
266
+ *
267
+ * @since 1.1.0
268
+ */
269
+ public function imported_term() {
270
+ $this->emit_sse_message(
271
+ array(
272
+ 'action' => 'updateDelta',
273
+ 'type' => 'terms',
274
+ 'delta' => 1,
275
+ )
276
+ );
277
+ }
278
 
279
+ /**
280
+ * Send message when a user has been imported.
281
+ *
282
+ * @since 1.1.0
283
+ */
284
+ public function imported_user() {
285
+ $this->emit_sse_message(
286
+ array(
287
+ 'action' => 'updateDelta',
288
+ 'type' => 'users',
289
+ 'delta' => 1,
290
+ )
291
+ );
292
+ }
293
+
294
+ /**
295
+ * Emit a Server-Sent Events message.
296
+ *
297
+ * @since 1.1.0
298
+ * @param mixed $data Data to be JSON-encoded and sent in the message.
299
+ */
300
+ public function emit_sse_message( $data ) {
301
+ echo "event: message\n";
302
+ echo 'data: ' . wp_json_encode( $data ) . "\n\n";
303
 
304
+ // Extra padding.
305
+ echo ':' . str_repeat( ' ', 2048 ) . "\n\n";
306
+
307
+ flush();
308
  }
309
 
310
  }
311
+
312
+ Astra_WXR_Importer::instance();
inc/importers/wxr-importer/class-logger.php CHANGED
@@ -126,6 +126,10 @@ class WP_Importer_Logger {
126
  * @return null
127
  */
128
  public function log( $level, $message, array $context = array() ) {
 
 
 
 
129
  $this->messages[] = array(
130
  'timestamp' => time(),
131
  'level' => $level,
126
  * @return null
127
  */
128
  public function log( $level, $message, array $context = array() ) {
129
+
130
+ // Log
131
+ do_action( 'astra_sites_import_xml_log', $level, $message, $context );
132
+
133
  $this->messages[] = array(
134
  'timestamp' => time(),
135
  'level' => $level,
inc/importers/wxr-importer/class-wp-importer-logger-serversentevents.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! class_exists( 'WP_Importer_Logger_ServerSentEvents' ) && class_exists( 'WP_Importer_Logger' ) ) {
4
+
5
+ class WP_Importer_Logger_ServerSentEvents extends WP_Importer_Logger {
6
+
7
+ /**
8
+ * Logs with an arbitrary level.
9
+ *
10
+ * @param mixed $level
11
+ * @param string $message
12
+ * @param array $context
13
+ * @return null
14
+ */
15
+ public function log( $level, $message, array $context = array() ) {
16
+
17
+ // Log
18
+ do_action( 'astra_sites_import_xml_log', $level, $message, $context );
19
+
20
+ $data = compact( 'level', 'message' );
21
+
22
+ switch ( $level ) {
23
+ case 'emergency':
24
+ case 'alert':
25
+ case 'critical':
26
+ case 'error':
27
+ case 'warning':
28
+ case 'notice':
29
+ case 'info':
30
+ echo "event: log\n";
31
+ echo 'data: ' . wp_json_encode( $data ) . "\n\n";
32
+ flush();
33
+ break;
34
+
35
+ case 'debug':
36
+ if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) {
37
+ echo "event: log\n";
38
+ echo 'data: ' . wp_json_encode( $data ) . "\n\n";
39
+ flush();
40
+ break;
41
+ }
42
+ break;
43
+ }
44
+ }
45
+ }
46
+ }
inc/importers/wxr-importer/class-wxr-import-info.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! class_exists( 'WXR_Import_Info' ) ) {
4
+
5
+ class WXR_Import_Info {
6
+ public $home;
7
+ public $siteurl;
8
+
9
+ public $title;
10
+
11
+ public $users = array();
12
+ public $post_count = 0;
13
+ public $media_count = 0;
14
+ public $comment_count = 0;
15
+ public $term_count = 0;
16
+
17
+ public $generator = '';
18
+ public $version;
19
+ }
20
+
21
+ }
inc/importers/wxr-importer/class-wxr-importer.php CHANGED
@@ -2296,4 +2296,4 @@ class WXR_Importer extends WP_Importer {
2296
  $exists_key = sha1( $data['taxonomy'] . ':' . $data['slug'] );
2297
  $this->exists['term'][ $exists_key ] = $term_id;
2298
  }
2299
- }
2296
  $exists_key = sha1( $data['taxonomy'] . ':' . $data['slug'] );
2297
  $this->exists['term'][ $exists_key ] = $term_id;
2298
  }
2299
+ }
inc/includes/admin-page.php CHANGED
@@ -14,6 +14,7 @@
14
  defined( 'ABSPATH' ) or exit;
15
 
16
  ?>
 
17
  <div class="wrap" id="astra-sites-admin">
18
 
19
  <div id="astra-sites-filters" class="wp-filter hide-if-no-js">
@@ -220,29 +221,26 @@ defined( 'ABSPATH' ) or exit;
220
  <input type="hidden" class="astra-enabled-extensions" value="{{ JSON.stringify(data.items[ key ]['astra-enabled-extensions'] ) }}" />
221
 
222
  <div class="inner">
223
- <span class="site-preview" data-href="{{ data.items[ key ]['astra-site-url'] }}?TB_iframe=true&width=600&height=550" data-title="{{ data.items[ key ].title.rendered }}">
224
-
225
- <div class="theme-screenshot">
226
- <# if( '' !== data.items[ key ]['featured-image-url'] ) { #>
227
- <img src="{{ data.items[ key ]['featured-image-url'] }}" />
228
- <# } #>
229
- </div>
230
-
231
- <a href="{{{data.astra_demo_url}}}" target="_blank" class="view-demo-wrap">
232
- <span class="more-details view-demo" id="astra-theme-action"><?php esc_html_e( 'Details &amp; Preview', 'astra-sites' ); ?></span>
233
- </a>
234
-
235
- </span>
236
- <h3 class="theme-name" id="astra-theme-name"> {{{ data.items[ key ].title.rendered }}} </h3>
237
- <# if ( data.items[ key ]['astra-site-type'] ) { #>
238
- <span class="site-type {{data.items[ key ]['astra-site-type']}}">{{data.items[ key ]['astra-site-type']}}</span>
239
- <# } #>
240
- <# if ( data.items[ key ].status ) { #>
241
- <span class="status {{data.items[ key ].status}}">{{data.items[ key ].status}}</span>
242
- <# } #>
243
- <div class="theme-actions">
244
- <button class="button preview install-theme-preview"><?php esc_html_e( 'Preview', 'astra-sites' ); ?></button>
245
- </div>
246
  </div>
247
  </div>
248
  <# } #>
@@ -276,3 +274,5 @@ defined( 'ABSPATH' ) or exit;
276
  </div>
277
  </div>
278
  </script>
 
 
14
  defined( 'ABSPATH' ) or exit;
15
 
16
  ?>
17
+
18
  <div class="wrap" id="astra-sites-admin">
19
 
20
  <div id="astra-sites-filters" class="wp-filter hide-if-no-js">
221
  <input type="hidden" class="astra-enabled-extensions" value="{{ JSON.stringify(data.items[ key ]['astra-enabled-extensions'] ) }}" />
222
 
223
  <div class="inner">
224
+ <span class="site-preview" data-href="{{ data.items[ key ]['astra-site-url'] }}?TB_iframe=true&width=600&height=550" data-title="{{ data.items[ key ].title.rendered }}">
225
+ <div class="theme-screenshot">
226
+ <# if( '' !== data.items[ key ]['featured-image-url'] ) { #>
227
+ <img src="{{ data.items[ key ]['featured-image-url'] }}" />
228
+ <# } #>
229
+ </div>
230
+ </span>
231
+ <span class="more-details"> <?php esc_html_e( 'Details &amp; Preview', 'astra-sites' ); ?> </span>
232
+ <# if ( data.items[ key ]['astra-site-type'] ) { #>
233
+ <span class="site-type {{data.items[ key ]['astra-site-type']}}">{{data.items[ key ]['astra-site-type']}}</span>
234
+ <# } #>
235
+ <# if ( data.items[ key ].status ) { #>
236
+ <span class="status {{data.items[ key ].status}}">{{data.items[ key ].status}}</span>
237
+ <# } #>
238
+ <div class="theme-id-container">
239
+ <h3 class="theme-name" id="astra-theme-name"> {{{ data.items[ key ].title.rendered }}} </h3>
240
+ <div class="theme-actions">
241
+ <button class="button preview install-theme-preview"><?php esc_html_e( 'Preview', 'astra-sites' ); ?></button>
242
+ </div>
243
+ </div>
 
 
 
244
  </div>
245
  </div>
246
  <# } #>
274
  </div>
275
  </div>
276
  </script>
277
+ <?php
278
+ wp_print_admin_notice_templates();
languages/astra-sites.pot CHANGED
@@ -1,10 +1,10 @@
1
  # Copyright (C) 2017 Brainstorm Force
2
- # This file is distributed under the same license as the Astra Sites - Lite package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Astra Sites - Lite 1.0.14\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/astra-sites\n"
7
- "POT-Creation-Date: 2017-11-09 09:45:20+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -28,12 +28,48 @@ msgstr ""
28
  msgid "Astra Sites"
29
  msgstr ""
30
 
31
- #: inc/classes/class-astra-sites-importer.php:74
32
- msgid "You have not \"customize\" access to import the astra site."
 
 
 
 
 
 
 
 
 
 
 
 
33
  msgstr ""
34
 
35
  #: inc/classes/class-astra-sites-importer.php:82
36
- msgid "Demo Imported Successfully."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  msgstr ""
38
 
39
  #: inc/classes/class-astra-sites-page.php:192
@@ -56,67 +92,75 @@ msgstr ""
56
  msgid "See Library"
57
  msgstr ""
58
 
59
- #: inc/classes/class-astra-sites.php:166
60
  msgid "Page Builder"
61
  msgstr ""
62
 
63
- #: inc/classes/class-astra-sites.php:171
64
  msgid "Categories"
65
  msgstr ""
66
 
67
- #: inc/classes/class-astra-sites.php:203
68
  msgid "Purchase"
69
  msgstr ""
70
 
71
- #: inc/classes/class-astra-sites.php:205
72
  msgid "Upgrade"
73
  msgstr ""
74
 
75
- #: inc/classes/class-astra-sites.php:210
76
  msgid "Error!"
77
  msgstr ""
78
 
79
- #: inc/classes/class-astra-sites.php:211
80
  msgid "Error! Read Possibilities."
81
  msgstr ""
82
 
83
- #: inc/classes/class-astra-sites.php:213
84
  msgid "Done! View Site"
85
  msgstr ""
86
 
87
- #: inc/classes/class-astra-sites.php:214
88
  msgid "Activating"
89
  msgstr ""
90
 
91
- #: inc/classes/class-astra-sites.php:215
92
  msgid "Active"
93
  msgstr ""
94
 
95
- #: inc/classes/class-astra-sites.php:216
 
 
 
 
 
 
 
 
96
  msgid "Import This Site"
97
  msgstr ""
98
 
99
- #: inc/classes/class-astra-sites.php:217
100
- msgid "Importing Demo"
101
  msgstr ""
102
 
103
- #: inc/classes/class-astra-sites.php:218 inc/includes/admin-page.php:102
104
  msgid "Read more"
105
  msgstr ""
106
 
107
- #: inc/classes/class-astra-sites.php:219
108
  msgid "Hide"
109
  msgstr ""
110
 
111
- #: inc/classes/class-astra-sites.php:220
112
  msgid "There was a problem receiving a response from server."
113
  msgstr ""
114
 
115
- #: inc/classes/class-astra-sites.php:221 inc/includes/admin-page.php:250
116
  msgid "No Demos found, Try a different search."
117
  msgstr ""
118
 
119
- #: inc/classes/class-astra-sites.php:222
120
  msgid ""
121
  "Executing Demo Import will make your site similar as ours. Please bear in "
122
  "mind -\n"
@@ -130,11 +174,135 @@ msgid ""
130
  "placeholders."
131
  msgstr ""
132
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  #: inc/classes/class-astra-sites.php:257
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  msgid "No plugin specified"
135
  msgstr ""
136
 
137
- #: inc/classes/class-astra-sites.php:286
138
  msgid "Plugin Successfully Activated"
139
  msgstr ""
140
 
@@ -174,6 +342,10 @@ msgstr ""
174
  msgid "No Title"
175
  msgstr ""
176
 
 
 
 
 
177
  #: inc/importers/wxr-importer/class-wxr-importer.php:130
178
  msgid "Could not open the file for parsing"
179
  msgstr ""
@@ -321,75 +493,75 @@ msgstr ""
321
  msgid "Could not update comment #%d with mapped data"
322
  msgstr ""
323
 
324
- #: inc/includes/admin-page.php:40
325
  msgid "Search Sites"
326
  msgstr ""
327
 
328
- #: inc/includes/admin-page.php:41
329
  msgid "Search Sites..."
330
  msgstr ""
331
 
332
- #: inc/includes/admin-page.php:83
333
  msgid "Close"
334
  msgstr ""
335
 
336
- #: inc/includes/admin-page.php:84
337
  msgid "Previous"
338
  msgstr ""
339
 
340
- #: inc/includes/admin-page.php:85
341
  msgid "Next"
342
  msgstr ""
343
 
344
- #: inc/includes/admin-page.php:86 inc/includes/admin-page.php:114
345
  msgid "Install Plugins"
346
  msgstr ""
347
 
348
- #: inc/includes/admin-page.php:105
349
  msgid "Required Plugins"
350
  msgstr ""
351
 
352
- #: inc/includes/admin-page.php:120
353
  msgid "Collapse"
354
  msgstr ""
355
 
356
- #: inc/includes/admin-page.php:126
357
  msgid "Enter desktop preview mode"
358
  msgstr ""
359
 
360
- #: inc/includes/admin-page.php:129
361
  msgid "Enter tablet preview mode"
362
  msgstr ""
363
 
364
- #: inc/includes/admin-page.php:132
365
  msgid "Enter mobile preview mode"
366
  msgstr ""
367
 
368
- #: inc/includes/admin-page.php:140 inc/includes/admin-page.php:244
369
  msgid "Preview"
370
  msgstr ""
371
 
372
- #: inc/includes/admin-page.php:155
373
  #. translators: %1$s & %2$s are a Demo API URL
374
  msgid ""
375
  "<p> It seems the demo data server, <i><a href=\"%1$s\">%2$s</a></i> is "
376
  "unreachable from your site.</p>"
377
  msgstr ""
378
 
379
- #: inc/includes/admin-page.php:157
380
  msgid ""
381
  "<p class=\"left-margin\"> 1. Sometimes, simple page reload fixes any "
382
  "temporary issues. No kidding!</p>"
383
  msgstr ""
384
 
385
- #: inc/includes/admin-page.php:159
386
  msgid ""
387
  "<p class=\"left-margin\"> 2. If that does not work, you will need to talk "
388
  "to your server administrator and check if demo server is being blocked by "
389
  "the firewall!</p>"
390
  msgstr ""
391
 
392
- #: inc/includes/admin-page.php:162
393
  #. translators: %1$s is a support link
394
  msgid ""
395
  "<p>If that does not help, please open up a <a href=\"%1$s\" "
@@ -397,15 +569,15 @@ msgid ""
397
  "for you.</p>"
398
  msgstr ""
399
 
400
- #: inc/includes/admin-page.php:232
401
  msgid "Details &amp; Preview"
402
  msgstr ""
403
 
404
- #: inc/includes/admin-page.php:265
405
  #. translators: %1$s External Link
406
  msgid ""
407
- "Don't see a site that you would like to import?<br>Please suggest <a "
408
- "target=\"_blank\" href=\"%1$s\">tell us</a>!"
409
  msgstr ""
410
 
411
  #: inc/includes/white-label.php:23
@@ -417,7 +589,7 @@ msgid "Plugin Description:"
417
  msgstr ""
418
 
419
  #. Plugin Name of the plugin/theme
420
- msgid "Astra Sites - Lite"
421
  msgstr ""
422
 
423
  #. Plugin URI of the plugin/theme
@@ -434,4 +606,15 @@ msgstr ""
434
 
435
  #. Author URI of the plugin/theme
436
  msgid "http://www.brainstormforce.com"
 
 
 
 
 
 
 
 
 
 
 
437
  msgstr ""
1
  # Copyright (C) 2017 Brainstorm Force
2
+ # This file is distributed under the same license as the Astra Starter Sites package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Astra Starter Sites 1.1.0\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/astra-sites\n"
7
+ "POT-Creation-Date: 2017-11-21 12:29:44+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
28
  msgid "Astra Sites"
29
  msgstr ""
30
 
31
+ #: inc/classes/class-astra-sites-importer-log.php:351
32
+ msgid "Enabled"
33
+ msgstr ""
34
+
35
+ #: inc/classes/class-astra-sites-importer-log.php:354
36
+ msgid "Disabled"
37
+ msgstr ""
38
+
39
+ #: inc/classes/class-astra-sites-importer-log.php:481
40
+ msgid "Yes"
41
+ msgstr ""
42
+
43
+ #: inc/classes/class-astra-sites-importer-log.php:484
44
+ msgid "No"
45
  msgstr ""
46
 
47
  #: inc/classes/class-astra-sites-importer.php:82
48
+ msgid "You have not \"customize\" access to import the Astra site."
49
+ msgstr ""
50
+
51
+ #: inc/classes/class-astra-sites-importer.php:101
52
+ msgid "Request site API URL is empty. Try again!"
53
+ msgstr ""
54
+
55
+ #: inc/classes/class-astra-sites-importer.php:124
56
+ msgid "Customizer data is empty!"
57
+ msgstr ""
58
+
59
+ #: inc/classes/class-astra-sites-importer.php:153
60
+ msgid "There was an error downloading the XML file."
61
+ msgstr ""
62
+
63
+ #: inc/classes/class-astra-sites-importer.php:159
64
+ msgid "Invalid site XML file!"
65
+ msgstr ""
66
+
67
+ #: inc/classes/class-astra-sites-importer.php:181
68
+ msgid "Site options are empty!"
69
+ msgstr ""
70
+
71
+ #: inc/classes/class-astra-sites-importer.php:203
72
+ msgid "Widget data is empty!"
73
  msgstr ""
74
 
75
  #: inc/classes/class-astra-sites-page.php:192
92
  msgid "See Library"
93
  msgstr ""
94
 
95
+ #: inc/classes/class-astra-sites.php:172
96
  msgid "Page Builder"
97
  msgstr ""
98
 
99
+ #: inc/classes/class-astra-sites.php:177
100
  msgid "Categories"
101
  msgstr ""
102
 
103
+ #: inc/classes/class-astra-sites.php:210
104
  msgid "Purchase"
105
  msgstr ""
106
 
107
+ #: inc/classes/class-astra-sites.php:212
108
  msgid "Upgrade"
109
  msgstr ""
110
 
111
+ #: inc/classes/class-astra-sites.php:217
112
  msgid "Error!"
113
  msgstr ""
114
 
115
+ #: inc/classes/class-astra-sites.php:218
116
  msgid "Error! Read Possibilities."
117
  msgstr ""
118
 
119
+ #: inc/classes/class-astra-sites.php:220
120
  msgid "Done! View Site"
121
  msgstr ""
122
 
123
+ #: inc/classes/class-astra-sites.php:221
124
  msgid "Activating"
125
  msgstr ""
126
 
127
+ #: inc/classes/class-astra-sites.php:222
128
  msgid "Active"
129
  msgstr ""
130
 
131
+ #: inc/classes/class-astra-sites.php:223
132
+ msgid "Import failed."
133
+ msgstr ""
134
+
135
+ #: inc/classes/class-astra-sites.php:224
136
+ msgid "Import failed. See error log."
137
+ msgstr ""
138
+
139
+ #: inc/classes/class-astra-sites.php:225
140
  msgid "Import This Site"
141
  msgstr ""
142
 
143
+ #: inc/classes/class-astra-sites.php:226 inc/classes/class-astra-sites.php:244
144
+ msgid "Importing.."
145
  msgstr ""
146
 
147
+ #: inc/classes/class-astra-sites.php:227 inc/includes/admin-page.php:103
148
  msgid "Read more"
149
  msgstr ""
150
 
151
+ #: inc/classes/class-astra-sites.php:228
152
  msgid "Hide"
153
  msgstr ""
154
 
155
+ #: inc/classes/class-astra-sites.php:229
156
  msgid "There was a problem receiving a response from server."
157
  msgstr ""
158
 
159
+ #: inc/classes/class-astra-sites.php:230 inc/includes/admin-page.php:249
160
  msgid "No Demos found, Try a different search."
161
  msgstr ""
162
 
163
+ #: inc/classes/class-astra-sites.php:231
164
  msgid ""
165
  "Executing Demo Import will make your site similar as ours. Please bear in "
166
  "mind -\n"
174
  "placeholders."
175
  msgstr ""
176
 
177
+ #: inc/classes/class-astra-sites.php:234
178
+ msgid "Installing plugin "
179
+ msgstr ""
180
+
181
+ #: inc/classes/class-astra-sites.php:235
182
+ msgid "Successfully plugin installed!"
183
+ msgstr ""
184
+
185
+ #: inc/classes/class-astra-sites.php:236
186
+ msgid "There was an error while installing the plugin "
187
+ msgstr ""
188
+
189
+ #: inc/classes/class-astra-sites.php:237
190
+ msgid "Activating plugin "
191
+ msgstr ""
192
+
193
+ #: inc/classes/class-astra-sites.php:238
194
+ msgid "Successfully plugin activated "
195
+ msgstr ""
196
+
197
+ #: inc/classes/class-astra-sites.php:239
198
+ msgid "Bulk plugin activation..."
199
+ msgstr ""
200
+
201
+ #: inc/classes/class-astra-sites.php:240
202
+ msgid "Successfully plugin activate - "
203
+ msgstr ""
204
+
205
+ #: inc/classes/class-astra-sites.php:241
206
+ msgid "Error! While activating plugin - "
207
+ msgstr ""
208
+
209
+ #: inc/classes/class-astra-sites.php:242
210
+ msgid "Bulk plugin installation..."
211
+ msgstr ""
212
+
213
+ #: inc/classes/class-astra-sites.php:243
214
+ msgid "Site API "
215
+ msgstr ""
216
+
217
+ #: inc/classes/class-astra-sites.php:245
218
+ msgid "Processing requests..."
219
+ msgstr ""
220
+
221
+ #: inc/classes/class-astra-sites.php:246
222
+ msgid "1) Importing \"Customizer Settings\"..."
223
+ msgstr ""
224
+
225
+ #: inc/classes/class-astra-sites.php:247
226
+ msgid "Successfully imported customizer settings!"
227
+ msgstr ""
228
+
229
+ #: inc/classes/class-astra-sites.php:248
230
+ msgid "2) Preparing \"XML\" Data..."
231
+ msgstr ""
232
+
233
+ #: inc/classes/class-astra-sites.php:249
234
+ msgid "Successfully set XML data!"
235
+ msgstr ""
236
+
237
+ #: inc/classes/class-astra-sites.php:250
238
+ msgid "3) Importing \"XML\"..."
239
+ msgstr ""
240
+
241
+ #: inc/classes/class-astra-sites.php:251
242
+ msgid "Successfully imported XML!"
243
+ msgstr ""
244
+
245
+ #: inc/classes/class-astra-sites.php:252
246
+ msgid "4) Importing \"Options\"..."
247
+ msgstr ""
248
+
249
+ #: inc/classes/class-astra-sites.php:253
250
+ msgid "Successfully imported Options!"
251
+ msgstr ""
252
+
253
+ #: inc/classes/class-astra-sites.php:254
254
+ msgid "5) Importing \"Widgets\"..."
255
+ msgstr ""
256
+
257
+ #: inc/classes/class-astra-sites.php:255
258
+ msgid "Successfully imported Widgets!"
259
+ msgstr ""
260
+
261
  #: inc/classes/class-astra-sites.php:257
262
+ msgid "Site imported successfully! visit : "
263
+ msgstr ""
264
+
265
+ #: inc/classes/class-astra-sites.php:258
266
+ msgid "Getting Site Information.."
267
+ msgstr ""
268
+
269
+ #: inc/classes/class-astra-sites.php:259
270
+ msgid "Importing Customizer Settings.."
271
+ msgstr ""
272
+
273
+ #: inc/classes/class-astra-sites.php:260
274
+ msgid "Setting up import data.."
275
+ msgstr ""
276
+
277
+ #: inc/classes/class-astra-sites.php:261
278
+ msgid "Importing Pages, Posts & Media.."
279
+ msgstr ""
280
+
281
+ #: inc/classes/class-astra-sites.php:262
282
+ msgid "Importing Site Options.."
283
+ msgstr ""
284
+
285
+ #: inc/classes/class-astra-sites.php:263
286
+ msgid "Importing Widgets.."
287
+ msgstr ""
288
+
289
+ #: inc/classes/class-astra-sites.php:264
290
+ msgid "Import Complete.."
291
+ msgstr ""
292
+
293
+ #: inc/classes/class-astra-sites.php:265
294
+ msgid "Previewing "
295
+ msgstr ""
296
+
297
+ #: inc/classes/class-astra-sites.php:266
298
+ msgid "See Error Log &rarr;"
299
+ msgstr ""
300
+
301
+ #: inc/classes/class-astra-sites.php:301
302
  msgid "No plugin specified"
303
  msgstr ""
304
 
305
+ #: inc/classes/class-astra-sites.php:330
306
  msgid "Plugin Successfully Activated"
307
  msgstr ""
308
 
342
  msgid "No Title"
343
  msgstr ""
344
 
345
+ #: inc/importers/wxr-importer/class-astra-wxr-importer.php:177
346
+ msgid "Import complete!"
347
+ msgstr ""
348
+
349
  #: inc/importers/wxr-importer/class-wxr-importer.php:130
350
  msgid "Could not open the file for parsing"
351
  msgstr ""
493
  msgid "Could not update comment #%d with mapped data"
494
  msgstr ""
495
 
496
+ #: inc/includes/admin-page.php:41
497
  msgid "Search Sites"
498
  msgstr ""
499
 
500
+ #: inc/includes/admin-page.php:42
501
  msgid "Search Sites..."
502
  msgstr ""
503
 
504
+ #: inc/includes/admin-page.php:84
505
  msgid "Close"
506
  msgstr ""
507
 
508
+ #: inc/includes/admin-page.php:85
509
  msgid "Previous"
510
  msgstr ""
511
 
512
+ #: inc/includes/admin-page.php:86
513
  msgid "Next"
514
  msgstr ""
515
 
516
+ #: inc/includes/admin-page.php:87 inc/includes/admin-page.php:115
517
  msgid "Install Plugins"
518
  msgstr ""
519
 
520
+ #: inc/includes/admin-page.php:106
521
  msgid "Required Plugins"
522
  msgstr ""
523
 
524
+ #: inc/includes/admin-page.php:121
525
  msgid "Collapse"
526
  msgstr ""
527
 
528
+ #: inc/includes/admin-page.php:127
529
  msgid "Enter desktop preview mode"
530
  msgstr ""
531
 
532
+ #: inc/includes/admin-page.php:130
533
  msgid "Enter tablet preview mode"
534
  msgstr ""
535
 
536
+ #: inc/includes/admin-page.php:133
537
  msgid "Enter mobile preview mode"
538
  msgstr ""
539
 
540
+ #: inc/includes/admin-page.php:141 inc/includes/admin-page.php:241
541
  msgid "Preview"
542
  msgstr ""
543
 
544
+ #: inc/includes/admin-page.php:156
545
  #. translators: %1$s & %2$s are a Demo API URL
546
  msgid ""
547
  "<p> It seems the demo data server, <i><a href=\"%1$s\">%2$s</a></i> is "
548
  "unreachable from your site.</p>"
549
  msgstr ""
550
 
551
+ #: inc/includes/admin-page.php:158
552
  msgid ""
553
  "<p class=\"left-margin\"> 1. Sometimes, simple page reload fixes any "
554
  "temporary issues. No kidding!</p>"
555
  msgstr ""
556
 
557
+ #: inc/includes/admin-page.php:160
558
  msgid ""
559
  "<p class=\"left-margin\"> 2. If that does not work, you will need to talk "
560
  "to your server administrator and check if demo server is being blocked by "
561
  "the firewall!</p>"
562
  msgstr ""
563
 
564
+ #: inc/includes/admin-page.php:163
565
  #. translators: %1$s is a support link
566
  msgid ""
567
  "<p>If that does not help, please open up a <a href=\"%1$s\" "
569
  "for you.</p>"
570
  msgstr ""
571
 
572
+ #: inc/includes/admin-page.php:231
573
  msgid "Details &amp; Preview"
574
  msgstr ""
575
 
576
+ #: inc/includes/admin-page.php:253 inc/includes/admin-page.php:271
577
  #. translators: %1$s External Link
578
  msgid ""
579
+ "Don't see a site that you would like to import?<br>Please <a "
580
+ "target=\"_blank\" href=\"%1$s\">suggest us</a>!"
581
  msgstr ""
582
 
583
  #: inc/includes/white-label.php:23
589
  msgstr ""
590
 
591
  #. Plugin Name of the plugin/theme
592
+ msgid "Astra Starter Sites"
593
  msgstr ""
594
 
595
  #. Plugin URI of the plugin/theme
606
 
607
  #. Author URI of the plugin/theme
608
  msgid "http://www.brainstormforce.com"
609
+ msgstr ""
610
+
611
+ #: inc/classes/class-astra-sites-importer-log.php:372
612
+ #. translators: %1$s Memory Limit, %2$s Recommended memory limit.
613
+ msgctxt "Recommended Memory Limit"
614
+ msgid "Current memory limit %1$s. We recommend setting memory to at least %2$s."
615
+ msgstr ""
616
+
617
+ #: inc/classes/class-astra-sites-importer-log.php:438
618
+ msgctxt "PHP Version"
619
+ msgid "We recommend to use php 5.4 or higher"
620
  msgstr ""
readme.txt CHANGED
@@ -1,14 +1,14 @@
1
- === Astra Sites - Lite ===
2
  Contributors: brainstormforce
3
  Donate link: https://wpastra.com/pro/
4
  Tags: demo, theme demos, one click import
5
  Requires at least: 4.4
6
  Tested up to: 4.9.0
7
- Stable tag: 1.0.14
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Import Astra Sites - Lite with just one click.
12
 
13
  == Description ==
14
 
@@ -49,12 +49,21 @@ https://wpastra.com/sites-suggestions/
49
 
50
 
51
  == Screenshots ==
 
52
  1. Select the demo you want to import.
53
  2. Install and activate the required plugins.
54
  3. Import the demo.
55
 
56
  == Changelog ==
57
 
 
 
 
 
 
 
 
 
58
  v1.0.14 - 9-Nov-2017
59
  * New: All the linked images on the Astra Sites will be downloaded to your site, No more loading images from external URLs.
60
  * New: Added suggestion box at as the last column in when listing sites so that you can add a suggest the sites you want.
@@ -124,4 +133,4 @@ v1.0.1 - 04-Aug-2017
124
  * Fix: Bug where widgets created with SiteOrigin plugin were not being imported.
125
 
126
  v1.0.0
127
- * Initial release
1
+ === Astra Starter Sites ===
2
  Contributors: brainstormforce
3
  Donate link: https://wpastra.com/pro/
4
  Tags: demo, theme demos, one click import
5
  Requires at least: 4.4
6
  Tested up to: 4.9.0
7
+ Stable tag: 1.1.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Import Astra Starter Sites with just one click.
12
 
13
  == Description ==
14
 
49
 
50
 
51
  == Screenshots ==
52
+
53
  1. Select the demo you want to import.
54
  2. Install and activate the required plugins.
55
  3. Import the demo.
56
 
57
  == Changelog ==
58
 
59
+ v1.1.0 - 21-Nov-2017
60
+ * New: Import the site content using Event Source (SSE) which ensures faithful imports.
61
+ * New: Divided the site import process in separate AJAX calls to reduce the possibility of timeouts.
62
+ * New: Generated the import log file. It will be displayed in the UI if the import fails.
63
+ * Improvement: Validate all the possible errors.
64
+ * Improvement: Updated Astra sites HTML grid structure for WordPress v4.9 compatibility.
65
+ * Enhancement: Updated plugin name from Astra Sites - Lite with Astra Starter Sites.
66
+
67
  v1.0.14 - 9-Nov-2017
68
  * New: All the linked images on the Astra Sites will be downloaded to your site, No more loading images from external URLs.
69
  * New: Added suggestion box at as the last column in when listing sites so that you can add a suggest the sites you want.
133
  * Fix: Bug where widgets created with SiteOrigin plugin were not being imported.
134
 
135
  v1.0.0
136
+ * Initial release