Version Description
Download this release
Release Info
Developer | Nikschavan |
Plugin | Astra Starter Sites |
Version | 1.2.11 |
Comparing to | |
See all releases |
Code changes from version 1.2.10 to 1.2.11
- astra-sites.php +2 -2
- inc/assets/css/admin.css +5 -0
- inc/assets/js/astra-sites-api.js +1 -1
- inc/assets/js/render-grid.js +14 -0
- inc/classes/class-astra-sites-white-label.php +289 -208
- inc/classes/class-astra-sites.php +466 -466
- inc/importers/wxr-importer/class-astra-wxr-importer.php +344 -344
- inc/includes/admin-page.php +311 -299
- languages/astra-sites.pot +51 -33
- readme.txt +6 -2
astra-sites.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Astra Starter Sites
|
4 |
* Plugin URI: http://www.wpastra.com/pro/
|
5 |
* Description: Import free sites build with Astra theme.
|
6 |
-
* Version: 1.2.
|
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.2.
|
23 |
}
|
24 |
|
25 |
if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
|
3 |
* Plugin Name: Astra Starter Sites
|
4 |
* Plugin URI: http://www.wpastra.com/pro/
|
5 |
* Description: Import free sites build with Astra theme.
|
6 |
+
* Version: 1.2.11
|
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.2.11' );
|
23 |
}
|
24 |
|
25 |
if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
|
inc/assets/css/admin.css
CHANGED
@@ -468,4 +468,9 @@ body.loading-content .select-page-builder {
|
|
468 |
#astra-sites-filters {
|
469 |
display: inline-block;
|
470 |
width: 100%;
|
|
|
|
|
|
|
|
|
|
|
471 |
}
|
468 |
#astra-sites-filters {
|
469 |
display: inline-block;
|
470 |
width: 100%;
|
471 |
+
}
|
472 |
+
|
473 |
+
.astra-site-down {
|
474 |
+
padding: 1em 2em;
|
475 |
+
margin-top: 1em;
|
476 |
}
|
inc/assets/js/astra-sites-api.js
CHANGED
@@ -41,7 +41,7 @@
|
|
41 |
})
|
42 |
.fail(function( jqXHR, textStatus ) {
|
43 |
|
44 |
-
$(document).trigger( 'astra-sites-api-request-fail' );
|
45 |
|
46 |
})
|
47 |
.always(function() {
|
41 |
})
|
42 |
.fail(function( jqXHR, textStatus ) {
|
43 |
|
44 |
+
$(document).trigger( 'astra-sites-api-request-fail', [jqXHR, textStatus, args] );
|
45 |
|
46 |
})
|
47 |
.always(function() {
|
inc/assets/js/render-grid.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
(function($){
|
|
|
2 |
AstraRender = {
|
3 |
|
4 |
_ref : null,
|
@@ -45,7 +46,20 @@
|
|
45 |
$( document ).on('click' , '.filter-links a', AstraRender._filterClick );
|
46 |
$( document ).on('keyup input' , '#wp-filter-search-input', AstraRender._search );
|
47 |
$( document ).on('scroll' , AstraRender._scroll );
|
|
|
|
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
},
|
50 |
|
51 |
/**
|
1 |
(function($){
|
2 |
+
|
3 |
AstraRender = {
|
4 |
|
5 |
_ref : null,
|
46 |
$( document ).on('click' , '.filter-links a', AstraRender._filterClick );
|
47 |
$( document ).on('keyup input' , '#wp-filter-search-input', AstraRender._search );
|
48 |
$( document ).on('scroll' , AstraRender._scroll );
|
49 |
+
$( document ).on('astra-sites-api-request-fail', AstraRender._site_unreachable );
|
50 |
+
},
|
51 |
|
52 |
+
/**
|
53 |
+
* Website is Down
|
54 |
+
*
|
55 |
+
* @since 1.2.11
|
56 |
+
* @return null
|
57 |
+
*/
|
58 |
+
_site_unreachable: function( event, jqXHR, textStatus, args ) {
|
59 |
+
event.preventDefault();
|
60 |
+
if ( 'astra-site-page-builder' === args.id ) {
|
61 |
+
$('#astra-sites-admin').html( wp.template('astra-site-down') )
|
62 |
+
}
|
63 |
},
|
64 |
|
65 |
/**
|
inc/classes/class-astra-sites-white-label.php
CHANGED
@@ -1,208 +1,289 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Astra Sites White Label
|
4 |
-
*
|
5 |
-
* @package Astra Sites
|
6 |
-
* @since 1.0.12
|
7 |
-
*/
|
8 |
-
|
9 |
-
if ( ! class_exists( 'Astra_Sites_White_Label' ) ) :
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Astra_Sites_White_Label
|
13 |
-
*
|
14 |
-
* @since 1.0.12
|
15 |
-
*/
|
16 |
-
class Astra_Sites_White_Label {
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Instance
|
20 |
-
*
|
21 |
-
* @since 1.0.12
|
22 |
-
*
|
23 |
-
* @var object Class Object.
|
24 |
-
* @access private
|
25 |
-
*/
|
26 |
-
private static $instance;
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Member Variable
|
30 |
-
*
|
31 |
-
* @since 1.0.12
|
32 |
-
*
|
33 |
-
* @var array branding
|
34 |
-
* @access private
|
35 |
-
*/
|
36 |
-
private static $branding;
|
37 |
-
|
38 |
-
/**
|
39 |
-
*
|
40 |
-
*
|
41 |
-
* @since 1.
|
42 |
-
*
|
43 |
-
* @
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
*
|
54 |
-
*
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
$plugins
|
99 |
-
}
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
$
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
*
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
*
|
183 |
-
*
|
184 |
-
* @
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Astra Sites White Label
|
4 |
+
*
|
5 |
+
* @package Astra Sites
|
6 |
+
* @since 1.0.12
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! class_exists( 'Astra_Sites_White_Label' ) ) :
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Astra_Sites_White_Label
|
13 |
+
*
|
14 |
+
* @since 1.0.12
|
15 |
+
*/
|
16 |
+
class Astra_Sites_White_Label {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Instance
|
20 |
+
*
|
21 |
+
* @since 1.0.12
|
22 |
+
*
|
23 |
+
* @var object Class Object.
|
24 |
+
* @access private
|
25 |
+
*/
|
26 |
+
private static $instance;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Member Variable
|
30 |
+
*
|
31 |
+
* @since 1.0.12
|
32 |
+
*
|
33 |
+
* @var array branding
|
34 |
+
* @access private
|
35 |
+
*/
|
36 |
+
private static $branding;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Settings
|
40 |
+
*
|
41 |
+
* @since 1.2.11
|
42 |
+
*
|
43 |
+
* @var array settings
|
44 |
+
*
|
45 |
+
* @access private
|
46 |
+
*/
|
47 |
+
private $settings;
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Initiator
|
51 |
+
*
|
52 |
+
* @since 1.0.12
|
53 |
+
*
|
54 |
+
* @return object initialized object of class.
|
55 |
+
*/
|
56 |
+
public static function get_instance() {
|
57 |
+
if ( ! isset( self::$instance ) ) {
|
58 |
+
self::$instance = new self;
|
59 |
+
}
|
60 |
+
return self::$instance;
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Constructor
|
65 |
+
*
|
66 |
+
* @since 1.0.12
|
67 |
+
*/
|
68 |
+
public function __construct() {
|
69 |
+
|
70 |
+
$this->set_white_labels();
|
71 |
+
|
72 |
+
add_filter( 'all_plugins', array( $this, 'plugins_page' ) );
|
73 |
+
add_filter( 'astra_addon_branding_options', __CLASS__ . '::settings' );
|
74 |
+
add_action( 'astra_pro_white_label_add_form', __CLASS__ . '::add_white_lavel_form' );
|
75 |
+
add_filter( 'astra_sites_menu_page_title', array( $this, 'page_title' ) );
|
76 |
+
|
77 |
+
// Display the link with the plugin meta.
|
78 |
+
if ( is_admin() ) {
|
79 |
+
add_filter( 'plugin_row_meta', array( $this, 'plugin_links' ), 10, 4 );
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* White labels the plugins page.
|
85 |
+
*
|
86 |
+
* @since 1.0.12
|
87 |
+
*
|
88 |
+
* @param array $plugins Plugins Array.
|
89 |
+
* @return array
|
90 |
+
*/
|
91 |
+
function plugins_page( $plugins ) {
|
92 |
+
|
93 |
+
if ( ! is_callable( 'Astra_Ext_White_Label_Markup::get_white_label' ) ) {
|
94 |
+
return $plugins;
|
95 |
+
}
|
96 |
+
|
97 |
+
if ( ! isset( $plugins[ ASTRA_SITES_BASE ] ) ) {
|
98 |
+
return $plugins;
|
99 |
+
}
|
100 |
+
|
101 |
+
// Set White Labels.
|
102 |
+
$name = Astra_Ext_White_Label_Markup::get_white_label( 'astra-sites', 'name' );
|
103 |
+
$description = Astra_Ext_White_Label_Markup::get_white_label( 'astra-sites', 'description' );
|
104 |
+
$author = Astra_Ext_White_Label_Markup::get_white_label( 'astra-agency', 'author' );
|
105 |
+
$author_uri = Astra_Ext_White_Label_Markup::get_white_label( 'astra-agency', 'author_url' );
|
106 |
+
|
107 |
+
if ( ! empty( $name ) ) {
|
108 |
+
$plugins[ ASTRA_SITES_BASE ]['Name'] = $name;
|
109 |
+
|
110 |
+
// Remove Plugin URI if Agency White Label name is set.
|
111 |
+
$plugins[ ASTRA_SITES_BASE ]['PluginURI'] = '';
|
112 |
+
}
|
113 |
+
|
114 |
+
if ( ! empty( $description ) ) {
|
115 |
+
$plugins[ ASTRA_SITES_BASE ]['Description'] = $description;
|
116 |
+
}
|
117 |
+
|
118 |
+
if ( ! empty( $author ) ) {
|
119 |
+
$plugins[ ASTRA_SITES_BASE ]['Author'] = $author;
|
120 |
+
}
|
121 |
+
|
122 |
+
if ( ! empty( $author_uri ) ) {
|
123 |
+
$plugins[ ASTRA_SITES_BASE ]['AuthorURI'] = $author_uri;
|
124 |
+
}
|
125 |
+
|
126 |
+
return $plugins;
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Remove a "view details" link from the plugin list table
|
131 |
+
*
|
132 |
+
* @since 1.0.12
|
133 |
+
*
|
134 |
+
* @param array $plugin_meta List of links.
|
135 |
+
* @param string $plugin_file Relative path to the main plugin file from the plugins directory.
|
136 |
+
* @param array $plugin_data Data from the plugin headers.
|
137 |
+
* @return array
|
138 |
+
*/
|
139 |
+
public function plugin_links( $plugin_meta, $plugin_file, $plugin_data ) {
|
140 |
+
|
141 |
+
if ( ! is_callable( 'Astra_Ext_White_Label_Markup::get_white_label' ) ) {
|
142 |
+
return $plugin_meta;
|
143 |
+
}
|
144 |
+
|
145 |
+
// Set White Labels.
|
146 |
+
if ( ASTRA_SITES_BASE == $plugin_file ) {
|
147 |
+
|
148 |
+
$name = Astra_Ext_White_Label_Markup::get_white_label( 'astra-sites', 'name' );
|
149 |
+
$description = Astra_Ext_White_Label_Markup::get_white_label( 'astra-sites', 'description' );
|
150 |
+
|
151 |
+
// Remove Plugin URI if Agency White Label name is set.
|
152 |
+
if ( ! empty( $name ) ) {
|
153 |
+
unset( $plugin_meta[2] );
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
return $plugin_meta;
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Add White Label setting's
|
162 |
+
*
|
163 |
+
* @since 1.0.12
|
164 |
+
*
|
165 |
+
* @param array $settings White label setting.
|
166 |
+
* @return array
|
167 |
+
*/
|
168 |
+
public static function settings( $settings = array() ) {
|
169 |
+
|
170 |
+
$settings['astra-sites'] = array(
|
171 |
+
'name' => '',
|
172 |
+
'description' => '',
|
173 |
+
);
|
174 |
+
|
175 |
+
return $settings;
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Add White Label form
|
180 |
+
*
|
181 |
+
* @since 1.0.12
|
182 |
+
*
|
183 |
+
* @param array $settings White label setting.
|
184 |
+
* @return void
|
185 |
+
*/
|
186 |
+
public static function add_white_lavel_form( $settings = array() ) {
|
187 |
+
|
188 |
+
/* translators: %1$s product name */
|
189 |
+
$plugin_name = sprintf( __( '%1$s Branding', 'astra-sites' ), ASTRA_SITES_NAME );
|
190 |
+
|
191 |
+
require_once ASTRA_SITES_DIR . 'inc/includes/white-label.php';
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Page Title
|
196 |
+
*
|
197 |
+
* @since 1.0.12
|
198 |
+
*
|
199 |
+
* @param string $title Page Title.
|
200 |
+
* @return string Filtered Page Title.
|
201 |
+
*/
|
202 |
+
function page_title( $title ) {
|
203 |
+
$get_white_labels = 'Astra_Ext_White_Label_Markup::get_white_labels';
|
204 |
+
if ( is_callable( $get_white_labels ) ) {
|
205 |
+
$astra_sites_name = Astra_Ext_White_Label_Markup::get_white_label( 'astra-sites', 'name' );
|
206 |
+
if ( ! empty( $astra_sites_name ) ) {
|
207 |
+
$title = Astra_Ext_White_Label_Markup::get_white_label( 'astra-sites', 'name' );
|
208 |
+
}
|
209 |
+
}
|
210 |
+
|
211 |
+
return $title;
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Set White Labels
|
216 |
+
*
|
217 |
+
* @since 1.2.11
|
218 |
+
*
|
219 |
+
* @return void
|
220 |
+
*/
|
221 |
+
function set_white_labels() {
|
222 |
+
|
223 |
+
$name = $description = $support_link = $author = '';
|
224 |
+
if ( is_callable( 'Astra_Ext_White_Label_Markup::get_white_label' ) ) {
|
225 |
+
$name = Astra_Ext_White_Label_Markup::get_white_label( 'astra-sites', 'name' );
|
226 |
+
$description = Astra_Ext_White_Label_Markup::get_white_label( 'astra-sites', 'description' );
|
227 |
+
$support_link = Astra_Ext_White_Label_Markup::get_white_label( 'astra-agency', 'author_url' );
|
228 |
+
$author = Astra_Ext_White_Label_Markup::get_white_label( 'astra-agency', 'author' );
|
229 |
+
}
|
230 |
+
|
231 |
+
$this->settings = array(
|
232 |
+
'name' => ( ! empty( $name ) ) ? $name : __( 'Astra Sites', 'astra-sites' ),
|
233 |
+
'author' => ( ! empty( $author ) ) ? $author : __( 'Brainstorm Force', 'astra-sites' ),
|
234 |
+
'description' => ( ! empty( $description ) ) ? $description : __( 'Import free sites build with Astra theme.', 'astra-sites' ),
|
235 |
+
'support-link' => ( ! empty( $support_link ) ) ? $support_link : 'mailto:support@bsf.io',
|
236 |
+
);
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Get Name
|
241 |
+
*
|
242 |
+
* @since 1.2.11
|
243 |
+
*
|
244 |
+
* @return string
|
245 |
+
*/
|
246 |
+
function get_name() {
|
247 |
+
return $this->settings['name'];
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Get Description
|
252 |
+
*
|
253 |
+
* @since 1.2.11
|
254 |
+
*
|
255 |
+
* @return string
|
256 |
+
*/
|
257 |
+
function get_description() {
|
258 |
+
return $this->settings['description'];
|
259 |
+
}
|
260 |
+
|
261 |
+
/**
|
262 |
+
* Get Author
|
263 |
+
*
|
264 |
+
* @since 1.2.11
|
265 |
+
*
|
266 |
+
* @return string
|
267 |
+
*/
|
268 |
+
function get_author() {
|
269 |
+
return $this->settings['author'];
|
270 |
+
}
|
271 |
+
|
272 |
+
/**
|
273 |
+
* Get Support Link
|
274 |
+
*
|
275 |
+
* @since 1.2.11
|
276 |
+
*
|
277 |
+
* @return string
|
278 |
+
*/
|
279 |
+
function get_support_link() {
|
280 |
+
return $this->settings['support-link'];
|
281 |
+
}
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Kicking this off by calling 'get_instance()' method
|
286 |
+
*/
|
287 |
+
Astra_Sites_White_Label::get_instance();
|
288 |
+
|
289 |
+
endif;
|
inc/classes/class-astra-sites.php
CHANGED
@@ -1,466 +1,466 @@
|
|
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 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Add Admin Notice.
|
72 |
-
*/
|
73 |
-
function add_notice() {
|
74 |
-
|
75 |
-
Astra_Sites_Notices::add_notice(
|
76 |
-
array(
|
77 |
-
'id' => 'astra-theme-activation-nag',
|
78 |
-
'type' => 'error',
|
79 |
-
'show_if' => ( ! defined( 'ASTRA_THEME_SETTINGS' ) ) ? true : false,
|
80 |
-
/* translators: 1: theme.php file*/
|
81 |
-
'message' => sprintf( __( 'Astra Theme needs to be active for you to use currently installed "%1$s" plugin. <a href="%2$s">Install & Activate Now</a>', 'astra-sites' ), ASTRA_SITES_NAME, esc_url( admin_url( 'themes.php?theme=astra' ) ) ),
|
82 |
-
'dismissible' => true,
|
83 |
-
'dismissible-time' => WEEK_IN_SECONDS,
|
84 |
-
)
|
85 |
-
);
|
86 |
-
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Loads textdomain for the plugin.
|
91 |
-
*
|
92 |
-
* @since 1.0.1
|
93 |
-
*/
|
94 |
-
function load_textdomain() {
|
95 |
-
load_plugin_textdomain( 'astra-sites' );
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* Admin Notices
|
100 |
-
*
|
101 |
-
* @since 1.0.5
|
102 |
-
* @return void
|
103 |
-
*/
|
104 |
-
function admin_notices() {
|
105 |
-
|
106 |
-
if ( ! defined( 'ASTRA_THEME_SETTINGS' ) ) {
|
107 |
-
return;
|
108 |
-
}
|
109 |
-
|
110 |
-
add_action( 'plugin_action_links_' . ASTRA_SITES_BASE, array( $this, 'action_links' ) );
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Show action links on the plugin screen.
|
115 |
-
*
|
116 |
-
* @param mixed $links Plugin Action links.
|
117 |
-
* @return array
|
118 |
-
*/
|
119 |
-
function action_links( $links ) {
|
120 |
-
$action_links = array(
|
121 |
-
'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>',
|
122 |
-
);
|
123 |
-
|
124 |
-
return array_merge( $action_links, $links );
|
125 |
-
}
|
126 |
-
|
127 |
-
/**
|
128 |
-
* Setter for $api_url
|
129 |
-
*
|
130 |
-
* @since 1.0.0
|
131 |
-
*/
|
132 |
-
public static function set_api_url() {
|
133 |
-
|
134 |
-
self::$api_url = apply_filters( 'astra_sites_api_url', 'https://websitedemos.net/wp-json/wp/v2/' );
|
135 |
-
|
136 |
-
}
|
137 |
-
|
138 |
-
/**
|
139 |
-
* Enqueue admin scripts.
|
140 |
-
*
|
141 |
-
* @since 1.0.5 Added 'getUpgradeText' and 'getUpgradeURL' localize variables.
|
142 |
-
*
|
143 |
-
* @since 1.0.0
|
144 |
-
*
|
145 |
-
* @param string $hook Current hook name.
|
146 |
-
* @return void
|
147 |
-
*/
|
148 |
-
public function admin_enqueue( $hook = '' ) {
|
149 |
-
|
150 |
-
if ( 'appearance_page_astra-sites' !== $hook ) {
|
151 |
-
return;
|
152 |
-
}
|
153 |
-
|
154 |
-
global $is_IE, $is_edge;
|
155 |
-
|
156 |
-
if ( $is_IE || $is_edge ) {
|
157 |
-
wp_enqueue_script( 'astra-sites-eventsource', ASTRA_SITES_URI . 'inc/assets/js/eventsource.min.js', array( 'jquery', 'wp-util', 'updates' ), ASTRA_SITES_VER, true );
|
158 |
-
}
|
159 |
-
|
160 |
-
// API.
|
161 |
-
wp_register_script( 'astra-sites-api', ASTRA_SITES_URI . 'inc/assets/js/astra-sites-api.js', array( 'jquery' ), ASTRA_SITES_VER, true );
|
162 |
-
|
163 |
-
// Admin Page.
|
164 |
-
wp_enqueue_style( 'astra-sites-admin', ASTRA_SITES_URI . 'inc/assets/css/admin.css', ASTRA_SITES_VER, true );
|
165 |
-
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 );
|
166 |
-
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 );
|
167 |
-
|
168 |
-
$data = apply_filters(
|
169 |
-
'astra_sites_localize_vars',
|
170 |
-
array(
|
171 |
-
'ApiURL' => self::$api_url,
|
172 |
-
'filters' => array(
|
173 |
-
'page_builder' => array(
|
174 |
-
'title' => __( 'Page Builder', 'astra-sites' ),
|
175 |
-
'slug' => 'astra-site-page-builder',
|
176 |
-
'trigger' => 'astra-api-category-loaded',
|
177 |
-
),
|
178 |
-
'categories' => array(
|
179 |
-
'title' => __( 'Categories', 'astra-sites' ),
|
180 |
-
'slug' => 'astra-site-category',
|
181 |
-
'trigger' => 'astra-api-category-loaded',
|
182 |
-
),
|
183 |
-
),
|
184 |
-
)
|
185 |
-
);
|
186 |
-
wp_localize_script( 'astra-sites-api', 'astraSitesApi', $data );
|
187 |
-
|
188 |
-
// Use this for premium demos.
|
189 |
-
$request_params = apply_filters(
|
190 |
-
'astra_sites_api_params',
|
191 |
-
array(
|
192 |
-
'purchase_key' => '',
|
193 |
-
'site_url' => '',
|
194 |
-
'par-page' => 15,
|
195 |
-
)
|
196 |
-
);
|
197 |
-
|
198 |
-
$data = apply_filters(
|
199 |
-
'astra_sites_render_localize_vars',
|
200 |
-
array(
|
201 |
-
'sites' => $request_params,
|
202 |
-
'page-builders' => array(),
|
203 |
-
'categories' => array(),
|
204 |
-
'settings' => array(),
|
205 |
-
)
|
206 |
-
);
|
207 |
-
|
208 |
-
wp_localize_script( 'astra-sites-render-grid', 'astraRenderGrid', $data );
|
209 |
-
|
210 |
-
$data = apply_filters(
|
211 |
-
'astra_sites_localize_vars',
|
212 |
-
array(
|
213 |
-
'debug' => ( ( defined( 'WP_DEBUG' ) && WP_DEBUG ) || isset( $_GET['debug'] ) ) ? true : false,
|
214 |
-
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
|
215 |
-
'siteURL' => site_url(),
|
216 |
-
'getProText' => __( 'Purchase', 'astra-sites' ),
|
217 |
-
'getProURL' => esc_url( 'https://wpastra.com/agency/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=wp-dashboard' ),
|
218 |
-
'getUpgradeText' => __( 'Upgrade', 'astra-sites' ),
|
219 |
-
'getUpgradeURL' => esc_url( 'https://wpastra.com/agency/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=wp-dashboard' ),
|
220 |
-
'_ajax_nonce' => wp_create_nonce( 'astra-sites' ),
|
221 |
-
'requiredPlugins' => array(),
|
222 |
-
'XMLReaderDisabled' => ! class_exists( 'XMLReader' ) ? true : false,
|
223 |
-
'strings' => array(
|
224 |
-
/* translators: %s are HTML tags. */
|
225 |
-
'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>' ),
|
226 |
-
'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' ),
|
227 |
-
'importFailedBtnSmall' => __( 'Error!', 'astra-sites' ),
|
228 |
-
'importFailedBtnLarge' => __( 'Error! Read Possibilities.', 'astra-sites' ),
|
229 |
-
'importFailedURL' => esc_url( 'https://wpastra.com/docs/?p=1314&utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=import-failed' ),
|
230 |
-
'viewSite' => __( 'Done! View Site', 'astra-sites' ),
|
231 |
-
'btnActivating' => __( 'Activating', 'astra-sites' ) . '…',
|
232 |
-
'btnActive' => __( 'Active', 'astra-sites' ),
|
233 |
-
'importFailBtn' => __( 'Import failed.', 'astra-sites' ),
|
234 |
-
'importFailBtnLarge' => __( 'Import failed. See error log.', 'astra-sites' ),
|
235 |
-
'importDemo' => __( 'Import This Site', 'astra-sites' ),
|
236 |
-
'importingDemo' => __( 'Importing..', 'astra-sites' ),
|
237 |
-
'DescExpand' => __( 'Read more', 'astra-sites' ) . '…',
|
238 |
-
'DescCollapse' => __( 'Hide', 'astra-sites' ),
|
239 |
-
'responseError' => __( 'There was a problem receiving a response from server.', 'astra-sites' ),
|
240 |
-
'searchNoFound' => __( 'No Demos found, Try a different search.', 'astra-sites' ),
|
241 |
-
'importWarning' => __( "Executing Demo Import will make your site similar as ours. Please bear in mind -\n\n1. It is recommended to run import on a fresh WordPress installation.\n\n2. Importing site does not delete any pages or posts. However, it can overwrite your existing content.\n\n3. Copyrighted media will not be imported. Instead it will be replaced with placeholders.", 'astra-sites' ),
|
242 |
-
),
|
243 |
-
'log' => array(
|
244 |
-
'installingPlugin' => __( 'Installing plugin ', 'astra-sites' ),
|
245 |
-
'installed' => __( 'Successfully plugin installed!', 'astra-sites' ),
|
246 |
-
'activating' => __( 'Activating plugin ', 'astra-sites' ),
|
247 |
-
'activated' => __( 'Successfully plugin activated ', 'astra-sites' ),
|
248 |
-
'bulkActivation' => __( 'Bulk plugin activation...', 'astra-sites' ),
|
249 |
-
'activate' => __( 'Successfully plugin activate - ', 'astra-sites' ),
|
250 |
-
'activationError' => __( 'Error! While activating plugin - ', 'astra-sites' ),
|
251 |
-
'bulkInstall' => __( 'Bulk plugin installation...', 'astra-sites' ),
|
252 |
-
'api' => __( 'Site API ', 'astra-sites' ),
|
253 |
-
'importing' => __( 'Importing..', 'astra-sites' ),
|
254 |
-
'processingRequest' => __( 'Processing requests...', 'astra-sites' ),
|
255 |
-
'importCustomizer' => __( '1) Importing "Customizer Settings"...', 'astra-sites' ),
|
256 |
-
'importCustomizerSuccess' => __( 'Successfully imported customizer settings!', 'astra-sites' ),
|
257 |
-
'importXMLPrepare' => __( '2) Preparing "XML" Data...', 'astra-sites' ),
|
258 |
-
'importXMLPrepareSuccess' => __( 'Successfully set XML data!', 'astra-sites' ),
|
259 |
-
'importXML' => __( '3) Importing "XML"...', 'astra-sites' ),
|
260 |
-
'importXMLSuccess' => __( 'Successfully imported XML!', 'astra-sites' ),
|
261 |
-
'importOptions' => __( '4) Importing "Options"...', 'astra-sites' ),
|
262 |
-
'importOptionsSuccess' => __( 'Successfully imported Options!', 'astra-sites' ),
|
263 |
-
'importWidgets' => __( '5) Importing "Widgets"...', 'astra-sites' ),
|
264 |
-
'importWidgetsSuccess' => __( 'Successfully imported Widgets!', 'astra-sites' ),
|
265 |
-
'serverConfiguration' => esc_url( 'https://wpastra.com/docs/?p=1314&utm_source=demo-import-panel&utm_campaign=import-error&utm_medium=wp-dashboard' ),
|
266 |
-
'success' => __( 'Site imported successfully! visit : ', 'astra-sites' ),
|
267 |
-
'gettingData' => __( 'Getting Site Information..', 'astra-sites' ),
|
268 |
-
'importingCustomizer' => __( 'Importing Customizer Settings..', 'astra-sites' ),
|
269 |
-
'importXMLPreparing' => __( 'Setting up import data..', 'astra-sites' ),
|
270 |
-
'importingXML' => __( 'Importing Pages, Posts & Media..', 'astra-sites' ),
|
271 |
-
'importingOptions' => __( 'Importing Site Options..', 'astra-sites' ),
|
272 |
-
'importingWidgets' => __( 'Importing Widgets..', 'astra-sites' ),
|
273 |
-
'importComplete' => __( 'Import Complete..', 'astra-sites' ),
|
274 |
-
'preview' => __( 'Previewing ', 'astra-sites' ),
|
275 |
-
'importLogText' => __( 'See Error Log →', 'astra-sites' ),
|
276 |
-
),
|
277 |
-
)
|
278 |
-
);
|
279 |
-
|
280 |
-
wp_localize_script( 'astra-sites-admin-page', 'astraSitesAdmin', $data );
|
281 |
-
|
282 |
-
}
|
283 |
-
|
284 |
-
/**
|
285 |
-
* Load all the required files in the importer.
|
286 |
-
*
|
287 |
-
* @since 1.0.0
|
288 |
-
*/
|
289 |
-
private function includes() {
|
290 |
-
|
291 |
-
require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-notices.php';
|
292 |
-
require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-page.php';
|
293 |
-
require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/class-astra-sites-compatibility.php';
|
294 |
-
require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-white-label.php';
|
295 |
-
require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-importer.php';
|
296 |
-
|
297 |
-
}
|
298 |
-
|
299 |
-
/**
|
300 |
-
* Required Plugin Activate
|
301 |
-
*
|
302 |
-
* @since 1.0.0
|
303 |
-
*/
|
304 |
-
public function required_plugin_activate() {
|
305 |
-
|
306 |
-
if ( ! current_user_can( 'install_plugins' ) || ! isset( $_POST['init'] ) || ! $_POST['init'] ) {
|
307 |
-
wp_send_json_error(
|
308 |
-
array(
|
309 |
-
'success' => false,
|
310 |
-
'message' => __( 'No plugin specified', 'astra-sites' ),
|
311 |
-
)
|
312 |
-
);
|
313 |
-
}
|
314 |
-
|
315 |
-
$data = array();
|
316 |
-
$plugin_init = ( isset( $_POST['init'] ) ) ? esc_attr( $_POST['init'] ) : '';
|
317 |
-
$astra_site_options = ( isset( $_POST['options'] ) ) ? json_decode( stripslashes( $_POST['options'] ) ) : '';
|
318 |
-
$enabled_extensions = ( isset( $_POST['enabledExtensions'] ) ) ? json_decode( stripslashes( $_POST['enabledExtensions'] ) ) : '';
|
319 |
-
|
320 |
-
$data['astra_site_options'] = $astra_site_options;
|
321 |
-
$data['enabled_extensions'] = $enabled_extensions;
|
322 |
-
|
323 |
-
$activate = activate_plugin( $plugin_init, '', false, true );
|
324 |
-
|
325 |
-
if ( is_wp_error( $activate ) ) {
|
326 |
-
wp_send_json_error(
|
327 |
-
array(
|
328 |
-
'success' => false,
|
329 |
-
'message' => $activate->get_error_message(),
|
330 |
-
)
|
331 |
-
);
|
332 |
-
}
|
333 |
-
|
334 |
-
do_action( 'astra_sites_after_plugin_activation', $plugin_init, $data );
|
335 |
-
|
336 |
-
wp_send_json_success(
|
337 |
-
array(
|
338 |
-
'success' => true,
|
339 |
-
'message' => __( 'Plugin Successfully Activated', 'astra-sites' ),
|
340 |
-
)
|
341 |
-
);
|
342 |
-
|
343 |
-
}
|
344 |
-
|
345 |
-
/**
|
346 |
-
* Required Plugin
|
347 |
-
*
|
348 |
-
* @since 1.0.0
|
349 |
-
* @return void
|
350 |
-
*/
|
351 |
-
public function required_plugin() {
|
352 |
-
|
353 |
-
// Verify Nonce.
|
354 |
-
check_ajax_referer( 'astra-sites', '_ajax_nonce' );
|
355 |
-
|
356 |
-
$response = array(
|
357 |
-
'active' => array(),
|
358 |
-
'inactive' => array(),
|
359 |
-
'notinstalled' => array(),
|
360 |
-
);
|
361 |
-
|
362 |
-
if ( ! current_user_can( 'customize' ) ) {
|
363 |
-
wp_send_json_error( $response );
|
364 |
-
}
|
365 |
-
|
366 |
-
$required_plugins = ( isset( $_POST['required_plugins'] ) ) ? $_POST['required_plugins'] : array();
|
367 |
-
|
368 |
-
if ( count( $required_plugins ) > 0 ) {
|
369 |
-
foreach ( $required_plugins as $key => $plugin ) {
|
370 |
-
|
371 |
-
/**
|
372 |
-
* Has Pro Version Support?
|
373 |
-
* And
|
374 |
-
* Is Pro Version Installed?
|
375 |
-
*/
|
376 |
-
$plugin_pro = self::pro_plugin_exist( $plugin['init'] );
|
377 |
-
if ( $plugin_pro ) {
|
378 |
-
|
379 |
-
// Pro - Active.
|
380 |
-
if ( is_plugin_active( $plugin_pro['init'] ) ) {
|
381 |
-
$response['active'][] = $plugin_pro;
|
382 |
-
|
383 |
-
// Pro - Inactive.
|
384 |
-
} else {
|
385 |
-
$response['inactive'][] = $plugin_pro;
|
386 |
-
}
|
387 |
-
} else {
|
388 |
-
|
389 |
-
// Lite - Installed but Inactive.
|
390 |
-
if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin['init'] ) && is_plugin_inactive( $plugin['init'] ) ) {
|
391 |
-
|
392 |
-
$response['inactive'][] = $plugin;
|
393 |
-
|
394 |
-
// Lite - Not Installed.
|
395 |
-
} elseif ( ! file_exists( WP_PLUGIN_DIR . '/' . $plugin['init'] ) ) {
|
396 |
-
|
397 |
-
$response['notinstalled'][] = $plugin;
|
398 |
-
|
399 |
-
// Lite - Active.
|
400 |
-
} else {
|
401 |
-
$response['active'][] = $plugin;
|
402 |
-
}
|
403 |
-
}
|
404 |
-
}
|
405 |
-
}
|
406 |
-
|
407 |
-
// Send response.
|
408 |
-
wp_send_json_success( $response );
|
409 |
-
}
|
410 |
-
|
411 |
-
/**
|
412 |
-
* Has Pro Version Support?
|
413 |
-
* And
|
414 |
-
* Is Pro Version Installed?
|
415 |
-
*
|
416 |
-
* Check Pro plugin version exist of requested plugin lite version.
|
417 |
-
*
|
418 |
-
* Eg. If plugin 'BB Lite Version' required to import demo. Then we check the 'BB Agency Version' is exist?
|
419 |
-
* If yes then we only 'Activate' Agency Version. [We couldn't install agency version.]
|
420 |
-
* Else we 'Activate' or 'Install' Lite Version.
|
421 |
-
*
|
422 |
-
* @since 1.0.1
|
423 |
-
*
|
424 |
-
* @param string $lite_version Lite version init file.
|
425 |
-
* @return mixed Return false if not installed or not supported by us
|
426 |
-
* else return 'Pro' version details.
|
427 |
-
*/
|
428 |
-
public static function pro_plugin_exist( $lite_version = '' ) {
|
429 |
-
|
430 |
-
// Lite init => Pro init.
|
431 |
-
$plugins = apply_filters(
|
432 |
-
'astra_sites_pro_plugin_exist',
|
433 |
-
array(
|
434 |
-
'beaver-builder-lite-version/fl-builder.php' => array(
|
435 |
-
'slug' => 'bb-plugin',
|
436 |
-
'init' => 'bb-plugin/fl-builder.php',
|
437 |
-
'name' => 'Beaver Builder Plugin',
|
438 |
-
),
|
439 |
-
'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' => array(
|
440 |
-
'slug' => 'bb-ultimate-addon',
|
441 |
-
'init' => 'bb-ultimate-addon/bb-ultimate-addon.php',
|
442 |
-
'name' => 'Ultimate Addon for Beaver Builder',
|
443 |
-
),
|
444 |
-
),
|
445 |
-
$lite_version
|
446 |
-
);
|
447 |
-
|
448 |
-
if ( isset( $plugins[ $lite_version ] ) ) {
|
449 |
-
|
450 |
-
// Pro plugin directory exist?
|
451 |
-
if ( file_exists( WP_PLUGIN_DIR . '/' . $plugins[ $lite_version ]['init'] ) ) {
|
452 |
-
return $plugins[ $lite_version ];
|
453 |
-
}
|
454 |
-
}
|
455 |
-
|
456 |
-
return false;
|
457 |
-
}
|
458 |
-
|
459 |
-
}
|
460 |
-
|
461 |
-
/**
|
462 |
-
* Kicking this off by calling 'get_instance()' method
|
463 |
-
*/
|
464 |
-
Astra_Sites::get_instance();
|
465 |
-
|
466 |
-
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 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Add Admin Notice.
|
72 |
+
*/
|
73 |
+
function add_notice() {
|
74 |
+
|
75 |
+
Astra_Sites_Notices::add_notice(
|
76 |
+
array(
|
77 |
+
'id' => 'astra-theme-activation-nag',
|
78 |
+
'type' => 'error',
|
79 |
+
'show_if' => ( ! defined( 'ASTRA_THEME_SETTINGS' ) ) ? true : false,
|
80 |
+
/* translators: 1: theme.php file*/
|
81 |
+
'message' => sprintf( __( 'Astra Theme needs to be active for you to use currently installed "%1$s" plugin. <a href="%2$s">Install & Activate Now</a>', 'astra-sites' ), ASTRA_SITES_NAME, esc_url( admin_url( 'themes.php?theme=astra' ) ) ),
|
82 |
+
'dismissible' => true,
|
83 |
+
'dismissible-time' => WEEK_IN_SECONDS,
|
84 |
+
)
|
85 |
+
);
|
86 |
+
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Loads textdomain for the plugin.
|
91 |
+
*
|
92 |
+
* @since 1.0.1
|
93 |
+
*/
|
94 |
+
function load_textdomain() {
|
95 |
+
load_plugin_textdomain( 'astra-sites' );
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Admin Notices
|
100 |
+
*
|
101 |
+
* @since 1.0.5
|
102 |
+
* @return void
|
103 |
+
*/
|
104 |
+
function admin_notices() {
|
105 |
+
|
106 |
+
if ( ! defined( 'ASTRA_THEME_SETTINGS' ) ) {
|
107 |
+
return;
|
108 |
+
}
|
109 |
+
|
110 |
+
add_action( 'plugin_action_links_' . ASTRA_SITES_BASE, array( $this, 'action_links' ) );
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Show action links on the plugin screen.
|
115 |
+
*
|
116 |
+
* @param mixed $links Plugin Action links.
|
117 |
+
* @return array
|
118 |
+
*/
|
119 |
+
function action_links( $links ) {
|
120 |
+
$action_links = array(
|
121 |
+
'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>',
|
122 |
+
);
|
123 |
+
|
124 |
+
return array_merge( $action_links, $links );
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Setter for $api_url
|
129 |
+
*
|
130 |
+
* @since 1.0.0
|
131 |
+
*/
|
132 |
+
public static function set_api_url() {
|
133 |
+
|
134 |
+
self::$api_url = apply_filters( 'astra_sites_api_url', 'https://websitedemos.net/wp-json/wp/v2/' );
|
135 |
+
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Enqueue admin scripts.
|
140 |
+
*
|
141 |
+
* @since 1.0.5 Added 'getUpgradeText' and 'getUpgradeURL' localize variables.
|
142 |
+
*
|
143 |
+
* @since 1.0.0
|
144 |
+
*
|
145 |
+
* @param string $hook Current hook name.
|
146 |
+
* @return void
|
147 |
+
*/
|
148 |
+
public function admin_enqueue( $hook = '' ) {
|
149 |
+
|
150 |
+
if ( 'appearance_page_astra-sites' !== $hook ) {
|
151 |
+
return;
|
152 |
+
}
|
153 |
+
|
154 |
+
global $is_IE, $is_edge;
|
155 |
+
|
156 |
+
if ( $is_IE || $is_edge ) {
|
157 |
+
wp_enqueue_script( 'astra-sites-eventsource', ASTRA_SITES_URI . 'inc/assets/js/eventsource.min.js', array( 'jquery', 'wp-util', 'updates' ), ASTRA_SITES_VER, true );
|
158 |
+
}
|
159 |
+
|
160 |
+
// API.
|
161 |
+
wp_register_script( 'astra-sites-api', ASTRA_SITES_URI . 'inc/assets/js/astra-sites-api.js', array( 'jquery' ), ASTRA_SITES_VER, true );
|
162 |
+
|
163 |
+
// Admin Page.
|
164 |
+
wp_enqueue_style( 'astra-sites-admin', ASTRA_SITES_URI . 'inc/assets/css/admin.css', ASTRA_SITES_VER, true );
|
165 |
+
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 );
|
166 |
+
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 );
|
167 |
+
|
168 |
+
$data = apply_filters(
|
169 |
+
'astra_sites_localize_vars',
|
170 |
+
array(
|
171 |
+
'ApiURL' => self::$api_url,
|
172 |
+
'filters' => array(
|
173 |
+
'page_builder' => array(
|
174 |
+
'title' => __( 'Page Builder', 'astra-sites' ),
|
175 |
+
'slug' => 'astra-site-page-builder',
|
176 |
+
'trigger' => 'astra-api-category-loaded',
|
177 |
+
),
|
178 |
+
'categories' => array(
|
179 |
+
'title' => __( 'Categories', 'astra-sites' ),
|
180 |
+
'slug' => 'astra-site-category',
|
181 |
+
'trigger' => 'astra-api-category-loaded',
|
182 |
+
),
|
183 |
+
),
|
184 |
+
)
|
185 |
+
);
|
186 |
+
wp_localize_script( 'astra-sites-api', 'astraSitesApi', $data );
|
187 |
+
|
188 |
+
// Use this for premium demos.
|
189 |
+
$request_params = apply_filters(
|
190 |
+
'astra_sites_api_params',
|
191 |
+
array(
|
192 |
+
'purchase_key' => '',
|
193 |
+
'site_url' => '',
|
194 |
+
'par-page' => 15,
|
195 |
+
)
|
196 |
+
);
|
197 |
+
|
198 |
+
$data = apply_filters(
|
199 |
+
'astra_sites_render_localize_vars',
|
200 |
+
array(
|
201 |
+
'sites' => $request_params,
|
202 |
+
'page-builders' => array(),
|
203 |
+
'categories' => array(),
|
204 |
+
'settings' => array(),
|
205 |
+
)
|
206 |
+
);
|
207 |
+
|
208 |
+
wp_localize_script( 'astra-sites-render-grid', 'astraRenderGrid', $data );
|
209 |
+
|
210 |
+
$data = apply_filters(
|
211 |
+
'astra_sites_localize_vars',
|
212 |
+
array(
|
213 |
+
'debug' => ( ( defined( 'WP_DEBUG' ) && WP_DEBUG ) || isset( $_GET['debug'] ) ) ? true : false,
|
214 |
+
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
|
215 |
+
'siteURL' => site_url(),
|
216 |
+
'getProText' => __( 'Purchase', 'astra-sites' ),
|
217 |
+
'getProURL' => esc_url( 'https://wpastra.com/agency/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=wp-dashboard' ),
|
218 |
+
'getUpgradeText' => __( 'Upgrade', 'astra-sites' ),
|
219 |
+
'getUpgradeURL' => esc_url( 'https://wpastra.com/agency/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=wp-dashboard' ),
|
220 |
+
'_ajax_nonce' => wp_create_nonce( 'astra-sites' ),
|
221 |
+
'requiredPlugins' => array(),
|
222 |
+
'XMLReaderDisabled' => ! class_exists( 'XMLReader' ) ? true : false,
|
223 |
+
'strings' => array(
|
224 |
+
/* translators: %s are HTML tags. */
|
225 |
+
'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>' ),
|
226 |
+
'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' ),
|
227 |
+
'importFailedBtnSmall' => __( 'Error!', 'astra-sites' ),
|
228 |
+
'importFailedBtnLarge' => __( 'Error! Read Possibilities.', 'astra-sites' ),
|
229 |
+
'importFailedURL' => esc_url( 'https://wpastra.com/docs/?p=1314&utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=import-failed' ),
|
230 |
+
'viewSite' => __( 'Done! View Site', 'astra-sites' ),
|
231 |
+
'btnActivating' => __( 'Activating', 'astra-sites' ) . '…',
|
232 |
+
'btnActive' => __( 'Active', 'astra-sites' ),
|
233 |
+
'importFailBtn' => __( 'Import failed.', 'astra-sites' ),
|
234 |
+
'importFailBtnLarge' => __( 'Import failed. See error log.', 'astra-sites' ),
|
235 |
+
'importDemo' => __( 'Import This Site', 'astra-sites' ),
|
236 |
+
'importingDemo' => __( 'Importing..', 'astra-sites' ),
|
237 |
+
'DescExpand' => __( 'Read more', 'astra-sites' ) . '…',
|
238 |
+
'DescCollapse' => __( 'Hide', 'astra-sites' ),
|
239 |
+
'responseError' => __( 'There was a problem receiving a response from server.', 'astra-sites' ),
|
240 |
+
'searchNoFound' => __( 'No Demos found, Try a different search.', 'astra-sites' ),
|
241 |
+
'importWarning' => __( "Executing Demo Import will make your site similar as ours. Please bear in mind -\n\n1. It is recommended to run import on a fresh WordPress installation.\n\n2. Importing site does not delete any pages or posts. However, it can overwrite your existing content.\n\n3. Copyrighted media will not be imported. Instead it will be replaced with placeholders.", 'astra-sites' ),
|
242 |
+
),
|
243 |
+
'log' => array(
|
244 |
+
'installingPlugin' => __( 'Installing plugin ', 'astra-sites' ),
|
245 |
+
'installed' => __( 'Successfully plugin installed!', 'astra-sites' ),
|
246 |
+
'activating' => __( 'Activating plugin ', 'astra-sites' ),
|
247 |
+
'activated' => __( 'Successfully plugin activated ', 'astra-sites' ),
|
248 |
+
'bulkActivation' => __( 'Bulk plugin activation...', 'astra-sites' ),
|
249 |
+
'activate' => __( 'Successfully plugin activate - ', 'astra-sites' ),
|
250 |
+
'activationError' => __( 'Error! While activating plugin - ', 'astra-sites' ),
|
251 |
+
'bulkInstall' => __( 'Bulk plugin installation...', 'astra-sites' ),
|
252 |
+
'api' => __( 'Site API ', 'astra-sites' ),
|
253 |
+
'importing' => __( 'Importing..', 'astra-sites' ),
|
254 |
+
'processingRequest' => __( 'Processing requests...', 'astra-sites' ),
|
255 |
+
'importCustomizer' => __( '1) Importing "Customizer Settings"...', 'astra-sites' ),
|
256 |
+
'importCustomizerSuccess' => __( 'Successfully imported customizer settings!', 'astra-sites' ),
|
257 |
+
'importXMLPrepare' => __( '2) Preparing "XML" Data...', 'astra-sites' ),
|
258 |
+
'importXMLPrepareSuccess' => __( 'Successfully set XML data!', 'astra-sites' ),
|
259 |
+
'importXML' => __( '3) Importing "XML"...', 'astra-sites' ),
|
260 |
+
'importXMLSuccess' => __( 'Successfully imported XML!', 'astra-sites' ),
|
261 |
+
'importOptions' => __( '4) Importing "Options"...', 'astra-sites' ),
|
262 |
+
'importOptionsSuccess' => __( 'Successfully imported Options!', 'astra-sites' ),
|
263 |
+
'importWidgets' => __( '5) Importing "Widgets"...', 'astra-sites' ),
|
264 |
+
'importWidgetsSuccess' => __( 'Successfully imported Widgets!', 'astra-sites' ),
|
265 |
+
'serverConfiguration' => esc_url( 'https://wpastra.com/docs/?p=1314&utm_source=demo-import-panel&utm_campaign=import-error&utm_medium=wp-dashboard' ),
|
266 |
+
'success' => __( 'Site imported successfully! visit : ', 'astra-sites' ),
|
267 |
+
'gettingData' => __( 'Getting Site Information..', 'astra-sites' ),
|
268 |
+
'importingCustomizer' => __( 'Importing Customizer Settings..', 'astra-sites' ),
|
269 |
+
'importXMLPreparing' => __( 'Setting up import data..', 'astra-sites' ),
|
270 |
+
'importingXML' => __( 'Importing Pages, Posts & Media..', 'astra-sites' ),
|
271 |
+
'importingOptions' => __( 'Importing Site Options..', 'astra-sites' ),
|
272 |
+
'importingWidgets' => __( 'Importing Widgets..', 'astra-sites' ),
|
273 |
+
'importComplete' => __( 'Import Complete..', 'astra-sites' ),
|
274 |
+
'preview' => __( 'Previewing ', 'astra-sites' ),
|
275 |
+
'importLogText' => __( 'See Error Log →', 'astra-sites' ),
|
276 |
+
),
|
277 |
+
)
|
278 |
+
);
|
279 |
+
|
280 |
+
wp_localize_script( 'astra-sites-admin-page', 'astraSitesAdmin', $data );
|
281 |
+
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Load all the required files in the importer.
|
286 |
+
*
|
287 |
+
* @since 1.0.0
|
288 |
+
*/
|
289 |
+
private function includes() {
|
290 |
+
|
291 |
+
require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-notices.php';
|
292 |
+
require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-page.php';
|
293 |
+
require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/class-astra-sites-compatibility.php';
|
294 |
+
require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-white-label.php';
|
295 |
+
require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-importer.php';
|
296 |
+
|
297 |
+
}
|
298 |
+
|
299 |
+
/**
|
300 |
+
* Required Plugin Activate
|
301 |
+
*
|
302 |
+
* @since 1.0.0
|
303 |
+
*/
|
304 |
+
public function required_plugin_activate() {
|
305 |
+
|
306 |
+
if ( ! current_user_can( 'install_plugins' ) || ! isset( $_POST['init'] ) || ! $_POST['init'] ) {
|
307 |
+
wp_send_json_error(
|
308 |
+
array(
|
309 |
+
'success' => false,
|
310 |
+
'message' => __( 'No plugin specified', 'astra-sites' ),
|
311 |
+
)
|
312 |
+
);
|
313 |
+
}
|
314 |
+
|
315 |
+
$data = array();
|
316 |
+
$plugin_init = ( isset( $_POST['init'] ) ) ? esc_attr( $_POST['init'] ) : '';
|
317 |
+
$astra_site_options = ( isset( $_POST['options'] ) ) ? json_decode( stripslashes( $_POST['options'] ) ) : '';
|
318 |
+
$enabled_extensions = ( isset( $_POST['enabledExtensions'] ) ) ? json_decode( stripslashes( $_POST['enabledExtensions'] ) ) : '';
|
319 |
+
|
320 |
+
$data['astra_site_options'] = $astra_site_options;
|
321 |
+
$data['enabled_extensions'] = $enabled_extensions;
|
322 |
+
|
323 |
+
$activate = activate_plugin( $plugin_init, '', false, true );
|
324 |
+
|
325 |
+
if ( is_wp_error( $activate ) ) {
|
326 |
+
wp_send_json_error(
|
327 |
+
array(
|
328 |
+
'success' => false,
|
329 |
+
'message' => $activate->get_error_message(),
|
330 |
+
)
|
331 |
+
);
|
332 |
+
}
|
333 |
+
|
334 |
+
do_action( 'astra_sites_after_plugin_activation', $plugin_init, $data );
|
335 |
+
|
336 |
+
wp_send_json_success(
|
337 |
+
array(
|
338 |
+
'success' => true,
|
339 |
+
'message' => __( 'Plugin Successfully Activated', 'astra-sites' ),
|
340 |
+
)
|
341 |
+
);
|
342 |
+
|
343 |
+
}
|
344 |
+
|
345 |
+
/**
|
346 |
+
* Required Plugin
|
347 |
+
*
|
348 |
+
* @since 1.0.0
|
349 |
+
* @return void
|
350 |
+
*/
|
351 |
+
public function required_plugin() {
|
352 |
+
|
353 |
+
// Verify Nonce.
|
354 |
+
check_ajax_referer( 'astra-sites', '_ajax_nonce' );
|
355 |
+
|
356 |
+
$response = array(
|
357 |
+
'active' => array(),
|
358 |
+
'inactive' => array(),
|
359 |
+
'notinstalled' => array(),
|
360 |
+
);
|
361 |
+
|
362 |
+
if ( ! current_user_can( 'customize' ) ) {
|
363 |
+
wp_send_json_error( $response );
|
364 |
+
}
|
365 |
+
|
366 |
+
$required_plugins = ( isset( $_POST['required_plugins'] ) ) ? $_POST['required_plugins'] : array();
|
367 |
+
|
368 |
+
if ( count( $required_plugins ) > 0 ) {
|
369 |
+
foreach ( $required_plugins as $key => $plugin ) {
|
370 |
+
|
371 |
+
/**
|
372 |
+
* Has Pro Version Support?
|
373 |
+
* And
|
374 |
+
* Is Pro Version Installed?
|
375 |
+
*/
|
376 |
+
$plugin_pro = self::pro_plugin_exist( $plugin['init'] );
|
377 |
+
if ( $plugin_pro ) {
|
378 |
+
|
379 |
+
// Pro - Active.
|
380 |
+
if ( is_plugin_active( $plugin_pro['init'] ) ) {
|
381 |
+
$response['active'][] = $plugin_pro;
|
382 |
+
|
383 |
+
// Pro - Inactive.
|
384 |
+
} else {
|
385 |
+
$response['inactive'][] = $plugin_pro;
|
386 |
+
}
|
387 |
+
} else {
|
388 |
+
|
389 |
+
// Lite - Installed but Inactive.
|
390 |
+
if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin['init'] ) && is_plugin_inactive( $plugin['init'] ) ) {
|
391 |
+
|
392 |
+
$response['inactive'][] = $plugin;
|
393 |
+
|
394 |
+
// Lite - Not Installed.
|
395 |
+
} elseif ( ! file_exists( WP_PLUGIN_DIR . '/' . $plugin['init'] ) ) {
|
396 |
+
|
397 |
+
$response['notinstalled'][] = $plugin;
|
398 |
+
|
399 |
+
// Lite - Active.
|
400 |
+
} else {
|
401 |
+
$response['active'][] = $plugin;
|
402 |
+
}
|
403 |
+
}
|
404 |
+
}
|
405 |
+
}
|
406 |
+
|
407 |
+
// Send response.
|
408 |
+
wp_send_json_success( $response );
|
409 |
+
}
|
410 |
+
|
411 |
+
/**
|
412 |
+
* Has Pro Version Support?
|
413 |
+
* And
|
414 |
+
* Is Pro Version Installed?
|
415 |
+
*
|
416 |
+
* Check Pro plugin version exist of requested plugin lite version.
|
417 |
+
*
|
418 |
+
* Eg. If plugin 'BB Lite Version' required to import demo. Then we check the 'BB Agency Version' is exist?
|
419 |
+
* If yes then we only 'Activate' Agency Version. [We couldn't install agency version.]
|
420 |
+
* Else we 'Activate' or 'Install' Lite Version.
|
421 |
+
*
|
422 |
+
* @since 1.0.1
|
423 |
+
*
|
424 |
+
* @param string $lite_version Lite version init file.
|
425 |
+
* @return mixed Return false if not installed or not supported by us
|
426 |
+
* else return 'Pro' version details.
|
427 |
+
*/
|
428 |
+
public static function pro_plugin_exist( $lite_version = '' ) {
|
429 |
+
|
430 |
+
// Lite init => Pro init.
|
431 |
+
$plugins = apply_filters(
|
432 |
+
'astra_sites_pro_plugin_exist',
|
433 |
+
array(
|
434 |
+
'beaver-builder-lite-version/fl-builder.php' => array(
|
435 |
+
'slug' => 'bb-plugin',
|
436 |
+
'init' => 'bb-plugin/fl-builder.php',
|
437 |
+
'name' => 'Beaver Builder Plugin',
|
438 |
+
),
|
439 |
+
'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' => array(
|
440 |
+
'slug' => 'bb-ultimate-addon',
|
441 |
+
'init' => 'bb-ultimate-addon/bb-ultimate-addon.php',
|
442 |
+
'name' => 'Ultimate Addon for Beaver Builder',
|
443 |
+
),
|
444 |
+
),
|
445 |
+
$lite_version
|
446 |
+
);
|
447 |
+
|
448 |
+
if ( isset( $plugins[ $lite_version ] ) ) {
|
449 |
+
|
450 |
+
// Pro plugin directory exist?
|
451 |
+
if ( file_exists( WP_PLUGIN_DIR . '/' . $plugins[ $lite_version ]['init'] ) ) {
|
452 |
+
return $plugins[ $lite_version ];
|
453 |
+
}
|
454 |
+
}
|
455 |
+
|
456 |
+
return false;
|
457 |
+
}
|
458 |
+
|
459 |
+
}
|
460 |
+
|
461 |
+
/**
|
462 |
+
* Kicking this off by calling 'get_instance()' method
|
463 |
+
*/
|
464 |
+
Astra_Sites::get_instance();
|
465 |
+
|
466 |
+
endif;
|
inc/importers/wxr-importer/class-astra-wxr-importer.php
CHANGED
@@ -1,344 +1,344 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class Astra WXR Importer
|
4 |
-
*
|
5 |
-
* @since 1.0.0
|
6 |
-
* @package Astra Addon
|
7 |
-
*/
|
8 |
-
|
9 |
-
defined( 'ABSPATH' ) or exit;
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Astra WXR Importer
|
13 |
-
*
|
14 |
-
* @since 1.0.0
|
15 |
-
*/
|
16 |
-
class Astra_WXR_Importer {
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Instance of Astra_WXR_Importer
|
20 |
-
*
|
21 |
-
* @since 1.0.0
|
22 |
-
* @var Astra_WXR_Importer
|
23 |
-
*/
|
24 |
-
private static $_instance = null;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Instantiate Astra_WXR_Importer
|
28 |
-
*
|
29 |
-
* @since 1.0.0
|
30 |
-
* @return (Object) Astra_WXR_Importer.
|
31 |
-
*/
|
32 |
-
public static function instance() {
|
33 |
-
if ( ! isset( self::$_instance ) ) {
|
34 |
-
self::$_instance = new self();
|
35 |
-
}
|
36 |
-
|
37 |
-
return self::$_instance;
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Constructor.
|
42 |
-
*
|
43 |
-
* @since 1.0.0
|
44 |
-
*/
|
45 |
-
private function __construct() {
|
46 |
-
|
47 |
-
require_once ABSPATH . '/wp-admin/includes/class-wp-importer.php';
|
48 |
-
require_once ASTRA_SITES_DIR . 'inc/importers/wxr-importer/class-logger.php';
|
49 |
-
require_once ASTRA_SITES_DIR . 'inc/importers/wxr-importer/class-wp-importer-logger-serversentevents.php';
|
50 |
-
require_once ASTRA_SITES_DIR . 'inc/importers/wxr-importer/class-wxr-importer.php';
|
51 |
-
require_once ASTRA_SITES_DIR . 'inc/importers/wxr-importer/class-wxr-import-info.php';
|
52 |
-
|
53 |
-
add_filter( 'upload_mimes', array( $this, 'custom_upload_mimes' ) );
|
54 |
-
add_action( 'wp_ajax_astra-wxr-import', array( $this, 'sse_import' ) );
|
55 |
-
add_filter( 'wxr_importer.pre_process.user', '__return_null' );
|
56 |
-
add_filter( 'wp_check_filetype_and_ext', array( $this, 'real_mime_type_for_xml' ), 10, 4 );
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Different MIME type of different PHP version
|
61 |
-
*
|
62 |
-
* Filters the "real" file type of the given file.
|
63 |
-
*
|
64 |
-
* @since 1.2.9
|
65 |
-
*
|
66 |
-
* @param array $defaults File data array containing 'ext', 'type', and
|
67 |
-
* 'proper_filename' keys.
|
68 |
-
* @param string $file Full path to the file.
|
69 |
-
* @param string $filename The name of the file (may differ from $file due to
|
70 |
-
* $file being in a tmp directory).
|
71 |
-
* @param array $mimes Key is the file extension with value as the mime type.
|
72 |
-
*/
|
73 |
-
function real_mime_type_for_xml( $defaults, $file, $filename, $mimes ) {
|
74 |
-
|
75 |
-
// Set EXT and real MIME type only for the file name `wxr.xml`.
|
76 |
-
if ( 'wxr.xml' == $filename ) {
|
77 |
-
$defaults['ext'] = 'xml';
|
78 |
-
$defaults['type'] = 'text/xml';
|
79 |
-
}
|
80 |
-
|
81 |
-
return $defaults;
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Constructor.
|
86 |
-
*
|
87 |
-
* @since 1.1.0
|
88 |
-
*/
|
89 |
-
function sse_import() {
|
90 |
-
|
91 |
-
// Start the event stream.
|
92 |
-
header( 'Content-Type: text/event-stream' );
|
93 |
-
|
94 |
-
// Turn off PHP output compression.
|
95 |
-
$previous = error_reporting( error_reporting() ^ E_WARNING );
|
96 |
-
ini_set( 'output_buffering', 'off' );
|
97 |
-
ini_set( 'zlib.output_compression', false );
|
98 |
-
error_reporting( $previous );
|
99 |
-
|
100 |
-
if ( $GLOBALS['is_nginx'] ) {
|
101 |
-
// Setting this header instructs Nginx to disable fastcgi_buffering
|
102 |
-
// and disable gzip for this request.
|
103 |
-
header( 'X-Accel-Buffering: no' );
|
104 |
-
header( 'Content-Encoding: none' );
|
105 |
-
}
|
106 |
-
|
107 |
-
$xml_url = urldecode( $_REQUEST['xml_url'] );
|
108 |
-
if ( empty( $xml_url ) ) {
|
109 |
-
exit;
|
110 |
-
}
|
111 |
-
|
112 |
-
// 2KB padding for IE
|
113 |
-
echo ':' . str_repeat( ' ', 2048 ) . "\n\n";
|
114 |
-
|
115 |
-
// Time to run the import!
|
116 |
-
set_time_limit( 0 );
|
117 |
-
|
118 |
-
// Ensure we're not buffered.
|
119 |
-
wp_ob_end_flush_all();
|
120 |
-
flush();
|
121 |
-
|
122 |
-
// Are we allowed to create users?
|
123 |
-
add_filter( 'wxr_importer.pre_process.user', '__return_null' );
|
124 |
-
|
125 |
-
// Keep track of our progress.
|
126 |
-
add_action( 'wxr_importer.processed.post', array( $this, 'imported_post' ), 10, 2 );
|
127 |
-
add_action( 'wxr_importer.process_failed.post', array( $this, 'imported_post' ), 10, 2 );
|
128 |
-
add_action( 'wxr_importer.process_already_imported.post', array( $this, 'already_imported_post' ), 10, 2 );
|
129 |
-
add_action( 'wxr_importer.process_skipped.post', array( $this, 'already_imported_post' ), 10, 2 );
|
130 |
-
add_action( 'wxr_importer.processed.comment', array( $this, 'imported_comment' ) );
|
131 |
-
add_action( 'wxr_importer.process_already_imported.comment', array( $this, 'imported_comment' ) );
|
132 |
-
add_action( 'wxr_importer.processed.term', array( $this, 'imported_term' ) );
|
133 |
-
add_action( 'wxr_importer.process_failed.term', array( $this, 'imported_term' ) );
|
134 |
-
add_action( 'wxr_importer.process_already_imported.term', array( $this, 'imported_term' ) );
|
135 |
-
add_action( 'wxr_importer.processed.user', array( $this, 'imported_user' ) );
|
136 |
-
add_action( 'wxr_importer.process_failed.user', array( $this, 'imported_user' ) );
|
137 |
-
// Flush once more.
|
138 |
-
flush();
|
139 |
-
|
140 |
-
$importer = $this->get_importer();
|
141 |
-
$response = $importer->import( $xml_url );
|
142 |
-
|
143 |
-
// Let the browser know we're done.
|
144 |
-
$complete = array(
|
145 |
-
'action' => 'complete',
|
146 |
-
'error' => false,
|
147 |
-
);
|
148 |
-
if ( is_wp_error( $response ) ) {
|
149 |
-
$complete['error'] = $response->get_error_message();
|
150 |
-
}
|
151 |
-
|
152 |
-
$this->emit_sse_message( $complete );
|
153 |
-
exit;
|
154 |
-
}
|
155 |
-
|
156 |
-
/**
|
157 |
-
* Add .xml files as supported format in the uploader.
|
158 |
-
*
|
159 |
-
* @since 1.1.5 Added SVG file support.
|
160 |
-
*
|
161 |
-
* @since 1.0.0
|
162 |
-
*
|
163 |
-
* @param array $mimes Already supported mime types.
|
164 |
-
*/
|
165 |
-
public function custom_upload_mimes( $mimes ) {
|
166 |
-
|
167 |
-
// Allow SVG files.
|
168 |
-
$mimes['svg'] = 'image/svg+xml';
|
169 |
-
$mimes['svgz'] = 'image/svg+xml';
|
170 |
-
|
171 |
-
// Allow XML files.
|
172 |
-
$mimes['xml'] = 'text/xml';
|
173 |
-
|
174 |
-
return $mimes;
|
175 |
-
}
|
176 |
-
|
177 |
-
/**
|
178 |
-
* Start the xml import.
|
179 |
-
*
|
180 |
-
* @since 1.0.0
|
181 |
-
*
|
182 |
-
* @param (String) $path Absolute path to the XML file.
|
183 |
-
*/
|
184 |
-
public function get_xml_data( $path ) {
|
185 |
-
|
186 |
-
$args = array(
|
187 |
-
'action' => 'astra-wxr-import',
|
188 |
-
'id' => '1',
|
189 |
-
'xml_url' => $path,
|
190 |
-
);
|
191 |
-
$url = add_query_arg( urlencode_deep( $args ), admin_url( 'admin-ajax.php' ) );
|
192 |
-
|
193 |
-
$data = $this->get_data( $path );
|
194 |
-
|
195 |
-
return array(
|
196 |
-
'count' => array(
|
197 |
-
'posts' => $data->post_count,
|
198 |
-
'media' => $data->media_count,
|
199 |
-
'users' => count( $data->users ),
|
200 |
-
'comments' => $data->comment_count,
|
201 |
-
'terms' => $data->term_count,
|
202 |
-
),
|
203 |
-
'url' => $url,
|
204 |
-
'strings' => array(
|
205 |
-
'complete' => __( 'Import complete!', 'astra-sites' ),
|
206 |
-
),
|
207 |
-
);
|
208 |
-
}
|
209 |
-
|
210 |
-
/**
|
211 |
-
* Get XML data.
|
212 |
-
*
|
213 |
-
* @since 1.1.0
|
214 |
-
* @param string $url Downloaded XML file absolute URL.
|
215 |
-
* @return array XML file data.
|
216 |
-
*/
|
217 |
-
function get_data( $url ) {
|
218 |
-
$importer = $this->get_importer();
|
219 |
-
$data = $importer->get_preliminary_information( $url );
|
220 |
-
if ( is_wp_error( $data ) ) {
|
221 |
-
return $data;
|
222 |
-
}
|
223 |
-
return $data;
|
224 |
-
}
|
225 |
-
|
226 |
-
/**
|
227 |
-
* Get Importer
|
228 |
-
*
|
229 |
-
* @since 1.1.0
|
230 |
-
* @return object Importer object.
|
231 |
-
*/
|
232 |
-
public function get_importer() {
|
233 |
-
$options = apply_filters(
|
234 |
-
'astra_sites_xml_import_options',
|
235 |
-
array(
|
236 |
-
'fetch_attachments' => true,
|
237 |
-
'default_author' => get_current_user_id(),
|
238 |
-
)
|
239 |
-
);
|
240 |
-
|
241 |
-
$importer = new WXR_Importer( $options );
|
242 |
-
$logger = new WP_Importer_Logger_ServerSentEvents();
|
243 |
-
|
244 |
-
$importer->set_logger( $logger );
|
245 |
-
return $importer;
|
246 |
-
}
|
247 |
-
|
248 |
-
/**
|
249 |
-
* Send message when a post has been imported.
|
250 |
-
*
|
251 |
-
* @since 1.1.0
|
252 |
-
* @param int $id Post ID.
|
253 |
-
* @param array $data Post data saved to the DB.
|
254 |
-
*/
|
255 |
-
public function imported_post( $id, $data ) {
|
256 |
-
$this->emit_sse_message(
|
257 |
-
array(
|
258 |
-
'action' => 'updateDelta',
|
259 |
-
'type' => ( 'attachment' === $data['post_type'] ) ? 'media' : 'posts',
|
260 |
-
'delta' => 1,
|
261 |
-
)
|
262 |
-
);
|
263 |
-
}
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Send message when a post is marked as already imported.
|
267 |
-
*
|
268 |
-
* @since 1.1.0
|
269 |
-
* @param array $data Post data saved to the DB.
|
270 |
-
*/
|
271 |
-
public function already_imported_post( $data ) {
|
272 |
-
$this->emit_sse_message(
|
273 |
-
array(
|
274 |
-
'action' => 'updateDelta',
|
275 |
-
'type' => ( 'attachment' === $data['post_type'] ) ? 'media' : 'posts',
|
276 |
-
'delta' => 1,
|
277 |
-
)
|
278 |
-
);
|
279 |
-
}
|
280 |
-
|
281 |
-
/**
|
282 |
-
* Send message when a comment has been imported.
|
283 |
-
*
|
284 |
-
* @since 1.1.0
|
285 |
-
*/
|
286 |
-
public function imported_comment() {
|
287 |
-
$this->emit_sse_message(
|
288 |
-
array(
|
289 |
-
'action' => 'updateDelta',
|
290 |
-
'type' => 'comments',
|
291 |
-
'delta' => 1,
|
292 |
-
)
|
293 |
-
);
|
294 |
-
}
|
295 |
-
|
296 |
-
/**
|
297 |
-
* Send message when a term has been imported.
|
298 |
-
*
|
299 |
-
* @since 1.1.0
|
300 |
-
*/
|
301 |
-
public function imported_term() {
|
302 |
-
$this->emit_sse_message(
|
303 |
-
array(
|
304 |
-
'action' => 'updateDelta',
|
305 |
-
'type' => 'terms',
|
306 |
-
'delta' => 1,
|
307 |
-
)
|
308 |
-
);
|
309 |
-
}
|
310 |
-
|
311 |
-
/**
|
312 |
-
* Send message when a user has been imported.
|
313 |
-
*
|
314 |
-
* @since 1.1.0
|
315 |
-
*/
|
316 |
-
public function imported_user() {
|
317 |
-
$this->emit_sse_message(
|
318 |
-
array(
|
319 |
-
'action' => 'updateDelta',
|
320 |
-
'type' => 'users',
|
321 |
-
'delta' => 1,
|
322 |
-
)
|
323 |
-
);
|
324 |
-
}
|
325 |
-
|
326 |
-
/**
|
327 |
-
* Emit a Server-Sent Events message.
|
328 |
-
*
|
329 |
-
* @since 1.1.0
|
330 |
-
* @param mixed $data Data to be JSON-encoded and sent in the message.
|
331 |
-
*/
|
332 |
-
public function emit_sse_message( $data ) {
|
333 |
-
echo "event: message\n";
|
334 |
-
echo 'data: ' . wp_json_encode( $data ) . "\n\n";
|
335 |
-
|
336 |
-
// Extra padding.
|
337 |
-
echo ':' . str_repeat( ' ', 2048 ) . "\n\n";
|
338 |
-
|
339 |
-
flush();
|
340 |
-
}
|
341 |
-
|
342 |
-
}
|
343 |
-
|
344 |
-
Astra_WXR_Importer::instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Astra WXR Importer
|
4 |
+
*
|
5 |
+
* @since 1.0.0
|
6 |
+
* @package Astra Addon
|
7 |
+
*/
|
8 |
+
|
9 |
+
defined( 'ABSPATH' ) or exit;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Astra WXR Importer
|
13 |
+
*
|
14 |
+
* @since 1.0.0
|
15 |
+
*/
|
16 |
+
class Astra_WXR_Importer {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Instance of Astra_WXR_Importer
|
20 |
+
*
|
21 |
+
* @since 1.0.0
|
22 |
+
* @var Astra_WXR_Importer
|
23 |
+
*/
|
24 |
+
private static $_instance = null;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Instantiate Astra_WXR_Importer
|
28 |
+
*
|
29 |
+
* @since 1.0.0
|
30 |
+
* @return (Object) Astra_WXR_Importer.
|
31 |
+
*/
|
32 |
+
public static function instance() {
|
33 |
+
if ( ! isset( self::$_instance ) ) {
|
34 |
+
self::$_instance = new self();
|
35 |
+
}
|
36 |
+
|
37 |
+
return self::$_instance;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Constructor.
|
42 |
+
*
|
43 |
+
* @since 1.0.0
|
44 |
+
*/
|
45 |
+
private function __construct() {
|
46 |
+
|
47 |
+
require_once ABSPATH . '/wp-admin/includes/class-wp-importer.php';
|
48 |
+
require_once ASTRA_SITES_DIR . 'inc/importers/wxr-importer/class-logger.php';
|
49 |
+
require_once ASTRA_SITES_DIR . 'inc/importers/wxr-importer/class-wp-importer-logger-serversentevents.php';
|
50 |
+
require_once ASTRA_SITES_DIR . 'inc/importers/wxr-importer/class-wxr-importer.php';
|
51 |
+
require_once ASTRA_SITES_DIR . 'inc/importers/wxr-importer/class-wxr-import-info.php';
|
52 |
+
|
53 |
+
add_filter( 'upload_mimes', array( $this, 'custom_upload_mimes' ) );
|
54 |
+
add_action( 'wp_ajax_astra-wxr-import', array( $this, 'sse_import' ) );
|
55 |
+
add_filter( 'wxr_importer.pre_process.user', '__return_null' );
|
56 |
+
add_filter( 'wp_check_filetype_and_ext', array( $this, 'real_mime_type_for_xml' ), 10, 4 );
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Different MIME type of different PHP version
|
61 |
+
*
|
62 |
+
* Filters the "real" file type of the given file.
|
63 |
+
*
|
64 |
+
* @since 1.2.9
|
65 |
+
*
|
66 |
+
* @param array $defaults File data array containing 'ext', 'type', and
|
67 |
+
* 'proper_filename' keys.
|
68 |
+
* @param string $file Full path to the file.
|
69 |
+
* @param string $filename The name of the file (may differ from $file due to
|
70 |
+
* $file being in a tmp directory).
|
71 |
+
* @param array $mimes Key is the file extension with value as the mime type.
|
72 |
+
*/
|
73 |
+
function real_mime_type_for_xml( $defaults, $file, $filename, $mimes ) {
|
74 |
+
|
75 |
+
// Set EXT and real MIME type only for the file name `wxr.xml`.
|
76 |
+
if ( 'wxr.xml' == $filename ) {
|
77 |
+
$defaults['ext'] = 'xml';
|
78 |
+
$defaults['type'] = 'text/xml';
|
79 |
+
}
|
80 |
+
|
81 |
+
return $defaults;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Constructor.
|
86 |
+
*
|
87 |
+
* @since 1.1.0
|
88 |
+
*/
|
89 |
+
function sse_import() {
|
90 |
+
|
91 |
+
// Start the event stream.
|
92 |
+
header( 'Content-Type: text/event-stream, charset=UTF-8' );
|
93 |
+
|
94 |
+
// Turn off PHP output compression.
|
95 |
+
$previous = error_reporting( error_reporting() ^ E_WARNING );
|
96 |
+
ini_set( 'output_buffering', 'off' );
|
97 |
+
ini_set( 'zlib.output_compression', false );
|
98 |
+
error_reporting( $previous );
|
99 |
+
|
100 |
+
if ( $GLOBALS['is_nginx'] ) {
|
101 |
+
// Setting this header instructs Nginx to disable fastcgi_buffering
|
102 |
+
// and disable gzip for this request.
|
103 |
+
header( 'X-Accel-Buffering: no' );
|
104 |
+
header( 'Content-Encoding: none' );
|
105 |
+
}
|
106 |
+
|
107 |
+
$xml_url = urldecode( $_REQUEST['xml_url'] );
|
108 |
+
if ( empty( $xml_url ) ) {
|
109 |
+
exit;
|
110 |
+
}
|
111 |
+
|
112 |
+
// 2KB padding for IE
|
113 |
+
echo ':' . str_repeat( ' ', 2048 ) . "\n\n";
|
114 |
+
|
115 |
+
// Time to run the import!
|
116 |
+
set_time_limit( 0 );
|
117 |
+
|
118 |
+
// Ensure we're not buffered.
|
119 |
+
wp_ob_end_flush_all();
|
120 |
+
flush();
|
121 |
+
|
122 |
+
// Are we allowed to create users?
|
123 |
+
add_filter( 'wxr_importer.pre_process.user', '__return_null' );
|
124 |
+
|
125 |
+
// Keep track of our progress.
|
126 |
+
add_action( 'wxr_importer.processed.post', array( $this, 'imported_post' ), 10, 2 );
|
127 |
+
add_action( 'wxr_importer.process_failed.post', array( $this, 'imported_post' ), 10, 2 );
|
128 |
+
add_action( 'wxr_importer.process_already_imported.post', array( $this, 'already_imported_post' ), 10, 2 );
|
129 |
+
add_action( 'wxr_importer.process_skipped.post', array( $this, 'already_imported_post' ), 10, 2 );
|
130 |
+
add_action( 'wxr_importer.processed.comment', array( $this, 'imported_comment' ) );
|
131 |
+
add_action( 'wxr_importer.process_already_imported.comment', array( $this, 'imported_comment' ) );
|
132 |
+
add_action( 'wxr_importer.processed.term', array( $this, 'imported_term' ) );
|
133 |
+
add_action( 'wxr_importer.process_failed.term', array( $this, 'imported_term' ) );
|
134 |
+
add_action( 'wxr_importer.process_already_imported.term', array( $this, 'imported_term' ) );
|
135 |
+
add_action( 'wxr_importer.processed.user', array( $this, 'imported_user' ) );
|
136 |
+
add_action( 'wxr_importer.process_failed.user', array( $this, 'imported_user' ) );
|
137 |
+
// Flush once more.
|
138 |
+
flush();
|
139 |
+
|
140 |
+
$importer = $this->get_importer();
|
141 |
+
$response = $importer->import( $xml_url );
|
142 |
+
|
143 |
+
// Let the browser know we're done.
|
144 |
+
$complete = array(
|
145 |
+
'action' => 'complete',
|
146 |
+
'error' => false,
|
147 |
+
);
|
148 |
+
if ( is_wp_error( $response ) ) {
|
149 |
+
$complete['error'] = $response->get_error_message();
|
150 |
+
}
|
151 |
+
|
152 |
+
$this->emit_sse_message( $complete );
|
153 |
+
exit;
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Add .xml files as supported format in the uploader.
|
158 |
+
*
|
159 |
+
* @since 1.1.5 Added SVG file support.
|
160 |
+
*
|
161 |
+
* @since 1.0.0
|
162 |
+
*
|
163 |
+
* @param array $mimes Already supported mime types.
|
164 |
+
*/
|
165 |
+
public function custom_upload_mimes( $mimes ) {
|
166 |
+
|
167 |
+
// Allow SVG files.
|
168 |
+
$mimes['svg'] = 'image/svg+xml';
|
169 |
+
$mimes['svgz'] = 'image/svg+xml';
|
170 |
+
|
171 |
+
// Allow XML files.
|
172 |
+
$mimes['xml'] = 'text/xml';
|
173 |
+
|
174 |
+
return $mimes;
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Start the xml import.
|
179 |
+
*
|
180 |
+
* @since 1.0.0
|
181 |
+
*
|
182 |
+
* @param (String) $path Absolute path to the XML file.
|
183 |
+
*/
|
184 |
+
public function get_xml_data( $path ) {
|
185 |
+
|
186 |
+
$args = array(
|
187 |
+
'action' => 'astra-wxr-import',
|
188 |
+
'id' => '1',
|
189 |
+
'xml_url' => $path,
|
190 |
+
);
|
191 |
+
$url = add_query_arg( urlencode_deep( $args ), admin_url( 'admin-ajax.php' ) );
|
192 |
+
|
193 |
+
$data = $this->get_data( $path );
|
194 |
+
|
195 |
+
return array(
|
196 |
+
'count' => array(
|
197 |
+
'posts' => $data->post_count,
|
198 |
+
'media' => $data->media_count,
|
199 |
+
'users' => count( $data->users ),
|
200 |
+
'comments' => $data->comment_count,
|
201 |
+
'terms' => $data->term_count,
|
202 |
+
),
|
203 |
+
'url' => $url,
|
204 |
+
'strings' => array(
|
205 |
+
'complete' => __( 'Import complete!', 'astra-sites' ),
|
206 |
+
),
|
207 |
+
);
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Get XML data.
|
212 |
+
*
|
213 |
+
* @since 1.1.0
|
214 |
+
* @param string $url Downloaded XML file absolute URL.
|
215 |
+
* @return array XML file data.
|
216 |
+
*/
|
217 |
+
function get_data( $url ) {
|
218 |
+
$importer = $this->get_importer();
|
219 |
+
$data = $importer->get_preliminary_information( $url );
|
220 |
+
if ( is_wp_error( $data ) ) {
|
221 |
+
return $data;
|
222 |
+
}
|
223 |
+
return $data;
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Get Importer
|
228 |
+
*
|
229 |
+
* @since 1.1.0
|
230 |
+
* @return object Importer object.
|
231 |
+
*/
|
232 |
+
public function get_importer() {
|
233 |
+
$options = apply_filters(
|
234 |
+
'astra_sites_xml_import_options',
|
235 |
+
array(
|
236 |
+
'fetch_attachments' => true,
|
237 |
+
'default_author' => get_current_user_id(),
|
238 |
+
)
|
239 |
+
);
|
240 |
+
|
241 |
+
$importer = new WXR_Importer( $options );
|
242 |
+
$logger = new WP_Importer_Logger_ServerSentEvents();
|
243 |
+
|
244 |
+
$importer->set_logger( $logger );
|
245 |
+
return $importer;
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* Send message when a post has been imported.
|
250 |
+
*
|
251 |
+
* @since 1.1.0
|
252 |
+
* @param int $id Post ID.
|
253 |
+
* @param array $data Post data saved to the DB.
|
254 |
+
*/
|
255 |
+
public function imported_post( $id, $data ) {
|
256 |
+
$this->emit_sse_message(
|
257 |
+
array(
|
258 |
+
'action' => 'updateDelta',
|
259 |
+
'type' => ( 'attachment' === $data['post_type'] ) ? 'media' : 'posts',
|
260 |
+
'delta' => 1,
|
261 |
+
)
|
262 |
+
);
|
263 |
+
}
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Send message when a post is marked as already imported.
|
267 |
+
*
|
268 |
+
* @since 1.1.0
|
269 |
+
* @param array $data Post data saved to the DB.
|
270 |
+
*/
|
271 |
+
public function already_imported_post( $data ) {
|
272 |
+
$this->emit_sse_message(
|
273 |
+
array(
|
274 |
+
'action' => 'updateDelta',
|
275 |
+
'type' => ( 'attachment' === $data['post_type'] ) ? 'media' : 'posts',
|
276 |
+
'delta' => 1,
|
277 |
+
)
|
278 |
+
);
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Send message when a comment has been imported.
|
283 |
+
*
|
284 |
+
* @since 1.1.0
|
285 |
+
*/
|
286 |
+
public function imported_comment() {
|
287 |
+
$this->emit_sse_message(
|
288 |
+
array(
|
289 |
+
'action' => 'updateDelta',
|
290 |
+
'type' => 'comments',
|
291 |
+
'delta' => 1,
|
292 |
+
)
|
293 |
+
);
|
294 |
+
}
|
295 |
+
|
296 |
+
/**
|
297 |
+
* Send message when a term has been imported.
|
298 |
+
*
|
299 |
+
* @since 1.1.0
|
300 |
+
*/
|
301 |
+
public function imported_term() {
|
302 |
+
$this->emit_sse_message(
|
303 |
+
array(
|
304 |
+
'action' => 'updateDelta',
|
305 |
+
'type' => 'terms',
|
306 |
+
'delta' => 1,
|
307 |
+
)
|
308 |
+
);
|
309 |
+
}
|
310 |
+
|
311 |
+
/**
|
312 |
+
* Send message when a user has been imported.
|
313 |
+
*
|
314 |
+
* @since 1.1.0
|
315 |
+
*/
|
316 |
+
public function imported_user() {
|
317 |
+
$this->emit_sse_message(
|
318 |
+
array(
|
319 |
+
'action' => 'updateDelta',
|
320 |
+
'type' => 'users',
|
321 |
+
'delta' => 1,
|
322 |
+
)
|
323 |
+
);
|
324 |
+
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
* Emit a Server-Sent Events message.
|
328 |
+
*
|
329 |
+
* @since 1.1.0
|
330 |
+
* @param mixed $data Data to be JSON-encoded and sent in the message.
|
331 |
+
*/
|
332 |
+
public function emit_sse_message( $data ) {
|
333 |
+
echo "event: message\n";
|
334 |
+
echo 'data: ' . wp_json_encode( $data ) . "\n\n";
|
335 |
+
|
336 |
+
// Extra padding.
|
337 |
+
echo ':' . str_repeat( ' ', 2048 ) . "\n\n";
|
338 |
+
|
339 |
+
flush();
|
340 |
+
}
|
341 |
+
|
342 |
+
}
|
343 |
+
|
344 |
+
Astra_WXR_Importer::instance();
|
inc/includes/admin-page.php
CHANGED
@@ -1,299 +1,311 @@
|
|
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 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
<
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
<
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
<
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
<
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
data-demo-
|
94 |
-
data-demo-
|
95 |
-
data-demo-
|
96 |
-
data-demo-
|
97 |
-
data-demo-
|
98 |
-
data-
|
99 |
-
data-
|
100 |
-
data-
|
101 |
-
|
102 |
-
<input type="hidden" class="astra-
|
103 |
-
<
|
104 |
-
<button class="
|
105 |
-
<button class="
|
106 |
-
<
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
<
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
<
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
<span class="collapse-sidebar-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
<
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
<
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
<
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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">
|
30 |
+
<div id="astra-site-page-builder"></div>
|
31 |
+
</div>
|
32 |
+
|
33 |
+
</div>
|
34 |
+
|
35 |
+
<div class="section-right">
|
36 |
+
|
37 |
+
<div class="filters-wrap">
|
38 |
+
<div id="astra-site-category"></div>
|
39 |
+
</div>
|
40 |
+
|
41 |
+
<div class="search-form">
|
42 |
+
<label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'astra-sites' ); ?> </label>
|
43 |
+
<input placeholder="<?php _e( 'Search Sites...', 'astra-sites' ); ?>" type="search" aria-describedby="live-search-desc" id="wp-filter-search-input" class="wp-filter-search">
|
44 |
+
</div>
|
45 |
+
|
46 |
+
</div>
|
47 |
+
</div>
|
48 |
+
<?php } ?>
|
49 |
+
|
50 |
+
</div>
|
51 |
+
|
52 |
+
<?php do_action( 'astra_sites_before_site_grid' ); ?>
|
53 |
+
|
54 |
+
<div class="theme-browser rendered">
|
55 |
+
<div id="astra-sites" class="themes wp-clearfix"></div>
|
56 |
+
</div>
|
57 |
+
|
58 |
+
<div class="spinner-wrap">
|
59 |
+
<span class="spinner"></span>
|
60 |
+
</div>
|
61 |
+
|
62 |
+
<?php do_action( 'astra_sites_after_site_grid' ); ?>
|
63 |
+
|
64 |
+
</div>
|
65 |
+
|
66 |
+
<?php
|
67 |
+
/**
|
68 |
+
* TMPL - Single Demo Preview
|
69 |
+
*/
|
70 |
+
?>
|
71 |
+
<script type="text/template" id="tmpl-astra-site-select-page-builder">
|
72 |
+
<div class="select-page-builder">
|
73 |
+
<div class="note-wrap">
|
74 |
+
<h3>
|
75 |
+
<span class="up-arrow dashicons dashicons-editor-break"></span>
|
76 |
+
<div class="note"><?php _e( 'Select Your Favorite Page Builder', 'astra-sites' ); ?></div>
|
77 |
+
</h3>
|
78 |
+
</div>
|
79 |
+
<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' ); ?>" />
|
80 |
+
</div>
|
81 |
+
</script>
|
82 |
+
|
83 |
+
<?php
|
84 |
+
/**
|
85 |
+
* TMPL - Single Demo Preview
|
86 |
+
*/
|
87 |
+
?>
|
88 |
+
<script type="text/template" id="tmpl-astra-site-preview">
|
89 |
+
<div class="astra-sites-preview theme-install-overlay wp-full-overlay expanded">
|
90 |
+
<div class="wp-full-overlay-sidebar">
|
91 |
+
<div class="wp-full-overlay-header"
|
92 |
+
data-demo-id="{{{data.id}}}"
|
93 |
+
data-demo-type="{{{data.astra_demo_type}}}"
|
94 |
+
data-demo-url="{{{data.astra_demo_url}}}"
|
95 |
+
data-demo-api="{{{data.demo_api}}}"
|
96 |
+
data-demo-name="{{{data.demo_name}}}"
|
97 |
+
data-demo-slug="{{{data.slug}}}"
|
98 |
+
data-screenshot="{{{data.screenshot}}}"
|
99 |
+
data-content="{{{data.content}}}"
|
100 |
+
data-required-plugins="{{data.required_plugins}}">
|
101 |
+
<input type="hidden" class="astra-site-options" value="{{data.astra_site_options}}" >
|
102 |
+
<input type="hidden" class="astra-enabled-extensions" value="{{data.astra_enabled_extensions}}" >
|
103 |
+
<button class="close-full-overlay"><span class="screen-reader-text"><?php esc_html_e( 'Close', 'astra-sites' ); ?></span></button>
|
104 |
+
<button class="previous-theme"><span class="screen-reader-text"><?php esc_html_e( 'Previous', 'astra-sites' ); ?></span></button>
|
105 |
+
<button class="next-theme"><span class="screen-reader-text"><?php esc_html_e( 'Next', 'astra-sites' ); ?></span></button>
|
106 |
+
<a class="button hide-if-no-customize astra-demo-import" href="#" data-import="disabled"><?php esc_html_e( 'Install Plugins', 'astra-sites' ); ?></a>
|
107 |
+
|
108 |
+
</div>
|
109 |
+
<div class="wp-full-overlay-sidebar-content">
|
110 |
+
<div class="install-theme-info">
|
111 |
+
|
112 |
+
<span class="site-type {{{data.astra_demo_type}}}">{{{data.astra_demo_type}}}</span>
|
113 |
+
<h3 class="theme-name">{{{data.demo_name}}}</h3>
|
114 |
+
|
115 |
+
<# if ( data.screenshot.length ) { #>
|
116 |
+
<img class="theme-screenshot" src="{{{data.screenshot}}}" alt="">
|
117 |
+
<# } #>
|
118 |
+
|
119 |
+
<div class="theme-details">
|
120 |
+
{{{data.content}}}
|
121 |
+
</div>
|
122 |
+
<a href="#" class="theme-details-read-more"><?php _e( 'Read more', 'astra-sites' ); ?> …</a>
|
123 |
+
|
124 |
+
<div class="required-plugins-wrap">
|
125 |
+
<h4><?php _e( 'Required Plugins', 'astra-sites' ); ?> </h4>
|
126 |
+
<div class="required-plugins"></div>
|
127 |
+
</div>
|
128 |
+
</div>
|
129 |
+
</div>
|
130 |
+
|
131 |
+
<div class="wp-full-overlay-footer">
|
132 |
+
<div class="footer-import-button-wrap">
|
133 |
+
<a class="button button-hero hide-if-no-customize astra-demo-import" href="#" data-import="disabled">
|
134 |
+
<?php esc_html_e( 'Install Plugins', 'astra-sites' ); ?>
|
135 |
+
</a>
|
136 |
+
</div>
|
137 |
+
<button type="button" class="collapse-sidebar button" aria-expanded="true"
|
138 |
+
aria-label="Collapse Sidebar">
|
139 |
+
<span class="collapse-sidebar-arrow"></span>
|
140 |
+
<span class="collapse-sidebar-label"><?php esc_html_e( 'Collapse', 'astra-sites' ); ?></span>
|
141 |
+
</button>
|
142 |
+
|
143 |
+
<div class="devices-wrapper">
|
144 |
+
<div class="devices">
|
145 |
+
<button type="button" class="preview-desktop active" aria-pressed="true" data-device="desktop">
|
146 |
+
<span class="screen-reader-text"><?php _e( 'Enter desktop preview mode', 'astra-sites' ); ?></span>
|
147 |
+
</button>
|
148 |
+
<button type="button" class="preview-tablet" aria-pressed="false" data-device="tablet">
|
149 |
+
<span class="screen-reader-text"><?php _e( 'Enter tablet preview mode', 'astra-sites' ); ?></span>
|
150 |
+
</button>
|
151 |
+
<button type="button" class="preview-mobile" aria-pressed="false" data-device="mobile">
|
152 |
+
<span class="screen-reader-text"><?php _e( 'Enter mobile preview mode', 'astra-sites' ); ?></span>
|
153 |
+
</button>
|
154 |
+
</div>
|
155 |
+
</div>
|
156 |
+
|
157 |
+
</div>
|
158 |
+
</div>
|
159 |
+
<div class="wp-full-overlay-main">
|
160 |
+
<iframe src="{{{data.astra_demo_url}}}" title="<?php esc_attr_e( 'Preview', 'astra-sites' ); ?>"></iframe>
|
161 |
+
</div>
|
162 |
+
</div>
|
163 |
+
</script>
|
164 |
+
|
165 |
+
<?php
|
166 |
+
/**
|
167 |
+
* TMPL - No more demos
|
168 |
+
*/
|
169 |
+
?>
|
170 |
+
<script type="text/template" id="tmpl-astra-site-api-request-failed">
|
171 |
+
<div class="no-themes">
|
172 |
+
<?php
|
173 |
+
|
174 |
+
/* translators: %1$s & %2$s are a Demo API URL */
|
175 |
+
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 ) );
|
176 |
+
|
177 |
+
_e( '<p class="left-margin"> 1. Sometimes, simple page reload fixes any temporary issues. No kidding!</p>', 'astra-sites' );
|
178 |
+
|
179 |
+
_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' );
|
180 |
+
|
181 |
+
/* translators: %1$s is a support link */
|
182 |
+
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' ) );
|
183 |
+
?>
|
184 |
+
</div>
|
185 |
+
</script>
|
186 |
+
|
187 |
+
<?php
|
188 |
+
/**
|
189 |
+
* TMPL - Site Down
|
190 |
+
*/
|
191 |
+
?>
|
192 |
+
<script type="text/template" id="tmpl-astra-site-down">
|
193 |
+
<div class="postbox astra-site-down">
|
194 |
+
<h2><?php _e( 'Under Maintenance..', 'astra-sites' ); ?></h2>
|
195 |
+
<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>
|
196 |
+
<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>
|
197 |
+
</div>
|
198 |
+
</script>
|
199 |
+
|
200 |
+
<?php
|
201 |
+
/**
|
202 |
+
* TMPL - Filters
|
203 |
+
*/
|
204 |
+
?>
|
205 |
+
<script type="text/template" id="tmpl-astra-site-filters">
|
206 |
+
|
207 |
+
<# if ( data ) { #>
|
208 |
+
|
209 |
+
<ul class="{{ data.args.wrapper_class }} {{ data.args.class }}">
|
210 |
+
|
211 |
+
<# if ( data.args.show_all ) { #>
|
212 |
+
<li>
|
213 |
+
<a href="#" data-group="all"> All </a>
|
214 |
+
</li>
|
215 |
+
<# } #>
|
216 |
+
|
217 |
+
<# for ( key in data.items ) { #>
|
218 |
+
<# if ( data.items[ key ].count ) { #>
|
219 |
+
<li>
|
220 |
+
<a href="#" data-group='{{ data.items[ key ].id }}' class="{{ data.items[ key ].name }}">
|
221 |
+
{{ data.items[ key ].name }}
|
222 |
+
</a>
|
223 |
+
</li>
|
224 |
+
<# } #>
|
225 |
+
<# } #>
|
226 |
+
|
227 |
+
</ul>
|
228 |
+
<# } #>
|
229 |
+
</script>
|
230 |
+
|
231 |
+
<?php
|
232 |
+
/**
|
233 |
+
* TMPL - List
|
234 |
+
*/
|
235 |
+
?>
|
236 |
+
<script type="text/template" id="tmpl-astra-sites-list">
|
237 |
+
|
238 |
+
<# if ( data.items.length ) { #>
|
239 |
+
<# for ( key in data.items ) { #>
|
240 |
+
|
241 |
+
<div class="theme astra-theme site-single {{ data.items[ key ].status }}" tabindex="0" aria-describedby="astra-theme-action astra-theme-name"
|
242 |
+
data-demo-id="{{{ data.items[ key ].id }}}"
|
243 |
+
data-demo-type="{{{ data.items[ key ]['astra-site-type'] }}}"
|
244 |
+
data-demo-url="{{{ data.items[ key ]['astra-site-url'] }}}"
|
245 |
+
data-demo-api="{{{ data.items[ key ]['_links']['self'][0]['href'] }}}"
|
246 |
+
data-demo-name="{{{ data.items[ key ].title.rendered }}}"
|
247 |
+
data-demo-slug="{{{ data.items[ key ].slug }}}"
|
248 |
+
data-screenshot="{{{ data.items[ key ]['featured-image-url'] }}}"
|
249 |
+
data-content="{{{ data.items[ key ].content.rendered }}}"
|
250 |
+
data-required-plugins="{{ JSON.stringify( data.items[ key ]['required-plugins'] ) }}"
|
251 |
+
data-groups=["{{ data.items[ key ].tags }}"]>
|
252 |
+
<input type="hidden" class="astra-site-options" value="{{ JSON.stringify(data.items[ key ]['astra-site-options-data'] ) }}" />
|
253 |
+
<input type="hidden" class="astra-enabled-extensions" value="{{ JSON.stringify(data.items[ key ]['astra-enabled-extensions'] ) }}" />
|
254 |
+
|
255 |
+
<div class="inner">
|
256 |
+
<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 }}">
|
257 |
+
<div class="theme-screenshot">
|
258 |
+
<# if( '' !== data.items[ key ]['featured-image-url'] ) { #>
|
259 |
+
<img src="{{ data.items[ key ]['featured-image-url'] }}" />
|
260 |
+
<# } #>
|
261 |
+
</div>
|
262 |
+
</span>
|
263 |
+
<span class="more-details"> <?php esc_html_e( 'Details & Preview', 'astra-sites' ); ?> </span>
|
264 |
+
<# if ( data.items[ key ]['astra-site-type'] ) { #>
|
265 |
+
<# var type = ( data.items[ key ]['astra-site-type'] !== 'premium' ) ? ( data.items[ key ]['astra-site-type'] ) : 'agency'; #>
|
266 |
+
<span class="site-type {{data.items[ key ]['astra-site-type']}}">{{ type }}</span>
|
267 |
+
<# } #>
|
268 |
+
<# if ( data.items[ key ].status ) { #>
|
269 |
+
<span class="status {{data.items[ key ].status}}">{{data.items[ key ].status}}</span>
|
270 |
+
<# } #>
|
271 |
+
<div class="theme-id-container">
|
272 |
+
<h3 class="theme-name" id="astra-theme-name"> {{{ data.items[ key ].title.rendered }}} </h3>
|
273 |
+
<div class="theme-actions">
|
274 |
+
<button class="button preview install-theme-preview"><?php esc_html_e( 'Preview', 'astra-sites' ); ?></button>
|
275 |
+
</div>
|
276 |
+
</div>
|
277 |
+
</div>
|
278 |
+
</div>
|
279 |
+
<# } #>
|
280 |
+
<# } else { #>
|
281 |
+
<p class="no-themes" style="display:block;">
|
282 |
+
<?php _e( 'No Demos found, Try a different search.', 'astra-sites' ); ?>
|
283 |
+
<span class="description">
|
284 |
+
<?php
|
285 |
+
/* translators: %1$s External Link */
|
286 |
+
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' ) );
|
287 |
+
?>
|
288 |
+
</span>
|
289 |
+
</p>
|
290 |
+
<# } #>
|
291 |
+
</script>
|
292 |
+
|
293 |
+
<?php
|
294 |
+
/**
|
295 |
+
* TMPL - List
|
296 |
+
*/
|
297 |
+
?>
|
298 |
+
<script type="text/template" id="tmpl-astra-sites-suggestions">
|
299 |
+
<div class="theme astra-theme site-single astra-sites-suggestions">
|
300 |
+
<div class="inner">
|
301 |
+
<p>
|
302 |
+
<?php
|
303 |
+
/* translators: %1$s External Link */
|
304 |
+
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' ) );
|
305 |
+
?>
|
306 |
+
</p>
|
307 |
+
</div>
|
308 |
+
</div>
|
309 |
+
</script>
|
310 |
+
<?php
|
311 |
+
wp_print_admin_notice_templates();
|
languages/astra-sites.pot
CHANGED
@@ -2,9 +2,9 @@
|
|
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.2.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/astra-sites\n"
|
7 |
-
"POT-Creation-Date: 2019-01-
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -25,6 +25,7 @@ msgstr ""
|
|
25 |
"X-Generator: grunt-wp-i18n1.0.0\n"
|
26 |
|
27 |
#: astra-sites.php:18 inc/classes/class-astra-sites-page.php:85
|
|
|
28 |
msgid "Astra Sites"
|
29 |
msgstr ""
|
30 |
|
@@ -97,11 +98,19 @@ msgstr ""
|
|
97 |
msgid "Settings saved successfully."
|
98 |
msgstr ""
|
99 |
|
100 |
-
#: inc/classes/class-astra-sites-white-label.php:
|
101 |
#. translators: %1$s product name
|
102 |
msgid "%1$s Branding"
|
103 |
msgstr ""
|
104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
#: inc/classes/class-astra-sites.php:81
|
106 |
#. translators: 1: theme.php file
|
107 |
msgid ""
|
@@ -180,7 +189,7 @@ msgstr ""
|
|
180 |
msgid "Importing.."
|
181 |
msgstr ""
|
182 |
|
183 |
-
#: inc/classes/class-astra-sites.php:237 inc/includes/admin-page.php:
|
184 |
msgid "Read more"
|
185 |
msgstr ""
|
186 |
|
@@ -192,7 +201,7 @@ msgstr ""
|
|
192 |
msgid "There was a problem receiving a response from server."
|
193 |
msgstr ""
|
194 |
|
195 |
-
#: inc/classes/class-astra-sites.php:240 inc/includes/admin-page.php:
|
196 |
msgid "No Demos found, Try a different search."
|
197 |
msgstr ""
|
198 |
|
@@ -526,83 +535,83 @@ msgstr ""
|
|
526 |
msgid "Could not update comment #%d with mapped data"
|
527 |
msgstr ""
|
528 |
|
529 |
-
#: inc/includes/admin-page.php:
|
530 |
msgid "Search Sites"
|
531 |
msgstr ""
|
532 |
|
533 |
-
#: inc/includes/admin-page.php:
|
534 |
msgid "Search Sites..."
|
535 |
msgstr ""
|
536 |
|
537 |
-
#: inc/includes/admin-page.php:
|
538 |
msgid "Select Your Favorite Page Builder"
|
539 |
msgstr ""
|
540 |
|
541 |
-
#: inc/includes/admin-page.php:
|
542 |
msgid "Sites List.."
|
543 |
msgstr ""
|
544 |
|
545 |
-
#: inc/includes/admin-page.php:
|
546 |
msgid "Close"
|
547 |
msgstr ""
|
548 |
|
549 |
-
#: inc/includes/admin-page.php:
|
550 |
msgid "Previous"
|
551 |
msgstr ""
|
552 |
|
553 |
-
#: inc/includes/admin-page.php:
|
554 |
msgid "Next"
|
555 |
msgstr ""
|
556 |
|
557 |
-
#: inc/includes/admin-page.php:
|
558 |
msgid "Install Plugins"
|
559 |
msgstr ""
|
560 |
|
561 |
-
#: inc/includes/admin-page.php:
|
562 |
msgid "Required Plugins"
|
563 |
msgstr ""
|
564 |
|
565 |
-
#: inc/includes/admin-page.php:
|
566 |
msgid "Collapse"
|
567 |
msgstr ""
|
568 |
|
569 |
-
#: inc/includes/admin-page.php:
|
570 |
msgid "Enter desktop preview mode"
|
571 |
msgstr ""
|
572 |
|
573 |
-
#: inc/includes/admin-page.php:
|
574 |
msgid "Enter tablet preview mode"
|
575 |
msgstr ""
|
576 |
|
577 |
-
#: inc/includes/admin-page.php:
|
578 |
msgid "Enter mobile preview mode"
|
579 |
msgstr ""
|
580 |
|
581 |
-
#: inc/includes/admin-page.php:
|
582 |
msgid "Preview"
|
583 |
msgstr ""
|
584 |
|
585 |
-
#: inc/includes/admin-page.php:
|
586 |
#. translators: %1$s & %2$s are a Demo API URL
|
587 |
msgid ""
|
588 |
"<p> It seems the demo data server, <i><a href=\"%1$s\">%2$s</a></i> is "
|
589 |
"unreachable from your site.</p>"
|
590 |
msgstr ""
|
591 |
|
592 |
-
#: inc/includes/admin-page.php:
|
593 |
msgid ""
|
594 |
"<p class=\"left-margin\"> 1. Sometimes, simple page reload fixes any "
|
595 |
"temporary issues. No kidding!</p>"
|
596 |
msgstr ""
|
597 |
|
598 |
-
#: inc/includes/admin-page.php:
|
599 |
msgid ""
|
600 |
"<p class=\"left-margin\"> 2. If that does not work, you will need to talk "
|
601 |
"to your server administrator and check if demo server is being blocked by "
|
602 |
"the firewall!</p>"
|
603 |
msgstr ""
|
604 |
|
605 |
-
#: inc/includes/admin-page.php:
|
606 |
#. translators: %1$s is a support link
|
607 |
msgid ""
|
608 |
"<p>If that does not help, please open up a <a href=\"%1$s\" "
|
@@ -610,11 +619,28 @@ msgid ""
|
|
610 |
"for you.</p>"
|
611 |
msgstr ""
|
612 |
|
613 |
-
#: inc/includes/admin-page.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
614 |
msgid "Details & Preview"
|
615 |
msgstr ""
|
616 |
|
617 |
-
#: inc/includes/admin-page.php:
|
618 |
#. translators: %1$s External Link
|
619 |
msgid ""
|
620 |
"Don't see a site that you would like to import?<br><a target=\"_blank\" "
|
@@ -637,14 +663,6 @@ msgstr ""
|
|
637 |
msgid "http://www.wpastra.com/pro/"
|
638 |
msgstr ""
|
639 |
|
640 |
-
#. Description of the plugin/theme
|
641 |
-
msgid "Import free sites build with Astra theme."
|
642 |
-
msgstr ""
|
643 |
-
|
644 |
-
#. Author of the plugin/theme
|
645 |
-
msgid "Brainstorm Force"
|
646 |
-
msgstr ""
|
647 |
-
|
648 |
#. Author URI of the plugin/theme
|
649 |
msgid "http://www.brainstormforce.com"
|
650 |
msgstr ""
|
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.2.11\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/astra-sites\n"
|
7 |
+
"POT-Creation-Date: 2019-01-24 06:48:32+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
25 |
"X-Generator: grunt-wp-i18n1.0.0\n"
|
26 |
|
27 |
#: astra-sites.php:18 inc/classes/class-astra-sites-page.php:85
|
28 |
+
#: inc/classes/class-astra-sites-white-label.php:232
|
29 |
msgid "Astra Sites"
|
30 |
msgstr ""
|
31 |
|
98 |
msgid "Settings saved successfully."
|
99 |
msgstr ""
|
100 |
|
101 |
+
#: inc/classes/class-astra-sites-white-label.php:189
|
102 |
#. translators: %1$s product name
|
103 |
msgid "%1$s Branding"
|
104 |
msgstr ""
|
105 |
|
106 |
+
#. Author of the plugin/theme
|
107 |
+
msgid "Brainstorm Force"
|
108 |
+
msgstr ""
|
109 |
+
|
110 |
+
#. Description of the plugin/theme
|
111 |
+
msgid "Import free sites build with Astra theme."
|
112 |
+
msgstr ""
|
113 |
+
|
114 |
#: inc/classes/class-astra-sites.php:81
|
115 |
#. translators: 1: theme.php file
|
116 |
msgid ""
|
189 |
msgid "Importing.."
|
190 |
msgstr ""
|
191 |
|
192 |
+
#: inc/classes/class-astra-sites.php:237 inc/includes/admin-page.php:122
|
193 |
msgid "Read more"
|
194 |
msgstr ""
|
195 |
|
201 |
msgid "There was a problem receiving a response from server."
|
202 |
msgstr ""
|
203 |
|
204 |
+
#: inc/classes/class-astra-sites.php:240 inc/includes/admin-page.php:282
|
205 |
msgid "No Demos found, Try a different search."
|
206 |
msgstr ""
|
207 |
|
535 |
msgid "Could not update comment #%d with mapped data"
|
536 |
msgstr ""
|
537 |
|
538 |
+
#: inc/includes/admin-page.php:42
|
539 |
msgid "Search Sites"
|
540 |
msgstr ""
|
541 |
|
542 |
+
#: inc/includes/admin-page.php:43
|
543 |
msgid "Search Sites..."
|
544 |
msgstr ""
|
545 |
|
546 |
+
#: inc/includes/admin-page.php:76
|
547 |
msgid "Select Your Favorite Page Builder"
|
548 |
msgstr ""
|
549 |
|
550 |
+
#: inc/includes/admin-page.php:79
|
551 |
msgid "Sites List.."
|
552 |
msgstr ""
|
553 |
|
554 |
+
#: inc/includes/admin-page.php:103
|
555 |
msgid "Close"
|
556 |
msgstr ""
|
557 |
|
558 |
+
#: inc/includes/admin-page.php:104
|
559 |
msgid "Previous"
|
560 |
msgstr ""
|
561 |
|
562 |
+
#: inc/includes/admin-page.php:105
|
563 |
msgid "Next"
|
564 |
msgstr ""
|
565 |
|
566 |
+
#: inc/includes/admin-page.php:106 inc/includes/admin-page.php:134
|
567 |
msgid "Install Plugins"
|
568 |
msgstr ""
|
569 |
|
570 |
+
#: inc/includes/admin-page.php:125
|
571 |
msgid "Required Plugins"
|
572 |
msgstr ""
|
573 |
|
574 |
+
#: inc/includes/admin-page.php:140
|
575 |
msgid "Collapse"
|
576 |
msgstr ""
|
577 |
|
578 |
+
#: inc/includes/admin-page.php:146
|
579 |
msgid "Enter desktop preview mode"
|
580 |
msgstr ""
|
581 |
|
582 |
+
#: inc/includes/admin-page.php:149
|
583 |
msgid "Enter tablet preview mode"
|
584 |
msgstr ""
|
585 |
|
586 |
+
#: inc/includes/admin-page.php:152
|
587 |
msgid "Enter mobile preview mode"
|
588 |
msgstr ""
|
589 |
|
590 |
+
#: inc/includes/admin-page.php:160 inc/includes/admin-page.php:274
|
591 |
msgid "Preview"
|
592 |
msgstr ""
|
593 |
|
594 |
+
#: inc/includes/admin-page.php:175
|
595 |
#. translators: %1$s & %2$s are a Demo API URL
|
596 |
msgid ""
|
597 |
"<p> It seems the demo data server, <i><a href=\"%1$s\">%2$s</a></i> is "
|
598 |
"unreachable from your site.</p>"
|
599 |
msgstr ""
|
600 |
|
601 |
+
#: inc/includes/admin-page.php:177
|
602 |
msgid ""
|
603 |
"<p class=\"left-margin\"> 1. Sometimes, simple page reload fixes any "
|
604 |
"temporary issues. No kidding!</p>"
|
605 |
msgstr ""
|
606 |
|
607 |
+
#: inc/includes/admin-page.php:179
|
608 |
msgid ""
|
609 |
"<p class=\"left-margin\"> 2. If that does not work, you will need to talk "
|
610 |
"to your server administrator and check if demo server is being blocked by "
|
611 |
"the firewall!</p>"
|
612 |
msgstr ""
|
613 |
|
614 |
+
#: inc/includes/admin-page.php:182
|
615 |
#. translators: %1$s is a support link
|
616 |
msgid ""
|
617 |
"<p>If that does not help, please open up a <a href=\"%1$s\" "
|
619 |
"for you.</p>"
|
620 |
msgstr ""
|
621 |
|
622 |
+
#: inc/includes/admin-page.php:194
|
623 |
+
msgid "Under Maintenance.."
|
624 |
+
msgstr ""
|
625 |
+
|
626 |
+
#: inc/includes/admin-page.php:195
|
627 |
+
msgid ""
|
628 |
+
"If you are seeing this message, most likely our servers are under routine "
|
629 |
+
"maintenance and we will be back shortly. "
|
630 |
+
msgstr ""
|
631 |
+
|
632 |
+
#: inc/includes/admin-page.php:196
|
633 |
+
msgid ""
|
634 |
+
"In rare case, it is possible your website is having trouble connecting with "
|
635 |
+
"ours. If you need help, please feel free to get in touch with us from our "
|
636 |
+
"website."
|
637 |
+
msgstr ""
|
638 |
+
|
639 |
+
#: inc/includes/admin-page.php:263
|
640 |
msgid "Details & Preview"
|
641 |
msgstr ""
|
642 |
|
643 |
+
#: inc/includes/admin-page.php:286 inc/includes/admin-page.php:304
|
644 |
#. translators: %1$s External Link
|
645 |
msgid ""
|
646 |
"Don't see a site that you would like to import?<br><a target=\"_blank\" "
|
663 |
msgid "http://www.wpastra.com/pro/"
|
664 |
msgstr ""
|
665 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
666 |
#. Author URI of the plugin/theme
|
667 |
msgid "http://www.brainstormforce.com"
|
668 |
msgstr ""
|
readme.txt
CHANGED
@@ -4,8 +4,8 @@ Donate link: https://wpastra.com/pro/
|
|
4 |
Tags: demo, theme demos, one click import
|
5 |
Requires at least: 4.4
|
6 |
Requires PHP: 5.3
|
7 |
-
Tested up to: 5.0
|
8 |
-
Stable tag: 1.2.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -57,6 +57,10 @@ https://wpastra.com/sites-suggestions/
|
|
57 |
|
58 |
== Changelog ==
|
59 |
|
|
|
|
|
|
|
|
|
60 |
v1.2.10 - 4-Jan-2019
|
61 |
* Fix: Astra Sites not accessible due to incorrect query parameters.
|
62 |
|
4 |
Tags: demo, theme demos, one click import
|
5 |
Requires at least: 4.4
|
6 |
Requires PHP: 5.3
|
7 |
+
Tested up to: 5.0
|
8 |
+
Stable tag: 1.2.11
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
57 |
|
58 |
== Changelog ==
|
59 |
|
60 |
+
v1.2.11 - 24-Jan-2019
|
61 |
+
* Improvement: Display a maintenance message if the Astra Sites API is unreachable.
|
62 |
+
* Fix: EventSource abort the import process if default charset is not UTF-8.
|
63 |
+
|
64 |
v1.2.10 - 4-Jan-2019
|
65 |
* Fix: Astra Sites not accessible due to incorrect query parameters.
|
66 |
|