PluginProbe ʕ •ᴥ•ʔ
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel / 1.2.2
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel v1.2.2
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 / libraries / XmlExportWooCommerceCoupon.php
wp-all-export / libraries Last commit date
VariableProductTitle 7 years ago .gitkeep 7 years ago WpaeInvalidPhpException.php 7 years ago WpaeInvalidStringException.php 7 years ago WpaeMethodNotFoundException.php 7 years ago WpaePhpInterpreterErrorHandler.php 7 years ago WpaeString.php 7 years ago WpaeTooMuchRecursionException.php 7 years ago WpaeXmlProcessor.php 7 years ago XmlCsvExport.php 7 years ago XmlExportACF.php 7 years ago XmlExportComment.php 7 years ago XmlExportCpt.php 7 years ago XmlExportEngine.php 7 years ago XmlExportFiltering.php 7 years ago XmlExportMediaGallery.php 7 years ago XmlExportTaxonomy.php 7 years ago XmlExportUser.php 7 years ago XmlExportWooCommerce.php 7 years ago XmlExportWooCommerceCoupon.php 7 years ago XmlExportWooCommerceOrder.php 7 years ago XmlGoogleMerchants.php 7 years ago XmlSpec.php 7 years ago
XmlExportWooCommerceCoupon.php
223 lines
1 <?php
2
3 if ( ! class_exists('XmlExportWooCommerceCoupon') )
4 {
5 final class XmlExportWooCommerceCoupon
6 {
7 public static $is_active = true;
8
9 public $init_fields = array(
10 array(
11 'name' => 'Coupon ID',
12 'type' => 'id',
13 'options' => '',
14 'label' => 'id'
15 ),
16 array(
17 'name' => 'Coupon Code',
18 'type' => 'title',
19 'options' => '',
20 'label' => 'title'
21 ),
22 array(
23 'name' => 'Expiry Date',
24 'type' => 'cf',
25 'options' => '',
26 'label' => 'expiry_date'
27 )
28 );
29
30 public $default_fields = array(
31 array(
32 'name' => 'Coupon ID',
33 'type' => 'id',
34 'label' => 'id'
35 ),
36 array(
37 'name' => 'Coupon Code',
38 'type' => 'title',
39 'label' => 'title'
40 ),
41 array(
42 'name' => 'Coupon Description',
43 'type' => 'excerpt',
44 'label' => 'excerpt'
45 ),
46 array(
47 'name' => 'Discount Type',
48 'type' => 'cf',
49 'label' => 'discount_type'
50 ),
51 array(
52 'name' => 'Coupon Amount',
53 'type' => 'cf',
54 'label' => 'coupon_amount'
55 ),
56 array(
57 'name' => 'Expiry Date',
58 'type' => 'cf',
59 'label' => 'expiry_date'
60 ),
61 array(
62 'name' => 'Free Shipping',
63 'type' => 'cf',
64 'label' => 'free_shipping'
65 ),
66 array(
67 'name' => 'Exclude Sale Items',
68 'type' => 'cf',
69 'label' => 'exclude_sale_items'
70 )
71 );
72
73 public $other_fields = array(
74 array(
75 'label' => 'status',
76 'name' => 'Status',
77 'type' => 'status'
78 ),
79 array(
80 'label' => 'author',
81 'name' => 'Author ID',
82 'type' => 'author'
83 ),
84
85 array(
86 'label' => 'author_username',
87 'name' => 'Author Username',
88 'type' => 'author'
89 ),
90
91 array(
92 'label' => 'author_email',
93 'name' => 'Author Email',
94 'type' => 'author'
95 ),
96
97 array(
98 'label' => 'author_first_name',
99 'name' => 'Author First Name',
100 'type' => 'author'
101 ),
102
103 array(
104 'label' => 'author_last_name',
105 'name' => 'Author Last Name',
106 'type' => 'author'
107 ),
108
109 array(
110 'label' => 'slug',
111 'name' => 'Slug',
112 'type' => 'slug'
113 ),
114 array(
115 'label' => 'date',
116 'name' => 'Date',
117 'type' => 'date'
118 ),
119 array(
120 'label' => 'post_type',
121 'name' => 'Post Type',
122 'type' => 'post_type'
123 )
124 );
125
126
127 private $_coupon_data = array();
128
129 public function __construct()
130 {
131 if ( ! class_exists('WooCommerce')
132 or ( XmlExportEngine::$exportOptions['export_type'] == 'specific' and ! in_array('shop_coupon', XmlExportEngine::$post_types) )
133 or ( XmlExportEngine::$exportOptions['export_type'] == 'advanced' and strpos(XmlExportEngine::$exportOptions['wp_query'], 'shop_coupon') === false ) ) {
134 self::$is_active = false;
135 return;
136 }
137
138 self::$is_active = true;
139
140 $this->_coupon_data = array(
141 'discount_type', 'coupon_amount', 'expiry_date', 'free_shipping', 'exclude_sale_items'
142 );
143
144 add_filter("wp_all_export_default_fields", array( &$this, "filter_default_fields"), 10, 1);
145 add_filter("wp_all_export_other_fields", array( &$this, "filter_other_fields"), 10, 1);
146 add_filter("wp_all_export_available_data", array( &$this, "filter_available_data"), 10, 1);
147 add_filter("wp_all_export_available_sections", array( &$this, "filter_available_sections" ), 10, 1);
148 add_filter("wp_all_export_init_fields", array( &$this, "filter_init_fields"), 10, 1);
149
150 }
151
152 // [FILTERS]
153
154 /**
155 *
156 * Filter Init Fields
157 *
158 */
159 public function filter_init_fields($init_fields){
160 return $this->init_fields;
161 }
162
163 /**
164 *
165 * Filter Default Fields
166 *
167 */
168 public function filter_default_fields($default_fields){
169 return $this->default_fields;
170 }
171
172 /**
173 *
174 * Filter Other Fields
175 *
176 */
177 public function filter_other_fields($other_fields){
178 return $this->other_fields;
179 }
180
181 /**
182 *
183 * Filter Available Data
184 *
185 */
186 public function filter_available_data($available_data){
187
188 $available_data['existing_meta_keys'] = array_merge($available_data['other_fields'], $available_data['existing_meta_keys']);
189
190 return $available_data;
191 }
192
193 /**
194 *
195 * Filter Sections in Available Data
196 *
197 */
198 public function filter_available_sections($sections){
199 unset($sections['media']);
200 unset($sections['other']);
201 $sections['cf']['title'] = __("Other", "wp_all_export_plugin");
202 return $sections;
203 }
204
205 // [\FILTERS]
206
207 public function init( & $existing_meta_keys = array() ){
208
209 if ( ! self::$is_active ) return;
210
211 if ( ! empty($existing_meta_keys) )
212 {
213 foreach ($existing_meta_keys as $key => $record_meta_key)
214 {
215 if ( in_array($record_meta_key, $this->_coupon_data) )
216 {
217 unset($existing_meta_keys[$key]);
218 }
219 }
220 }
221 }
222 }
223 }