| 1 |
<?php |
| 2 |
/** |
| 3 |
* WP Ultimate Exporter plugin file. |
| 4 |
* |
| 5 |
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace Smackcoders\SMEXP; |
| 9 |
|
| 10 |
if ( ! defined( 'ABSPATH' ) ) |
| 11 |
exit; // Exit if accessed directly |
| 12 |
|
| 13 |
class ExportHandler extends ExportExtension{ |
| 14 |
protected static $instance = null,$export_extension; |
| 15 |
public static function getInstance() { |
| 16 |
if ( null == self::$instance ) { |
| 17 |
self::$instance = new self; |
| 18 |
self::$instance->doHooks(); |
| 19 |
ExportHandler::$export_extension = ExportExtension::getInstance(); |
| 20 |
} |
| 21 |
return self::$instance; |
| 22 |
} |
| 23 |
|
| 24 |
public function doHooks(){ |
| 25 |
add_action('wp_ajax_get_post_types',array($this,'getPostTypes')); |
| 26 |
add_action('wp_ajax_get_taxonomies',array($this,'getTaxonomies')); |
| 27 |
add_action('wp_ajax_get_authors',array($this,'getAuthors')); |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* SmackUCIExporter constructor. |
| 32 |
* |
| 33 |
* Set values into global variables based on post value |
| 34 |
*/ |
| 35 |
public function __construct() { |
| 36 |
$this->plugin = Plugin::getInstance(); |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
public function getPostTypes(){ |
| 41 |
check_ajax_referer('smack-ultimate-csv-importer', 'securekey'); |
| 42 |
global $wpdb; |
| 43 |
$i = 0; |
| 44 |
$get_post_types = get_post_types(); |
| 45 |
if(is_plugin_active('jet-engine/jet-engine.php')){ |
| 46 |
$get_slug_name = $wpdb->get_results("SELECT slug FROM {$wpdb->prefix}jet_post_types WHERE status = 'content-type'"); |
| 47 |
|
| 48 |
foreach($get_slug_name as $key=>$get_slug){ |
| 49 |
$value=$get_slug->slug; |
| 50 |
$get_post_types[$value]=$value; |
| 51 |
} |
| 52 |
} |
| 53 |
array_push($get_post_types, 'widgets'); |
| 54 |
foreach ($get_post_types as $key => $value) { |
| 55 |
if (($value !== 'featured_image') && ($value !== 'attachment') && ($value !== 'wpsc-product') && ($value !== 'wpsc-product-file') && ($value !== 'revision') && ($value !== 'post') && ($value !== 'page') && ($value !== 'wp-types-group') && ($value !== 'wp-types-user-group') && ($value !== 'product') && ($value !== 'product_variation') && ($value !== 'shop_order') && ($value !== 'shop_coupon') && ($value !== 'acf') && ($value !== 'acf-field') && ($value !== 'acf-field-group') && ($value !== '_pods_pod') && ($value !== '_pods_field') && ($value !== 'shop_order_refund') && ($value !== 'shop_webhook') && ($value !=='llms_quiz') && ($value!=='llms_question') && ($value!=='llms_membership') && ($value!=='llms_engagement') && ($value!=='llms_order') && ($value!=='llms_transaction') && ($value!=='llms_achievement')&&($value !=='llms_my_achievement')&&($value!=='llms_my_certificate')&& ($value!=='llms_email') && ($value!=='llms_voucher') && ($value !=='llms_access_plan') && ($value !=='llms_form') &&($value!=='section') && ($value !=='llms_certificate')) { |
| 56 |
$response['custom_post_type'][$i] = $value; |
| 57 |
$i++; |
| 58 |
} |
| 59 |
} |
| 60 |
if (is_plugin_active('jet-booking/jet-booking.php')) { |
| 61 |
$response['jetbooking_active'] = true; |
| 62 |
} |
| 63 |
if (is_plugin_active('jet-reviews/jet-reviews.php')) { |
| 64 |
$response['jetreviews_active'] = true; |
| 65 |
} |
| 66 |
echo wp_json_encode($response); |
| 67 |
wp_die(); |
| 68 |
} |
| 69 |
|
| 70 |
public function getAuthors(){ |
| 71 |
check_ajax_referer('smack-ultimate-csv-importer', 'securekey'); |
| 72 |
$i = 0; |
| 73 |
$blogusers = get_users( [ 'role__in' => [ 'administrator', 'author' ] ] ); |
| 74 |
foreach( $blogusers as $user ) { |
| 75 |
$response['user_name'][$i] = $user->display_name; |
| 76 |
$response['user_id'][$i] = $user->ID; |
| 77 |
$i++; |
| 78 |
} |
| 79 |
echo wp_json_encode($response); |
| 80 |
wp_die(); |
| 81 |
} |
| 82 |
|
| 83 |
public function getTaxonomies(){ |
| 84 |
check_ajax_referer('smack-ultimate-csv-importer', 'securekey'); |
| 85 |
$i = 0; |
| 86 |
foreach (get_taxonomies() as $key => $value) { |
| 87 |
$response['taxonomies'][$i] = $value; |
| 88 |
$i++; |
| 89 |
} |
| 90 |
echo wp_json_encode($response); |
| 91 |
wp_die(); |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
global $export_handler_class; |
| 96 |
$export_handler_class = new ExportHandler(); |
| 97 |
|