| 1 |
<?php |
| 2 |
/** |
| 3 |
* WP Ultimate Exporter. |
| 4 |
* |
| 5 |
* WP Ultimate Exporter plugin file. |
| 6 |
* |
| 7 |
* @package Smackcoders\SMEXP |
| 8 |
* @copyright Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com |
| 9 |
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, version 3 or higher |
| 10 |
* |
| 11 |
* @wordpress-plugin |
| 12 |
* Plugin Name: WP Ultimate Exporter |
| 13 |
* Version: 3.0 |
| 14 |
* Plugin URI: https://www.smackcoders.com/ultimate-exporter.html |
| 15 |
* Description: Backup tool to export all your WordPress data as CSV file. eCommerce data of WooCommerce, eCommerce, Custom Post and Custom field information along with default WordPress modules. |
| 16 |
* Author: Smackcoders |
| 17 |
* Author URI: https://www.smackcoders.com/wordpress.html |
| 18 |
* Text Domain: wp-ultimate-exporter |
| 19 |
* Domain Path: /languages |
| 20 |
* License: GPL v3 |
| 21 |
* |
| 22 |
* This program is free software: you can redistribute it and/or modify |
| 23 |
* it under the terms of the GNU General Public License as published by |
| 24 |
* the Free Software Foundation, either version 3 of the License, or |
| 25 |
* (at your option) any later version. |
| 26 |
* |
| 27 |
* This program is distributed in the hope that it will be useful, |
| 28 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 29 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 30 |
* GNU General Public License for more details. |
| 31 |
* |
| 32 |
* You should have received a copy of the GNU General Public License |
| 33 |
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 34 |
*/ |
| 35 |
|
| 36 |
namespace Smackcoders\SMEXP; |
| 37 |
|
| 38 |
if (!defined('ABSPATH')) |
| 39 |
exit; // Exit if accessed directly |
| 40 |
|
| 41 |
define('IMPORTER_VERSION', '7.41'); |
| 42 |
define('EXPORTER_VERSION', '3.0'); |
| 43 |
|
| 44 |
if (!function_exists('is_plugin_active')) { |
| 45 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 46 |
} |
| 47 |
|
| 48 |
function smexp_is_parent_importer_active() |
| 49 |
{ |
| 50 |
return is_plugin_active('wp-ultimate-csv-importer/wp-ultimate-csv-importer.php') |
| 51 |
|| is_plugin_active('wp-ultimate-csv-importer-pro/wp-ultimate-csv-importer-pro.php'); |
| 52 |
} |
| 53 |
|
| 54 |
require_once('Plugin.php'); |
| 55 |
require_once('SmackExporterInstall.php'); |
| 56 |
require_once('exportExtensions/ExportExtension.php'); |
| 57 |
require_once('exportExtensions/JetBookingExport.php'); |
| 58 |
require_once('exportExtensions/JetReviewsExport.php'); |
| 59 |
require_once('exportExtensions/JetCustomTableExport.php'); |
| 60 |
require_once('exportExtensions/EDDExport.php'); |
| 61 |
|
| 62 |
|
| 63 |
if ( |
| 64 |
smexp_is_parent_importer_active() && |
| 65 |
class_exists('Smackcoders\SMEXP\ExportExtension') |
| 66 |
) { |
| 67 |
$upload = wp_upload_dir(); |
| 68 |
$exports_dir = $upload['basedir'] . '/smack_uci_uploads/exports/'; |
| 69 |
$htaccess_file = $exports_dir . '.htaccess'; |
| 70 |
if (file_exists($htaccess_file)) { |
| 71 |
unlink($htaccess_file); |
| 72 |
} |
| 73 |
if (is_plugin_active('wp-ultimate-exporter/wp-ultimate-exporter.php')) { |
| 74 |
$plugin_pages = ['com.smackcoders.csvimporternew.menu']; |
| 75 |
include __DIR__ . '/wp-exp-hooks.php'; |
| 76 |
global $plugin_ajax_hooks; |
| 77 |
|
| 78 |
$request_page = isset($_REQUEST['page']) ? $_REQUEST['page'] : ''; |
| 79 |
$request_action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
| 80 |
require_once('exportExtensions/ExportExtension.php'); |
| 81 |
|
| 82 |
require_once('exportExtensions/WPQueryExport.php'); |
| 83 |
require_once('exportExtensions/WooComExport.php'); |
| 84 |
|
| 85 |
if (in_array($request_page, $plugin_pages) || in_array($request_action, $plugin_ajax_hooks)) { |
| 86 |
require_once('exportExtensions/JetEngine.php'); |
| 87 |
require_once('exportExtensions/LearnPress.php'); |
| 88 |
require_once('exportExtensions/MetaBox.php'); |
| 89 |
require_once('exportExtensions/ExportHandler.php'); |
| 90 |
require_once('exportExtensions/CustomerReviewsExport.php'); |
| 91 |
require_once('exportExtensions/PostExport.php'); |
| 92 |
require_once('exportExtensions/WooComExport.php'); |
| 93 |
require_once('exportExtensions/WPQueryExport.php'); |
| 94 |
require_once('exportExtensions/EDDExport.php'); |
| 95 |
require_once('exportExtensions/SureCartExport.php'); |
| 96 |
|
| 97 |
} |
| 98 |
} |
| 99 |
|
| 100 |
if (!class_exists('Smackcoders\SMEXP\ExportExtension')) { |
| 101 |
ExpInstall::init(plugin_basename(__FILE__)); |
| 102 |
add_action('admin_notices', 'Smackcoders\\SMEXP\\Notice_msg_exporter_free'); |
| 103 |
} else { |
| 104 |
class ExpCSVHandler extends ExportExtension |
| 105 |
{ |
| 106 |
|
| 107 |
protected static $instance = null, $install, $exp_instance; |
| 108 |
|
| 109 |
public function __construct() |
| 110 |
{ |
| 111 |
$this->plugin = Plugin::getInstance(); |
| 112 |
add_action('wp_ajax_get_plugin_notice', array($this, 'check_parent_plugin_version')); |
| 113 |
// add_action('wp_ajax_upgrade_notices_csv_bro',array($this,'dismiss_function')); |
| 114 |
add_action('wp_ajax_upgrade_notices_csv_bro', array($this, 'dismiss_function')); |
| 115 |
add_action('wp_ajax_nopriv_upgrade_notices_csv_bro', array($this, 'dismiss_function')); |
| 116 |
add_action('wp_ajax_dismiss_notice', array($this, 'dismiss_function_new')); |
| 117 |
} |
| 118 |
|
| 119 |
public function dismiss_function_new() |
| 120 |
{ |
| 121 |
update_option('csv_update_option', 0); |
| 122 |
exit(); |
| 123 |
} |
| 124 |
|
| 125 |
public function dismiss_function() |
| 126 |
{ |
| 127 |
update_option('csv_update_option', 0); |
| 128 |
$response = array(); |
| 129 |
$response['value'] = 0; |
| 130 |
echo wp_json_encode($response); |
| 131 |
wp_die(); |
| 132 |
// exit(); |
| 133 |
} |
| 134 |
function check_parent_plugin_version() |
| 135 |
{ |
| 136 |
$parent_plugin_dir = WP_PLUGIN_DIR . '/wp-ultimate-csv-importer/wp-ultimate-csv-importer.php'; |
| 137 |
$parent_plugin_data = get_plugin_data($parent_plugin_dir); |
| 138 |
$parent_version = $parent_plugin_data['Version']; |
| 139 |
|
| 140 |
$child_plugin_dir = WP_PLUGIN_DIR . '/wp-ultimate-exporter/wp-ultimate-exporter.php'; |
| 141 |
$child_plugin_data = get_plugin_data($child_plugin_dir); |
| 142 |
$child_version = $child_plugin_data['Version']; |
| 143 |
// if($parent_version < IMPORTER_VERSION || $child_version < EXPORTER_VERSION ){ |
| 144 |
if (version_compare($parent_version, IMPORTER_VERSION, '<') || version_compare($child_version, EXPORTER_VERSION, '<')) { |
| 145 |
$option_name = 'csv_update_option'; |
| 146 |
$option_value = 1; |
| 147 |
$autoload = true; |
| 148 |
if (get_option($option_name) === false) { |
| 149 |
add_option($option_name, $option_value, '', $autoload); |
| 150 |
} |
| 151 |
if (get_option('csv_update_option') == 1) { |
| 152 |
$response = array(); |
| 153 |
$response['message'] = 'Important note: Please upgrade latest versions for security updates.'; |
| 154 |
$response['link'] = admin_url('plugins.php'); |
| 155 |
$response['value'] = 1; |
| 156 |
$response['dismiss'] = 'Dismiss this notice.'; |
| 157 |
$response['upgrade'] = 'Upgrade Now'; |
| 158 |
echo wp_json_encode($response); |
| 159 |
wp_die(); |
| 160 |
?> |
| 161 |
<!-- <div class="notice notice-info is-dismissible"> |
| 162 |
<p><? php//_e('Important note: Please upgrade your WP Ultimate CSV Importer to latest versions for security updates.', 'wp-ultimate-exporter'); ?></p> |
| 163 |
<p><a href="<?php //echo admin_url('plugins.php'); ?>" class="button"><?php //_e('Upgrade Now', 'wp-ultimate-exporter'); ?></a></p> |
| 164 |
<button type="submit"class="notice-dismiss" id="upgrade_notices_csv_bro"> |
| 165 |
<span class="screen-reader-text">Dismiss this notice.</span> |
| 166 |
</button> |
| 167 |
</div> --> |
| 168 |
<?php |
| 169 |
} |
| 170 |
} |
| 171 |
} |
| 172 |
// public static function is_upgrade_notice_dismissed() { |
| 173 |
// return get_option('csv_update_option', false); |
| 174 |
// } |
| 175 |
public static function getInstance() |
| 176 |
{ |
| 177 |
if (ExpCSVHandler::$instance == null) { |
| 178 |
ExpCSVHandler::$instance = new ExpCSVHandler; |
| 179 |
ExpCSVHandler::$install = ExpInstall::getInstance(); |
| 180 |
ExpCSVHandler::$exp_instance = ExportExtension::getInstance(); |
| 181 |
|
| 182 |
return ExpCSVHandler::$instance; |
| 183 |
} |
| 184 |
return ExpCSVHandler::$instance; |
| 185 |
} |
| 186 |
/** |
| 187 |
* Init UserSmCSVHandlerPro when WordPress Initialises. |
| 188 |
*/ |
| 189 |
public function init() |
| 190 |
{ |
| 191 |
if (is_admin()) { |
| 192 |
// Init action. |
| 193 |
do_action('uci_init'); |
| 194 |
} |
| 195 |
} |
| 196 |
} |
| 197 |
} |
| 198 |
|
| 199 |
add_action('plugins_loaded', 'Smackcoders\\SMEXP\\onpluginsload'); |
| 200 |
|
| 201 |
|
| 202 |
function onpluginsload() |
| 203 |
{ |
| 204 |
$plugin_pages = ['com.smackcoders.csvimporternew.menu']; |
| 205 |
include __DIR__ . '/wp-exp-hooks.php'; |
| 206 |
global $plugin_ajax_hooks; |
| 207 |
|
| 208 |
$request_page = isset($_REQUEST['page']) ? $_REQUEST['page'] : ''; |
| 209 |
$request_action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
| 210 |
if (in_array($request_page, $plugin_pages) || in_array($request_action, $plugin_ajax_hooks)) { |
| 211 |
$plugin = ExpCSVHandler::getInstance(); |
| 212 |
} |
| 213 |
$upload = wp_upload_dir(); |
| 214 |
$upload_dir = $upload['basedir']; |
| 215 |
// if(!is_dir($upload_dir)){ |
| 216 |
// return false; |
| 217 |
// } |
| 218 |
// else{ |
| 219 |
// $exports_dir = $upload['basedir'] . '/smack_uci_uploads/exports/'; |
| 220 |
// $htaccess_content = "deny from all\n"; |
| 221 |
// $htaccess_file = $exports_dir . '.htaccess'; |
| 222 |
// if (!file_exists($htaccess_file)) { |
| 223 |
// file_put_contents($htaccess_file, $htaccess_content); |
| 224 |
// } |
| 225 |
// } |
| 226 |
} |
| 227 |
} else { |
| 228 |
|
| 229 |
if (is_plugin_active('wp-ultimate-exporter/wp-ultimate-exporter.php')) { |
| 230 |
deactivate_plugins('wp-ultimate-exporter/wp-ultimate-exporter.php'); |
| 231 |
|
| 232 |
add_action('admin_notices', 'Smackcoders\\SMEXP\\Notice_msg_exporter_Deactivate'); |
| 233 |
|
| 234 |
} |
| 235 |
} |
| 236 |
|
| 237 |
function Notice_msg_exporter_free() |
| 238 |
{ |
| 239 |
|
| 240 |
?> |
| 241 |
<div class="notice notice-warning is-dismissible"> |
| 242 |
<p> WP Ultimate Exporter is an addon of <a href="https://wordpress.org/plugins/wp-ultimate-csv-importer" |
| 243 |
target="blank" style="cursor: pointer;text-decoration:none">WP Ultimate CSV Importer</a> plugin, kindly |
| 244 |
install it to continue using WP ultimate exporter. </p> |
| 245 |
</div> |
| 246 |
<?php |
| 247 |
|
| 248 |
} |
| 249 |
|
| 250 |
function Notice_msg_exporter_Deactivate() |
| 251 |
{ |
| 252 |
?> |
| 253 |
<div class="notice notice-warning is-dismissible"> |
| 254 |
<p> WP Ultimate Exporter is an addon of <a href="https://wordpress.org/plugins/wp-ultimate-csv-importer" |
| 255 |
target="blank" style="cursor: pointer;text-decoration:none">WP Ultimate CSV Importer</a> plugin, kindly |
| 256 |
install it to continue using import woocommerce. </p> |
| 257 |
</div> |
| 258 |
<?php |
| 259 |
|
| 260 |
} |
| 261 |
|
| 262 |
|
| 263 |
?> |