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.