Astra Starter Sites - Version 1.0.14

Version Description

Download this release

Release Info

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

Code changes from version 1.0.13 to 1.0.14

astra-sites.php CHANGED
@@ -3,7 +3,7 @@
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.13
7
  * Author: Brainstorm Force
8
  * Author URI: http://www.brainstormforce.com
9
  * Text Domain: astra-sites
@@ -15,11 +15,11 @@
15
  * Set constants.
16
  */
17
  if ( ! defined( 'ASTRA_SITES_NAME' ) ) {
18
- define( 'ASTRA_SITES_NAME', __( 'Astra Sites', 'astra-sites' ) );
19
  }
20
 
21
  if ( ! defined( 'ASTRA_SITES_VER' ) ) {
22
- define( 'ASTRA_SITES_VER', '1.0.13' );
23
  }
24
 
25
  if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
@@ -31,11 +31,11 @@ if ( ! defined( 'ASTRA_SITES_BASE' ) ) {
31
  }
32
 
33
  if ( ! defined( 'ASTRA_SITES_DIR' ) ) {
34
- define( 'ASTRA_SITES_DIR', plugin_dir_path( ASTRA_SITES_FILE ) );
35
  }
36
 
37
  if ( ! defined( 'ASTRA_SITES_URI' ) ) {
38
- define( 'ASTRA_SITES_URI', plugins_url( '/', ASTRA_SITES_FILE ) );
39
  }
40
 
41
  if ( ! function_exists( 'astra_sites_setup' ) ) :
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
15
  * Set constants.
16
  */
17
  if ( ! defined( 'ASTRA_SITES_NAME' ) ) {
18
+ define( 'ASTRA_SITES_NAME', __( 'Astra Sites', 'astra-sites' ) );
19
  }
20
 
21
  if ( ! defined( 'ASTRA_SITES_VER' ) ) {
22
+ define( 'ASTRA_SITES_VER', '1.0.14' );
23
  }
24
 
25
  if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
31
  }
32
 
33
  if ( ! defined( 'ASTRA_SITES_DIR' ) ) {
34
+ define( 'ASTRA_SITES_DIR', plugin_dir_path( ASTRA_SITES_FILE ) );
35
  }
36
 
37
  if ( ! defined( 'ASTRA_SITES_URI' ) ) {
38
+ define( 'ASTRA_SITES_URI', plugins_url( '/', ASTRA_SITES_FILE ) );
39
  }
40
 
41
  if ( ! function_exists( 'astra_sites_setup' ) ) :
inc/assets/css/admin.css CHANGED
@@ -80,7 +80,7 @@
80
  }
81
 
82
  .expanded .wp-full-overlay-footer {
83
- height: 100px;
84
  }
85
 
86
  .wp-full-overlay-footer .view-site,
@@ -235,4 +235,54 @@
235
  }
236
  #astra-sites-admin {
237
  height: 100vh;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  }
80
  }
81
 
82
  .expanded .wp-full-overlay-footer {
83
+ height: 111px;
84
  }
85
 
86
  .wp-full-overlay-footer .view-site,
235
  }
236
  #astra-sites-admin {
237
  height: 100vh;
238
+ }
239
+
240
+ .astra-sites-suggestions:before {
241
+ border: 5px dashed #ccc;
242
+ position: absolute;
243
+ left: 0;
244
+ right: 0;
245
+ top: 0;
246
+ bottom: 0px;
247
+ }
248
+
249
+ .astra-sites-suggestions {
250
+ min-height: 280px;
251
+ border: none !important;
252
+ }
253
+
254
+ .astra-sites-suggestions a {
255
+ border: none;
256
+ outline: none;
257
+ }
258
+
259
+ .astra-sites-suggestions .inner {
260
+ border: 6px solid #24282e !important;
261
+ padding: 27% 10% 50% 10%;
262
+ text-align: center;
263
+ position: absolute;
264
+ left: 0;
265
+ right: 0;
266
+ top: 0;
267
+ background: #33383d;
268
+ bottom: 0;
269
+ color: #eee;
270
+ cursor: auto;
271
+ }
272
+
273
+ .astra-sites-suggestions .inner a {
274
+ color: #00b9eb;
275
+ }
276
+
277
+ .astra-sites-suggestions p {
278
+ font-size: 1rem;
279
+ margin: 0;
280
+ }
281
+
282
+ .astra-notice {
283
+ margin: 2em 2em 0em 0em;
284
+ }
285
+
286
+ .no-themes .description {
287
+ display: block;
288
  }
