Version Description
Download this release
Release Info
Developer | Nikschavan |
Plugin | Astra Starter Sites |
Version | 1.2.10 |
Comparing to | |
See all releases |
Code changes from version 1.2.9 to 1.2.10
- astra-sites.php +2 -2
- inc/assets/js/astra-sites-api.js +0 -1
- inc/assets/js/render-grid.js +14 -2
- inc/importers/wxr-importer/class-astra-wxr-importer.php +344 -344
- languages/astra-sites.pot +5 -5
- readme.txt +5 -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.10
|
7 |
* Author: Brainstorm Force
|
8 |
* Author URI: http://www.brainstormforce.com
|
9 |
* Text Domain: astra-sites
|
19 |
}
|
20 |
|
21 |
if ( ! defined( 'ASTRA_SITES_VER' ) ) {
|
22 |
+
define( 'ASTRA_SITES_VER', '1.2.10' );
|
23 |
}
|
24 |
|
25 |
if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
|
inc/assets/js/astra-sites-api.js
CHANGED
@@ -13,7 +13,6 @@
|
|
13 |
// Set API Request Data.
|
14 |
var data = {
|
15 |
url: AstraSitesAPI._api_url + args.slug,
|
16 |
-
cache: false,
|
17 |
};
|
18 |
|
19 |
if( astraRenderGrid.headers ) {
|
13 |
// Set API Request Data.
|
14 |
var data = {
|
15 |
url: AstraSitesAPI._api_url + args.slug,
|
|
|
16 |
};
|
17 |
|
18 |
if( astraRenderGrid.headers ) {
|
inc/assets/js/render-grid.js
CHANGED
@@ -300,7 +300,13 @@
|
|
300 |
}
|
301 |
}
|
302 |
|
303 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
},
|
305 |
|
306 |
/**
|
@@ -321,7 +327,13 @@
|
|
321 |
}
|
322 |
}
|
323 |
|
324 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
325 |
},
|
326 |
|
327 |
/**
|
300 |
}
|
301 |
}
|
302 |
|
303 |
+
var decoded_params = decodeURIComponent( $.param( _params ) );
|
304 |
+
|
305 |
+
if( decoded_params.length ) {
|
306 |
+
return '/?' + decoded_params;
|
307 |
+
}
|
308 |
+
|
309 |
+
return '/';
|
310 |
},
|
311 |
|
312 |
/**
|
327 |
}
|
328 |
}
|
329 |
|
330 |
+
var decoded_params = decodeURIComponent( $.param( _params ) );
|
331 |
+
|
332 |
+
if( decoded_params.length ) {
|
333 |
+
return '/?' + decoded_params;
|
334 |
+
}
|
335 |
+
|
336 |
+
return '/';
|
337 |
},
|
338 |
|
339 |
/**
|
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' );
|
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();
|
languages/astra-sites.pot
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
-
# Copyright (C)
|
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:
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
11 |
-
"PO-Revision-Date:
|
12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
"Language: en\n"
|
@@ -375,7 +375,7 @@ msgstr ""
|
|
375 |
msgid "No Title"
|
376 |
msgstr ""
|
377 |
|
378 |
-
#: inc/importers/wxr-importer/class-astra-wxr-importer.php:
|
379 |
msgid "Import complete!"
|
380 |
msgstr ""
|
381 |
|
1 |
+
# Copyright (C) 2019 Brainstorm Force
|
2 |
# This file is distributed under the same license as the Astra Starter Sites package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Astra Starter Sites 1.2.10\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/astra-sites\n"
|
7 |
+
"POT-Creation-Date: 2019-01-04 13:44:02+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
11 |
+
"PO-Revision-Date: 2019-MO-DA HO:MI+ZONE\n"
|
12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
"Language: en\n"
|
375 |
msgid "No Title"
|
376 |
msgstr ""
|
377 |
|
378 |
+
#: inc/importers/wxr-importer/class-astra-wxr-importer.php:205
|
379 |
msgid "Import complete!"
|
380 |
msgstr ""
|
381 |
|
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,9 @@ https://wpastra.com/sites-suggestions/
|
|
57 |
|
58 |
== Changelog ==
|
59 |
|
|
|
|
|
|
|
60 |
v1.2.9 - 17-Dec-2018
|
61 |
* Fix: XML not import due to getting different MIME file types on different PHP versions.
|
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.2
|
8 |
+
Stable tag: 1.2.10
|
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.10 - 4-Jan-2019
|
61 |
+
* Fix: Astra Sites not accessible due to incorrect query parameters.
|
62 |
+
|
63 |
v1.2.9 - 17-Dec-2018
|
64 |
* Fix: XML not import due to getting different MIME file types on different PHP versions.
|
65 |
|