PluginProbe ʕ •ᴥ•ʔ
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel / 1.3.6
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel v1.3.6
trunk 0.9.0 0.9.1 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0 1.2.1 1.2.10 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.14 1.4.15 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0
wp-all-export / src / App / Specification / IsImportAllowed.php
wp-all-export / src / App / Specification Last commit date
IsImportAllowed.php 7 years ago
IsImportAllowed.php
53 lines
1 <?php
2
3 namespace Wpae\App\Specification;
4
5
6 class IsImportAllowed
7 {
8 public function isSatisfied($item)
9 {
10 $is_re_import_allowed = true;
11 if ( ! empty($item['options']['ids']) )
12 {
13 if (in_array('shop_order', $item['options']['cpt']) and class_exists('WooCommerce')) {
14 $required_fields = array('woo_order' => 'id');
15 }
16 else {
17 $required_fields = array('id' => 'id');
18 }
19 // re-import products
20 if ((in_array('product', $item['options']['cpt']) or $item['options']['export_type'] == 'advanced') and class_exists('WooCommerce') and (empty($item['options']['wp_query_selector']) or $item['options']['wp_query_selector'] == 'wp_query')) {
21 $required_fields['woo'] = '_sku';
22 $required_fields['cats'] = 'product_type';
23 $required_fields['parent'] = 'parent';
24 }
25 if ((in_array('users', $item['options']['cpt']) or $item['options']['export_type'] == 'advanced') and (!empty($item['options']['wp_query_selector']) and $item['options']['wp_query_selector'] == 'wp_user_query')) {
26 $required_fields['user_email'] = 'user_email';
27 $required_fields['user_login'] = 'user_login';
28 }
29 if ($item['options']['export_type'] == 'advanced' and (empty($item['options']['wp_query_selector']) or $item['options']['wp_query_selector'] == 'wp_query')){
30 $required_fields['post_type'] = 'post_type';
31 }
32 $defined_fields = array();
33 foreach ($item['options']['ids'] as $ID => $value)
34 {
35 foreach ($required_fields as $type => $field)
36 {
37 if (strtolower($item['options']['cc_type'][$ID]) == $type && strtolower($item['options']['cc_label'][$ID]) == strtolower($field)){
38 $defined_fields[] = $field;
39 }
40 }
41 }
42
43 foreach ($required_fields as $type => $field) {
44 if ( ! in_array($field, $defined_fields) ){
45 $is_re_import_allowed = false;
46 break;
47 }
48 }
49 }
50
51 return $is_re_import_allowed;
52 }
53 }