Astra Starter Sites - Version 1.3.10

Version Description

Download this release

Release Info

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

Code changes from version 1.3.9 to 1.3.10

astra-sites.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /**
3
- * Plugin Name: Astra Starter Sites – Elementor, Beaver Builder & Gutenberg Templates
4
  * Plugin URI: http://www.wpastra.com/pro/
5
  * Description: Import free sites build with Astra theme.
6
- * Version: 1.3.9
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.9' );
23
  }
24
 
25
  if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
1
  <?php
2
  /**
3
+ * Plugin Name: Astra Starter Sites
4
  * Plugin URI: http://www.wpastra.com/pro/
5
  * Description: Import free sites build with Astra theme.
6
+ * Version: 1.3.10
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.10' );
23
  }
24
 
25
  if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
inc/assets/css/admin.css CHANGED
@@ -225,7 +225,9 @@
225
  margin-left: 0;
226
  width: auto;
227
  float: none;
 
228
  }
 
229
  .filters-wrap {
230
  display: inline-block;
231
  }
@@ -528,13 +530,19 @@ body.loading-content .select-page-builder {
528
  visibility: hidden;
529
  }
530
 
531
- .required-plugins-list {
 
 
 
 
 
532
  margin-left: 2em;
533
  margin-top: .5em;
534
  margin-bottom: .5em;
535
  list-style-type: disc;
536
  }
537
 
 
538
  .required-plugins-list .plugin-card {
539
  background: transparent;
540
  border: none;
225
  margin-left: 0;
226
  width: auto;
227
  float: none;
228
+ margin-right: 220px;
229
  }
230
+
231
  .filters-wrap {
232
  display: inline-block;
233
  }
530
  visibility: hidden;
531
  }
532
 
533
+ .astra-sites-third-party-required-plugins-wrap .notice {
534
+ margin: 0;
535
+ }
536
+
537
+ .required-plugins-list,
538
+ .astra-sites-third-party-required-plugins {
539
  margin-left: 2em;
540
  margin-top: .5em;
541
  margin-bottom: .5em;
542
  list-style-type: disc;
543
  }
544
 
545
+ .astra-sites-third-party-required-plugins .plugin-card,
546
  .required-plugins-list .plugin-card {
547
  background: transparent;
548
  border: none;
inc/assets/js/admin-page.js CHANGED
@@ -120,7 +120,6 @@ var AstraSitesAjaxQueue = (function() {
120
  var complete = 0;
121
  var total = 0;
122
 
123
-
124
  for (var i = types.length - 1; i >= 0; i--) {
125
  var type = types[i];
126
  this.updateProgress( type, this.complete[ type ], this.data.count[ type ] );
@@ -762,7 +761,7 @@ var AstraSitesAjaxQueue = (function() {
762
  evtSource.addEventListener( 'log', function ( message ) {
763
  var data = JSON.parse( message.data );
764
  var message = data.message || '';
765
- if( message ) {
766
  message = message.replace(/"/g, function(letter) {
767
  return '';
768
  });
@@ -983,7 +982,7 @@ var AstraSitesAjaxQueue = (function() {
983
  return;
984
  }
985
 
986
- AstraSitesAdmin._log_title( 'Installing Plugin..' );
987
 
988
  if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked ) {
989
  wp.updates.requestFilesystemCredentials( event );
@@ -999,7 +998,7 @@ var AstraSitesAjaxQueue = (function() {
999
  } );
1000
  }
1001
 
1002
- AstraSitesAdmin._log_title( 'Installing ' + AstraSitesAdmin.ucwords( $button.data( 'name' ) ) );
1003
 
1004
  wp.updates.installPlugin( {
1005
  slug: $button.data( 'slug' )
@@ -1036,6 +1035,7 @@ var AstraSitesAjaxQueue = (function() {
1036
 
1037
  // Transform the 'Install' button into an 'Activate' button.
1038
  var $init = $( '.plugin-card-' + response.slug ).data('init');
 
1039
 
1040
  // Reset not installed plugins list.
1041
  var pluginsList = astraSitesAdmin.requiredPlugins.notinstalled;
@@ -1044,7 +1044,7 @@ var AstraSitesAjaxQueue = (function() {
1044
  // WordPress adds "Activate" button after waiting for 1000ms. So we will run our activation after that.
1045
  setTimeout( function() {
1046
 
1047
- AstraSitesAdmin._log_title( 'Activating Plugin..' );
1048
 
1049
  $.ajax({
1050
  url: astraSitesAdmin.ajaxurl,
@@ -1059,10 +1059,10 @@ var AstraSitesAjaxQueue = (function() {
1059
  .done(function (result) {
1060
 
1061
  if( result.success ) {
1062
- AstraSitesAdmin._log_title( 'Activating Plugin ' + AstraSitesAdmin.ucwords(response.name) );
1063
-
1064
  var pluginsList = astraSitesAdmin.requiredPlugins.inactive;
1065
 
 
 
1066
  // Reset not installed plugins list.
1067
  astraSitesAdmin.requiredPlugins.inactive = AstraSitesAdmin._removePluginFromQueue( response.slug, pluginsList );
1068
 
@@ -1082,8 +1082,9 @@ var AstraSitesAjaxQueue = (function() {
1082
  _installError: function( event, response ) {
1083
 
1084
  var $card = $( '.plugin-card-' + response.slug );
 
1085
 
1086
- AstraSitesAdmin._log_title( response.errorMessage + ' ' + AstraSitesAdmin.ucwords(response.name) );
1087
 
1088
 
1089
  $card
@@ -1100,8 +1101,9 @@ var AstraSitesAjaxQueue = (function() {
1100
  event.preventDefault();
1101
 
1102
  var $card = $( '.plugin-card-' + args.slug );
 
1103
 
1104
- AstraSitesAdmin._log_title( 'Installing ' + AstraSitesAdmin.ucwords(args.name ));
1105
 
1106
  $card.addClass('updating-message');
1107
 
@@ -1123,7 +1125,7 @@ var AstraSitesAjaxQueue = (function() {
1123
  return;
1124
  }
1125
 
1126
- AstraSitesAdmin._log_title( 'Activating plugin ' + AstraSitesAdmin.ucwords( $name ) );
1127
 
1128
  $button.addClass('updating-message button-primary')
1129
  .html( astraSitesAdmin.strings.btnActivating );
@@ -1145,7 +1147,7 @@ var AstraSitesAjaxQueue = (function() {
1145
 
1146
  if( result.success ) {
1147
 
1148
- AstraSitesAdmin._log_title( 'Activated ' + AstraSitesAdmin.ucwords($name) );
1149
 
1150
  var pluginsList = astraSitesAdmin.requiredPlugins.inactive;
1151
 
@@ -1221,7 +1223,7 @@ var AstraSitesAjaxQueue = (function() {
1221
  */
