| @@ -6,15 +6,17 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace Smackcoders\SMEXP; |
| 9 | 9 | |
| 10 | -if ( ! defined( 'ABSPATH' ) ) | |
| 10 | +if (!defined('ABSPATH')) | |
| 11 | 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 ) { | |
| 12 | + | |
| 13 | +class ExportHandler extends ExportExtension | |
| 14 | +{ | |
| 15 | + protected static $instance = null, $export_extension; | |
| 16 | + public static function getInstance() | |
| 17 | + { | |
| 18 | + if (null == self::$instance) { | |
| 17 | 19 | self::$instance = new self; |
| 18 | 20 | self::$instance->doHooks(); |
| 19 | 21 | ExportHandler::$export_extension = ExportExtension::getInstance(); |
| 20 | 22 | } |
| @@ -20,12 +22,13 @@ | ||
| 20 | 22 | } |
| 21 | 23 | return self::$instance; |
| 22 | 24 | } |
| 23 | 25 | |
| 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')); | |
| 26 | + public function doHooks() | |
| 27 | + { | |
| 28 | + add_action('wp_ajax_get_post_types', array($this, 'getPostTypes')); | |
| 29 | + add_action('wp_ajax_get_taxonomies', array($this, 'getTaxonomies')); | |
| 30 | + add_action('wp_ajax_get_authors', array($this, 'getAuthors')); | |
| 28 | 31 | } |
| 29 | 32 | |
| 30 | 33 | /** |
| 31 | 34 | * SmackUCIExporter constructor. |
| @@ -31,48 +34,84 @@ | ||
| 31 | 34 | * SmackUCIExporter constructor. |
| 32 | 35 | * |
| 33 | 36 | * Set values into global variables based on post value |
| 34 | 37 | */ |
| 35 | - public function __construct() { | |
| 38 | + public function __construct() | |
| 39 | + { | |
| 36 | 40 | $this->plugin = Plugin::getInstance(); |
| 37 | 41 | } |
| 38 | 42 | |
| 39 | 43 | |
| 40 | - public function getPostTypes(){ | |
| 44 | + public function getPostTypes() | |
| 45 | + { | |
| 41 | 46 | check_ajax_referer('smack-ultimate-csv-importer', 'securekey'); |
| 42 | 47 | global $wpdb; |
| 43 | 48 | $i = 0; |
| 44 | 49 | $get_post_types = get_post_types(); |
| 45 | - if(is_plugin_active('jet-engine/jet-engine.php')){ | |
| 50 | + if (is_plugin_active('easy-digital-downloads/easy-digital-downloads.php')) { | |
| 51 | + | |
| 52 | + if (isset($get_post_types['download'])) { | |
| 53 | + unset($get_post_types['download']); | |
| 54 | + } | |
| 55 | + | |
| 56 | + $get_post_types['EDD Downloads'] = 'EDD_DOWNLOADS'; | |
| 57 | + $get_post_types['EDD Customers'] = 'EDD_CUSTOMERS'; | |
| 58 | + $get_post_types['EDD Discounts'] = 'EDD_DISCOUNTS'; | |
| 59 | + } | |
| 60 | + | |
| 61 | + if (is_plugin_active('surecart/surecart.php')) { | |
| 62 | + | |
| 63 | + if (isset($get_post_types['sc_product'])) { | |
| 64 | + unset($get_post_types['sc_product']); | |
| 65 | + } | |
| 66 | + if (isset($get_post_types['sc_order'])) { | |
| 67 | + unset($get_post_types['sc_order']); | |
| 68 | + } | |
| 69 | + if (isset($get_post_types['sc_customer'])) { | |
| 70 | + unset($get_post_types['sc_customer']); | |
| 71 | + } | |
| 72 | + if (isset($get_post_types['sc_subscription'])) { | |
| 73 | + unset($get_post_types['sc_subscription']); | |
| 74 | + } | |
| 75 | + if (isset($get_post_types['sc_coupon'])) { | |
| 76 | + unset($get_post_types['sc_coupon']); | |
| 77 | + } | |
| 78 | + | |
| 79 | + $get_post_types['SureCart Products'] = 'SURECART_PRODUCTS'; | |
| 80 | + $get_post_types['SureCart Customers'] = 'SURECART_CUSTOMERS'; | |
| 81 | + $get_post_types['SureCart Coupons'] = 'SURECART_COUPONS'; | |
| 82 | + } | |
| 83 | + if (is_plugin_active('jet-engine/jet-engine.php')) { | |
| 46 | 84 | $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; | |
| 85 | + | |
| 86 | + foreach ($get_slug_name as $key => $get_slug) { | |
| 87 | + $value = $get_slug->slug; | |
| 88 | + $get_post_types[$value] = $value; | |
| 51 | 89 | } |
| 52 | 90 | } |
| 53 | 91 | array_push($get_post_types, 'widgets'); |
| 54 | 92 | 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')) { | |
| 93 | + 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 | 94 | $response['custom_post_type'][$i] = $value; |
| 57 | 95 | $i++; |
| 58 | 96 | } |
| 59 | - } | |
| 97 | + } | |
| 60 | 98 | if (is_plugin_active('jet-booking/jet-booking.php')) { |
| 61 | 99 | $response['jetbooking_active'] = true; |
| 62 | - } | |
| 100 | + } | |
| 63 | 101 | if (is_plugin_active('jet-reviews/jet-reviews.php')) { |
| 64 | 102 | $response['jetreviews_active'] = true; |
| 65 | - } | |
| 103 | + } | |
| 66 | 104 | echo wp_json_encode($response); |
| 67 | 105 | wp_die(); |
| 68 | 106 | } |
| 69 | 107 | |
| 70 | - public function getAuthors(){ | |
| 108 | + public function getAuthors() | |
| 109 | + { | |
| 71 | 110 | check_ajax_referer('smack-ultimate-csv-importer', 'securekey'); |
| 72 | 111 | $i = 0; |
| 73 | - $blogusers = get_users( [ 'role__in' => [ 'administrator', 'author' ] ] ); | |
| 74 | - foreach( $blogusers as $user ) { | |
| 112 | + $blogusers = get_users(['role__in' => ['administrator', 'author']]); | |
| 113 | + foreach ($blogusers as $user) { | |
| 75 | 114 | $response['user_name'][$i] = $user->display_name; |
| 76 | 115 | $response['user_id'][$i] = $user->ID; |
| 77 | 116 | $i++; |
| 78 | 117 | } |
| @@ -79,14 +118,15 @@ | ||
| 79 | 118 | echo wp_json_encode($response); |
| 80 | 119 | wp_die(); |
| 81 | 120 | } |
| 82 | 121 | |
| 83 | - public function getTaxonomies(){ | |
| 122 | + public function getTaxonomies() | |
| 123 | + { | |
| 84 | 124 | check_ajax_referer('smack-ultimate-csv-importer', 'securekey'); |
| 85 | 125 | $i = 0; |
| 86 | 126 | foreach (get_taxonomies() as $key => $value) { |
| 87 | - $response['taxonomies'][$i] = $value; | |
| 88 | - $i++; | |
| 127 | + $response['taxonomies'][$i] = $value; | |
| 128 | + $i++; | |
| 89 | 129 | } |
| 90 | 130 | echo wp_json_encode($response); |
| 91 | 131 | wp_die(); |
| 92 | 132 | } |