Passed
Push — master ( 72af12...8565ec )
by Brian
11:19
created
includes/libraries/wp-all-import/rapid-addon.php 1 patch
Indentation   +802 added lines, -802 removed lines patch added patch discarded remove patch
@@ -10,232 +10,232 @@  discard block
 block discarded – undo
10 10
 
11 11
 if (!class_exists('RapidAddon')) {
12 12
 	
13
-	class RapidAddon {
14
-
15
-		public $name;
16
-		public $slug;
17
-		public $fields;
18
-		public $options = array();
19
-		public $accordions = array();
20
-		public $image_sections = array();
21
-		public $import_function;
22
-		public $post_saved_function;
23
-		public $notice_text;
24
-		public $logger = null;
25
-		public $when_to_run = false;
26
-		public $image_options = array(
27
-			'download_images' => 'yes', 
28
-			'download_featured_delim' => ',', 
29
-			'download_featured_image' => '',
30
-			'gallery_featured_image' => '',
31
-			'gallery_featured_delim' => ',',
32
-			'featured_image' => '',
33
-			'featured_delim' => ',', 
34
-			'search_existing_images' => 1,
35
-			'is_featured' => 0,
36
-			'create_draft' => 'no',
37
-			'set_image_meta_title' => 0,
38
-			'image_meta_title_delim' => ',',
39
-			'image_meta_title' => '',
40
-			'set_image_meta_caption' => 0,
41
-			'image_meta_caption_delim' => ',',
42
-			'image_meta_caption' => '',
43
-			'set_image_meta_alt' => 0,
44
-			'image_meta_alt_delim' => ',',
45
-			'image_meta_alt' => '',
46
-			'set_image_meta_description' => 0,
47
-			'image_meta_description_delim' => ',',
48
-			'image_meta_description_delim_logic' => 'separate',
49
-			'image_meta_description' => '',
50
-			'auto_rename_images' => 0,
51
-			'auto_rename_images_suffix' => '',
52
-			'auto_set_extension' => 0,
53
-			'new_extension' => '',
54
-			'do_not_remove_images' => 1,
13
+    class RapidAddon {
14
+
15
+        public $name;
16
+        public $slug;
17
+        public $fields;
18
+        public $options = array();
19
+        public $accordions = array();
20
+        public $image_sections = array();
21
+        public $import_function;
22
+        public $post_saved_function;
23
+        public $notice_text;
24
+        public $logger = null;
25
+        public $when_to_run = false;
26
+        public $image_options = array(
27
+            'download_images' => 'yes', 
28
+            'download_featured_delim' => ',', 
29
+            'download_featured_image' => '',
30
+            'gallery_featured_image' => '',
31
+            'gallery_featured_delim' => ',',
32
+            'featured_image' => '',
33
+            'featured_delim' => ',', 
34
+            'search_existing_images' => 1,
35
+            'is_featured' => 0,
36
+            'create_draft' => 'no',
37
+            'set_image_meta_title' => 0,
38
+            'image_meta_title_delim' => ',',
39
+            'image_meta_title' => '',
40
+            'set_image_meta_caption' => 0,
41
+            'image_meta_caption_delim' => ',',
42
+            'image_meta_caption' => '',
43
+            'set_image_meta_alt' => 0,
44
+            'image_meta_alt_delim' => ',',
45
+            'image_meta_alt' => '',
46
+            'set_image_meta_description' => 0,
47
+            'image_meta_description_delim' => ',',
48
+            'image_meta_description_delim_logic' => 'separate',
49
+            'image_meta_description' => '',
50
+            'auto_rename_images' => 0,
51
+            'auto_rename_images_suffix' => '',
52
+            'auto_set_extension' => 0,
53
+            'new_extension' => '',
54
+            'do_not_remove_images' => 1,
55 55
             'search_existing_images_logic' => 'by_url'
56
-		);
56
+        );
57 57
 
58
-		protected $isWizard = true;
58
+        protected $isWizard = true;
59 59
 
60
-		function __construct($name, $slug) {
61
-			$this->name = $name;
62
-			$this->slug = $slug;
63
-			if (!empty($_GET['id'])){
64
-				$this->isWizard = false;
65
-			}
60
+        function __construct($name, $slug) {
61
+            $this->name = $name;
62
+            $this->slug = $slug;
63
+            if (!empty($_GET['id'])){
64
+                $this->isWizard = false;
65
+            }
66 66
         }
67 67
         
68
-		function set_import_function($name) {
69
-			$this->import_function = $name;
70
-		}
68
+        function set_import_function($name) {
69
+            $this->import_function = $name;
70
+        }
71 71
 
72
-		function set_post_saved_function($name) {
73
-			$this->post_saved_function = $name;
74
-		}
72
+        function set_post_saved_function($name) {
73
+            $this->post_saved_function = $name;
74
+        }
75 75
 
76
-		function is_active_addon($post_type = null) {
76
+        function is_active_addon($post_type = null) {
77 77
 			
78
-			if ( ! class_exists( 'PMXI_Plugin' ) ) {
79
-				return false;
80
-			}
78
+            if ( ! class_exists( 'PMXI_Plugin' ) ) {
79
+                return false;
80
+            }
81 81
 
82
-			$addon_active = false;
82
+            $addon_active = false;
83 83
 
84
-			if ($post_type !== null) {
85
-				if (@in_array($post_type, $this->active_post_types) or empty($this->active_post_types)) {
86
-					$addon_active = true;
87
-				}
88
-			}
84
+            if ($post_type !== null) {
85
+                if (@in_array($post_type, $this->active_post_types) or empty($this->active_post_types)) {
86
+                    $addon_active = true;
87
+                }
88
+            }
89 89
 
90
-			if ($addon_active){
90
+            if ($addon_active){
91 91
 				
92
-				$current_theme = wp_get_theme();
92
+                $current_theme = wp_get_theme();
93 93
 
94
-				$parent_theme = $current_theme->parent();				
94
+                $parent_theme = $current_theme->parent();				
95 95
 
96
-				$theme_name = $current_theme->get('Name');
96
+                $theme_name = $current_theme->get('Name');
97 97
 				
98
-				$addon_active = (@in_array($theme_name, $this->active_themes) or empty($this->active_themes)) ? true : false;
98
+                $addon_active = (@in_array($theme_name, $this->active_themes) or empty($this->active_themes)) ? true : false;
99 99
 
100
-				if ( ! $addon_active and $parent_theme ){
101
-					$parent_theme_name = $parent_theme->get('Name');
102
-					$addon_active = (@in_array($parent_theme_name, $this->active_themes) or empty($this->active_themes)) ? true : false;
100
+                if ( ! $addon_active and $parent_theme ){
101
+                    $parent_theme_name = $parent_theme->get('Name');
102
+                    $addon_active = (@in_array($parent_theme_name, $this->active_themes) or empty($this->active_themes)) ? true : false;
103 103
 
104
-				}
104
+                }
105 105
 				
106
-				if ( $addon_active and ! empty($this->active_plugins) ){
106
+                if ( $addon_active and ! empty($this->active_plugins) ){
107 107
 
108
-					include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
108
+                    include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
109 109
 
110
-					foreach ($this->active_plugins as $plugin) {
111
-						if ( ! is_plugin_active($plugin) ) {
112
-							$addon_active = false;
113
-							break;
114
-						}
115
-					}					
116
-				}
110
+                    foreach ($this->active_plugins as $plugin) {
111
+                        if ( ! is_plugin_active($plugin) ) {
112
+                            $addon_active = false;
113
+                            break;
114
+                        }
115
+                    }					
116
+                }
117 117
 
118
-			}
118
+            }
119 119
 
120
-			if ($this->when_to_run == "always") {
121
-				$addon_active = true;
122
-			}
120
+            if ($this->when_to_run == "always") {
121
+                $addon_active = true;
122
+            }
123 123
 
124
-			return apply_filters('rapid_is_active_add_on', $addon_active, $post_type, $this->slug);
125
-		}
124
+            return apply_filters('rapid_is_active_add_on', $addon_active, $post_type, $this->slug);
125
+        }
126 126
 		
127
-		/**
128
-		* 
129
-		* Add-On Initialization
130
-		*
131
-		* @param array $conditions - list of supported themes and post types
132
-		*
133
-		*/
134
-		function run($conditions = array()) {
135
-
136
-			if (empty($conditions)) {
137
-				$this->when_to_run = "always";
138
-			}
127
+        /**
128
+         * 
129
+         * Add-On Initialization
130
+         *
131
+         * @param array $conditions - list of supported themes and post types
132
+         *
133
+         */
134
+        function run($conditions = array()) {
135
+
136
+            if (empty($conditions)) {
137
+                $this->when_to_run = "always";
138
+            }
139 139
 
140
-			@$this->active_post_types = ( ! empty($conditions['post_types'])) ? $conditions['post_types'] : array();
141
-			@$this->active_themes = ( ! empty($conditions['themes'])) ? $conditions['themes'] : array();
142
-			@$this->active_plugins = ( ! empty($conditions['plugins'])) ? $conditions['plugins'] : array();			
140
+            @$this->active_post_types = ( ! empty($conditions['post_types'])) ? $conditions['post_types'] : array();
141
+            @$this->active_themes = ( ! empty($conditions['themes'])) ? $conditions['themes'] : array();
142
+            @$this->active_plugins = ( ! empty($conditions['plugins'])) ? $conditions['plugins'] : array();			
143 143
 
144
-			add_filter('pmxi_addons', array($this, 'wpai_api_register'));
145
-			add_filter('wp_all_import_addon_parse', array($this, 'wpai_api_parse'));
146
-			add_filter('wp_all_import_addon_import', array($this, 'wpai_api_import'));
147
-			add_filter('wp_all_import_addon_saved_post', array($this, 'wpai_api_post_saved'));
148
-			add_filter('pmxi_options_options', array($this, 'wpai_api_options'));
144
+            add_filter('pmxi_addons', array($this, 'wpai_api_register'));
145
+            add_filter('wp_all_import_addon_parse', array($this, 'wpai_api_parse'));
146
+            add_filter('wp_all_import_addon_import', array($this, 'wpai_api_import'));
147
+            add_filter('wp_all_import_addon_saved_post', array($this, 'wpai_api_post_saved'));
148
+            add_filter('pmxi_options_options', array($this, 'wpai_api_options'));
149 149
             add_filter('wp_all_import_image_sections', array($this, 'additional_sections'), 10, 1);
150 150
             add_filter('pmxi_custom_types', array($this, 'filter_post_types'), 10, 2);
151 151
             add_filter('pmxi_post_list_order', array($this,'sort_post_types'), 10, 1);
152 152
             add_filter('wp_all_import_post_type_image', array($this, 'post_type_image'), 10, 1 );
153
-			add_action('pmxi_extend_options_featured',  array($this, 'wpai_api_metabox'), 10, 2);
153
+            add_action('pmxi_extend_options_featured',  array($this, 'wpai_api_metabox'), 10, 2);
154 154
             add_action('admin_init', array($this, 'admin_notice_ignore'));
155 155
         }        
156 156
 
157
-		function parse($data) {
157
+        function parse($data) {
158 158
 			
159
-			if ( ! $this->is_active_addon($data['import']->options['custom_type'])) return false;
159
+            if ( ! $this->is_active_addon($data['import']->options['custom_type'])) return false;
160 160
 
161
-			$parsedData = $this->helper_parse($data, $this->options_array());
162
-			return $parsedData;
161
+            $parsedData = $this->helper_parse($data, $this->options_array());
162
+            return $parsedData;
163 163
 
164
-		}
164
+        }
165 165
 
166 166
 
167
-		function add_field($field_slug, $field_name, $field_type, $enum_values = null, $tooltip = "", $is_html = true, $default_text = '') {
167
+        function add_field($field_slug, $field_name, $field_type, $enum_values = null, $tooltip = "", $is_html = true, $default_text = '') {
168 168
 
169
-			$field =  array("name" => $field_name, "type" => $field_type, "enum_values" => $enum_values, "tooltip" => $tooltip, "is_sub_field" => false, "is_main_field" => false, "slug" => $field_slug, "is_html" => $is_html, 'default_text' => $default_text);
169
+            $field =  array("name" => $field_name, "type" => $field_type, "enum_values" => $enum_values, "tooltip" => $tooltip, "is_sub_field" => false, "is_main_field" => false, "slug" => $field_slug, "is_html" => $is_html, 'default_text' => $default_text);
170 170
 
171
-			$this->fields[$field_slug] = $field;
171
+            $this->fields[$field_slug] = $field;
172 172
 
173
-			if ( ! empty($enum_values) ){
174
-				foreach ($enum_values as $key => $value) {
175
-					if (is_array($value))
176
-					{
177
-						if ($field['type'] == 'accordion')
178
-						{
179
-							$this->fields[$value['slug']]['is_sub_field'] = true;
180
-						}
181
-						else
182
-						{
183
-							foreach ($value as $n => $param) {							
184
-								if (is_array($param) and ! empty($this->fields[$param['slug']])){
185
-									$this->fields[$param['slug']]['is_sub_field'] = true;								
186
-								}
187
-							}
188
-						}
189
-					}
190
-				}
191
-			}
173
+            if ( ! empty($enum_values) ){
174
+                foreach ($enum_values as $key => $value) {
175
+                    if (is_array($value))
176
+                    {
177
+                        if ($field['type'] == 'accordion')
178
+                        {
179
+                            $this->fields[$value['slug']]['is_sub_field'] = true;
180
+                        }
181
+                        else
182
+                        {
183
+                            foreach ($value as $n => $param) {							
184
+                                if (is_array($param) and ! empty($this->fields[$param['slug']])){
185
+                                    $this->fields[$param['slug']]['is_sub_field'] = true;								
186
+                                }
187
+                            }
188
+                        }
189
+                    }
190
+                }
191
+            }
192 192
 
193
-			return $field;
193
+            return $field;
194 194
 
195
-		}
195
+        }
196 196
 
197
-		function add_acf_field($field){
198
-			$this->fields[$field->post_name] = array(
199
-				'type' => 'acf',
200
-				'field_obj' => $field
201
-			);
202
-		}
197
+        function add_acf_field($field){
198
+            $this->fields[$field->post_name] = array(
199
+                'type' => 'acf',
200
+                'field_obj' => $field
201
+            );
202
+        }
203 203
 
204
-		private $acfGroups = array();
204
+        private $acfGroups = array();
205 205
 
206
-		function use_acf_group($acf_group){
207
-			$this->add_text(
208
-				'<div class="postbox acf_postbox default acf_signle_group rad4">
206
+        function use_acf_group($acf_group){
207
+            $this->add_text(
208
+                '<div class="postbox acf_postbox default acf_signle_group rad4">
209 209
     <h3 class="hndle" style="margin-top:0;"><span>'.$acf_group['title'].'</span></h3>
210 210
 	    <div class="inside">');
211
-			$acf_fields = get_posts(array('posts_per_page' => -1, 'post_type' => 'acf-field', 'post_parent' => $acf_group['ID'], 'post_status' => 'publish', 'orderby' => 'menu_order', 'order' => 'ASC'));
212
-			if (!empty($acf_fields)){
213
-				foreach ($acf_fields as $field) {
214
-					$this->add_acf_field($field);
215
-				}
216
-			}
217
-			$this->add_text('</div></div>');
218
-			$this->acfGroups[] = $acf_group['ID'];
219
-			add_filter('wp_all_import_acf_is_show_group', array($this, 'acf_is_show_group'), 10, 2);
220
-		}
221
-
222
-		function acf_is_show_group($is_show, $acf_group){
223
-			return (in_array($acf_group['ID'], $this->acfGroups)) ? false : true;
224
-		}
225
-
226
-		/**
227
-		* 
228
-		* Add an option to WP All Import options list
229
-		*
230
-		* @param string $slug - option name
231
-		* @param string $default_value - default option value
232
-		*
233
-		*/
234
-		function add_option($slug, $default_value = ''){
235
-			$this->options[$slug] = $default_value;
236
-		}
211
+            $acf_fields = get_posts(array('posts_per_page' => -1, 'post_type' => 'acf-field', 'post_parent' => $acf_group['ID'], 'post_status' => 'publish', 'orderby' => 'menu_order', 'order' => 'ASC'));
212
+            if (!empty($acf_fields)){
213
+                foreach ($acf_fields as $field) {
214
+                    $this->add_acf_field($field);
215
+                }
216
+            }
217
+            $this->add_text('</div></div>');
218
+            $this->acfGroups[] = $acf_group['ID'];
219
+            add_filter('wp_all_import_acf_is_show_group', array($this, 'acf_is_show_group'), 10, 2);
220
+        }
237 221
 
238
-		function options_array() {
222
+        function acf_is_show_group($is_show, $acf_group){
223
+            return (in_array($acf_group['ID'], $this->acfGroups)) ? false : true;
224
+        }
225
+
226
+        /**
227
+         * 
228
+         * Add an option to WP All Import options list
229
+         *
230
+         * @param string $slug - option name
231
+         * @param string $default_value - default option value
232
+         *
233
+         */
234
+        function add_option($slug, $default_value = ''){
235
+            $this->options[$slug] = $default_value;
236
+        }
237
+
238
+        function options_array() {
239 239
 
240 240
             $options_list = array();
241 241
             
@@ -255,528 +255,528 @@  discard block
 block discarded – undo
255 255
 
256 256
             }			
257 257
 
258
-			if ( ! empty($this->options) ){
259
-				foreach ($this->options as $slug => $value) {
260
-					$options_arr[$slug] = $value;
261
-				}
262
-			}
258
+            if ( ! empty($this->options) ){
259
+                foreach ($this->options as $slug => $value) {
260
+                    $options_arr[$slug] = $value;
261
+                }
262
+            }
263 263
 
264
-			$options_arr[$this->slug]   = $options_list;
265
-			$options_arr['rapid_addon'] = plugin_basename( __FILE__ );
264
+            $options_arr[$this->slug]   = $options_list;
265
+            $options_arr['rapid_addon'] = plugin_basename( __FILE__ );
266 266
 
267
-			return $options_arr;
267
+            return $options_arr;
268 268
 
269
-		}
269
+        }
270 270
 
271
-		function wpai_api_options($all_options) {
271
+        function wpai_api_options($all_options) {
272 272
 
273
-			$all_options = $all_options + $this->options_array();
273
+            $all_options = $all_options + $this->options_array();
274 274
 
275
-			return $all_options;
275
+            return $all_options;
276 276
 
277
-		}
277
+        }
278 278
 
279 279
 
280
-		function wpai_api_register($addons) {
280
+        function wpai_api_register($addons) {
281 281
 
282
-			if (empty($addons[$this->slug])) {
283
-				$addons[$this->slug] = 1;
284
-			}
282
+            if (empty($addons[$this->slug])) {
283
+                $addons[$this->slug] = 1;
284
+            }
285 285
 
286
-			return $addons;
286
+            return $addons;
287 287
 
288
-		}
288
+        }
289 289
 
290 290
 
291
-		function wpai_api_parse($functions) {
291
+        function wpai_api_parse($functions) {
292 292
 
293
-			$functions[$this->slug] = array($this, 'parse');
294
-			return $functions;
293
+            $functions[$this->slug] = array($this, 'parse');
294
+            return $functions;
295 295
 
296
-		}
296
+        }
297 297
 
298
-		function wpai_api_post_saved($functions){
299
-			$functions[$this->slug] = array($this, 'post_saved');
300
-			return $functions;
301
-		}
298
+        function wpai_api_post_saved($functions){
299
+            $functions[$this->slug] = array($this, 'post_saved');
300
+            return $functions;
301
+        }
302 302
 
303 303
 
304
-		function wpai_api_import($functions) {
304
+        function wpai_api_import($functions) {
305 305
 
306
-			$functions[$this->slug] = array($this, 'import');
307
-			return $functions;
306
+            $functions[$this->slug] = array($this, 'import');
307
+            return $functions;
308 308
 
309
-		}
309
+        }
310 310
 
311
-		function post_saved( $importData ){
311
+        function post_saved( $importData ){
312 312
 
313
-			if (is_callable($this->post_saved_function))
314
-				call_user_func($this->post_saved_function, $importData['pid'], $importData['import'], $importData['logger']);
313
+            if (is_callable($this->post_saved_function))
314
+                call_user_func($this->post_saved_function, $importData['pid'], $importData['import'], $importData['logger']);
315 315
 			
316
-		}
316
+        }
317 317
 
318
-		function import($importData, $parsedData) {
318
+        function import($importData, $parsedData) {
319 319
 
320
-			if (!$this->is_active_addon($importData['post_type'])) {
321
-				return;
322
-			}
320
+            if (!$this->is_active_addon($importData['post_type'])) {
321
+                return;
322
+            }
323 323
 
324
-			$import_options = $importData['import']['options'][$this->slug];
324
+            $import_options = $importData['import']['options'][$this->slug];
325 325
 
326
-	//		echo "<pre>";
327
-	//		print_r($import_options);
328
-	//		echo "</pre>";
326
+    //		echo "<pre>";
327
+    //		print_r($import_options);
328
+    //		echo "</pre>";
329 329
 
330
-			if ( ! empty($parsedData) )	{
330
+            if ( ! empty($parsedData) )	{
331 331
 
332
-				$this->logger = $importData['logger'];
332
+                $this->logger = $importData['logger'];
333 333
 
334
-				$post_id = $importData['pid'];
335
-				$index = $importData['i'];
336
-				$data = array();
337
-				if (!empty($this->fields)){
338
-					foreach ($this->fields as $field_slug => $field_params) {
339
-						if (in_array($field_params['type'], array('title', 'plain_text'))) continue;
340
-						switch ($field_params['type']) {
334
+                $post_id = $importData['pid'];
335
+                $index = $importData['i'];
336
+                $data = array();
337
+                if (!empty($this->fields)){
338
+                    foreach ($this->fields as $field_slug => $field_params) {
339
+                        if (in_array($field_params['type'], array('title', 'plain_text'))) continue;
340
+                        switch ($field_params['type']) {
341 341
 
342
-							case 'image':
342
+                            case 'image':
343 343
 								
344
-								// import the specified image, then set the value of the field to the image ID in the media library
344
+                                // import the specified image, then set the value of the field to the image ID in the media library
345 345
 
346
-								$image_url_or_path = $parsedData[$field_slug][$index];
346
+                                $image_url_or_path = $parsedData[$field_slug][$index];
347 347
 
348
-								if ( ! array_key_exists( $field_slug, $import_options['download_image'] ) ) {
349
-									continue 2;
350
-								}
348
+                                if ( ! array_key_exists( $field_slug, $import_options['download_image'] ) ) {
349
+                                    continue 2;
350
+                                }
351 351
 
352
-								$download = $import_options['download_image'][$field_slug];
352
+                                $download = $import_options['download_image'][$field_slug];
353 353
 
354
-								$uploaded_image = PMXI_API::upload_image($post_id, $image_url_or_path, $download, $importData['logger'], true, "", "images", true, $importData['articleData']);
354
+                                $uploaded_image = PMXI_API::upload_image($post_id, $image_url_or_path, $download, $importData['logger'], true, "", "images", true, $importData['articleData']);
355 355
 
356
-								$data[$field_slug] = array(
357
-									"attachment_id" => $uploaded_image,
358
-									"image_url_or_path" => $image_url_or_path,
359
-									"download" => $download
360
-								);
356
+                                $data[$field_slug] = array(
357
+                                    "attachment_id" => $uploaded_image,
358
+                                    "image_url_or_path" => $image_url_or_path,
359
+                                    "download" => $download
360
+                                );
361 361
 
362
-								break;
362
+                                break;
363 363
 
364
-							case 'file':
364
+                            case 'file':
365 365
 
366
-								$image_url_or_path = $parsedData[$field_slug][$index];
366
+                                $image_url_or_path = $parsedData[$field_slug][$index];
367 367
 
368
-								if ( ! array_key_exists( $field_slug, $import_options['download_image'] ) ) {
369
-									continue 2;
370
-								}
368
+                                if ( ! array_key_exists( $field_slug, $import_options['download_image'] ) ) {
369
+                                    continue 2;
370
+                                }
371 371
 
372
-								$download = $import_options['download_image'][$field_slug];
372
+                                $download = $import_options['download_image'][$field_slug];
373 373
 
374
-								$uploaded_file = PMXI_API::upload_image($post_id, $image_url_or_path, $download, $importData['logger'], true, "", "files", true, $importData['articleData']);
374
+                                $uploaded_file = PMXI_API::upload_image($post_id, $image_url_or_path, $download, $importData['logger'], true, "", "files", true, $importData['articleData']);
375 375
 
376
-								$data[$field_slug] = array(
377
-									"attachment_id" => $uploaded_file,
378
-									"image_url_or_path" => $image_url_or_path,
379
-									"download" => $download
380
-								);
376
+                                $data[$field_slug] = array(
377
+                                    "attachment_id" => $uploaded_file,
378
+                                    "image_url_or_path" => $image_url_or_path,
379
+                                    "download" => $download
380
+                                );
381 381
 
382
-								break;
382
+                                break;
383 383
 							
384
-							default:
385
-								// set the field data to the value of the field after it's been parsed
386
-								$data[$field_slug] = $parsedData[$field_slug][$index];
387
-								break;
388
-						}					
384
+                            default:
385
+                                // set the field data to the value of the field after it's been parsed
386
+                                $data[$field_slug] = $parsedData[$field_slug][$index];
387
+                                break;
388
+                        }					
389
+
390
+                        // apply mapping rules if they exist
391
+                        if (!empty($import_options['mapping'][$field_slug])) {
392
+                            $mapping_rules = json_decode($import_options['mapping'][$field_slug], true);
393
+
394
+                            if (!empty($mapping_rules) and is_array($mapping_rules)) {
395
+                                foreach ($mapping_rules as $rule_number => $map_to) {
396
+                                    if (isset($map_to[trim($data[$field_slug])])){
397
+                                        $data[$field_slug] = trim($map_to[trim($data[$field_slug])]);
398
+                                        break;
399
+                                    }
400
+                                }
401
+                            }
402
+                        }
403
+                        // --------------------
404
+                    }
405
+                }				
389 406
 
390
-						// apply mapping rules if they exist
391
-						if (!empty($import_options['mapping'][$field_slug])) {
392
-							$mapping_rules = json_decode($import_options['mapping'][$field_slug], true);
407
+                call_user_func($this->import_function, $post_id, $data, $importData['import'], $importData['articleData'], $importData['logger']);
408
+            }
393 409
 
394
-							if (!empty($mapping_rules) and is_array($mapping_rules)) {
395
-								foreach ($mapping_rules as $rule_number => $map_to) {
396
-									if (isset($map_to[trim($data[$field_slug])])){
397
-										$data[$field_slug] = trim($map_to[trim($data[$field_slug])]);
398
-										break;
399
-									}
400
-								}
401
-							}
402
-						}
403
-						// --------------------
404
-					}
405
-				}				
410
+        }
406 411
 
407
-				call_user_func($this->import_function, $post_id, $data, $importData['import'], $importData['articleData'], $importData['logger']);
408
-			}
409 412
 
410
-		}
413
+        function wpai_api_metabox($post_type, $current_values) {
411 414
 
415
+            if (!$this->is_active_addon($post_type)) {
416
+                return;
417
+            }
412 418
 
413
-		function wpai_api_metabox($post_type, $current_values) {
419
+            echo $this->helper_metabox_top($this->name);
414 420
 
415
-			if (!$this->is_active_addon($post_type)) {
416
-				return;
417
-			}
421
+            $visible_fields = 0;
418 422
 
419
-			echo $this->helper_metabox_top($this->name);
423
+            foreach ($this->fields as $field_slug => $field_params) {
424
+                if ($field_params['is_sub_field']) continue;
425
+                $visible_fields++;
426
+            }
420 427
 
421
-			$visible_fields = 0;
428
+            $counter = 0;
422 429
 
423
-			foreach ($this->fields as $field_slug => $field_params) {
424
-				if ($field_params['is_sub_field']) continue;
425
-				$visible_fields++;
426
-			}
430
+            foreach ($this->fields as $field_slug => $field_params) {				
427 431
 
428
-			$counter = 0;
432
+                // do not render sub fields
433
+                if ($field_params['is_sub_field']) continue;		
429 434
 
430
-			foreach ($this->fields as $field_slug => $field_params) {				
435
+                $counter++;		
431 436
 
432
-				// do not render sub fields
433
-				if ($field_params['is_sub_field']) continue;		
437
+                $this->render_field($field_params, $field_slug, $current_values, $visible_fields == $counter);										
434 438
 
435
-				$counter++;		
439
+                //if ( $field_params['type'] != 'accordion' ) echo "<br />";				
436 440
 
437
-				$this->render_field($field_params, $field_slug, $current_values, $visible_fields == $counter);										
441
+            }
438 442
 
439
-				//if ( $field_params['type'] != 'accordion' ) echo "<br />";				
443
+            echo $this->helper_metabox_bottom();
444
+
445
+            if ( ! empty($this->image_sections) ){				
446
+                $is_images_section_enabled = apply_filters('wp_all_import_is_images_section_enabled', true, $post_type);						
447
+                foreach ($this->image_sections as $k => $section) {
448
+                    $section_options = array();
449
+                    foreach ($this->image_options as $slug => $value) {
450
+                        $section_options[$section['slug'] . $slug] = $value;
451
+                    }										
452
+                    if ( ! $is_images_section_enabled and ! $k ){
453
+                        $section_options[$section['slug'] . 'is_featured'] = 1;
454
+                    }
455
+                    PMXI_API::add_additional_images_section($section['title'], $section['slug'], $current_values, '', true, false, $section['type']);
456
+                }
457
+            }
440 458
 
441
-			}
459
+        }		
442 460
 
443
-			echo $this->helper_metabox_bottom();
461
+        function render_field($field_params, $field_slug, $current_values, $in_the_bottom = false){
444 462
 
445
-			if ( ! empty($this->image_sections) ){				
446
-				$is_images_section_enabled = apply_filters('wp_all_import_is_images_section_enabled', true, $post_type);						
447
-				foreach ($this->image_sections as $k => $section) {
448
-					$section_options = array();
449
-					foreach ($this->image_options as $slug => $value) {
450
-						$section_options[$section['slug'] . $slug] = $value;
451
-					}										
452
-					if ( ! $is_images_section_enabled and ! $k ){
453
-						$section_options[$section['slug'] . 'is_featured'] = 1;
454
-					}
455
-					PMXI_API::add_additional_images_section($section['title'], $section['slug'], $current_values, '', true, false, $section['type']);
456
-				}
457
-			}
458
-
459
-		}		
460
-
461
-		function render_field($field_params, $field_slug, $current_values, $in_the_bottom = false){
462
-
463
-			if (!isset($current_values[$this->slug][$field_slug])) {
464
-				$current_values[$this->slug][$field_slug] = isset($field_params['default_text']) ? $field_params['default_text'] : '';
465
-			}
466
-
467
-			if ($field_params['type'] == 'text') {
468
-
469
-				PMXI_API::add_field(
470
-					'simple',
471
-					$field_params['name'],
472
-					array(
473
-						'tooltip' => $field_params['tooltip'],
474
-						'field_name' => $this->slug."[".$field_slug."]",
475
-						'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug]
476
-					)
477
-				);
478
-
479
-			} else if ($field_params['type'] == 'textarea') {
480
-
481
-				PMXI_API::add_field(
482
-					'textarea',
483
-					$field_params['name'],
484
-					array(
485
-						'tooltip' => $field_params['tooltip'],
486
-						'field_name' => $this->slug."[".$field_slug."]",
487
-						'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug]
488
-					)
489
-				);
490
-
491
-			} else if ($field_params['type'] == 'wp_editor') {
492
-
493
-				PMXI_API::add_field(
494
-					'wp_editor',
495
-					$field_params['name'],
496
-					array(
497
-						'tooltip' => $field_params['tooltip'],
498
-						'field_name' => $this->slug."[".$field_slug."]",
499
-						'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug]
500
-					)
501
-				);
502
-
503
-			} else if ($field_params['type'] == 'image' or $field_params['type'] == 'file') {
463
+            if (!isset($current_values[$this->slug][$field_slug])) {
464
+                $current_values[$this->slug][$field_slug] = isset($field_params['default_text']) ? $field_params['default_text'] : '';
465
+            }
466
+
467
+            if ($field_params['type'] == 'text') {
468
+
469
+                PMXI_API::add_field(
470
+                    'simple',
471
+                    $field_params['name'],
472
+                    array(
473
+                        'tooltip' => $field_params['tooltip'],
474
+                        'field_name' => $this->slug."[".$field_slug."]",
475
+                        'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug]
476
+                    )
477
+                );
478
+
479
+            } else if ($field_params['type'] == 'textarea') {
480
+
481
+                PMXI_API::add_field(
482
+                    'textarea',
483
+                    $field_params['name'],
484
+                    array(
485
+                        'tooltip' => $field_params['tooltip'],
486
+                        'field_name' => $this->slug."[".$field_slug."]",
487
+                        'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug]
488
+                    )
489
+                );
490
+
491
+            } else if ($field_params['type'] == 'wp_editor') {
492
+
493
+                PMXI_API::add_field(
494
+                    'wp_editor',
495
+                    $field_params['name'],
496
+                    array(
497
+                        'tooltip' => $field_params['tooltip'],
498
+                        'field_name' => $this->slug."[".$field_slug."]",
499
+                        'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug]
500
+                    )
501
+                );
502
+
503
+            } else if ($field_params['type'] == 'image' or $field_params['type'] == 'file') {
504 504
 				
505
-				if (!isset($current_values[$this->slug]['download_image'][$field_slug])) { $current_values[$this->slug]['download_image'][$field_slug] = ''; }
506
-
507
-				PMXI_API::add_field(
508
-					$field_params['type'],
509
-					$field_params['name'],
510
-					array(
511
-						'tooltip' => $field_params['tooltip'],
512
-						'field_name' => $this->slug."[".$field_slug."]",
513
-						'field_value' => $current_values[$this->slug][$field_slug],
514
-						'download_image' => $current_values[$this->slug]['download_image'][$field_slug],
515
-						'field_key' => $field_slug,
516
-						'addon_prefix' => $this->slug
517
-
518
-					)
519
-				);
520
-
521
-			} else if ($field_params['type'] == 'radio') {					
505
+                if (!isset($current_values[$this->slug]['download_image'][$field_slug])) { $current_values[$this->slug]['download_image'][$field_slug] = ''; }
506
+
507
+                PMXI_API::add_field(
508
+                    $field_params['type'],
509
+                    $field_params['name'],
510
+                    array(
511
+                        'tooltip' => $field_params['tooltip'],
512
+                        'field_name' => $this->slug."[".$field_slug."]",
513
+                        'field_value' => $current_values[$this->slug][$field_slug],
514
+                        'download_image' => $current_values[$this->slug]['download_image'][$field_slug],
515
+                        'field_key' => $field_slug,
516
+                        'addon_prefix' => $this->slug
517
+
518
+                    )
519
+                );
520
+
521
+            } else if ($field_params['type'] == 'radio') {					
522 522
 				
523
-				if (!isset($current_values[$this->slug]['mapping'][$field_slug])) { $current_values[$this->slug]['mapping'][$field_slug] = array(); }
524
-				if (!isset($current_values[$this->slug]['xpaths'][$field_slug])) { $current_values[$this->slug]['xpaths'][$field_slug] = ''; }
525
-
526
-				PMXI_API::add_field(
527
-					'enum',
528
-					$field_params['name'],
529
-					array(
530
-						'tooltip' => $field_params['tooltip'],
531
-						'field_name' => $this->slug."[".$field_slug."]",
532
-						'field_value' => $current_values[$this->slug][$field_slug],
533
-						'enum_values' => $field_params['enum_values'],
534
-						'mapping' => true,
535
-						'field_key' => $field_slug,
536
-						'mapping_rules' => $current_values[$this->slug]['mapping'][$field_slug],
537
-						'xpath' => $current_values[$this->slug]['xpaths'][$field_slug],
538
-						'addon_prefix' => $this->slug,
539
-						'sub_fields' => $this->get_sub_fields($field_params, $field_slug, $current_values)
540
-					)
541
-				);
542
-
543
-			} else if($field_params['type'] == 'accordion') {
544
-
545
-				PMXI_API::add_field(
546
-					'accordion',
547
-					$field_params['name'],
548
-					array(						
549
-						'tooltip' => $field_params['tooltip'],
550
-						'field_name' => $this->slug."[".$field_slug."]",																
551
-						'field_key' => $field_slug,								
552
-						'addon_prefix' => $this->slug,
553
-						'sub_fields' => $this->get_sub_fields($field_params, $field_slug, $current_values),
554
-						'in_the_bottom' => $in_the_bottom						
555
-					)
556
-				);
557
-
558
-			} else if($field_params['type'] == 'acf') {
559
-				$fieldData = (!empty($field_params['field_obj']->post_content)) ? unserialize($field_params['field_obj']->post_content) : array();
560
-				$fieldData['ID']    = $field_params['field_obj']->ID;
561
-				$fieldData['id']    = $field_params['field_obj']->ID;
562
-				$fieldData['label'] = $field_params['field_obj']->post_title;
563
-				$fieldData['key']   = $field_params['field_obj']->post_name;
564
-				if (empty($fieldData['name'])) $fieldData['name'] = $field_params['field_obj']->post_excerpt;
565
-				if (function_exists('pmai_render_field')) {
566
-					echo pmai_render_field($fieldData, ( ! empty($current_values) ) ? $current_values : array() );
567
-				}
568
-			} else if($field_params['type'] == 'title'){
569
-				?>
523
+                if (!isset($current_values[$this->slug]['mapping'][$field_slug])) { $current_values[$this->slug]['mapping'][$field_slug] = array(); }
524
+                if (!isset($current_values[$this->slug]['xpaths'][$field_slug])) { $current_values[$this->slug]['xpaths'][$field_slug] = ''; }
525
+
526
+                PMXI_API::add_field(
527
+                    'enum',
528
+                    $field_params['name'],
529
+                    array(
530
+                        'tooltip' => $field_params['tooltip'],
531
+                        'field_name' => $this->slug."[".$field_slug."]",
532
+                        'field_value' => $current_values[$this->slug][$field_slug],
533
+                        'enum_values' => $field_params['enum_values'],
534
+                        'mapping' => true,
535
+                        'field_key' => $field_slug,
536
+                        'mapping_rules' => $current_values[$this->slug]['mapping'][$field_slug],
537
+                        'xpath' => $current_values[$this->slug]['xpaths'][$field_slug],
538
+                        'addon_prefix' => $this->slug,
539
+                        'sub_fields' => $this->get_sub_fields($field_params, $field_slug, $current_values)
540
+                    )
541
+                );
542
+
543
+            } else if($field_params['type'] == 'accordion') {
544
+
545
+                PMXI_API::add_field(
546
+                    'accordion',
547
+                    $field_params['name'],
548
+                    array(						
549
+                        'tooltip' => $field_params['tooltip'],
550
+                        'field_name' => $this->slug."[".$field_slug."]",																
551
+                        'field_key' => $field_slug,								
552
+                        'addon_prefix' => $this->slug,
553
+                        'sub_fields' => $this->get_sub_fields($field_params, $field_slug, $current_values),
554
+                        'in_the_bottom' => $in_the_bottom						
555
+                    )
556
+                );
557
+
558
+            } else if($field_params['type'] == 'acf') {
559
+                $fieldData = (!empty($field_params['field_obj']->post_content)) ? unserialize($field_params['field_obj']->post_content) : array();
560
+                $fieldData['ID']    = $field_params['field_obj']->ID;
561
+                $fieldData['id']    = $field_params['field_obj']->ID;
562
+                $fieldData['label'] = $field_params['field_obj']->post_title;
563
+                $fieldData['key']   = $field_params['field_obj']->post_name;
564
+                if (empty($fieldData['name'])) $fieldData['name'] = $field_params['field_obj']->post_excerpt;
565
+                if (function_exists('pmai_render_field')) {
566
+                    echo pmai_render_field($fieldData, ( ! empty($current_values) ) ? $current_values : array() );
567
+                }
568
+            } else if($field_params['type'] == 'title'){
569
+                ?>
570 570
 				<h4 class="wpallimport-add-on-options-title"><?php esc_html_e($field_params['name'], 'wp_all_import_plugin'); ?><?php if ( ! empty($field_params['tooltip'])): ?><a href="#help" class="wpallimport-help" title="<?php echo $field_params['tooltip']; ?>" style="position:relative; top: -1px;">?</a><?php endif; ?></h4>				
571 571
 				<?php
572 572
 
573
-			} else if($field_params['type'] == 'plain_text'){
574
-				if ($field_params['is_html']):					
575
-					echo $field_params['name'];				
576
-				else:
577
-					?>
573
+            } else if($field_params['type'] == 'plain_text'){
574
+                if ($field_params['is_html']):					
575
+                    echo $field_params['name'];				
576
+                else:
577
+                    ?>
578 578
 					<p style="margin: 0 0 12px 0;"><?php echo $field_params['name'];?></p>
579 579
 					<?php
580
-				endif;
581
-			}
580
+                endif;
581
+            }
582 582
 
583 583
 
584
-		}
585
-		/**
586
-		*
587
-		* Helper function for nested radio fields
588
-		*
589
-		*/
590
-		function get_sub_fields($field_params, $field_slug, $current_values){
591
-			$sub_fields = array();	
592
-			if ( ! empty($field_params['enum_values']) ){										
593
-				foreach ($field_params['enum_values'] as $key => $value) {					
594
-					$sub_fields[$key] = array();	
595
-					if (is_array($value)){
596
-						if ($field_params['type'] == 'accordion'){								
597
-							$sub_fields[$key][] = $this->convert_field($value, $current_values);
598
-						}
599
-						else
600
-						{
601
-							foreach ($value as $k => $sub_field) {								
602
-								if (is_array($sub_field) and ! empty($this->fields[$sub_field['slug']]))
603
-								{									
604
-									$sub_fields[$key][] = $this->convert_field($sub_field, $current_values);
605
-								}								
606
-							}
607
-						}
608
-					}
609
-				}
610
-			}
611
-			return $sub_fields;
612
-		}			
613
-
614
-		function convert_field($sub_field, $current_values){
615
-			$field = array();
616
-			if (!isset($current_values[$this->slug][$sub_field['slug']])) {
617
-				$current_values[$this->slug][$sub_field['slug']] = isset($sub_field['default_text']) ? $sub_field['default_text'] : '';
618
-			}
619
-			switch ($this->fields[$sub_field['slug']]['type']) {
620
-				case 'text':
621
-					$field = array(
622
-						'type'   => 'simple',
623
-						'label'  => $this->fields[$sub_field['slug']]['name'],
624
-						'params' => array(
625
-							'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
626
-							'field_name' => $this->slug."[".$sub_field['slug']."]",
627
-							'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']],
628
-							'is_main_field' => $sub_field['is_main_field']
629
-						)
630
-					);
631
-					break;
632
-				case 'textarea':
633
-					$field = array(
634
-						'type'   => 'textarea',
635
-						'label'  => $this->fields[$sub_field['slug']]['name'],
636
-						'params' => array(
637
-							'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
638
-							'field_name' => $this->slug."[".$sub_field['slug']."]",
639
-							'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']],
640
-							'is_main_field' => $sub_field['is_main_field']
641
-						)
642
-					);
643
-					break;
644
-				case 'wp_editor':
645
-					$field = array(
646
-						'type'   => 'wp_editor',
647
-						'label'  => $this->fields[$sub_field['slug']]['name'],
648
-						'params' => array(
649
-							'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
650
-							'field_name' => $this->slug."[".$sub_field['slug']."]",
651
-							'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']],
652
-							'is_main_field' => $sub_field['is_main_field']
653
-						)
654
-					);
655
-					break;
656
-				case 'image':
657
-					$field = array(
658
-						'type'   => 'image',
659
-						'label'  => $this->fields[$sub_field['slug']]['name'],
660
-						'params' => array(
661
-							'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
662
-							'field_name' => $this->slug."[".$sub_field['slug']."]",
663
-							'field_value' => $current_values[$this->slug][$sub_field['slug']],
664
-							'download_image' => null,
665
-							'field_key' => $sub_field['slug'],
666
-							'addon_prefix' => $this->slug,
667
-							'is_main_field' => $sub_field['is_main_field']
668
-						)
669
-					);
670
-
671
-					if ( array_key_exists( 'download_image', $current_values[$this->slug] ) && array_key_exists( $sub_field['slug'], $current_values[$this->slug]['download_image'] ) ) {
672
-						$field['params']['download_image'] = $current_values[$this->slug]['download_image'][$sub_field['slug']];
673
-					}
584
+        }
585
+        /**
586
+         *
587
+         * Helper function for nested radio fields
588
+         *
589
+         */
590
+        function get_sub_fields($field_params, $field_slug, $current_values){
591
+            $sub_fields = array();	
592
+            if ( ! empty($field_params['enum_values']) ){										
593
+                foreach ($field_params['enum_values'] as $key => $value) {					
594
+                    $sub_fields[$key] = array();	
595
+                    if (is_array($value)){
596
+                        if ($field_params['type'] == 'accordion'){								
597
+                            $sub_fields[$key][] = $this->convert_field($value, $current_values);
598
+                        }
599
+                        else
600
+                        {
601
+                            foreach ($value as $k => $sub_field) {								
602
+                                if (is_array($sub_field) and ! empty($this->fields[$sub_field['slug']]))
603
+                                {									
604
+                                    $sub_fields[$key][] = $this->convert_field($sub_field, $current_values);
605
+                                }								
606
+                            }
607
+                        }
608
+                    }
609
+                }
610
+            }
611
+            return $sub_fields;
612
+        }			
613
+
614
+        function convert_field($sub_field, $current_values){
615
+            $field = array();
616
+            if (!isset($current_values[$this->slug][$sub_field['slug']])) {
617
+                $current_values[$this->slug][$sub_field['slug']] = isset($sub_field['default_text']) ? $sub_field['default_text'] : '';
618
+            }
619
+            switch ($this->fields[$sub_field['slug']]['type']) {
620
+                case 'text':
621
+                    $field = array(
622
+                        'type'   => 'simple',
623
+                        'label'  => $this->fields[$sub_field['slug']]['name'],
624
+                        'params' => array(
625
+                            'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
626
+                            'field_name' => $this->slug."[".$sub_field['slug']."]",
627
+                            'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']],
628
+                            'is_main_field' => $sub_field['is_main_field']
629
+                        )
630
+                    );
674 631
                     break;
675
-				case 'file':
676
-					$field = array(
677
-						'type'   => 'file',
678
-						'label'  => $this->fields[$sub_field['slug']]['name'],
679
-						'params' => array(
680
-							'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
681
-							'field_name' => $this->slug."[".$sub_field['slug']."]",
682
-							'field_value' => $current_values[$this->slug][$sub_field['slug']],
683
-							'download_image' => null,
684
-							'field_key' => $sub_field['slug'],
685
-							'addon_prefix' => $this->slug,
686
-							'is_main_field' => $sub_field['is_main_field']
687
-						)
688
-					);
689
-
690
-					if ( array_key_exists( 'download_image', $current_values[$this->slug] )  && array_key_exists( $sub_field['slug'], $current_values[$this->slug]['download_image'] ) ) {
691
-						$field['params']['download_image'] = $current_values[$this->slug]['download_image'][$sub_field['slug']];
692
-					}
693
-
694
-					break;
695
-				case 'radio':
696
-					$field = array(
697
-						'type'   => 'enum',
698
-						'label'  => $this->fields[$sub_field['slug']]['name'],
699
-						'params' => array(
700
-							'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
701
-							'field_name' => $this->slug."[".$sub_field['slug']."]",
702
-							'field_value' => $current_values[$this->slug][$sub_field['slug']],
703
-							'enum_values' => $this->fields[$sub_field['slug']]['enum_values'],
704
-							'mapping' => true,
705
-							'field_key' => $sub_field['slug'],
706
-							'mapping_rules' => isset($current_values[$this->slug]['mapping'][$sub_field['slug']]) ? $current_values[$this->slug]['mapping'][$sub_field['slug']] : array(),
707
-							'xpath' => isset($current_values[$this->slug]['xpaths'][$sub_field['slug']]) ? $current_values[$this->slug]['xpaths'][$sub_field['slug']] : '',
708
-							'addon_prefix' => $this->slug,
709
-							'sub_fields' => $this->get_sub_fields($this->fields[$sub_field['slug']], $sub_field['slug'], $current_values),
710
-							'is_main_field' => $sub_field['is_main_field']
711
-						)
712
-					);
713
-					break;
714
-				case 'accordion':
715
-					$field = array(
716
-						'type'   => 'accordion',
717
-						'label'  => $this->fields[$sub_field['slug']]['name'],
718
-						'params' => array(
719
-							'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
720
-							'field_name' => $this->slug."[".$sub_field['slug']."]",																
721
-							'field_key' => $sub_field['slug'],								
722
-							'addon_prefix' => $this->slug,
723
-							'sub_fields' => $this->get_sub_fields($this->fields[$sub_field['slug']], $sub_field['slug'], $current_values),
724
-							'in_the_bottom' => false
725
-						)
726
-					);						
727
-					break;
728
-				default:
729
-					# code...
730
-					break;
731
-			}
732
-			return $field;
733
-		}				
734
-
735
-		/**
736
-		* 
737
-		* Add accordion options
738
-		*
739
-		*
740
-		*/
741
-		function add_options( $main_field = false, $title = '', $fields = array() ){
632
+                case 'textarea':
633
+                    $field = array(
634
+                        'type'   => 'textarea',
635
+                        'label'  => $this->fields[$sub_field['slug']]['name'],
636
+                        'params' => array(
637
+                            'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
638
+                            'field_name' => $this->slug."[".$sub_field['slug']."]",
639
+                            'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']],
640
+                            'is_main_field' => $sub_field['is_main_field']
641
+                        )
642
+                    );
643
+                    break;
644
+                case 'wp_editor':
645
+                    $field = array(
646
+                        'type'   => 'wp_editor',
647
+                        'label'  => $this->fields[$sub_field['slug']]['name'],
648
+                        'params' => array(
649
+                            'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
650
+                            'field_name' => $this->slug."[".$sub_field['slug']."]",
651
+                            'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']],
652
+                            'is_main_field' => $sub_field['is_main_field']
653
+                        )
654
+                    );
655
+                    break;
656
+                case 'image':
657
+                    $field = array(
658
+                        'type'   => 'image',
659
+                        'label'  => $this->fields[$sub_field['slug']]['name'],
660
+                        'params' => array(
661
+                            'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
662
+                            'field_name' => $this->slug."[".$sub_field['slug']."]",
663
+                            'field_value' => $current_values[$this->slug][$sub_field['slug']],
664
+                            'download_image' => null,
665
+                            'field_key' => $sub_field['slug'],
666
+                            'addon_prefix' => $this->slug,
667
+                            'is_main_field' => $sub_field['is_main_field']
668
+                        )
669
+                    );
670
+
671
+                    if ( array_key_exists( 'download_image', $current_values[$this->slug] ) && array_key_exists( $sub_field['slug'], $current_values[$this->slug]['download_image'] ) ) {
672
+                        $field['params']['download_image'] = $current_values[$this->slug]['download_image'][$sub_field['slug']];
673
+                    }
674
+                    break;
675
+                case 'file':
676
+                    $field = array(
677
+                        'type'   => 'file',
678
+                        'label'  => $this->fields[$sub_field['slug']]['name'],
679
+                        'params' => array(
680
+                            'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
681
+                            'field_name' => $this->slug."[".$sub_field['slug']."]",
682
+                            'field_value' => $current_values[$this->slug][$sub_field['slug']],
683
+                            'download_image' => null,
684
+                            'field_key' => $sub_field['slug'],
685
+                            'addon_prefix' => $this->slug,
686
+                            'is_main_field' => $sub_field['is_main_field']
687
+                        )
688
+                    );
689
+
690
+                    if ( array_key_exists( 'download_image', $current_values[$this->slug] )  && array_key_exists( $sub_field['slug'], $current_values[$this->slug]['download_image'] ) ) {
691
+                        $field['params']['download_image'] = $current_values[$this->slug]['download_image'][$sub_field['slug']];
692
+                    }
693
+
694
+                    break;
695
+                case 'radio':
696
+                    $field = array(
697
+                        'type'   => 'enum',
698
+                        'label'  => $this->fields[$sub_field['slug']]['name'],
699
+                        'params' => array(
700
+                            'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
701
+                            'field_name' => $this->slug."[".$sub_field['slug']."]",
702
+                            'field_value' => $current_values[$this->slug][$sub_field['slug']],
703
+                            'enum_values' => $this->fields[$sub_field['slug']]['enum_values'],
704
+                            'mapping' => true,
705
+                            'field_key' => $sub_field['slug'],
706
+                            'mapping_rules' => isset($current_values[$this->slug]['mapping'][$sub_field['slug']]) ? $current_values[$this->slug]['mapping'][$sub_field['slug']] : array(),
707
+                            'xpath' => isset($current_values[$this->slug]['xpaths'][$sub_field['slug']]) ? $current_values[$this->slug]['xpaths'][$sub_field['slug']] : '',
708
+                            'addon_prefix' => $this->slug,
709
+                            'sub_fields' => $this->get_sub_fields($this->fields[$sub_field['slug']], $sub_field['slug'], $current_values),
710
+                            'is_main_field' => $sub_field['is_main_field']
711
+                        )
712
+                    );
713
+                    break;
714
+                case 'accordion':
715
+                    $field = array(
716
+                        'type'   => 'accordion',
717
+                        'label'  => $this->fields[$sub_field['slug']]['name'],
718
+                        'params' => array(
719
+                            'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
720
+                            'field_name' => $this->slug."[".$sub_field['slug']."]",																
721
+                            'field_key' => $sub_field['slug'],								
722
+                            'addon_prefix' => $this->slug,
723
+                            'sub_fields' => $this->get_sub_fields($this->fields[$sub_field['slug']], $sub_field['slug'], $current_values),
724
+                            'in_the_bottom' => false
725
+                        )
726
+                    );						
727
+                    break;
728
+                default:
729
+                    # code...
730
+                    break;
731
+            }
732
+            return $field;
733
+        }				
734
+
735
+        /**
736
+         * 
737
+         * Add accordion options
738
+         *
739
+         *
740
+         */
741
+        function add_options( $main_field = false, $title = '', $fields = array() ){
742 742
 			
743
-			if ( ! empty($fields) )
744
-			{				
743
+            if ( ! empty($fields) )
744
+            {				
745 745
 				
746
-				if ($main_field){
746
+                if ($main_field){
747 747
 
748
-					$main_field['is_main_field'] = true;
749
-					$fields[] = $main_field;
748
+                    $main_field['is_main_field'] = true;
749
+                    $fields[] = $main_field;
750 750
 
751
-				}
751
+                }
752 752
 
753
-				return $this->add_field('accordion_' . $fields[0]['slug'], $title, 'accordion', $fields);							
753
+                return $this->add_field('accordion_' . $fields[0]['slug'], $title, 'accordion', $fields);							
754 754
 			
755
-			}
755
+            }
756 756
 
757
-		}			
757
+        }			
758 758
 
759
-		function add_title($title = '', $tooltip = ''){
759
+        function add_title($title = '', $tooltip = ''){
760 760
 
761
-			if (empty($title)) return;
761
+            if (empty($title)) return;
762 762
 
763
-			return $this->add_field(sanitize_key($title) . time(), $title, 'title', null, $tooltip);			
763
+            return $this->add_field(sanitize_key($title) . time(), $title, 'title', null, $tooltip);			
764 764
 
765
-		}		
765
+        }		
766 766
 
767
-		function add_text($text = '', $is_html = false){
767
+        function add_text($text = '', $is_html = false){
768 768
 
769
-			if (empty($text)) return;
769
+            if (empty($text)) return;
770 770
 
771
-			$count = is_array($this->fields) ? count($this->fields) : 0;
771
+            $count = is_array($this->fields) ? count($this->fields) : 0;
772 772
 
773
-			return $this->add_field(sanitize_key($text) . time() . uniqid() . $count, $text, 'plain_text', null, "", $is_html);
773
+            return $this->add_field(sanitize_key($text) . time() . uniqid() . $count, $text, 'plain_text', null, "", $is_html);
774 774
 
775
-		}			
775
+        }			
776 776
 
777
-		function helper_metabox_top($name) {
777
+        function helper_metabox_top($name) {
778 778
 
779
-			return '
779
+            return '
780 780
 			<style type="text/css">
781 781
 				.wpallimport-plugin .wpallimport-addon div.input {
782 782
 					margin-bottom: 15px;
@@ -872,11 +872,11 @@  discard block
 block discarded – undo
872 872
 							<table class="form-table" style="max-width:none;">
873 873
 								<tr>
874 874
 									<td colspan="3">';
875
-		}
875
+        }
876 876
 
877
-		function helper_metabox_bottom() {
877
+        function helper_metabox_bottom() {
878 878
 
879
-			return '				</td>
879
+            return '				</td>
880 880
 								</tr>
881 881
 							</table>
882 882
 						</div>
@@ -884,298 +884,298 @@  discard block
 block discarded – undo
884 884
 				</div>
885 885
 			</div>';
886 886
 
887
-		}
887
+        }
888 888
 
889
-		/**
890
-		*
891
-		* simply add an additional section for attachments
892
-		*
893
-		*/
894
-		function import_files( $slug, $title, $callback = NULL ){
895
-			$this->import_images( $slug, $title, 'files', $callback);
896
-		}
889
+        /**
890
+         *
891
+         * simply add an additional section for attachments
892
+         *
893
+         */
894
+        function import_files( $slug, $title, $callback = NULL ){
895
+            $this->import_images( $slug, $title, 'files', $callback);
896
+        }
897 897
 
898
-		/**
899
-		*
900
-		* simply add an additional section 
901
-		*
902
-		*/
903
-		function import_images( $slug, $title, $type = 'images', $callback = NULL ){
898
+        /**
899
+         *
900
+         * simply add an additional section 
901
+         *
902
+         */
903
+        function import_images( $slug, $title, $type = 'images', $callback = NULL ){
904 904
 			
905
-			if ( empty($title) or empty($slug) ) return;
905
+            if ( empty($title) or empty($slug) ) return;
906 906
 
907
-			if (is_array($slug)) {
907
+            if (is_array($slug)) {
908 908
                 $section_slug = 'pmxi_' . md5(serialize($slug));
909 909
             } else {
910 910
                 $section_slug = 'pmxi_' . $slug;
911 911
             }
912 912
 
913
-			$this->image_sections[] = array(
914
-				'title' => $title,
915
-				'slug'  => $section_slug,
916
-				'type'  => $type
917
-			);			
913
+            $this->image_sections[] = array(
914
+                'title' => $title,
915
+                'slug'  => $section_slug,
916
+                'type'  => $type
917
+            );			
918 918
 			
919
-			foreach ($this->image_options as $option_slug => $value) {
920
-				$this->add_option($section_slug . $option_slug, $value);
921
-			}
919
+            foreach ($this->image_options as $option_slug => $value) {
920
+                $this->add_option($section_slug . $option_slug, $value);
921
+            }
922 922
 
923
-			if (count($this->image_sections) > 1){
924
-				add_filter('wp_all_import_is_show_add_new_images', array($this, 'filter_is_show_add_new_images'), 10, 2);
925
-			}
923
+            if (count($this->image_sections) > 1){
924
+                add_filter('wp_all_import_is_show_add_new_images', array($this, 'filter_is_show_add_new_images'), 10, 2);
925
+            }
926 926
 
927
-			add_filter('wp_all_import_is_allow_import_images', array($this, 'is_allow_import_images'), 10, 2);			
927
+            add_filter('wp_all_import_is_allow_import_images', array($this, 'is_allow_import_images'), 10, 2);			
928 928
 
929
-			if ($callback && is_callable($callback)) {
929
+            if ($callback && is_callable($callback)) {
930 930
                 add_action( $section_slug, $callback, 10, 4);
931 931
             } else {
932 932
                 if (function_exists($slug)) {
933 933
                     add_action( $section_slug, $slug, 10, 4);
934 934
                 }
935 935
             }
936
-		}			
937
-			/**
938
-			*
939
-			* filter to allow import images for free edition of WP All Import
940
-			*
941
-			*/
942
-			function is_allow_import_images($is_allow, $post_type){
943
-				return ($this->is_active_addon($post_type)) ? true : $is_allow;
944
-			}
945
-
946
-		/**
947
-		*
948
-		* filter to control additional images sections
949
-		*
950
-		*/
951
-		function additional_sections($sections){
952
-			if ( ! empty($this->image_sections) ){
953
-				foreach ($this->image_sections as $add_section) {
954
-					$sections[] = $add_section;
955
-				}
956
-			}
936
+        }			
937
+            /**
938
+             *
939
+             * filter to allow import images for free edition of WP All Import
940
+             *
941
+             */
942
+            function is_allow_import_images($is_allow, $post_type){
943
+                return ($this->is_active_addon($post_type)) ? true : $is_allow;
944
+            }
945
+
946
+        /**
947
+         *
948
+         * filter to control additional images sections
949
+         *
950
+         */
951
+        function additional_sections($sections){
952
+            if ( ! empty($this->image_sections) ){
953
+                foreach ($this->image_sections as $add_section) {
954
+                    $sections[] = $add_section;
955
+                }
956
+            }
957 957
 			
958
-			return $sections;
959
-		}
960
-			/**
961
-			*
962
-			* remove the 'Don't touch existing images, append new images' when more than one image section is in use.
963
-			*
964
-			*/
965
-			function filter_is_show_add_new_images($is_show, $post_type){
966
-				return ($this->is_active_addon($post_type)) ? false : $is_show;
967
-			}
968
-
969
-		/**
970
-		*
971
-		* disable the default images section
972
-		*
973
-		*/		
974
-		function disable_default_images($post_type = false){
958
+            return $sections;
959
+        }
960
+            /**
961
+             *
962
+             * remove the 'Don't touch existing images, append new images' when more than one image section is in use.
963
+             *
964
+             */
965
+            function filter_is_show_add_new_images($is_show, $post_type){
966
+                return ($this->is_active_addon($post_type)) ? false : $is_show;
967
+            }
968
+
969
+        /**
970
+         *
971
+         * disable the default images section
972
+         *
973
+         */		
974
+        function disable_default_images($post_type = false){
975 975
 									
976
-			add_filter('wp_all_import_is_images_section_enabled', array($this, 'is_enable_default_images_section'), 10, 2);
976
+            add_filter('wp_all_import_is_images_section_enabled', array($this, 'is_enable_default_images_section'), 10, 2);
977 977
 
978
-		}
979
-			function is_enable_default_images_section($is_enabled, $post_type){						
978
+        }
979
+            function is_enable_default_images_section($is_enabled, $post_type){						
980 980
 				
981
-				return ($this->is_active_addon($post_type)) ? false : true;
981
+                return ($this->is_active_addon($post_type)) ? false : true;
982 982
 								
983
-			}
983
+            }
984 984
 
985
-		function helper_parse($parsingData, $options) {
985
+        function helper_parse($parsingData, $options) {
986 986
 
987
-			extract($parsingData);
987
+            extract($parsingData);
988 988
 
989
-			$data = array(); // parsed data
989
+            $data = array(); // parsed data
990 990
 
991
-			if ( ! empty($import->options[$this->slug])){
991
+            if ( ! empty($import->options[$this->slug])){
992 992
 
993
-				$this->logger = $parsingData['logger'];
993
+                $this->logger = $parsingData['logger'];
994 994
 
995
-				$cxpath = $xpath_prefix . $import->xpath;
995
+                $cxpath = $xpath_prefix . $import->xpath;
996 996
 
997
-				$tmp_files = array();
997
+                $tmp_files = array();
998 998
 
999
-				foreach ($options[$this->slug] as $option_name => $option_value) {					
1000
-					if ( isset($import->options[$this->slug][$option_name]) and $import->options[$this->slug][$option_name] != '') {						
1001
-						if ($import->options[$this->slug][$option_name] == "xpath") {
1002
-							if ($import->options[$this->slug]['xpaths'][$option_name] == ""){
1003
-								$count and $data[$option_name] = array_fill(0, $count, "");
1004
-							} else {
1005
-								$data[$option_name] = XmlImportParser::factory($xml, $cxpath, (string) $import->options[$this->slug]['xpaths'][$option_name], $file)->parse();
1006
-								$tmp_files[] = $file;						
1007
-							}
1008
-						} 
1009
-						else {							
1010
-							$data[$option_name] = XmlImportParser::factory($xml, $cxpath, (string) $import->options[$this->slug][$option_name], $file)->parse();
1011
-							$tmp_files[] = $file;
1012
-						}
999
+                foreach ($options[$this->slug] as $option_name => $option_value) {					
1000
+                    if ( isset($import->options[$this->slug][$option_name]) and $import->options[$this->slug][$option_name] != '') {						
1001
+                        if ($import->options[$this->slug][$option_name] == "xpath") {
1002
+                            if ($import->options[$this->slug]['xpaths'][$option_name] == ""){
1003
+                                $count and $data[$option_name] = array_fill(0, $count, "");
1004
+                            } else {
1005
+                                $data[$option_name] = XmlImportParser::factory($xml, $cxpath, (string) $import->options[$this->slug]['xpaths'][$option_name], $file)->parse();
1006
+                                $tmp_files[] = $file;						
1007
+                            }
1008
+                        } 
1009
+                        else {							
1010
+                            $data[$option_name] = XmlImportParser::factory($xml, $cxpath, (string) $import->options[$this->slug][$option_name], $file)->parse();
1011
+                            $tmp_files[] = $file;
1012
+                        }
1013 1013
 
1014 1014
 
1015
-					} else {
1016
-						$data[$option_name] = array_fill(0, $count, "");
1017
-					}
1015
+                    } else {
1016
+                        $data[$option_name] = array_fill(0, $count, "");
1017
+                    }
1018 1018
 
1019
-				}
1019
+                }
1020 1020
 
1021
-				foreach ($tmp_files as $file) { // remove all temporary files created
1022
-					unlink($file);
1023
-				}
1021
+                foreach ($tmp_files as $file) { // remove all temporary files created
1022
+                    unlink($file);
1023
+                }
1024 1024
 
1025
-			}
1025
+            }
1026 1026
 
1027
-			return $data;
1028
-		}
1027
+            return $data;
1028
+        }
1029 1029
 
1030 1030
 
1031
-		function can_update_meta($meta_key, $import_options) {
1031
+        function can_update_meta($meta_key, $import_options) {
1032 1032
 
1033
-			//echo "<pre>";
1034
-			//print_r($import_options['options']);
1035
-			//echo "</pre>";
1033
+            //echo "<pre>";
1034
+            //print_r($import_options['options']);
1035
+            //echo "</pre>";
1036 1036
 			
1037
-			$import_options = $import_options['options'];
1037
+            $import_options = $import_options['options'];
1038 1038
 
1039
-			if ($import_options['update_all_data'] == 'yes') return true;
1039
+            if ($import_options['update_all_data'] == 'yes') return true;
1040 1040
 
1041
-			if ( ! $import_options['is_update_custom_fields'] ) return false;			
1041
+            if ( ! $import_options['is_update_custom_fields'] ) return false;			
1042 1042
 
1043
-			if ($import_options['update_custom_fields_logic'] == "full_update") return true;
1044
-			if ($import_options['update_custom_fields_logic'] == "only" and ! empty($import_options['custom_fields_list']) and is_array($import_options['custom_fields_list']) and in_array($meta_key, $import_options['custom_fields_list']) ) return true;
1045
-			if ($import_options['update_custom_fields_logic'] == "all_except" and ( empty($import_options['custom_fields_list']) or ! in_array($meta_key, $import_options['custom_fields_list']) )) return true;
1043
+            if ($import_options['update_custom_fields_logic'] == "full_update") return true;
1044
+            if ($import_options['update_custom_fields_logic'] == "only" and ! empty($import_options['custom_fields_list']) and is_array($import_options['custom_fields_list']) and in_array($meta_key, $import_options['custom_fields_list']) ) return true;
1045
+            if ($import_options['update_custom_fields_logic'] == "all_except" and ( empty($import_options['custom_fields_list']) or ! in_array($meta_key, $import_options['custom_fields_list']) )) return true;
1046 1046
 
1047
-			return false;
1047
+            return false;
1048 1048
 
1049
-		}
1049
+        }
1050 1050
 
1051
-		function can_update_taxonomy($tax_name, $import_options) {
1051
+        function can_update_taxonomy($tax_name, $import_options) {
1052 1052
 
1053
-			//echo "<pre>";
1054
-			//print_r($import_options['options']);
1055
-			//echo "</pre>";
1053
+            //echo "<pre>";
1054
+            //print_r($import_options['options']);
1055
+            //echo "</pre>";
1056 1056
 			
1057
-			$import_options = $import_options['options'];
1057
+            $import_options = $import_options['options'];
1058 1058
 
1059
-			if ($import_options['update_all_data'] == 'yes') return true;
1059
+            if ($import_options['update_all_data'] == 'yes') return true;
1060 1060
 
1061
-			if ( ! $import_options['is_update_categories'] ) return false;			
1061
+            if ( ! $import_options['is_update_categories'] ) return false;			
1062 1062
 
1063
-			if ($import_options['update_categories_logic'] == "full_update") return true;
1064
-			if ($import_options['update_categories_logic'] == "only" and ! empty($import_options['taxonomies_list']) and is_array($import_options['taxonomies_list']) and in_array($tax_name, $import_options['taxonomies_list']) ) return true;
1065
-			if ($import_options['update_categories_logic'] == "all_except" and ( empty($import_options['taxonomies_list']) or ! in_array($tax_name, $import_options['taxonomies_list']) )) return true;
1063
+            if ($import_options['update_categories_logic'] == "full_update") return true;
1064
+            if ($import_options['update_categories_logic'] == "only" and ! empty($import_options['taxonomies_list']) and is_array($import_options['taxonomies_list']) and in_array($tax_name, $import_options['taxonomies_list']) ) return true;
1065
+            if ($import_options['update_categories_logic'] == "all_except" and ( empty($import_options['taxonomies_list']) or ! in_array($tax_name, $import_options['taxonomies_list']) )) return true;
1066 1066
 
1067
-			return false;
1067
+            return false;
1068 1068
 
1069
-		}
1069
+        }
1070 1070
 
1071
-		function can_update_image($import_options) {
1071
+        function can_update_image($import_options) {
1072 1072
 
1073
-			$import_options = $import_options['options'];
1073
+            $import_options = $import_options['options'];
1074 1074
 
1075
-			if ($import_options['update_all_data'] == 'yes') return true;
1075
+            if ($import_options['update_all_data'] == 'yes') return true;
1076 1076
 
1077
-			if (!$import_options['is_update_images']) return false;			
1077
+            if (!$import_options['is_update_images']) return false;			
1078 1078
 
1079
-			if ($import_options['is_update_images']) return true;			
1079
+            if ($import_options['is_update_images']) return true;			
1080 1080
 
1081
-			return false;
1082
-		}
1081
+            return false;
1082
+        }
1083 1083
 
1084 1084
 
1085
-		function admin_notice_ignore() {
1086
-			if (isset($_GET[$this->slug.'_ignore']) && '0' == $_GET[$this->slug.'_ignore'] ) {
1087
-				update_option($this->slug.'_ignore', 'true');
1088
-			}
1089
-		}
1085
+        function admin_notice_ignore() {
1086
+            if (isset($_GET[$this->slug.'_ignore']) && '0' == $_GET[$this->slug.'_ignore'] ) {
1087
+                update_option($this->slug.'_ignore', 'true');
1088
+            }
1089
+        }
1090 1090
 
1091
-		function display_admin_notice() {
1091
+        function display_admin_notice() {
1092 1092
 
1093 1093
 
1094
-			if ($this->notice_text) {
1095
-				$notice_text = $this->notice_text;
1096
-			} else {
1097
-				$notice_text = $this->name.' requires WP All Import <a href="http://www.wpallimport.com/" target="_blank">Pro</a> or <a href="http://wordpress.org/plugins/wp-all-import" target="_blank">Free</a>.';
1098
-			}
1094
+            if ($this->notice_text) {
1095
+                $notice_text = $this->notice_text;
1096
+            } else {
1097
+                $notice_text = $this->name.' requires WP All Import <a href="http://www.wpallimport.com/" target="_blank">Pro</a> or <a href="http://wordpress.org/plugins/wp-all-import" target="_blank">Free</a>.';
1098
+            }
1099 1099
 
1100
-			if (!get_option(sanitize_key($this->slug).'_notice_ignore')) {
1100
+            if (!get_option(sanitize_key($this->slug).'_notice_ignore')) {
1101 1101
 
1102
-				?>
1102
+                ?>
1103 1103
 
1104 1104
 	    		<div class="error notice is-dismissible wpallimport-dismissible" style="margin-top: 10px;" rel="<?php echo esc_attr($this->slug); ?>">
1105 1105
 	    		    <p><?php echo wp_kses_post(__(
1106
-		    		    	sprintf(
1107
-	    			    		$notice_text,
1108
-	    			    		'?'.$this->slug.'_ignore=0'
1109
-	    			    	), 
1110
-	    		    		'rapid_addon_'.$this->slug
1111
-	    		    	)); ?></p>
1106
+                            sprintf(
1107
+                                $notice_text,
1108
+                                '?'.$this->slug.'_ignore=0'
1109
+                            ), 
1110
+                            'rapid_addon_'.$this->slug
1111
+                        )); ?></p>
1112 1112
 			    </div>
1113 1113
 
1114 1114
 				<?php
1115 1115
 
1116
-			}
1116
+            }
1117 1117
 
1118
-		}
1118
+        }
1119 1119
 
1120
-		/*
1120
+        /*
1121 1121
 		*
1122 1122
 		* $conditions - array('themes' => array('Realia'), 'plugins' => array('plugin-directory/plugin-file.php', 'plugin-directory2/plugin-file.php')) 
1123 1123
 		*
1124 1124
 		*/
1125
-		function admin_notice($notice_text = '', $conditions = array()) {
1125
+        function admin_notice($notice_text = '', $conditions = array()) {
1126 1126
 
1127
-			$is_show_notice = false;
1127
+            $is_show_notice = false;
1128 1128
 
1129
-			include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
1129
+            include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
1130 1130
 
1131
-			if ( ! class_exists( 'PMXI_Plugin' ) ) {
1132
-				$is_show_notice = true;
1133
-			}
1131
+            if ( ! class_exists( 'PMXI_Plugin' ) ) {
1132
+                $is_show_notice = true;
1133
+            }
1134 1134
 
1135
-			// Supported Themes
1136
-			if ( ! $is_show_notice and ! empty($conditions['themes']) ){
1135
+            // Supported Themes
1136
+            if ( ! $is_show_notice and ! empty($conditions['themes']) ){
1137 1137
 
1138
-				$themeInfo    = wp_get_theme();
1139
-				$parentInfo = $themeInfo->parent();				
1140
-				$currentTheme = $themeInfo->get('Name');
1138
+                $themeInfo    = wp_get_theme();
1139
+                $parentInfo = $themeInfo->parent();				
1140
+                $currentTheme = $themeInfo->get('Name');
1141 1141
 				
1142
-				$is_show_notice = in_array($currentTheme, $conditions['themes']) ? false : true;				
1142
+                $is_show_notice = in_array($currentTheme, $conditions['themes']) ? false : true;				
1143 1143
 
1144
-				if ( $is_show_notice and $parentInfo ){
1145
-					$parent_theme = $parentInfo->get('Name');
1146
-					$is_show_notice = in_array($parent_theme, $conditions['themes']) ? false : true;					
1147
-				}
1144
+                if ( $is_show_notice and $parentInfo ){
1145
+                    $parent_theme = $parentInfo->get('Name');
1146
+                    $is_show_notice = in_array($parent_theme, $conditions['themes']) ? false : true;					
1147
+                }
1148 1148
 
1149
-			}			
1149
+            }			
1150 1150
 
1151
-			// Required Plugins
1152
-			if ( ! $is_show_notice and ! empty($conditions['plugins']) ){				
1151
+            // Required Plugins
1152
+            if ( ! $is_show_notice and ! empty($conditions['plugins']) ){				
1153 1153
 
1154
-				$requires_counter = 0;
1155
-				foreach ($conditions['plugins'] as $plugin) {
1156
-					if ( is_plugin_active($plugin) ) $requires_counter++;
1157
-				}
1154
+                $requires_counter = 0;
1155
+                foreach ($conditions['plugins'] as $plugin) {
1156
+                    if ( is_plugin_active($plugin) ) $requires_counter++;
1157
+                }
1158 1158
 
1159
-				if ($requires_counter != count($conditions['plugins'])){ 					
1160
-					$is_show_notice = true;			
1161
-				}
1159
+                if ($requires_counter != count($conditions['plugins'])){ 					
1160
+                    $is_show_notice = true;			
1161
+                }
1162 1162
 
1163
-			}
1163
+            }
1164 1164
 
1165
-			if ( $is_show_notice ){
1165
+            if ( $is_show_notice ){
1166 1166
 
1167
-				if ( $notice_text != '' ) {
1168
-					$this->notice_text = $notice_text;
1169
-				}
1167
+                if ( $notice_text != '' ) {
1168
+                    $this->notice_text = $notice_text;
1169
+                }
1170 1170
 
1171
-				add_action('admin_notices', array($this, 'display_admin_notice'));
1172
-			}
1171
+                add_action('admin_notices', array($this, 'display_admin_notice'));
1172
+            }
1173 1173
 
1174
-		}
1174
+        }
1175 1175
 
1176
-		function log( $m = false){		
1176
+        function log( $m = false){		
1177 1177
 
1178
-			$m and $this->logger and call_user_func($this->logger, $m);
1178
+            $m and $this->logger and call_user_func($this->logger, $m);
1179 1179
 
1180 1180
         }
1181 1181
         
@@ -1293,5 +1293,5 @@  discard block
 block discarded – undo
1293 1293
             }
1294 1294
             return $image;
1295 1295
         }
1296
-	}	
1296
+    }	
1297 1297
 }
1298 1298
\ No newline at end of file
Please login to merge, or discard this patch.
templates/payment-forms/cart-item.php 1 patch
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -26,71 +26,71 @@  discard block
 block discarded – undo
26 26
 
27 27
 				<?php
28 28
 
29
-					// Fires before printing a line item column.
30
-					do_action( "getpaid_form_cart_item_before_$key", $item, $form );
29
+                    // Fires before printing a line item column.
30
+                    do_action( "getpaid_form_cart_item_before_$key", $item, $form );
31 31
 
32
-					// Item name.
33
-					if ( 'name' === $key ) {
32
+                    // Item name.
33
+                    if ( 'name' === $key ) {
34 34
 
35 35
 
36
-						ob_start();
36
+                        ob_start();
37 37
 
38
-						// Add an optional description.
39
-						$description = $item->get_description();
38
+                        // Add an optional description.
39
+                        $description = $item->get_description();
40 40
 
41
-						if ( ! empty( $description ) ) {
42
-							echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post( $description ) . '</small>';
43
-						}
41
+                        if ( ! empty( $description ) ) {
42
+                            echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post( $description ) . '</small>';
43
+                        }
44 44
 
45
-						// Price help text.
46
-						$description = getpaid_item_recurring_price_help_text( $item, $currency );
47
-						if ( $description ) {
48
-							echo "<small class='getpaid-form-item-price-desc form-text text-muted font-italic pr-2 m-0'>" . wp_kses_post( $description ) . '</small>';
49
-						}
45
+                        // Price help text.
46
+                        $description = getpaid_item_recurring_price_help_text( $item, $currency );
47
+                        if ( $description ) {
48
+                            echo "<small class='getpaid-form-item-price-desc form-text text-muted font-italic pr-2 m-0'>" . wp_kses_post( $description ) . '</small>';
49
+                        }
50 50
 
51
-						do_action( 'getpaid_payment_form_cart_item_description', $item, $form );
51
+                        do_action( 'getpaid_payment_form_cart_item_description', $item, $form );
52 52
 
53
-						if ( wpinv_current_user_can_manage_invoicing() ) {
53
+                        if ( wpinv_current_user_can_manage_invoicing() ) {
54 54
 
55
-							edit_post_link(
56
-								__( 'Edit this item.', 'invoicing' ),
57
-								'<small class="form-text text-muted">',
58
-								'</small>',
59
-								$item->get_id(),
60
-								'text-danger'
61
-							);
55
+                            edit_post_link(
56
+                                __( 'Edit this item.', 'invoicing' ),
57
+                                '<small class="form-text text-muted">',
58
+                                '</small>',
59
+                                $item->get_id(),
60
+                                'text-danger'
61
+                            );
62 62
 
63
-						}
63
+                        }
64 64
 
65
-						$description = ob_get_clean();
65
+                        $description = ob_get_clean();
66 66
 
67
-						// Display the name.
68
-						$tootip = empty( $description ) ? '' : '&nbsp;<i class="fas fa-xs fa-info gp-tooltip d-sm-none text-muted"></i>';
67
+                        // Display the name.
68
+                        $tootip = empty( $description ) ? '' : '&nbsp;<i class="fas fa-xs fa-info gp-tooltip d-sm-none text-muted"></i>';
69 69
 
70
-						$has_featured_image = has_post_thumbnail( $item->get_id() );
70
+                        $has_featured_image = has_post_thumbnail( $item->get_id() );
71 71
 
72
-						if ( $has_featured_image ) {
73
-							echo '<div class="d-flex align-items-center getpaid-form-item-has-featured-image">';
74
-							echo '<div class="getpaid-form-item-image-container mr-2">';
75
-							echo get_the_post_thumbnail( $item->get_id(), 'thumbnail', array( 'class' => 'getpaid-form-item-image mb-0' ) );
76
-							echo '</div>';
77
-							echo '<div class="getpaid-form-item-name-container">';
78
-						}
72
+                        if ( $has_featured_image ) {
73
+                            echo '<div class="d-flex align-items-center getpaid-form-item-has-featured-image">';
74
+                            echo '<div class="getpaid-form-item-image-container mr-2">';
75
+                            echo get_the_post_thumbnail( $item->get_id(), 'thumbnail', array( 'class' => 'getpaid-form-item-image mb-0' ) );
76
+                            echo '</div>';
77
+                            echo '<div class="getpaid-form-item-name-container">';
78
+                        }
79 79
 
80
-						echo '<div class="mb-1 font-weight-bold">' . esc_html( $item->get_name() ) . wp_kses_post( $tootip ) . '</div>';
80
+                        echo '<div class="mb-1 font-weight-bold">' . esc_html( $item->get_name() ) . wp_kses_post( $tootip ) . '</div>';
81 81
 
82
-						if ( ! empty( $description ) ) {
83
-							printf( '<span class="d-none d-sm-block getpaid-item-desc">%s</span>', wp_kses_post( $description ) );
84
-						}
82
+                        if ( ! empty( $description ) ) {
83
+                            printf( '<span class="d-none d-sm-block getpaid-item-desc">%s</span>', wp_kses_post( $description ) );
84
+                        }
85 85
 
86
-						if ( $item->allows_quantities() ) {
87
-							printf(
88
-								'<small class="d-sm-none text-muted form-text">%s</small>',
89
-								sprintf(
90
-									// translators: %s is the item quantity.
91
-									esc_html__( 'Qty %s', 'invoicing' ),
92
-									sprintf(
93
-										'<input
86
+                        if ( $item->allows_quantities() ) {
87
+                            printf(
88
+                                '<small class="d-sm-none text-muted form-text">%s</small>',
89
+                                sprintf(
90
+                                    // translators: %s is the item quantity.
91
+                                    esc_html__( 'Qty %s', 'invoicing' ),
92
+                                    sprintf(
93
+                                        '<input
94 94
 												type="number"
95 95
 												step="0.01"
96 96
 												style="width: 48px;"
@@ -99,62 +99,62 @@  discard block
 block discarded – undo
99 99
 												min="1"
100 100
 												max="%s"
101 101
 												>',
102
-										(float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity(),
103
-										floatval( null !== $max_qty ? $max_qty : 1000000000000 )
104
-									)
105
-								)
106
-							);
107
-						} else {
108
-							printf(
109
-								'<small class="d-sm-none text-muted form-text">%s</small>',
110
-								sprintf(
111
-									// translators: %s is the item quantity.
112
-									esc_html__( 'Qty %s', 'invoicing' ),
113
-									(float) $item->get_quantity()
114
-								)
115
-							);
116
-						}
117
-
118
-						if ( $has_featured_image ) {
119
-							echo '</div>';
120
-							echo '</div>';
121
-						}
122
-					}
123
-
124
-					// Item price.
125
-					if ( 'price' === $key ) {
126
-
127
-					// Set the currency position.
128
-					$position = wpinv_currency_position();
129
-
130
-					if ( 'left_space' === $position ) {
131
-						$position = 'left';
132
-					}
133
-
134
-					if ( 'right_space' === $position ) {
135
-						$position = 'right';
136
-					}
137
-
138
-					if ( $item->user_can_set_their_price() ) {
139
-						$price            = max( (float) $item->get_price(), (float) $item->get_minimum_price() );
140
-						$minimum          = (float) $item->get_minimum_price();
141
-						$validate_minimum = '';
142
-						$class            = '';
143
-						$data_minimum     = '';
144
-
145
-						if ( $minimum > 0 ) {
146
-							$validate_minimum = sprintf(
147
-								// translators: %s is the minimum price.
148
-								esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ),
149
-								wp_strip_all_tags( wpinv_price( $minimum, $currency ) )
150
-							);
151
-
152
-							$class = 'getpaid-validate-minimum-amount';
153
-
154
-							$data_minimum     = "data-minimum-amount='" . esc_attr( getpaid_unstandardize_amount( $minimum ) ) . "'";
155
-						}
156
-
157
-						?>
102
+                                        (float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity(),
103
+                                        floatval( null !== $max_qty ? $max_qty : 1000000000000 )
104
+                                    )
105
+                                )
106
+                            );
107
+                        } else {
108
+                            printf(
109
+                                '<small class="d-sm-none text-muted form-text">%s</small>',
110
+                                sprintf(
111
+                                    // translators: %s is the item quantity.
112
+                                    esc_html__( 'Qty %s', 'invoicing' ),
113
+                                    (float) $item->get_quantity()
114
+                                )
115
+                            );
116
+                        }
117
+
118
+                        if ( $has_featured_image ) {
119
+                            echo '</div>';
120
+                            echo '</div>';
121
+                        }
122
+                    }
123
+
124
+                    // Item price.
125
+                    if ( 'price' === $key ) {
126
+
127
+                    // Set the currency position.
128
+                    $position = wpinv_currency_position();
129
+
130
+                    if ( 'left_space' === $position ) {
131
+                        $position = 'left';
132
+                    }
133
+
134
+                    if ( 'right_space' === $position ) {
135
+                        $position = 'right';
136
+                    }
137
+
138
+                    if ( $item->user_can_set_their_price() ) {
139
+                        $price            = max( (float) $item->get_price(), (float) $item->get_minimum_price() );
140
+                        $minimum          = (float) $item->get_minimum_price();
141
+                        $validate_minimum = '';
142
+                        $class            = '';
143
+                        $data_minimum     = '';
144
+
145
+                        if ( $minimum > 0 ) {
146
+                            $validate_minimum = sprintf(
147
+                                // translators: %s is the minimum price.
148
+                                esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ),
149
+                                wp_strip_all_tags( wpinv_price( $minimum, $currency ) )
150
+                            );
151
+
152
+                            $class = 'getpaid-validate-minimum-amount';
153
+
154
+                            $data_minimum     = "data-minimum-amount='" . esc_attr( getpaid_unstandardize_amount( $minimum ) ) . "'";
155
+                        }
156
+
157
+                        ?>
158 158
 								<div class="input-group input-group-sm">
159 159
 								<?php if ( 'left' === $position ) : ?>
160 160
 										<div class="input-group-prepend">
@@ -179,44 +179,44 @@  discard block
 block discarded – undo
179 179
 
180 180
 							<?php
181 181
 
182
-						} else {
183
-						echo wp_kses_post( wpinv_price( $item->get_price(), $currency ) );
182
+                        } else {
183
+                        echo wp_kses_post( wpinv_price( $item->get_price(), $currency ) );
184 184
 
185
-						?>
185
+                        ?>
186 186
 								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $item->get_price() ); ?>'>
187 187
 						<?php
188
-						}
188
+                        }
189 189
 
190
-					printf(
190
+                    printf(
191 191
                         '<small class="d-sm-none text-muted form-text getpaid-mobile-item-subtotal">%s</small>',
192
-						// translators: %s is the item subtotal.
192
+                        // translators: %s is the item subtotal.
193 193
                         sprintf( esc_html__( 'Subtotal: %s', 'invoicing' ), wp_kses_post( wpinv_price( $item->get_sub_total(), $currency ) ) )
194 194
                     );
195
-					}
195
+                    }
196 196
 
197
-					// Item quantity.
198
-					if ( 'quantity' === $key ) {
197
+                    // Item quantity.
198
+                    if ( 'quantity' === $key ) {
199 199
 
200
-					if ( $item->allows_quantities() ) {
201
-						?>
200
+                    if ( $item->allows_quantities() ) {
201
+                        ?>
202 202
 								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type="number" step="0.01" style='width: 64px; line-height: 1; min-height: 35px;' class='getpaid-item-quantity-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border' value='<?php echo (float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity(); ?>' min='1' <?php echo null !== $max_qty ? 'max="' . (float) $max_qty . '"' : ''; ?> required>
203 203
 							<?php
204
-						} else {
205
-						echo (float) $item->get_quantity();
206
-						echo '&nbsp;&nbsp;&nbsp;';
207
-						?>
204
+                        } else {
205
+                        echo (float) $item->get_quantity();
206
+                        echo '&nbsp;&nbsp;&nbsp;';
207
+                        ?>
208 208
 								<input type='hidden' name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' class='getpaid-item-quantity-input' value='<?php echo (float) $item->get_quantity(); ?>'>
209 209
 						<?php
210
-						}
210
+                        }
211 211
 }
212 212
 
213
-					// Item sub total.
214
-					if ( 'subtotal' === $key ) {
215
-					echo wp_kses_post( wpinv_price( $item->get_sub_total(), $currency ) );
216
-					}
213
+                    // Item sub total.
214
+                    if ( 'subtotal' === $key ) {
215
+                    echo wp_kses_post( wpinv_price( $item->get_sub_total(), $currency ) );
216
+                    }
217 217
 
218
-					do_action( "getpaid_payment_form_cart_item_$key", $item, $form );
219
-				?>
218
+                    do_action( "getpaid_payment_form_cart_item_$key", $item, $form );
219
+                ?>
220 220
 
221 221
 			</div>
222 222
 
Please login to merge, or discard this patch.
templates/invoice/line-item.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -26,90 +26,90 @@
 block discarded – undo
26 26
 
27 27
 				<?php
28 28
 
29
-					// Fires before printing a line item column.
30
-					do_action( "getpaid_invoice_line_item_before_$column", $item, $invoice );
29
+                    // Fires before printing a line item column.
30
+                    do_action( "getpaid_invoice_line_item_before_$column", $item, $invoice );
31 31
 
32
-					// Item name.
33
-					if ( 'name' === $column ) {
32
+                    // Item name.
33
+                    if ( 'name' === $column ) {
34 34
 
35
-						$has_featured_image = has_post_thumbnail( $item->get_id() );
35
+                        $has_featured_image = has_post_thumbnail( $item->get_id() );
36 36
 
37
-						if ( $has_featured_image ) {
38
-							echo '<div class="d-flex align-items-center getpaid-form-item-has-featured-image">';
39
-							echo '<div class="getpaid-form-item-image-container mr-2">';
40
-							echo get_the_post_thumbnail( $item->get_id(), 'thumbnail', array( 'class' => 'getpaid-form-item-image mb-0' ) );
41
-							echo '</div>';
42
-							echo '<div class="getpaid-form-item-name-container">';
43
-						}
37
+                        if ( $has_featured_image ) {
38
+                            echo '<div class="d-flex align-items-center getpaid-form-item-has-featured-image">';
39
+                            echo '<div class="getpaid-form-item-image-container mr-2">';
40
+                            echo get_the_post_thumbnail( $item->get_id(), 'thumbnail', array( 'class' => 'getpaid-form-item-image mb-0' ) );
41
+                            echo '</div>';
42
+                            echo '<div class="getpaid-form-item-name-container">';
43
+                        }
44 44
 
45
-						// Display the name.
46
-						echo '<div class="mb-1">' . esc_html( $item->get_name() ) . '</div>';
45
+                        // Display the name.
46
+                        echo '<div class="mb-1">' . esc_html( $item->get_name() ) . '</div>';
47 47
 
48
-						// And an optional description.
49
-						$description = $item->get_description();
48
+                        // And an optional description.
49
+                        $description = $item->get_description();
50 50
 
51
-						if ( ! empty( $description ) ) {
52
-							echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post( $description ) . '</small>';
53
-						}
51
+                        if ( ! empty( $description ) ) {
52
+                            echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post( $description ) . '</small>';
53
+                        }
54 54
 
55
-						// Fires before printing the line item actions.
56
-						do_action( 'getpaid_before_invoice_line_item_actions', $item, $invoice );
55
+                        // Fires before printing the line item actions.
56
+                        do_action( 'getpaid_before_invoice_line_item_actions', $item, $invoice );
57 57
 
58
-						$actions = apply_filters( 'getpaid-invoice-page-line-item-actions', array(), $item, $invoice );
58
+                        $actions = apply_filters( 'getpaid-invoice-page-line-item-actions', array(), $item, $invoice );
59 59
 
60
-						if ( ! empty( $actions ) ) {
60
+                        if ( ! empty( $actions ) ) {
61 61
 
62
-							$sanitized  = array();
63
-							foreach ( $actions as $key => $item_action ) {
64
-								$key         = sanitize_html_class( $key );
65
-								$item_action = wp_kses_post( $item_action );
66
-								$sanitized[] = "<span class='$key'>$item_action</span>";
67
-							}
62
+                            $sanitized  = array();
63
+                            foreach ( $actions as $key => $item_action ) {
64
+                                $key         = sanitize_html_class( $key );
65
+                                $item_action = wp_kses_post( $item_action );
66
+                                $sanitized[] = "<span class='$key'>$item_action</span>";
67
+                            }
68 68
 
69
-							echo "<small class='form-text getpaid-line-item-actions'>";
70
-							echo wp_kses_post( implode( ' | ', $sanitized ) );
71
-							echo '</small>';
69
+                            echo "<small class='form-text getpaid-line-item-actions'>";
70
+                            echo wp_kses_post( implode( ' | ', $sanitized ) );
71
+                            echo '</small>';
72 72
 
73
-						}
73
+                        }
74 74
 
75
-						if ( $has_featured_image ) {
76
-							echo '</div>';
77
-							echo '</div>';
78
-						}
79
-					}
75
+                        if ( $has_featured_image ) {
76
+                            echo '</div>';
77
+                            echo '</div>';
78
+                        }
79
+                    }
80 80
 
81
-					// Item price.
82
-					if ( 'price' === $column ) {
81
+                    // Item price.
82
+                    if ( 'price' === $column ) {
83 83
 
84
-					// Display the item price (or recurring price if this is a renewal invoice)
85
-					$price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price();
86
-					wpinv_the_price( $price, $invoice->get_currency() );
84
+                    // Display the item price (or recurring price if this is a renewal invoice)
85
+                    $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price();
86
+                    wpinv_the_price( $price, $invoice->get_currency() );
87 87
 
88
-					}
88
+                    }
89 89
 
90
-					// Tax rate.
91
-					if ( 'tax_rate' === $column ) {
92
-					echo floatval( round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%';
93
-					}
90
+                    // Tax rate.
91
+                    if ( 'tax_rate' === $column ) {
92
+                    echo floatval( round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%';
93
+                    }
94 94
 
95
-					// Item quantity.
96
-					if ( 'quantity' === $column ) {
97
-					echo (float) $item->get_quantity();
98
-					}
95
+                    // Item quantity.
96
+                    if ( 'quantity' === $column ) {
97
+                    echo (float) $item->get_quantity();
98
+                    }
99 99
 
100
-					// Item sub total.
101
-					if ( 'subtotal' === $column ) {
102
-					$subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total();
103
-					wpinv_the_price( $subtotal, $invoice->get_currency() );
104
-					}
100
+                    // Item sub total.
101
+                    if ( 'subtotal' === $column ) {
102
+                    $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total();
103
+                    wpinv_the_price( $subtotal, $invoice->get_currency() );
104
+                    }
105 105
 
106
-					// Fires when printing a line item column.
107
-					do_action( "getpaid_invoice_line_item_$column", $item, $invoice );
106
+                    // Fires when printing a line item column.
107
+                    do_action( "getpaid_invoice_line_item_$column", $item, $invoice );
108 108
 
109
-					// Fires after printing a line item column.
110
-					do_action( "getpaid_invoice_line_item_after_$column", $item, $invoice );
109
+                    // Fires after printing a line item column.
110
+                    do_action( "getpaid_invoice_line_item_after_$column", $item, $invoice );
111 111
 
112
-				?>
112
+                ?>
113 113
 
114 114
 			</div>
115 115
 
Please login to merge, or discard this patch.
includes/admin/class-getpaid-post-types-admin.php 1 patch
Indentation   +757 added lines, -757 removed lines patch added patch discarded remove patch
@@ -13,719 +13,719 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Post_Types_Admin {
14 14
 
15 15
     /**
16
-	 * Hook in methods.
17
-	 */
18
-	public static function init() {
19
-
20
-		// Init metaboxes.
21
-		GetPaid_Metaboxes::init();
22
-
23
-		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
-
26
-		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
-
30
-		// Invoice table columns.
31
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
-		add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
-		add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
-
36
-		// Items table columns.
37
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
-
44
-		// Payment forms columns.
45
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
-
49
-		// Discount table columns.
50
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
-
53
-		// Deleting posts.
54
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
-
57
-		add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
-	}
59
-
60
-	/**
61
-	 * Post updated messages.
62
-	 */
63
-	public static function post_updated_messages( $messages ) {
64
-		global $post;
65
-
66
-		$messages['wpi_discount'] = array(
67
-			0  => '',
68
-			1  => __( 'Discount updated.', 'invoicing' ),
69
-			2  => __( 'Custom field updated.', 'invoicing' ),
70
-			3  => __( 'Custom field deleted.', 'invoicing' ),
71
-			4  => __( 'Discount updated.', 'invoicing' ),
72
-			5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
-			6  => __( 'Discount updated.', 'invoicing' ),
74
-			7  => __( 'Discount saved.', 'invoicing' ),
75
-			8  => __( 'Discount submitted.', 'invoicing' ),
76
-			9  => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
-			10 => __( 'Discount draft updated.', 'invoicing' ),
78
-		);
79
-
80
-		$messages['wpi_payment_form'] = array(
81
-			0  => '',
82
-			1  => __( 'Payment Form updated.', 'invoicing' ),
83
-			2  => __( 'Custom field updated.', 'invoicing' ),
84
-			3  => __( 'Custom field deleted.', 'invoicing' ),
85
-			4  => __( 'Payment Form updated.', 'invoicing' ),
86
-			5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
-			6  => __( 'Payment Form updated.', 'invoicing' ),
88
-			7  => __( 'Payment Form saved.', 'invoicing' ),
89
-			8  => __( 'Payment Form submitted.', 'invoicing' ),
90
-			9  => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
-			10 => __( 'Payment Form draft updated.', 'invoicing' ),
92
-		);
93
-
94
-		return $messages;
95
-
96
-	}
97
-
98
-	/**
99
-	 * Post row actions.
100
-	 */
101
-	public static function post_row_actions( $actions, $post ) {
102
-
103
-		$post = get_post( $post );
104
-
105
-		// We do not want to edit the default payment form.
106
-		if ( 'wpi_payment_form' == $post->post_type ) {
107
-
108
-			if ( $post->ID == wpinv_get_default_payment_form() ) {
109
-				unset( $actions['trash'] );
110
-				unset( $actions['inline hide-if-no-js'] );
111
-			}
112
-
113
-			$actions['duplicate'] = sprintf(
114
-				'<a href="%1$s">%2$s</a>',
115
-				esc_url(
116
-					wp_nonce_url(
117
-						add_query_arg(
118
-							array(
119
-								'getpaid-admin-action' => 'duplicate_form',
120
-								'form_id'              => $post->ID,
121
-							)
122
-						),
123
-						'getpaid-nonce',
124
-						'getpaid-nonce'
125
-					)
126
-				),
127
-				esc_html( __( 'Duplicate', 'invoicing' ) )
128
-			);
129
-
130
-		}
131
-
132
-		// Link to item payment form.
133
-		if ( 'wpi_item' == $post->post_type ) {
134
-
135
-			if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) {
136
-
137
-				$actions['buy'] = sprintf(
138
-					'<a href="%1$s">%2$s</a>',
139
-					esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
140
-					esc_html( __( 'Buy', 'invoicing' ) )
141
-				);
142
-
143
-			}
16
+     * Hook in methods.
17
+     */
18
+    public static function init() {
19
+
20
+        // Init metaboxes.
21
+        GetPaid_Metaboxes::init();
22
+
23
+        // Filter the post updated messages.
24
+        add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
+
26
+        // Filter post actions.
27
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
+
30
+        // Invoice table columns.
31
+        add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
+        add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
+        add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
+        add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
+
36
+        // Items table columns.
37
+        add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
+        add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
+        add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
+        add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
+        add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
+        add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
+
44
+        // Payment forms columns.
45
+        add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
+        add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
+
49
+        // Discount table columns.
50
+        add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
+        add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
+
53
+        // Deleting posts.
54
+        add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
+
57
+        add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
+    }
59
+
60
+    /**
61
+     * Post updated messages.
62
+     */
63
+    public static function post_updated_messages( $messages ) {
64
+        global $post;
65
+
66
+        $messages['wpi_discount'] = array(
67
+            0  => '',
68
+            1  => __( 'Discount updated.', 'invoicing' ),
69
+            2  => __( 'Custom field updated.', 'invoicing' ),
70
+            3  => __( 'Custom field deleted.', 'invoicing' ),
71
+            4  => __( 'Discount updated.', 'invoicing' ),
72
+            5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
+            6  => __( 'Discount updated.', 'invoicing' ),
74
+            7  => __( 'Discount saved.', 'invoicing' ),
75
+            8  => __( 'Discount submitted.', 'invoicing' ),
76
+            9  => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
+            10 => __( 'Discount draft updated.', 'invoicing' ),
78
+        );
79
+
80
+        $messages['wpi_payment_form'] = array(
81
+            0  => '',
82
+            1  => __( 'Payment Form updated.', 'invoicing' ),
83
+            2  => __( 'Custom field updated.', 'invoicing' ),
84
+            3  => __( 'Custom field deleted.', 'invoicing' ),
85
+            4  => __( 'Payment Form updated.', 'invoicing' ),
86
+            5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
+            6  => __( 'Payment Form updated.', 'invoicing' ),
88
+            7  => __( 'Payment Form saved.', 'invoicing' ),
89
+            8  => __( 'Payment Form submitted.', 'invoicing' ),
90
+            9  => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
+            10 => __( 'Payment Form draft updated.', 'invoicing' ),
92
+        );
93
+
94
+        return $messages;
95
+
96
+    }
97
+
98
+    /**
99
+     * Post row actions.
100
+     */
101
+    public static function post_row_actions( $actions, $post ) {
102
+
103
+        $post = get_post( $post );
104
+
105
+        // We do not want to edit the default payment form.
106
+        if ( 'wpi_payment_form' == $post->post_type ) {
107
+
108
+            if ( $post->ID == wpinv_get_default_payment_form() ) {
109
+                unset( $actions['trash'] );
110
+                unset( $actions['inline hide-if-no-js'] );
111
+            }
112
+
113
+            $actions['duplicate'] = sprintf(
114
+                '<a href="%1$s">%2$s</a>',
115
+                esc_url(
116
+                    wp_nonce_url(
117
+                        add_query_arg(
118
+                            array(
119
+                                'getpaid-admin-action' => 'duplicate_form',
120
+                                'form_id'              => $post->ID,
121
+                            )
122
+                        ),
123
+                        'getpaid-nonce',
124
+                        'getpaid-nonce'
125
+                    )
126
+                ),
127
+                esc_html( __( 'Duplicate', 'invoicing' ) )
128
+            );
129
+
130
+        }
131
+
132
+        // Link to item payment form.
133
+        if ( 'wpi_item' == $post->post_type ) {
134
+
135
+            if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) {
136
+
137
+                $actions['buy'] = sprintf(
138
+                    '<a href="%1$s">%2$s</a>',
139
+                    esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
140
+                    esc_html( __( 'Buy', 'invoicing' ) )
141
+                );
142
+
143
+            }
144 144
 }
145 145
 
146
-		return $actions;
147
-	}
146
+        return $actions;
147
+    }
148 148
 
149
-	/**
149
+    /**
150 150
      * Remove bulk edit option from admin side quote listing
151 151
      *
152 152
      * @since    1.0.0
153 153
      * @param array $actions post actions
154
-	 * @param WP_Post $post
154
+     * @param WP_Post $post
155 155
      * @return array $actions actions without edit option
156 156
      */
157 157
     public static function filter_invoice_row_actions( $actions, $post ) {
158 158
 
159 159
         if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
160 160
 
161
-			$actions = array();
162
-			$invoice = new WPInv_Invoice( $post );
163
-
164
-			$actions['edit'] = sprintf(
165
-				'<a href="%1$s">%2$s</a>',
166
-				esc_url( get_edit_post_link( $invoice->get_id() ) ),
167
-				esc_html( __( 'Edit', 'invoicing' ) )
168
-			);
169
-
170
-			if ( ! $invoice->is_draft() ) {
171
-
172
-				$actions['view'] = sprintf(
173
-					'<a href="%1$s">%2$s</a>',
174
-					esc_url( $invoice->get_view_url() ),
175
-					sprintf(
176
-						esc_html( __( 'View %s', 'invoicing' ) ),
177
-						getpaid_get_post_type_label( $invoice->get_post_type(), false )
178
-					)
179
-				);
180
-
181
-				$actions['send'] = sprintf(
182
-					'<a href="%1$s">%2$s</a>',
183
-					esc_url(
184
-						wp_nonce_url(
185
-							add_query_arg(
186
-								array(
187
-									'getpaid-admin-action' => 'send_invoice',
188
-									'invoice_id'           => $invoice->get_id(),
189
-								)
190
-							),
191
-							'getpaid-nonce',
192
-							'getpaid-nonce'
193
-						)
194
-					),
195
-					esc_html( __( 'Send to Customer', 'invoicing' ) )
196
-				);
197
-
198
-			}
199
-
200
-			$actions['duplicate'] = sprintf(
201
-				'<a href="%1$s">%2$s</a>',
202
-				esc_url(
203
-					wp_nonce_url(
204
-						add_query_arg(
205
-							array(
206
-								'getpaid-admin-action' => 'duplicate_invoice',
207
-								'invoice_id'           => $post->ID,
208
-							)
209
-						),
210
-						'getpaid-nonce',
211
-						'getpaid-nonce'
212
-					)
213
-				),
214
-				esc_html( __( 'Duplicate', 'invoicing' ) )
215
-			);
161
+            $actions = array();
162
+            $invoice = new WPInv_Invoice( $post );
163
+
164
+            $actions['edit'] = sprintf(
165
+                '<a href="%1$s">%2$s</a>',
166
+                esc_url( get_edit_post_link( $invoice->get_id() ) ),
167
+                esc_html( __( 'Edit', 'invoicing' ) )
168
+            );
169
+
170
+            if ( ! $invoice->is_draft() ) {
171
+
172
+                $actions['view'] = sprintf(
173
+                    '<a href="%1$s">%2$s</a>',
174
+                    esc_url( $invoice->get_view_url() ),
175
+                    sprintf(
176
+                        esc_html( __( 'View %s', 'invoicing' ) ),
177
+                        getpaid_get_post_type_label( $invoice->get_post_type(), false )
178
+                    )
179
+                );
180
+
181
+                $actions['send'] = sprintf(
182
+                    '<a href="%1$s">%2$s</a>',
183
+                    esc_url(
184
+                        wp_nonce_url(
185
+                            add_query_arg(
186
+                                array(
187
+                                    'getpaid-admin-action' => 'send_invoice',
188
+                                    'invoice_id'           => $invoice->get_id(),
189
+                                )
190
+                            ),
191
+                            'getpaid-nonce',
192
+                            'getpaid-nonce'
193
+                        )
194
+                    ),
195
+                    esc_html( __( 'Send to Customer', 'invoicing' ) )
196
+                );
197
+
198
+            }
199
+
200
+            $actions['duplicate'] = sprintf(
201
+                '<a href="%1$s">%2$s</a>',
202
+                esc_url(
203
+                    wp_nonce_url(
204
+                        add_query_arg(
205
+                            array(
206
+                                'getpaid-admin-action' => 'duplicate_invoice',
207
+                                'invoice_id'           => $post->ID,
208
+                            )
209
+                        ),
210
+                        'getpaid-nonce',
211
+                        'getpaid-nonce'
212
+                    )
213
+                ),
214
+                esc_html( __( 'Duplicate', 'invoicing' ) )
215
+            );
216 216
 
217 217
         }
218 218
 
219 219
         return $actions;
220
-	}
221
-
222
-	/**
223
-	 * Returns an array of invoice table columns.
224
-	 */
225
-	public static function invoice_columns( $columns ) {
226
-
227
-		$columns = array(
228
-			'cb'           => $columns['cb'],
229
-			'number'       => __( 'Invoice', 'invoicing' ),
230
-			'customer'     => __( 'Customer', 'invoicing' ),
231
-			'invoice_date' => __( 'Created', 'invoicing' ),
232
-			'payment_date' => __( 'Completed', 'invoicing' ),
233
-			'amount'       => __( 'Amount', 'invoicing' ),
234
-			'recurring'    => __( 'Recurring', 'invoicing' ),
235
-			'status'       => __( 'Status', 'invoicing' ),
236
-		);
237
-
238
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
239
-	}
240
-
241
-	/**
242
-	 * Displays invoice table columns.
243
-	 */
244
-	public static function display_invoice_columns( $column_name, $post_id ) {
245
-
246
-		$invoice = new WPInv_Invoice( $post_id );
247
-
248
-		switch ( $column_name ) {
249
-
250
-			case 'invoice_date':
251
-				$date_time = esc_attr( $invoice->get_created_date() );
252
-				$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
253
-				echo wp_kses_post( "<span title='$date_time'>$date</span>" );
254
-				break;
255
-
256
-			case 'payment_date':
257
-				if ( $invoice->is_paid() ) {
258
-					$date_time = esc_attr( $invoice->get_completed_date() );
259
-					$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
260
-					echo wp_kses_post( "<span title='$date_time'>$date</span>" );
261
-				} else {
262
-					echo '&mdash;';
263
-				}
264
-
265
-				break;
266
-
267
-			case 'amount':
268
-				$amount = $invoice->get_total();
269
-				$formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) );
270
-
271
-				if ( $invoice->is_refunded() ) {
272
-					$refunded_amount = wpinv_price( 0, $invoice->get_currency() );
273
-					echo wp_kses_post( "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>" );
274
-				} else {
275
-
276
-					$discount = $invoice->get_total_discount();
277
-
278
-					if ( ! empty( $discount ) ) {
279
-						$new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
280
-						echo wp_kses_post( "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>" );
281
-					} else {
282
-						echo wp_kses_post( $formated_amount );
283
-					}
220
+    }
221
+
222
+    /**
223
+     * Returns an array of invoice table columns.
224
+     */
225
+    public static function invoice_columns( $columns ) {
226
+
227
+        $columns = array(
228
+            'cb'           => $columns['cb'],
229
+            'number'       => __( 'Invoice', 'invoicing' ),
230
+            'customer'     => __( 'Customer', 'invoicing' ),
231
+            'invoice_date' => __( 'Created', 'invoicing' ),
232
+            'payment_date' => __( 'Completed', 'invoicing' ),
233
+            'amount'       => __( 'Amount', 'invoicing' ),
234
+            'recurring'    => __( 'Recurring', 'invoicing' ),
235
+            'status'       => __( 'Status', 'invoicing' ),
236
+        );
237
+
238
+        return apply_filters( 'wpi_invoice_table_columns', $columns );
239
+    }
240
+
241
+    /**
242
+     * Displays invoice table columns.
243
+     */
244
+    public static function display_invoice_columns( $column_name, $post_id ) {
245
+
246
+        $invoice = new WPInv_Invoice( $post_id );
247
+
248
+        switch ( $column_name ) {
249
+
250
+            case 'invoice_date':
251
+                $date_time = esc_attr( $invoice->get_created_date() );
252
+                $date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
253
+                echo wp_kses_post( "<span title='$date_time'>$date</span>" );
254
+                break;
255
+
256
+            case 'payment_date':
257
+                if ( $invoice->is_paid() ) {
258
+                    $date_time = esc_attr( $invoice->get_completed_date() );
259
+                    $date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
260
+                    echo wp_kses_post( "<span title='$date_time'>$date</span>" );
261
+                } else {
262
+                    echo '&mdash;';
263
+                }
264
+
265
+                break;
266
+
267
+            case 'amount':
268
+                $amount = $invoice->get_total();
269
+                $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) );
270
+
271
+                if ( $invoice->is_refunded() ) {
272
+                    $refunded_amount = wpinv_price( 0, $invoice->get_currency() );
273
+                    echo wp_kses_post( "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>" );
274
+                } else {
275
+
276
+                    $discount = $invoice->get_total_discount();
277
+
278
+                    if ( ! empty( $discount ) ) {
279
+                        $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
280
+                        echo wp_kses_post( "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>" );
281
+                    } else {
282
+                        echo wp_kses_post( $formated_amount );
283
+                    }
284 284
 }
285 285
 
286
-				break;
287
-
288
-			case 'status':
289
-				$status       = esc_html( $invoice->get_status() );
290
-				$status_label = esc_html( $invoice->get_status_nicename() );
291
-
292
-				// If it is paid, show the gateway title.
293
-				if ( $invoice->is_paid() ) {
294
-					$gateway = esc_html( $invoice->get_gateway_title() );
295
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) );
296
-
297
-					echo wp_kses_post( "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>" );
298
-				} else {
299
-					echo wp_kses_post( "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>" );
300
-				}
301
-
302
-				// If it is not paid, display the overdue and view status.
303
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
304
-
305
-					// Invoice view status.
306
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
307
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>';
308
-					} else {
309
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>';
310
-					}
311
-
312
-					// Display the overview status.
313
-					if ( wpinv_get_option( 'overdue_active' ) ) {
314
-						$due_date = $invoice->get_due_date();
315
-						$fomatted = getpaid_format_date( $due_date );
316
-
317
-						if ( ! empty( $fomatted ) ) {
318
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
319
-							echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" );
320
-						}
321
-					}
286
+                break;
287
+
288
+            case 'status':
289
+                $status       = esc_html( $invoice->get_status() );
290
+                $status_label = esc_html( $invoice->get_status_nicename() );
291
+
292
+                // If it is paid, show the gateway title.
293
+                if ( $invoice->is_paid() ) {
294
+                    $gateway = esc_html( $invoice->get_gateway_title() );
295
+                    $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) );
296
+
297
+                    echo wp_kses_post( "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>" );
298
+                } else {
299
+                    echo wp_kses_post( "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>" );
300
+                }
301
+
302
+                // If it is not paid, display the overdue and view status.
303
+                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
304
+
305
+                    // Invoice view status.
306
+                    if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
307
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>';
308
+                    } else {
309
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>';
310
+                    }
311
+
312
+                    // Display the overview status.
313
+                    if ( wpinv_get_option( 'overdue_active' ) ) {
314
+                        $due_date = $invoice->get_due_date();
315
+                        $fomatted = getpaid_format_date( $due_date );
316
+
317
+                        if ( ! empty( $fomatted ) ) {
318
+                            $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
319
+                            echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" );
320
+                        }
321
+                    }
322 322
 }
323 323
 
324
-				break;
324
+                break;
325 325
 
326
-			case 'recurring':
327
-				if ( $invoice->is_recurring() ) {
328
-					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
329
-				} else {
330
-					echo '<i class="fa fa-times" style="color:#616161;"></i>';
331
-				}
332
-				break;
326
+            case 'recurring':
327
+                if ( $invoice->is_recurring() ) {
328
+                    echo '<i class="fa fa-check" style="color:#43850a;"></i>';
329
+                } else {
330
+                    echo '<i class="fa fa-times" style="color:#616161;"></i>';
331
+                }
332
+                break;
333 333
 
334
-			case 'number':
335
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
336
-				$invoice_number  = esc_html( $invoice->get_number() );
337
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
334
+            case 'number':
335
+                $edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
336
+                $invoice_number  = esc_html( $invoice->get_number() );
337
+                $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
338 338
 
339
-				echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" );
339
+                echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" );
340 340
 
341
-				break;
341
+                break;
342 342
 
343
-			case 'customer':
344
-				$customer_name = $invoice->get_user_full_name();
343
+            case 'customer':
344
+                $customer_name = $invoice->get_user_full_name();
345 345
 
346
-				if ( empty( $customer_name ) ) {
347
-					$customer_name = $invoice->get_email();
348
-				}
346
+                if ( empty( $customer_name ) ) {
347
+                    $customer_name = $invoice->get_email();
348
+                }
349 349
 
350
-				if ( ! empty( $customer_name ) ) {
351
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
352
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
353
-					echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" );
354
-				} else {
355
-					echo '<div>&mdash;</div>';
356
-				}
350
+                if ( ! empty( $customer_name ) ) {
351
+                    $customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
352
+                    $view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
353
+                    echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" );
354
+                } else {
355
+                    echo '<div>&mdash;</div>';
356
+                }
357 357
 
358
-				break;
359
-
360
-		}
361
-
362
-	}
363
-
364
-	/**
365
-	 * Displays invoice bulk actions.
366
-	 */
367
-	public static function invoice_bulk_actions( $actions ) {
368
-		$actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
369
-		return $actions;
370
-	}
371
-
372
-	/**
373
-	 * Processes invoice bulk actions.
374
-	 */
375
-	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
376
-
377
-		if ( $action == 'resend-invoice' ) {
378
-			foreach ( $post_ids as $post_id ) {
379
-				getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
380
-			}
381
-		}
382
-
383
-		return $redirect_url;
384
-
385
-	}
386
-
387
-	/**
388
-	 * Returns an array of payment forms table columns.
389
-	 */
390
-	public static function payment_form_columns( $columns ) {
391
-
392
-		$columns = array(
393
-			'cb'        => $columns['cb'],
394
-			'title'     => __( 'Name', 'invoicing' ),
395
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
396
-			'earnings'  => __( 'Revenue', 'invoicing' ),
397
-			'refunds'   => __( 'Refunded', 'invoicing' ),
398
-			'items'     => __( 'Items', 'invoicing' ),
399
-			'date'      => __( 'Date', 'invoicing' ),
400
-		);
401
-
402
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
403
-
404
-	}
405
-
406
-	/**
407
-	 * Displays payment form table columns.
408
-	 */
409
-	public static function display_payment_form_columns( $column_name, $post_id ) {
410
-
411
-		// Retrieve the payment form.
412
-		$form = new GetPaid_Payment_Form( $post_id );
413
-
414
-		switch ( $column_name ) {
415
-
416
-			case 'earnings':
417
-				echo wp_kses_post( wpinv_price( $form->get_earned() ) );
418
-				break;
419
-
420
-			case 'refunds':
421
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
422
-				break;
423
-
424
-			case 'refunds':
425
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
426
-				break;
427
-
428
-			case 'shortcode':
429
-				if ( $form->is_default() ) {
430
-					echo '&mdash;';
431
-				} else {
432
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
433
-				}
434
-
435
-				break;
358
+                break;
436 359
 
437
-			case 'items':
438
-				$items = $form->get_items();
439
-
440
-				if ( $form->is_default() || empty( $items ) ) {
441
-					echo '&mdash;';
442
-					return;
443
-				}
444
-
445
-				$_items = array();
446
-
447
-				foreach ( $items as $item ) {
448
-					$url = $item->get_edit_url();
449
-
450
-					if ( empty( $url ) ) {
451
-						$_items[] = esc_html( $item->get_name() );
452
-					} else {
453
-						$_items[] = sprintf(
454
-							'<a href="%s">%s</a>',
455
-							esc_url( $url ),
456
-							esc_html( $item->get_name() )
457
-						);
458
-					}
360
+        }
361
+
362
+    }
363
+
364
+    /**
365
+     * Displays invoice bulk actions.
366
+     */
367
+    public static function invoice_bulk_actions( $actions ) {
368
+        $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
369
+        return $actions;
370
+    }
371
+
372
+    /**
373
+     * Processes invoice bulk actions.
374
+     */
375
+    public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
376
+
377
+        if ( $action == 'resend-invoice' ) {
378
+            foreach ( $post_ids as $post_id ) {
379
+                getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
380
+            }
381
+        }
382
+
383
+        return $redirect_url;
384
+
385
+    }
386
+
387
+    /**
388
+     * Returns an array of payment forms table columns.
389
+     */
390
+    public static function payment_form_columns( $columns ) {
391
+
392
+        $columns = array(
393
+            'cb'        => $columns['cb'],
394
+            'title'     => __( 'Name', 'invoicing' ),
395
+            'shortcode' => __( 'Shortcode', 'invoicing' ),
396
+            'earnings'  => __( 'Revenue', 'invoicing' ),
397
+            'refunds'   => __( 'Refunded', 'invoicing' ),
398
+            'items'     => __( 'Items', 'invoicing' ),
399
+            'date'      => __( 'Date', 'invoicing' ),
400
+        );
401
+
402
+        return apply_filters( 'wpi_payment_form_table_columns', $columns );
403
+
404
+    }
405
+
406
+    /**
407
+     * Displays payment form table columns.
408
+     */
409
+    public static function display_payment_form_columns( $column_name, $post_id ) {
410
+
411
+        // Retrieve the payment form.
412
+        $form = new GetPaid_Payment_Form( $post_id );
413
+
414
+        switch ( $column_name ) {
415
+
416
+            case 'earnings':
417
+                echo wp_kses_post( wpinv_price( $form->get_earned() ) );
418
+                break;
419
+
420
+            case 'refunds':
421
+                echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
422
+                break;
423
+
424
+            case 'refunds':
425
+                echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
426
+                break;
427
+
428
+            case 'shortcode':
429
+                if ( $form->is_default() ) {
430
+                    echo '&mdash;';
431
+                } else {
432
+                    echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
433
+                }
434
+
435
+                break;
436
+
437
+            case 'items':
438
+                $items = $form->get_items();
439
+
440
+                if ( $form->is_default() || empty( $items ) ) {
441
+                    echo '&mdash;';
442
+                    return;
443
+                }
444
+
445
+                $_items = array();
446
+
447
+                foreach ( $items as $item ) {
448
+                    $url = $item->get_edit_url();
449
+
450
+                    if ( empty( $url ) ) {
451
+                        $_items[] = esc_html( $item->get_name() );
452
+                    } else {
453
+                        $_items[] = sprintf(
454
+                            '<a href="%s">%s</a>',
455
+                            esc_url( $url ),
456
+                            esc_html( $item->get_name() )
457
+                        );
458
+                    }
459 459
 }
460 460
 
461
-				echo wp_kses_post( implode( '<br>', $_items ) );
461
+                echo wp_kses_post( implode( '<br>', $_items ) );
462 462
 
463
-				break;
463
+                break;
464 464
 
465
-		}
465
+        }
466 466
 
467
-	}
467
+    }
468 468
 
469
-	/**
470
-	 * Filters post states.
471
-	 */
472
-	public static function filter_payment_form_state( $post_states, $post ) {
469
+    /**
470
+     * Filters post states.
471
+     */
472
+    public static function filter_payment_form_state( $post_states, $post ) {
473 473
 
474
-		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
475
-			$post_states['default_form'] = __( 'Default Payment Form', 'invoicing' );
476
-		}
474
+        if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
475
+            $post_states['default_form'] = __( 'Default Payment Form', 'invoicing' );
476
+        }
477 477
 
478
-		return $post_states;
478
+        return $post_states;
479 479
 
480
-	}
480
+    }
481 481
 
482
-	/**
483
-	 * Returns an array of coupon table columns.
484
-	 */
485
-	public static function discount_columns( $columns ) {
482
+    /**
483
+     * Returns an array of coupon table columns.
484
+     */
485
+    public static function discount_columns( $columns ) {
486
+
487
+        $columns = array(
488
+            'cb'          => $columns['cb'],
489
+            'title'       => __( 'Name', 'invoicing' ),
490
+            'code'        => __( 'Code', 'invoicing' ),
491
+            'amount'      => __( 'Amount', 'invoicing' ),
492
+            'usage'       => __( 'Usage / Limit', 'invoicing' ),
493
+            'start_date'  => __( 'Start Date', 'invoicing' ),
494
+            'expiry_date' => __( 'Expiry Date', 'invoicing' ),
495
+        );
496
+
497
+        return apply_filters( 'wpi_discount_table_columns', $columns );
498
+    }
486 499
 
487
-		$columns = array(
488
-			'cb'          => $columns['cb'],
489
-			'title'       => __( 'Name', 'invoicing' ),
490
-			'code'        => __( 'Code', 'invoicing' ),
491
-			'amount'      => __( 'Amount', 'invoicing' ),
492
-			'usage'       => __( 'Usage / Limit', 'invoicing' ),
493
-			'start_date'  => __( 'Start Date', 'invoicing' ),
494
-			'expiry_date' => __( 'Expiry Date', 'invoicing' ),
495
-		);
500
+    /**
501
+     * Filters post states.
502
+     */
503
+    public static function filter_discount_state( $post_states, $post ) {
496 504
 
497
-		return apply_filters( 'wpi_discount_table_columns', $columns );
498
-	}
505
+        if ( 'wpi_discount' == $post->post_type ) {
499 506
 
500
-	/**
501
-	 * Filters post states.
502
-	 */
503
-	public static function filter_discount_state( $post_states, $post ) {
507
+            $discount = new WPInv_Discount( $post );
504 508
 
505
-		if ( 'wpi_discount' == $post->post_type ) {
509
+            $status = $discount->is_expired() ? 'expired' : $discount->get_status();
506 510
 
507
-			$discount = new WPInv_Discount( $post );
511
+            if ( $status != 'publish' ) {
512
+                return array(
513
+                    'discount_status' => wpinv_discount_status( $status ),
514
+                );
515
+            }
508 516
 
509
-			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
517
+            return array();
510 518
 
511
-			if ( $status != 'publish' ) {
512
-				return array(
513
-					'discount_status' => wpinv_discount_status( $status ),
514
-				);
515
-			}
519
+        }
516 520
 
517
-			return array();
521
+        return $post_states;
518 522
 
519
-		}
523
+    }
520 524
 
521
-		return $post_states;
525
+    /**
526
+     * Returns an array of items table columns.
527
+     */
528
+    public static function item_columns( $columns ) {
529
+
530
+        $columns = array(
531
+            'cb'        => $columns['cb'],
532
+            'title'     => __( 'Name', 'invoicing' ),
533
+            'price'     => __( 'Price', 'invoicing' ),
534
+            'vat_rule'  => __( 'Tax Rule', 'invoicing' ),
535
+            'vat_class' => __( 'Tax Class', 'invoicing' ),
536
+            'type'      => __( 'Type', 'invoicing' ),
537
+            'shortcode' => __( 'Shortcode', 'invoicing' ),
538
+        );
539
+
540
+        if ( ! wpinv_use_taxes() ) {
541
+            unset( $columns['vat_rule'] );
542
+            unset( $columns['vat_class'] );
543
+        }
544
+
545
+        return apply_filters( 'wpi_item_table_columns', $columns );
546
+    }
547
+
548
+    /**
549
+     * Returns an array of sortable items table columns.
550
+     */
551
+    public static function sortable_item_columns( $columns ) {
552
+
553
+        return array_merge(
554
+            $columns,
555
+            array(
556
+                'price'     => 'price',
557
+                'vat_rule'  => 'vat_rule',
558
+                'vat_class' => 'vat_class',
559
+                'type'      => 'type',
560
+            )
561
+        );
562
+
563
+    }
564
+
565
+    /**
566
+     * Displays items table columns.
567
+     */
568
+    public static function display_item_columns( $column_name, $post_id ) {
569
+
570
+        $item = new WPInv_Item( $post_id );
571
+
572
+        switch ( $column_name ) {
573
+
574
+            case 'price':
575
+                if ( ! $item->is_recurring() ) {
576
+                    echo wp_kses_post( $item->get_the_price() );
577
+                    break;
578
+                }
579
+
580
+                $price = wp_sprintf(
581
+                    __( '%1$s / %2$s', 'invoicing' ),
582
+                    $item->get_the_price(),
583
+                    getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
584
+                );
585
+
586
+                if ( $item->get_the_price() == $item->get_the_initial_price() ) {
587
+                    echo wp_kses_post( $price );
588
+                    break;
589
+                }
590
+
591
+                echo wp_kses_post( $item->get_the_initial_price() );
592
+
593
+                echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>';
594
+                break;
595
+
596
+            case 'vat_rule':
597
+                echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) );
598
+                break;
599
+
600
+            case 'vat_class':
601
+                echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) );
602
+                break;
603
+
604
+            case 'shortcode':
605
+                if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
606
+                    echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
607
+                } else {
608
+                    echo '&mdash;';
609
+                }
610
+
611
+                break;
612
+
613
+            case 'type':
614
+                echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' );
615
+                break;
616
+
617
+        }
618
+
619
+    }
620
+
621
+    /**
622
+     * Lets users filter items using taxes.
623
+     */
624
+    public static function add_item_filters( $post_type ) {
625
+
626
+        // Abort if we're not dealing with items.
627
+        if ( $post_type != 'wpi_item' ) {
628
+            return;
629
+        }
630
+
631
+        // Filter by vat rules.
632
+        if ( wpinv_use_taxes() ) {
633
+
634
+            // Sanitize selected vat rule.
635
+            $vat_rule   = '';
636
+            $vat_rules  = getpaid_get_tax_rules();
637
+            if ( isset( $_GET['vat_rule'] ) ) {
638
+                $vat_rule   = sanitize_text_field( $_GET['vat_rule'] );
639
+            }
640
+
641
+            // Filter by VAT rule.
642
+            wpinv_html_select(
643
+                array(
644
+                    'options'          => array_merge(
645
+                        array(
646
+                            '' => __( 'All Tax Rules', 'invoicing' ),
647
+                        ),
648
+                        $vat_rules
649
+                    ),
650
+                    'name'             => 'vat_rule',
651
+                    'id'               => 'vat_rule',
652
+                    'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
653
+                    'show_option_all'  => false,
654
+                    'show_option_none' => false,
655
+                )
656
+            );
657
+
658
+            // Filter by VAT class.
659
+
660
+            // Sanitize selected vat rule.
661
+            $vat_class   = '';
662
+            $vat_classes = getpaid_get_tax_classes();
663
+            if ( isset( $_GET['vat_class'] ) ) {
664
+                $vat_class   = sanitize_text_field( $_GET['vat_class'] );
665
+            }
666
+
667
+            wpinv_html_select(
668
+                array(
669
+                    'options'          => array_merge(
670
+                        array(
671
+                            '' => __( 'All Tax Classes', 'invoicing' ),
672
+                        ),
673
+                        $vat_classes
674
+                    ),
675
+                    'name'             => 'vat_class',
676
+                    'id'               => 'vat_class',
677
+                    'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
678
+                    'show_option_all'  => false,
679
+                    'show_option_none' => false,
680
+                )
681
+            );
682
+
683
+        }
684
+
685
+        // Filter by item type.
686
+        $type   = '';
687
+        if ( isset( $_GET['type'] ) ) {
688
+            $type   = sanitize_text_field( $_GET['type'] );
689
+        }
522 690
 
523
-	}
691
+        wpinv_html_select(
692
+            array(
693
+                'options'          => array_merge(
694
+                    array(
695
+                        '' => __( 'All item types', 'invoicing' ),
696
+                    ),
697
+                    wpinv_get_item_types()
698
+                ),
699
+                'name'             => 'type',
700
+                'id'               => 'type',
701
+                'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
702
+                'show_option_all'  => false,
703
+                'show_option_none' => false,
704
+            )
705
+        );
524 706
 
525
-	/**
526
-	 * Returns an array of items table columns.
527
-	 */
528
-	public static function item_columns( $columns ) {
707
+    }
529 708
 
530
-		$columns = array(
531
-			'cb'        => $columns['cb'],
532
-			'title'     => __( 'Name', 'invoicing' ),
533
-			'price'     => __( 'Price', 'invoicing' ),
534
-			'vat_rule'  => __( 'Tax Rule', 'invoicing' ),
535
-			'vat_class' => __( 'Tax Class', 'invoicing' ),
536
-			'type'      => __( 'Type', 'invoicing' ),
537
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
538
-		);
709
+    /**
710
+     * Filters the item query.
711
+     */
712
+    public static function filter_item_query( $query ) {
539 713
 
540
-		if ( ! wpinv_use_taxes() ) {
541
-			unset( $columns['vat_rule'] );
542
-			unset( $columns['vat_class'] );
543
-		}
714
+        // modify the query only if it admin and main query.
715
+        if ( ! ( is_admin() && $query->is_main_query() ) ) {
716
+            return $query;
717
+        }
544 718
 
545
-		return apply_filters( 'wpi_item_table_columns', $columns );
546
-	}
719
+        // we want to modify the query for our items.
720
+        if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ) {
721
+            return $query;
722
+        }
547 723
 
548
-	/**
549
-	 * Returns an array of sortable items table columns.
550
-	 */
551
-	public static function sortable_item_columns( $columns ) {
552
-
553
-		return array_merge(
554
-			$columns,
555
-			array(
556
-				'price'     => 'price',
557
-				'vat_rule'  => 'vat_rule',
558
-				'vat_class' => 'vat_class',
559
-				'type'      => 'type',
560
-			)
561
-		);
562
-
563
-	}
564
-
565
-	/**
566
-	 * Displays items table columns.
567
-	 */
568
-	public static function display_item_columns( $column_name, $post_id ) {
569
-
570
-		$item = new WPInv_Item( $post_id );
571
-
572
-		switch ( $column_name ) {
573
-
574
-			case 'price':
575
-				if ( ! $item->is_recurring() ) {
576
-					echo wp_kses_post( $item->get_the_price() );
577
-					break;
578
-				}
579
-
580
-				$price = wp_sprintf(
581
-					__( '%1$s / %2$s', 'invoicing' ),
582
-					$item->get_the_price(),
583
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
584
-				);
585
-
586
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
587
-					echo wp_kses_post( $price );
588
-					break;
589
-				}
590
-
591
-				echo wp_kses_post( $item->get_the_initial_price() );
592
-
593
-				echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>';
594
-				break;
595
-
596
-			case 'vat_rule':
597
-				echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) );
598
-				break;
599
-
600
-			case 'vat_class':
601
-				echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) );
602
-				break;
603
-
604
-			case 'shortcode':
605
-				if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
606
-					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
607
-				} else {
608
-					echo '&mdash;';
609
-				}
610
-
611
-				break;
612
-
613
-			case 'type':
614
-				echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' );
615
-				break;
616
-
617
-		}
618
-
619
-	}
620
-
621
-	/**
622
-	 * Lets users filter items using taxes.
623
-	 */
624
-	public static function add_item_filters( $post_type ) {
625
-
626
-		// Abort if we're not dealing with items.
627
-		if ( $post_type != 'wpi_item' ) {
628
-			return;
629
-		}
630
-
631
-		// Filter by vat rules.
632
-		if ( wpinv_use_taxes() ) {
633
-
634
-			// Sanitize selected vat rule.
635
-			$vat_rule   = '';
636
-			$vat_rules  = getpaid_get_tax_rules();
637
-			if ( isset( $_GET['vat_rule'] ) ) {
638
-				$vat_rule   = sanitize_text_field( $_GET['vat_rule'] );
639
-			}
640
-
641
-			// Filter by VAT rule.
642
-			wpinv_html_select(
643
-				array(
644
-					'options'          => array_merge(
645
-						array(
646
-							'' => __( 'All Tax Rules', 'invoicing' ),
647
-						),
648
-						$vat_rules
649
-					),
650
-					'name'             => 'vat_rule',
651
-					'id'               => 'vat_rule',
652
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
653
-					'show_option_all'  => false,
654
-					'show_option_none' => false,
655
-				)
656
-			);
657
-
658
-			// Filter by VAT class.
659
-
660
-			// Sanitize selected vat rule.
661
-			$vat_class   = '';
662
-			$vat_classes = getpaid_get_tax_classes();
663
-			if ( isset( $_GET['vat_class'] ) ) {
664
-				$vat_class   = sanitize_text_field( $_GET['vat_class'] );
665
-			}
666
-
667
-			wpinv_html_select(
668
-				array(
669
-					'options'          => array_merge(
670
-						array(
671
-							'' => __( 'All Tax Classes', 'invoicing' ),
672
-						),
673
-						$vat_classes
674
-					),
675
-					'name'             => 'vat_class',
676
-					'id'               => 'vat_class',
677
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
678
-					'show_option_all'  => false,
679
-					'show_option_none' => false,
680
-				)
681
-			);
682
-
683
-		}
684
-
685
-		// Filter by item type.
686
-		$type   = '';
687
-		if ( isset( $_GET['type'] ) ) {
688
-			$type   = sanitize_text_field( $_GET['type'] );
689
-		}
690
-
691
-		wpinv_html_select(
692
-			array(
693
-				'options'          => array_merge(
694
-					array(
695
-						'' => __( 'All item types', 'invoicing' ),
696
-					),
697
-					wpinv_get_item_types()
698
-				),
699
-				'name'             => 'type',
700
-				'id'               => 'type',
701
-				'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
702
-				'show_option_all'  => false,
703
-				'show_option_none' => false,
704
-			)
705
-		);
706
-
707
-	}
708
-
709
-	/**
710
-	 * Filters the item query.
711
-	 */
712
-	public static function filter_item_query( $query ) {
713
-
714
-		// modify the query only if it admin and main query.
715
-		if ( ! ( is_admin() && $query->is_main_query() ) ) {
716
-			return $query;
717
-		}
718
-
719
-		// we want to modify the query for our items.
720
-		if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ) {
721
-			return $query;
722
-		}
723
-
724
-		if ( empty( $query->query_vars['meta_query'] ) ) {
725
-			$query->query_vars['meta_query'] = array();
726
-		}
727
-
728
-		// Filter vat rule type
724
+        if ( empty( $query->query_vars['meta_query'] ) ) {
725
+            $query->query_vars['meta_query'] = array();
726
+        }
727
+
728
+        // Filter vat rule type
729 729
         if ( ! empty( $_GET['vat_rule'] ) ) {
730 730
             $query->query_vars['meta_query'][] = array(
731 731
                 'key'     => '_wpinv_vat_rule',
@@ -750,97 +750,97 @@  discard block
 block discarded – undo
750 750
                 'value'   => sanitize_text_field( $_GET['type'] ),
751 751
                 'compare' => '=',
752 752
             );
753
-		}
754
-
755
-	}
756
-
757
-	/**
758
-	 * Reorders items.
759
-	 */
760
-	public static function reorder_items( $vars ) {
761
-		global $typenow;
762
-
763
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
764
-			return $vars;
765
-		}
766
-
767
-		// By item type.
768
-		if ( 'type' == $vars['orderby'] ) {
769
-			return array_merge(
770
-				$vars,
771
-				array(
772
-					'meta_key' => '_wpinv_type',
773
-					'orderby'  => 'meta_value',
774
-				)
775
-			);
776
-		}
777
-
778
-		// By vat class.
779
-		if ( 'vat_class' == $vars['orderby'] ) {
780
-			return array_merge(
781
-				$vars,
782
-				array(
783
-					'meta_key' => '_wpinv_vat_class',
784
-					'orderby'  => 'meta_value',
785
-				)
786
-			);
787
-		}
788
-
789
-		// By vat rule.
790
-		if ( 'vat_rule' == $vars['orderby'] ) {
791
-			return array_merge(
792
-				$vars,
793
-				array(
794
-					'meta_key' => '_wpinv_vat_rule',
795
-					'orderby'  => 'meta_value',
796
-				)
797
-			);
798
-		}
799
-
800
-		// By price.
801
-		if ( 'price' == $vars['orderby'] ) {
802
-			return array_merge(
803
-				$vars,
804
-				array(
805
-					'meta_key' => '_wpinv_price',
806
-					'orderby'  => 'meta_value_num',
807
-				)
808
-			);
809
-		}
810
-
811
-		return $vars;
812
-
813
-	}
814
-
815
-	/**
816
-	 * Fired when deleting a post.
817
-	 */
818
-	public static function delete_post( $post_id ) {
819
-
820
-		switch ( get_post_type( $post_id ) ) {
821
-
822
-			case 'wpi_item':
823
-				do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) );
824
-				break;
825
-
826
-			case 'wpi_payment_form':
827
-				do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) );
828
-				break;
829
-
830
-			case 'wpi_discount':
831
-				do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) );
832
-				break;
833
-
834
-			case 'wpi_invoice':
835
-				$invoice = new WPInv_Invoice( $post_id );
836
-				do_action( 'getpaid_before_delete_invoice', $invoice );
837
-				$invoice->get_data_store()->delete_items( $invoice );
838
-				$invoice->get_data_store()->delete_special_fields( $invoice );
839
-				break;
840
-		}
841
-	}
842
-
843
-	/**
753
+        }
754
+
755
+    }
756
+
757
+    /**
758
+     * Reorders items.
759
+     */
760
+    public static function reorder_items( $vars ) {
761
+        global $typenow;
762
+
763
+        if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
764
+            return $vars;
765
+        }
766
+
767
+        // By item type.
768
+        if ( 'type' == $vars['orderby'] ) {
769
+            return array_merge(
770
+                $vars,
771
+                array(
772
+                    'meta_key' => '_wpinv_type',
773
+                    'orderby'  => 'meta_value',
774
+                )
775
+            );
776
+        }
777
+
778
+        // By vat class.
779
+        if ( 'vat_class' == $vars['orderby'] ) {
780
+            return array_merge(
781
+                $vars,
782
+                array(
783
+                    'meta_key' => '_wpinv_vat_class',
784
+                    'orderby'  => 'meta_value',
785
+                )
786
+            );
787
+        }
788
+
789
+        // By vat rule.
790
+        if ( 'vat_rule' == $vars['orderby'] ) {
791
+            return array_merge(
792
+                $vars,
793
+                array(
794
+                    'meta_key' => '_wpinv_vat_rule',
795
+                    'orderby'  => 'meta_value',
796
+                )
797
+            );
798
+        }
799
+
800
+        // By price.
801
+        if ( 'price' == $vars['orderby'] ) {
802
+            return array_merge(
803
+                $vars,
804
+                array(
805
+                    'meta_key' => '_wpinv_price',
806
+                    'orderby'  => 'meta_value_num',
807
+                )
808
+            );
809
+        }
810
+
811
+        return $vars;
812
+
813
+    }
814
+
815
+    /**
816
+     * Fired when deleting a post.
817
+     */
818
+    public static function delete_post( $post_id ) {
819
+
820
+        switch ( get_post_type( $post_id ) ) {
821
+
822
+            case 'wpi_item':
823
+                do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) );
824
+                break;
825
+
826
+            case 'wpi_payment_form':
827
+                do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) );
828
+                break;
829
+
830
+            case 'wpi_discount':
831
+                do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) );
832
+                break;
833
+
834
+            case 'wpi_invoice':
835
+                $invoice = new WPInv_Invoice( $post_id );
836
+                do_action( 'getpaid_before_delete_invoice', $invoice );
837
+                $invoice->get_data_store()->delete_items( $invoice );
838
+                $invoice->get_data_store()->delete_special_fields( $invoice );
839
+                break;
840
+        }
841
+    }
842
+
843
+    /**
844 844
      * Add a post display state for special GetPaid pages in the page list table.
845 845
      *
846 846
      * @param array   $post_states An array of post display states.
@@ -854,21 +854,21 @@  discard block
 block discarded – undo
854 854
             $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
855 855
         }
856 856
 
857
-		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
857
+        foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
858 858
 
859
-			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
860
-				$post_states[ "getpaid_{$post_type}_history_page" ] = sprintf(
861
-					__( 'GetPaid %s History Page', 'invoicing' ),
862
-					$label
863
-				);
864
-			}
859
+            if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
860
+                $post_states[ "getpaid_{$post_type}_history_page" ] = sprintf(
861
+                    __( 'GetPaid %s History Page', 'invoicing' ),
862
+                    $label
863
+                );
864
+            }
865 865
 }
866 866
 
867
-		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
867
+        if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
868 868
             $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );
869 869
         }
870 870
 
871
-		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
871
+        if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
872 872
             $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
873 873
         }
874 874
 
Please login to merge, or discard this patch.
includes/admin/register-settings.php 1 patch
Indentation   +309 added lines, -309 removed lines patch added patch discarded remove patch
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
     $name       = isset( $option['name'] ) ? $option['name'] : '';
193 193
     $cb         = "wpinv_{$option['type']}_callback";
194 194
     $section    = "wpinv_settings_{$tab}_$section";
195
-	$is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
195
+    $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
196 196
 
197
-	if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
198
-		$tip   = wpinv_clean( $option['desc'] );
199
-		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
200
-		unset( $option['desc'] );
201
-	}
197
+    if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
198
+        $tip   = wpinv_clean( $option['desc'] );
199
+        $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
200
+        unset( $option['desc'] );
201
+    }
202 202
 
203 203
     // Loop through all tabs.
204 204
     add_settings_field(
@@ -225,9 +225,9 @@  discard block
 block discarded – undo
225 225
             'faux'            => isset( $option['faux'] ) ? $option['faux'] : false,
226 226
             'onchange'        => isset( $option['onchange'] ) ? $option['onchange'] : '',
227 227
             'custom'          => isset( $option['custom'] ) ? $option['custom'] : '',
228
-			'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '',
229
-			'class'           => isset( $option['class'] ) ? $option['class'] : '',
230
-			'style'           => isset( $option['style'] ) ? $option['style'] : '',
228
+            'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '',
229
+            'class'           => isset( $option['class'] ) ? $option['class'] : '',
230
+            'style'           => isset( $option['style'] ) ? $option['style'] : '',
231 231
             'cols'            => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
232 232
             'rows'            => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
233 233
         )
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
  * @return array
242 242
  */
243 243
 function wpinv_get_registered_settings() {
244
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
244
+    return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
245 245
 }
246 246
 
247 247
 /**
@@ -260,18 +260,18 @@  discard block
 block discarded – undo
260 260
  */
261 261
 function wpinv_settings_sanitize( $input = array() ) {
262 262
 
263
-	$wpinv_options = wpinv_get_options();
264
-	$raw_referrer  = wp_get_raw_referer();
263
+    $wpinv_options = wpinv_get_options();
264
+    $raw_referrer  = wp_get_raw_referer();
265 265
 
266 266
     if ( empty( $raw_referrer ) ) {
267
-		return array_merge( $wpinv_options, $input );
267
+        return array_merge( $wpinv_options, $input );
268 268
     }
269 269
 
270 270
     wp_parse_str( $raw_referrer, $referrer );
271 271
 
272
-	if ( in_array( 'gp-setup', $referrer ) ) {
273
-		return array_merge( $wpinv_options, $input );
274
-	}
272
+    if ( in_array( 'gp-setup', $referrer ) ) {
273
+        return array_merge( $wpinv_options, $input );
274
+    }
275 275
 
276 276
     $settings = wpinv_get_registered_settings();
277 277
     $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
         }
294 294
 
295 295
         // General filter
296
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
296
+        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
297 297
 
298
-		// Key specific filter.
299
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
298
+        // Key specific filter.
299
+        $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
300 300
     }
301 301
 
302 302
     // Loop through the whitelist and unset any that are empty for the tab being saved
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
 
340 340
     foreach ( $new_rates as $rate ) {
341 341
 
342
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
343
-		$rate['name']    = sanitize_text_field( $rate['name'] );
344
-		$rate['state']   = sanitize_text_field( $rate['state'] );
345
-		$rate['country'] = sanitize_text_field( $rate['country'] );
346
-		$rate['global']  = empty( $rate['state'] );
347
-		$tax_rates[]     = $rate;
342
+        $rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
343
+        $rate['name']    = sanitize_text_field( $rate['name'] );
344
+        $rate['state']   = sanitize_text_field( $rate['state'] );
345
+        $rate['country'] = sanitize_text_field( $rate['country'] );
346
+        $rate['global']  = empty( $rate['state'] );
347
+        $tax_rates[]     = $rate;
348 348
 
349
-	}
349
+    }
350 350
 
351 351
     update_option( 'wpinv_tax_rates', $tax_rates );
352 352
 
@@ -359,21 +359,21 @@  discard block
 block discarded – undo
359 359
         return $input;
360 360
     }
361 361
 
362
-	if ( empty( $_POST['wpinv_tax_rules_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_tax_rules_nonce'], 'wpinv_tax_rules' ) ) {
363
-		return $input;
364
-	}
362
+    if ( empty( $_POST['wpinv_tax_rules_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_tax_rules_nonce'], 'wpinv_tax_rules' ) ) {
363
+        return $input;
364
+    }
365 365
 
366 366
     $new_rules = ! empty( $_POST['tax_rules'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rules'] ) ) : array();
367 367
     $tax_rules = array();
368 368
 
369 369
     foreach ( $new_rules as $rule ) {
370 370
 
371
-		$rule['key']      = sanitize_title_with_dashes( $rule['key'] );
372
-		$rule['label']    = sanitize_text_field( $rule['label'] );
373
-		$rule['tax_base'] = sanitize_text_field( $rule['tax_base'] );
374
-		$tax_rules[]      = $rule;
371
+        $rule['key']      = sanitize_title_with_dashes( $rule['key'] );
372
+        $rule['label']    = sanitize_text_field( $rule['label'] );
373
+        $rule['tax_base'] = sanitize_text_field( $rule['tax_base'] );
374
+        $tax_rules[]      = $rule;
375 375
 
376
-	}
376
+    }
377 377
 
378 378
     update_option( 'wpinv_tax_rules', $tax_rules );
379 379
 
@@ -386,11 +386,11 @@  discard block
 block discarded – undo
386 386
     $tabs['general']  = __( 'General', 'invoicing' );
387 387
     $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
388 388
     $tabs['taxes']    = __( 'Taxes', 'invoicing' );
389
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
389
+    $tabs['emails']   = __( 'Emails', 'invoicing' );
390 390
 
391
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
392
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
393
-	}
391
+    if ( count( getpaid_get_integration_settings() ) > 0 ) {
392
+        $tabs['integrations'] = __( 'Integrations', 'invoicing' );
393
+    }
394 394
 
395 395
     $tabs['privacy']  = __( 'Privacy', 'invoicing' );
396 396
     $tabs['misc']     = __( 'Misc', 'invoicing' );
@@ -421,53 +421,53 @@  discard block
 block discarded – undo
421 421
         'general'      => apply_filters(
422 422
             'wpinv_settings_sections_general',
423 423
             array(
424
-				'main'             => __( 'General Settings', 'invoicing' ),
425
-				'page_section'     => __( 'Page Settings', 'invoicing' ),
426
-				'currency_section' => __( 'Currency Settings', 'invoicing' ),
427
-				'labels'           => __( 'Label Texts', 'invoicing' ),
424
+                'main'             => __( 'General Settings', 'invoicing' ),
425
+                'page_section'     => __( 'Page Settings', 'invoicing' ),
426
+                'currency_section' => __( 'Currency Settings', 'invoicing' ),
427
+                'labels'           => __( 'Label Texts', 'invoicing' ),
428 428
             )
429 429
         ),
430 430
         'gateways'     => apply_filters(
431 431
             'wpinv_settings_sections_gateways',
432 432
             array(
433
-				'main' => __( 'Gateway Settings', 'invoicing' ),
433
+                'main' => __( 'Gateway Settings', 'invoicing' ),
434 434
             )
435 435
         ),
436 436
         'taxes'        => apply_filters(
437 437
             'wpinv_settings_sections_taxes',
438 438
             array(
439
-				'main'  => __( 'Tax Settings', 'invoicing' ),
440
-				'rules' => __( 'Tax Rules', 'invoicing' ),
441
-				'rates' => __( 'Tax Rates', 'invoicing' ),
442
-				'vat'   => __( 'EU VAT Settings', 'invoicing' ),
439
+                'main'  => __( 'Tax Settings', 'invoicing' ),
440
+                'rules' => __( 'Tax Rules', 'invoicing' ),
441
+                'rates' => __( 'Tax Rates', 'invoicing' ),
442
+                'vat'   => __( 'EU VAT Settings', 'invoicing' ),
443 443
             )
444 444
         ),
445 445
         'emails'       => apply_filters(
446 446
             'wpinv_settings_sections_emails',
447 447
             array(
448
-				'main' => __( 'Email Settings', 'invoicing' ),
448
+                'main' => __( 'Email Settings', 'invoicing' ),
449 449
             )
450 450
         ),
451 451
 
452
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
452
+        'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
453 453
 
454 454
         'privacy'      => apply_filters(
455 455
             'wpinv_settings_sections_privacy',
456 456
             array(
457
-				'main' => __( 'Privacy policy', 'invoicing' ),
457
+                'main' => __( 'Privacy policy', 'invoicing' ),
458 458
             )
459 459
         ),
460 460
         'misc'         => apply_filters(
461 461
             'wpinv_settings_sections_misc',
462 462
             array(
463
-				'main'       => __( 'Miscellaneous', 'invoicing' ),
464
-				'custom-css' => __( 'Custom CSS', 'invoicing' ),
463
+                'main'       => __( 'Miscellaneous', 'invoicing' ),
464
+                'custom-css' => __( 'Custom CSS', 'invoicing' ),
465 465
             )
466 466
         ),
467 467
         'tools'        => apply_filters(
468 468
             'wpinv_settings_sections_tools',
469 469
             array(
470
-				'main' => __( 'Diagnostic Tools', 'invoicing' ),
470
+                'main' => __( 'Diagnostic Tools', 'invoicing' ),
471 471
             )
472 472
         ),
473 473
     );
@@ -478,46 +478,46 @@  discard block
 block discarded – undo
478 478
 }
479 479
 
480 480
 function wpinv_get_pages( $with_slug = false, $default_label = null ) {
481
-	$pages_options = array();
481
+    $pages_options = array();
482 482
 
483
-	if ( $default_label !== null && $default_label !== false ) {
484
-		$pages_options = array( '' => $default_label ); // Blank option
485
-	}
483
+    if ( $default_label !== null && $default_label !== false ) {
484
+        $pages_options = array( '' => $default_label ); // Blank option
485
+    }
486 486
 
487
-	$pages = get_pages();
488
-	if ( $pages ) {
489
-		foreach ( $pages as $page ) {
490
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
487
+    $pages = get_pages();
488
+    if ( $pages ) {
489
+        foreach ( $pages as $page ) {
490
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
491 491
             $pages_options[ $page->ID ] = $title;
492
-		}
493
-	}
492
+        }
493
+    }
494 494
 
495
-	return $pages_options;
495
+    return $pages_options;
496 496
 }
497 497
 
498 498
 function wpinv_header_callback( $args ) {
499
-	if ( ! empty( $args['desc'] ) ) {
499
+    if ( ! empty( $args['desc'] ) ) {
500 500
         echo wp_kses_post( $args['desc'] );
501 501
     }
502 502
 }
503 503
 
504 504
 function wpinv_hidden_callback( $args ) {
505 505
 
506
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
507
-	$value   = wpinv_get_option( $args['id'], $std );
506
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
507
+    $value   = wpinv_get_option( $args['id'], $std );
508 508
 
509
-	if ( isset( $args['set_value'] ) ) {
510
-		$value = $args['set_value'];
511
-	}
509
+    if ( isset( $args['set_value'] ) ) {
510
+        $value = $args['set_value'];
511
+    }
512 512
 
513
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
514
-		$args['readonly'] = true;
515
-		$name  = '';
516
-	} else {
517
-		$name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']';
518
-	}
513
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
514
+        $args['readonly'] = true;
515
+        $name  = '';
516
+    } else {
517
+        $name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']';
518
+    }
519 519
 
520
-	echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />';
520
+    echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />';
521 521
 
522 522
 }
523 523
 
@@ -526,12 +526,12 @@  discard block
 block discarded – undo
526 526
  */
527 527
 function wpinv_checkbox_callback( $args ) {
528 528
 
529
-	$std = isset( $args['std'] ) ? $args['std'] : '';
530
-	$std = wpinv_get_option( $args['id'], $std );
531
-	$id  = esc_attr( $args['id'] );
529
+    $std = isset( $args['std'] ) ? $args['std'] : '';
530
+    $std = wpinv_get_option( $args['id'], $std );
531
+    $id  = esc_attr( $args['id'] );
532 532
 
533
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
534
-	?>
533
+    getpaid_hidden_field( "wpinv_settings[$id]", '0' );
534
+    ?>
535 535
 		<fieldset>
536 536
 			<label>
537 537
 				<input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox" />
@@ -543,75 +543,75 @@  discard block
 block discarded – undo
543 543
 
544 544
 function wpinv_multicheck_callback( $args ) {
545 545
 
546
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
547
-	$class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
546
+    $sanitize_id = wpinv_sanitize_key( $args['id'] );
547
+    $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
548 548
 
549
-	if ( ! empty( $args['options'] ) ) {
549
+    if ( ! empty( $args['options'] ) ) {
550 550
 
551
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
552
-		$value   = wpinv_get_option( $args['id'], $std );
551
+        $std     = isset( $args['std'] ) ? $args['std'] : array();
552
+        $value   = wpinv_get_option( $args['id'], $std );
553 553
 
554
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">';
554
+        echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">';
555 555
         foreach ( $args['options'] as $key => $option ) :
556
-			$sanitize_key = esc_attr( wpinv_sanitize_key( $key ) );
557
-			if ( in_array( $sanitize_key, $value ) ) {
558
-				$enabled = $sanitize_key;
559
-			} else {
560
-				$enabled = null;
561
-			}
562
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
563
-			echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>';
564
-		endforeach;
565
-		echo '</div>';
566
-		echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
567
-	}
556
+            $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) );
557
+            if ( in_array( $sanitize_key, $value ) ) {
558
+                $enabled = $sanitize_key;
559
+            } else {
560
+                $enabled = null;
561
+            }
562
+            echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
563
+            echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>';
564
+        endforeach;
565
+        echo '</div>';
566
+        echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
567
+    }
568 568
 }
569 569
 
570 570
 function wpinv_payment_icons_callback( $args ) {
571 571
 
572 572
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
573
-	$value   = wpinv_get_option( $args['id'], false );
573
+    $value   = wpinv_get_option( $args['id'], false );
574 574
 
575
-	if ( ! empty( $args['options'] ) ) {
576
-		foreach ( $args['options'] as $key => $option ) {
575
+    if ( ! empty( $args['options'] ) ) {
576
+        foreach ( $args['options'] as $key => $option ) {
577 577
             $sanitize_key = wpinv_sanitize_key( $key );
578 578
 
579
-			if ( empty( $value ) ) {
580
-				$enabled = $option;
581
-			} else {
582
-				$enabled = null;
583
-			}
584
-
585
-			echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
586
-
587
-				echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
588
-
589
-				if ( wpinv_string_is_image_url( $key ) ) {
590
-				echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
591
-				} else {
592
-				$card = strtolower( str_replace( ' ', '', $option ) );
593
-
594
-				if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
595
-					$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
596
-					} else {
597
-					$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
598
-					$content_dir = WP_CONTENT_DIR;
599
-
600
-					if ( function_exists( 'wp_normalize_path' ) ) {
601
-						// Replaces backslashes with forward slashes for Windows systems
602
-						$image = wp_normalize_path( $image );
603
-						$content_dir = wp_normalize_path( $content_dir );
604
-						}
605
-
606
-					$image = str_replace( $content_dir, content_url(), $image );
607
-					}
608
-
609
-				echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
610
-				}
611
-			echo wp_kses_post( $option ) . '</label>';
612
-		}
613
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
614
-	}
579
+            if ( empty( $value ) ) {
580
+                $enabled = $option;
581
+            } else {
582
+                $enabled = null;
583
+            }
584
+
585
+            echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
586
+
587
+                echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
588
+
589
+                if ( wpinv_string_is_image_url( $key ) ) {
590
+                echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
591
+                } else {
592
+                $card = strtolower( str_replace( ' ', '', $option ) );
593
+
594
+                if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
595
+                    $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
596
+                    } else {
597
+                    $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
598
+                    $content_dir = WP_CONTENT_DIR;
599
+
600
+                    if ( function_exists( 'wp_normalize_path' ) ) {
601
+                        // Replaces backslashes with forward slashes for Windows systems
602
+                        $image = wp_normalize_path( $image );
603
+                        $content_dir = wp_normalize_path( $content_dir );
604
+                        }
605
+
606
+                    $image = str_replace( $content_dir, content_url(), $image );
607
+                    }
608
+
609
+                echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
610
+                }
611
+            echo wp_kses_post( $option ) . '</label>';
612
+        }
613
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
614
+    }
615 615
 }
616 616
 
617 617
 /**
@@ -619,9 +619,9 @@  discard block
 block discarded – undo
619 619
  */
620 620
 function wpinv_radio_callback( $args ) {
621 621
 
622
-	$std = isset( $args['std'] ) ? $args['std'] : '';
623
-	$std = wpinv_get_option( $args['id'], $std );
624
-	?>
622
+    $std = isset( $args['std'] ) ? $args['std'] : '';
623
+    $std = wpinv_get_option( $args['id'], $std );
624
+    ?>
625 625
 		<fieldset>
626 626
 			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
627 627
 				<?php foreach ( $args['options'] as $key => $option ) : ?>
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 			</ul>
636 636
 		</fieldset>
637 637
 	<?php
638
-	getpaid_settings_description_callback( $args );
638
+    getpaid_settings_description_callback( $args );
639 639
 }
640 640
 
641 641
 /**
@@ -643,10 +643,10 @@  discard block
 block discarded – undo
643 643
  */
644 644
 function getpaid_settings_description_callback( $args ) {
645 645
 
646
-	if ( ! empty( $args['desc'] ) ) {
647
-		$description = $args['desc'];
648
-		echo wp_kses_post( "<p class='description'>$description</p>" );
649
-	}
646
+    if ( ! empty( $args['desc'] ) ) {
647
+        $description = $args['desc'];
648
+        echo wp_kses_post( "<p class='description'>$description</p>" );
649
+    }
650 650
 
651 651
 }
652 652
 
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
  */
656 656
 function wpinv_gateways_callback() {
657 657
 
658
-	?>
658
+    ?>
659 659
 		</td>
660 660
 	</tr>
661 661
 	<tr class="bsui">
@@ -669,26 +669,26 @@  discard block
 block discarded – undo
669 669
 
670 670
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
671 671
     $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
672
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
673
-	$value   = wpinv_get_option( $args['id'], $std );
672
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
673
+    $value   = wpinv_get_option( $args['id'], $std );
674 674
 
675
-	echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >';
675
+    echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >';
676 676
 
677
-	foreach ( $args['options'] as $key => $option ) :
677
+    foreach ( $args['options'] as $key => $option ) :
678 678
 
679
-		echo '<option value="' . esc_attr( $key ) . '" ';
679
+        echo '<option value="' . esc_attr( $key ) . '" ';
680 680
 
681
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
681
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
682 682
             selected( $key, $args['selected'] );
683 683
         } else {
684 684
             selected( $key, $value );
685 685
         }
686 686
 
687
-		echo '>' . esc_html( $option['admin_label'] ) . '</option>';
688
-	endforeach;
687
+        echo '>' . esc_html( $option['admin_label'] ) . '</option>';
688
+    endforeach;
689 689
 
690
-	echo '</select>';
691
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
690
+    echo '</select>';
691
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
692 692
 }
693 693
 
694 694
 /**
@@ -699,38 +699,38 @@  discard block
 block discarded – undo
699 699
  */
700 700
 function wpinv_settings_attrs_helper( $args ) {
701 701
 
702
-	$value = isset( $args['std'] ) ? $args['std'] : '';
703
-	$id    = esc_attr( $args['id'] );
704
-	$value = is_scalar( $value ) ? $value : '';
705
-
706
-	$attrs = array(
707
-		'name'     => ! empty( $args['faux'] ) ? false : "wpinv_settings[$id]",
708
-		'readonly' => ! empty( $args['faux'] ),
709
-		'value'    => ! empty( $args['faux'] ) ? $value : wpinv_get_option( $args['id'], $value ),
710
-		'id'       => 'wpinv-settings-' . $args['id'],
711
-		'style'    => $args['style'],
712
-		'class'    => $args['class'],
713
-		'placeholder' => $args['placeholder'],
714
-		'data-placeholder' => $args['placeholder'],
715
-	);
702
+    $value = isset( $args['std'] ) ? $args['std'] : '';
703
+    $id    = esc_attr( $args['id'] );
704
+    $value = is_scalar( $value ) ? $value : '';
705
+
706
+    $attrs = array(
707
+        'name'     => ! empty( $args['faux'] ) ? false : "wpinv_settings[$id]",
708
+        'readonly' => ! empty( $args['faux'] ),
709
+        'value'    => ! empty( $args['faux'] ) ? $value : wpinv_get_option( $args['id'], $value ),
710
+        'id'       => 'wpinv-settings-' . $args['id'],
711
+        'style'    => $args['style'],
712
+        'class'    => $args['class'],
713
+        'placeholder' => $args['placeholder'],
714
+        'data-placeholder' => $args['placeholder'],
715
+    );
716 716
 
717
-	if ( ! empty( $args['onchange'] ) ) {
718
-		$attrs['onchange'] = $args['onchange'];
719
-	}
717
+    if ( ! empty( $args['onchange'] ) ) {
718
+        $attrs['onchange'] = $args['onchange'];
719
+    }
720 720
 
721
-	foreach ( $attrs as $key => $value ) {
721
+    foreach ( $attrs as $key => $value ) {
722 722
 
723
-		if ( false === $value ) {
724
-			continue;
725
-		}
723
+        if ( false === $value ) {
724
+            continue;
725
+        }
726 726
 
727
-		if ( true === $value ) {
728
-			echo ' ' . esc_attr( $key );
729
-		} else {
730
-			echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
731
-		}
727
+        if ( true === $value ) {
728
+            echo ' ' . esc_attr( $key );
729
+        } else {
730
+            echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
731
+        }
732 732
 
733
-	}
733
+    }
734 734
 
735 735
 }
736 736
 
@@ -739,9 +739,9 @@  discard block
 block discarded – undo
739 739
  */
740 740
 function wpinv_text_callback( $args ) {
741 741
 
742
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
742
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
743 743
 
744
-	?>
744
+    ?>
745 745
 		<label style="width: 100%;">
746 746
 			<input type="text" <?php wpinv_settings_attrs_helper( $args ); ?>>
747 747
 			<?php echo wp_kses_post( $desc ); ?>
@@ -755,9 +755,9 @@  discard block
 block discarded – undo
755 755
  */
756 756
 function wpinv_number_callback( $args ) {
757 757
 
758
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
758
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
759 759
 
760
-	?>
760
+    ?>
761 761
 		<label style="width: 100%;">
762 762
 			<input type="number" step="<?php echo floatval( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php wpinv_settings_attrs_helper( $args ); ?>>
763 763
 			<?php echo wp_kses_post( $desc ); ?>
@@ -769,34 +769,34 @@  discard block
 block discarded – undo
769 769
 function wpinv_textarea_callback( $args ) {
770 770
 
771 771
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
772
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
773
-	$value   = wpinv_get_option( $args['id'], $std );
772
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
773
+    $value   = wpinv_get_option( $args['id'], $std );
774 774
 
775 775
     $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
776 776
     $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
777 777
 
778
-	echo '<textarea class="' . esc_attr( $class ) . ' txtarea-' . esc_attr( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . esc_attr( $args['cols'] ) . '" rows="' . esc_attr( $args['rows'] ) . '" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
779
-	echo '<br /><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
778
+    echo '<textarea class="' . esc_attr( $class ) . ' txtarea-' . esc_attr( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . esc_attr( $args['cols'] ) . '" rows="' . esc_attr( $args['rows'] ) . '" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
779
+    echo '<br /><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
780 780
 
781 781
 }
782 782
 
783 783
 function wpinv_password_callback( $args ) {
784 784
 
785 785
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
786
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
787
-	$value   = wpinv_get_option( $args['id'], $std );
786
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
787
+    $value   = wpinv_get_option( $args['id'], $std );
788 788
 
789
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
790
-	echo '<input type="password" class="' . esc_attr( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
791
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
789
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
790
+    echo '<input type="password" class="' . esc_attr( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
791
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
792 792
 
793 793
 }
794 794
 
795 795
 function wpinv_missing_callback( $args ) {
796
-	printf(
797
-		esc_html__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
798
-		'<strong>' . esc_html( $args['id'] ) . '</strong>'
799
-	);
796
+    printf(
797
+        esc_html__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
798
+        '<strong>' . esc_html( $args['id'] ) . '</strong>'
799
+    );
800 800
 }
801 801
 
802 802
 /**
@@ -804,13 +804,13 @@  discard block
 block discarded – undo
804 804
  */
805 805
 function wpinv_select_callback( $args ) {
806 806
 
807
-	$desc   = wp_kses_post( $args['desc'] );
808
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
809
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
810
-	$value  = wpinv_get_option( $args['id'], $value );
811
-	$rand   = uniqid( 'random_id' );
807
+    $desc   = wp_kses_post( $args['desc'] );
808
+    $desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
809
+    $value  = isset( $args['std'] ) ? $args['std'] : '';
810
+    $value  = wpinv_get_option( $args['id'], $value );
811
+    $rand   = uniqid( 'random_id' );
812 812
 
813
-	?>
813
+    ?>
814 814
 		<label style="width: 100%;">
815 815
 			<select <?php wpinv_settings_attrs_helper( $args ); ?> data-allow-clear="true">
816 816
 				<?php foreach ( $args['options'] as $option => $name ) : ?>
@@ -843,50 +843,50 @@  discard block
 block discarded – undo
843 843
 function wpinv_color_select_callback( $args ) {
844 844
 
845 845
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
846
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
847
-	$value   = wpinv_get_option( $args['id'], $std );
846
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
847
+    $value   = wpinv_get_option( $args['id'], $std );
848 848
 
849
-	echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
849
+    echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
850 850
 
851
-	foreach ( $args['options'] as $option => $color ) {
852
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>';
853
-	}
851
+    foreach ( $args['options'] as $option => $color ) {
852
+        echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>';
853
+    }
854 854
 
855
-	echo '</select>';
856
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
855
+    echo '</select>';
856
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
857 857
 
858 858
 }
859 859
 
860 860
 function wpinv_rich_editor_callback( $args ) {
861
-	global $wp_version;
861
+    global $wp_version;
862 862
 
863 863
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
864 864
 
865
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
866
-	$value   = wpinv_get_option( $args['id'], $std );
865
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
866
+    $value   = wpinv_get_option( $args['id'], $std );
867 867
 
868
-	if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
869
-		$value = $std;
870
-	}
868
+    if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
869
+        $value = $std;
870
+    }
871 871
 
872
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
872
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
873 873
 
874
-	echo '<div class="getpaid-settings-editor-input">';
875
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
876
-		wp_editor(
874
+    echo '<div class="getpaid-settings-editor-input">';
875
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
876
+        wp_editor(
877 877
             stripslashes( $value ),
878 878
             'wpinv_settings_' . esc_attr( $args['id'] ),
879 879
             array(
880
-				'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']',
881
-				'textarea_rows' => absint( $rows ),
882
-				'media_buttons' => false,
880
+                'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']',
881
+                'textarea_rows' => absint( $rows ),
882
+                'media_buttons' => false,
883 883
             )
884 884
         );
885
-	} else {
886
-		echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
887
-	}
885
+    } else {
886
+        echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
887
+    }
888 888
 
889
-	echo '</div><br/><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
889
+    echo '</div><br/><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
890 890
 
891 891
 }
892 892
 
@@ -894,51 +894,51 @@  discard block
 block discarded – undo
894 894
 
895 895
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
896 896
 
897
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
898
-	$value   = wpinv_get_option( $args['id'], $std );
897
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
898
+    $value   = wpinv_get_option( $args['id'], $std );
899 899
 
900
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
901
-	echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
902
-	echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__( 'Upload File', 'invoicing' ) . '"/></span>';
903
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
900
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
901
+    echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
902
+    echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__( 'Upload File', 'invoicing' ) . '"/></span>';
903
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
904 904
 
905 905
 }
906 906
 
907 907
 function wpinv_color_callback( $args ) {
908 908
 
909
-	$std         = isset( $args['std'] ) ? $args['std'] : '';
910
-	$value       = wpinv_get_option( $args['id'], $std );
909
+    $std         = isset( $args['std'] ) ? $args['std'] : '';
910
+    $value       = wpinv_get_option( $args['id'], $std );
911 911
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
912 912
 
913
-	echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
914
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
913
+    echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
914
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
915 915
 
916 916
 }
917 917
 
918 918
 function wpinv_country_states_callback( $args ) {
919 919
 
920
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
921
-	$value   = wpinv_get_option( $args['id'], $std );
920
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
921
+    $value   = wpinv_get_option( $args['id'], $std );
922 922
 
923 923
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
924 924
 
925
-	if ( isset( $args['placeholder'] ) ) {
926
-		$placeholder = $args['placeholder'];
927
-	} else {
928
-		$placeholder = '';
929
-	}
925
+    if ( isset( $args['placeholder'] ) ) {
926
+        $placeholder = $args['placeholder'];
927
+    } else {
928
+        $placeholder = '';
929
+    }
930 930
 
931
-	$states = wpinv_get_country_states();
931
+    $states = wpinv_get_country_states();
932 932
 
933
-	$class = empty( $states ) ? 'wpinv-no-states' : 'wpi_select2';
934
-	echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="' . esc_attr( $class ) . '" data-placeholder="' . esc_html( $placeholder ) . '"/>';
933
+    $class = empty( $states ) ? 'wpinv-no-states' : 'wpi_select2';
934
+    echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="' . esc_attr( $class ) . '" data-placeholder="' . esc_html( $placeholder ) . '"/>';
935 935
 
936
-	foreach ( $states as $option => $name ) {
937
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>';
938
-	}
936
+    foreach ( $states as $option => $name ) {
937
+        echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>';
938
+    }
939 939
 
940
-	echo '</select>';
941
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
940
+    echo '</select>';
941
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
942 942
 
943 943
 }
944 944
 
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
  */
948 948
 function wpinv_tax_rates_callback() {
949 949
 
950
-	?>
950
+    ?>
951 951
 		</td>
952 952
 	</tr>
953 953
 	<tr class="bsui">
@@ -963,9 +963,9 @@  discard block
 block discarded – undo
963 963
  */
964 964
 function wpinv_tax_rate_callback( $tax_rate, $key ) {
965 965
 
966
-	$key                      = sanitize_key( $key );
967
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
968
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
966
+    $key                      = sanitize_key( $key );
967
+    $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
968
+    include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
969 969
 
970 970
 }
971 971
 
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
  */
975 975
 function wpinv_tax_rules_callback() {
976 976
 
977
-	?>
977
+    ?>
978 978
 		</td>
979 979
 	</tr>
980 980
 	<tr class="bsui">
@@ -1012,14 +1012,14 @@  discard block
 block discarded – undo
1012 1012
                 <td>
1013 1013
 					<a href="
1014 1014
                     <?php
1015
-						echo esc_url(
1016
-							wp_nonce_url(
1017
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
1018
-								'getpaid-nonce',
1019
-								'getpaid-nonce'
1020
-							)
1021
-						);
1022
-					?>
1015
+                        echo esc_url(
1016
+                            wp_nonce_url(
1017
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
1018
+                                'getpaid-nonce',
1019
+                                'getpaid-nonce'
1020
+                            )
1021
+                        );
1022
+                    ?>
1023 1023
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1024 1024
                 </td>
1025 1025
             </tr>
@@ -1031,14 +1031,14 @@  discard block
 block discarded – undo
1031 1031
                 <td>
1032 1032
 					<a href="
1033 1033
                     <?php
1034
-						echo esc_url(
1035
-							wp_nonce_url(
1036
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
1037
-								'getpaid-nonce',
1038
-								'getpaid-nonce'
1039
-							)
1040
-						);
1041
-					?>
1034
+                        echo esc_url(
1035
+                            wp_nonce_url(
1036
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
1037
+                                'getpaid-nonce',
1038
+                                'getpaid-nonce'
1039
+                            )
1040
+                        );
1041
+                    ?>
1042 1042
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1043 1043
                 </td>
1044 1044
             </tr>
@@ -1050,14 +1050,14 @@  discard block
 block discarded – undo
1050 1050
                 <td>
1051 1051
 					<a href="
1052 1052
                     <?php
1053
-						echo esc_url(
1054
-							wp_nonce_url(
1055
-								add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1056
-								'getpaid-nonce',
1057
-								'getpaid-nonce'
1058
-							)
1059
-						);
1060
-					?>
1053
+                        echo esc_url(
1054
+                            wp_nonce_url(
1055
+                                add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1056
+                                'getpaid-nonce',
1057
+                                'getpaid-nonce'
1058
+                            )
1059
+                        );
1060
+                    ?>
1061 1061
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1062 1062
                 </td>
1063 1063
             </tr>
@@ -1070,14 +1070,14 @@  discard block
 block discarded – undo
1070 1070
                 <td>
1071 1071
 					<a href="
1072 1072
                     <?php
1073
-						echo esc_url(
1074
-							wp_nonce_url(
1075
-								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1076
-								'getpaid-nonce',
1077
-								'getpaid-nonce'
1078
-							)
1079
-						);
1080
-					?>
1073
+                        echo esc_url(
1074
+                            wp_nonce_url(
1075
+                                add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1076
+                                'getpaid-nonce',
1077
+                                'getpaid-nonce'
1078
+                            )
1079
+                        );
1080
+                    ?>
1081 1081
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1082 1082
                 </td>
1083 1083
             </tr>
@@ -1090,8 +1090,8 @@  discard block
 block discarded – undo
1090 1090
                 <td>
1091 1091
 					<a href="
1092 1092
                     <?php
1093
-						echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1094
-					?>
1093
+                        echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1094
+                    ?>
1095 1095
                     " class="button button-primary"><?php esc_html_e( 'Launch', 'invoicing' ); ?></a>
1096 1096
                 </td>
1097 1097
             </tr>
@@ -1105,19 +1105,19 @@  discard block
 block discarded – undo
1105 1105
 
1106 1106
 
1107 1107
 function wpinv_descriptive_text_callback( $args ) {
1108
-	echo wp_kses_post( $args['desc'] );
1108
+    echo wp_kses_post( $args['desc'] );
1109 1109
 }
1110 1110
 
1111 1111
 function wpinv_raw_html_callback( $args ) {
1112
-	echo wp_kses( $args['desc'], getpaid_allowed_html() );
1112
+    echo wp_kses( $args['desc'], getpaid_allowed_html() );
1113 1113
 }
1114 1114
 
1115 1115
 function wpinv_hook_callback( $args ) {
1116
-	do_action( 'wpinv_' . $args['id'], $args );
1116
+    do_action( 'wpinv_' . $args['id'], $args );
1117 1117
 }
1118 1118
 
1119 1119
 function wpinv_set_settings_cap() {
1120
-	return wpinv_get_capability();
1120
+    return wpinv_get_capability();
1121 1121
 }
1122 1122
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1123 1123
 
@@ -1141,15 +1141,15 @@  discard block
 block discarded – undo
1141 1141
  */
1142 1142
 function wpinv_get_merge_tags_help_text( $subscription = false ) {
1143 1143
 
1144
-	$url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1145
-	$link = sprintf(
1146
-		'<strong><a href="%s" target="_blank">%s</a></strong>',
1147
-		$url,
1148
-		esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1149
-	);
1144
+    $url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1145
+    $link = sprintf(
1146
+        '<strong><a href="%s" target="_blank">%s</a></strong>',
1147
+        $url,
1148
+        esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1149
+    );
1150 1150
 
1151
-	$description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1151
+    $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1152 1152
 
1153
-	return "$description $link";
1153
+    return "$description $link";
1154 1154
 
1155 1155
 }
Please login to merge, or discard this patch.
includes/class-getpaid-tax.php 1 patch
Indentation   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -13,199 +13,199 @@
 block discarded – undo
13 13
  */
14 14
 class GetPaid_Tax {
15 15
 
16
-	/**
17
-	 * Calculates tax for a line item.
18
-	 *
19
-	 * @param  float   $price              The price to calc tax on.
20
-	 * @param  array   $rates              The rates to apply.
21
-	 * @param  boolean $price_includes_tax Whether the passed price has taxes included.
22
-	 * @return array                       Array of tax name => tax amount.
23
-	 */
24
-	public static function calc_tax( $price, $rates, $price_includes_tax = false ) {
25
-
26
-		if ( $price_includes_tax ) {
27
-			$taxes = self::calc_inclusive_tax( $price, $rates );
28
-		} else {
29
-			$taxes = self::calc_exclusive_tax( $price, $rates );
30
-		}
31
-
32
-		return apply_filters( 'getpaid_calc_tax', $taxes, $price, $rates, $price_includes_tax );
33
-
34
-	}
35
-
36
-	/**
37
-	 * Calc tax from inclusive price.
38
-	 *
39
-	 * @param  float $price Price to calculate tax for.
40
-	 * @param  array $rates Array of tax rates.
41
-	 * @return array
42
-	 */
43
-	public static function calc_inclusive_tax( $price, $rates ) {
44
-		$taxes     = array();
45
-		$tax_rates = wp_list_pluck( $rates, 'rate', 'name' );
46
-
47
-		// Add tax rates.
48
-		$tax_rate  = 1 + ( array_sum( $tax_rates ) / 100 );
49
-
50
-		foreach ( $tax_rates as $name => $rate ) {
51
-			$the_rate       = ( $rate / 100 ) / $tax_rate;
52
-			$net_price      = $price - ( $the_rate * $price );
53
-			$tax_amount     = apply_filters( 'getpaid_price_inc_tax_amount', $price - $net_price, $name, $rate, $price );
54
-			$taxes[ $name ] = $tax_amount;
55
-		}
56
-
57
-		// Round all taxes to precision (4DP) before passing them back.
58
-		$taxes = array_map( array( __CLASS__, 'round' ), $taxes );
59
-
60
-		return $taxes;
61
-	}
62
-
63
-	/**
64
-	 * Calc tax from exclusive price.
65
-	 *
66
-	 * @param  float $price Price to calculate tax for.
67
-	 * @param  array $rates Array of tax rates.
68
-	 * @return array
69
-	 */
70
-	public static function calc_exclusive_tax( $price, $rates ) {
71
-		$taxes     = array();
72
-		$tax_rates = wp_list_pluck( $rates, 'rate', 'name' );
73
-
74
-		foreach ( $tax_rates as $name => $rate ) {
75
-
76
-			$tax_amount     = $price * ( $rate / 100 );
77
-			$taxes[ $name ] = apply_filters( 'getpaid_price_ex_tax_amount', $tax_amount, $name, $rate, $price );
78
-
79
-		}
80
-
81
-		// Round all taxes to precision (4DP) before passing them back.
82
-		$taxes = array_map( array( __CLASS__, 'round' ), $taxes );
83
-
84
-		return $taxes;
85
-	}
86
-
87
-	/**
88
-	 * Get's an array of all tax rates.
89
-	 *
90
-	 * @return array
91
-	 */
92
-	public static function get_all_tax_rates() {
93
-
94
-		$rates = get_option( 'wpinv_tax_rates', array() );
95
-
96
-		return apply_filters(
97
-			'getpaid_get_all_tax_rates',
98
-			array_filter( wpinv_parse_list( $rates ) )
99
-		);
100
-
101
-	}
102
-
103
-	/**
104
-	 * Get's an array of default tax rates.
105
-	 *
106
-	 * @return array
107
-	 */
108
-	public static function get_default_tax_rates() {
109
-
110
-		return apply_filters(
111
-			'getpaid_get_default_tax_rates',
112
-			array(
113
-				array(
114
-					'country' => wpinv_get_default_country(),
115
-					'state'   => wpinv_get_default_state(),
116
-					'global'  => true,
117
-					'rate'    => wpinv_get_default_tax_rate(),
118
-					'name'    => __( 'Base Tax', 'invoicing' ),
119
-				),
120
-			)
121
-		);
122
-
123
-	}
124
-
125
-	/**
126
-	 * Get's an array of all tax rules.
127
-	 *
128
-	 * @return array
129
-	 */
130
-	public static function get_all_tax_rules() {
131
-
132
-		$rules = get_option(
133
-			'wpinv_tax_rules',
134
-			array(
135
-				array(
136
-					'key'               => 'physical',
137
-					'label'             => __( 'Physical Item', 'invoicing' ),
138
-					'tax_base'          => wpinv_get_option( 'tax_base', 'billing' ),
139
-					'same_country_rule' => wpinv_get_option( 'vat_same_country_rule', 'vat_too' ),
140
-				),
141
-				array(
142
-					'key'               => 'digital',
143
-					'label'             => __( 'Digital Item', 'invoicing' ),
144
-					'tax_base'          => wpinv_get_option( 'tax_base', 'billing' ),
145
-					'same_country_rule' => wpinv_get_option( 'vat_same_country_rule', 'vat_too' ),
146
-				),
147
-        	)
148
-		);
149
-
150
-		return apply_filters(
151
-			'getpaid_tax_rules',
152
-			array_filter( array_values( wpinv_parse_list( $rules ) ) )
153
-		);
154
-
155
-	}
156
-
157
-	/**
158
-	 * Get's an array of tax rates for a given address.
159
-	 *
160
-	 * @param string $country
161
-	 * @param string $state
162
-	 * @return array
163
-	 */
164
-	public static function get_address_tax_rates( $country, $state ) {
165
-
166
-		$all_tax_rates  = self::get_all_tax_rates();
167
-		$matching_rates = array_merge(
168
-			wp_list_filter( $all_tax_rates, array( 'country' => $country ) ),
169
-			wp_list_filter( $all_tax_rates, array( 'country' => '' ) )
170
-		);
171
-
172
-		foreach ( $matching_rates as $i => $rate ) {
173
-
174
-			$states = array_filter( wpinv_clean( explode( ',', strtolower( $rate['state'] ) ) ) );
175
-			if ( empty( $rate['global'] ) && ! in_array( strtolower( $state ), $states ) ) {
176
-				unset( $matching_rates[ $i ] );
177
-			}
16
+    /**
17
+     * Calculates tax for a line item.
18
+     *
19
+     * @param  float   $price              The price to calc tax on.
20
+     * @param  array   $rates              The rates to apply.
21
+     * @param  boolean $price_includes_tax Whether the passed price has taxes included.
22
+     * @return array                       Array of tax name => tax amount.
23
+     */
24
+    public static function calc_tax( $price, $rates, $price_includes_tax = false ) {
25
+
26
+        if ( $price_includes_tax ) {
27
+            $taxes = self::calc_inclusive_tax( $price, $rates );
28
+        } else {
29
+            $taxes = self::calc_exclusive_tax( $price, $rates );
30
+        }
31
+
32
+        return apply_filters( 'getpaid_calc_tax', $taxes, $price, $rates, $price_includes_tax );
33
+
34
+    }
35
+
36
+    /**
37
+     * Calc tax from inclusive price.
38
+     *
39
+     * @param  float $price Price to calculate tax for.
40
+     * @param  array $rates Array of tax rates.
41
+     * @return array
42
+     */
43
+    public static function calc_inclusive_tax( $price, $rates ) {
44
+        $taxes     = array();
45
+        $tax_rates = wp_list_pluck( $rates, 'rate', 'name' );
46
+
47
+        // Add tax rates.
48
+        $tax_rate  = 1 + ( array_sum( $tax_rates ) / 100 );
49
+
50
+        foreach ( $tax_rates as $name => $rate ) {
51
+            $the_rate       = ( $rate / 100 ) / $tax_rate;
52
+            $net_price      = $price - ( $the_rate * $price );
53
+            $tax_amount     = apply_filters( 'getpaid_price_inc_tax_amount', $price - $net_price, $name, $rate, $price );
54
+            $taxes[ $name ] = $tax_amount;
55
+        }
56
+
57
+        // Round all taxes to precision (4DP) before passing them back.
58
+        $taxes = array_map( array( __CLASS__, 'round' ), $taxes );
59
+
60
+        return $taxes;
61
+    }
62
+
63
+    /**
64
+     * Calc tax from exclusive price.
65
+     *
66
+     * @param  float $price Price to calculate tax for.
67
+     * @param  array $rates Array of tax rates.
68
+     * @return array
69
+     */
70
+    public static function calc_exclusive_tax( $price, $rates ) {
71
+        $taxes     = array();
72
+        $tax_rates = wp_list_pluck( $rates, 'rate', 'name' );
73
+
74
+        foreach ( $tax_rates as $name => $rate ) {
75
+
76
+            $tax_amount     = $price * ( $rate / 100 );
77
+            $taxes[ $name ] = apply_filters( 'getpaid_price_ex_tax_amount', $tax_amount, $name, $rate, $price );
78
+
79
+        }
80
+
81
+        // Round all taxes to precision (4DP) before passing them back.
82
+        $taxes = array_map( array( __CLASS__, 'round' ), $taxes );
83
+
84
+        return $taxes;
85
+    }
86
+
87
+    /**
88
+     * Get's an array of all tax rates.
89
+     *
90
+     * @return array
91
+     */
92
+    public static function get_all_tax_rates() {
93
+
94
+        $rates = get_option( 'wpinv_tax_rates', array() );
95
+
96
+        return apply_filters(
97
+            'getpaid_get_all_tax_rates',
98
+            array_filter( wpinv_parse_list( $rates ) )
99
+        );
100
+
101
+    }
102
+
103
+    /**
104
+     * Get's an array of default tax rates.
105
+     *
106
+     * @return array
107
+     */
108
+    public static function get_default_tax_rates() {
109
+
110
+        return apply_filters(
111
+            'getpaid_get_default_tax_rates',
112
+            array(
113
+                array(
114
+                    'country' => wpinv_get_default_country(),
115
+                    'state'   => wpinv_get_default_state(),
116
+                    'global'  => true,
117
+                    'rate'    => wpinv_get_default_tax_rate(),
118
+                    'name'    => __( 'Base Tax', 'invoicing' ),
119
+                ),
120
+            )
121
+        );
122
+
123
+    }
124
+
125
+    /**
126
+     * Get's an array of all tax rules.
127
+     *
128
+     * @return array
129
+     */
130
+    public static function get_all_tax_rules() {
131
+
132
+        $rules = get_option(
133
+            'wpinv_tax_rules',
134
+            array(
135
+                array(
136
+                    'key'               => 'physical',
137
+                    'label'             => __( 'Physical Item', 'invoicing' ),
138
+                    'tax_base'          => wpinv_get_option( 'tax_base', 'billing' ),
139
+                    'same_country_rule' => wpinv_get_option( 'vat_same_country_rule', 'vat_too' ),
140
+                ),
141
+                array(
142
+                    'key'               => 'digital',
143
+                    'label'             => __( 'Digital Item', 'invoicing' ),
144
+                    'tax_base'          => wpinv_get_option( 'tax_base', 'billing' ),
145
+                    'same_country_rule' => wpinv_get_option( 'vat_same_country_rule', 'vat_too' ),
146
+                ),
147
+            )
148
+        );
149
+
150
+        return apply_filters(
151
+            'getpaid_tax_rules',
152
+            array_filter( array_values( wpinv_parse_list( $rules ) ) )
153
+        );
154
+
155
+    }
156
+
157
+    /**
158
+     * Get's an array of tax rates for a given address.
159
+     *
160
+     * @param string $country
161
+     * @param string $state
162
+     * @return array
163
+     */
164
+    public static function get_address_tax_rates( $country, $state ) {
165
+
166
+        $all_tax_rates  = self::get_all_tax_rates();
167
+        $matching_rates = array_merge(
168
+            wp_list_filter( $all_tax_rates, array( 'country' => $country ) ),
169
+            wp_list_filter( $all_tax_rates, array( 'country' => '' ) )
170
+        );
171
+
172
+        foreach ( $matching_rates as $i => $rate ) {
173
+
174
+            $states = array_filter( wpinv_clean( explode( ',', strtolower( $rate['state'] ) ) ) );
175
+            if ( empty( $rate['global'] ) && ! in_array( strtolower( $state ), $states ) ) {
176
+                unset( $matching_rates[ $i ] );
177
+            }
178 178
 }
179 179
 
180
-		return apply_filters( 'getpaid_get_address_tax_rates', $matching_rates, $country, $state );
181
-
182
-	}
183
-
184
-	/**
185
-	 * Sums a set of taxes to form a single total. Result is rounded to precision.
186
-	 *
187
-	 * @param  array $taxes Array of taxes.
188
-	 * @return float
189
-	 */
190
-	public static function get_tax_total( $taxes ) {
191
-		return self::round( array_sum( $taxes ) );
192
-	}
193
-
194
-	/**
195
-	 * Round to precision.
196
-	 *
197
-	 * Filter example: to return rounding to .5 cents you'd use:
198
-	 *
199
-	 * function euro_5cent_rounding( $in ) {
200
-	 *      return round( $in / 5, 2 ) * 5;
201
-	 * }
202
-	 * add_filter( 'getpaid_tax_round', 'euro_5cent_rounding' );
203
-	 *
204
-	 * @param float|int $in Value to round.
205
-	 * @return float
206
-	 */
207
-	public static function round( $in ) {
208
-		return apply_filters( 'getpaid_tax_round', round( $in, 4 ), $in );
209
-	}
180
+        return apply_filters( 'getpaid_get_address_tax_rates', $matching_rates, $country, $state );
181
+
182
+    }
183
+
184
+    /**
185
+     * Sums a set of taxes to form a single total. Result is rounded to precision.
186
+     *
187
+     * @param  array $taxes Array of taxes.
188
+     * @return float
189
+     */
190
+    public static function get_tax_total( $taxes ) {
191
+        return self::round( array_sum( $taxes ) );
192
+    }
193
+
194
+    /**
195
+     * Round to precision.
196
+     *
197
+     * Filter example: to return rounding to .5 cents you'd use:
198
+     *
199
+     * function euro_5cent_rounding( $in ) {
200
+     *      return round( $in / 5, 2 ) * 5;
201
+     * }
202
+     * add_filter( 'getpaid_tax_round', 'euro_5cent_rounding' );
203
+     *
204
+     * @param float|int $in Value to round.
205
+     * @return float
206
+     */
207
+    public static function round( $in ) {
208
+        return apply_filters( 'getpaid_tax_round', round( $in, 4 ), $in );
209
+    }
210 210
 
211 211
 }
Please login to merge, or discard this patch.
includes/admin/views/html-tax-rules-edit.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,8 @@
 block discarded – undo
8 8
 
9 9
 $dummy_rule = array(
10 10
     'key'               => 'TAX_RULE_KEY',
11
-	'label'             => __( 'New Tax Rule', 'invoicing' ),
12
-	'tax_base'          => wpinv_get_option( 'tax_base', 'billing' ),
11
+    'label'             => __( 'New Tax Rule', 'invoicing' ),
12
+    'tax_base'          => wpinv_get_option( 'tax_base', 'billing' ),
13 13
     'same_country_rule' => wpinv_get_option( 'vat_same_country_rule', 'vat_too' ),
14 14
 );
15 15
 
Please login to merge, or discard this patch.
includes/user-functions.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -34,11 +34,11 @@  discard block
 block discarded – undo
34 34
  */
35 35
 function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) {
36 36
 
37
-	if ( current_user_can( 'manage_options' ) ) {
38
-		return 'manage_options';
39
-	};
37
+    if ( current_user_can( 'manage_options' ) ) {
38
+        return 'manage_options';
39
+    };
40 40
 
41
-	return $capalibilty;
41
+    return $capalibilty;
42 42
 }
43 43
 
44 44
 /**
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
     // Prepare user values.
63 63
     $prefix = preg_replace( '/\s+/', '', $prefix );
64 64
     $prefix = empty( $prefix ) ? $email : $prefix;
65
-	$args   = array(
66
-		'user_login' => wpinv_generate_user_name( $prefix ),
67
-		'user_pass'  => wp_generate_password(),
68
-		'user_email' => $email,
65
+    $args   = array(
66
+        'user_login' => wpinv_generate_user_name( $prefix ),
67
+        'user_pass'  => wp_generate_password(),
68
+        'user_email' => $email,
69 69
         'role'       => 'subscriber',
70 70
     );
71 71
 
@@ -82,16 +82,16 @@  discard block
 block discarded – undo
82 82
 function wpinv_generate_user_name( $prefix = '' ) {
83 83
 
84 84
     // If prefix is an email, retrieve the part before the email.
85
-	$prefix = strtok( $prefix, '@' );
85
+    $prefix = strtok( $prefix, '@' );
86 86
     $prefix = trim( $prefix, '.' );
87 87
 
88
-	// Sanitize the username.
89
-	$prefix = sanitize_user( $prefix, true );
88
+    // Sanitize the username.
89
+    $prefix = sanitize_user( $prefix, true );
90 90
 
91
-	$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
92
-	if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
93
-		$prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 );
94
-	}
91
+    $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
92
+    if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
93
+        $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 );
94
+    }
95 95
 
96 96
     $username = $prefix;
97 97
     $postfix  = 2;
@@ -220,43 +220,43 @@  discard block
 block discarded – undo
220 220
 
221 221
                     foreach ( getpaid_user_address_fields() as $key => $label ) {
222 222
 
223
-					// Display the country.
224
-					if ( 'country' == $key ) {
225
-
226
-						aui()->select(
227
-							array(
228
-								'options'     => wpinv_get_country_list(),
229
-								'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
230
-								'id'          => 'wpinv-' . sanitize_html_class( $key ),
231
-								'value'       => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ),
232
-								'placeholder' => $label,
233
-								'label'       => wp_kses_post( $label ),
234
-								'label_type'  => 'vertical',
235
-								'class'       => 'getpaid-address-field',
223
+                    // Display the country.
224
+                    if ( 'country' == $key ) {
225
+
226
+                        aui()->select(
227
+                            array(
228
+                                'options'     => wpinv_get_country_list(),
229
+                                'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
230
+                                'id'          => 'wpinv-' . sanitize_html_class( $key ),
231
+                                'value'       => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ),
232
+                                'placeholder' => $label,
233
+                                'label'       => wp_kses_post( $label ),
234
+                                'label_type'  => 'vertical',
235
+                                'class'       => 'getpaid-address-field',
236 236
                             ),
237 237
                             true
238
-						);
239
-
240
-					}
241
-
242
-					// Display the state.
243
-					elseif ( 'state' == $key ) {
244
-
245
-						getpaid_get_states_select_markup(
246
-							getpaid_get_user_address_field( get_current_user_id(), 'country' ),
247
-							getpaid_get_user_address_field( get_current_user_id(), 'state' ),
248
-							$label,
249
-							$label,
250
-							'',
251
-							false,
252
-							'',
253
-							'getpaid_address[' . esc_attr( $key ) . ']',
238
+                        );
239
+
240
+                    }
241
+
242
+                    // Display the state.
243
+                    elseif ( 'state' == $key ) {
244
+
245
+                        getpaid_get_states_select_markup(
246
+                            getpaid_get_user_address_field( get_current_user_id(), 'country' ),
247
+                            getpaid_get_user_address_field( get_current_user_id(), 'state' ),
248
+                            $label,
249
+                            $label,
250
+                            '',
251
+                            false,
252
+                            '',
253
+                            'getpaid_address[' . esc_attr( $key ) . ']',
254 254
                             true
255
-						);
255
+                        );
256 256
 
257 257
                         } else {
258 258
 
259
-						aui()->input(
259
+                        aui()->input(
260 260
                             array(
261 261
                                 'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
262 262
                                 'id'          => 'wpinv-' . sanitize_html_class( $key ),
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
                                 'class'       => 'getpaid-address-field',
269 269
                             ),
270 270
                             true
271
-						);
271
+                        );
272 272
 
273 273
                         }
274 274
                     }
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 function getpaid_allowed_html() {
408 408
     $allowed_html = wp_kses_allowed_html( 'post' );
409 409
 
410
-	// form fields
410
+    // form fields
411 411
     $allowed_html['form'] = array(
412 412
         'action'         => true,
413 413
         'accept'         => true,
@@ -419,12 +419,12 @@  discard block
 block discarded – undo
419 419
     );
420 420
 
421 421
     // - input
422
-	$allowed_html['input'] = array(
423
-		'class'        => array(),
424
-		'id'           => array(),
425
-		'name'         => array(),
426
-		'value'        => array(),
427
-		'type'         => array(),
422
+    $allowed_html['input'] = array(
423
+        'class'        => array(),
424
+        'id'           => array(),
425
+        'name'         => array(),
426
+        'value'        => array(),
427
+        'type'         => array(),
428 428
         'placeholder'  => array(),
429 429
         'autocomplete' => array(),
430 430
         'autofocus'    => array(),
@@ -438,33 +438,33 @@  discard block
 block discarded – undo
438 438
         'max'          => array(),
439 439
         'step'         => array(),
440 440
         'size'         => array(),
441
-	);
441
+    );
442 442
 
443 443
     // - input
444
-	$allowed_html['textarea'] = array(
445
-		'class' => array(),
446
-		'id'    => array(),
447
-		'name'  => array(),
448
-		'value' => array(),
449
-	);
450
-
451
-	// select
452
-	$allowed_html['select'] = array(
453
-		'class'        => array(),
454
-		'id'           => array(),
455
-		'name'         => array(),
444
+    $allowed_html['textarea'] = array(
445
+        'class' => array(),
446
+        'id'    => array(),
447
+        'name'  => array(),
448
+        'value' => array(),
449
+    );
450
+
451
+    // select
452
+    $allowed_html['select'] = array(
453
+        'class'        => array(),
454
+        'id'           => array(),
455
+        'name'         => array(),
456 456
         'autocomplete' => array(),
457 457
         'multiple'     => array(),
458
-	);
458
+    );
459 459
 
460
-	// select options
461
-	$allowed_html['option'] = array(
462
-		'selected' => array(),
460
+    // select options
461
+    $allowed_html['option'] = array(
462
+        'selected' => array(),
463 463
         'disabled' => array(),
464 464
         'value'    => array(),
465
-	);
465
+    );
466 466
 
467
-	return $allowed_html;
467
+    return $allowed_html;
468 468
 
469 469
 }
470 470
 
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 1 patch
Indentation   +2632 added lines, -2632 removed lines patch added patch discarded remove patch
@@ -14,30 +14,30 @@  discard block
 block discarded – undo
14 14
 class WPInv_Invoice extends GetPaid_Data {
15 15
 
16 16
     /**
17
-	 * Which data store to load.
18
-	 *
19
-	 * @var string
20
-	 */
17
+     * Which data store to load.
18
+     *
19
+     * @var string
20
+     */
21 21
     protected $data_store_name = 'invoice';
22 22
 
23 23
     /**
24
-	 * This is the name of this object type.
25
-	 *
26
-	 * @var string
27
-	 */
24
+     * This is the name of this object type.
25
+     *
26
+     * @var string
27
+     */
28 28
     protected $object_type = 'invoice';
29 29
 
30 30
     /**
31
-	 * Item Data array. This is the core item data exposed in APIs.
32
-	 *
33
-	 * @since 1.0.19
34
-	 * @var array
35
-	 */
36
-	protected $data = array(
37
-		'parent_id'              => 0,
38
-		'status'                 => 'wpi-pending',
39
-		'version'                => '',
40
-		'date_created'           => null,
31
+     * Item Data array. This is the core item data exposed in APIs.
32
+     *
33
+     * @since 1.0.19
34
+     * @var array
35
+     */
36
+    protected $data = array(
37
+        'parent_id'              => 0,
38
+        'status'                 => 'wpi-pending',
39
+        'version'                => '',
40
+        'date_created'           => null,
41 41
         'date_modified'          => null,
42 42
         'due_date'               => null,
43 43
         'completed_date'         => null,
@@ -60,17 +60,17 @@  discard block
 block discarded – undo
60 60
         'state'                  => null,
61 61
         'zip'                    => null,
62 62
         'company'                => null,
63
-		'company_id'             => null,
63
+        'company_id'             => null,
64 64
         'vat_number'             => null,
65 65
         'vat_rate'               => null,
66 66
         'address'                => null,
67 67
         'address_confirmed'      => false,
68 68
         'shipping'               => null,
69
-		'subtotal'               => 0,
69
+        'subtotal'               => 0,
70 70
         'total_discount'         => 0,
71 71
         'total_tax'              => 0,
72
-		'total_fees'             => 0,
73
-		'total'                  => 0,
72
+        'total_fees'             => 0,
73
+        'total'                  => 0,
74 74
         'fees'                   => array(),
75 75
         'discounts'              => array(),
76 76
         'taxes'                  => array(),
@@ -82,22 +82,22 @@  discard block
 block discarded – undo
82 82
         'transaction_id'         => '',
83 83
         'currency'               => '',
84 84
         'disable_taxes'          => false,
85
-		'subscription_id'        => null,
86
-		'remote_subscription_id' => null,
87
-		'is_viewed'              => false,
88
-		'email_cc'               => '',
89
-		'template'               => 'quantity', // hours, amount only
90
-		'created_via'            => null,
85
+        'subscription_id'        => null,
86
+        'remote_subscription_id' => null,
87
+        'is_viewed'              => false,
88
+        'email_cc'               => '',
89
+        'template'               => 'quantity', // hours, amount only
90
+        'created_via'            => null,
91 91
     );
92 92
 
93 93
     /**
94
-	 * Stores meta in cache for future reads.
95
-	 *
96
-	 * A group must be set to to enable caching.
97
-	 *
98
-	 * @var string
99
-	 */
100
-	protected $cache_group = 'getpaid_invoices';
94
+     * Stores meta in cache for future reads.
95
+     *
96
+     * A group must be set to to enable caching.
97
+     *
98
+     * @var string
99
+     */
100
+    protected $cache_group = 'getpaid_invoices';
101 101
 
102 102
     /**
103 103
      * Stores a reference to the original WP_Post object
@@ -111,110 +111,110 @@  discard block
 block discarded – undo
111 111
      *
112 112
      * @var int
113 113
      */
114
-	protected $recurring_item = null;
114
+    protected $recurring_item = null;
115 115
 
116
-	/**
116
+    /**
117 117
      * Stores an array of item totals.
118
-	 *
119
-	 * e.g $totals['discount'] = array(
120
-	 *      'initial'   => 10,
121
-	 *      'recurring' => 10,
122
-	 * )
118
+     *
119
+     * e.g $totals['discount'] = array(
120
+     *      'initial'   => 10,
121
+     *      'recurring' => 10,
122
+     * )
123 123
      *
124 124
      * @var array
125 125
      */
126
-	protected $totals = array();
126
+    protected $totals = array();
127 127
 
128
-	/**
128
+    /**
129 129
      * Tax rate.
130
-	 *
130
+     *
131 131
      * @var float
132 132
      */
133
-	protected $tax_rate = 0;
133
+    protected $tax_rate = 0;
134 134
 
135
-	/**
136
-	 * Stores the status transition information.
137
-	 *
138
-	 * @since 1.0.19
139
-	 * @var bool|array
140
-	 */
141
-	protected $status_transition = false;
135
+    /**
136
+     * Stores the status transition information.
137
+     *
138
+     * @since 1.0.19
139
+     * @var bool|array
140
+     */
141
+    protected $status_transition = false;
142 142
 
143 143
     /**
144
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
145
-	 *
146
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
147
-	 */
144
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
145
+     *
146
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
147
+     */
148 148
     public function __construct( $invoice = 0 ) {
149 149
 
150 150
         parent::__construct( $invoice );
151 151
 
152
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
153
-			$this->set_id( (int) $invoice );
154
-		} elseif ( $invoice instanceof self ) {
155
-			$this->set_id( $invoice->get_id() );
156
-		} elseif ( ! empty( $invoice->ID ) ) {
157
-			$this->set_id( $invoice->ID );
158
-		} elseif ( is_array( $invoice ) ) {
159
-			$this->set_props( $invoice );
160
-
161
-			if ( isset( $invoice['ID'] ) ) {
162
-				$this->set_id( $invoice['ID'] );
163
-			}
152
+        if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
153
+            $this->set_id( (int) $invoice );
154
+        } elseif ( $invoice instanceof self ) {
155
+            $this->set_id( $invoice->get_id() );
156
+        } elseif ( ! empty( $invoice->ID ) ) {
157
+            $this->set_id( $invoice->ID );
158
+        } elseif ( is_array( $invoice ) ) {
159
+            $this->set_props( $invoice );
160
+
161
+            if ( isset( $invoice['ID'] ) ) {
162
+                $this->set_id( $invoice['ID'] );
163
+            }
164 164
 } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
165
-			$this->set_id( $invoice_id );
166
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
167
-			$this->set_id( $invoice_id );
168
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
169
-			$this->set_id( $invoice_id );
170
-		} else {
171
-			$this->set_object_read( true );
172
-		}
165
+            $this->set_id( $invoice_id );
166
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
167
+            $this->set_id( $invoice_id );
168
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
169
+            $this->set_id( $invoice_id );
170
+        } else {
171
+            $this->set_object_read( true );
172
+        }
173 173
 
174 174
         // Load the datastore.
175
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
175
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
176 176
 
177
-		if ( $this->get_id() > 0 ) {
177
+        if ( $this->get_id() > 0 ) {
178 178
             $this->post = get_post( $this->get_id() );
179 179
             $this->ID   = $this->get_id();
180
-			$this->data_store->read( $this );
180
+            $this->data_store->read( $this );
181 181
         }
182 182
 
183 183
     }
184 184
 
185 185
     /**
186
-	 * Given an invoice key/number, it returns its id.
187
-	 *
188
-	 *
189
-	 * @static
190
-	 * @param string $value The invoice key or number
191
-	 * @param string $field Either key, transaction_id or number.
192
-	 * @since 1.0.15
193
-	 * @return int
194
-	 */
195
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
186
+     * Given an invoice key/number, it returns its id.
187
+     *
188
+     *
189
+     * @static
190
+     * @param string $value The invoice key or number
191
+     * @param string $field Either key, transaction_id or number.
192
+     * @since 1.0.15
193
+     * @return int
194
+     */
195
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
196 196
         global $wpdb;
197 197
 
198
-		// Trim the value.
199
-		$value = trim( $value );
198
+        // Trim the value.
199
+        $value = trim( $value );
200 200
 
201
-		if ( empty( $value ) ) {
202
-			return 0;
203
-		}
201
+        if ( empty( $value ) ) {
202
+            return 0;
203
+        }
204 204
 
205 205
         // Valid fields.
206 206
         $fields = array( 'key', 'number', 'transaction_id' );
207 207
 
208
-		// Ensure a field has been passed.
209
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
210
-			return 0;
211
-		}
208
+        // Ensure a field has been passed.
209
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
210
+            return 0;
211
+        }
212 212
 
213
-		// Maybe retrieve from the cache.
214
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
215
-		if ( false !== $invoice_id ) {
216
-			return $invoice_id;
217
-		}
213
+        // Maybe retrieve from the cache.
214
+        $invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
215
+        if ( false !== $invoice_id ) {
216
+            return $invoice_id;
217
+        }
218 218
 
219 219
         // Fetch from the db.
220 220
         $table       = $wpdb->prefix . 'getpaid_invoices';
@@ -222,10 +222,10 @@  discard block
 block discarded – undo
222 222
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
223 223
         );
224 224
 
225
-		// Update the cache with our data
226
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
225
+        // Update the cache with our data
226
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
227 227
 
228
-		return $invoice_id;
228
+        return $invoice_id;
229 229
     }
230 230
 
231 231
     /**
@@ -251,83 +251,83 @@  discard block
 block discarded – undo
251 251
     */
252 252
 
253 253
     /**
254
-	 * Get parent invoice ID.
255
-	 *
256
-	 * @since 1.0.19
257
-	 * @param  string $context View or edit context.
258
-	 * @return int
259
-	 */
260
-	public function get_parent_id( $context = 'view' ) {
261
-		return (int) $this->get_prop( 'parent_id', $context );
254
+     * Get parent invoice ID.
255
+     *
256
+     * @since 1.0.19
257
+     * @param  string $context View or edit context.
258
+     * @return int
259
+     */
260
+    public function get_parent_id( $context = 'view' ) {
261
+        return (int) $this->get_prop( 'parent_id', $context );
262 262
     }
263 263
 
264 264
     /**
265
-	 * Get parent invoice.
266
-	 *
267
-	 * @since 1.0.19
268
-	 * @return WPInv_Invoice
269
-	 */
265
+     * Get parent invoice.
266
+     *
267
+     * @since 1.0.19
268
+     * @return WPInv_Invoice
269
+     */
270 270
     public function get_parent_payment() {
271 271
         return new WPInv_Invoice( $this->get_parent_id() );
272 272
     }
273 273
 
274 274
     /**
275
-	 * Alias for self::get_parent_payment().
276
-	 *
277
-	 * @since 1.0.19
278
-	 * @return WPInv_Invoice
279
-	 */
275
+     * Alias for self::get_parent_payment().
276
+     *
277
+     * @since 1.0.19
278
+     * @return WPInv_Invoice
279
+     */
280 280
     public function get_parent() {
281 281
         return $this->get_parent_payment();
282 282
     }
283 283
 
284 284
     /**
285
-	 * Get invoice status.
286
-	 *
287
-	 * @since 1.0.19
288
-	 * @param  string $context View or edit context.
289
-	 * @return string
290
-	 */
291
-	public function get_status( $context = 'view' ) {
292
-		return $this->get_prop( 'status', $context );
293
-	}
285
+     * Get invoice status.
286
+     *
287
+     * @since 1.0.19
288
+     * @param  string $context View or edit context.
289
+     * @return string
290
+     */
291
+    public function get_status( $context = 'view' ) {
292
+        return $this->get_prop( 'status', $context );
293
+    }
294 294
 
295
-	/**
296
-	 * Retrieves an array of possible invoice statuses.
297
-	 *
298
-	 * @since 1.0.19
299
-	 * @return array
300
-	 */
301
-	public function get_all_statuses() {
302
-		return wpinv_get_invoice_statuses( true, true, $this );
295
+    /**
296
+     * Retrieves an array of possible invoice statuses.
297
+     *
298
+     * @since 1.0.19
299
+     * @return array
300
+     */
301
+    public function get_all_statuses() {
302
+        return wpinv_get_invoice_statuses( true, true, $this );
303 303
     }
304 304
 
305 305
     /**
306
-	 * Get invoice status nice name.
307
-	 *
308
-	 * @since 1.0.19
309
-	 * @return string
310
-	 */
306
+     * Get invoice status nice name.
307
+     *
308
+     * @since 1.0.19
309
+     * @return string
310
+     */
311 311
     public function get_status_nicename() {
312
-		$statuses = $this->get_all_statuses();
312
+        $statuses = $this->get_all_statuses();
313 313
 
314 314
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
315 315
 
316 316
         return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
317 317
     }
318 318
 
319
-	/**
320
-	 * Retrieves the invoice status class
321
-	 *
322
-	 * @since  1.0.19
323
-	 * @return string
324
-	 */
325
-	public function get_status_class() {
326
-		$statuses = getpaid_get_invoice_status_classes();
327
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
328
-	}
319
+    /**
320
+     * Retrieves the invoice status class
321
+     *
322
+     * @since  1.0.19
323
+     * @return string
324
+     */
325
+    public function get_status_class() {
326
+        $statuses = getpaid_get_invoice_status_classes();
327
+        return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
328
+    }
329 329
 
330
-	/**
330
+    /**
331 331
      * Retrieves the invoice status label html
332 332
      *
333 333
      * @since  1.0.0
@@ -335,263 +335,263 @@  discard block
 block discarded – undo
335 335
      */
336 336
     public function get_status_label_html() {
337 337
 
338
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
339
-		$status       = sanitize_html_class( $this->get_status() );
340
-		$class        = esc_attr( $this->get_status_class() );
341
-
342
-		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
343
-	}
344
-
345
-    /**
346
-	 * Get plugin version when the invoice was created.
347
-	 *
348
-	 * @since 1.0.19
349
-	 * @param  string $context View or edit context.
350
-	 * @return string
351
-	 */
352
-	public function get_version( $context = 'view' ) {
353
-		return $this->get_prop( 'version', $context );
354
-	}
355
-
356
-	/**
357
-	 * @deprecated
358
-	 */
359
-	public function get_invoice_date( $format = true ) {
360
-		$date      = getpaid_format_date( $this->get_date_completed() );
361
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
362
-		$formatted = getpaid_format_date( $date );
363
-
364
-		if ( $format ) {
365
-			return $formatted;
366
-		}
367
-
368
-		return empty( $formatted ) ? '' : $date;
369
-
370
-    }
371
-
372
-    /**
373
-	 * Get date when the invoice was created.
374
-	 *
375
-	 * @since 1.0.19
376
-	 * @param  string $context View or edit context.
377
-	 * @return string
378
-	 */
379
-	public function get_date_created( $context = 'view' ) {
380
-		return $this->get_prop( 'date_created', $context );
381
-	}
382
-
383
-	/**
384
-	 * Alias for self::get_date_created().
385
-	 *
386
-	 * @since 1.0.19
387
-	 * @param  string $context View or edit context.
388
-	 * @return string
389
-	 */
390
-	public function get_created_date( $context = 'view' ) {
391
-		return $this->get_date_created( $context );
392
-    }
393
-
394
-    /**
395
-	 * Get GMT date when the invoice was created.
396
-	 *
397
-	 * @since 1.0.19
398
-	 * @param  string $context View or edit context.
399
-	 * @return string
400
-	 */
401
-	public function get_date_created_gmt( $context = 'view' ) {
338
+        $status_label = sanitize_text_field( $this->get_status_nicename() );
339
+        $status       = sanitize_html_class( $this->get_status() );
340
+        $class        = esc_attr( $this->get_status_class() );
341
+
342
+        return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
343
+    }
344
+
345
+    /**
346
+     * Get plugin version when the invoice was created.
347
+     *
348
+     * @since 1.0.19
349
+     * @param  string $context View or edit context.
350
+     * @return string
351
+     */
352
+    public function get_version( $context = 'view' ) {
353
+        return $this->get_prop( 'version', $context );
354
+    }
355
+
356
+    /**
357
+     * @deprecated
358
+     */
359
+    public function get_invoice_date( $format = true ) {
360
+        $date      = getpaid_format_date( $this->get_date_completed() );
361
+        $date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
362
+        $formatted = getpaid_format_date( $date );
363
+
364
+        if ( $format ) {
365
+            return $formatted;
366
+        }
367
+
368
+        return empty( $formatted ) ? '' : $date;
369
+
370
+    }
371
+
372
+    /**
373
+     * Get date when the invoice was created.
374
+     *
375
+     * @since 1.0.19
376
+     * @param  string $context View or edit context.
377
+     * @return string
378
+     */
379
+    public function get_date_created( $context = 'view' ) {
380
+        return $this->get_prop( 'date_created', $context );
381
+    }
382
+
383
+    /**
384
+     * Alias for self::get_date_created().
385
+     *
386
+     * @since 1.0.19
387
+     * @param  string $context View or edit context.
388
+     * @return string
389
+     */
390
+    public function get_created_date( $context = 'view' ) {
391
+        return $this->get_date_created( $context );
392
+    }
393
+
394
+    /**
395
+     * Get GMT date when the invoice was created.
396
+     *
397
+     * @since 1.0.19
398
+     * @param  string $context View or edit context.
399
+     * @return string
400
+     */
401
+    public function get_date_created_gmt( $context = 'view' ) {
402 402
         $date = $this->get_date_created( $context );
403 403
 
404 404
         if ( $date ) {
405 405
             $date = get_gmt_from_date( $date );
406 406
         }
407
-		return $date;
407
+        return $date;
408 408
     }
409 409
 
410 410
     /**
411
-	 * Get date when the invoice was last modified.
412
-	 *
413
-	 * @since 1.0.19
414
-	 * @param  string $context View or edit context.
415
-	 * @return string
416
-	 */
417
-	public function get_date_modified( $context = 'view' ) {
418
-		return $this->get_prop( 'date_modified', $context );
419
-	}
411
+     * Get date when the invoice was last modified.
412
+     *
413
+     * @since 1.0.19
414
+     * @param  string $context View or edit context.
415
+     * @return string
416
+     */
417
+    public function get_date_modified( $context = 'view' ) {
418
+        return $this->get_prop( 'date_modified', $context );
419
+    }
420 420
 
421
-	/**
422
-	 * Alias for self::get_date_modified().
423
-	 *
424
-	 * @since 1.0.19
425
-	 * @param  string $context View or edit context.
426
-	 * @return string
427
-	 */
428
-	public function get_modified_date( $context = 'view' ) {
429
-		return $this->get_date_modified( $context );
421
+    /**
422
+     * Alias for self::get_date_modified().
423
+     *
424
+     * @since 1.0.19
425
+     * @param  string $context View or edit context.
426
+     * @return string
427
+     */
428
+    public function get_modified_date( $context = 'view' ) {
429
+        return $this->get_date_modified( $context );
430 430
     }
431 431
 
432 432
     /**
433
-	 * Get GMT date when the invoice was last modified.
434
-	 *
435
-	 * @since 1.0.19
436
-	 * @param  string $context View or edit context.
437
-	 * @return string
438
-	 */
439
-	public function get_date_modified_gmt( $context = 'view' ) {
433
+     * Get GMT date when the invoice was last modified.
434
+     *
435
+     * @since 1.0.19
436
+     * @param  string $context View or edit context.
437
+     * @return string
438
+     */
439
+    public function get_date_modified_gmt( $context = 'view' ) {
440 440
         $date = $this->get_date_modified( $context );
441 441
 
442 442
         if ( $date ) {
443 443
             $date = get_gmt_from_date( $date );
444 444
         }
445
-		return $date;
445
+        return $date;
446 446
     }
447 447
 
448 448
     /**
449
-	 * Get the invoice due date.
450
-	 *
451
-	 * @since 1.0.19
452
-	 * @param  string $context View or edit context.
453
-	 * @return string
454
-	 */
455
-	public function get_due_date( $context = 'view' ) {
456
-		return $this->get_prop( 'due_date', $context );
449
+     * Get the invoice due date.
450
+     *
451
+     * @since 1.0.19
452
+     * @param  string $context View or edit context.
453
+     * @return string
454
+     */
455
+    public function get_due_date( $context = 'view' ) {
456
+        return $this->get_prop( 'due_date', $context );
457 457
     }
458 458
 
459 459
     /**
460
-	 * Alias for self::get_due_date().
461
-	 *
462
-	 * @since 1.0.19
463
-	 * @param  string $context View or edit context.
464
-	 * @return string
465
-	 */
466
-	public function get_date_due( $context = 'view' ) {
467
-		return $this->get_due_date( $context );
460
+     * Alias for self::get_due_date().
461
+     *
462
+     * @since 1.0.19
463
+     * @param  string $context View or edit context.
464
+     * @return string
465
+     */
466
+    public function get_date_due( $context = 'view' ) {
467
+        return $this->get_due_date( $context );
468 468
     }
469 469
 
470 470
     /**
471
-	 * Get the invoice GMT due date.
472
-	 *
473
-	 * @since 1.0.19
474
-	 * @param  string $context View or edit context.
475
-	 * @return string
476
-	 */
477
-	public function get_due_date_gmt( $context = 'view' ) {
471
+     * Get the invoice GMT due date.
472
+     *
473
+     * @since 1.0.19
474
+     * @param  string $context View or edit context.
475
+     * @return string
476
+     */
477
+    public function get_due_date_gmt( $context = 'view' ) {
478 478
         $date = $this->get_due_date( $context );
479 479
 
480 480
         if ( $date ) {
481 481
             $date = get_gmt_from_date( $date );
482 482
         }
483
-		return $date;
483
+        return $date;
484 484
     }
485 485
 
486 486
     /**
487
-	 * Alias for self::get_due_date_gmt().
488
-	 *
489
-	 * @since 1.0.19
490
-	 * @param  string $context View or edit context.
491
-	 * @return string
492
-	 */
493
-	public function get_gmt_date_due( $context = 'view' ) {
494
-		return $this->get_due_date_gmt( $context );
487
+     * Alias for self::get_due_date_gmt().
488
+     *
489
+     * @since 1.0.19
490
+     * @param  string $context View or edit context.
491
+     * @return string
492
+     */
493
+    public function get_gmt_date_due( $context = 'view' ) {
494
+        return $this->get_due_date_gmt( $context );
495 495
     }
496 496
 
497 497
     /**
498
-	 * Get date when the invoice was completed.
499
-	 *
500
-	 * @since 1.0.19
501
-	 * @param  string $context View or edit context.
502
-	 * @return string
503
-	 */
504
-	public function get_completed_date( $context = 'view' ) {
505
-		return $this->get_prop( 'completed_date', $context );
498
+     * Get date when the invoice was completed.
499
+     *
500
+     * @since 1.0.19
501
+     * @param  string $context View or edit context.
502
+     * @return string
503
+     */
504
+    public function get_completed_date( $context = 'view' ) {
505
+        return $this->get_prop( 'completed_date', $context );
506 506
     }
507 507
 
508 508
     /**
509
-	 * Alias for self::get_completed_date().
510
-	 *
511
-	 * @since 1.0.19
512
-	 * @param  string $context View or edit context.
513
-	 * @return string
514
-	 */
515
-	public function get_date_completed( $context = 'view' ) {
516
-		return $this->get_completed_date( $context );
509
+     * Alias for self::get_completed_date().
510
+     *
511
+     * @since 1.0.19
512
+     * @param  string $context View or edit context.
513
+     * @return string
514
+     */
515
+    public function get_date_completed( $context = 'view' ) {
516
+        return $this->get_completed_date( $context );
517 517
     }
518 518
 
519 519
     /**
520
-	 * Get GMT date when the invoice was was completed.
521
-	 *
522
-	 * @since 1.0.19
523
-	 * @param  string $context View or edit context.
524
-	 * @return string
525
-	 */
526
-	public function get_completed_date_gmt( $context = 'view' ) {
520
+     * Get GMT date when the invoice was was completed.
521
+     *
522
+     * @since 1.0.19
523
+     * @param  string $context View or edit context.
524
+     * @return string
525
+     */
526
+    public function get_completed_date_gmt( $context = 'view' ) {
527 527
         $date = $this->get_completed_date( $context );
528 528
 
529 529
         if ( $date ) {
530 530
             $date = get_gmt_from_date( $date );
531 531
         }
532
-		return $date;
532
+        return $date;
533 533
     }
534 534
 
535 535
     /**
536
-	 * Alias for self::get_completed_date_gmt().
537
-	 *
538
-	 * @since 1.0.19
539
-	 * @param  string $context View or edit context.
540
-	 * @return string
541
-	 */
542
-	public function get_gmt_completed_date( $context = 'view' ) {
543
-		return $this->get_completed_date_gmt( $context );
536
+     * Alias for self::get_completed_date_gmt().
537
+     *
538
+     * @since 1.0.19
539
+     * @param  string $context View or edit context.
540
+     * @return string
541
+     */
542
+    public function get_gmt_completed_date( $context = 'view' ) {
543
+        return $this->get_completed_date_gmt( $context );
544 544
     }
545 545
 
546 546
     /**
547
-	 * Get the invoice number.
548
-	 *
549
-	 * @since 1.0.19
550
-	 * @param  string $context View or edit context.
551
-	 * @return string
552
-	 */
553
-	public function get_number( $context = 'view' ) {
554
-		$number = $this->get_prop( 'number', $context );
547
+     * Get the invoice number.
548
+     *
549
+     * @since 1.0.19
550
+     * @param  string $context View or edit context.
551
+     * @return string
552
+     */
553
+    public function get_number( $context = 'view' ) {
554
+        $number = $this->get_prop( 'number', $context );
555 555
 
556
-		if ( empty( $number ) ) {
557
-			$number = $this->generate_number();
558
-			$this->set_number( $this->generate_number() );
559
-		}
556
+        if ( empty( $number ) ) {
557
+            $number = $this->generate_number();
558
+            $this->set_number( $this->generate_number() );
559
+        }
560 560
 
561
-		return $number;
561
+        return $number;
562 562
     }
563 563
 
564
-	/**
565
-	 * Set the invoice number.
566
-	 *
567
-	 * @since 1.0.19
568
-	 */
569
-	public function maybe_set_number() {
564
+    /**
565
+     * Set the invoice number.
566
+     *
567
+     * @since 1.0.19
568
+     */
569
+    public function maybe_set_number() {
570 570
         $number = $this->get_number();
571 571
 
572 572
         if ( empty( $number ) || $this->get_id() == $number ) {
573
-			$this->set_number( $this->generate_number() );
573
+            $this->set_number( $this->generate_number() );
574 574
         }
575 575
 
576
-	}
576
+    }
577 577
 
578 578
     /**
579
-	 * Get the invoice key.
580
-	 *
581
-	 * @since 1.0.19
582
-	 * @param  string $context View or edit context.
583
-	 * @return string
584
-	 */
585
-	public function get_key( $context = 'view' ) {
579
+     * Get the invoice key.
580
+     *
581
+     * @since 1.0.19
582
+     * @param  string $context View or edit context.
583
+     * @return string
584
+     */
585
+    public function get_key( $context = 'view' ) {
586 586
         return $this->get_prop( 'key', $context );
587
-	}
588
-
589
-	/**
590
-	 * Set the invoice key.
591
-	 *
592
-	 * @since 1.0.19
593
-	 */
594
-	public function maybe_set_key() {
587
+    }
588
+
589
+    /**
590
+     * Set the invoice key.
591
+     *
592
+     * @since 1.0.19
593
+     */
594
+    public function maybe_set_key() {
595 595
         $key = $this->get_key();
596 596
 
597 597
         if ( empty( $key ) ) {
@@ -602,140 +602,140 @@  discard block
 block discarded – undo
602 602
     }
603 603
 
604 604
     /**
605
-	 * Get the invoice type.
606
-	 *
607
-	 * @since 1.0.19
608
-	 * @param  string $context View or edit context.
609
-	 * @return string
610
-	 */
611
-	public function get_type( $context = 'view' ) {
605
+     * Get the invoice type.
606
+     *
607
+     * @since 1.0.19
608
+     * @param  string $context View or edit context.
609
+     * @return string
610
+     */
611
+    public function get_type( $context = 'view' ) {
612 612
         return $this->get_prop( 'type', $context );
613
-	}
614
-
615
-	/**
616
-	 * Returns the post type name.
617
-	 *
618
-	 * @since 1.0.19
619
-	 * @return string
620
-	 */
621
-	public function get_invoice_quote_type() {
613
+    }
614
+
615
+    /**
616
+     * Returns the post type name.
617
+     *
618
+     * @since 1.0.19
619
+     * @return string
620
+     */
621
+    public function get_invoice_quote_type() {
622 622
         return getpaid_get_post_type_label( $this->get_post_type(), false );
623 623
     }
624 624
 
625 625
     /**
626
-	 * Get the invoice post type label.
627
-	 *
628
-	 * @since 1.0.19
629
-	 * @param  string $context View or edit context.
630
-	 * @return string
631
-	 */
632
-	public function get_label( $context = 'view' ) {
626
+     * Get the invoice post type label.
627
+     *
628
+     * @since 1.0.19
629
+     * @param  string $context View or edit context.
630
+     * @return string
631
+     */
632
+    public function get_label( $context = 'view' ) {
633 633
         return getpaid_get_post_type_label( $this->get_post_type( $context ), false );
634
-	}
635
-
636
-	/**
637
-	 * Get the invoice post type.
638
-	 *
639
-	 * @since 1.0.19
640
-	 * @param  string $context View or edit context.
641
-	 * @return string
642
-	 */
643
-	public function get_post_type( $context = 'view' ) {
634
+    }
635
+
636
+    /**
637
+     * Get the invoice post type.
638
+     *
639
+     * @since 1.0.19
640
+     * @param  string $context View or edit context.
641
+     * @return string
642
+     */
643
+    public function get_post_type( $context = 'view' ) {
644 644
         return $this->get_prop( 'post_type', $context );
645 645
     }
646 646
 
647 647
     /**
648
-	 * Get the invoice mode.
649
-	 *
650
-	 * @since 1.0.19
651
-	 * @param  string $context View or edit context.
652
-	 * @return string
653
-	 */
654
-	public function get_mode( $context = 'view' ) {
648
+     * Get the invoice mode.
649
+     *
650
+     * @since 1.0.19
651
+     * @param  string $context View or edit context.
652
+     * @return string
653
+     */
654
+    public function get_mode( $context = 'view' ) {
655 655
         return $this->get_prop( 'mode', $context );
656 656
     }
657 657
 
658 658
     /**
659
-	 * Get the invoice path.
660
-	 *
661
-	 * @since 1.0.19
662
-	 * @param  string $context View or edit context.
663
-	 * @return string
664
-	 */
665
-	public function get_path( $context = 'view' ) {
659
+     * Get the invoice path.
660
+     *
661
+     * @since 1.0.19
662
+     * @param  string $context View or edit context.
663
+     * @return string
664
+     */
665
+    public function get_path( $context = 'view' ) {
666 666
         $path   = $this->get_prop( 'path', $context );
667
-		$prefix = $this->get_type();
667
+        $prefix = $this->get_type();
668 668
 
669
-		if ( 0 !== strpos( $path, $prefix ) ) {
670
-			$path = sanitize_title( $prefix . '-' . $this->get_id() );
671
-			$this->set_path( $path );
672
-		}
669
+        if ( 0 !== strpos( $path, $prefix ) ) {
670
+            $path = sanitize_title( $prefix . '-' . $this->get_id() );
671
+            $this->set_path( $path );
672
+        }
673 673
 
674
-		return $path;
674
+        return $path;
675 675
     }
676 676
 
677 677
     /**
678
-	 * Get the invoice name/title.
679
-	 *
680
-	 * @since 1.0.19
681
-	 * @param  string $context View or edit context.
682
-	 * @return string
683
-	 */
684
-	public function get_name( $context = 'view' ) {
678
+     * Get the invoice name/title.
679
+     *
680
+     * @since 1.0.19
681
+     * @param  string $context View or edit context.
682
+     * @return string
683
+     */
684
+    public function get_name( $context = 'view' ) {
685 685
         return $this->get_prop( 'title', $context );
686 686
     }
687 687
 
688 688
     /**
689
-	 * Alias of self::get_name().
690
-	 *
691
-	 * @since 1.0.19
692
-	 * @param  string $context View or edit context.
693
-	 * @return string
694
-	 */
695
-	public function get_title( $context = 'view' ) {
696
-		return $this->get_name( $context );
689
+     * Alias of self::get_name().
690
+     *
691
+     * @since 1.0.19
692
+     * @param  string $context View or edit context.
693
+     * @return string
694
+     */
695
+    public function get_title( $context = 'view' ) {
696
+        return $this->get_name( $context );
697 697
     }
698 698
 
699 699
     /**
700
-	 * Get the invoice description.
701
-	 *
702
-	 * @since 1.0.19
703
-	 * @param  string $context View or edit context.
704
-	 * @return string
705
-	 */
706
-	public function get_description( $context = 'view' ) {
707
-		return $this->get_prop( 'description', $context );
700
+     * Get the invoice description.
701
+     *
702
+     * @since 1.0.19
703
+     * @param  string $context View or edit context.
704
+     * @return string
705
+     */
706
+    public function get_description( $context = 'view' ) {
707
+        return $this->get_prop( 'description', $context );
708 708
     }
709 709
 
710 710
     /**
711
-	 * Alias of self::get_description().
712
-	 *
713
-	 * @since 1.0.19
714
-	 * @param  string $context View or edit context.
715
-	 * @return string
716
-	 */
717
-	public function get_excerpt( $context = 'view' ) {
718
-		return $this->get_description( $context );
711
+     * Alias of self::get_description().
712
+     *
713
+     * @since 1.0.19
714
+     * @param  string $context View or edit context.
715
+     * @return string
716
+     */
717
+    public function get_excerpt( $context = 'view' ) {
718
+        return $this->get_description( $context );
719 719
     }
720 720
 
721 721
     /**
722
-	 * Alias of self::get_description().
723
-	 *
724
-	 * @since 1.0.19
725
-	 * @param  string $context View or edit context.
726
-	 * @return string
727
-	 */
728
-	public function get_summary( $context = 'view' ) {
729
-		return $this->get_description( $context );
722
+     * Alias of self::get_description().
723
+     *
724
+     * @since 1.0.19
725
+     * @param  string $context View or edit context.
726
+     * @return string
727
+     */
728
+    public function get_summary( $context = 'view' ) {
729
+        return $this->get_description( $context );
730 730
     }
731 731
 
732 732
     /**
733
-	 * Returns the user info.
734
-	 *
735
-	 * @since 1.0.19
733
+     * Returns the user info.
734
+     *
735
+     * @since 1.0.19
736 736
      * @param  string $context View or edit context.
737
-	 * @return array
738
-	 */
737
+     * @return array
738
+     */
739 739
     public function get_user_info( $context = 'view' ) {
740 740
 
741 741
         $user_info = array(
@@ -750,683 +750,683 @@  discard block
 block discarded – undo
750 750
             'state'      => $this->get_state( $context ),
751 751
             'zip'        => $this->get_zip( $context ),
752 752
             'company'    => $this->get_company( $context ),
753
-			'company_id' => $this->get_company_id( $context ),
753
+            'company_id' => $this->get_company_id( $context ),
754 754
             'vat_number' => $this->get_vat_number( $context ),
755 755
             'discount'   => $this->get_discount_code( $context ),
756
-		);
756
+        );
757 757
 
758
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
758
+        return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
759 759
 
760 760
     }
761 761
 
762 762
     /**
763
-	 * Get the customer id.
764
-	 *
765
-	 * @since 1.0.19
766
-	 * @param  string $context View or edit context.
767
-	 * @return int
768
-	 */
769
-	public function get_author( $context = 'view' ) {
770
-		return (int) $this->get_prop( 'author', $context );
763
+     * Get the customer id.
764
+     *
765
+     * @since 1.0.19
766
+     * @param  string $context View or edit context.
767
+     * @return int
768
+     */
769
+    public function get_author( $context = 'view' ) {
770
+        return (int) $this->get_prop( 'author', $context );
771 771
     }
772 772
 
773 773
     /**
774
-	 * Alias of self::get_author().
775
-	 *
776
-	 * @since 1.0.19
777
-	 * @param  string $context View or edit context.
778
-	 * @return int
779
-	 */
780
-	public function get_user_id( $context = 'view' ) {
781
-		return $this->get_author( $context );
774
+     * Alias of self::get_author().
775
+     *
776
+     * @since 1.0.19
777
+     * @param  string $context View or edit context.
778
+     * @return int
779
+     */
780
+    public function get_user_id( $context = 'view' ) {
781
+        return $this->get_author( $context );
782 782
     }
783 783
 
784
-     /**
785
-	 * Alias of self::get_author().
786
-	 *
787
-	 * @since 1.0.19
788
-	 * @param  string $context View or edit context.
789
-	 * @return int
790
-	 */
791
-	public function get_customer_id( $context = 'view' ) {
792
-		return $this->get_author( $context );
784
+        /**
785
+         * Alias of self::get_author().
786
+         *
787
+         * @since 1.0.19
788
+         * @param  string $context View or edit context.
789
+         * @return int
790
+         */
791
+    public function get_customer_id( $context = 'view' ) {
792
+        return $this->get_author( $context );
793 793
     }
794 794
 
795 795
     /**
796
-	 * Get the customer's ip.
797
-	 *
798
-	 * @since 1.0.19
799
-	 * @param  string $context View or edit context.
800
-	 * @return string
801
-	 */
802
-	public function get_ip( $context = 'view' ) {
803
-		return $this->get_prop( 'user_ip', $context );
796
+     * Get the customer's ip.
797
+     *
798
+     * @since 1.0.19
799
+     * @param  string $context View or edit context.
800
+     * @return string
801
+     */
802
+    public function get_ip( $context = 'view' ) {
803
+        return $this->get_prop( 'user_ip', $context );
804 804
     }
805 805
 
806 806
     /**
807
-	 * Alias of self::get_ip().
808
-	 *
809
-	 * @since 1.0.19
810
-	 * @param  string $context View or edit context.
811
-	 * @return string
812
-	 */
813
-	public function get_user_ip( $context = 'view' ) {
814
-		return $this->get_ip( $context );
807
+     * Alias of self::get_ip().
808
+     *
809
+     * @since 1.0.19
810
+     * @param  string $context View or edit context.
811
+     * @return string
812
+     */
813
+    public function get_user_ip( $context = 'view' ) {
814
+        return $this->get_ip( $context );
815 815
     }
816 816
 
817
-     /**
818
-	 * Alias of self::get_ip().
819
-	 *
820
-	 * @since 1.0.19
821
-	 * @param  string $context View or edit context.
822
-	 * @return string
823
-	 */
824
-	public function get_customer_ip( $context = 'view' ) {
825
-		return $this->get_ip( $context );
817
+        /**
818
+         * Alias of self::get_ip().
819
+         *
820
+         * @since 1.0.19
821
+         * @param  string $context View or edit context.
822
+         * @return string
823
+         */
824
+    public function get_customer_ip( $context = 'view' ) {
825
+        return $this->get_ip( $context );
826 826
     }
827 827
 
828 828
     /**
829
-	 * Get the customer's first name.
830
-	 *
831
-	 * @since 1.0.19
832
-	 * @param  string $context View or edit context.
833
-	 * @return string
834
-	 */
835
-	public function get_first_name( $context = 'view' ) {
836
-		return $this->get_prop( 'first_name', $context );
829
+     * Get the customer's first name.
830
+     *
831
+     * @since 1.0.19
832
+     * @param  string $context View or edit context.
833
+     * @return string
834
+     */
835
+    public function get_first_name( $context = 'view' ) {
836
+        return $this->get_prop( 'first_name', $context );
837 837
     }
838 838
 
839 839
     /**
840
-	 * Alias of self::get_first_name().
841
-	 *
842
-	 * @since 1.0.19
843
-	 * @param  string $context View or edit context.
844
-	 * @return string
845
-	 */
846
-	public function get_user_first_name( $context = 'view' ) {
847
-		return $this->get_first_name( $context );
840
+     * Alias of self::get_first_name().
841
+     *
842
+     * @since 1.0.19
843
+     * @param  string $context View or edit context.
844
+     * @return string
845
+     */
846
+    public function get_user_first_name( $context = 'view' ) {
847
+        return $this->get_first_name( $context );
848 848
     }
849 849
 
850
-     /**
851
-	 * Alias of self::get_first_name().
852
-	 *
853
-	 * @since 1.0.19
854
-	 * @param  string $context View or edit context.
855
-	 * @return string
856
-	 */
857
-	public function get_customer_first_name( $context = 'view' ) {
858
-		return $this->get_first_name( $context );
850
+        /**
851
+         * Alias of self::get_first_name().
852
+         *
853
+         * @since 1.0.19
854
+         * @param  string $context View or edit context.
855
+         * @return string
856
+         */
857
+    public function get_customer_first_name( $context = 'view' ) {
858
+        return $this->get_first_name( $context );
859 859
     }
860 860
 
861 861
     /**
862
-	 * Get the customer's last name.
863
-	 *
864
-	 * @since 1.0.19
865
-	 * @param  string $context View or edit context.
866
-	 * @return string
867
-	 */
868
-	public function get_last_name( $context = 'view' ) {
869
-		return $this->get_prop( 'last_name', $context );
862
+     * Get the customer's last name.
863
+     *
864
+     * @since 1.0.19
865
+     * @param  string $context View or edit context.
866
+     * @return string
867
+     */
868
+    public function get_last_name( $context = 'view' ) {
869
+        return $this->get_prop( 'last_name', $context );
870 870
     }
871 871
 
872 872
     /**
873
-	 * Alias of self::get_last_name().
874
-	 *
875
-	 * @since 1.0.19
876
-	 * @param  string $context View or edit context.
877
-	 * @return string
878
-	 */
879
-	public function get_user_last_name( $context = 'view' ) {
880
-		return $this->get_last_name( $context );
873
+     * Alias of self::get_last_name().
874
+     *
875
+     * @since 1.0.19
876
+     * @param  string $context View or edit context.
877
+     * @return string
878
+     */
879
+    public function get_user_last_name( $context = 'view' ) {
880
+        return $this->get_last_name( $context );
881 881
     }
882 882
 
883 883
     /**
884
-	 * Alias of self::get_last_name().
885
-	 *
886
-	 * @since 1.0.19
887
-	 * @param  string $context View or edit context.
888
-	 * @return string
889
-	 */
890
-	public function get_customer_last_name( $context = 'view' ) {
891
-		return $this->get_last_name( $context );
884
+     * Alias of self::get_last_name().
885
+     *
886
+     * @since 1.0.19
887
+     * @param  string $context View or edit context.
888
+     * @return string
889
+     */
890
+    public function get_customer_last_name( $context = 'view' ) {
891
+        return $this->get_last_name( $context );
892 892
     }
893 893
 
894 894
     /**
895
-	 * Get the customer's full name.
896
-	 *
897
-	 * @since 1.0.19
898
-	 * @param  string $context View or edit context.
899
-	 * @return string
900
-	 */
901
-	public function get_full_name( $context = 'view' ) {
902
-		$name = trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
895
+     * Get the customer's full name.
896
+     *
897
+     * @since 1.0.19
898
+     * @param  string $context View or edit context.
899
+     * @return string
900
+     */
901
+    public function get_full_name( $context = 'view' ) {
902
+        $name = trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
903 903
 
904
-		if ( ! $name ) {
905
-			$user = get_userdata( $this->get_author( $context ) );
904
+        if ( ! $name ) {
905
+            $user = get_userdata( $this->get_author( $context ) );
906 906
 
907
-			if ( $user ) {
908
-				$name = $user->display_name;
909
-			}
910
-		}
907
+            if ( $user ) {
908
+                $name = $user->display_name;
909
+            }
910
+        }
911 911
 
912
-		if ( ! $name ) {
913
-			$name = $this->get_email( $context );
914
-		}
912
+        if ( ! $name ) {
913
+            $name = $this->get_email( $context );
914
+        }
915 915
 
916
-		return apply_filters( 'wpinv_invoice_user_full_name', $name, $this );
916
+        return apply_filters( 'wpinv_invoice_user_full_name', $name, $this );
917 917
     }
918 918
 
919 919
     /**
920
-	 * Alias of self::get_full_name().
921
-	 *
922
-	 * @since 1.0.19
923
-	 * @param  string $context View or edit context.
924
-	 * @return string
925
-	 */
926
-	public function get_user_full_name( $context = 'view' ) {
927
-		return $this->get_full_name( $context );
920
+     * Alias of self::get_full_name().
921
+     *
922
+     * @since 1.0.19
923
+     * @param  string $context View or edit context.
924
+     * @return string
925
+     */
926
+    public function get_user_full_name( $context = 'view' ) {
927
+        return $this->get_full_name( $context );
928 928
     }
929 929
 
930 930
     /**
931
-	 * Alias of self::get_full_name().
932
-	 *
933
-	 * @since 1.0.19
934
-	 * @param  string $context View or edit context.
935
-	 * @return string
936
-	 */
937
-	public function get_customer_full_name( $context = 'view' ) {
938
-		return $this->get_full_name( $context );
931
+     * Alias of self::get_full_name().
932
+     *
933
+     * @since 1.0.19
934
+     * @param  string $context View or edit context.
935
+     * @return string
936
+     */
937
+    public function get_customer_full_name( $context = 'view' ) {
938
+        return $this->get_full_name( $context );
939 939
     }
940 940
 
941 941
     /**
942
-	 * Get the customer's phone number.
943
-	 *
944
-	 * @since 1.0.19
945
-	 * @param  string $context View or edit context.
946
-	 * @return string
947
-	 */
948
-	public function get_phone( $context = 'view' ) {
949
-		return $this->get_prop( 'phone', $context );
942
+     * Get the customer's phone number.
943
+     *
944
+     * @since 1.0.19
945
+     * @param  string $context View or edit context.
946
+     * @return string
947
+     */
948
+    public function get_phone( $context = 'view' ) {
949
+        return $this->get_prop( 'phone', $context );
950
+    }
951
+
952
+    /**
953
+     * Alias of self::get_phone().
954
+     *
955
+     * @since 1.0.19
956
+     * @param  string $context View or edit context.
957
+     * @return string
958
+     */
959
+    public function get_phone_number( $context = 'view' ) {
960
+        return $this->get_phone( $context );
961
+    }
962
+
963
+    /**
964
+     * Alias of self::get_phone().
965
+     *
966
+     * @since 1.0.19
967
+     * @param  string $context View or edit context.
968
+     * @return string
969
+     */
970
+    public function get_user_phone( $context = 'view' ) {
971
+        return $this->get_phone( $context );
972
+    }
973
+
974
+    /**
975
+     * Alias of self::get_phone().
976
+     *
977
+     * @since 1.0.19
978
+     * @param  string $context View or edit context.
979
+     * @return string
980
+     */
981
+    public function get_customer_phone( $context = 'view' ) {
982
+        return $this->get_phone( $context );
983
+    }
984
+
985
+    /**
986
+     * Get the customer's email address.
987
+     *
988
+     * @since 1.0.19
989
+     * @param  string $context View or edit context.
990
+     * @return string
991
+     */
992
+    public function get_email( $context = 'view' ) {
993
+        return $this->get_prop( 'email', $context );
994
+    }
995
+
996
+    /**
997
+     * Alias of self::get_email().
998
+     *
999
+     * @since 1.0.19
1000
+     * @param  string $context View or edit context.
1001
+     * @return string
1002
+     */
1003
+    public function get_email_address( $context = 'view' ) {
1004
+        return $this->get_email( $context );
1005
+    }
1006
+
1007
+    /**
1008
+     * Alias of self::get_email().
1009
+     *
1010
+     * @since 1.0.19
1011
+     * @param  string $context View or edit context.
1012
+     * @return string
1013
+     */
1014
+    public function get_user_email( $context = 'view' ) {
1015
+        return $this->get_email( $context );
1016
+    }
1017
+
1018
+    /**
1019
+     * Alias of self::get_email().
1020
+     *
1021
+     * @since 1.0.19
1022
+     * @param  string $context View or edit context.
1023
+     * @return string
1024
+     */
1025
+    public function get_customer_email( $context = 'view' ) {
1026
+        return $this->get_email( $context );
1027
+    }
1028
+
1029
+    /**
1030
+     * Get the customer's country.
1031
+     *
1032
+     * @since 1.0.19
1033
+     * @param  string $context View or edit context.
1034
+     * @return string
1035
+     */
1036
+    public function get_country( $context = 'view' ) {
1037
+        $country = $this->get_prop( 'country', $context );
1038
+        return empty( $country ) ? wpinv_get_default_country() : $country;
1039
+    }
1040
+
1041
+    /**
1042
+     * Alias of self::get_country().
1043
+     *
1044
+     * @since 1.0.19
1045
+     * @param  string $context View or edit context.
1046
+     * @return string
1047
+     */
1048
+    public function get_user_country( $context = 'view' ) {
1049
+        return $this->get_country( $context );
1050
+    }
1051
+
1052
+    /**
1053
+     * Alias of self::get_country().
1054
+     *
1055
+     * @since 1.0.19
1056
+     * @param  string $context View or edit context.
1057
+     * @return string
1058
+     */
1059
+    public function get_customer_country( $context = 'view' ) {
1060
+        return $this->get_country( $context );
1061
+    }
1062
+
1063
+    /**
1064
+     * Get the customer's state.
1065
+     *
1066
+     * @since 1.0.19
1067
+     * @param  string $context View or edit context.
1068
+     * @return string
1069
+     */
1070
+    public function get_state( $context = 'view' ) {
1071
+        $state = $this->get_prop( 'state', $context );
1072
+        return empty( $state ) ? wpinv_get_default_state() : $state;
950 1073
     }
951 1074
 
952 1075
     /**
953
-	 * Alias of self::get_phone().
954
-	 *
955
-	 * @since 1.0.19
956
-	 * @param  string $context View or edit context.
957
-	 * @return string
958
-	 */
959
-	public function get_phone_number( $context = 'view' ) {
960
-		return $this->get_phone( $context );
1076
+     * Alias of self::get_state().
1077
+     *
1078
+     * @since 1.0.19
1079
+     * @param  string $context View or edit context.
1080
+     * @return string
1081
+     */
1082
+    public function get_user_state( $context = 'view' ) {
1083
+        return $this->get_state( $context );
961 1084
     }
962 1085
 
963 1086
     /**
964
-	 * Alias of self::get_phone().
965
-	 *
966
-	 * @since 1.0.19
967
-	 * @param  string $context View or edit context.
968
-	 * @return string
969
-	 */
970
-	public function get_user_phone( $context = 'view' ) {
971
-		return $this->get_phone( $context );
1087
+     * Alias of self::get_state().
1088
+     *
1089
+     * @since 1.0.19
1090
+     * @param  string $context View or edit context.
1091
+     * @return string
1092
+     */
1093
+    public function get_customer_state( $context = 'view' ) {
1094
+        return $this->get_state( $context );
972 1095
     }
973 1096
 
974 1097
     /**
975
-	 * Alias of self::get_phone().
976
-	 *
977
-	 * @since 1.0.19
978
-	 * @param  string $context View or edit context.
979
-	 * @return string
980
-	 */
981
-	public function get_customer_phone( $context = 'view' ) {
982
-		return $this->get_phone( $context );
1098
+     * Get the customer's city.
1099
+     *
1100
+     * @since 1.0.19
1101
+     * @param  string $context View or edit context.
1102
+     * @return string
1103
+     */
1104
+    public function get_city( $context = 'view' ) {
1105
+        return $this->get_prop( 'city', $context );
983 1106
     }
984 1107
 
985 1108
     /**
986
-	 * Get the customer's email address.
987
-	 *
988
-	 * @since 1.0.19
989
-	 * @param  string $context View or edit context.
990
-	 * @return string
991
-	 */
992
-	public function get_email( $context = 'view' ) {
993
-		return $this->get_prop( 'email', $context );
1109
+     * Alias of self::get_city().
1110
+     *
1111
+     * @since 1.0.19
1112
+     * @param  string $context View or edit context.
1113
+     * @return string
1114
+     */
1115
+    public function get_user_city( $context = 'view' ) {
1116
+        return $this->get_city( $context );
994 1117
     }
995 1118
 
996 1119
     /**
997
-	 * Alias of self::get_email().
998
-	 *
999
-	 * @since 1.0.19
1000
-	 * @param  string $context View or edit context.
1001
-	 * @return string
1002
-	 */
1003
-	public function get_email_address( $context = 'view' ) {
1004
-		return $this->get_email( $context );
1120
+     * Alias of self::get_city().
1121
+     *
1122
+     * @since 1.0.19
1123
+     * @param  string $context View or edit context.
1124
+     * @return string
1125
+     */
1126
+    public function get_customer_city( $context = 'view' ) {
1127
+        return $this->get_city( $context );
1005 1128
     }
1006 1129
 
1007 1130
     /**
1008
-	 * Alias of self::get_email().
1009
-	 *
1010
-	 * @since 1.0.19
1011
-	 * @param  string $context View or edit context.
1012
-	 * @return string
1013
-	 */
1014
-	public function get_user_email( $context = 'view' ) {
1015
-		return $this->get_email( $context );
1131
+     * Get the customer's zip.
1132
+     *
1133
+     * @since 1.0.19
1134
+     * @param  string $context View or edit context.
1135
+     * @return string
1136
+     */
1137
+    public function get_zip( $context = 'view' ) {
1138
+        return $this->get_prop( 'zip', $context );
1016 1139
     }
1017 1140
 
1018 1141
     /**
1019
-	 * Alias of self::get_email().
1020
-	 *
1021
-	 * @since 1.0.19
1022
-	 * @param  string $context View or edit context.
1023
-	 * @return string
1024
-	 */
1025
-	public function get_customer_email( $context = 'view' ) {
1026
-		return $this->get_email( $context );
1142
+     * Alias of self::get_zip().
1143
+     *
1144
+     * @since 1.0.19
1145
+     * @param  string $context View or edit context.
1146
+     * @return string
1147
+     */
1148
+    public function get_user_zip( $context = 'view' ) {
1149
+        return $this->get_zip( $context );
1027 1150
     }
1028 1151
 
1029 1152
     /**
1030
-	 * Get the customer's country.
1031
-	 *
1032
-	 * @since 1.0.19
1033
-	 * @param  string $context View or edit context.
1034
-	 * @return string
1035
-	 */
1036
-	public function get_country( $context = 'view' ) {
1037
-		$country = $this->get_prop( 'country', $context );
1038
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1153
+     * Alias of self::get_zip().
1154
+     *
1155
+     * @since 1.0.19
1156
+     * @param  string $context View or edit context.
1157
+     * @return string
1158
+     */
1159
+    public function get_customer_zip( $context = 'view' ) {
1160
+        return $this->get_zip( $context );
1039 1161
     }
1040 1162
 
1041 1163
     /**
1042
-	 * Alias of self::get_country().
1043
-	 *
1044
-	 * @since 1.0.19
1045
-	 * @param  string $context View or edit context.
1046
-	 * @return string
1047
-	 */
1048
-	public function get_user_country( $context = 'view' ) {
1049
-		return $this->get_country( $context );
1164
+     * Get the customer's company.
1165
+     *
1166
+     * @since 1.0.19
1167
+     * @param  string $context View or edit context.
1168
+     * @return string
1169
+     */
1170
+    public function get_company( $context = 'view' ) {
1171
+        return $this->get_prop( 'company', $context );
1172
+    }
1173
+
1174
+    /**
1175
+     * Alias of self::get_company().
1176
+     *
1177
+     * @since 1.0.19
1178
+     * @param  string $context View or edit context.
1179
+     * @return string
1180
+     */
1181
+    public function get_user_company( $context = 'view' ) {
1182
+        return $this->get_company( $context );
1183
+    }
1184
+
1185
+    /**
1186
+     * Alias of self::get_company().
1187
+     *
1188
+     * @since 1.0.19
1189
+     * @param  string $context View or edit context.
1190
+     * @return string
1191
+     */
1192
+    public function get_customer_company( $context = 'view' ) {
1193
+        return $this->get_company( $context );
1194
+    }
1195
+
1196
+    /**
1197
+     * Get the customer's company id.
1198
+     *
1199
+     * @since 1.0.19
1200
+     * @param  string $context View or edit context.
1201
+     * @return string
1202
+     */
1203
+    public function get_company_id( $context = 'view' ) {
1204
+        return $this->get_prop( 'company_id', $context );
1205
+    }
1206
+
1207
+    /**
1208
+     * Get the customer's vat number.
1209
+     *
1210
+     * @since 1.0.19
1211
+     * @param  string $context View or edit context.
1212
+     * @return string
1213
+     */
1214
+    public function get_vat_number( $context = 'view' ) {
1215
+        return $this->get_prop( 'vat_number', $context );
1050 1216
     }
1051 1217
 
1052 1218
     /**
1053
-	 * Alias of self::get_country().
1054
-	 *
1055
-	 * @since 1.0.19
1056
-	 * @param  string $context View or edit context.
1057
-	 * @return string
1058
-	 */
1059
-	public function get_customer_country( $context = 'view' ) {
1060
-		return $this->get_country( $context );
1219
+     * Alias of self::get_vat_number().
1220
+     *
1221
+     * @since 1.0.19
1222
+     * @param  string $context View or edit context.
1223
+     * @return string
1224
+     */
1225
+    public function get_user_vat_number( $context = 'view' ) {
1226
+        return $this->get_vat_number( $context );
1227
+    }
1228
+
1229
+    /**
1230
+     * Alias of self::get_vat_number().
1231
+     *
1232
+     * @since 1.0.19
1233
+     * @param  string $context View or edit context.
1234
+     * @return string
1235
+     */
1236
+    public function get_customer_vat_number( $context = 'view' ) {
1237
+        return $this->get_vat_number( $context );
1061 1238
     }
1062 1239
 
1063 1240
     /**
1064
-	 * Get the customer's state.
1065
-	 *
1066
-	 * @since 1.0.19
1067
-	 * @param  string $context View or edit context.
1068
-	 * @return string
1069
-	 */
1070
-	public function get_state( $context = 'view' ) {
1071
-		$state = $this->get_prop( 'state', $context );
1072
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1241
+     * Get the customer's vat rate.
1242
+     *
1243
+     * @since 1.0.19
1244
+     * @param  string $context View or edit context.
1245
+     * @return string
1246
+     */
1247
+    public function get_vat_rate( $context = 'view' ) {
1248
+        return $this->get_prop( 'vat_rate', $context );
1073 1249
     }
1074 1250
 
1075 1251
     /**
1076
-	 * Alias of self::get_state().
1077
-	 *
1078
-	 * @since 1.0.19
1079
-	 * @param  string $context View or edit context.
1080
-	 * @return string
1081
-	 */
1082
-	public function get_user_state( $context = 'view' ) {
1083
-		return $this->get_state( $context );
1252
+     * Alias of self::get_vat_rate().
1253
+     *
1254
+     * @since 1.0.19
1255
+     * @param  string $context View or edit context.
1256
+     * @return string
1257
+     */
1258
+    public function get_user_vat_rate( $context = 'view' ) {
1259
+        return $this->get_vat_rate( $context );
1084 1260
     }
1085 1261
 
1086 1262
     /**
1087
-	 * Alias of self::get_state().
1088
-	 *
1089
-	 * @since 1.0.19
1090
-	 * @param  string $context View or edit context.
1091
-	 * @return string
1092
-	 */
1093
-	public function get_customer_state( $context = 'view' ) {
1094
-		return $this->get_state( $context );
1263
+     * Alias of self::get_vat_rate().
1264
+     *
1265
+     * @since 1.0.19
1266
+     * @param  string $context View or edit context.
1267
+     * @return string
1268
+     */
1269
+    public function get_customer_vat_rate( $context = 'view' ) {
1270
+        return $this->get_vat_rate( $context );
1095 1271
     }
1096 1272
 
1097 1273
     /**
1098
-	 * Get the customer's city.
1099
-	 *
1100
-	 * @since 1.0.19
1101
-	 * @param  string $context View or edit context.
1102
-	 * @return string
1103
-	 */
1104
-	public function get_city( $context = 'view' ) {
1105
-		return $this->get_prop( 'city', $context );
1274
+     * Get the customer's address.
1275
+     *
1276
+     * @since 1.0.19
1277
+     * @param  string $context View or edit context.
1278
+     * @return string
1279
+     */
1280
+    public function get_address( $context = 'view' ) {
1281
+        return $this->get_prop( 'address', $context );
1106 1282
     }
1107 1283
 
1108 1284
     /**
1109
-	 * Alias of self::get_city().
1110
-	 *
1111
-	 * @since 1.0.19
1112
-	 * @param  string $context View or edit context.
1113
-	 * @return string
1114
-	 */
1115
-	public function get_user_city( $context = 'view' ) {
1116
-		return $this->get_city( $context );
1285
+     * Alias of self::get_address().
1286
+     *
1287
+     * @since 1.0.19
1288
+     * @param  string $context View or edit context.
1289
+     * @return string
1290
+     */
1291
+    public function get_user_address( $context = 'view' ) {
1292
+        return $this->get_address( $context );
1117 1293
     }
1118 1294
 
1119 1295
     /**
1120
-	 * Alias of self::get_city().
1121
-	 *
1122
-	 * @since 1.0.19
1123
-	 * @param  string $context View or edit context.
1124
-	 * @return string
1125
-	 */
1126
-	public function get_customer_city( $context = 'view' ) {
1127
-		return $this->get_city( $context );
1296
+     * Alias of self::get_address().
1297
+     *
1298
+     * @since 1.0.19
1299
+     * @param  string $context View or edit context.
1300
+     * @return string
1301
+     */
1302
+    public function get_customer_address( $context = 'view' ) {
1303
+        return $this->get_address( $context );
1128 1304
     }
1129 1305
 
1130 1306
     /**
1131
-	 * Get the customer's zip.
1132
-	 *
1133
-	 * @since 1.0.19
1134
-	 * @param  string $context View or edit context.
1135
-	 * @return string
1136
-	 */
1137
-	public function get_zip( $context = 'view' ) {
1138
-		return $this->get_prop( 'zip', $context );
1307
+     * Get whether the customer has viewed the invoice or not.
1308
+     *
1309
+     * @since 1.0.19
1310
+     * @param  string $context View or edit context.
1311
+     * @return bool
1312
+     */
1313
+    public function get_is_viewed( $context = 'view' ) {
1314
+        return (bool) $this->get_prop( 'is_viewed', $context );
1139 1315
     }
1140 1316
 
1141 1317
     /**
1142
-	 * Alias of self::get_zip().
1143
-	 *
1144
-	 * @since 1.0.19
1145
-	 * @param  string $context View or edit context.
1146
-	 * @return string
1147
-	 */
1148
-	public function get_user_zip( $context = 'view' ) {
1149
-		return $this->get_zip( $context );
1318
+     * Get other recipients for invoice communications.
1319
+     *
1320
+     * @since 1.0.19
1321
+     * @param  string $context View or edit context.
1322
+     * @return bool
1323
+     */
1324
+    public function get_email_cc( $context = 'view' ) {
1325
+        return $this->get_prop( 'email_cc', $context );
1150 1326
     }
1151 1327
 
1152 1328
     /**
1153
-	 * Alias of self::get_zip().
1154
-	 *
1155
-	 * @since 1.0.19
1156
-	 * @param  string $context View or edit context.
1157
-	 * @return string
1158
-	 */
1159
-	public function get_customer_zip( $context = 'view' ) {
1160
-		return $this->get_zip( $context );
1329
+     * Get invoice template.
1330
+     *
1331
+     * @since 1.0.19
1332
+     * @param  string $context View or edit context.
1333
+     * @return bool
1334
+     */
1335
+    public function get_template( $context = 'view' ) {
1336
+        return $this->get_prop( 'template', $context );
1161 1337
     }
1162 1338
 
1163 1339
     /**
1164
-	 * Get the customer's company.
1165
-	 *
1166
-	 * @since 1.0.19
1167
-	 * @param  string $context View or edit context.
1168
-	 * @return string
1169
-	 */
1170
-	public function get_company( $context = 'view' ) {
1171
-		return $this->get_prop( 'company', $context );
1340
+     * Get invoice source.
1341
+     *
1342
+     * @since 1.0.19
1343
+     * @param  string $context View or edit context.
1344
+     * @return bool
1345
+     */
1346
+    public function get_created_via( $context = 'view' ) {
1347
+        return $this->get_prop( 'created_via', $context );
1172 1348
     }
1173 1349
 
1174 1350
     /**
1175
-	 * Alias of self::get_company().
1176
-	 *
1177
-	 * @since 1.0.19
1178
-	 * @param  string $context View or edit context.
1179
-	 * @return string
1180
-	 */
1181
-	public function get_user_company( $context = 'view' ) {
1182
-		return $this->get_company( $context );
1351
+     * Get whether the customer has confirmed their address.
1352
+     *
1353
+     * @since 1.0.19
1354
+     * @param  string $context View or edit context.
1355
+     * @return bool
1356
+     */
1357
+    public function get_address_confirmed( $context = 'view' ) {
1358
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1183 1359
     }
1184 1360
 
1185 1361
     /**
1186
-	 * Alias of self::get_company().
1187
-	 *
1188
-	 * @since 1.0.19
1189
-	 * @param  string $context View or edit context.
1190
-	 * @return string
1191
-	 */
1192
-	public function get_customer_company( $context = 'view' ) {
1193
-		return $this->get_company( $context );
1362
+     * Alias of self::get_address_confirmed().
1363
+     *
1364
+     * @since 1.0.19
1365
+     * @param  string $context View or edit context.
1366
+     * @return bool
1367
+     */
1368
+    public function get_user_address_confirmed( $context = 'view' ) {
1369
+        return $this->get_address_confirmed( $context );
1194 1370
     }
1195 1371
 
1196
-	/**
1197
-	 * Get the customer's company id.
1198
-	 *
1199
-	 * @since 1.0.19
1200
-	 * @param  string $context View or edit context.
1201
-	 * @return string
1202
-	 */
1203
-	public function get_company_id( $context = 'view' ) {
1204
-		return $this->get_prop( 'company_id', $context );
1372
+    /**
1373
+     * Alias of self::get_address().
1374
+     *
1375
+     * @since 1.0.19
1376
+     * @param  string $context View or edit context.
1377
+     * @return bool
1378
+     */
1379
+    public function get_customer_address_confirmed( $context = 'view' ) {
1380
+        return $this->get_address_confirmed( $context );
1205 1381
     }
1206 1382
 
1207 1383
     /**
1208
-	 * Get the customer's vat number.
1209
-	 *
1210
-	 * @since 1.0.19
1211
-	 * @param  string $context View or edit context.
1212
-	 * @return string
1213
-	 */
1214
-	public function get_vat_number( $context = 'view' ) {
1215
-		return $this->get_prop( 'vat_number', $context );
1384
+     * Get the shipping address.
1385
+     *
1386
+     * @since 1.0.19
1387
+     * @return array|false
1388
+     */
1389
+    public function get_shipping_address() {
1390
+
1391
+        $shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true );
1392
+        return is_array( $shipping_address ) ? $shipping_address : false;
1216 1393
     }
1217 1394
 
1218 1395
     /**
1219
-	 * Alias of self::get_vat_number().
1220
-	 *
1221
-	 * @since 1.0.19
1222
-	 * @param  string $context View or edit context.
1223
-	 * @return string
1224
-	 */
1225
-	public function get_user_vat_number( $context = 'view' ) {
1226
-		return $this->get_vat_number( $context );
1396
+     * Check if the invoice has a shipping address.
1397
+     */
1398
+    public function has_shipping_address() {
1399
+        return false !== $this->get_shipping_address();
1227 1400
     }
1228 1401
 
1229 1402
     /**
1230
-	 * Alias of self::get_vat_number().
1231
-	 *
1232
-	 * @since 1.0.19
1233
-	 * @param  string $context View or edit context.
1234
-	 * @return string
1235
-	 */
1236
-	public function get_customer_vat_number( $context = 'view' ) {
1237
-		return $this->get_vat_number( $context );
1403
+     * Get the shipping amount.
1404
+     *
1405
+     * @since 1.0.19
1406
+     * @param  string $context View or edit context.
1407
+     * @return float
1408
+     */
1409
+    public function get_shipping( $context = 'view' ) {
1410
+
1411
+        if ( $context = 'view' ) {
1412
+            return floatval( $this->get_prop( 'shipping', $context ) );
1413
+        }
1414
+
1415
+        return $this->get_prop( 'shipping', $context );
1416
+    }
1417
+
1418
+    public function has_shipping() {
1419
+        return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && null !== $this->get_prop( 'shipping', 'edit' );
1238 1420
     }
1239 1421
 
1240
-    /**
1241
-	 * Get the customer's vat rate.
1242
-	 *
1243
-	 * @since 1.0.19
1244
-	 * @param  string $context View or edit context.
1245
-	 * @return string
1246
-	 */
1247
-	public function get_vat_rate( $context = 'view' ) {
1248
-		return $this->get_prop( 'vat_rate', $context );
1249
-    }
1250
-
1251
-    /**
1252
-	 * Alias of self::get_vat_rate().
1253
-	 *
1254
-	 * @since 1.0.19
1255
-	 * @param  string $context View or edit context.
1256
-	 * @return string
1257
-	 */
1258
-	public function get_user_vat_rate( $context = 'view' ) {
1259
-		return $this->get_vat_rate( $context );
1260
-    }
1261
-
1262
-    /**
1263
-	 * Alias of self::get_vat_rate().
1264
-	 *
1265
-	 * @since 1.0.19
1266
-	 * @param  string $context View or edit context.
1267
-	 * @return string
1268
-	 */
1269
-	public function get_customer_vat_rate( $context = 'view' ) {
1270
-		return $this->get_vat_rate( $context );
1271
-    }
1272
-
1273
-    /**
1274
-	 * Get the customer's address.
1275
-	 *
1276
-	 * @since 1.0.19
1277
-	 * @param  string $context View or edit context.
1278
-	 * @return string
1279
-	 */
1280
-	public function get_address( $context = 'view' ) {
1281
-		return $this->get_prop( 'address', $context );
1282
-    }
1283
-
1284
-    /**
1285
-	 * Alias of self::get_address().
1286
-	 *
1287
-	 * @since 1.0.19
1288
-	 * @param  string $context View or edit context.
1289
-	 * @return string
1290
-	 */
1291
-	public function get_user_address( $context = 'view' ) {
1292
-		return $this->get_address( $context );
1293
-    }
1294
-
1295
-    /**
1296
-	 * Alias of self::get_address().
1297
-	 *
1298
-	 * @since 1.0.19
1299
-	 * @param  string $context View or edit context.
1300
-	 * @return string
1301
-	 */
1302
-	public function get_customer_address( $context = 'view' ) {
1303
-		return $this->get_address( $context );
1304
-    }
1305
-
1306
-    /**
1307
-	 * Get whether the customer has viewed the invoice or not.
1308
-	 *
1309
-	 * @since 1.0.19
1310
-	 * @param  string $context View or edit context.
1311
-	 * @return bool
1312
-	 */
1313
-	public function get_is_viewed( $context = 'view' ) {
1314
-		return (bool) $this->get_prop( 'is_viewed', $context );
1315
-	}
1316
-
1317
-	/**
1318
-	 * Get other recipients for invoice communications.
1319
-	 *
1320
-	 * @since 1.0.19
1321
-	 * @param  string $context View or edit context.
1322
-	 * @return bool
1323
-	 */
1324
-	public function get_email_cc( $context = 'view' ) {
1325
-		return $this->get_prop( 'email_cc', $context );
1326
-	}
1327
-
1328
-	/**
1329
-	 * Get invoice template.
1330
-	 *
1331
-	 * @since 1.0.19
1332
-	 * @param  string $context View or edit context.
1333
-	 * @return bool
1334
-	 */
1335
-	public function get_template( $context = 'view' ) {
1336
-		return $this->get_prop( 'template', $context );
1337
-	}
1338
-
1339
-	/**
1340
-	 * Get invoice source.
1341
-	 *
1342
-	 * @since 1.0.19
1343
-	 * @param  string $context View or edit context.
1344
-	 * @return bool
1345
-	 */
1346
-	public function get_created_via( $context = 'view' ) {
1347
-		return $this->get_prop( 'created_via', $context );
1348
-	}
1349
-
1350
-	/**
1351
-	 * Get whether the customer has confirmed their address.
1352
-	 *
1353
-	 * @since 1.0.19
1354
-	 * @param  string $context View or edit context.
1355
-	 * @return bool
1356
-	 */
1357
-	public function get_address_confirmed( $context = 'view' ) {
1358
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1359
-    }
1360
-
1361
-    /**
1362
-	 * Alias of self::get_address_confirmed().
1363
-	 *
1364
-	 * @since 1.0.19
1365
-	 * @param  string $context View or edit context.
1366
-	 * @return bool
1367
-	 */
1368
-	public function get_user_address_confirmed( $context = 'view' ) {
1369
-		return $this->get_address_confirmed( $context );
1370
-    }
1371
-
1372
-    /**
1373
-	 * Alias of self::get_address().
1374
-	 *
1375
-	 * @since 1.0.19
1376
-	 * @param  string $context View or edit context.
1377
-	 * @return bool
1378
-	 */
1379
-	public function get_customer_address_confirmed( $context = 'view' ) {
1380
-		return $this->get_address_confirmed( $context );
1381
-    }
1382
-
1383
-	/**
1384
-	 * Get the shipping address.
1385
-	 *
1386
-	 * @since 1.0.19
1387
-	 * @return array|false
1388
-	 */
1389
-	public function get_shipping_address() {
1390
-
1391
-		$shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true );
1392
-		return is_array( $shipping_address ) ? $shipping_address : false;
1393
-    }
1394
-
1395
-	/**
1396
-	 * Check if the invoice has a shipping address.
1397
-	 */
1398
-	public function has_shipping_address() {
1399
-		return false !== $this->get_shipping_address();
1400
-    }
1401
-
1402
-	/**
1403
-	 * Get the shipping amount.
1404
-	 *
1405
-	 * @since 1.0.19
1406
-	 * @param  string $context View or edit context.
1407
-	 * @return float
1408
-	 */
1409
-	public function get_shipping( $context = 'view' ) {
1410
-
1411
-		if ( $context = 'view' ) {
1412
-			return floatval( $this->get_prop( 'shipping', $context ) );
1413
-		}
1414
-
1415
-		return $this->get_prop( 'shipping', $context );
1416
-    }
1417
-
1418
-	public function has_shipping() {
1419
-		return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && null !== $this->get_prop( 'shipping', 'edit' );
1420
-    }
1421
-
1422
-    /**
1423
-	 * Get the invoice subtotal.
1424
-	 *
1425
-	 * @since 1.0.19
1426
-	 * @param  string $context View or edit context.
1427
-	 * @return float
1428
-	 */
1429
-	public function get_subtotal( $context = 'view' ) {
1422
+    /**
1423
+     * Get the invoice subtotal.
1424
+     *
1425
+     * @since 1.0.19
1426
+     * @param  string $context View or edit context.
1427
+     * @return float
1428
+     */
1429
+    public function get_subtotal( $context = 'view' ) {
1430 1430
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1431 1431
 
1432 1432
         // Backwards compatibility.
@@ -1438,198 +1438,198 @@  discard block
 block discarded – undo
1438 1438
     }
1439 1439
 
1440 1440
     /**
1441
-	 * Get the invoice discount total.
1442
-	 *
1443
-	 * @since 1.0.19
1444
-	 * @param  string $context View or edit context.
1445
-	 * @return float
1446
-	 */
1447
-	public function get_total_discount( $context = 'view' ) {
1448
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1441
+     * Get the invoice discount total.
1442
+     *
1443
+     * @since 1.0.19
1444
+     * @param  string $context View or edit context.
1445
+     * @return float
1446
+     */
1447
+    public function get_total_discount( $context = 'view' ) {
1448
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1449 1449
     }
1450 1450
 
1451 1451
     /**
1452
-	 * Get the invoice tax total.
1453
-	 *
1454
-	 * @since 1.0.19
1455
-	 * @param  string $context View or edit context.
1456
-	 * @return float
1457
-	 */
1458
-	public function get_total_tax( $context = 'view' ) {
1459
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1460
-	}
1452
+     * Get the invoice tax total.
1453
+     *
1454
+     * @since 1.0.19
1455
+     * @param  string $context View or edit context.
1456
+     * @return float
1457
+     */
1458
+    public function get_total_tax( $context = 'view' ) {
1459
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1460
+    }
1461 1461
 
1462
-	/**
1463
-	 * @deprecated
1464
-	 */
1465
-	public function get_final_tax( $currency = false ) {
1466
-		$tax = $this->get_total_tax();
1462
+    /**
1463
+     * @deprecated
1464
+     */
1465
+    public function get_final_tax( $currency = false ) {
1466
+        $tax = $this->get_total_tax();
1467 1467
 
1468 1468
         if ( $currency ) {
1469
-			return wpinv_price( $tax, $this->get_currency() );
1469
+            return wpinv_price( $tax, $this->get_currency() );
1470 1470
         }
1471 1471
 
1472 1472
         return $tax;
1473 1473
     }
1474 1474
 
1475 1475
     /**
1476
-	 * Get the invoice fees total.
1477
-	 *
1478
-	 * @since 1.0.19
1479
-	 * @param  string $context View or edit context.
1480
-	 * @return float
1481
-	 */
1482
-	public function get_total_fees( $context = 'view' ) {
1483
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1476
+     * Get the invoice fees total.
1477
+     *
1478
+     * @since 1.0.19
1479
+     * @param  string $context View or edit context.
1480
+     * @return float
1481
+     */
1482
+    public function get_total_fees( $context = 'view' ) {
1483
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1484
+    }
1485
+
1486
+    /**
1487
+     * Alias for self::get_total_fees().
1488
+     *
1489
+     * @since 1.0.19
1490
+     * @param  string $context View or edit context.
1491
+     * @return float
1492
+     */
1493
+    public function get_fees_total( $context = 'view' ) {
1494
+        return $this->get_total_fees( $context );
1484 1495
     }
1485 1496
 
1486 1497
     /**
1487
-	 * Alias for self::get_total_fees().
1488
-	 *
1489
-	 * @since 1.0.19
1490
-	 * @param  string $context View or edit context.
1491
-	 * @return float
1492
-	 */
1493
-	public function get_fees_total( $context = 'view' ) {
1494
-		return $this->get_total_fees( $context );
1498
+     * Get the invoice total.
1499
+     *
1500
+     * @since 1.0.19
1501
+     * @return float
1502
+     */
1503
+    public function get_total( $context = 'view' ) {
1504
+        $total = $this->get_prop( 'total', $context );
1505
+
1506
+        if ( $this->has_shipping() && $context == 'view' ) {
1507
+            $total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context );
1508
+        }
1509
+
1510
+        return wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1495 1511
     }
1496 1512
 
1497 1513
     /**
1498
-	 * Get the invoice total.
1499
-	 *
1500
-	 * @since 1.0.19
1514
+     * Retrieves the non-recurring total of items.
1515
+     *
1516
+     * @since 2.3.0
1501 1517
      * @return float
1502
-	 */
1503
-	public function get_total( $context = 'view' ) {
1504
-		$total = $this->get_prop( 'total', $context );
1505
-
1506
-		if ( $this->has_shipping() && $context == 'view' ) {
1507
-			$total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context );
1508
-		}
1509
-
1510
-		return wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1511
-	}
1512
-
1513
-	/**
1514
-	 * Retrieves the non-recurring total of items.
1515
-	 *
1516
-	 * @since 2.3.0
1517
-	 * @return float
1518
-	 */
1519
-	public function get_non_recurring_total() {
1520
-
1521
-		$subtotal = 0;
1522
-		foreach ( $this->get_items() as $item ) {
1523
-			if ( ! $item->is_recurring() ) {
1524
-				$subtotal += $item->get_sub_total();
1525
-			}
1526
-		}
1527
-
1528
-		foreach ( $this->get_fees() as $fee ) {
1529
-			if ( empty( $fee['recurring_fee'] ) ) {
1530
-				$subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1531
-			}
1532
-		}
1533
-
1534
-		$subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1518
+     */
1519
+    public function get_non_recurring_total() {
1520
+
1521
+        $subtotal = 0;
1522
+        foreach ( $this->get_items() as $item ) {
1523
+            if ( ! $item->is_recurring() ) {
1524
+                $subtotal += $item->get_sub_total();
1525
+            }
1526
+        }
1527
+
1528
+        foreach ( $this->get_fees() as $fee ) {
1529
+            if ( empty( $fee['recurring_fee'] ) ) {
1530
+                $subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1531
+            }
1532
+        }
1533
+
1534
+        $subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1535 1535
         return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this );
1536 1536
 
1537 1537
     }
1538 1538
 
1539
-	/**
1540
-	 * Get the invoice totals.
1541
-	 *
1542
-	 * @since 1.0.19
1539
+    /**
1540
+     * Get the invoice totals.
1541
+     *
1542
+     * @since 1.0.19
1543 1543
      * @return array
1544
-	 */
1545
-	public function get_totals() {
1546
-		return $this->totals;
1544
+     */
1545
+    public function get_totals() {
1546
+        return $this->totals;
1547 1547
     }
1548 1548
 
1549 1549
     /**
1550
-	 * Get the initial invoice total.
1551
-	 *
1552
-	 * @since 1.0.19
1550
+     * Get the initial invoice total.
1551
+     *
1552
+     * @since 1.0.19
1553 1553
      * @param  string $context View or edit context.
1554 1554
      * @return float
1555
-	 */
1555
+     */
1556 1556
     public function get_initial_total() {
1557 1557
 
1558
-		if ( empty( $this->totals ) ) {
1559
-			$this->recalculate_total();
1560
-		}
1558
+        if ( empty( $this->totals ) ) {
1559
+            $this->recalculate_total();
1560
+        }
1561 1561
 
1562
-		$tax      = $this->totals['tax']['initial'];
1563
-		$fee      = $this->totals['fee']['initial'];
1564
-		$discount = $this->totals['discount']['initial'];
1565
-		$subtotal = $this->totals['subtotal']['initial'];
1566
-		$total    = $tax + $fee - $discount + $subtotal;
1562
+        $tax      = $this->totals['tax']['initial'];
1563
+        $fee      = $this->totals['fee']['initial'];
1564
+        $discount = $this->totals['discount']['initial'];
1565
+        $subtotal = $this->totals['subtotal']['initial'];
1566
+        $total    = $tax + $fee - $discount + $subtotal;
1567 1567
 
1568
-		if ( 0 > $total ) {
1569
-			$total = 0;
1570
-		}
1568
+        if ( 0 > $total ) {
1569
+            $total = 0;
1570
+        }
1571 1571
 
1572
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1572
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1573 1573
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1574
-	}
1574
+    }
1575 1575
 
1576
-	/**
1577
-	 * Get the recurring invoice total.
1578
-	 *
1579
-	 * @since 1.0.19
1576
+    /**
1577
+     * Get the recurring invoice total.
1578
+     *
1579
+     * @since 1.0.19
1580 1580
      * @param  string $context View or edit context.
1581 1581
      * @return float
1582
-	 */
1582
+     */
1583 1583
     public function get_recurring_total() {
1584 1584
 
1585
-		if ( empty( $this->totals ) ) {
1586
-			$this->recalculate_total();
1587
-		}
1585
+        if ( empty( $this->totals ) ) {
1586
+            $this->recalculate_total();
1587
+        }
1588 1588
 
1589
-		$tax      = $this->totals['tax']['recurring'];
1590
-		$fee      = $this->totals['fee']['recurring'];
1591
-		$discount = $this->totals['discount']['recurring'];
1592
-		$subtotal = $this->totals['subtotal']['recurring'];
1593
-		$total    = $tax + $fee - $discount + $subtotal;
1589
+        $tax      = $this->totals['tax']['recurring'];
1590
+        $fee      = $this->totals['fee']['recurring'];
1591
+        $discount = $this->totals['discount']['recurring'];
1592
+        $subtotal = $this->totals['subtotal']['recurring'];
1593
+        $total    = $tax + $fee - $discount + $subtotal;
1594 1594
 
1595
-		if ( 0 > $total ) {
1596
-			$total = 0;
1597
-		}
1595
+        if ( 0 > $total ) {
1596
+            $total = 0;
1597
+        }
1598 1598
 
1599
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1599
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1600 1600
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1601
-	}
1601
+    }
1602 1602
 
1603
-	/**
1604
-	 * Returns recurring payment details.
1605
-	 *
1606
-	 * @since 1.0.19
1603
+    /**
1604
+     * Returns recurring payment details.
1605
+     *
1606
+     * @since 1.0.19
1607 1607
      * @param  string $field Optionally provide a field to return.
1608
-	 * @param string $currency Whether to include the currency.
1608
+     * @param string $currency Whether to include the currency.
1609 1609
      * @return float|string
1610
-	 */
1610
+     */
1611 1611
     public function get_recurring_details( $field = '', $currency = false ) {
1612 1612
 
1613
-		// Maybe recalculate totals.
1614
-		if ( empty( $this->totals ) ) {
1615
-			$this->recalculate_total();
1616
-		}
1613
+        // Maybe recalculate totals.
1614
+        if ( empty( $this->totals ) ) {
1615
+            $this->recalculate_total();
1616
+        }
1617 1617
 
1618
-		// Prepare recurring totals.
1618
+        // Prepare recurring totals.
1619 1619
         $data = apply_filters(
1620
-			'wpinv_get_invoice_recurring_details',
1621
-			array(
1622
-				'cart_details' => $this->get_cart_details(),
1623
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1624
-				'discount'     => $this->totals['discount']['recurring'],
1625
-				'tax'          => $this->totals['tax']['recurring'],
1626
-				'fee'          => $this->totals['fee']['recurring'],
1627
-				'total'        => $this->get_recurring_total(),
1628
-			),
1629
-			$this,
1630
-			$field,
1631
-			$currency
1632
-		);
1620
+            'wpinv_get_invoice_recurring_details',
1621
+            array(
1622
+                'cart_details' => $this->get_cart_details(),
1623
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1624
+                'discount'     => $this->totals['discount']['recurring'],
1625
+                'tax'          => $this->totals['tax']['recurring'],
1626
+                'fee'          => $this->totals['fee']['recurring'],
1627
+                'total'        => $this->get_recurring_total(),
1628
+            ),
1629
+            $this,
1630
+            $field,
1631
+            $currency
1632
+        );
1633 1633
 
1634 1634
         if ( isset( $data[ $field ] ) ) {
1635 1635
             return ( $currency ? wpinv_price( $data[ $field ], $this->get_currency() ) : $data[ $field ] );
@@ -1639,166 +1639,166 @@  discard block
 block discarded – undo
1639 1639
     }
1640 1640
 
1641 1641
     /**
1642
-	 * Get the invoice fees.
1643
-	 *
1644
-	 * @since 1.0.19
1645
-	 * @param  string $context View or edit context.
1646
-	 * @return array
1647
-	 */
1648
-	public function get_fees( $context = 'view' ) {
1649
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1642
+     * Get the invoice fees.
1643
+     *
1644
+     * @since 1.0.19
1645
+     * @param  string $context View or edit context.
1646
+     * @return array
1647
+     */
1648
+    public function get_fees( $context = 'view' ) {
1649
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1650 1650
     }
1651 1651
 
1652 1652
     /**
1653
-	 * Get the invoice discounts.
1654
-	 *
1655
-	 * @since 1.0.19
1656
-	 * @param  string $context View or edit context.
1657
-	 * @return array
1658
-	 */
1659
-	public function get_discounts( $context = 'view' ) {
1660
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1653
+     * Get the invoice discounts.
1654
+     *
1655
+     * @since 1.0.19
1656
+     * @param  string $context View or edit context.
1657
+     * @return array
1658
+     */
1659
+    public function get_discounts( $context = 'view' ) {
1660
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1661 1661
     }
1662 1662
 
1663 1663
     /**
1664
-	 * Get the invoice taxes.
1665
-	 *
1666
-	 * @since 1.0.19
1667
-	 * @param  string $context View or edit context.
1668
-	 * @return array
1669
-	 */
1670
-	public function get_taxes( $context = 'view' ) {
1671
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1664
+     * Get the invoice taxes.
1665
+     *
1666
+     * @since 1.0.19
1667
+     * @param  string $context View or edit context.
1668
+     * @return array
1669
+     */
1670
+    public function get_taxes( $context = 'view' ) {
1671
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1672 1672
     }
1673 1673
 
1674 1674
     /**
1675
-	 * Get the invoice items.
1676
-	 *
1677
-	 * @since 1.0.19
1678
-	 * @param  string $context View or edit context.
1679
-	 * @return GetPaid_Form_Item[]
1680
-	 */
1681
-	public function get_items( $context = 'view' ) {
1675
+     * Get the invoice items.
1676
+     *
1677
+     * @since 1.0.19
1678
+     * @param  string $context View or edit context.
1679
+     * @return GetPaid_Form_Item[]
1680
+     */
1681
+    public function get_items( $context = 'view' ) {
1682 1682
         return $this->get_prop( 'items', $context );
1683
-	}
1683
+    }
1684 1684
 
1685
-	/**
1686
-	 * Get the invoice item ids.
1687
-	 *
1688
-	 * @since 1.0.19
1689
-	 * @return string
1690
-	 */
1691
-	public function get_item_ids() {
1692
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1685
+    /**
1686
+     * Get the invoice item ids.
1687
+     *
1688
+     * @since 1.0.19
1689
+     * @return string
1690
+     */
1691
+    public function get_item_ids() {
1692
+        return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1693 1693
     }
1694 1694
 
1695 1695
     /**
1696
-	 * Get the invoice's payment form.
1697
-	 *
1698
-	 * @since 1.0.19
1699
-	 * @param  string $context View or edit context.
1700
-	 * @return int
1701
-	 */
1702
-	public function get_payment_form( $context = 'view' ) {
1703
-		return intval( $this->get_prop( 'payment_form', $context ) );
1696
+     * Get the invoice's payment form.
1697
+     *
1698
+     * @since 1.0.19
1699
+     * @param  string $context View or edit context.
1700
+     * @return int
1701
+     */
1702
+    public function get_payment_form( $context = 'view' ) {
1703
+        return intval( $this->get_prop( 'payment_form', $context ) );
1704 1704
     }
1705 1705
 
1706 1706
     /**
1707
-	 * Get the invoice's submission id.
1708
-	 *
1709
-	 * @since 1.0.19
1710
-	 * @param  string $context View or edit context.
1711
-	 * @return string
1712
-	 */
1713
-	public function get_submission_id( $context = 'view' ) {
1714
-		return $this->get_prop( 'submission_id', $context );
1707
+     * Get the invoice's submission id.
1708
+     *
1709
+     * @since 1.0.19
1710
+     * @param  string $context View or edit context.
1711
+     * @return string
1712
+     */
1713
+    public function get_submission_id( $context = 'view' ) {
1714
+        return $this->get_prop( 'submission_id', $context );
1715 1715
     }
1716 1716
 
1717 1717
     /**
1718
-	 * Get the invoice's discount code.
1719
-	 *
1720
-	 * @since 1.0.19
1721
-	 * @param  string $context View or edit context.
1722
-	 * @return string
1723
-	 */
1724
-	public function get_discount_code( $context = 'view' ) {
1725
-		return $this->get_prop( 'discount_code', $context );
1718
+     * Get the invoice's discount code.
1719
+     *
1720
+     * @since 1.0.19
1721
+     * @param  string $context View or edit context.
1722
+     * @return string
1723
+     */
1724
+    public function get_discount_code( $context = 'view' ) {
1725
+        return $this->get_prop( 'discount_code', $context );
1726 1726
     }
1727 1727
 
1728 1728
     /**
1729
-	 * Get the invoice's gateway.
1730
-	 *
1731
-	 * @since 1.0.19
1732
-	 * @param  string $context View or edit context.
1733
-	 * @return string
1734
-	 */
1735
-	public function get_gateway( $context = 'view' ) {
1736
-		return $this->get_prop( 'gateway', $context );
1729
+     * Get the invoice's gateway.
1730
+     *
1731
+     * @since 1.0.19
1732
+     * @param  string $context View or edit context.
1733
+     * @return string
1734
+     */
1735
+    public function get_gateway( $context = 'view' ) {
1736
+        return $this->get_prop( 'gateway', $context );
1737 1737
     }
1738 1738
 
1739 1739
     /**
1740
-	 * Get the invoice's gateway display title.
1741
-	 *
1742
-	 * @since 1.0.19
1743
-	 * @return string
1744
-	 */
1740
+     * Get the invoice's gateway display title.
1741
+     *
1742
+     * @since 1.0.19
1743
+     * @return string
1744
+     */
1745 1745
     public function get_gateway_title() {
1746 1746
         $title = wpinv_get_gateway_checkout_label( $this->get_gateway() );
1747 1747
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1748 1748
     }
1749 1749
 
1750 1750
     /**
1751
-	 * Get the invoice's transaction id.
1752
-	 *
1753
-	 * @since 1.0.19
1754
-	 * @param  string $context View or edit context.
1755
-	 * @return string
1756
-	 */
1757
-	public function get_transaction_id( $context = 'view' ) {
1758
-		return $this->get_prop( 'transaction_id', $context );
1751
+     * Get the invoice's transaction id.
1752
+     *
1753
+     * @since 1.0.19
1754
+     * @param  string $context View or edit context.
1755
+     * @return string
1756
+     */
1757
+    public function get_transaction_id( $context = 'view' ) {
1758
+        return $this->get_prop( 'transaction_id', $context );
1759 1759
     }
1760 1760
 
1761 1761
     /**
1762
-	 * Get the invoice's currency.
1763
-	 *
1764
-	 * @since 1.0.19
1765
-	 * @param  string $context View or edit context.
1766
-	 * @return string
1767
-	 */
1768
-	public function get_currency( $context = 'view' ) {
1762
+     * Get the invoice's currency.
1763
+     *
1764
+     * @since 1.0.19
1765
+     * @param  string $context View or edit context.
1766
+     * @return string
1767
+     */
1768
+    public function get_currency( $context = 'view' ) {
1769 1769
         $currency = $this->get_prop( 'currency', $context );
1770 1770
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1771 1771
     }
1772 1772
 
1773 1773
     /**
1774
-	 * Checks if we are charging taxes for this invoice.
1775
-	 *
1776
-	 * @since 1.0.19
1777
-	 * @param  string $context View or edit context.
1778
-	 * @return bool
1779
-	 */
1780
-	public function get_disable_taxes( $context = 'view' ) {
1774
+     * Checks if we are charging taxes for this invoice.
1775
+     *
1776
+     * @since 1.0.19
1777
+     * @param  string $context View or edit context.
1778
+     * @return bool
1779
+     */
1780
+    public function get_disable_taxes( $context = 'view' ) {
1781 1781
         return (bool) $this->get_prop( 'disable_taxes', $context );
1782 1782
     }
1783 1783
 
1784 1784
     /**
1785
-	 * Retrieves the subscription id for an invoice.
1786
-	 *
1787
-	 * @since 1.0.19
1788
-	 * @param  string $context View or edit context.
1789
-	 * @return int
1790
-	 */
1785
+     * Retrieves the subscription id for an invoice.
1786
+     *
1787
+     * @since 1.0.19
1788
+     * @param  string $context View or edit context.
1789
+     * @return int
1790
+     */
1791 1791
     public function get_subscription_id( $context = 'view' ) {
1792
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1793
-	}
1794
-
1795
-	/**
1796
-	 * Retrieves the remote subscription id for an invoice.
1797
-	 *
1798
-	 * @since 1.0.19
1799
-	 * @param  string $context View or edit context.
1800
-	 * @return int
1801
-	 */
1792
+        return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1793
+    }
1794
+
1795
+    /**
1796
+     * Retrieves the remote subscription id for an invoice.
1797
+     *
1798
+     * @since 1.0.19
1799
+     * @param  string $context View or edit context.
1800
+     * @return int
1801
+     */
1802 1802
     public function get_remote_subscription_id( $context = 'view' ) {
1803 1803
         $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1804 1804
 
@@ -1811,12 +1811,12 @@  discard block
 block discarded – undo
1811 1811
     }
1812 1812
 
1813 1813
     /**
1814
-	 * Retrieves the payment meta for an invoice.
1815
-	 *
1816
-	 * @since 1.0.19
1817
-	 * @param  string $context View or edit context.
1818
-	 * @return array
1819
-	 */
1814
+     * Retrieves the payment meta for an invoice.
1815
+     *
1816
+     * @since 1.0.19
1817
+     * @param  string $context View or edit context.
1818
+     * @return array
1819
+     */
1820 1820
     public function get_payment_meta( $context = 'view' ) {
1821 1821
 
1822 1822
         return array(
@@ -1836,31 +1836,31 @@  discard block
 block discarded – undo
1836 1836
     }
1837 1837
 
1838 1838
     /**
1839
-	 * Retrieves the cart details for an invoice.
1840
-	 *
1841
-	 * @since 1.0.19
1842
-	 * @return array
1843
-	 */
1839
+     * Retrieves the cart details for an invoice.
1840
+     *
1841
+     * @since 1.0.19
1842
+     * @return array
1843
+     */
1844 1844
     public function get_cart_details() {
1845 1845
         $items        = $this->get_items();
1846 1846
         $cart_details = array();
1847 1847
 
1848 1848
         foreach ( $items as $item ) {
1849
-			$item->invoice_id = $this->get_id();
1849
+            $item->invoice_id = $this->get_id();
1850 1850
             $cart_details[]   = $item->prepare_data_for_saving();
1851 1851
         }
1852 1852
 
1853 1853
         return $cart_details;
1854
-	}
1854
+    }
1855 1855
 
1856
-	/**
1857
-	 * Retrieves the recurring item.
1858
-	 *
1859
-	 * @return null|GetPaid_Form_Item|int
1860
-	 */
1861
-	public function get_recurring( $object = false ) {
1856
+    /**
1857
+     * Retrieves the recurring item.
1858
+     *
1859
+     * @return null|GetPaid_Form_Item|int
1860
+     */
1861
+    public function get_recurring( $object = false ) {
1862 1862
 
1863
-		// Are we returning an object?
1863
+        // Are we returning an object?
1864 1864
         if ( $object ) {
1865 1865
             return $this->get_item( $this->recurring_item );
1866 1866
         }
@@ -1868,124 +1868,124 @@  discard block
 block discarded – undo
1868 1868
         return $this->recurring_item;
1869 1869
     }
1870 1870
 
1871
-	/**
1872
-	 * Retrieves the subscription name.
1873
-	 *
1874
-	 * @since 1.0.19
1875
-	 * @return string
1876
-	 */
1877
-	public function get_subscription_name() {
1871
+    /**
1872
+     * Retrieves the subscription name.
1873
+     *
1874
+     * @since 1.0.19
1875
+     * @return string
1876
+     */
1877
+    public function get_subscription_name() {
1878 1878
 
1879
-		// Retrieve the recurring name
1879
+        // Retrieve the recurring name
1880 1880
         $item = $this->get_recurring( true );
1881 1881
 
1882
-		// Abort if it does not exist.
1882
+        // Abort if it does not exist.
1883 1883
         if ( empty( $item ) ) {
1884 1884
             return '';
1885 1885
         }
1886 1886
 
1887
-		// Return the item name.
1887
+        // Return the item name.
1888 1888
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1889
-	}
1890
-
1891
-	/**
1892
-	 * Retrieves the view url.
1893
-	 *
1894
-	 * @since 1.0.19
1895
-	 * @return string
1896
-	 */
1897
-	public function get_view_url() {
1889
+    }
1890
+
1891
+    /**
1892
+     * Retrieves the view url.
1893
+     *
1894
+     * @since 1.0.19
1895
+     * @return string
1896
+     */
1897
+    public function get_view_url() {
1898 1898
         $invoice_url = get_permalink( $this->get_id() );
1899
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1899
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1900 1900
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1901
-	}
1901
+    }
1902 1902
 
1903
-	/**
1904
-	 * Retrieves the payment url.
1905
-	 *
1906
-	 * @since 1.0.19
1907
-	 * @return string
1908
-	 */
1909
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1903
+    /**
1904
+     * Retrieves the payment url.
1905
+     *
1906
+     * @since 1.0.19
1907
+     * @return string
1908
+     */
1909
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1910 1910
 
1911
-		// Retrieve the checkout url.
1911
+        // Retrieve the checkout url.
1912 1912
         $pay_url = wpinv_get_checkout_uri();
1913 1913
 
1914
-		// Maybe force ssl.
1914
+        // Maybe force ssl.
1915 1915
         if ( is_ssl() ) {
1916 1916
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1917 1917
         }
1918 1918
 
1919
-		// Add the invoice key.
1920
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1919
+        // Add the invoice key.
1920
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1921 1921
 
1922
-		// (Maybe?) add a secret
1922
+        // (Maybe?) add a secret
1923 1923
         if ( $secret ) {
1924 1924
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1925 1925
         }
1926 1926
 
1927 1927
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1928
-	}
1928
+    }
1929 1929
 
1930
-	/**
1931
-	 * Retrieves the receipt url.
1932
-	 *
1933
-	 * @since 1.0.19
1934
-	 * @return string
1935
-	 */
1936
-	public function get_receipt_url() {
1930
+    /**
1931
+     * Retrieves the receipt url.
1932
+     *
1933
+     * @since 1.0.19
1934
+     * @return string
1935
+     */
1936
+    public function get_receipt_url() {
1937 1937
 
1938
-		// Retrieve the checkout url.
1938
+        // Retrieve the checkout url.
1939 1939
         $receipt_url = wpinv_get_success_page_uri();
1940 1940
 
1941
-		// Maybe force ssl.
1941
+        // Maybe force ssl.
1942 1942
         if ( is_ssl() ) {
1943 1943
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1944 1944
         }
1945 1945
 
1946
-		// Add the invoice key.
1947
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1946
+        // Add the invoice key.
1947
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1948 1948
 
1949 1949
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1950
-	}
1951
-
1952
-	/**
1953
-	 * Retrieves the remote transaction url.
1954
-	 *
1955
-	 * @since 1.6.0
1956
-	 * @return string
1957
-	 */
1958
-	public function get_transaction_url() {
1959
-		return apply_filters( 'getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this );
1960
-	}
1961
-
1962
-	/**
1963
-	 * Retrieves the default status.
1964
-	 *
1965
-	 * @since 1.0.19
1966
-	 * @return string
1967
-	 */
1968
-	public function get_default_status() {
1969
-
1970
-		$type   = $this->get_type();
1971
-		$status = "wpi-$type-pending";
1972
-		return str_replace( '-invoice', '', $status );
1973
-
1974
-	}
1975
-
1976
-    /**
1977
-	 * Magic method for accessing invoice properties.
1978
-	 *
1979
-	 * @since 1.0.15
1980
-	 * @access public
1981
-	 *
1982
-	 * @param string $key Discount data to retrieve
1983
-	 * @param  string $context View or edit context.
1984
-	 * @return mixed Value of the given invoice property (if set).
1985
-	 */
1986
-	public function get( $key, $context = 'view' ) {
1950
+    }
1951
+
1952
+    /**
1953
+     * Retrieves the remote transaction url.
1954
+     *
1955
+     * @since 1.6.0
1956
+     * @return string
1957
+     */
1958
+    public function get_transaction_url() {
1959
+        return apply_filters( 'getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this );
1960
+    }
1961
+
1962
+    /**
1963
+     * Retrieves the default status.
1964
+     *
1965
+     * @since 1.0.19
1966
+     * @return string
1967
+     */
1968
+    public function get_default_status() {
1969
+
1970
+        $type   = $this->get_type();
1971
+        $status = "wpi-$type-pending";
1972
+        return str_replace( '-invoice', '', $status );
1973
+
1974
+    }
1975
+
1976
+    /**
1977
+     * Magic method for accessing invoice properties.
1978
+     *
1979
+     * @since 1.0.15
1980
+     * @access public
1981
+     *
1982
+     * @param string $key Discount data to retrieve
1983
+     * @param  string $context View or edit context.
1984
+     * @return mixed Value of the given invoice property (if set).
1985
+     */
1986
+    public function get( $key, $context = 'view' ) {
1987 1987
         return $this->get_prop( $key, $context );
1988
-	}
1988
+    }
1989 1989
 
1990 1990
     /*
1991 1991
 	|--------------------------------------------------------------------------
@@ -1998,129 +1998,129 @@  discard block
 block discarded – undo
1998 1998
     */
1999 1999
 
2000 2000
     /**
2001
-	 * Magic method for setting invoice properties.
2002
-	 *
2003
-	 * @since 1.0.19
2004
-	 * @access public
2005
-	 *
2006
-	 * @param string $key Discount data to retrieve
2007
-	 * @param  mixed $value new value.
2008
-	 * @return mixed Value of the given invoice property (if set).
2009
-	 */
2010
-	public function set( $key, $value ) {
2001
+     * Magic method for setting invoice properties.
2002
+     *
2003
+     * @since 1.0.19
2004
+     * @access public
2005
+     *
2006
+     * @param string $key Discount data to retrieve
2007
+     * @param  mixed $value new value.
2008
+     * @return mixed Value of the given invoice property (if set).
2009
+     */
2010
+    public function set( $key, $value ) {
2011 2011
 
2012 2012
         $setter = "set_$key";
2013 2013
         if ( is_callable( array( $this, $setter ) ) ) {
2014 2014
             $this->{$setter}( $value );
2015 2015
         }
2016 2016
 
2017
-	}
2017
+    }
2018 2018
 
2019
-	/**
2020
-	 * Sets item status.
2021
-	 *
2022
-	 * @since 1.0.19
2023
-	 * @param string $new_status    New status.
2024
-	 * @param string $note          Optional note to add.
2025
-	 * @param bool   $manual_update Is this a manual status change?.
2026
-	 * @return array details of change.
2027
-	 */
2028
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
2029
-		$old_status = $this->get_status();
2019
+    /**
2020
+     * Sets item status.
2021
+     *
2022
+     * @since 1.0.19
2023
+     * @param string $new_status    New status.
2024
+     * @param string $note          Optional note to add.
2025
+     * @param bool   $manual_update Is this a manual status change?.
2026
+     * @return array details of change.
2027
+     */
2028
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
2029
+        $old_status = $this->get_status();
2030 2030
 
2031
-		$statuses = $this->get_all_statuses();
2031
+        $statuses = $this->get_all_statuses();
2032 2032
 
2033
-		if ( isset( $statuses['draft'] ) ) {
2034
-			unset( $statuses['draft'] );
2035
-		}
2033
+        if ( isset( $statuses['draft'] ) ) {
2034
+            unset( $statuses['draft'] );
2035
+        }
2036 2036
 
2037
-		$this->set_prop( 'status', $new_status );
2037
+        $this->set_prop( 'status', $new_status );
2038 2038
 
2039
-		// If setting the status, ensure it's set to a valid status.
2040
-		if ( true === $this->object_read ) {
2039
+        // If setting the status, ensure it's set to a valid status.
2040
+        if ( true === $this->object_read ) {
2041 2041
 
2042
-			// Only allow valid new status.
2043
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
2044
-				$new_status = $this->get_default_status();
2045
-			}
2042
+            // Only allow valid new status.
2043
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
2044
+                $new_status = $this->get_default_status();
2045
+            }
2046 2046
 
2047
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
2048
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
2049
-				$old_status = $this->get_default_status();
2050
-			}
2047
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
2048
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
2049
+                $old_status = $this->get_default_status();
2050
+            }
2051 2051
 
2052
-			// Paid - Renewal (i.e when duplicating a parent invoice )
2053
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
2054
-				$old_status = 'wpi-pending';
2055
-			}
2052
+            // Paid - Renewal (i.e when duplicating a parent invoice )
2053
+            if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
2054
+                $old_status = 'wpi-pending';
2055
+            }
2056 2056
 
2057
-			if ( $old_status !== $new_status ) {
2058
-				$this->status_transition = array(
2059
-					'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
2060
-					'to'     => $new_status,
2061
-					'note'   => $note,
2062
-					'manual' => (bool) $manual_update,
2063
-				);
2057
+            if ( $old_status !== $new_status ) {
2058
+                $this->status_transition = array(
2059
+                    'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
2060
+                    'to'     => $new_status,
2061
+                    'note'   => $note,
2062
+                    'manual' => (bool) $manual_update,
2063
+                );
2064 2064
 
2065
-				if ( $manual_update ) {
2066
-					do_action( 'getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status );
2067
-				}
2065
+                if ( $manual_update ) {
2066
+                    do_action( 'getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status );
2067
+                }
2068 2068
 
2069
-				$this->maybe_set_date_paid();
2069
+                $this->maybe_set_date_paid();
2070 2070
 
2071
-			}
2071
+            }
2072 2072
 }
2073 2073
 
2074
-		return array(
2075
-			'from' => $old_status,
2076
-			'to'   => $new_status,
2077
-		);
2078
-	}
2079
-
2080
-	/**
2081
-	 * Maybe set date paid.
2082
-	 *
2083
-	 * Sets the date paid variable when transitioning to the payment complete
2084
-	 * order status.
2085
-	 *
2086
-	 * @since 1.0.19
2087
-	 */
2088
-	public function maybe_set_date_paid() {
2089
-
2090
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2091
-			$this->set_date_completed( current_time( 'mysql' ) );
2092
-		}
2093
-	}
2094
-
2095
-    /**
2096
-	 * Set parent invoice ID.
2097
-	 *
2098
-	 * @since 1.0.19
2099
-	 */
2100
-	public function set_parent_id( $value ) {
2101
-		if ( $value && ( $value === $this->get_id() ) ) {
2102
-			return;
2103
-		}
2104
-		$this->set_prop( 'parent_id', absint( $value ) );
2105
-    }
2106
-
2107
-    /**
2108
-	 * Set plugin version when the invoice was created.
2109
-	 *
2110
-	 * @since 1.0.19
2111
-	 */
2112
-	public function set_version( $value ) {
2113
-		$this->set_prop( 'version', $value );
2114
-    }
2115
-
2116
-    /**
2117
-	 * Set date when the invoice was created.
2118
-	 *
2119
-	 * @since 1.0.19
2120
-	 * @param string $value Value to set.
2074
+        return array(
2075
+            'from' => $old_status,
2076
+            'to'   => $new_status,
2077
+        );
2078
+    }
2079
+
2080
+    /**
2081
+     * Maybe set date paid.
2082
+     *
2083
+     * Sets the date paid variable when transitioning to the payment complete
2084
+     * order status.
2085
+     *
2086
+     * @since 1.0.19
2087
+     */
2088
+    public function maybe_set_date_paid() {
2089
+
2090
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2091
+            $this->set_date_completed( current_time( 'mysql' ) );
2092
+        }
2093
+    }
2094
+
2095
+    /**
2096
+     * Set parent invoice ID.
2097
+     *
2098
+     * @since 1.0.19
2099
+     */
2100
+    public function set_parent_id( $value ) {
2101
+        if ( $value && ( $value === $this->get_id() ) ) {
2102
+            return;
2103
+        }
2104
+        $this->set_prop( 'parent_id', absint( $value ) );
2105
+    }
2106
+
2107
+    /**
2108
+     * Set plugin version when the invoice was created.
2109
+     *
2110
+     * @since 1.0.19
2111
+     */
2112
+    public function set_version( $value ) {
2113
+        $this->set_prop( 'version', $value );
2114
+    }
2115
+
2116
+    /**
2117
+     * Set date when the invoice was created.
2118
+     *
2119
+     * @since 1.0.19
2120
+     * @param string $value Value to set.
2121 2121
      * @return bool Whether or not the date was set.
2122
-	 */
2123
-	public function set_date_created( $value ) {
2122
+     */
2123
+    public function set_date_created( $value ) {
2124 2124
         $date = strtotime( $value );
2125 2125
 
2126 2126
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2128,19 +2128,19 @@  discard block
 block discarded – undo
2128 2128
             return true;
2129 2129
         }
2130 2130
 
2131
-		$this->set_prop( 'date_created', '' );
2132
-		return false;
2131
+        $this->set_prop( 'date_created', '' );
2132
+        return false;
2133 2133
 
2134 2134
     }
2135 2135
 
2136 2136
     /**
2137
-	 * Set date invoice due date.
2138
-	 *
2139
-	 * @since 1.0.19
2140
-	 * @param string $value Value to set.
2137
+     * Set date invoice due date.
2138
+     *
2139
+     * @since 1.0.19
2140
+     * @param string $value Value to set.
2141 2141
      * @return bool Whether or not the date was set.
2142
-	 */
2143
-	public function set_due_date( $value ) {
2142
+     */
2143
+    public function set_due_date( $value ) {
2144 2144
         $date = strtotime( $value );
2145 2145
 
2146 2146
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2148,29 +2148,29 @@  discard block
 block discarded – undo
2148 2148
             return true;
2149 2149
         }
2150 2150
 
2151
-		$this->set_prop( 'due_date', '' );
2151
+        $this->set_prop( 'due_date', '' );
2152 2152
         return false;
2153 2153
 
2154 2154
     }
2155 2155
 
2156 2156
     /**
2157
-	 * Alias of self::set_due_date().
2158
-	 *
2159
-	 * @since 1.0.19
2160
-	 * @param  string $value New name.
2161
-	 */
2162
-	public function set_date_due( $value ) {
2163
-		$this->set_due_date( $value );
2157
+     * Alias of self::set_due_date().
2158
+     *
2159
+     * @since 1.0.19
2160
+     * @param  string $value New name.
2161
+     */
2162
+    public function set_date_due( $value ) {
2163
+        $this->set_due_date( $value );
2164 2164
     }
2165 2165
 
2166 2166
     /**
2167
-	 * Set date invoice was completed.
2168
-	 *
2169
-	 * @since 1.0.19
2170
-	 * @param string $value Value to set.
2167
+     * Set date invoice was completed.
2168
+     *
2169
+     * @since 1.0.19
2170
+     * @param string $value Value to set.
2171 2171
      * @return bool Whether or not the date was set.
2172
-	 */
2173
-	public function set_completed_date( $value ) {
2172
+     */
2173
+    public function set_completed_date( $value ) {
2174 2174
         $date = strtotime( $value );
2175 2175
 
2176 2176
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2178,29 +2178,29 @@  discard block
 block discarded – undo
2178 2178
             return true;
2179 2179
         }
2180 2180
 
2181
-		$this->set_prop( 'completed_date', '' );
2181
+        $this->set_prop( 'completed_date', '' );
2182 2182
         return false;
2183 2183
 
2184 2184
     }
2185 2185
 
2186 2186
     /**
2187
-	 * Alias of self::set_completed_date().
2188
-	 *
2189
-	 * @since 1.0.19
2190
-	 * @param  string $value New name.
2191
-	 */
2192
-	public function set_date_completed( $value ) {
2193
-		$this->set_completed_date( $value );
2187
+     * Alias of self::set_completed_date().
2188
+     *
2189
+     * @since 1.0.19
2190
+     * @param  string $value New name.
2191
+     */
2192
+    public function set_date_completed( $value ) {
2193
+        $this->set_completed_date( $value );
2194 2194
     }
2195 2195
 
2196 2196
     /**
2197
-	 * Set date when the invoice was last modified.
2198
-	 *
2199
-	 * @since 1.0.19
2200
-	 * @param string $value Value to set.
2197
+     * Set date when the invoice was last modified.
2198
+     *
2199
+     * @since 1.0.19
2200
+     * @param string $value Value to set.
2201 2201
      * @return bool Whether or not the date was set.
2202
-	 */
2203
-	public function set_date_modified( $value ) {
2202
+     */
2203
+    public function set_date_modified( $value ) {
2204 2204
         $date = strtotime( $value );
2205 2205
 
2206 2206
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2208,813 +2208,813 @@  discard block
 block discarded – undo
2208 2208
             return true;
2209 2209
         }
2210 2210
 
2211
-		$this->set_prop( 'date_modified', '' );
2211
+        $this->set_prop( 'date_modified', '' );
2212 2212
         return false;
2213 2213
 
2214 2214
     }
2215 2215
 
2216 2216
     /**
2217
-	 * Set the invoice number.
2218
-	 *
2219
-	 * @since 1.0.19
2220
-	 * @param  string $value New number.
2221
-	 */
2222
-	public function set_number( $value ) {
2217
+     * Set the invoice number.
2218
+     *
2219
+     * @since 1.0.19
2220
+     * @param  string $value New number.
2221
+     */
2222
+    public function set_number( $value ) {
2223 2223
         $number = sanitize_text_field( $value );
2224
-		$this->set_prop( 'number', $number );
2224
+        $this->set_prop( 'number', $number );
2225 2225
     }
2226 2226
 
2227 2227
     /**
2228
-	 * Set the invoice type.
2229
-	 *
2230
-	 * @since 1.0.19
2231
-	 * @param  string $value Type.
2232
-	 */
2233
-	public function set_type( $value ) {
2228
+     * Set the invoice type.
2229
+     *
2230
+     * @since 1.0.19
2231
+     * @param  string $value Type.
2232
+     */
2233
+    public function set_type( $value ) {
2234 2234
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2235
-		$this->set_prop( 'type', $type );
2236
-	}
2235
+        $this->set_prop( 'type', $type );
2236
+    }
2237 2237
 
2238 2238
     /**
2239
-	 * Set the invoice post type.
2240
-	 *
2241
-	 * @since 1.0.19
2242
-	 * @param  string $value Post type.
2243
-	 */
2244
-	public function set_post_type( $value ) {
2239
+     * Set the invoice post type.
2240
+     *
2241
+     * @since 1.0.19
2242
+     * @param  string $value Post type.
2243
+     */
2244
+    public function set_post_type( $value ) {
2245 2245
         if ( getpaid_is_invoice_post_type( $value ) ) {
2246
-			$this->set_type( $value );
2246
+            $this->set_type( $value );
2247 2247
             $this->set_prop( 'post_type', $value );
2248 2248
         }
2249 2249
     }
2250 2250
 
2251 2251
     /**
2252
-	 * Set the invoice key.
2253
-	 *
2254
-	 * @since 1.0.19
2255
-	 * @param  string $value New key.
2256
-	 */
2257
-	public function set_key( $value ) {
2252
+     * Set the invoice key.
2253
+     *
2254
+     * @since 1.0.19
2255
+     * @param  string $value New key.
2256
+     */
2257
+    public function set_key( $value ) {
2258 2258
         $key = sanitize_text_field( $value );
2259
-		$this->set_prop( 'key', $key );
2259
+        $this->set_prop( 'key', $key );
2260 2260
     }
2261 2261
 
2262 2262
     /**
2263
-	 * Set the invoice mode.
2264
-	 *
2265
-	 * @since 1.0.19
2266
-	 * @param  string $value mode.
2267
-	 */
2268
-	public function set_mode( $value ) {
2263
+     * Set the invoice mode.
2264
+     *
2265
+     * @since 1.0.19
2266
+     * @param  string $value mode.
2267
+     */
2268
+    public function set_mode( $value ) {
2269 2269
         if ( in_array( $value, array( 'live', 'test' ) ) ) {
2270 2270
             $this->set_prop( 'mode', $value );
2271 2271
         }
2272 2272
     }
2273 2273
 
2274 2274
     /**
2275
-	 * Set the invoice path.
2276
-	 *
2277
-	 * @since 1.0.19
2278
-	 * @param  string $value path.
2279
-	 */
2280
-	public function set_path( $value ) {
2275
+     * Set the invoice path.
2276
+     *
2277
+     * @since 1.0.19
2278
+     * @param  string $value path.
2279
+     */
2280
+    public function set_path( $value ) {
2281 2281
         $this->set_prop( 'path', $value );
2282 2282
     }
2283 2283
 
2284 2284
     /**
2285
-	 * Set the invoice name.
2286
-	 *
2287
-	 * @since 1.0.19
2288
-	 * @param  string $value New name.
2289
-	 */
2290
-	public function set_name( $value ) {
2285
+     * Set the invoice name.
2286
+     *
2287
+     * @since 1.0.19
2288
+     * @param  string $value New name.
2289
+     */
2290
+    public function set_name( $value ) {
2291 2291
         $name = sanitize_text_field( $value );
2292
-		$this->set_prop( 'name', $name );
2292
+        $this->set_prop( 'name', $name );
2293 2293
     }
2294 2294
 
2295 2295
     /**
2296
-	 * Alias of self::set_name().
2297
-	 *
2298
-	 * @since 1.0.19
2299
-	 * @param  string $value New name.
2300
-	 */
2301
-	public function set_title( $value ) {
2302
-		$this->set_name( $value );
2296
+     * Alias of self::set_name().
2297
+     *
2298
+     * @since 1.0.19
2299
+     * @param  string $value New name.
2300
+     */
2301
+    public function set_title( $value ) {
2302
+        $this->set_name( $value );
2303 2303
     }
2304 2304
 
2305 2305
     /**
2306
-	 * Set the invoice description.
2307
-	 *
2308
-	 * @since 1.0.19
2309
-	 * @param  string $value New description.
2310
-	 */
2311
-	public function set_description( $value ) {
2306
+     * Set the invoice description.
2307
+     *
2308
+     * @since 1.0.19
2309
+     * @param  string $value New description.
2310
+     */
2311
+    public function set_description( $value ) {
2312 2312
         $description = wp_kses_post( $value );
2313
-		$this->set_prop( 'description', $description );
2313
+        $this->set_prop( 'description', $description );
2314
+    }
2315
+
2316
+    /**
2317
+     * Alias of self::set_description().
2318
+     *
2319
+     * @since 1.0.19
2320
+     * @param  string $value New description.
2321
+     */
2322
+    public function set_excerpt( $value ) {
2323
+        $this->set_description( $value );
2324
+    }
2325
+
2326
+    /**
2327
+     * Alias of self::set_description().
2328
+     *
2329
+     * @since 1.0.19
2330
+     * @param  string $value New description.
2331
+     */
2332
+    public function set_summary( $value ) {
2333
+        $this->set_description( $value );
2334
+    }
2335
+
2336
+    /**
2337
+     * Set the receiver of the invoice.
2338
+     *
2339
+     * @since 1.0.19
2340
+     * @param  int $value New author.
2341
+     */
2342
+    public function set_author( $value ) {
2343
+        $user = get_user_by( 'id', (int) $value );
2344
+
2345
+        if ( $user && $user->ID ) {
2346
+            $this->set_prop( 'author', $user->ID );
2347
+            $this->set_prop( 'email', $user->user_email );
2348
+        }
2349
+
2350
+    }
2351
+
2352
+    /**
2353
+     * Alias of self::set_author().
2354
+     *
2355
+     * @since 1.0.19
2356
+     * @param  int $value New user id.
2357
+     */
2358
+    public function set_user_id( $value ) {
2359
+        $this->set_author( $value );
2360
+    }
2361
+
2362
+    /**
2363
+     * Alias of self::set_author().
2364
+     *
2365
+     * @since 1.0.19
2366
+     * @param  int $value New user id.
2367
+     */
2368
+    public function set_customer_id( $value ) {
2369
+        $this->set_author( $value );
2370
+    }
2371
+
2372
+    /**
2373
+     * Set the customer's ip.
2374
+     *
2375
+     * @since 1.0.19
2376
+     * @param  string $value ip address.
2377
+     */
2378
+    public function set_ip( $value ) {
2379
+        $this->set_prop( 'ip', $value );
2380
+    }
2381
+
2382
+    /**
2383
+     * Alias of self::set_ip().
2384
+     *
2385
+     * @since 1.0.19
2386
+     * @param  string $value ip address.
2387
+     */
2388
+    public function set_user_ip( $value ) {
2389
+        $this->set_ip( $value );
2390
+    }
2391
+
2392
+    /**
2393
+     * Set the customer's first name.
2394
+     *
2395
+     * @since 1.0.19
2396
+     * @param  string $value first name.
2397
+     */
2398
+    public function set_first_name( $value ) {
2399
+        $this->set_prop( 'first_name', $value );
2400
+    }
2401
+
2402
+    /**
2403
+     * Alias of self::set_first_name().
2404
+     *
2405
+     * @since 1.0.19
2406
+     * @param  string $value first name.
2407
+     */
2408
+    public function set_user_first_name( $value ) {
2409
+        $this->set_first_name( $value );
2314 2410
     }
2315 2411
 
2316 2412
     /**
2317
-	 * Alias of self::set_description().
2318
-	 *
2319
-	 * @since 1.0.19
2320
-	 * @param  string $value New description.
2321
-	 */
2322
-	public function set_excerpt( $value ) {
2323
-		$this->set_description( $value );
2413
+     * Alias of self::set_first_name().
2414
+     *
2415
+     * @since 1.0.19
2416
+     * @param  string $value first name.
2417
+     */
2418
+    public function set_customer_first_name( $value ) {
2419
+        $this->set_first_name( $value );
2420
+    }
2421
+
2422
+    /**
2423
+     * Set the customer's last name.
2424
+     *
2425
+     * @since 1.0.19
2426
+     * @param  string $value last name.
2427
+     */
2428
+    public function set_last_name( $value ) {
2429
+        $this->set_prop( 'last_name', $value );
2430
+    }
2431
+
2432
+    /**
2433
+     * Alias of self::set_last_name().
2434
+     *
2435
+     * @since 1.0.19
2436
+     * @param  string $value last name.
2437
+     */
2438
+    public function set_user_last_name( $value ) {
2439
+        $this->set_last_name( $value );
2440
+    }
2441
+
2442
+    /**
2443
+     * Alias of self::set_last_name().
2444
+     *
2445
+     * @since 1.0.19
2446
+     * @param  string $value last name.
2447
+     */
2448
+    public function set_customer_last_name( $value ) {
2449
+        $this->set_last_name( $value );
2450
+    }
2451
+
2452
+    /**
2453
+     * Set the customer's phone number.
2454
+     *
2455
+     * @since 1.0.19
2456
+     * @param  string $value phone.
2457
+     */
2458
+    public function set_phone( $value ) {
2459
+        $this->set_prop( 'phone', $value );
2324 2460
     }
2325 2461
 
2326 2462
     /**
2327
-	 * Alias of self::set_description().
2328
-	 *
2329
-	 * @since 1.0.19
2330
-	 * @param  string $value New description.
2331
-	 */
2332
-	public function set_summary( $value ) {
2333
-		$this->set_description( $value );
2463
+     * Alias of self::set_phone().
2464
+     *
2465
+     * @since 1.0.19
2466
+     * @param  string $value phone.
2467
+     */
2468
+    public function set_user_phone( $value ) {
2469
+        $this->set_phone( $value );
2334 2470
     }
2335 2471
 
2336 2472
     /**
2337
-	 * Set the receiver of the invoice.
2338
-	 *
2339
-	 * @since 1.0.19
2340
-	 * @param  int $value New author.
2341
-	 */
2342
-	public function set_author( $value ) {
2343
-		$user = get_user_by( 'id', (int) $value );
2473
+     * Alias of self::set_phone().
2474
+     *
2475
+     * @since 1.0.19
2476
+     * @param  string $value phone.
2477
+     */
2478
+    public function set_customer_phone( $value ) {
2479
+        $this->set_phone( $value );
2480
+    }
2344 2481
 
2345
-		if ( $user && $user->ID ) {
2346
-			$this->set_prop( 'author', $user->ID );
2347
-			$this->set_prop( 'email', $user->user_email );
2348
-		}
2482
+    /**
2483
+     * Alias of self::set_phone().
2484
+     *
2485
+     * @since 1.0.19
2486
+     * @param  string $value phone.
2487
+     */
2488
+    public function set_phone_number( $value ) {
2489
+        $this->set_phone( $value );
2490
+    }
2349 2491
 
2492
+    /**
2493
+     * Set the customer's email address.
2494
+     *
2495
+     * @since 1.0.19
2496
+     * @param  string $value email address.
2497
+     */
2498
+    public function set_email( $value ) {
2499
+        $this->set_prop( 'email', $value );
2350 2500
     }
2351 2501
 
2352 2502
     /**
2353
-	 * Alias of self::set_author().
2354
-	 *
2355
-	 * @since 1.0.19
2356
-	 * @param  int $value New user id.
2357
-	 */
2358
-	public function set_user_id( $value ) {
2359
-		$this->set_author( $value );
2503
+     * Alias of self::set_email().
2504
+     *
2505
+     * @since 1.0.19
2506
+     * @param  string $value email address.
2507
+     */
2508
+    public function set_user_email( $value ) {
2509
+        $this->set_email( $value );
2360 2510
     }
2361 2511
 
2362 2512
     /**
2363
-	 * Alias of self::set_author().
2364
-	 *
2365
-	 * @since 1.0.19
2366
-	 * @param  int $value New user id.
2367
-	 */
2368
-	public function set_customer_id( $value ) {
2369
-		$this->set_author( $value );
2513
+     * Alias of self::set_email().
2514
+     *
2515
+     * @since 1.0.19
2516
+     * @param  string $value email address.
2517
+     */
2518
+    public function set_email_address( $value ) {
2519
+        $this->set_email( $value );
2370 2520
     }
2371 2521
 
2372 2522
     /**
2373
-	 * Set the customer's ip.
2374
-	 *
2375
-	 * @since 1.0.19
2376
-	 * @param  string $value ip address.
2377
-	 */
2378
-	public function set_ip( $value ) {
2379
-		$this->set_prop( 'ip', $value );
2523
+     * Alias of self::set_email().
2524
+     *
2525
+     * @since 1.0.19
2526
+     * @param  string $value email address.
2527
+     */
2528
+    public function set_customer_email( $value ) {
2529
+        $this->set_email( $value );
2380 2530
     }
2381 2531
 
2382 2532
     /**
2383
-	 * Alias of self::set_ip().
2384
-	 *
2385
-	 * @since 1.0.19
2386
-	 * @param  string $value ip address.
2387
-	 */
2388
-	public function set_user_ip( $value ) {
2389
-		$this->set_ip( $value );
2533
+     * Set the customer's country.
2534
+     *
2535
+     * @since 1.0.19
2536
+     * @param  string $value country.
2537
+     */
2538
+    public function set_country( $value ) {
2539
+        $this->set_prop( 'country', $value );
2390 2540
     }
2391 2541
 
2392 2542
     /**
2393
-	 * Set the customer's first name.
2394
-	 *
2395
-	 * @since 1.0.19
2396
-	 * @param  string $value first name.
2397
-	 */
2398
-	public function set_first_name( $value ) {
2399
-		$this->set_prop( 'first_name', $value );
2543
+     * Alias of self::set_country().
2544
+     *
2545
+     * @since 1.0.19
2546
+     * @param  string $value country.
2547
+     */
2548
+    public function set_user_country( $value ) {
2549
+        $this->set_country( $value );
2400 2550
     }
2401 2551
 
2402 2552
     /**
2403
-	 * Alias of self::set_first_name().
2404
-	 *
2405
-	 * @since 1.0.19
2406
-	 * @param  string $value first name.
2407
-	 */
2408
-	public function set_user_first_name( $value ) {
2409
-		$this->set_first_name( $value );
2553
+     * Alias of self::set_country().
2554
+     *
2555
+     * @since 1.0.19
2556
+     * @param  string $value country.
2557
+     */
2558
+    public function set_customer_country( $value ) {
2559
+        $this->set_country( $value );
2410 2560
     }
2411 2561
 
2412 2562
     /**
2413
-	 * Alias of self::set_first_name().
2414
-	 *
2415
-	 * @since 1.0.19
2416
-	 * @param  string $value first name.
2417
-	 */
2418
-	public function set_customer_first_name( $value ) {
2419
-		$this->set_first_name( $value );
2563
+     * Set the customer's state.
2564
+     *
2565
+     * @since 1.0.19
2566
+     * @param  string $value state.
2567
+     */
2568
+    public function set_state( $value ) {
2569
+        $this->set_prop( 'state', $value );
2420 2570
     }
2421 2571
 
2422 2572
     /**
2423
-	 * Set the customer's last name.
2424
-	 *
2425
-	 * @since 1.0.19
2426
-	 * @param  string $value last name.
2427
-	 */
2428
-	public function set_last_name( $value ) {
2429
-		$this->set_prop( 'last_name', $value );
2573
+     * Alias of self::set_state().
2574
+     *
2575
+     * @since 1.0.19
2576
+     * @param  string $value state.
2577
+     */
2578
+    public function set_user_state( $value ) {
2579
+        $this->set_state( $value );
2430 2580
     }
2431 2581
 
2432 2582
     /**
2433
-	 * Alias of self::set_last_name().
2434
-	 *
2435
-	 * @since 1.0.19
2436
-	 * @param  string $value last name.
2437
-	 */
2438
-	public function set_user_last_name( $value ) {
2439
-		$this->set_last_name( $value );
2583
+     * Alias of self::set_state().
2584
+     *
2585
+     * @since 1.0.19
2586
+     * @param  string $value state.
2587
+     */
2588
+    public function set_customer_state( $value ) {
2589
+        $this->set_state( $value );
2440 2590
     }
2441 2591
 
2442 2592
     /**
2443
-	 * Alias of self::set_last_name().
2444
-	 *
2445
-	 * @since 1.0.19
2446
-	 * @param  string $value last name.
2447
-	 */
2448
-	public function set_customer_last_name( $value ) {
2449
-		$this->set_last_name( $value );
2593
+     * Set the customer's city.
2594
+     *
2595
+     * @since 1.0.19
2596
+     * @param  string $value city.
2597
+     */
2598
+    public function set_city( $value ) {
2599
+        $this->set_prop( 'city', $value );
2450 2600
     }
2451 2601
 
2452 2602
     /**
2453
-	 * Set the customer's phone number.
2454
-	 *
2455
-	 * @since 1.0.19
2456
-	 * @param  string $value phone.
2457
-	 */
2458
-	public function set_phone( $value ) {
2459
-		$this->set_prop( 'phone', $value );
2603
+     * Alias of self::set_city().
2604
+     *
2605
+     * @since 1.0.19
2606
+     * @param  string $value city.
2607
+     */
2608
+    public function set_user_city( $value ) {
2609
+        $this->set_city( $value );
2460 2610
     }
2461 2611
 
2462 2612
     /**
2463
-	 * Alias of self::set_phone().
2464
-	 *
2465
-	 * @since 1.0.19
2466
-	 * @param  string $value phone.
2467
-	 */
2468
-	public function set_user_phone( $value ) {
2469
-		$this->set_phone( $value );
2613
+     * Alias of self::set_city().
2614
+     *
2615
+     * @since 1.0.19
2616
+     * @param  string $value city.
2617
+     */
2618
+    public function set_customer_city( $value ) {
2619
+        $this->set_city( $value );
2470 2620
     }
2471 2621
 
2472 2622
     /**
2473
-	 * Alias of self::set_phone().
2474
-	 *
2475
-	 * @since 1.0.19
2476
-	 * @param  string $value phone.
2477
-	 */
2478
-	public function set_customer_phone( $value ) {
2479
-		$this->set_phone( $value );
2623
+     * Set the customer's zip code.
2624
+     *
2625
+     * @since 1.0.19
2626
+     * @param  string $value zip.
2627
+     */
2628
+    public function set_zip( $value ) {
2629
+        $this->set_prop( 'zip', $value );
2480 2630
     }
2481 2631
 
2482 2632
     /**
2483
-	 * Alias of self::set_phone().
2484
-	 *
2485
-	 * @since 1.0.19
2486
-	 * @param  string $value phone.
2487
-	 */
2488
-	public function set_phone_number( $value ) {
2489
-		$this->set_phone( $value );
2633
+     * Alias of self::set_zip().
2634
+     *
2635
+     * @since 1.0.19
2636
+     * @param  string $value zip.
2637
+     */
2638
+    public function set_user_zip( $value ) {
2639
+        $this->set_zip( $value );
2490 2640
     }
2491 2641
 
2492 2642
     /**
2493
-	 * Set the customer's email address.
2494
-	 *
2495
-	 * @since 1.0.19
2496
-	 * @param  string $value email address.
2497
-	 */
2498
-	public function set_email( $value ) {
2499
-		$this->set_prop( 'email', $value );
2643
+     * Alias of self::set_zip().
2644
+     *
2645
+     * @since 1.0.19
2646
+     * @param  string $value zip.
2647
+     */
2648
+    public function set_customer_zip( $value ) {
2649
+        $this->set_zip( $value );
2500 2650
     }
2501 2651
 
2502 2652
     /**
2503
-	 * Alias of self::set_email().
2504
-	 *
2505
-	 * @since 1.0.19
2506
-	 * @param  string $value email address.
2507
-	 */
2508
-	public function set_user_email( $value ) {
2509
-		$this->set_email( $value );
2653
+     * Set the customer's company.
2654
+     *
2655
+     * @since 1.0.19
2656
+     * @param  string $value company.
2657
+     */
2658
+    public function set_company( $value ) {
2659
+        $this->set_prop( 'company', $value );
2510 2660
     }
2511 2661
 
2512 2662
     /**
2513
-	 * Alias of self::set_email().
2514
-	 *
2515
-	 * @since 1.0.19
2516
-	 * @param  string $value email address.
2517
-	 */
2518
-	public function set_email_address( $value ) {
2519
-		$this->set_email( $value );
2663
+     * Alias of self::set_company().
2664
+     *
2665
+     * @since 1.0.19
2666
+     * @param  string $value company.
2667
+     */
2668
+    public function set_user_company( $value ) {
2669
+        $this->set_company( $value );
2520 2670
     }
2521 2671
 
2522 2672
     /**
2523
-	 * Alias of self::set_email().
2524
-	 *
2525
-	 * @since 1.0.19
2526
-	 * @param  string $value email address.
2527
-	 */
2528
-	public function set_customer_email( $value ) {
2529
-		$this->set_email( $value );
2673
+     * Alias of self::set_company().
2674
+     *
2675
+     * @since 1.0.19
2676
+     * @param  string $value company.
2677
+     */
2678
+    public function set_customer_company( $value ) {
2679
+        $this->set_company( $value );
2530 2680
     }
2531 2681
 
2532 2682
     /**
2533
-	 * Set the customer's country.
2534
-	 *
2535
-	 * @since 1.0.19
2536
-	 * @param  string $value country.
2537
-	 */
2538
-	public function set_country( $value ) {
2539
-		$this->set_prop( 'country', $value );
2683
+     * Set the customer's company id.
2684
+     *
2685
+     * @since 1.0.19
2686
+     * @param  string $value company id.
2687
+     */
2688
+    public function set_company_id( $value ) {
2689
+        $this->set_prop( 'company_id', $value );
2540 2690
     }
2541 2691
 
2542 2692
     /**
2543
-	 * Alias of self::set_country().
2544
-	 *
2545
-	 * @since 1.0.19
2546
-	 * @param  string $value country.
2547
-	 */
2548
-	public function set_user_country( $value ) {
2549
-		$this->set_country( $value );
2693
+     * Set the customer's var number.
2694
+     *
2695
+     * @since 1.0.19
2696
+     * @param  string $value var number.
2697
+     */
2698
+    public function set_vat_number( $value ) {
2699
+        $this->set_prop( 'vat_number', $value );
2550 2700
     }
2551 2701
 
2552 2702
     /**
2553
-	 * Alias of self::set_country().
2554
-	 *
2555
-	 * @since 1.0.19
2556
-	 * @param  string $value country.
2557
-	 */
2558
-	public function set_customer_country( $value ) {
2559
-		$this->set_country( $value );
2703
+     * Alias of self::set_vat_number().
2704
+     *
2705
+     * @since 1.0.19
2706
+     * @param  string $value var number.
2707
+     */
2708
+    public function set_user_vat_number( $value ) {
2709
+        $this->set_vat_number( $value );
2560 2710
     }
2561 2711
 
2562 2712
     /**
2563
-	 * Set the customer's state.
2564
-	 *
2565
-	 * @since 1.0.19
2566
-	 * @param  string $value state.
2567
-	 */
2568
-	public function set_state( $value ) {
2569
-		$this->set_prop( 'state', $value );
2713
+     * Alias of self::set_vat_number().
2714
+     *
2715
+     * @since 1.0.19
2716
+     * @param  string $value var number.
2717
+     */
2718
+    public function set_customer_vat_number( $value ) {
2719
+        $this->set_vat_number( $value );
2570 2720
     }
2571 2721
 
2572 2722
     /**
2573
-	 * Alias of self::set_state().
2574
-	 *
2575
-	 * @since 1.0.19
2576
-	 * @param  string $value state.
2577
-	 */
2578
-	public function set_user_state( $value ) {
2579
-		$this->set_state( $value );
2723
+     * Set the customer's vat rate.
2724
+     *
2725
+     * @since 1.0.19
2726
+     * @param  string $value var rate.
2727
+     */
2728
+    public function set_vat_rate( $value ) {
2729
+        $this->set_prop( 'vat_rate', $value );
2580 2730
     }
2581 2731
 
2582 2732
     /**
2583
-	 * Alias of self::set_state().
2584
-	 *
2585
-	 * @since 1.0.19
2586
-	 * @param  string $value state.
2587
-	 */
2588
-	public function set_customer_state( $value ) {
2589
-		$this->set_state( $value );
2733
+     * Alias of self::set_vat_rate().
2734
+     *
2735
+     * @since 1.0.19
2736
+     * @param  string $value var number.
2737
+     */
2738
+    public function set_user_vat_rate( $value ) {
2739
+        $this->set_vat_rate( $value );
2590 2740
     }
2591 2741
 
2592 2742
     /**
2593
-	 * Set the customer's city.
2594
-	 *
2595
-	 * @since 1.0.19
2596
-	 * @param  string $value city.
2597
-	 */
2598
-	public function set_city( $value ) {
2599
-		$this->set_prop( 'city', $value );
2743
+     * Alias of self::set_vat_rate().
2744
+     *
2745
+     * @since 1.0.19
2746
+     * @param  string $value var number.
2747
+     */
2748
+    public function set_customer_vat_rate( $value ) {
2749
+        $this->set_vat_rate( $value );
2600 2750
     }
2601 2751
 
2602 2752
     /**
2603
-	 * Alias of self::set_city().
2604
-	 *
2605
-	 * @since 1.0.19
2606
-	 * @param  string $value city.
2607
-	 */
2608
-	public function set_user_city( $value ) {
2609
-		$this->set_city( $value );
2753
+     * Set the customer's address.
2754
+     *
2755
+     * @since 1.0.19
2756
+     * @param  string $value address.
2757
+     */
2758
+    public function set_address( $value ) {
2759
+        $this->set_prop( 'address', $value );
2610 2760
     }
2611 2761
 
2612 2762
     /**
2613
-	 * Alias of self::set_city().
2614
-	 *
2615
-	 * @since 1.0.19
2616
-	 * @param  string $value city.
2617
-	 */
2618
-	public function set_customer_city( $value ) {
2619
-		$this->set_city( $value );
2763
+     * Alias of self::set_address().
2764
+     *
2765
+     * @since 1.0.19
2766
+     * @param  string $value address.
2767
+     */
2768
+    public function set_user_address( $value ) {
2769
+        $this->set_address( $value );
2620 2770
     }
2621 2771
 
2622 2772
     /**
2623
-	 * Set the customer's zip code.
2624
-	 *
2625
-	 * @since 1.0.19
2626
-	 * @param  string $value zip.
2627
-	 */
2628
-	public function set_zip( $value ) {
2629
-		$this->set_prop( 'zip', $value );
2773
+     * Alias of self::set_address().
2774
+     *
2775
+     * @since 1.0.19
2776
+     * @param  string $value address.
2777
+     */
2778
+    public function set_customer_address( $value ) {
2779
+        $this->set_address( $value );
2630 2780
     }
2631 2781
 
2632 2782
     /**
2633
-	 * Alias of self::set_zip().
2634
-	 *
2635
-	 * @since 1.0.19
2636
-	 * @param  string $value zip.
2637
-	 */
2638
-	public function set_user_zip( $value ) {
2639
-		$this->set_zip( $value );
2783
+     * Set whether the customer has viewed the invoice or not.
2784
+     *
2785
+     * @since 1.0.19
2786
+     * @param  int|bool $value confirmed.
2787
+     */
2788
+    public function set_is_viewed( $value ) {
2789
+        $this->set_prop( 'is_viewed', $value );
2640 2790
     }
2641 2791
 
2642 2792
     /**
2643
-	 * Alias of self::set_zip().
2644
-	 *
2645
-	 * @since 1.0.19
2646
-	 * @param  string $value zip.
2647
-	 */
2648
-	public function set_customer_zip( $value ) {
2649
-		$this->set_zip( $value );
2793
+     * Set extra email recipients.
2794
+     *
2795
+     * @since 1.0.19
2796
+     * @param  string $value email recipients.
2797
+     */
2798
+    public function set_email_cc( $value ) {
2799
+        $this->set_prop( 'email_cc', $value );
2650 2800
     }
2651 2801
 
2652 2802
     /**
2653
-	 * Set the customer's company.
2654
-	 *
2655
-	 * @since 1.0.19
2656
-	 * @param  string $value company.
2657
-	 */
2658
-	public function set_company( $value ) {
2659
-		$this->set_prop( 'company', $value );
2803
+     * Set the invoice template.
2804
+     *
2805
+     * @since 1.0.19
2806
+     * @param  string $value template.
2807
+     */
2808
+    public function set_template( $value ) {
2809
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2810
+            $this->set_prop( 'template', $value );
2811
+        }
2660 2812
     }
2661 2813
 
2662 2814
     /**
2663
-	 * Alias of self::set_company().
2664
-	 *
2665
-	 * @since 1.0.19
2666
-	 * @param  string $value company.
2667
-	 */
2668
-	public function set_user_company( $value ) {
2669
-		$this->set_company( $value );
2815
+     * Set the invoice source.
2816
+     *
2817
+     * @since 1.0.19
2818
+     * @param  string $value source.
2819
+     * @deprecated
2820
+     */
2821
+    public function created_via( $value ) {
2822
+        $this->set_created_via( sanitize_text_field( $value ) );
2670 2823
     }
2671 2824
 
2672 2825
     /**
2673
-	 * Alias of self::set_company().
2674
-	 *
2675
-	 * @since 1.0.19
2676
-	 * @param  string $value company.
2677
-	 */
2678
-	public function set_customer_company( $value ) {
2679
-		$this->set_company( $value );
2826
+     * Set the invoice source.
2827
+     *
2828
+     * @since 1.0.19
2829
+     * @param  string $value source.
2830
+     */
2831
+    public function set_created_via( $value ) {
2832
+        $this->set_prop( 'created_via', sanitize_text_field( $value ) );
2680 2833
     }
2681 2834
 
2682
-	/**
2683
-	 * Set the customer's company id.
2684
-	 *
2685
-	 * @since 1.0.19
2686
-	 * @param  string $value company id.
2687
-	 */
2688
-	public function set_company_id( $value ) {
2689
-		$this->set_prop( 'company_id', $value );
2835
+    /**
2836
+     * Set the customer's address confirmed status.
2837
+     *
2838
+     * @since 1.0.19
2839
+     * @param  int|bool $value confirmed.
2840
+     */
2841
+    public function set_address_confirmed( $value ) {
2842
+        $this->set_prop( 'address_confirmed', $value );
2690 2843
     }
2691 2844
 
2692 2845
     /**
2693
-	 * Set the customer's var number.
2694
-	 *
2695
-	 * @since 1.0.19
2696
-	 * @param  string $value var number.
2697
-	 */
2698
-	public function set_vat_number( $value ) {
2699
-		$this->set_prop( 'vat_number', $value );
2846
+     * Alias of self::set_address_confirmed().
2847
+     *
2848
+     * @since 1.0.19
2849
+     * @param  int|bool $value confirmed.
2850
+     */
2851
+    public function set_user_address_confirmed( $value ) {
2852
+        $this->set_address_confirmed( $value );
2700 2853
     }
2701 2854
 
2702 2855
     /**
2703
-	 * Alias of self::set_vat_number().
2704
-	 *
2705
-	 * @since 1.0.19
2706
-	 * @param  string $value var number.
2707
-	 */
2708
-	public function set_user_vat_number( $value ) {
2709
-		$this->set_vat_number( $value );
2856
+     * Alias of self::set_address_confirmed().
2857
+     *
2858
+     * @since 1.0.19
2859
+     * @param  int|bool $value confirmed.
2860
+     */
2861
+    public function set_customer_address_confirmed( $value ) {
2862
+        $this->set_address_confirmed( $value );
2710 2863
     }
2711 2864
 
2712 2865
     /**
2713
-	 * Alias of self::set_vat_number().
2714
-	 *
2715
-	 * @since 1.0.19
2716
-	 * @param  string $value var number.
2717
-	 */
2718
-	public function set_customer_vat_number( $value ) {
2719
-		$this->set_vat_number( $value );
2866
+     * Set the shipping fee
2867
+     *
2868
+     * @since 1.0.19
2869
+     * @param  float $value shipping amount.
2870
+     */
2871
+    public function set_shipping( $value ) {
2872
+
2873
+        if ( ! is_numeric( $value ) ) {
2874
+            return $this->set_prop( 'shipping', null );
2875
+        }
2876
+
2877
+        $this->set_prop( 'shipping', max( 0, floatval( $value ) ) );
2720 2878
     }
2721 2879
 
2722 2880
     /**
2723
-	 * Set the customer's vat rate.
2724
-	 *
2725
-	 * @since 1.0.19
2726
-	 * @param  string $value var rate.
2727
-	 */
2728
-	public function set_vat_rate( $value ) {
2729
-		$this->set_prop( 'vat_rate', $value );
2881
+     * Set the invoice sub total.
2882
+     *
2883
+     * @since 1.0.19
2884
+     * @param  float $value sub total.
2885
+     */
2886
+    public function set_subtotal( $value ) {
2887
+        $this->set_prop( 'subtotal', max( 0, $value ) );
2730 2888
     }
2731 2889
 
2732
-    /**
2733
-	 * Alias of self::set_vat_rate().
2734
-	 *
2735
-	 * @since 1.0.19
2736
-	 * @param  string $value var number.
2737
-	 */
2738
-	public function set_user_vat_rate( $value ) {
2739
-		$this->set_vat_rate( $value );
2740
-    }
2741
-
2742
-    /**
2743
-	 * Alias of self::set_vat_rate().
2744
-	 *
2745
-	 * @since 1.0.19
2746
-	 * @param  string $value var number.
2747
-	 */
2748
-	public function set_customer_vat_rate( $value ) {
2749
-		$this->set_vat_rate( $value );
2750
-    }
2751
-
2752
-    /**
2753
-	 * Set the customer's address.
2754
-	 *
2755
-	 * @since 1.0.19
2756
-	 * @param  string $value address.
2757
-	 */
2758
-	public function set_address( $value ) {
2759
-		$this->set_prop( 'address', $value );
2760
-    }
2761
-
2762
-    /**
2763
-	 * Alias of self::set_address().
2764
-	 *
2765
-	 * @since 1.0.19
2766
-	 * @param  string $value address.
2767
-	 */
2768
-	public function set_user_address( $value ) {
2769
-		$this->set_address( $value );
2770
-    }
2771
-
2772
-    /**
2773
-	 * Alias of self::set_address().
2774
-	 *
2775
-	 * @since 1.0.19
2776
-	 * @param  string $value address.
2777
-	 */
2778
-	public function set_customer_address( $value ) {
2779
-		$this->set_address( $value );
2780
-    }
2781
-
2782
-    /**
2783
-	 * Set whether the customer has viewed the invoice or not.
2784
-	 *
2785
-	 * @since 1.0.19
2786
-	 * @param  int|bool $value confirmed.
2787
-	 */
2788
-	public function set_is_viewed( $value ) {
2789
-		$this->set_prop( 'is_viewed', $value );
2790
-	}
2791
-
2792
-	/**
2793
-	 * Set extra email recipients.
2794
-	 *
2795
-	 * @since 1.0.19
2796
-	 * @param  string $value email recipients.
2797
-	 */
2798
-	public function set_email_cc( $value ) {
2799
-		$this->set_prop( 'email_cc', $value );
2800
-	}
2801
-
2802
-	/**
2803
-	 * Set the invoice template.
2804
-	 *
2805
-	 * @since 1.0.19
2806
-	 * @param  string $value template.
2807
-	 */
2808
-	public function set_template( $value ) {
2809
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2810
-			$this->set_prop( 'template', $value );
2811
-		}
2812
-	}
2813
-
2814
-	/**
2815
-	 * Set the invoice source.
2816
-	 *
2817
-	 * @since 1.0.19
2818
-	 * @param  string $value source.
2819
-	 * @deprecated
2820
-	 */
2821
-	public function created_via( $value ) {
2822
-		$this->set_created_via( sanitize_text_field( $value ) );
2823
-	}
2824
-
2825
-	/**
2826
-	 * Set the invoice source.
2827
-	 *
2828
-	 * @since 1.0.19
2829
-	 * @param  string $value source.
2830
-	 */
2831
-	public function set_created_via( $value ) {
2832
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2833
-	}
2834
-
2835
-	/**
2836
-	 * Set the customer's address confirmed status.
2837
-	 *
2838
-	 * @since 1.0.19
2839
-	 * @param  int|bool $value confirmed.
2840
-	 */
2841
-	public function set_address_confirmed( $value ) {
2842
-		$this->set_prop( 'address_confirmed', $value );
2843
-    }
2844
-
2845
-    /**
2846
-	 * Alias of self::set_address_confirmed().
2847
-	 *
2848
-	 * @since 1.0.19
2849
-	 * @param  int|bool $value confirmed.
2850
-	 */
2851
-	public function set_user_address_confirmed( $value ) {
2852
-		$this->set_address_confirmed( $value );
2853
-    }
2854
-
2855
-    /**
2856
-	 * Alias of self::set_address_confirmed().
2857
-	 *
2858
-	 * @since 1.0.19
2859
-	 * @param  int|bool $value confirmed.
2860
-	 */
2861
-	public function set_customer_address_confirmed( $value ) {
2862
-		$this->set_address_confirmed( $value );
2863
-    }
2864
-
2865
-    /**
2866
-	 * Set the shipping fee
2867
-	 *
2868
-	 * @since 1.0.19
2869
-	 * @param  float $value shipping amount.
2870
-	 */
2871
-	public function set_shipping( $value ) {
2872
-
2873
-		if ( ! is_numeric( $value ) ) {
2874
-			return $this->set_prop( 'shipping', null );
2875
-		}
2876
-
2877
-		$this->set_prop( 'shipping', max( 0, floatval( $value ) ) );
2878
-	}
2879
-
2880
-	/**
2881
-	 * Set the invoice sub total.
2882
-	 *
2883
-	 * @since 1.0.19
2884
-	 * @param  float $value sub total.
2885
-	 */
2886
-	public function set_subtotal( $value ) {
2887
-		$this->set_prop( 'subtotal', max( 0, $value ) );
2888
-	}
2889
-
2890
-	/**
2891
-	 * Set the invoice total.
2892
-	 *
2893
-	 * @since 1.0.19
2894
-	 * @param  float $value sub total.
2895
-	 */
2896
-	public function set_total( $value ) {
2897
-		$this->set_prop( 'total', max( 0, $value ) );
2890
+    /**
2891
+     * Set the invoice total.
2892
+     *
2893
+     * @since 1.0.19
2894
+     * @param  float $value sub total.
2895
+     */
2896
+    public function set_total( $value ) {
2897
+        $this->set_prop( 'total', max( 0, $value ) );
2898 2898
     }
2899 2899
 
2900 2900
     /**
2901
-	 * Set the invoice discount amount.
2902
-	 *
2903
-	 * @since 1.0.19
2904
-	 * @param  float $value discount total.
2905
-	 */
2906
-	public function set_total_discount( $value ) {
2907
-		$this->set_prop( 'total_discount', max( 0, $value ) );
2901
+     * Set the invoice discount amount.
2902
+     *
2903
+     * @since 1.0.19
2904
+     * @param  float $value discount total.
2905
+     */
2906
+    public function set_total_discount( $value ) {
2907
+        $this->set_prop( 'total_discount', max( 0, $value ) );
2908 2908
     }
2909 2909
 
2910 2910
     /**
2911
-	 * Alias of self::set_total_discount().
2912
-	 *
2913
-	 * @since 1.0.19
2914
-	 * @param  float $value discount total.
2915
-	 */
2916
-	public function set_discount( $value ) {
2917
-		$this->set_total_discount( $value );
2911
+     * Alias of self::set_total_discount().
2912
+     *
2913
+     * @since 1.0.19
2914
+     * @param  float $value discount total.
2915
+     */
2916
+    public function set_discount( $value ) {
2917
+        $this->set_total_discount( $value );
2918 2918
     }
2919 2919
 
2920 2920
     /**
2921
-	 * Set the invoice tax amount.
2922
-	 *
2923
-	 * @since 1.0.19
2924
-	 * @param  float $value tax total.
2925
-	 */
2926
-	public function set_total_tax( $value ) {
2927
-		$this->set_prop( 'total_tax', max( 0, $value ) );
2921
+     * Set the invoice tax amount.
2922
+     *
2923
+     * @since 1.0.19
2924
+     * @param  float $value tax total.
2925
+     */
2926
+    public function set_total_tax( $value ) {
2927
+        $this->set_prop( 'total_tax', max( 0, $value ) );
2928 2928
     }
2929 2929
 
2930 2930
     /**
2931
-	 * Alias of self::set_total_tax().
2932
-	 *
2933
-	 * @since 1.0.19
2934
-	 * @param  float $value tax total.
2935
-	 */
2936
-	public function set_tax_total( $value ) {
2937
-		$this->set_total_tax( $value );
2931
+     * Alias of self::set_total_tax().
2932
+     *
2933
+     * @since 1.0.19
2934
+     * @param  float $value tax total.
2935
+     */
2936
+    public function set_tax_total( $value ) {
2937
+        $this->set_total_tax( $value );
2938 2938
     }
2939 2939
 
2940 2940
     /**
2941
-	 * Set the invoice fees amount.
2942
-	 *
2943
-	 * @since 1.0.19
2944
-	 * @param  float $value fees total.
2945
-	 */
2946
-	public function set_total_fees( $value ) {
2947
-		$this->set_prop( 'total_fees', max( 0, $value ) );
2941
+     * Set the invoice fees amount.
2942
+     *
2943
+     * @since 1.0.19
2944
+     * @param  float $value fees total.
2945
+     */
2946
+    public function set_total_fees( $value ) {
2947
+        $this->set_prop( 'total_fees', max( 0, $value ) );
2948 2948
     }
2949 2949
 
2950 2950
     /**
2951
-	 * Alias of self::set_total_fees().
2952
-	 *
2953
-	 * @since 1.0.19
2954
-	 * @param  float $value fees total.
2955
-	 */
2956
-	public function set_fees_total( $value ) {
2957
-		$this->set_total_fees( $value );
2951
+     * Alias of self::set_total_fees().
2952
+     *
2953
+     * @since 1.0.19
2954
+     * @param  float $value fees total.
2955
+     */
2956
+    public function set_fees_total( $value ) {
2957
+        $this->set_total_fees( $value );
2958 2958
     }
2959 2959
 
2960 2960
     /**
2961
-	 * Set the invoice fees.
2962
-	 *
2963
-	 * @since 1.0.19
2964
-	 * @param  array $value fees.
2965
-	 */
2966
-	public function set_fees( $value ) {
2961
+     * Set the invoice fees.
2962
+     *
2963
+     * @since 1.0.19
2964
+     * @param  array $value fees.
2965
+     */
2966
+    public function set_fees( $value ) {
2967 2967
 
2968
-		if ( ! is_array( $value ) ) {
2969
-			$value = array();
2970
-		}
2968
+        if ( ! is_array( $value ) ) {
2969
+            $value = array();
2970
+        }
2971 2971
 
2972
-		$this->set_prop( 'fees', $value );
2972
+        $this->set_prop( 'fees', $value );
2973 2973
 
2974 2974
     }
2975 2975
 
2976 2976
     /**
2977
-	 * Set the invoice taxes.
2978
-	 *
2979
-	 * @since 1.0.19
2980
-	 * @param  array $value taxes.
2981
-	 */
2982
-	public function set_taxes( $value ) {
2977
+     * Set the invoice taxes.
2978
+     *
2979
+     * @since 1.0.19
2980
+     * @param  array $value taxes.
2981
+     */
2982
+    public function set_taxes( $value ) {
2983 2983
 
2984
-		if ( ! is_array( $value ) ) {
2985
-			$value = array();
2986
-		}
2984
+        if ( ! is_array( $value ) ) {
2985
+            $value = array();
2986
+        }
2987 2987
 
2988
-		$this->set_prop( 'taxes', $value );
2988
+        $this->set_prop( 'taxes', $value );
2989 2989
 
2990 2990
     }
2991 2991
 
2992 2992
     /**
2993
-	 * Set the invoice discounts.
2994
-	 *
2995
-	 * @since 1.0.19
2996
-	 * @param  array $value discounts.
2997
-	 */
2998
-	public function set_discounts( $value ) {
2993
+     * Set the invoice discounts.
2994
+     *
2995
+     * @since 1.0.19
2996
+     * @param  array $value discounts.
2997
+     */
2998
+    public function set_discounts( $value ) {
2999 2999
 
3000
-		if ( ! is_array( $value ) ) {
3001
-			$value = array();
3002
-		}
3000
+        if ( ! is_array( $value ) ) {
3001
+            $value = array();
3002
+        }
3003 3003
 
3004
-		$this->set_prop( 'discounts', $value );
3004
+        $this->set_prop( 'discounts', $value );
3005 3005
     }
3006 3006
 
3007 3007
     /**
3008
-	 * Set the invoice items.
3009
-	 *
3010
-	 * @since 1.0.19
3011
-	 * @param  GetPaid_Form_Item[] $value items.
3012
-	 */
3013
-	public function set_items( $value ) {
3008
+     * Set the invoice items.
3009
+     *
3010
+     * @since 1.0.19
3011
+     * @param  GetPaid_Form_Item[] $value items.
3012
+     */
3013
+    public function set_items( $value ) {
3014 3014
 
3015 3015
         // Remove existing items.
3016 3016
         $this->set_prop( 'items', array() );
3017
-		$this->recurring_item = null;
3017
+        $this->recurring_item = null;
3018 3018
 
3019 3019
         // Ensure that we have an array.
3020 3020
         if ( ! is_array( $value ) ) {
@@ -3028,95 +3028,95 @@  discard block
 block discarded – undo
3028 3028
     }
3029 3029
 
3030 3030
     /**
3031
-	 * Set the payment form.
3032
-	 *
3033
-	 * @since 1.0.19
3034
-	 * @param  int $value payment form.
3035
-	 */
3036
-	public function set_payment_form( $value ) {
3037
-		$this->set_prop( 'payment_form', $value );
3031
+     * Set the payment form.
3032
+     *
3033
+     * @since 1.0.19
3034
+     * @param  int $value payment form.
3035
+     */
3036
+    public function set_payment_form( $value ) {
3037
+        $this->set_prop( 'payment_form', $value );
3038 3038
     }
3039 3039
 
3040 3040
     /**
3041
-	 * Set the submission id.
3042
-	 *
3043
-	 * @since 1.0.19
3044
-	 * @param  string $value submission id.
3045
-	 */
3046
-	public function set_submission_id( $value ) {
3047
-		$this->set_prop( 'submission_id', $value );
3041
+     * Set the submission id.
3042
+     *
3043
+     * @since 1.0.19
3044
+     * @param  string $value submission id.
3045
+     */
3046
+    public function set_submission_id( $value ) {
3047
+        $this->set_prop( 'submission_id', $value );
3048 3048
     }
3049 3049
 
3050 3050
     /**
3051
-	 * Set the discount code.
3052
-	 *
3053
-	 * @since 1.0.19
3054
-	 * @param  string $value discount code.
3055
-	 */
3056
-	public function set_discount_code( $value ) {
3057
-		$this->set_prop( 'discount_code', sanitize_text_field( $value ) );
3051
+     * Set the discount code.
3052
+     *
3053
+     * @since 1.0.19
3054
+     * @param  string $value discount code.
3055
+     */
3056
+    public function set_discount_code( $value ) {
3057
+        $this->set_prop( 'discount_code', sanitize_text_field( $value ) );
3058 3058
     }
3059 3059
 
3060 3060
     /**
3061
-	 * Set the gateway.
3062
-	 *
3063
-	 * @since 1.0.19
3064
-	 * @param  string $value gateway.
3065
-	 */
3066
-	public function set_gateway( $value ) {
3067
-		$this->set_prop( 'gateway', $value );
3061
+     * Set the gateway.
3062
+     *
3063
+     * @since 1.0.19
3064
+     * @param  string $value gateway.
3065
+     */
3066
+    public function set_gateway( $value ) {
3067
+        $this->set_prop( 'gateway', $value );
3068 3068
     }
3069 3069
 
3070 3070
     /**
3071
-	 * Set the transaction id.
3072
-	 *
3073
-	 * @since 1.0.19
3074
-	 * @param  string $value transaction id.
3075
-	 */
3076
-	public function set_transaction_id( $value ) {
3077
-		if ( ! empty( $value ) ) {
3078
-			$this->set_prop( 'transaction_id', $value );
3079
-		}
3071
+     * Set the transaction id.
3072
+     *
3073
+     * @since 1.0.19
3074
+     * @param  string $value transaction id.
3075
+     */
3076
+    public function set_transaction_id( $value ) {
3077
+        if ( ! empty( $value ) ) {
3078
+            $this->set_prop( 'transaction_id', $value );
3079
+        }
3080 3080
     }
3081 3081
 
3082 3082
     /**
3083
-	 * Set the currency id.
3084
-	 *
3085
-	 * @since 1.0.19
3086
-	 * @param  string $value currency id.
3087
-	 */
3088
-	public function set_currency( $value ) {
3089
-		$this->set_prop( 'currency', $value );
3083
+     * Set the currency id.
3084
+     *
3085
+     * @since 1.0.19
3086
+     * @param  string $value currency id.
3087
+     */
3088
+    public function set_currency( $value ) {
3089
+        $this->set_prop( 'currency', $value );
3090 3090
     }
3091 3091
 
3092
-	/**
3093
-	 * Set whether to disable taxes.
3094
-	 *
3095
-	 * @since 1.0.19
3096
-	 * @param  bool $value value.
3097
-	 */
3098
-	public function set_disable_taxes( $value ) {
3099
-		$this->set_prop( 'disable_taxes', (bool) $value );
3100
-	}
3092
+    /**
3093
+     * Set whether to disable taxes.
3094
+     *
3095
+     * @since 1.0.19
3096
+     * @param  bool $value value.
3097
+     */
3098
+    public function set_disable_taxes( $value ) {
3099
+        $this->set_prop( 'disable_taxes', (bool) $value );
3100
+    }
3101 3101
 
3102 3102
     /**
3103
-	 * Set the subscription id.
3104
-	 *
3105
-	 * @since 1.0.19
3106
-	 * @param  string $value subscription id.
3107
-	 */
3108
-	public function set_subscription_id( $value ) {
3109
-		$this->set_prop( 'subscription_id', $value );
3110
-	}
3103
+     * Set the subscription id.
3104
+     *
3105
+     * @since 1.0.19
3106
+     * @param  string $value subscription id.
3107
+     */
3108
+    public function set_subscription_id( $value ) {
3109
+        $this->set_prop( 'subscription_id', $value );
3110
+    }
3111 3111
 
3112
-	/**
3113
-	 * Set the remote subscription id.
3114
-	 *
3115
-	 * @since 1.0.19
3116
-	 * @param  string $value subscription id.
3117
-	 */
3118
-	public function set_remote_subscription_id( $value ) {
3119
-		$this->set_prop( 'remote_subscription_id', $value );
3112
+    /**
3113
+     * Set the remote subscription id.
3114
+     *
3115
+     * @since 1.0.19
3116
+     * @param  string $value subscription id.
3117
+     */
3118
+    public function set_remote_subscription_id( $value ) {
3119
+        $this->set_prop( 'remote_subscription_id', $value );
3120 3120
     }
3121 3121
 
3122 3122
     /*
@@ -3155,24 +3155,24 @@  discard block
 block discarded – undo
3155 3155
      */
3156 3156
     public function is_taxable() {
3157 3157
         return ! $this->get_disable_taxes();
3158
-	}
3158
+    }
3159 3159
 
3160
-	/**
3161
-	 * @deprecated
3162
-	 */
3163
-	public function has_vat() {
3160
+    /**
3161
+     * @deprecated
3162
+     */
3163
+    public function has_vat() {
3164 3164
         return $this->is_taxable();
3165
-	}
3165
+    }
3166 3166
 
3167
-	/**
3168
-	 * Checks to see if the invoice requires payment.
3169
-	 */
3170
-	public function is_free() {
3167
+    /**
3168
+     * Checks to see if the invoice requires payment.
3169
+     */
3170
+    public function is_free() {
3171 3171
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
3172 3172
 
3173
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3174
-			$is_free = false;
3175
-		}
3173
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3174
+            $is_free = false;
3175
+        }
3176 3176
 
3177 3177
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
3178 3178
     }
@@ -3183,46 +3183,46 @@  discard block
 block discarded – undo
3183 3183
     public function is_paid() {
3184 3184
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
3185 3185
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3186
-	}
3186
+    }
3187 3187
 
3188
-	/**
3188
+    /**
3189 3189
      * Checks if the invoice needs payment.
3190 3190
      */
3191
-	public function needs_payment() {
3192
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3191
+    public function needs_payment() {
3192
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3193 3193
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3194 3194
     }
3195 3195
 
3196
-	/**
3196
+    /**
3197 3197
      * Checks if the invoice is refunded.
3198 3198
      */
3199
-	public function is_refunded() {
3199
+    public function is_refunded() {
3200 3200
         $is_refunded = $this->has_status( 'wpi-refunded' );
3201 3201
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3202
-	}
3202
+    }
3203 3203
 
3204
-	/**
3204
+    /**
3205 3205
      * Checks if the invoice is held.
3206 3206
      */
3207
-	public function is_held() {
3207
+    public function is_held() {
3208 3208
         $is_held = $this->has_status( 'wpi-onhold' );
3209 3209
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3210
-	}
3210
+    }
3211 3211
 
3212
-	/**
3212
+    /**
3213 3213
      * Checks if the invoice is due.
3214 3214
      */
3215
-	public function is_due() {
3216
-		$due_date = $this->get_due_date();
3217
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3218
-	}
3215
+    public function is_due() {
3216
+        $due_date = $this->get_due_date();
3217
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3218
+    }
3219 3219
 
3220
-	/**
3220
+    /**
3221 3221
      * Checks if the invoice is draft.
3222 3222
      */
3223
-	public function is_draft() {
3223
+    public function is_draft() {
3224 3224
         return $this->has_status( 'draft, auto-draft' );
3225
-	}
3225
+    }
3226 3226
 
3227 3227
     /**
3228 3228
      * Checks if the invoice has a given status.
@@ -3230,9 +3230,9 @@  discard block
 block discarded – undo
3230 3230
     public function has_status( $status ) {
3231 3231
         $status = wpinv_parse_list( $status );
3232 3232
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3233
-	}
3233
+    }
3234 3234
 
3235
-	/**
3235
+    /**
3236 3236
      * Checks if the invoice is of a given type.
3237 3237
      */
3238 3238
     public function is_type( $type ) {
@@ -3255,25 +3255,25 @@  discard block
 block discarded – undo
3255 3255
      */
3256 3256
     public function has_free_trial() {
3257 3257
         return $this->is_recurring() && 0 == $this->get_initial_total();
3258
-	}
3258
+    }
3259 3259
 
3260
-	/**
3260
+    /**
3261 3261
      * @deprecated
3262 3262
      */
3263 3263
     public function is_free_trial() {
3264 3264
         $this->has_free_trial();
3265 3265
     }
3266 3266
 
3267
-	/**
3267
+    /**
3268 3268
      * Check if the initial payment if 0.
3269 3269
      *
3270 3270
      */
3271
-	public function is_initial_free() {
3271
+    public function is_initial_free() {
3272 3272
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3273 3273
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3274 3274
     }
3275 3275
 
3276
-	/**
3276
+    /**
3277 3277
      * Check if the recurring item has a free trial.
3278 3278
      *
3279 3279
      */
@@ -3286,21 +3286,21 @@  discard block
 block discarded – undo
3286 3286
 
3287 3287
         $item = $this->get_recurring( true );
3288 3288
         return $item->has_free_trial();
3289
-	}
3289
+    }
3290 3290
 
3291
-	/**
3291
+    /**
3292 3292
      * Check if the free trial is a result of a discount.
3293 3293
      */
3294 3294
     public function is_free_trial_from_discount() {
3295
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3296
-	}
3295
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3296
+    }
3297 3297
 
3298
-	/**
3298
+    /**
3299 3299
      * @deprecated
3300 3300
      */
3301 3301
     public function discount_first_payment_only() {
3302 3302
 
3303
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3303
+        $discount = wpinv_get_discount_obj( $this->get_discount_code() );
3304 3304
         if ( ! $discount->exists() || ! $this->is_recurring() ) {
3305 3305
             return true;
3306 3306
         }
@@ -3325,146 +3325,146 @@  discard block
 block discarded – undo
3325 3325
      */
3326 3326
     public function add_item( $item ) {
3327 3327
 
3328
-		if ( is_array( $item ) ) {
3329
-			$item = $this->process_array_item( $item );
3330
-		}
3328
+        if ( is_array( $item ) ) {
3329
+            $item = $this->process_array_item( $item );
3330
+        }
3331 3331
 
3332
-		if ( is_numeric( $item ) ) {
3333
-			$item = new GetPaid_Form_Item( $item );
3334
-		}
3332
+        if ( is_numeric( $item ) ) {
3333
+            $item = new GetPaid_Form_Item( $item );
3334
+        }
3335 3335
 
3336 3336
         // Make sure that it is available for purchase.
3337
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3338
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3337
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3338
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3339 3339
         }
3340 3340
 
3341 3341
         // Do we have a recurring item?
3342
-		if ( $item->is_recurring() ) {
3343
-			$this->recurring_item = $item->get_id();
3342
+        if ( $item->is_recurring() ) {
3343
+            $this->recurring_item = $item->get_id();
3344 3344
         }
3345 3345
 
3346 3346
         // Invoice id.
3347 3347
         $item->invoice_id = (int) $this->get_id();
3348 3348
 
3349
-		// Remove duplicates.
3350
-		$this->remove_item( $item->get_id() );
3349
+        // Remove duplicates.
3350
+        $this->remove_item( $item->get_id() );
3351 3351
 
3352
-		if ( 0 == $item->get_quantity() ) {
3353
-			return;
3354
-		}
3352
+        if ( 0 == $item->get_quantity() ) {
3353
+            return;
3354
+        }
3355 3355
 
3356
-		// Retrieve all items.
3356
+        // Retrieve all items.
3357 3357
         $items   = $this->get_items();
3358 3358
 
3359
-		// Add new item.
3359
+        // Add new item.
3360 3360
         $items[] = $item;
3361 3361
 
3362 3362
         $this->set_prop( 'items', $items );
3363 3363
 
3364
-		return true;
3365
-	}
3364
+        return true;
3365
+    }
3366 3366
 
3367
-	/**
3368
-	 * Converts an array to an item.
3369
-	 *
3370
-	 * @since 1.0.19
3371
-	 * @return GetPaid_Form_Item
3372
-	 */
3373
-	protected function process_array_item( $array ) {
3367
+    /**
3368
+     * Converts an array to an item.
3369
+     *
3370
+     * @since 1.0.19
3371
+     * @return GetPaid_Form_Item
3372
+     */
3373
+    protected function process_array_item( $array ) {
3374 3374
 
3375
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3376
-		$item    = new GetPaid_Form_Item( $item_id );
3375
+        $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3376
+        $item    = new GetPaid_Form_Item( $item_id );
3377 3377
 
3378
-		// Set item data.
3379
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3380
-			if ( isset( $array[ "item_$key" ] ) ) {
3381
-				$method = "set_$key";
3382
-				$item->$method( $array[ "item_$key" ] );
3383
-			}
3384
-		}
3378
+        // Set item data.
3379
+        foreach ( array( 'name', 'price', 'description' ) as $key ) {
3380
+            if ( isset( $array[ "item_$key" ] ) ) {
3381
+                $method = "set_$key";
3382
+                $item->$method( $array[ "item_$key" ] );
3383
+            }
3384
+        }
3385 3385
 
3386
-		if ( isset( $array['quantity'] ) ) {
3387
-			$item->set_quantity( $array['quantity'] );
3388
-		}
3386
+        if ( isset( $array['quantity'] ) ) {
3387
+            $item->set_quantity( $array['quantity'] );
3388
+        }
3389 3389
 
3390
-		// Set item meta.
3391
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3392
-			$item->set_item_meta( $array['meta'] );
3393
-		}
3390
+        // Set item meta.
3391
+        if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3392
+            $item->set_item_meta( $array['meta'] );
3393
+        }
3394 3394
 
3395
-		return $item;
3395
+        return $item;
3396 3396
 
3397
-	}
3397
+    }
3398 3398
 
3399 3399
     /**
3400
-	 * Retrieves a specific item.
3401
-	 *
3402
-	 * @since 1.0.19
3403
-	 * @return GetPaid_Form_Item|null
3404
-	 */
3405
-	public function get_item( $item_id ) {
3400
+     * Retrieves a specific item.
3401
+     *
3402
+     * @since 1.0.19
3403
+     * @return GetPaid_Form_Item|null
3404
+     */
3405
+    public function get_item( $item_id ) {
3406 3406
 
3407
-		foreach ( $this->get_items() as $item ) {
3408
-			if ( (int) $item_id == $item->get_id() ) {
3409
-				return $item;
3410
-			}
3411
-		}
3407
+        foreach ( $this->get_items() as $item ) {
3408
+            if ( (int) $item_id == $item->get_id() ) {
3409
+                return $item;
3410
+            }
3411
+        }
3412 3412
 
3413
-		return null;
3413
+        return null;
3414 3414
     }
3415 3415
 
3416 3416
     /**
3417
-	 * Removes a specific item.
3418
-	 *
3419
-	 * @since 1.0.19
3420
-	 */
3421
-	public function remove_item( $item_id ) {
3422
-		$items   = $this->get_items();
3423
-		$item_id = (int) $item_id;
3417
+     * Removes a specific item.
3418
+     *
3419
+     * @since 1.0.19
3420
+     */
3421
+    public function remove_item( $item_id ) {
3422
+        $items   = $this->get_items();
3423
+        $item_id = (int) $item_id;
3424 3424
 
3425
-		foreach ( $items as $index => $item ) {
3426
-			if ( (int) $item_id == $item->get_id() ) {
3427
-				unset( $items[ $index ] );
3428
-				$this->set_prop( 'items', $items );
3425
+        foreach ( $items as $index => $item ) {
3426
+            if ( (int) $item_id == $item->get_id() ) {
3427
+                unset( $items[ $index ] );
3428
+                $this->set_prop( 'items', $items );
3429 3429
 
3430
-				if ( $item_id == $this->recurring_item ) {
3431
-					$this->recurring_item = null;
3432
-				}
3430
+                if ( $item_id == $this->recurring_item ) {
3431
+                    $this->recurring_item = null;
3432
+                }
3433 3433
 }
3434
-		}
3434
+        }
3435 3435
 
3436 3436
     }
3437 3437
 
3438 3438
     /**
3439
-	 * Adds a fee to the invoice.
3440
-	 *
3441
-	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3442
-	 * @since 1.0.19
3443
-	 */
3439
+     * Adds a fee to the invoice.
3440
+     *
3441
+     * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3442
+     * @since 1.0.19
3443
+     */
3444 3444
     public function add_fee( $fee ) {
3445 3445
 
3446
-		$fees                 = $this->get_fees();
3447
-		$fees[ $fee['name'] ] = $fee;
3448
-		$this->set_prop( 'fees', $fees );
3446
+        $fees                 = $this->get_fees();
3447
+        $fees[ $fee['name'] ] = $fee;
3448
+        $this->set_prop( 'fees', $fees );
3449 3449
 
3450 3450
     }
3451 3451
 
3452 3452
     /**
3453
-	 * Retrieves a specific fee.
3454
-	 *
3455
-	 * @since 1.0.19
3456
-	 */
3457
-	public function get_fee( $fee ) {
3453
+     * Retrieves a specific fee.
3454
+     *
3455
+     * @since 1.0.19
3456
+     */
3457
+    public function get_fee( $fee ) {
3458 3458
         $fees = $this->get_fees();
3459
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3459
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3460 3460
     }
3461 3461
 
3462 3462
     /**
3463
-	 * Removes a specific fee.
3464
-	 *
3465
-	 * @since 1.0.19
3466
-	 */
3467
-	public function remove_fee( $fee ) {
3463
+     * Removes a specific fee.
3464
+     *
3465
+     * @since 1.0.19
3466
+     */
3467
+    public function remove_fee( $fee ) {
3468 3468
         $fees = $this->get_fees();
3469 3469
         if ( isset( $fees[ $fee ] ) ) {
3470 3470
             unset( $fees[ $fee ] );
@@ -3472,55 +3472,55 @@  discard block
 block discarded – undo
3472 3472
         }
3473 3473
     }
3474 3474
 
3475
-	/**
3476
-	 * Adds a discount to the invoice.
3477
-	 *
3478
-	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3479
-	 * @since 1.0.19
3480
-	 */
3481
-	public function add_discount( $discount ) {
3475
+    /**
3476
+     * Adds a discount to the invoice.
3477
+     *
3478
+     * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3479
+     * @since 1.0.19
3480
+     */
3481
+    public function add_discount( $discount ) {
3482 3482
 
3483
-		$discounts = $this->get_discounts();
3484
-		$discounts[ $discount['name'] ] = $discount;
3485
-		$this->set_prop( 'discounts', $discounts );
3483
+        $discounts = $this->get_discounts();
3484
+        $discounts[ $discount['name'] ] = $discount;
3485
+        $this->set_prop( 'discounts', $discounts );
3486 3486
 
3487
-	}
3487
+    }
3488 3488
 
3489 3489
     /**
3490
-	 * Retrieves a specific discount.
3491
-	 *
3492
-	 * @since 1.0.19
3493
-	 * @return float
3494
-	 */
3495
-	public function get_discount( $discount = false ) {
3490
+     * Retrieves a specific discount.
3491
+     *
3492
+     * @since 1.0.19
3493
+     * @return float
3494
+     */
3495
+    public function get_discount( $discount = false ) {
3496 3496
 
3497
-		// Backwards compatibilty.
3498
-		if ( empty( $discount ) ) {
3499
-			return $this->get_total_discount();
3500
-		}
3497
+        // Backwards compatibilty.
3498
+        if ( empty( $discount ) ) {
3499
+            return $this->get_total_discount();
3500
+        }
3501 3501
 
3502 3502
         $discounts = $this->get_discounts();
3503
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3503
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3504 3504
     }
3505 3505
 
3506 3506
     /**
3507
-	 * Removes a specific discount.
3508
-	 *
3509
-	 * @since 1.0.19
3510
-	 */
3511
-	public function remove_discount( $discount ) {
3507
+     * Removes a specific discount.
3508
+     *
3509
+     * @since 1.0.19
3510
+     */
3511
+    public function remove_discount( $discount ) {
3512 3512
         $discounts = $this->get_discounts();
3513 3513
         if ( isset( $discounts[ $discount ] ) ) {
3514 3514
             unset( $discounts[ $discount ] );
3515 3515
             $this->set_prop( 'discounts', $discounts );
3516 3516
         }
3517 3517
 
3518
-		if ( 'discount_code' == $discount ) {
3519
-			foreach ( $this->get_items() as $item ) {
3520
-				$item->item_discount           = 0;
3521
-				$item->recurring_item_discount = 0;
3522
-			}
3523
-		}
3518
+        if ( 'discount_code' == $discount ) {
3519
+            foreach ( $this->get_items() as $item ) {
3520
+                $item->item_discount           = 0;
3521
+                $item->recurring_item_discount = 0;
3522
+            }
3523
+        }
3524 3524
 
3525 3525
     }
3526 3526
 
@@ -3533,34 +3533,34 @@  discard block
 block discarded – undo
3533 3533
         if ( $this->is_taxable() ) {
3534 3534
 
3535 3535
             $taxes                 = $this->get_taxes();
3536
-			$taxes[ $tax['name'] ] = $tax;
3537
-			$this->set_prop( 'taxes', $tax );
3536
+            $taxes[ $tax['name'] ] = $tax;
3537
+            $this->set_prop( 'taxes', $tax );
3538 3538
 
3539 3539
         }
3540 3540
     }
3541 3541
 
3542 3542
     /**
3543
-	 * Retrieves a specific tax.
3544
-	 *
3545
-	 * @since 1.0.19
3546
-	 */
3547
-	public function get_tax( $tax = null ) {
3543
+     * Retrieves a specific tax.
3544
+     *
3545
+     * @since 1.0.19
3546
+     */
3547
+    public function get_tax( $tax = null ) {
3548 3548
 
3549
-		// Backwards compatility.
3550
-		if ( empty( $tax ) ) {
3551
-			return $this->get_total_tax();
3552
-		}
3549
+        // Backwards compatility.
3550
+        if ( empty( $tax ) ) {
3551
+            return $this->get_total_tax();
3552
+        }
3553 3553
 
3554 3554
         $taxes = $this->get_taxes();
3555
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3555
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3556 3556
     }
3557 3557
 
3558 3558
     /**
3559
-	 * Removes a specific tax.
3560
-	 *
3561
-	 * @since 1.0.19
3562
-	 */
3563
-	public function remove_tax( $tax ) {
3559
+     * Removes a specific tax.
3560
+     *
3561
+     * @since 1.0.19
3562
+     */
3563
+    public function remove_tax( $tax ) {
3564 3564
         $taxes = $this->get_taxes();
3565 3565
         if ( isset( $taxes[ $tax ] ) ) {
3566 3566
             unset( $taxes[ $tax ] );
@@ -3569,184 +3569,184 @@  discard block
 block discarded – undo
3569 3569
     }
3570 3570
 
3571 3571
     /**
3572
-	 * Recalculates the invoice subtotal.
3573
-	 *
3574
-	 * @since 1.0.19
3575
-	 * @return float The recalculated subtotal
3576
-	 */
3577
-	public function recalculate_subtotal() {
3572
+     * Recalculates the invoice subtotal.
3573
+     *
3574
+     * @since 1.0.19
3575
+     * @return float The recalculated subtotal
3576
+     */
3577
+    public function recalculate_subtotal() {
3578 3578
         $items     = $this->get_items();
3579
-		$subtotal  = 0;
3580
-		$recurring = 0;
3579
+        $subtotal  = 0;
3580
+        $recurring = 0;
3581 3581
 
3582 3582
         foreach ( $items as $item ) {
3583
-			$subtotal  += $item->get_sub_total( 'edit' );
3584
-			$recurring += $item->get_recurring_sub_total( 'edit' );
3583
+            $subtotal  += $item->get_sub_total( 'edit' );
3584
+            $recurring += $item->get_recurring_sub_total( 'edit' );
3585 3585
         }
3586 3586
 
3587
-		if ( wpinv_prices_include_tax() ) {
3588
-			$subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3589
-			$recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3590
-		}
3587
+        if ( wpinv_prices_include_tax() ) {
3588
+            $subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3589
+            $recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3590
+        }
3591 3591
 
3592
-		$current = $this->is_renewal() ? $recurring : $subtotal;
3593
-		$this->set_subtotal( $current );
3592
+        $current = $this->is_renewal() ? $recurring : $subtotal;
3593
+        $this->set_subtotal( $current );
3594 3594
 
3595
-		$this->totals['subtotal'] = array(
3596
-			'initial'   => $subtotal,
3597
-			'recurring' => $recurring,
3598
-		);
3595
+        $this->totals['subtotal'] = array(
3596
+            'initial'   => $subtotal,
3597
+            'recurring' => $recurring,
3598
+        );
3599 3599
 
3600 3600
         return $current;
3601 3601
     }
3602 3602
 
3603 3603
     /**
3604
-	 * Recalculates the invoice discount total.
3605
-	 *
3606
-	 * @since 1.0.19
3607
-	 * @return float The recalculated discount
3608
-	 */
3609
-	public function recalculate_total_discount() {
3604
+     * Recalculates the invoice discount total.
3605
+     *
3606
+     * @since 1.0.19
3607
+     * @return float The recalculated discount
3608
+     */
3609
+    public function recalculate_total_discount() {
3610 3610
         $discounts = $this->get_discounts();
3611
-		$discount  = 0;
3612
-		$recurring = 0;
3611
+        $discount  = 0;
3612
+        $recurring = 0;
3613 3613
 
3614 3614
         foreach ( $discounts as $data ) {
3615
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3616
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3617
-		}
3615
+            $discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3616
+            $recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3617
+        }
3618 3618
 
3619
-		$current = $this->is_renewal() ? $recurring : $discount;
3619
+        $current = $this->is_renewal() ? $recurring : $discount;
3620 3620
 
3621
-		$this->set_total_discount( $current );
3621
+        $this->set_total_discount( $current );
3622 3622
 
3623
-		$this->totals['discount'] = array(
3624
-			'initial'   => $discount,
3625
-			'recurring' => $recurring,
3626
-		);
3623
+        $this->totals['discount'] = array(
3624
+            'initial'   => $discount,
3625
+            'recurring' => $recurring,
3626
+        );
3627 3627
 
3628
-		return $current;
3628
+        return $current;
3629 3629
 
3630 3630
     }
3631 3631
 
3632 3632
     /**
3633
-	 * Recalculates the invoice tax total.
3634
-	 *
3635
-	 * @since 1.0.19
3636
-	 * @return float The recalculated tax
3637
-	 */
3638
-	public function recalculate_total_tax() {
3633
+     * Recalculates the invoice tax total.
3634
+     *
3635
+     * @since 1.0.19
3636
+     * @return float The recalculated tax
3637
+     */
3638
+    public function recalculate_total_tax() {
3639 3639
 
3640
-		// Maybe disable taxes.
3641
-		$vat_number = $this->get_vat_number();
3642
-		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3640
+        // Maybe disable taxes.
3641
+        $vat_number = $this->get_vat_number();
3642
+        $skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3643 3643
 
3644
-		if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' === wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3645
-			$skip_tax = false;
3646
-		}
3644
+        if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' === wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3645
+            $skip_tax = false;
3646
+        }
3647 3647
 
3648
-		if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) {
3648
+        if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) {
3649 3649
 
3650
-			$this->totals['tax'] = array(
3651
-				'initial'   => 0,
3652
-				'recurring' => 0,
3653
-			);
3650
+            $this->totals['tax'] = array(
3651
+                'initial'   => 0,
3652
+                'recurring' => 0,
3653
+            );
3654 3654
 
3655
-			$this->tax_rate = 0;
3655
+            $this->tax_rate = 0;
3656 3656
 
3657
-			$this->set_taxes( array() );
3658
-			$current = 0;
3659
-		} else {
3657
+            $this->set_taxes( array() );
3658
+            $current = 0;
3659
+        } else {
3660 3660
 
3661
-			$item_taxes = array();
3661
+            $item_taxes = array();
3662 3662
 
3663
-			foreach ( $this->get_items() as $item ) {
3664
-				$rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3665
-				$rates    = getpaid_filter_item_tax_rates( $item, $rates );
3666
-				$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3667
-				$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3668
-				foreach ( $taxes as $name => $amount ) {
3669
-					$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3670
-					$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3663
+            foreach ( $this->get_items() as $item ) {
3664
+                $rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3665
+                $rates    = getpaid_filter_item_tax_rates( $item, $rates );
3666
+                $taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3667
+                $r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3668
+                foreach ( $taxes as $name => $amount ) {
3669
+                    $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3670
+                    $tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3671 3671
 
3672
-					if ( ! isset( $item_taxes[ $name ] ) ) {
3673
-						$item_taxes[ $name ] = $tax;
3674
-						continue;
3675
-					}
3672
+                    if ( ! isset( $item_taxes[ $name ] ) ) {
3673
+                        $item_taxes[ $name ] = $tax;
3674
+                        continue;
3675
+                    }
3676 3676
 
3677
-					$item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3678
-					$item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3677
+                    $item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3678
+                    $item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3679 3679
 
3680
-				}
3681
-			}
3680
+                }
3681
+            }
3682 3682
 
3683
-			$item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3684
-			$this->set_taxes( $item_taxes );
3683
+            $item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3684
+            $this->set_taxes( $item_taxes );
3685 3685
 
3686
-			$initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3687
-			$recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3686
+            $initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3687
+            $recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3688 3688
 
3689
-			$current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3689
+            $current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3690 3690
 
3691
-			$this->totals['tax'] = array(
3692
-				'initial'   => $initial_tax,
3693
-				'recurring' => $recurring_tax,
3694
-			);
3691
+            $this->totals['tax'] = array(
3692
+                'initial'   => $initial_tax,
3693
+                'recurring' => $recurring_tax,
3694
+            );
3695 3695
 
3696
-		}
3696
+        }
3697 3697
 
3698
-		$this->set_total_tax( $current );
3698
+        $this->set_total_tax( $current );
3699 3699
 
3700
-		return $current;
3700
+        return $current;
3701 3701
 
3702 3702
     }
3703 3703
 
3704 3704
     /**
3705
-	 * Recalculates the invoice fees total.
3706
-	 *
3707
-	 * @since 1.0.19
3708
-	 * @return float The recalculated fee
3709
-	 */
3710
-	public function recalculate_total_fees() {
3711
-		$fees      = $this->get_fees();
3712
-		$fee       = 0;
3713
-		$recurring = 0;
3705
+     * Recalculates the invoice fees total.
3706
+     *
3707
+     * @since 1.0.19
3708
+     * @return float The recalculated fee
3709
+     */
3710
+    public function recalculate_total_fees() {
3711
+        $fees      = $this->get_fees();
3712
+        $fee       = 0;
3713
+        $recurring = 0;
3714 3714
 
3715 3715
         foreach ( $fees as $data ) {
3716
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3717
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3718
-		}
3716
+            $fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3717
+            $recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3718
+        }
3719 3719
 
3720
-		$current = $this->is_renewal() ? $recurring : $fee;
3721
-		$this->set_total_fees( $current );
3720
+        $current = $this->is_renewal() ? $recurring : $fee;
3721
+        $this->set_total_fees( $current );
3722 3722
 
3723
-		$this->totals['fee'] = array(
3724
-			'initial'   => $fee,
3725
-			'recurring' => $recurring,
3726
-		);
3723
+        $this->totals['fee'] = array(
3724
+            'initial'   => $fee,
3725
+            'recurring' => $recurring,
3726
+        );
3727 3727
 
3728 3728
         $this->set_total_fees( $fee );
3729 3729
         return $current;
3730 3730
     }
3731 3731
 
3732 3732
     /**
3733
-	 * Recalculates the invoice total.
3734
-	 *
3735
-	 * @since 1.0.19
3733
+     * Recalculates the invoice total.
3734
+     *
3735
+     * @since 1.0.19
3736 3736
      * @return float The invoice total
3737
-	 */
3738
-	public function recalculate_total() {
3737
+     */
3738
+    public function recalculate_total() {
3739 3739
         $this->recalculate_total_fees();
3740 3740
         $this->recalculate_total_discount();
3741
-		$this->recalculate_total_tax();
3742
-		$this->recalculate_subtotal();
3743
-		$this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3744
-		return $this->get_total();
3745
-	}
3746
-
3747
-	/**
3748
-	 * @deprecated
3749
-	 */
3741
+        $this->recalculate_total_tax();
3742
+        $this->recalculate_subtotal();
3743
+        $this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3744
+        return $this->get_total();
3745
+    }
3746
+
3747
+    /**
3748
+     * @deprecated
3749
+     */
3750 3750
     public function recalculate_totals() {
3751 3751
         $this->recalculate_total();
3752 3752
         $this->save( true );
@@ -3760,22 +3760,22 @@  discard block
 block discarded – undo
3760 3760
         return $this->get_data();
3761 3761
     }
3762 3762
 
3763
-	/**
3763
+    /**
3764 3764
      * Adds a system note to an invoice.
3765 3765
      *
3766 3766
      * @param string $note The note being added.
3767
-	 * @return int|false The new note's ID on success, false on failure.
3767
+     * @return int|false The new note's ID on success, false on failure.
3768 3768
      *
3769 3769
      */
3770 3770
     public function add_system_note( $note ) {
3771
-		return $this->add_note( $note, false, false, true );
3772
-	}
3771
+        return $this->add_note( $note, false, false, true );
3772
+    }
3773 3773
 
3774 3774
     /**
3775 3775
      * Adds a note to an invoice.
3776 3776
      *
3777 3777
      * @param string $note The note being added.
3778
-	 * @return int|false The new note's ID on success, false on failure.
3778
+     * @return int|false The new note's ID on success, false on failure.
3779 3779
      *
3780 3780
      */
3781 3781
     public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
@@ -3785,21 +3785,21 @@  discard block
 block discarded – undo
3785 3785
             return false;
3786 3786
         }
3787 3787
 
3788
-		$author       = 'System';
3789
-		$author_email = '[email protected]';
3788
+        $author       = 'System';
3789
+        $author_email = '[email protected]';
3790 3790
 
3791
-		// If this is an admin comment or it has been added by the user.
3792
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3793
-			$user         = get_user_by( 'id', get_current_user_id() );
3791
+        // If this is an admin comment or it has been added by the user.
3792
+        if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3793
+            $user         = get_user_by( 'id', get_current_user_id() );
3794 3794
             $author       = $user->display_name;
3795 3795
             $author_email = $user->user_email;
3796
-		}
3796
+        }
3797 3797
 
3798
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3798
+        return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3799 3799
 
3800
-	}
3800
+    }
3801 3801
 
3802
-	/**
3802
+    /**
3803 3803
      * Generates a unique key for the invoice.
3804 3804
      */
3805 3805
     public function generate_key( $string = '' ) {
@@ -3819,113 +3819,113 @@  discard block
 block discarded – undo
3819 3819
             $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3820 3820
         }
3821 3821
 
3822
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3823
-
3824
-	}
3825
-
3826
-	/**
3827
-	 * Handle the status transition.
3828
-	 */
3829
-	protected function status_transition() {
3830
-		$status_transition = $this->status_transition;
3831
-
3832
-		// Reset status transition variable.
3833
-		$this->status_transition = false;
3834
-
3835
-		if ( $status_transition ) {
3836
-			try {
3822
+        return wpinv_format_invoice_number( $number, $this->get_post_type() );
3837 3823
 
3838
-				// Fire a hook for the status change.
3839
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3840
-
3841
-				// @deprecated this is deprecated and will be removed in the future.
3842
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3843
-
3844
-				if ( ! empty( $status_transition['from'] ) ) {
3845
-
3846
-					/* translators: 1: old invoice status 2: new invoice status */
3847
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) );
3848
-
3849
-					// Fire another hook.
3850
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3851
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3852
-
3853
-					// @deprecated this is deprecated and will be removed in the future.
3854
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3855
-
3856
-					// Note the transition occurred.
3857
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3858
-
3859
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3860
-					if (
3861
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3862
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3863
-					) {
3864
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3865
-					}
3866
-
3867
-					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3868
-					if (
3869
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3870
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3871
-					) {
3872
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3873
-					}
3874
-				} else {
3875
-					/* translators: %s: new invoice status */
3876
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) );
3877
-
3878
-					// Note the transition occurred.
3879
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3824
+    }
3880 3825
 
3881
-				}
3882
-			} catch ( Exception $e ) {
3883
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3884
-			}
3885
-		}
3886
-	}
3826
+    /**
3827
+     * Handle the status transition.
3828
+     */
3829
+    protected function status_transition() {
3830
+        $status_transition = $this->status_transition;
3831
+
3832
+        // Reset status transition variable.
3833
+        $this->status_transition = false;
3834
+
3835
+        if ( $status_transition ) {
3836
+            try {
3837
+
3838
+                // Fire a hook for the status change.
3839
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3840
+
3841
+                // @deprecated this is deprecated and will be removed in the future.
3842
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3843
+
3844
+                if ( ! empty( $status_transition['from'] ) ) {
3845
+
3846
+                    /* translators: 1: old invoice status 2: new invoice status */
3847
+                    $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) );
3848
+
3849
+                    // Fire another hook.
3850
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3851
+                    do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3852
+
3853
+                    // @deprecated this is deprecated and will be removed in the future.
3854
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3855
+
3856
+                    // Note the transition occurred.
3857
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3858
+
3859
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3860
+                    if (
3861
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3862
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3863
+                    ) {
3864
+                        do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3865
+                    }
3866
+
3867
+                    // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3868
+                    if (
3869
+                        in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3870
+                        && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3871
+                    ) {
3872
+                        do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3873
+                    }
3874
+                } else {
3875
+                    /* translators: %s: new invoice status */
3876
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) );
3877
+
3878
+                    // Note the transition occurred.
3879
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3880
+
3881
+                }
3882
+            } catch ( Exception $e ) {
3883
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3884
+            }
3885
+        }
3886
+    }
3887 3887
 
3888
-	/**
3889
-	 * Updates an invoice status.
3890
-	 */
3891
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3888
+    /**
3889
+     * Updates an invoice status.
3890
+     */
3891
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3892 3892
 
3893
-		// Fires before updating a status.
3894
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3893
+        // Fires before updating a status.
3894
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3895 3895
 
3896
-		// Update the status.
3897
-		$this->set_status( $new_status, $note, $manual );
3896
+        // Update the status.
3897
+        $this->set_status( $new_status, $note, $manual );
3898 3898
 
3899
-		// Save the order.
3900
-		return $this->save();
3899
+        // Save the order.
3900
+        return $this->save();
3901 3901
 
3902
-	}
3902
+    }
3903 3903
 
3904
-	/**
3905
-	 * @deprecated
3906
-	 */
3907
-	public function refresh_item_ids() {
3904
+    /**
3905
+     * @deprecated
3906
+     */
3907
+    public function refresh_item_ids() {
3908 3908
         $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) );
3909 3909
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3910
-	}
3910
+    }
3911 3911
 
3912
-	/**
3913
-	 * @deprecated
3914
-	 */
3915
-	public function update_items( $temp = false ) {
3912
+    /**
3913
+     * @deprecated
3914
+     */
3915
+    public function update_items( $temp = false ) {
3916 3916
 
3917
-		$this->set_items( $this->get_items() );
3917
+        $this->set_items( $this->get_items() );
3918 3918
 
3919
-		if ( ! $temp ) {
3920
-			$this->save();
3921
-		}
3919
+        if ( ! $temp ) {
3920
+            $this->save();
3921
+        }
3922 3922
 
3923 3923
         return $this;
3924
-	}
3924
+    }
3925 3925
 
3926
-	/**
3927
-	 * @deprecated
3928
-	 */
3926
+    /**
3927
+     * @deprecated
3928
+     */
3929 3929
     public function validate_discount() {
3930 3930
 
3931 3931
         $discount_code = $this->get_discount_code();
@@ -3941,93 +3941,93 @@  discard block
 block discarded – undo
3941 3941
 
3942 3942
     }
3943 3943
 
3944
-	/**
3945
-	 * Refunds an invoice.
3946
-	 */
3944
+    /**
3945
+     * Refunds an invoice.
3946
+     */
3947 3947
     public function refund() {
3948
-		$this->set_status( 'wpi-refunded' );
3948
+        $this->set_status( 'wpi-refunded' );
3949 3949
         $this->save();
3950
-	}
3950
+    }
3951 3951
 
3952
-	/**
3953
-	 * Marks an invoice as paid.
3954
-	 *
3955
-	 * @param string $transaction_id
3956
-	 */
3952
+    /**
3953
+     * Marks an invoice as paid.
3954
+     *
3955
+     * @param string $transaction_id
3956
+     */
3957 3957
     public function mark_paid( $transaction_id = null, $note = '' ) {
3958 3958
 
3959
-		// Set the transaction id.
3960
-		if ( empty( $transaction_id ) ) {
3961
-			$transaction_id = $this->generate_key( 'trans_' );
3962
-		}
3959
+        // Set the transaction id.
3960
+        if ( empty( $transaction_id ) ) {
3961
+            $transaction_id = $this->generate_key( 'trans_' );
3962
+        }
3963 3963
 
3964
-		if ( ! $this->get_transaction_id() ) {
3965
-			$this->set_transaction_id( $transaction_id );
3966
-		}
3964
+        if ( ! $this->get_transaction_id() ) {
3965
+            $this->set_transaction_id( $transaction_id );
3966
+        }
3967 3967
 
3968
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3969
-			return $this->save();
3970
-		}
3968
+        if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3969
+            return $this->save();
3970
+        }
3971 3971
 
3972
-		// Set the completed date.
3973
-		$this->set_date_completed( current_time( 'mysql' ) );
3972
+        // Set the completed date.
3973
+        $this->set_date_completed( current_time( 'mysql' ) );
3974 3974
 
3975
-		// Set the new status.
3976
-		$gateway = sanitize_text_field( $this->get_gateway_title() );
3977
-		if ( $this->is_renewal() || ! $this->is_parent() ) {
3975
+        // Set the new status.
3976
+        $gateway = sanitize_text_field( $this->get_gateway_title() );
3977
+        if ( $this->is_renewal() || ! $this->is_parent() ) {
3978 3978
 
3979
-			$_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3980
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3979
+            $_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3980
+            $_note = $_note . empty( $note ) ? '' : " ($note)";
3981 3981
 
3982
-			if ( 'none' == $this->get_gateway() ) {
3983
-				$_note = $note;
3984
-			}
3982
+            if ( 'none' == $this->get_gateway() ) {
3983
+                $_note = $note;
3984
+            }
3985 3985
 
3986
-			$this->set_status( 'wpi-renewal', $_note );
3986
+            $this->set_status( 'wpi-renewal', $_note );
3987 3987
 
3988
-		} else {
3988
+        } else {
3989 3989
 
3990
-			$_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3991
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3990
+            $_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3991
+            $_note = $_note . empty( $note ) ? '' : " ($note)";
3992 3992
 
3993
-			if ( 'none' == $this->get_gateway() ) {
3994
-				$_note = $note;
3995
-			}
3993
+            if ( 'none' == $this->get_gateway() ) {
3994
+                $_note = $note;
3995
+            }
3996 3996
 
3997
-			$this->set_status( 'publish', $_note );
3997
+            $this->set_status( 'publish', $_note );
3998 3998
 
3999
-		}
3999
+        }
4000 4000
 
4001
-		// Set checkout mode.
4002
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
4003
-		$this->set_mode( $mode );
4001
+        // Set checkout mode.
4002
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
4003
+        $this->set_mode( $mode );
4004 4004
 
4005
-		// Save the invoice.
4005
+        // Save the invoice.
4006 4006
         $this->save();
4007
-	}
4008
-
4009
-	/**
4010
-	 * Save data to the database.
4011
-	 *
4012
-	 * @since 1.0.19
4013
-	 * @return int invoice ID
4014
-	 */
4015
-	public function save() {
4016
-		$this->maybe_set_date_paid();
4017
-		$this->maybe_set_key();
4018
-		parent::save();
4019
-		$this->clear_cache();
4020
-		$this->status_transition();
4021
-		return $this->get_id();
4022
-	}
4023
-
4024
-	/**
4007
+    }
4008
+
4009
+    /**
4010
+     * Save data to the database.
4011
+     *
4012
+     * @since 1.0.19
4013
+     * @return int invoice ID
4014
+     */
4015
+    public function save() {
4016
+        $this->maybe_set_date_paid();
4017
+        $this->maybe_set_key();
4018
+        parent::save();
4019
+        $this->clear_cache();
4020
+        $this->status_transition();
4021
+        return $this->get_id();
4022
+    }
4023
+
4024
+    /**
4025 4025
      * Clears the subscription's cache.
4026 4026
      */
4027 4027
     public function clear_cache() {
4028
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
4029
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
4030
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
4031
-	}
4028
+        wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
4029
+        wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
4030
+        wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
4031
+    }
4032 4032
 
4033 4033
 }
Please login to merge, or discard this patch.