| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: WP Import Export Lite |
| 4 |
* Plugin URI: https://www.vjinfotech.com/ |
| 5 |
* Description: The Advanced and powerful solution for importing and exporting data to WordPress. Import and Export to Posts, Pages, and Custom Post Types. Ability to update existing data, and much more. |
| 6 |
* Version: 3.9.33 |
| 7 |
* Requires at least: 4.4 |
| 8 |
* Tested up to: 7.1 |
| 9 |
* Requires PHP: 5.6 |
| 10 |
* Author: VJInfotech |
| 11 |
* Author URI: https://www.vjinfotech.com/ |
| 12 |
* License: GPL-2.0-or-later |
| 13 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 14 |
* Text Domain: wp-import-export-lite |
| 15 |
* Domain Path: /languages/ |
| 16 |
* |
| 17 |
* @package WP_Import_Export_Lite |
| 18 |
*/ |
| 19 |
|
| 20 |
defined( 'ABSPATH' ) || exit; |
| 21 |
|
| 22 |
// Auto deactivation of conflicting Pro/Lite plugins. |
| 23 |
if ( file_exists( dirname( __FILE__ ) . '/deactivate-plugins.php' ) ) { |
| 24 |
require_once dirname( __FILE__ ) . '/deactivate-plugins.php'; |
| 25 |
add_action( 'admin_init', 'wpie_auto_deactivate_pro_plugins' ); |
| 26 |
} |
| 27 |
|
| 28 |
// Plugin version. |
| 29 |
if ( ! defined( 'WPIE_PLUGIN_VERSION' ) ) { |
| 30 |
define( 'WPIE_PLUGIN_VERSION', '3.9.33' ); |
| 31 |
} |
| 32 |
|
| 33 |
// Database schema version. |
| 34 |
if ( ! defined( 'WPIE_DB_VERSION' ) ) { |
| 35 |
define( 'WPIE_DB_VERSION', '1.0.0' ); |
| 36 |
} |
| 37 |
|
| 38 |
// Plugin main file path. |
| 39 |
if ( ! defined( 'WPIE_PLUGIN_FILE' ) ) { |
| 40 |
define( 'WPIE_PLUGIN_FILE', __FILE__ ); |
| 41 |
} |
| 42 |
|
| 43 |
// Plugin directory path with normalized slashes. |
| 44 |
if ( ! defined( 'WPIE_PLUGIN_DIR' ) ) { |
| 45 |
define( 'WPIE_PLUGIN_DIR', wp_normalize_path( plugin_dir_path( WPIE_PLUGIN_FILE ) ) ); |
| 46 |
} |
| 47 |
|
| 48 |
// Plugin URL with correct scheme. |
| 49 |
if ( ! defined( 'WPIE_PLUGIN_URL' ) ) { |
| 50 |
$wpie_plugin_url = untrailingslashit( plugin_dir_url( WPIE_PLUGIN_FILE ) ); |
| 51 |
if ( is_ssl() ) { |
| 52 |
$wpie_plugin_url = set_url_scheme( $wpie_plugin_url, 'https' ); |
| 53 |
} |
| 54 |
define( 'WPIE_PLUGIN_URL', $wpie_plugin_url ); |
| 55 |
unset( $wpie_plugin_url ); |
| 56 |
} |
| 57 |
|
| 58 |
// External resource URLs (using HTTPS). |
| 59 |
if ( ! defined( 'WPIE_PLUGIN_SITE' ) ) { |
| 60 |
define( 'WPIE_PLUGIN_SITE', 'https://www.vjinfotech.com' ); |
| 61 |
} |
| 62 |
if ( ! defined( 'WPIE_PLUGIN_API' ) ) { |
| 63 |
define( 'WPIE_PLUGIN_API', 'https://api.vjinfotech.com/' ); |
| 64 |
} |
| 65 |
if ( ! defined( 'WPIE_DOC_URL' ) ) { |
| 66 |
define( 'WPIE_DOC_URL', 'https://plugins.vjinfotech.com/wordpress-import-export/documentation/' ); |
| 67 |
} |
| 68 |
if ( ! defined( 'WPIE_SUPPORT_URL' ) ) { |
| 69 |
define( 'WPIE_SUPPORT_URL', 'https://www.vjinfotech.com/support/' ); |
| 70 |
} |
| 71 |
|
| 72 |
// Upload directory paths and URLs. |
| 73 |
$wpie_upload_dir = wp_upload_dir(); |
| 74 |
|
| 75 |
if ( ! defined( 'WPIE_SITE_UPLOAD_DIR' ) ) { |
| 76 |
define( 'WPIE_SITE_UPLOAD_DIR', ! empty( $wpie_upload_dir['basedir'] ) ? wp_normalize_path( $wpie_upload_dir['basedir'] ) : '' ); |
| 77 |
} |
| 78 |
|
| 79 |
if ( ! defined( 'WPIE_UPLOAD_DIR' ) ) { |
| 80 |
define( 'WPIE_UPLOAD_DIR', WPIE_SITE_UPLOAD_DIR . '/wp-import-export-lite' ); |
| 81 |
} |
| 82 |
|
| 83 |
if ( ! defined( 'WPIE_UPLOAD_URL' ) ) { |
| 84 |
$wpie_base_url = ! empty( $wpie_upload_dir['baseurl'] ) ? $wpie_upload_dir['baseurl'] . '/wp-import-export-lite' : ''; |
| 85 |
if ( is_ssl() && ! empty( $wpie_base_url ) ) { |
| 86 |
$wpie_base_url = set_url_scheme( $wpie_base_url, 'https' ); |
| 87 |
} |
| 88 |
define( 'WPIE_UPLOAD_URL', $wpie_base_url ); |
| 89 |
unset( $wpie_base_url ); |
| 90 |
} |
| 91 |
unset( $wpie_upload_dir ); |
| 92 |
|
| 93 |
if ( ! defined( 'WPIE_ASSETS_URL' ) ) { |
| 94 |
define( 'WPIE_ASSETS_URL', WPIE_PLUGIN_URL . '/assets' ); |
| 95 |
} |
| 96 |
|
| 97 |
if ( ! defined( 'WPIE_UPLOAD_EXPORT_DIR' ) ) { |
| 98 |
define( 'WPIE_UPLOAD_EXPORT_DIR', WPIE_UPLOAD_DIR . '/export' ); |
| 99 |
} |
| 100 |
|
| 101 |
if ( ! defined( 'WPIE_UPLOAD_IMPORT_DIR' ) ) { |
| 102 |
define( 'WPIE_UPLOAD_IMPORT_DIR', WPIE_UPLOAD_DIR . '/import' ); |
| 103 |
} |
| 104 |
|
| 105 |
if ( ! defined( 'WPIE_UPLOAD_TEMP_DIR' ) ) { |
| 106 |
define( 'WPIE_UPLOAD_TEMP_DIR', WPIE_UPLOAD_DIR . '/temp' ); |
| 107 |
} |
| 108 |
|
| 109 |
if ( ! defined( 'WPIE_UPLOAD_MAIN_DIR' ) ) { |
| 110 |
define( 'WPIE_UPLOAD_MAIN_DIR', WPIE_UPLOAD_DIR . '/upload' ); |
| 111 |
} |
| 112 |
|
| 113 |
if ( ! function_exists( 'wpie_setup_upload_dirs' ) ) { |
| 114 |
/** |
| 115 |
* Ensure plugin upload and working directories exist with security index files. |
| 116 |
* |
| 117 |
* Creates the base, import, export, temp, and upload directories if they do not exist, |
| 118 |
* and writes an index.php / .htaccess to prevent directory indexing and unauthorized direct access. |
| 119 |
* |
| 120 |
* @since 1.0.0 |
| 121 |
* @return void |
| 122 |
*/ |
| 123 |
function wpie_setup_upload_dirs() { |
| 124 |
$upload_dirs = array( |
| 125 |
WPIE_UPLOAD_DIR, |
| 126 |
WPIE_UPLOAD_EXPORT_DIR, |
| 127 |
WPIE_UPLOAD_IMPORT_DIR, |
| 128 |
WPIE_UPLOAD_TEMP_DIR, |
| 129 |
WPIE_UPLOAD_MAIN_DIR, |
| 130 |
); |
| 131 |
|
| 132 |
foreach ( $upload_dirs as $dir ) { |
| 133 |
if ( ! is_dir( $dir ) ) { |
| 134 |
wp_mkdir_p( $dir ); |
| 135 |
} |
| 136 |
if ( is_dir( $dir ) && wp_is_writable( $dir ) ) { |
| 137 |
$index_file = $dir . '/index.php'; |
| 138 |
if ( ! file_exists( $index_file ) ) { |
| 139 |
@file_put_contents( $index_file, "<?php\n// Silence is golden.\n" ); |
| 140 |
} |
| 141 |
} |
| 142 |
} |
| 143 |
|
| 144 |
// Protect export and temp folders on Apache/LiteSpeed. |
| 145 |
$protected_dirs = array( WPIE_UPLOAD_EXPORT_DIR, WPIE_UPLOAD_TEMP_DIR ); |
| 146 |
foreach ( $protected_dirs as $pdir ) { |
| 147 |
if ( is_dir( $pdir ) && wp_is_writable( $pdir ) ) { |
| 148 |
$htaccess_file = $pdir . '/.htaccess'; |
| 149 |
if ( ! file_exists( $htaccess_file ) ) { |
| 150 |
@file_put_contents( $htaccess_file, "<IfModule !mod_authz_core.c>\nOrder deny,allow\nDeny from all\n</IfModule>\n<IfModule mod_authz_core.c>\nRequire all denied\n</IfModule>\n" ); |
| 151 |
} |
| 152 |
} |
| 153 |
} |
| 154 |
} |
| 155 |
} |
| 156 |
|
| 157 |
// Ensure upload directories are initialized on activation or lazily if missing. |
| 158 |
register_activation_hook( WPIE_PLUGIN_FILE, 'wpie_setup_upload_dirs' ); |
| 159 |
if ( ! is_dir( WPIE_UPLOAD_DIR ) ) { |
| 160 |
wpie_setup_upload_dirs(); |
| 161 |
} |
| 162 |
|
| 163 |
// Addon and asset URLs. |
| 164 |
if ( ! defined( 'WPIE_IMPORT_ADDON_URL' ) ) { |
| 165 |
define( 'WPIE_IMPORT_ADDON_URL', WPIE_PLUGIN_URL . '/includes/classes/import/extensions' ); |
| 166 |
} |
| 167 |
if ( ! defined( 'WPIE_EXPORT_ADDON_URL' ) ) { |
| 168 |
define( 'WPIE_EXPORT_ADDON_URL', WPIE_PLUGIN_URL . '/includes/classes/export/extensions' ); |
| 169 |
} |
| 170 |
|
| 171 |
if ( ! defined( 'WPIE_CSS_URL' ) ) { |
| 172 |
define( 'WPIE_CSS_URL', WPIE_ASSETS_URL . '/css' ); |
| 173 |
} |
| 174 |
|
| 175 |
if ( ! defined( 'WPIE_JS_URL' ) ) { |
| 176 |
define( 'WPIE_JS_URL', WPIE_ASSETS_URL . '/js' ); |
| 177 |
} |
| 178 |
|
| 179 |
if ( ! defined( 'WPIE_IMAGES_URL' ) ) { |
| 180 |
define( 'WPIE_IMAGES_URL', WPIE_ASSETS_URL . '/images' ); |
| 181 |
} |
| 182 |
|
| 183 |
// Internal directories. |
| 184 |
if ( ! defined( 'WPIE_INCLUDES_DIR' ) ) { |
| 185 |
define( 'WPIE_INCLUDES_DIR', WPIE_PLUGIN_DIR . 'includes' ); |
| 186 |
} |
| 187 |
|
| 188 |
if ( ! defined( 'WPIE_LIBRARIES_DIR' ) ) { |
| 189 |
define( 'WPIE_LIBRARIES_DIR', WPIE_PLUGIN_DIR . 'libraries' ); |
| 190 |
} |
| 191 |
if ( ! defined( 'WPIE_CLASSES_DIR' ) ) { |
| 192 |
define( 'WPIE_CLASSES_DIR', WPIE_INCLUDES_DIR . '/classes' ); |
| 193 |
} |
| 194 |
|
| 195 |
if ( ! defined( 'WPIE_HELPERS_DIR' ) ) { |
| 196 |
define( 'WPIE_HELPERS_DIR', WPIE_CLASSES_DIR . '/helpers' ); |
| 197 |
} |
| 198 |
|
| 199 |
// Helper dependencies. |
| 200 |
if ( file_exists( WPIE_HELPERS_DIR . '/Sanitizer.php' ) ) { |
| 201 |
require_once WPIE_HELPERS_DIR . '/Sanitizer.php'; |
| 202 |
} |
| 203 |
if ( file_exists( WPIE_HELPERS_DIR . '/Param.php' ) ) { |
| 204 |
require_once WPIE_HELPERS_DIR . '/Param.php'; |
| 205 |
} |
| 206 |
if ( file_exists( WPIE_HELPERS_DIR . '/SafeFunction.php' ) ) { |
| 207 |
require_once WPIE_HELPERS_DIR . '/SafeFunction.php'; |
| 208 |
} |
| 209 |
|
| 210 |
if ( ! defined( 'WPIE_IMPORT_CLASSES_DIR' ) ) { |
| 211 |
define( 'WPIE_IMPORT_CLASSES_DIR', WPIE_CLASSES_DIR . '/import' ); |
| 212 |
} |
| 213 |
|
| 214 |
if ( ! defined( 'WPIE_EXPORT_CLASSES_DIR' ) ) { |
| 215 |
define( 'WPIE_EXPORT_CLASSES_DIR', WPIE_CLASSES_DIR . '/export' ); |
| 216 |
} |
| 217 |
|
| 218 |
if ( ! defined( 'WPIE_VIEW_DIR' ) ) { |
| 219 |
define( 'WPIE_VIEW_DIR', WPIE_INCLUDES_DIR . '/views' ); |
| 220 |
} |
| 221 |
|
| 222 |
// Schedule class. |
| 223 |
if ( file_exists( WPIE_CLASSES_DIR . '/class-wpie-schedule.php' ) ) { |
| 224 |
require_once WPIE_CLASSES_DIR . '/class-wpie-schedule.php'; |
| 225 |
new \wpie\WPIE_Schedule(); |
| 226 |
} |
| 227 |
|
| 228 |
// Compatibility support. |
| 229 |
if ( file_exists( WPIE_PLUGIN_DIR . 'support/support.php' ) ) { |
| 230 |
require_once WPIE_PLUGIN_DIR . 'support/support.php'; |
| 231 |
} |
| 232 |
|
| 233 |
// Helper functions. |
| 234 |
if ( file_exists( WPIE_CLASSES_DIR . '/function.php' ) ) { |
| 235 |
require_once WPIE_CLASSES_DIR . '/function.php'; |
| 236 |
} |
| 237 |
|
| 238 |
add_action( 'init', 'wpie_init_addons' ); |
| 239 |
|
| 240 |
if ( ! function_exists( 'wpie_init_addons' ) ) { |
| 241 |
/** |
| 242 |
* Initialize plugin extensions and add-ons. |
| 243 |
* |
| 244 |
* @since 1.0.0 |
| 245 |
* @return void |
| 246 |
*/ |
| 247 |
function wpie_init_addons() { |
| 248 |
if ( file_exists( WPIE_CLASSES_DIR . '/class-wpie-extensions.php' ) ) { |
| 249 |
require_once WPIE_CLASSES_DIR . '/class-wpie-extensions.php'; |
| 250 |
|
| 251 |
$wpie_ext = new \wpie\addons\WPIE_Extension(); |
| 252 |
$wpie_ext->wpie_init_extensions(); |
| 253 |
unset( $wpie_ext ); |
| 254 |
} |
| 255 |
} |
| 256 |
} |
| 257 |
|
| 258 |
// Plugin updates handler. |
| 259 |
if ( file_exists( WPIE_CLASSES_DIR . '/class-updates.php' ) ) { |
| 260 |
require_once WPIE_CLASSES_DIR . '/class-updates.php'; |
| 261 |
new \wpie\Updates(); |
| 262 |
} |
| 263 |
|
| 264 |
// Safely retrieve request action with class check fallback. |
| 265 |
$wpie_request_action = ''; |
| 266 |
if ( class_exists( '\WpieApp\Core\Helpers\Param' ) ) { |
| 267 |
$wpie_request_action = \WpieApp\Core\Helpers\Param::requestSanitized( 'action', 'key', '' ); |
| 268 |
} elseif ( isset( $_REQUEST['action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 269 |
$wpie_request_action = sanitize_key( wp_unslash( $_REQUEST['action'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 270 |
} |
| 271 |
|
| 272 |
$wpie_is_doing_ajax = function_exists( 'wp_doing_ajax' ) ? wp_doing_ajax() : ( defined( 'DOING_AJAX' ) && DOING_AJAX ); |
| 273 |
|
| 274 |
if ( is_admin() && $wpie_is_doing_ajax && '' !== $wpie_request_action && strpos( $wpie_request_action, 'wpie' ) === 0 ) { |
| 275 |
if ( file_exists( WPIE_CLASSES_DIR . '/class-wpie-action.php' ) ) { |
| 276 |
require_once WPIE_CLASSES_DIR . '/class-wpie-action.php'; |
| 277 |
} |
| 278 |
} elseif ( file_exists( WPIE_CLASSES_DIR . '/class-wpie-general.php' ) ) { |
| 279 |
require_once WPIE_CLASSES_DIR . '/class-wpie-general.php'; |
| 280 |
new \wpie\core\WPIE_General(); |
| 281 |
} |