-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimportwp-wpml.php
79 lines (61 loc) · 1.81 KB
/
importwp-wpml.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
79
<?php
/**
* Plugin Name: Import WP - WPML Addon
* Plugin URI: https://www.importwp.com
* Description: WPML Integration for ImportWP
* Author: James Collings <james@jclabs.co.uk>
* Version: 0.0.1
* Author URI: https://www.importwp.com
* Network: True
*/
if (!defined('IWP_WPML_MIN_CORE_VERSION')) {
define('IWP_WPML_MIN_CORE_VERSION', '2.14.1');
}
add_action('admin_init', 'iwp_wpml_check');
function iwp_wpml_requirements_met()
{
if (!class_exists('\SitePress')) {
return false;
}
if (!function_exists('import_wp')) {
return false;
}
if (version_compare(IWP_VERSION, IWP_WPML_MIN_CORE_VERSION, '<')) {
return false;
}
return true;
}
function iwp_wpml_check()
{
if (!iwp_wpml_requirements_met()) {
add_action('admin_notices', 'iwp_wpml_notice');
deactivate_plugins(plugin_basename(__FILE__));
if (isset($_GET['activate'])) {
unset($_GET['activate']);
}
}
}
function iwp_wpml_setup()
{
if (!iwp_wpml_requirements_met()) {
return;
}
$base_path = dirname(__FILE__);
// require_once $base_path . '/class/autoload.php';
require_once $base_path . '/setup.php';
// Install updater
if (file_exists($base_path . '/updater.php') && !class_exists('IWP_Updater')) {
require_once $base_path . '/updater.php';
}
if (class_exists('IWP_Updater')) {
$updater = new IWP_Updater(__FILE__, 'importwp-wpml');
$updater->initialize();
}
}
add_action('plugins_loaded', 'iwp_wpml_setup', 9);
function iwp_wpml_notice()
{
echo '<div class="error">';
echo '<p><strong>Import WP - WPML Importer Addon</strong> requires that you have <strong>Import WP v' . IWP_WPML_MIN_CORE_VERSION . ' or newer</strong>, and <strong>WPML</strong> installed.</p>';
echo '</div>';
}