Astra Starter Sites - Version 1.3.18

Version Description

Download this release

Release Info

Developer vrundakansara
Plugin Icon Astra Starter Sites
Version 1.3.18
Comparing to
See all releases

Code changes from version 1.3.17 to 1.3.18

astra-sites.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Astra Starter Sites
4
  * Plugin URI: http://www.wpastra.com/pro/
5
  * Description: Import free sites build with Astra theme.
6
- * Version: 1.3.17
7
  * Author: Brainstorm Force
8
  * Author URI: http://www.brainstormforce.com
9
  * Text Domain: astra-sites
@@ -19,7 +19,7 @@ if ( ! defined( 'ASTRA_SITES_NAME' ) ) {
19
  }
20
 
21
  if ( ! defined( 'ASTRA_SITES_VER' ) ) {
22
- define( 'ASTRA_SITES_VER', '1.3.17' );
23
  }
24
 
25
  if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
3
  * Plugin Name: Astra Starter Sites
4
  * Plugin URI: http://www.wpastra.com/pro/
5
  * Description: Import free sites build with Astra theme.
6
+ * Version: 1.3.18
7
  * Author: Brainstorm Force
8
  * Author URI: http://www.brainstormforce.com
9
  * Text Domain: astra-sites
19
  }
20
 
21
  if ( ! defined( 'ASTRA_SITES_VER' ) ) {
22
+ define( 'ASTRA_SITES_VER', '1.3.18' );
23
  }
24
 
25
  if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
