-
Notifications
You must be signed in to change notification settings - Fork 81
/
import.php
78 lines (57 loc) · 1.68 KB
/
import.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
<?php defined( 'ABSPATH' ) or die();
class Brizy_Import_Import {
private $demoId;
private $provider;
private $extractor;
private $cleaner;
public function __construct( $demoId ) {
$this->demoId = $demoId;
$this->provider = new Brizy_Import_Provider();
$this->extractor = new Brizy_Import_Extractor( $this->provider->getExportUrl( $this->demoId, $this->getKey() ) );
$this->cleaner = new Brizy_Import_Cleaner();
}
/**
* @param bool $rmContent
*
* @throws Exception
*/
public function import( $rmContent = false ) {
if ( ! class_exists( 'WP_Import' ) ) {
new Brizy_Compatibilities_WordpressImporter();
}
try {
if ( $rmContent ) {
$this->cleaner->clean();
}
$this->extractor->getFiles();
$parser = new Brizy_Import_Parser( $this->extractor->getPath( 'demo.xml' ) );
$data = $parser->parse();
if ( ! empty( $data['importSettings']['plugins'] ) ) {
$plugins = new Brizy_Import_Plugins( $data['importSettings']['plugins'] );
$plugins->install();
}
$importer = new Brizy_Import_Importer( $data, $this->extractor );
$importer->import();
$remap = new Brizy_Import_Remap( $importer, $data );
$remap->remapping();
} catch ( Exception $e ) {
$this->cleanup();
throw new Exception( $e->getMessage() );
}
Brizy_Editor_Post::mark_all_for_compilation();
$this->cleanup();
}
private function getKey() {
$key = '';
if ( Brizy_Compatibilities_BrizyProCompatibility::isPro() ) {
$licenseData = BrizyPro_Admin_License::_init()->getCurrentLicense();
if ( ! empty( $licenseData['key'] ) ) {
$key = $licenseData['key'];
}
}
return $key;
}
public function cleanup() {
$this->extractor->cleanup();
}
}