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
← All changes | exportExtensions/PostExport.php +1069 -1033 2.13trunk View file →
@@ -6,23 +6,27 @@
6 6 */
7 7
8 8 namespace Smackcoders\SMEXP;
9 9
10 -if ( ! defined( 'ABSPATH' ) )
11 - exit; // Exit if accessed directly
10 +if (!defined('ABSPATH'))
11 + exit; // Exit if accessed directly
12 12
13 13 /**
14 14 * Class PostExport
15 15 * @package Smackcoders\WCSV
16 - */
17 -class PostExport extends ExportExtension{
16 + */
17 +require_once dirname(__FILE__) . '/ExportExtension.php';
18 +use Smackcoders\SMEXP\ExportExtension;
18 19
19 - protected static $instance = null,$mapping_instance,$export_handler,$export_instance,$jet_custom_table_export;
20 - public $offset = 0;
20 +class PostExport extends ExportExtension
21 +{
22 + protected static $instance = null, $mapping_instance, $export_handler, $export_instance, $jet_custom_table_export;
23 + public $offset = 0;
21 24 public $limit;
22 25 public $totalRowCount;
23 - public static function getInstance() {
24 - if ( null == self::$instance ) {
26 + public static function getInstance()
27 + {
28 + if (null == self::$instance) {
25 29 self::$instance = new self;
26 30 self::$export_instance = ExportExtension::getInstance();
27 31 PostExport::$jet_custom_table_export = JetCustomTableExport::getInstance();
28 32 }
@@ -31,16 +35,18 @@
31 35
32 36 /**
33 37 * PostExport constructor.
34 38 */
35 - public function __construct() {
39 + public function __construct()
40 + {
36 41 $this->plugin = Plugin::getInstance();
37 42 }
38 43
39 - public function get_total_rowCount(){
44 + public function get_total_rowCount()
45 + {
40 46 $product_counts = wp_count_posts('product');
41 47 $statuses = ['publish', 'draft', 'future', 'private', 'pending'];
42 -
48 +
43 49 $total_count = 0;
44 50 foreach ($statuses as $status) {
45 51 if (isset($product_counts->$status)) {
46 52 $total_count += $product_counts->$status;
@@ -56,92 +62,109 @@
56 62 * @param $optionalType
57 63 * @param $conditions
58 64 * @return array
59 65 */
60 - public function getRecordsBasedOnPostTypes ($module, $optionalType, $conditions ,$offset , $limit ,$headers = '') {
61 - global $wpdb,$sitepress;
62 - if($module == 'JetBooking'){
63 - if(!empty($conditions['specific_jetbooking_status']['is_check']) && $conditions['specific_jetbooking_status']['is_check'] == 'true' && !empty($conditions['specific_jetbooking_status']['status']) ) {
66 + public function getRecordsBasedOnPostTypes($module, $optionalType, $conditions, $offset, $limit, $headers = '')
67 + {
68 + global $wpdb, $sitepress;
69 + $offset = (int) $offset;
70 + $limit = (int) $limit;
71 + if ($module == 'JetBooking') {
72 + if (!empty($conditions['specific_jetbooking_status']['is_check']) && $conditions['specific_jetbooking_status']['is_check'] == 'true' && !empty($conditions['specific_jetbooking_status']['status'])) {
64 73 $jet_booking_status = $conditions['specific_jetbooking_status']['status'];
65 - $bookings = jet_abaf_get_bookings( ['status' => $jet_booking_status,'return' => 'arrays']);
74 + $bookings = jet_abaf_get_bookings(['status' => $jet_booking_status, 'return' => 'arrays']);
66 75 $post_ids = wp_list_pluck($bookings, 'ID');
67 76 self::$export_instance->totalRowCount = count($post_ids);
68 77 return $post_ids;
69 - }else{
70 - $bookings = jet_abaf_get_bookings( [ 'return' => 'arrays' ] );
78 + } else {
79 + $bookings = jet_abaf_get_bookings(['return' => 'arrays']);
71 80 $post_ids = wp_list_pluck($bookings, 'ID');
72 81 self::$export_instance->totalRowCount = count($post_ids);
73 82 return $post_ids;
74 - }
83 + }
75 84 }
76 85 if ($module == 'WooCommerceCustomer') {
77 86 // Get all customer user IDs
78 87 $post_ids = get_users([
79 - 'role' => 'customer',
80 - 'fields' => 'ID'
88 + 'role' => 'customer',
89 + 'fields' => 'ID'
81 90 ]);
82 -
91 +
83 92 // Return the array of customer user IDs
84 93 return $post_ids;
85 94 }
86 -
87 - if($module == 'CustomPosts' && $optionalType == 'nav_menu_item'){
95 +
96 + if ($module == 'EDD_CUSTOMERS') {
97 + $post_ids = $wpdb->get_col($wpdb->prepare("SELECT id FROM {$wpdb->prefix}edd_customers ORDER BY id ASC LIMIT %d, %d", $offset, $limit));
98 + self::$export_instance->totalRowCount = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}edd_customers");
99 + return $post_ids;
100 + }
101 +
102 + if ($module == 'EDD_DISCOUNTS') {
103 + if ($this->is_edd_3_0_plus()) {
104 + $post_ids = $wpdb->get_col($wpdb->prepare("SELECT id FROM {$wpdb->prefix}edd_adjustments WHERE type = 'discount' ORDER BY id ASC LIMIT %d, %d", $offset, $limit));
105 + self::$export_instance->totalRowCount = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}edd_adjustments WHERE type = 'discount'");
106 + } else {
107 + $post_ids = $wpdb->get_col($wpdb->prepare("SELECT id FROM {$wpdb->prefix}edd_discounts ORDER BY id ASC LIMIT %d, %d", $offset, $limit));
108 + self::$export_instance->totalRowCount = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}edd_discounts");
109 + }
110 + return $post_ids;
111 + }
112 +
113 +
114 +
115 + if ($module == 'CustomPosts' && $optionalType == 'nav_menu_item') {
88 116 $get_menu_id = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}terms AS t LEFT JOIN {$wpdb->prefix}term_taxonomy AS tt ON tt.term_id = t.term_id WHERE tt.taxonomy = 'nav_menu' ", ARRAY_A);
89 117 $get_menu_arr = array_column($get_menu_id, 'term_id');
90 118 self::$export_instance->totalRowCount = count($get_menu_arr);
91 - return $get_menu_arr;
119 + return $get_menu_arr;
92 120 }
93 - if($module == 'CustomPosts' && $optionalType == 'widgets'){
121 + if ($module == 'CustomPosts' && $optionalType == 'widgets') {
94 122 $get_widget_id = $wpdb->get_row("SELECT option_id FROM {$wpdb->prefix}options where option_name = 'widget_recent-posts' ", ARRAY_A);
95 123 self::$export_instance->totalRowCount = 1;
96 - return $get_widget_id;
124 + return $get_widget_id;
97 125 }
98 - if($module == 'CustomPosts') {
99 - $module = $optionalType;
100 - } elseif ($module == 'WooCommerceOrders') {
126 + if ($module == 'WooCommerceOrders') {
101 127 $module = 'shop_order';
102 - }
103 - elseif ($module == 'WooCommerceCoupons') {
128 + } elseif ($module == 'WooCommerceCoupons') {
104 129 $module = 'shop_coupon';
105 - }
106 - elseif ($module == 'WooCommerceRefunds') {
130 + } elseif ($module == 'WooCommerceRefunds') {
107 131 $module = 'shop_order_refund';
108 - }
109 - elseif ($module == 'WooCommerceVariations') {
110 - if(is_plugin_active('polylang/polylang.php') || is_plugin_active('polylang-pro/polylang.php') || is_plugin_active('polylang-wc/polylang-wc.php')){
132 + } elseif ($module == 'WooCommerceVariations') {
133 + if (is_plugin_active('polylang/polylang.php') || is_plugin_active('polylang-pro/polylang.php') || is_plugin_active('polylang-wc/polylang-wc.php')) {
111 134 $module = 'product_variation';
112 135 $extracted_ids = "select DISTINCT ID from {$wpdb->prefix}posts";
113 - $extracted_ids .= " where post_type = '$module'";
114 - $extracted_ids .= "and post_status in ('publish','draft','future','private','pending') AND post_parent!=0";
136 + $extracted_ids .= $wpdb->prepare(" where post_type = %s", $module);
137 + $extracted_ids .= " and post_status in ('publish','draft','future','private','pending') AND post_parent!=0";
115 138 $extracted_id = $wpdb->get_col($extracted_ids);
116 - $extracted_ids =array();
117 - foreach($extracted_id as $ids){
118 -
119 - $parent_id = $wpdb->get_var("SELECT post_parent FROM {$wpdb->prefix}posts where ID=$ids");
120 -
121 - $post_status =$wpdb->get_var("SELECT post_status FROM {$wpdb->prefix}posts where ID=$parent_id");
122 - if(!empty($post_status )){
123 - if($post_status !='trash' && $post_status != 'inherit'){
124 - $extracted_ids [] =$ids;
139 + $extracted_ids = array();
140 + foreach ($extracted_id as $ids) {
141 +
142 + $parent_id = $wpdb->get_var($wpdb->prepare("SELECT post_parent FROM {$wpdb->prefix}posts where ID=%d", absint($ids)));
143 +
144 + $post_status = $wpdb->get_var($wpdb->prepare("SELECT post_status FROM {$wpdb->prefix}posts where ID=%d", absint($parent_id)));
145 + if (!empty($post_status)) {
146 + if ($post_status != 'trash' && $post_status != 'inherit') {
147 + $extracted_ids[] = $ids;
125 148 }
126 149
127 150 }
128 151 }
129 - self::$export_instance->totalRowCount = count($extracted_ids);
152 + self::$export_instance->totalRowCount = count($extracted_ids);
130 153 return array_reverse($extracted_ids);
131 - }
132 - else{
154 + } else {
133 155 $product_statuses = array('publish', 'draft', 'future', 'private', 'pending');
134 - $products = wc_get_products(array('status' => $product_statuses ,'limit' => -1));
156 + $products = wc_get_products(array('status' => $product_statuses, 'limit' => -1));
135 157 $variable_product_ids = [];
136 - foreach($products as $product){
158 + foreach ($products as $product) {
137 159 if ($product->is_type('variable')) {
138 160 $variable_product_ids[] = $product->get_id();
139 161 }
140 - }$variation_ids = [];
141 - foreach($variable_product_ids as $variable_product_id){
162 + }
163 + $variation_ids = [];
164 + foreach ($variable_product_ids as $variable_product_id) {
142 165 $variable_product = wc_get_product($variable_product_id);
143 - $variation_ids[] = $variable_product->get_children();
166 + $variation_ids[] = $variable_product->get_children();
144 167 }
145 168 $extracted_ids = [];
146 169 foreach ($variation_ids as $v_ids) {
147 170 foreach ($v_ids as $v_id) {
@@ -147,57 +170,97 @@
147 170 foreach ($v_ids as $v_id) {
148 171 $extracted_ids[] = $v_id;
149 172 }
150 173 }
151 - self::$export_instance->totalRowCount = count($extracted_ids);
174 + self::$export_instance->totalRowCount = count($extracted_ids);
152 175 return array_reverse($extracted_ids);
153 - }
176 + }
177 + }elseif ($module == 'SURECART_PRODUCTS') {
178 + $module = 'sc_product';
179 + } elseif ($module == 'SURECART_CUSTOMERS') {
180 + if (class_exists('\\SureCart\\Models\\Customer')) {
181 + try {
182 + $collection = \SureCart\Models\Customer::paginate(['per_page' => 1]);
183 + $total_count = $collection->total();
184 + if (isset(self::$export_instance)) {
185 + self::$export_instance->totalRowCount = $total_count;
186 + }
187 +
188 + $customers = \SureCart\Models\Customer::where(['limit' => $limit, 'offset' => $offset])->get();
189 + $result = [];
190 + if (!empty($customers)) {
191 + foreach ($customers as $customer) {
192 + $result[] = $customer->id;
193 + }
194 + }
195 + return $result;
196 + } catch (\Throwable $e) {
197 + return [];
198 + }
199 + }
200 + return [];
201 + } elseif ($module == 'SURECART_COUPONS') {
202 + if (class_exists('\\SureCart\\Models\\Coupon')) {
203 + try {
204 + $collection = \SureCart\Models\Coupon::paginate(['per_page' => 1]);
205 + $total_count = $collection->total();
206 + if (isset(self::$export_instance)) {
207 + self::$export_instance->totalRowCount = $total_count;
208 + }
209 +
210 + $coupons = \SureCart\Models\Coupon::where(['limit' => $limit, 'offset' => $offset])->get();
211 + $result = [];
212 + if (!empty($coupons)) {
213 + foreach ($coupons as $coupon) {
214 + $result[] = $coupon->id;
215 + }
216 + }
217 + return $result;
218 + } catch (\Throwable $e) {
219 + return [];
220 + }
221 + }
154 222 }
155 - elseif($module == 'WPeCommerceCoupons'){
223 + elseif ($module == 'WPeCommerceCoupons') {
156 224 $module = 'wpsc-coupon';
225 + } else {
226 + $module = self::import_post_types($module, $optionalType);
157 227 }
158 - else {
159 - $module = self::import_post_types($module);
160 - }
161 228
162 229 $get_post_ids = "select DISTINCT ID from {$wpdb->prefix}posts";
163 - $get_post_ids .= " where post_type = '$module'";
230 + $get_post_ids .= $wpdb->prepare(" where post_type = %s", $module);
164 231
165 232 /**
166 233 * Check for specific status
167 234 */
168 - if($module == 'product' && is_plugin_active('woocommerce/woocommerce.php')){
169 - if ($sitepress == null && !is_plugin_active('polylang/polylang.php') && !is_plugin_active('polylang-pro/polylang.php') && !is_plugin_active('polylang-wc/polylang-wc.php') && !is_plugin_active('woocommerce-multilingual/wpml-woocommerce.php') && !is_plugin_active('sitepress-multilingual-cms/sitepress.php')) {
170 - if(!empty($conditions['specific_period']['is_check']) && $conditions['specific_period']['is_check'] == 'true') {
171 - if($conditions['specific_period']['from'] == $conditions['specific_period']['to']){
235 + if ($module == 'product' && is_plugin_active('woocommerce/woocommerce.php')) {
236 + if ($sitepress == null && !is_plugin_active('polylang/polylang.php') && !is_plugin_active('polylang-pro/polylang.php') && !is_plugin_active('polylang-wc/polylang-wc.php') && !is_plugin_active('woocommerce-multilingual/wpml-woocommerce.php') && !is_plugin_active('sitepress-multilingual-cms/sitepress.php')) {
237 + if (!empty($conditions['specific_period']['is_check']) && $conditions['specific_period']['is_check'] == 'true') {
238 + if ($conditions['specific_period']['from'] == $conditions['specific_period']['to']) {
172 239 $from_date = $conditions['specific_period']['from'];
173 240 $product_statuses = array('publish', 'draft', 'future', 'private', 'pending');
174 - $args = array('date_query' => array(array('year' => date( 'Y', strtotime( $from_date ) ),'month' => date( 'm', strtotime( $from_date ) ),'day' => date( 'd', strtotime( $from_date ) ),),),'status' => $product_statuses,'limit' => $limit,'offset' => $offset,'orderby' => 'date');
175 - }else{
241 + $args = array('date_query' => array(array('year' => date('Y', strtotime($from_date)), 'month' => date('m', strtotime($from_date)), 'day' => date('d', strtotime($from_date)), ), ), 'status' => $product_statuses, 'limit' => $limit, 'offset' => $offset, 'orderby' => 'date');
242 + } else {
176 243 $from_date = $conditions['specific_period']['from'] ?? null;
177 - $to_date = $conditions['specific_period']['to'] ?? null;
244 + $to_date = $conditions['specific_period']['to'] ?? null;
178 245 $product_statuses = array('publish', 'draft', 'future', 'private', 'pending');
179 - $args = array('date_query' => array(array('after' => $from_date,'before' => $to_date,'inclusive' => true,),),'status' => $product_statuses,'limit' => $limit,'offset' => $offset,'orderby' => 'date');
246 + $args = array('date_query' => array(array('after' => $from_date, 'before' => $to_date, 'inclusive' => true, ), ), 'status' => $product_statuses, 'limit' => $limit, 'offset' => $offset, 'orderby' => 'date');
180 247 }
181 248 $products = wc_get_products($args);
182 - }
183 - elseif(!empty($conditions['specific_post_id']['is_check']) && $conditions['specific_post_id']['is_check'] == 'true'){
184 - $prod_id=explode(',',$conditions['specific_post_id']['post_id']);
185 - $args=array('include' => $prod_id);
186 - $products=wc_get_products($args);
187 - }
188 - elseif(!empty($conditions['specific_status']['status'])) {
249 + } elseif (!empty($conditions['specific_post_id']['is_check']) && $conditions['specific_post_id']['is_check'] == 'true') {
250 + $prod_id = explode(',', $conditions['specific_post_id']['post_id']);
251 + $args = array('include' => $prod_id);
252 + $products = wc_get_products($args);
253 + } elseif (!empty($conditions['specific_status']['status'])) {
189 254 $status = $conditions['specific_status']['status'];
190 - if($conditions['specific_status']['status'] == 'all') {
255 + if ($conditions['specific_status']['status'] == 'all') {
191 256 $product_statuses = array('publish', 'draft', 'trash', 'private', 'pending');
192 - $products = wc_get_products(array('status' => $product_statuses, 'limit' => $limit,'offset' => $offset,'orderby' => 'date'));
193 - }
194 - else{
257 + $products = wc_get_products(array('status' => $product_statuses, 'limit' => $limit, 'offset' => $offset, 'orderby' => 'date'));
258 + } else {
195 259 $product_statuses = array($status);
196 - $products = wc_get_products(array('status' => $product_statuses, 'limit' => $limit,'offset' => $offset,'orderby' => 'date'));
260 + $products = wc_get_products(array('status' => $product_statuses, 'limit' => $limit, 'offset' => $offset, 'orderby' => 'date'));
197 261 }
198 - }
199 - else{
262 + } else {
200 263
201 264 // Define product statuses
202 265 $product_statuses = ['publish', 'draft', 'future', 'private', 'pending'];
203 266
@@ -202,13 +265,13 @@
202 265 $product_statuses = ['publish', 'draft', 'future', 'private', 'pending'];
203 266
204 267 // Prepare query arguments
205 268 $args = [
206 - 'status' => $product_statuses,
207 - 'limit' => $limit,
208 - 'offset' => $offset,
269 + 'status' => $product_statuses,
270 + 'limit' => $limit,
271 + 'offset' => $offset,
209 272 'orderby' => 'date',
210 - 'order' => 'DESC', // Order products by date in descending order
273 + 'order' => 'DESC', // Order products by date in descending order
211 274 ];
212 275
213 276 // Fetch products
214 277 $products = wc_get_products($args);
@@ -232,218 +295,231 @@
232 295 $all_product_ids = array_unique($all_product_ids);
233 296 self::$export_instance->totalRowCount = $this->get_total_rowCount();
234 297 $product_ids = !empty($all_product_ids) ? $all_product_ids : [];
235 298 return $product_ids;
236 - }
237 - else{
299 + } else {
238 300 //when polylang wpml active
239 301 $products = "select DISTINCT ID from {$wpdb->prefix}posts";
240 - $products .= " where post_type = '$module'";
241 - if(!empty($conditions['specific_period']['is_check']) && $conditions['specific_period']['is_check'] == 'true' && !empty($conditions['specific_status']['status'])) { //Period and Status both are TRUE
242 - if($conditions['specific_period']['from'] == $conditions['specific_period']['to']){
302 + $products .= $wpdb->prepare(" where post_type = %s", $module);
303 + if (!empty($conditions['specific_period']['is_check']) && $conditions['specific_period']['is_check'] == 'true' && !empty($conditions['specific_status']['status'])) { //Period and Status both are TRUE
304 + if ($conditions['specific_period']['from'] == $conditions['specific_period']['to']) {
243 305 $status = $conditions['specific_status']['status'];
244 - $products .= " and post_status = '$status'";
245 - $products .= " and DATE(post_date) ='" . $conditions['specific_period']['from'] . "'";
246 - }else{
306 + $products .= $wpdb->prepare(" and post_status = %s", $status);
307 + $products .= " and DATE(post_date) ='" . $conditions['specific_period']['from'] . "'";
308 + } else {
247 309 $status = $conditions['specific_status']['status'];
248 - $products .= " and post_status = '$status'";
310 + $products .= $wpdb->prepare(" and post_status = %s", $status);
249 311 $products .= " and post_date >= '" . $conditions['specific_period']['from'] . "' and post_date <= '" . $conditions['specific_period']['to'] . " 23:00:00'";
250 312 }
251 - }
252 - elseif(!empty($conditions['specific_period']['is_check']) && $conditions['specific_period']['is_check'] == 'true') {
313 + } elseif (!empty($conditions['specific_period']['is_check']) && $conditions['specific_period']['is_check'] == 'true') {
253 314 $products .= " and post_status in ('publish','draft','private','pending') ";
254 - if($conditions['specific_period']['from'] == $conditions['specific_period']['to']){
255 - $products .= " and DATE(post_date) ='".$conditions['specific_period']['from']."'";
256 - }else{
315 + if ($conditions['specific_period']['from'] == $conditions['specific_period']['to']) {
316 + $products .= " and DATE(post_date) ='" . $conditions['specific_period']['from'] . "'";
317 + } else {
257 318 $products .= " and post_date >= '" . $conditions['specific_period']['from'] . "' and post_date <= '" . $conditions['specific_period']['to'] . " 23:00:00'";
258 319 }
259 - }
260 - elseif(!empty($conditions['specific_status']['status'])) {
320 + } elseif (!empty($conditions['specific_status']['status'])) {
261 321 $status = $conditions['specific_status']['status'];
262 - if($conditions['specific_status']['status'] == 'all') {
263 - $products .= " and post_status in ('publish','draft','trash','private','pending') ORDER by post_date";
264 - }
265 - else{
266 - $products .= " and post_status = '$status' ORDER by post_date";
322 + if ($conditions['specific_status']['status'] == 'all') {
323 + $products .= " and post_status in ('publish','draft','trash','private','pending') ORDER by post_date";
324 + } else {
325 + $products .= $wpdb->prepare(" and post_status = %s", $status) . " ORDER by post_date";
267 326 }
268 - }
269 - elseif(!empty($conditions['specific_post_id']['is_check']) && $conditions['specific_post_id']['is_check'] == 'true'){
270 - $prod_ids =$conditions['specific_post_id']['post_id'];
271 - $products .= "and ID in ($prod_ids)";
327 + } elseif (!empty($conditions['specific_post_id']['is_check']) && $conditions['specific_post_id']['is_check'] == 'true') {
328 + $prod_ids = array_filter(array_map('absint', explode(',', $conditions['specific_post_id']['post_id'])));
329 + if (!empty($prod_ids)) {
330 + $products .= " and ID in (" . implode(',', $prod_ids) . ")";
331 + }
272 332
273 333 }
274 - if(empty($conditions['specific_status']['status']) && empty($conditions['specific_period']['is_check'])) {
334 + if (empty($conditions['specific_status']['status']) && empty($conditions['specific_period']['is_check'])) {
275 335 $products .= " and post_status in ('publish','draft','future','private','pending') ORDER by post_date";
276 336 }
277 - $products = $wpdb->get_col($products);
278 - $product_array = $products;
279 - foreach($products as $product_val){
337 + $products = $wpdb->get_col($products);
338 + $product_array = $products;
339 + foreach ($products as $product_val) {
280 340 $products_var = "select DISTINCT ID from {$wpdb->prefix}posts";
281 - $products_var .= " where post_type = 'product_variation' and post_parent = '$product_val'";
282 - if(!empty($conditions['specific_period']['is_check']) && $conditions['specific_period']['is_check'] == 'true' && !empty($conditions['specific_status']['status'])) { //Period and Status both are TRUE
283 - if($conditions['specific_period']['from'] == $conditions['specific_period']['to']){
341 + $products_var .= $wpdb->prepare(" where post_type = 'product_variation' and post_parent = %d", absint($product_val));
342 + if (!empty($conditions['specific_period']['is_check']) && $conditions['specific_period']['is_check'] == 'true' && !empty($conditions['specific_status']['status'])) { //Period and Status both are TRUE
343 + if ($conditions['specific_period']['from'] == $conditions['specific_period']['to']) {
284 344 $status = $conditions['specific_status']['status'];
285 - $products_var .= " and post_status = '$status'";
286 - $products_var .= " and DATE(post_date) ='" . $conditions['specific_period']['from'] . "'";
287 - }else{
345 + $products_var .= $wpdb->prepare(" and post_status = %s", $status);
346 + $products_var .= " and DATE(post_date) ='" . $conditions['specific_period']['from'] . "'";
347 + } else {
288 348 $status = $conditions['specific_status']['status'];
289 - $products_var .= " and post_status = '$status'";
349 + $products_var .= $wpdb->prepare(" and post_status = %s", $status);
290 350 $products_var .= " and post_date >= '" . $conditions['specific_period']['from'] . "' and post_date <= '" . $conditions['specific_period']['to'] . " 23:00:00'";
291 351 }
292 - }
293 - elseif(!empty($conditions['specific_period']['is_check']) && $conditions['specific_period']['is_check'] == 'true') {
352 + } elseif (!empty($conditions['specific_period']['is_check']) && $conditions['specific_period']['is_check'] == 'true') {
294 353 $products .= " and post_status in ('publish','draft','private','pending') ";
295 - if($conditions['specific_period']['from'] == $conditions['specific_period']['to']){
296 - $products_var .= " and DATE(post_date) ='".$conditions['specific_period']['from']."'";
297 - }else{
354 + if ($conditions['specific_period']['from'] == $conditions['specific_period']['to']) {
355 + $products_var .= " and DATE(post_date) ='" . $conditions['specific_period']['from'] . "'";
356 + } else {
298 357 $products_var .= " and post_date >= '" . $conditions['specific_period']['from'] . "' and post_date <= '" . $conditions['specific_period']['to'] . " 23:00:00'";
299 358 }
300 - }
301 - elseif(!empty($conditions['specific_status']['status'])) {
359 + } elseif (!empty($conditions['specific_status']['status'])) {
302 360 $status = $conditions['specific_status']['status'];
303 - if($conditions['specific_status']['status'] == 'all') {
304 - $products_var .= " and post_status in ('publish','draft','trash','private','pending') ORDER by post_date";
305 - }
306 - else{
307 - $products_var .= " and post_status = '$status' ORDER by post_date";
361 + if ($conditions['specific_status']['status'] == 'all') {
362 + $products_var .= " and post_status in ('publish','draft','trash','private','pending') ORDER by post_date";
363 + } else {
364 + $products_var .= $wpdb->prepare(" and post_status = %s", $status) . " ORDER by post_date";
308 365 }
309 - }
310 - elseif(!empty($conditions['specific_post_id']['is_check']) && $conditions['specific_post_id']['is_check'] == 'true'){
311 - $prod_ids =$conditions['specific_post_id']['post_id'];
312 - $products_var .= "and ID in ($prod_ids)";
366 + } elseif (!empty($conditions['specific_post_id']['is_check']) && $conditions['specific_post_id']['is_check'] == 'true') {
367 + $prod_ids = array_filter(array_map('absint', explode(',', $conditions['specific_post_id']['post_id'])));
368 + if (!empty($prod_ids)) {
369 + $products_var .= " and ID in (" . implode(',', $prod_ids) . ")";
370 + }
313 371
314 372 }
315 - if(empty($conditions['specific_status']['status']) && empty($conditions['specific_period']['is_check'])) {
373 + if (empty($conditions['specific_status']['status']) && empty($conditions['specific_period']['is_check'])) {
316 374 $products_var .= " and post_status in ('publish','draft','future','private','pending') ORDER by post_date";
317 375 }
318 376 $products_vars = $wpdb->get_col($products_var);
319 - $product_array = array_merge($product_array,$products_vars);
320 - }
321 - self::$export_instance->totalRowCount = count($product_array);
322 - $products_ids = !empty($products) ? array_slice($product_array, $offset, $limit) : [];
323 - return $products_ids;
324 - }
325 - }
326 - elseif($module == 'shop_order' && is_plugin_active('woocommerce/woocommerce.php')){
327 - if($sitepress == null && !is_plugin_active('polylang/polylang.php') && !is_plugin_active('polylang-pro/polylang.php') && !is_plugin_active('polylang-wc/polylang-wc.php') && !is_plugin_active('woocommerce-multilingual/wpml-woocommerce.php')){
328 - if(!empty($conditions['specific_period']['is_check']) && $conditions['specific_period']['is_check'] == 'true') { //Specific period ONLY TRUE
329 - if($conditions['specific_period']['from'] == $conditions['specific_period']['to']){
377 + $product_array = array_merge($product_array, $products_vars);
378 + }
379 + self::$export_instance->totalRowCount = count($product_array);
380 + $products_ids = !empty($products) ? array_slice($product_array, $offset, $limit) : [];
381 + return $products_ids;
382 + }
383 + } elseif ($module == 'shop_order' && is_plugin_active('woocommerce/woocommerce.php')) {
384 +
385 + if (!empty($conditions['specific_period']['is_check'])) {
386 + $args = [
387 + 'return' => 'ids',
388 + 'limit' => $limit,
389 + 'offset' => $offset,
390 + 'orderby' => 'date',
391 + 'order' => 'DESC',
392 + ];
393 +
394 + if (!empty($conditions['specific_period']['is_check']) &&!empty($conditions['specific_period']['from']) &&!empty($conditions['specific_period']['to'])) {
395 + $args['date_query'] = [[
396 + 'after' => $conditions['specific_period']['from'],
397 + 'before' => $conditions['specific_period']['to'],
398 + 'inclusive' => true,
399 + ]];
400 + }
401 +
402 + $order_ids = wc_get_orders($args);
403 + $count_args = $args;
404 + $count_args['limit'] = -1;
405 + $count_args['offset'] = 0;
406 +
407 + self::$export_instance->totalRowCount = count(wc_get_orders($count_args));
408 +
409 + return $order_ids;
410 + }
411 + if ($sitepress == null && !is_plugin_active('polylang/polylang.php') && !is_plugin_active('polylang-pro/polylang.php') && !is_plugin_active('polylang-wc/polylang-wc.php') && !is_plugin_active('woocommerce-multilingual/wpml-woocommerce.php')) {
412 + if (!empty($conditions['specific_period']['is_check']) && $conditions['specific_period']['is_check'] == 'true') { //Specific period ONLY TRUE
413 + if ($conditions['specific_period']['from'] == $conditions['specific_period']['to']) {
330 414 $from_date = $conditions['specific_period']['from'];
331 415 $status = array('wc-completed', 'wc-cancelled', 'wc-on-hold', 'wc-processing', 'wc-pending');
332 - $args = array('date_query' => array(array('year' => date('Y', strtotime($from_date)),'month' => date('m', strtotime($from_date)),'day' => date('d', strtotime($from_date)),),),'status' => $status,'numberposts' => -1,'orderby' => 'date',);
333 - }else{
416 + $args = array('date_query' => array(array('year' => date('Y', strtotime($from_date)), 'month' => date('m', strtotime($from_date)), 'day' => date('d', strtotime($from_date)), ), ), 'status' => $status, 'numberposts' => -1, 'orderby' => 'date', );
417 + } else {
334 418 $from_date = $conditions['specific_period']['from'] ?? null;
335 - $to_date = $conditions['specific_period']['to'] ?? null;
336 - $status = array('wc-completed', 'wc-cancelled', 'wc-on-hold', 'wc-processing', 'wc-pending');;
337 - $args = array('date_query' => array(array('after' => $from_date,'before'=> $to_date,'inclusive' => true,),),'status' => $status,'numberposts' => -1,'orderby' => 'date');
419 + $to_date = $conditions['specific_period']['to'] ?? null;
420 + $status = array('wc-completed', 'wc-cancelled', 'wc-on-hold', 'wc-processing', 'wc-pending');
421 + ;
422 + $args = array('date_query' => array(array('after' => $from_date, 'before' => $to_date, 'inclusive' => true, ), ), 'status' => $status, 'numberposts' => -1, 'orderby' => 'date');
338 423 }
339 424 $orders = wc_get_orders($args);
340 - }
341 - else{
425 + } else {
342 426 $order_statuses = array('wc-completed', 'wc-cancelled', 'wc-on-hold', 'wc-processing', 'wc-pending');
343 - $orders = wc_get_orders(array('status' => $order_statuses,'numberposts' => -1,'orderby' => 'date','order' => 'ASC'));
427 + $orders = wc_get_orders(array('status' => $order_statuses, 'numberposts' => -1, 'orderby' => 'date', 'order' => 'ASC'));
344 428 }
345 429 $get_order_ids = array();
346 - if(!empty($orders)){
430 + if (!empty($orders)) {
347 431 $get_post_ids = array();
348 - foreach($orders as $my_orders){
432 + foreach ($orders as $my_orders) {
349 433 $get_post_ids[] = $my_orders->get_id();
350 434 }
351 435 self::$export_instance->totalRowCount = count($get_post_ids);
352 - $get_order_ids = !empty($get_post_ids) ? array_slice($get_post_ids, $offset, $limit) : [];
436 + $get_order_ids = !empty($get_post_ids) ? array_slice($get_post_ids, $offset, $limit) : [];
353 437 }
354 - return $get_order_ids;
355 - }
356 - else{//polylang or wpml active
357 - $order_statuses = array('wc-completed', 'wc-cancelled', 'wc-on-hold', 'wc-processing', 'wc-pending');
358 - $orders = wc_get_orders(array('status' => $order_statuses,'numberposts' => -1,'orderby' => 'date','order' => 'ASC'));
359 - $get_post_ids = array();
360 - foreach($orders as $my_orders){
361 - $get_post_ids[] = $my_orders->get_id();
438 + return $get_order_ids;
439 + } else {//polylang or wpml active
440 + $order_statuses = array('wc-completed', 'wc-cancelled', 'wc-on-hold', 'wc-processing', 'wc-pending');
441 + $orders = wc_get_orders(array('status' => $order_statuses, 'numberposts' => -1, 'orderby' => 'date', 'order' => 'ASC'));
442 + $get_post_ids = array();
443 + foreach ($orders as $my_orders) {
444 + $get_post_ids[] = $my_orders->get_id();
445 + }
446 + foreach ($get_post_ids as $ids) {
447 + $module = $wpdb->get_var($wpdb->prepare("SELECT post_type FROM {$wpdb->prefix}posts where id=%d", absint($ids)));
448 + }
449 + if ($module == 'shop_order_placehold') {//post_status shop_order_placehold!
450 + $orders = "select DISTINCT p.ID from {$wpdb->prefix}posts as p inner join {$wpdb->prefix}wc_orders as wc ON p.ID=wc.id";
451 + $orders .= $wpdb->prepare(" where p.post_type = %s", $module);
452 + if (!empty($conditions['specific_period']['is_check']) && $conditions['specific_period']['is_check'] == 'true') {
453 + $orders .= " and wc.status in ('wc-completed', 'wc-cancelled', 'wc-on-hold', 'wc-processing', 'wc-pending')";
454 + if ($conditions['specific_period']['from'] == $conditions['specific_period']['to']) {
455 + $orders .= " and DATE(p.post_date) ='" . $conditions['specific_period']['from'] . "'";
456 + } else {
457 + $orders .= " and p.post_date >= '" . $conditions['specific_period']['from'] . "' and p.post_date <= '" . $conditions['specific_period']['to'] . " 23:00:00'";
458 + }
362 459 }
363 - foreach($get_post_ids as $ids){
364 - $module =$wpdb->get_var("SELECT post_type FROM {$wpdb->prefix}posts where id=$ids");
460 + if (empty($conditions['specific_status']['status']) && empty($conditions['specific_period']['is_check'])) {
461 + $orders .= " and wc.status in ('wc-completed', 'wc-cancelled', 'wc-on-hold', 'wc-processing', 'wc-pending') ORDER BY post_date";
365 462 }
366 - if($module == 'shop_order_placehold'){//post_status shop_order_placehold!
367 - $orders = "select DISTINCT p.ID from {$wpdb->prefix}posts as p inner join {$wpdb->prefix}wc_orders as wc ON p.ID=wc.id";
368 - $orders.= " where p.post_type = '$module'";
369 - if(!empty($conditions['specific_period']['is_check']) && $conditions['specific_period']['is_check'] == 'true') {
370 - $orders .= " and wc.status in ('wc-completed', 'wc-cancelled', 'wc-on-hold', 'wc-processing', 'wc-pending')";
371 - if($conditions['specific_period']['from'] == $conditions['specific_period']['to']){
372 - $orders .= " and DATE(p.post_date) ='".$conditions['specific_period']['from']."'";
373 - }else{
374 - $orders .= " and p.post_date >= '" . $conditions['specific_period']['from'] . "' and p.post_date <= '" . $conditions['specific_period']['to'] . " 23:00:00'";
375 - }
463 + } else {//post_status shop_order!
464 + $orders = "select DISTINCT ID from {$wpdb->prefix}posts";
465 + $orders .= $wpdb->prepare(" where post_type = %s", $module);
466 + if (!empty($conditions['specific_period']['is_check']) && $conditions['specific_period']['is_check'] == 'true') {
467 + $orders .= " and post_status in ('wc-completed', 'wc-cancelled', 'wc-on-hold', 'wc-processing', 'wc-pending')";
468 + if ($conditions['specific_period']['from'] == $conditions['specific_period']['to']) {
469 + $orders .= " and DATE(post_date) = '" . $conditions['specific_period']['from'] . "'";
470 + } else {
471 + $orders .= " and post_date >= '" . $conditions['specific_period']['from'] . "' and post_date <= '" . $conditions['specific_period']['to'] . " 23:00:00'";
376 472 }
377 - if(empty($conditions['specific_status']['status']) && empty($conditions['specific_period']['is_check'])) {
378 - $orders .= " and wc.status in ('wc-completed', 'wc-cancelled', 'wc-on-hold', 'wc-processing', 'wc-pending') ORDER BY post_date";
379 - }
473 + } else {
474 + $orders .= " and post_status in ('wc-completed', 'wc-cancelled', 'wc-on-hold', 'wc-processing', 'wc-pending')";
380 475 }
381 - else{//post_status shop_order!
382 - $orders = "select DISTINCT ID from {$wpdb->prefix}posts";
383 - $orders.= " where post_type = '$module'";
384 - if(!empty($conditions['specific_period']['is_check']) && $conditions['specific_period']['is_check'] == 'true') {
385 - $orders .= " and post_status in ('wc-completed', 'wc-cancelled', 'wc-on-hold', 'wc-processing', 'wc-pending')";
386 - if($conditions['specific_period']['from'] == $conditions['specific_period']['to']){
387 - $orders .= " and DATE(post_date) = '". $conditions['specific_period']['from'] . "'";
388 - }else{
389 - $orders .= " and post_date >= '" . $conditions['specific_period']['from'] . "' and post_date <= '" . $conditions['specific_period']['to'] . " 23:00:00'";
390 - }
391 - }
392 - else {
393 - $orders .= " and post_status in ('wc-completed', 'wc-cancelled', 'wc-on-hold', 'wc-processing', 'wc-pending')";
394 - }
395 - }
396 - $orders = $wpdb->get_col($orders);
397 - self::$export_instance->totalRowCount = count($orders);
398 - $get_order_ids = !empty($orders) ? array_slice($orders, $offset, $limit) : [];
399 - return $get_order_ids;
400 476 }
401 - }elseif ($module == 'shop_coupon') {
402 - if(isset($conditions['specific_status']) && !empty($conditions['specific_status']['status'])) {
403 - if($conditions['specific_status']['status'] == 'All') {
477 + $orders = $wpdb->get_col($orders);
478 + self::$export_instance->totalRowCount = count($orders);
479 + $get_order_ids = !empty($orders) ? array_slice($orders, $offset, $limit) : [];
480 + return $get_order_ids;
481 + }
482 + } elseif ($module == 'shop_coupon') {
483 + if (isset($conditions['specific_status']) && !empty($conditions['specific_status']['status'])) {
484 + if ($conditions['specific_status']['status'] == 'All') {
404 485 $get_post_ids .= " and post_status in ('publish','draft','pending')";
405 - } elseif($conditions['specific_status']['status']== 'Publish') {
486 + } elseif ($conditions['specific_status']['status'] == 'Publish') {
406 487 $get_post_ids .= " and post_status in ('publish')";
407 - } elseif($conditions['specific_status']['status'] == 'Draft') {
488 + } elseif ($conditions['specific_status']['status'] == 'Draft') {
408 489 $get_post_ids .= " and post_status in ('draft')";
409 - } elseif($conditions['specific_status']['status'] == 'Pending') {
490 + } elseif ($conditions['specific_status']['status'] == 'Pending') {
410 491 $get_post_ids .= " and post_status in ('pending')";
411 - }
492 + }
412 493 } else {
413 494 $get_post_ids .= " and post_status in ('publish','draft','pending')";
414 495 }
415 496
416 - }elseif ($module == 'shop_order_refund') {
497 + } elseif ($module == 'shop_order_refund') {
417 498
418 - }
419 - elseif( $module == 'lp_order'){
499 + } elseif ($module == 'lp_order') {
420 500 $get_post_ids .= " and post_status in ('lp-pending', 'lp-processing', 'lp-completed', 'lp-cancelled', 'lp-failed')";
421 - }
422 - elseif ($module == 'forum') {
501 + } elseif ($module == 'forum') {
423 502 $get_post_ids .= " and post_status in ('publish','draft','future','private','pending','hidden')";
424 - }
425 - elseif ($module == 'topic') {
503 + } elseif ($module == 'topic') {
426 504 $get_post_ids .= " and post_status in ('publish','draft','future','open','pending','closed','spam')";
427 - }
428 - elseif ($module == 'reply') {
505 + } elseif ($module == 'reply') {
429 506 $get_post_ids .= " and post_status in ('publish','spam','pending')";
430 - }
431 - else {
432 - if(!empty($conditions['specific_status']['status'])) {
433 - if($conditions['specific_status']['status'] == 'All') {
507 + } else {
508 + if (!empty($conditions['specific_status']['status'])) {
509 + if ($conditions['specific_status']['status'] == 'All') {
434 510 $get_post_ids .= " and post_status in ('publish','draft','future','private','pending')";
435 - } elseif($conditions['specific_status']['status'] == 'Publish' || $conditions['specific_status']['status'] == 'Sticky') {
511 + } elseif ($conditions['specific_status']['status'] == 'Publish' || $conditions['specific_status']['status'] == 'Sticky') {
436 512 $get_post_ids .= " and post_status in ('publish')";
437 - } elseif($conditions['specific_status']['status'] == 'Draft') {
513 + } elseif ($conditions['specific_status']['status'] == 'Draft') {
438 514 $get_post_ids .= " and post_status in ('draft')";
439 - } elseif($conditions['specific_status']['status'] == 'Scheduled') {
515 + } elseif ($conditions['specific_status']['status'] == 'Scheduled') {
440 516 $get_post_ids .= " and post_status in ('future')";
441 - } elseif($conditions['specific_status']['status'] == 'Private') {
517 + } elseif ($conditions['specific_status']['status'] == 'Private') {
442 518 $get_post_ids .= " and post_status in ('private')";
443 - } elseif($conditions['specific_status']['status'] == 'Pending') {
519 + } elseif ($conditions['specific_status']['status'] == 'Pending') {
444 520 $get_post_ids .= " and post_status in ('pending')";
445 - } elseif($conditions['specific_status']['status'] == 'Protected') {
521 + } elseif ($conditions['specific_status']['status'] == 'Protected') {
446 522 $get_post_ids .= " and post_status in ('publish') and post_password != ''";
447 523 }
448 524 } else {
449 525 $get_post_ids .= " and post_status in ('publish','draft','future','private','pending')";
@@ -449,26 +525,28 @@
449 525 $get_post_ids .= " and post_status in ('publish','draft','future','private','pending')";
450 526 }
451 527 }
452 528 // Check for specific period
453 - if(!empty($conditions['specific_period']['is_check']) && $conditions['specific_period']['is_check'] == 'true') {
454 - if($conditions['specific_period']['from'] == $conditions['specific_period']['to']){
529 + if (!empty($conditions['specific_period']['is_check']) && $conditions['specific_period']['is_check'] == 'true') {
530 + if ($conditions['specific_period']['from'] == $conditions['specific_period']['to']) {
455 531 $get_post_ids .= " and post_date >= '" . $conditions['specific_period']['from'] . "'";
456 - }else{
532 + } else {
457 533 $get_post_ids .= " and post_date >= '" . $conditions['specific_period']['from'] . "' and post_date <= '" . $conditions['specific_period']['to'] . " 23:00:00'";
458 534 }
459 535 }
460 - if($module == 'woocommerce')
536 + if ($module == 'woocommerce')
461 537 $get_post_ids .= " and pm.meta_key = '_sku'";
462 538
463 - if($module == 'wpcommerce')
539 + if ($module == 'wpcommerce')
464 540 $get_post_ids .= " and pm.meta_key = '_wpsc_sku'";
465 541
466 542 // Check for specific authors
467 543 if (!empty($conditions['specific_authors']['is_check'] == '1') && !empty($conditions['specific_authors']['author'])) {
468 544 if (isset($conditions['specific_authors']['author'])) {
469 - $author_ids = implode(',', $conditions['specific_authors']['author']);
470 - $get_post_ids .= " AND post_author IN ({$author_ids})";
545 + $author_ids = array_filter(array_map('absint', (array) $conditions['specific_authors']['author']));
546 + if (!empty($author_ids)) {
547 + $get_post_ids .= " AND post_author IN (" . implode(',', $author_ids) . ")";
548 + }
471 549
472 550 }
473 551 }
474 552
@@ -473,38 +551,36 @@
473 551 }
474 552
475 553
476 554 //WpeCommercecoupons
477 - if($module == 'wpsc-coupon'){
555 + if ($module == 'wpsc-coupon') {
478 556 $get_post_ids = "select DISTINCT ID from {$wpdb->prefix}wpsc_coupon_codes";
479 557 }
480 558 //WpeCommercecoupons
481 559 $get_total_row_count = $wpdb->get_col($get_post_ids);
482 - if(!empty($get_total_row_count )){
483 - if(!empty($conditions['specific_period']['is_check']) && $conditions['specific_period']['is_check'] == 'true') {
484 - if($conditions['specific_period']['from'] == $conditions['specific_period']['to']){
560 + if (!empty($get_total_row_count)) {
561 + if (!empty($conditions['specific_period']['is_check']) && $conditions['specific_period']['is_check'] == 'true') {
562 + if ($conditions['specific_period']['from'] == $conditions['specific_period']['to']) {
485 563 $result = array();
486 - foreach($get_total_row_count as $result_value){
564 + foreach ($get_total_row_count as $result_value) {
487 565 //$get_post_date_time = $wpdb->get_results( $wpdb->prepare("SELECT post_date FROM {$wpdb->prefix}posts WHERE id=$result_value") ,ARRAY_A);
488 - $get_post_date_time = $wpdb->get_results("SELECT post_date FROM {$wpdb->prefix}posts WHERE id = $result_value", ARRAY_A);
489 - $get_post_date = date("Y-m-d",strtotime($get_post_date_time[0]['post_date'] ));
490 - if($get_post_date == $conditions['specific_period']['from']){
566 + $get_post_date_time = $wpdb->get_results($wpdb->prepare("SELECT post_date FROM {$wpdb->prefix}posts WHERE id = %d", absint($result_value)), ARRAY_A);
567 + $get_post_date = date("Y-m-d", strtotime($get_post_date_time[0]['post_date']));
568 + if ($get_post_date == $conditions['specific_period']['from']) {
491 569 $get_post_date_value[] = $result_value;
492 - }
570 + }
493 571 }
494 572 self::$export_instance->totalRowCount = count($get_post_date_value);
495 573 $result = $get_post_date_value;
496 - }
497 - else{
574 + } else {
498 575 self::$export_instance->totalRowCount = count($get_total_row_count);
499 - $offset_limit = " order by ID asc limit $offset, $limit";
576 + $offset_limit = " order by ID asc limit {$offset}, {$limit}";
500 577 $query_with_offset_limit = $get_post_ids . $offset_limit;
501 578 $result = $wpdb->get_col($query_with_offset_limit);
502 579 }
503 - }
504 - else{
580 + } else {
505 581 self::$export_instance->totalRowCount = count($get_total_row_count);
506 - $offset_limit = " order by ID asc limit $offset, $limit";
582 + $offset_limit = " order by ID asc limit {$offset}, {$limit}";
507 583 $query_with_offset_limit = $get_post_ids . $offset_limit;
508 584 $result = $wpdb->get_col($query_with_offset_limit);
509 585 }
510 586 }
@@ -514,46 +590,50 @@
514 590 $approved = $conditions['specific_review_status']['approved'];
515 591 $reviews = $wpdb->get_results(
516 592 $wpdb->prepare(
517 593 "SELECT * FROM {$wpdb->prefix}jet_reviews WHERE approved = %d ORDER BY date DESC LIMIT %d OFFSET %d",
518 - $approved,
519 - $limit,
594 + $approved,
595 + $limit,
520 596 $offset
521 597 ),
522 598 ARRAY_A
523 599 );
524 -
600 +
525 601 // Collect review IDs
526 602 foreach ($reviews as $review) {
527 603 $result[] = $review['id']; // Assuming 'id' is the primary key for reviews
528 604 }
529 -
605 +
530 606 self::$export_instance->totalRowCount = !empty($result) ? count($result) : 0;
531 607 return !empty($result) ? array_slice($result, $offset, $limit) : [];
532 608 } else {
533 609 // Fetch all reviews if no specific conditions are set
534 610 $reviews = $wpdb->get_results(
535 - "SELECT * FROM {$wpdb->prefix}jet_reviews ORDER BY date DESC LIMIT {$limit} OFFSET {$offset}",
611 + $wpdb->prepare(
612 + "SELECT * FROM {$wpdb->prefix}jet_reviews ORDER BY date DESC LIMIT %d OFFSET %d",
613 + $limit,
614 + $offset
615 + ),
536 616 ARRAY_A
537 617 );
538 -
618 +
539 619 foreach ($reviews as $review) {
540 620 $result[] = $review['id'];
541 621 }
542 -
622 +
543 623 self::$export_instance->totalRowCount = !empty($result) ? count($result) : 0;
544 624 return !empty($result) ? array_slice($result, $offset, $limit) : [];
545 625 }
546 626 }
547 627
548 - if(is_plugin_active('jet-engine/jet-engine.php')){
628 + if (is_plugin_active('jet-engine/jet-engine.php')) {
549 629 $get_slug_name = $wpdb->get_results("SELECT slug FROM {$wpdb->prefix}jet_post_types WHERE status = 'content-type'");
550 - foreach($get_slug_name as $key=>$get_slug){
551 - $value=$get_slug->slug;
552 - $optional_type=$value;
553 - if($optionalType ==$optional_type){
554 - $table_name='jet_cct_'.$optional_type;
555 - $get_total_row_count= $wpdb->get_results("SELECT _ID FROM {$wpdb->prefix}$table_name ");
630 + foreach ($get_slug_name as $key => $get_slug) {
631 + $value = $get_slug->slug;
632 + $optional_type = $value;
633 + if ($optionalType == $optional_type) {
634 + $table_name = 'jet_cct_' . $optional_type;
635 + $get_total_row_count = $wpdb->get_results("SELECT _ID FROM {$wpdb->prefix}$table_name ");
556 636 self::$export_instance->totalRowCount = count($get_total_row_count);
557 637 }
558 638 }
559 639 }
@@ -558,13 +638,13 @@
558 638 }
559 639 }
560 640
561 641 // Get sticky post alone on the specific post status
562 - if(isset($conditions['specific_period']['is_check']) && isset($conditions['specific_status']['is_check']) && $conditions['specific_status']['is_check'] == 'true') {
563 - if(isset($conditions['specific_status']['status']) && $conditions['specific_status']['status'] == 'Sticky') {
642 + if (isset($conditions['specific_period']['is_check']) && isset($conditions['specific_status']['is_check']) && $conditions['specific_status']['is_check'] == 'true') {
643 + if (isset($conditions['specific_status']['status']) && $conditions['specific_status']['status'] == 'Sticky') {
564 644 $get_sticky_posts = get_option('sticky_posts');
565 - foreach($get_sticky_posts as $sticky_post_id) {
566 - if(in_array($sticky_post_id, $result))
645 + foreach ($get_sticky_posts as $sticky_post_id) {
646 + if (in_array($sticky_post_id, $result))
567 647 $sticky_posts[] = $sticky_post_id;
568 648 }
569 649 return $sticky_posts;
570 650 }
@@ -572,18 +652,18 @@
572 652 $result = isset($result) ? $result : [];
573 653 return $result;
574 654 }
575 655
576 - public function import_post_types($import_type, $importAs = null) {
656 + public function import_post_types($import_type, $importAs = null)
657 + {
577 658 $import_type = trim($import_type);
578 - $module = array('Posts' => 'post', 'Pages' => 'page', 'Users' => 'user', 'Comments' => 'comments', 'Taxonomies' => $importAs, 'CustomerReviews' =>'wpcr3_review', 'Categories' => 'categories', 'Tags' => 'tags', 'WooCommerce' => 'product', 'WPeCommerce' => 'wpsc-product','WPeCommerceCoupons' => 'wpsc-product','WooCommerceVariations' => 'product', 'WooCommerceOrders' => 'product', 'WooCommerceCoupons' => 'product', 'WooCommerceRefunds' => 'product', 'CustomPosts' => $importAs);
659 + $module = array('Posts' => 'post', 'Pages' => 'page', 'Users' => 'user', 'Comments' => 'comments', 'Taxonomies' => $importAs, 'CustomerReviews' => 'wpcr3_review', 'Categories' => 'categories', 'Tags' => 'tags', 'WooCommerce' => 'product', 'WPeCommerce' => 'wpsc-product', 'WPeCommerceCoupons' => 'wpsc-product', 'WooCommerceVariations' => 'product', 'WooCommerceOrders' => 'product', 'WooCommerceCoupons' => 'product', 'WooCommerceRefunds' => 'product', 'CustomPosts' => $importAs, 'EDD_DOWNLOADS' => 'download');
579 660 foreach (get_taxonomies() as $key => $taxonomy) {
580 661 $module[$taxonomy] = $taxonomy;
581 662 }
582 - if(array_key_exists($import_type, $module)) {
663 + if (array_key_exists($import_type, $module)) {
583 664 return $module[$import_type];
584 - }
585 - else {
665 + } else {
586 666 return $import_type;
587 667 }
588 668 }
589 669
@@ -591,12 +671,19 @@
591 671 * Function to export the meta information based on Fetch ACF field information to be export
592 672 * @param $id
593 673 * @return mixed
594 674 */
595 - public function getPostsMetaDataBasedOnRecordId ($id, $module, $optionalType) {
675 + public function getPostsMetaDataBasedOnRecordId($id, $module, $optionalType)
676 + {
596 677
597 678 global $wpdb;
598 - $typeOftypesField = NULL; $checkRep = NULL; $allacf= NULL; $alltype = NULL; $parent = NULL; $typesf= NULL;$jet_metafields=NULL;
679 + $typeOftypesField = NULL;
680 + $checkRep = NULL;
681 + $allacf = NULL;
682 + $alltype = NULL;
683 + $parent = NULL;
684 + $typesf = NULL;
685 + $jet_metafields = NULL;
599 686 if ($module == 'Users') {
600 687 $query = "SELECT user_id, meta_key, meta_value FROM {$wpdb->prefix}users wp JOIN {$wpdb->prefix}usermeta wpm ON wpm.user_id = wp.ID WHERE meta_key NOT IN ('_edit_lock', '_edit_last') AND ID={$id}";
601 688 } elseif ($module == 'Categories' || $module == 'Taxonomies' || $module == 'Tags') {
602 689 $query = "SELECT wp.term_id, meta_key, meta_value FROM {$wpdb->prefix}terms wp JOIN {$wpdb->prefix}termmeta wpm ON wpm.term_id = wp.term_id WHERE meta_key NOT IN ('_edit_lock', '_edit_last') AND wp.term_id = {$id}";
@@ -602,30 +689,30 @@
602 689 $query = "SELECT wp.term_id, meta_key, meta_value FROM {$wpdb->prefix}terms wp JOIN {$wpdb->prefix}termmeta wpm ON wpm.term_id = wp.term_id WHERE meta_key NOT IN ('_edit_lock', '_edit_last') AND wp.term_id = {$id}";
603 690 } else {
604 691 $query = "SELECT post_id, meta_key, meta_value FROM {$wpdb->prefix}posts wp JOIN {$wpdb->prefix}postmeta wpm ON wpm.post_id = wp.ID WHERE meta_key NOT IN ('_edit_lock', '_edit_last') AND ID={$id}";
605 692 }
606 -
607 693
694 +
608 695 $get_acf_fields = $wpdb->get_results("SELECT ID, post_excerpt, post_content, post_name, post_parent, post_type FROM {$wpdb->prefix}posts where post_type = 'acf-field'", ARRAY_A);
609 696
610 697 $group_unset = array('customer_email', 'product_categories', 'exclude_product_categories');
611 698
612 - if(!empty($get_acf_fields)){
699 + if (!empty($get_acf_fields)) {
613 700 foreach ($get_acf_fields as $key => $value) {
614 701
615 - if(!empty($value['post_parent'])){
702 + if (!empty($value['post_parent'])) {
616 703 $parent = get_post($value['post_parent']);
617 - if(!empty($parent)){
618 - if($parent->post_type == 'acf-field'){
619 - $allacf[$value['post_excerpt']] = $parent->post_excerpt.'_'.$value['post_excerpt'];
620 - }else{
621 - $allacf[$value['post_excerpt']] = $value['post_excerpt'];
704 + if (!empty($parent)) {
705 + if ($parent->post_type == 'acf-field') {
706 + $allacf[$value['post_excerpt']] = $parent->post_excerpt . '_' . $value['post_excerpt'];
707 + } else {
708 + $allacf[$value['post_excerpt']] = $value['post_excerpt'];
622 709 }
623 - }else{
624 - $allacf[$value['post_excerpt']] = $value['post_excerpt'];
710 + } else {
711 + $allacf[$value['post_excerpt']] = $value['post_excerpt'];
625 712 }
626 - }else{
627 - $allacf[$value['post_excerpt']] = $value['post_excerpt'];
713 + } else {
714 + $allacf[$value['post_excerpt']] = $value['post_excerpt'];
628 715 }
629 716
630 717 self::$export_instance->allacf = $allacf;
631 718
@@ -631,11 +718,11 @@
631 718
632 719 $content = unserialize($value['post_content']);
633 720 $alltype[$value['post_excerpt']] = $content['type'];
634 721
635 - if($content['type'] == 'repeater' || $content['type'] == 'flexible_content'){
722 + if ($content['type'] == 'repeater' || $content['type'] == 'flexible_content') {
636 723 $checkRep[$value['post_excerpt']] = $this->getRepeater($value['ID']);
637 - }else{
724 + } else {
638 725 $checkRep[$value['post_excerpt']] = "";
639 726 }
640 727 }
641 728 }
@@ -641,28 +728,26 @@
641 728 }
642 729
643 730 self::$export_instance->allpodsfields = $this->getAllPodsFields();
644 731
645 - if($module == 'Categories' || $module == 'Tags' || $module == 'Taxonomies'){
732 + if ($module == 'Categories' || $module == 'Tags' || $module == 'Taxonomies') {
646 733 self::$export_instance->alltoolsetfields = get_option('wpcf-termmeta');
647 - }
648 - elseif($module == 'Users'){
734 + } elseif ($module == 'Users') {
649 735 self::$export_instance->alltoolsetfields = get_option('wpcf-usermeta');
650 -
651 - }
652 - else{
736 +
737 + } else {
653 738 self::$export_instance->alltoolsetfields = get_option('wpcf-fields');
654 739 }
655 -
656 - if(!empty(self::$export_instance->alltoolsetfields)){
740 +
741 + if (!empty(self::$export_instance->alltoolsetfields)) {
657 742 $i = 1;
658 743 foreach (self::$export_instance->alltoolsetfields as $key => $value) {
659 - $typesf[$i] = 'wpcf-'.$key;
660 - $typeOftypesField[$typesf[$i]] = $value['type'];
744 + $typesf[$i] = 'wpcf-' . $key;
745 + $typeOftypesField[$typesf[$i]] = $value['type'];
661 746 $i++;
662 747 }
663 748 }
664 - $typeOftypesField=isset($typeOftypesField)?$typeOftypesField:'';
749 + $typeOftypesField = isset($typeOftypesField) ? $typeOftypesField : '';
665 750 self::$export_instance->typeOftypesField = $typeOftypesField;
666 751 self::$export_instance->alltoolsetfields = get_option('wpcf-fields');
667 752
668 753 self::$export_instance->typeOftypesField = $typeOftypesField;
@@ -669,10 +754,10 @@
669 754
670 755 $result = $wpdb->get_results($query);
671 756
672 757 if (is_plugin_active('jet-booking/jet-booking.php')) {
673 - $manage_units = jet_abaf()->db->get_apartment_units( $id );
674 - if(!empty($manage_units)) {
758 + $manage_units = jet_abaf()->db->get_apartment_units($id);
759 + if (!empty($manage_units)) {
675 760
676 761 $titleCounts = [];
677 762 foreach ($manage_units as $unit) {
678 763 // Remove any trailing space followed by numbers (e.g., " 1", " 2", " 3") at the end of unit_title
@@ -687,67 +772,63 @@
687 772 }
688 773 }
689 774
690 775 // jeteng fields
691 - if(is_plugin_active('jet-engine/jet-engine.php')){
776 + if (is_plugin_active('jet-engine/jet-engine.php')) {
692 777
693 - $jetEnginefields = $wpdb->get_results("SELECT id, meta_fields FROM {$wpdb->prefix}jet_post_types WHERE slug = '$optionalType' AND status IN ('publish','built-in')", ARRAY_A);
694 - $jetEnginefields[0]['meta_fields']=isset($jetEnginefields[0]['meta_fields'])?$jetEnginefields[0]['meta_fields']:'';
778 + $jetEnginefields = $wpdb->get_results($wpdb->prepare("SELECT id, meta_fields FROM {$wpdb->prefix}jet_post_types WHERE slug = %s AND status IN ('publish','built-in')", $optionalType), ARRAY_A);
779 + $jetEnginefields[0]['meta_fields'] = isset($jetEnginefields[0]['meta_fields']) ? $jetEnginefields[0]['meta_fields'] : '';
695 780
696 781 $unserializedMeta = maybe_unserialize($jetEnginefields[0]['meta_fields']);
697 - $unserializedMeta=isset($unserializedMeta)?$unserializedMeta:'';
782 + $unserializedMeta = isset($unserializedMeta) ? $unserializedMeta : '';
698 783
699 - if(is_array($unserializedMeta)){
700 - foreach($unserializedMeta as $jet_key => $jetValue){
784 + if (is_array($unserializedMeta)) {
785 + foreach ($unserializedMeta as $jet_key => $jetValue) {
701 786 $jetFieldLabel = $jetValue['title'];
702 787 $jetFieldType = $jetValue['type'];
703 - if($jetFieldType != 'repeater' && $jetFieldType != 'media' && $jetFieldType != 'gallery' && $jetFieldType != 'posts' && $jetFieldType != 'html' ){
788 + if ($jetFieldType != 'repeater' && $jetFieldType != 'media' && $jetFieldType != 'gallery' && $jetFieldType != 'posts' && $jetFieldType != 'html') {
704 789 $jetFieldNameArr[] = $jetValue['name'];
705 - }
706 - else{
790 + } else {
707 791 $jetFieldNameArr[] = $jetValue['name'];
708 - $fields=$jetValue['repeater-fields'];
709 - if(is_array($fields)){
710 - foreach($fields as $repFieldKey => $repFieldVal){
792 + $fields = $jetValue['repeater-fields'];
793 + if (is_array($fields)) {
794 + foreach ($fields as $repFieldKey => $repFieldVal) {
711 795 $jetFieldName[] = $repFieldVal['name'];
712 796
713 797 }
714 798 }
715 799 }
716 - }
800 + }
717 801 }
718 802
719 - if(isset($jetFieldName) && is_array($jetFieldName) ){
720 - if(is_array($jetFieldNameArr)){
721 - $jetCPTFieldsName=array_merge($jetFieldNameArr,$jetFieldName);
803 + if (isset($jetFieldName) && is_array($jetFieldName)) {
804 + if (is_array($jetFieldNameArr)) {
805 + $jetCPTFieldsName = array_merge($jetFieldNameArr, $jetFieldName);
806 + } else {
807 + $jetCPTFieldsName = $jetFieldName;
722 808 }
723 - else{
724 - $jetCPTFieldsName= $jetFieldName;
725 - }
726 809
727 - }
728 - else{
810 + } else {
729 811 $jetFieldNameArr = isset($jetFieldNameArr) ? $jetFieldNameArr : '';
730 - $jetCPTFieldsName= $jetFieldNameArr;
812 + $jetCPTFieldsName = $jetFieldNameArr;
731 813 }
732 814
733 815 //jeteng metabox fields
734 816
735 - global $wpdb;
817 + global $wpdb;
736 818 //$getMetaFields = $wpdb->get_results( $wpdb->prepare("SELECT option_value FROM {$wpdb->prefix}options WHERE option_name=%s",'jet_engine_meta_boxes'),ARRAY_A);
737 819 $getMetaFields = $wpdb->get_results("SELECT option_value FROM {$wpdb->prefix}options WHERE option_name='jet_engine_meta_boxes'", ARRAY_A);
738 - if(!empty($getMetaFields)){
820 + if (!empty($getMetaFields)) {
739 821 $unserializedMeta = maybe_unserialize($getMetaFields[0]['option_value']);
740 - }
741 - else{
822 + } else {
742 823 $unserializedMeta = '';
743 824 }
744 825
745 - if(is_array($unserializedMeta)){
826 + if (is_array($unserializedMeta)) {
746 827 $arraykeys = array_keys($unserializedMeta);
747 828
748 - foreach($arraykeys as $val){
749 - $values = explode('-',$val);
829 + foreach ($arraykeys as $val) {
830 + $values = explode('-', $val);
750 831 $v = $values[1];
751 832 }
752 833 }
753 834
@@ -752,21 +833,20 @@
752 833 }
753 834
754 835
755 836 $jetMetaFieldName = [];
756 - if(isset($v)){
757 - for($i=1 ; $i<=$v ; $i++){
758 - $unserializedMeta['meta-'.$i]= isset($unserializedMeta['meta-'.$i])? $unserializedMeta['meta-'.$i] : '';
759 - $fields= $unserializedMeta['meta-'.$i];
760 - if(!empty($fields)){
761 - foreach($fields['meta_fields'] as $jet_key => $jetValue){
762 - if($jetValue['type'] != 'repeater'){
837 + if (isset($v)) {
838 + for ($i = 1; $i <= $v; $i++) {
839 + $unserializedMeta['meta-' . $i] = isset($unserializedMeta['meta-' . $i]) ? $unserializedMeta['meta-' . $i] : '';
840 + $fields = $unserializedMeta['meta-' . $i];
841 + if (!empty($fields)) {
842 + foreach ($fields['meta_fields'] as $jet_key => $jetValue) {
843 + if ($jetValue['type'] != 'repeater') {
763 844 $jetMetaFieldName[] = $jetValue['name'];
764 - }
765 - else{
845 + } else {
766 846 $jetMetaFieldName[] = $jetValue['name'];
767 847 $jetRepFields = $jetValue['repeater-fields'];
768 - foreach($jetRepFields as $jetRepKey => $jetRepVal){
848 + foreach ($jetRepFields as $jetRepKey => $jetRepVal) {
769 849 $jetRepFieldName[] = $jetRepVal['name'];
770 850 }
771 851 }
772 852 }
@@ -772,28 +852,26 @@
772 852 }
773 853 }
774 854
775 855 }
776 - }
777 - if( isset($jetRepFieldName) && is_array($jetRepFieldName)){
778 - if(is_array($jetMetaFieldName)){
779 - $jetFName = array_merge($jetMetaFieldName,$jetRepFieldName);
856 + }
857 + if (isset($jetRepFieldName) && is_array($jetRepFieldName)) {
858 + if (is_array($jetMetaFieldName)) {
859 + $jetFName = array_merge($jetMetaFieldName, $jetRepFieldName);
860 + } else {
861 + $jetFName = $jetRepFieldName;
780 862 }
781 - else{
782 - $jetFName= $jetRepFieldName;
783 - }
863 + } else {
864 + $jetFName = $jetMetaFieldName;
784 865 }
785 - else{
786 - $jetFName= $jetMetaFieldName;
787 - }
788 866
789 867 /*jet releation export support added */
790 868 $get_rel_fields = $wpdb->get_results("SELECT id,labels, args, meta_fields FROM {$wpdb->prefix}jet_post_types WHERE status = 'relation' ", ARRAY_A);
791 - $get_cpt_fields = $wpdb->get_results("SELECT id,labels, args, meta_fields FROM {$wpdb->prefix}jet_post_types WHERE slug = '$optionalType' ", ARRAY_A);
792 - if(!empty($get_rel_fields)){
793 - foreach($get_rel_fields as $get_rel_values){
869 + $get_cpt_fields = $wpdb->get_results($wpdb->prepare("SELECT id,labels, args, meta_fields FROM {$wpdb->prefix}jet_post_types WHERE slug = %s ", $optionalType), ARRAY_A);
870 + if (!empty($get_rel_fields)) {
871 + foreach ($get_rel_fields as $get_rel_values) {
794 872 $imported_type = !empty($optionalType) ? $optionalType : $module;
795 -
873 +
796 874 $jet_relation_names = maybe_unserialize($get_rel_values['labels']);
797 875 $jet_relation_name = maybe_unserialize($jet_relation_names['name']);
798 876 $jet_relation_id = $get_rel_values['id'];
799 877
@@ -800,9 +878,9 @@
800 878 $get_rel_fields_args = maybe_unserialize($get_rel_values['args']);
801 879 $get_rel_parent_value = $get_rel_fields_args['parent_object'];
802 880 $get_rel_child_value = $get_rel_fields_args['child_object'];
803 881 $get_rel_db_table = $get_rel_fields_args['db_table'];
804 -
882 +
805 883 $get_rel_parent1 = explode('::', $get_rel_parent_value);
806 884 $get_rel_parent = $get_rel_parent1[1];
807 885 $get_rel_parent_type = $get_rel_parent1[0];
808 886
@@ -808,167 +886,152 @@
808 886
809 887 $get_rel_child1 = explode('::', $get_rel_child_value);
810 888 $get_rel_child = $get_rel_child1[1];
811 889 $get_rel_child_type = $get_rel_child1[0];
812 -
813 - if($imported_type == 'user'){
890 +
891 + if ($imported_type == 'user') {
814 892 $imported_type = 'users';
815 893 }
816 - if($imported_type == 'posts'){
894 + if ($imported_type == 'posts') {
817 895 $imported_type = 'post';
818 896 }
819 897
820 - if($get_rel_db_table == 1){
898 + if ($get_rel_db_table == 1) {
821 899 $jet_rel_table_name = $wpdb->prefix . 'jet_rel_' . $jet_relation_id;
822 900 $jet_relmeta_table_name = $wpdb->prefix . 'jet_rel_' . $jet_relation_id . '_meta';
823 - }
824 - else{
901 + } else {
825 902 $jet_rel_table_name = $wpdb->prefix . 'jet_rel_default';
826 903 $jet_relmeta_table_name = $wpdb->prefix . 'jet_rel_default_meta';
827 904 }
828 - if($imported_type == $get_rel_parent || $imported_type == $get_rel_child){
829 - $get_rel_metafields = maybe_unserialize($get_rel_values['meta_fields']);
905 + if ($imported_type == $get_rel_parent || $imported_type == $get_rel_child) {
906 + $get_rel_metafields = maybe_unserialize($get_rel_values['meta_fields']);
830 907
831 - if($imported_type == $get_rel_parent){
832 - $get_jet_rel_object_connections =array();
908 + if ($imported_type == $get_rel_parent) {
909 + $get_jet_rel_object_connections = array();
833 910 $get_jet_rel_connections = $wpdb->get_results("SELECT child_object_id FROM $jet_rel_table_name WHERE parent_object_id = $id and rel_id = $jet_relation_id", ARRAY_A);
834 911 $get_jet_rel_object_connections = array_column($get_jet_rel_connections, 'child_object_id');
835 -
836 - if(!empty($get_jet_rel_object_connections) && !empty($get_rel_metafields)){
912 +
913 + if (!empty($get_jet_rel_object_connections) && !empty($get_rel_metafields)) {
837 914 $this->get_jetengine_relation_meta_fields($jet_relation_id, $id, $get_rel_metafields, $get_jet_rel_object_connections, 'parent', $jet_relmeta_table_name);
838 915 }
839 - }
840 - elseif($imported_type == $get_rel_child){
841 - $get_jet_rel_object_connections =array();
916 + } elseif ($imported_type == $get_rel_child) {
917 + $get_jet_rel_object_connections = array();
842 918 $get_jet_rel_connections = $wpdb->get_results("SELECT parent_object_id FROM $jet_rel_table_name WHERE child_object_id = $id and rel_id = $jet_relation_id", ARRAY_A);
843 919 $get_jet_rel_object_connections = array_column($get_jet_rel_connections, 'parent_object_id');
844 -
845 - if(!empty($get_jet_rel_object_connections) && !empty($get_rel_metafields)){
920 +
921 + if (!empty($get_jet_rel_object_connections) && !empty($get_rel_metafields)) {
846 922 $this->get_jetengine_relation_meta_fields($jet_relation_id, $id, $get_rel_metafields, $get_jet_rel_object_connections, 'child', $jet_relmeta_table_name);
847 923 }
848 924 }
849 925 $get_rel_object_value = '';
850 - if(!empty($get_jet_rel_object_connections)){
851 - if($imported_type == $get_rel_parent){
852 -
853 -
854 - if($get_rel_child == 'users'){
855 - $users = $wpdb->prefix.'users';
926 + if (!empty($get_jet_rel_object_connections)) {
927 + if ($imported_type == $get_rel_parent) {
928 +
929 +
930 + if ($get_rel_child == 'users') {
931 + $users = $wpdb->prefix . 'users';
856 932 $get_jet_rel_object_connections = implode(",", $get_jet_rel_object_connections);
857 933 $get_jet_rel_connections = $wpdb->get_col("SELECT user_login FROM $users WHERE ID IN ($get_jet_rel_object_connections)");
858 - $get_rel_object_value = implode('|', $get_jet_rel_connections);
859 - }
860 - elseif($get_rel_parent_type== 'terms' && $get_rel_child_type == 'terms'){
934 + $get_rel_object_value = implode('|', $get_jet_rel_connections);
935 + } elseif ($get_rel_parent_type == 'terms' && $get_rel_child_type == 'terms') {
861 936 $stored_objects = [];
862 - foreach($get_jet_rel_object_connections as $my_jet_rel_objects){
863 - $stored_objects[] = $wpdb->get_col("SELECT wp_terms.name FROM {$wpdb->prefix}terms AS wp_terms INNER JOIN {$wpdb->prefix}jet_rel_default AS wp_jet_rel_default ON wp_terms.term_id = wp_jet_rel_default.child_object_id WHERE wp_jet_rel_default.child_object_id = $my_jet_rel_objects");
864 - }
865 - $stored_objects_results = [];
866 - foreach($stored_objects as $inner_array_values){
867 - $stored_objects_results[] = implode('|' , $inner_array_values);
868 - }
869 - $get_rel_object_value = implode('|', $stored_objects_results);
870 - }
871 - else{
937 + foreach ($get_jet_rel_object_connections as $my_jet_rel_objects) {
938 + $stored_objects[] = $wpdb->get_col("SELECT wp_terms.name FROM {$wpdb->prefix}terms AS wp_terms INNER JOIN {$wpdb->prefix}jet_rel_default AS wp_jet_rel_default ON wp_terms.term_id = wp_jet_rel_default.child_object_id WHERE wp_jet_rel_default.child_object_id = $my_jet_rel_objects");
939 + }
940 + $stored_objects_results = [];
941 + foreach ($stored_objects as $inner_array_values) {
942 + $stored_objects_results[] = implode('|', $inner_array_values);
943 + }
944 + $get_rel_object_value = implode('|', $stored_objects_results);
945 + } else {
872 946 $posts = $wpdb->prefix . 'posts';
873 947 $get_jet_rel_object_connections = implode(",", $get_jet_rel_object_connections);
874 948 $get_jet_rel_connections = $wpdb->get_col("SELECT post_title FROM $posts WHERE ID IN ($get_jet_rel_object_connections)");
875 - $get_rel_object_value = implode('|', $get_jet_rel_connections);
949 + $get_rel_object_value = implode('|', $get_jet_rel_connections);
876 950 }
877 - }
878 - else if($imported_type == $get_rel_child){
879 -
880 -
881 - if($get_rel_parent == 'users'){
882 - $users = $wpdb->prefix.'users';
951 + } else if ($imported_type == $get_rel_child) {
952 +
953 +
954 + if ($get_rel_parent == 'users') {
955 + $users = $wpdb->prefix . 'users';
883 956 $get_jet_rel_object_connections = implode(",", $get_jet_rel_object_connections);
884 957 $get_jet_rel_connections = $wpdb->get_col("SELECT user_login FROM $users WHERE ID IN ($get_jet_rel_object_connections)");
885 - $get_rel_object_value = implode('|', $get_jet_rel_connections);
886 - }
887 - elseif($get_rel_parent_type== 'terms' && $get_rel_child_type == 'terms'){
958 + $get_rel_object_value = implode('|', $get_jet_rel_connections);
959 + } elseif ($get_rel_parent_type == 'terms' && $get_rel_child_type == 'terms') {
888 960 $stored_objects = [];
889 - foreach($get_jet_rel_object_connections as $my_jet_rel_objects){
961 + foreach ($get_jet_rel_object_connections as $my_jet_rel_objects) {
890 962 $stored_objects[] = $wpdb->get_col("SELECT wp_terms.name FROM {$wpdb->prefix}terms AS wp_terms INNER JOIN {$wpdb->prefix}jet_rel_default AS wp_jet_rel_default ON wp_terms.term_id = wp_jet_rel_default.parent_object_id WHERE wp_jet_rel_default.parent_object_id = $my_jet_rel_objects");
891 963 }
892 - $stored_objects_results = [];
893 - foreach($stored_objects as $inner_array_values){
894 - $stored_objects_results[] = implode('|' , $inner_array_values);
964 + $stored_objects_results = [];
965 + foreach ($stored_objects as $inner_array_values) {
966 + $stored_objects_results[] = implode('|', $inner_array_values);
895 967 }
896 - $get_rel_object_value = implode('|', $stored_objects_results);
897 - }
898 - else{
968 + $get_rel_object_value = implode('|', $stored_objects_results);
969 + } else {
899 970 $posts = $wpdb->prefix . 'posts';
900 971 $get_jet_rel_object_connections = implode(",", $get_jet_rel_object_connections);
901 972 $get_jet_rel_connections = $wpdb->get_col("SELECT post_title FROM $posts WHERE ID IN ($get_jet_rel_object_connections)");
902 - $get_rel_object_value = implode('|', $get_jet_rel_connections);
973 + $get_rel_object_value = implode('|', $get_jet_rel_connections);
903 974 }
904 975 }
905 976 }
906 - self::$export_instance->data[$id][ 'jet_related_post :: ' . $jet_relation_id ] = $get_rel_object_value;
977 + self::$export_instance->data[$id]['jet_related_post :: ' . $jet_relation_id] = $get_rel_object_value;
907 978 }
908 979 }
909 - }
910 - else if(!empty($get_cpt_fields[0])){
980 + } else if (!empty($get_cpt_fields[0])) {
911 981 $get_cpt_fields_args = maybe_unserialize($get_cpt_fields[0]['args']);
912 982 $check_custom_table = $get_cpt_fields_args['custom_storage'];
913 - if($check_custom_table && isset($check_custom_table)){
983 + if ($check_custom_table && isset($check_custom_table)) {
914 984 $table_name = $wpdb->prefix . $optionalType . '_meta';
915 985 // Check if the table exists
916 986 if ($wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $table_name)) === $table_name) {
917 987 // Call the function if the table exists
918 - PostExport::$jet_custom_table_export->get_custom_table_meta_fields($module,$id, $table_name, $optionalType);
988 + PostExport::$jet_custom_table_export->get_custom_table_meta_fields($module, $id, $table_name, $optionalType);
919 989 }
920 990 }
921 991 }
922 992
993 + } else {
994 + $jetCPTFieldsName = $jetFName = $jet_tax_fields_name = '';
923 995 }
924 - else{
925 - $jetCPTFieldsName =$jetFName= $jet_tax_fields_name = '';
926 - }
927 996
928 997 //added for metabox plugin fields
929 - if(is_plugin_active('meta-box/meta-box.php')){
998 + if (is_plugin_active('meta-box/meta-box.php') || is_plugin_active('meta-box-aio/meta-box-aio.php')) {
930 999 $metabox_import_type = self::import_post_types($module, $optionalType);
931 - $metabox_fields = \rwmb_get_object_fields( $metabox_import_type );
1000 + $metabox_fields = \rwmb_get_object_fields($metabox_import_type);
932 1001
933 - $taxonomies = get_taxonomies();
934 -
935 - if ($metabox_import_type == 'user')
936 - {
937 - $metabox_fields = \rwmb_get_object_fields($metabox_import_type, 'user');
938 - }
939 - else if (array_key_exists($metabox_import_type, $taxonomies))
940 - {
941 - $metabox_fields = \rwmb_get_object_fields($metabox_import_type, 'term');
942 - }
943 - else
944 - {
945 - $metabox_fields = \rwmb_get_object_fields($metabox_import_type);
946 - }
947 - $this->getCustomFieldValue($id, $value=null, $checkRep, $allacf, $typeOftypesField, $alltype, $jet_fields=null, $jet_types=null, $jet_rep_fields =null, $jet_rep_types=null, $parent, $typesf, $group_unset , $optionalType , self::$export_instance->allpodsfields, $metabox_fields, $module, $metabox_relation_fields =null);
1002 + $taxonomies = get_taxonomies();
948 1003
949 - }
950 - else{
1004 + if ($metabox_import_type == 'user') {
1005 + $metabox_fields = \rwmb_get_object_fields($metabox_import_type, 'user');
1006 + } else if (array_key_exists($metabox_import_type, $taxonomies)) {
1007 + $metabox_fields = \rwmb_get_object_fields($metabox_import_type, 'term');
1008 + } else {
1009 + $metabox_fields = \rwmb_get_object_fields($metabox_import_type);
1010 + }
1011 + $this->getCustomFieldValue($id, $value = null, $checkRep, $allacf, $typeOftypesField, $alltype, $jet_fields = null, $jet_types = null, $jet_rep_fields = null, $jet_rep_types = null, $parent, $typesf, $group_unset, $optionalType, self::$export_instance->allpodsfields, $metabox_fields, $module, $metabox_relation_fields = null);
1012 +
1013 + } else {
951 1014 $metabox_fields = [];
952 1015 }
953 1016
954 - if(!empty($result)) {
1017 + if (!empty($result)) {
955 1018
956 - foreach($result as $key => $value) {
1019 + foreach ($result as $key => $value) {
957 1020
958 - if($value->meta_key == 'rank_math_schema_BlogPosting'){
959 - $rank_value=$value->meta_value;
960 - $rank_math=unserialize($rank_value) ;
961 - $headline=$rank_math['headline'];
962 - $schema_description=$rank_math['description'];
963 - $article_type=$rank_math['@type'];
964 - $re_id = $wpdb->get_results("SELECT redirection_id FROM {$wpdb->prefix}rank_math_redirections_cache where object_id='$id'");
965 - $redirect_id=$re_id[0];
966 - $redirection_id=$redirect_id->redirection_id;
967 - $result = $wpdb->get_results("SELECT url_to,header_code FROM {$wpdb->prefix}rank_math_redirections where id='$redirection_id'");
968 - $rank_math_redirections=$result[0];
969 - $url_to=$rank_math_redirections->url_to;
970 - $header_code=$rank_math_redirections->header_code;
1021 + if ($value->meta_key == 'rank_math_schema_BlogPosting') {
1022 + $rank_value = $value->meta_value;
1023 + $rank_math = unserialize($rank_value);
1024 + $headline = $rank_math['headline'];
1025 + $schema_description = $rank_math['description'];
1026 + $article_type = $rank_math['@type'];
1027 + $re_id = $wpdb->get_results($wpdb->prepare("SELECT redirection_id FROM {$wpdb->prefix}rank_math_redirections_cache where object_id=%d", absint($id)));
1028 + $redirect_id = $re_id[0];
1029 + $redirection_id = $redirect_id->redirection_id;
1030 + $result = $wpdb->get_results($wpdb->prepare("SELECT url_to,header_code FROM {$wpdb->prefix}rank_math_redirections where id=%d", absint($redirection_id)));
1031 + $rank_math_redirections = $result[0];
1032 + $url_to = $rank_math_redirections->url_to;
1033 + $header_code = $rank_math_redirections->header_code;
971 1034
972 1035 self::$export_instance->data[$id]['headline'] = $headline;
973 1036 self::$export_instance->data[$id]['schema_description'] = $schema_description;
974 1037 self::$export_instance->data[$id]['article_type'] = $article_type;
@@ -974,11 +1037,11 @@
974 1037 self::$export_instance->data[$id]['article_type'] = $article_type;
975 1038 self::$export_instance->data[$id]['destination_url'] = $url_to;
976 1039 self::$export_instance->data[$id]['redirection_type'] = $header_code;
977 1040 }
978 - if($value->meta_key == 'rank_math_schema_Dataset'){
979 -
980 - $schema_data = get_post_meta($id, 'rank_math_schema_Dataset',true);
1041 + if ($value->meta_key == 'rank_math_schema_Dataset') {
1042 +
1043 + $schema_data = get_post_meta($id, 'rank_math_schema_Dataset', true);
981 1044 self::$export_instance->data[$id]['ds_name'] = $schema_data['name'];
982 1045 self::$export_instance->data[$id]['ds_description'] = $schema_data['description'];
983 1046 self::$export_instance->data[$id]['ds_url'] = $schema_data['url'];
984 1047 self::$export_instance->data[$id]['ds_sameAs'] = $schema_data['sameAs'];
@@ -987,74 +1050,74 @@
987 1050 self::$export_instance->data[$id]['ds_spatial_coverage'] = $schema_data['spatialCoverage'];
988 1051 $distribution = $schema_data['distribution'];
989 1052 $identifier = $schema_data['identifier'];
990 1053 $keywords = $schema_data['keywords'];
991 - if(is_array($distribution)){
1054 + if (is_array($distribution)) {
992 1055 $encodeFormat = '';
993 1056 $contenUrl = '';
994 - foreach ($distribution as $disKey => $disVal) {
995 - $encodeFormat.= $disVal['encodingFormat'].',';
996 - $contentUrl.= $disVal['contentUrl'].',';
997 - self::$export_instance->data[$id]['encodingFormat'] = rtrim($encodeFormat,',');
998 - self::$export_instance->data[$id]['contentUrl'] = rtrim($contentUrl,',');
1057 + foreach ($distribution as $disKey => $disVal) {
1058 + $encodeFormat .= $disVal['encodingFormat'] . ',';
1059 + $contentUrl .= $disVal['contentUrl'] . ',';
1060 + self::$export_instance->data[$id]['encodingFormat'] = rtrim($encodeFormat, ',');
1061 + self::$export_instance->data[$id]['contentUrl'] = rtrim($contentUrl, ',');
999 1062 }
1000 -
1063 +
1001 1064 }
1002 1065
1003 - if(is_array($identifier)){
1066 + if (is_array($identifier)) {
1004 1067 $ident = '';
1005 - foreach ($identifier as $identKey => $identVal) {
1006 - $ident.= $identVal.',';
1007 -
1008 - self::$export_instance->data[$id]['ds_identifier'] = rtrim($ident,',');
1009 -
1068 + foreach ($identifier as $identKey => $identVal) {
1069 + $ident .= $identVal . ',';
1070 +
1071 + self::$export_instance->data[$id]['ds_identifier'] = rtrim($ident, ',');
1072 +
1010 1073 }
1011 1074 }
1012 1075
1013 - if(is_array($keywords)){
1076 + if (is_array($keywords)) {
1014 1077 $keyword = '';
1015 - foreach ($keywords as $kwKey => $keyVal) {
1016 - $keyword.= $keyVal.',';
1017 - self::$export_instance->data[$id]['ds_keywords'] = rtrim($keyword,',');
1078 + foreach ($keywords as $kwKey => $keyVal) {
1079 + $keyword .= $keyVal . ',';
1080 + self::$export_instance->data[$id]['ds_keywords'] = rtrim($keyword, ',');
1018 1081 }
1019 1082 }
1020 -
1021 - }
1022 - if($value->meta_key == 'rank_math_advanced_robots'){
1023 - $rank_robots_value=$value->meta_value;
1024 - $rank_robots=unserialize($rank_robots_value);
1025 - $max_snippet=$rank_robots['max-snippet'];
1026 - $max_video_preview=$rank_robots['max-video-preview'];
1027 - $max_image_preview=$rank_robots['max-image-preview'];
1028 - $rank_math_advanced_robots=$max_snippet.','.$max_video_preview.','.$max_image_preview;
1083 +
1084 + }
1085 + if ($value->meta_key == 'rank_math_advanced_robots') {
1086 + $rank_robots_value = $value->meta_value;
1087 + $rank_robots = unserialize($rank_robots_value);
1088 + $max_snippet = $rank_robots['max-snippet'];
1089 + $max_video_preview = $rank_robots['max-video-preview'];
1090 + $max_image_preview = $rank_robots['max-image-preview'];
1091 + $rank_math_advanced_robots = $max_snippet . ',' . $max_video_preview . ',' . $max_image_preview;
1029 1092 self::$export_instance->data[$id]['rank_math_advanced_robots'] = $rank_math_advanced_robots;
1030 1093 }
1031 - if(is_plugin_active('advanced-classifieds-and-directory-pro/acadp.php')) {
1032 - $listingFields = array('price','views','views','zipcode','phone','email','website','images','video','latitude','longitude','location');
1033 -
1034 -
1035 - if(isset($value->meta_key) && in_array($value->meta_key,$listingFields)){
1036 -
1037 - if(is_serialized($value->meta_value)){
1094 + if (is_plugin_active('advanced-classifieds-and-directory-pro/acadp.php')) {
1095 + $listingFields = array('price', 'views', 'views', 'zipcode', 'phone', 'email', 'website', 'images', 'video', 'latitude', 'longitude', 'location');
1096 +
1097 +
1098 + if (isset($value->meta_key) && in_array($value->meta_key, $listingFields)) {
1099 +
1100 + if (is_serialized($value->meta_value)) {
1038 1101 $value->meta_value = unserialize($value->meta_value);
1039 1102 }
1040 -
1041 - self::$export_instance->data[$id][ $value->meta_key ] = $value->meta_value ;
1042 -
1103 +
1104 + self::$export_instance->data[$id][$value->meta_key] = $value->meta_value;
1105 +
1043 1106 }
1044 -
1045 -
1046 - }
1047 - if((isset($value->meta_key) && is_array($jetFName))){
1048 - if(in_array($value->meta_key,$jetFName)){
1049 - $getMetaFields = $wpdb->get_results( $wpdb->prepare("SELECT option_value FROM {$wpdb->prefix}options WHERE option_name=%s",'jet_engine_meta_boxes'),ARRAY_A);
1107 +
1108 +
1109 + }
1110 + if ((isset($value->meta_key) && is_array($jetFName))) {
1111 + if (in_array($value->meta_key, $jetFName)) {
1112 + $getMetaFields = $wpdb->get_results($wpdb->prepare("SELECT option_value FROM {$wpdb->prefix}options WHERE option_name=%s", 'jet_engine_meta_boxes'), ARRAY_A);
1050 1113 $getMetaFields[0]['option_value'] = isset($getMetaFields[0]) ? $getMetaFields[0]['option_value'] : '';
1051 1114 $unserializedMeta = maybe_unserialize($getMetaFields[0]['option_value']);
1052 - if(is_array($unserializedMeta)){
1115 + if (is_array($unserializedMeta)) {
1053 1116 $arraykeys = array_keys($unserializedMeta);
1054 1117
1055 - foreach($arraykeys as $val){
1056 - $values = explode('-',$val);
1118 + foreach ($arraykeys as $val) {
1119 + $values = explode('-', $val);
1057 1120 $v = $values[1];
1058 1121 }
1059 1122 }
1060 1123
@@ -1059,84 +1122,80 @@
1059 1122 }
1060 1123
1061 1124
1062 1125
1063 - for($i=1 ; $i<=$v ; $i++){
1064 - $unserializedMeta['meta-'.$i] = isset($unserializedMeta['meta-'.$i])? $unserializedMeta['meta-'.$i] :'';
1065 - $fields = $unserializedMeta['meta-'.$i];
1066 - if(!empty($fields)){
1067 - $jet_metatypes=array();
1068 - $jet_reptype=array();
1069 - foreach($fields['meta_fields'] as $jet_key => $jetValue){
1126 + for ($i = 1; $i <= $v; $i++) {
1127 + $unserializedMeta['meta-' . $i] = isset($unserializedMeta['meta-' . $i]) ? $unserializedMeta['meta-' . $i] : '';
1128 + $fields = $unserializedMeta['meta-' . $i];
1129 + if (!empty($fields)) {
1130 + $jet_metatypes = array();
1131 + $jet_reptype = array();
1132 + foreach ($fields['meta_fields'] as $jet_key => $jetValue) {
1070 1133 $jetFieldLabel = $jetValue['title'];
1071 1134 $jetFNames = $jetValue['name'];
1072 1135 $jetFieldType = $jetValue['type'];
1073 - if($jetFieldType != 'repeater'){
1136 + if ($jetFieldType != 'repeater') {
1074 1137
1075 - $jet_metafields[$jetFNames]=$jetFNames;
1138 + $jet_metafields[$jetFNames] = $jetFNames;
1076 1139
1077 1140 $jet_metatypes[$jetFNames] = $jetFieldType;
1078 1141
1079 - }
1080 - else{
1081 - $jet_metafields[$jetFNames]=$jetFNames;
1142 + } else {
1143 + $jet_metafields[$jetFNames] = $jetFNames;
1082 1144 $jet_metatypes[$jetFNames] = $jetFieldType;
1083 - $repfields=$jetValue['repeater-fields'];
1084 - $jet_repfield=array();
1085 - foreach($repfields as $repFieldKey => $repFieldVal){
1145 + $repfields = $jetValue['repeater-fields'];
1146 + $jet_repfield = array();
1147 + foreach ($repfields as $repFieldKey => $repFieldVal) {
1086 1148 $jetRepFields_label = $repFieldVal['name'];
1087 - $jetRepFields_type = $repFieldVal['type'];
1149 + $jetRepFields_type = $repFieldVal['type'];
1088 1150
1089 1151 $jet_repfield[$jetRepFields_label] = $jetRepFields_label;
1090 - $jet_reptype[$jetRepFields_label] = $jetRepFields_type;
1152 + $jet_reptype[$jetRepFields_label] = $jetRepFields_type;
1091 1153 }
1092 - }
1154 + }
1093 1155 }
1094 1156 }
1095 1157
1096 1158 self::$export_instance->jet_metafields = $jet_metafields;
1097 1159 self::$export_instance->jet_metatypes = $jet_metatypes;
1098 - if(!empty($jet_repfield)){
1160 + if (!empty($jet_repfield)) {
1099 1161 self::$export_instance->jet_repfield = $jet_repfield;
1100 - self::$export_instance->jet_reptype = $jet_reptype;
1101 - }
1102 - else{
1162 + self::$export_instance->jet_reptype = $jet_reptype;
1163 + } else {
1103 1164 $jet_repfield = '';
1104 1165 $jet_reptype = '';
1105 1166 }
1106 - $this->getCustomFieldValue($id, $value, $checkRep, $allacf, $typeOftypesField, $alltype, $jet_metafields, $jet_metatypes, $jet_repfield, $jet_reptype,$parent, $typesf, $group_unset , $optionalType , self::$export_instance->allpodsfields, $metabox_fields, $module);
1107 - }
1167 + $this->getCustomFieldValue($id, $value, $checkRep, $allacf, $typeOftypesField, $alltype, $jet_metafields, $jet_metatypes, $jet_repfield, $jet_reptype, $parent, $typesf, $group_unset, $optionalType, self::$export_instance->allpodsfields, $metabox_fields, $module);
1168 + }
1108 1169 }
1109 1170 }
1110 - if(is_array($jetCPTFieldsName)&& isset($value->meta_key)){
1111 - if(in_array($value->meta_key,$jetCPTFieldsName)){
1112 - $jetEnginefields = $wpdb->get_results("SELECT id, meta_fields FROM {$wpdb->prefix}jet_post_types WHERE slug = '$optionalType' AND status IN ('publish','built-in')", ARRAY_A);
1171 + if (is_array($jetCPTFieldsName) && isset($value->meta_key)) {
1172 + if (in_array($value->meta_key, $jetCPTFieldsName)) {
1173 + $jetEnginefields = $wpdb->get_results($wpdb->prepare("SELECT id, meta_fields FROM {$wpdb->prefix}jet_post_types WHERE slug = %s AND status IN ('publish','built-in')", $optionalType), ARRAY_A);
1113 1174
1114 - if(!empty($jetEnginefields)){
1175 + if (!empty($jetEnginefields)) {
1115 1176 $unserializedMeta = maybe_unserialize($jetEnginefields[0]['meta_fields']);
1116 - }
1117 - else{
1177 + } else {
1118 1178 $unserializedMeta = '';
1119 1179 }
1120 - $jetTypes=array();
1121 - $jet_rep_cpttypes=array();
1122 - foreach($unserializedMeta as $jet_key => $jetValue){
1180 + $jetTypes = array();
1181 + $jet_rep_cpttypes = array();
1182 + foreach ($unserializedMeta as $jet_key => $jetValue) {
1123 1183 $jetFieldLabel = $jetValue['title'];
1124 1184 $jet_cptfield_names = $jetValue['name'];
1125 1185 $jetFieldType = $jetValue['type'];
1126 - if($jetFieldType != 'repeater'){
1127 - $jet_cptfields[$jet_cptfield_names]=$jet_cptfield_names;
1186 + if ($jetFieldType != 'repeater') {
1187 + $jet_cptfields[$jet_cptfield_names] = $jet_cptfield_names;
1128 1188 $jetTypes[$jet_cptfield_names] = $jetFieldType;
1129 - }
1130 - else{
1131 - $jet_cptfields[$jet_cptfield_names]=$jet_cptfield_names;
1189 + } else {
1190 + $jet_cptfields[$jet_cptfield_names] = $jet_cptfield_names;
1132 1191 $jetTypes[$jet_cptfield_names] = $jetFieldType;
1133 - $fields=$jetValue['repeater-fields'];
1134 - foreach($fields as $repFieldKey => $repFieldVal){
1192 + $fields = $jetValue['repeater-fields'];
1193 + foreach ($fields as $repFieldKey => $repFieldVal) {
1135 1194 $jet_rep_cptfields_label = $repFieldVal['name'];
1136 - $jet_rep_cptfields_type = $repFieldVal['type'];
1195 + $jet_rep_cptfields_type = $repFieldVal['type'];
1137 1196 $jet_rep_cptfields[$jet_rep_cptfields_label] = $jet_rep_cptfields_label;
1138 - $jet_rep_cpttypes[$jet_rep_cptfields_label] = $jet_rep_cptfields_type;
1197 + $jet_rep_cpttypes[$jet_rep_cptfields_label] = $jet_rep_cptfields_type;
1139 1198 }
1140 1199 }
1141 1200
1142 1201 }
@@ -1141,97 +1200,95 @@
1141 1200
1142 1201 }
1143 1202 self::$export_instance->jet_cptfields = $jet_cptfields;
1144 1203 self::$export_instance->jet_types = $jetTypes;
1145 - if(isset($jet_rep_cptfields)){
1204 + if (isset($jet_rep_cptfields)) {
1146 1205 self::$export_instance->jet_rep_cptfields = $jet_rep_cptfields;
1147 - self::$export_instance->jet_rep_cpttypes = $jet_rep_cpttypes;
1148 - }
1149 - else{
1206 + self::$export_instance->jet_rep_cpttypes = $jet_rep_cpttypes;
1207 + } else {
1150 1208 $jet_rep_cptfields = '';
1151 1209 $jet_rep_cpttypes = '';
1152 1210 }
1153 - $this->getCustomFieldValue($id, $value, $checkRep, $allacf, $typeOftypesField, $alltype, $jet_cptfields, $jetTypes, $jet_rep_cptfields, $jet_rep_cpttypes, $parent, $typesf, $group_unset , $optionalType , self::$export_instance->allpodsfields, $metabox_fields, $module);
1211 + $this->getCustomFieldValue($id, $value, $checkRep, $allacf, $typeOftypesField, $alltype, $jet_cptfields, $jetTypes, $jet_rep_cptfields, $jet_rep_cpttypes, $parent, $typesf, $group_unset, $optionalType, self::$export_instance->allpodsfields, $metabox_fields, $module);
1154 1212 }
1155 - }
1156 - else{
1213 + } else {
1157 1214 $jet_fields = $jetFieldType = $jetRepFields = $jet_rep_types = '';
1158 - $typesf=isset($typesf)?$typesf:'';
1159 - $jetTypes=isset($jetTypes)?$jetTypes:'';
1160 - $this->getCustomFieldValue($id, $value, $checkRep, $allacf, $typeOftypesField, $alltype, $jet_fields , $jetTypes, $jetRepFields, $jet_rep_types, $parent, $typesf, $group_unset , $optionalType , self::$export_instance->allpodsfields ,$metabox_fields, $module);
1215 + $typesf = isset($typesf) ? $typesf : '';
1216 + $jetTypes = isset($jetTypes) ? $jetTypes : '';
1217 + $this->getCustomFieldValue($id, $value, $checkRep, $allacf, $typeOftypesField, $alltype, $jet_fields, $jetTypes, $jetRepFields, $jet_rep_types, $parent, $typesf, $group_unset, $optionalType, self::$export_instance->allpodsfields, $metabox_fields, $module);
1161 1218 }
1162 1219 }
1163 1220 }
1164 1221
1165 - if(is_plugin_active('wordpress-seo/wp-seo.php') || is_plugin_active('wordpress-seo-premium/wp-seo-premium.php')){
1222 + if (is_plugin_active('wordpress-seo/wp-seo.php') || is_plugin_active('wordpress-seo-premium/wp-seo-premium.php')) {
1166 1223 self::$export_instance->data[$id]['title'] = self::$export_instance->data[$id]['post_title'];
1167 - if($value->meta_key == '_yoast_wpseo_focuskw'){
1224 + if ($value->meta_key == '_yoast_wpseo_focuskw') {
1168 1225 self::$export_instance->data[$id]['focus_keyword'] = $value->meta_value;
1169 1226 }
1170 - if($value->meta_key == '_yoast_wpseo_linkdex'){
1227 + if ($value->meta_key == '_yoast_wpseo_linkdex') {
1171 1228 self::$export_instance->data[$id]['linkdex'] = $value->meta_value;
1172 1229 }
1173 - if($value->meta_key == '_yoast_wpseo_meta-robots-noindex'){
1230 + if ($value->meta_key == '_yoast_wpseo_meta-robots-noindex') {
1174 1231 self::$export_instance->data[$id]['meta-robots-noindex'] = $value->meta_value;
1175 1232 }
1176 - if($value->meta_key == '_yoast_wpseo_metadesc'){
1233 + if ($value->meta_key == '_yoast_wpseo_metadesc') {
1177 1234 self::$export_instance->data[$id]['meta_desc'] = $value->meta_value;
1178 1235 }
1179 - if($value->meta_key == '_yoast_wpseo_opengraph-description'){
1236 + if ($value->meta_key == '_yoast_wpseo_opengraph-description') {
1180 1237 self::$export_instance->data[$id]['opengraph-description'] = $value->meta_value;
1181 1238 }
1182 - if($value->meta_key == '_yoast_wpseo_opengraph-title'){
1239 + if ($value->meta_key == '_yoast_wpseo_opengraph-title') {
1183 1240 self::$export_instance->data[$id]['opengraph-title'] = $value->meta_value;
1184 1241 }
1185 - if($value->meta_key == '_yoast_wpseo_twitter-title'){
1242 + if ($value->meta_key == '_yoast_wpseo_twitter-title') {
1186 1243 self::$export_instance->data[$id]['twitter-title'] = $value->meta_value;
1187 1244 }
1188 - if($value->meta_key == '_yoast_wpseo_google-plus-title'){
1245 + if ($value->meta_key == '_yoast_wpseo_google-plus-title') {
1189 1246 self::$export_instance->data[$id]['google-plus-title'] = $value->meta_value;
1190 1247 }
1191 - if($value->meta_key == '_yoast_wpseo_google-plus-description'){
1248 + if ($value->meta_key == '_yoast_wpseo_google-plus-description') {
1192 1249 self::$export_instance->data[$id]['google-plus-description'] = $value->meta_value;
1193 1250 }
1194 - if($value->meta_key == '_yoast_wpseo_google-plus-image'){
1251 + if ($value->meta_key == '_yoast_wpseo_google-plus-image') {
1195 1252 self::$export_instance->data[$id]['google-plus-image'] = $value->meta_value;
1196 1253 }
1197 - if($value->meta_key == '_yoast_wpseo_twitter-description'){
1254 + if ($value->meta_key == '_yoast_wpseo_twitter-description') {
1198 1255 self::$export_instance->data[$id]['twitter-description'] = $value->meta_value;
1199 1256 }
1200 - if($value->meta_key == '_yoast_wpseo_twitter-image'){
1257 + if ($value->meta_key == '_yoast_wpseo_twitter-image') {
1201 1258 self::$export_instance->data[$id]['twitter-image'] = $value->meta_value;
1202 1259 }
1203 - if($value->meta_key == '_yoast_wpseo_bctitle'){
1260 + if ($value->meta_key == '_yoast_wpseo_bctitle') {
1204 1261 self::$export_instance->data[$id]['bctitle'] = $value->meta_value;
1205 1262 }
1206 - if($value->meta_key == '_yoast_wpseo_canonical'){
1263 + if ($value->meta_key == '_yoast_wpseo_canonical') {
1207 1264 self::$export_instance->data[$id]['canonical'] = $value->meta_value;
1208 1265 }
1209 - if($value->meta_key == '_yoast_wpseo_redirect'){
1266 + if ($value->meta_key == '_yoast_wpseo_redirect') {
1210 1267 self::$export_instance->data[$id]['redirect'] = $value->meta_value;
1211 1268 }
1212 - if($value->meta_key == '_yoast_wpseo_opengraph-image'){
1269 + if ($value->meta_key == '_yoast_wpseo_opengraph-image') {
1213 1270 self::$export_instance->data[$id]['opengraph-image'] = $value->meta_value;
1214 1271 }
1215 - if($value->meta_key == '_yoast_wpseo_meta-robots-nofollow'){
1272 + if ($value->meta_key == '_yoast_wpseo_meta-robots-nofollow') {
1216 1273 self::$export_instance->data[$id]['meta-robots-nofollow'] = $value->meta_value;
1217 1274 }
1218 - if($value->meta_key == '_yoast_wpseo_meta-robots-adv'){
1275 + if ($value->meta_key == '_yoast_wpseo_meta-robots-adv') {
1219 1276 self::$export_instance->data[$id]['meta-robots-adv'] = $value->meta_value;
1220 1277 }
1221 - if($value->meta_key == '_yoast_wpseo_cornerstone-content'){
1278 + if ($value->meta_key == '_yoast_wpseo_cornerstone-content') {
1222 1279 self::$export_instance->data[$id]['cornerstone-content'] = $value->meta_value;
1223 1280 }
1224 - if($value->meta_key == '_yoast_wpseo_focuskeywords'){
1281 + if ($value->meta_key == '_yoast_wpseo_focuskeywords') {
1225 1282 self::$export_instance->data[$id]['focuskeywords'] = $value->meta_value;
1226 - }
1227 - if($value->meta_key == '_yoast_wpseo_keywordsynonyms'){
1283 + }
1284 + if ($value->meta_key == '_yoast_wpseo_keywordsynonyms') {
1228 1285 self::$export_instance->data[$id]['keywordsynonyms'] = $value->meta_value;
1229 1286 }
1230 - if($value->meta_key == '_yoast_wpseo_schema_page_type'){
1287 + if ($value->meta_key == '_yoast_wpseo_schema_page_type') {
1231 1288 self::$export_instance->data[$id]['schema_page_type'] = $value->meta_value;
1232 1289 }
1233 - if($value->meta_key == '_yoast_wpseo_schema_article_type'){
1290 + if ($value->meta_key == '_yoast_wpseo_schema_article_type') {
1234 1291 self::$export_instance->data[$id]['schema_article_type'] = $value->meta_value;
1235 1292 }
1236 1293 }
1237 1294
@@ -1236,49 +1293,49 @@
1236 1293 }
1237 1294
1238 1295 return self::$export_instance->data;
1239 1296 }
1240 - public function get_jetengine_relation_meta_fields($jet_relation_id, $posted_id, $get_rel_metafields, $get_jet_rel_object_connections, $connection_type, $jet_relmeta_table_name){
1241 - global $wpdb;
1242 - foreach($get_rel_metafields as $get_rel_metavalue){
1297 + public function get_jetengine_relation_meta_fields($jet_relation_id, $posted_id, $get_rel_metafields, $get_jet_rel_object_connections, $connection_type, $jet_relmeta_table_name)
1298 + {
1299 + global $wpdb;
1300 + foreach ($get_rel_metafields as $get_rel_metavalue) {
1243 1301 $rel_meta_key = $get_rel_metavalue['name'];
1244 1302
1245 1303 $get_jet_rel_values = [];
1246 - foreach($get_jet_rel_object_connections as $get_jet_rel_object_connection_values){
1247 - if($connection_type == 'parent'){
1304 + foreach ($get_jet_rel_object_connections as $get_jet_rel_object_connection_values) {
1305 + if ($connection_type == 'parent') {
1248 1306 $get_jet_rel_value = $wpdb->get_var("SELECT meta_value FROM $jet_relmeta_table_name WHERE rel_id = $jet_relation_id AND meta_key = '$rel_meta_key' AND parent_object_id = $posted_id AND child_object_id = $get_jet_rel_object_connection_values ");
1249 - if(is_serialized($get_jet_rel_value)){
1307 + if (is_serialized($get_jet_rel_value)) {
1250 1308 $unser_relvalue = unserialize($get_jet_rel_value);
1251 1309 //Added for export only media id,while media have return format as both[if]
1252 - if($rel_meta_key == 'media'){
1253 - if(!empty($unser_relvalue) && array_key_exists('id',$unser_relvalue))
1254 - $get_jet_rel_value = $unser_relvalue['id'];
1255 - }
1256 - else
1257 - $get_jet_rel_value = implode(',', $unser_relvalue);
1310 + if ($rel_meta_key == 'media') {
1311 + if (!empty($unser_relvalue) && array_key_exists('id', $unser_relvalue))
1312 + $get_jet_rel_value = $unser_relvalue['id'];
1313 + } else
1314 + $get_jet_rel_value = implode(',', $unser_relvalue);
1258 1315 }
1259 1316 $get_jet_rel_values[] = $get_jet_rel_value;
1260 - }
1261 - else{
1317 + } else {
1262 1318 $get_jet_rel_values[] = $wpdb->get_var("SELECT meta_value FROM $jet_relmeta_table_name WHERE rel_id = $jet_relation_id AND meta_key = '$rel_meta_key' AND parent_object_id = $get_jet_rel_object_connection_values AND child_object_id = $posted_id ");
1263 1319 }
1264 - }
1320 + }
1265 1321 $get_rel_meta_value = '';
1266 - if(!empty($get_jet_rel_values)){
1322 + if (!empty($get_jet_rel_values)) {
1267 1323 $get_rel_meta_value = implode('|', $get_jet_rel_values);
1268 1324 }
1269 - self::$export_instance->data[$posted_id][ $rel_meta_key . ' :: ' . $jet_relation_id ] = $get_rel_meta_value;
1270 -
1325 + self::$export_instance->data[$posted_id][$rel_meta_key . ' :: ' . $jet_relation_id] = $get_rel_meta_value;
1326 +
1271 1327 }
1272 1328 }
1273 1329
1274 - public function getAllPodsFields(){
1330 + public function getAllPodsFields()
1331 + {
1275 1332
1276 1333 $pods_fields = [];
1277 - if(in_array('pods/init.php', self::$export_instance->get_active_plugins())) {
1334 + if (in_array('pods/init.php', self::$export_instance->get_active_plugins())) {
1278 1335 global $wpdb;
1279 - $pods_fields_query_result = $wpdb->get_results("SELECT post_name FROM ".$wpdb->prefix."posts WHERE post_type = '_pods_field'");
1280 - foreach($pods_fields_query_result as $single_result){
1336 + $pods_fields_query_result = $wpdb->get_results("SELECT post_name FROM " . $wpdb->prefix . "posts WHERE post_type = '_pods_field'");
1337 + foreach ($pods_fields_query_result as $single_result) {
1281 1338 $pods_fields[] = $single_result->post_name;
1282 1339 }
1283 1340 }
1284 1341 return $pods_fields;
@@ -1283,9 +1340,10 @@
1283 1340 }
1284 1341 return $pods_fields;
1285 1342 }
1286 1343
1287 - public function getCustomFieldValue($id, $value, $checkRep, $allacf, $typeOftypesField, $alltype, $jet_fields, $jetTypes, $jetRepFields, $jet_rep_types, $parent, $typesf, $group_unset , $optionalType , $pods_type, $metabox_fields, $module){
1344 + public function getCustomFieldValue($id, $value, $checkRep, $allacf, $typeOftypesField, $alltype, $jet_fields, $jetTypes, $jetRepFields, $jet_rep_types, $parent, $typesf, $group_unset, $optionalType, $pods_type, $metabox_fields, $module)
1345 + {
1288 1346 global $wpdb;
1289 1347 $taxonomies = get_taxonomies();
1290 1348 $down_file = false;
1291 1349
@@ -1296,9 +1354,9 @@
1296 1354 $attachment_file = $wpdb->get_var($get_attachment);
1297 1355 self::$export_instance->data[$id][$value->meta_key] = '';
1298 1356 $value->meta_key = 'featured_image';
1299 1357 self::$export_instance->data[$id][$value->meta_key] = $attachment_file;
1300 - if(isset($attachment_file)){
1358 + if (isset($attachment_file)) {
1301 1359 $attachment = get_post($thumbnail_id);
1302 1360 $image_meta = wp_get_attachment_metadata($thumbnail_id);
1303 1361 $title = get_the_title($thumbnail_id);
1304 1362 $alt_text = get_post_meta($thumbnail_id, '_wp_attachment_image_alt', true);
@@ -1305,87 +1363,78 @@
1305 1363 $description = $attachment->post_content;
1306 1364 $caption = $attachment->post_excerpt;
1307 1365 $file_name = isset($image_meta['file']) ? basename($image_meta['file']) : '';
1308 1366
1309 - self::$export_instance->data[$id]['featured_image_title'] = isset($title)? $title : '' ;
1310 - self::$export_instance->data[$id]['featured_image_alt_text'] = isset($alt_text)? $alt_text : '' ;
1311 - self::$export_instance->data[$id]['featured_image_caption'] = isset($caption)? $caption : '' ;
1312 - self::$export_instance->data[$id]['featured_image_description'] = isset($description)? $description : '' ;
1313 - self::$export_instance->data[$id]['featured_file_name'] = isset($file_name)? $file_name : '' ;
1367 + self::$export_instance->data[$id]['featured_image_title'] = isset($title) ? $title : '';
1368 + self::$export_instance->data[$id]['featured_image_alt_text'] = isset($alt_text) ? $alt_text : '';
1369 + self::$export_instance->data[$id]['featured_image_caption'] = isset($caption) ? $caption : '';
1370 + self::$export_instance->data[$id]['featured_image_description'] = isset($description) ? $description : '';
1371 + self::$export_instance->data[$id]['featured_file_name'] = isset($file_name) ? $file_name : '';
1314 1372 }
1315 - }
1316 - else if(is_plugin_active('jet-booking/jet-booking.php')){
1373 + } else if (is_plugin_active('jet-booking/jet-booking.php')) {
1317 1374
1318 - if(isset($value->meta_key) && $value->meta_key == 'jet_abaf_price'){
1375 + if (isset($value->meta_key) && $value->meta_key == 'jet_abaf_price') {
1319 1376 self::$export_instance->data[$id]['jet_abaf_price'] = $value->meta_value;
1377 + } else if (isset($value->meta_key) && $value->meta_key == 'jet_abaf_configuration') {
1378 + self::$export_instance->data[$id]['jet_abaf_configuration'] = $value->meta_value;
1379 + } else if (isset($value->meta_key) && $value->meta_key == 'jet_abaf_custom_schedule') {
1380 + self::$export_instance->data[$id]['jet_abaf_custom_schedule'] = $value->meta_value;
1320 1381 }
1321 - else if(isset($value->meta_key) && $value->meta_key == 'jet_abaf_configuration'){
1322 - self::$export_instance->data[$id]['jet_abaf_configuration'] = $value->meta_value ;
1323 - }
1324 - else if(isset($value->meta_key) && $value->meta_key == 'jet_abaf_custom_schedule'){
1325 - self::$export_instance->data[$id]['jet_abaf_custom_schedule'] =$value->meta_value;
1326 - }
1327 - }
1328 - else if(isset($value->meta_key) && $value->meta_key == '_downloadable_files'){
1382 + } else if (isset($value->meta_key) && $value->meta_key == '_downloadable_files') {
1329 1383
1330 - $downfiles = unserialize($value->meta_value);
1331 - if(!empty($downfiles)){
1332 - foreach($downfiles as $dk => $dv){
1333 - $down_file .= $dv['name'].','.$dv['file'].'|';
1384 + $downfiles = unserialize($value->meta_value);
1385 + if (!empty($downfiles)) {
1386 + foreach ($downfiles as $dk => $dv) {
1387 + $down_file .= $dv['name'] . ',' . $dv['file'] . '|';
1334 1388 }
1335 - self::$export_instance->data[$id]['downloadable_files'] = rtrim($down_file,"|");
1389 + self::$export_instance->data[$id]['downloadable_files'] = rtrim($down_file, "|");
1336 1390 }
1337 - }
1338 - elseif($value !== null && $value->meta_key == '_downloadable'){
1339 - self::$export_instance->data[$id]['downloadable'] = $value->meta_value;
1340 - }
1341 - elseif($value !== null && $value->meta_key == '_upsell_ids'){
1391 + } elseif ($value !== null && $value->meta_key == '_downloadable') {
1392 + self::$export_instance->data[$id]['downloadable'] = $value->meta_value;
1393 + } elseif ($value !== null && $value->meta_key == '_upsell_ids') {
1342 1394 $upselldata = unserialize($value->meta_value);
1343 - if(!empty($upselldata)){
1344 - foreach($upselldata as $upselldata_value){
1395 + if (!empty($upselldata)) {
1396 + foreach ($upselldata as $upselldata_value) {
1345 1397 $upselldata_query = $wpdb->prepare("SELECT post_title FROM {$wpdb->prefix}posts where id = %d", $upselldata_value);
1346 - $upselldata_value=$wpdb->get_results($upselldata_query);
1398 + $upselldata_value = $wpdb->get_results($upselldata_query);
1347 1399 $upselldata_item[] = $upselldata_value[0]->post_title;
1348 1400 }
1349 - $upsellids = implode(',',$upselldata_item);
1350 - self::$export_instance->data[$id]['upsell_ids'] = $upsellids;
1401 + $upsellids = implode(',', $upselldata_item);
1402 + self::$export_instance->data[$id]['upsell_ids'] = $upsellids;
1351 1403 }
1352 - }
1353 - elseif($value !== null && $value->meta_key == '_crosssell_ids'){
1404 + } elseif ($value !== null && $value->meta_key == '_crosssell_ids') {
1354 1405 $cross_selldata = unserialize($value->meta_value);
1355 - if(!empty($cross_selldata)){
1356 - foreach($cross_selldata as $cross_selldata_value){
1406 + if (!empty($cross_selldata)) {
1407 + foreach ($cross_selldata as $cross_selldata_value) {
1357 1408 $cross_selldata_query = $wpdb->prepare("SELECT post_title FROM {$wpdb->prefix}posts where id = %d", $cross_selldata_value);
1358 - $cross_selldata_value=$wpdb->get_results($cross_selldata_query);
1409 + $cross_selldata_value = $wpdb->get_results($cross_selldata_query);
1359 1410
1360 1411 $cross_selldata_item[] = $cross_selldata_value[0]->post_title;
1361 1412 }
1362 - $cross_sellids = implode(',',$cross_selldata_item);
1363 - self::$export_instance->data[$id]['crosssell_ids'] = $cross_sellids;
1413 + $cross_sellids = implode(',', $cross_selldata_item);
1414 + self::$export_instance->data[$id]['crosssell_ids'] = $cross_sellids;
1364 1415 }
1365 - }
1366 - elseif($value !== null && $value->meta_key == '_wc_pb_bundle_sell_ids'){
1416 + } elseif ($value !== null && $value->meta_key == '_wc_pb_bundle_sell_ids') {
1367 1417 $bundleselldata = unserialize($value->meta_value);
1368 - if(!empty($bundleselldata) && is_array($bundleselldata)){
1418 + if (!empty($bundleselldata) && is_array($bundleselldata)) {
1369 1419 $bundsell = [];
1370 - foreach($bundleselldata as $bundle_id){
1420 + foreach ($bundleselldata as $bundle_id) {
1371 1421 $bundleids = $wpdb->get_results("SELECT post_title FROM {$wpdb->prefix}posts WHERE post_type = 'product' AND ID = '$bundle_id'");
1372 - foreach($bundleids as $bundid){
1422 + foreach ($bundleids as $bundid) {
1373 1423 $bundsell[] = $bundid->post_title;
1374 1424 }
1375 1425 }
1376 - $value->meta_value = implode(',',$bundsell);
1377 - self::$export_instance->data[$id]['_wc_pb_bundle_sell_ids'] = $value->meta_value;
1426 + $value->meta_value = implode(',', $bundsell);
1427 + self::$export_instance->data[$id]['_wc_pb_bundle_sell_ids'] = $value->meta_value;
1378 1428 }
1379 - }
1380 - elseif($value !== null && $value->meta_key == '_children'){
1429 + } elseif ($value !== null && $value->meta_key == '_children') {
1381 1430 $grpdata = unserialize($value->meta_value);
1382 - if(!empty($grpdata)){
1383 - $grpids = implode(',',$grpdata);
1384 - self::$export_instance->data[$id]['grouping_product'] = $grpids;
1431 + if (!empty($grpdata)) {
1432 + $grpids = implode(',', $grpdata);
1433 + self::$export_instance->data[$id]['grouping_product'] = $grpids;
1385 1434 }
1386 - }elseif($value !== null && $value->meta_key == '_product_image_gallery'){
1387 - if(strpos($value->meta_value, ',') !== false) {
1435 + } elseif ($value !== null && $value->meta_key == '_product_image_gallery') {
1436 + if (strpos($value->meta_value, ',') !== false) {
1388 1437 // $file_data = explode(',',$value->meta_value);
1389 1438 // foreach($file_data as $k => $v){
1390 1439 // $attachment = wp_get_attachment_image_src($v);
1391 1440 // $attach[$k] = $attachment[0];
@@ -1395,44 +1444,42 @@
1395 1444 $attachment = wp_get_attachment_image_src($v);
1396 1445 if ($attachment !== false && is_array($attachment) && isset($attachment[0])) {
1397 1446 $attach[$k] = $attachment[0];
1398 1447 } else {
1399 - $attach[$k] = '';
1448 + $attach[$k] = '';
1400 1449 }
1401 1450 }
1402 1451 $gallery_data = '';
1403 - foreach($attach as $values){
1404 - $gallery_data .= $values.'|';
1452 + foreach ($attach as $values) {
1453 + $gallery_data .= $values . '|';
1405 1454 }
1406 - $gallery_data = rtrim($gallery_data , '|');
1455 + $gallery_data = rtrim($gallery_data, '|');
1407 1456 self::$export_instance->data[$id]['product_image_gallery'] = $gallery_data;
1408 - }else{
1457 + } else {
1409 1458 $attachment = wp_get_attachment_image_src($value->meta_value);
1410 1459 self::$export_instance->data[$id]['product_image_gallery'] = $attachment[0];
1411 1460 }
1412 - }elseif($value !== null && $value->meta_key == '_sale_price_dates_from'){
1461 + } elseif ($value !== null && $value->meta_key == '_sale_price_dates_from') {
1413 1462 $sales_price_date_from_value = '';
1414 - if(!empty($value->meta_value)){
1415 - $sales_price_date_from_value = date('Y-m-d',$value->meta_value);
1463 + if (!empty($value->meta_value)) {
1464 + $sales_price_date_from_value = date('Y-m-d', $value->meta_value);
1416 1465 }
1417 1466 self::$export_instance->data[$id]['sale_price_dates_from'] = $sales_price_date_from_value;
1418 - }
1419 - elseif($value !== null && $value->meta_key == '_lp_faqs'){
1420 - $faqs=$value->meta_value;
1421 - $unserialize_faq_value=unserialize($faqs);
1467 + } elseif ($value !== null && $value->meta_key == '_lp_faqs') {
1468 + $faqs = $value->meta_value;
1469 + $unserialize_faq_value = unserialize($faqs);
1422 1470 $faqs_value = '';
1423 - foreach($unserialize_faq_value as $faq_key=>$faq_value){
1424 - $faqs_value .= $faq_value[0].','.$faq_value[1].'|';
1471 + foreach ($unserialize_faq_value as $faq_key => $faq_value) {
1472 + $faqs_value .= $faq_value[0] . ',' . $faq_value[1] . '|';
1425 1473 }
1426 - self::$export_instance->data[$id][ $value->meta_key ] = rtrim($faqs_value,'|');
1427 - }
1428 - elseif($value !== null && $value->meta_key == '_sale_price_dates_to'){
1474 + self::$export_instance->data[$id][$value->meta_key] = rtrim($faqs_value, '|');
1475 + } elseif ($value !== null && $value->meta_key == '_sale_price_dates_to') {
1429 1476 $sales_price_dates_value = '';
1430 - if(!empty($value->meta_value)){
1431 - $sales_price_dates_value = date('Y-m-d',$value->meta_value);
1477 + if (!empty($value->meta_value)) {
1478 + $sales_price_dates_value = date('Y-m-d', $value->meta_value);
1432 1479 }
1433 1480 self::$export_instance->data[$id]['sale_price_dates_to'] = $sales_price_dates_value;
1434 - }else {
1481 + } else {
1435 1482
1436 1483 // commented this if statement
1437 1484 // if(preg_match('/group_/',$value->meta_key)){
1438 1485 // $value->meta_key = preg_replace('/group_/','', $value->meta_key );
@@ -1438,21 +1485,21 @@
1438 1485 // $value->meta_key = preg_replace('/group_/','', $value->meta_key );
1439 1486 // }
1440 1487
1441 1488
1442 - if($value !== null && isset($allacf) && array_search($value->meta_key, $allacf)){
1489 + if ($value !== null && isset($allacf) && array_search($value->meta_key, $allacf)) {
1443 1490 $repeaterOfrepeater = false;
1444 1491 $getType = $alltype[$value->meta_key];
1445 - if(empty($getType)){
1492 + if (empty($getType)) {
1446 1493 $tempFieldname = array_search($value->meta_key, $allacf);
1447 1494 $getType = $alltype[$tempFieldname];
1448 1495 }
1449 1496
1450 - if ($getType == 'flexible_content' || $getType == 'repeater') {
1451 - if(is_serialized($value->meta_value)){
1497 + if ($getType == 'flexible_content' || $getType == 'repeater') {
1498 + if (is_serialized($value->meta_value)) {
1452 1499 $value->meta_value = unserialize($value->meta_value);
1453 1500 $count = count($value->meta_value);
1454 - }else{
1501 + } else {
1455 1502 $count = $value->meta_value;
1456 1503 }
1457 1504
1458 1505 $getRF = $checkRep[$value->meta_key];
@@ -1457,14 +1504,14 @@
1457 1504
1458 1505 $getRF = $checkRep[$value->meta_key];
1459 1506 $repeater_data = [];
1460 1507
1461 - if($getType == 'flexible_content'){
1508 + if ($getType == 'flexible_content') {
1462 1509 $flexible_value = '';
1463 - foreach($value->meta_value as $values){
1464 - $flexible_value .= $values.'|';
1510 + foreach ($value->meta_value as $values) {
1511 + $flexible_value .= $values . '|';
1465 1512 }
1466 - $flexible_value = rtrim($flexible_value , '|');
1513 + $flexible_value = rtrim($flexible_value, '|');
1467 1514 self::$export_instance->data[$id][$value->meta_key] = self::$export_instance->returnMetaValueAsCustomerInput($flexible_value);
1468 1515 }
1469 1516
1470 1517 foreach ($getRF as $rep => $rep1) {
@@ -1470,158 +1517,136 @@
1470 1517 foreach ($getRF as $rep => $rep1) {
1471 1518 $repType = $alltype[$rep1];
1472 1519
1473 1520 $reval = "";
1474 - for($z=0;$z<$count;$z++){
1475 - $var = $value->meta_key.'_'.$z.'_'.$rep1;
1521 + for ($z = 0; $z < $count; $z++) {
1522 + $var = $value->meta_key . '_' . $z . '_' . $rep1;
1476 1523
1477 - if(in_array($optionalType , $taxonomies)){
1524 + if (in_array($optionalType, $taxonomies)) {
1478 1525 $qry = $wpdb->get_results($wpdb->prepare("SELECT meta_value FROM {$wpdb->prefix}terms wp JOIN {$wpdb->prefix}termmeta wpm ON wpm.term_id = wp.term_id where meta_key = %s AND wp.term_id = %d", $var, $id));
1479 - }else{
1526 + } else {
1480 1527 $qry = $wpdb->get_results($wpdb->prepare("SELECT meta_value FROM {$wpdb->prefix}posts wp JOIN {$wpdb->prefix}postmeta wpm ON wpm.post_id = wp.ID where meta_key = %s AND ID=%d", $var, $id));
1481 1528 }
1482 1529
1483 1530 $meta = $qry[0]->meta_value;
1484 - if($repType == 'image')
1531 + if ($repType == 'image')
1485 1532 $meta = $this->getAttachment($meta);
1486 - if($repType == 'file')
1487 - $meta =$this->getAttachment($meta);
1488 - if($repType == 'repeater' || $repType == 'flexible_content')
1533 + if ($repType == 'file')
1534 + $meta = $this->getAttachment($meta);
1535 + if ($repType == 'repeater' || $repType == 'flexible_content')
1489 1536 $meta = $this->getRepeaterofRepeater($value->meta_key);
1490 - if(is_serialized($meta))
1491 - {
1537 + if (is_serialized($meta)) {
1492 1538 $unmeta = unserialize($meta);
1493 1539 $meta = "";
1494 1540 foreach ($unmeta as $unmeta1) {
1495 - if($repType == 'image' || $repType == 'gallery')
1496 - $meta .= $this->getAttachment($unmeta1).",";
1497 - elseif($repType == 'taxonomy') {
1498 - $meta .=$unmeta1.',';
1499 - }
1500 - elseif($repType == 'user') {
1501 - $meta .=$unmeta1.',';
1502 - }
1503 - elseif($repType == 'post_object') {
1504 - $meta .=$unmeta1.',';
1505 - }
1506 - elseif($repType == 'relationship') {
1507 - $meta .=$unmeta1.',';
1508 - }
1509 - elseif($repType == 'page_link') {
1510 - $meta .=$unmeta1.',';
1511 - }
1512 - elseif($repType == 'link') {
1513 - $meta .=$unmeta1;
1514 - }
1515 -
1516 -
1517 - else
1518 - $meta .= $unmeta1.",";
1541 + if ($repType == 'image' || $repType == 'gallery')
1542 + $meta .= $this->getAttachment($unmeta1) . ",";
1543 + elseif ($repType == 'taxonomy') {
1544 + $meta .= $unmeta1 . ',';
1545 + } elseif ($repType == 'user') {
1546 + $meta .= $unmeta1 . ',';
1547 + } elseif ($repType == 'post_object') {
1548 + $meta .= $unmeta1 . ',';
1549 + } elseif ($repType == 'relationship') {
1550 + $meta .= $unmeta1 . ',';
1551 + } elseif ($repType == 'page_link') {
1552 + $meta .= $unmeta1 . ',';
1553 + } elseif ($repType == 'link') {
1554 + $meta .= $unmeta1;
1555 + } else
1556 + $meta .= $unmeta1 . ",";
1519 1557 }
1520 - $meta = rtrim($meta,',');
1558 + $meta = rtrim($meta, ',');
1521 1559 }
1522 - if($meta != "")
1523 - $reval .= $meta."|";
1560 + if ($meta != "")
1561 + $reval .= $meta . "|";
1524 1562 }
1525 - self::$export_instance->data[$id][$rep1] = self::$export_instance->returnMetaValueAsCustomerInput(rtrim($reval,'|'));
1563 + self::$export_instance->data[$id][$rep1] = self::$export_instance->returnMetaValueAsCustomerInput(rtrim($reval, '|'));
1526 1564 }
1527 - }
1528 - elseif( is_serialized($value->meta_value)){
1565 + } elseif (is_serialized($value->meta_value)) {
1529 1566
1530 1567 $acfva = unserialize($value->meta_value);
1531 1568 $acfdata = "";
1532 1569 foreach ($acfva as $key1 => $value1) {
1533 - if($getType == 'checkbox')
1534 - $acfdata .= $value1.',';
1535 - elseif($getType == 'gallery' || $getType == 'image'){
1570 + if ($getType == 'checkbox')
1571 + $acfdata .= $value1 . ',';
1572 + elseif ($getType == 'gallery' || $getType == 'image') {
1536 1573 $attach = $this->getAttachment($value1);
1537 - $acfdata .= $attach.',';
1538 - }
1539 - elseif($getType == 'google_map')
1540 - {
1541 - $acfdata=$acfva['address'];
1542 - }
1543 - else{
1544 - if(!empty($value1)) {
1545 - $acfdata .= $value1.',';
1574 + $acfdata .= $attach . ',';
1575 + } elseif ($getType == 'google_map') {
1576 + $acfdata = $acfva['address'];
1577 + } else {
1578 + if (!empty($value1)) {
1579 + $acfdata .= $value1 . ',';
1546 1580 }
1547 1581 }
1548 1582
1549 1583 }
1550 - self::$export_instance->data[$id][ $value->meta_key ] = self::$export_instance->returnMetaValueAsCustomerInput(rtrim($acfdata,','));
1551 - }
1552 - elseif($getType == 'gallery' || $getType == 'image'|| $getType == 'file' ){
1584 + self::$export_instance->data[$id][$value->meta_key] = self::$export_instance->returnMetaValueAsCustomerInput(rtrim($acfdata, ','));
1585 + } elseif ($getType == 'gallery' || $getType == 'image' || $getType == 'file') {
1553 1586 $attach1 = $this->getAttachment($value->meta_value);
1554 - self::$export_instance->data[$id][ $value->meta_key ] = $attach1;
1587 + self::$export_instance->data[$id][$value->meta_key] = $attach1;
1588 + } else {
1589 + self::$export_instance->data[$id][$value->meta_key] = self::$export_instance->returnMetaValueAsCustomerInput($value->meta_value);
1555 1590 }
1556 - else{
1557 - self::$export_instance->data[$id][ $value->meta_key ] = self::$export_instance->returnMetaValueAsCustomerInput($value->meta_value);
1558 - }
1559 - }
1560 - elseif(is_array($jet_fields) && in_array($value->meta_key, $jet_fields) && !empty($value->meta_value)){
1591 + } elseif (is_array($jet_fields) && in_array($value->meta_key, $jet_fields) && !empty($value->meta_value)) {
1561 1592 $getjetType = isset($jetTypes[$value->meta_key]) ? $jetTypes[$value->meta_key] : '';
1562 - if(empty($getjetType)){
1593 + if (empty($getjetType)) {
1563 1594 $tempFieldname = array_search($value->meta_key, $jet_fields);
1564 1595 $getjetType = isset($jetTypes[$tempFieldname]) ? $jetTypes[$tempFieldname] : '';
1565 - }
1596 + }
1566 1597
1567 - if($getjetType == 'checkbox' && is_string($value->meta_value)){
1598 + if ($getjetType == 'checkbox' && is_string($value->meta_value)) {
1568 1599 $value->meta_value = unserialize($value->meta_value);
1569 1600 $check = '';
1570 - foreach($value->meta_value as $key => $metvalue){
1571 - if(is_numeric($key)){
1572 - $check .= $metvalue.',';
1573 - $rcheck = substr($check,0,-1);
1574 - self::$export_instance->data[$id][ $value->meta_key ] = $rcheck;
1575 - }
1576 - else{
1577 - if($metvalue == 'true'){
1601 + foreach ($value->meta_value as $key => $metvalue) {
1602 + if (is_numeric($key)) {
1603 + $check .= $metvalue . ',';
1604 + $rcheck = substr($check, 0, -1);
1605 + self::$export_instance->data[$id][$value->meta_key] = $rcheck;
1606 + } else {
1607 + if ($metvalue == 'true') {
1578 1608
1579 1609 $exp_value[] = $key;
1580 1610 }
1581 - if(isset($exp_value) && is_array($exp_value)){
1582 - $value->meta_value = implode(',',$exp_value );
1611 + if (isset($exp_value) && is_array($exp_value)) {
1612 + $value->meta_value = implode(',', $exp_value);
1583 1613 }
1584 1614
1585 - self::$export_instance->data[$id][ $value->meta_key ] = $value->meta_value;
1615 + self::$export_instance->data[$id][$value->meta_key] = $value->meta_value;
1586 1616 }
1587 1617
1588 1618 }
1589 1619
1590 - }
1591 - elseif($getjetType == 'select'){
1592 - if(is_serialized($value->meta_value)){
1620 + } elseif ($getjetType == 'select') {
1621 + if (is_serialized($value->meta_value)) {
1593 1622 $value->meta_value = unserialize($value->meta_value);
1594 - foreach($value->meta_value as $metkey => $metselectvalue){
1623 + foreach ($value->meta_value as $metkey => $metselectvalue) {
1595 1624 $select[] = $metselectvalue;
1596 - $value->meta_value = implode(',',$select );
1597 - self::$export_instance->data[$id][ $value->meta_key ] = $value->meta_value;
1598 - }
1625 + $value->meta_value = implode(',', $select);
1626 + self::$export_instance->data[$id][$value->meta_key] = $value->meta_value;
1627 + }
1628 + } else {
1629 + self::$export_instance->data[$id][$value->meta_key] = $value->meta_value;
1599 1630 }
1600 - else{
1601 - self::$export_instance->data[$id][ $value->meta_key ] = $value->meta_value;
1602 - }
1603 - }
1604 - elseif($getjetType == 'date'){
1605 - if(!empty($value->meta_value)){
1606 - if(strpos($value->meta_value, '-') !== FALSE){
1607 - }else{
1631 + } elseif ($getjetType == 'date') {
1632 + if (!empty($value->meta_value)) {
1633 + if (strpos($value->meta_value, '-') !== FALSE) {
1634 + } else {
1608 1635 $value->meta_value = date('Y-m-d', $value->meta_value);
1609 1636 }
1610 1637 }
1611 - self::$export_instance->data[$id][ $value->meta_key ] = $value->meta_value;
1612 - }
1613 - elseif($getjetType == 'datetime-local'){
1614 - if(!empty($value->meta_value)){
1615 - if(strpos($value->meta_value, '-') !== FALSE){
1616 - }else{
1638 + self::$export_instance->data[$id][$value->meta_key] = $value->meta_value;
1639 + } elseif ($getjetType == 'datetime-local') {
1640 + if (!empty($value->meta_value)) {
1641 + if (strpos($value->meta_value, '-') !== FALSE) {
1642 + } else {
1617 1643 $value->meta_value = date('Y-m-d H:i', $value->meta_value);
1618 1644 }
1619 1645 $value->meta_value = str_replace(' ', 'T', $value->meta_value);
1620 1646 }
1621 - self::$export_instance->data[$id][ $value->meta_key ] = $value->meta_value;
1622 - }
1623 - else if (is_object($value) && isset($value->meta_value)) {
1647 + self::$export_instance->data[$id][$value->meta_key] = $value->meta_value;
1648 + } else if (is_object($value) && isset($value->meta_value)) {
1624 1649 $meta_value = $value->meta_value;
1625 1650
1626 1651 // Check if $meta_value is a JSON string
1627 1652 if (is_string($meta_value) && json_decode($meta_value)) {
@@ -1647,107 +1672,100 @@
1647 1672 $value_all = implode(',', $output_array);
1648 1673
1649 1674 self::$export_instance->data[$id][$value->meta_key] = $value_all;
1650 1675 }
1676 + } else {
1677 + self::$export_instance->data[$id][$value->meta_key] = $value->meta_value;
1651 1678 }
1652 - else{
1653 - self::$export_instance->data[$id][ $value->meta_key ] = $value->meta_value;
1654 - }
1655 - }
1656 - elseif (!empty($typesf) && isset($value->meta_key) && in_array($value->meta_key, $typesf)) {
1679 + } elseif (!empty($typesf) && isset($value->meta_key) && in_array($value->meta_key, $typesf)) {
1657 1680 global $wpdb;
1658 - $type_value = '';
1681 + $type_value = '';
1659 1682 $typeoftype = $typeOftypesField[$value->meta_key];
1660 - if(in_array($optionalType , $taxonomies)){
1661 - $type_data = get_term_meta($id,$value->meta_key);
1662 - }
1663 - elseif($optionalType == 'user' || $optionalType == 'users'){
1664 - $type_data = get_user_meta($id,$value->meta_key);
1665 - }
1666 - else{
1667 - $type_data = get_post_meta($id,$value->meta_key);
1683 + if (in_array($optionalType, $taxonomies)) {
1684 + $type_data = get_term_meta($id, $value->meta_key);
1685 + } elseif ($optionalType == 'user' || $optionalType == 'users') {
1686 + $type_data = get_user_meta($id, $value->meta_key);
1687 + } else {
1688 + $type_data = get_post_meta($id, $value->meta_key);
1668 1689 $typcap = "";
1669 - foreach($type_data as $type_key =>$type_value){
1670 - if(!is_array($type_value)){
1671 - $substring='http';
1672 - $string=substr($type_value,0,4);
1673 - if($string==$substring){
1674 - $getid=$wpdb->get_results("select ID from {$wpdb->prefix}posts where guid= '$type_value'" ,ARRAY_A);
1675 - foreach($getid as $getkey => $getval){
1690 + foreach ($type_data as $type_key => $type_value) {
1691 + if (!is_array($type_value)) {
1692 + $substring = 'http';
1693 + $string = substr($type_value, 0, 4);
1694 + if ($string == $substring) {
1695 + $getid = $wpdb->get_results("select ID from {$wpdb->prefix}posts where guid= '$type_value'", ARRAY_A);
1696 + foreach ($getid as $getkey => $getval) {
1676 1697 global $wpdb;
1677 - $ids=$getval['ID'];
1678 - $types_caption=$wpdb->get_results("select post_excerpt from {$wpdb->prefix}posts where ID= '$ids'" ,ARRAY_A);
1679 - $types_description=$wpdb->get_results("select post_content from {$wpdb->prefix}posts where ID= '$ids'" ,ARRAY_A);
1680 - $types_title=$wpdb->get_results("select post_title from {$wpdb->prefix}posts where ID= '$ids'" ,ARRAY_A);
1681 - $types_alt_text=$wpdb->get_results("select meta_value from {$wpdb->prefix}postmeta where meta_key= '_wp_attachment_image_alt' AND post_id='$ids'" ,ARRAY_A);
1682 - $types_filename=$wpdb->get_results("select meta_value from {$wpdb->prefix}postmeta where meta_key= '_wp_attached_file' AND post_id='$ids'" ,ARRAY_A);
1683 - if(isset($types_filename[0])){
1684 - $filename=$types_filename[0]['meta_value'];
1698 + $ids = $getval['ID'];
1699 + $types_caption = $wpdb->get_results("select post_excerpt from {$wpdb->prefix}posts where ID= '$ids'", ARRAY_A);
1700 + $types_description = $wpdb->get_results("select post_content from {$wpdb->prefix}posts where ID= '$ids'", ARRAY_A);
1701 + $types_title = $wpdb->get_results("select post_title from {$wpdb->prefix}posts where ID= '$ids'", ARRAY_A);
1702 + $types_alt_text = $wpdb->get_results("select meta_value from {$wpdb->prefix}postmeta where meta_key= '_wp_attachment_image_alt' AND post_id='$ids'", ARRAY_A);
1703 + $types_filename = $wpdb->get_results("select meta_value from {$wpdb->prefix}postmeta where meta_key= '_wp_attached_file' AND post_id='$ids'", ARRAY_A);
1704 + if (isset($types_filename[0])) {
1705 + $filename = $types_filename[0]['meta_value'];
1685 1706 }
1686 - if(isset($filename)){
1687 - $file_names=explode('/', $filename);
1707 + if (isset($filename)) {
1708 + $file_names = explode('/', $filename);
1688 1709 }
1689 - if(isset($file_names[2])){
1690 - $file_name= $file_names[2];
1710 + if (isset($file_names[2])) {
1711 + $file_name = $file_names[2];
1691 1712 }
1692 - $file_name=isset($file_name)?$file_name:'';
1713 + $file_name = isset($file_name) ? $file_name : '';
1693 1714 self::$export_instance->data[$id]['types_caption'] = $types_caption[0]['post_excerpt'];
1694 1715 self::$export_instance->data[$id]['types_description'] = $types_description;
1695 1716 self::$export_instance->data[$id]['types_title'] = $types_title;
1696 1717 self::$export_instance->data[$id]['types_alt_text'] = $types_alt_text;
1697 1718 self::$export_instance->data[$id]['types_file_name'] = $file_name;
1698 -
1699 -
1719 +
1720 +
1700 1721 }
1701 1722 }
1702 -
1703 - $type_value = rtrim($type_value , '|');
1704 -
1723 +
1724 + $type_value = rtrim($type_value, '|');
1725 +
1705 1726 }
1706 -
1727 +
1707 1728 }
1708 -
1709 - self::$export_instance->data[$id][ $value->meta_key ] = $type_value;
1710 -
1729 +
1730 + self::$export_instance->data[$id][$value->meta_key] = $type_value;
1731 +
1711 1732 }
1712 -
1713 - if(is_array($type_data)){
1714 - $type_value="";
1715 - foreach($type_data as $k => $mid){
1716 - if(is_array($mid) && !empty($mid)){
1717 - if($typeoftype == 'skype'){
1733 +
1734 + if (is_array($type_data)) {
1735 + $type_value = "";
1736 + foreach ($type_data as $k => $mid) {
1737 + if (is_array($mid) && !empty($mid)) {
1738 + if ($typeoftype == 'skype') {
1718 1739 $type_value .= $mid['skypename'] . '|';
1740 + } elseif ($typeoftype == 'checkboxes') {
1741 + $check_type_value = '';
1742 + foreach ($mid as $mid_value) {
1743 + $check_type_value .= $mid_value[0] . ',';
1744 + }
1745 + $type_value .= rtrim($check_type_value, ',');
1719 1746 }
1720 - elseif($typeoftype == 'checkboxes'){
1721 - $check_type_value = '';
1722 - foreach($mid as $mid_value){
1723 - $check_type_value .= $mid_value[0] . ',';
1724 - }
1725 - $type_value .= rtrim($check_type_value , ',');
1726 - }
1727 - }
1728 - elseif($typeoftype == 'date'){
1747 + } elseif ($typeoftype == 'date') {
1729 1748 $wptypesfields = get_option('wpcf-fields');
1730 - $fd_name = preg_replace('/wpcf-/','', $value->meta_key );
1749 + $fd_name = preg_replace('/wpcf-/', '', $value->meta_key);
1731 1750 if (isset($wptypesfields[$fd_name]['data']['date_and_time'])) {
1732 - $format = $wptypesfields[$fd_name]['data']['date_and_time'];
1733 - $dateformat =$format == 'date'?"Y-m-d" : "Y-m-d H:i:s";
1734 - if(!empty($mid))
1735 - $type_value .= date($dateformat, $mid) . '|';
1736 - }
1737 - }
1738 - else{
1739 - if(!is_array($mid)){
1751 + $format = $wptypesfields[$fd_name]['data']['date_and_time'];
1752 + $dateformat = $format == 'date' ? "Y-m-d" : "Y-m-d H:i:s";
1753 + if (!empty($mid))
1754 + $type_value .= date($dateformat, $mid) . '|';
1755 + }
1756 + } else {
1757 + if (!is_array($mid)) {
1740 1758 $type_value .= $mid . '|';
1741 - }
1759 + }
1742 1760 }
1743 1761 }
1744 - if(preg_match('/wpcf-/',$value->meta_key)){
1745 - $value->meta_key = preg_replace('/wpcf-/','', $value->meta_key );
1746 - self::$export_instance->data[$id][ $value->meta_key ] = rtrim($type_value , '|');
1762 + if (preg_match('/wpcf-/', $value->meta_key)) {
1763 + $value->meta_key = preg_replace('/wpcf-/', '', $value->meta_key);
1764 + self::$export_instance->data[$id][$value->meta_key] = rtrim($type_value, '|');
1747 1765 }
1748 - }
1749 -
1766 + }
1767 +
1750 1768 // if(preg_match('/group_/',$value->meta_key)){
1751 1769 // $getType = $alltype[$value->meta_key];
1752 1770 // if($value->meta_key == 'group_gallery' || $value->meta_key == 'group_image'|| $value->meta_key == 'file' ){
1753 1771 // $groupattach = $this->getAttachment($value->meta_value);
@@ -1757,147 +1775,130 @@
1757 1775 // $value->meta_key = preg_replace('/group_/','', $value->meta_key );
1758 1776 // self::$export_instance->data[$id][ $value->meta_key ] = $value->meta_value;
1759 1777 // }
1760 1778 // }
1761 -
1779 +
1762 1780 //TYPES Allow multiple-instances of this field
1763 - }elseif(!empty($group_unset) && is_array($value) && isset($value['meta_key']) && in_array($value['meta_key'], $group_unset) && is_serialized($value['meta_value'])) {
1781 + } elseif (!empty($group_unset) && is_array($value) && isset($value['meta_key']) && in_array($value['meta_key'], $group_unset) && is_serialized($value['meta_value'])) {
1764 1782
1765 1783 $unser = unserialize($value->meta_value);
1766 1784 $data = "";
1767 - foreach ($unser as $key4 => $value4)
1768 - $data .= $value4.',';
1769 - self::$export_instance->data[$id][ $value->meta_key ] = substr($data, 0, -1);
1770 - }
1771 - elseif(!empty($pods_type) && in_array($value->meta_key , $pods_type)){
1772 - if(!isset(self::$export_instance->data[$id][$value->meta_key])){
1773 - if(in_array($optionalType , $taxonomies)){
1774 - $pods_file_data = get_term_meta($id,$value->meta_key);
1775 - }else{
1776 - $pods_file_data = get_post_meta($id,$value->meta_key);
1785 + foreach ($unser as $key4 => $value4)
1786 + $data .= $value4 . ',';
1787 + self::$export_instance->data[$id][$value->meta_key] = substr($data, 0, -1);
1788 + } elseif (!empty($pods_type) && in_array($value->meta_key, $pods_type)) {
1789 + if (!isset(self::$export_instance->data[$id][$value->meta_key])) {
1790 + if (in_array($optionalType, $taxonomies)) {
1791 + $pods_file_data = get_term_meta($id, $value->meta_key);
1792 + } else {
1793 + $pods_file_data = get_post_meta($id, $value->meta_key);
1777 1794 }
1778 1795
1779 1796 $pods_value = '';
1780 - foreach($pods_file_data as $pods_file_value){
1781 - if(!empty($pods_file_value)){
1782 - if(is_array($pods_file_value)){
1783 - $pods_file_value['post_type']=isset($pods_file_value['post_type'])?$pods_file_value['post_type']:'';
1784 - $posts_type=$pods_file_value['post_type'];
1785 - if($posts_type=='attachment'){
1797 + foreach ($pods_file_data as $pods_file_value) {
1798 + if (!empty($pods_file_value)) {
1799 + if (is_array($pods_file_value)) {
1800 + $pods_file_value['post_type'] = isset($pods_file_value['post_type']) ? $pods_file_value['post_type'] : '';
1801 + $posts_type = $pods_file_value['post_type'];
1802 + if ($posts_type == 'attachment') {
1786 1803 $pods_value .= $pods_file_value['guid'] . ',';
1787 - }
1788 - elseif($posts_type!=='attachment'){
1789 - $pods_file_value['guid']=isset($pods_file_value['guid'])?$pods_file_value['guid']:'';
1790 - $p_guid=$pods_file_value['guid'];
1791 - $pod_tit = $wpdb->get_results("SELECT post_title FROM {$wpdb->prefix}posts where guid='$p_guid'");
1792 - if(!empty($pod_tit)){
1793 - foreach($pod_tit as $pods_title){
1794 - $pods_title_value=$pods_title->post_title;
1804 + } elseif ($posts_type !== 'attachment') {
1805 + $pods_file_value['guid'] = isset($pods_file_value['guid']) ? $pods_file_value['guid'] : '';
1806 + $p_guid = $pods_file_value['guid'];
1807 + $pod_tit = $wpdb->get_results("SELECT post_title FROM {$wpdb->prefix}posts where guid='$p_guid'");
1808 + if (!empty($pod_tit)) {
1809 + foreach ($pod_tit as $pods_title) {
1810 + $pods_title_value = $pods_title->post_title;
1795 1811 $pods_value .= $pods_title_value . ',';
1796 1812 }
1797 - }
1798 - else{
1813 + } else {
1799 1814 $podstaxval = $pods_file_value['name'];
1800 - $pods_value .= $podstaxval. ',';
1815 + $pods_value .= $podstaxval . ',';
1801 1816 }
1802 1817 }
1803 - }else{
1818 + } else {
1804 1819 $pods_value .= $pods_file_value . ',';
1805 1820 }
1806 - }
1821 + }
1807 1822 }
1808 - self::$export_instance->data[$id][$value->meta_key] = rtrim($pods_value , ',');
1823 + self::$export_instance->data[$id][$value->meta_key] = rtrim($pods_value, ',');
1809 1824 }
1810 - }
1811 -
1812 - elseif(!empty($metabox_fields) && is_array($metabox_fields) || (is_array($metabox_fields) && array_key_exists($value->meta_key, $metabox_fields))){
1813 - foreach($metabox_fields as $meta_val){
1814 - if($meta_val['type'] == 'taxonomy'){
1825 + } elseif (!empty($metabox_fields) && is_array($metabox_fields) || (is_array($metabox_fields) && array_key_exists($value->meta_key, $metabox_fields))) {
1826 + foreach ($metabox_fields as $meta_val) {
1827 + if ($meta_val['type'] == 'taxonomy') {
1815 1828 $meta_tax = $meta_val['taxonomy'];
1816 1829
1817 1830 $meta_key = $meta_val['id'];
1818 - foreach($meta_tax as $meta_val){
1819 - $get_metabox_titles[] = $wpdb->get_results("SELECT t.name FROM {$wpdb->prefix}terms t Inner join {$wpdb->prefix}term_taxonomy tax ON t.term_id=tax.term_id INNER JOIN {$wpdb->prefix}term_relationships tr ON tr.term_taxonomy_id=tax.term_taxonomy_id WHERE tr.object_id =$id AND tax.taxonomy ='$meta_val'",ARRAY_A);
1831 + foreach ($meta_tax as $meta_val) {
1832 + $get_metabox_titles[] = $wpdb->get_results("SELECT t.name FROM {$wpdb->prefix}terms t Inner join {$wpdb->prefix}term_taxonomy tax ON t.term_id=tax.term_id INNER JOIN {$wpdb->prefix}term_relationships tr ON tr.term_taxonomy_id=tax.term_taxonomy_id WHERE tr.object_id =$id AND tax.taxonomy ='$meta_val'", ARRAY_A);
1820 1833 }
1821 1834
1822 1835
1823 - $titles =array();
1824 - if(is_array($get_metabox_titles)){
1825 - foreach($get_metabox_titles as $title => $value){
1826 - foreach($value as $valu => $val){
1836 + $titles = array();
1837 + if (is_array($get_metabox_titles)) {
1838 + foreach ($get_metabox_titles as $title => $value) {
1839 + foreach ($value as $valu => $val) {
1827 1840 $titles[] = $val['name'];
1828 1841 }
1829 1842 }
1830 - $tax_val =implode('|',$titles);
1843 + $tax_val = implode('|', $titles);
1831 1844
1832 - self::$export_instance->data[$id][$meta_key] = $tax_val;
1845 + self::$export_instance->data[$id][$meta_key] = $tax_val;
1833 1846 }
1834 - }
1847 + }
1835 1848 }
1836 1849
1837 1850 $get_metabox_fieldtype = $metabox_fields[$value->meta_key]['type'];
1838 1851
1839 - if($get_metabox_fieldtype == 'select' || $get_metabox_fieldtype == 'select_advanced' || $get_metabox_fieldtype == 'checkbox_list' || $get_metabox_fieldtype == 'text_list' || $get_metabox_fieldtype == 'file_advanced'){
1852 + if ($get_metabox_fieldtype == 'select' || $get_metabox_fieldtype == 'select_advanced' || $get_metabox_fieldtype == 'checkbox_list' || $get_metabox_fieldtype == 'text_list' || $get_metabox_fieldtype == 'file_advanced') {
1840 1853
1841 1854 $metabox_metakey = $value->meta_key;
1842 - if($module == 'Users'){
1855 + if ($module == 'Users') {
1843 1856 $get_metabox_values = $wpdb->get_results("SELECT meta_value FROM {$wpdb->prefix}usermeta WHERE meta_key = '$metabox_metakey' AND user_id = $id ", ARRAY_A);
1844 - }else if($module == 'Categories' || $module == 'Taxonomies' || $module == 'Tags'){
1857 + } else if ($module == 'Categories' || $module == 'Taxonomies' || $module == 'Tags') {
1845 1858 $get_metabox_values = $wpdb->get_results("SELECT meta_value FROM {$wpdb->prefix}termmeta WHERE meta_key = '$metabox_metakey' AND term_id = $id ", ARRAY_A);
1846 - }else{
1859 + } else {
1847 1860 $get_metabox_values = $wpdb->get_results("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE meta_key = '$metabox_metakey' AND post_id = $id ", ARRAY_A);
1848 1861 }
1849 1862
1850 1863 $metabox_values = array_column($get_metabox_values, 'meta_value');
1851 - if($get_metabox_fieldtype == 'file_advanced' || $get_metabox_fieldtype == 'image_advanced'){
1864 + if ($get_metabox_fieldtype == 'file_advanced' || $get_metabox_fieldtype == 'image_advanced') {
1852 1865 $get_metabox_file_url = [];
1853 - foreach($metabox_values as $metavalue){
1866 + foreach ($metabox_values as $metavalue) {
1854 1867 $get_metabox_file_url[] = $wpdb->get_var("SELECT guid FROM {$wpdb->prefix}posts WHERE ID = $metavalue AND post_type = 'attachment' ");
1855 1868 }
1856 1869
1857 1870 $metabox_file_value = implode(',', $get_metabox_file_url);
1858 - self::$export_instance->data[$id][ $value->meta_key ] = $metabox_file_value;
1859 - }
1860 - else{
1871 + self::$export_instance->data[$id][$value->meta_key] = $metabox_file_value;
1872 + } else {
1861 1873 $metabox_value = implode(',', $metabox_values);
1862 - self::$export_instance->data[$id][ $value->meta_key ] = $metabox_value;
1874 + self::$export_instance->data[$id][$value->meta_key] = $metabox_value;
1863 1875 }
1864 - }
1865 -
1866 - elseif($get_metabox_fieldtype == 'fieldset_text'){
1876 + } elseif ($get_metabox_fieldtype == 'fieldset_text') {
1867 1877 $fieldset_values = unserialize($value->meta_value);
1868 1878 $fieldset_value = implode(',', array_values($fieldset_values));
1869 - self::$export_instance->data[$id][ $value->meta_key ] = $fieldset_value;
1870 - }
1871 -
1872 - elseif($get_metabox_fieldtype == 'post' || $get_metabox_fieldtype == 'taxonomy' || $get_metabox_fieldtype == 'user'){
1873 - if($get_metabox_fieldtype == 'post'){
1879 + self::$export_instance->data[$id][$value->meta_key] = $fieldset_value;
1880 + } elseif ($get_metabox_fieldtype == 'post' || $get_metabox_fieldtype == 'taxonomy' || $get_metabox_fieldtype == 'user') {
1881 + if ($get_metabox_fieldtype == 'post') {
1874 1882 $get_metabox_titles = $wpdb->get_var("SELECT post_title FROM {$wpdb->prefix}posts WHERE ID = $value->meta_value ");
1875 - }
1876 - elseif($get_metabox_fieldtype == 'taxonomy' || $get_metabox_fieldtype == 'taxonomy_advanced'){
1883 + } elseif ($get_metabox_fieldtype == 'taxonomy' || $get_metabox_fieldtype == 'taxonomy_advanced') {
1877 1884 $get_metabox_titles = $wpdb->get_var("SELECT name FROM {$wpdb->prefix}terms WHERE term_id = $value->meta_value ");
1878 - }
1879 - elseif($get_metabox_fieldtype == 'user'){
1885 + } elseif ($get_metabox_fieldtype == 'user') {
1880 1886 $get_metabox_titles = $wpdb->get_var("SELECT user_login FROM {$wpdb->prefix}users WHERE ID = $value->meta_value ");
1881 1887 }
1882 - self::$export_instance->data[$id][ $value->meta_key ] = $get_metabox_titles;
1883 - }
1884 -
1885 - elseif($get_metabox_fieldtype == 'image' || $get_metabox_fieldtype == 'file'){
1888 + self::$export_instance->data[$id][$value->meta_key] = $get_metabox_titles;
1889 + } elseif ($get_metabox_fieldtype == 'image' || $get_metabox_fieldtype == 'file') {
1886 1890 $upload_values = $value->meta_value;
1887 1891 $upload_value = $wpdb->get_var("SELECT guid FROM {$wpdb->prefix}posts WHERE ID = $upload_values AND post_type = 'attachment' ");
1888 - self::$export_instance->data[$id][ $value->meta_key ] = $upload_value;
1892 + self::$export_instance->data[$id][$value->meta_key] = $upload_value;
1893 + } else {
1894 + self::$export_instance->data[$id][$value->meta_key] = $value->meta_value;
1889 1895 }
1890 - else{
1891 - self::$export_instance->data[$id][ $value->meta_key ] = $value->meta_value;
1892 - }
1896 + } else {
1897 + self::$export_instance->data[$id][$value->meta_key] = $value->meta_value;
1893 1898 }
1894 1899
1895 - else{
1896 - self::$export_instance->data[$id][ $value->meta_key ] = $value->meta_value;
1897 - }
1898 1900
1899 -
1900 1901 }
1901 1902 }
1902 1903
1903 1904 public function getRepeater($parent)
@@ -1910,9 +1911,9 @@
1910 1911 $array[$i] = $value['post_excerpt'];
1911 1912 $i++;
1912 1913 }
1913 1914
1914 - return $array;
1915 + return $array;
1915 1916 }
1916 1917
1917 1918 public function getRepeaterofRepeater($parent)
1918 1919 {
@@ -1917,17 +1918,17 @@
1917 1918 public function getRepeaterofRepeater($parent)
1918 1919 {
1919 1920 global $wpdb;
1920 1921 $get_fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->posts where post_parent = %d", $parent), ARRAY_A);
1921 - $test = $get_fields[0]->ID ;
1922 + $test = $get_fields[0]->ID;
1922 1923 $get_fieldss = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->posts where post_parent = %d", $test), ARRAY_A);
1923 1924 $i = 0;
1924 1925 foreach ($get_fieldss as $key => $value) {
1925 - $array[$i] = $value['post_excerpt'];
1926 + $array[$i] = $value['post_excerpt'];
1926 1927 $i++;
1927 1928 }
1928 1929
1929 - return $array;
1930 + return $array;
1930 1931 }
1931 1932
1932 1933
1933 1934
@@ -1937,49 +1938,50 @@
1937 1938 * @param $module
1938 1939 * @param $optionalType
1939 1940 * @return array
1940 1941 */
1941 - public function FetchCategories($module,$optionalType,$mode = null) {
1942 + public function FetchCategories($module, $optionalType, $mode = null)
1943 + {
1942 1944 $headers = self::$export_instance->generateHeaders($module, $optionalType);
1943 1945 global $wpdb;
1944 1946 // $get_all_terms = get_categories('hide_empty=0');
1945 1947 // self::$export_instance->totalRowCount = count($get_all_terms);
1946 1948 $query = "SELECT * FROM {$wpdb->prefix}terms t INNER JOIN {$wpdb->prefix}term_taxonomy tax
1947 - ON `tax`.term_id = `t`.term_id WHERE `tax`.taxonomy = 'category'";
1948 - $get_all_taxonomies = $wpdb->get_results($query);
1949 - self::$export_instance->totalRowCount = count($get_all_taxonomies);
1949 + ON `tax`.term_id = `t`.term_id WHERE `tax`.taxonomy = 'category'";
1950 + $get_all_taxonomies = $wpdb->get_results($query);
1951 + self::$export_instance->totalRowCount = count($get_all_taxonomies);
1950 1952 $offset = self::$export_instance->offset;
1951 - $limit = self::$export_instance->limit;
1952 -
1953 -
1954 - $query="SELECT term_id FROM {$wpdb->prefix}term_taxonomy where taxonomy='category'";
1955 -
1953 + $limit = self::$export_instance->limit;
1954 +
1955 +
1956 + $query = "SELECT term_id FROM {$wpdb->prefix}term_taxonomy where taxonomy='category'";
1957 +
1956 1958 $offset_limit = " order by term_id asc limit $offset, $limit";
1957 - $query_with_offset_limit = $query.$offset_limit;
1958 -
1959 - $result= $wpdb->get_col($query_with_offset_limit);
1960 - $query1=array();
1961 - foreach($result as $res=>$re){
1962 - $query1[]=$wpdb->get_results(" SELECT t.name, t.slug, tx.description, tx.parent, t.term_id FROM {$wpdb->prefix}terms as t join {$wpdb->prefix}term_taxonomy as tx on t.term_id = tx.term_id where t.term_id = '$re'");
1959 + $query_with_offset_limit = $query . $offset_limit;
1960 +
1961 + $result = $wpdb->get_col($query_with_offset_limit);
1962 + $query1 = array();
1963 + foreach ($result as $res => $re) {
1964 + $query1[] = $wpdb->get_results(" SELECT t.name, t.slug, tx.description, tx.parent, t.term_id FROM {$wpdb->prefix}terms as t join {$wpdb->prefix}term_taxonomy as tx on t.term_id = tx.term_id where t.term_id = '$re'");
1963 1965 }
1964 - $new=array();
1965 - foreach($query1 as $qkey => $qval){
1966 - foreach($qval as $qid){
1967 - $new[]=$qid;
1966 + $new = array();
1967 + foreach ($query1 as $qkey => $qval) {
1968 + foreach ($qval as $qid) {
1969 + $new[] = $qid;
1968 1970 }
1969 -
1970 - }
1971 - if(!empty($new)) {
1972 - foreach( $new as $termKey => $termValue ) {
1971 +
1972 + }
1973 + if (!empty($new)) {
1974 + foreach ($new as $termKey => $termValue) {
1973 1975 $termID = $termValue->term_id;
1974 1976 $termName = $termValue->name;
1975 1977 $termSlug = $termValue->slug;
1976 1978 $termDesc = $termValue->description;
1977 1979 $termParent = $termValue->parent;
1978 - if($termParent == 0) {
1980 + if ($termParent == 0) {
1979 1981 self::$export_instance->data[$termID]['name'] = $termName;
1980 1982 } else {
1981 - $termParentName = get_cat_name( $termParent );
1983 + $termParentName = get_cat_name($termParent);
1982 1984 self::$export_instance->data[$termID]['name'] = $termParentName . '|' . $termName;
1983 1985 }
1984 1986 self::$export_instance->data[$termID]['slug'] = $termSlug;
1985 1987 self::$export_instance->data[$termID]['description'] = $termDesc;
@@ -1985,31 +1987,31 @@
1985 1987 self::$export_instance->data[$termID]['description'] = $termDesc;
1986 1988 self::$export_instance->data[$termID]['parent'] = $termParent;
1987 1989 self::$export_instance->data[$termID]['TERMID'] = $termID;
1988 1990
1989 - self::$export_instance->getWPMLData($termID,$optionalType,$module);
1990 - if(is_plugin_active('polylang/polylang.php') || is_plugin_active('polylang-pro/polylang.php') || is_plugin_active('polylang-wc/polylang-wc.php')){
1991 - self::$export_instance->getPolylangData($termID,$optionalType,$module);
1991 + self::$export_instance->getWPMLData($termID, $optionalType, $module);
1992 + if (is_plugin_active('polylang/polylang.php') || is_plugin_active('polylang-pro/polylang.php') || is_plugin_active('polylang-wc/polylang-wc.php')) {
1993 + self::$export_instance->getPolylangData($termID, $optionalType, $module);
1992 1994 }
1993 - $this->getPostsMetaDataBasedOnRecordId ($termID, $module, $optionalType);
1995 + $this->getPostsMetaDataBasedOnRecordId($termID, $module, $optionalType);
1994 1996
1995 - if(in_array('wordpress-seo/wp-seo.php', self::$export_instance->get_active_plugins())) {
1996 - $seo_yoast_taxonomies = get_option( 'wpseo_taxonomy_meta' );
1997 - if ( isset( $seo_yoast_taxonomies['category'] ) ) {
1997 + if (in_array('wordpress-seo/wp-seo.php', self::$export_instance->get_active_plugins())) {
1998 + $seo_yoast_taxonomies = get_option('wpseo_taxonomy_meta');
1999 + if (isset($seo_yoast_taxonomies['category'])) {
1998 2000
1999 - self::$export_instance->data[ $termID ]['title'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_title'];
2000 - self::$export_instance->data[ $termID ]['meta_desc'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_desc'];
2001 - self::$export_instance->data[ $termID ]['canonical'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_canonical'];
2002 - self::$export_instance->data[ $termID ]['bctitle'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_bctitle'];
2003 - self::$export_instance->data[ $termID ]['meta-robots-noindex'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_noindex'];
2004 - self::$export_instance->data[ $termID ]['sitemap-include'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_sitemap_include'];
2005 - self::$export_instance->data[ $termID ]['opengraph-title'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_opengraph-title'];
2006 - self::$export_instance->data[ $termID ]['opengraph-description'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_opengraph-description'];
2007 - self::$export_instance->data[ $termID ]['opengraph-image'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_opengraph-image'];
2008 - self::$export_instance->data[ $termID ]['twitter-title'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_twitter-title'];
2009 - self::$export_instance->data[ $termID ]['twitter-description'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_twitter-description'];
2010 - self::$export_instance->data[ $termID ]['twitter-image'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_twitter-image'];
2011 - self::$export_instance->data[ $termID ]['focus_keyword'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_focuskw'];
2001 + self::$export_instance->data[$termID]['title'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_title'];
2002 + self::$export_instance->data[$termID]['meta_desc'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_desc'];
2003 + self::$export_instance->data[$termID]['canonical'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_canonical'];
2004 + self::$export_instance->data[$termID]['bctitle'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_bctitle'];
2005 + self::$export_instance->data[$termID]['meta-robots-noindex'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_noindex'];
2006 + self::$export_instance->data[$termID]['sitemap-include'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_sitemap_include'];
2007 + self::$export_instance->data[$termID]['opengraph-title'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_opengraph-title'];
2008 + self::$export_instance->data[$termID]['opengraph-description'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_opengraph-description'];
2009 + self::$export_instance->data[$termID]['opengraph-image'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_opengraph-image'];
2010 + self::$export_instance->data[$termID]['twitter-title'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_twitter-title'];
2011 + self::$export_instance->data[$termID]['twitter-description'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_twitter-description'];
2012 + self::$export_instance->data[$termID]['twitter-image'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_twitter-image'];
2013 + self::$export_instance->data[$termID]['focus_keyword'] = $seo_yoast_taxonomies['category'][$termID]['wpseo_focuskw'];
2012 2014
2013 2015 }
2014 2016 }
2015 2017 }
@@ -2015,19 +2017,20 @@
2015 2017 }
2016 2018 }
2017 2019 $result = self::$export_instance->finalDataToExport(self::$export_instance->data, $module);
2018 2020
2019 - if($mode == null){
2021 + if ($mode == null) {
2020 2022 self::$export_instance->proceedExport($result);
2021 - }else{
2023 + } else {
2022 2024 return $result;
2023 2025 }
2024 2026 }
2025 2027
2026 2028
2027 - public function get_common_post_metadata($meta_id){
2029 + public function get_common_post_metadata($meta_id)
2030 + {
2028 2031 global $wpdb;
2029 - $mdata = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE meta_id = %d", $meta_id) ,ARRAY_A);
2032 + $mdata = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE meta_id = %d", $meta_id), ARRAY_A);
2030 2033 return $mdata[0];
2031 2034 }
2032 2035
2033 2036 public function getAttachment($id)
@@ -2050,40 +2053,41 @@
2050 2053 * @param $module
2051 2054 * @param $optionalType
2052 2055 * @return array
2053 2056 */
2054 - public function FetchTags($module,$optionalType,$mode = null) {
2057 + public function FetchTags($module, $optionalType, $mode = null)
2058 + {
2055 2059 global $wpdb;
2056 2060 self::$export_instance->generateHeaders($module, $optionalType);
2057 2061 // $get_all_terms = get_tags('hide_empty=0');
2058 -
2062 +
2059 2063 // self::$export_instance->totalRowCount = count($get_all_terms);
2060 2064 $query = "SELECT * FROM {$wpdb->prefix}terms t INNER JOIN {$wpdb->prefix}term_taxonomy tax
2061 - ON `tax`.term_id = `t`.term_id WHERE `tax`.taxonomy = 'post_tag'";
2062 - $get_all_taxonomies = $wpdb->get_results($query);
2065 + ON `tax`.term_id = `t`.term_id WHERE `tax`.taxonomy = 'post_tag'";
2066 + $get_all_taxonomies = $wpdb->get_results($query);
2063 2067 self::$export_instance->totalRowCount = count($get_all_taxonomies);
2064 2068 $offset = self::$export_instance->offset;
2065 - $limit = self::$export_instance->limit;
2066 -
2067 - $query="SELECT term_id FROM {$wpdb->prefix}term_taxonomy where taxonomy='post_tag'";
2068 -
2069 + $limit = self::$export_instance->limit;
2070 +
2071 + $query = "SELECT term_id FROM {$wpdb->prefix}term_taxonomy where taxonomy='post_tag'";
2072 +
2069 2073 $offset_limit = " order by term_id asc limit $offset, $limit";
2070 - $query_with_offset_limit = $query.$offset_limit;
2071 -
2072 - $result= $wpdb->get_col($query_with_offset_limit);
2073 - $query1=array();
2074 - foreach($result as $res=>$id){
2075 - $query1[]=$wpdb->get_results(" SELECT t.name, t.slug, tx.description, tx.parent, t.term_id FROM {$wpdb->prefix}terms as t join {$wpdb->prefix}term_taxonomy as tx on t.term_id = tx.term_id where t.term_id = '$id'");
2074 + $query_with_offset_limit = $query . $offset_limit;
2075 +
2076 + $result = $wpdb->get_col($query_with_offset_limit);
2077 + $query1 = array();
2078 + foreach ($result as $res => $id) {
2079 + $query1[] = $wpdb->get_results(" SELECT t.name, t.slug, tx.description, tx.parent, t.term_id FROM {$wpdb->prefix}terms as t join {$wpdb->prefix}term_taxonomy as tx on t.term_id = tx.term_id where t.term_id = '$id'");
2076 2080 }
2077 - $new=array();
2078 - foreach($query1 as $qkey => $qval){
2079 - foreach($qval as $qid){
2080 - $new[]=$qid;
2081 + $new = array();
2082 + foreach ($query1 as $qkey => $qval) {
2083 + foreach ($qval as $qid) {
2084 + $new[] = $qid;
2081 2085 }
2082 -
2086 +
2083 2087 }
2084 - if(!empty($new)) {
2085 - foreach( $new as $termKey => $termValue ) {
2088 + if (!empty($new)) {
2089 + foreach ($new as $termKey => $termValue) {
2086 2090 $termID = $termValue->term_id;
2087 2091 $termName = $termValue->name;
2088 2092 $termSlug = $termValue->slug;
2089 2093 $termDesc = $termValue->description;
@@ -2090,30 +2094,30 @@
2090 2094 self::$export_instance->data[$termID]['name'] = $termName;
2091 2095 self::$export_instance->data[$termID]['slug'] = $termSlug;
2092 2096 self::$export_instance->data[$termID]['description'] = $termDesc;
2093 2097
2094 - $this->getPostsMetaDataBasedOnRecordId ($termID, $module, $optionalType);
2095 - self::$export_instance->getWPMLData($termID,$optionalType,$module);
2096 - if(is_plugin_active('polylang/polylang.php') || is_plugin_active('polylang-pro/polylang.php') || is_plugin_active('polylang-wc/polylang-wc.php')){
2097 - self::$export_instance->getPolylangData($termID,$optionalType,$module);
2098 + $this->getPostsMetaDataBasedOnRecordId($termID, $module, $optionalType);
2099 + self::$export_instance->getWPMLData($termID, $optionalType, $module);
2100 + if (is_plugin_active('polylang/polylang.php') || is_plugin_active('polylang-pro/polylang.php') || is_plugin_active('polylang-wc/polylang-wc.php')) {
2101 + self::$export_instance->getPolylangData($termID, $optionalType, $module);
2098 2102 }
2099 - if(in_array('wordpress-seo/wp-seo.php', self::$export_instance->get_active_plugins())) {
2100 - $seo_yoast_taxonomies = get_option( 'wpseo_taxonomy_meta' );
2101 - if ( isset( $seo_yoast_taxonomies['post_tag'] ) ) {
2103 + if (in_array('wordpress-seo/wp-seo.php', self::$export_instance->get_active_plugins())) {
2104 + $seo_yoast_taxonomies = get_option('wpseo_taxonomy_meta');
2105 + if (isset($seo_yoast_taxonomies['post_tag'])) {
2102 2106
2103 - self::$export_instance->data[ $termID ]['title'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_title'];
2104 - self::$export_instance->data[ $termID ]['meta_desc'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_desc'];
2105 - self::$export_instance->data[ $termID ]['canonical'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_canonical'];
2106 - self::$export_instance->data[ $termID ]['bctitle'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_bctitle'];
2107 - self::$export_instance->data[ $termID ]['meta-robots-noindex'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_noindex'];
2108 - self::$export_instance->data[ $termID ]['sitemap-include'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_sitemap_include'];
2109 - self::$export_instance->data[ $termID ]['opengraph-title'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_opengraph-title'];
2110 - self::$export_instance->data[ $termID ]['opengraph-description'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_opengraph-description'];
2111 - self::$export_instance->data[ $termID ]['opengraph-image'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_opengraph-image'];
2112 - self::$export_instance->data[ $termID ]['twitter-title'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_twitter-title'];
2113 - self::$export_instance->data[ $termID ]['twitter-description'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_twitter-description'];
2114 - self::$export_instance->data[ $termID ]['twitter-image'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_twitter-image'];
2115 - self::$export_instance->data[ $termID ]['focus_keyword'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_focuskw'];
2107 + self::$export_instance->data[$termID]['title'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_title'];
2108 + self::$export_instance->data[$termID]['meta_desc'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_desc'];
2109 + self::$export_instance->data[$termID]['canonical'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_canonical'];
2110 + self::$export_instance->data[$termID]['bctitle'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_bctitle'];
2111 + self::$export_instance->data[$termID]['meta-robots-noindex'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_noindex'];
2112 + self::$export_instance->data[$termID]['sitemap-include'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_sitemap_include'];
2113 + self::$export_instance->data[$termID]['opengraph-title'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_opengraph-title'];
2114 + self::$export_instance->data[$termID]['opengraph-description'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_opengraph-description'];
2115 + self::$export_instance->data[$termID]['opengraph-image'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_opengraph-image'];
2116 + self::$export_instance->data[$termID]['twitter-title'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_twitter-title'];
2117 + self::$export_instance->data[$termID]['twitter-description'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_twitter-description'];
2118 + self::$export_instance->data[$termID]['twitter-image'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_twitter-image'];
2119 + self::$export_instance->data[$termID]['focus_keyword'] = $seo_yoast_taxonomies['post_tag'][$termID]['wpseo_focuskw'];
2116 2120
2117 2121 }
2118 2122 }
2119 2123 }
@@ -2119,12 +2123,44 @@
2119 2123 }
2120 2124 }
2121 2125
2122 2126 $result = self::$export_instance->finalDataToExport(self::$export_instance->data, $module);
2123 - if($mode == null)
2127 + if ($mode == null)
2124 2128 self::$export_instance->proceedExport($result);
2125 2129 else
2126 2130 return $result;
2131 + }
2132 +
2133 + /**
2134 + * Check if EDD 3.0+ is active (uses custom order tables)
2135 + *
2136 + * @return bool True if EDD 3.0+, false otherwise
2137 + */
2138 + private function is_edd_3_0_plus()
2139 + {
2140 + if (!class_exists('Easy_Digital_Downloads')) {
2141 + return false;
2142 + }
2143 +
2144 + // Check for EDD 3.0+ Order class
2145 + if (class_exists('\\EDD\\Orders\\Order')) {
2146 + return true;
2147 + }
2148 +
2149 + // Check for Order_Query class
2150 + if (class_exists('\\EDD\\Orders\\Order_Query')) {
2151 + return true;
2152 + }
2153 +
2154 + // Check version if function exists
2155 + if (function_exists('edd_get_version')) {
2156 + $version = edd_get_version();
2157 + if ($version && version_compare($version, '3.0', '>=')) {
2158 + return true;
2159 + }
2160 + }
2161 +
2162 + return false;
2127 2163 }
2128 2164 }
2129 2165
2130 2166 global $post_export_class;