inc/assets/js/admin-page.js CHANGED
@@ -93,6 +93,7 @@ var AstraSitesAjaxQueue = (function() {
93
  */
94
  _bind: function()
95
  {
 
96
  $( document ).on('click' , '.theme-browser .theme-screenshot, .theme-browser .more-details, .theme-browser .install-theme-preview', AstraSitesAdmin._preview);
97
  $( document ).on('click' , '.next-theme', AstraSitesAdmin._nextTheme);
98
  $( document ).on('click' , '.previous-theme', AstraSitesAdmin._previousTheme);
@@ -104,7 +105,35 @@ var AstraSitesAjaxQueue = (function() {
104
  $( document ).on('wp-plugin-installing' , AstraSitesAdmin._pluginInstalling);
105
  $( document ).on('wp-plugin-install-error' , AstraSitesAdmin._installError);
106
  $( document ).on('wp-plugin-install-success' , AstraSitesAdmin._installSuccess);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
 
 
 
 
108
  },
109
 
110
  /**
@@ -431,7 +460,7 @@ var AstraSitesAjaxQueue = (function() {
431
 
432
  if ( typeof disabled !== 'undefined' && disabled === 'disabled' ) {
433
 
434
- $this.addClass('updating-message')
435
  .text( wp.updates.l10n.installing );
436
 
437
  /**
@@ -447,7 +476,7 @@ var AstraSitesAjaxQueue = (function() {
447
  return;
448
  }
449
 
450
- jQuery('.astra-demo-import').attr('data-import', 'disabled')
451
  .addClass('updating-message installing')
452
  .text( astraSitesAdmin.strings.importingDemo );
453
 
@@ -457,7 +486,7 @@ var AstraSitesAjaxQueue = (function() {
457
 
458
  var apiURL = $theme.data('demo-api') || '';
459
 
460
- jQuery.ajax({
461
  url: astraSitesAdmin.ajaxurl,
462
  type: 'POST',
463
  dataType: 'json',
@@ -814,7 +843,7 @@ var AstraSitesAjaxQueue = (function() {
814
 
815
  jQuery('.astra-demo-import')
816
  .removeAttr('data-import')
817
- .removeClass('updating-message')
818
  .addClass('button-primary')
819
  .text( astraSitesAdmin.strings.importDemo );
820
  }
93
  */
94
  _bind: function()
95
  {
96
+ $( document ).on('click' , '.devices button', AstraSitesAdmin._previewDevice);
97
  $( document ).on('click' , '.theme-browser .theme-screenshot, .theme-browser .more-details, .theme-browser .install-theme-preview', AstraSitesAdmin._preview);
98
  $( document ).on('click' , '.next-theme', AstraSitesAdmin._nextTheme);
99
  $( document ).on('click' , '.previous-theme', AstraSitesAdmin._previousTheme);
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
+ /**
111
+ * Preview Device
112
+ */
113
+ _previewDevice: function( event ) {
114
+ var device = $( event.currentTarget ).data( 'device' );
115
+
116
+ $('.theme-install-overlay')
117
+ .removeClass( 'preview-desktop preview-tablet preview-mobile' )
118
+ .addClass( 'preview-' + device )
119
+ .data( 'current-preview-device', device );
120
+
121
+ AstraSitesAdmin._tooglePreviewDeviceButtons( device );
122
+ },
123
+
124
+ /**
125
+ * Toggle Preview Buttons
126
+ */
127
+ _tooglePreviewDeviceButtons: function( newDevice ) {
128
+ var $devices = $( '.wp-full-overlay-footer .devices' );
129
+
130
+ $devices.find( 'button' )
131
+ .removeClass( 'active' )
132
+ .attr( 'aria-pressed', false );
133
 
134
+ $devices.find( 'button.preview-' + newDevice )
135
+ .addClass( 'active' )
136
+ .attr( 'aria-pressed', true );
137
  },
138
 
139
  /**
460
 
461
  if ( typeof disabled !== 'undefined' && disabled === 'disabled' ) {
462
 
463
+ $('.astra-demo-import').addClass('updating-message installing')
464
  .text( wp.updates.l10n.installing );
465
 
466
  /**
476
  return;
477
  }
478
 
479
+ $('.astra-demo-import').attr('data-import', 'disabled')
480
  .addClass('updating-message installing')
481
  .text( astraSitesAdmin.strings.importingDemo );
482
 
486
 
487
  var apiURL = $theme.data('demo-api') || '';
488
 
489
+ $.ajax({
490
  url: astraSitesAdmin.ajaxurl,
491
  type: 'POST',
492
  dataType: 'json',
843
 
844
  jQuery('.astra-demo-import')
845
  .removeAttr('data-import')
846
+ .removeClass('installing updating-message')
847
  .addClass('button-primary')
848
  .text( astraSitesAdmin.strings.importDemo );
849
  }
inc/assets/js/astra-sites-api.js CHANGED
@@ -16,7 +16,6 @@
16
  cache: false,
17
  };
18
 
19
- // Set API Request Header.
20
  if( astraRenderGrid.headers ) {
21
  data.headers = astraRenderGrid.headers;
22
  }
16
  cache: false,
17
  };
18
 
 
19
  if( astraRenderGrid.headers ) {
20
  data.headers = astraRenderGrid.headers;
21
  }
inc/assets/js/render-grid.js CHANGED
@@ -33,7 +33,8 @@
33
  */
34
  _bind: function()
35
  {
36
- $( document ).on('astra-sites-api-request-fail' , AstraRender._apiFailed );
 
37
  $( document ).on('astra-api-post-loaded-on-scroll' , AstraRender._reinitGridScrolled );
38
  $( document ).on('astra-api-post-loaded' , AstraRender._reinitGrid );
39
  $( document ).on('astra-api-category-loaded' , AstraRender._addFilters );
@@ -64,8 +65,15 @@
64
  $(this).addClass('current');
65
 
66
  // Prepare Before Search.
67
- $('#wp-filter-search-input').val('');
 
 
 
 
 
 
68
  $('#astra-sites').hide().css('height', '');
 
69
  $('body').addClass('loading-content');
70
  $('#astra-sites-admin').find('.spinner').removeClass('hide-me');
71
 
@@ -88,6 +96,9 @@
88
 
89
  // Prepare Before Search.
90
  $('#astra-sites').hide().css('height', '');
 
 
 
91
  $('body').addClass('loading-content');
92
  $('#astra-sites-admin').find('.spinner').removeClass('hide-me');
93
 
@@ -136,18 +147,6 @@
136
  }
137
  },
138
 
139
- /**
140
- * Lazy Load Images
141
- *
142
- * @see http://jquery.eisbehr.de/lazy/#features
143
- */
144
- _lazyLoad: function() {
145
-
146
- $('#astra-sites img').Lazy({
147
- effect: 'fadeIn',
148
- });
149
- },
150
-
151
  _apiAddParam_status: function() {
152
  if( astraRenderGrid.sites && astraRenderGrid.sites.status ) {
153
  AstraRender._api_params['status'] = astraRenderGrid.sites.status;
@@ -164,7 +163,7 @@
164
 
165
  _apiAddParam_per_page: function() {
166
  // Add 'per_page'
167
- var per_page_val = 3;
168
  if( astraRenderGrid.sites && astraRenderGrid.sites["par-page"] ) {
169
  per_page_val = parseInt( astraRenderGrid.sites["par-page"] );
170
  }
@@ -394,8 +393,6 @@
394
  setTimeout(function() {
395
  jQuery('#astra-sites').append(template( data ));
396
 
397
- AstraRender._lazyLoad();
398
-
399
  AstraRender._imagesLoaded();
400
  }, 800);
401
  } else {
@@ -424,14 +421,15 @@
424
 
425
  jQuery('#astra-sites').show().html(template( data ));
426
 
427
- AstraRender._lazyLoad();
428
-
429
  AstraRender._imagesLoaded();
430
 
431
  $('#astra-sites-admin').find('.spinner').removeClass('is-active');
432
 
433
  if( data.items_count <= 0 ) {
434
  $('#astra-sites-admin').find('.spinner').removeClass('is-active');
 
 
 
435
  } else {
436
  $('body').removeClass('listed-all-sites');
437
  }
@@ -461,10 +459,16 @@
461
  },
462
 
463
  /**
464
- * API Request Failed/Not found any demos.
465
  */
466
- _apiFailed: function() {
467
  $('#astra-sites-admin').find('.spinner').removeClass('is-active').addClass('hide-me');
 
 
 
 
 
 
468
  },
469
 
470
  /**
33
  */
34
  _bind: function()
35
  {
36
+ $( document ).on('astra-sites-api-request-error' , AstraRender._addSuggestionBox );
37
+ $( document ).on('astra-sites-api-request-fail' , AstraRender._addSuggestionBox );
38
  $( document ).on('astra-api-post-loaded-on-scroll' , AstraRender._reinitGridScrolled );
39
  $( document ).on('astra-api-post-loaded' , AstraRender._reinitGrid );
40
  $( document ).on('astra-api-category-loaded' , AstraRender._addFilters );
65
  $(this).addClass('current');
66
 
67
  // Prepare Before Search.
68
+ $('.no-more-demos').addClass('hide-me');
69
+ $('.astra-sites-suggestions').remove();
70
+
71
+ // Empty the search input only click on category filter not on page builder filter.
72
+ if( $(this).parents('.filter-links').hasClass('astra-site-category') ) {
73
+ $('#wp-filter-search-input').val('');
74
+ }
75
  $('#astra-sites').hide().css('height', '');
76
+
77
  $('body').addClass('loading-content');
78
  $('#astra-sites-admin').find('.spinner').removeClass('hide-me');
79
 
96
 
97
  // Prepare Before Search.
98
  $('#astra-sites').hide().css('height', '');
99
+ $('.no-more-demos').addClass('hide-me');
100
+ $('.astra-sites-suggestions').remove();
101
+
102
  $('body').addClass('loading-content');
103
  $('#astra-sites-admin').find('.spinner').removeClass('hide-me');
104
 
147
  }
148
  },
149
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  _apiAddParam_status: function() {
151
  if( astraRenderGrid.sites && astraRenderGrid.sites.status ) {
152
  AstraRender._api_params['status'] = astraRenderGrid.sites.status;
163
 
164
  _apiAddParam_per_page: function() {
165
  // Add 'per_page'
166
+ var per_page_val = 15;
167
  if( astraRenderGrid.sites && astraRenderGrid.sites["par-page"] ) {
168
  per_page_val = parseInt( astraRenderGrid.sites["par-page"] );
169
  }
393
  setTimeout(function() {
394
  jQuery('#astra-sites').append(template( data ));
395
 
 
 
396
  AstraRender._imagesLoaded();
397
  }, 800);
398
  } else {
421
 
422
  jQuery('#astra-sites').show().html(template( data ));
423
 
 
 
424
  AstraRender._imagesLoaded();
425
 
426
  $('#astra-sites-admin').find('.spinner').removeClass('is-active');
427
 
428
  if( data.items_count <= 0 ) {
429
  $('#astra-sites-admin').find('.spinner').removeClass('is-active');
430
+ $('.no-more-demos').addClass('hide-me');
431
+ $('.astra-sites-suggestions').remove();
432
+
433
  } else {
434
  $('body').removeClass('listed-all-sites');
435
  }
459
  },
460
 
461
  /**
462
+ * Add Suggestion Box
463
  */
464
+ _addSuggestionBox: function() {
465
  $('#astra-sites-admin').find('.spinner').removeClass('is-active').addClass('hide-me');
466
+
467
+ $('#astra-sites-admin').find('.no-more-demos').removeClass('hide-me');
468
+ var template = wp.template('astra-sites-suggestions');
469
+ if( ! $( '.astra-sites-suggestions').length ) {
470
+ $('#astra-sites').append( template );
471
+ }
472
  },
473
 
474
  /**
inc/classes/class-astra-sites-importer.php CHANGED
@@ -30,7 +30,7 @@ if ( ! class_exists( 'Astra_Sites_Importer' ) ) :
30
  *
31
  * @return object Class object.
32
  */
33
- public static function set_instance() {
34
  if ( ! isset( self::$_instance ) ) {
35
  self::$_instance = new self;
36
  }
@@ -51,8 +51,10 @@ 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
- add_action( 'wp_ajax_astra-import-demo', array( $this, 'demo_ajax_import' ) );
55
- add_action( 'astra_sites_image_import_complete', array( $this, 'clear_cache' ) );
 
 
56
 
57
  }
58
 
@@ -125,7 +127,7 @@ if ( ! class_exists( 'Astra_Sites_Importer' ) ) :
125
  *
126
  * @param (Object) $data Widgets data.
127
  */
128
- private function import_widgets( $data ) {
129
 
130
  // bail if widgets data is not available.
131
  if ( null == $data ) {
@@ -143,7 +145,7 @@ if ( ! class_exists( 'Astra_Sites_Importer' ) ) :
143
  *
144
  * @param (Array) $options_404 404 Extensions settings from the demo.
145
  */
146
- private function import_custom_404_extension_options( $options_404 ) {
147
  if ( is_callable( 'Astra_Admin_Helper::update_admin_settings_option' ) ) {
148
  Astra_Admin_Helper::update_admin_settings_option( '_astra_ext_custom_404', $options_404 );
149
  }
@@ -156,7 +158,7 @@ if ( ! class_exists( 'Astra_Sites_Importer' ) ) :
156
  *
157
  * @param (Array) $options Array of required site options from the demo.
158
  */
159
- private function import_site_options( $options ) {
160
  $options_importer = Astra_Site_Options_Import::instance();
161
  $options_importer->import_options( $options );
162
  }
@@ -168,7 +170,7 @@ if ( ! class_exists( 'Astra_Sites_Importer' ) ) :
168
  *
169
  * @param (String) $wxr_url URL of the xml export of the demo to be imported.
170
  */
171
- private function import_wxr( $wxr_url ) {
172
  $wxr_importer = Astra_WXR_Importer::instance();
173
  $xml_path = $wxr_importer->download_xml( $wxr_url );
174
  $wxr_importer->import_xml( $xml_path['file'] );
@@ -181,7 +183,7 @@ if ( ! class_exists( 'Astra_Sites_Importer' ) ) :
181
  *
182
  * @param (Array) $customizer_data Customizer data for the demo to be imported.
183
  */
184
- private function import_customizer_settings( $customizer_data ) {
185
  $customizer_import = Astra_Customizer_Import::instance();
186
  $customizer_data = $customizer_import->import( $customizer_data );
187
  }
@@ -193,7 +195,7 @@ if ( ! class_exists( 'Astra_Sites_Importer' ) ) :
193
  *
194
  * @param (Array) $saved_extensions Array of enabled extensions.
195
  */
196
- private function import_astra_enabled_extension( $saved_extensions ) {
197
  if ( is_callable( 'Astra_Admin_Helper::update_admin_settings_option' ) ) {
198
  Astra_Admin_Helper::update_admin_settings_option( '_astra_ext_enabled_extensions', $saved_extensions );
199
  }
@@ -244,7 +246,7 @@ if ( ! class_exists( 'Astra_Sites_Importer' ) ) :
244
 
245
  if ( ! is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) === 200 ) {
246
 
247
- $result = json_decode( wp_remote_retrieve_body( $response ), true );
248
 
249
  if ( ! isset( $result['code'] ) ) {
250
  $remote_args['id'] = $result['id'];
@@ -283,8 +285,8 @@ if ( ! class_exists( 'Astra_Sites_Importer' ) ) :
283
  }
284
 
285
  /**
286
- * Kicking this off by calling 'set_instance()' method
287
  */
288
- Astra_Sites_Importer::set_instance();
289
 
290
  endif;
30
  *
31
  * @return object Class object.
32
  */
33
+ public static function get_instance() {
34
  if ( ! isset( self::$_instance ) ) {
35
  self::$_instance = new self;
36
  }
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
 
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 ) {
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
  }
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
  }
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'] );
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
  }
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
  }
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'];
285
  }
286
 
287
  /**
288
+ * Kicking this off by calling 'get_instance()' method
289
  */
290
+ Astra_Sites_Importer::get_instance();
291
 
292
  endif;
inc/classes/class-astra-sites-notices.php CHANGED
@@ -39,7 +39,7 @@ if ( ! class_exists( 'Astra_Sites_Notices' ) ) :
39
  * @since 1.0.8
40
  * @return object initialized object of class.
41
  */
42
- public static function set_instance() {
43
  if ( ! isset( self::$instance ) ) {
44
  self::$instance = new self;
45
  }
@@ -53,9 +53,9 @@ if ( ! class_exists( 'Astra_Sites_Notices' ) ) :
53
  */
54
  public function __construct() {
55
 
56
- add_action( 'admin_notices', array( $this, 'show_notices' ) );
57
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
58
- add_action( 'wp_ajax_astra-notices', array( $this, 'dismiss' ) );
59
 
60
  }
61
 
@@ -118,16 +118,16 @@ if ( ! class_exists( 'Astra_Sites_Notices' ) ) :
118
  function show_notices() {
119
 
120
  $defaults = array(
121
- 'type' => 'info',
122
- 'show_if' => true,
123
- 'message' => '',
124
- 'class' => 'ast-active-notice',
125
-
126
- 'dismissible' => false,
127
  'dismissible-meta' => 'user',
128
- 'dismissible-time' => MINUTE_IN_SECONDS,
129
 
130
- 'data' => '',
131
  );
132
 
133
  foreach ( self::$notices as $key => $notice ) {
@@ -150,15 +150,20 @@ if ( ! class_exists( 'Astra_Sites_Notices' ) ) :
150
  }
151
 
152
  // Notice ID.
153
- $notice_id = 'astra-sites-notices-id-' . $key;
154
- $notice['id'] = $notice_id;
 
 
 
 
 
155
  $notice['classes'] = implode( ' ', $classes );
156
 
157
  // User meta.
158
- $notice['data'] = ' dismissible-meta=' . esc_attr( $notice['dismissible-meta'] ) . ' ';
159
  if ( 'user' === $notice['dismissible-meta'] ) {
160
  $expired = get_user_meta( get_current_user_id(), $notice_id, true );
161
- } else {
162
  $expired = get_transient( $notice_id );
163
  }
164
 
@@ -204,8 +209,8 @@ if ( ! class_exists( 'Astra_Sites_Notices' ) ) :
204
  }
205
 
206
  /**
207
- * Kicking this off by calling 'set_instance()' method
208
  */
209
- Astra_Sites_Notices::set_instance();
210
 
211
  endif;
39
  * @since 1.0.8
40
  * @return object initialized object of class.
41
  */
42
+ public static function get_instance() {
43
  if ( ! isset( self::$instance ) ) {
44
  self::$instance = new self;
45
  }
53
  */
54
  public function __construct() {
55
 
56
+ add_action( 'admin_notices', array( $this, 'show_notices' ) );
57
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
58
+ add_action( 'wp_ajax_astra-notices', array( $this, 'dismiss' ) );
59
 
60
  }
61
 
118
  function show_notices() {
119
 
120
  $defaults = array(
121
+ 'id' => '',
122
+ 'type' => 'info',
123
+ 'show_if' => true,
124
+ 'message' => '',
125
+ 'class' => 'astra-active-notice',
126
+ 'dismissible' => false,
127
  'dismissible-meta' => 'user',
128
+ 'dismissible-time' => WEEK_IN_SECONDS,
129
 
130
+ 'data' => '',
131
  );
132
 
133
  foreach ( self::$notices as $key => $notice ) {
150
  }
151
 
152
  // Notice ID.
153
+ if ( ! isset( $notice['id'] ) ) {
154
+ $notice_id = 'astra-sites-notices-id-' . $key;
155
+ $notice['id'] = $notice_id;
156
+ } else {
157
+ $notice_id = $notice['id'];
158
+ }
159
+
160
  $notice['classes'] = implode( ' ', $classes );
161
 
162
  // User meta.
163
+ $notice['data'] .= ' dismissible-meta=' . esc_attr( $notice['dismissible-meta'] ) . ' ';
164
  if ( 'user' === $notice['dismissible-meta'] ) {
165
  $expired = get_user_meta( get_current_user_id(), $notice_id, true );
166
+ } elseif ( 'transient' === $notice['dismissible-meta'] ) {
167
  $expired = get_transient( $notice_id );
168
  }
169
 
209
  }
210
 
211
  /**
212
+ * Kicking this off by calling 'get_instance()' method
213
  */
214
+ Astra_Sites_Notices::get_instance();
215
 
216
  endif;
inc/classes/class-astra-sites-page.php CHANGED
@@ -82,7 +82,7 @@ if ( ! class_exists( 'Astra_Sites_Page' ) ) {
82
  */
83
  static public function init_admin_settings() {
84
 
85
- self::$menu_page_title = apply_filters( 'astra_sites_menu_page_title', __( 'Astra Sites' , 'astra-sites' ) );
86
 
87
  if ( isset( $_REQUEST['page'] ) && strpos( $_REQUEST['page'], self::$plugin_slug ) !== false ) {
88
 
82
  */
83
  static public function init_admin_settings() {
84
 
85
+ self::$menu_page_title = apply_filters( 'astra_sites_menu_page_title', __( 'Astra Sites', 'astra-sites' ) );
86
 
87
  if ( isset( $_REQUEST['page'] ) && strpos( $_REQUEST['page'], self::$plugin_slug ) !== false ) {
88
 
inc/classes/class-astra-sites-white-label.php CHANGED
@@ -42,7 +42,7 @@ if ( ! class_exists( 'Astra_Sites_White_Label' ) ) :
42
  *
43
  * @return object initialized object of class.
44
  */
45
- public static function set_instance() {
46
  if ( ! isset( self::$instance ) ) {
47
  self::$instance = new self;
48
  }
@@ -56,10 +56,10 @@ if ( ! class_exists( 'Astra_Sites_White_Label' ) ) :
56
  */
57
  public function __construct() {
58
 
59
- add_filter( 'all_plugins' , array( $this, 'plugins_page' ) );
60
- add_filter( 'astra_addon_branding_options' , __CLASS__ . '::settings' );
61
- add_action( 'astra_pro_white_label_add_form' , __CLASS__ . '::add_white_lavel_form' );
62
- add_filter( 'astra_sites_menu_page_title' , array( $this, 'page_title' ) );
63
 
64
  // Display the link with the plugin meta.
65
  if ( is_admin() ) {
@@ -155,8 +155,8 @@ if ( ! class_exists( 'Astra_Sites_White_Label' ) ) :
155
  public static function settings( $settings = array() ) {
156
 
157
  $settings['astra-sites'] = array(
158
- 'name' => '',
159
- 'description' => '',
160
  );
161
 
162
  return $settings;
@@ -201,8 +201,8 @@ if ( ! class_exists( 'Astra_Sites_White_Label' ) ) :
201
  }
202
 
203
  /**
204
- * Kicking this off by calling 'set_instance()' method
205
  */
206
- Astra_Sites_White_Label::set_instance();
207
 
208
  endif;
42
  *
43
  * @return object initialized object of class.
44
  */
45
+ public static function get_instance() {
46
  if ( ! isset( self::$instance ) ) {
47
  self::$instance = new self;
48
  }
56
  */
57
  public function __construct() {
58
 
59
+ add_filter( 'all_plugins', array( $this, 'plugins_page' ) );
60
+ add_filter( 'astra_addon_branding_options', __CLASS__ . '::settings' );
61
+ add_action( 'astra_pro_white_label_add_form', __CLASS__ . '::add_white_lavel_form' );
62
+ add_filter( 'astra_sites_menu_page_title', array( $this, 'page_title' ) );
63
 
64
  // Display the link with the plugin meta.
65
  if ( is_admin() ) {
155
  public static function settings( $settings = array() ) {
156
 
157
  $settings['astra-sites'] = array(
158
+ 'name' => '',
159
+ 'description' => '',
160
  );
161
 
162
  return $settings;
201
  }
202
 
203
  /**
204
+ * Kicking this off by calling 'get_instance()' method
205
  */
206
+ Astra_Sites_White_Label::get_instance();
207
 
208
  endif;
inc/classes/class-astra-sites.php CHANGED
@@ -38,7 +38,7 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
38
  *
39
  * @return object Class object.
40
  */
41
- public static function set_instance() {
42
  if ( ! isset( self::$_instance ) ) {
43
  self::$_instance = new self;
44
  }
@@ -57,14 +57,14 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
57
 
58
  $this->includes();
59
 
60
- add_action( 'admin_notices', array( $this, 'add_notice' ), 1 );
61
- add_action( 'admin_notices', array( $this, 'admin_notices' ) );
62
- add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
63
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue' ) );
64
 
65
  // AJAX.
66
- add_action( 'wp_ajax_astra-required-plugins', array( $this, 'required_plugin' ) );
67
- add_action( 'wp_ajax_astra-required-plugin-activate', array( $this, 'required_plugin_activate' ) );
68
  }
69
 
70
  /**
@@ -74,12 +74,13 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
74
 
75
  Astra_Sites_Notices::add_notice(
76
  array(
77
- 'type' => 'error',
78
- 'show_if' => ( ! defined( 'ASTRA_THEME_SETTINGS' ) ) ? true : false,
 
79
  /* translators: 1: theme.php file*/
80
- 'message' => sprintf( __( 'Astra Theme needs to be active for you to use currently installed "%1$s" plugin. <a href="%2$s">Install & Activate Now</a>', 'astra-sites' ), ASTRA_SITES_NAME, esc_url( admin_url( 'themes.php?theme=astra' ) ) ),
81
- 'dismissible' => true,
82
- 'dismissible-time' => MINUTE_IN_SECONDS,
83
  )
84
  );
85
 
@@ -106,7 +107,7 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
106
  return;
107
  }
108
 
109
- add_action( 'plugin_action_links_' . ASTRA_SITES_BASE, array( $this, 'action_links' ) );
110
  }
111
 
112
  /**
@@ -150,26 +151,23 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
150
  return;
151
  }
152
 
153
- // Lazyload & Image Loaded.
154
- wp_register_script( 'astra-sites-lazyload', ASTRA_SITES_URI . 'inc/assets/vendor/js/jquery.lazy.min.js', array( 'jquery' ), ASTRA_SITES_VER, true );
155
-
156
  // API.
157
  wp_register_script( 'astra-sites-api', ASTRA_SITES_URI . 'inc/assets/js/astra-sites-api.js', array( 'jquery' ), ASTRA_SITES_VER, true );
158
 
159
  // Admin Page.
160
  wp_enqueue_style( 'astra-sites-admin', ASTRA_SITES_URI . 'inc/assets/css/admin.css', ASTRA_SITES_VER, true );
161
  wp_enqueue_script( 'astra-sites-admin-page', ASTRA_SITES_URI . 'inc/assets/js/admin-page.js', array( 'jquery', 'wp-util', 'updates' ), ASTRA_SITES_VER, true );
162
- wp_enqueue_script( 'astra-sites-render-grid', ASTRA_SITES_URI . 'inc/assets/js/render-grid.js', array( 'wp-util', 'astra-sites-api', 'imagesloaded', 'jquery', 'astra-sites-lazyload' ), ASTRA_SITES_VER, true );
163
 
164
  $data = array(
165
- 'ApiURL' => self::$api_url,
166
  'filters' => array(
167
  'page_builder' => array(
168
  'title' => __( 'Page Builder', 'astra-sites' ),
169
  'slug' => 'astra-site-page-builder',
170
  'trigger' => 'astra-api-category-loaded',
171
  ),
172
- 'categories' => array(
173
  'title' => __( 'Categories', 'astra-sites' ),
174
  'slug' => 'astra-site-category',
175
  'trigger' => 'astra-api-category-loaded',
@@ -183,7 +181,7 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
183
  'astra_sites_api_params', array(
184
  'purchase_key' => '',
185
  'site_url' => '',
186
- 'par-page' => 6,
187
  )
188
  );
189
 
@@ -211,7 +209,7 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
211
  'strings' => array(
212
  'importFailedBtnSmall' => __( 'Error!', 'astra-sites' ),
213
  'importFailedBtnLarge' => __( 'Error! Read Possibilities.', 'astra-sites' ),
214
- 'importFailedURL' => esc_url( 'https://wpastra.com/docs/?p=1314' ),
215
  'viewSite' => __( 'Done! View Site', 'astra-sites' ),
216
  'btnActivating' => __( 'Activating', 'astra-sites' ) . '&hellip;',
217
  'btnActive' => __( 'Active', 'astra-sites' ),
@@ -319,8 +317,8 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
319
 
320
  /**
321
  * Has Pro Version Support?
322
- * And
323
- * Is Pro Version Installed?
324
  */
325
  $plugin_pro = self::pro_plugin_exist( $plugin['init'] );
326
  if ( $plugin_pro ) {
@@ -405,8 +403,8 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
405
  }
406
 
407
  /**
408
- * Kicking this off by calling 'set_instance()' method
409
  */
410
- Astra_Sites::set_instance();
411
 
412
  endif;
38
  *
39
  * @return object Class object.
40
  */
41
+ public static function get_instance() {
42
  if ( ! isset( self::$_instance ) ) {
43
  self::$_instance = new self;
44
  }
57
 
58
  $this->includes();
59
 
60
+ add_action( 'admin_notices', array( $this, 'add_notice' ), 1 );
61
+ add_action( 'admin_notices', array( $this, 'admin_notices' ) );
62
+ add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
63
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue' ) );
64
 
65
  // AJAX.
66
+ add_action( 'wp_ajax_astra-required-plugins', array( $this, 'required_plugin' ) );
67
+ add_action( 'wp_ajax_astra-required-plugin-activate', array( $this, 'required_plugin_activate' ) );
68
  }
69
 
70
  /**
74
 
75
  Astra_Sites_Notices::add_notice(
76
  array(
77
+ 'id' => 'theme-activation-nag',
78
+ 'type' => 'error',
79
+ 'show_if' => ( ! defined( 'ASTRA_THEME_SETTINGS' ) ) ? true : false,
80
  /* translators: 1: theme.php file*/
81
+ 'message' => sprintf( __( 'Astra Theme needs to be active for you to use currently installed "%1$s" plugin. <a href="%2$s">Install & Activate Now</a>', 'astra-sites' ), ASTRA_SITES_NAME, esc_url( admin_url( 'themes.php?theme=astra' ) ) ),
82
+ 'dismissible' => true,
83
+ 'dismissible-time' => WEEK_IN_SECONDS,
84
  )
85
  );
86
 
107
  return;
108
  }
109
 
110
+ add_action( 'plugin_action_links_' . ASTRA_SITES_BASE, array( $this, 'action_links' ) );
111
  }
112
 
113
  /**
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
 
157
  // Admin Page.
158
  wp_enqueue_style( 'astra-sites-admin', ASTRA_SITES_URI . 'inc/assets/css/admin.css', ASTRA_SITES_VER, true );
159
  wp_enqueue_script( 'astra-sites-admin-page', ASTRA_SITES_URI . 'inc/assets/js/admin-page.js', array( 'jquery', 'wp-util', 'updates' ), ASTRA_SITES_VER, true );
160
+ wp_enqueue_script( 'astra-sites-render-grid', ASTRA_SITES_URI . 'inc/assets/js/render-grid.js', array( 'wp-util', 'astra-sites-api', 'imagesloaded', 'jquery' ), ASTRA_SITES_VER, true );
161
 
162
  $data = array(
163
+ 'ApiURL' => self::$api_url,
164
  'filters' => array(
165
  'page_builder' => array(
166
  'title' => __( 'Page Builder', 'astra-sites' ),
167
  'slug' => 'astra-site-page-builder',
168
  'trigger' => 'astra-api-category-loaded',
169
  ),
170
+ 'categories' => array(
171
  'title' => __( 'Categories', 'astra-sites' ),
172
  'slug' => 'astra-site-category',
173
  'trigger' => 'astra-api-category-loaded',
181
  'astra_sites_api_params', array(
182
  'purchase_key' => '',
183
  'site_url' => '',
184
+ 'par-page' => 15,
185
  )
186
  );
187
 
209
  'strings' => array(
210
  'importFailedBtnSmall' => __( 'Error!', 'astra-sites' ),
211
  'importFailedBtnLarge' => __( 'Error! Read Possibilities.', 'astra-sites' ),
212
+ 'importFailedURL' => esc_url( 'https://wpastra.com/docs/?p=1314&utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=import-failed' ),
213
  'viewSite' => __( 'Done! View Site', 'astra-sites' ),
214
  'btnActivating' => __( 'Activating', 'astra-sites' ) . '&hellip;',
215
  'btnActive' => __( 'Active', 'astra-sites' ),
317
 
318
  /**
319
  * Has Pro Version Support?
320
+ * And
321
+ * Is Pro Version Installed?
322
  */
323
  $plugin_pro = self::pro_plugin_exist( $plugin['init'] );
324
  if ( $plugin_pro ) {
403
  }
404
 
405
  /**
406
+ * Kicking this off by calling 'get_instance()' method
407
  */
408
+ Astra_Sites::get_instance();
409
 
410
  endif;
inc/classes/compatibility/class-astra-sites-compatibility.php CHANGED
@@ -44,21 +44,13 @@ if ( ! class_exists( 'Astra_Sites_Compatibility' ) ) :
44
  */
45
  public function __construct() {
46
 
47
- // Background Processing.
48
- require_once ASTRA_SITES_DIR . 'inc/classes/vendor/wp-async-request.php';
49
- require_once ASTRA_SITES_DIR . 'inc/classes/vendor/wp-background-process.php';
50
-
51
  // Plugin - Astra Pro.
52
  require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/astra-pro/class-astra-sites-compatibility-astra-pro.php';
53
 
54
  // Plugin - Site Origin Widgets.
55
  require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/so-widgets-bundle/class-astra-sites-compatibility-so-widgets.php';
56
-
57
- // Plugin - Elementor.
58
- require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/elementor/class-astra-sites-compatibility-elementor.php';
59
  }
60
 
61
-
62
  }
63
 
64
  /**
@@ -67,3 +59,5 @@ if ( ! class_exists( 'Astra_Sites_Compatibility' ) ) :
67
  Astra_Sites_Compatibility::instance();
68
 
69
  endif;
 
 
44
  */
45
  public function __construct() {
46
 
 
 
 
 
47
  // Plugin - Astra Pro.
48
  require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/astra-pro/class-astra-sites-compatibility-astra-pro.php';
49
 
50
  // Plugin - Site Origin Widgets.
51
  require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/so-widgets-bundle/class-astra-sites-compatibility-so-widgets.php';
 
 
 
52
  }
53
 
 
54
  }
55
 
56
  /**
59
  Astra_Sites_Compatibility::instance();
60
 
61
  endif;
62
+
63
+
inc/importers/batch-processing/class-astra-sites-batch-processing-beaver-builder.php ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Batch Processing
4
+ *
5
+ * @package Astra Sites
6
+ * @since 1.0.14
7
+ */
8
+
9
+ if ( ! class_exists( 'Astra_Sites_Batch_Processing_Beaver_Builder' ) ) :
10
+
11
+ /**
12
+ * Astra_Sites_Batch_Processing_Beaver_Builder
13
+ *
14
+ * @since 1.0.14
15
+ */
16
+ class Astra_Sites_Batch_Processing_Beaver_Builder {
17
+
18
+ /**
19
+ * Instance
20
+ *
21
+ * @since 1.0.14
22
+ * @access private
23
+ * @var object Class object.
24
+ */
25
+ private static $instance;
26
+
27
+ /**
28
+ * Initiator
29
+ *
30
+ * @since 1.0.14
31
+ * @return object initialized object of class.
32
+ */
33
+ public static function get_instance() {
34
+
35
+ if ( ! isset( self::$instance ) ) {
36
+ self::$instance = new self;
37
+ }
38
+ return self::$instance;
39
+ }
40
+
41
+ /**
42
+ * Constructor
43
+ *
44
+ * @since 1.0.14
45
+ */
46
+ public function __construct() {
47
+ }
48
+
49
+ /**
50
+ * Import
51
+ *
52
+ * @since 1.0.14
53
+ * @return void
54
+ */
55
+ public function import() {
56
+
57
+ Astra_Sites_Image_Importer::log( '---- Processing WordPress Posts / Pages - for Beaver Builder ----' );
58
+
59
+ $post_ids = Astra_Sites_Batch_Processing::get_pages();
60
+ if ( is_array( $post_ids ) ) {
61
+ foreach ( $post_ids as $post_id ) {
62
+ $this->import_single_post( $post_id );
63
+ }
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Update post meta.
69
+ *
70
+ * @param integer $post_id Post ID.
71
+ * @return void
72
+ */
73
+ public function import_single_post( $post_id = 0 ) {
74
+
75
+ Astra_Sites_Image_Importer::log( 'Post ID: ' . $post_id );
76
+
77
+ if ( ! empty( $post_id ) ) {
78
+
79
+ // Get page builder data.
80
+ $data = get_post_meta( $post_id, '_fl_builder_data', true );
81
+
82
+ if ( ! empty( $data ) ) {
83
+ foreach ( $data as $key => $el ) {
84
+
85
+ // Import 'row' images.
86
+ if ( 'row' === $el->type ) {
87
+ $data[ $key ]->settings = self::import_row_images( $el->settings );
88
+ }
89
+
90
+ // Import 'module' images.
91
+ if ( 'module' === $el->type ) {
92
+ $data[ $key ]->settings = self::import_module_images( $el->settings );
93
+ }
94
+
95
+ // Import 'column' images.
96
+ if ( 'column' === $el->type ) {
97
+ $data[ $key ]->settings = self::import_column_images( $el->settings );
98
+ }
99
+ }
100
+
101
+ // Update page builder data.
102
+ update_post_meta( $post_id, '_fl_builder_data', $data );
103
+ update_post_meta( $post_id, '_fl_builder_draft', $data );
104
+
105
+ // Clear all cache.
106
+ FLBuilderModel::delete_asset_cache_for_all_posts();
107
+ }
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Import Module Images.
113
+ *
114
+ * @param object $settings Module settings object.
115
+ * @return object
116
+ */
117
+ public static function import_module_images( $settings ) {
118
+
119
+ /**
120
+ * 1) Set photos.
121
+ */
122
+ $settings = self::import_photo( $settings );
123
+
124
+ /**
125
+ * 2) Set `$settings->data` for Only type 'image-icon'
126
+ *
127
+ * @todo Remove the condition `'image-icon' === $settings->type` if `$settings->data` is used only for the Image Icon.
128
+ */
129
+ if (
130
+ isset( $settings->data ) &&
131
+ isset( $settings->photo ) && ! empty( $settings->photo ) &&
132
+ 'image-icon' === $settings->type
133
+ ) {
134
+ $settings->data = FLBuilderPhoto::get_attachment_data( $settings->photo );
135
+ }
136
+
137
+ /**
138
+ * 3) Set `list item` module images
139
+ */
140
+ if ( isset( $settings->add_list_item ) ) {
141
+ foreach ( $settings->add_list_item as $key => $value ) {
142
+ $settings->add_list_item[ $key ] = self::import_photo( $value );
143
+ }
144
+ }
145
+
146
+ return $settings;
147
+ }
148
+
149
+ /**
150
+ * Import Column Images.
151
+ *
152
+ * @param object $settings Column settings object.
153
+ * @return object
154
+ */
155
+ public static function import_column_images( $settings ) {
156
+
157
+ // 1) Set BG Images.
158
+ $settings = self::import_bg_image( $settings );
159
+
160
+ return $settings;
161
+ }
162
+
163
+ /**
164
+ * Import Row Images.
165
+ *
166
+ * @param object $settings Row settings object.
167
+ * @return object
168
+ */
169
+ public static function import_row_images( $settings ) {
170
+
171
+ // 1) Set BG Images.
172
+ $settings = self::import_bg_image( $settings );
173
+
174
+ return $settings;
175
+ }
176
+
177
+ /**
178
+ * Helper: Import BG Images.
179
+ *
180
+ * @param object $settings Row settings object.
181
+ * @return object
182
+ */
183
+ public static function import_bg_image( $settings ) {
184
+
185
+ if (
186
+ ( ! empty( $settings->bg_image ) && ! empty( $settings->bg_image_src ) )
187
+ ) {
188
+ $image = array(
189
+ 'url' => $settings->bg_image_src,
190
+ 'id' => $settings->bg_image,
191
+ );
192
+
193
+ $downloaded_image = Astra_Sites_Image_Importer::get_instance()->import( $image );
194
+
195
+ $settings->bg_image_src = $downloaded_image['url'];
196
+ $settings->bg_image = $downloaded_image['id'];
197
+ }
198
+
199
+ return $settings;
200
+ }
201
+
202
+ /**
203
+ * Helper: Import Photo.
204
+ *
205
+ * @param object $settings Row settings object.
206
+ * @return object
207
+ */
208
+ public static function import_photo( $settings ) {
209
+
210
+ if ( ! empty( $settings->photo ) && ! empty( $settings->photo_src ) ) {
211
+
212
+ $image = array(
213
+ 'url' => $settings->photo_src,
214
+ 'id' => $settings->photo,
215
+ );
216
+
217
+ $downloaded_image = Astra_Sites_Image_Importer::get_instance()->import( $image );
218
+
219
+ $settings->photo_src = $downloaded_image['url'];
220
+ $settings->photo = $downloaded_image['id'];
221
+ }
222
+
223
+ return $settings;
224
+ }
225
+
226
+
227
+ }
228
+
229
+ /**
230
+ * Kicking this off by calling 'get_instance()' method
231
+ */
232
+ Astra_Sites_Batch_Processing_Beaver_Builder::get_instance();
233
+
234
+ endif;
235
+
236
+
inc/importers/batch-processing/class-astra-sites-batch-processing-elementor.php ADDED
@@ -0,0 +1,324 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Elementor Images Batch Processing
4
+ *
5
+ * @package Astra Sites
6
+ * @since 1.0.0
7
+ */
8
+
9
+ namespace Elementor;
10
+
11
+ // If plugin - 'Elementor' not exist then return.
12
+ if ( ! class_exists( '\Elementor\Plugin' ) ) {
13
+ return;
14
+ }
15
+
16
+ namespace Elementor\TemplateLibrary;
17
+
18
+ use Elementor\Core\Settings\Manager as SettingsManager;
19
+ use Elementor\TemplateLibrary\Classes\Import_Images;
20
+ use Elementor\TemplateLibrary;
21
+ use Elementor\TemplateLibrary\Classes;
22
+ use Elementor\Api;
23
+ use Elementor\PageSettings\Page;
24
+
25
+ // For working protected methods defined in.
26
+ // file '/elementor/includes/template-library/sources/base.php'.
27
+ use Elementor\Plugin;
28
+ use Elementor\Utils;
29
+
30
+ if ( ! defined( 'ABSPATH' ) ) {
31
+ exit; // Exit if accessed directly.
32
+ }
33
+
34
+ /**
35
+ * Astra Source Remote
36
+ */
37
+ class Astra_Sites_Batch_Processing_Elementor extends Source_Base {
38
+
39
+ /**
40
+ * Get ID
41
+ *
42
+ * @since 1.0.4
43
+ *
44
+ * @return string
45
+ */
46
+ public function get_id() {
47
+ return 'remote';
48
+ }
49
+
50
+ /**
51
+ * Get Title.
52
+ *
53
+ * @since 1.0.4
54
+ *
55
+ * @return string
56
+ */
57
+ public function get_title() {
58
+ return __( 'Remote', 'astra-sites' );
59
+ }
60
+
61
+ /**
62
+ * Get Data
63
+ *
64
+ * @since 1.0.4
65
+ *
66
+ * @return void
67
+ */
68
+ public function register_data() {}
69
+
70
+ /**
71
+ * Get Items
72
+ *
73
+ * @since 1.0.4
74
+ *
75
+ * @param array $args Arguments.
76
+ * @return array
77
+ */
78
+ public function get_items( $args = array() ) {
79
+ $templates_data = Api::get_templates_data();
80
+
81
+ $templates = array();
82
+
83
+ if ( ! empty( $templates_data ) ) {
84
+ foreach ( $templates_data as $template_data ) {
85
+ $templates[] = $this->get_item( $template_data );
86
+ }
87
+ }
88
+
89
+ if ( ! empty( $args ) ) {
90
+ $templates = wp_list_filter( $templates, $args );
91
+ }
92
+
93
+ return $templates;
94
+ }
95
+
96
+ /**
97
+ * Get Item
98
+ *
99
+ * @param array $template_data Template Data.
100
+ *
101
+ * @return array
102
+ */
103
+ public function get_item( $template_data ) {
104
+ return array(
105
+ 'template_id' => $template_data['id'],
106
+ 'source' => $this->get_id(),
107
+ 'title' => $template_data['title'],
108
+ 'thumbnail' => $template_data['thumbnail'],
109
+ 'date' => date( get_option( 'date_format' ), $template_data['tmpl_created'] ),
110
+ 'author' => $template_data['author'],
111
+ 'categories' => array(),
112
+ 'keywords' => array(),
113
+ 'isPro' => ( '1' === $template_data['is_pro'] ),
114
+ 'hasPageSettings' => ( '1' === $template_data['has_page_settings'] ),
115
+ 'url' => $template_data['url'],
116
+ );
117
+ }
118
+
119
+ /**
120
+ * Template Data
121
+ *
122
+ * @param boolean $template_data Template Data.
123
+ * @return boolean Return false.
124
+ */
125
+ public function save_item( $template_data ) {
126
+ return false;
127
+ }
128
+
129
+ /**
130
+ * Update Item
131
+ *
132
+ * @param boolean $new_data New Data.
133
+ * @return boolean Return false.
134
+ */
135
+ public function update_item( $new_data ) {
136
+ return false;
137
+ }
138
+
139
+ /**
140
+ * Delete Template
141
+ *
142
+ * @param boolean $template_id Template ID.
143
+ * @return boolean Return false.
144
+ */
145
+ public function delete_template( $template_id ) {
146
+ return false;
147
+ }
148
+
149
+ /**
150
+ * Delete Template
151
+ *
152
+ * @param boolean $template_id Template ID.
153
+ * @return boolean Return false.
154
+ */
155
+ public function export_template( $template_id ) {
156
+ return false;
157
+ }
158
+
159
+ /**
160
+ * Get Data
161
+ *
162
+ * @param array $args Arguments.
163
+ * @param string $context Context.
164
+ * @return array Data.
165
+ */
166
+ public function get_data( array $args, $context = 'display' ) {
167
+ $data = Api::get_template_content( $args['template_id'] );
168
+
169
+ if ( is_wp_error( $data ) ) {
170
+ return $data;
171
+ }
172
+
173
+ // TODO: since 1.5.0 to content container named `content` instead of `data`.
174
+ if ( ! empty( $data['data'] ) ) {
175
+ $data['content'] = $data['data'];
176
+ unset( $data['data'] );
177
+ }
178
+
179
+ $data['content'] = $this->replace_elements_ids( $data['content'] );
180
+ $data['content'] = $this->process_export_import_content( $data['content'], 'on_import' );
181
+
182
+ if ( ! empty( $args['page_settings'] ) && ! empty( $data['page_settings'] ) ) {
183
+ $page = new Page(
184
+ array(
185
+ 'settings' => $data['page_settings'],
186
+ )
187
+ );
188
+
189
+ $page_settings_data = $this->process_element_export_import_content( $page, 'on_import' );
190
+ $data['page_settings'] = $page_settings_data['settings'];
191
+ }
192
+
193
+ return $data;
194
+ }
195
+
196
+ /**
197
+ * Replace Elements Ids
198
+ *
199
+ * @param string $content Context.
200
+ * @return array Element.
201
+ */
202
+ public function replace_elements_ids( $content ) {
203
+ return Plugin::$instance->db->iterate_data(
204
+ $content, function( $element ) {
205
+ $element['id'] = Utils::generate_random_string();
206
+
207
+ return $element;
208
+ }
209
+ );
210
+ }
211
+
212
+ /**
213
+ * Process Import Content.
214
+ *
215
+ * @param array $content a set of elements.
216
+ * @param string $method (on_export|on_import).
217
+ *
218
+ * @return mixed
219
+ */
220
+ public function process_export_import_content( $content, $method ) {
221
+ return Plugin::$instance->db->iterate_data(
222
+ $content, function( $element_data ) use ( $method ) {
223
+ $element = Plugin::$instance->elements_manager->create_element_instance( $element_data );
224
+
225
+ // If the widget/element isn't exist, like a plugin that creates a widget but deactivated.
226
+ if ( ! $element ) {
227
+ return null;
228
+ }
229
+
230
+ return $this->process_element_export_import_content( $element, $method );
231
+ }
232
+ );
233
+ }
234
+
235
+ /**
236
+ * Process Element/Export Import Content.
237
+ *
238
+ * @param \Elementor\Controls_Stack $element Element.
239
+ * @param string $method Method.
240
+ *
241
+ * @return array
242
+ */
243
+ public function process_element_export_import_content( $element, $method ) {
244
+ $element_data = $element->get_data();
245
+
246
+ if ( method_exists( $element, $method ) ) {
247
+ // TODO: Use the internal element data without parameters.
248
+ $element_data = $element->{$method}( $element_data );
249
+ }
250
+
251
+ foreach ( $element->get_controls() as $control ) {
252
+ $control_class = Plugin::$instance->controls_manager->get_control( $control['type'] );
253
+
254
+ // If the control isn't exist, like a plugin that creates the control but deactivated.
255
+ if ( ! $control_class ) {
256
+ return $element_data;
257
+ }
258
+
259
+ if ( method_exists( $control_class, $method ) ) {
260
+ $element_data['settings'][ $control['name'] ] = $control_class->{$method}( $element->get_settings( $control['name'] ) );
261
+ }
262
+ }
263
+
264
+ return $element_data;
265
+ }
266
+
267
+ /**
268
+ * Import
269
+ *
270
+ * @since 1.0.14
271
+ * @return void
272
+ */
273
+ public function import() {
274
+
275
+ \Astra_Sites_Image_Importer::log( '---- Processing WordPress Posts / Pages - for Elementor ----' );
276
+
277
+ $post_ids = \Astra_Sites_Batch_Processing::get_pages();
278
+ if ( is_array( $post_ids ) ) {
279
+ foreach ( $post_ids as $post_id ) {
280
+ $this->import_single_post( $post_id );
281
+ }
282
+ }
283
+
284
+ }
285
+
286
+ /**
287
+ * Update post meta.
288
+ *
289
+ * @since 1.0.14
290
+ * @param integer $post_id Post ID.
291
+ * @return void
292
+ */
293
+ public function import_single_post( $post_id = 0 ) {
294
+
295
+ \Astra_Sites_Image_Importer::log( 'Post ID: ' . $post_id );
296
+
297
+ if ( ! empty( $post_id ) ) {
298
+
299
+ $hotlink_imported = get_post_meta( $post_id, '_astra_sites_hotlink_imported', true );
300
+
301
+ if ( empty( $hotlink_imported ) ) {
302
+
303
+ $data = get_post_meta( $post_id, '_elementor_data', true );
304
+
305
+ if ( ! empty( $data ) ) {
306
+
307
+ $data = json_decode( $data, true );
308
+
309
+ $data = $this->replace_elements_ids( $data );
310
+ $data = $this->process_export_import_content( $data, 'on_import' );
311
+
312
+ // Update processed meta.
313
+ update_metadata( 'post', $post_id, '_elementor_data', $data );
314
+ update_metadata( 'post', $post_id, '_astra_sites_hotlink_imported', true );
315
+
316
+ // !important, Clear the cache after images import.
317
+ Plugin::$instance->posts_css_manager->clear_cache();
318
+
319
+ }
320
+ }
321
+ }
322
+
323
+ }
324
+ }
inc/importers/batch-processing/class-astra-sites-batch-processing-widgets.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Batch Processing
4
+ *
5
+ * @package Astra Sites
6
+ * @since 1.0.14
7
+ */
8
+
9
+ if ( ! class_exists( 'Astra_Sites_Batch_Processing_Widgets' ) ) :
10
+
11
+ /**
12
+ * Astra_Sites_Batch_Processing_Widgets
13
+ *
14
+ * @since 1.0.14
15
+ */
16
+ class Astra_Sites_Batch_Processing_Widgets {
17
+
18
+ /**
19
+ * Instance
20
+ *
21
+ * @since 1.0.14
22
+ * @access private
23
+ * @var object Class object.
24
+ */
25
+ private static $instance;
26
+
27
+ /**
28
+ * Initiator
29
+ *
30
+ * @since 1.0.14
31
+ * @return object initialized object of class.
32
+ */
33
+ public static function get_instance() {
34
+ if ( ! isset( self::$instance ) ) {
35
+ self::$instance = new self;
36
+ }
37
+ return self::$instance;
38
+ }
39
+
40
+ /**
41
+ * Constructor
42
+ *
43
+ * @since 1.0.14
44
+ */
45
+ public function __construct() {
46
+ }
47
+
48
+ /**
49
+ * Import
50
+ *
51
+ * @since 1.0.14
52
+ * @return void
53
+ */
54
+ public function import() {
55
+ $this->widget_media_image();
56
+ }
57
+
58
+ /**
59
+ * Widget Media Image
60
+ *
61
+ * @since 1.0.14
62
+ * @return void
63
+ */
64
+ public function widget_media_image() {
65
+
66
+ $data = get_option( 'widget_media_image', null );
67
+
68
+ Astra_Sites_Image_Importer::log( '---- Processing Images from Widgets -----' );
69
+
70
+ foreach ( $data as $key => $value ) {
71
+
72
+ if (
73
+ isset( $value['url'] ) &&
74
+ isset( $value['attachment_id'] )
75
+ ) {
76
+
77
+ $image = array(
78
+ 'url' => $value['url'],
79
+ 'id' => $value['attachment_id'],
80
+ );
81
+
82
+ $downloaded_image = Astra_Sites_Image_Importer::get_instance()->import( $image );
83
+
84
+ $data[ $key ]['url'] = $downloaded_image['url'];
85
+ $data[ $key ]['attachment_id'] = $downloaded_image['id'];
86
+ }
87
+ }
88
+
89
+ update_option( 'widget_media_image', $data );
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Kicking this off by calling 'get_instance()' method
95
+ */
96
+ Astra_Sites_Batch_Processing_Widgets::get_instance();
97
+
98
+ endif;
inc/importers/batch-processing/class-astra-sites-batch-processing.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Batch Processing
4
+ *
5
+ * @package Astra Sites
6
+ * @since 1.0.14
7
+ */
8
+
9
+ if ( ! class_exists( 'Astra_Sites_Batch_Processing' ) ) :
10
+
11
+ /**
12
+ * Astra_Sites_Batch_Processing
13
+ *
14
+ * @since 1.0.14
15
+ */
16
+ class Astra_Sites_Batch_Processing {
17
+
18
+ /**
19
+ * Instance
20
+ *
21
+ * @since 1.0.14
22
+ * @var object Class object.
23
+ * @access private
24
+ */
25
+ private static $instance;
26
+
27
+ /**
28
+ * Process All
29
+ *
30
+ * @since 1.0.14
31
+ * @var object Class object.
32
+ * @access public
33
+ */
34
+ public static $process_all;
35
+
36
+ /**
37
+ * Initiator
38
+ *
39
+ * @since 1.0.14
40
+ * @return object initialized object of class.
41
+ */
42
+ public static function get_instance() {
43
+ if ( ! isset( self::$instance ) ) {
44
+ self::$instance = new self;
45
+ }
46
+ return self::$instance;
47
+ }
48
+
49
+ /**
50
+ * Constructor
51
+ *
52
+ * @since 1.0.14
53
+ */
54
+ public function __construct() {
55
+
56
+ // Core Helpers - Image.
57
+ // @todo This file is required for Elementor.
58
+ // Once we implement our logic for updating elementor data then we'll delete this file.
59
+ require_once ABSPATH . 'wp-admin/includes/image.php';
60
+
61
+ // Core Helpers - Image Downloader.
62
+ require_once ASTRA_SITES_DIR . 'inc/importers/batch-processing/helpers/class-astra-sites-image-importer.php';
63
+
64
+ // Core Helpers - Batch Processing.
65
+ require_once ASTRA_SITES_DIR . 'inc/importers/batch-processing/helpers/class-wp-async-request.php';
66
+ require_once ASTRA_SITES_DIR . 'inc/importers/batch-processing/helpers/class-wp-background-process.php';
67
+ require_once ASTRA_SITES_DIR . 'inc/importers/batch-processing/helpers/class-wp-background-process-astra.php';
68
+
69
+ // Prepare Widgets.
70
+ require_once ASTRA_SITES_DIR . 'inc/importers/batch-processing/class-astra-sites-batch-processing-widgets.php';
71
+ require_once ASTRA_SITES_DIR . 'inc/importers/batch-processing/class-astra-sites-batch-processing-beaver-builder.php';
72
+ require_once ASTRA_SITES_DIR . 'inc/importers/batch-processing/class-astra-sites-batch-processing-elementor.php';
73
+
74
+ self::$process_all = new WP_Background_Process_Astra();
75
+
76
+ // Start image importing after site import complete.
77
+ add_filter( 'astra_sites_image_importer_skip_image', array( $this, 'skip_image' ), 10, 2 );
78
+ add_action( 'astra_sites_import_complete', array( $this, 'start_process' ) );
79
+ }
80
+
81
+ /**
82
+ * Skip Image from Batch Processing.
83
+ *
84
+ * @since 1.0.14
85
+ *
86
+ * @param boolean $can_process Batch process image status.
87
+ * @param array $attachment Batch process image input.
88
+ * @return boolean
89
+ */
90
+ function skip_image( $can_process, $attachment ) {
91
+
92
+ if ( isset( $attachment['url'] ) && ! empty( $attachment['url'] ) ) {
93
+ if (
94
+ strpos( $attachment['url'], 'brainstormforce.com' ) !== false ||
95
+ strpos( $attachment['url'], 'wpastra.com' ) !== false ||
96
+ strpos( $attachment['url'], 'sharkz.in' ) !== false
97
+ ) {
98
+ return false;
99
+ }
100
+ }
101
+
102
+ return true;
103
+ }
104
+
105
+ /**
106
+ * Start Image Import
107
+ *
108
+ * @since 1.0.14
109
+ *
110
+ * @return void
111
+ */
112
+ public function start_process() {
113
+
114
+ Astra_Sites_Image_Importer::log( '=================== ' . Astra_Sites_White_Label::get_instance()->page_title( ASTRA_SITES_NAME ) . ' - Importing Images for Blog name \'' . get_bloginfo( 'name' ) . '\' (' . get_current_blog_id() . ') ===================' );
115
+
116
+ // Add "widget" in import [queue].
117
+ if ( class_exists( 'Astra_Sites_Batch_Processing_Widgets' ) ) {
118
+ self::$process_all->push_to_queue( Astra_Sites_Batch_Processing_Widgets::get_instance() );
119
+ }
120
+
121
+ // Add "bb-plugin" in import [queue].
122
+ // Add "beaver-builder-lite-version" in import [queue].
123
+ if ( is_plugin_active( 'beaver-builder-lite-version/fl-builder.php' ) || is_plugin_active( 'bb-plugin/fl-builder.php' ) ) {
124
+ if ( class_exists( 'Astra_Sites_Batch_Processing_Beaver_Builder' ) ) {
125
+ self::$process_all->push_to_queue( Astra_Sites_Batch_Processing_Beaver_Builder::get_instance() );
126
+ }
127
+ }
128
+
129
+ // Add "elementor" in import [queue].
130
+ // @todo Remove required `allow_url_fopen` support.
131
+ if ( ini_get( 'allow_url_fopen' ) ) {
132
+ if ( is_plugin_active( 'elementor/elementor.php' ) ) {
133
+ if ( class_exists( '\Elementor\TemplateLibrary\Astra_Sites_Batch_Processing_Elementor' ) ) {
134
+ $import = new \Elementor\TemplateLibrary\Astra_Sites_Batch_Processing_Elementor();
135
+ self::$process_all->push_to_queue( $import );
136
+ }
137
+ }
138
+ } else {
139
+ Astra_Sites_Image_Importer::log( 'Couldn\'t not import image due to allow_url_fopen() is disabled!' );
140
+ }
141
+
142
+ // Dispatch Queue.
143
+ self::$process_all->save()->dispatch();
144
+ }
145
+
146
+ /**
147
+ * Get all post id's
148
+ *
149
+ * @since 1.0.14
150
+ *
151
+ * @return array
152
+ */
153
+ public static function get_pages() {
154
+
155
+ $args = array(
156
+ 'post_type' => 'any',
157
+
158
+ // Query performance optimization.
159
+ 'fields' => 'ids',
160
+ 'no_found_rows' => true,
161
+ 'post_status' => 'publish',
162
+ );
163
+
164
+ $query = new WP_Query( $args );
165
+
166
+ // Have posts?
167
+ if ( $query->have_posts() ) :
168
+
169
+ return $query->posts;
170
+
171
+ endif;
172
+ return null;
173
+ }
174
+
175
+ }
176
+
177
+ /**
178
+ * Kicking this off by calling 'get_instance()' method
179
+ */
180
+ Astra_Sites_Batch_Processing::get_instance();
181
+
182
+ endif;
inc/importers/batch-processing/helpers/class-astra-sites-image-importer.php ADDED
@@ -0,0 +1,263 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Image Importer
4
+ *
5
+ * => How to use?
6
+ *
7
+ * $image = array(
8
+ * 'url' => '<image-url>',
9
+ * 'id' => '<image-id>',
10
+ * );
11
+ *
12
+ * $downloaded_image = Astra_Sites_Image_Importer::get_instance()->import( $image );
13
+ *
14
+ * @package Astra Sites
15
+ * @since 1.0.14
16
+ */
17
+
18
+ if ( ! class_exists( 'Astra_Sites_Image_Importer' ) ) :
19
+
20
+ /**
21
+ * Astra Sites Image Importer
22
+ *
23
+ * @since 1.0.14
24
+ */
25
+ class Astra_Sites_Image_Importer {
26
+
27
+ /**
28
+ * Instance
29
+ *
30
+ * @since 1.0.14
31
+ * @var object Class object.
32
+ * @access private
33
+ */
34
+ private static $instance;
35
+
36
+ /**
37
+ * Images IDs
38
+ *
39
+ * @var array The Array of already image IDs.
40
+ * @since 1.0.14
41
+ */
42
+ private $already_imported_ids = array();
43
+
44
+ /**
45
+ * Initiator
46
+ *
47
+ * @since 1.0.14
48
+ * @return object initialized object of class.
49
+ */
50
+ public static function get_instance() {
51
+ if ( ! isset( self::$instance ) ) {
52
+ self::$instance = new self;
53
+ }
54
+ return self::$instance;
55
+ }
56
+
57
+ /**
58
+ * Constructor
59
+ *
60
+ * @since 1.0.14
61
+ */
62
+ public function __construct() {
63
+
64
+ if ( ! function_exists( 'WP_Filesystem' ) ) {
65
+ require_once ABSPATH . 'wp-admin/includes/file.php';
66
+ }
67
+
68
+ WP_Filesystem();
69
+ }
70
+
71
+ /**
72
+ * Process Image Download
73
+ *
74
+ * @since 1.0.14
75
+ * @param array $attachments Attachment array.
76
+ * @return array Attachment array.
77
+ */
78
+ public function process( $attachments ) {
79
+
80
+ $downloaded_images = array();
81
+
82
+ foreach ( $attachments as $key => $attachment ) {
83
+ $downloaded_images[] = $this->import( $attachment );
84
+ }
85
+
86
+ return $downloaded_images;
87
+ }
88
+
89
+ /**
90
+ * Get Hash Image.
91
+ *
92
+ * @since 1.0.14
93
+ * @param string $attachment_url Attachment URL.
94
+ * @return string Hash string.
95
+ */
96
+ private function get_hash_image( $attachment_url ) {
97
+ return sha1( $attachment_url );
98
+ }
99
+
100
+ /**
101
+ * Get Saved Image.
102
+ *
103
+ * @since 1.0.14
104
+ * @param string $attachment Attachment Data.
105
+ * @return string Hash string.
106
+ */
107
+ private function get_saved_image( $attachment ) {
108
+
109
+ if ( apply_filters( 'astra_sites_image_importer_skip_image', false, $attachment ) ) {
110
+
111
+ Astra_Sites_Image_Importer::log( 'Download (✕) Replace (✕) - ' . $attachment['url'] );
112
+
113
+ return $attachment;
114
+ }
115
+
116
+ global $wpdb;
117
+
118
+ // Already imported? Then return!
119
+ if ( isset( $this->already_imported_ids[ $attachment['id'] ] ) ) {
120
+
121
+ Astra_Sites_Image_Importer::log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
122
+
123
+ return $this->already_imported_ids[ $attachment['id'] ];
124
+ }
125
+
126
+ // 1. Is already imported in Batch Import Process?
127
+ $post_id = $wpdb->get_var(
128
+ $wpdb->prepare(
129
+ 'SELECT `post_id` FROM `' . $wpdb->postmeta . '`
130
+ WHERE `meta_key` = \'_astra_sites_image_hash\'
131
+ AND `meta_value` = %s
132
+ ;',
133
+ $this->get_hash_image( $attachment['url'] )
134
+ )
135
+ );
136
+
137
+ // 2. Is image already imported though XML?
138
+ if ( empty( $post_id ) ) {
139
+
140
+ // Get file name without extension.
141
+ // To check it exist in attachment.
142
+ $filename = preg_replace( '/\\.[^.\\s]{3,4}$/', '', basename( $attachment['url'] ) );
143
+
144
+ $post_id = $wpdb->get_var(
145
+ $wpdb->prepare(
146
+ 'SELECT `post_id` FROM `' . $wpdb->postmeta . '`
147
+ WHERE `meta_key` = \'_wp_attached_file\'
148
+ AND `meta_value` LIKE %s
149
+ ;',
150
+ '%' . $filename . '%'
151
+ )
152
+ );
153
+
154
+ Astra_Sites_Image_Importer::log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
155
+ }
156
+
157
+ if ( $post_id ) {
158
+ $new_attachment = array(
159
+ 'id' => $post_id,
160
+ 'url' => wp_get_attachment_url( $post_id ),
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
+
169
+ return false;
170
+ }
171
+
172
+ /**
173
+ * Import Image
174
+ *
175
+ * @since 1.0.14
176
+ * @param array $attachment Attachment array.
177
+ * @return array Attachment array.
178
+ */
179
+ public function import( $attachment ) {
180
+
181
+ $saved_image = $this->get_saved_image( $attachment );
182
+ if ( $saved_image ) {
183
+ return $saved_image;
184
+ }
185
+
186
+ $file_content = wp_remote_retrieve_body( wp_safe_remote_get( $attachment['url'] ) );
187
+
188
+ // Empty file content?
189
+ if ( empty( $file_content ) ) {
190
+
191
+ Astra_Sites_Image_Importer::log( 'Download (✕) Replace (✕) - ' . $attachment['url'] );
192
+ Astra_Sites_Image_Importer::log( 'Error: Failed wp_remote_retrieve_body().' );
193
+
194
+ return $attachment;
195
+ }
196
+
197
+ // Extract the file name and extension from the URL.
198
+ $filename = basename( $attachment['url'] );
199
+
200
+ $upload = wp_upload_bits(
201
+ $filename,
202
+ null,
203
+ $file_content
204
+ );
205
+
206
+ $post = array(
207
+ 'post_title' => $filename,
208
+ 'guid' => $upload['url'],
209
+ );
210
+
211
+ $info = wp_check_filetype( $upload['file'] );
212
+ if ( $info ) {
213
+ $post['post_mime_type'] = $info['type'];
214
+ } else {
215
+ // For now just return the origin attachment.
216
+ return $attachment;
217
+ }
218
+
219
+ $post_id = wp_insert_attachment( $post, $upload['file'] );
220
+ wp_update_attachment_metadata(
221
+ $post_id,
222
+ wp_generate_attachment_metadata( $post_id, $upload['file'] )
223
+ );
224
+ update_post_meta( $post_id, '_astra_sites_image_hash', $this->get_hash_image( $attachment['url'] ) );
225
+
226
+ $new_attachment = array(
227
+ 'id' => $post_id,
228
+ 'url' => $upload['url'],
229
+ );
230
+
231
+ $this->already_imported_ids[ $attachment['id'] ] = $new_attachment;
232
+
233
+ return $new_attachment;
234
+ }
235
+
236
+ /**
237
+ * Debugging Log.
238
+ *
239
+ * @since 1.0.14
240
+ * @param mixed $log Log data.
241
+ * @return void
242
+ */
243
+ public static function log( $log ) {
244
+
245
+ if ( ! WP_DEBUG_LOG ) {
246
+ return;
247
+ }
248
+
249
+ if ( is_array( $log ) || is_object( $log ) ) {
250
+ error_log( print_r( $log, true ) );
251
+ } else {
252
+ error_log( $log );
253
+ }
254
+ }
255
+
256
+ }
257
+
258
+ /**
259
+ * Kicking this off by calling 'get_instance()' method
260
+ */
261
+ Astra_Sites_Image_Importer::get_instance();
262
+
263
+ endif;
inc/importers/batch-processing/helpers/class-wp-async-request.php ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WP Async Request
4
+ *
5
+ * @see https://github.com/A5hleyRich/wp-background-processing/
6
+ * @package WP-Background-Processing
7
+ */
8
+
9
+ if ( ! class_exists( 'WP_Async_Request' ) ) {
10
+
11
+ /**
12
+ * Abstract WP_Async_Request class.
13
+ *
14
+ * @abstract
15
+ */
16
+ abstract class WP_Async_Request {
17
+
18
+ /**
19
+ * Prefix
20
+ *
21
+ * (default value: 'wp')
22
+ *
23
+ * @var string
24
+ * @access protected
25
+ */
26
+ protected $prefix = 'wp';
27
+
28
+ /**
29
+ * Action
30
+ *
31
+ * (default value: 'async_request')
32
+ *
33
+ * @var string
34
+ * @access protected
35
+ */
36
+ protected $action = 'async_request';
37
+
38
+ /**
39
+ * Identifier
40
+ *
41
+ * @var mixed
42
+ * @access protected
43
+ */
44
+ protected $identifier;
45
+
46
+ /**
47
+ * Data
48
+ *
49
+ * (default value: array())
50
+ *
51
+ * @var array
52
+ * @access protected
53
+ */
54
+ protected $data = array();
55
+
56
+ /**
57
+ * Initiate new async request
58
+ */
59
+ public function __construct() {
60
+ $this->identifier = $this->prefix . '_' . $this->action;
61
+
62
+ add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) );
63
+ add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) );
64
+ }
65
+
66
+ /**
67
+ * Set data used during the request
68
+ *
69
+ * @param array $data Data.
70
+ *
71
+ * @return $this
72
+ */
73
+ public function data( $data ) {
74
+ $this->data = $data;
75
+
76
+ return $this;
77
+ }
78
+
79
+ /**
80
+ * Dispatch the async request
81
+ *
82
+ * @return array|WP_Error
83
+ */
84
+ public function dispatch() {
85
+ $url = add_query_arg( $this->get_query_args(), $this->get_query_url() );
86
+ $args = $this->get_post_args();
87
+
88
+ return wp_remote_post( esc_url_raw( $url ), $args );
89
+ }
90
+
91
+ /**
92
+ * Get query args
93
+ *
94
+ * @return array
95
+ */
96
+ protected function get_query_args() {
97
+ if ( property_exists( $this, 'query_args' ) ) {
98
+ return $this->query_args;
99
+ }
100
+
101
+ return array(
102
+ 'action' => $this->identifier,
103
+ 'nonce' => wp_create_nonce( $this->identifier ),
104
+ );
105
+ }
106
+
107
+ /**
108
+ * Get query URL
109
+ *
110
+ * @return string
111
+ */
112
+ protected function get_query_url() {
113
+ if ( property_exists( $this, 'query_url' ) ) {
114
+ return $this->query_url;
115
+ }
116
+
117
+ return admin_url( 'admin-ajax.php' );
118
+ }
119
+
120
+ /**
121
+ * Get post args
122
+ *
123
+ * @return array
124
+ */
125
+ protected function get_post_args() {
126
+ if ( property_exists( $this, 'post_args' ) ) {
127
+ return $this->post_args;
128
+ }
129
+
130
+ return array(
131
+ 'timeout' => 0.01,
132
+ 'blocking' => false,
133
+ 'body' => $this->data,
134
+ 'cookies' => $_COOKIE,
135
+ 'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
136
+ );
137
+ }
138
+
139
+ /**
140
+ * Maybe handle
141
+ *
142
+ * Check for correct nonce and pass to handler.
143
+ */
144
+ public function maybe_handle() {
145
+ // Don't lock up other requests while processing.
146
+ session_write_close();
147
+
148
+ check_ajax_referer( $this->identifier, 'nonce' );
149
+
150
+ $this->handle();
151
+
152
+ wp_die();
153
+ }
154
+
155
+ /**
156
+ * Handle
157
+ *
158
+ * Override this method to perform any actions required
159
+ * during the async request.
160
+ */
161
+ abstract protected function handle();
162
+
163
+ }
164
+ }
inc/importers/batch-processing/helpers/class-wp-background-process-astra.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Image Background Process
4
+ *
5
+ * @package Astra Sites
6
+ * @since 1.0.11
7
+ */
8
+
9
+ if ( class_exists( 'WP_Background_Process' ) ) :
10
+
11
+ /**
12
+ * Image Background Process
13
+ *
14
+ * @since 1.0.11
15
+ */
16
+ class WP_Background_Process_Astra extends WP_Background_Process {
17
+
18
+ /**
19
+ * Image Process
20
+ *
21
+ * @var string
22
+ */
23
+ protected $action = 'image_process';
24
+
25
+ /**
26
+ * Task
27
+ *
28
+ * Override this method to perform any actions required on each
29
+ * queue item. Return the modified item for further processing
30
+ * in the next pass through. Or, return false to remove the
31
+ * item from the queue.
32
+ *
33
+ * @since 1.0.11
34
+ *
35
+ * @param object $process Queue item object.
36
+ * @return mixed
37
+ */
38
+ protected function task( $process ) {
39
+
40
+ if ( method_exists( $process, 'import' ) ) {
41
+ $process->import();
42
+ }
43
+
44
+ return false;
45
+ }
46
+
47
+ /**
48
+ * Complete
49
+ *
50
+ * Override if applicable, but ensure that the below actions are
51
+ * performed, or, call parent::complete().
52
+ *
53
+ * @since 1.0.11
54
+ */
55
+ protected function complete() {
56
+
57
+ Astra_Sites_Image_Importer::log( '=================== ' . Astra_Sites_White_Label::get_instance()->page_title( ASTRA_SITES_NAME ) . ' - Importing Images Complete ===================' );
58
+
59
+ parent::complete();
60
+
61
+ do_action( 'astra_sites_image_import_complete' );
62
+
63
+ }
64
+
65
+ }
66
+
67
+ endif;
inc/importers/batch-processing/helpers/class-wp-background-process.php ADDED
@@ -0,0 +1,513 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WP Background Process
4
+ *
5
+ * @see https://github.com/A5hleyRich/wp-background-processing/
6
+ * @package WP-Background-Processing
7
+ */
8
+
9
+ if ( ! class_exists( 'WP_Background_Process' ) ) {
10
+
11
+ /**
12
+ * Abstract WP_Background_Process class.
13
+ *
14
+ * @abstract
15
+ * @extends WP_Async_Request
16
+ */
17
+ abstract class WP_Background_Process extends WP_Async_Request {
18
+
19
+ /**
20
+ * Action
21
+ *
22
+ * (default value: 'background_process')
23
+ *
24
+ * @var string
25
+ * @access protected
26
+ */
27
+ protected $action = 'background_process';
28
+
29
+ /**
30
+ * Start time of current process.
31
+ *
32
+ * (default value: 0)
33
+ *
34
+ * @var int
35
+ * @access protected
36
+ */
37
+ protected $start_time = 0;
38
+
39
+ /**
40
+ * Cron_hook_identifier
41
+ *
42
+ * @var mixed
43
+ * @access protected
44
+ */
45
+ protected $cron_hook_identifier;
46
+
47
+ /**
48
+ * Cron_interval_identifier
49
+ *
50
+ * @var mixed
51
+ * @access protected
52
+ */
53
+ protected $cron_interval_identifier;
54
+
55
+ /**
56
+ * Initiate new background process
57
+ */
58
+ public function __construct() {
59
+ parent::__construct();
60
+
61
+ $this->cron_hook_identifier = $this->identifier . '_cron';
62
+ $this->cron_interval_identifier = $this->identifier . '_cron_interval';
63
+
64
+ add_action( $this->cron_hook_identifier, array( $this, 'handle_cron_healthcheck' ) );
65
+ add_filter( 'cron_schedules', array( $this, 'schedule_cron_healthcheck' ) );
66
+ }
67
+
68
+ /**
69
+ * Dispatch
70
+ *
71
+ * @return mixed dispatch event.
72
+ */
73
+ public function dispatch() {
74
+ // Schedule the cron healthcheck.
75
+ $this->schedule_event();
76
+
77
+ // Perform remote post.
78
+ return parent::dispatch();
79
+ }
80
+
81
+ /**
82
+ * Push to queue
83
+ *
84
+ * @param mixed $data Data.
85
+ *
86
+ * @return $this
87
+ */
88
+ public function push_to_queue( $data ) {
89
+ $this->data[] = $data;
90
+
91
+ return $this;
92
+ }
93
+
94
+ /**
95
+ * Save queue
96
+ *
97
+ * @return $this
98
+ */
99
+ public function save() {
100
+ $key = $this->generate_key();
101
+
102
+ if ( ! empty( $this->data ) ) {
103
+ update_site_option( $key, $this->data );
104
+ }
105
+
106
+ return $this;
107
+ }
108
+
109
+ /**
110
+ * Update queue
111
+ *
112
+ * @param string $key Key.
113
+ * @param array $data Data.
114
+ *
115
+ * @return $this
116
+ */
117
+ public function update( $key, $data ) {
118
+ if ( ! empty( $data ) ) {
119
+ update_site_option( $key, $data );
120
+ }
121
+
122
+ return $this;
123
+ }
124
+
125
+ /**
126
+ * Delete queue
127
+ *
128
+ * @param string $key Key.
129
+ *
130
+ * @return $this
131
+ */
132
+ public function delete( $key ) {
133
+ delete_site_option( $key );
134
+
135
+ return $this;
136
+ }
137
+
138
+ /**
139
+ * Generate key
140
+ *
141
+ * Generates a unique key based on microtime. Queue items are
142
+ * given a unique key so that they can be merged upon save.
143
+ *
144
+ * @param int $length Length.
145
+ *
146
+ * @return string
147
+ */
148
+ protected function generate_key( $length = 64 ) {
149
+ $unique = md5( microtime() . rand() );
150
+ $prepend = $this->identifier . '_batch_';
151
+
152
+ return substr( $prepend . $unique, 0, $length );
153
+ }
154
+
155
+ /**
156
+ * Maybe process queue
157
+ *
158
+ * Checks whether data exists within the queue and that
159
+ * the process is not already running.
160
+ */
161
+ public function maybe_handle() {
162
+ // Don't lock up other requests while processing.
163
+ session_write_close();
164
+
165
+ if ( $this->is_process_running() ) {
166
+ // Background process already running.
167
+ wp_die();
168
+ }
169
+
170
+ if ( $this->is_queue_empty() ) {
171
+ // No data to process.
172
+ wp_die();
173
+ }
174
+
175
+ check_ajax_referer( $this->identifier, 'nonce' );
176
+
177
+ $this->handle();
178
+
179
+ wp_die();
180
+ }
181
+
182
+ /**
183
+ * Is queue empty
184
+ *
185
+ * @return bool
186
+ */
187
+ protected function is_queue_empty() {
188
+ global $wpdb;
189
+
190
+ $table = $wpdb->options;
191
+ $column = 'option_name';
192
+
193
+ if ( is_multisite() ) {
194
+ $table = $wpdb->sitemeta;
195
+ $column = 'meta_key';
196
+ }
197
+
198
+ $key = $this->identifier . '_batch_%';
199
+
200
+ $count = $wpdb->get_var(
201
+ $wpdb->prepare(
202
+ "
203
+ SELECT COUNT(*)
204
+ FROM {$table}
205
+ WHERE {$column} LIKE %s
206
+ ", $key
207
+ )
208
+ );
209
+
210
+ return ( $count > 0 ) ? false : true;
211
+ }
212
+
213
+ /**
214
+ * Is process running
215
+ *
216
+ * Check whether the current process is already running
217
+ * in a background process.
218
+ */
219
+ protected function is_process_running() {
220
+ if ( get_site_transient( $this->identifier . '_process_lock' ) ) {
221
+ // Process already running.
222
+ return true;
223
+ }
224
+
225
+ return false;
226
+ }
227
+
228
+ /**
229
+ * Lock process
230
+ *
231
+ * Lock the process so that multiple instances can't run simultaneously.
232
+ * Override if applicable, but the duration should be greater than that
233
+ * defined in the time_exceeded() method.
234
+ */
235
+ protected function lock_process() {
236
+ $this->start_time = time(); // Set start time of current process.
237
+
238
+ $lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : 60; // 1 minute
239
+ $lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration );
240
+
241
+ set_site_transient( $this->identifier . '_process_lock', microtime(), $lock_duration );
242
+ }
243
+
244
+ /**
245
+ * Unlock process
246
+ *
247
+ * Unlock the process so that other instances can spawn.
248
+ *
249
+ * @return $this
250
+ */
251
+ protected function unlock_process() {
252
+ delete_site_transient( $this->identifier . '_process_lock' );
253
+
254
+ return $this;
255
+ }
256
+
257
+ /**
258
+ * Get batch
259
+ *
260
+ * @return stdClass Return the first batch from the queue
261
+ */
262
+ protected function get_batch() {
263
+ global $wpdb;
264
+
265
+ $table = $wpdb->options;
266
+ $column = 'option_name';
267
+ $key_column = 'option_id';
268
+ $value_column = 'option_value';
269
+
270
+ if ( is_multisite() ) {
271
+ $table = $wpdb->sitemeta;
272
+ $column = 'meta_key';
273
+ $key_column = 'meta_id';
274
+ $value_column = 'meta_value';
275
+ }
276
+
277
+ $key = $this->identifier . '_batch_%';
278
+
279
+ $query = $wpdb->get_row(
280
+ $wpdb->prepare(
281
+ "
282
+ SELECT *
283
+ FROM {$table}
284
+ WHERE {$column} LIKE %s
285
+ ORDER BY {$key_column} ASC
286
+ LIMIT 1
287
+ ", $key
288
+ )
289
+ );
290
+
291
+ $batch = new stdClass();
292
+ $batch->key = $query->$column;
293
+ $batch->data = maybe_unserialize( $query->$value_column );
294
+
295
+ return $batch;
296
+ }
297
+
298
+ /**
299
+ * Handle
300
+ *
301
+ * Pass each queue item to the task handler, while remaining
302
+ * within server memory and time limit constraints.
303
+ */
304
+ protected function handle() {
305
+ $this->lock_process();
306
+
307
+ do {
308
+ $batch = $this->get_batch();
309
+
310
+ foreach ( $batch->data as $key => $value ) {
311
+ $task = $this->task( $value );
312
+
313
+ if ( false !== $task ) {
314
+ $batch->data[ $key ] = $task;
315
+ } else {
316
+ unset( $batch->data[ $key ] );
317
+ }
318
+
319
+ if ( $this->time_exceeded() || $this->memory_exceeded() ) {
320
+ // Batch limits reached.
321
+ break;
322
+ }
323
+ }
324
+
325
+ // Update or delete current batch.
326
+ if ( ! empty( $batch->data ) ) {
327
+ $this->update( $batch->key, $batch->data );
328
+ } else {
329
+ $this->delete( $batch->key );
330
+ }
331
+ } while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() );
332
+
333
+ $this->unlock_process();
334
+
335
+ // Start next batch or complete process.
336
+ if ( ! $this->is_queue_empty() ) {
337
+ $this->dispatch();
338
+ } else {
339
+ $this->complete();
340
+ }
341
+
342
+ wp_die();
343
+ }
344
+
345
+ /**
346
+ * Memory exceeded
347
+ *
348
+ * Ensures the batch process never exceeds 90%
349
+ * of the maximum WordPress memory.
350
+ *
351
+ * @return bool
352
+ */
353
+ protected function memory_exceeded() {
354
+ $memory_limit = $this->get_memory_limit() * 0.9; // 90% of max memory
355
+ $current_memory = memory_get_usage( true );
356
+ $return = false;
357
+
358
+ if ( $current_memory >= $memory_limit ) {
359
+ $return = true;
360
+ }
361
+
362
+ return apply_filters( $this->identifier . '_memory_exceeded', $return );
363
+ }
364
+
365
+ /**
366
+ * Get memory limit
367
+ *
368
+ * @return int
369
+ */
370
+ protected function get_memory_limit() {
371
+ if ( function_exists( 'ini_get' ) ) {
372
+ $memory_limit = ini_get( 'memory_limit' );
373
+ } else {
374
+ // Sensible default.
375
+ $memory_limit = '128M';
376
+ }
377
+
378
+ if ( ! $memory_limit || -1 === $memory_limit ) {
379
+ // Unlimited, set to 32GB.
380
+ $memory_limit = '32000M';
381
+ }
382
+
383
+ return intval( $memory_limit ) * 1024 * 1024;
384
+ }
385
+
386
+ /**
387
+ * Time exceeded.
388
+ *
389
+ * Ensures the batch never exceeds a sensible time limit.
390
+ * A timeout limit of 30s is common on shared hosting.
391
+ *
392
+ * @return bool
393
+ */
394
+ protected function time_exceeded() {
395
+ $finish = $this->start_time + apply_filters( $this->identifier . '_default_time_limit', 20 ); // 20 seconds
396
+ $return = false;
397
+
398
+ if ( time() >= $finish ) {
399
+ $return = true;
400
+ }
401
+
402
+ return apply_filters( $this->identifier . '_time_exceeded', $return );
403
+ }
404
+
405
+ /**
406
+ * Complete.
407
+ *
408
+ * Override if applicable, but ensure that the below actions are
409
+ * performed, or, call parent::complete().
410
+ */
411
+ protected function complete() {
412
+ // Unschedule the cron healthcheck.
413
+ $this->clear_scheduled_event();
414
+ }
415
+
416
+ /**
417
+ * Schedule cron healthcheck
418
+ *
419
+ * @access public
420
+ * @param mixed $schedules Schedules.
421
+ * @return mixed
422
+ */
423
+ public function schedule_cron_healthcheck( $schedules ) {
424
+ $interval = apply_filters( $this->identifier . '_cron_interval', 5 );
425
+
426
+ if ( property_exists( $this, 'cron_interval' ) ) {
427
+ $interval = apply_filters( $this->identifier . '_cron_interval', $this->cron_interval_identifier );
428
+ }
429
+
430
+ // Adds every 5 minutes to the existing schedules.
431
+ $schedules[ $this->identifier . '_cron_interval' ] = array(
432
+ 'interval' => MINUTE_IN_SECONDS * $interval,
433
+ 'display' => sprintf( __( 'Every %d Minutes', 'astra-sites' ), $interval ),
434
+ );
435
+
436
+ return $schedules;
437
+ }
438
+
439
+ /**
440
+ * Handle cron healthcheck
441
+ *
442
+ * Restart the background process if not already running
443
+ * and data exists in the queue.
444
+ */
445
+ public function handle_cron_healthcheck() {
446
+ if ( $this->is_process_running() ) {
447
+ // Background process already running.
448
+ exit;
449
+ }
450
+
451
+ if ( $this->is_queue_empty() ) {
452
+ // No data to process.
453
+ $this->clear_scheduled_event();
454
+ exit;
455
+ }
456
+
457
+ $this->handle();
458
+
459
+ exit;
460
+ }
461
+
462
+ /**
463
+ * Schedule event
464
+ */
465
+ protected function schedule_event() {
466
+ if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) {
467
+ wp_schedule_event( time(), $this->cron_interval_identifier, $this->cron_hook_identifier );
468
+ }
469
+ }
470
+
471
+ /**
472
+ * Clear scheduled event
473
+ */
474
+ protected function clear_scheduled_event() {
475
+ $timestamp = wp_next_scheduled( $this->cron_hook_identifier );
476
+
477
+ if ( $timestamp ) {
478
+ wp_unschedule_event( $timestamp, $this->cron_hook_identifier );
479
+ }
480
+ }
481
+
482
+ /**
483
+ * Cancel Process
484
+ *
485
+ * Stop processing queue items, clear cronjob and delete batch.
486
+ */
487
+ public function cancel_process() {
488
+ if ( ! $this->is_queue_empty() ) {
489
+ $batch = $this->get_batch();
490
+
491
+ $this->delete( $batch->key );
492
+
493
+ wp_clear_scheduled_hook( $this->cron_hook_identifier );
494
+ }
495
+
496
+ }
497
+
498
+ /**
499
+ * Task
500
+ *
501
+ * Override this method to perform any actions required on each
502
+ * queue item. Return the modified item for further processing
503
+ * in the next pass through. Or, return false to remove the
504
+ * item from the queue.
505
+ *
506
+ * @param mixed $item Queue item to iterate over.
507
+ *
508
+ * @return mixed
509
+ */
510
+ abstract protected function task( $item );
511
+
512
+ }
513
+ }
inc/importers/class-astra-site-options-import.php CHANGED
@@ -135,7 +135,7 @@ class Astra_Site_Options_Import {
135
  }
136
 
137
  /**
138
- * Update Page ID
139
  *
140
  * @since 1.0.2
141
  *
@@ -188,12 +188,13 @@ class Astra_Site_Options_Import {
188
  */
189
  private function insert_logo( $image_url = '' ) {
190
 
191
- $data = Astra_Sites_Helper::_sideload_image( $image_url );
192
 
193
  if ( ! is_wp_error( $data ) ) {
194
 
195
- set_theme_mod( 'custom_logo', $data->attachment_id );
196
-
 
197
  }
198
  }
199
 
135
  }
136
 
137
  /**
138
+ * Update post option
139
  *
140
  * @since 1.0.2
141
  *
188
  */
189
  private function insert_logo( $image_url = '' ) {
190
 
191
+ $data = (object) Astra_Sites_Helper::_sideload_image( $image_url );
192
 
193
  if ( ! is_wp_error( $data ) ) {
194
 
195
+ if ( isset( $data->attachment_id ) && ! empty( $data->attachment_id ) ) {
196
+ set_theme_mod( 'custom_logo', $data->attachment_id );
197
+ }
198
  }
199
  }
200
 
inc/importers/class-astra-sites-helper.php CHANGED
@@ -62,7 +62,7 @@ if ( ! class_exists( 'Astra_Sites_Helper' ) ) :
62
 
63
  // Get current menu ID & Slugs.
64
  $menu_locations = array();
65
- $nav_menus = (object) wp_get_nav_menus();
66
  if ( isset( $nav_menus ) ) {
67
  foreach ( $nav_menus as $menu_key => $menu ) {
68
  if ( is_object( $menu ) ) {
@@ -128,11 +128,11 @@ if ( ! class_exists( 'Astra_Sites_Helper' ) ) :
128
  // we downloaded the file from a remote server, so there
129
  // will be no form fields
130
  // Default is true.
131
- 'test_form' => false,
132
 
133
  // Setting this to false lets WordPress allow empty files, not recommended.
134
  // Default is true.
135
- 'test_size' => true,
136
 
137
  // A properly uploaded file will pass this test. There should be no reason to override this one.
138
  'test_upload' => true,
@@ -180,7 +180,7 @@ if ( ! class_exists( 'Astra_Sites_Helper' ) ) :
180
 
181
  // Set variables for storage, fix file filename for query strings.
182
  preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );
183
- $file_array = array();
184
  $file_array['name'] = basename( $matches[0] );
185
 
186
  // Download file to temp location.
@@ -201,12 +201,12 @@ if ( ! class_exists( 'Astra_Sites_Helper' ) ) :
201
  }
202
 
203
  // Build the object to return.
204
- $meta = wp_get_attachment_metadata( $id );
205
- $data->attachment_id = $id;
206
- $data->url = wp_get_attachment_url( $id );
207
- $data->thumbnail_url = wp_get_attachment_thumb_url( $id );
208
- $data->height = $meta['height'];
209
- $data->width = $meta['width'];
210
  }
211
 
212
  return $data;
62
 
63
  // Get current menu ID & Slugs.
64
  $menu_locations = array();
65
+ $nav_menus = (object) wp_get_nav_menus();
66
  if ( isset( $nav_menus ) ) {
67
  foreach ( $nav_menus as $menu_key => $menu ) {
68
  if ( is_object( $menu ) ) {
128
  // we downloaded the file from a remote server, so there
129
  // will be no form fields
130
  // Default is true.
131
+ 'test_form' => false,
132
 
133
  // Setting this to false lets WordPress allow empty files, not recommended.
134
  // Default is true.
135
+ 'test_size' => true,
136
 
137
  // A properly uploaded file will pass this test. There should be no reason to override this one.
138
  'test_upload' => true,
180
 
181
  // Set variables for storage, fix file filename for query strings.
182
  preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );
183
+ $file_array = array();
184
  $file_array['name'] = basename( $matches[0] );
185
 
186
  // Download file to temp location.
201
  }
202
 
203
  // Build the object to return.
204
+ $meta = wp_get_attachment_metadata( $id );
205
+ $data->attachment_id = $id;
206
+ $data->url = wp_get_attachment_url( $id );
207
+ $data->thumbnail_url = wp_get_attachment_thumb_url( $id );
208
+ $data->height = $meta['height'];
209
+ $data->width = $meta['width'];
210
  }
211
 
212
  return $data;
inc/importers/wxr-importer/class-astra-wxr-importer.php CHANGED
@@ -45,8 +45,8 @@ class Astra_WXR_Importer {
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
  /**
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
  /**
inc/includes/admin-page.php CHANGED
@@ -41,7 +41,7 @@ defined( 'ABSPATH' ) or exit;
41
  <input placeholder="<?php _e( 'Search Sites...', 'astra-sites' ); ?>" type="search" aria-describedby="live-search-desc" id="wp-filter-search-input" class="wp-filter-search">
42
  </div>
43
 
44
- </div>
45
 
46
  </div>
47
 
@@ -119,6 +119,21 @@ defined( 'ABSPATH' ) or exit;
119
  <span class="collapse-sidebar-arrow"></span>
120
  <span class="collapse-sidebar-label"><?php esc_html_e( 'Collapse', 'astra-sites' ); ?></span>
121
  </button>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  </div>
123
  </div>
124
  <div class="wp-full-overlay-main">
@@ -137,14 +152,14 @@ defined( 'ABSPATH' ) or exit;
137
  <?php
138
 
139
  /* translators: %1$s & %2$s are a Demo API URL */
140
- printf( __( '<p> It seems the demo data server, <i><a href="%1$s">%2$s</a></i> is unreachable from your site.</p>', 'astra-sites' ) , esc_url( Astra_Sites::$api_url ), esc_url( Astra_Sites::$api_url ) );
141
 
142
  _e( '<p class="left-margin"> 1. Sometimes, simple page reload fixes any temporary issues. No kidding!</p>', 'astra-sites' );
143
 
144
  _e( '<p class="left-margin"> 2. If that does not work, you will need to talk to your server administrator and check if demo server is being blocked by the firewall!</p>', 'astra-sites' );
145
 
146
  /* translators: %1$s is a support link */
147
- printf( __( '<p>If that does not help, please open up a <a href="%1$s" target="_blank">Support Ticket</a> and we will be glad take a closer look for you.</p>', 'astra-sites' ), esc_url( 'https://wpastra.com/support/' ) );
148
  ?>
149
  </div>
150
  </script>
@@ -159,7 +174,7 @@ defined( 'ABSPATH' ) or exit;
159
  <# if ( data ) { #>
160
 
161
  <ul class="{{ data.args.wrapper_class }} {{ data.args.class }}">
162
-
163
  <# if ( data.args.show_all ) { #>
164
  <li>
165
  <a href="#" data-group="all"> All </a>
@@ -170,7 +185,7 @@ defined( 'ABSPATH' ) or exit;
170
  <# if ( data.items[ key ].count ) { #>
171
  <li>
172
  <a href="#" data-group='{{ data.items[ key ].id }}' class="{{ data.items[ key ].name }}">
173
- {{ data.items[ key ].name }}
174
  </a>
175
  </li>
176
  <# } #>
@@ -204,16 +219,12 @@ defined( 'ABSPATH' ) or exit;
204
  <input type="hidden" class="astra-site-options" value="{{ JSON.stringify(data.items[ key ]['astra-site-options-data'] ) }}" />
205
  <input type="hidden" class="astra-enabled-extensions" value="{{ JSON.stringify(data.items[ key ]['astra-enabled-extensions'] ) }}" />
206
 
207
- <!-- <div class="theme astra-theme site-single" data-groups=["{{ data.items[ key ].tags }}"]> -->
208
  <div class="inner">
209
  <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 }}">
210
-
211
  <div class="theme-screenshot">
212
  <# if( '' !== data.items[ key ]['featured-image-url'] ) { #>
213
- <img class="lazy" data-src="{{ data.items[ key ]['featured-image-url'] }}" />
214
- <noscript>
215
- <img src="{{ data.items[ key ]['featured-image-url'] }}" />
216
- </noscript>
217
  <# } #>
218
  </div>
219
 
@@ -236,6 +247,32 @@ defined( 'ABSPATH' ) or exit;
236
  </div>
237
  <# } #>
238
  <# } else { #>
239
- <p class="no-themes" style="display:block;"> <?php _e( 'No Demos found, Try a different search.', 'astra-sites' ); ?> </p>
 
 
 
 
 
 
 
 
240
  <# } #>
241
  </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  <input placeholder="<?php _e( 'Search Sites...', 'astra-sites' ); ?>" type="search" aria-describedby="live-search-desc" id="wp-filter-search-input" class="wp-filter-search">
42
  </div>
43
 
44
+ </div>
45
 
46
  </div>
47
 
119
  <span class="collapse-sidebar-arrow"></span>
120
  <span class="collapse-sidebar-label"><?php esc_html_e( 'Collapse', 'astra-sites' ); ?></span>
121
  </button>
122
+
123
+ <div class="devices-wrapper">
124
+ <div class="devices">
125
+ <button type="button" class="preview-desktop active" aria-pressed="true" data-device="desktop">
126
+ <span class="screen-reader-text"><?php _e( 'Enter desktop preview mode', 'astra-sites' ); ?></span>
127
+ </button>
128
+ <button type="button" class="preview-tablet" aria-pressed="false" data-device="tablet">
129
+ <span class="screen-reader-text"><?php _e( 'Enter tablet preview mode', 'astra-sites' ); ?></span>
130
+ </button>
131
+ <button type="button" class="preview-mobile" aria-pressed="false" data-device="mobile">
132
+ <span class="screen-reader-text"><?php _e( 'Enter mobile preview mode', 'astra-sites' ); ?></span>
133
+ </button>
134
+ </div>
135
+ </div>
136
+
137
  </div>
138
  </div>
139
  <div class="wp-full-overlay-main">
152
  <?php
153
 
154
  /* translators: %1$s & %2$s are a Demo API URL */
155
+ printf( __( '<p> It seems the demo data server, <i><a href="%1$s">%2$s</a></i> is unreachable from your site.</p>', 'astra-sites' ), esc_url( Astra_Sites::$api_url ), esc_url( Astra_Sites::$api_url ) );
156
 
157
  _e( '<p class="left-margin"> 1. Sometimes, simple page reload fixes any temporary issues. No kidding!</p>', 'astra-sites' );
158
 
159
  _e( '<p class="left-margin"> 2. If that does not work, you will need to talk to your server administrator and check if demo server is being blocked by the firewall!</p>', 'astra-sites' );
160
 
161
  /* translators: %1$s is a support link */
162
+ printf( __( '<p>If that does not help, please open up a <a href="%1$s" target="_blank">Support Ticket</a> and we will be glad take a closer look for you.</p>', 'astra-sites' ), esc_url( 'https://wpastra.com/support/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=api-request-failed' ) );
163
  ?>
164
  </div>
165
  </script>
174
  <# if ( data ) { #>
175
 
176
  <ul class="{{ data.args.wrapper_class }} {{ data.args.class }}">
177
+
178
  <# if ( data.args.show_all ) { #>
179
  <li>
180
  <a href="#" data-group="all"> All </a>
185
  <# if ( data.items[ key ].count ) { #>
186
  <li>
187
  <a href="#" data-group='{{ data.items[ key ].id }}' class="{{ data.items[ key ].name }}">
188
+ {{ data.items[ key ].name }}
189
  </a>
190
  </li>
191
  <# } #>
219
  <input type="hidden" class="astra-site-options" value="{{ JSON.stringify(data.items[ key ]['astra-site-options-data'] ) }}" />
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
 
247
  </div>
248
  <# } #>
249
  <# } else { #>
250
+ <p class="no-themes" style="display:block;">
251
+ <?php _e( 'No Demos found, Try a different search.', 'astra-sites' ); ?>
252
+ <span class="description">
253
+ <?php
254
+ /* translators: %1$s External Link */
255
+ printf( __( 'Don\'t see a site that you would like to import?<br>Please <a target="_blank" href="%1$s">suggest us</a>!', 'astra-sites' ), esc_url( 'https://wpastra.com/sites-suggestions/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=suggestions' ) );
256
+ ?>
257
+ </span>
258
+ </p>
259
  <# } #>
260
  </script>
261
+
262
+ <?php
263
+ /**
264
+ * TMPL - List
265
+ */
266
+ ?>
267
+ <script type="text/template" id="tmpl-astra-sites-suggestions">
268
+ <div class="theme astra-theme site-single astra-sites-suggestions">
269
+ <div class="inner">
270
+ <p>
271
+ <?php
272
+ /* translators: %1$s External Link */
273
+ printf( __( 'Don\'t see a site that you would like to import?<br>Please <a target="_blank" href="%1$s">suggest us</a>!', 'astra-sites' ), esc_url( 'https://wpastra.com/sites-suggestions/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=suggestions' ) );
274
+ ?>
275
+ </p>
276
+ </div>
277
+ </div>
278
+ </script>
inc/includes/white-label.php CHANGED
@@ -12,11 +12,11 @@
12
  <span class="screen-reader-text"><?php echo esc_html( $plugin_name ); ?></span>
13
  <span class="toggle-indicator" aria-hidden="true"></span>
14
  </button>
15
-
16
  <h2 class="hndle ui-sortable-handle">
17
  <span><?php echo esc_html( $plugin_name ); ?></span>
18
  </h2>
19
-
20
  <div class="inside">
21
  <div class="form-wrap">
22
  <div class="form-field">
12
  <span class="screen-reader-text"><?php echo esc_html( $plugin_name ); ?></span>
13
  <span class="toggle-indicator" aria-hidden="true"></span>
14
  </button>
15
+
16
  <h2 class="hndle ui-sortable-handle">
17
  <span><?php echo esc_html( $plugin_name ); ?></span>
18
  </h2>
19
+
20
  <div class="inside">
21
  <div class="form-wrap">
22
  <div class="form-field">
languages/astra-sites.pot CHANGED
@@ -2,9 +2,9 @@
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.13\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/astra-sites\n"
7
- "POT-Creation-Date: 2017-10-09 14:55:13+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,11 +28,11 @@ msgstr ""
28
  msgid "Astra Sites"
29
  msgstr ""
30
 
31
- #: inc/classes/class-astra-sites-importer.php:72
32
  msgid "You have not \"customize\" access to import the astra site."
33
  msgstr ""
34
 
35
- #: inc/classes/class-astra-sites-importer.php:80
36
  msgid "Demo Imported Successfully."
37
  msgstr ""
38
 
@@ -45,78 +45,78 @@ msgstr ""
45
  msgid "%1$s Branding"
46
  msgstr ""
47
 
48
- #: inc/classes/class-astra-sites.php:80
49
  #. translators: 1: theme.php file
50
  msgid ""
51
  "Astra Theme needs to be active for you to use currently installed \"%1$s\" "
52
  "plugin. <a href=\"%2$s\">Install & Activate Now</a>"
53
  msgstr ""
54
 
55
- #: inc/classes/class-astra-sites.php:120
56
  msgid "See Library"
57
  msgstr ""
58
 
59
- #: inc/classes/class-astra-sites.php:168
60
  msgid "Page Builder"
61
  msgstr ""
62
 
63
- #: inc/classes/class-astra-sites.php:173
64
  msgid "Categories"
65
  msgstr ""
66
 
67
- #: inc/classes/class-astra-sites.php:205
68
  msgid "Purchase"
69
  msgstr ""
70
 
71
- #: inc/classes/class-astra-sites.php:207
72
  msgid "Upgrade"
73
  msgstr ""
74
 
75
- #: inc/classes/class-astra-sites.php:212
76
  msgid "Error!"
77
  msgstr ""
78
 
79
- #: inc/classes/class-astra-sites.php:213
80
  msgid "Error! Read Possibilities."
81
  msgstr ""
82
 
83
- #: inc/classes/class-astra-sites.php:215
84
  msgid "Done! View Site"
85
  msgstr ""
86
 
87
- #: inc/classes/class-astra-sites.php:216
88
  msgid "Activating"
89
  msgstr ""
90
 
91
- #: inc/classes/class-astra-sites.php:217
92
  msgid "Active"
93
  msgstr ""
94
 
95
- #: inc/classes/class-astra-sites.php:218
96
  msgid "Import This Site"
97
  msgstr ""
98
 
99
- #: inc/classes/class-astra-sites.php:219
100
  msgid "Importing Demo"
101
  msgstr ""
102
 
103
- #: inc/classes/class-astra-sites.php:220 inc/includes/admin-page.php:102
104
  msgid "Read more"
105
  msgstr ""
106
 
107
- #: inc/classes/class-astra-sites.php:221
108
  msgid "Hide"
109
  msgstr ""
110
 
111
- #: inc/classes/class-astra-sites.php:222
112
  msgid "There was a problem receiving a response from server."
113
  msgstr ""
114
 
115
- #: inc/classes/class-astra-sites.php:223 inc/includes/admin-page.php:240
116
  msgid "No Demos found, Try a different search."
117
  msgstr ""
118
 
119
- #: inc/classes/class-astra-sites.php:224
120
  msgid ""
121
  "Executing Demo Import will make your site similar as ours. Please bear in "
122
  "mind -\n"
@@ -130,19 +130,19 @@ msgid ""
130
  "placeholders."
131
  msgstr ""
132
 
133
- #: inc/classes/class-astra-sites.php:259
134
  msgid "No plugin specified"
135
  msgstr ""
136
 
137
- #: inc/classes/class-astra-sites.php:288
138
  msgid "Plugin Successfully Activated"
139
  msgstr ""
140
 
141
- #: inc/classes/compatibility/elementor/class-astra-sites-source-remote.php:58
142
  msgid "Remote"
143
  msgstr ""
144
 
145
- #: inc/classes/vendor/wp-background-process.php:426
146
  msgid "Every %d Minutes"
147
  msgstr ""
148
 
@@ -353,31 +353,43 @@ msgstr ""
353
  msgid "Collapse"
354
  msgstr ""
355
 
356
- #: inc/includes/admin-page.php:125 inc/includes/admin-page.php:234
 
 
 
 
 
 
 
 
 
 
 
 
357
  msgid "Preview"
358
  msgstr ""
359
 
360
- #: inc/includes/admin-page.php:140
361
  #. translators: %1$s & %2$s are a Demo API URL
362
  msgid ""
363
  "<p> It seems the demo data server, <i><a href=\"%1$s\">%2$s</a></i> is "
364
  "unreachable from your site.</p>"
365
  msgstr ""
366
 
367
- #: inc/includes/admin-page.php:142
368
  msgid ""
369
  "<p class=\"left-margin\"> 1. Sometimes, simple page reload fixes any "
370
  "temporary issues. No kidding!</p>"
371
  msgstr ""
372
 
373
- #: inc/includes/admin-page.php:144
374
  msgid ""
375
  "<p class=\"left-margin\"> 2. If that does not work, you will need to talk "
376
  "to your server administrator and check if demo server is being blocked by "
377
  "the firewall!</p>"
378
  msgstr ""
379
 
380
- #: inc/includes/admin-page.php:147
381
  #. translators: %1$s is a support link
382
  msgid ""
383
  "<p>If that does not help, please open up a <a href=\"%1$s\" "
@@ -385,10 +397,17 @@ msgid ""
385
  "for you.</p>"
386
  msgstr ""
387
 
388
- #: inc/includes/admin-page.php:222
389
  msgid "Details &amp; Preview"
390
  msgstr ""
391
 
 
 
 
 
 
 
 
392
  #: inc/includes/white-label.php:23
393
  msgid "Plugin Name:"
394
  msgstr ""
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
  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
 
45
  msgid "%1$s Branding"
46
  msgstr ""
47
 
48
+ #: inc/classes/class-astra-sites.php:81
49
  #. translators: 1: theme.php file
50
  msgid ""
51
  "Astra Theme needs to be active for you to use currently installed \"%1$s\" "
52
  "plugin. <a href=\"%2$s\">Install & Activate Now</a>"
53
  msgstr ""
54
 
55
+ #: inc/classes/class-astra-sites.php:121
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
  "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
 
141
+ #: inc/importers/batch-processing/class-astra-sites-batch-processing-elementor.php:58
142
  msgid "Remote"
143
  msgstr ""
144
 
145
+ #: inc/importers/batch-processing/helpers/class-wp-background-process.php:433
146
  msgid "Every %d Minutes"
147
  msgstr ""
148
 
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
  "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
412
  msgid "Plugin Name:"
413
  msgstr ""
readme.txt CHANGED
@@ -3,8 +3,8 @@ 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.8.1
7
- Stable tag: 1.0.13
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -20,23 +20,49 @@ This plugin is an add-on for the Astra WordPress Theme. It offers a library of r
20
  4. Import the site data.
21
  5. Done ;)
22
 
 
23
  Use this imported site as a base for your project and don't waste time starting from scratch!
24
 
25
  _<a href="https://wpastra.com/ready-websites/">See list of all available sites to import »</a>_
26
 
 
 
 
27
  == Installation ==
28
 
29
  1. Upload the plugin files to the `/wp-content/plugins/astra-sites` directory, or install the plugin through the WordPress plugins screen directly.
30
- 1. Activate the plugin through the 'Plugins' screen in WordPress
31
- 1. Use the Appearance->Astra->Astra Free Sites to select the page to be displayed as header and footer.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  == Screenshots ==
34
  1. Select the demo you want to import.
35
- 1. Install and activate the required plugins.
36
- 1. Import the demo.
37
 
38
  == Changelog ==
39
 
 
 
 
 
 
 
 
 
40
  v1.0.13 - 9-Oct-2017
41
  * New: Browsing the Astra Sites in the Admin panel is not faster with JS rendering.
42
 
@@ -98,4 +124,4 @@ v1.0.1 - 04-Aug-2017
98
  * Fix: Bug where widgets created with SiteOrigin plugin were not being imported.
99
 
100
  v1.0.0
101
- * Initial release
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
 
20
  4. Import the site data.
21
  5. Done ;)
22
 
23
+
24
  Use this imported site as a base for your project and don't waste time starting from scratch!
25
 
26
  _<a href="https://wpastra.com/ready-websites/">See list of all available sites to import »</a>_
27
 
28
+ #### Video Walkthrough by Adam from WPCrafter:
29
+ [youtube https://www.youtube.com/watch?v=zYbz-jxE9_Q]
30
+
31
  == Installation ==
32
 
33
  1. Upload the plugin files to the `/wp-content/plugins/astra-sites` directory, or install the plugin through the WordPress plugins screen directly.
34
+ 2. Activate the plugin through the 'Plugins' screen in WordPress
35
+ 3. Use the Appearance->Astra->Astra Free Sites to select the page to be displayed as header and footer.
36
+
37
+ == Frequently Asked Questions ==
38
+
39
+ = Is this really free? =
40
+
41
+ Yup, we have dozens of free websites ready to import! We have a premium version as well that is required for importing premium sites.
42
+
43
+ Learn More: https://wpastra.com/agency/
44
+
45
+ = Can I suggest new websites that you I add? =
46
+
47
+ Sure. We love suggestions! Please submit them here -
48
+ 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.
61
+ * New: Added site responsive preview buttons.
62
+ * Improvement: Search string will not be removed when switching the page builder when scrolling through sites.
63
+ * Improvement: Loading 15 sites instead of 6 Astra sites in the first load.
64
+ * Improvement: Removed LazyLoad which is not useful in admin back-end for showing Astra Sites.
65
+
66
  v1.0.13 - 9-Oct-2017
67
  * New: Browsing the Astra Sites in the Admin panel is not faster with JS rendering.
68
 
124
  * Fix: Bug where widgets created with SiteOrigin plugin were not being imported.
125
 
126
  v1.0.0
127
+ * Initial release