inc/assets/js/admin-page.js CHANGED
@@ -930,7 +930,7 @@ var AstraSitesAjaxQueue = (function() {
930
  *
931
  * @param {string} data Error message.
932
  */
933
- _importFailMessage: function( message, from ) {
934
 
935
  $('.astra-demo-import')
936
  .addClass('go-pro button-primary')
@@ -940,40 +940,10 @@ var AstraSitesAjaxQueue = (function() {
940
  .append('<i class="dashicons dashicons-external"></i>')
941
  .removeClass('astra-demo-import');
942
 
943
- // Add the doc link due to import log file not generated.
944
- if( 'undefined' === from ) {
945
 
946
- $('.wp-full-overlay-header .go-pro').text( astraSitesAdmin.strings.importFailedBtnSmall );
947
- $('.wp-full-overlay-footer .go-pro').text( astraSitesAdmin.strings.importFailedBtnLarge );
948
- $('.go-pro').attr('href', astraSitesAdmin.log.serverConfiguration );
949
-
950
- // Add the import log file link.
951
- } else {
952
-
953
- $('.wp-full-overlay-header .go-pro').text( astraSitesAdmin.strings.importFailBtn );
954
- $('.wp-full-overlay-footer .go-pro').text( astraSitesAdmin.strings.importFailBtnLarge )
955
-
956
- // Add the import log file link.
957
- if( 'undefined' !== AstraSitesAdmin.log_file_url ) {
958
- $('.go-pro').attr('href', AstraSitesAdmin.log_file_url );
959
- } else {
960
- $('.go-pro').attr('href', astraSitesAdmin.log.serverConfiguration );
961
- }
962
- }
963
-
964
- var output = '<div class="astra-api-error notice notice-error notice-alt is-dismissible">';
965
- output += ' <p>'+message+'</p>';
966
- output += ' <button type="button" class="notice-dismiss">';
967
- output += ' <span class="screen-reader-text">'+commonL10n.dismiss+'</span>';
968
- output += ' </button>';
969
- output += '</div>';
970
-
971
- // Fail Notice.
972
- $('.install-theme-info').append( output );
973
-
974
- // !important to add trigger.
975
- // Which reinitialize the dismiss error message events.
976
- $(document).trigger('wp-updates-notice-added');
977
  },
978
 
979
 
@@ -1376,8 +1346,7 @@ var AstraSitesAjaxQueue = (function() {
1376
 
1377
  // 1. Fail - Request Site Import
1378
  if( false === demo_data.success ) {
1379
-
1380
-
1381
  } else {
1382
 
1383
  // Set log file URL.
930
  *
931
  * @param {string} data Error message.
932
  */
933
+ _importFailMessage: function( message ) {
934
 
935
  $('.astra-demo-import')
936
  .addClass('go-pro button-primary')
940
  .append('<i class="dashicons dashicons-external"></i>')
941
  .removeClass('astra-demo-import');
942
 
943
+ AstraSitesAdmin._log_title( message );
 
944
 
945
+ $('.wp-full-overlay-header .go-pro').text( astraSitesAdmin.strings.importFailBtn );
946
+ $('.wp-full-overlay-footer .go-pro').text( astraSitesAdmin.strings.importFailBtnLarge )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
947
  },
948
 
949
 
1346
 
1347
  // 1. Fail - Request Site Import
1348
  if( false === demo_data.success ) {
1349
+ AstraSitesAdmin._importFailMessage( demo_data.data );
 
1350
  } else {
1351
 
1352
  // Set log file URL.
inc/classes/class-astra-sites-importer.php CHANGED
@@ -1,602 +1,605 @@
1
- <?php
2
- /**
3
- * Astra Sites Importer
4
- *
5
- * @since 1.0.0
6
- * @package Astra Sites
7
- */
8
-
9
- defined( 'ABSPATH' ) or exit;
10
-
11
- if ( ! class_exists( 'Astra_Sites_Importer' ) ) :
12
-
13
- /**
14
- * Astra Sites Importer
15
- */
16
- class Astra_Sites_Importer {
17
-
18
- /**
19
- * Instance
20
- *
21
- * @since 1.0.0
22
- * @var (Object) Class object
23
- */
24
- public static $_instance = null;
25
-
26
- /**
27
- * Set Instance
28
- *
29
- * @since 1.0.0
30
- *
31
- * @return object Class object.
32
- */
33
- public static function get_instance() {
34
- if ( ! isset( self::$_instance ) ) {
35
- self::$_instance = new self;
36
- }
37
-
38
- return self::$_instance;
39
- }
40
-
41
- /**
42
- * Constructor.
43
- *
44
- * @since 1.0.0
45
- */
46
- public function __construct() {
47
-
48
- require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-importer-log.php';
49
- require_once ASTRA_SITES_DIR . 'inc/importers/class-astra-sites-helper.php';
50
- require_once ASTRA_SITES_DIR . 'inc/importers/class-widgets-importer.php';
51
- require_once ASTRA_SITES_DIR . 'inc/importers/class-astra-customizer-import.php';
52
- require_once ASTRA_SITES_DIR . 'inc/importers/class-astra-site-options-import.php';
53
-
54
- // Import AJAX.
55
- add_action( 'wp_ajax_astra-sites-import-set-site-data', array( $this, 'import_start' ) );
56
- add_action( 'wp_ajax_astra-sites-import-wpforms', array( $this, 'import_wpforms' ) );
57
- add_action( 'wp_ajax_astra-sites-import-customizer-settings', array( $this, 'import_customizer_settings' ) );
58
- add_action( 'wp_ajax_astra-sites-import-prepare-xml', array( $this, 'prepare_xml_data' ) );
59
- add_action( 'wp_ajax_astra-sites-import-options', array( $this, 'import_options' ) );
60
- add_action( 'wp_ajax_astra-sites-import-widgets', array( $this, 'import_widgets' ) );
61
- add_action( 'wp_ajax_astra-sites-import-end', array( $this, 'import_end' ) );
62
-
63
- // Hooks in AJAX.
64
- add_action( 'astra_sites_import_complete', array( $this, 'clear_cache' ) );
65
- add_action( 'init', array( $this, 'load_importer' ) );
66
-
67
- require_once ASTRA_SITES_DIR . 'inc/importers/batch-processing/class-astra-sites-batch-processing.php';
68
-
69
- add_action( 'astra_sites_image_import_complete', array( $this, 'clear_cache' ) );
70
-
71
- // Reset Customizer Data.
72
- add_action( 'wp_ajax_astra-sites-reset-customizer-data', array( $this, 'reset_customizer_data' ) );
73
- add_action( 'wp_ajax_astra-sites-reset-site-options', array( $this, 'reset_site_options' ) );
74
- add_action( 'wp_ajax_astra-sites-reset-widgets-data', array( $this, 'reset_widgets_data' ) );
75
-
76
- // Reset Post & Terms.
77
- add_action( 'wp_ajax_astra-sites-delete-posts', array( $this, 'delete_imported_posts' ) );
78
- add_action( 'wp_ajax_astra-sites-delete-wp-forms', array( $this, 'delete_imported_wp_forms' ) );
79
- add_action( 'wp_ajax_astra-sites-delete-terms', array( $this, 'delete_imported_terms' ) );
80
-
81
- if ( version_compare( get_bloginfo( 'version' ), '5.1.0', '>=' ) ) {
82
- add_filter( 'http_request_timeout', array( $this, 'set_timeout_for_images' ), 10, 2 );
83
- }
84
- }
85
-
86
- /**
87
- * Set the timeout for the HTTP request by request URL.
88
- *
89
- * E.g. If URL is images (jpg|png|gif|jpeg) are from the domain `https://websitedemos.net` then we have set the timeout by 30 seconds. Default 5 seconds.
90
- *
91
- * @since 1.3.8
92
- *
93
- * @param int $timeout_value Time in seconds until a request times out. Default 5.
94
- * @param string $url The request URL.
95
- */
96
- function set_timeout_for_images( $timeout_value, $url ) {
97
-
98
- // URL not contain `https://websitedemos.net` then return $timeout_value.
99
- if ( strpos( $url, 'https://websitedemos.net' ) === false ) {
100
- return $timeout_value;
101
- }
102
-
103
- // Check is image URL of type jpg|png|gif|jpeg.
104
- if ( Astra_Sites_Image_Importer::get_instance()->is_image_url( $url ) ) {
105
- $timeout_value = 30;
106
- }
107
- return $timeout_value;
108
- }
109
-
110
- /**
111
- * Load WordPress WXR importer.
112
- */
113
- public function load_importer() {
114
- require_once ASTRA_SITES_DIR . 'inc/importers/wxr-importer/class-astra-wxr-importer.php';
115
- }
116
-
117
- /**
118
- * Start Site Import
119
- *
120
- * @since 1.1.0
121
- * @return void
122
- */
123
- function import_start() {
124
-
125
- if ( ! current_user_can( 'customize' ) ) {
126
- wp_send_json_error( __( 'You have not "customize" access to import the Astra site.', 'astra-sites' ) );
127
- }
128
-
129
- $demo_api_uri = isset( $_POST['api_url'] ) ? esc_url( $_POST['api_url'] ) : '';
130
-
131
- if ( ! empty( $demo_api_uri ) ) {
132
-
133
- $demo_data = self::get_astra_single_demo( $demo_api_uri );
134
-
135
- update_option( 'astra_sites_import_data', $demo_data );
136
-
137
- if ( is_wp_error( $demo_data ) ) {
138
- wp_send_json_error( $demo_data->get_error_message() );
139
- } else {
140
- $log_file = Astra_Sites_Importer_Log::add_log_file_url();
141
- if ( isset( $log_file['url'] ) && ! empty( $log_file['url'] ) ) {
142
- $demo_data['log_file'] = $log_file['url'];
143
- }
144
- do_action( 'astra_sites_import_start', $demo_data, $demo_api_uri );
145
- }
146
-
147
- wp_send_json_success( $demo_data );
148
-
149
- } else {
150
- wp_send_json_error( __( 'Request site API URL is empty. Try again!', 'astra-sites' ) );
151
- }
152
-
153
- }
154
-
155
- /**
156
- * Import WP Forms
157
- *
158
- * @since 1.2.14
159
- *
160
- * @return void
161
- */
162
- function import_wpforms() {
163
-
164
- $wpforms_url = ( isset( $_REQUEST['wpforms_url'] ) ) ? urldecode( $_REQUEST['wpforms_url'] ) : '';
165
- $ids_mapping = array();
166
-
167
- if ( ! empty( $wpforms_url ) && function_exists( 'wpforms_encode' ) ) {
168
-
169
- // Download XML file.
170
- $xml_path = Astra_Sites_Helper::download_file( $wpforms_url );
171
-
172
- if ( $xml_path['success'] ) {
173
- if ( isset( $xml_path['data']['file'] ) ) {
174
-
175
- $ext = strtolower( pathinfo( $xml_path['data']['file'], PATHINFO_EXTENSION ) );
176
-
177
- if ( 'json' === $ext ) {
178
- $forms = json_decode( file_get_contents( $xml_path['data']['file'] ), true );
179
-
180
- if ( ! empty( $forms ) ) {
181
-
182
- foreach ( $forms as $form ) {
183
- $title = ! empty( $form['settings']['form_title'] ) ? $form['settings']['form_title'] : '';
184
- $desc = ! empty( $form['settings']['form_desc'] ) ? $form['settings']['form_desc'] : '';
185
-
186
- $new_id = post_exists( $title );
187
-
188
- if ( ! $new_id ) {
189
- $new_id = wp_insert_post(
190
- array(
191
- 'post_title' => $title,
192
- 'post_status' => 'publish',
193
- 'post_type' => 'wpforms',
194
- 'post_excerpt' => $desc,
195
- )
196
- );
197
-
198
- // Set meta for tracking the post.
199
- update_post_meta( $new_id, '_astra_sites_imported_wp_forms', true );
200
- Astra_Sites_Importer_Log::add( 'Inserted WP Form ' . $new_id );
201
- }
202
-
203
- if ( $new_id ) {
204
-
205
- // ID mapping.
206
- $ids_mapping[ $form['id'] ] = $new_id;
207
-
208
- $form['id'] = $new_id;
209
- wp_update_post(
210
- array(
211
- 'ID' => $new_id,
212
- 'post_content' => wpforms_encode( $form ),
213
- )
214
- );
215
- }
216
- }
217
- }
218
- }
219
- }
220
- }
221
- }
222
-
223
- update_option( 'astra_sites_wpforms_ids_mapping', $ids_mapping );
224
-
225
- wp_send_json_success( $ids_mapping );
226
- }
227
-
228
- /**
229
- * Import Customizer Settings.
230
- *
231
- * @since 1.0.14
232
- * @return void
233
- */
234
- function import_customizer_settings() {
235
-
236
- $customizer_data = ( isset( $_POST['customizer_data'] ) ) ? (array) json_decode( stripcslashes( $_POST['customizer_data'] ), 1 ) : array();
237
-
238
- if ( ! empty( $customizer_data ) ) {
239
-
240
- Astra_Sites_Importer_Log::add( 'Imported Customizer Settings ' . json_encode( $customizer_data ) );
241
-
242
- // Set meta for tracking the post.
243
- update_option( '_astra_sites_old_customizer_data', $customizer_data );
244
-
245
- Astra_Customizer_Import::instance()->import( $customizer_data );
246
-
247
- wp_send_json_success( $customizer_data );
248
-
249
- } else {
250
- wp_send_json_error( __( 'Customizer data is empty!', 'astra-sites' ) );
251
- }
252
-
253
- }
254
-
255
- /**
256
- * Prepare XML Data.
257
- *
258
- * @since 1.1.0
259
- * @return void
260
- */
261
- function prepare_xml_data() {
262
-
263
- if ( ! class_exists( 'XMLReader' ) ) {
264
- wp_send_json_error( __( 'If XMLReader is not available, it imports all other settings and only skips XML import. This creates an incomplete website. We should bail early and not import anything if this is not present.', 'astra-sites' ) );
265
- }
266
-
267
- $wxr_url = ( isset( $_REQUEST['wxr_url'] ) ) ? urldecode( $_REQUEST['wxr_url'] ) : '';
268
-
269
- if ( isset( $wxr_url ) ) {
270
-
271
- Astra_Sites_Importer_Log::add( 'Importing from XML ' . $wxr_url );
272
-
273
- // Download XML file.
274
- $xml_path = Astra_Sites_Helper::download_file( $wxr_url );
275
-
276
- if ( $xml_path['success'] ) {
277
- if ( isset( $xml_path['data']['file'] ) ) {
278
- $data = Astra_WXR_Importer::instance()->get_xml_data( $xml_path['data']['file'] );
279
- $data['xml'] = $xml_path['data'];
280
- wp_send_json_success( $data );
281
- } else {
282
- wp_send_json_error( __( 'There was an error downloading the XML file.', 'astra-sites' ) );
283
- }
284
- } else {
285
- wp_send_json_error( $xml_path['data'] );
286
- }
287
- } else {
288
- wp_send_json_error( __( 'Invalid site XML file!', 'astra-sites' ) );
289
- }
290
-
291
- }
292
-
293
- /**
294
- * Import Options.
295
- *
296
- * @since 1.0.14
297
- * @return void
298
- */
299
- function import_options() {
300
-
301
- $options_data = ( isset( $_POST['options_data'] ) ) ? (array) json_decode( stripcslashes( $_POST['options_data'] ), 1 ) : '';
302
-
303
- if ( ! empty( $options_data ) ) {
304
-
305
- // Set meta for tracking the post.
306
- if ( is_array( $options_data ) ) {
307
- Astra_Sites_Importer_Log::add( 'Imported - Site Options ' . json_encode( $options_data ) );
308
- update_option( '_astra_sites_old_site_options', $options_data );
309
- }
310
-
311
- $options_importer = Astra_Site_Options_Import::instance();
312
- $options_importer->import_options( $options_data );
313
- wp_send_json_success( $options_data );
314
- } else {
315
- wp_send_json_error( __( 'Site options are empty!', 'astra-sites' ) );
316
- }
317
-
318
- }
319
-
320
- /**
321
- * Import Widgets.
322
- *
323
- * @since 1.0.14
324
- * @return void
325
- */
326
- function import_widgets() {
327
-
328
- $widgets_data = ( isset( $_POST['widgets_data'] ) ) ? (object) json_decode( stripcslashes( $_POST['widgets_data'] ) ) : '';
329
-
330
- Astra_Sites_Importer_Log::add( 'Imported - Widgets ' . json_encode( $widgets_data ) );
331
-
332
- if ( ! empty( $widgets_data ) ) {
333
-
334
- $widgets_importer = Astra_Widget_Importer::instance();
335
- $status = $widgets_importer->import_widgets_data( $widgets_data );
336
-
337
- // Set meta for tracking the post.
338
- if ( is_object( $widgets_data ) ) {
339
- $widgets_data = (array) $widgets_data;
340
- update_option( '_astra_sites_old_widgets_data', $widgets_data );
341
- }
342
-
343
- wp_send_json_success( $widgets_data );
344
- } else {
345
- wp_send_json_error( __( 'Widget data is empty!', 'astra-sites' ) );
346
- }
347
-
348
- }
349
-
350
- /**
351
- * Import End.
352
- *
353
- * @since 1.0.14
354
- * @return void
355
- */
356
- function import_end() {
357
- do_action( 'astra_sites_import_complete' );
358
- }
359
-
360
-
361
- /**
362
- * Get single demo.
363
- *
364
- * @since 1.0.0
365
- *
366
- * @param (String) $demo_api_uri API URL of a demo.
367
- *
368
- * @return (Array) $astra_demo_data demo data for the demo.
369
- */
370
- public static function get_astra_single_demo( $demo_api_uri ) {
371
-
372
- // default values.
373
- $remote_args = array();
374
- $defaults = array(
375
- 'id' => '',
376
- 'astra-site-widgets-data' => '',
377
- 'astra-site-customizer-data' => '',
378
- 'astra-site-options-data' => '',
379
- 'astra-post-data-mapping' => '',
380
- 'astra-site-wxr-path' => '',
381
- 'astra-site-wpforms-path' => '',
382
- 'astra-enabled-extensions' => '',
383
- 'astra-custom-404' => '',
384
- 'required-plugins' => '',
385
- 'astra-site-taxonomy-mapping' => '',
386
- );
387
-
388
- $api_args = apply_filters(
389
- 'astra_sites_api_args',
390
- array(
391
- 'timeout' => 15,
392
- )
393
- );
394
-
395
- // Use this for premium demos.
396
- $request_params = apply_filters(
397
- 'astra_sites_api_params',
398
- array(
399
- 'purchase_key' => '',
400
- 'site_url' => '',
401
- )
402
- );
403
-
404
- $demo_api_uri = add_query_arg( $request_params, $demo_api_uri );
405
-
406
- // API Call.
407
- $response = wp_remote_get( $demo_api_uri, $api_args );
408
-
409
- if ( is_wp_error( $response ) || ( isset( $response->status ) && 0 === $response->status ) ) {
410
- if ( isset( $response->status ) ) {
411
- $data = json_decode( $response, true );
412
- } else {
413
- return new WP_Error( 'api_invalid_response_code', $response->get_error_message() );
414
- }
415
- } else {
416
- $data = json_decode( wp_remote_retrieve_body( $response ), true );
417
- }
418
-
419
- $data = json_decode( wp_remote_retrieve_body( $response ), true );
420
-
421
- if ( ! isset( $data['code'] ) ) {
422
- $remote_args['id'] = $data['id'];
423
- $remote_args['astra-site-widgets-data'] = json_decode( $data['astra-site-widgets-data'] );
424
- $remote_args['astra-site-customizer-data'] = $data['astra-site-customizer-data'];
425
- $remote_args['astra-site-options-data'] = $data['astra-site-options-data'];
426
- $remote_args['astra-post-data-mapping'] = $data['astra-post-data-mapping'];
427
- $remote_args['astra-site-wxr-path'] = $data['astra-site-wxr-path'];
428
- $remote_args['astra-site-wpforms-path'] = $data['astra-site-wpforms-path'];
429
- $remote_args['astra-enabled-extensions'] = $data['astra-enabled-extensions'];
430
- $remote_args['astra-custom-404'] = $data['astra-custom-404'];
431
- $remote_args['required-plugins'] = $data['required-plugins'];
432
- $remote_args['astra-site-taxonomy-mapping'] = $data['astra-site-taxonomy-mapping'];
433
- }
434
-
435
- // Merge remote demo and defaults.
436
- return wp_parse_args( $remote_args, $defaults );
437
- }
438
-
439
- /**
440
- * Clear Cache.
441
- *
442
- * @since 1.0.9
443
- */
444
- public function clear_cache() {
445
- // Clear 'Elementor' file cache.
446
- if ( class_exists( '\Elementor\Plugin' ) ) {
447
- Elementor\Plugin::$instance->posts_css_manager->clear_cache();
448
- }
449
-
450
- // Clear 'Builder Builder' cache.
451
- if ( is_callable( 'FLBuilderModel::delete_asset_cache_for_all_posts' ) ) {
452
- FLBuilderModel::delete_asset_cache_for_all_posts();
453
- }
454
-
455
- // Clear 'Astra Addon' cache.
456
- if ( is_callable( 'Astra_Minify::refresh_assets' ) ) {
457
- Astra_Minify::refresh_assets();
458
- }
459
-
460
- Astra_Sites_Importer_Log::add( 'Complete ' );
461
- }
462
-
463
- /**
464
- * Reset customizer data
465
- *
466
- * @since 1.3.0
467
- * @return void
468
- */
469
- function reset_customizer_data() {
470
- Astra_Sites_Importer_Log::add( 'Deleted customizer Settings ' . json_encode( get_option( 'astra-settings', array() ) ) );
471
-
472
- delete_option( 'astra-settings' );
473
-
474
- wp_send_json_success();
475
- }
476
-
477
- /**
478
- * Reset site options
479
- *
480
- * @since 1.3.0
481
- * @return void
482
- */
483
- function reset_site_options() {
484
-
485
- $options = get_option( '_astra_sites_old_site_options', array() );
486
-
487
- Astra_Sites_Importer_Log::add( 'Deleted - Site Options ' . json_encode( $options ) );
488
-
489
- if ( $options ) {
490
- foreach ( $options as $option_key => $option_value ) {
491
- delete_option( $option_key );
492
- }
493
- }
494
-
495
- wp_send_json_success();
496
- }
497
-
498
- /**
499
- * Reset widgets data
500
- *
501
- * @since 1.3.0
502
- * @return void
503
- */
504
- function reset_widgets_data() {
505
- $old_widgets = get_option( '_astra_sites_old_widgets_data', array() );
506
-
507
- Astra_Sites_Importer_Log::add( 'DELETED - WIDGETS ' . json_encode( $old_widgets ) );
508
-
509
- if ( $old_widgets ) {
510
- $sidebars_widgets = get_option( 'sidebars_widgets', array() );
511
-
512
- foreach ( $old_widgets as $sidebar_id => $widgets ) {
513
-
514
- if ( $widgets ) {
515
- foreach ( $widgets as $widget_key => $widget_data ) {
516
-
517
- if ( isset( $sidebars_widgets['wp_inactive_widgets'] ) ) {
518
- if ( ! in_array( $widget_key, $sidebars_widgets['wp_inactive_widgets'], true ) ) {
519
- $sidebars_widgets['wp_inactive_widgets'][] = $widget_key;
520
- }
521
- }
522
- }
523
- }
524
- }
525
-
526
- update_option( 'sidebars_widgets', $sidebars_widgets );
527
- }
528
-
529
- wp_send_json_success();
530
- }
531
-
532
- /**
533
- * Delete imported posts
534
- *
535
- * @since 1.3.0
536
- * @return void
537
- */
538
- function delete_imported_posts() {
539
- $post_id = isset( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : '';
540
- $message = 'Deleted - Post ID ' . $post_id . ' - ' . get_post_type( $post_id ) . ' - ' . get_the_title( $post_id );
541
-
542
- Astra_Sites_Importer_Log::add( $message );
543
- wp_delete_post( $post_id, true );
544
-
545
- /* translators: %s is the post ID */
546
- wp_send_json_success( $message );
547
- }
548
-
549
- /**
550
- * Delete imported WP forms
551
- *
552
- * @since 1.3.0
553
- * @return void
554
- */
555
- function delete_imported_wp_forms() {
556
- $post_id = isset( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : '';
557
-
558
- $message = 'Deleted - Form ID ' . $post_id . ' - ' . get_post_type( $post_id ) . ' - ' . get_the_title( $post_id );
559
-
560
- Astra_Sites_Importer_Log::add( $message );
561
-
562
- wp_delete_post( $post_id, true );
563
-
564
- /* translators: %s is the form ID */
565
- wp_send_json_success( $message );
566
- }
567
-
568
- /**
569
- * Delete imported terms
570
- *
571
- * @since 1.3.0
572
- * @return void
573
- */
574
- function delete_imported_terms() {
575
-
576
- $term_id = isset( $_REQUEST['term_id'] ) ? absint( $_REQUEST['term_id'] ) : '';
577
-
578
- $message = '';
579
-
580
- if ( $term_id ) {
581
- $term = get_term( $term_id );
582
- if ( $term ) {
583
- $message = 'Deleted - Term ' . $term_id . ' - ' . $term->name . ' ' . $term->taxonomy;
584
- Astra_Sites_Importer_Log::add( $message );
585
- wp_delete_term( $term_id, $term->taxonomy );
586
- }
587
- }
588
-
589
- /* translators: %s is the term ID */
590
- wp_send_json_success( $message );
591
- }
592
-
593
- }
594
-
595
- /**
596
- * Kicking this off by calling 'get_instance()' method
597
- */
598
- Astra_Sites_Importer::get_instance();
599
-
600
- endif;
601
-
602
-
 
 
 
1
+ <?php
2
+ /**
3
+ * Astra Sites Importer
4
+ *
5
+ * @since 1.0.0
6
+ * @package Astra Sites
7
+ */
8
+
9
+ defined( 'ABSPATH' ) or exit;
10
+
11
+ if ( ! class_exists( 'Astra_Sites_Importer' ) ) :
12
+
13
+ /**
14
+ * Astra Sites Importer
15
+ */
16
+ class Astra_Sites_Importer {
17
+
18
+ /**
19
+ * Instance
20
+ *
21
+ * @since 1.0.0
22
+ * @var (Object) Class object
23
+ */
24
+ public static $_instance = null;
25
+
26
+ /**
27
+ * Set Instance
28
+ *
29
+ * @since 1.0.0
30
+ *
31
+ * @return object Class object.
32
+ */
33
+ public static function get_instance() {
34
+ if ( ! isset( self::$_instance ) ) {
35
+ self::$_instance = new self;
36
+ }
37
+
38
+ return self::$_instance;
39
+ }
40
+
41
+ /**
42
+ * Constructor.
43
+ *
44
+ * @since 1.0.0
45
+ */
46
+ public function __construct() {
47
+
48
+ require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-importer-log.php';
49
+ require_once ASTRA_SITES_DIR . 'inc/importers/class-astra-sites-helper.php';
50
+ require_once ASTRA_SITES_DIR . 'inc/importers/class-widgets-importer.php';
51
+ require_once ASTRA_SITES_DIR . 'inc/importers/class-astra-customizer-import.php';
52
+ require_once ASTRA_SITES_DIR . 'inc/importers/class-astra-site-options-import.php';
53
+
54
+ // Import AJAX.
55
+ add_action( 'wp_ajax_astra-sites-import-set-site-data', array( $this, 'import_start' ) );
56
+ add_action( 'wp_ajax_astra-sites-import-wpforms', array( $this, 'import_wpforms' ) );
57
+ add_action( 'wp_ajax_astra-sites-import-customizer-settings', array( $this, 'import_customizer_settings' ) );
58
+ add_action( 'wp_ajax_astra-sites-import-prepare-xml', array( $this, 'prepare_xml_data' ) );
59
+ add_action( 'wp_ajax_astra-sites-import-options', array( $this, 'import_options' ) );
60
+ add_action( 'wp_ajax_astra-sites-import-widgets', array( $this, 'import_widgets' ) );
61
+ add_action( 'wp_ajax_astra-sites-import-end', array( $this, 'import_end' ) );
62
+
63
+ // Hooks in AJAX.
64
+ add_action( 'astra_sites_import_complete', array( $this, 'clear_cache' ) );
65
+ add_action( 'init', array( $this, 'load_importer' ) );
66
+
67
+ require_once ASTRA_SITES_DIR . 'inc/importers/batch-processing/class-astra-sites-batch-processing.php';
68
+
69
+ add_action( 'astra_sites_image_import_complete', array( $this, 'clear_cache' ) );
70
+
71
+ // Reset Customizer Data.
72
+ add_action( 'wp_ajax_astra-sites-reset-customizer-data', array( $this, 'reset_customizer_data' ) );
73
+ add_action( 'wp_ajax_astra-sites-reset-site-options', array( $this, 'reset_site_options' ) );
74
+ add_action( 'wp_ajax_astra-sites-reset-widgets-data', array( $this, 'reset_widgets_data' ) );
75
+
76
+ // Reset Post & Terms.
77
+ add_action( 'wp_ajax_astra-sites-delete-posts', array( $this, 'delete_imported_posts' ) );
78
+ add_action( 'wp_ajax_astra-sites-delete-wp-forms', array( $this, 'delete_imported_wp_forms' ) );
79
+ add_action( 'wp_ajax_astra-sites-delete-terms', array( $this, 'delete_imported_terms' ) );
80
+
81
+ if ( version_compare( get_bloginfo( 'version' ), '5.1.0', '>=' ) ) {
82
+ add_filter( 'http_request_timeout', array( $this, 'set_timeout_for_images' ), 10, 2 );
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Set the timeout for the HTTP request by request URL.
88
+ *
89
+ * E.g. If URL is images (jpg|png|gif|jpeg) are from the domain `https://websitedemos.net` then we have set the timeout by 30 seconds. Default 5 seconds.
90
+ *
91
+ * @since 1.3.8
92
+ *
93
+ * @param int $timeout_value Time in seconds until a request times out. Default 5.
94
+ * @param string $url The request URL.
95
+ */
96
+ function set_timeout_for_images( $timeout_value, $url ) {
97
+
98
+ // URL not contain `https://websitedemos.net` then return $timeout_value.
99
+ if ( strpos( $url, 'https://websitedemos.net' ) === false ) {
100
+ return $timeout_value;
101
+ }
102
+
103
+ // Check is image URL of type jpg|png|gif|jpeg.
104
+ if ( Astra_Sites_Image_Importer::get_instance()->is_image_url( $url ) ) {
105
+ $timeout_value = 30;
106
+ }
107
+ return $timeout_value;
108
+ }
109
+
110
+ /**
111
+ * Load WordPress WXR importer.
112
+ */
113
+ public function load_importer() {
114
+ require_once ASTRA_SITES_DIR . 'inc/importers/wxr-importer/class-astra-wxr-importer.php';
115
+ }
116
+
117
+ /**
118
+ * Start Site Import
119
+ *
120
+ * @since 1.1.0
121
+ * @return void
122
+ */
123
+ function import_start() {
124
+
125
+ if ( ! current_user_can( 'customize' ) ) {
126
+ wp_send_json_error( __( 'You have not "customize" access to import the Astra site.', 'astra-sites' ) );
127
+ }
128
+
129
+ $demo_api_uri = isset( $_POST['api_url'] ) ? esc_url( $_POST['api_url'] ) : '';
130
+
131
+ if ( ! empty( $demo_api_uri ) ) {
132
+
133
+ $demo_data = self::get_astra_single_demo( $demo_api_uri );
134
+ update_option( 'astra_sites_import_data', $demo_data );
135
+
136
+ if ( is_wp_error( $demo_data ) ) {
137
+ wp_send_json_error( $demo_data->get_error_message() );
138
+ } else {
139
+ $log_file = Astra_Sites_Importer_Log::add_log_file_url();
140
+ if ( isset( $log_file['url'] ) && ! empty( $log_file['url'] ) ) {
141
+ $demo_data['log_file'] = $log_file['url'];
142
+ }
143
+ do_action( 'astra_sites_import_start', $demo_data, $demo_api_uri );
144
+ }
145
+
146
+ wp_send_json_success( $demo_data );
147
+
148
+ } else {
149
+ wp_send_json_error( __( 'Request site API URL is empty. Try again!', 'astra-sites' ) );
150
+ }
151
+
152
+ }
153
+
154
+ /**
155
+ * Import WP Forms
156
+ *
157
+ * @since 1.2.14
158
+ *
159
+ * @return void
160
+ */
161
+ function import_wpforms() {
162
+
163
+ $wpforms_url = ( isset( $_REQUEST['wpforms_url'] ) ) ? urldecode( $_REQUEST['wpforms_url'] ) : '';
164
+ $ids_mapping = array();
165
+
166
+ if ( ! empty( $wpforms_url ) && function_exists( 'wpforms_encode' ) ) {
167
+
168
+ // Download XML file.
169
+ $xml_path = Astra_Sites_Helper::download_file( $wpforms_url );
170
+
171
+ if ( $xml_path['success'] ) {
172
+ if ( isset( $xml_path['data']['file'] ) ) {
173
+
174
+ $ext = strtolower( pathinfo( $xml_path['data']['file'], PATHINFO_EXTENSION ) );
175
+
176
+ if ( 'json' === $ext ) {
177
+ $forms = json_decode( file_get_contents( $xml_path['data']['file'] ), true );
178
+
179
+ if ( ! empty( $forms ) ) {
180
+
181
+ foreach ( $forms as $form ) {
182
+ $title = ! empty( $form['settings']['form_title'] ) ? $form['settings']['form_title'] : '';
183
+ $desc = ! empty( $form['settings']['form_desc'] ) ? $form['settings']['form_desc'] : '';
184
+
185
+ $new_id = post_exists( $title );
186
+
187
+ if ( ! $new_id ) {
188
+ $new_id = wp_insert_post(
189
+ array(
190
+ 'post_title' => $title,
191
+ 'post_status' => 'publish',
192
+ 'post_type' => 'wpforms',
193
+ 'post_excerpt' => $desc,
194
+ )
195
+ );
196
+
197
+ // Set meta for tracking the post.
198
+ update_post_meta( $new_id, '_astra_sites_imported_wp_forms', true );
199
+ Astra_Sites_Importer_Log::add( 'Inserted WP Form ' . $new_id );
200
+ }
201
+
202
+ if ( $new_id ) {
203
+
204
+ // ID mapping.
205
+ $ids_mapping[ $form['id'] ] = $new_id;
206
+
207
+ $form['id'] = $new_id;
208
+ wp_update_post(
209
+ array(
210
+ 'ID' => $new_id,
211
+ 'post_content' => wpforms_encode( $form ),
212
+ )
213
+ );
214
+ }
215
+ }
216
+ }
217
+ }
218
+ }
219
+ }
220
+ }
221
+
222
+ update_option( 'astra_sites_wpforms_ids_mapping', $ids_mapping );
223
+
224
+ wp_send_json_success( $ids_mapping );
225
+ }
226
+
227
+ /**
228
+ * Import Customizer Settings.
229
+ *
230
+ * @since 1.0.14
231
+ * @return void
232
+ */
233
+ function import_customizer_settings() {
234
+
235
+ $customizer_data = ( isset( $_POST['customizer_data'] ) ) ? (array) json_decode( stripcslashes( $_POST['customizer_data'] ), 1 ) : array();
236
+
237
+ if ( ! empty( $customizer_data ) ) {
238
+
239
+ Astra_Sites_Importer_Log::add( 'Imported Customizer Settings ' . json_encode( $customizer_data ) );
240
+
241
+ // Set meta for tracking the post.
242
+ update_option( '_astra_sites_old_customizer_data', $customizer_data );
243
+
244
+ Astra_Customizer_Import::instance()->import( $customizer_data );
245
+
246
+ wp_send_json_success( $customizer_data );
247
+
248
+ } else {
249
+ wp_send_json_error( __( 'Customizer data is empty!', 'astra-sites' ) );
250
+ }
251
+
252
+ }
253
+
254
+ /**
255
+ * Prepare XML Data.
256
+ *
257
+ * @since 1.1.0
258
+ * @return void
259
+ */
260
+ function prepare_xml_data() {
261
+
262
+ if ( ! class_exists( 'XMLReader' ) ) {
263
+ wp_send_json_error( __( 'If XMLReader is not available, it imports all other settings and only skips XML import. This creates an incomplete website. We should bail early and not import anything if this is not present.', 'astra-sites' ) );
264
+ }
265
+
266
+ $wxr_url = ( isset( $_REQUEST['wxr_url'] ) ) ? urldecode( $_REQUEST['wxr_url'] ) : '';
267
+
268
+ if ( isset( $wxr_url ) ) {
269
+
270
+ Astra_Sites_Importer_Log::add( 'Importing from XML ' . $wxr_url );
271
+
272
+ // Download XML file.
273
+ $xml_path = Astra_Sites_Helper::download_file( $wxr_url );
274
+
275
+ if ( $xml_path['success'] ) {
276
+ if ( isset( $xml_path['data']['file'] ) ) {
277
+ $data = Astra_WXR_Importer::instance()->get_xml_data( $xml_path['data']['file'] );
278
+ $data['xml'] = $xml_path['data'];
279
+ wp_send_json_success( $data );
280
+ } else {
281
+ wp_send_json_error( __( 'There was an error downloading the XML file.', 'astra-sites' ) );
282
+ }
283
+ } else {
284
+ wp_send_json_error( $xml_path['data'] );
285
+ }
286
+ } else {
287
+ wp_send_json_error( __( 'Invalid site XML file!', 'astra-sites' ) );
288
+ }
289
+
290
+ }
291
+
292
+ /**
293
+ * Import Options.
294
+ *
295
+ * @since 1.0.14
296
+ * @return void
297
+ */
298
+ function import_options() {
299
+
300
+ $options_data = ( isset( $_POST['options_data'] ) ) ? (array) json_decode( stripcslashes( $_POST['options_data'] ), 1 ) : '';
301
+
302
+ if ( ! empty( $options_data ) ) {
303
+
304
+ // Set meta for tracking the post.
305
+ if ( is_array( $options_data ) ) {
306
+ Astra_Sites_Importer_Log::add( 'Imported - Site Options ' . json_encode( $options_data ) );
307
+ update_option( '_astra_sites_old_site_options', $options_data );
308
+ }
309
+
310
+ $options_importer = Astra_Site_Options_Import::instance();
311
+ $options_importer->import_options( $options_data );
312
+ wp_send_json_success( $options_data );
313
+ } else {
314
+ wp_send_json_error( __( 'Site options are empty!', 'astra-sites' ) );
315
+ }
316
+
317
+ }
318
+
319
+ /**
320
+ * Import Widgets.
321
+ *
322
+ * @since 1.0.14
323
+ * @return void
324
+ */
325
+ function import_widgets() {
326
+
327
+ $widgets_data = ( isset( $_POST['widgets_data'] ) ) ? (object) json_decode( stripcslashes( $_POST['widgets_data'] ) ) : '';
328
+
329
+ Astra_Sites_Importer_Log::add( 'Imported - Widgets ' . json_encode( $widgets_data ) );
330
+
331
+ if ( ! empty( $widgets_data ) ) {
332
+
333
+ $widgets_importer = Astra_Widget_Importer::instance();
334
+ $status = $widgets_importer->import_widgets_data( $widgets_data );
335
+
336
+ // Set meta for tracking the post.
337
+ if ( is_object( $widgets_data ) ) {
338
+ $widgets_data = (array) $widgets_data;
339
+ update_option( '_astra_sites_old_widgets_data', $widgets_data );
340
+ }
341
+
342
+ wp_send_json_success( $widgets_data );
343
+ } else {
344
+ wp_send_json_error( __( 'Widget data is empty!', 'astra-sites' ) );
345
+ }
346
+
347
+ }
348
+
349
+ /**
350
+ * Import End.
351
+ *
352
+ * @since 1.0.14
353
+ * @return void
354
+ */
355
+ function import_end() {
356
+ do_action( 'astra_sites_import_complete' );
357
+ }
358
+
359
+
360
+ /**
361
+ * Get single demo.
362
+ *
363
+ * @since 1.0.0
364
+ *
365
+ * @param (String) $demo_api_uri API URL of a demo.
366
+ *
367
+ * @return (Array) $astra_demo_data demo data for the demo.
368
+ */
369
+ public static function get_astra_single_demo( $demo_api_uri ) {
370
+
371
+ // default values.
372
+ $remote_args = array();
373
+ $defaults = array(
374
+ 'id' => '',
375
+ 'astra-site-widgets-data' => '',
376
+ 'astra-site-customizer-data' => '',
377
+ 'astra-site-options-data' => '',
378
+ 'astra-post-data-mapping' => '',
379
+ 'astra-site-wxr-path' => '',
380
+ 'astra-site-wpforms-path' => '',
381
+ 'astra-enabled-extensions' => '',
382
+ 'astra-custom-404' => '',
383
+ 'required-plugins' => '',
384
+ 'astra-site-taxonomy-mapping' => '',
385
+ );
386
+
387
+ $api_args = apply_filters(
388
+ 'astra_sites_api_args',
389
+ array(
390
+ 'timeout' => 15,
391
+ )
392
+ );
393
+
394
+ // Use this for premium demos.
395
+ $request_params = apply_filters(
396
+ 'astra_sites_api_params',
397
+ array(
398
+ 'purchase_key' => '',
399
+ 'site_url' => '',
400
+ )
401
+ );
402
+
403
+ $demo_api_uri = add_query_arg( $request_params, $demo_api_uri );
404
+
405
+ // API Call.
406
+ $response = wp_remote_get( $demo_api_uri, $api_args );
407
+
408
+ if ( is_wp_error( $response ) || ( isset( $response->status ) && 0 === $response->status ) ) {
409
+ if ( isset( $response->status ) ) {
410
+ $data = json_decode( $response, true );
411
+ } else {
412
+ return new WP_Error( 'api_invalid_response_code', $response->get_error_message() );
413
+ }
414
+ }
415
+
416
+ if ( wp_remote_retrieve_response_code( $response ) !== 200 ) {
417
+ return new WP_Error( 'api_invalid_response_code', wp_remote_retrieve_body( $response ) );
418
+ } else {
419
+ $data = json_decode( wp_remote_retrieve_body( $response ), true );
420
+ }
421
+
422
+ $data = json_decode( wp_remote_retrieve_body( $response ), true );
423
+
424
+ if ( ! isset( $data['code'] ) ) {
425
+ $remote_args['id'] = $data['id'];
426
+ $remote_args['astra-site-widgets-data'] = json_decode( $data['astra-site-widgets-data'] );
427
+ $remote_args['astra-site-customizer-data'] = $data['astra-site-customizer-data'];
428
+ $remote_args['astra-site-options-data'] = $data['astra-site-options-data'];
429
+ $remote_args['astra-post-data-mapping'] = $data['astra-post-data-mapping'];
430
+ $remote_args['astra-site-wxr-path'] = $data['astra-site-wxr-path'];
431
+ $remote_args['astra-site-wpforms-path'] = $data['astra-site-wpforms-path'];
432
+ $remote_args['astra-enabled-extensions'] = $data['astra-enabled-extensions'];
433
+ $remote_args['astra-custom-404'] = $data['astra-custom-404'];
434
+ $remote_args['required-plugins'] = $data['required-plugins'];
435
+ $remote_args['astra-site-taxonomy-mapping'] = $data['astra-site-taxonomy-mapping'];
436
+ }
437
+
438
+ // Merge remote demo and defaults.
439
+ return wp_parse_args( $remote_args, $defaults );
440
+ }
441
+
442
+ /**
443
+ * Clear Cache.
444
+ *
445
+ * @since 1.0.9
446
+ */
447
+ public function clear_cache() {
448
+ // Clear 'Elementor' file cache.
449
+ if ( class_exists( '\Elementor\Plugin' ) ) {
450
+ Elementor\Plugin::$instance->posts_css_manager->clear_cache();
451
+ }
452
+
453
+ // Clear 'Builder Builder' cache.
454
+ if ( is_callable( 'FLBuilderModel::delete_asset_cache_for_all_posts' ) ) {
455
+ FLBuilderModel::delete_asset_cache_for_all_posts();
456
+ }
457
+
458
+ // Clear 'Astra Addon' cache.
459
+ if ( is_callable( 'Astra_Minify::refresh_assets' ) ) {
460
+ Astra_Minify::refresh_assets();
461
+ }
462
+
463
+ Astra_Sites_Importer_Log::add( 'Complete ' );
464
+ }
465
+
466
+ /**
467
+ * Reset customizer data
468
+ *
469
+ * @since 1.3.0
470
+ * @return void
471
+ */
472
+ function reset_customizer_data() {
473
+ Astra_Sites_Importer_Log::add( 'Deleted customizer Settings ' . json_encode( get_option( 'astra-settings', array() ) ) );
474
+
475
+ delete_option( 'astra-settings' );
476
+
477
+ wp_send_json_success();
478
+ }
479
+
480
+ /**
481
+ * Reset site options
482
+ *
483
+ * @since 1.3.0
484
+ * @return void
485
+ */
486
+ function reset_site_options() {
487
+
488
+ $options = get_option( '_astra_sites_old_site_options', array() );
489
+
490
+ Astra_Sites_Importer_Log::add( 'Deleted - Site Options ' . json_encode( $options ) );
491
+
492
+ if ( $options ) {
493
+ foreach ( $options as $option_key => $option_value ) {
494
+ delete_option( $option_key );
495
+ }
496
+ }
497
+
498
+ wp_send_json_success();
499
+ }
500
+
501
+ /**
502
+ * Reset widgets data
503
+ *
504
+ * @since 1.3.0
505
+ * @return void
506
+ */
507
+ function reset_widgets_data() {
508
+ $old_widgets = get_option( '_astra_sites_old_widgets_data', array() );
509
+
510
+ Astra_Sites_Importer_Log::add( 'DELETED - WIDGETS ' . json_encode( $old_widgets ) );
511
+
512
+ if ( $old_widgets ) {
513
+ $sidebars_widgets = get_option( 'sidebars_widgets', array() );
514
+
515
+ foreach ( $old_widgets as $sidebar_id => $widgets ) {
516
+
517
+ if ( $widgets ) {
518
+ foreach ( $widgets as $widget_key => $widget_data ) {
519
+
520
+ if ( isset( $sidebars_widgets['wp_inactive_widgets'] ) ) {
521
+ if ( ! in_array( $widget_key, $sidebars_widgets['wp_inactive_widgets'], true ) ) {
522
+ $sidebars_widgets['wp_inactive_widgets'][] = $widget_key;
523
+ }
524
+ }
525
+ }
526
+ }
527
+ }
528
+
529
+ update_option( 'sidebars_widgets', $sidebars_widgets );
530
+ }
531
+
532
+ wp_send_json_success();
533
+ }
534
+
535
+ /**
536
+ * Delete imported posts
537
+ *
538
+ * @since 1.3.0
539
+ * @return void
540
+ */
541
+ function delete_imported_posts() {
542
+ $post_id = isset( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : '';
543
+ $message = 'Deleted - Post ID ' . $post_id . ' - ' . get_post_type( $post_id ) . ' - ' . get_the_title( $post_id );
544
+
545
+ Astra_Sites_Importer_Log::add( $message );
546
+ wp_delete_post( $post_id, true );
547
+
548
+ /* translators: %s is the post ID */
549
+ wp_send_json_success( $message );
550
+ }
551
+
552
+ /**
553
+ * Delete imported WP forms
554
+ *
555
+ * @since 1.3.0
556
+ * @return void
557
+ */
558
+ function delete_imported_wp_forms() {
559
+ $post_id = isset( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : '';
560
+
561
+ $message = 'Deleted - Form ID ' . $post_id . ' - ' . get_post_type( $post_id ) . ' - ' . get_the_title( $post_id );
562
+
563
+ Astra_Sites_Importer_Log::add( $message );
564
+
565
+ wp_delete_post( $post_id, true );
566
+
567
+ /* translators: %s is the form ID */
568
+ wp_send_json_success( $message );
569
+ }
570
+
571
+ /**
572
+ * Delete imported terms
573
+ *
574
+ * @since 1.3.0
575
+ * @return void
576
+ */
577
+ function delete_imported_terms() {
578
+
579
+ $term_id = isset( $_REQUEST['term_id'] ) ? absint( $_REQUEST['term_id'] ) : '';
580
+
581
+ $message = '';
582
+
583
+ if ( $term_id ) {
584
+ $term = get_term( $term_id );
585
+ if ( $term ) {
586
+ $message = 'Deleted - Term ' . $term_id . ' - ' . $term->name . ' ' . $term->taxonomy;
587
+ Astra_Sites_Importer_Log::add( $message );
588
+ wp_delete_term( $term_id, $term->taxonomy );
589
+ }
590
+ }
591
+
592
+ /* translators: %s is the term ID */
593
+ wp_send_json_success( $message );
594
+ }
595
+
596
+ }
597
+
598
+ /**
599
+ * Kicking this off by calling 'get_instance()' method
600
+ */
601
+ Astra_Sites_Importer::get_instance();
602
+
603
+ endif;
604
+
605
+
inc/classes/class-astra-sites-page.php CHANGED
@@ -1,434 +1,434 @@
1
- <?php
2
- /**
3
- * Astra Sites Page
4
- *
5
- * @since 1.0.6
6
- * @package Astra Sites
7
- */
8
-
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
- if ( ! class_exists( 'Astra_Sites_Page' ) ) {
14
-
15
- /**
16
- * Astra Admin Settings
17
- */
18
- class Astra_Sites_Page {
19
-
20
- /**
21
- * View all actions
22
- *
23
- * @since 1.0.6
24
- * @var array $view_actions
25
- */
26
- public $view_actions = array();
27
-
28
- /**
29
- * Member Variable
30
- *
31
- * @var instance
32
- */
33
- private static $instance;
34
-
35
- /**
36
- * Initiator
37
- *
38
- * @since 1.3.0
39
- */
40
- public static function get_instance() {
41
- if ( ! isset( self::$instance ) ) {
42
- self::$instance = new self;
43
- }
44
- return self::$instance;
45
- }
46
-
47
- /**
48
- * Constructor
49
- *
50
- * @since 1.3.0
51
- */
52
- public function __construct() {
53
-
54
- if ( ! is_admin() ) {
55
- return;
56
- }
57
-
58
- add_action( 'after_setup_theme', array( $this, 'init_admin_settings' ), 99 );
59
- add_action( 'admin_init', array( $this, 'save_page_builder' ) );
60
- add_action( 'admin_notices', array( $this, 'getting_started' ) );
61
- }
62
-
63
- /**
64
- * Admin notice
65
- *
66
- * @since 1.3.5
67
- *
68
- * @return void
69
- */
70
- function getting_started() {
71
- if ( 'plugins' !== get_current_screen()->base ) {
72
- return;
73
- }
74
-
75
- $processed = get_user_meta( get_current_user_id(), '_astra_sites_gettings_started', true );
76
- $product_name = Astra_Sites_White_Label::get_instance()->page_title( 'Astra' );
77
-
78
- if ( $processed ) {
79
- return;
80
- }
81
-
82
- ?>
83
- <div class="notice notice-info is-dismissible astra-sites-getting-started-notice">
84
- <?php /* translators: %1$s is the admin page URL, %2$s is product name. */ ?>
85
- <p><?php printf( __( 'Thank you for choosing %1$s! Check the library of <a class="astra-sites-getting-started-btn" href="%2$s">ready starter sites here »</a>', 'astra-sites' ), $product_name, admin_url( 'themes.php?page=astra-sites' ) ); ?></p>
86
- </div>
87
- <?php
88
- }
89
-
90
- /**
91
- * Save Page Builder
92
- *
93
- * @return void
94
- */
95
- function save_page_builder() {
96
-
97
- // Only admins can save settings.
98
- if ( ! current_user_can( 'manage_options' ) ) {
99
- return;
100
- }
101
-
102
- // Make sure we have a valid nonce.
103
- if ( isset( $_REQUEST['astra-sites-page-builder'] ) && wp_verify_nonce( $_REQUEST['astra-sites-page-builder'], 'astra-sites-welcome-screen' ) ) {
104
-
105
- // Stored Settings.
106
- $stored_data = $this->get_settings();
107
-
108
- // New settings.
109
- $new_data = array(
110
- 'page_builder' => ( isset( $_REQUEST['page_builder'] ) ) ? sanitize_key( $_REQUEST['page_builder'] ) : '',
111
- );
112
-
113
- // Merge settings.
114
- $data = wp_parse_args( $new_data, $stored_data );
115
-
116
- // Update settings.
117
- update_option( 'astra_sites_settings', $data );
118
-
119
- wp_redirect( admin_url( '/themes.php?page=astra-sites' ) );
120
- }
121
- }
122
-
123
- /**
124
- * Get single setting value
125
- *
126
- * @param string $key Setting key.
127
- * @param mixed $defaults Setting value.
128
- * @return mixed Stored setting value.
129
- */
130
- function get_setting( $key = '', $defaults = '' ) {
131
-
132
- $settings = $this->get_settings();
133
-
134
- if ( empty( $settings ) ) {
135
- return $defaults;
136
- }
137
-
138
- if ( array_key_exists( $key, $settings ) ) {
139
- return $settings[ $key ];
140
- }
141
-
142
- return $defaults;
143
- }
144
-
145
- /**
146
- * Get Settings
147
- *
148
- * @return array Stored settings.
149
- */
150
- function get_settings() {
151
-
152
- $defaults = array(
153
- 'page_builder' => '',
154
- );
155
-
156
- $stored_data = get_option( 'astra_sites_settings', $defaults );
157
-
158
- return wp_parse_args( $stored_data, $defaults );
159
- }
160
-
161
- /**
162
- * Admin settings init
163
- */
164
- public function init_admin_settings() {
165
- add_action( 'admin_menu', array( $this, 'add_admin_menu' ), 100 );
166
- add_action( 'admin_notices', array( $this, 'notices' ) );
167
- add_action( 'astra_sites_menu_general_action', array( $this, 'general_page' ) );
168
- }
169
-
170
- /**
171
- * Admin notice
172
- *
173
- * @since 1.2.8
174
- */
175
- public function notices() {
176
-
177
- if ( 'appearance_page_astra-sites' !== get_current_screen()->id ) {
178
- return;
179
- }
180
-
181
- if ( ! class_exists( 'XMLReader' ) ) {
182
- ?>
183
- <div class="notice astra-sites-xml-notice notice-error">
184
- <p><b><?php _e( 'Required XMLReader PHP extension is missing on your server!', 'astra-sites' ); ?></b></p>
185
- <?php /* translators: %s is the white label name. */ ?>
186
- <p><?php printf( __( '%s import requires XMLReader extension to be installed. Please contact your web hosting provider and ask them to install and activate the XMLReader PHP extension.', 'astra-sites' ), ASTRA_SITES_NAME ); ?></p>
187
- </div>
188
- <?php
189
- }
190
- }
191
-
192
- /**
193
- * Init Nav Menu
194
- *
195
- * @param mixed $action Action name.
196
- * @since 1.0.6
197
- */
198
- public function init_nav_menu( $action = '' ) {
199
-
200
- if ( '' !== $action ) {
201
- $this->render_tab_menu( $action );
202
- }
203
- }
204
-
205
- /**
206
- * Render tab menu
207
- *
208
- * @param mixed $action Action name.
209
- * @since 1.0.6
210
- */
211
- public function render_tab_menu( $action = '' ) {
212
- ?>
213
- <div id="astra-sites-menu-page">
214
- <?php $this->render( $action ); ?>
215
- </div>
216
- <?php
217
- }
218
-
219
- /**
220
- * View actions
221
- *
222
- * @since 1.0.11
223
- */
224
- public function get_view_actions() {
225
-
226
- if ( empty( $this->view_actions ) ) {
227
-
228
- $this->view_actions = apply_filters(
229
- 'astra_sites_menu_item',
230
- array()
231
- );
232
- }
233
-
234
- return $this->view_actions;
235
- }
236
-
237
- /**
238
- * Prints HTML content for tabs
239
- *
240
- * @param mixed $action Action name.
241
- * @since 1.0.6
242
- */
243
- public function render( $action ) {
244
-
245
- // Settings update message.
246
- if ( isset( $_REQUEST['message'] ) && ( 'saved' === $_REQUEST['message'] || 'saved_ext' === $_REQUEST['message'] ) ) {
247
- ?>
248
- <span id="message" class="notice notice-success is-dismissive"><p> <?php esc_html_e( 'Settings saved successfully.', 'astra-sites' ); ?> </p></span>
249
- <?php
250
- }
251
-
252
- $default_page_builder = $this->get_setting( 'page_builder' );
253
-
254
- if ( empty( $default_page_builder ) || isset( $_GET['change-page-builder'] ) ) {
255
-
256
- $plugins = get_option( 'active_plugins', array() );
257
- $page_builders = array();
258
- if ( $plugins ) {
259
- foreach ( $plugins as $key => $plugin_init ) {
260
- if ( false !== strpos( $plugin_init, 'elementor' ) ) {
261
- $page_builders[] = 'elementor';
262
- }
263
- if ( false !== strpos( $plugin_init, 'beaver-builder' ) ) {
264
- $page_builders[] = 'beaver-builder';
265
- }
266
- if ( false !== strpos( $plugin_init, 'brizy' ) ) {
267
- $page_builders[] = 'brizy';
268
- }
269
- }
270
- }
271
- $page_builders = array_unique( $page_builders );
272
- $page_builders[] = 'gutenberg';
273
- $page_builders = implode( ',', $page_builders );
274
- ?>
275
- <div class="astra-sites-welcome" data-plugins="<?php echo esc_attr( $page_builders ); ?>">
276
- <div class="inner">
277
- <form id="astra-sites-welcome-form" enctype="multipart/form-data" method="post">
278
- <h1><?php _e( 'Select Page Builder', 'astra-sites' ); ?></h1>
279
- <p><?php _e( 'Astra offers starter sites that can be imported in one click. These templates are available in few different page builders. Please choose your preferred page builder from the list below.', 'astra-sites' ); ?></p>
280
- <div class="fields">
281
- <ul class="page-builders">
282
- <li>
283
- <label>
284
- <input type="radio" name="page_builder" value="gutenberg">
285
- <img src="<?php echo esc_url( ASTRA_SITES_URI . 'inc/assets/images/gutenberg.jpg' ); ?>" />
286
- <div class="title"><?php _e( 'Gutenberg', 'astra-sites' ); ?></div>
287
- </label>
288
- </li>
289
- <li>
290
- <label>
291
- <input type="radio" name="page_builder" value="elementor">
292
- <img src="<?php echo esc_url( ASTRA_SITES_URI . 'inc/assets/images/elementor.jpg' ); ?>" />
293
- <div class="title"><?php _e( 'Elementor', 'astra-sites' ); ?></div>
294
- </label>
295
- </li>
296
- <li>
297
- <label>
298
- <input type="radio" name="page_builder" value="beaver-builder">
299
- <img src="<?php echo esc_url( ASTRA_SITES_URI . 'inc/assets/images/beaver-builder.png' ); ?>" />
300
- <div class="title"><?php _e( 'Beaver Builder', 'astra-sites' ); ?></div>
301
- </li>
302
- <li>
303
- <label>
304
- <input type="radio" name="page_builder" value="brizy">
305
- <img src="<?php echo esc_url( ASTRA_SITES_URI . 'inc/assets/images/brizy.jpg' ); ?>" />
306
- <div class="title"><?php _e( 'Brizy', 'astra-sites' ); ?></div>
307
- </label>
308
- </li>
309
- </ul>
310
- <div class="astra-sites-page-builder-notice" style="display: none;">
311
- <p class="description"><?php _e( 'Please select your favorite page builder to continue..', 'astra-sites' ); ?></p>
312
- </div>
313
- <?php submit_button( __( 'Next', 'astra-sites' ), 'primary button-hero disabled' ); ?>
314
- </div>
315
-
316
- <input type="hidden" name="message" value="saved" />
317
- <?php wp_nonce_field( 'astra-sites-welcome-screen', 'astra-sites-page-builder' ); ?>
318
- </form>
319
- </div>
320
- </div>
321
- <?php } else { ?>
322
- <?php
323
- $page_title = apply_filters( 'astra_sites_page_title', __( 'Astra Starter Sites - Your Library of 100+ Ready Templates!', 'astra-sites' ) );
324
- ?>
325
- <div class="nav-tab-wrapper">
326
- <h1 class='astra-sites-title'> <?php echo esc_html( $page_title ); ?> </h1>
327
- <form id="astra-sites-welcome-form-inline" enctype="multipart/form-data" method="post">
328
- <div class="fields">
329
- <select name="page_builder" required="required">
330
- <option value="gutenberg" <?php selected( $default_page_builder, 'gutenberg' ); ?>><?php _e( 'Block Editor (Gutenberg)', 'astra-sites' ); ?></option>
331
- <option value="elementor" <?php selected( $default_page_builder, 'elementor' ); ?>><?php _e( 'Elementor', 'astra-sites' ); ?></option>
332
- <option value="beaver-builder" <?php selected( $default_page_builder, 'beaver-builder' ); ?>><?php _e( 'Beaver Builder', 'astra-sites' ); ?></option>
333
- <option value="brizy" <?php selected( $default_page_builder, 'brizy' ); ?>><?php _e( 'Brizy', 'astra-sites' ); ?></option>
334
- </select>
335
- </div>
336
- <input type="hidden" name="message" value="saved" />
337
- <?php wp_nonce_field( 'astra-sites-welcome-screen', 'astra-sites-page-builder' ); ?>
338
- </form>
339
- <?php
340
- $view_actions = $this->get_view_actions();
341
-
342
- foreach ( $view_actions as $slug => $data ) {
343
-
344
- if ( ! $data['show'] ) {
345
- continue;
346
- }
347
-
348
- $url = $this->get_page_url( $slug );
349
-
350
- if ( 'general' === $slug ) {
351
- update_option( 'astra_parent_page_url', $url );
352
- }
353
-
354
- $active = ( $slug === $action ) ? 'nav-tab-active' : '';
355
- ?>
356
- <a class='nav-tab <?php echo esc_attr( $active ); ?>' href='<?php echo esc_url( $url ); ?>'> <?php echo esc_html( $data['label'] ); ?> </a>
357
- <?php } ?>
358
- </div><!-- .nav-tab-wrapper -->
359
- <?php
360
- }
361
- }
362
-
363
- /**
364
- * Get and return page URL
365
- *
366
- * @param string $menu_slug Menu name.
367
- * @since 1.0.6
368
- * @return string page url
369
- */
370
- public function get_page_url( $menu_slug ) {
371
-
372
- $parent_page = 'themes.php';
373
-
374
- if ( strpos( $parent_page, '?' ) !== false ) {
375
- $query_var = '&page=astra-sites';
376
- } else {
377
- $query_var = '?page=astra-sites';
378
- }
379
-
380
- $parent_page_url = admin_url( $parent_page . $query_var );
381
-
382
- $url = $parent_page_url . '&action=' . $menu_slug;
383
-
384
- return esc_url( $url );
385
- }
386
-
387
- /**
388
- * Add main menu
389
- *
390
- * @since 1.0.6
391
- */
392
- public function add_admin_menu() {
393
- $page_title = apply_filters( 'astra_sites_menu_page_title', __( 'Astra Starter Sites', 'astra-sites' ) );
394
-
395
- $page = add_theme_page( $page_title, $page_title, 'manage_options', 'astra-sites', array( $this, 'menu_callback' ) );
396
- }
397
-
398
- /**
399
- * Menu callback
400
- *
401
- * @since 1.0.6
402
- */
403
- public function menu_callback() {
404
-
405
- $current_slug = isset( $_GET['action'] ) ? esc_attr( $_GET['action'] ) : 'general';
406
-
407
- $active_tab = str_replace( '_', '-', $current_slug );
408
- $current_slug = str_replace( '-', '_', $current_slug );
409
-
410
- ?>
411
- <div class="astra-sites-menu-page-wrapper">
412
- <?php $this->init_nav_menu( $active_tab ); ?>
413
- <?php do_action( 'astra_sites_menu_' . esc_attr( $current_slug ) . '_action' ); ?>
414
- </div>
415
- <?php
416
- }
417
-
418
- /**
419
- * Include general page
420
- *
421
- * @since 1.0.6
422
- */
423
- public function general_page() {
424
- $default_page_builder = $this->get_setting( 'page_builder' );
425
- if ( empty( $default_page_builder ) || isset( $_GET['change-page-builder'] ) ) {
426
- return;
427
- }
428
- require_once ASTRA_SITES_DIR . 'inc/includes/admin-page.php';
429
- }
430
- }
431
-
432
- Astra_Sites_Page::get_instance();
433
-
434
- }// End if.
1
+ <?php
2
+ /**
3
+ * Astra Sites Page
4
+ *
5
+ * @since 1.0.6
6
+ * @package Astra Sites
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ if ( ! class_exists( 'Astra_Sites_Page' ) ) {
14
+
15
+ /**
16
+ * Astra Admin Settings
17
+ */
18
+ class Astra_Sites_Page {
19
+
20
+ /**
21
+ * View all actions
22
+ *
23
+ * @since 1.0.6
24
+ * @var array $view_actions
25
+ */
26
+ public $view_actions = array();
27
+
28
+ /**
29
+ * Member Variable
30
+ *
31
+ * @var instance
32
+ */
33
+ private static $instance;
34
+
35
+ /**
36
+ * Initiator
37
+ *
38
+ * @since 1.3.0
39
+ */
40
+ public static function get_instance() {
41
+ if ( ! isset( self::$instance ) ) {
42
+ self::$instance = new self;
43
+ }
44
+ return self::$instance;
45
+ }
46
+
47
+ /**
48
+ * Constructor
49
+ *
50
+ * @since 1.3.0
51
+ */
52
+ public function __construct() {
53
+
54
+ if ( ! is_admin() ) {
55
+ return;
56
+ }
57
+
58
+ add_action( 'after_setup_theme', array( $this, 'init_admin_settings' ), 99 );
59
+ add_action( 'admin_init', array( $this, 'save_page_builder' ) );
60
+ add_action( 'admin_notices', array( $this, 'getting_started' ) );
61
+ }
62
+
63
+ /**
64
+ * Admin notice
65
+ *
66
+ * @since 1.3.5
67
+ *
68
+ * @return void
69
+ */
70
+ function getting_started() {
71
+ if ( 'plugins' !== get_current_screen()->base ) {
72
+ return;
73
+ }
74
+
75
+ $processed = get_user_meta( get_current_user_id(), '_astra_sites_gettings_started', true );
76
+ $product_name = Astra_Sites_White_Label::get_instance()->page_title( 'Astra' );
77
+
78
+ if ( $processed ) {
79
+ return;
80
+ }
81
+
82
+ ?>
83
+ <div class="notice notice-info is-dismissible astra-sites-getting-started-notice">
84
+ <?php /* translators: %1$s is the admin page URL, %2$s is product name. */ ?>
85
+ <p><?php printf( __( 'Thank you for choosing %1$s! Check the library of <a class="astra-sites-getting-started-btn" href="%2$s">ready starter sites here »</a>', 'astra-sites' ), $product_name, admin_url( 'themes.php?page=astra-sites' ) ); ?></p>
86
+ </div>
87
+ <?php
88
+ }
89
+
90
+ /**
91
+ * Save Page Builder
92
+ *
93
+ * @return void
94
+ */
95
+ function save_page_builder() {
96
+
97
+ // Only admins can save settings.
98
+ if ( ! current_user_can( 'manage_options' ) ) {
99
+ return;
100
+ }
101
+
102
+ // Make sure we have a valid nonce.
103
+ if ( isset( $_REQUEST['astra-sites-page-builder'] ) && wp_verify_nonce( $_REQUEST['astra-sites-page-builder'], 'astra-sites-welcome-screen' ) ) {
104
+
105
+ // Stored Settings.
106
+ $stored_data = $this->get_settings();
107
+
108
+ // New settings.
109
+ $new_data = array(
110
+ 'page_builder' => ( isset( $_REQUEST['page_builder'] ) ) ? sanitize_key( $_REQUEST['page_builder'] ) : '',
111
+ );
112
+
113
+ // Merge settings.
114
+ $data = wp_parse_args( $new_data, $stored_data );
115
+
116
+ // Update settings.
117
+ update_option( 'astra_sites_settings', $data );
118
+
119
+ wp_redirect( admin_url( '/themes.php?page=astra-sites' ) );
120
+ }
121
+ }
122
+
123
+ /**
124
+ * Get single setting value
125
+ *
126
+ * @param string $key Setting key.
127
+ * @param mixed $defaults Setting value.
128
+ * @return mixed Stored setting value.
129
+ */
130
+ function get_setting( $key = '', $defaults = '' ) {
131
+
132
+ $settings = $this->get_settings();
133
+
134
+ if ( empty( $settings ) ) {
135
+ return $defaults;
136
+ }
137
+
138
+ if ( array_key_exists( $key, $settings ) ) {
139
+ return $settings[ $key ];
140
+ }
141
+
142
+ return $defaults;
143
+ }
144
+
145
+ /**
146
+ * Get Settings
147
+ *
148
+ * @return array Stored settings.
149
+ */
150
+ function get_settings() {
151
+
152
+ $defaults = array(
153
+ 'page_builder' => '',
154
+ );
155
+
156
+ $stored_data = get_option( 'astra_sites_settings', $defaults );
157
+
158
+ return wp_parse_args( $stored_data, $defaults );
159
+ }
160
+
161
+ /**
162
+ * Admin settings init
163
+ */
164
+ public function init_admin_settings() {
165
+ add_action( 'admin_menu', array( $this, 'add_admin_menu' ), 100 );
166
+ add_action( 'admin_notices', array( $this, 'notices' ) );
167
+ add_action( 'astra_sites_menu_general_action', array( $this, 'general_page' ) );
168
+ }
169
+
170
+ /**
171
+ * Admin notice
172
+ *
173
+ * @since 1.2.8
174
+ */
175
+ public function notices() {
176
+
177
+ if ( 'appearance_page_astra-sites' !== get_current_screen()->id ) {
178
+ return;
179
+ }
180
+
181
+ if ( ! class_exists( 'XMLReader' ) ) {
182
+ ?>
183
+ <div class="notice astra-sites-xml-notice notice-error">
184
+ <p><b><?php _e( 'Required XMLReader PHP extension is missing on your server!', 'astra-sites' ); ?></b></p>
185
+ <?php /* translators: %s is the white label name. */ ?>
186
+ <p><?php printf( __( '%s import requires XMLReader extension to be installed. Please contact your web hosting provider and ask them to install and activate the XMLReader PHP extension.', 'astra-sites' ), ASTRA_SITES_NAME ); ?></p>
187
+ </div>
188
+ <?php
189
+ }
190
+ }
191
+
192
+ /**
193
+ * Init Nav Menu
194
+ *
195
+ * @param mixed $action Action name.
196
+ * @since 1.0.6
197
+ */
198
+ public function init_nav_menu( $action = '' ) {
199
+
200
+ if ( '' !== $action ) {
201
+ $this->render_tab_menu( $action );
202
+ }
203
+ }
204
+
205
+ /**
206
+ * Render tab menu
207
+ *
208
+ * @param mixed $action Action name.
209
+ * @since 1.0.6
210
+ */
211
+ public function render_tab_menu( $action = '' ) {
212
+ ?>
213
+ <div id="astra-sites-menu-page">
214
+ <?php $this->render( $action ); ?>
215
+ </div>
216
+ <?php
217
+ }
218
+
219
+ /**
220
+ * View actions
221
+ *
222
+ * @since 1.0.11
223
+ */
224
+ public function get_view_actions() {
225
+
226
+ if ( empty( $this->view_actions ) ) {
227
+
228
+ $this->view_actions = apply_filters(
229
+ 'astra_sites_menu_item',
230
+ array()
231
+ );
232
+ }
233
+
234
+ return $this->view_actions;
235
+ }
236
+
237
+ /**
238
+ * Prints HTML content for tabs
239
+ *
240
+ * @param mixed $action Action name.
241
+ * @since 1.0.6
242
+ */
243
+ public function render( $action ) {
244
+
245
+ // Settings update message.
246
+ if ( isset( $_REQUEST['message'] ) && ( 'saved' === $_REQUEST['message'] || 'saved_ext' === $_REQUEST['message'] ) ) {
247
+ ?>
248
+ <span id="message" class="notice notice-success is-dismissive"><p> <?php esc_html_e( 'Settings saved successfully.', 'astra-sites' ); ?> </p></span>
249
+ <?php
250
+ }
251
+
252
+ $default_page_builder = $this->get_setting( 'page_builder' );
253
+
254
+ if ( empty( $default_page_builder ) || isset( $_GET['change-page-builder'] ) ) {
255
+
256
+ $plugins = get_option( 'active_plugins', array() );
257
+ $page_builders = array();
258
+ if ( $plugins ) {
259
+ foreach ( $plugins as $key => $plugin_init ) {
260
+ if ( false !== strpos( $plugin_init, 'elementor' ) ) {
261
+ $page_builders[] = 'elementor';
262
+ }
263
+ if ( false !== strpos( $plugin_init, 'beaver-builder' ) ) {
264
+ $page_builders[] = 'beaver-builder';
265
+ }
266
+ if ( false !== strpos( $plugin_init, 'brizy' ) ) {
267
+ $page_builders[] = 'brizy';
268
+ }
269
+ }
270
+ }
271
+ $page_builders = array_unique( $page_builders );
272
+ $page_builders[] = 'gutenberg';
273
+ $page_builders = implode( ',', $page_builders );
274
+ ?>
275
+ <div class="astra-sites-welcome" data-plugins="<?php echo esc_attr( $page_builders ); ?>">
276
+ <div class="inner">
277
+ <form id="astra-sites-welcome-form" enctype="multipart/form-data" method="post">
278
+ <h1><?php _e( 'Select Page Builder', 'astra-sites' ); ?></h1>
279
+ <p><?php _e( 'Astra offers starter sites that can be imported in one click. These templates are available in few different page builders. Please choose your preferred page builder from the list below.', 'astra-sites' ); ?></p>
280
+ <div class="fields">
281
+ <ul class="page-builders">
282
+ <li>
283
+ <label>
284
+ <input type="radio" name="page_builder" value="gutenberg">
285
+ <img src="<?php echo esc_url( ASTRA_SITES_URI . 'inc/assets/images/gutenberg.jpg' ); ?>" />
286
+ <div class="title"><?php _e( 'Gutenberg', 'astra-sites' ); ?></div>
287
+ </label>
288
+ </li>
289
+ <li>
290
+ <label>
291
+ <input type="radio" name="page_builder" value="elementor">
292
+ <img src="<?php echo esc_url( ASTRA_SITES_URI . 'inc/assets/images/elementor.jpg' ); ?>" />
293
+ <div class="title"><?php _e( 'Elementor', 'astra-sites' ); ?></div>
294
+ </label>
295
+ </li>
296
+ <li>
297
+ <label>
298
+ <input type="radio" name="page_builder" value="beaver-builder">
299
+ <img src="<?php echo esc_url( ASTRA_SITES_URI . 'inc/assets/images/beaver-builder.png' ); ?>" />
300
+ <div class="title"><?php _e( 'Beaver Builder', 'astra-sites' ); ?></div>
301
+ </li>
302
+ <li>
303
+ <label>
304
+ <input type="radio" name="page_builder" value="brizy">
305
+ <img src="<?php echo esc_url( ASTRA_SITES_URI . 'inc/assets/images/brizy.jpg' ); ?>" />
306
+ <div class="title"><?php _e( 'Brizy', 'astra-sites' ); ?></div>
307
+ </label>
308
+ </li>
309
+ </ul>
310
+ <div class="astra-sites-page-builder-notice" style="display: none;">
311
+ <p class="description"><?php _e( 'Please select your favorite page builder to continue..', 'astra-sites' ); ?></p>
312
+ </div>
313
+ <?php submit_button( __( 'Next', 'astra-sites' ), 'primary button-hero disabled' ); ?>
314
+ </div>
315
+
316
+ <input type="hidden" name="message" value="saved" />
317
+ <?php wp_nonce_field( 'astra-sites-welcome-screen', 'astra-sites-page-builder' ); ?>
318
+ </form>
319
+ </div>
320
+ </div>
321
+ <?php } else { ?>
322
+ <?php
323
+ $page_title = apply_filters( 'astra_sites_page_title', __( 'Astra Starter Sites - Your Library of 100+ Ready Templates!', 'astra-sites' ) );
324
+ ?>
325
+ <div class="nav-tab-wrapper">
326
+ <h1 class='astra-sites-title'> <?php echo esc_html( $page_title ); ?> </h1>
327
+ <form id="astra-sites-welcome-form-inline" enctype="multipart/form-data" method="post">
328
+ <div class="fields">
329
+ <select name="page_builder" required="required">
330
+ <option value="gutenberg" <?php selected( $default_page_builder, 'gutenberg' ); ?>><?php _e( 'Block Editor (Gutenberg)', 'astra-sites' ); ?></option>
331
+ <option value="elementor" <?php selected( $default_page_builder, 'elementor' ); ?>><?php _e( 'Elementor', 'astra-sites' ); ?></option>
332
+ <option value="beaver-builder" <?php selected( $default_page_builder, 'beaver-builder' ); ?>><?php _e( 'Beaver Builder', 'astra-sites' ); ?></option>
333
+ <option value="brizy" <?php selected( $default_page_builder, 'brizy' ); ?>><?php _e( 'Brizy', 'astra-sites' ); ?></option>
334
+ </select>
335
+ </div>
336
+ <input type="hidden" name="message" value="saved" />
337
+ <?php wp_nonce_field( 'astra-sites-welcome-screen', 'astra-sites-page-builder' ); ?>
338
+ </form>
339
+ <?php
340
+ $view_actions = $this->get_view_actions();
341
+
342
+ foreach ( $view_actions as $slug => $data ) {
343
+
344
+ if ( ! $data['show'] ) {
345
+ continue;
346
+ }
347
+
348
+ $url = $this->get_page_url( $slug );
349
+
350
+ if ( 'general' === $slug ) {
351
+ update_option( 'astra_parent_page_url', $url );
352
+ }
353
+
354
+ $active = ( $slug === $action ) ? 'nav-tab-active' : '';
355
+ ?>
356
+ <a class='nav-tab <?php echo esc_attr( $active ); ?>' href='<?php echo esc_url( $url ); ?>'> <?php echo esc_html( $data['label'] ); ?> </a>
357
+ <?php } ?>
358
+ </div><!-- .nav-tab-wrapper -->
359
+ <?php
360
+ }
361
+ }
362
+
363
+ /**
364
+ * Get and return page URL
365
+ *
366
+ * @param string $menu_slug Menu name.
367
+ * @since 1.0.6
368
+ * @return string page url
369
+ */
370
+ public function get_page_url( $menu_slug ) {
371
+
372
+ $parent_page = 'themes.php';
373
+
374
+ if ( strpos( $parent_page, '?' ) !== false ) {
375
+ $query_var = '&page=astra-sites';
376
+ } else {
377
+ $query_var = '?page=astra-sites';
378
+ }
379
+
380
+ $parent_page_url = admin_url( $parent_page . $query_var );
381
+
382
+ $url = $parent_page_url . '&action=' . $menu_slug;
383
+
384
+ return esc_url( $url );
385
+ }
386
+
387
+ /**
388
+ * Add main menu
389
+ *
390
+ * @since 1.0.6
391
+ */
392
+ public function add_admin_menu() {
393
+ $page_title = apply_filters( 'astra_sites_menu_page_title', __( 'Astra Starter Sites', 'astra-sites' ) );
394
+
395
+ $page = add_theme_page( $page_title, $page_title, 'manage_options', 'astra-sites', array( $this, 'menu_callback' ) );
396
+ }
397
+
398
+ /**
399
+ * Menu callback
400
+ *
401
+ * @since 1.0.6
402
+ */
403
+ public function menu_callback() {
404
+
405
+ $current_slug = isset( $_GET['action'] ) ? esc_attr( $_GET['action'] ) : 'general';
406
+
407
+ $active_tab = str_replace( '_', '-', $current_slug );
408
+ $current_slug = str_replace( '-', '_', $current_slug );
409
+
410
+ ?>
411
+ <div class="astra-sites-menu-page-wrapper">
412
+ <?php $this->init_nav_menu( $active_tab ); ?>
413
+ <?php do_action( 'astra_sites_menu_' . esc_attr( $current_slug ) . '_action' ); ?>
414
+ </div>
415
+ <?php
416
+ }
417
+
418
+ /**
419
+ * Include general page
420
+ *
421
+ * @since 1.0.6
422
+ */
423
+ public function general_page() {
424
+ $default_page_builder = $this->get_setting( 'page_builder' );
425
+ if ( empty( $default_page_builder ) || isset( $_GET['change-page-builder'] ) ) {
426
+ return;
427
+ }
428
+ require_once ASTRA_SITES_DIR . 'inc/includes/admin-page.php';
429
+ }
430
+ }
431
+
432
+ Astra_Sites_Page::get_instance();
433
+
434
+ }// End if.
inc/classes/class-astra-sites-white-label.php CHANGED
@@ -1,239 +1,239 @@
1
- <?php
2
- /**
3
- * Astra Sites White Label
4
- *
5
- * @package Astra Sites
6
- * @since 1.0.12
7
- */
8
-
9
- if ( ! class_exists( 'Astra_Sites_White_Label' ) ) :
10
-
11
- /**
12
- * Astra_Sites_White_Label
13
- *
14
- * @since 1.0.12
15
- */
16
- class Astra_Sites_White_Label {
17
-
18
- /**
19
- * Instance
20
- *
21
- * @since 1.0.12
22
- *
23
- * @var object Class Object.
24
- * @access private
25
- */
26
- private static $instance;
27
-
28
- /**
29
- * Member Variable
30
- *
31
- * @since 1.0.12
32
- *
33
- * @var array branding
34
- * @access private
35
- */
36
- private static $branding;
37
-
38
- /**
39
- * Settings
40
- *
41
- * @since 1.2.11
42
- *
43
- * @var array settings
44
- *
45
- * @access private
46
- */
47
- private $settings;
48
-
49
- /**
50
- * Initiator
51
- *
52
- * @since 1.0.12
53
- *
54
- * @return object initialized object of class.
55
- */
56
- public static function get_instance() {
57
- if ( ! isset( self::$instance ) ) {
58
- self::$instance = new self;
59
- }
60
- return self::$instance;
61
- }
62
-
63
- /**
64
- * Constructor
65
- *
66
- * @since 1.0.12
67
- */
68
- public function __construct() {
69
- add_filter( 'all_plugins', array( $this, 'plugins_page' ) );
70
- add_filter( 'astra_addon_branding_options', __CLASS__ . '::settings' );
71
- add_action( 'astra_pro_white_label_add_form', __CLASS__ . '::add_white_lavel_form' );
72
- add_filter( 'astra_sites_menu_page_title', array( $this, 'page_title' ) );
73
- add_filter( 'astra_sites_page_title', array( $this, 'page_title' ) );
74
-
75
- // Display the link with the plugin meta.
76
- if ( is_admin() ) {
77
- add_filter( 'plugin_row_meta', array( $this, 'plugin_links' ), 10, 4 );
78
- }
79
- }
80
-
81
- /**
82
- * White labels the plugins page.
83
- *
84
- * @since 1.0.12
85
- *
86
- * @param array $plugins Plugins Array.
87
- * @return array
88
- */
89
- function plugins_page( $plugins ) {
90
-
91
- if ( ! is_callable( 'Astra_Ext_White_Label_Markup::get_whitelabel_string' ) ) {
92
- return $plugins;
93
- }
94
-
95
- if ( ! isset( $plugins[ ASTRA_SITES_BASE ] ) ) {
96
- return $plugins;
97
- }
98
-
99
- // Set White Labels.
100
- $name = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'name' );
101
- $description = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'description' );
102
- $author = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-agency', 'author' );
103
- $author_uri = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-agency', 'author_url' );
104
-
105
- if ( ! empty( $name ) ) {
106
- $plugins[ ASTRA_SITES_BASE ]['Name'] = $name;
107
-
108
- // Remove Plugin URI if Agency White Label name is set.
109
- $plugins[ ASTRA_SITES_BASE ]['PluginURI'] = '';
110
- }
111
-
112
- if ( ! empty( $description ) ) {
113
- $plugins[ ASTRA_SITES_BASE ]['Description'] = $description;
114
- }
115
-
116
- if ( ! empty( $author ) ) {
117
- $plugins[ ASTRA_SITES_BASE ]['Author'] = $author;
118
- }
119
-
120
- if ( ! empty( $author_uri ) ) {
121
- $plugins[ ASTRA_SITES_BASE ]['AuthorURI'] = $author_uri;
122
- }
123
-
124
- return $plugins;
125
- }
126
-
127
- /**
128
- * Remove a "view details" link from the plugin list table
129
- *
130
- * @since 1.0.12
131
- *
132
- * @param array $plugin_meta List of links.
133
- * @param string $plugin_file Relative path to the main plugin file from the plugins directory.
134
- * @param array $plugin_data Data from the plugin headers.
135
- * @return array
136
- */
137
- public function plugin_links( $plugin_meta, $plugin_file, $plugin_data ) {
138
-
139
- if ( ! is_callable( 'Astra_Ext_White_Label_Markup::get_whitelabel_string' ) ) {
140
- return $plugin_meta;
141
- }
142
-
143
- // Set White Labels.
144
- if ( ASTRA_SITES_BASE === $plugin_file ) {
145
-
146
- $name = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'name' );
147
- $description = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'description' );
148
-
149
- // Remove Plugin URI if Agency White Label name is set.
150
- if ( ! empty( $name ) ) {
151
- unset( $plugin_meta[2] );
152
- }
153
- }
154
-
155
- return $plugin_meta;
156
- }
157
-
158
- /**
159
- * Add White Label setting's
160
- *
161
- * @since 1.0.12
162
- *
163
- * @param array $settings White label setting.
164
- * @return array
165
- */
166
- public static function settings( $settings = array() ) {
167
-
168
- $settings['astra-sites'] = array(
169
- 'name' => '',
170
- 'description' => '',
171
- );
172
-
173
- return $settings;
174
- }
175
-
176
- /**
177
- * Add White Label form
178
- *
179
- * @since 1.0.12
180
- *
181
- * @param array $settings White label setting.
182
- * @return void
183
- */
184
- public static function add_white_lavel_form( $settings = array() ) {
185
-
186
- /* translators: %1$s product name */
187
- $plugin_name = sprintf( __( '%1$s Branding', 'astra-sites' ), ASTRA_SITES_NAME );
188
-
189
- require_once ASTRA_SITES_DIR . 'inc/includes/white-label.php';
190
- }
191
-
192
- /**
193
- * Page Title
194
- *
195
- * @since 1.0.12
196
- *
197
- * @param string $title Page Title.
198
- * @return string Filtered Page Title.
199
- */
200
- function page_title( $title = '' ) {
201
-
202
- if ( is_callable( 'Astra_Ext_White_Label_Markup::get_whitelabel_string' ) ) {
203
- $astra_sites_name = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'name' );
204
- if ( ! empty( $astra_sites_name ) ) {
205
- $title = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'name' );
206
- }
207
- }
208
-
209
- return $title;
210
- }
211
-
212
- /**
213
- * Is Astra sites White labeled
214
- *
215
- * @since 1.2.13
216
- *
217
- * @return string
218
- */
219
- function is_white_labeled() {
220
- if ( ! is_callable( 'Astra_Ext_White_Label_Markup::get_whitelabel_string' ) ) {
221
- return false;
222
- }
223
-
224
- $astra_sites_name = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'name' );
225
- if ( empty( $astra_sites_name ) ) {
226
- return false;
227
- }
228
-
229
- return true;
230
- }
231
-
232
- }
233
-
234
- /**
235
- * Kicking this off by calling 'get_instance()' method
236
- */
237
- Astra_Sites_White_Label::get_instance();
238
-
239
- endif;
1
+ <?php
2
+ /**
3
+ * Astra Sites White Label
4
+ *
5
+ * @package Astra Sites
6
+ * @since 1.0.12
7
+ */
8
+
9
+ if ( ! class_exists( 'Astra_Sites_White_Label' ) ) :
10
+
11
+ /**
12
+ * Astra_Sites_White_Label
13
+ *
14
+ * @since 1.0.12
15
+ */
16
+ class Astra_Sites_White_Label {
17
+
18
+ /**
19
+ * Instance
20
+ *
21
+ * @since 1.0.12
22
+ *
23
+ * @var object Class Object.
24
+ * @access private
25
+ */
26
+ private static $instance;
27
+
28
+ /**
29
+ * Member Variable
30
+ *
31
+ * @since 1.0.12
32
+ *
33
+ * @var array branding
34
+ * @access private
35
+ */
36
+ private static $branding;
37
+
38
+ /**
39
+ * Settings
40
+ *
41
+ * @since 1.2.11
42
+ *
43
+ * @var array settings
44
+ *
45
+ * @access private
46
+ */
47
+ private $settings;
48
+
49
+ /**
50
+ * Initiator
51
+ *
52
+ * @since 1.0.12
53
+ *
54
+ * @return object initialized object of class.
55
+ */
56
+ public static function get_instance() {
57
+ if ( ! isset( self::$instance ) ) {
58
+ self::$instance = new self;
59
+ }
60
+ return self::$instance;
61
+ }
62
+
63
+ /**
64
+ * Constructor
65
+ *
66
+ * @since 1.0.12
67
+ */
68
+ public function __construct() {
69
+ add_filter( 'all_plugins', array( $this, 'plugins_page' ) );
70
+ add_filter( 'astra_addon_branding_options', __CLASS__ . '::settings' );
71
+ add_action( 'astra_pro_white_label_add_form', __CLASS__ . '::add_white_lavel_form' );
72
+ add_filter( 'astra_sites_menu_page_title', array( $this, 'page_title' ) );
73
+ add_filter( 'astra_sites_page_title', array( $this, 'page_title' ) );
74
+
75
+ // Display the link with the plugin meta.
76
+ if ( is_admin() ) {
77
+ add_filter( 'plugin_row_meta', array( $this, 'plugin_links' ), 10, 4 );
78
+ }
79
+ }
80
+
81
+ /**
82
+ * White labels the plugins page.
83
+ *
84
+ * @since 1.0.12
85
+ *
86
+ * @param array $plugins Plugins Array.
87
+ * @return array
88
+ */
89
+ function plugins_page( $plugins ) {
90
+
91
+ if ( ! is_callable( 'Astra_Ext_White_Label_Markup::get_whitelabel_string' ) ) {
92
+ return $plugins;
93
+ }
94
+
95
+ if ( ! isset( $plugins[ ASTRA_SITES_BASE ] ) ) {
96
+ return $plugins;
97
+ }
98
+
99
+ // Set White Labels.
100
+ $name = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'name' );
101
+ $description = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'description' );
102
+ $author = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-agency', 'author' );
103
+ $author_uri = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-agency', 'author_url' );
104
+
105
+ if ( ! empty( $name ) ) {
106
+ $plugins[ ASTRA_SITES_BASE ]['Name'] = $name;
107
+
108
+ // Remove Plugin URI if Agency White Label name is set.
109
+ $plugins[ ASTRA_SITES_BASE ]['PluginURI'] = '';
110
+ }
111
+
112
+ if ( ! empty( $description ) ) {
113
+ $plugins[ ASTRA_SITES_BASE ]['Description'] = $description;
114
+ }
115
+
116
+ if ( ! empty( $author ) ) {
117
+ $plugins[ ASTRA_SITES_BASE ]['Author'] = $author;
118
+ }
119
+
120
+ if ( ! empty( $author_uri ) ) {
121
+ $plugins[ ASTRA_SITES_BASE ]['AuthorURI'] = $author_uri;
122
+ }
123
+
124
+ return $plugins;
125
+ }
126
+
127
+ /**
128
+ * Remove a "view details" link from the plugin list table
129
+ *
130
+ * @since 1.0.12
131
+ *
132
+ * @param array $plugin_meta List of links.
133
+ * @param string $plugin_file Relative path to the main plugin file from the plugins directory.
134
+ * @param array $plugin_data Data from the plugin headers.
135
+ * @return array
136
+ */
137
+ public function plugin_links( $plugin_meta, $plugin_file, $plugin_data ) {
138
+
139
+ if ( ! is_callable( 'Astra_Ext_White_Label_Markup::get_whitelabel_string' ) ) {
140
+ return $plugin_meta;
141
+ }
142
+
143
+ // Set White Labels.
144
+ if ( ASTRA_SITES_BASE === $plugin_file ) {
145
+
146
+ $name = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'name' );
147
+ $description = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'description' );
148
+
149
+ // Remove Plugin URI if Agency White Label name is set.
150
+ if ( ! empty( $name ) ) {
151
+ unset( $plugin_meta[2] );
152
+ }
153
+ }
154
+
155
+ return $plugin_meta;
156
+ }
157
+
158
+ /**
159
+ * Add White Label setting's
160
+ *
161
+ * @since 1.0.12
162
+ *
163
+ * @param array $settings White label setting.
164
+ * @return array
165
+ */
166
+ public static function settings( $settings = array() ) {
167
+
168
+ $settings['astra-sites'] = array(
169
+ 'name' => '',
170
+ 'description' => '',
171
+ );
172
+
173
+ return $settings;
174
+ }
175
+
176
+ /**
177
+ * Add White Label form
178
+ *
179
+ * @since 1.0.12
180
+ *
181
+ * @param array $settings White label setting.
182
+ * @return void
183
+ */
184
+ public static function add_white_lavel_form( $settings = array() ) {
185
+
186
+ /* translators: %1$s product name */
187
+ $plugin_name = sprintf( __( '%1$s Branding', 'astra-sites' ), ASTRA_SITES_NAME );
188
+
189
+ require_once ASTRA_SITES_DIR . 'inc/includes/white-label.php';
190
+ }
191
+
192
+ /**
193
+ * Page Title
194
+ *
195
+ * @since 1.0.12
196
+ *
197
+ * @param string $title Page Title.
198
+ * @return string Filtered Page Title.
199
+ */
200
+ function page_title( $title = '' ) {
201
+
202
+ if ( is_callable( 'Astra_Ext_White_Label_Markup::get_whitelabel_string' ) ) {
203
+ $astra_sites_name = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'name' );
204
+ if ( ! empty( $astra_sites_name ) ) {
205
+ $title = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'name' );
206
+ }
207
+ }
208
+
209
+ return $title;
210
+ }
211
+
212
+ /**
213
+ * Is Astra sites White labeled
214
+ *
215
+ * @since 1.2.13
216
+ *
217
+ * @return string
218
+ */
219
+ function is_white_labeled() {
220
+ if ( ! is_callable( 'Astra_Ext_White_Label_Markup::get_whitelabel_string' ) ) {
221
+ return false;
222
+ }
223
+
224
+ $astra_sites_name = Astra_Ext_White_Label_Markup::get_whitelabel_string( 'astra-sites', 'name' );
225
+ if ( empty( $astra_sites_name ) ) {
226
+ return false;
227
+ }
228
+
229
+ return true;
230
+ }
231
+
232
+ }
233
+
234
+ /**
235
+ * Kicking this off by calling 'get_instance()' method
236
+ */
237
+ Astra_Sites_White_Label::get_instance();
238
+
239
+ endif;
inc/classes/class-astra-sites.php CHANGED
@@ -359,7 +359,7 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
359
  'btnActivating' => __( 'Activating', 'astra-sites' ) . '&hellip;',