1222
  _activateAllPlugins: function( activate_plugins ) {
1223
 
1224
- AstraSitesAdmin._log_title( 'Activating Plugins..' );
1225
 
1226
  $.each( activate_plugins, function(index, single_plugin) {
1227
 
@@ -1263,11 +1265,11 @@ var AstraSitesAjaxQueue = (function() {
1263
  */
1264
  _installAllPlugins: function( not_installed ) {
1265
 
1266
- AstraSitesAdmin._log_title( 'Installing Plugins..' );
1267
 
1268
  $.each( not_installed, function(index, single_plugin) {
1269
 
1270
- AstraSitesAdmin._log_title( 'Installing ' + AstraSitesAdmin.ucwords( single_plugin.name ));
1271
 
1272
  var $card = $( '.plugin-card-' + single_plugin.slug );
1273
 
@@ -1661,12 +1663,20 @@ var AstraSitesAjaxQueue = (function() {
1661
 
1662
  })
1663
  .done(function ( response ) {
 
1664
 
 
 
1665
 
1666
- // Release disabled class from import button.
1667
- $('.astra-demo-import')
1668
- .removeClass('disabled not-click-able')
1669
- .attr('data-import', 'disabled');
 
 
 
 
 
1670
 
1671
  // Remove loader.
1672
  $('.required-plugins').removeClass('loading').html('');
@@ -1683,12 +1693,12 @@ var AstraSitesAjaxQueue = (function() {
1683
  *
1684
  * List of not installed required plugins.
1685
  */
1686
- if ( typeof response.data.notinstalled !== 'undefined' ) {
1687
 
1688
  // Add not have installed plugins count.
1689
- remaining_plugins += parseInt( response.data.notinstalled.length );
1690
 
1691
- $( response.data.notinstalled ).each(function( index, plugin ) {
1692
  $('.required-plugins-list').append('<li class="plugin-card plugin-card-'+plugin.slug+'" data-slug="'+plugin.slug+'" data-init="'+plugin.init+'" data-name="'+plugin.name+'">'+plugin.name+'</li>');
1693
  });
1694
  }
@@ -1698,12 +1708,12 @@ var AstraSitesAjaxQueue = (function() {
1698
  *
1699
  * List of not inactive required plugins.
1700
  */
1701
- if ( typeof response.data.inactive !== 'undefined' ) {
1702
 
1703
  // Add inactive plugins count.
1704
- remaining_plugins += parseInt( response.data.inactive.length );
1705
 
1706
- $( response.data.inactive ).each(function( index, plugin ) {
1707
  $('.required-plugins-list').append('<li class="plugin-card plugin-card-'+plugin.slug+'" data-slug="'+plugin.slug+'" data-init="'+plugin.init+'" data-name="'+plugin.name+'">'+plugin.name+'</li>');
1708
  });
1709
  }
@@ -1713,9 +1723,9 @@ var AstraSitesAjaxQueue = (function() {
1713
  *
1714
  * List of not active required plugins.
1715
  */
1716
- if ( typeof response.data.active !== 'undefined' ) {
1717
 
1718
- $( response.data.active ).each(function( index, plugin ) {
1719
  $('.required-plugins-list').append('<li class="plugin-card plugin-card-'+plugin.slug+'" data-slug="'+plugin.slug+'" data-init="'+plugin.init+'" data-name="'+plugin.name+'">'+plugin.name+'</li>');
1720
  });
1721
  }
@@ -1724,7 +1734,7 @@ var AstraSitesAjaxQueue = (function() {
1724
  * Enable Demo Import Button
1725
  * @type number
1726
  */
1727
- astraSitesAdmin.requiredPlugins = response.data;
1728
  });
1729
 
1730
  } else {
120
  var complete = 0;
121
  var total = 0;
122
 
 
123
  for (var i = types.length - 1; i >= 0; i--) {
124
  var type = types[i];
125
  this.updateProgress( type, this.complete[ type ], this.data.count[ type ] );
761
  evtSource.addEventListener( 'log', function ( message ) {
762
  var data = JSON.parse( message.data );
763
  var message = data.message || '';
764
+ if( message && 'info' === data.level ) {
765
  message = message.replace(/"/g, function(letter) {
766
  return '';
767
  });
982
  return;
983
  }
984
 
985
+ AstraSitesAdmin._log_title( 'Installing Required Plugin..' );
986
 
987
  if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked ) {
988
  wp.updates.requestFilesystemCredentials( event );
998
  } );
999
  }
1000
 
1001
+ AstraSitesAdmin._log_title( 'Installing Plugin - ' + AstraSitesAdmin.ucwords( $button.data( 'name' ) ) );
1002
 
1003
  wp.updates.installPlugin( {
1004
  slug: $button.data( 'slug' )
1035
 
1036
  // Transform the 'Install' button into an 'Activate' button.
1037
  var $init = $( '.plugin-card-' + response.slug ).data('init');
1038
+ var $name = $( '.plugin-card-' + response.slug ).data('name');
1039
 
1040
  // Reset not installed plugins list.
1041
  var pluginsList = astraSitesAdmin.requiredPlugins.notinstalled;
1044
  // WordPress adds "Activate" button after waiting for 1000ms. So we will run our activation after that.
1045
  setTimeout( function() {
1046
 
1047
+ AstraSitesAdmin._log_title( 'Installing Plugin - ' + AstraSitesAdmin.ucwords($name) );
1048
 
1049
  $.ajax({
1050
  url: astraSitesAdmin.ajaxurl,
1059
  .done(function (result) {
1060
 
1061
  if( result.success ) {
 
 
1062
  var pluginsList = astraSitesAdmin.requiredPlugins.inactive;
1063
 
1064
+ AstraSitesAdmin._log_title( 'Installed Plugin - ' + AstraSitesAdmin.ucwords($name) );
1065
+
1066
  // Reset not installed plugins list.
1067
  astraSitesAdmin.requiredPlugins.inactive = AstraSitesAdmin._removePluginFromQueue( response.slug, pluginsList );
1068
 
1082
  _installError: function( event, response ) {
1083
 
1084
  var $card = $( '.plugin-card-' + response.slug );
1085
+ var $name = $card.data('name');
1086
 
1087
+ AstraSitesAdmin._log_title( response.errorMessage + ' ' + AstraSitesAdmin.ucwords($name) );
1088
 
1089
 
1090
  $card
1101
  event.preventDefault();
1102
 
1103
  var $card = $( '.plugin-card-' + args.slug );
1104
+ var $name = $card.data('name');
1105
 
1106
+ AstraSitesAdmin._log_title( 'Installing Plugin - ' + AstraSitesAdmin.ucwords( $name ));
1107
 
1108
  $card.addClass('updating-message');
1109
 
1125
  return;
1126
  }
1127
 
1128
+ AstraSitesAdmin._log_title( 'Activating Plugin - ' + AstraSitesAdmin.ucwords( $name ) );
1129
 
1130
  $button.addClass('updating-message button-primary')
1131
  .html( astraSitesAdmin.strings.btnActivating );
1147
 
1148
  if( result.success ) {
1149
 
1150
+ AstraSitesAdmin._log_title( 'Activated Plugin - ' + AstraSitesAdmin.ucwords($name) );
1151
 
1152
  var pluginsList = astraSitesAdmin.requiredPlugins.inactive;
1153
 
1223
  */
1224
  _activateAllPlugins: function( activate_plugins ) {
1225
 
1226
+ AstraSitesAdmin._log_title( 'Activating Required Plugins..' );
1227
 
1228
  $.each( activate_plugins, function(index, single_plugin) {
1229
 
1265
  */
1266
  _installAllPlugins: function( not_installed ) {
1267
 
1268
+ AstraSitesAdmin._log_title( 'Installing Required Plugins..' );
1269
 
1270
  $.each( not_installed, function(index, single_plugin) {
1271
 
1272
+ AstraSitesAdmin._log_title( 'Installing Plugin - ' + AstraSitesAdmin.ucwords( single_plugin.name ));
1273
 
1274
  var $card = $( '.plugin-card-' + single_plugin.slug );
1275
 
1663
 
1664
  })
1665
  .done(function ( response ) {
1666
+ required_plugins = response.data['required_plugins'];
1667
 
1668
+ if( response.data['third_party_required_plugins'].length ) {
1669
+ $('.astra-demo-import').removeClass('button-primary').addClass('disabled');
1670
 
1671
+ $('.astra-sites-third-party-required-plugins-wrap').remove();
1672
+ var template = wp.template('astra-sites-third-party-required-plugins');
1673
+ $('.astra-sites-advanced-options-wrap').append( template( response.data['third_party_required_plugins'] ) );
1674
+ } else {
1675
+ // Release disabled class from import button.
1676
+ $('.astra-demo-import')
1677
+ .removeClass('disabled not-click-able')
1678
+ .attr('data-import', 'disabled');
1679
+ }
1680
 
1681
  // Remove loader.
1682
  $('.required-plugins').removeClass('loading').html('');
1693
  *
1694
  * List of not installed required plugins.
1695
  */
1696
+ if ( typeof required_plugins.notinstalled !== 'undefined' ) {
1697
 
1698
  // Add not have installed plugins count.
1699
+ remaining_plugins += parseInt( required_plugins.notinstalled.length );
1700
 
1701
+ $( required_plugins.notinstalled ).each(function( index, plugin ) {
1702
  $('.required-plugins-list').append('<li class="plugin-card plugin-card-'+plugin.slug+'" data-slug="'+plugin.slug+'" data-init="'+plugin.init+'" data-name="'+plugin.name+'">'+plugin.name+'</li>');
1703
  });
1704
  }
1708
  *
1709
  * List of not inactive required plugins.
1710
  */
1711
+ if ( typeof required_plugins.inactive !== 'undefined' ) {
1712
 
1713
  // Add inactive plugins count.
1714
+ remaining_plugins += parseInt( required_plugins.inactive.length );
1715
 
1716
+ $( required_plugins.inactive ).each(function( index, plugin ) {
1717
  $('.required-plugins-list').append('<li class="plugin-card plugin-card-'+plugin.slug+'" data-slug="'+plugin.slug+'" data-init="'+plugin.init+'" data-name="'+plugin.name+'">'+plugin.name+'</li>');
1718
  });
1719
  }
1723
  *
1724
  * List of not active required plugins.
1725
  */
1726
+ if ( typeof required_plugins.active !== 'undefined' ) {
1727
 
1728
+ $( required_plugins.active ).each(function( index, plugin ) {
1729
  $('.required-plugins-list').append('<li class="plugin-card plugin-card-'+plugin.slug+'" data-slug="'+plugin.slug+'" data-init="'+plugin.init+'" data-name="'+plugin.name+'">'+plugin.name+'</li>');
1730
  });
1731
  }
1734
  * Enable Demo Import Button
1735
  * @type number
1736
  */
1737
+ astraSitesAdmin.requiredPlugins = required_plugins;
1738
  });
1739
 
1740
  } else {
inc/classes/class-astra-sites-importer.php CHANGED
@@ -101,7 +101,7 @@ if ( ! class_exists( 'Astra_Sites_Importer' ) ) :
101
  }
102
 
103
  // Check is image URL of type jpg|png|gif|jpeg.
104
- if ( preg_match( '/^((https?:\/\/)|(www\.))([a-z0-9-].?)+(:[0-9]+)?\/[\w\-]+\.(jpg|png|gif|jpeg)\/?$/i', $url ) ) {
105
  $timeout_value = 30;
106
  }
107
  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;
inc/classes/class-astra-sites.php CHANGED
@@ -1,600 +1,621 @@
1
- <?php
2
- /**
3
- * Astra Sites
4
- *
5
- * @since 1.0.0
6
- * @package Astra Sites
7
- */
8
-
9
- defined( 'ABSPATH' ) or exit;
10
-
11
- if ( ! class_exists( 'Astra_Sites' ) ) :
12
-
13
- /**
14
- * Astra_Sites
15
- */
16
- class Astra_Sites {
17
-
18
- /**
19
- * API URL which is used to get the response from.
20
- *
21
- * @since 1.0.0
22
- * @var (String) URL
23
- */
24
- public static $api_url;
25
-
26
- /**
27
- * Instance of Astra_Sites
28
- *
29
- * @since 1.0.0
30
- * @var (Object) Astra_Sites
31
- */
32
- private static $_instance = null;
33
-
34
- /**
35
- * Instance of Astra_Sites.
36
- *
37
- * @since 1.0.0
38
- *
39
- * @return object Class object.
40
- */
41
- public static function get_instance() {
42
- if ( ! isset( self::$_instance ) ) {
43
- self::$_instance = new self;
44
- }
45
-
46
- return self::$_instance;
47
- }
48
-
49
- /**
50
- * Constructor.
51
- *
52
- * @since 1.0.0
53
- */
54
- private function __construct() {
55
-
56
- self::set_api_url();
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
- add_action( 'wp_ajax_astra-sites-backup-settings', array( $this, 'backup_settings' ) );
69
- add_action( 'wp_ajax_astra-sites-set-reset-data', array( $this, 'set_reset_data' ) );
70
- add_action( 'wp_ajax_astra-sites-activate-theme', array( $this, 'activate_theme' ) );
71
- add_action( 'wp_ajax_astra-sites-getting-started-notice', array( $this, 'getting_started_notice' ) );
72
- }
73
-
74
- /**
75
- * Close getting started notice for current user
76
- *
77
- * @since 1.3.5
78
- * @return void
79
- */
80
- function getting_started_notice() {
81
- update_user_meta( get_current_user_id(), '_astra_sites_gettings_started', true );
82
- wp_send_json_success();
83
- }
84
-
85
- /**
86
- * Activate theme
87
- *
88
- * @since 1.3.2
89
- * @return void
90
- */
91
- function activate_theme() {
92
-
93
- switch_theme( 'astra' );
94
-
95
- wp_send_json_success(
96
- array(
97
- 'success' => true,
98
- 'message' => __( 'Theme Activated', 'astra-sites' ),
99
- )
100
- );
101
- }
102
-
103
- /**
104
- * Set reset data
105
- */
106
- function set_reset_data() {
107
- if ( ! current_user_can( 'manage_options' ) ) {
108
- return;
109
- }
110
-
111
- global $wpdb;
112
-
113
- $post_ids = $wpdb->get_col( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='_astra_sites_imported_post'" );
114
- $form_ids = $wpdb->get_col( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='_astra_sites_imported_wp_forms'" );
115
- $term_ids = $wpdb->get_col( "SELECT term_id FROM {$wpdb->termmeta} WHERE meta_key='_astra_sites_imported_term'" );
116
-
117
- wp_send_json_success(
118
- array(
119
- 'reset_posts' => $post_ids,
120
- 'reset_wp_forms' => $form_ids,
121
- 'reset_terms' => $term_ids,
122
- )
123
- );
124
- }
125
-
126
- /**
127
- * Backup our existing settings.
128
- */
129
- function backup_settings() {
130
- if ( ! current_user_can( 'manage_options' ) ) {
131
- return;
132
- }
133
-
134
- $file_name = 'astra-sites-backup-' . date( 'd-M-Y-h-i-s' ) . '.json';
135
- $old_settings = get_option( 'astra-settings', array() );
136
- $upload_dir = Astra_Sites_Importer_Log::get_instance()->log_dir();
137
- $upload_path = trailingslashit( $upload_dir['path'] );
138
- $log_file = $upload_path . $file_name;
139
- $file_system = Astra_Sites_Importer_Log::get_instance()->get_filesystem();
140
-
141
- // If file system fails? Then take a backup in site option.
142
- if ( false === $file_system->put_contents( $log_file, json_encode( $old_settings ), FS_CHMOD_FILE ) ) {
143
- update_option( 'astra_sites_' . $file_name, $old_settings );
144
- }
145
-
146
- wp_send_json_success();
147
- }
148
-
149
- /**
150
- * Add Admin Notice.
151
- */
152
- function add_notice() {
153
-
154
- $theme_status = 'astra-sites-theme-' . $this->get_theme_status();
155
-
156
- Astra_Notices::add_notice(
157
- array(
158
- 'id' => 'astra-theme-activation-nag',
159
- 'type' => 'error',
160
- 'show_if' => ( ! defined( 'ASTRA_THEME_SETTINGS' ) ) ? true : false,
161
- /* translators: 1: theme.php file*/
162
- 'message' => sprintf( __( '<p>Astra Theme needs to be active for you to use currently installed "%1$s" plugin. <a href="#" class="%3$s" data-theme-slug="astra">Install & Activate Now</a></p>', 'astra-sites' ), ASTRA_SITES_NAME, esc_url( admin_url( 'themes.php?theme=astra' ) ), $theme_status ),
163
- 'dismissible' => true,
164
- 'dismissible-time' => WEEK_IN_SECONDS,
165
- )
166
- );
167
- }
168
-
169
- /**
170
- * Get theme install, active or inactive status.
171
- *
172
- * @since 1.3.2
173
- *
174
- * @return string Theme status
175
- */
176
- function get_theme_status() {
177
-
178
- $theme = wp_get_theme();
179
-
180
- // Theme installed and activate.
181
- if ( 'Astra' === $theme->name || 'Astra' === $theme->parent_theme ) {
182
- return 'installed-and-active';
183
- }
184
-
185
- // Theme installed but not activate.
186
- foreach ( (array) wp_get_themes() as $theme_dir => $theme ) {
187
- if ( 'Astra' === $theme->name || 'Astra' === $theme->parent_theme ) {
188
- return 'installed-but-inactive';
189
- }
190
- }
191
-
192
- return 'not-installed';
193
- }
194
-
195
- /**
196
- * Loads textdomain for the plugin.
197
- *
198
- * @since 1.0.1
199
- */
200
- function load_textdomain() {
201
- load_plugin_textdomain( 'astra-sites' );
202
- }
203
-
204
- /**
205
- * Admin Notices
206
- *
207
- * @since 1.0.5
208
- * @return void
209
- */
210
- function admin_notices() {
211
-
212
- if ( ! defined( 'ASTRA_THEME_SETTINGS' ) ) {
213
- return;
214
- }
215
-
216
- add_action( 'plugin_action_links_' . ASTRA_SITES_BASE, array( $this, 'action_links' ) );
217
- }
218
-
219
- /**
220
- * Show action links on the plugin screen.
221
- *
222
- * @param mixed $links Plugin Action links.
223
- * @return array
224
- */
225
- function action_links( $links ) {
226
- $action_links = array(
227
- 'settings' => '<a href="' . admin_url( 'themes.php?page=astra-sites' ) . '" aria-label="' . esc_attr__( 'See Library', 'astra-sites' ) . '">' . esc_html__( 'See Library', 'astra-sites' ) . '</a>',
228
- );
229
-
230
- return array_merge( $action_links, $links );
231
- }
232
-
233
- /**
234
- * Setter for $api_url
235
- *
236
- * @since 1.0.0
237
- */
238
- public static function set_api_url() {
239
- self::$api_url = apply_filters( 'astra_sites_api_url', 'https://websitedemos.net/wp-json/wp/v2/' );
240
-
241
- }
242
-
243
- /**
244
- * Enqueue admin scripts.
245
- *
246
- * @since 1.3.2 Added 'install-theme.js' to install and activate theme.
247
- * @since 1.0.5 Added 'getUpgradeText' and 'getUpgradeURL' localize variables.
248
- *
249
- * @since 1.0.0
250
- *
251
- * @param string $hook Current hook name.
252
- * @return void
253
- */
254
- public function admin_enqueue( $hook = '' ) {
255
-
256
- wp_enqueue_script( 'astra-sites-install-theme', ASTRA_SITES_URI . 'inc/assets/js/install-theme.js', array( 'jquery', 'updates' ), ASTRA_SITES_VER, true );
257
- wp_enqueue_style( 'astra-sites-install-theme', ASTRA_SITES_URI . 'inc/assets/css/install-theme.css', null, ASTRA_SITES_VER, 'all' );
258
-
259
- $data = apply_filters(
260
- 'astra_sites_install_theme_localize_vars',
261
- array(
262
- 'installed' => __( 'Installed! Activating..', 'astra-sites' ),
263
- 'activating' => __( 'Activating..', 'astra-sites' ),
264
- 'activated' => __( 'Activated! Reloading..', 'astra-sites' ),
265
- 'installing' => __( 'Installing..', 'astra-sites' ),
266
- 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
267
- )
268
- );
269
- wp_localize_script( 'astra-sites-install-theme', 'AstraSitesInstallThemeVars', $data );
270
-
271
- if ( 'appearance_page_astra-sites' !== $hook ) {
272
- return;
273
- }
274
-
275
- global $is_IE, $is_edge;
276
-
277
- if ( $is_IE || $is_edge ) {
278
- wp_enqueue_script( 'astra-sites-eventsource', ASTRA_SITES_URI . 'inc/assets/js/eventsource.min.js', array( 'jquery', 'wp-util', 'updates' ), ASTRA_SITES_VER, true );
279
- }
280
-
281
- // Fetch.
282
- wp_register_script( 'astra-sites-fetch', ASTRA_SITES_URI . 'inc/assets/js/fetch.umd.js', array( 'jquery' ), ASTRA_SITES_VER, true );
283
-
284
- // API.
285
- wp_register_script( 'astra-sites-api', ASTRA_SITES_URI . 'inc/assets/js/astra-sites-api.js', array( 'jquery', 'astra-sites-fetch' ), ASTRA_SITES_VER, true );
286
-
287
- // Admin Page.
288
- wp_enqueue_style( 'astra-sites-admin', ASTRA_SITES_URI . 'inc/assets/css/admin.css', ASTRA_SITES_VER, true );
289
- 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 );
290
- 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 );
291
-
292
- $data = apply_filters(
293
- 'astra_sites_localize_vars',
294
- array(
295
- 'ApiURL' => self::$api_url,
296
- 'filters' => array(
297
- 'page_builder' => array(
298
- 'title' => __( 'Page Builder', 'astra-sites' ),
299
- 'slug' => 'astra-site-page-builder',
300
- 'trigger' => 'astra-api-category-loaded',
301
- ),
302
- 'categories' => array(
303
- 'title' => __( 'Categories', 'astra-sites' ),
304
- 'slug' => 'astra-site-category',
305
- 'trigger' => 'astra-api-category-loaded',
306
- ),
307
- ),
308
- )
309
- );
310
- wp_localize_script( 'astra-sites-api', 'astraSitesApi', $data );
311
-
312
- // Use this for premium demos.
313
- $request_params = apply_filters(
314
- 'astra_sites_api_params',
315
- array(
316
- 'purchase_key' => '',
317
- 'site_url' => '',
318
- 'par-page' => 30,
319
- )
320
- );
321
-
322
- $data = apply_filters(
323
- 'astra_sites_render_localize_vars',
324
- array(
325
- 'sites' => $request_params,
326
- 'page-builders' => array(),
327
- 'categories' => array(),
328
- 'settings' => array(),
329
- 'default_page_builder' => Astra_Sites_Page::get_instance()->get_setting( 'page_builder' ),
330
- )
331
- );
332
-
333
- wp_localize_script( 'astra-sites-render-grid', 'astraRenderGrid', $data );
334
-
335
- $data = apply_filters(
336
- 'astra_sites_localize_vars',
337
- array(
338
- 'debug' => ( ( defined( 'WP_DEBUG' ) && WP_DEBUG ) || isset( $_GET['debug'] ) ) ? true : false,
339
- 'isPro' => defined( 'ASTRA_PRO_SITES_NAME' ) ? true : false,
340
- 'isWhiteLabeled' => Astra_Sites_White_Label::get_instance()->is_white_labeled(),
341
- 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
342
- 'siteURL' => site_url(),
343
- 'docUrl' => 'https://wpastra.com/',
344
- 'getProText' => __( 'Get Agency Bundle', 'astra-sites' ),
345
- 'getProURL' => esc_url( 'https://wpastra.com/agency/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=wp-dashboard' ),
346
- 'getUpgradeText' => __( 'Upgrade', 'astra-sites' ),
347
- 'getUpgradeURL' => esc_url( 'https://wpastra.com/agency/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=wp-dashboard' ),
348
- '_ajax_nonce' => wp_create_nonce( 'astra-sites' ),
349
- 'requiredPlugins' => array(),
350
- 'XMLReaderDisabled' => ! class_exists( 'XMLReader' ) ? true : false,
351
- 'strings' => array(
352
- /* translators: %s are HTML tags. */
353
- 'warningXMLReader' => sprintf( __( '%1$sRequired XMLReader PHP extension is missing on your server!%2$sAstra Sites 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' ), '<div class="notice astra-sites-xml-notice notice-error"><p><b>', '</b></p><p>', '</p></div>' ),
354
- 'warningBeforeCloseWindow' => __( 'Warning! Astra Site Import process is not complete. Don\'t close the window until import process complete. Do you still want to leave the window?', 'astra-sites' ),
355
- 'importFailedBtnSmall' => __( 'Error!', 'astra-sites' ),
356
- 'importFailedBtnLarge' => __( 'Error! Read Possibilities.', 'astra-sites' ),
357
- 'importFailedURL' => esc_url( 'https://wpastra.com/docs/?p=1314&utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=import-failed' ),
358
- 'viewSite' => __( 'Done! View Site', '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;',
366
- 'DescCollapse' => __( 'Hide', 'astra-sites' ),
367
- 'responseError' => __( 'There was a problem receiving a response from server.', 'astra-sites' ),
368
- 'searchNoFound' => __( 'No Demos found, Try a different search.', 'astra-sites' ),
369
- ),
370
- 'log' => array(
371
- 'installingPlugin' => __( 'Installing plugin ', 'astra-sites' ),
372
- 'installed' => __( 'Plugin installed!', 'astra-sites' ),
373
- 'activating' => __( 'Activating plugin ', 'astra-sites' ),
374
- 'activated' => __( 'Plugin activated ', 'astra-sites' ),
375
- 'bulkActivation' => __( 'Bulk plugin activation...', 'astra-sites' ),
376
- 'activate' => __( 'Plugin activate - ', 'astra-sites' ),
377
- 'activationError' => __( 'Error! While activating plugin - ', 'astra-sites' ),
378
- 'bulkInstall' => __( 'Bulk plugin installation...', 'astra-sites' ),
379
- 'api' => __( 'Site API ', 'astra-sites' ),
380
- 'importing' => __( 'Importing..', 'astra-sites' ),
381
- 'processingRequest' => __( 'Processing requests...', 'astra-sites' ),
382
- 'importCustomizer' => __( 'Importing "Customizer Settings"...', 'astra-sites' ),
383
- 'importCustomizerSuccess' => __( 'Imported customizer settings!', 'astra-sites' ),
384
- 'importWPForms' => __( 'Importing "Contact Forms"...', 'astra-sites' ),
385
- 'importWPFormsSuccess' => __( 'Imported Contact Forms!', 'astra-sites' ),
386
- 'importXMLPrepare' => __( 'Preparing "XML" Data...', 'astra-sites' ),
387
- 'importXMLPrepareSuccess' => __( 'Set XML data!', 'astra-sites' ),
388
- 'importXML' => __( 'Importing "XML"...', 'astra-sites' ),
389
- 'importXMLSuccess' => __( 'Imported XML!', 'astra-sites' ),
390
- 'importOptions' => __( 'Importing "Options"...', 'astra-sites' ),
391
- 'importOptionsSuccess' => __( 'Imported Options!', 'astra-sites' ),
392
- 'importWidgets' => __( 'Importing "Widgets"...', 'astra-sites' ),
393
- 'importWidgetsSuccess' => __( 'Imported Widgets!', 'astra-sites' ),
394
- 'serverConfiguration' => esc_url( 'https://wpastra.com/docs/?p=1314&utm_source=demo-import-panel&utm_campaign=import-error&utm_medium=wp-dashboard' ),
395
- 'success' => __( 'View site: ', 'astra-sites' ),
396
- 'gettingData' => __( 'Getting Site Information..', 'astra-sites' ),
397
- 'importingCustomizer' => __( 'Importing Customizer Settings..', 'astra-sites' ),
398
- 'importingWPForms' => __( 'Importing Contact Forms..', 'astra-sites' ),
399
- 'importXMLPreparing' => __( 'Setting up import data..', 'astra-sites' ),
400
- 'importingXML' => __( 'Importing Content..', 'astra-sites' ),
401
- 'importingOptions' => __( 'Importing Site Options..', 'astra-sites' ),
402
- 'importingWidgets' => __( 'Importing Widgets..', 'astra-sites' ),
403
- 'importComplete' => __( 'Import Complete..', 'astra-sites' ),
404
- 'preview' => __( 'Previewing ', 'astra-sites' ),
405
- 'importLogText' => __( 'See Error Log &rarr;', 'astra-sites' ),
406
- ),
407
- )
408
- );
409
-
410
- wp_localize_script( 'astra-sites-admin-page', 'astraSitesAdmin', $data );
411
-
412
- }
413
-
414
- /**
415
- * Load all the required files in the importer.
416
- *
417
- * @since 1.0.0
418
- */
419
- private function includes() {
420
-
421
- require_once ASTRA_SITES_DIR . 'inc/lib/astra-notices/class-astra-notices.php';
422
- require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-white-label.php';
423
- require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-page.php';
424
- require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/class-astra-sites-compatibility.php';
425
- require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-importer.php';
426
- }
427
-
428
- /**
429
- * Required Plugin Activate
430
- *
431
- * @since 1.0.0
432
- */
433
- public function required_plugin_activate() {
434
-
435
- if ( ! current_user_can( 'install_plugins' ) || ! isset( $_POST['init'] ) || ! $_POST['init'] ) {
436
- wp_send_json_error(
437
- array(
438
- 'success' => false,
439
- 'message' => __( 'No plugin specified', 'astra-sites' ),
440
- )
441
- );
442
- }
443
-
444
- $data = array();
445
- $plugin_init = ( isset( $_POST['init'] ) ) ? esc_attr( $_POST['init'] ) : '';
446
- $astra_site_options = ( isset( $_POST['options'] ) ) ? json_decode( stripslashes( $_POST['options'] ) ) : '';
447
- $enabled_extensions = ( isset( $_POST['enabledExtensions'] ) ) ? json_decode( stripslashes( $_POST['enabledExtensions'] ) ) : '';
448
-
449
- $data['astra_site_options'] = $astra_site_options;
450
- $data['enabled_extensions'] = $enabled_extensions;
451
-
452
- $activate = activate_plugin( $plugin_init, '', false, true );
453
-
454
- if ( is_wp_error( $activate ) ) {
455
- wp_send_json_error(
456
- array(
457
- 'success' => false,
458
- 'message' => $activate->get_error_message(),
459
- )
460
- );
461
- }
462
-
463
- do_action( 'astra_sites_after_plugin_activation', $plugin_init, $data );
464
-
465
- wp_send_json_success(
466
- array(
467
- 'success' => true,
468
- 'message' => __( 'Plugin Activated', 'astra-sites' ),
469
- )
470
- );
471
-
472
- }
473
-
474
- /**
475
- * Required Plugin
476
- *
477
- * @since 1.0.0
478
- * @return void
479
- */
480
- public function required_plugin() {
481
-
482
- // Verify Nonce.
483
- check_ajax_referer( 'astra-sites', '_ajax_nonce' );
484
-
485
- $response = array(
486
- 'active' => array(),
487
- 'inactive' => array(),
488
- 'notinstalled' => array(),
489
- );
490
-
491
- if ( ! current_user_can( 'customize' ) ) {
492
- wp_send_json_error( $response );
493
- }
494
-
495
- $required_plugins = ( isset( $_POST['required_plugins'] ) ) ? $_POST['required_plugins'] : array();
496
-
497
- if ( count( $required_plugins ) > 0 ) {
498
- foreach ( $required_plugins as $key => $plugin ) {
499
-
500
- /**
501
- * Has Pro Version Support?
502
- * And
503
- * Is Pro Version Installed?
504
- */
505
- $plugin_pro = self::pro_plugin_exist( $plugin['init'] );
506
- if ( $plugin_pro ) {
507
-
508
- // Pro - Active.
509
- if ( is_plugin_active( $plugin_pro['init'] ) ) {
510
- $response['active'][] = $plugin_pro;
511
-
512
- // Pro - Inactive.
513
- } else {
514
- $response['inactive'][] = $plugin_pro;
515
- }
516
- } else {
517
-
518
- // Lite - Installed but Inactive.
519
- if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin['init'] ) && is_plugin_inactive( $plugin['init'] ) ) {
520
-
521
- $response['inactive'][] = $plugin;
522
-
523
- // Lite - Not Installed.
524
- } elseif ( ! file_exists( WP_PLUGIN_DIR . '/' . $plugin['init'] ) ) {
525
-
526
- $response['notinstalled'][] = $plugin;
527
-
528
- // Lite - Active.
529
- } else {
530
- $response['active'][] = $plugin;
531
- }
532
- }
533
- }
534
- }
535
-
536
- // Send response.
537
- wp_send_json_success( $response );
538
- }
539
-
540
- /**
541
- * Has Pro Version Support?
542
- * And
543
- * Is Pro Version Installed?
544
- *
545
- * Check Pro plugin version exist of requested plugin lite version.
546
- *
547
- * Eg. If plugin 'BB Lite Version' required to import demo. Then we check the 'BB Agency Version' is exist?
548
- * If yes then we only 'Activate' Agency Version. [We couldn't install agency version.]
549
- * Else we 'Activate' or 'Install' Lite Version.
550
- *
551
- * @since 1.0.1
552
- *
553
- * @param string $lite_version Lite version init file.
554
- * @return mixed Return false if not installed or not supported by us
555
- * else return 'Pro' version details.
556
- */
557
- public static function pro_plugin_exist( $lite_version = '' ) {
558
-
559
- // Lite init => Pro init.
560
- $plugins = apply_filters(
561
- 'astra_sites_pro_plugin_exist',
562
- array(
563
- 'beaver-builder-lite-version/fl-builder.php' => array(
564
- 'slug' => 'bb-plugin',
565
- 'init' => 'bb-plugin/fl-builder.php',
566
- 'name' => 'Beaver Builder Plugin',
567
- ),
568
- 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' => array(
569
- 'slug' => 'bb-ultimate-addon',
570
- 'init' => 'bb-ultimate-addon/bb-ultimate-addon.php',
571
- 'name' => 'Ultimate Addon for Beaver Builder',
572
- ),
573
- 'wpforms-lite/wpforms.php' => array(
574
- 'slug' => 'wpforms',
575
- 'init' => 'wpforms/wpforms.php',
576
- 'name' => 'WPForms',
577
- ),
578
- ),
579
- $lite_version
580
- );
581
-
582
- if ( isset( $plugins[ $lite_version ] ) ) {
583
-
584
- // Pro plugin directory exist?
585
- if ( file_exists( WP_PLUGIN_DIR . '/' . $plugins[ $lite_version ]['init'] ) ) {
586
- return $plugins[ $lite_version ];
587
- }
588
- }
589
-
590
- return false;
591
- }
592
-
593
- }
594
-
595
- /**
596
- * Kicking this off by calling 'get_instance()' method
597
- */
598
- Astra_Sites::get_instance();
599
-
600
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Astra Sites
4
+ *
5
+ * @since 1.0.0
6
+ * @package Astra Sites
7
+ */
8
+
9
+ defined( 'ABSPATH' ) or exit;
10
+
11
+ if ( ! class_exists( 'Astra_Sites' ) ) :
12
+
13
+ /**
14
+ * Astra_Sites
15
+ */
16
+ class Astra_Sites {
17
+
18
+ /**
19
+ * API URL which is used to get the response from.
20
+ *
21
+ * @since 1.0.0
22
+ * @var (String) URL
23
+ */
24
+ public static $api_url;
25
+
26
+ /**
27
+ * Instance of Astra_Sites
28
+ *
29
+ * @since 1.0.0
30
+ * @var (Object) Astra_Sites
31
+ */
32
+ private static $_instance = null;
33
+
34
+ /**
35
+ * Instance of Astra_Sites.
36
+ *
37
+ * @since 1.0.0
38
+ *
39
+ * @return object Class object.
40
+ */
41
+ public static function get_instance() {
42
+ if ( ! isset( self::$_instance ) ) {
43
+ self::$_instance = new self;
44
+ }
45
+
46
+ return self::$_instance;
47
+ }
48
+
49
+ /**
50
+ * Constructor.
51
+ *
52
+ * @since 1.0.0
53
+ */
54
+ private function __construct() {
55
+
56
+ self::set_api_url();
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
+ add_action( 'wp_ajax_astra-sites-backup-settings', array( $this, 'backup_settings' ) );
69
+ add_action( 'wp_ajax_astra-sites-set-reset-data', array( $this, 'set_reset_data' ) );
70
+ add_action( 'wp_ajax_astra-sites-activate-theme', array( $this, 'activate_theme' ) );
71
+ add_action( 'wp_ajax_astra-sites-getting-started-notice', array( $this, 'getting_started_notice' ) );
72
+ }
73
+
74
+ /**
75
+ * Close getting started notice for current user
76
+ *
77
+ * @since 1.3.5
78
+ * @return void
79
+ */
80
+ function getting_started_notice() {
81
+ update_user_meta( get_current_user_id(), '_astra_sites_gettings_started', true );
82
+ wp_send_json_success();
83
+ }
84
+
85
+ /**
86
+ * Activate theme
87
+ *
88
+ * @since 1.3.2
89
+ * @return void
90
+ */
91
+ function activate_theme() {
92
+
93
+ switch_theme( 'astra' );
94
+
95
+ wp_send_json_success(
96
+ array(
97
+ 'success' => true,
98
+ 'message' => __( 'Theme Activated', 'astra-sites' ),
99
+ )
100
+ );
101
+ }
102
+
103
+ /**
104
+ * Set reset data
105
+ */
106
+ function set_reset_data() {
107
+ if ( ! current_user_can( 'manage_options' ) ) {
108
+ return;
109
+ }
110
+
111
+ global $wpdb;
112
+
113
+ $post_ids = $wpdb->get_col( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='_astra_sites_imported_post'" );
114
+ $form_ids = $wpdb->get_col( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='_astra_sites_imported_wp_forms'" );
115
+ $term_ids = $wpdb->get_col( "SELECT term_id FROM {$wpdb->termmeta} WHERE meta_key='_astra_sites_imported_term'" );
116
+
117
+ wp_send_json_success(
118
+ array(
119
+ 'reset_posts' => $post_ids,
120
+ 'reset_wp_forms' => $form_ids,
121
+ 'reset_terms' => $term_ids,
122
+ )
123
+ );
124
+ }
125
+
126
+ /**
127
+ * Backup our existing settings.
128
+ */
129
+ function backup_settings() {
130
+ if ( ! current_user_can( 'manage_options' ) ) {
131
+ return;
132
+ }
133
+
134
+ $file_name = 'astra-sites-backup-' . date( 'd-M-Y-h-i-s' ) . '.json';
135
+ $old_settings = get_option( 'astra-settings', array() );
136
+ $upload_dir = Astra_Sites_Importer_Log::get_instance()->log_dir();
137
+ $upload_path = trailingslashit( $upload_dir['path'] );
138
+ $log_file = $upload_path . $file_name;
139
+ $file_system = Astra_Sites_Importer_Log::get_instance()->get_filesystem();
140
+
141
+ // If file system fails? Then take a backup in site option.
142
+ if ( false === $file_system->put_contents( $log_file, json_encode( $old_settings ), FS_CHMOD_FILE ) ) {
143
+ update_option( 'astra_sites_' . $file_name, $old_settings );
144
+ }
145
+
146
+ wp_send_json_success();
147
+ }
148
+
149
+ /**
150
+ * Add Admin Notice.
151
+ */
152
+ function add_notice() {
153
+
154
+ $theme_status = 'astra-sites-theme-' . $this->get_theme_status();
155
+
156
+ Astra_Notices::add_notice(
157
+ array(
158
+ 'id' => 'astra-theme-activation-nag',
159
+ 'type' => 'error',
160
+ 'show_if' => ( ! defined( 'ASTRA_THEME_SETTINGS' ) ) ? true : false,
161
+ /* translators: 1: theme.php file*/
162
+ 'message' => sprintf( __( '<p>Astra Theme needs to be active for you to use currently installed "%1$s" plugin. <a href="#" class="%3$s" data-theme-slug="astra">Install & Activate Now</a></p>', 'astra-sites' ), ASTRA_SITES_NAME, esc_url( admin_url( 'themes.php?theme=astra' ) ), $theme_status ),
163
+ 'dismissible' => true,
164
+ 'dismissible-time' => WEEK_IN_SECONDS,
165
+ )
166
+ );
167
+ }
168
+
169
+ /**
170
+ * Get theme install, active or inactive status.
171
+ *
172
+ * @since 1.3.2
173
+ *
174
+ * @return string Theme status
175
+ */
176
+ function get_theme_status() {
177
+
178
+ $theme = wp_get_theme();
179
+
180
+ // Theme installed and activate.
181
+ if ( 'Astra' === $theme->name || 'Astra' === $theme->parent_theme ) {
182
+ return 'installed-and-active';
183
+ }
184
+
185
+ // Theme installed but not activate.
186
+ foreach ( (array) wp_get_themes() as $theme_dir => $theme ) {
187
+ if ( 'Astra' === $theme->name || 'Astra' === $theme->parent_theme ) {
188
+ return 'installed-but-inactive';
189
+ }
190
+ }
191
+
192
+ return 'not-installed';
193
+ }
194
+
195
+ /**
196
+ * Loads textdomain for the plugin.
197
+ *
198
+ * @since 1.0.1
199
+ */
200
+ function load_textdomain() {
201
+ load_plugin_textdomain( 'astra-sites' );
202
+ }
203
+
204
+ /**
205
+ * Admin Notices
206
+ *
207
+ * @since 1.0.5
208
+ * @return void
209
+ */
210
+ function admin_notices() {
211
+
212
+ if ( ! defined( 'ASTRA_THEME_SETTINGS' ) ) {
213
+ return;
214
+ }
215
+
216
+ add_action( 'plugin_action_links_' . ASTRA_SITES_BASE, array( $this, 'action_links' ) );
217
+ }
218
+
219
+ /**
220
+ * Show action links on the plugin screen.
221
+ *
222
+ * @param mixed $links Plugin Action links.
223
+ * @return array
224
+ */
225
+ function action_links( $links ) {
226
+ $action_links = array(
227
+ 'settings' => '<a href="' . admin_url( 'themes.php?page=astra-sites' ) . '" aria-label="' . esc_attr__( 'See Library', 'astra-sites' ) . '">' . esc_html__( 'See Library', 'astra-sites' ) . '</a>',
228
+ );
229
+
230
+ return array_merge( $action_links, $links );
231
+ }
232
+
233
+ /**
234
+ * Setter for $api_url
235
+ *
236
+ * @since 1.0.0
237
+ */
238
+ public static function set_api_url() {
239
+ self::$api_url = apply_filters( 'astra_sites_api_url', 'https://websitedemos.net/wp-json/wp/v2/' );
240
+
241
+ }
242
+
243
+ /**
244
+ * Enqueue admin scripts.
245
+ *
246
+ * @since 1.3.2 Added 'install-theme.js' to install and activate theme.
247
+ * @since 1.0.5 Added 'getUpgradeText' and 'getUpgradeURL' localize variables.
248
+ *
249
+ * @since 1.0.0
250
+ *
251
+ * @param string $hook Current hook name.
252
+ * @return void
253
+ */
254
+ public function admin_enqueue( $hook = '' ) {
255
+
256
+ wp_enqueue_script( 'astra-sites-install-theme', ASTRA_SITES_URI . 'inc/assets/js/install-theme.js', array( 'jquery', 'updates' ), ASTRA_SITES_VER, true );
257
+ wp_enqueue_style( 'astra-sites-install-theme', ASTRA_SITES_URI . 'inc/assets/css/install-theme.css', null, ASTRA_SITES_VER, 'all' );
258
+
259
+ $data = apply_filters(
260
+ 'astra_sites_install_theme_localize_vars',
261
+ array(
262
+ 'installed' => __( 'Installed! Activating..', 'astra-sites' ),
263
+ 'activating' => __( 'Activating..', 'astra-sites' ),
264
+ 'activated' => __( 'Activated! Reloading..', 'astra-sites' ),
265
+ 'installing' => __( 'Installing..', 'astra-sites' ),
266
+ 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
267
+ )
268
+ );
269
+ wp_localize_script( 'astra-sites-install-theme', 'AstraSitesInstallThemeVars', $data );
270
+
271
+ if ( 'appearance_page_astra-sites' !== $hook ) {
272
+ return;
273
+ }
274
+
275
+ global $is_IE, $is_edge;
276
+
277
+ if ( $is_IE || $is_edge ) {
278
+ wp_enqueue_script( 'astra-sites-eventsource', ASTRA_SITES_URI . 'inc/assets/js/eventsource.min.js', array( 'jquery', 'wp-util', 'updates' ), ASTRA_SITES_VER, true );
279
+ }
280
+
281
+ // Fetch.
282
+ wp_register_script( 'astra-sites-fetch', ASTRA_SITES_URI . 'inc/assets/js/fetch.umd.js', array( 'jquery' ), ASTRA_SITES_VER, true );
283
+
284
+ // API.
285
+ wp_register_script( 'astra-sites-api', ASTRA_SITES_URI . 'inc/assets/js/astra-sites-api.js', array( 'jquery', 'astra-sites-fetch' ), ASTRA_SITES_VER, true );
286
+
287
+ // Admin Page.
288
+ wp_enqueue_style( 'astra-sites-admin', ASTRA_SITES_URI . 'inc/assets/css/admin.css', ASTRA_SITES_VER, true );
289
+ 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 );
290
+ 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 );
291
+
292
+ $data = apply_filters(
293
+ 'astra_sites_localize_vars',
294
+ array(
295
+ 'ApiURL' => self::$api_url,
296
+ 'filters' => array(
297
+ 'page_builder' => array(
298
+ 'title' => __( 'Page Builder', 'astra-sites' ),
299
+ 'slug' => 'astra-site-page-builder',
300
+ 'trigger' => 'astra-api-category-loaded',
301
+ ),
302
+ 'categories' => array(
303
+ 'title' => __( 'Categories', 'astra-sites' ),
304
+ 'slug' => 'astra-site-category',
305
+ 'trigger' => 'astra-api-category-loaded',
306
+ ),
307
+ ),
308
+ )
309
+ );
310
+ wp_localize_script( 'astra-sites-api', 'astraSitesApi', $data );
311
+
312
+ // Use this for premium demos.
313
+ $request_params = apply_filters(
314
+ 'astra_sites_api_params',
315
+ array(
316
+ 'purchase_key' => '',
317
+ 'site_url' => '',
318
+ 'par-page' => 30,
319
+ )
320
+ );
321
+
322
+ $data = apply_filters(
323
+ 'astra_sites_render_localize_vars',
324
+ array(
325
+ 'sites' => $request_params,
326
+ 'page-builders' => array(),
327
+ 'categories' => array(),
328
+ 'settings' => array(),
329
+ 'default_page_builder' => Astra_Sites_Page::get_instance()->get_setting( 'page_builder' ),
330
+ )
331
+ );
332
+
333
+ wp_localize_script( 'astra-sites-render-grid', 'astraRenderGrid', $data );
334
+
335
+ $data = apply_filters(
336
+ 'astra_sites_localize_vars',
337
+ array(
338
+ 'debug' => ( ( defined( 'WP_DEBUG' ) && WP_DEBUG ) || isset( $_GET['debug'] ) ) ? true : false,
339
+ 'isPro' => defined( 'ASTRA_PRO_SITES_NAME' ) ? true : false,
340
+ 'isWhiteLabeled' => Astra_Sites_White_Label::get_instance()->is_white_labeled(),
341
+ 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
342
+ 'siteURL' => site_url(),
343
+ 'docUrl' => 'https://wpastra.com/',
344
+ 'getProText' => __( 'Get Agency Bundle', 'astra-sites' ),
345
+ 'getProURL' => esc_url( 'https://wpastra.com/agency/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=wp-dashboard' ),
346
+ 'getUpgradeText' => __( 'Upgrade', 'astra-sites' ),
347
+ 'getUpgradeURL' => esc_url( 'https://wpastra.com/agency/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=wp-dashboard' ),
348
+ '_ajax_nonce' => wp_create_nonce( 'astra-sites' ),
349
+ 'requiredPlugins' => array(),
350
+ 'XMLReaderDisabled' => ! class_exists( 'XMLReader' ) ? true : false,
351
+ 'strings' => array(
352
+ /* translators: %s are HTML tags. */
353
+ 'warningXMLReader' => sprintf( __( '%1$sRequired XMLReader PHP extension is missing on your server!%2$sAstra Sites 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' ), '<div class="notice astra-sites-xml-notice notice-error"><p><b>', '</b></p><p>', '</p></div>' ),
354
+ 'warningBeforeCloseWindow' => __( 'Warning! Astra Site Import process is not complete. Don\'t close the window until import process complete. Do you still want to leave the window?', 'astra-sites' ),
355
+ 'importFailedBtnSmall' => __( 'Error!', 'astra-sites' ),
356
+ 'importFailedBtnLarge' => __( 'Error! Read Possibilities.', 'astra-sites' ),
357
+ 'importFailedURL' => esc_url( 'https://wpastra.com/docs/?p=1314&utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=import-failed' ),
358
+ 'viewSite' => __( 'Done! View Site', '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;',
366
+ 'DescCollapse' => __( 'Hide', 'astra-sites' ),
367
+ 'responseError' => __( 'There was a problem receiving a response from server.', 'astra-sites' ),
368
+ 'searchNoFound' => __( 'No Demos found, Try a different search.', 'astra-sites' ),
369
+ ),
370
+ 'log' => array(
371
+ 'installingPlugin' => __( 'Installing plugin ', 'astra-sites' ),
372
+ 'installed' => __( 'Plugin installed!', 'astra-sites' ),
373
+ 'activating' => __( 'Activating plugin ', 'astra-sites' ),
374
+ 'activated' => __( 'Plugin activated ', 'astra-sites' ),
375
+ 'bulkActivation' => __( 'Bulk plugin activation...', 'astra-sites' ),
376
+ 'activate' => __( 'Plugin activate - ', 'astra-sites' ),
377
+ 'activationError' => __( 'Error! While activating plugin - ', 'astra-sites' ),
378
+ 'bulkInstall' => __( 'Bulk plugin installation...', 'astra-sites' ),
379
+ 'api' => __( 'Site API ', 'astra-sites' ),
380
+ 'importing' => __( 'Importing..', 'astra-sites' ),
381
+ 'processingRequest' => __( 'Processing requests...', 'astra-sites' ),
382
+ 'importCustomizer' => __( 'Importing "Customizer Settings"...', 'astra-sites' ),
383
+ 'importCustomizerSuccess' => __( 'Imported customizer settings!', 'astra-sites' ),
384
+ 'importWPForms' => __( 'Importing "Contact Forms"...', 'astra-sites' ),
385
+ 'importWPFormsSuccess' => __( 'Imported Contact Forms!', 'astra-sites' ),
386
+ 'importXMLPrepare' => __( 'Preparing "XML" Data...', 'astra-sites' ),
387
+ 'importXMLPrepareSuccess' => __( 'Set XML data!', 'astra-sites' ),
388
+ 'importXML' => __( 'Importing "XML"...', 'astra-sites' ),
389
+ 'importXMLSuccess' => __( 'Imported XML!', 'astra-sites' ),
390
+ 'importOptions' => __( 'Importing "Options"...', 'astra-sites' ),
391
+ 'importOptionsSuccess' => __( 'Imported Options!', 'astra-sites' ),
392
+ 'importWidgets' => __( 'Importing "Widgets"...', 'astra-sites' ),
393
+ 'importWidgetsSuccess' => __( 'Imported Widgets!', 'astra-sites' ),
394
+ 'serverConfiguration' => esc_url( 'https://wpastra.com/docs/?p=1314&utm_source=demo-import-panel&utm_campaign=import-error&utm_medium=wp-dashboard' ),
395
+ 'success' => __( 'View site: ', 'astra-sites' ),
396
+ 'gettingData' => __( 'Getting Site Information..', 'astra-sites' ),
397
+ 'importingCustomizer' => __( 'Importing Customizer Settings..', 'astra-sites' ),
398
+ 'importingWPForms' => __( 'Importing Contact Forms..', 'astra-sites' ),
399
+ 'importXMLPreparing' => __( 'Setting up import data..', 'astra-sites' ),
400
+ 'importingXML' => __( 'Importing Content..', 'astra-sites' ),
401
+ 'importingOptions' => __( 'Importing Site Options..', 'astra-sites' ),
402
+ 'importingWidgets' => __( 'Importing Widgets..', 'astra-sites' ),
403
+ 'importComplete' => __( 'Import Complete..', 'astra-sites' ),
404
+ 'preview' => __( 'Previewing ', 'astra-sites' ),
405
+ 'importLogText' => __( 'See Error Log &rarr;', 'astra-sites' ),
406
+ ),
407
+ )
408
+ );
409
+
410
+ wp_localize_script( 'astra-sites-admin-page', 'astraSitesAdmin', $data );
411
+
412
+ }
413
+
414
+ /**
415
+ * Load all the required files in the importer.
416
+ *
417
+ * @since 1.0.0
418
+ */
419
+ private function includes() {
420
+
421
+ require_once ASTRA_SITES_DIR . 'inc/lib/astra-notices/class-astra-notices.php';
422
+ require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-white-label.php';
423
+ require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-page.php';
424
+ require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/class-astra-sites-compatibility.php';
425
+ require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-importer.php';
426
+ }
427
+
428
+ /**
429
+ * Required Plugin Activate
430
+ *
431
+ * @since 1.0.0
432
+ */
433
+ public function required_plugin_activate() {
434
+
435
+ if ( ! current_user_can( 'install_plugins' ) || ! isset( $_POST['init'] ) || ! $_POST['init'] ) {
436
+ wp_send_json_error(
437
+ array(
438
+ 'success' => false,
439
+ 'message' => __( 'No plugin specified', 'astra-sites' ),
440
+ )
441
+ );
442
+ }
443
+
444
+ $data = array();
445
+ $plugin_init = ( isset( $_POST['init'] ) ) ? esc_attr( $_POST['init'] ) : '';
446
+ $astra_site_options = ( isset( $_POST['options'] ) ) ? json_decode( stripslashes( $_POST['options'] ) ) : '';
447
+ $enabled_extensions = ( isset( $_POST['enabledExtensions'] ) ) ? json_decode( stripslashes( $_POST['enabledExtensions'] ) ) : '';
448
+
449
+ $data['astra_site_options'] = $astra_site_options;
450
+ $data['enabled_extensions'] = $enabled_extensions;
451
+
452
+ $activate = activate_plugin( $plugin_init, '', false, true );
453
+
454
+ if ( is_wp_error( $activate ) ) {
455
+ wp_send_json_error(
456
+ array(
457
+ 'success' => false,
458
+ 'message' => $activate->get_error_message(),
459
+ )
460
+ );
461
+ }
462
+
463
+ do_action( 'astra_sites_after_plugin_activation', $plugin_init, $data );
464
+
465
+ wp_send_json_success(
466
+ array(
467
+ 'success' => true,
468
+ 'message' => __( 'Plugin Activated', 'astra-sites' ),
469
+ )
470
+ );
471
+
472
+ }
473
+
474
+ /**
475
+ * Required Plugin
476
+ *
477
+ * @since 1.0.0
478
+ * @return void
479
+ */
480
+ public function required_plugin() {
481
+
482
+ // Verify Nonce.
483
+ check_ajax_referer( 'astra-sites', '_ajax_nonce' );
484
+
485
+ $response = array(
486
+ 'active' => array(),
487
+ 'inactive' => array(),
488
+ 'notinstalled' => array(),
489
+ );
490
+
491
+ if ( ! current_user_can( 'customize' ) ) {
492
+ wp_send_json_error( $response );
493
+ }
494
+
495
+ $required_plugins = ( isset( $_POST['required_plugins'] ) ) ? $_POST['required_plugins'] : array();
496
+ $third_party_required_plugins = array();
497
+ $third_party_plugins = array(
498
+ 'learndash-course-grid' => array(
499
+ 'init' => 'learndash-course-grid/learndash_course_grid.php',
500
+ 'name' => 'LearnDash Course Grid',
501
+ ),
502
+ 'sfwd-lms' => array(
503
+ 'init' => 'sfwd-lms/sfwd_lms.php',
504
+ 'name' => 'LearnDash LMS',
505
+ ),
506
+ );
507
+
508
+ if ( count( $required_plugins ) > 0 ) {
509
+ foreach ( $required_plugins as $key => $plugin ) {
510
+
511
+ /**
512
+ * Has Pro Version Support?
513
+ * And
514
+ * Is Pro Version Installed?
515
+ */
516
+ $plugin_pro = self::pro_plugin_exist( $plugin['init'] );
517
+ if ( $plugin_pro ) {
518
+
519
+ // Pro - Active.
520
+ if ( is_plugin_active( $plugin_pro['init'] ) ) {
521
+ $response['active'][] = $plugin_pro;
522
+
523
+ // Pro - Inactive.
524
+ } else {
525
+ $response['inactive'][] = $plugin_pro;
526
+ }
527
+ } else {
528
+
529
+ // Lite - Installed but Inactive.
530
+ if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin['init'] ) && is_plugin_inactive( $plugin['init'] ) ) {
531
+
532
+ $response['inactive'][] = $plugin;
533
+
534
+ // Lite - Not Installed.
535
+ } elseif ( ! file_exists( WP_PLUGIN_DIR . '/' . $plugin['init'] ) ) {
536
+
537
+ $response['notinstalled'][] = $plugin;
538
+
539
+ // Added premium plugins which need to install first.
540
+ if ( array_key_exists( $plugin['slug'], $third_party_plugins ) ) {
541
+ $third_party_required_plugins[] = $plugin;
542
+ }
543
+
544
+ // Lite - Active.
545
+ } else {
546
+ $response['active'][] = $plugin;
547
+ }
548
+ }
549
+ }
550
+ }
551
+
552
+ // Send response.
553
+ wp_send_json_success(
554
+ array(
555
+ 'required_plugins' => $response,
556
+ 'third_party_required_plugins' => $third_party_required_plugins,
557
+ )
558
+ );
559
+ }
560
+
561
+ /**
562
+ * Has Pro Version Support?
563
+ * And
564
+ * Is Pro Version Installed?
565
+ *
566
+ * Check Pro plugin version exist of requested plugin lite version.
567
+ *
568
+ * Eg. If plugin 'BB Lite Version' required to import demo. Then we check the 'BB Agency Version' is exist?
569
+ * If yes then we only 'Activate' Agency Version. [We couldn't install agency version.]
570
+ * Else we 'Activate' or 'Install' Lite Version.
571
+ *
572
+ * @since 1.0.1
573
+ *
574
+ * @param string $lite_version Lite version init file.
575
+ * @return mixed Return false if not installed or not supported by us
576
+ * else return 'Pro' version details.
577
+ */
578
+ public static function pro_plugin_exist( $lite_version = '' ) {
579
+
580
+ // Lite init => Pro init.
581
+ $plugins = apply_filters(
582
+ 'astra_sites_pro_plugin_exist',
583
+ array(
584
+ 'beaver-builder-lite-version/fl-builder.php' => array(
585
+ 'slug' => 'bb-plugin',
586
+ 'init' => 'bb-plugin/fl-builder.php',
587
+ 'name' => 'Beaver Builder Plugin',
588
+ ),
589
+ 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' => array(
590
+ 'slug' => 'bb-ultimate-addon',
591
+ 'init' => 'bb-ultimate-addon/bb-ultimate-addon.php',
592
+ 'name' => 'Ultimate Addon for Beaver Builder',
593
+ ),
594
+ 'wpforms-lite/wpforms.php' => array(
595
+ 'slug' => 'wpforms',
596
+ 'init' => 'wpforms/wpforms.php',
597
+ 'name' => 'WPForms',
598
+ ),
599
+ ),
600
+ $lite_version
601
+ );
602
+
603
+ if ( isset( $plugins[ $lite_version ] ) ) {
604
+
605
+ // Pro plugin directory exist?
606
+ if ( file_exists( WP_PLUGIN_DIR . '/' . $plugins[ $lite_version ]['init'] ) ) {
607
+ return $plugins[ $lite_version ];
608
+ }
609
+ }
610
+
611
+ return false;
612
+ }
613
+
614
+ }
615
+
616
+ /**
617
+ * Kicking this off by calling 'get_instance()' method
618
+ */
619
+ Astra_Sites::get_instance();
620
+
621
+ endif;
inc/importers/batch-processing/class-astra-sites-batch-processing.php CHANGED
@@ -1,227 +1,249 @@
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
-
72
- // Prepare Page Builders.
73
- require_once ASTRA_SITES_DIR . 'inc/importers/batch-processing/class-astra-sites-batch-processing-beaver-builder.php';
74
- require_once ASTRA_SITES_DIR . 'inc/importers/batch-processing/class-astra-sites-batch-processing-elementor.php';
75
- require_once ASTRA_SITES_DIR . 'inc/importers/batch-processing/class-astra-sites-batch-processing-gutenberg.php';
76
- require_once ASTRA_SITES_DIR . 'inc/importers/batch-processing/class-astra-sites-batch-processing-brizy.php';
77
-
78
- // Prepare Misc.
79
- require_once ASTRA_SITES_DIR . 'inc/importers/batch-processing/class-astra-sites-batch-processing-misc.php';
80
-
81
- self::$process_all = new WP_Background_Process_Astra();
82
-
83
- // Start image importing after site import complete.
84
- add_filter( 'astra_sites_image_importer_skip_image', array( $this, 'skip_image' ), 10, 2 );
85
- add_action( 'astra_sites_import_complete', array( $this, 'start_process' ) );
86
- }
87
-
88
- /**
89
- * Skip Image from Batch Processing.
90
- *
91
- * @since 1.0.14
92
- *
93
- * @param boolean $can_process Batch process image status.
94
- * @param array $attachment Batch process image input.
95
- * @return boolean
96
- */
97
- function skip_image( $can_process, $attachment ) {
98
-
99
- if ( isset( $attachment['url'] ) && ! empty( $attachment['url'] ) ) {
100
- if (
101
- strpos( $attachment['url'], 'brainstormforce.com' ) !== false ||
102
- strpos( $attachment['url'], 'wpastra.com' ) !== false ||
103
- strpos( $attachment['url'], 'sharkz.in' ) !== false ||
104
- strpos( $attachment['url'], 'websitedemos.net' ) !== false
105
- ) {
106
- return false;
107
- }
108
- }
109
-
110
- return true;
111
- }
112
-
113
- /**
114
- * Start Image Import
115
- *
116
- * @since 1.0.14
117
- *
118
- * @return void
119
- */
120
- public function start_process() {
121
-
122
- Astra_Sites_Importer_Log::add( 'Batch Process Started!' );
123
- Astra_Sites_Importer_Log::add( Astra_Sites_White_Label::get_instance()->page_title( ASTRA_SITES_NAME ) . ' - Importing Images for Blog name \'' . get_bloginfo( 'name' ) . '\' (' . get_current_blog_id() . ')' );
124
-
125
- // Add "widget" in import [queue].
126
- if ( class_exists( 'Astra_Sites_Batch_Processing_Widgets' ) ) {
127
- self::$process_all->push_to_queue( Astra_Sites_Batch_Processing_Widgets::get_instance() );
128
- }
129
-
130
- // Add "gutenberg" in import [queue].
131
- self::$process_all->push_to_queue( Astra_Sites_Batch_Processing_Gutenberg::get_instance() );
132
-
133
- // Add "brizy" in import [queue].
134
- if ( is_plugin_active( 'brizy/brizy.php' ) ) {
135
- self::$process_all->push_to_queue( Astra_Sites_Batch_Processing_Brizy::get_instance() );
136
- }
137
-
138
- // Add "bb-plugin" in import [queue].
139
- // Add "beaver-builder-lite-version" in import [queue].
140
- if ( is_plugin_active( 'beaver-builder-lite-version/fl-builder.php' ) || is_plugin_active( 'bb-plugin/fl-builder.php' ) ) {
141
- self::$process_all->push_to_queue( Astra_Sites_Batch_Processing_Beaver_Builder::get_instance() );
142
- }
143
-
144
- // Add "elementor" in import [queue].
145
- // @todo Remove required `allow_url_fopen` support.
146
- if ( ini_get( 'allow_url_fopen' ) ) {
147
- if ( is_plugin_active( 'elementor/elementor.php' ) ) {
148
- $import = new \Elementor\TemplateLibrary\Astra_Sites_Batch_Processing_Elementor();
149
- self::$process_all->push_to_queue( $import );
150
- }
151
- } else {
152
- Astra_Sites_Importer_Log::add( 'Couldn\'t not import image due to allow_url_fopen() is disabled!' );
153
- }
154
-
155
- // Add "astra-addon" in import [queue].
156
- if ( is_plugin_active( 'astra-addon/astra-addon.php' ) ) {
157
- if ( class_exists( 'Astra_Sites_Compatibility_Astra_Pro' ) ) {
158
- self::$process_all->push_to_queue( Astra_Sites_Compatibility_Astra_Pro::get_instance() );
159
- }
160
- }
161
-
162
- // Add "misc" in import [queue].
163
- self::$process_all->push_to_queue( Astra_Sites_Batch_Processing_Misc::get_instance() );
164
-
165
- // Dispatch Queue.
166
- self::$process_all->save()->dispatch();
167
- }
168
-
169
- /**
170
- * Get all post id's
171
- *
172
- * @since 1.0.14
173
- *
174
- * @param array $post_types Post types.
175
- * @return array
176
- */
177
- public static function get_pages( $post_types = array() ) {
178
-
179
- if ( $post_types ) {
180
- $args = array(
181
- 'post_type' => $post_types,
182
-
183
- // Query performance optimization.
184
- 'fields' => 'ids',
185
- 'no_found_rows' => true,
186
- 'post_status' => 'publish',
187
- 'posts_per_page' => -1,
188
- );
189
-
190
- $query = new WP_Query( $args );
191
-
192
- // Have posts?
193
- if ( $query->have_posts() ) :
194
-
195
- return $query->posts;
196
-
197
- endif;
198
- }
199
-
200
- return null;
201
- }
202
-
203
- /**
204
- * Get Supporting Post Types..
205
- *
206
- * @since 1.3.7
207
- * @param integer $feature Feature.
208
- * @return array
209
- */
210
- public static function get_post_types_supporting( $feature ) {
211
- global $_wp_post_type_features;
212
-
213
- $post_types = array_keys(
214
- wp_filter_object_list( $_wp_post_type_features, array( $feature => true ) )
215
- );
216
-
217
- return $post_types;
218
- }
219
-
220
- }
221
-
222
- /**
223
- * Kicking this off by calling 'get_instance()' method
224
- */
225
- Astra_Sites_Batch_Processing::get_instance();
226
-
227
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
72
+ // Prepare Page Builders.
73
+ require_once ASTRA_SITES_DIR . 'inc/importers/batch-processing/class-astra-sites-batch-processing-beaver-builder.php';
74
+ require_once ASTRA_SITES_DIR . 'inc/importers/batch-processing/class-astra-sites-batch-processing-elementor.php';
75
+ require_once ASTRA_SITES_DIR . 'inc/importers/batch-processing/class-astra-sites-batch-processing-gutenberg.php';
76
+ require_once ASTRA_SITES_DIR . 'inc/importers/batch-processing/class-astra-sites-batch-processing-brizy.php';
77
+
78
+ // Prepare Misc.
79
+ require_once ASTRA_SITES_DIR . 'inc/importers/batch-processing/class-astra-sites-batch-processing-misc.php';
80
+
81
+ self::$process_all = new WP_Background_Process_Astra();
82
+
83
+ // Start image importing after site import complete.
84
+ add_filter( 'astra_sites_image_importer_skip_image', array( $this, 'skip_image' ), 10, 2 );
85
+ add_action( 'astra_sites_import_complete', array( $this, 'start_process' ) );
86
+ add_filter( 'http_request_timeout', array( $this, 'set_http_timeout' ), 10, 2 );
87
+ }
88
+
89
+ /**
90
+ * Set the timeout for the HTTP request for the images which serve from domain `websitedemos.net`.
91
+ *
92
+ * @since 1.3.10
93
+ *
94
+ * @param int $default Time in seconds until a request times out. Default 5.
95
+ * @param string $url The request URL.
96
+ */
97
+ function set_http_timeout( $default, $url ) {
98
+
99
+ if ( strpos( $url, 'websitedemos.net' ) === false ) {
100
+ return $default;
101
+ }
102
+
103
+ if ( Astra_Sites_Image_Importer::get_instance()->is_image_url( $url ) ) {
104
+ $default = 30;
105
+ }
106
+
107
+ return $default;
108
+ }
109
+
110
+ /**
111
+ * Skip Image from Batch Processing.
112
+ *
113
+ * @since 1.0.14
114
+ *
115
+ * @param boolean $can_process Batch process image status.
116
+ * @param array $attachment Batch process image input.
117
+ * @return boolean
118
+ */
119
+ function skip_image( $can_process, $attachment ) {
120
+
121
+ if ( isset( $attachment['url'] ) && ! empty( $attachment['url'] ) ) {
122
+ if (
123
+ strpos( $attachment['url'], 'brainstormforce.com' ) !== false ||
124
+ strpos( $attachment['url'], 'wpastra.com' ) !== false ||
125
+ strpos( $attachment['url'], 'sharkz.in' ) !== false ||
126
+ strpos( $attachment['url'], 'websitedemos.net' ) !== false
127
+ ) {
128
+ return false;
129
+ }
130
+ }
131
+
132
+ return true;
133
+ }
134
+
135
+ /**
136
+ * Start Image Import
137
+ *
138
+ * @since 1.0.14
139
+ *
140
+ * @return void
141
+ */
142
+ public function start_process() {
143
+
144
+ Astra_Sites_Importer_Log::add( 'Batch Process Started!' );
145
+ Astra_Sites_Importer_Log::add( Astra_Sites_White_Label::get_instance()->page_title( ASTRA_SITES_NAME ) . ' - Importing Images for Blog name \'' . get_bloginfo( 'name' ) . '\' (' . get_current_blog_id() . ')' );
146
+
147
+ // Add "widget" in import [queue].
148
+ if ( class_exists( 'Astra_Sites_Batch_Processing_Widgets' ) ) {
149
+ self::$process_all->push_to_queue( Astra_Sites_Batch_Processing_Widgets::get_instance() );
150
+ }
151
+
152
+ // Add "gutenberg" in import [queue].
153
+ self::$process_all->push_to_queue( Astra_Sites_Batch_Processing_Gutenberg::get_instance() );
154
+
155
+ // Add "brizy" in import [queue].
156
+ if ( is_plugin_active( 'brizy/brizy.php' ) ) {
157
+ self::$process_all->push_to_queue( Astra_Sites_Batch_Processing_Brizy::get_instance() );
158
+ }
159
+
160
+ // Add "bb-plugin" in import [queue].
161
+ // Add "beaver-builder-lite-version" in import [queue].
162
+ if ( is_plugin_active( 'beaver-builder-lite-version/fl-builder.php' ) || is_plugin_active( 'bb-plugin/fl-builder.php' ) ) {
163
+ self::$process_all->push_to_queue( Astra_Sites_Batch_Processing_Beaver_Builder::get_instance() );
164
+ }
165
+
166
+ // Add "elementor" in import [queue].
167
+ // @todo Remove required `allow_url_fopen` support.
168
+ if ( ini_get( 'allow_url_fopen' ) ) {
169
+ if ( is_plugin_active( 'elementor/elementor.php' ) ) {
170
+ $import = new \Elementor\TemplateLibrary\Astra_Sites_Batch_Processing_Elementor();
171
+ self::$process_all->push_to_queue( $import );
172
+ }
173
+ } else {
174
+ Astra_Sites_Importer_Log::add( 'Couldn\'t not import image due to allow_url_fopen() is disabled!' );
175
+ }
176
+
177
+ // Add "astra-addon" in import [queue].
178
+ if ( is_plugin_active( 'astra-addon/astra-addon.php' ) ) {
179
+ if ( class_exists( 'Astra_Sites_Compatibility_Astra_Pro' ) ) {
180
+ self::$process_all->push_to_queue( Astra_Sites_Compatibility_Astra_Pro::get_instance() );
181
+ }
182
+ }
183
+
184
+ // Add "misc" in import [queue].
185
+ self::$process_all->push_to_queue( Astra_Sites_Batch_Processing_Misc::get_instance() );
186
+
187
+ // Dispatch Queue.
188
+ self::$process_all->save()->dispatch();
189
+ }
190
+
191
+ /**
192
+ * Get all post id's
193
+ *
194
+ * @since 1.0.14
195
+ *
196
+ * @param array $post_types Post types.
197
+ * @return array
198
+ */
199
+ public static function get_pages( $post_types = array() ) {
200
+
201
+ if ( $post_types ) {
202
+ $args = array(
203
+ 'post_type' => $post_types,
204
+
205
+ // Query performance optimization.
206
+ 'fields' => 'ids',
207
+ 'no_found_rows' => true,
208
+ 'post_status' => 'publish',
209
+ 'posts_per_page' => -1,
210
+ );
211
+
212
+ $query = new WP_Query( $args );
213
+
214
+ // Have posts?
215
+ if ( $query->have_posts() ) :
216
+
217
+ return $query->posts;
218
+
219
+ endif;
220
+ }
221
+
222
+ return null;
223
+ }
224
+
225
+ /**
226
+ * Get Supporting Post Types..
227
+ *
228
+ * @since 1.3.7
229
+ * @param integer $feature Feature.
230
+ * @return array
231
+ */
232
+ public static function get_post_types_supporting( $feature ) {
233
+ global $_wp_post_type_features;
234
+
235
+ $post_types = array_keys(
236
+ wp_filter_object_list( $_wp_post_type_features, array( $feature => true ) )
237
+ );
238
+
239
+ return $post_types;
240
+ }
241
+
242
+ }
243
+
244
+ /**
245
+ * Kicking this off by calling 'get_instance()' method
246
+ */
247
+ Astra_Sites_Batch_Processing::get_instance();
248
+
249
+ endif;
inc/importers/batch-processing/helpers/class-astra-sites-image-importer.php CHANGED
@@ -1,243 +1,263 @@
1
- <?php
2
- /**
3
- * Image Importer
4
- *
5
- * => How to use?
6
- *
7
- * $image = array(
8
- * 'url' => '<image-url>',
9
- * 'id' => '<image-id>',
10
- * );
11
- *
12
- * $downloaded_image = Astra_Sites_Image_Importer::get_instance()->import( $image );
13
- *
14
- * @package Astra Sites
15
- * @since 1.0.14
16
- */
17
-
18
- if ( ! class_exists( 'Astra_Sites_Image_Importer' ) ) :
19
-
20
- /**
21
- * Astra Sites Image Importer
22
- *
23
- * @since 1.0.14
24
- */
25
- class Astra_Sites_Image_Importer {
26
-
27
- /**
28
- * Instance
29
- *
30
- * @since 1.0.14
31
- * @var object Class object.
32
- * @access private
33
- */
34
- private static $instance;
35
-
36
- /**
37
- * Images IDs
38
- *
39
- * @var array The Array of already image IDs.
40
- * @since 1.0.14
41
- */
42
- private $already_imported_ids = array();
43
-
44
- /**
45
- * Initiator
46
- *
47
- * @since 1.0.14
48
- * @return object initialized object of class.
49
- */
50
- public static function get_instance() {
51
- if ( ! isset( self::$instance ) ) {
52
- self::$instance = new self;
53
- }
54
- return self::$instance;
55
- }
56
-
57
- /**
58
- * Constructor
59
- *
60
- * @since 1.0.14
61
- */
62
- public function __construct() {
63
-
64
- if ( ! function_exists( 'WP_Filesystem' ) ) {
65
- require_once ABSPATH . 'wp-admin/includes/file.php';
66
- }
67
-
68
- WP_Filesystem();
69
- }
70
-
71
- /**
72
- * Process Image Download
73
- *
74
- * @since 1.0.14
75
- * @param array $attachments Attachment array.
76
- * @return array Attachment array.
77
- */
78
- public function process( $attachments ) {
79
-
80
- $downloaded_images = array();
81
-
82
- foreach ( $attachments as $key => $attachment ) {
83
- $downloaded_images[] = $this->import( $attachment );
84
- }
85
-
86
- return $downloaded_images;
87
- }
88
-
89
- /**
90
- * Get Hash Image.
91
- *
92
- * @since 1.0.14
93
- * @param string $attachment_url Attachment URL.
94
- * @return string Hash string.
95
- */
96
- private function get_hash_image( $attachment_url ) {
97
- return sha1( $attachment_url );
98
- }
99
-
100
- /**
101
- * Get Saved Image.
102
- *
103
- * @since 1.0.14
104
- * @param string $attachment Attachment Data.
105
- * @return string Hash string.
106
- */
107
- private function get_saved_image( $attachment ) {
108
-
109
- if ( apply_filters( 'astra_sites_image_importer_skip_image', false, $attachment ) ) {
110
- Astra_Sites_Importer_Log::add( 'BATCH - SKIP Image - {from filter} - ' . $attachment['url'] . ' - Filter name `astra_sites_image_importer_skip_image`.' );
111
- return $attachment;
112
- }
113
-
114
- global $wpdb;
115
-
116
- // Already imported? Then return!
117
- if ( isset( $this->already_imported_ids[ $attachment['id'] ] ) ) {
118
- Astra_Sites_Importer_Log::add( 'BATCH - SKIP Image {already imported from batch process} - ' . $attachment['url'] . ' - already imported.' );
119
- return $this->already_imported_ids[ $attachment['id'] ];
120
- }
121
-
122
- // 1. Is already imported in Batch Import Process?
123
- $post_id = $wpdb->get_var(
124
- $wpdb->prepare(
125
- 'SELECT `post_id` FROM `' . $wpdb->postmeta . '`
126
- WHERE `meta_key` = \'_astra_sites_image_hash\'
127
- AND `meta_value` = %s
128
- ;',
129
- $this->get_hash_image( $attachment['url'] )
130
- )
131
- );
132
-
133
- // 2. Is image already imported though XML?
134
- if ( empty( $post_id ) ) {
135
-
136
- // Get file name without extension.
137
- // To check it exist in attachment.
138
- $filename = basename( $attachment['url'] );
139
-
140
- $post_id = $wpdb->get_var(
141
- $wpdb->prepare(
142
- "SELECT post_id FROM {$wpdb->postmeta}
143
- WHERE meta_key = '_wp_attached_file'
144
- AND meta_value LIKE %s",
145
- '%' . $filename . '%'
146
- )
147
- );
148
-
149
- Astra_Sites_Importer_Log::add( 'BATCH - SKIP Image {already imported from xml} - ' . $attachment['url'] );
150
- }
151
-
152
- if ( $post_id ) {
153
- $new_attachment = array(
154
- 'id' => $post_id,
155
- 'url' => wp_get_attachment_url( $post_id ),
156
- );
157
- $this->already_imported_ids[ $attachment['id'] ] = $new_attachment;
158
-
159
- return $new_attachment;
160
- }
161
-
162
- return false;
163
- }
164
-
165
- /**
166
- * Import Image
167
- *
168
- * @since 1.0.14
169
- * @param array $attachment Attachment array.
170
- * @return array Attachment array.
171
- */
172
- public function import( $attachment ) {
173
-
174
- $saved_image = $this->get_saved_image( $attachment );
175
- if ( $saved_image ) {
176
- return $saved_image;
177
- }
178
-
179
- $file_content = wp_remote_retrieve_body(
180
- wp_safe_remote_get(
181
- $attachment['url'],
182
- array(
183
- 'timeout' => '60',
184
- 'sslverify' => false,
185
- )
186
- )
187
- );
188
-
189
- // Empty file content?
190
- if ( empty( $file_content ) ) {
191
- Astra_Sites_Importer_Log::add( 'BATCH - FAIL Image {Error: Failed wp_remote_retrieve_body} - ' . $attachment['url'] );
192
- return $attachment;
193
- }
194
-
195
- // Extract the file name and extension from the URL.
196
- $filename = basename( $attachment['url'] );
197
-
198
- $upload = wp_upload_bits(
199
- $filename,
200
- null,
201
- $file_content
202
- );
203
-
204
- $post = array(
205
- 'post_title' => $filename,
206
- 'guid' => $upload['url'],
207
- );
208
-
209
- $info = wp_check_filetype( $upload['file'] );
210
- if ( $info ) {
211
- $post['post_mime_type'] = $info['type'];
212
- } else {
213
- // For now just return the origin attachment.
214
- return $attachment;
215
- }
216
-
217
- $post_id = wp_insert_attachment( $post, $upload['file'] );
218
- wp_update_attachment_metadata(
219
- $post_id,
220
- wp_generate_attachment_metadata( $post_id, $upload['file'] )
221
- );
222
- update_post_meta( $post_id, '_astra_sites_image_hash', $this->get_hash_image( $attachment['url'] ) );
223
-
224
- $new_attachment = array(
225
- 'id' => $post_id,
226
- 'url' => $upload['url'],
227
- );
228
-
229
- Astra_Sites_Importer_Log::add( 'BATCH - SUCCESS Image {Imported} - ' . $new_attachment['url'] );
230
-
231
- $this->already_imported_ids[ $attachment['id'] ] = $new_attachment;
232
-
233
- return $new_attachment;
234
- }
235
-
236
- }
237
-
238
- /**
239
- * Kicking this off by calling 'get_instance()' method
240
- */
241
- Astra_Sites_Image_Importer::get_instance();
242
-
243
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Image Importer
4
+ *
5
+ * => How to use?
6
+ *
7
+ * $image = array(
8
+ * 'url' => '<image-url>',
9
+ * 'id' => '<image-id>',
10
+ * );
11
+ *
12
+ * $downloaded_image = Astra_Sites_Image_Importer::get_instance()->import( $image );
13
+ *
14
+ * @package Astra Sites
15
+ * @since 1.0.14
16
+ */
17
+
18
+ if ( ! class_exists( 'Astra_Sites_Image_Importer' ) ) :
19
+
20
+ /**
21
+ * Astra Sites Image Importer
22
+ *
23
+ * @since 1.0.14
24
+ */
25
+ class Astra_Sites_Image_Importer {
26
+
27
+ /**
28
+ * Instance
29
+ *
30
+ * @since 1.0.14
31
+ * @var object Class object.
32
+ * @access private
33
+ */
34
+ private static $instance;
35
+
36
+ /**
37
+ * Images IDs
38
+ *
39
+ * @var array The Array of already image IDs.
40
+ * @since 1.0.14
41
+ */
42
+ private $already_imported_ids = array();
43
+
44
+ /**
45
+ * Initiator
46
+ *
47
+ * @since 1.0.14
48
+ * @return object initialized object of class.
49
+ */
50
+ public static function get_instance() {
51
+ if ( ! isset( self::$instance ) ) {
52
+ self::$instance = new self;
53
+ }
54
+ return self::$instance;
55
+ }
56
+
57
+ /**
58
+ * Constructor
59
+ *
60
+ * @since 1.0.14
61
+ */
62
+ public function __construct() {
63
+
64
+ if ( ! function_exists( 'WP_Filesystem' ) ) {
65
+ require_once ABSPATH . 'wp-admin/includes/file.php';
66
+ }
67
+
68
+ WP_Filesystem();
69
+ }
70
+
71
+ /**
72
+ * Process Image Download
73
+ *
74
+ * @since 1.0.14
75
+ * @param array $attachments Attachment array.
76
+ * @return array Attachment array.
77
+ */
78
+ public function process( $attachments ) {
79
+
80
+ $downloaded_images = array();
81
+
82
+ foreach ( $attachments as $key => $attachment ) {
83
+ $downloaded_images[] = $this->import( $attachment );
84
+ }
85
+
86
+ return $downloaded_images;
87
+ }
88
+
89
+ /**
90
+ * Get Hash Image.
91
+ *
92
+ * @since 1.0.14
93
+ * @param string $attachment_url Attachment URL.
94
+ * @return string Hash string.
95
+ */
96
+ private function get_hash_image( $attachment_url ) {
97
+ return sha1( $attachment_url );
98
+ }
99
+
100
+ /**
101
+ * Get Saved Image.
102
+ *
103
+ * @since 1.0.14
104
+ * @param string $attachment Attachment Data.
105
+ * @return string Hash string.
106
+ */
107
+ private function get_saved_image( $attachment ) {
108
+
109
+ if ( apply_filters( 'astra_sites_image_importer_skip_image', false, $attachment ) ) {
110
+ Astra_Sites_Importer_Log::add( 'BATCH - SKIP Image - {from filter} - ' . $attachment['url'] . ' - Filter name `astra_sites_image_importer_skip_image`.' );
111
+ return $attachment;
112
+ }
113
+
114
+ global $wpdb;
115
+
116
+ // Already imported? Then return!
117
+ if ( isset( $this->already_imported_ids[ $attachment['id'] ] ) ) {
118
+ Astra_Sites_Importer_Log::add( 'BATCH - SKIP Image {already imported from batch process} - ' . $attachment['url'] . ' - already imported.' );
119
+ return $this->already_imported_ids[ $attachment['id'] ];
120
+ }
121
+
122
+ // 1. Is already imported in Batch Import Process?
123
+ $post_id = $wpdb->get_var(
124
+ $wpdb->prepare(
125
+ 'SELECT `post_id` FROM `' . $wpdb->postmeta . '`
126
+ WHERE `meta_key` = \'_astra_sites_image_hash\'
127
+ AND `meta_value` = %s
128
+ ;',
129
+ $this->get_hash_image( $attachment['url'] )
130
+ )
131
+ );
132
+
133
+ // 2. Is image already imported though XML?
134
+ if ( empty( $post_id ) ) {
135
+
136
+ // Get file name without extension.
137
+ // To check it exist in attachment.
138
+ $filename = basename( $attachment['url'] );
139
+
140
+ $post_id = $wpdb->get_var(
141
+ $wpdb->prepare(
142
+ "SELECT post_id FROM {$wpdb->postmeta}
143
+ WHERE meta_key = '_wp_attached_file'
144
+ AND meta_value LIKE %s",
145
+ '%' . $filename . '%'
146
+ )
147
+ );
148
+
149
+ Astra_Sites_Importer_Log::add( 'BATCH - SKIP Image {already imported from xml} - ' . $attachment['url'] );
150
+ }
151
+
152
+ if ( $post_id ) {
153
+ $new_attachment = array(
154
+ 'id' => $post_id,
155
+ 'url' => wp_get_attachment_url( $post_id ),
156
+ );
157
+ $this->already_imported_ids[ $attachment['id'] ] = $new_attachment;
158
+
159
+ return $new_attachment;
160
+ }
161
+
162
+ return false;
163
+ }
164
+
165
+ /**
166
+ * Import Image
167
+ *
168
+ * @since 1.0.14
169
+ * @param array $attachment Attachment array.
170
+ * @return array Attachment array.
171
+ */
172
+ public function import( $attachment ) {
173
+
174
+ $saved_image = $this->get_saved_image( $attachment );
175
+ if ( $saved_image ) {
176
+ return $saved_image;
177
+ }
178
+
179
+ $file_content = wp_remote_retrieve_body(
180
+ wp_safe_remote_get(
181
+ $attachment['url'],
182
+ array(
183
+ 'timeout' => '60',
184
+ 'sslverify' => false,
185
+ )
186
+ )
187
+ );
188
+
189
+ // Empty file content?
190
+ if ( empty( $file_content ) ) {
191
+ Astra_Sites_Importer_Log::add( 'BATCH - FAIL Image {Error: Failed wp_remote_retrieve_body} - ' . $attachment['url'] );
192
+ return $attachment;
193
+ }
194
+
195
+ // Extract the file name and extension from the URL.
196
+ $filename = basename( $attachment['url'] );
197
+
198
+ $upload = wp_upload_bits(
199
+ $filename,
200
+ null,
201
+ $file_content
202
+ );
203
+
204
+ $post = array(
205
+ 'post_title' => $filename,
206
+ 'guid' => $upload['url'],
207
+ );
208
+
209
+ $info = wp_check_filetype( $upload['file'] );
210
+ if ( $info ) {
211
+ $post['post_mime_type'] = $info['type'];
212
+ } else {
213
+ // For now just return the origin attachment.
214
+ return $attachment;
215
+ }
216
+
217
+ $post_id = wp_insert_attachment( $post, $upload['file'] );
218
+ wp_update_attachment_metadata(
219
+ $post_id,
220
+ wp_generate_attachment_metadata( $post_id, $upload['file'] )
221
+ );
222
+ update_post_meta( $post_id, '_astra_sites_image_hash', $this->get_hash_image( $attachment['url'] ) );
223
+
224
+ $new_attachment = array(
225
+ 'id' => $post_id,
226
+ 'url' => $upload['url'],
227
+ );
228
+
229
+ Astra_Sites_Importer_Log::add( 'BATCH - SUCCESS Image {Imported} - ' . $new_attachment['url'] );
230
+
231
+ $this->already_imported_ids[ $attachment['id'] ] = $new_attachment;
232
+
233
+ return $new_attachment;
234
+ }
235
+
236
+ /**
237
+ * Is Image URL
238
+ *
239
+ * @since 1.3.10
240
+ *
241
+ * @param string $url URL.
242
+ * @return boolean
243
+ */
244
+ function is_image_url( $url = '' ) {
245
+ if ( empty( $url ) ) {
246
+ return false;
247
+ }
248
+
249
+ if ( preg_match( '/^((https?:\/\/)|(www\.))([a-z0-9-].?)+(:[0-9]+)?\/[\w\-]+\.(jpg|png|svg|gif|jpeg)\/?$/i', $url ) ) {
250
+ return true;
251
+ }
252
+
253
+ return false;
254
+ }
255
+
256
+ }
257
+
258
+ /**
259
+ * Kicking this off by calling 'get_instance()' method
260
+ */
261
+ Astra_Sites_Image_Importer::get_instance();
262
+
263
+ endif;
inc/importers/class-astra-sites-helper.php CHANGED
@@ -1,311 +1,311 @@
1
- <?php
2
- /**
3
- * Astra Site Helper
4
- *
5
- * @since 1.0.0
6
- * @package Astra Sites
7
- */
8
-
9
- if ( ! class_exists( 'Astra_Sites_Helper' ) ) :
10
-
11
- /**
12
- * Astra_Sites_Helper
13
- *
14
- * @since 1.0.0
15
- */
16
- class Astra_Sites_Helper {
17
-
18
- /**
19
- * Instance
20
- *
21
- * @access private
22
- * @var object Instance
23
- * @since 1.0.0
24
- */
25
- private static $instance;
26
-
27
- /**
28
- * Initiator
29
- *
30
- * @since 1.0.0
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.0
44
- */
45
- public function __construct() {
46
- add_filter( 'wie_import_data', array( $this, 'custom_menu_widget' ) );
47
- add_filter( 'wp_prepare_attachment_for_js', array( $this, 'add_svg_image_support' ), 10, 3 );
48
- }
49
-
50
- /**
51
- * Add svg image support
52
- *
53
- * @since 1.1.5
54
- *
55
- * @param array $response Attachment response.
56
- * @param object $attachment Attachment object.
57
- * @param array $meta Attachment meta data.
58
- */
59
- function add_svg_image_support( $response, $attachment, $meta ) {
60
- if ( ! function_exists( 'simplexml_load_file' ) ) {
61
- return $response;
62
- }
63
-
64
- if ( ! empty( $response['sizes'] ) ) {
65
- return $response;
66
- }
67
-
68
- if ( 'image/svg+xml' !== $response['mime'] ) {
69
- return $response;
70
- }
71
-
72
- $svg_path = get_attached_file( $attachment->ID );
73
-
74
- $dimensions = self::get_svg_dimensions( $svg_path );
75
-
76
- $response['sizes'] = array(
77
- 'full' => array(
78
- 'url' => $response['url'],
79
- 'width' => $dimensions->width,
80
- 'height' => $dimensions->height,
81
- 'orientation' => $dimensions->width > $dimensions->height ? 'landscape' : 'portrait',
82
- ),
83
- );
84
-
85
- return $response;
86
- }
87
-
88
- /**
89
- * Get SVG Dimensions
90
- *
91
- * @since 1.1.5
92
- *
93
- * @param string $svg SVG file path.
94
- * @return array Return SVG file height & width for valid SVG file.
95
- */
96
- public static function get_svg_dimensions( $svg ) {
97
-
98
- $svg = simplexml_load_file( $svg );
99
-
100
- if ( false === $svg ) {
101
- $width = '0';
102
- $height = '0';
103
- } else {
104
- $attributes = $svg->attributes();
105
- $width = (string) $attributes->width;
106
- $height = (string) $attributes->height;
107
- }
108
-
109
- return (object) array(
110
- 'width' => $width,
111
- 'height' => $height,
112
- );
113
- }
114
-
115
- /**
116
- * Custom Menu Widget
117
- *
118
- * In widget export we set the nav menu slug instead of ID.
119
- * So, In import process we check get menu id by slug and set
120
- * it in import widget process.
121
- *
122
- * @since 1.0.7
123
- *
124
- * @param object $all_sidebars Widget data.
125
- * @return object Set custom menu id by slug.
126
- */
127
- function custom_menu_widget( $all_sidebars ) {
128
-
129
- // Get current menu ID & Slugs.
130
- $menu_locations = array();
131
- $nav_menus = (object) wp_get_nav_menus();
132
- if ( isset( $nav_menus ) ) {
133
- foreach ( $nav_menus as $menu_key => $menu ) {
134
- if ( is_object( $menu ) ) {
135
- $menu_locations[ $menu->term_id ] = $menu->slug;
136
- }
137
- }
138
- }
139
-
140
- // Import widget data.
141
- $all_sidebars = (object) $all_sidebars;
142
- foreach ( $all_sidebars as $widgets_key => $widgets ) {
143
- foreach ( $widgets as $widget_key => $widget ) {
144
-
145
- // Found slug in current menu list.
146
- if ( isset( $widget->nav_menu ) ) {
147
- $menu_id = array_search( $widget->nav_menu, $menu_locations, true );
148
- if ( ! empty( $menu_id ) ) {
149
- $all_sidebars->$widgets_key->$widget_key->nav_menu = $menu_id;
150
- }
151
- }
152
- }
153
- }
154
-
155
- return $all_sidebars;
156
- }
157
-
158
- /**
159
- * Download File Into Uploads Directory
160
- *
161
- * @param string $file Download File URL.
162
- * @return array Downloaded file data.
163
- */
164
- public static function download_file( $file = '' ) {
165
-
166
- // Gives us access to the download_url() and wp_handle_sideload() functions.
167
- require_once( ABSPATH . 'wp-admin/includes/file.php' );
168
-
169
- $timeout_seconds = 5;
170
-
171
- // Download file to temp dir.
172
- $temp_file = download_url( $file, $timeout_seconds );
173
-
174
- // WP Error.
175
- if ( is_wp_error( $temp_file ) ) {
176
- return array(
177
- 'success' => false,
178
- 'data' => $temp_file->get_error_message(),
179
- );
180
- }
181
-
182
- // Array based on $_FILE as seen in PHP file uploads.
183
- $file_args = array(
184
- 'name' => basename( $file ),
185
- 'tmp_name' => $temp_file,
186
- 'error' => 0,
187
- 'size' => filesize( $temp_file ),
188
- );
189
-
190
- $overrides = array(
191
-
192
- // Tells WordPress to not look for the POST form
193
- // fields that would normally be present as
194
- // we downloaded the file from a remote server, so there
195
- // will be no form fields
196
- // Default is true.
197
- 'test_form' => false,
198
-
199
- // Setting this to false lets WordPress allow empty files, not recommended.
200
- // Default is true.
201
- 'test_size' => true,
202
-
203
- // A properly uploaded file will pass this test. There should be no reason to override this one.
204
- 'test_upload' => true,
205
-
206
- 'mimes' => array(
207
- 'xml' => 'text/xml',
208
- 'json' => 'text/plain',
209
- ),
210
- );
211
-
212
- // Move the temporary file into the uploads directory.
213
- $results = wp_handle_sideload( $file_args, $overrides );
214
-
215
- if ( isset( $results['error'] ) ) {
216
- return array(
217
- 'success' => false,
218
- 'data' => $results,
219
- );
220
- }
221
-
222
- // Success.
223
- return array(
224
- 'success' => true,
225
- 'data' => $results,
226
- );
227
- }
228
-
229
- /**
230
- * Downloads an image from the specified URL.
231
- *
232
- * Taken from the core media_sideload_image() function and
233
- * modified to return an array of data instead of html.
234
- *
235
- * @since 1.0.10
236
- *
237
- * @param string $file The image file path.
238
- * @return array An array of image data.
239
- */
240
- static public function _sideload_image( $file ) {
241
- $data = new stdClass();
242
-
243
- if ( ! function_exists( 'media_handle_sideload' ) ) {
244
- require_once( ABSPATH . 'wp-admin/includes/media.php' );
245
- require_once( ABSPATH . 'wp-admin/includes/file.php' );
246
- require_once( ABSPATH . 'wp-admin/includes/image.php' );
247
- }
248
-
249
- if ( ! empty( $file ) ) {
250
-
251
- // Set variables for storage, fix file filename for query strings.
252
- preg_match( '/[^\?]+\.(jpe?g|jpe|svg|gif|png)\b/i', $file, $matches );
253
- $file_array = array();
254
- $file_array['name'] = basename( $matches[0] );
255
-
256
- // Download file to temp location.
257
- $file_array['tmp_name'] = download_url( $file );
258
-
259
- // If error storing temporarily, return the error.
260
- if ( is_wp_error( $file_array['tmp_name'] ) ) {
261
- return $file_array['tmp_name'];
262
- }
263
-
264
- // Do the validation and storage stuff.
265
- $id = media_handle_sideload( $file_array, 0 );
266
-
267
- // If error storing permanently, unlink.
268
- if ( is_wp_error( $id ) ) {
269
- unlink( $file_array['tmp_name'] );
270
- return $id;
271
- }
272
-
273
- // Build the object to return.
274
- $meta = wp_get_attachment_metadata( $id );
275
- $data->attachment_id = $id;
276
- $data->url = wp_get_attachment_url( $id );
277
- $data->thumbnail_url = wp_get_attachment_thumb_url( $id );
278
- $data->height = $meta['height'];
279
- $data->width = $meta['width'];
280
- }
281
-
282
- return $data;
283
- }
284
-
285
- /**
286
- * Checks to see whether a string is an image url or not.
287
- *
288
- * @since 1.0.10
289
- *
290
- * @param string $string The string to check.
291
- * @return bool Whether the string is an image url or not.
292
- */
293
- static public function _is_image_url( $string = '' ) {
294
- if ( is_string( $string ) ) {
295
-
296
- if ( preg_match( '/\.(jpg|jpeg|png|gif)/i', $string ) ) {
297
- return true;
298
- }
299
- }
300
-
301
- return false;
302
- }
303
-
304
- }
305
-
306
- /**
307
- * Kicking this off by calling 'get_instance()' method
308
- */
309
- Astra_Sites_Helper::get_instance();
310
-
311
- endif;
1
+ <?php
2
+ /**
3
+ * Astra Site Helper
4
+ *
5
+ * @since 1.0.0
6
+ * @package Astra Sites
7
+ */
8
+
9
+ if ( ! class_exists( 'Astra_Sites_Helper' ) ) :
10
+
11
+ /**
12
+ * Astra_Sites_Helper
13
+ *
14
+ * @since 1.0.0
15
+ */
16
+ class Astra_Sites_Helper {
17
+
18
+ /**
19
+ * Instance
20
+ *
21
+ * @access private
22
+ * @var object Instance
23
+ * @since 1.0.0
24
+ */
25
+ private static $instance;
26
+
27
+ /**
28
+ * Initiator
29
+ *
30
+ * @since 1.0.0
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.0
44
+ */
45
+ public function __construct() {
46
+ add_filter( 'wie_import_data', array( $this, 'custom_menu_widget' ) );
47
+ add_filter( 'wp_prepare_attachment_for_js', array( $this, 'add_svg_image_support' ), 10, 3 );
48
+ }
49
+
50
+ /**
51
+ * Add svg image support
52
+ *
53
+ * @since 1.1.5
54
+ *
55
+ * @param array $response Attachment response.
56
+ * @param object $attachment Attachment object.
57
+ * @param array $meta Attachment meta data.
58
+ */
59
+ function add_svg_image_support( $response, $attachment, $meta ) {
60
+ if ( ! function_exists( 'simplexml_load_file' ) ) {
61
+ return $response;
62
+ }
63
+
64
+ if ( ! empty( $response['sizes'] ) ) {
65
+ return $response;
66
+ }
67
+
68
+ if ( 'image/svg+xml' !== $response['mime'] ) {
69
+ return $response;
70
+ }
71
+
72
+ $svg_path = get_attached_file( $attachment->ID );
73
+
74
+ $dimensions = self::get_svg_dimensions( $svg_path );
75
+
76
+ $response['sizes'] = array(
77
+ 'full' => array(
78
+ 'url' => $response['url'],
79
+ 'width' => $dimensions->width,
80
+ 'height' => $dimensions->height,
81
+ 'orientation' => $dimensions->width > $dimensions->height ? 'landscape' : 'portrait',
82
+ ),
83
+ );
84
+
85
+ return $response;
86
+ }
87
+
88
+ /**
89
+ * Get SVG Dimensions
90
+ *
91
+ * @since 1.1.5
92
+ *
93
+ * @param string $svg SVG file path.
94
+ * @return array Return SVG file height & width for valid SVG file.
95
+ */
96
+ public static function get_svg_dimensions( $svg ) {
97
+
98
+ $svg = simplexml_load_file( $svg );
99
+
100
+ if ( false === $svg ) {
101
+ $width = '0';
102
+ $height = '0';
103
+ } else {
104
+ $attributes = $svg->attributes();
105
+ $width = (string) $attributes->width;
106
+ $height = (string) $attributes->height;
107
+ }
108
+
109
+ return (object) array(
110
+ 'width' => $width,
111
+ 'height' => $height,
112
+ );
113
+ }
114
+
115
+ /**
116
+ * Custom Menu Widget
117
+ *
118
+ * In widget export we set the nav menu slug instead of ID.
119
+ * So, In import process we check get menu id by slug and set
120
+ * it in import widget process.
121
+ *
122
+ * @since 1.0.7
123
+ *
124
+ * @param object $all_sidebars Widget data.
125
+ * @return object Set custom menu id by slug.
126
+ */
127
+ function custom_menu_widget( $all_sidebars ) {
128
+
129
+ // Get current menu ID & Slugs.
130
+ $menu_locations = array();
131
+ $nav_menus = (object) wp_get_nav_menus();
132
+ if ( isset( $nav_menus ) ) {
133
+ foreach ( $nav_menus as $menu_key => $menu ) {
134
+ if ( is_object( $menu ) ) {
135
+ $menu_locations[ $menu->term_id ] = $menu->slug;
136
+ }
137
+ }
138
+ }
139
+
140
+ // Import widget data.
141
+ $all_sidebars = (object) $all_sidebars;
142
+ foreach ( $all_sidebars as $widgets_key => $widgets ) {
143
+ foreach ( $widgets as $widget_key => $widget ) {
144
+
145
+ // Found slug in current menu list.
146
+ if ( isset( $widget->nav_menu ) ) {
147
+ $menu_id = array_search( $widget->nav_menu, $menu_locations, true );
148
+ if ( ! empty( $menu_id ) ) {
149
+ $all_sidebars->$widgets_key->$widget_key->nav_menu = $menu_id;
150
+ }
151
+ }
152
+ }
153
+ }
154
+
155
+ return $all_sidebars;
156
+ }
157
+
158
+ /**
159
+ * Download File Into Uploads Directory
160
+ *
161
+ * @param string $file Download File URL.
162
+ * @return array Downloaded file data.
163
+ */
164
+ public static function download_file( $file = '' ) {
165
+
166
+ // Gives us access to the download_url() and wp_handle_sideload() functions.
167
+ require_once( ABSPATH . 'wp-admin/includes/file.php' );
168
+
169
+ $timeout_seconds = 5;
170
+
171
+ // Download file to temp dir.
172
+ $temp_file = download_url( $file, $timeout_seconds );
173
+
174
+ // WP Error.
175
+ if ( is_wp_error( $temp_file ) ) {
176
+ return array(
177
+ 'success' => false,
178
+ 'data' => $temp_file->get_error_message(),
179
+ );
180
+ }
181
+
182
+ // Array based on $_FILE as seen in PHP file uploads.
183
+ $file_args = array(
184
+ 'name' => basename( $file ),
185
+ 'tmp_name' => $temp_file,
186
+ 'error' => 0,
187
+ 'size' => filesize( $temp_file ),
188
+ );
189
+
190
+ $overrides = array(
191
+
192
+ // Tells WordPress to not look for the POST form
193
+ // fields that would normally be present as
194
+ // we downloaded the file from a remote server, so there
195
+ // will be no form fields
196
+ // Default is true.
197
+ 'test_form' => false,
198
+
199
+ // Setting this to false lets WordPress allow empty files, not recommended.
200
+ // Default is true.
201
+ 'test_size' => true,
202
+
203
+ // A properly uploaded file will pass this test. There should be no reason to override this one.
204
+ 'test_upload' => true,
205
+
206
+ 'mimes' => array(
207
+ 'xml' => 'text/xml',
208
+ 'json' => 'text/plain',
209
+ ),
210
+ );
211
+
212
+ // Move the temporary file into the uploads directory.
213
+ $results = wp_handle_sideload( $file_args, $overrides );
214
+
215
+ if ( isset( $results['error'] ) ) {
216
+ return array(
217
+ 'success' => false,
218
+ 'data' => $results,
219
+ );
220
+ }
221
+
222
+ // Success.
223
+ return array(
224
+ 'success' => true,
225
+ 'data' => $results,
226
+ );
227
+ }
228
+
229
+ /**
230
+ * Downloads an image from the specified URL.
231
+ *
232
+ * Taken from the core media_sideload_image() function and
233
+ * modified to return an array of data instead of html.
234
+ *
235
+ * @since 1.0.10
236
+ *
237
+ * @param string $file The image file path.
238
+ * @return array An array of image data.
239
+ */
240
+ static public function _sideload_image( $file ) {
241
+ $data = new stdClass();
242
+
243
+ if ( ! function_exists( 'media_handle_sideload' ) ) {
244
+ require_once( ABSPATH . 'wp-admin/includes/media.php' );
245
+ require_once( ABSPATH . 'wp-admin/includes/file.php' );
246
+ require_once( ABSPATH . 'wp-admin/includes/image.php' );
247
+ }
248
+
249
+ if ( ! empty( $file ) ) {
250
+
251
+ // Set variables for storage, fix file filename for query strings.
252
+ preg_match( '/[^\?]+\.(jpe?g|jpe|svg|gif|png)\b/i', $file, $matches );
253
+ $file_array = array();
254
+ $file_array['name'] = basename( $matches[0] );
255
+
256
+ // Download file to temp location.
257
+ $file_array['tmp_name'] = download_url( $file );
258
+
259
+ // If error storing temporarily, return the error.
260
+ if ( is_wp_error( $file_array['tmp_name'] ) ) {
261
+ return $file_array['tmp_name'];
262
+ }
263
+
264
+ // Do the validation and storage stuff.
265
+ $id = media_handle_sideload( $file_array, 0 );
266
+
267
+ // If error storing permanently, unlink.
268
+ if ( is_wp_error( $id ) ) {
269
+ unlink( $file_array['tmp_name'] );
270
+ return $id;
271
+ }
272
+
273
+ // Build the object to return.
274
+ $meta = wp_get_attachment_metadata( $id );
275
+ $data->attachment_id = $id;
276
+ $data->url = wp_get_attachment_url( $id );
277
+ $data->thumbnail_url = wp_get_attachment_thumb_url( $id );
278
+ $data->height = $meta['height'];
279
+ $data->width = $meta['width'];
280
+ }
281
+
282
+ return $data;
283
+ }
284
+
285
+ /**
286
+ * Checks to see whether a string is an image url or not.
287
+ *
288
+ * @since 1.0.10
289
+ *
290
+ * @param string $string The string to check.
291
+ * @return bool Whether the string is an image url or not.
292
+ */
293
+ static public function _is_image_url( $string = '' ) {
294
+ if ( is_string( $string ) ) {
295
+
296
+ if ( preg_match( '/\.(jpg|jpeg|svg|png|gif)/i', $string ) ) {
297
+ return true;
298
+ }
299
+ }
300
+
301
+ return false;
302
+ }
303
+
304
+ }
305
+
306
+ /**
307
+ * Kicking this off by calling 'get_instance()' method
308
+ */
309
+ Astra_Sites_Helper::get_instance();
310
+
311
+ endif;
inc/includes/admin-page.php CHANGED
@@ -1,420 +1,438 @@
1
- <?php
2
- /**
3
- * Shortcode Markup
4
- *
5
- * TMPL - Single Demo Preview
6
- * TMPL - No more demos
7
- * TMPL - Filters
8
- * TMPL - List
9
- *
10
- * @package Astra Sites
11
- * @since 1.0.0
12
- */
13
-
14
- defined( 'ABSPATH' ) or exit;
15
- ?>
16
-
17
- <div class="wrap" id="astra-sites-admin">
18
-
19
- <div id="astra-sites-filters">
20
-
21
- <?php if ( apply_filters( 'astra_sites_show_filters', true ) ) { ?>
22
- <div class="wp-filter hide-if-no-js">
23
- <div class="section-left">
24
-
25
- <!-- All Filters -->
26
- <div class="filter-count">
27
- <span class="count"></span>
28
- </div>
29
- <div class="filters-wrap" style="display: none;">
30
- <div id="astra-site-page-builder"></div>
31
- </div>
32
- <div class="filters-wrap">
33
- <div id="astra-site-category"></div>
34
- </div>
35
-
36
- </div>
37
-
38
- <div class="section-right">
39
-
40
- <div class="search-form">
41
- <label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'astra-sites' ); ?> </label>
42
- <input placeholder="<?php _e( 'Search Sites...', 'astra-sites' ); ?>" type="search" aria-describedby="live-search-desc" id="wp-filter-search-input" class="wp-filter-search">
43
- </div>
44
-
45
- </div>
46
- </div>
47
- <?php } ?>
48
-
49
- </div>
50
-
51
- <?php do_action( 'astra_sites_before_site_grid' ); ?>
52
-
53
- <div class="theme-browser rendered">
54
- <div id="astra-sites" class="themes wp-clearfix"></div>
55
- </div>
56
-
57
- <div class="spinner-wrap">
58
- <span class="spinner"></span>
59
- </div>
60
-
61
- <?php do_action( 'astra_sites_after_site_grid' ); ?>
62
-
63
- </div>
64
-
65
- <?php
66
- /**
67
- * TMPL - Pro Site Description
68
- */
69
- ?>
70
- <script type="text/template" id="tmpl-astra-sites-pro-site-description">
71
- <p><?php _e( 'Liked this demo?', 'astra-sites' ); ?></p>
72
- <p>
73
- <?php
74
- /* translators: %s is pricing page link */
75
- printf( __( 'It is a premium website demo which is available only with the Agency Bundles <a href="%s" target="_blank">Buy Now!</a>', 'astra-sites' ), 'https://wpastra.com/pricing/' );
76
- ?>
77
- </p>
78
- <p>
79
- <?php
80
- /* translators: %s is article link */
81
- printf( __( 'Already own an Agency Bundle? Read an article to know how you can <a href="%s" target="_blank">import a premium website demo</a>.', 'astra-sites' ), 'https://wpastra.com/docs/import-astra-agency-website-demos/' );
82
- ?>
83
- </p>
84
- </script>
85
-
86
- <?php
87
- /**
88
- * TMPL - Pro Site Description for Inactive license
89
- */
90
- ?>
91
- <script type="text/template" id="tmpl-astra-sites-pro-inactive-site-description">
92
- <p><?php _e( 'You are just 2 minutes away from importing this demo!', 'astra-sites' ); ?></p>
93
- <p><?php _e( 'It is a premium website demo and you need to activate the license to access it.', 'astra-sites' ); ?></p>
94
- <p>
95
- <?php
96
- /* translators: %s is article link */
97
- printf( __( 'Learn how you can <a href="%s" target="_blank">activate the license</a> of the Astra Premium Sites plugin.', 'astra-sites' ), 'https://wpastra.com/docs/activate-license-for-astra-premium-sites-plugin/' );
98
- ?>
99
- </p>
100
- </script>
101
-
102
- <?php
103
- /**
104
- * TMPL - Single Demo Preview
105
- */
106
- ?>
107
- <script type="text/template" id="tmpl-astra-site-select-page-builder">
108
- <div class="select-page-builder">
109
- <div class="note-wrap">
110
- <h3>
111
- <span class="up-arrow dashicons dashicons-editor-break"></span>
112
- <div class="note"><?php _e( 'Select Your Favorite Page Builder', 'astra-sites' ); ?></div>
113
- </h3>
114
- </div>
115
- <img src="<?php echo esc_url( ASTRA_SITES_URI . 'inc/assets/images/sites-screenshot.jpg' ); ?>" alt="<?php _e( 'Sites List..', 'astra-sites' ); ?>" title="<?php _e( 'Sites List..', 'astra-sites' ); ?>" />
116
- </div>
117
- </script>
118
-
119
- <?php
120
- /**
121
- * TMPL - Single Demo Preview
122
- */
123
- ?>
124
- <script type="text/template" id="tmpl-astra-site-preview">
125
- <div class="astra-sites-preview theme-install-overlay wp-full-overlay expanded">
126
- <div class="wp-full-overlay-sidebar">
127
- <div class="wp-full-overlay-header"
128
- data-demo-id="{{{data.id}}}"
129
- data-demo-type="{{{data.astra_demo_type}}}"
130
- data-demo-url="{{{data.astra_demo_url}}}"
131
- data-demo-api="{{{data.demo_api}}}"
132
- data-demo-name="{{{data.demo_name}}}"
133
- data-demo-slug="{{{data.slug}}}"
134
- data-screenshot="{{{data.screenshot}}}"
135
- data-content="{{{data.content}}}"
136
- data-required-plugins="{{data.required_plugins}}">
137
- <input type="hidden" class="astra-site-options" value="{{data.astra_site_options}}" >
138
- <input type="hidden" class="astra-enabled-extensions" value="{{data.astra_enabled_extensions}}" >
139
- <button class="close-full-overlay"><span class="screen-reader-text"><?php esc_html_e( 'Close', 'astra-sites' ); ?></span></button>
140
- <button class="previous-theme"><span class="screen-reader-text"><?php esc_html_e( 'Previous', 'astra-sites' ); ?></span></button>
141
- <button class="next-theme"><span class="screen-reader-text"><?php esc_html_e( 'Next', 'astra-sites' ); ?></span></button>
142
- <!-- <a class="button hide-if-no-customize astra-site-import" href="#" data-import="disabled"><?php esc_html_e( 'Import Site', 'astra-sites' ); ?></a> -->
143
- <a class="button hide-if-no-customize button-primary astra-demo-import" href="#" data-import="disabled"><?php esc_html_e( 'Import Site', 'astra-sites' ); ?></a>
144
-
145
- </div>
146
- <div class="wp-full-overlay-sidebar-content">
147
- <div class="install-theme-info">
148
-
149
- <span class="site-type {{{data.astra_demo_type}}}">{{{data.astra_demo_type}}}</span>
150
- <h3 class="theme-name">{{{data.demo_name}}}</h3>
151
-
152
- <# if ( data.screenshot.length ) { #>
153
- <div class="theme-screenshot-wrap">
154
- <img class="theme-screenshot" src="{{{data.screenshot}}}" alt="">
155
- </div>
156
- <# } #>
157
-
158
- <div class="theme-details">
159
- {{{data.content}}}
160
- </div>
161
- <a href="#" class="theme-details-read-more"><?php _e( 'Read more', 'astra-sites' ); ?> &hellip;</a>
162
-
163
- <div class="astra-sites-advanced-options-wrap">
164
-
165
- <div class="astra-sites-advanced-options">
166
-
167
- <ul class="astra-site-contents">
168
- <li class="astra-sites-import-plugins">
169
- <input type="checkbox" name="plugins" checked="checked" class="disabled checkbox" readonly>
170
- <strong><?php _e( 'Install Required Plugins', 'astra-sites' ); ?></strong>
171
- <span class="astra-sites-tooltip-icon" data-tip-id="astra-sites-tooltip-plugins-settings"><span class="dashicons dashicons-editor-help"></span></span>
172
- <div class="astra-sites-tooltip-message" id="astra-sites-tooltip-plugins-settings" style="display: none;">
173
- <ul class="required-plugins-list"><span class="spinner is-active"></span></ul>
174
- </div>
175
- </li>
176
- <li class="astra-sites-import-customizer">
177
- <label>
178
- <input type="checkbox" name="customizer" checked="checked" class="checkbox">
179
- <strong>Import Customizer Settings</strong>
180
- <span class="astra-sites-tooltip-icon" data-tip-id="astra-sites-tooltip-customizer-settings"><span class="dashicons dashicons-editor-help"></span></span>
181
- <div class="astra-sites-tooltip-message" id="astra-sites-tooltip-customizer-settings" style="display: none;">
182
- <p><?php _e( 'Customizer is what gives a design to the website; and selecting this option replaces your current design with a new one.', 'astra-sites' ); ?></p>
183
- <p><?php _e( 'Backup of current customizer settings will be stored in "wp-content/astra-sites" directory, just in case if you want to restore it later.', 'astra-sites' ); ?></p>
184
- </div>
185
- </label>
186
- </li>
187
- <li class="astra-sites-import-xml">
188
- <label>
189
- <input type="checkbox" name="xml" checked="checked" class="checkbox">
190
- <strong>Import Content</strong>
191
- </label>
192
- <span class="astra-sites-tooltip-icon" data-tip-id="astra-sites-tooltip-site-content"><span class="dashicons dashicons-editor-help"></span></span>
193
- <div class="astra-sites-tooltip-message" id="astra-sites-tooltip-site-content" style="display: none;"><p><?php _e( 'Selecting this option will import dummy pages, posts, images and menus. If you do not want to import dummy content, please uncheck this option.', 'astra-sites' ); ?></p></div>
194
- </li>
195
- <li class="astra-sites-import-widgets">
196
- <label>
197
- <input type="checkbox" name="widgets" checked="checked" class="checkbox">
198
- <strong>Import Widgets</strong>
199
- </label>
200
- </li>
201
- </ul>
202
- </div>
203
-
204
- <ul>
205
- <li class="astra-sites-reset-data">
206
- <label>
207
- <input type="checkbox" name="reset" class="checkbox">
208
- <strong>Delete Previously Imported Site</strong>
209
- <div class="astra-sites-tooltip-message" id="astra-sites-tooltip-reset-data" style="display: none;"><p><?php _e( 'WARNING: Selecting this option will delete data from your current website. Choose this option only if this is intended.', 'astra-sites' ); ?></p></div>
210
- </label>
211
- </li>
212
- </ul>
213
-
214
- <!-- <p><a href="#" class="astra-sites-advanced-options-button"><?php _e( 'Advanced Options', 'astra-sites' ); ?></a></p> -->
215
-
216
- </div>
217
-
218
- <!-- <div class="astra-sites-advanced-options">
219
- <h4><?php _e( 'Required Plugins', 'astra-sites' ); ?> </h4>
220
- <div class="required-plugins"></div>
221
- </div> -->
222
- </div>
223
- </div>
224
-
225
- <div class="wp-full-overlay-footer">
226
- <div class="footer-import-button-wrap">
227
- <a class="button button-hero hide-if-no-customize button-primary astra-demo-import" href="#" data-import="disabled">
228
- <?php esc_html_e( 'Import Site', 'astra-sites' ); ?>
229
- <span class="percent"></span>
230
- </a>
231
- <div class="astra-site-import-process-wrap" style="display: none;">
232
- <progress class="astra-site-import-process" max="100" value="0"></progress>
233
- </div>
234
- <!-- <a class="button button-hero hide-if-no-customize astra-site-import" href="#">
235
- <?php esc_html_e( 'Import Site', 'astra-sites' ); ?>
236
- </a> -->
237
- </div>
238
- <button type="button" class="collapse-sidebar button" aria-expanded="true"
239
- aria-label="Collapse Sidebar">
240
- <span class="collapse-sidebar-arrow"></span>
241
- <span class="collapse-sidebar-label"><?php esc_html_e( 'Collapse', 'astra-sites' ); ?></span>
242
- </button>
243
-
244
- <div class="devices-wrapper">
245
- <div class="devices">
246
- <button type="button" class="preview-desktop active" aria-pressed="true" data-device="desktop">
247
- <span class="screen-reader-text"><?php _e( 'Enter desktop preview mode', 'astra-sites' ); ?></span>
248
- </button>
249
- <button type="button" class="preview-tablet" aria-pressed="false" data-device="tablet">
250
- <span class="screen-reader-text"><?php _e( 'Enter tablet preview mode', 'astra-sites' ); ?></span>
251
- </button>
252
- <button type="button" class="preview-mobile" aria-pressed="false" data-device="mobile">
253
- <span class="screen-reader-text"><?php _e( 'Enter mobile preview mode', 'astra-sites' ); ?></span>
254
- </button>
255
- </div>
256
- </div>
257
-
258
- </div>
259
- </div>
260
- <div class="wp-full-overlay-main">
261
- <iframe src="{{{data.astra_demo_url}}}" title="<?php esc_attr_e( 'Preview', 'astra-sites' ); ?>"></iframe>
262
- <div class="astra-sites-result-preview" style="display: none;">
263
- <div class="inner">
264
- <h2><?php _e( 'We\'re building your website.', 'astra-sites' ); ?></h2>
265
- <p><?php _e( 'The process can take anywhere between 2 to 10 minutes depending on the size of the website and speed of connection.', 'astra-sites' ); ?></p>
266
- <p><?php _e( 'Please do not close this browser window until the site is imported completely.', 'astra-sites' ); ?></p>
267
- <div class="current-importing-status-wrap">
268
- <div class="current-importing-status">
269
- <div class="current-importing-status-title"></div>
270
- <div class="current-importing-status-description"></div>
271
- </div>
272
- </div>
273
- </div>
274
- </div>
275
- </div>
276
- </div>
277
- </script>
278
-
279
- <?php
280
- /**
281
- * TMPL - No more demos
282
- */
283
- ?>
284
- <script type="text/template" id="tmpl-astra-site-api-request-failed">
285
- <div class="no-themes">
286
- <?php
287
-
288
- /* translators: %1$s & %2$s are a Demo API URL */
289
- printf( __( '<p> It seems the demo data server, <i><a href="%1$s">%2$s</a></i> is unreachable from your site.</p>', 'astra-sites' ), esc_url( Astra_Sites::$api_url ), esc_url( Astra_Sites::$api_url ) );
290
-
291
- _e( '<p class="left-margin"> 1. Sometimes, simple page reload fixes any temporary issues. No kidding!</p>', 'astra-sites' );
292
-
293
- _e( '<p class="left-margin"> 2. If that does not work, you will need to talk to your server administrator and check if demo server is being blocked by the firewall!</p>', 'astra-sites' );
294
-
295
- /* translators: %1$s is a support link */
296
- printf( __( '<p>If that does not help, please open up a <a href="%1$s" target="_blank">Support Ticket</a> and we will be glad take a closer look for you.</p>', 'astra-sites' ), esc_url( 'https://wpastra.com/support/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=api-request-failed' ) );
297
- ?>
298
- </div>
299
- </script>
300
-
301
- <?php
302
- /**
303
- * TMPL - Site Down
304
- */
305
- ?>
306
- <script type="text/template" id="tmpl-astra-site-down">
307
- <div class="postbox astra-site-down">
308
- <h2><?php _e( 'Under Maintenance..', 'astra-sites' ); ?></h2>
309
- <p><?php _e( 'If you are seeing this message, most likely our servers are under routine maintenance and we will be back shortly. ', 'astra-sites' ); ?></p>
310
- <p><?php _e( 'In rare case, it is possible your website is having trouble connecting with ours. If you need help, please feel free to get in touch with us from our website.', 'astra-sites' ); ?></p>
311
- </div>
312
- </script>
313
-
314
- <?php
315
- /**
316
- * TMPL - Filters
317
- */
318
- ?>
319
- <script type="text/template" id="tmpl-astra-site-filters">
320
-
321
- <# if ( data ) { #>
322
-
323
- <ul class="{{ data.args.wrapper_class }} {{ data.args.class }}">
324
-
325
- <# if ( data.args.show_all ) { #>
326
- <li>
327
- <a href="#" data-group="all"> All </a>
328
- </li>
329
- <# } #>
330
-
331
- <# for ( key in data.items ) { #>
332
- <# if ( data.items[ key ].count ) { #>
333
- <li>
334
- <a href="#" data-group='{{ data.items[ key ].id }}' class="{{ data.items[ key ].name }}">
335
- {{ data.items[ key ].name }}
336
- </a>
337
- </li>
338
- <# } #>
339
- <# } #>
340
-
341
- </ul>
342
- <# } #>
343
- </script>
344
-
345
- <?php
346
- /**
347
- * TMPL - List
348
- */
349
- ?>
350
- <script type="text/template" id="tmpl-astra-sites-list">
351
-
352
- <# if ( data.items.length ) { #>
353
- <# for ( key in data.items ) { #>
354
-
355
- <div class="theme astra-theme site-single {{ data.items[ key ].status }}" tabindex="0" aria-describedby="astra-theme-action astra-theme-name"
356
- data-demo-id="{{{ data.items[ key ].id }}}"
357
- data-demo-type="{{{ data.items[ key ]['astra-site-type'] }}}"
358
- data-demo-url="{{{ data.items[ key ]['astra-site-url'] }}}"
359
- data-demo-api="{{{ data.items[ key ]['_links']['self'][0]['href'] }}}"
360
- data-demo-name="{{{ data.items[ key ].title.rendered }}}"
361
- data-demo-slug="{{{ data.items[ key ].slug }}}"
362
- data-screenshot="{{{ data.items[ key ]['featured-image-url'] }}}"
363
- data-content="{{{ data.items[ key ].content.rendered }}}"
364
- data-required-plugins="{{ JSON.stringify( data.items[ key ]['required-plugins'] ) }}"
365
- data-groups=["{{ data.items[ key ].tags }}"]>
366
- <input type="hidden" class="astra-site-options" value="{{ JSON.stringify(data.items[ key ]['astra-site-options-data'] ) }}" />
367
- <input type="hidden" class="astra-enabled-extensions" value="{{ JSON.stringify(data.items[ key ]['astra-enabled-extensions'] ) }}" />
368
-
369
- <div class="inner">
370
- <span class="site-preview" data-href="{{ data.items[ key ]['astra-site-url'] }}?TB_iframe=true&width=600&height=550" data-title="{{ data.items[ key ].title.rendered }}">
371
- <div class="theme-screenshot" style="background-image: url('{{ data.items[ key ]['featured-image-url'] }}');"></div>
372
- </span>
373
- <# if ( data.items[ key ]['astra-site-type'] ) { #>
374
- <# var type = ( data.items[ key ]['astra-site-type'] !== 'premium' ) ? ( data.items[ key ]['astra-site-type'] ) : 'agency'; #>
375
- <span class="site-type {{data.items[ key ]['astra-site-type']}}">{{ type }}</span>
376
- <# } #>
377
- <# if ( data.items[ key ].status ) { #>
378
- <span class="status {{data.items[ key ].status}}">{{data.items[ key ].status}}</span>
379
- <# } #>
380
- <div class="theme-id-container">
381
- <h3 class="theme-name" id="astra-theme-name"> {{{ data.items[ key ].title.rendered }}} </h3>
382
- <div class="theme-actions">
383
- <button class="button-primary button preview install-theme-preview"><?php esc_html_e( 'Preview', 'astra-sites' ); ?></button>
384
- </div>
385
- </div>
386
- </div>
387
- </div>
388
- <# } #>
389
- <# } else { #>
390
- <p class="no-themes" style="display:block;">
391
- <?php _e( 'No Demos found, Try a different search.', 'astra-sites' ); ?>
392
- <span class="description">
393
- <?php
394
- /* translators: %1$s External Link */
395
- printf( __( 'Don\'t see a site that you would like to import?<br><a target="_blank" href="%1$s">Please suggest us!</a>', 'astra-sites' ), esc_url( 'https://wpastra.com/sites-suggestions/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=suggestions' ) );
396
- ?>
397
- </span>
398
- </p>
399
- <# } #>
400
- </script>
401
-
402
- <?php
403
- /**
404
- * TMPL - List
405
- */
406
- ?>
407
- <script type="text/template" id="tmpl-astra-sites-suggestions">
408
- <div class="theme astra-theme site-single astra-sites-suggestions">
409
- <div class="inner">
410
- <p>
411
- <?php
412
- /* translators: %1$s External Link */
413
- printf( __( 'Don\'t see a site that you would like to import?<br><a target="_blank" href="%1$s">Please suggest us!</a>', 'astra-sites' ), esc_url( 'https://wpastra.com/sites-suggestions/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=suggestions' ) );
414
- ?>
415
- </p>
416
- </div>
417
- </div>
418
- </script>
419
- <?php
420
- wp_print_admin_notice_templates();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shortcode Markup
4
+ *
5
+ * TMPL - Single Demo Preview
6
+ * TMPL - No more demos
7
+ * TMPL - Filters
8
+ * TMPL - List
9
+ *
10
+ * @package Astra Sites
11
+ * @since 1.0.0
12
+ */
13
+
14
+ defined( 'ABSPATH' ) or exit;
15
+ ?>
16
+
17
+ <div class="wrap" id="astra-sites-admin">
18
+
19
+ <div id="astra-sites-filters">
20
+
21
+ <?php if ( apply_filters( 'astra_sites_show_filters', true ) ) { ?>
22
+ <div class="wp-filter hide-if-no-js">
23
+ <div class="section-left">
24
+
25
+ <!-- All Filters -->
26
+ <div class="filter-count">
27
+ <span class="count"></span>
28
+ </div>
29
+ <div class="filters-wrap" style="display: none;">
30
+ <div id="astra-site-page-builder"></div>
31
+ </div>
32
+ <div class="filters-wrap">
33
+ <div id="astra-site-category"></div>
34
+ </div>
35
+
36
+ </div>
37
+
38
+ <div class="section-right">
39
+
40
+ <div class="search-form">
41
+ <label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'astra-sites' ); ?> </label>
42
+ <input placeholder="<?php _e( 'Search Sites...', 'astra-sites' ); ?>" type="search" aria-describedby="live-search-desc" id="wp-filter-search-input" class="wp-filter-search">
43
+ </div>
44
+
45
+ </div>
46
+ </div>
47
+ <?php } ?>
48
+
49
+ </div>
50
+
51
+ <?php do_action( 'astra_sites_before_site_grid' ); ?>
52
+
53
+ <div class="theme-browser rendered">
54
+ <div id="astra-sites" class="themes wp-clearfix"></div>
55
+ </div>
56
+
57
+ <div class="spinner-wrap">
58
+ <span class="spinner"></span>
59
+ </div>
60
+
61
+ <?php do_action( 'astra_sites_after_site_grid' ); ?>
62
+
63
+ </div>
64
+
65
+ <?php
66
+ /**
67
+ * TMPL - Pro Site Description
68
+ */
69
+ ?>
70
+ <script type="text/template" id="tmpl-astra-sites-pro-site-description">
71
+ <p><?php _e( 'Liked this demo?', 'astra-sites' ); ?></p>
72
+ <p>
73
+ <?php
74
+ /* translators: %s is pricing page link */
75
+ printf( __( 'It is a premium website demo which is available only with the Agency Bundles <a href="%s" target="_blank">Buy Now!</a>', 'astra-sites' ), 'https://wpastra.com/pricing/' );
76
+ ?>
77
+ </p>
78
+ <p>
79
+ <?php
80
+ /* translators: %s is article link */
81
+ printf( __( 'Already own an Agency Bundle? Read an article to know how you can <a href="%s" target="_blank">import a premium website demo</a>.', 'astra-sites' ), 'https://wpastra.com/docs/import-astra-agency-website-demos/' );
82
+ ?>
83
+ </p>
84
+ </script>
85
+
86
+ <?php
87
+ /**
88
+ * TMPL - Pro Site Description for Inactive license
89
+ */
90
+ ?>
91
+ <script type="text/template" id="tmpl-astra-sites-pro-inactive-site-description">
92
+ <p><?php _e( 'You are just 2 minutes away from importing this demo!', 'astra-sites' ); ?></p>
93
+ <p><?php _e( 'It is a premium website demo and you need to activate the license to access it.', 'astra-sites' ); ?></p>
94
+ <p>
95
+ <?php
96
+ /* translators: %s is article link */
97
+ printf( __( 'Learn how you can <a href="%s" target="_blank">activate the license</a> of the Astra Premium Sites plugin.', 'astra-sites' ), 'https://wpastra.com/docs/activate-license-for-astra-premium-sites-plugin/' );
98
+ ?>
99
+ </p>
100
+ </script>
101
+
102
+ <?php
103
+ /**
104
+ * TMPL - Third Party Required Plugins
105
+ */
106
+ ?>
107
+ <script type="text/template" id="tmpl-astra-sites-third-party-required-plugins">
108
+ <div class="astra-sites-third-party-required-plugins-wrap">
109
+ <div class="notice notice-warning">
110
+ <p>To import this website, You need to install below plugins!</p>
111
+ </div>
112
+ <ul class="astra-sites-third-party-required-plugins">
113
+ <# for ( key in data ) { #>
114
+ <li class="plugin-card plugin-card-{{data[ key ].slug}}'" data-slug="{{data[ key ].slug }}" data-init="{{data[ key ].init}}" data-name="{{data[ key ].name}}">{{data[ key ].name}}</li>
115
+ <# } #>
116
+ </ul>
117
+ </div>
118
+ </script>
119
+
120
+ <?php
121
+ /**
122
+ * TMPL - Single Demo Preview
123
+ */
124
+ ?>
125
+ <script type="text/template" id="tmpl-astra-site-select-page-builder">
126
+ <div class="select-page-builder">
127
+ <div class="note-wrap">
128
+ <h3>
129
+ <span class="up-arrow dashicons dashicons-editor-break"></span>
130
+ <div class="note"><?php _e( 'Select Your Favorite Page Builder', 'astra-sites' ); ?></div>
131
+ </h3>
132
+ </div>
133
+ <img src="<?php echo esc_url( ASTRA_SITES_URI . 'inc/assets/images/sites-screenshot.jpg' ); ?>" alt="<?php _e( 'Sites List..', 'astra-sites' ); ?>" title="<?php _e( 'Sites List..', 'astra-sites' ); ?>" />
134
+ </div>
135
+ </script>
136
+
137
+ <?php
138
+ /**
139
+ * TMPL - Single Demo Preview
140
+ */
141
+ ?>
142
+ <script type="text/template" id="tmpl-astra-site-preview">
143
+ <div class="astra-sites-preview theme-install-overlay wp-full-overlay expanded">
144
+ <div class="wp-full-overlay-sidebar">
145
+ <div class="wp-full-overlay-header"
146
+ data-demo-id="{{{data.id}}}"
147
+ data-demo-type="{{{data.astra_demo_type}}}"
148
+ data-demo-url="{{{data.astra_demo_url}}}"
149
+ data-demo-api="{{{data.demo_api}}}"
150
+ data-demo-name="{{{data.demo_name}}}"
151
+ data-demo-slug="{{{data.slug}}}"
152
+ data-screenshot="{{{data.screenshot}}}"
153
+ data-content="{{{data.content}}}"
154
+ data-required-plugins="{{data.required_plugins}}">
155
+ <input type="hidden" class="astra-site-options" value="{{data.astra_site_options}}" >
156
+ <input type="hidden" class="astra-enabled-extensions" value="{{data.astra_enabled_extensions}}" >
157
+ <button class="close-full-overlay"><span class="screen-reader-text"><?php esc_html_e( 'Close', 'astra-sites' ); ?></span></button>
158
+ <button class="previous-theme"><span class="screen-reader-text"><?php esc_html_e( 'Previous', 'astra-sites' ); ?></span></button>
159
+ <button class="next-theme"><span class="screen-reader-text"><?php esc_html_e( 'Next', 'astra-sites' ); ?></span></button>
160
+ <!-- <a class="button hide-if-no-customize astra-site-import" href="#" data-import="disabled"><?php esc_html_e( 'Import Site', 'astra-sites' ); ?></a> -->
161
+ <a class="button hide-if-no-customize button-primary astra-demo-import" href="#" data-import="disabled"><?php esc_html_e( 'Import Site', 'astra-sites' ); ?></a>
162
+
163
+ </div>
164
+ <div class="wp-full-overlay-sidebar-content">
165
+ <div class="install-theme-info">
166
+
167
+ <span class="site-type {{{data.astra_demo_type}}}">{{{data.astra_demo_type}}}</span>
168
+ <h3 class="theme-name">{{{data.demo_name}}}</h3>
169
+
170
+ <# if ( data.screenshot.length ) { #>
171
+ <div class="theme-screenshot-wrap">
172
+ <img class="theme-screenshot" src="{{{data.screenshot}}}" alt="">
173
+ </div>
174
+ <# } #>
175
+
176
+ <div class="theme-details">
177
+ {{{data.content}}}
178
+ </div>
179
+ <a href="#" class="theme-details-read-more"><?php _e( 'Read more', 'astra-sites' ); ?> &hellip;</a>
180
+
181
+ <div class="astra-sites-advanced-options-wrap">
182
+
183
+ <div class="astra-sites-advanced-options">
184
+
185
+ <ul class="astra-site-contents">
186
+ <li class="astra-sites-import-plugins">
187
+ <input type="checkbox" name="plugins" checked="checked" class="disabled checkbox" readonly>
188
+ <strong><?php _e( 'Install Required Plugins', 'astra-sites' ); ?></strong>
189
+ <span class="astra-sites-tooltip-icon" data-tip-id="astra-sites-tooltip-plugins-settings"><span class="dashicons dashicons-editor-help"></span></span>
190
+ <div class="astra-sites-tooltip-message" id="astra-sites-tooltip-plugins-settings" style="display: none;">
191
+ <ul class="required-plugins-list"><span class="spinner is-active"></span></ul>
192
+ </div>
193
+ </li>
194
+ <li class="astra-sites-import-customizer">
195
+ <label>
196
+ <input type="checkbox" name="customizer" checked="checked" class="checkbox">
197
+ <strong>Import Customizer Settings</strong>
198
+ <span class="astra-sites-tooltip-icon" data-tip-id="astra-sites-tooltip-customizer-settings"><span class="dashicons dashicons-editor-help"></span></span>
199
+ <div class="astra-sites-tooltip-message" id="astra-sites-tooltip-customizer-settings" style="display: none;">
200
+ <p><?php _e( 'Customizer is what gives a design to the website; and selecting this option replaces your current design with a new one.', 'astra-sites' ); ?></p>
201
+ <p><?php _e( 'Backup of current customizer settings will be stored in "wp-content/astra-sites" directory, just in case if you want to restore it later.', 'astra-sites' ); ?></p>
202
+ </div>
203
+ </label>
204
+ </li>
205
+ <li class="astra-sites-import-xml">
206
+ <label>
207
+ <input type="checkbox" name="xml" checked="checked" class="checkbox">
208
+ <strong>Import Content</strong>
209
+ </label>
210
+ <span class="astra-sites-tooltip-icon" data-tip-id="astra-sites-tooltip-site-content"><span class="dashicons dashicons-editor-help"></span></span>
211
+ <div class="astra-sites-tooltip-message" id="astra-sites-tooltip-site-content" style="display: none;"><p><?php _e( 'Selecting this option will import dummy pages, posts, images and menus. If you do not want to import dummy content, please uncheck this option.', 'astra-sites' ); ?></p></div>
212
+ </li>
213
+ <li class="astra-sites-import-widgets">
214
+ <label>
215
+ <input type="checkbox" name="widgets" checked="checked" class="checkbox">
216
+ <strong>Import Widgets</strong>
217
+ </label>
218
+ </li>
219
+ </ul>
220
+ </div>
221
+
222
+ <ul>
223
+ <li class="astra-sites-reset-data">
224
+ <label>
225
+ <input type="checkbox" name="reset" class="checkbox">
226
+ <strong>Delete Previously Imported Site</strong>
227
+ <div class="astra-sites-tooltip-message" id="astra-sites-tooltip-reset-data" style="display: none;"><p><?php _e( 'WARNING: Selecting this option will delete data from your current website. Choose this option only if this is intended.', 'astra-sites' ); ?></p></div>
228
+ </label>
229
+ </li>
230
+ </ul>
231
+
232
+ <!-- <p><a href="#" class="astra-sites-advanced-options-button"><?php _e( 'Advanced Options', 'astra-sites' ); ?></a></p> -->
233
+
234
+ </div>
235
+
236
+ <!-- <div class="astra-sites-advanced-options">
237
+ <h4><?php _e( 'Required Plugins', 'astra-sites' ); ?> </h4>
238
+ <div class="required-plugins"></div>
239
+ </div> -->
240
+ </div>
241
+ </div>
242
+
243
+ <div class="wp-full-overlay-footer">
244
+ <div class="footer-import-button-wrap">
245
+ <a class="button button-hero hide-if-no-customize button-primary astra-demo-import" href="#" data-import="disabled">
246
+ <?php esc_html_e( 'Import Site', 'astra-sites' ); ?>
247
+ <span class="percent"></span>
248
+ </a>
249
+ <div class="astra-site-import-process-wrap" style="display: none;">
250
+ <progress class="astra-site-import-process" max="100" value="0"></progress>
251
+ </div>
252
+ <!-- <a class="button button-hero hide-if-no-customize astra-site-import" href="#">
253
+ <?php esc_html_e( 'Import Site', 'astra-sites' ); ?>
254
+ </a> -->
255
+ </div>
256
+ <button type="button" class="collapse-sidebar button" aria-expanded="true"
257
+ aria-label="Collapse Sidebar">
258
+ <span class="collapse-sidebar-arrow"></span>
259
+ <span class="collapse-sidebar-label"><?php esc_html_e( 'Collapse', 'astra-sites' ); ?></span>
260
+ </button>
261
+
262
+ <div class="devices-wrapper">
263
+ <div class="devices">
264
+ <button type="button" class="preview-desktop active" aria-pressed="true" data-device="desktop">
265
+ <span class="screen-reader-text"><?php _e( 'Enter desktop preview mode', 'astra-sites' ); ?></span>
266
+ </button>
267
+ <button type="button" class="preview-tablet" aria-pressed="false" data-device="tablet">
268
+ <span class="screen-reader-text"><?php _e( 'Enter tablet preview mode', 'astra-sites' ); ?></span>
269
+ </button>
270
+ <button type="button" class="preview-mobile" aria-pressed="false" data-device="mobile">
271
+ <span class="screen-reader-text"><?php _e( 'Enter mobile preview mode', 'astra-sites' ); ?></span>
272
+ </button>
273
+ </div>
274
+ </div>
275
+
276
+ </div>
277
+ </div>
278
+ <div class="wp-full-overlay-main">
279
+ <iframe src="{{{data.astra_demo_url}}}" title="<?php esc_attr_e( 'Preview', 'astra-sites' ); ?>"></iframe>
280
+ <div class="astra-sites-result-preview" style="display: none;">
281
+ <div class="inner">
282
+ <h2><?php _e( 'We\'re importing your website.', 'astra-sites' ); ?></h2>
283
+ <p><?php _e( 'The process can take anywhere between 2 to 10 minutes depending on the size of the website and speed of connection.', 'astra-sites' ); ?></p>
284
+ <p><?php _e( 'Please do not close this browser window until the site is imported completely.', 'astra-sites' ); ?></p>
285
+ <div class="current-importing-status-wrap">
286
+ <div class="current-importing-status">
287
+ <div class="current-importing-status-title"></div>
288
+ <div class="current-importing-status-description"></div>
289
+ </div>
290
+ </div>
291
+ </div>
292
+ </div>
293
+ </div>
294
+ </div>
295
+ </script>
296
+
297
+ <?php
298
+ /**
299
+ * TMPL - No more demos
300
+ */
301
+ ?>
302
+ <script type="text/template" id="tmpl-astra-site-api-request-failed">
303
+ <div class="no-themes">
304
+ <?php
305
+
306
+ /* translators: %1$s & %2$s are a Demo API URL */
307
+ printf( __( '<p> It seems the demo data server, <i><a href="%1$s">%2$s</a></i> is unreachable from your site.</p>', 'astra-sites' ), esc_url( Astra_Sites::$api_url ), esc_url( Astra_Sites::$api_url ) );
308
+
309
+ _e( '<p class="left-margin"> 1. Sometimes, simple page reload fixes any temporary issues. No kidding!</p>', 'astra-sites' );
310
+
311
+ _e( '<p class="left-margin"> 2. If that does not work, you will need to talk to your server administrator and check if demo server is being blocked by the firewall!</p>', 'astra-sites' );
312
+
313
+ /* translators: %1$s is a support link */
314
+ printf( __( '<p>If that does not help, please open up a <a href="%1$s" target="_blank">Support Ticket</a> and we will be glad take a closer look for you.</p>', 'astra-sites' ), esc_url( 'https://wpastra.com/support/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=api-request-failed' ) );
315
+ ?>
316
+ </div>
317
+ </script>
318
+
319
+ <?php
320
+ /**
321
+ * TMPL - Site Down
322
+ */
323
+ ?>
324
+ <script type="text/template" id="tmpl-astra-site-down">
325
+ <div class="postbox astra-site-down">
326
+ <h2><?php _e( 'Under Maintenance..', 'astra-sites' ); ?></h2>
327
+ <p><?php _e( 'If you are seeing this message, most likely our servers are under routine maintenance and we will be back shortly. ', 'astra-sites' ); ?></p>
328
+ <p><?php _e( 'In rare case, it is possible your website is having trouble connecting with ours. If you need help, please feel free to get in touch with us from our website.', 'astra-sites' ); ?></p>
329
+ </div>
330
+ </script>
331
+
332
+ <?php
333
+ /**
334
+ * TMPL - Filters
335
+ */
336
+ ?>
337
+ <script type="text/template" id="tmpl-astra-site-filters">
338
+
339
+ <# if ( data ) { #>
340
+
341
+ <ul class="{{ data.args.wrapper_class }} {{ data.args.class }}">
342
+
343
+ <# if ( data.args.show_all ) { #>
344
+ <li>
345
+ <a href="#" data-group="all"> All </a>
346
+ </li>
347
+ <# } #>
348
+
349
+ <# for ( key in data.items ) { #>
350
+ <# if ( data.items[ key ].count ) { #>
351
+ <li>
352
+ <a href="#" data-group='{{ data.items[ key ].id }}' class="{{ data.items[ key ].name }}">
353
+ {{ data.items[ key ].name }}
354
+ </a>
355
+ </li>
356
+ <# } #>
357
+ <# } #>
358
+
359
+ </ul>
360
+ <# } #>
361
+ </script>
362
+
363
+ <?php
364
+ /**
365
+ * TMPL - List
366
+ */
367
+ ?>
368
+ <script type="text/template" id="tmpl-astra-sites-list">
369
+
370
+ <# if ( data.items.length ) { #>
371
+ <# for ( key in data.items ) { #>
372
+
373
+ <div class="theme astra-theme site-single {{ data.items[ key ].status }}" tabindex="0" aria-describedby="astra-theme-action astra-theme-name"
374
+ data-demo-id="{{{ data.items[ key ].id }}}"
375
+ data-demo-type="{{{ data.items[ key ]['astra-site-type'] }}}"
376
+ data-demo-url="{{{ data.items[ key ]['astra-site-url'] }}}"
377
+ data-demo-api="{{{ data.items[ key ]['_links']['self'][0]['href'] }}}"
378
+ data-demo-name="{{{ data.items[ key ].title.rendered }}}"
379
+ data-demo-slug="{{{ data.items[ key ].slug }}}"
380
+ data-screenshot="{{{ data.items[ key ]['featured-image-url'] }}}"
381
+ data-content="{{{ data.items[ key ].content.rendered }}}"
382
+ data-required-plugins="{{ JSON.stringify( data.items[ key ]['required-plugins'] ) }}"
383
+ data-groups=["{{ data.items[ key ].tags }}"]>
384
+ <input type="hidden" class="astra-site-options" value="{{ JSON.stringify(data.items[ key ]['astra-site-options-data'] ) }}" />
385
+ <input type="hidden" class="astra-enabled-extensions" value="{{ JSON.stringify(data.items[ key ]['astra-enabled-extensions'] ) }}" />
386
+
387
+ <div class="inner">
388
+ <span class="site-preview" data-href="{{ data.items[ key ]['astra-site-url'] }}?TB_iframe=true&width=600&height=550" data-title="{{ data.items[ key ].title.rendered }}">
389
+ <div class="theme-screenshot" style="background-image: url('{{ data.items[ key ]['featured-image-url'] }}');"></div>
390
+ </span>
391
+ <# if ( data.items[ key ]['astra-site-type'] ) { #>
392
+ <# var type = ( data.items[ key ]['astra-site-type'] !== 'premium' ) ? ( data.items[ key ]['astra-site-type'] ) : 'agency'; #>
393
+ <span class="site-type {{data.items[ key ]['astra-site-type']}}">{{ type }}</span>
394
+ <# } #>
395
+ <# if ( data.items[ key ].status ) { #>
396
+ <span class="status {{data.items[ key ].status}}">{{data.items[ key ].status}}</span>
397
+ <# } #>
398
+ <div class="theme-id-container">
399
+ <h3 class="theme-name" id="astra-theme-name"> {{{ data.items[ key ].title.rendered }}} </h3>
400
+ <div class="theme-actions">
401
+ <button class="button-primary button preview install-theme-preview"><?php esc_html_e( 'Preview', 'astra-sites' ); ?></button>
402
+ </div>
403
+ </div>
404
+ </div>
405
+ </div>
406
+ <# } #>
407
+ <# } else { #>
408
+ <p class="no-themes" style="display:block;">
409
+ <?php _e( 'No Demos found, Try a different search.', 'astra-sites' ); ?>
410
+ <span class="description">
411
+ <?php
412
+ /* translators: %1$s External Link */
413
+ printf( __( 'Don\'t see a site that you would like to import?<br><a target="_blank" href="%1$s">Please suggest us!</a>', 'astra-sites' ), esc_url( 'https://wpastra.com/sites-suggestions/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=suggestions' ) );
414
+ ?>
415
+ </span>
416
+ </p>
417
+ <# } #>
418
+ </script>
419
+
420
+ <?php
421
+ /**
422
+ * TMPL - List
423
+ */
424
+ ?>
425
+ <script type="text/template" id="tmpl-astra-sites-suggestions">
426
+ <div class="theme astra-theme site-single astra-sites-suggestions">
427
+ <div class="inner">
428
+ <p>
429
+ <?php
430
+ /* translators: %1$s External Link */
431
+ printf( __( 'Don\'t see a site that you would like to import?<br><a target="_blank" href="%1$s">Please suggest us!</a>', 'astra-sites' ), esc_url( 'https://wpastra.com/sites-suggestions/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=suggestions' ) );
432
+ ?>
433
+ </p>
434
+ </div>
435
+ </div>
436
+ </script>
437
+ <?php
438
+ wp_print_admin_notice_templates();
languages/astra-sites.pot CHANGED
@@ -1,11 +1,10 @@
1
  # Copyright (C) 2019 Brainstorm Force
2
- # This file is distributed under the same license as the Astra Starter Sites – Elementor, Beaver Builder & Gutenberg Templates package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Astra Starter Sites – Elementor, Beaver Builder & "
6
- "Gutenberg Templates 1.3.9\n"
7
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/astra-sites\n"
8
- "POT-Creation-Date: 2019-04-29 06:17:44+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
@@ -140,7 +139,7 @@ msgstr ""
140
  msgid "Please select your favorite page builder to continue.."
141
  msgstr ""
142
 
143
- #: inc/classes/class-astra-sites-page.php:313 inc/includes/admin-page.php:141
144
  msgid "Next"
145
  msgstr ""
146
 
@@ -152,7 +151,7 @@ msgstr ""
152
  msgid "Block Editor (Gutenberg)"
153
  msgstr ""
154
 
155
- #: inc/classes/class-astra-sites-page.php:393
156
  msgid "Astra Starter Sites"
157
  msgstr ""
158
 
@@ -260,7 +259,7 @@ msgstr ""
260
  msgid "Importing.."
261
  msgstr ""
262
 
263
- #: inc/classes/class-astra-sites.php:365 inc/includes/admin-page.php:161
264
  msgid "Read more"
265
  msgstr ""
266
 
@@ -272,7 +271,7 @@ msgstr ""
272
  msgid "There was a problem receiving a response from server."
273
  msgstr ""
274
 
275
- #: inc/classes/class-astra-sites.php:368 inc/includes/admin-page.php:391
276
  msgid "No Demos found, Try a different search."
277
  msgstr ""
278
 
@@ -642,121 +641,121 @@ msgid ""
642
  "of the Astra Premium Sites plugin."
643
  msgstr ""
644
 
645
- #: inc/includes/admin-page.php:112
646
  msgid "Select Your Favorite Page Builder"
647
  msgstr ""
648
 
649
- #: inc/includes/admin-page.php:115
650
  msgid "Sites List.."
651
  msgstr ""
652
 
653
- #: inc/includes/admin-page.php:139
654
  msgid "Close"
655
  msgstr ""
656
 
657
- #: inc/includes/admin-page.php:140
658
  msgid "Previous"
659
  msgstr ""
660
 
661
- #: inc/includes/admin-page.php:142 inc/includes/admin-page.php:143
662
- #: inc/includes/admin-page.php:228 inc/includes/admin-page.php:235
663
  msgid "Import Site"
664
  msgstr ""
665
 
666
- #: inc/includes/admin-page.php:170
667
  msgid "Install Required Plugins"
668
  msgstr ""
669
 
670
- #: inc/includes/admin-page.php:182
671
  msgid ""
672
  "Customizer is what gives a design to the website; and selecting this option "
673
  "replaces your current design with a new one."
674
  msgstr ""
675
 
676
- #: inc/includes/admin-page.php:183
677
  msgid ""
678
  "Backup of current customizer settings will be stored in "
679
  "\"wp-content/astra-sites\" directory, just in case if you want to restore "
680
  "it later."
681
  msgstr ""
682
 
683
- #: inc/includes/admin-page.php:193
684
  msgid ""
685
  "Selecting this option will import dummy pages, posts, images and menus. If "
686
  "you do not want to import dummy content, please uncheck this option."
687
  msgstr ""
688
 
689
- #: inc/includes/admin-page.php:209
690
  msgid ""
691
  "WARNING: Selecting this option will delete data from your current website. "
692
  "Choose this option only if this is intended."
693
  msgstr ""
694
 
695
- #: inc/includes/admin-page.php:214
696
  msgid "Advanced Options"
697
  msgstr ""
698
 
699
- #: inc/includes/admin-page.php:219
700
  msgid "Required Plugins"
701
  msgstr ""
702
 
703
- #: inc/includes/admin-page.php:241
704
  msgid "Collapse"
705
  msgstr ""
706
 
707
- #: inc/includes/admin-page.php:247
708
  msgid "Enter desktop preview mode"
709
  msgstr ""
710
 
711
- #: inc/includes/admin-page.php:250
712
  msgid "Enter tablet preview mode"
713
  msgstr ""
714
 
715
- #: inc/includes/admin-page.php:253
716
  msgid "Enter mobile preview mode"
717
  msgstr ""
718
 
719
- #: inc/includes/admin-page.php:261 inc/includes/admin-page.php:383
720
  msgid "Preview"
721
  msgstr ""
722
 
723
- #: inc/includes/admin-page.php:264
724
- msgid "We're building your website."
725
  msgstr ""
726
 
727
- #: inc/includes/admin-page.php:265
728
  msgid ""
729
  "The process can take anywhere between 2 to 10 minutes depending on the size "
730
  "of the website and speed of connection."
731
  msgstr ""
732
 
733
- #: inc/includes/admin-page.php:266
734
  msgid ""
735
  "Please do not close this browser window until the site is imported "
736
  "completely."
737
  msgstr ""
738
 
739
- #: inc/includes/admin-page.php:289
740
  #. translators: %1$s & %2$s are a Demo API URL
741
  msgid ""
742
  "<p> It seems the demo data server, <i><a href=\"%1$s\">%2$s</a></i> is "
743
  "unreachable from your site.</p>"
744
  msgstr ""
745
 
746
- #: inc/includes/admin-page.php:291
747
  msgid ""
748
  "<p class=\"left-margin\"> 1. Sometimes, simple page reload fixes any "
749
  "temporary issues. No kidding!</p>"
750
  msgstr ""
751
 
752
- #: inc/includes/admin-page.php:293
753
  msgid ""
754
  "<p class=\"left-margin\"> 2. If that does not work, you will need to talk "
755
  "to your server administrator and check if demo server is being blocked by "
756
  "the firewall!</p>"
757
  msgstr ""
758
 
759
- #: inc/includes/admin-page.php:296
760
  #. translators: %1$s is a support link
761
  msgid ""
762
  "<p>If that does not help, please open up a <a href=\"%1$s\" "
@@ -764,24 +763,24 @@ msgid ""
764
  "for you.</p>"
765
  msgstr ""
766
 
767
- #: inc/includes/admin-page.php:308
768
  msgid "Under Maintenance.."
769
  msgstr ""
770
 
771
- #: inc/includes/admin-page.php:309
772
  msgid ""
773
  "If you are seeing this message, most likely our servers are under routine "
774
  "maintenance and we will be back shortly. "
775
  msgstr ""
776
 
777
- #: inc/includes/admin-page.php:310
778
  msgid ""
779
  "In rare case, it is possible your website is having trouble connecting with "
780
  "ours. If you need help, please feel free to get in touch with us from our "
781
  "website."
782
  msgstr ""
783
 
784
- #: inc/includes/admin-page.php:395 inc/includes/admin-page.php:413
785
  #. translators: %1$s External Link
786
  msgid ""
787
  "Don't see a site that you would like to import?<br><a target=\"_blank\" "
@@ -796,10 +795,6 @@ msgstr ""
796
  msgid "Plugin Description:"
797
  msgstr ""
798
 
799
- #. Plugin Name of the plugin/theme
800
- msgid "Astra Starter Sites – Elementor, Beaver Builder & Gutenberg Templates"
801
- msgstr ""
802
-
803
  #. Plugin URI of the plugin/theme
804
  msgid "http://www.wpastra.com/pro/"
805
  msgstr ""
1
  # Copyright (C) 2019 Brainstorm Force
2
+ # This file is distributed under the same license as the Astra Starter Sites package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Astra Starter Sites 1.3.10\n"
 
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/astra-sites\n"
7
+ "POT-Creation-Date: 2019-05-13 08:30:13+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
139
  msgid "Please select your favorite page builder to continue.."
140
  msgstr ""
141
 
142
+ #: inc/classes/class-astra-sites-page.php:313 inc/includes/admin-page.php:159
143
  msgid "Next"
144
  msgstr ""
145
 
151
  msgid "Block Editor (Gutenberg)"
152
  msgstr ""
153
 
154
+ #. Plugin Name of the plugin/theme
155
  msgid "Astra Starter Sites"
156
  msgstr ""
157
 
259
  msgid "Importing.."
260
  msgstr ""
261
 
262
+ #: inc/classes/class-astra-sites.php:365 inc/includes/admin-page.php:179
263
  msgid "Read more"
264
  msgstr ""
265
 
271
  msgid "There was a problem receiving a response from server."
272
  msgstr ""
273
 
274
+ #: inc/classes/class-astra-sites.php:368 inc/includes/admin-page.php:409
275
  msgid "No Demos found, Try a different search."
276
  msgstr ""
277
 
641
  "of the Astra Premium Sites plugin."
642
  msgstr ""
643
 
644
+ #: inc/includes/admin-page.php:130
645
  msgid "Select Your Favorite Page Builder"
646
  msgstr ""
647
 
648
+ #: inc/includes/admin-page.php:133
649
  msgid "Sites List.."
650
  msgstr ""
651
 
652
+ #: inc/includes/admin-page.php:157
653
  msgid "Close"
654
  msgstr ""
655
 
656
+ #: inc/includes/admin-page.php:158
657
  msgid "Previous"
658
  msgstr ""
659
 
660
+ #: inc/includes/admin-page.php:160 inc/includes/admin-page.php:161
661
+ #: inc/includes/admin-page.php:246 inc/includes/admin-page.php:253
662
  msgid "Import Site"
663
  msgstr ""
664
 
665
+ #: inc/includes/admin-page.php:188
666
  msgid "Install Required Plugins"
667
  msgstr ""
668
 
669
+ #: inc/includes/admin-page.php:200
670
  msgid ""
671
  "Customizer is what gives a design to the website; and selecting this option "
672
  "replaces your current design with a new one."
673
  msgstr ""
674
 
675
+ #: inc/includes/admin-page.php:201
676
  msgid ""
677
  "Backup of current customizer settings will be stored in "
678
  "\"wp-content/astra-sites\" directory, just in case if you want to restore "
679
  "it later."
680
  msgstr ""
681
 
682
+ #: inc/includes/admin-page.php:211
683
  msgid ""
684
  "Selecting this option will import dummy pages, posts, images and menus. If "
685
  "you do not want to import dummy content, please uncheck this option."
686
  msgstr ""
687
 
688
+ #: inc/includes/admin-page.php:227
689
  msgid ""
690
  "WARNING: Selecting this option will delete data from your current website. "
691
  "Choose this option only if this is intended."
692
  msgstr ""
693
 
694
+ #: inc/includes/admin-page.php:232
695
  msgid "Advanced Options"
696
  msgstr ""
697
 
698
+ #: inc/includes/admin-page.php:237
699
  msgid "Required Plugins"
700
  msgstr ""
701
 
702
+ #: inc/includes/admin-page.php:259
703
  msgid "Collapse"
704
  msgstr ""
705
 
706
+ #: inc/includes/admin-page.php:265
707
  msgid "Enter desktop preview mode"
708
  msgstr ""
709
 
710
+ #: inc/includes/admin-page.php:268
711
  msgid "Enter tablet preview mode"
712
  msgstr ""
713
 
714
+ #: inc/includes/admin-page.php:271
715
  msgid "Enter mobile preview mode"
716
  msgstr ""
717
 
718
+ #: inc/includes/admin-page.php:279 inc/includes/admin-page.php:401
719
  msgid "Preview"
720
  msgstr ""
721
 
722
+ #: inc/includes/admin-page.php:282
723
+ msgid "We're importing your website."
724
  msgstr ""
725
 
726
+ #: inc/includes/admin-page.php:283
727
  msgid ""
728
  "The process can take anywhere between 2 to 10 minutes depending on the size "
729
  "of the website and speed of connection."
730
  msgstr ""
731
 
732
+ #: inc/includes/admin-page.php:284
733
  msgid ""
734
  "Please do not close this browser window until the site is imported "
735
  "completely."
736
  msgstr ""
737
 
738
+ #: inc/includes/admin-page.php:307
739
  #. translators: %1$s & %2$s are a Demo API URL
740
  msgid ""
741
  "<p> It seems the demo data server, <i><a href=\"%1$s\">%2$s</a></i> is "
742
  "unreachable from your site.</p>"
743
  msgstr ""
744
 
745
+ #: inc/includes/admin-page.php:309
746
  msgid ""
747
  "<p class=\"left-margin\"> 1. Sometimes, simple page reload fixes any "
748
  "temporary issues. No kidding!</p>"
749
  msgstr ""
750
 
751
+ #: inc/includes/admin-page.php:311
752
  msgid ""
753
  "<p class=\"left-margin\"> 2. If that does not work, you will need to talk "
754
  "to your server administrator and check if demo server is being blocked by "
755
  "the firewall!</p>"
756
  msgstr ""
757
 
758
+ #: inc/includes/admin-page.php:314
759
  #. translators: %1$s is a support link
760
  msgid ""
761
  "<p>If that does not help, please open up a <a href=\"%1$s\" "
763
  "for you.</p>"
764
  msgstr ""
765
 
766
+ #: inc/includes/admin-page.php:326
767
  msgid "Under Maintenance.."
768
  msgstr ""
769
 
770
+ #: inc/includes/admin-page.php:327
771
  msgid ""
772
  "If you are seeing this message, most likely our servers are under routine "
773
  "maintenance and we will be back shortly. "
774
  msgstr ""
775
 
776
+ #: inc/includes/admin-page.php:328
777
  msgid ""
778
  "In rare case, it is possible your website is having trouble connecting with "
779
  "ours. If you need help, please feel free to get in touch with us from our "
780
  "website."
781
  msgstr ""
782
 
783
+ #: inc/includes/admin-page.php:413 inc/includes/admin-page.php:431
784
  #. translators: %1$s External Link
785
  msgid ""
786
  "Don't see a site that you would like to import?<br><a target=\"_blank\" "
795
  msgid "Plugin Description:"
796
  msgstr ""
797
 
 
 
 
 
798
  #. Plugin URI of the plugin/theme
799
  msgid "http://www.wpastra.com/pro/"
800
  msgstr ""
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: Elementor,Beaver Builder,Templates,Gutenberg,Astra Starter Sites
5
  Requires at least: 4.4
6
  Requires PHP: 5.3
7
  Tested up to: 5.1.1
8
- Stable tag: 1.3.9
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -117,6 +117,11 @@ We are open to suggestions and would love to work on topics that our users are l
117
 
118
  == Changelog ==
119
 
 
 
 
 
 
120
  v1.3.9 - 29-April-2019
121
  - Fix: Fatal error for below WordPress version 5.1.0.
122
 
5
  Requires at least: 4.4
6
  Requires PHP: 5.3
7
  Tested up to: 5.1.1
8
+ Stable tag: 1.3.10
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
117
 
118
  == Changelog ==
119
 
120
+ v1.3.10 - 13-May-2019
121
+ - Improvement: Added LarnDash plugin support for LarnDash demos.
122
+ - Fix: SVG images are not importing in media library.
123
+ - Fix: Images not uploaded due to timeout issue.
124
+
125
  v1.3.9 - 29-April-2019
126
  - Fix: Fatal error for below WordPress version 5.1.0.
127