PluginProbe
Export All Posts, Products, Orders & Users | WP Ultimate Exporter | WordPress CSV Export / trunk
Export All Posts, Products, Orders & Users | WP Ultimate Exporter | WordPress CSV Export vtrunk
3.0 2.24.2 2.24.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 2.0 2.0.1 2.1 2.1.1 2.1.2 2.10 2.11 2.12 2.13 2.14 2.15 2.16 2.16.1 2.16.2 All 96 releases
wp-ultimate-exporter / exportExtensions / ExportHandler.php

ExportHandler.php in Export All Posts, Products, Orders & Users | WP Ultimate Exporter | WordPress CSV Export trunk, at exportExtensions/ExportHandler.php

137 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 {
15 protected static $instance = null, $export_extension;
16 public static function getInstance()
17 {
18 if (null == self::$instance) {
19 self::$instance = new self;
20 self::$instance->doHooks();
21 ExportHandler::$export_extension = ExportExtension::getInstance();
22 }
23 return self::$instance;
24 }
25
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'));
31 }
32
33 /**
34 * SmackUCIExporter constructor.
35 *
36 * Set values into global variables based on post value
37 */
38 public function __construct()
39 {
40 $this->plugin = Plugin::getInstance();
41 }
42
43
44 public function getPostTypes()
45 {
46 check_ajax_referer('smack-ultimate-csv-importer', 'securekey');
47 global $wpdb;
48 $i = 0;
49 $get_post_types = get_post_types();
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')) {
84 $get_slug_name = $wpdb->get_results("SELECT slug FROM {$wpdb->prefix}jet_post_types WHERE status = 'content-type'");
85
86 foreach ($get_slug_name as $key => $get_slug) {
87 $value = $get_slug->slug;
88 $get_post_types[$value] = $value;
89 }
90 }
91 array_push($get_post_types, 'widgets');
92 foreach ($get_post_types as $key => $value) {
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')) {
94 $response['custom_post_type'][$i] = $value;
95 $i++;
96 }
97 }
98 if (is_plugin_active('jet-booking/jet-booking.php')) {
99 $response['jetbooking_active'] = true;
100 }
101 if (is_plugin_active('jet-reviews/jet-reviews.php')) {
102 $response['jetreviews_active'] = true;
103 }
104 echo wp_json_encode($response);
105 wp_die();
106 }
107
108 public function getAuthors()
109 {
110 check_ajax_referer('smack-ultimate-csv-importer', 'securekey');
111 $i = 0;
112 $blogusers = get_users(['role__in' => ['administrator', 'author']]);
113 foreach ($blogusers as $user) {
114 $response['user_name'][$i] = $user->display_name;
115 $response['user_id'][$i] = $user->ID;
116 $i++;
117 }
118 echo wp_json_encode($response);
119 wp_die();
120 }
121
122 public function getTaxonomies()
123 {
124 check_ajax_referer('smack-ultimate-csv-importer', 'securekey');
125 $i = 0;
126 foreach (get_taxonomies() as $key => $value) {
127 $response['taxonomies'][$i] = $value;
128 $i++;
129 }
130 echo wp_json_encode($response);
131 wp_die();
132 }
133 }
134
135 global $export_handler_class;
136 $export_handler_class = new ExportHandler();
137