360
  'btnActive' => __( 'Active', 'astra-sites' ),
361
  'importFailBtn' => __( 'Import failed.', 'astra-sites' ),
362
- 'importFailBtnLarge' => __( 'Import failed. See error log.', 'astra-sites' ),
363
  'importDemo' => __( 'Import This Site', 'astra-sites' ),
364
  'importingDemo' => __( 'Importing..', 'astra-sites' ),
365
  'DescExpand' => __( 'Read more', 'astra-sites' ) . '&hellip;',
359
  'btnActivating' => __( 'Activating', 'astra-sites' ) . '&hellip;',
360
  'btnActive' => __( 'Active', 'astra-sites' ),
361
  'importFailBtn' => __( 'Import failed.', 'astra-sites' ),
362
+ 'importFailBtnLarge' => __( 'Import failed.', 'astra-sites' ),
363
  'importDemo' => __( 'Import This Site', 'astra-sites' ),
364
  'importingDemo' => __( 'Importing..', 'astra-sites' ),
365
  'DescExpand' => __( 'Read more', 'astra-sites' ) . '&hellip;',
inc/classes/compatibility/class-astra-sites-compatibility.php CHANGED
@@ -1,69 +1,69 @@
1
- <?php
2
- /**
3
- * Astra Sites Compatibility for 3rd party plugins.
4
- *
5
- * @package Astra Sites
6
- * @since 1.0.11
7
- */
8
-
9
- if ( ! class_exists( 'Astra_Sites_Compatibility' ) ) :
10
-
11
- /**
12
- * Astra Sites Compatibility
13
- *
14
- * @since 1.0.11
15
- */
16
- class Astra_Sites_Compatibility {
17
-
18
- /**
19
- * Instance
20
- *
21
- * @access private
22
- * @var object Class object.
23
- * @since 1.0.11
24
- */
25
- private static $instance;
26
-
27
- /**
28
- * Initiator
29
- *
30
- * @since 1.0.11
31
- * @return object initialized object of class.
32
- */
33
- public static function 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.11
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
- // Plugin - WooCommerce.
54
- require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/woocommerce/class-astra-sites-compatibility-woocommerce.php';
55
-
56
- // Plugin - LearnDash LMS.
57
- require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/sfwd-lms/class-astra-sites-compatibility-sfwd-lms.php';
58
- }
59
-
60
- }
61
-
62
- /**
63
- * Kicking this off by calling 'instance()' method
64
- */
65
- Astra_Sites_Compatibility::instance();
66
-
67
- endif;
68
-
69
-
1
+ <?php
2
+ /**
3
+ * Astra Sites Compatibility for 3rd party plugins.
4
+ *
5
+ * @package Astra Sites
6
+ * @since 1.0.11
7
+ */
8
+
9
+ if ( ! class_exists( 'Astra_Sites_Compatibility' ) ) :
10
+
11
+ /**
12
+ * Astra Sites Compatibility
13
+ *
14
+ * @since 1.0.11
15
+ */
16
+ class Astra_Sites_Compatibility {
17
+
18
+ /**
19
+ * Instance
20
+ *
21
+ * @access private
22
+ * @var object Class object.
23
+ * @since 1.0.11
24
+ */
25
+ private static $instance;
26
+
27
+ /**
28
+ * Initiator
29
+ *
30
+ * @since 1.0.11
31
+ * @return object initialized object of class.
32
+ */
33
+ public static function 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.11
44
+ */
45
+ public function __construct() {
46
+
47
+ // Plugin - Astra Pro.
48