PluginProbe
Import WP – CSV & XML Import Export for WordPress / 2.8.1
Import WP – CSV & XML Import Export for WordPress v2.8.1
2.15.1 2.15.0 2.14.24 2.14.23 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 2.9.1 All 144 releases
jc-importer / setup-iwp.php

setup-iwp.php in Import WP – CSV & XML Import Export for WordPress 2.8.1, at setup-iwp.php

161 lines 5.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 function import_wp()
4 {
5 global $iwp;
6
7 if (!is_null($iwp)) {
8 return $iwp;
9 }
10
11 $iwp = new ImportWP\Free\ImportWPFree();
12 $iwp->register();
13 return $iwp;
14 }
15
16 /**
17 * @return \ImportWP\ImportWP
18 */
19 function iwp()
20 {
21 global $iwp;
22 return $iwp;
23 }
24
25 function iwp_is_pro_disabled()
26 {
27 return defined('IWP_PRO_VERSION') && version_compare(IWP_PRO_VERSION, IWP_CORE_MIN_PRO_VERSION, '<');
28 }
29
30 /**
31 * When updating ImportWP errors can arrise if the pro version has a different codebase
32 *
33 * Disable PRO functionality and alert user to reason.
34 *
35 * @return void
36 */
37 function iwp_has_required_version_of_pro()
38 {
39 if (iwp_is_pro_disabled()) {
40 remove_action('plugins_loaded', 'iwp_pro_loaded');
41
42 // Display compatability message
43 $message = '<strong>Import WP v' . IWP_VERSION . '</strong> requires <strong>Import WP PRO v' . IWP_CORE_MIN_PRO_VERSION . ' or greater</strong>, Download the lastest version of Import WP Pro or Rollback Import WP to a compatable version.';
44 add_action('admin_notices', function () use ($message) {
45
46 global $pagenow;
47
48 if (!in_array($pagenow, ['plugins.php', 'update-core.php', 'index.php'])) {
49 return;
50 }
51
52 echo '<div class="notice notice-error is-dismissible">
53 <p>' . $message . '</p>
54 </div>';
55 });
56
57 // display error message after plugin row
58 $upgrade_mesasge = function () use ($message) {
59 ?>
60 <tr class="iwp-upgrade-row-error iwp-invalid">
61 <td colspan="4"><?= $message; ?></td>
62 </tr>
63 <style>
64 .iwp-upgrade-row-error td {
65 -webkit-box-shadow: 0px -1px 0 rgba(255, 255, 255, 0.1),
66 inset 0 -1px 0 rgba(0, 0, 0, 0.1);
67 box-shadow: 0px -1px 0 rgba(255, 255, 255, 0.1),
68 inset 0 -1px 0 rgba(0, 0, 0, 0.1);
69 border-left: 4px solid #ffb900;
70 background-color: #fff8e5;
71 }
72
73 .iwp-upgrade-row-error.iwp-invalid td {
74 border-left: 4px solid #dc3232;
75 background-color: #fef1f1;
76 }
77
78 .iwp-upgrade-row-error.iwp-valid td {
79 border-left: 4px solid #00a0d2;
80 background-color: #f7fcfe;
81 }
82 </style>
83 <?php
84 };
85 add_action('after_plugin_row_' . plugin_basename(dirname(__FILE__) . '/importwp-pro.php'), $upgrade_mesasge);
86 add_action('after_plugin_row_' . plugin_basename(dirname(__FILE__) . '/jc-importer.php'), $upgrade_mesasge);
87
88 add_filter('iwp/frontent/notices', function ($notices) use ($message) {
89 $notices[] = ['type' => 'error', 'message' => strip_tags($message)];
90 return $notices;
91 });
92 }
93 }
94 add_action('plugins_loaded', 'iwp_has_required_version_of_pro', 0);
95
96
97 function iwp_check_installed_plugins()
98 {
99
100 // Check and disable loading of zip archive plugin
101 if (function_exists('iwp_zip_archive_setup') && has_filter('plugins_loaded', 'iwp_zip_archive_setup')) {
102 remove_action('plugins_loaded', 'iwp_zip_archive_setup', 9);
103
104 $upgrade_mesasge = function () {
105 ?>
106 <tr class="iwp-zip-remove-row-error iwp-invalid">
107 <td colspan="4">Import WP - Zip Archive Importer Addon is now included in ImportWP, please deactivate and remove this plugin.</td>
108 </tr>
109 <style>
110 .iwp-zip-remove-row-error td {
111 -webkit-box-shadow: 0px -1px 0 rgba(255, 255, 255, 0.1),
112 inset 0 -1px 0 rgba(0, 0, 0, 0.1);
113 box-shadow: 0px -1px 0 rgba(255, 255, 255, 0.1),
114 inset 0 -1px 0 rgba(0, 0, 0, 0.1);
115 border-left: 4px solid #ffb900;
116 background-color: #fff8e5;
117 }
118
119 .iwp-zip-remove-row-error.iwp-invalid td {
120 border-left: 4px solid #dc3232;
121 background-color: #fef1f1;
122 }
123
124 .iwp-zip-remove-row-error.iwp-valid td {
125 border-left: 4px solid #00a0d2;
126 background-color: #f7fcfe;
127 }
128 </style>
129 <?php
130 };
131 add_action('after_plugin_row_importwp-zip-archive/zip-archive.php', $upgrade_mesasge);
132 }
133 }
134 add_action('plugins_loaded', 'iwp_check_installed_plugins', 0);
135
136 function iwp_loaded()
137 {
138 if (function_exists('import_wp_pro') && !iwp_is_pro_disabled()) {
139 return;
140 }
141
142 if (function_exists('import_wp')) {
143 import_wp();
144 }
145 }
146 add_action('plugins_loaded', 'iwp_loaded');
147
148 /**
149 * Register IWP Addon
150 *
151 * @param string $name
152 * @param string $id
153 * @param callable(AddonInterface) $callback
154 *
155 * @return ImportWP\Common\Addon\AddonInterface
156 */
157 function iwp_register_importer_addon($name, $id, $callback)
158 {
159 return new ImportWP\Common\Addon\AddonBase($name, $id, $callback);
160 }
161