Passed
Push — master ( 6621fa...568391 )
by Brian
06:12
created
includes/admin/class-getpaid-admin.php 2 patches
Indentation   +210 added lines, -210 removed lines patch added patch discarded remove patch
@@ -14,61 +14,61 @@  discard block
 block discarded – undo
14 14
 class GetPaid_Admin {
15 15
 
16 16
     /**
17
-	 * Local path to this plugins admin directory
18
-	 *
19
-	 * @var         string
20
-	 */
21
-	public $admin_path;
22
-
23
-	/**
24
-	 * Web path to this plugins admin directory
25
-	 *
26
-	 * @var         string
27
-	 */
17
+     * Local path to this plugins admin directory
18
+     *
19
+     * @var         string
20
+     */
21
+    public $admin_path;
22
+
23
+    /**
24
+     * Web path to this plugins admin directory
25
+     *
26
+     * @var         string
27
+     */
28 28
     public $admin_url;
29 29
 
30 30
     /**
31
-	 * Class constructor.
32
-	 */
33
-	public function __construct(){
31
+     * Class constructor.
32
+     */
33
+    public function __construct(){
34 34
 
35 35
         $this->admin_path  = plugin_dir_path( __FILE__ );
36 36
         $this->admin_url   = plugins_url( '/', __FILE__ );
37 37
 
38 38
         if ( is_admin() ) {
39
-			$this->init_admin_hooks();
39
+            $this->init_admin_hooks();
40 40
         }
41 41
 
42 42
     }
43 43
 
44 44
     /**
45
-	 * Init action and filter hooks
46
-	 *
47
-	 */
48
-	private function init_admin_hooks() {
45
+     * Init action and filter hooks
46
+     *
47
+     */
48
+    private function init_admin_hooks() {
49 49
         add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
50 50
         add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
51 51
         add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
52 52
         add_action( 'admin_init', array( $this, 'activation_redirect') );
53 53
         add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
54
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
55
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
56
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
57
-		do_action( 'getpaid_init_admin_hooks', $this );
54
+        add_action( 'admin_notices', array( $this, 'show_notices' ) );
55
+        add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
56
+        add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
57
+        do_action( 'getpaid_init_admin_hooks', $this );
58 58
 
59 59
     }
60 60
 
61 61
     /**
62
-	 * Register admin scripts
63
-	 *
64
-	 */
65
-	public function enqeue_scripts() {
62
+     * Register admin scripts
63
+     *
64
+     */
65
+    public function enqeue_scripts() {
66 66
         global $current_screen;
67 67
 
68 68
         $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
69 69
 
70 70
         if ( ! empty( $current_screen->post_type ) ) {
71
-			$page = $current_screen->post_type;
71
+            $page = $current_screen->post_type;
72 72
         }
73 73
 
74 74
         // General styles.
@@ -92,30 +92,30 @@  discard block
 block discarded – undo
92 92
         }
93 93
 
94 94
         // Payment form scripts.
95
-		if ( 'wpi_payment_form' == $page ) {
95
+        if ( 'wpi_payment_form' == $page ) {
96 96
             $this->load_payment_form_scripts();
97 97
         }
98 98
 
99 99
         if ( $page == 'wpinv-subscriptions' ) {
100
-			wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
101
-			wp_enqueue_script( 'wpinv-sub-admin-script' );
102
-		}
100
+            wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
101
+            wp_enqueue_script( 'wpinv-sub-admin-script' );
102
+        }
103 103
 
104
-		if ( $page == 'wpinv-reports' ) {
105
-			wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' );
106
-		}
104
+        if ( $page == 'wpinv-reports' ) {
105
+            wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' );
106
+        }
107 107
 
108
-		if ( $page == 'wpinv-subscriptions' ) {
109
-			wp_enqueue_script( 'postbox' );
110
-		}
108
+        if ( $page == 'wpinv-subscriptions' ) {
109
+            wp_enqueue_script( 'postbox' );
110
+        }
111 111
 
112 112
     }
113 113
 
114 114
     /**
115
-	 * Returns admin js translations.
116
-	 *
117
-	 */
118
-	protected function get_admin_i18() {
115
+     * Returns admin js translations.
116
+     *
117
+     */
118
+    protected function get_admin_i18() {
119 119
         global $post;
120 120
 
121 121
         return array(
@@ -156,33 +156,33 @@  discard block
 block discarded – undo
156 156
     }
157 157
 
158 158
     /**
159
-	 * Loads payment form js.
160
-	 *
161
-	 */
162
-	protected function load_payment_form_scripts() {
159
+     * Loads payment form js.
160
+     *
161
+     */
162
+    protected function load_payment_form_scripts() {
163 163
         global $post;
164 164
 
165 165
         wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
166
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
167
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
166
+        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
167
+        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
168 168
 
169
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
170
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
169
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
170
+        wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
171 171
 
172
-		wp_localize_script(
172
+        wp_localize_script(
173 173
             'wpinv-admin-payment-form-script',
174 174
             'wpinvPaymentFormAdmin',
175 175
             array(
176
-				'elements'      => getpaid()->form_elements->get_elements(),
177
-				'form_elements' => getpaid()->form_elements->get_form_elements( $post->ID ),
178
-				'all_items'     => getpaid()->form_elements->get_published_items(),
179
-				'currency'      => wpinv_currency_symbol(),
180
-				'position'      => wpinv_currency_position(),
181
-				'decimals'      => (int) wpinv_decimals(),
182
-				'thousands_sep' => wpinv_thousands_separator(),
183
-				'decimals_sep'  => wpinv_decimal_separator(),
184
-				'form_items'    => getpaid()->form_elements->get_form_items( $post->ID ),
185
-				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
176
+                'elements'      => getpaid()->form_elements->get_elements(),
177
+                'form_elements' => getpaid()->form_elements->get_form_elements( $post->ID ),
178
+                'all_items'     => getpaid()->form_elements->get_published_items(),
179
+                'currency'      => wpinv_currency_symbol(),
180
+                'position'      => wpinv_currency_position(),
181
+                'decimals'      => (int) wpinv_decimals(),
182
+                'thousands_sep' => wpinv_thousands_separator(),
183
+                'decimals_sep'  => wpinv_decimal_separator(),
184
+                'form_items'    => getpaid()->form_elements->get_form_items( $post->ID ),
185
+                'is_default'    => $post->ID == wpinv_get_default_payment_form(),
186 186
             )
187 187
         );
188 188
 
@@ -191,20 +191,20 @@  discard block
 block discarded – undo
191 191
     }
192 192
 
193 193
     /**
194
-	 * Add our classes to admin pages.
194
+     * Add our classes to admin pages.
195 195
      *
196 196
      * @param string $classes
197 197
      * @return string
198
-	 *
199
-	 */
198
+     *
199
+     */
200 200
     public function admin_body_class( $classes ) {
201
-		global $pagenow, $post, $current_screen;
201
+        global $pagenow, $post, $current_screen;
202 202
 
203 203
 
204 204
         $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
205 205
 
206 206
         if ( ! empty( $current_screen->post_type ) ) {
207
-			$page = $current_screen->post_type;
207
+            $page = $current_screen->post_type;
208 208
         }
209 209
 
210 210
         if ( false !== stripos( $page, 'wpi' ) ) {
@@ -215,27 +215,27 @@  discard block
 block discarded – undo
215 215
             $classes .= ' wpinv-cpt wpinv';
216 216
         }
217 217
 
218
-		if ( $pagenow == 'post.php' && $page == 'wpi_item' && ! empty( $post ) && ! wpinv_item_is_editable( $post ) ) {
219
-			$classes .= ' wpi-editable-n';
220
-		}
218
+        if ( $pagenow == 'post.php' && $page == 'wpi_item' && ! empty( $post ) && ! wpinv_item_is_editable( $post ) ) {
219
+            $classes .= ' wpi-editable-n';
220
+        }
221 221
 
222
-		return $classes;
222
+        return $classes;
223 223
     }
224 224
 
225 225
     /**
226
-	 * Maybe show the AyeCode Connect Notice.
227
-	 */
228
-	public function init_ayecode_connect_helper(){
226
+     * Maybe show the AyeCode Connect Notice.
227
+     */
228
+    public function init_ayecode_connect_helper(){
229 229
 
230 230
         new AyeCode_Connect_Helper(
231 231
             array(
232
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
233
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
234
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
235
-				'connect_button'    => __("Connect Site","invoicing"),
236
-				'connecting_button'    => __("Connecting...","invoicing"),
237
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
238
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
232
+                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
233
+                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
234
+                'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
235
+                'connect_button'    => __("Connect Site","invoicing"),
236
+                'connecting_button'    => __("Connecting...","invoicing"),
237
+                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
238
+                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
239 239
             ),
240 240
             array( 'wpi-addons' )
241 241
         );
@@ -247,21 +247,21 @@  discard block
 block discarded – undo
247 247
      */
248 248
     public function activation_redirect() {
249 249
 
250
-		// Bail if no activation redirect.
251
-		if ( ! get_transient( '_wpinv_activation_redirect' ) || is_ajax() ) {
252
-			return;
253
-		}
250
+        // Bail if no activation redirect.
251
+        if ( ! get_transient( '_wpinv_activation_redirect' ) || is_ajax() ) {
252
+            return;
253
+        }
254 254
 
255
-		// Delete the redirect transient.
256
-		delete_transient( '_wpinv_activation_redirect' );
255
+        // Delete the redirect transient.
256
+        delete_transient( '_wpinv_activation_redirect' );
257 257
 
258
-		// Bail if activating from network, or bulk
259
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
260
-			return;
261
-		}
258
+        // Bail if activating from network, or bulk
259
+        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
260
+            return;
261
+        }
262 262
 
263
-		wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
264
-		exit;
263
+        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
264
+        exit;
265 265
     }
266 266
 
267 267
     /**
@@ -276,150 +276,150 @@  discard block
 block discarded – undo
276 276
 
277 277
     }
278 278
 
279
-	/**
279
+    /**
280 280
      * Sends a payment reminder to a customer.
281
-	 * 
282
-	 * @param array $args
281
+     * 
282
+     * @param array $args
283 283
      */
284 284
     public function send_customer_invoice( $args ) {
285
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
285
+        $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
286 286
 
287
-		if ( $sent ) {
288
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
289
-		} else {
290
-			$this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
291
-		}
287
+        if ( $sent ) {
288
+            $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
289
+        } else {
290
+            $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
291
+        }
292 292
 
293
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
294
-		exit;
295
-	}
293
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
294
+        exit;
295
+    }
296 296
 
297
-	/**
297
+    /**
298 298
      * Sends a payment reminder to a customer.
299
-	 * 
300
-	 * @param array $args
299
+     * 
300
+     * @param array $args
301 301
      */
302 302
     public function send_customer_payment_reminder( $args ) {
303
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
303
+        $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
304 304
 
305
-		if ( $sent ) {
306
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
307
-		} else {
308
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
309
-		}
305
+        if ( $sent ) {
306
+            $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
307
+        } else {
308
+            $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
309
+        }
310 310
 
311
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
312
-		exit;
313
-	}
311
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
312
+        exit;
313
+    }
314 314
 
315 315
     /**
316
-	 * Returns an array of admin notices.
317
-	 *
318
-	 * @since       1.0.19
316
+     * Returns an array of admin notices.
317
+     *
318
+     * @since       1.0.19
319 319
      * @return array
320
-	 */
321
-	public function get_notices() {
322
-		$notices = get_option( 'wpinv_admin_notices' );
320
+     */
321
+    public function get_notices() {
322
+        $notices = get_option( 'wpinv_admin_notices' );
323 323
         return is_array( $notices ) ? $notices : array();
324
-	}
325
-
326
-	/**
327
-	 * Clears all admin notices
328
-	 *
329
-	 * @access      public
330
-	 * @since       1.0.19
331
-	 */
332
-	public function clear_notices() {
333
-		delete_option( 'wpinv_admin_notices' );
334
-	}
335
-
336
-	/**
337
-	 * Saves a new admin notice
338
-	 *
339
-	 * @access      public
340
-	 * @since       1.0.19
341
-	 */
342
-	public function save_notice( $type, $message ) {
343
-		$notices = $this->get_notices();
344
-
345
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
346
-			$notices[ $type ] = array();
347
-		}
348
-
349
-		$notices[ $type ][] = $message;
350
-
351
-		update_option( 'wpinv_admin_notices', $notices );
352
-	}
353
-
354
-	/**
355
-	 * Displays a success notice
356
-	 *
357
-	 * @param       string $msg The message to qeue.
358
-	 * @access      public
359
-	 * @since       1.0.19
360
-	 */
361
-	public function show_success( $msg ) {
362
-		$this->save_notice( 'success', $msg );
363
-	}
364
-
365
-	/**
366
-	 * Displays a error notice
367
-	 *
368
-	 * @access      public
369
-	 * @param       string $msg The message to qeue.
370
-	 * @since       1.0.19
371
-	 */
372
-	public function show_error( $msg ) {
373
-		$this->save_notice( 'error', $msg );
374
-	}
375
-
376
-	/**
377
-	 * Displays a warning notice
378
-	 *
379
-	 * @access      public
380
-	 * @param       string $msg The message to qeue.
381
-	 * @since       1.0.19
382
-	 */
383
-	public function show_warning( $msg ) {
384
-		$this->save_notice( 'warning', $msg );
385
-	}
386
-
387
-	/**
388
-	 * Displays a info notice
389
-	 *
390
-	 * @access      public
391
-	 * @param       string $msg The message to qeue.
392
-	 * @since       1.0.19
393
-	 */
394
-	public function show_info( $msg ) {
395
-		$this->save_notice( 'info', $msg );
396
-	}
397
-
398
-	/**
399
-	 * Show notices
400
-	 *
401
-	 * @access      public
402
-	 * @since       1.0.19
403
-	 */
404
-	public function show_notices() {
324
+    }
325
+
326
+    /**
327
+     * Clears all admin notices
328
+     *
329
+     * @access      public
330
+     * @since       1.0.19
331
+     */
332
+    public function clear_notices() {
333
+        delete_option( 'wpinv_admin_notices' );
334
+    }
335
+
336
+    /**
337
+     * Saves a new admin notice
338
+     *
339
+     * @access      public
340
+     * @since       1.0.19
341
+     */
342
+    public function save_notice( $type, $message ) {
343
+        $notices = $this->get_notices();
344
+
345
+        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
346
+            $notices[ $type ] = array();
347
+        }
348
+
349
+        $notices[ $type ][] = $message;
350
+
351
+        update_option( 'wpinv_admin_notices', $notices );
352
+    }
353
+
354
+    /**
355
+     * Displays a success notice
356
+     *
357
+     * @param       string $msg The message to qeue.
358
+     * @access      public
359
+     * @since       1.0.19
360
+     */
361
+    public function show_success( $msg ) {
362
+        $this->save_notice( 'success', $msg );
363
+    }
364
+
365
+    /**
366
+     * Displays a error notice
367
+     *
368
+     * @access      public
369
+     * @param       string $msg The message to qeue.
370
+     * @since       1.0.19
371
+     */
372
+    public function show_error( $msg ) {
373
+        $this->save_notice( 'error', $msg );
374
+    }
375
+
376
+    /**
377
+     * Displays a warning notice
378
+     *
379
+     * @access      public
380
+     * @param       string $msg The message to qeue.
381
+     * @since       1.0.19
382
+     */
383
+    public function show_warning( $msg ) {
384
+        $this->save_notice( 'warning', $msg );
385
+    }
386
+
387
+    /**
388
+     * Displays a info notice
389
+     *
390
+     * @access      public
391
+     * @param       string $msg The message to qeue.
392
+     * @since       1.0.19
393
+     */
394
+    public function show_info( $msg ) {
395
+        $this->save_notice( 'info', $msg );
396
+    }
397
+
398
+    /**
399
+     * Show notices
400
+     *
401
+     * @access      public
402
+     * @since       1.0.19
403
+     */
404
+    public function show_notices() {
405 405
 
406 406
         $notices = $this->get_notices();
407 407
         $this->clear_notices();
408 408
 
409
-		foreach ( $notices as $type => $messages ) {
409
+        foreach ( $notices as $type => $messages ) {
410 410
 
411
-			if ( ! is_array( $messages ) ) {
412
-				continue;
413
-			}
411
+            if ( ! is_array( $messages ) ) {
412
+                continue;
413
+            }
414 414
 
415 415
             $type  = sanitize_key( $type );
416
-			foreach ( $messages as $message ) {
416
+            foreach ( $messages as $message ) {
417 417
                 $message = wp_kses_post( $message );
418
-				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
418
+                echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
419 419
             }
420 420
 
421 421
         }
422 422
 
423
-	}
423
+    }
424 424
 
425 425
 }
Please login to merge, or discard this patch.
Spacing   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * The main admin class.
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
     /**
31 31
 	 * Class constructor.
32 32
 	 */
33
-	public function __construct(){
33
+	public function __construct() {
34 34
 
35
-        $this->admin_path  = plugin_dir_path( __FILE__ );
36
-        $this->admin_url   = plugins_url( '/', __FILE__ );
35
+        $this->admin_path  = plugin_dir_path(__FILE__);
36
+        $this->admin_url   = plugins_url('/', __FILE__);
37 37
 
38
-        if ( is_admin() ) {
38
+        if (is_admin()) {
39 39
 			$this->init_admin_hooks();
40 40
         }
41 41
 
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 */
48 48
 	private function init_admin_hooks() {
49
-        add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
50
-        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
51
-        add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
52
-        add_action( 'admin_init', array( $this, 'activation_redirect') );
53
-        add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
54
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
55
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
56
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
57
-		do_action( 'getpaid_init_admin_hooks', $this );
49
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'));
50
+        add_filter('admin_body_class', array($this, 'admin_body_class'));
51
+        add_action('admin_init', array($this, 'init_ayecode_connect_helper'));
52
+        add_action('admin_init', array($this, 'activation_redirect'));
53
+        add_action('admin_init', array($this, 'maybe_do_admin_action'));
54
+		add_action('admin_notices', array($this, 'show_notices'));
55
+		add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice'));
56
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
57
+		do_action('getpaid_init_admin_hooks', $this);
58 58
 
59 59
     }
60 60
 
@@ -65,48 +65,48 @@  discard block
 block discarded – undo
65 65
 	public function enqeue_scripts() {
66 66
         global $current_screen;
67 67
 
68
-        $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
68
+        $page = isset($_GET['page']) ? $_GET['page'] : '';
69 69
 
70
-        if ( ! empty( $current_screen->post_type ) ) {
70
+        if (!empty($current_screen->post_type)) {
71 71
 			$page = $current_screen->post_type;
72 72
         }
73 73
 
74 74
         // General styles.
75
-        if ( false!== stripos( $page, 'wpi' ) ) {
75
+        if (false !== stripos($page, 'wpi')) {
76 76
 
77 77
             // Styles.
78
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
79
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
80
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
81
-            wp_enqueue_style( 'wp_enqueue_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
82
-            wp_enqueue_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16' );
78
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
79
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
80
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
81
+            wp_enqueue_style('wp_enqueue_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
82
+            wp_enqueue_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16');
83 83
 
84 84
             // Scripts.
85
-            wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '4.0.13', true );
86
-            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
85
+            wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '4.0.13', true);
86
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
87 87
 
88
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
89
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker' ),  $version );
90
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
88
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
89
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker'), $version);
90
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
91 91
 
92 92
         }
93 93
 
94 94
         // Payment form scripts.
95
-		if ( 'wpi_payment_form' == $page ) {
95
+		if ('wpi_payment_form' == $page) {
96 96
             $this->load_payment_form_scripts();
97 97
         }
98 98
 
99
-        if ( $page == 'wpinv-subscriptions' ) {
100
-			wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
101
-			wp_enqueue_script( 'wpinv-sub-admin-script' );
99
+        if ($page == 'wpinv-subscriptions') {
100
+			wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION);
101
+			wp_enqueue_script('wpinv-sub-admin-script');
102 102
 		}
103 103
 
104
-		if ( $page == 'wpinv-reports' ) {
105
-			wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' );
104
+		if ($page == 'wpinv-reports') {
105
+			wp_enqueue_script('jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array('jquery'), '0.7');
106 106
 		}
107 107
 
108
-		if ( $page == 'wpinv-subscriptions' ) {
109
-			wp_enqueue_script( 'postbox' );
108
+		if ($page == 'wpinv-subscriptions') {
109
+			wp_enqueue_script('postbox');
110 110
 		}
111 111
 
112 112
     }
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
         global $post;
120 120
 
121 121
         return array(
122
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
123
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
124
-            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
125
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
126
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
127
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
128
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
122
+            'ajax_url'                  => admin_url('admin-ajax.php'),
123
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
124
+            'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
125
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
126
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
127
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
128
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
129 129
             'tax'                       => wpinv_tax_amount(),
130 130
             'discount'                  => wpinv_discount_amount(),
131 131
             'currency_symbol'           => wpinv_currency_symbol(),
@@ -133,24 +133,24 @@  discard block
 block discarded – undo
133 133
             'thousand_sep'              => wpinv_thousands_separator(),
134 134
             'decimal_sep'               => wpinv_decimal_separator(),
135 135
             'decimals'                  => wpinv_decimals(),
136
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
137
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
138
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
139
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
140
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
141
-            'OneItemMin'                => __( 'Invoice must contain at least one item', 'invoicing' ),
142
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
143
-            'confirmCalcTotals'         => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ),
144
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
145
-            'emptyInvoice'              => __( 'Add at least one item to save invoice!', 'invoicing' ),
146
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
147
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
148
-            'action_edit'               => __( 'Edit', 'invoicing' ),
149
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
150
-            'item_description'          => __( 'Item Description', 'invoicing' ),
151
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
152
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
153
-            'searching'                 => __( 'Searching', 'invoicing' ),
136
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
137
+            'status_publish'            => wpinv_status_nicename('publish'),
138
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
139
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
140
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
141
+            'OneItemMin'                => __('Invoice must contain at least one item', 'invoicing'),
142
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
143
+            'confirmCalcTotals'         => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'),
144
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
145
+            'emptyInvoice'              => __('Add at least one item to save invoice!', 'invoicing'),
146
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
147
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
148
+            'action_edit'               => __('Edit', 'invoicing'),
149
+            'action_cancel'             => __('Cancel', 'invoicing'),
150
+            'item_description'          => __('Item Description', 'invoicing'),
151
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
152
+            'discount_description'      => __('Discount Description', 'invoicing'),
153
+            'searching'                 => __('Searching', 'invoicing'),
154 154
         );
155 155
 
156 156
     }
@@ -162,31 +162,31 @@  discard block
 block discarded – undo
162 162
 	protected function load_payment_form_scripts() {
163 163
         global $post;
164 164
 
165
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
166
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
167
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
165
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
166
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
167
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
168 168
 
169
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
170
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
169
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
170
+		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
171 171
 
172 172
 		wp_localize_script(
173 173
             'wpinv-admin-payment-form-script',
174 174
             'wpinvPaymentFormAdmin',
175 175
             array(
176 176
 				'elements'      => getpaid()->form_elements->get_elements(),
177
-				'form_elements' => getpaid()->form_elements->get_form_elements( $post->ID ),
177
+				'form_elements' => getpaid()->form_elements->get_form_elements($post->ID),
178 178
 				'all_items'     => getpaid()->form_elements->get_published_items(),
179 179
 				'currency'      => wpinv_currency_symbol(),
180 180
 				'position'      => wpinv_currency_position(),
181 181
 				'decimals'      => (int) wpinv_decimals(),
182 182
 				'thousands_sep' => wpinv_thousands_separator(),
183 183
 				'decimals_sep'  => wpinv_decimal_separator(),
184
-				'form_items'    => getpaid()->form_elements->get_form_items( $post->ID ),
184
+				'form_items'    => getpaid()->form_elements->get_form_items($post->ID),
185 185
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
186 186
             )
187 187
         );
188 188
 
189
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
189
+        wp_enqueue_script('wpinv-admin-payment-form-script');
190 190
 
191 191
     }
192 192
 
@@ -197,25 +197,25 @@  discard block
 block discarded – undo
197 197
      * @return string
198 198
 	 *
199 199
 	 */
200
-    public function admin_body_class( $classes ) {
200
+    public function admin_body_class($classes) {
201 201
 		global $pagenow, $post, $current_screen;
202 202
 
203 203
 
204
-        $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
204
+        $page = isset($_GET['page']) ? $_GET['page'] : '';
205 205
 
206
-        if ( ! empty( $current_screen->post_type ) ) {
206
+        if (!empty($current_screen->post_type)) {
207 207
 			$page = $current_screen->post_type;
208 208
         }
209 209
 
210
-        if ( false !== stripos( $page, 'wpi' ) ) {
211
-            $classes .= ' wpi-' . sanitize_key( $page );
210
+        if (false !== stripos($page, 'wpi')) {
211
+            $classes .= ' wpi-' . sanitize_key($page);
212 212
         }
213 213
 
214
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
214
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
215 215
             $classes .= ' wpinv-cpt wpinv';
216 216
         }
217 217
 
218
-		if ( $pagenow == 'post.php' && $page == 'wpi_item' && ! empty( $post ) && ! wpinv_item_is_editable( $post ) ) {
218
+		if ($pagenow == 'post.php' && $page == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
219 219
 			$classes .= ' wpi-editable-n';
220 220
 		}
221 221
 
@@ -225,19 +225,19 @@  discard block
 block discarded – undo
225 225
     /**
226 226
 	 * Maybe show the AyeCode Connect Notice.
227 227
 	 */
228
-	public function init_ayecode_connect_helper(){
228
+	public function init_ayecode_connect_helper() {
229 229
 
230 230
         new AyeCode_Connect_Helper(
231 231
             array(
232
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
233
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
234
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
235
-				'connect_button'    => __("Connect Site","invoicing"),
236
-				'connecting_button'    => __("Connecting...","invoicing"),
237
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
238
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
232
+				'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
233
+				'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
234
+				'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"),
235
+				'connect_button'    => __("Connect Site", "invoicing"),
236
+				'connecting_button'    => __("Connecting...", "invoicing"),
237
+				'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
238
+				'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
239 239
             ),
240
-            array( 'wpi-addons' )
240
+            array('wpi-addons')
241 241
         );
242 242
 
243 243
     }
@@ -248,19 +248,19 @@  discard block
 block discarded – undo
248 248
     public function activation_redirect() {
249 249
 
250 250
 		// Bail if no activation redirect.
251
-		if ( ! get_transient( '_wpinv_activation_redirect' ) || is_ajax() ) {
251
+		if (!get_transient('_wpinv_activation_redirect') || is_ajax()) {
252 252
 			return;
253 253
 		}
254 254
 
255 255
 		// Delete the redirect transient.
256
-		delete_transient( '_wpinv_activation_redirect' );
256
+		delete_transient('_wpinv_activation_redirect');
257 257
 
258 258
 		// Bail if activating from network, or bulk
259
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
259
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
260 260
 			return;
261 261
 		}
262 262
 
263
-		wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
263
+		wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
264 264
 		exit;
265 265
     }
266 266
 
@@ -269,9 +269,9 @@  discard block
 block discarded – undo
269 269
      */
270 270
     public function maybe_do_admin_action() {
271 271
 
272
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
273
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
274
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
272
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
273
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
274
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
275 275
         }
276 276
 
277 277
     }
@@ -281,16 +281,16 @@  discard block
 block discarded – undo
281 281
 	 * 
282 282
 	 * @param array $args
283 283
      */
284
-    public function send_customer_invoice( $args ) {
285
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
284
+    public function send_customer_invoice($args) {
285
+		$sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']));
286 286
 
287
-		if ( $sent ) {
288
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
287
+		if ($sent) {
288
+			$this->show_success(__('Invoice was successfully sent to the customer', 'invoicing'));
289 289
 		} else {
290
-			$this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
290
+			$this->show_error(__('Could not sent the invoice to the customer', 'invoicing'));
291 291
 		}
292 292
 
293
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
293
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
294 294
 		exit;
295 295
 	}
296 296
 
@@ -299,16 +299,16 @@  discard block
 block discarded – undo
299 299
 	 * 
300 300
 	 * @param array $args
301 301
      */
302
-    public function send_customer_payment_reminder( $args ) {
303
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
302
+    public function send_customer_payment_reminder($args) {
303
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
304 304
 
305
-		if ( $sent ) {
306
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
305
+		if ($sent) {
306
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
307 307
 		} else {
308
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
308
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
309 309
 		}
310 310
 
311
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
311
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
312 312
 		exit;
313 313
 	}
314 314
 
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
      * @return array
320 320
 	 */
321 321
 	public function get_notices() {
322
-		$notices = get_option( 'wpinv_admin_notices' );
323
-        return is_array( $notices ) ? $notices : array();
322
+		$notices = get_option('wpinv_admin_notices');
323
+        return is_array($notices) ? $notices : array();
324 324
 	}
325 325
 
326 326
 	/**
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 * @since       1.0.19
331 331
 	 */
332 332
 	public function clear_notices() {
333
-		delete_option( 'wpinv_admin_notices' );
333
+		delete_option('wpinv_admin_notices');
334 334
 	}
335 335
 
336 336
 	/**
@@ -339,16 +339,16 @@  discard block
 block discarded – undo
339 339
 	 * @access      public
340 340
 	 * @since       1.0.19
341 341
 	 */
342
-	public function save_notice( $type, $message ) {
342
+	public function save_notice($type, $message) {
343 343
 		$notices = $this->get_notices();
344 344
 
345
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
346
-			$notices[ $type ] = array();
345
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
346
+			$notices[$type] = array();
347 347
 		}
348 348
 
349
-		$notices[ $type ][] = $message;
349
+		$notices[$type][] = $message;
350 350
 
351
-		update_option( 'wpinv_admin_notices', $notices );
351
+		update_option('wpinv_admin_notices', $notices);
352 352
 	}
353 353
 
354 354
 	/**
@@ -358,8 +358,8 @@  discard block
 block discarded – undo
358 358
 	 * @access      public
359 359
 	 * @since       1.0.19
360 360
 	 */
361
-	public function show_success( $msg ) {
362
-		$this->save_notice( 'success', $msg );
361
+	public function show_success($msg) {
362
+		$this->save_notice('success', $msg);
363 363
 	}
364 364
 
365 365
 	/**
@@ -369,8 +369,8 @@  discard block
 block discarded – undo
369 369
 	 * @param       string $msg The message to qeue.
370 370
 	 * @since       1.0.19
371 371
 	 */
372
-	public function show_error( $msg ) {
373
-		$this->save_notice( 'error', $msg );
372
+	public function show_error($msg) {
373
+		$this->save_notice('error', $msg);
374 374
 	}
375 375
 
376 376
 	/**
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
 	 * @param       string $msg The message to qeue.
381 381
 	 * @since       1.0.19
382 382
 	 */
383
-	public function show_warning( $msg ) {
384
-		$this->save_notice( 'warning', $msg );
383
+	public function show_warning($msg) {
384
+		$this->save_notice('warning', $msg);
385 385
 	}
386 386
 
387 387
 	/**
@@ -391,8 +391,8 @@  discard block
 block discarded – undo
391 391
 	 * @param       string $msg The message to qeue.
392 392
 	 * @since       1.0.19
393 393
 	 */
394
-	public function show_info( $msg ) {
395
-		$this->save_notice( 'info', $msg );
394
+	public function show_info($msg) {
395
+		$this->save_notice('info', $msg);
396 396
 	}
397 397
 
398 398
 	/**
@@ -406,15 +406,15 @@  discard block
 block discarded – undo
406 406
         $notices = $this->get_notices();
407 407
         $this->clear_notices();
408 408
 
409
-		foreach ( $notices as $type => $messages ) {
409
+		foreach ($notices as $type => $messages) {
410 410
 
411
-			if ( ! is_array( $messages ) ) {
411
+			if (!is_array($messages)) {
412 412
 				continue;
413 413
 			}
414 414
 
415
-            $type  = sanitize_key( $type );
416
-			foreach ( $messages as $message ) {
417
-                $message = wp_kses_post( $message );
415
+            $type = sanitize_key($type);
416
+			foreach ($messages as $message) {
417
+                $message = wp_kses_post($message);
418 418
 				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
419 419
             }
420 420
 
Please login to merge, or discard this patch.
includes/admin/wpinv-upgrade-functions.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -11,55 +11,55 @@  discard block
 block discarded – undo
11 11
  * @since 1.0.0
12 12
 */
13 13
 function wpinv_automatic_upgrade() {
14
-    $wpi_version = get_option( 'wpinv_version' );
14
+    $wpi_version = get_option('wpinv_version');
15 15
 
16 16
     // Update tables.
17
-    if ( ! get_option( 'getpaid_created_invoice_tables' ) ) {
17
+    if (!get_option('getpaid_created_invoice_tables')) {
18 18
         wpinv_v119_upgrades();
19
-        update_option( 'getpaid_created_invoice_tables', true );
19
+        update_option('getpaid_created_invoice_tables', true);
20 20
     }
21 21
 
22
-    if ( $wpi_version == WPINV_VERSION ) {
22
+    if ($wpi_version == WPINV_VERSION) {
23 23
         return;
24 24
     }
25 25
 
26
-    if ( version_compare( $wpi_version, '0.0.5', '<' ) ) {
26
+    if (version_compare($wpi_version, '0.0.5', '<')) {
27 27
         wpinv_v005_upgrades();
28 28
     }
29 29
 
30
-    if ( version_compare( $wpi_version, '1.0.3', '<' ) ) {
30
+    if (version_compare($wpi_version, '1.0.3', '<')) {
31 31
         wpinv_v110_upgrades();
32 32
     }
33 33
 
34
-    update_option( 'wpinv_version', WPINV_VERSION );
34
+    update_option('wpinv_version', WPINV_VERSION);
35 35
 }
36
-add_action( 'admin_init', 'wpinv_automatic_upgrade' );
36
+add_action('admin_init', 'wpinv_automatic_upgrade');
37 37
 
38 38
 function wpinv_v005_upgrades() {
39 39
     global $wpdb;
40 40
 
41 41
     // Invoices status
42
-    $results = $wpdb->get_results( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
43
-    if ( !empty( $results ) ) {
44
-        $wpdb->query( "UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
42
+    $results = $wpdb->get_results("SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
43
+    if (!empty($results)) {
44
+        $wpdb->query("UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
45 45
 
46 46
         // Clean post cache
47
-        foreach ( $results as $row ) {
48
-            clean_post_cache( $row->ID );
47
+        foreach ($results as $row) {
48
+            clean_post_cache($row->ID);
49 49
         }
50 50
     }
51 51
 
52 52
     // Item meta key changes
53 53
     $query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
54
-    $results = $wpdb->get_results( $query );
54
+    $results = $wpdb->get_results($query);
55 55
 
56
-    if ( !empty( $results ) ) {
57
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
58
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
59
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
56
+    if (!empty($results)) {
57
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )");
58
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'");
59
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'");
60 60
         
61
-        foreach ( $results as $row ) {
62
-            clean_post_cache( $row->post_id );
61
+        foreach ($results as $row) {
62
+            clean_post_cache($row->post_id);
63 63
         }
64 64
     }
65 65
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 function wpinv_create_invoices_table() {
89 89
     global $wpdb;
90 90
 
91
-    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
91
+    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
92 92
 
93 93
     // Create invoices table.
94 94
     $table = $wpdb->prefix . 'getpaid_invoices';
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
             KEY `key` ( `key` )
133 133
             ) CHARACTER SET utf8 COLLATE utf8_general_ci;";
134 134
 
135
-    dbDelta( $sql );
135
+    dbDelta($sql);
136 136
 
137 137
     // Create invoice items table.
138 138
     $table = $wpdb->prefix . 'getpaid_invoice_items';
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
             KEY post_id ( post_id )
161 161
             ) CHARACTER SET utf8 COLLATE utf8_general_ci;";
162 162
 
163
-    dbDelta( $sql );
163
+    dbDelta($sql);
164 164
 }
165 165
 
166 166
 /**
@@ -172,29 +172,29 @@  discard block
 block discarded – undo
172 172
     $invoices = array_unique(
173 173
         get_posts(
174 174
             array(
175
-                'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
175
+                'post_type'      => array('wpi_invoice', 'wpi_quote'),
176 176
                 'posts_per_page' => -1,
177 177
                 'fields'         => 'ids',
178
-                'post_status'    => array_keys( wpinv_get_invoice_statuses( true ) ),
178
+                'post_status'    => array_keys(wpinv_get_invoice_statuses(true)),
179 179
             )
180 180
         )
181 181
     );
182 182
     $invoices_table = $wpdb->prefix . 'getpaid_invoices';
183 183
     $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
184 184
 
185
-    if ( ! class_exists( 'WPInv_Legacy_Invoice' ) ) {
186
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php' );
185
+    if (!class_exists('WPInv_Legacy_Invoice')) {
186
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php');
187 187
     }
188 188
 
189 189
     $invoice_rows = array();
190
-    foreach ( $invoices as $invoice ) {
190
+    foreach ($invoices as $invoice) {
191 191
 
192
-        $invoice = new WPInv_Legacy_Invoice( $invoice );
193
-        $fields = array (
192
+        $invoice = new WPInv_Legacy_Invoice($invoice);
193
+        $fields = array(
194 194
             'post_id'        => $invoice->ID,
195 195
             'number'         => $invoice->get_number(),
196 196
             'key'            => $invoice->get_key(),
197
-            'type'           => str_replace( 'wpi_', '', $invoice->post_type ),
197
+            'type'           => str_replace('wpi_', '', $invoice->post_type),
198 198
             'mode'           => $invoice->mode,
199 199
             'user_ip'        => $invoice->get_ip(),
200 200
             'first_name'     => $invoice->get_first_name(),
@@ -223,27 +223,27 @@  discard block
 block discarded – undo
223 223
             'custom_meta'    => $invoice->payment_meta
224 224
         );
225 225
 
226
-        foreach ( $fields as $key => $val ) {
227
-            if ( is_null( $val ) ) {
226
+        foreach ($fields as $key => $val) {
227
+            if (is_null($val)) {
228 228
                 $val = '';
229 229
             }
230
-            $val = maybe_serialize( $val );
231
-            $fields[ $key ] = $wpdb->prepare( '%s', $val );
230
+            $val = maybe_serialize($val);
231
+            $fields[$key] = $wpdb->prepare('%s', $val);
232 232
         }
233 233
 
234
-        $fields = implode( ', ', $fields );
234
+        $fields = implode(', ', $fields);
235 235
         $invoice_rows[] = "($fields)";
236 236
 
237 237
         $item_rows    = array();
238 238
         $item_columns = array();
239
-        foreach ( $invoice->get_cart_details() as $details ) {
239
+        foreach ($invoice->get_cart_details() as $details) {
240 240
             $fields = array(
241 241
                 'post_id'          => $invoice->ID,
242 242
                 'item_id'          => $details['id'],
243 243
                 'item_name'        => $details['name'],
244
-                'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
244
+                'item_description' => empty($details['meta']['description']) ? '' : $details['meta']['description'],
245 245
                 'vat_rate'         => $details['vat_rate'],
246
-                'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
246
+                'vat_class'        => empty($details['vat_class']) ? '_standard' : $details['vat_class'],
247 247
                 'tax'              => $details['tax'],
248 248
                 'item_price'       => $details['item_price'],
249 249
                 'custom_price'     => $details['custom_price'],
@@ -255,26 +255,26 @@  discard block
 block discarded – undo
255 255
                 'fees'             => $details['fees'],
256 256
             );
257 257
 
258
-            $item_columns = array_keys ( $fields );
258
+            $item_columns = array_keys($fields);
259 259
 
260
-            foreach ( $fields as $key => $val ) {
261
-                if ( is_null( $val ) ) {
260
+            foreach ($fields as $key => $val) {
261
+                if (is_null($val)) {
262 262
                     $val = '';
263 263
                 }
264
-                $val = maybe_serialize( $val );
265
-                $fields[ $key ] = $wpdb->prepare( '%s', $val );
264
+                $val = maybe_serialize($val);
265
+                $fields[$key] = $wpdb->prepare('%s', $val);
266 266
             }
267 267
 
268
-            $fields = implode( ', ', $fields );
268
+            $fields = implode(', ', $fields);
269 269
             $item_rows[] = "($fields)";
270 270
         }
271 271
 
272
-        $item_rows    = implode( ', ', $item_rows );
273
-        $item_columns = implode( ', ', $item_columns );
274
-        $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
272
+        $item_rows    = implode(', ', $item_rows);
273
+        $item_columns = implode(', ', $item_columns);
274
+        $wpdb->query("INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows");
275 275
     }
276 276
 
277
-    $invoice_rows = implode( ', ', $invoice_rows );
278
-    $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
277
+    $invoice_rows = implode(', ', $invoice_rows);
278
+    $wpdb->query("INSERT INTO $invoices_table VALUES $invoice_rows");
279 279
 
280 280
 }
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 2 patches
Indentation   +2300 added lines, -2300 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,
@@ -79,21 +79,21 @@  discard block
 block discarded – undo
79 79
         'transaction_id'       => '',
80 80
         'currency'             => '',
81 81
         'disable_taxes'        => false,
82
-		'subscription_id'      => null,
83
-		'remote_subscription_id' => null,
84
-		'is_viewed'            => false,
85
-		'email_cc'             => '',
86
-		'template'             => 'quantity', // hours, amount only
82
+        'subscription_id'      => null,
83
+        'remote_subscription_id' => null,
84
+        'is_viewed'            => false,
85
+        'email_cc'             => '',
86
+        'template'             => 'quantity', // hours, amount only
87 87
     );
88 88
 
89 89
     /**
90
-	 * Stores meta in cache for future reads.
91
-	 *
92
-	 * A group must be set to to enable caching.
93
-	 *
94
-	 * @var string
95
-	 */
96
-	protected $cache_group = 'getpaid_invoices';
90
+     * Stores meta in cache for future reads.
91
+     *
92
+     * A group must be set to to enable caching.
93
+     *
94
+     * @var string
95
+     */
96
+    protected $cache_group = 'getpaid_invoices';
97 97
 
98 98
     /**
99 99
      * Stores a reference to the original WP_Post object
@@ -107,104 +107,104 @@  discard block
 block discarded – undo
107 107
      *
108 108
      * @var int
109 109
      */
110
-	protected $recurring_item = null;
110
+    protected $recurring_item = null;
111 111
 
112
-	/**
112
+    /**
113 113
      * Stores an array of item totals.
114
-	 *
115
-	 * e.g $totals['discount'] = array(
116
-	 * 		'initial'   => 10,
117
-	 * 		'recurring' => 10,
118
-	 * )
114
+     *
115
+     * e.g $totals['discount'] = array(
116
+     * 		'initial'   => 10,
117
+     * 		'recurring' => 10,
118
+     * )
119 119
      *
120 120
      * @var array
121 121
      */
122
-	protected $totals = array();
122
+    protected $totals = array();
123 123
 
124
-	/**
125
-	 * Stores the status transition information.
126
-	 *
127
-	 * @since 1.0.19
128
-	 * @var bool
129
-	 */
130
-	protected $status_transition = false;
124
+    /**
125
+     * Stores the status transition information.
126
+     *
127
+     * @since 1.0.19
128
+     * @var bool
129
+     */
130
+    protected $status_transition = false;
131 131
 
132 132
     /**
133
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
134
-	 *
135
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
136
-	 */
133
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
134
+     *
135
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
136
+     */
137 137
     public function __construct( $invoice = false ) {
138 138
 
139 139
         parent::__construct( $invoice );
140 140
 
141
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
142
-			$this->set_id( $invoice );
143
-		} elseif ( $invoice instanceof self ) {
144
-			$this->set_id( $invoice->get_id() );
145
-		} elseif ( ! empty( $invoice->ID ) ) {
146
-			$this->set_id( $invoice->ID );
147
-		} elseif ( is_array( $invoice ) ) {
148
-			$this->set_props( $invoice );
149
-
150
-			if ( isset( $invoice['ID'] ) ) {
151
-				$this->set_id( $invoice['ID'] );
152
-			}
153
-
154
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
155
-			$this->set_id( $invoice_id );
156
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
157
-			$this->set_id( $invoice_id );
158
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
159
-			$this->set_id( $invoice_id );
160
-		}else {
161
-			$this->set_object_read( true );
162
-		}
141
+        if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
142
+            $this->set_id( $invoice );
143
+        } elseif ( $invoice instanceof self ) {
144
+            $this->set_id( $invoice->get_id() );
145
+        } elseif ( ! empty( $invoice->ID ) ) {
146
+            $this->set_id( $invoice->ID );
147
+        } elseif ( is_array( $invoice ) ) {
148
+            $this->set_props( $invoice );
149
+
150
+            if ( isset( $invoice['ID'] ) ) {
151
+                $this->set_id( $invoice['ID'] );
152
+            }
153
+
154
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
155
+            $this->set_id( $invoice_id );
156
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
157
+            $this->set_id( $invoice_id );
158
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
159
+            $this->set_id( $invoice_id );
160
+        }else {
161
+            $this->set_object_read( true );
162
+        }
163 163
 
164 164
         // Load the datastore.
165
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
165
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
166 166
 
167
-		if ( $this->get_id() > 0 ) {
167
+        if ( $this->get_id() > 0 ) {
168 168
             $this->post = get_post( $this->get_id() );
169 169
             $this->ID   = $this->get_id();
170
-			$this->data_store->read( $this );
170
+            $this->data_store->read( $this );
171 171
         }
172 172
 
173 173
     }
174 174
 
175 175
     /**
176
-	 * Given an invoice key/number, it returns its id.
177
-	 *
178
-	 *
179
-	 * @static
180
-	 * @param string $value The invoice key or number
181
-	 * @param string $field Either key, transaction_id or number.
182
-	 * @since 1.0.15
183
-	 * @return int
184
-	 */
185
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
176
+     * Given an invoice key/number, it returns its id.
177
+     *
178
+     *
179
+     * @static
180
+     * @param string $value The invoice key or number
181
+     * @param string $field Either key, transaction_id or number.
182
+     * @since 1.0.15
183
+     * @return int
184
+     */
185
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
186 186
         global $wpdb;
187 187
 
188
-		// Trim the value.
189
-		$value = trim( $value );
188
+        // Trim the value.
189
+        $value = trim( $value );
190 190
 
191
-		if ( empty( $value ) ) {
192
-			return 0;
193
-		}
191
+        if ( empty( $value ) ) {
192
+            return 0;
193
+        }
194 194
 
195 195
         // Valid fields.
196 196
         $fields = array( 'key', 'number', 'transaction_id' );
197 197
 
198
-		// Ensure a field has been passed.
199
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
200
-			return 0;
201
-		}
198
+        // Ensure a field has been passed.
199
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
200
+            return 0;
201
+        }
202 202
 
203
-		// Maybe retrieve from the cache.
204
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
205
-		if ( false !== $invoice_id ) {
206
-			return $invoice_id;
207
-		}
203
+        // Maybe retrieve from the cache.
204
+        $invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
205
+        if ( false !== $invoice_id ) {
206
+            return $invoice_id;
207
+        }
208 208
 
209 209
         // Fetch from the db.
210 210
         $table       = $wpdb->prefix . 'getpaid_invoices';
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
213 213
         );
214 214
 
215
-		// Update the cache with our data
216
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
215
+        // Update the cache with our data
216
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
217 217
 
218
-		return $invoice_id;
218
+        return $invoice_id;
219 219
     }
220 220
 
221 221
     /**
@@ -241,80 +241,80 @@  discard block
 block discarded – undo
241 241
     */
242 242
 
243 243
     /**
244
-	 * Get parent invoice ID.
245
-	 *
246
-	 * @since 1.0.19
247
-	 * @param  string $context View or edit context.
248
-	 * @return int
249
-	 */
250
-	public function get_parent_id( $context = 'view' ) {
251
-		return (int) $this->get_prop( 'parent_id', $context );
244
+     * Get parent invoice ID.
245
+     *
246
+     * @since 1.0.19
247
+     * @param  string $context View or edit context.
248
+     * @return int
249
+     */
250
+    public function get_parent_id( $context = 'view' ) {
251
+        return (int) $this->get_prop( 'parent_id', $context );
252 252
     }
253 253
 
254 254
     /**
255
-	 * Get parent invoice.
256
-	 *
257
-	 * @since 1.0.19
258
-	 * @return WPInv_Invoice
259
-	 */
255
+     * Get parent invoice.
256
+     *
257
+     * @since 1.0.19
258
+     * @return WPInv_Invoice
259
+     */
260 260
     public function get_parent_payment() {
261 261
         return new WPInv_Invoice( $this->get_parent_id() );
262 262
     }
263 263
 
264 264
     /**
265
-	 * Alias for self::get_parent_payment().
266
-	 *
267
-	 * @since 1.0.19
268
-	 * @return WPInv_Invoice
269
-	 */
265
+     * Alias for self::get_parent_payment().
266
+     *
267
+     * @since 1.0.19
268
+     * @return WPInv_Invoice
269
+     */
270 270
     public function get_parent() {
271 271
         return $this->get_parent_payment();
272 272
     }
273 273
 
274 274
     /**
275
-	 * Get invoice status.
276
-	 *
277
-	 * @since 1.0.19
278
-	 * @param  string $context View or edit context.
279
-	 * @return string
280
-	 */
281
-	public function get_status( $context = 'view' ) {
282
-		return $this->get_prop( 'status', $context );
283
-	}
275
+     * Get invoice status.
276
+     *
277
+     * @since 1.0.19
278
+     * @param  string $context View or edit context.
279
+     * @return string
280
+     */
281
+    public function get_status( $context = 'view' ) {
282
+        return $this->get_prop( 'status', $context );
283
+    }
284 284
 	
285
-	/**
286
-	 * Retrieves an array of possible invoice statuses.
287
-	 *
288
-	 * @since 1.0.19
289
-	 * @return array
290
-	 */
291
-	public function get_all_statuses() {
292
-
293
-		$statuses = wpinv_get_invoice_statuses( true, true, $this );
294
-
295
-		// For backwards compatibility.
296
-		if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
285
+    /**
286
+     * Retrieves an array of possible invoice statuses.
287
+     *
288
+     * @since 1.0.19
289
+     * @return array
290
+     */
291
+    public function get_all_statuses() {
292
+
293
+        $statuses = wpinv_get_invoice_statuses( true, true, $this );
294
+
295
+        // For backwards compatibility.
296
+        if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
297 297
             $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
298
-		}
298
+        }
299 299
 
300
-		return $statuses;
300
+        return $statuses;
301 301
     }
302 302
 
303 303
     /**
304
-	 * Get invoice status nice name.
305
-	 *
306
-	 * @since 1.0.19
307
-	 * @return string
308
-	 */
304
+     * Get invoice status nice name.
305
+     *
306
+     * @since 1.0.19
307
+     * @return string
308
+     */
309 309
     public function get_status_nicename() {
310
-		$statuses = $this->get_all_statuses();
310
+        $statuses = $this->get_all_statuses();
311 311
 
312 312
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
313 313
 
314 314
         return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
315 315
     }
316 316
 
317
-	/**
317
+    /**
318 318
      * Retrieves the invoice status label html
319 319
      *
320 320
      * @since  1.0.0
@@ -322,262 +322,262 @@  discard block
 block discarded – undo
322 322
      */
323 323
     public function get_status_label_html() {
324 324
 
325
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
326
-		$status       = sanitize_html_class( $this->get_status() );
325
+        $status_label = sanitize_text_field( $this->get_status_nicename() );
326
+        $status       = sanitize_html_class( $this->get_status() );
327 327
 
328
-		return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
329
-	}
328
+        return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
329
+    }
330 330
 
331 331
     /**
332
-	 * Get plugin version when the invoice was created.
333
-	 *
334
-	 * @since 1.0.19
335
-	 * @param  string $context View or edit context.
336
-	 * @return string
337
-	 */
338
-	public function get_version( $context = 'view' ) {
339
-		return $this->get_prop( 'version', $context );
340
-	}
332
+     * Get plugin version when the invoice was created.
333
+     *
334
+     * @since 1.0.19
335
+     * @param  string $context View or edit context.
336
+     * @return string
337
+     */
338
+    public function get_version( $context = 'view' ) {
339
+        return $this->get_prop( 'version', $context );
340
+    }
341 341
 
342
-	/**
343
-	 * @deprecated
344
-	 */
345
-	public function get_invoice_date( $format = true ) {
346
-		$date      = getpaid_format_date( $this->get_date_completed() );
347
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
348
-		$formatted = getpaid_format_date( $date );
342
+    /**
343
+     * @deprecated
344
+     */
345
+    public function get_invoice_date( $format = true ) {
346
+        $date      = getpaid_format_date( $this->get_date_completed() );
347
+        $date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
348
+        $formatted = getpaid_format_date( $date );
349 349
 
350
-		if ( $format ) {
351
-			return $formatted;
352
-		}
350
+        if ( $format ) {
351
+            return $formatted;
352
+        }
353 353
 
354
-		return empty( $formatted ) ? '' : $date;
354
+        return empty( $formatted ) ? '' : $date;
355 355
 
356 356
     }
357 357
 
358 358
     /**
359
-	 * Get date when the invoice was created.
360
-	 *
361
-	 * @since 1.0.19
362
-	 * @param  string $context View or edit context.
363
-	 * @return string
364
-	 */
365
-	public function get_date_created( $context = 'view' ) {
366
-		return $this->get_prop( 'date_created', $context );
367
-	}
359
+     * Get date when the invoice was created.
360
+     *
361
+     * @since 1.0.19
362
+     * @param  string $context View or edit context.
363
+     * @return string
364
+     */
365
+    public function get_date_created( $context = 'view' ) {
366
+        return $this->get_prop( 'date_created', $context );
367
+    }
368 368
 	
369
-	/**
370
-	 * Alias for self::get_date_created().
371
-	 *
372
-	 * @since 1.0.19
373
-	 * @param  string $context View or edit context.
374
-	 * @return string
375
-	 */
376
-	public function get_created_date( $context = 'view' ) {
377
-		return $this->get_date_created( $context );
378
-    }
379
-
380
-    /**
381
-	 * Get GMT date when the invoice was created.
382
-	 *
383
-	 * @since 1.0.19
384
-	 * @param  string $context View or edit context.
385
-	 * @return string
386
-	 */
387
-	public function get_date_created_gmt( $context = 'view' ) {
369
+    /**
370
+     * Alias for self::get_date_created().
371
+     *
372
+     * @since 1.0.19
373
+     * @param  string $context View or edit context.
374
+     * @return string
375
+     */
376
+    public function get_created_date( $context = 'view' ) {
377
+        return $this->get_date_created( $context );
378
+    }
379
+
380
+    /**
381
+     * Get GMT date when the invoice was created.
382
+     *
383
+     * @since 1.0.19
384
+     * @param  string $context View or edit context.
385
+     * @return string
386
+     */
387
+    public function get_date_created_gmt( $context = 'view' ) {
388 388
         $date = $this->get_date_created( $context );
389 389
 
390 390
         if ( $date ) {
391 391
             $date = get_gmt_from_date( $date );
392 392
         }
393
-		return $date;
393
+        return $date;
394 394
     }
395 395
 
396 396
     /**
397
-	 * Get date when the invoice was last modified.
398
-	 *
399
-	 * @since 1.0.19
400
-	 * @param  string $context View or edit context.
401
-	 * @return string
402
-	 */
403
-	public function get_date_modified( $context = 'view' ) {
404
-		return $this->get_prop( 'date_modified', $context );
405
-	}
397
+     * Get date when the invoice was last modified.
398
+     *
399
+     * @since 1.0.19
400
+     * @param  string $context View or edit context.
401
+     * @return string
402
+     */
403
+    public function get_date_modified( $context = 'view' ) {
404
+        return $this->get_prop( 'date_modified', $context );
405
+    }
406 406
 
407
-	/**
408
-	 * Alias for self::get_date_modified().
409
-	 *
410
-	 * @since 1.0.19
411
-	 * @param  string $context View or edit context.
412
-	 * @return string
413
-	 */
414
-	public function get_modified_date( $context = 'view' ) {
415
-		return $this->get_date_modified( $context );
407
+    /**
408
+     * Alias for self::get_date_modified().
409
+     *
410
+     * @since 1.0.19
411
+     * @param  string $context View or edit context.
412
+     * @return string
413
+     */
414
+    public function get_modified_date( $context = 'view' ) {
415
+        return $this->get_date_modified( $context );
416 416
     }
417 417
 
418 418
     /**
419
-	 * Get GMT date when the invoice was last modified.
420
-	 *
421
-	 * @since 1.0.19
422
-	 * @param  string $context View or edit context.
423
-	 * @return string
424
-	 */
425
-	public function get_date_modified_gmt( $context = 'view' ) {
419
+     * Get GMT date when the invoice was last modified.
420
+     *
421
+     * @since 1.0.19
422
+     * @param  string $context View or edit context.
423
+     * @return string
424
+     */
425
+    public function get_date_modified_gmt( $context = 'view' ) {
426 426
         $date = $this->get_date_modified( $context );
427 427
 
428 428
         if ( $date ) {
429 429
             $date = get_gmt_from_date( $date );
430 430
         }
431
-		return $date;
431
+        return $date;
432 432
     }
433 433
 
434 434
     /**
435
-	 * Get the invoice due date.
436
-	 *
437
-	 * @since 1.0.19
438
-	 * @param  string $context View or edit context.
439
-	 * @return string
440
-	 */
441
-	public function get_due_date( $context = 'view' ) {
442
-		return $this->get_prop( 'due_date', $context );
435
+     * Get the invoice due date.
436
+     *
437
+     * @since 1.0.19
438
+     * @param  string $context View or edit context.
439
+     * @return string
440
+     */
441
+    public function get_due_date( $context = 'view' ) {
442
+        return $this->get_prop( 'due_date', $context );
443 443
     }
444 444
 
445 445
     /**
446
-	 * Alias for self::get_due_date().
447
-	 *
448
-	 * @since 1.0.19
449
-	 * @param  string $context View or edit context.
450
-	 * @return string
451
-	 */
452
-	public function get_date_due( $context = 'view' ) {
453
-		return $this->get_due_date( $context );
446
+     * Alias for self::get_due_date().
447
+     *
448
+     * @since 1.0.19
449
+     * @param  string $context View or edit context.
450
+     * @return string
451
+     */
452
+    public function get_date_due( $context = 'view' ) {
453
+        return $this->get_due_date( $context );
454 454
     }
455 455
 
456 456
     /**
457
-	 * Get the invoice GMT due date.
458
-	 *
459
-	 * @since 1.0.19
460
-	 * @param  string $context View or edit context.
461
-	 * @return string
462
-	 */
463
-	public function get_due_date_gmt( $context = 'view' ) {
457
+     * Get the invoice GMT due date.
458
+     *
459
+     * @since 1.0.19
460
+     * @param  string $context View or edit context.
461
+     * @return string
462
+     */
463
+    public function get_due_date_gmt( $context = 'view' ) {
464 464
         $date = $this->get_due_date( $context );
465 465
 
466 466
         if ( $date ) {
467 467
             $date = get_gmt_from_date( $date );
468 468
         }
469
-		return $date;
469
+        return $date;
470 470
     }
471 471
 
472 472
     /**
473
-	 * Alias for self::get_due_date_gmt().
474
-	 *
475
-	 * @since 1.0.19
476
-	 * @param  string $context View or edit context.
477
-	 * @return string
478
-	 */
479
-	public function get_gmt_date_due( $context = 'view' ) {
480
-		return $this->get_due_date_gmt( $context );
473
+     * Alias for self::get_due_date_gmt().
474
+     *
475
+     * @since 1.0.19
476
+     * @param  string $context View or edit context.
477
+     * @return string
478
+     */
479
+    public function get_gmt_date_due( $context = 'view' ) {
480
+        return $this->get_due_date_gmt( $context );
481 481
     }
482 482
 
483 483
     /**
484
-	 * Get date when the invoice was completed.
485
-	 *
486
-	 * @since 1.0.19
487
-	 * @param  string $context View or edit context.
488
-	 * @return string
489
-	 */
490
-	public function get_completed_date( $context = 'view' ) {
491
-		return $this->get_prop( 'completed_date', $context );
484
+     * Get date when the invoice was completed.
485
+     *
486
+     * @since 1.0.19
487
+     * @param  string $context View or edit context.
488
+     * @return string
489
+     */
490
+    public function get_completed_date( $context = 'view' ) {
491
+        return $this->get_prop( 'completed_date', $context );
492 492
     }
493 493
 
494 494
     /**
495
-	 * Alias for self::get_completed_date().
496
-	 *
497
-	 * @since 1.0.19
498
-	 * @param  string $context View or edit context.
499
-	 * @return string
500
-	 */
501
-	public function get_date_completed( $context = 'view' ) {
502
-		return $this->get_completed_date( $context );
495
+     * Alias for self::get_completed_date().
496
+     *
497
+     * @since 1.0.19
498
+     * @param  string $context View or edit context.
499
+     * @return string
500
+     */
501
+    public function get_date_completed( $context = 'view' ) {
502
+        return $this->get_completed_date( $context );
503 503
     }
504 504
 
505 505
     /**
506
-	 * Get GMT date when the invoice was was completed.
507
-	 *
508
-	 * @since 1.0.19
509
-	 * @param  string $context View or edit context.
510
-	 * @return string
511
-	 */
512
-	public function get_completed_date_gmt( $context = 'view' ) {
506
+     * Get GMT date when the invoice was was completed.
507
+     *
508
+     * @since 1.0.19
509
+     * @param  string $context View or edit context.
510
+     * @return string
511
+     */
512
+    public function get_completed_date_gmt( $context = 'view' ) {
513 513
         $date = $this->get_completed_date( $context );
514 514
 
515 515
         if ( $date ) {
516 516
             $date = get_gmt_from_date( $date );
517 517
         }
518
-		return $date;
518
+        return $date;
519 519
     }
520 520
 
521 521
     /**
522
-	 * Alias for self::get_completed_date_gmt().
523
-	 *
524
-	 * @since 1.0.19
525
-	 * @param  string $context View or edit context.
526
-	 * @return string
527
-	 */
528
-	public function get_gmt_completed_date( $context = 'view' ) {
529
-		return $this->get_completed_date_gmt( $context );
522
+     * Alias for self::get_completed_date_gmt().
523
+     *
524
+     * @since 1.0.19
525
+     * @param  string $context View or edit context.
526
+     * @return string
527
+     */
528
+    public function get_gmt_completed_date( $context = 'view' ) {
529
+        return $this->get_completed_date_gmt( $context );
530 530
     }
531 531
 
532 532
     /**
533
-	 * Get the invoice number.
534
-	 *
535
-	 * @since 1.0.19
536
-	 * @param  string $context View or edit context.
537
-	 * @return string
538
-	 */
539
-	public function get_number( $context = 'view' ) {
540
-		$number = $this->get_prop( 'number', $context );
533
+     * Get the invoice number.
534
+     *
535
+     * @since 1.0.19
536
+     * @param  string $context View or edit context.
537
+     * @return string
538
+     */
539
+    public function get_number( $context = 'view' ) {
540
+        $number = $this->get_prop( 'number', $context );
541 541
 
542
-		if ( empty( $number ) ) {
543
-			$number = $this->generate_number();
544
-			$this->set_number( $this->generate_number() );
545
-		}
542
+        if ( empty( $number ) ) {
543
+            $number = $this->generate_number();
544
+            $this->set_number( $this->generate_number() );
545
+        }
546 546
 
547
-		return $number;
547
+        return $number;
548 548
     }
549 549
 
550
-	/**
551
-	 * Set the invoice number.
552
-	 *
553
-	 * @since 1.0.19
554
-	 */
555
-	public function maybe_set_number() {
550
+    /**
551
+     * Set the invoice number.
552
+     *
553
+     * @since 1.0.19
554
+     */
555
+    public function maybe_set_number() {
556 556
         $number = $this->get_number();
557 557
 
558 558
         if ( empty( $number ) || $this->get_id() == $number ) {
559
-			$this->set_number( $this->generate_number() );
559
+            $this->set_number( $this->generate_number() );
560 560
         }
561 561
 
562
-	}
562
+    }
563 563
 
564 564
     /**
565
-	 * Get the invoice key.
566
-	 *
567
-	 * @since 1.0.19
568
-	 * @param  string $context View or edit context.
569
-	 * @return string
570
-	 */
571
-	public function get_key( $context = 'view' ) {
565
+     * Get the invoice key.
566
+     *
567
+     * @since 1.0.19
568
+     * @param  string $context View or edit context.
569
+     * @return string
570
+     */
571
+    public function get_key( $context = 'view' ) {
572 572
         return $this->get_prop( 'key', $context );
573
-	}
574
-
575
-	/**
576
-	 * Set the invoice key.
577
-	 *
578
-	 * @since 1.0.19
579
-	 */
580
-	public function maybe_set_key() {
573
+    }
574
+
575
+    /**
576
+     * Set the invoice key.
577
+     *
578
+     * @since 1.0.19
579
+     */
580
+    public function maybe_set_key() {
581 581
         $key = $this->get_key();
582 582
 
583 583
         if ( empty( $key ) ) {
@@ -588,126 +588,126 @@  discard block
 block discarded – undo
588 588
     }
589 589
 
590 590
     /**
591
-	 * Get the invoice type.
592
-	 *
593
-	 * @since 1.0.19
594
-	 * @param  string $context View or edit context.
595
-	 * @return string
596
-	 */
597
-	public function get_type( $context = 'view' ) {
591
+     * Get the invoice type.
592
+     *
593
+     * @since 1.0.19
594
+     * @param  string $context View or edit context.
595
+     * @return string
596
+     */
597
+    public function get_type( $context = 'view' ) {
598 598
         return $this->get_prop( 'type', $context );
599
-	}
599
+    }
600 600
 
601
-	/**
602
-	 * @deprecated
603
-	 */
604
-	public function get_invoice_quote_type() {
601
+    /**
602
+     * @deprecated
603
+     */
604
+    public function get_invoice_quote_type() {
605 605
         ucfirst( $this->get_type() );
606 606
     }
607 607
 
608 608
     /**
609
-	 * Get the invoice post type.
610
-	 *
611
-	 * @since 1.0.19
612
-	 * @param  string $context View or edit context.
613
-	 * @return string
614
-	 */
615
-	public function get_post_type( $context = 'view' ) {
609
+     * Get the invoice post type.
610
+     *
611
+     * @since 1.0.19
612
+     * @param  string $context View or edit context.
613
+     * @return string
614
+     */
615
+    public function get_post_type( $context = 'view' ) {
616 616
         return $this->get_prop( 'post_type', $context );
617 617
     }
618 618
 
619 619
     /**
620
-	 * Get the invoice mode.
621
-	 *
622
-	 * @since 1.0.19
623
-	 * @param  string $context View or edit context.
624
-	 * @return string
625
-	 */
626
-	public function get_mode( $context = 'view' ) {
620
+     * Get the invoice mode.
621
+     *
622
+     * @since 1.0.19
623
+     * @param  string $context View or edit context.
624
+     * @return string
625
+     */
626
+    public function get_mode( $context = 'view' ) {
627 627
         return $this->get_prop( 'mode', $context );
628 628
     }
629 629
 
630 630
     /**
631
-	 * Get the invoice path.
632
-	 *
633
-	 * @since 1.0.19
634
-	 * @param  string $context View or edit context.
635
-	 * @return string
636
-	 */
637
-	public function get_path( $context = 'view' ) {
631
+     * Get the invoice path.
632
+     *
633
+     * @since 1.0.19
634
+     * @param  string $context View or edit context.
635
+     * @return string
636
+     */
637
+    public function get_path( $context = 'view' ) {
638 638
         $path   = $this->get_prop( 'path', $context );
639
-		$prefix = wpinv_post_name_prefix( $this->get_post_type() );
639
+        $prefix = wpinv_post_name_prefix( $this->get_post_type() );
640 640
 
641
-		if ( 0 !== strpos( $path, $prefix ) ) {
642
-			$path = sanitize_title(  $prefix . $this->get_id()  );
643
-			$this->set_path( $path );
644
-		}
641
+        if ( 0 !== strpos( $path, $prefix ) ) {
642
+            $path = sanitize_title(  $prefix . $this->get_id()  );
643
+            $this->set_path( $path );
644
+        }
645 645
 
646
-		return $path;
646
+        return $path;
647 647
     }
648 648
 
649 649
     /**
650
-	 * Get the invoice name/title.
651
-	 *
652
-	 * @since 1.0.19
653
-	 * @param  string $context View or edit context.
654
-	 * @return string
655
-	 */
656
-	public function get_name( $context = 'view' ) {
650
+     * Get the invoice name/title.
651
+     *
652
+     * @since 1.0.19
653
+     * @param  string $context View or edit context.
654
+     * @return string
655
+     */
656
+    public function get_name( $context = 'view' ) {
657 657
         return $this->get_prop( 'title', $context );
658 658
     }
659 659
 
660 660
     /**
661
-	 * Alias of self::get_name().
662
-	 *
663
-	 * @since 1.0.19
664
-	 * @param  string $context View or edit context.
665
-	 * @return string
666
-	 */
667
-	public function get_title( $context = 'view' ) {
668
-		return $this->get_name( $context );
661
+     * Alias of self::get_name().
662
+     *
663
+     * @since 1.0.19
664
+     * @param  string $context View or edit context.
665
+     * @return string
666
+     */
667
+    public function get_title( $context = 'view' ) {
668
+        return $this->get_name( $context );
669 669
     }
670 670
 
671 671
     /**
672
-	 * Get the invoice description.
673
-	 *
674
-	 * @since 1.0.19
675
-	 * @param  string $context View or edit context.
676
-	 * @return string
677
-	 */
678
-	public function get_description( $context = 'view' ) {
679
-		return $this->get_prop( 'description', $context );
672
+     * Get the invoice description.
673
+     *
674
+     * @since 1.0.19
675
+     * @param  string $context View or edit context.
676
+     * @return string
677
+     */
678
+    public function get_description( $context = 'view' ) {
679
+        return $this->get_prop( 'description', $context );
680 680
     }
681 681
 
682 682
     /**
683
-	 * Alias of self::get_description().
684
-	 *
685
-	 * @since 1.0.19
686
-	 * @param  string $context View or edit context.
687
-	 * @return string
688
-	 */
689
-	public function get_excerpt( $context = 'view' ) {
690
-		return $this->get_description( $context );
683
+     * Alias of self::get_description().
684
+     *
685
+     * @since 1.0.19
686
+     * @param  string $context View or edit context.
687
+     * @return string
688
+     */
689
+    public function get_excerpt( $context = 'view' ) {
690
+        return $this->get_description( $context );
691 691
     }
692 692
 
693 693
     /**
694
-	 * Alias of self::get_description().
695
-	 *
696
-	 * @since 1.0.19
697
-	 * @param  string $context View or edit context.
698
-	 * @return string
699
-	 */
700
-	public function get_summary( $context = 'view' ) {
701
-		return $this->get_description( $context );
694
+     * Alias of self::get_description().
695
+     *
696
+     * @since 1.0.19
697
+     * @param  string $context View or edit context.
698
+     * @return string
699
+     */
700
+    public function get_summary( $context = 'view' ) {
701
+        return $this->get_description( $context );
702 702
     }
703 703
 
704 704
     /**
705
-	 * Returns the user info.
706
-	 *
707
-	 * @since 1.0.19
705
+     * Returns the user info.
706
+     *
707
+     * @since 1.0.19
708 708
      * @param  string $context View or edit context.
709
-	 * @return array
710
-	 */
709
+     * @return array
710
+     */
711 711
     public function get_user_info( $context = 'view' ) {
712 712
 
713 713
         $user_info = array(
@@ -724,605 +724,605 @@  discard block
 block discarded – undo
724 724
             'company'    => $this->get_company( $context ),
725 725
             'vat_number' => $this->get_vat_number( $context ),
726 726
             'discount'   => $this->get_discount_code( $context ),
727
-		);
727
+        );
728
+
729
+        return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
730
+
731
+    }
732
+
733
+    /**
734
+     * Get the customer id.
735
+     *
736
+     * @since 1.0.19
737
+     * @param  string $context View or edit context.
738
+     * @return int
739
+     */
740
+    public function get_author( $context = 'view' ) {
741
+        return (int) $this->get_prop( 'author', $context );
742
+    }
728 743
 
729
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
744
+    /**
745
+     * Alias of self::get_author().
746
+     *
747
+     * @since 1.0.19
748
+     * @param  string $context View or edit context.
749
+     * @return int
750
+     */
751
+    public function get_user_id( $context = 'view' ) {
752
+        return $this->get_author( $context );
753
+    }
730 754
 
755
+        /**
756
+         * Alias of self::get_author().
757
+         *
758
+         * @since 1.0.19
759
+         * @param  string $context View or edit context.
760
+         * @return int
761
+         */
762
+    public function get_customer_id( $context = 'view' ) {
763
+        return $this->get_author( $context );
731 764
     }
732 765
 
733 766
     /**
734
-	 * Get the customer id.
735
-	 *
736
-	 * @since 1.0.19
737
-	 * @param  string $context View or edit context.
738
-	 * @return int
739
-	 */
740
-	public function get_author( $context = 'view' ) {
741
-		return (int) $this->get_prop( 'author', $context );
767
+     * Get the customer's ip.
768
+     *
769
+     * @since 1.0.19
770
+     * @param  string $context View or edit context.
771
+     * @return string
772
+     */
773
+    public function get_ip( $context = 'view' ) {
774
+        return $this->get_prop( 'user_ip', $context );
742 775
     }
743 776
 
744 777
     /**
745
-	 * Alias of self::get_author().
746
-	 *
747
-	 * @since 1.0.19
748
-	 * @param  string $context View or edit context.
749
-	 * @return int
750
-	 */
751
-	public function get_user_id( $context = 'view' ) {
752
-		return $this->get_author( $context );
778
+     * Alias of self::get_ip().
779
+     *
780
+     * @since 1.0.19
781
+     * @param  string $context View or edit context.
782
+     * @return string
783
+     */
784
+    public function get_user_ip( $context = 'view' ) {
785
+        return $this->get_ip( $context );
753 786
     }
754 787
 
755
-     /**
756
-	 * Alias of self::get_author().
757
-	 *
758
-	 * @since 1.0.19
759
-	 * @param  string $context View or edit context.
760
-	 * @return int
761
-	 */
762
-	public function get_customer_id( $context = 'view' ) {
763
-		return $this->get_author( $context );
788
+        /**
789
+         * Alias of self::get_ip().
790
+         *
791
+         * @since 1.0.19
792
+         * @param  string $context View or edit context.
793
+         * @return string
794
+         */
795
+    public function get_customer_ip( $context = 'view' ) {
796
+        return $this->get_ip( $context );
764 797
     }
765 798
 
766 799
     /**
767
-	 * Get the customer's ip.
768
-	 *
769
-	 * @since 1.0.19
770
-	 * @param  string $context View or edit context.
771
-	 * @return string
772
-	 */
773
-	public function get_ip( $context = 'view' ) {
774
-		return $this->get_prop( 'user_ip', $context );
800
+     * Get the customer's first name.
801
+     *
802
+     * @since 1.0.19
803
+     * @param  string $context View or edit context.
804
+     * @return string
805
+     */
806
+    public function get_first_name( $context = 'view' ) {
807
+        return $this->get_prop( 'first_name', $context );
775 808
     }
776 809
 
777 810
     /**
778
-	 * Alias of self::get_ip().
779
-	 *
780
-	 * @since 1.0.19
781
-	 * @param  string $context View or edit context.
782
-	 * @return string
783
-	 */
784
-	public function get_user_ip( $context = 'view' ) {
785
-		return $this->get_ip( $context );
811
+     * Alias of self::get_first_name().
812
+     *
813
+     * @since 1.0.19
814
+     * @param  string $context View or edit context.
815
+     * @return int
816
+     */
817
+    public function get_user_first_name( $context = 'view' ) {
818
+        return $this->get_first_name( $context );
786 819
     }
787 820
 
788
-     /**
789
-	 * Alias of self::get_ip().
790
-	 *
791
-	 * @since 1.0.19
792
-	 * @param  string $context View or edit context.
793
-	 * @return string
794
-	 */
795
-	public function get_customer_ip( $context = 'view' ) {
796
-		return $this->get_ip( $context );
821
+        /**
822
+         * Alias of self::get_first_name().
823
+         *
824
+         * @since 1.0.19
825
+         * @param  string $context View or edit context.
826
+         * @return int
827
+         */
828
+    public function get_customer_first_name( $context = 'view' ) {
829
+        return $this->get_first_name( $context );
797 830
     }
798 831
 
799 832
     /**
800
-	 * Get the customer's first name.
801
-	 *
802
-	 * @since 1.0.19
803
-	 * @param  string $context View or edit context.
804
-	 * @return string
805
-	 */
806
-	public function get_first_name( $context = 'view' ) {
807
-		return $this->get_prop( 'first_name', $context );
833
+     * Get the customer's last name.
834
+     *
835
+     * @since 1.0.19
836
+     * @param  string $context View or edit context.
837
+     * @return string
838
+     */
839
+    public function get_last_name( $context = 'view' ) {
840
+        return $this->get_prop( 'last_name', $context );
808 841
     }
809 842
 
810 843
     /**
811
-	 * Alias of self::get_first_name().
812
-	 *
813
-	 * @since 1.0.19
814
-	 * @param  string $context View or edit context.
815
-	 * @return int
816
-	 */
817
-	public function get_user_first_name( $context = 'view' ) {
818
-		return $this->get_first_name( $context );
844
+     * Alias of self::get_last_name().
845
+     *
846
+     * @since 1.0.19
847
+     * @param  string $context View or edit context.
848
+     * @return int
849
+     */
850
+    public function get_user_last_name( $context = 'view' ) {
851
+        return $this->get_last_name( $context );
819 852
     }
820 853
 
821
-     /**
822
-	 * Alias of self::get_first_name().
823
-	 *
824
-	 * @since 1.0.19
825
-	 * @param  string $context View or edit context.
826
-	 * @return int
827
-	 */
828
-	public function get_customer_first_name( $context = 'view' ) {
829
-		return $this->get_first_name( $context );
854
+    /**
855
+     * Alias of self::get_last_name().
856
+     *
857
+     * @since 1.0.19
858
+     * @param  string $context View or edit context.
859
+     * @return int
860
+     */
861
+    public function get_customer_last_name( $context = 'view' ) {
862
+        return $this->get_last_name( $context );
830 863
     }
831 864
 
832 865
     /**
833
-	 * Get the customer's last name.
834
-	 *
835
-	 * @since 1.0.19
836
-	 * @param  string $context View or edit context.
837
-	 * @return string
838
-	 */
839
-	public function get_last_name( $context = 'view' ) {
840
-		return $this->get_prop( 'last_name', $context );
866
+     * Get the customer's full name.
867
+     *
868
+     * @since 1.0.19
869
+     * @param  string $context View or edit context.
870
+     * @return string
871
+     */
872
+    public function get_full_name( $context = 'view' ) {
873
+        return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
841 874
     }
842 875
 
843 876
     /**
844
-	 * Alias of self::get_last_name().
845
-	 *
846
-	 * @since 1.0.19
847
-	 * @param  string $context View or edit context.
848
-	 * @return int
849
-	 */
850
-	public function get_user_last_name( $context = 'view' ) {
851
-		return $this->get_last_name( $context );
877
+     * Alias of self::get_full_name().
878
+     *
879
+     * @since 1.0.19
880
+     * @param  string $context View or edit context.
881
+     * @return int
882
+     */
883
+    public function get_user_full_name( $context = 'view' ) {
884
+        return $this->get_full_name( $context );
852 885
     }
853 886
 
854 887
     /**
855
-	 * Alias of self::get_last_name().
856
-	 *
857
-	 * @since 1.0.19
858
-	 * @param  string $context View or edit context.
859
-	 * @return int
860
-	 */
861
-	public function get_customer_last_name( $context = 'view' ) {
862
-		return $this->get_last_name( $context );
888
+     * Alias of self::get_full_name().
889
+     *
890
+     * @since 1.0.19
891
+     * @param  string $context View or edit context.
892
+     * @return int
893
+     */
894
+    public function get_customer_full_name( $context = 'view' ) {
895
+        return $this->get_full_name( $context );
863 896
     }
864 897
 
865 898
     /**
866
-	 * Get the customer's full name.
867
-	 *
868
-	 * @since 1.0.19
869
-	 * @param  string $context View or edit context.
870
-	 * @return string
871
-	 */
872
-	public function get_full_name( $context = 'view' ) {
873
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
899
+     * Get the customer's phone number.
900
+     *
901
+     * @since 1.0.19
902
+     * @param  string $context View or edit context.
903
+     * @return string
904
+     */
905
+    public function get_phone( $context = 'view' ) {
906
+        return $this->get_prop( 'phone', $context );
874 907
     }
875 908
 
876 909
     /**
877
-	 * Alias of self::get_full_name().
878
-	 *
879
-	 * @since 1.0.19
880
-	 * @param  string $context View or edit context.
881
-	 * @return int
882
-	 */
883
-	public function get_user_full_name( $context = 'view' ) {
884
-		return $this->get_full_name( $context );
910
+     * Alias of self::get_phone().
911
+     *
912
+     * @since 1.0.19
913
+     * @param  string $context View or edit context.
914
+     * @return int
915
+     */
916
+    public function get_phone_number( $context = 'view' ) {
917
+        return $this->get_phone( $context );
885 918
     }
886 919
 
887 920
     /**
888
-	 * Alias of self::get_full_name().
889
-	 *
890
-	 * @since 1.0.19
891
-	 * @param  string $context View or edit context.
892
-	 * @return int
893
-	 */
894
-	public function get_customer_full_name( $context = 'view' ) {
895
-		return $this->get_full_name( $context );
921
+     * Alias of self::get_phone().
922
+     *
923
+     * @since 1.0.19
924
+     * @param  string $context View or edit context.
925
+     * @return int
926
+     */
927
+    public function get_user_phone( $context = 'view' ) {
928
+        return $this->get_phone( $context );
896 929
     }
897 930
 
898 931
     /**
899
-	 * Get the customer's phone number.
900
-	 *
901
-	 * @since 1.0.19
902
-	 * @param  string $context View or edit context.
903
-	 * @return string
904
-	 */
905
-	public function get_phone( $context = 'view' ) {
906
-		return $this->get_prop( 'phone', $context );
932
+     * Alias of self::get_phone().
933
+     *
934
+     * @since 1.0.19
935
+     * @param  string $context View or edit context.
936
+     * @return int
937
+     */
938
+    public function get_customer_phone( $context = 'view' ) {
939
+        return $this->get_phone( $context );
907 940
     }
908 941
 
909 942
     /**
910
-	 * Alias of self::get_phone().
911
-	 *
912
-	 * @since 1.0.19
913
-	 * @param  string $context View or edit context.
914
-	 * @return int
915
-	 */
916
-	public function get_phone_number( $context = 'view' ) {
917
-		return $this->get_phone( $context );
943
+     * Get the customer's email address.
944
+     *
945
+     * @since 1.0.19
946
+     * @param  string $context View or edit context.
947
+     * @return string
948
+     */
949
+    public function get_email( $context = 'view' ) {
950
+        return $this->get_prop( 'email', $context );
918 951
     }
919 952
 
920 953
     /**
921
-	 * Alias of self::get_phone().
922
-	 *
923
-	 * @since 1.0.19
924
-	 * @param  string $context View or edit context.
925
-	 * @return int
926
-	 */
927
-	public function get_user_phone( $context = 'view' ) {
928
-		return $this->get_phone( $context );
954
+     * Alias of self::get_email().
955
+     *
956
+     * @since 1.0.19
957
+     * @param  string $context View or edit context.
958
+     * @return string
959
+     */
960
+    public function get_email_address( $context = 'view' ) {
961
+        return $this->get_email( $context );
929 962
     }
930 963
 
931 964
     /**
932
-	 * Alias of self::get_phone().
933
-	 *
934
-	 * @since 1.0.19
935
-	 * @param  string $context View or edit context.
936
-	 * @return int
937
-	 */
938
-	public function get_customer_phone( $context = 'view' ) {
939
-		return $this->get_phone( $context );
965
+     * Alias of self::get_email().
966
+     *
967
+     * @since 1.0.19
968
+     * @param  string $context View or edit context.
969
+     * @return int
970
+     */
971
+    public function get_user_email( $context = 'view' ) {
972
+        return $this->get_email( $context );
940 973
     }
941 974
 
942 975
     /**
943
-	 * Get the customer's email address.
944
-	 *
945
-	 * @since 1.0.19
946
-	 * @param  string $context View or edit context.
947
-	 * @return string
948
-	 */
949
-	public function get_email( $context = 'view' ) {
950
-		return $this->get_prop( 'email', $context );
976
+     * Alias of self::get_email().
977
+     *
978
+     * @since 1.0.19
979
+     * @param  string $context View or edit context.
980
+     * @return int
981
+     */
982
+    public function get_customer_email( $context = 'view' ) {
983
+        return $this->get_email( $context );
951 984
     }
952 985
 
953 986
     /**
954
-	 * Alias of self::get_email().
955
-	 *
956
-	 * @since 1.0.19
957
-	 * @param  string $context View or edit context.
958
-	 * @return string
959
-	 */
960
-	public function get_email_address( $context = 'view' ) {
961
-		return $this->get_email( $context );
987
+     * Get the customer's country.
988
+     *
989
+     * @since 1.0.19
990
+     * @param  string $context View or edit context.
991
+     * @return string
992
+     */
993
+    public function get_country( $context = 'view' ) {
994
+        $country = $this->get_prop( 'country', $context );
995
+        return empty( $country ) ? wpinv_get_default_country() : $country;
962 996
     }
963 997
 
964 998
     /**
965
-	 * Alias of self::get_email().
966
-	 *
967
-	 * @since 1.0.19
968
-	 * @param  string $context View or edit context.
969
-	 * @return int
970
-	 */
971
-	public function get_user_email( $context = 'view' ) {
972
-		return $this->get_email( $context );
999
+     * Alias of self::get_country().
1000
+     *
1001
+     * @since 1.0.19
1002
+     * @param  string $context View or edit context.
1003
+     * @return int
1004
+     */
1005
+    public function get_user_country( $context = 'view' ) {
1006
+        return $this->get_country( $context );
973 1007
     }
974 1008
 
975 1009
     /**
976
-	 * Alias of self::get_email().
977
-	 *
978
-	 * @since 1.0.19
979
-	 * @param  string $context View or edit context.
980
-	 * @return int
981
-	 */
982
-	public function get_customer_email( $context = 'view' ) {
983
-		return $this->get_email( $context );
1010
+     * Alias of self::get_country().
1011
+     *
1012
+     * @since 1.0.19
1013
+     * @param  string $context View or edit context.
1014
+     * @return int
1015
+     */
1016
+    public function get_customer_country( $context = 'view' ) {
1017
+        return $this->get_country( $context );
984 1018
     }
985 1019
 
986 1020
     /**
987
-	 * Get the customer's country.
988
-	 *
989
-	 * @since 1.0.19
990
-	 * @param  string $context View or edit context.
991
-	 * @return string
992
-	 */
993
-	public function get_country( $context = 'view' ) {
994
-		$country = $this->get_prop( 'country', $context );
995
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1021
+     * Get the customer's state.
1022
+     *
1023
+     * @since 1.0.19
1024
+     * @param  string $context View or edit context.
1025
+     * @return string
1026
+     */
1027
+    public function get_state( $context = 'view' ) {
1028
+        $state = $this->get_prop( 'state', $context );
1029
+        return empty( $state ) ? wpinv_get_default_state() : $state;
996 1030
     }
997 1031
 
998 1032
     /**
999
-	 * Alias of self::get_country().
1000
-	 *
1001
-	 * @since 1.0.19
1002
-	 * @param  string $context View or edit context.
1003
-	 * @return int
1004
-	 */
1005
-	public function get_user_country( $context = 'view' ) {
1006
-		return $this->get_country( $context );
1033
+     * Alias of self::get_state().
1034
+     *
1035
+     * @since 1.0.19
1036
+     * @param  string $context View or edit context.
1037
+     * @return int
1038
+     */
1039
+    public function get_user_state( $context = 'view' ) {
1040
+        return $this->get_state( $context );
1007 1041
     }
1008 1042
 
1009 1043
     /**
1010
-	 * Alias of self::get_country().
1011
-	 *
1012
-	 * @since 1.0.19
1013
-	 * @param  string $context View or edit context.
1014
-	 * @return int
1015
-	 */
1016
-	public function get_customer_country( $context = 'view' ) {
1017
-		return $this->get_country( $context );
1044
+     * Alias of self::get_state().
1045
+     *
1046
+     * @since 1.0.19
1047
+     * @param  string $context View or edit context.
1048
+     * @return int
1049
+     */
1050
+    public function get_customer_state( $context = 'view' ) {
1051
+        return $this->get_state( $context );
1018 1052
     }
1019 1053
 
1020 1054
     /**
1021
-	 * Get the customer's state.
1022
-	 *
1023
-	 * @since 1.0.19
1024
-	 * @param  string $context View or edit context.
1025
-	 * @return string
1026
-	 */
1027
-	public function get_state( $context = 'view' ) {
1028
-		$state = $this->get_prop( 'state', $context );
1029
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1055
+     * Get the customer's city.
1056
+     *
1057
+     * @since 1.0.19
1058
+     * @param  string $context View or edit context.
1059
+     * @return string
1060
+     */
1061
+    public function get_city( $context = 'view' ) {
1062
+        return $this->get_prop( 'city', $context );
1030 1063
     }
1031 1064
 
1032 1065
     /**
1033
-	 * Alias of self::get_state().
1034
-	 *
1035
-	 * @since 1.0.19
1036
-	 * @param  string $context View or edit context.
1037
-	 * @return int
1038
-	 */
1039
-	public function get_user_state( $context = 'view' ) {
1040
-		return $this->get_state( $context );
1066
+     * Alias of self::get_city().
1067
+     *
1068
+     * @since 1.0.19
1069
+     * @param  string $context View or edit context.
1070
+     * @return string
1071
+     */
1072
+    public function get_user_city( $context = 'view' ) {
1073
+        return $this->get_city( $context );
1041 1074
     }
1042 1075
 
1043 1076
     /**
1044
-	 * Alias of self::get_state().
1045
-	 *
1046
-	 * @since 1.0.19
1047
-	 * @param  string $context View or edit context.
1048
-	 * @return int
1049
-	 */
1050
-	public function get_customer_state( $context = 'view' ) {
1051
-		return $this->get_state( $context );
1077
+     * Alias of self::get_city().
1078
+     *
1079
+     * @since 1.0.19
1080
+     * @param  string $context View or edit context.
1081
+     * @return string
1082
+     */
1083
+    public function get_customer_city( $context = 'view' ) {
1084
+        return $this->get_city( $context );
1085
+    }
1086
+
1087
+    /**
1088
+     * Get the customer's zip.
1089
+     *
1090
+     * @since 1.0.19
1091
+     * @param  string $context View or edit context.
1092
+     * @return string
1093
+     */
1094
+    public function get_zip( $context = 'view' ) {
1095
+        return $this->get_prop( 'zip', $context );
1096
+    }
1097
+
1098
+    /**
1099
+     * Alias of self::get_zip().
1100
+     *
1101
+     * @since 1.0.19
1102
+     * @param  string $context View or edit context.
1103
+     * @return string
1104
+     */
1105
+    public function get_user_zip( $context = 'view' ) {
1106
+        return $this->get_zip( $context );
1107
+    }
1108
+
1109
+    /**
1110
+     * Alias of self::get_zip().
1111
+     *
1112
+     * @since 1.0.19
1113
+     * @param  string $context View or edit context.
1114
+     * @return string
1115
+     */
1116
+    public function get_customer_zip( $context = 'view' ) {
1117
+        return $this->get_zip( $context );
1052 1118
     }
1053 1119
 
1054 1120
     /**
1055
-	 * Get the customer's city.
1056
-	 *
1057
-	 * @since 1.0.19
1058
-	 * @param  string $context View or edit context.
1059
-	 * @return string
1060
-	 */
1061
-	public function get_city( $context = 'view' ) {
1062
-		return $this->get_prop( 'city', $context );
1121
+     * Get the customer's company.
1122
+     *
1123
+     * @since 1.0.19
1124
+     * @param  string $context View or edit context.
1125
+     * @return string
1126
+     */
1127
+    public function get_company( $context = 'view' ) {
1128
+        return $this->get_prop( 'company', $context );
1129
+    }
1130
+
1131
+    /**
1132
+     * Alias of self::get_company().
1133
+     *
1134
+     * @since 1.0.19
1135
+     * @param  string $context View or edit context.
1136
+     * @return string
1137
+     */
1138
+    public function get_user_company( $context = 'view' ) {
1139
+        return $this->get_company( $context );
1140
+    }
1141
+
1142
+    /**
1143
+     * Alias of self::get_company().
1144
+     *
1145
+     * @since 1.0.19
1146
+     * @param  string $context View or edit context.
1147
+     * @return string
1148
+     */
1149
+    public function get_customer_company( $context = 'view' ) {
1150
+        return $this->get_company( $context );
1151
+    }
1152
+
1153
+    /**
1154
+     * Get the customer's vat number.
1155
+     *
1156
+     * @since 1.0.19
1157
+     * @param  string $context View or edit context.
1158
+     * @return string
1159
+     */
1160
+    public function get_vat_number( $context = 'view' ) {
1161
+        return $this->get_prop( 'vat_number', $context );
1063 1162
     }
1064 1163
 
1065 1164
     /**
1066
-	 * Alias of self::get_city().
1067
-	 *
1068
-	 * @since 1.0.19
1069
-	 * @param  string $context View or edit context.
1070
-	 * @return string
1071
-	 */
1072
-	public function get_user_city( $context = 'view' ) {
1073
-		return $this->get_city( $context );
1165
+     * Alias of self::get_vat_number().
1166
+     *
1167
+     * @since 1.0.19
1168
+     * @param  string $context View or edit context.
1169
+     * @return string
1170
+     */
1171
+    public function get_user_vat_number( $context = 'view' ) {
1172
+        return $this->get_vat_number( $context );
1074 1173
     }
1075 1174
 
1076 1175
     /**
1077
-	 * Alias of self::get_city().
1078
-	 *
1079
-	 * @since 1.0.19
1080
-	 * @param  string $context View or edit context.
1081
-	 * @return string
1082
-	 */
1083
-	public function get_customer_city( $context = 'view' ) {
1084
-		return $this->get_city( $context );
1176
+     * Alias of self::get_vat_number().
1177
+     *
1178
+     * @since 1.0.19
1179
+     * @param  string $context View or edit context.
1180
+     * @return string
1181
+     */
1182
+    public function get_customer_vat_number( $context = 'view' ) {
1183
+        return $this->get_vat_number( $context );
1085 1184
     }
1086 1185
 
1087 1186
     /**
1088
-	 * Get the customer's zip.
1089
-	 *
1090
-	 * @since 1.0.19
1091
-	 * @param  string $context View or edit context.
1092
-	 * @return string
1093
-	 */
1094
-	public function get_zip( $context = 'view' ) {
1095
-		return $this->get_prop( 'zip', $context );
1187
+     * Get the customer's vat rate.
1188
+     *
1189
+     * @since 1.0.19
1190
+     * @param  string $context View or edit context.
1191
+     * @return string
1192
+     */
1193
+    public function get_vat_rate( $context = 'view' ) {
1194
+        return $this->get_prop( 'vat_rate', $context );
1096 1195
     }
1097 1196
 
1098 1197
     /**
1099
-	 * Alias of self::get_zip().
1100
-	 *
1101
-	 * @since 1.0.19
1102
-	 * @param  string $context View or edit context.
1103
-	 * @return string
1104
-	 */
1105
-	public function get_user_zip( $context = 'view' ) {
1106
-		return $this->get_zip( $context );
1198
+     * Alias of self::get_vat_rate().
1199
+     *
1200
+     * @since 1.0.19
1201
+     * @param  string $context View or edit context.
1202
+     * @return string
1203
+     */
1204
+    public function get_user_vat_rate( $context = 'view' ) {
1205
+        return $this->get_vat_rate( $context );
1107 1206
     }
1108 1207
 
1109 1208
     /**
1110
-	 * Alias of self::get_zip().
1111
-	 *
1112
-	 * @since 1.0.19
1113
-	 * @param  string $context View or edit context.
1114
-	 * @return string
1115
-	 */
1116
-	public function get_customer_zip( $context = 'view' ) {
1117
-		return $this->get_zip( $context );
1209
+     * Alias of self::get_vat_rate().
1210
+     *
1211
+     * @since 1.0.19
1212
+     * @param  string $context View or edit context.
1213
+     * @return string
1214
+     */
1215
+    public function get_customer_vat_rate( $context = 'view' ) {
1216
+        return $this->get_vat_rate( $context );
1118 1217
     }
1119 1218
 
1120 1219
     /**
1121
-	 * Get the customer's company.
1122
-	 *
1123
-	 * @since 1.0.19
1124
-	 * @param  string $context View or edit context.
1125
-	 * @return string
1126
-	 */
1127
-	public function get_company( $context = 'view' ) {
1128
-		return $this->get_prop( 'company', $context );
1220
+     * Get the customer's address.
1221
+     *
1222
+     * @since 1.0.19
1223
+     * @param  string $context View or edit context.
1224
+     * @return string
1225
+     */
1226
+    public function get_address( $context = 'view' ) {
1227
+        return $this->get_prop( 'address', $context );
1129 1228
     }
1130 1229
 
1131 1230
     /**
1132
-	 * Alias of self::get_company().
1133
-	 *
1134
-	 * @since 1.0.19
1135
-	 * @param  string $context View or edit context.
1136
-	 * @return string
1137
-	 */
1138
-	public function get_user_company( $context = 'view' ) {
1139
-		return $this->get_company( $context );
1231
+     * Alias of self::get_address().
1232
+     *
1233
+     * @since 1.0.19
1234
+     * @param  string $context View or edit context.
1235
+     * @return string
1236
+     */
1237
+    public function get_user_address( $context = 'view' ) {
1238
+        return $this->get_address( $context );
1140 1239
     }
1141 1240
 
1142 1241
     /**
1143
-	 * Alias of self::get_company().
1144
-	 *
1145
-	 * @since 1.0.19
1146
-	 * @param  string $context View or edit context.
1147
-	 * @return string
1148
-	 */
1149
-	public function get_customer_company( $context = 'view' ) {
1150
-		return $this->get_company( $context );
1242
+     * Alias of self::get_address().
1243
+     *
1244
+     * @since 1.0.19
1245
+     * @param  string $context View or edit context.
1246
+     * @return string
1247
+     */
1248
+    public function get_customer_address( $context = 'view' ) {
1249
+        return $this->get_address( $context );
1151 1250
     }
1152 1251
 
1153 1252
     /**
1154
-	 * Get the customer's vat number.
1155
-	 *
1156
-	 * @since 1.0.19
1157
-	 * @param  string $context View or edit context.
1158
-	 * @return string
1159
-	 */
1160
-	public function get_vat_number( $context = 'view' ) {
1161
-		return $this->get_prop( 'vat_number', $context );
1253
+     * Get whether the customer has viewed the invoice or not.
1254
+     *
1255
+     * @since 1.0.19
1256
+     * @param  string $context View or edit context.
1257
+     * @return bool
1258
+     */
1259
+    public function get_is_viewed( $context = 'view' ) {
1260
+        return (bool) $this->get_prop( 'is_viewed', $context );
1162 1261
     }
1163 1262
 
1164 1263
     /**
1165
-	 * Alias of self::get_vat_number().
1166
-	 *
1167
-	 * @since 1.0.19
1168
-	 * @param  string $context View or edit context.
1169
-	 * @return string
1170
-	 */
1171
-	public function get_user_vat_number( $context = 'view' ) {
1172
-		return $this->get_vat_number( $context );
1264
+     * Get other recipients for invoice communications.
1265
+     *
1266
+     * @since 1.0.19
1267
+     * @param  string $context View or edit context.
1268
+     * @return bool
1269
+     */
1270
+    public function get_email_cc( $context = 'view' ) {
1271
+        return $this->get_prop( 'email_cc', $context );
1173 1272
     }
1174 1273
 
1175 1274
     /**
1176
-	 * Alias of self::get_vat_number().
1177
-	 *
1178
-	 * @since 1.0.19
1179
-	 * @param  string $context View or edit context.
1180
-	 * @return string
1181
-	 */
1182
-	public function get_customer_vat_number( $context = 'view' ) {
1183
-		return $this->get_vat_number( $context );
1275
+     * Get invoice template.
1276
+     *
1277
+     * @since 1.0.19
1278
+     * @param  string $context View or edit context.
1279
+     * @return bool
1280
+     */
1281
+    public function get_template( $context = 'view' ) {
1282
+        return $this->get_prop( 'template', $context );
1184 1283
     }
1185 1284
 
1186 1285
     /**
1187
-	 * Get the customer's vat rate.
1188
-	 *
1189
-	 * @since 1.0.19
1190
-	 * @param  string $context View or edit context.
1191
-	 * @return string
1192
-	 */
1193
-	public function get_vat_rate( $context = 'view' ) {
1194
-		return $this->get_prop( 'vat_rate', $context );
1286
+     * Get whether the customer has confirmed their address.
1287
+     *
1288
+     * @since 1.0.19
1289
+     * @param  string $context View or edit context.
1290
+     * @return bool
1291
+     */
1292
+    public function get_address_confirmed( $context = 'view' ) {
1293
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1195 1294
     }
1196 1295
 
1197 1296
     /**
1198
-	 * Alias of self::get_vat_rate().
1199
-	 *
1200
-	 * @since 1.0.19
1201
-	 * @param  string $context View or edit context.
1202
-	 * @return string
1203
-	 */
1204
-	public function get_user_vat_rate( $context = 'view' ) {
1205
-		return $this->get_vat_rate( $context );
1297
+     * Alias of self::get_address_confirmed().
1298
+     *
1299
+     * @since 1.0.19
1300
+     * @param  string $context View or edit context.
1301
+     * @return bool
1302
+     */
1303
+    public function get_user_address_confirmed( $context = 'view' ) {
1304
+        return $this->get_address_confirmed( $context );
1206 1305
     }
1207 1306
 
1208 1307
     /**
1209
-	 * Alias of self::get_vat_rate().
1210
-	 *
1211
-	 * @since 1.0.19
1212
-	 * @param  string $context View or edit context.
1213
-	 * @return string
1214
-	 */
1215
-	public function get_customer_vat_rate( $context = 'view' ) {
1216
-		return $this->get_vat_rate( $context );
1308
+     * Alias of self::get_address().
1309
+     *
1310
+     * @since 1.0.19
1311
+     * @param  string $context View or edit context.
1312
+     * @return bool
1313
+     */
1314
+    public function get_customer_address_confirmed( $context = 'view' ) {
1315
+        return $this->get_address_confirmed( $context );
1217 1316
     }
1218 1317
 
1219 1318
     /**
1220
-	 * Get the customer's address.
1221
-	 *
1222
-	 * @since 1.0.19
1223
-	 * @param  string $context View or edit context.
1224
-	 * @return string
1225
-	 */
1226
-	public function get_address( $context = 'view' ) {
1227
-		return $this->get_prop( 'address', $context );
1228
-    }
1229
-
1230
-    /**
1231
-	 * Alias of self::get_address().
1232
-	 *
1233
-	 * @since 1.0.19
1234
-	 * @param  string $context View or edit context.
1235
-	 * @return string
1236
-	 */
1237
-	public function get_user_address( $context = 'view' ) {
1238
-		return $this->get_address( $context );
1239
-    }
1240
-
1241
-    /**
1242
-	 * Alias of self::get_address().
1243
-	 *
1244
-	 * @since 1.0.19
1245
-	 * @param  string $context View or edit context.
1246
-	 * @return string
1247
-	 */
1248
-	public function get_customer_address( $context = 'view' ) {
1249
-		return $this->get_address( $context );
1250
-    }
1251
-
1252
-    /**
1253
-	 * Get whether the customer has viewed the invoice or not.
1254
-	 *
1255
-	 * @since 1.0.19
1256
-	 * @param  string $context View or edit context.
1257
-	 * @return bool
1258
-	 */
1259
-	public function get_is_viewed( $context = 'view' ) {
1260
-		return (bool) $this->get_prop( 'is_viewed', $context );
1261
-	}
1262
-
1263
-	/**
1264
-	 * Get other recipients for invoice communications.
1265
-	 *
1266
-	 * @since 1.0.19
1267
-	 * @param  string $context View or edit context.
1268
-	 * @return bool
1269
-	 */
1270
-	public function get_email_cc( $context = 'view' ) {
1271
-		return $this->get_prop( 'email_cc', $context );
1272
-	}
1273
-
1274
-	/**
1275
-	 * Get invoice template.
1276
-	 *
1277
-	 * @since 1.0.19
1278
-	 * @param  string $context View or edit context.
1279
-	 * @return bool
1280
-	 */
1281
-	public function get_template( $context = 'view' ) {
1282
-		return $this->get_prop( 'template', $context );
1283
-	}
1284
-
1285
-	/**
1286
-	 * Get whether the customer has confirmed their address.
1287
-	 *
1288
-	 * @since 1.0.19
1289
-	 * @param  string $context View or edit context.
1290
-	 * @return bool
1291
-	 */
1292
-	public function get_address_confirmed( $context = 'view' ) {
1293
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1294
-    }
1295
-
1296
-    /**
1297
-	 * Alias of self::get_address_confirmed().
1298
-	 *
1299
-	 * @since 1.0.19
1300
-	 * @param  string $context View or edit context.
1301
-	 * @return bool
1302
-	 */
1303
-	public function get_user_address_confirmed( $context = 'view' ) {
1304
-		return $this->get_address_confirmed( $context );
1305
-    }
1306
-
1307
-    /**
1308
-	 * Alias of self::get_address().
1309
-	 *
1310
-	 * @since 1.0.19
1311
-	 * @param  string $context View or edit context.
1312
-	 * @return bool
1313
-	 */
1314
-	public function get_customer_address_confirmed( $context = 'view' ) {
1315
-		return $this->get_address_confirmed( $context );
1316
-    }
1317
-
1318
-    /**
1319
-	 * Get the invoice subtotal.
1320
-	 *
1321
-	 * @since 1.0.19
1322
-	 * @param  string $context View or edit context.
1323
-	 * @return float
1324
-	 */
1325
-	public function get_subtotal( $context = 'view' ) {
1319
+     * Get the invoice subtotal.
1320
+     *
1321
+     * @since 1.0.19
1322
+     * @param  string $context View or edit context.
1323
+     * @return float
1324
+     */
1325
+    public function get_subtotal( $context = 'view' ) {
1326 1326
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1327 1327
 
1328 1328
         // Backwards compatibility.
@@ -1334,165 +1334,165 @@  discard block
 block discarded – undo
1334 1334
     }
1335 1335
 
1336 1336
     /**
1337
-	 * Get the invoice discount total.
1338
-	 *
1339
-	 * @since 1.0.19
1340
-	 * @param  string $context View or edit context.
1341
-	 * @return float
1342
-	 */
1343
-	public function get_total_discount( $context = 'view' ) {
1344
-		return (float) $this->get_prop( 'total_discount', $context );
1337
+     * Get the invoice discount total.
1338
+     *
1339
+     * @since 1.0.19
1340
+     * @param  string $context View or edit context.
1341
+     * @return float
1342
+     */
1343
+    public function get_total_discount( $context = 'view' ) {
1344
+        return (float) $this->get_prop( 'total_discount', $context );
1345 1345
     }
1346 1346
 
1347 1347
     /**
1348
-	 * Get the invoice tax total.
1349
-	 *
1350
-	 * @since 1.0.19
1351
-	 * @param  string $context View or edit context.
1352
-	 * @return float
1353
-	 */
1354
-	public function get_total_tax( $context = 'view' ) {
1355
-		return (float) $this->get_prop( 'total_tax', $context );
1356
-	}
1348
+     * Get the invoice tax total.
1349
+     *
1350
+     * @since 1.0.19
1351
+     * @param  string $context View or edit context.
1352
+     * @return float
1353
+     */
1354
+    public function get_total_tax( $context = 'view' ) {
1355
+        return (float) $this->get_prop( 'total_tax', $context );
1356
+    }
1357 1357
 
1358
-	/**
1359
-	 * @deprecated
1360
-	 */
1361
-	public function get_final_tax( $currency = false ) {
1362
-		$tax = $this->get_total_tax();
1358
+    /**
1359
+     * @deprecated
1360
+     */
1361
+    public function get_final_tax( $currency = false ) {
1362
+        $tax = $this->get_total_tax();
1363 1363
 
1364 1364
         if ( $currency ) {
1365
-			return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1365
+            return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1366 1366
         }
1367 1367
 
1368 1368
         return $tax;
1369 1369
     }
1370 1370
 
1371 1371
     /**
1372
-	 * Get the invoice fees total.
1373
-	 *
1374
-	 * @since 1.0.19
1375
-	 * @param  string $context View or edit context.
1376
-	 * @return float
1377
-	 */
1378
-	public function get_total_fees( $context = 'view' ) {
1379
-		return (float) $this->get_prop( 'total_fees', $context );
1372
+     * Get the invoice fees total.
1373
+     *
1374
+     * @since 1.0.19
1375
+     * @param  string $context View or edit context.
1376
+     * @return float
1377
+     */
1378
+    public function get_total_fees( $context = 'view' ) {
1379
+        return (float) $this->get_prop( 'total_fees', $context );
1380 1380
     }
1381 1381
 
1382 1382
     /**
1383
-	 * Alias for self::get_total_fees().
1384
-	 *
1385
-	 * @since 1.0.19
1386
-	 * @param  string $context View or edit context.
1387
-	 * @return float
1388
-	 */
1389
-	public function get_fees_total( $context = 'view' ) {
1390
-		return $this->get_total_fees( $context );
1383
+     * Alias for self::get_total_fees().
1384
+     *
1385
+     * @since 1.0.19
1386
+     * @param  string $context View or edit context.
1387
+     * @return float
1388
+     */
1389
+    public function get_fees_total( $context = 'view' ) {
1390
+        return $this->get_total_fees( $context );
1391 1391
     }
1392 1392
 
1393 1393
     /**
1394
-	 * Get the invoice total.
1395
-	 *
1396
-	 * @since 1.0.19
1394
+     * Get the invoice total.
1395
+     *
1396
+     * @since 1.0.19
1397 1397
      * @return float
1398
-	 */
1399
-	public function get_total() {
1400
-		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1401
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1402
-	}
1398
+     */
1399
+    public function get_total() {
1400
+        $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1401
+        return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1402
+    }
1403 1403
 	
1404
-	/**
1405
-	 * Get the invoice totals.
1406
-	 *
1407
-	 * @since 1.0.19
1404
+    /**
1405
+     * Get the invoice totals.
1406
+     *
1407
+     * @since 1.0.19
1408 1408
      * @return float
1409
-	 */
1410
-	public function get_totals() {
1411
-		return $this->totals;
1409
+     */
1410
+    public function get_totals() {
1411
+        return $this->totals;
1412 1412
     }
1413 1413
 
1414 1414
     /**
1415
-	 * Get the initial invoice total.
1416
-	 *
1417
-	 * @since 1.0.19
1415
+     * Get the initial invoice total.
1416
+     *
1417
+     * @since 1.0.19
1418 1418
      * @param  string $context View or edit context.
1419 1419
      * @return float
1420
-	 */
1420
+     */
1421 1421
     public function get_initial_total() {
1422 1422
 
1423
-		if ( empty( $this->totals ) ) {
1424
-			$this->recalculate_total();
1425
-		}
1423
+        if ( empty( $this->totals ) ) {
1424
+            $this->recalculate_total();
1425
+        }
1426 1426
 
1427
-		$tax      = $this->totals['tax']['initial'];
1428
-		$fee      = $this->totals['fee']['initial'];
1429
-		$discount = $this->totals['discount']['initial'];
1430
-		$subtotal = $this->totals['subtotal']['initial'];
1431
-		$total    = $tax + $fee - $discount + $subtotal;
1427
+        $tax      = $this->totals['tax']['initial'];
1428
+        $fee      = $this->totals['fee']['initial'];
1429
+        $discount = $this->totals['discount']['initial'];
1430
+        $subtotal = $this->totals['subtotal']['initial'];
1431
+        $total    = $tax + $fee - $discount + $subtotal;
1432 1432
 
1433
-		if ( 0 > $total ) {
1434
-			$total = 0;
1435
-		}
1433
+        if ( 0 > $total ) {
1434
+            $total = 0;
1435
+        }
1436 1436
 
1437 1437
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1438
-	}
1438
+    }
1439 1439
 
1440
-	/**
1441
-	 * Get the recurring invoice total.
1442
-	 *
1443
-	 * @since 1.0.19
1440
+    /**
1441
+     * Get the recurring invoice total.
1442
+     *
1443
+     * @since 1.0.19
1444 1444
      * @param  string $context View or edit context.
1445 1445
      * @return float
1446
-	 */
1446
+     */
1447 1447
     public function get_recurring_total() {
1448 1448
 
1449
-		if ( empty( $this->totals ) ) {
1450
-			$this->recalculate_total();
1451
-		}
1449
+        if ( empty( $this->totals ) ) {
1450
+            $this->recalculate_total();
1451
+        }
1452 1452
 
1453
-		$tax      = $this->totals['tax']['recurring'];
1454
-		$fee      = $this->totals['fee']['recurring'];
1455
-		$discount = $this->totals['discount']['recurring'];
1456
-		$subtotal = $this->totals['subtotal']['recurring'];
1457
-		$total    = $tax + $fee - $discount + $subtotal;
1453
+        $tax      = $this->totals['tax']['recurring'];
1454
+        $fee      = $this->totals['fee']['recurring'];
1455
+        $discount = $this->totals['discount']['recurring'];
1456
+        $subtotal = $this->totals['subtotal']['recurring'];
1457
+        $total    = $tax + $fee - $discount + $subtotal;
1458 1458
 
1459
-		if ( 0 > $total ) {
1460
-			$total = 0;
1461
-		}
1459
+        if ( 0 > $total ) {
1460
+            $total = 0;
1461
+        }
1462 1462
 
1463 1463
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1464
-	}
1464
+    }
1465 1465
 
1466
-	/**
1467
-	 * Returns recurring payment details.
1468
-	 *
1469
-	 * @since 1.0.19
1466
+    /**
1467
+     * Returns recurring payment details.
1468
+     *
1469
+     * @since 1.0.19
1470 1470
      * @param  string $field Optionally provide a field to return.
1471
-	 * @param string $currency Whether to include the currency.
1471
+     * @param string $currency Whether to include the currency.
1472 1472
      * @return float
1473
-	 */
1473
+     */
1474 1474
     public function get_recurring_details( $field = '', $currency = false ) {
1475 1475
 
1476
-		// Maybe recalculate totals.
1477
-		if ( empty( $this->totals ) ) {
1478
-			$this->recalculate_total();
1479
-		}
1476
+        // Maybe recalculate totals.
1477
+        if ( empty( $this->totals ) ) {
1478
+            $this->recalculate_total();
1479
+        }
1480 1480
 
1481
-		// Prepare recurring totals.
1481
+        // Prepare recurring totals.
1482 1482
         $data = apply_filters(
1483
-			'wpinv_get_invoice_recurring_details',
1484
-			array(
1485
-				'cart_details' => $this->get_cart_details(),
1486
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1487
-				'discount'     => $this->totals['discount']['recurring'],
1488
-				'tax'          => $this->totals['tax']['recurring'],
1489
-				'fee'          => $this->totals['fee']['recurring'],
1490
-				'total'        => $this->get_recurring_total(),
1491
-			),
1492
-			$this,
1493
-			$field,
1494
-			$currency
1495
-		);
1483
+            'wpinv_get_invoice_recurring_details',
1484
+            array(
1485
+                'cart_details' => $this->get_cart_details(),
1486
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1487
+                'discount'     => $this->totals['discount']['recurring'],
1488
+                'tax'          => $this->totals['tax']['recurring'],
1489
+                'fee'          => $this->totals['fee']['recurring'],
1490
+                'total'        => $this->get_recurring_total(),
1491
+            ),
1492
+            $this,
1493
+            $field,
1494
+            $currency
1495
+        );
1496 1496
 
1497 1497
         if ( isset( $data[$field] ) ) {
1498 1498
             return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
@@ -1502,156 +1502,156 @@  discard block
 block discarded – undo
1502 1502
     }
1503 1503
 
1504 1504
     /**
1505
-	 * Get the invoice fees.
1506
-	 *
1507
-	 * @since 1.0.19
1508
-	 * @param  string $context View or edit context.
1509
-	 * @return array
1510
-	 */
1511
-	public function get_fees( $context = 'view' ) {
1512
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1505
+     * Get the invoice fees.
1506
+     *
1507
+     * @since 1.0.19
1508
+     * @param  string $context View or edit context.
1509
+     * @return array
1510
+     */
1511
+    public function get_fees( $context = 'view' ) {
1512
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1513 1513
     }
1514 1514
 
1515 1515
     /**
1516
-	 * Get the invoice discounts.
1517
-	 *
1518
-	 * @since 1.0.19
1519
-	 * @param  string $context View or edit context.
1520
-	 * @return array
1521
-	 */
1522
-	public function get_discounts( $context = 'view' ) {
1523
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1516
+     * Get the invoice discounts.
1517
+     *
1518
+     * @since 1.0.19
1519
+     * @param  string $context View or edit context.
1520
+     * @return array
1521
+     */
1522
+    public function get_discounts( $context = 'view' ) {
1523
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1524 1524
     }
1525 1525
 
1526 1526
     /**
1527
-	 * Get the invoice taxes.
1528
-	 *
1529
-	 * @since 1.0.19
1530
-	 * @param  string $context View or edit context.
1531
-	 * @return array
1532
-	 */
1533
-	public function get_taxes( $context = 'view' ) {
1534
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1527
+     * Get the invoice taxes.
1528
+     *
1529
+     * @since 1.0.19
1530
+     * @param  string $context View or edit context.
1531
+     * @return array
1532
+     */
1533
+    public function get_taxes( $context = 'view' ) {
1534
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1535 1535
     }
1536 1536
 
1537 1537
     /**
1538
-	 * Get the invoice items.
1539
-	 *
1540
-	 * @since 1.0.19
1541
-	 * @param  string $context View or edit context.
1542
-	 * @return GetPaid_Form_Item[]
1543
-	 */
1544
-	public function get_items( $context = 'view' ) {
1538
+     * Get the invoice items.
1539
+     *
1540
+     * @since 1.0.19
1541
+     * @param  string $context View or edit context.
1542
+     * @return GetPaid_Form_Item[]
1543
+     */
1544
+    public function get_items( $context = 'view' ) {
1545 1545
         return $this->get_prop( 'items', $context );
1546 1546
     }
1547 1547
 
1548 1548
     /**
1549
-	 * Get the invoice's payment form.
1550
-	 *
1551
-	 * @since 1.0.19
1552
-	 * @param  string $context View or edit context.
1553
-	 * @return int
1554
-	 */
1555
-	public function get_payment_form( $context = 'view' ) {
1556
-		return intval( $this->get_prop( 'payment_form', $context ) );
1549
+     * Get the invoice's payment form.
1550
+     *
1551
+     * @since 1.0.19
1552
+     * @param  string $context View or edit context.
1553
+     * @return int
1554
+     */
1555
+    public function get_payment_form( $context = 'view' ) {
1556
+        return intval( $this->get_prop( 'payment_form', $context ) );
1557 1557
     }
1558 1558
 
1559 1559
     /**
1560
-	 * Get the invoice's submission id.
1561
-	 *
1562
-	 * @since 1.0.19
1563
-	 * @param  string $context View or edit context.
1564
-	 * @return string
1565
-	 */
1566
-	public function get_submission_id( $context = 'view' ) {
1567
-		return $this->get_prop( 'submission_id', $context );
1560
+     * Get the invoice's submission id.
1561
+     *
1562
+     * @since 1.0.19
1563
+     * @param  string $context View or edit context.
1564
+     * @return string
1565
+     */
1566
+    public function get_submission_id( $context = 'view' ) {
1567
+        return $this->get_prop( 'submission_id', $context );
1568 1568
     }
1569 1569
 
1570 1570
     /**
1571
-	 * Get the invoice's discount code.
1572
-	 *
1573
-	 * @since 1.0.19
1574
-	 * @param  string $context View or edit context.
1575
-	 * @return string
1576
-	 */
1577
-	public function get_discount_code( $context = 'view' ) {
1578
-		return $this->get_prop( 'discount_code', $context );
1571
+     * Get the invoice's discount code.
1572
+     *
1573
+     * @since 1.0.19
1574
+     * @param  string $context View or edit context.
1575
+     * @return string
1576
+     */
1577
+    public function get_discount_code( $context = 'view' ) {
1578
+        return $this->get_prop( 'discount_code', $context );
1579 1579
     }
1580 1580
 
1581 1581
     /**
1582
-	 * Get the invoice's gateway.
1583
-	 *
1584
-	 * @since 1.0.19
1585
-	 * @param  string $context View or edit context.
1586
-	 * @return string
1587
-	 */
1588
-	public function get_gateway( $context = 'view' ) {
1589
-		return $this->get_prop( 'gateway', $context );
1582
+     * Get the invoice's gateway.
1583
+     *
1584
+     * @since 1.0.19
1585
+     * @param  string $context View or edit context.
1586
+     * @return string
1587
+     */
1588
+    public function get_gateway( $context = 'view' ) {
1589
+        return $this->get_prop( 'gateway', $context );
1590 1590
     }
1591 1591
 
1592 1592
     /**
1593
-	 * Get the invoice's gateway display title.
1594
-	 *
1595
-	 * @since 1.0.19
1596
-	 * @return string
1597
-	 */
1593
+     * Get the invoice's gateway display title.
1594
+     *
1595
+     * @since 1.0.19
1596
+     * @return string
1597
+     */
1598 1598
     public function get_gateway_title() {
1599 1599
         $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1600 1600
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1601 1601
     }
1602 1602
 
1603 1603
     /**
1604
-	 * Get the invoice's transaction id.
1605
-	 *
1606
-	 * @since 1.0.19
1607
-	 * @param  string $context View or edit context.
1608
-	 * @return string
1609
-	 */
1610
-	public function get_transaction_id( $context = 'view' ) {
1611
-		return $this->get_prop( 'transaction_id', $context );
1604
+     * Get the invoice's transaction id.
1605
+     *
1606
+     * @since 1.0.19
1607
+     * @param  string $context View or edit context.
1608
+     * @return string
1609
+     */
1610
+    public function get_transaction_id( $context = 'view' ) {
1611
+        return $this->get_prop( 'transaction_id', $context );
1612 1612
     }
1613 1613
 
1614 1614
     /**
1615
-	 * Get the invoice's currency.
1616
-	 *
1617
-	 * @since 1.0.19
1618
-	 * @param  string $context View or edit context.
1619
-	 * @return string
1620
-	 */
1621
-	public function get_currency( $context = 'view' ) {
1615
+     * Get the invoice's currency.
1616
+     *
1617
+     * @since 1.0.19
1618
+     * @param  string $context View or edit context.
1619
+     * @return string
1620
+     */
1621
+    public function get_currency( $context = 'view' ) {
1622 1622
         $currency = $this->get_prop( 'currency', $context );
1623 1623
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1624 1624
     }
1625 1625
 
1626 1626
     /**
1627
-	 * Checks if we are charging taxes for this invoice.
1628
-	 *
1629
-	 * @since 1.0.19
1630
-	 * @param  string $context View or edit context.
1631
-	 * @return bool
1632
-	 */
1633
-	public function get_disable_taxes( $context = 'view' ) {
1627
+     * Checks if we are charging taxes for this invoice.
1628
+     *
1629
+     * @since 1.0.19
1630
+     * @param  string $context View or edit context.
1631
+     * @return bool
1632
+     */
1633
+    public function get_disable_taxes( $context = 'view' ) {
1634 1634
         return (bool) $this->get_prop( 'disable_taxes', $context );
1635 1635
     }
1636 1636
 
1637 1637
     /**
1638
-	 * Retrieves the subscription id for an invoice.
1639
-	 *
1640
-	 * @since 1.0.19
1641
-	 * @param  string $context View or edit context.
1642
-	 * @return int
1643
-	 */
1638
+     * Retrieves the subscription id for an invoice.
1639
+     *
1640
+     * @since 1.0.19
1641
+     * @param  string $context View or edit context.
1642
+     * @return int
1643
+     */
1644 1644
     public function get_subscription_id( $context = 'view' ) {
1645
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1646
-	}
1647
-
1648
-	/**
1649
-	 * Retrieves the remote subscription id for an invoice.
1650
-	 *
1651
-	 * @since 1.0.19
1652
-	 * @param  string $context View or edit context.
1653
-	 * @return int
1654
-	 */
1645
+        return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1646
+    }
1647
+
1648
+    /**
1649
+     * Retrieves the remote subscription id for an invoice.
1650
+     *
1651
+     * @since 1.0.19
1652
+     * @param  string $context View or edit context.
1653
+     * @return int
1654
+     */
1655 1655
     public function get_remote_subscription_id( $context = 'view' ) {
1656 1656
         $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1657 1657
 
@@ -1664,12 +1664,12 @@  discard block
 block discarded – undo
1664 1664
     }
1665 1665
 
1666 1666
     /**
1667
-	 * Retrieves the payment meta for an invoice.
1668
-	 *
1669
-	 * @since 1.0.19
1670
-	 * @param  string $context View or edit context.
1671
-	 * @return array
1672
-	 */
1667
+     * Retrieves the payment meta for an invoice.
1668
+     *
1669
+     * @since 1.0.19
1670
+     * @param  string $context View or edit context.
1671
+     * @return array
1672
+     */
1673 1673
     public function get_payment_meta( $context = 'view' ) {
1674 1674
 
1675 1675
         return array(
@@ -1689,31 +1689,31 @@  discard block
 block discarded – undo
1689 1689
     }
1690 1690
 
1691 1691
     /**
1692
-	 * Retrieves the cart details for an invoice.
1693
-	 *
1694
-	 * @since 1.0.19
1695
-	 * @return array
1696
-	 */
1692
+     * Retrieves the cart details for an invoice.
1693
+     *
1694
+     * @since 1.0.19
1695
+     * @return array
1696
+     */
1697 1697
     public function get_cart_details() {
1698 1698
         $items        = $this->get_items();
1699 1699
         $cart_details = array();
1700 1700
 
1701 1701
         foreach ( $items as $item_id => $item ) {
1702
-			$item->invoice_id = $this->get_id();
1702
+            $item->invoice_id = $this->get_id();
1703 1703
             $cart_details[]   = $item->prepare_data_for_saving();
1704 1704
         }
1705 1705
 
1706 1706
         return $cart_details;
1707
-	}
1707
+    }
1708 1708
 
1709
-	/**
1710
-	 * Retrieves the recurring item.
1711
-	 *
1712
-	 * @return null|GetPaid_Form_Item|int
1713
-	 */
1714
-	public function get_recurring( $object = false ) {
1709
+    /**
1710
+     * Retrieves the recurring item.
1711
+     *
1712
+     * @return null|GetPaid_Form_Item|int
1713
+     */
1714
+    public function get_recurring( $object = false ) {
1715 1715
 
1716
-		// Are we returning an object?
1716
+        // Are we returning an object?
1717 1717
         if ( $object ) {
1718 1718
             return $this->get_item( $this->recurring_item );
1719 1719
         }
@@ -1721,100 +1721,100 @@  discard block
 block discarded – undo
1721 1721
         return $this->recurring_item;
1722 1722
     }
1723 1723
 
1724
-	/**
1725
-	 * Retrieves the subscription name.
1726
-	 *
1727
-	 * @since 1.0.19
1728
-	 * @return string
1729
-	 */
1730
-	public function get_subscription_name() {
1724
+    /**
1725
+     * Retrieves the subscription name.
1726
+     *
1727
+     * @since 1.0.19
1728
+     * @return string
1729
+     */
1730
+    public function get_subscription_name() {
1731 1731
 
1732
-		// Retrieve the recurring name
1732
+        // Retrieve the recurring name
1733 1733
         $item = $this->get_recurring( true );
1734 1734
 
1735
-		// Abort if it does not exist.
1735
+        // Abort if it does not exist.
1736 1736
         if ( empty( $item ) ) {
1737 1737
             return '';
1738 1738
         }
1739 1739
 
1740
-		// Return the item name.
1740
+        // Return the item name.
1741 1741
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1742
-	}
1743
-
1744
-	/**
1745
-	 * Retrieves the view url.
1746
-	 *
1747
-	 * @since 1.0.19
1748
-	 * @return string
1749
-	 */
1750
-	public function get_view_url() {
1742
+    }
1743
+
1744
+    /**
1745
+     * Retrieves the view url.
1746
+     *
1747
+     * @since 1.0.19
1748
+     * @return string
1749
+     */
1750
+    public function get_view_url() {
1751 1751
         $invoice_url = get_permalink( $this->get_id() );
1752
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1752
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1753 1753
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1754
-	}
1754
+    }
1755 1755
 
1756
-	/**
1757
-	 * Retrieves the payment url.
1758
-	 *
1759
-	 * @since 1.0.19
1760
-	 * @return string
1761
-	 */
1762
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1756
+    /**
1757
+     * Retrieves the payment url.
1758
+     *
1759
+     * @since 1.0.19
1760
+     * @return string
1761
+     */
1762
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1763 1763
 
1764
-		// Retrieve the checkout url.
1764
+        // Retrieve the checkout url.
1765 1765
         $pay_url = wpinv_get_checkout_uri();
1766 1766
 
1767
-		// Maybe force ssl.
1767
+        // Maybe force ssl.
1768 1768
         if ( is_ssl() ) {
1769 1769
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1770 1770
         }
1771 1771
 
1772
-		// Add the invoice key.
1773
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1772
+        // Add the invoice key.
1773
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1774 1774
 
1775
-		// (Maybe?) add a secret
1775
+        // (Maybe?) add a secret
1776 1776
         if ( $secret ) {
1777 1777
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1778 1778
         }
1779 1779
 
1780 1780
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1781
-	}
1781
+    }
1782 1782
 	
1783
-	/**
1784
-	 * Retrieves the receipt url.
1785
-	 *
1786
-	 * @since 1.0.19
1787
-	 * @return string
1788
-	 */
1789
-	public function get_receipt_url() {
1790
-
1791
-		// Retrieve the checkout url.
1783
+    /**
1784
+     * Retrieves the receipt url.
1785
+     *
1786
+     * @since 1.0.19
1787
+     * @return string
1788
+     */
1789
+    public function get_receipt_url() {
1790
+
1791
+        // Retrieve the checkout url.
1792 1792
         $receipt_url = wpinv_get_success_page_uri();
1793 1793
 
1794
-		// Maybe force ssl.
1794
+        // Maybe force ssl.
1795 1795
         if ( is_ssl() ) {
1796 1796
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1797 1797
         }
1798 1798
 
1799
-		// Add the invoice key.
1800
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1799
+        // Add the invoice key.
1800
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1801 1801
 
1802 1802
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1803 1803
     }
1804 1804
 
1805 1805
     /**
1806
-	 * Magic method for accessing invoice properties.
1807
-	 *
1808
-	 * @since 1.0.15
1809
-	 * @access public
1810
-	 *
1811
-	 * @param string $key Discount data to retrieve
1812
-	 * @param  string $context View or edit context.
1813
-	 * @return mixed Value of the given invoice property (if set).
1814
-	 */
1815
-	public function get( $key, $context = 'view' ) {
1806
+     * Magic method for accessing invoice properties.
1807
+     *
1808
+     * @since 1.0.15
1809
+     * @access public
1810
+     *
1811
+     * @param string $key Discount data to retrieve
1812
+     * @param  string $context View or edit context.
1813
+     * @return mixed Value of the given invoice property (if set).
1814
+     */
1815
+    public function get( $key, $context = 'view' ) {
1816 1816
         return $this->get_prop( $key, $context );
1817
-	}
1817
+    }
1818 1818
 
1819 1819
     /*
1820 1820
 	|--------------------------------------------------------------------------
@@ -1827,130 +1827,130 @@  discard block
 block discarded – undo
1827 1827
     */
1828 1828
 
1829 1829
     /**
1830
-	 * Magic method for setting invoice properties.
1831
-	 *
1832
-	 * @since 1.0.19
1833
-	 * @access public
1834
-	 *
1835
-	 * @param string $key Discount data to retrieve
1836
-	 * @param  mixed $value new value.
1837
-	 * @return mixed Value of the given invoice property (if set).
1838
-	 */
1839
-	public function set( $key, $value ) {
1830
+     * Magic method for setting invoice properties.
1831
+     *
1832
+     * @since 1.0.19
1833
+     * @access public
1834
+     *
1835
+     * @param string $key Discount data to retrieve
1836
+     * @param  mixed $value new value.
1837
+     * @return mixed Value of the given invoice property (if set).
1838
+     */
1839
+    public function set( $key, $value ) {
1840 1840
 
1841 1841
         $setter = "set_$key";
1842 1842
         if ( is_callable( array( $this, $setter ) ) ) {
1843 1843
             $this->{$setter}( $value );
1844 1844
         }
1845 1845
 
1846
-	}
1846
+    }
1847 1847
 
1848
-	/**
1849
-	 * Sets item status.
1850
-	 *
1851
-	 * @since 1.0.19
1852
-	 * @param string $new_status    New status.
1853
-	 * @param string $note          Optional note to add.
1854
-	 * @param bool   $manual_update Is this a manual status change?.
1855
-	 * @return array details of change.
1856
-	 */
1857
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1858
-		$old_status = $this->get_status();
1848
+    /**
1849
+     * Sets item status.
1850
+     *
1851
+     * @since 1.0.19
1852
+     * @param string $new_status    New status.
1853
+     * @param string $note          Optional note to add.
1854
+     * @param bool   $manual_update Is this a manual status change?.
1855
+     * @return array details of change.
1856
+     */
1857
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
1858
+        $old_status = $this->get_status();
1859 1859
 
1860
-		$statuses = $this->get_all_statuses();
1860
+        $statuses = $this->get_all_statuses();
1861 1861
 
1862
-		if ( isset( $statuses[ 'draft' ] ) ) {
1863
-			unset( $statuses[ 'draft' ] );
1864
-		}
1862
+        if ( isset( $statuses[ 'draft' ] ) ) {
1863
+            unset( $statuses[ 'draft' ] );
1864
+        }
1865 1865
 
1866
-		$this->set_prop( 'status', $new_status );
1866
+        $this->set_prop( 'status', $new_status );
1867 1867
 
1868
-		// If setting the status, ensure it's set to a valid status.
1869
-		if ( true === $this->object_read ) {
1868
+        // If setting the status, ensure it's set to a valid status.
1869
+        if ( true === $this->object_read ) {
1870 1870
 
1871
-			// Only allow valid new status.
1872
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1873
-				$new_status = 'wpi-pending';
1874
-			}
1871
+            // Only allow valid new status.
1872
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
1873
+                $new_status = 'wpi-pending';
1874
+            }
1875 1875
 
1876
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1877
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1878
-				$old_status = 'wpi-pending';
1879
-			}
1876
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1877
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1878
+                $old_status = 'wpi-pending';
1879
+            }
1880 1880
 
1881
-			// Paid - Renewal (i.e when duplicating a parent invoice )
1882
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1883
-				$old_status = 'wpi-pending';
1884
-			}
1881
+            // Paid - Renewal (i.e when duplicating a parent invoice )
1882
+            if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1883
+                $old_status = 'wpi-pending';
1884
+            }
1885 1885
 
1886
-		}
1886
+        }
1887 1887
 
1888
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1889
-			$this->status_transition = array(
1890
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1891
-				'to'     => $new_status,
1892
-				'note'   => $note,
1893
-				'manual' => (bool) $manual_update,
1894
-			);
1888
+        if ( true === $this->object_read && $old_status !== $new_status ) {
1889
+            $this->status_transition = array(
1890
+                'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1891
+                'to'     => $new_status,
1892
+                'note'   => $note,
1893
+                'manual' => (bool) $manual_update,
1894
+            );
1895 1895
 
1896
-			if ( $manual_update ) {
1897
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1898
-			}
1896
+            if ( $manual_update ) {
1897
+                do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1898
+            }
1899 1899
 
1900
-			$this->maybe_set_date_paid();
1900
+            $this->maybe_set_date_paid();
1901 1901
 
1902
-		}
1902
+        }
1903 1903
 
1904
-		return array(
1905
-			'from' => $old_status,
1906
-			'to'   => $new_status,
1907
-		);
1908
-	}
1904
+        return array(
1905
+            'from' => $old_status,
1906
+            'to'   => $new_status,
1907
+        );
1908
+    }
1909 1909
 
1910
-	/**
1911
-	 * Maybe set date paid.
1912
-	 *
1913
-	 * Sets the date paid variable when transitioning to the payment complete
1914
-	 * order status.
1915
-	 *
1916
-	 * @since 1.0.19
1917
-	 */
1918
-	public function maybe_set_date_paid() {
1910
+    /**
1911
+     * Maybe set date paid.
1912
+     *
1913
+     * Sets the date paid variable when transitioning to the payment complete
1914
+     * order status.
1915
+     *
1916
+     * @since 1.0.19
1917
+     */
1918
+    public function maybe_set_date_paid() {
1919 1919
 
1920
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1921
-			$this->set_date_completed( current_time( 'mysql' ) );
1922
-		}
1923
-	}
1920
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1921
+            $this->set_date_completed( current_time( 'mysql' ) );
1922
+        }
1923
+    }
1924 1924
 
1925 1925
     /**
1926
-	 * Set parent invoice ID.
1927
-	 *
1928
-	 * @since 1.0.19
1929
-	 */
1930
-	public function set_parent_id( $value ) {
1931
-		if ( $value && ( $value === $this->get_id() ) ) {
1932
-			return;
1933
-		}
1934
-		$this->set_prop( 'parent_id', absint( $value ) );
1926
+     * Set parent invoice ID.
1927
+     *
1928
+     * @since 1.0.19
1929
+     */
1930
+    public function set_parent_id( $value ) {
1931
+        if ( $value && ( $value === $this->get_id() ) ) {
1932
+            return;
1933
+        }
1934
+        $this->set_prop( 'parent_id', absint( $value ) );
1935 1935
     }
1936 1936
 
1937 1937
     /**
1938
-	 * Set plugin version when the invoice was created.
1939
-	 *
1940
-	 * @since 1.0.19
1941
-	 */
1942
-	public function set_version( $value ) {
1943
-		$this->set_prop( 'version', $value );
1938
+     * Set plugin version when the invoice was created.
1939
+     *
1940
+     * @since 1.0.19
1941
+     */
1942
+    public function set_version( $value ) {
1943
+        $this->set_prop( 'version', $value );
1944 1944
     }
1945
-
1946
-    /**
1947
-	 * Set date when the invoice was created.
1948
-	 *
1949
-	 * @since 1.0.19
1950
-	 * @param string $value Value to set.
1945
+
1946
+    /**
1947
+     * Set date when the invoice was created.
1948
+     *
1949
+     * @since 1.0.19
1950
+     * @param string $value Value to set.
1951 1951
      * @return bool Whether or not the date was set.
1952
-	 */
1953
-	public function set_date_created( $value ) {
1952
+     */
1953
+    public function set_date_created( $value ) {
1954 1954
         $date = strtotime( $value );
1955 1955
 
1956 1956
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1963,13 +1963,13 @@  discard block
 block discarded – undo
1963 1963
     }
1964 1964
 
1965 1965
     /**
1966
-	 * Set date invoice due date.
1967
-	 *
1968
-	 * @since 1.0.19
1969
-	 * @param string $value Value to set.
1966
+     * Set date invoice due date.
1967
+     *
1968
+     * @since 1.0.19
1969
+     * @param string $value Value to set.
1970 1970
      * @return bool Whether or not the date was set.
1971
-	 */
1972
-	public function set_due_date( $value ) {
1971
+     */
1972
+    public function set_due_date( $value ) {
1973 1973
         $date = strtotime( $value );
1974 1974
 
1975 1975
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1977,29 +1977,29 @@  discard block
 block discarded – undo
1977 1977
             return true;
1978 1978
         }
1979 1979
 
1980
-		$this->set_prop( 'due_date', '' );
1980
+        $this->set_prop( 'due_date', '' );
1981 1981
         return false;
1982 1982
 
1983 1983
     }
1984 1984
 
1985 1985
     /**
1986
-	 * Alias of self::set_due_date().
1987
-	 *
1988
-	 * @since 1.0.19
1989
-	 * @param  string $value New name.
1990
-	 */
1991
-	public function set_date_due( $value ) {
1992
-		$this->set_due_date( $value );
1986
+     * Alias of self::set_due_date().
1987
+     *
1988
+     * @since 1.0.19
1989
+     * @param  string $value New name.
1990
+     */
1991
+    public function set_date_due( $value ) {
1992
+        $this->set_due_date( $value );
1993 1993
     }
1994 1994
 
1995 1995
     /**
1996
-	 * Set date invoice was completed.
1997
-	 *
1998
-	 * @since 1.0.19
1999
-	 * @param string $value Value to set.
1996
+     * Set date invoice was completed.
1997
+     *
1998
+     * @since 1.0.19
1999
+     * @param string $value Value to set.
2000 2000
      * @return bool Whether or not the date was set.
2001
-	 */
2002
-	public function set_completed_date( $value ) {
2001
+     */
2002
+    public function set_completed_date( $value ) {
2003 2003
         $date = strtotime( $value );
2004 2004
 
2005 2005
         if ( $date && $value !== '0000-00-00 00:00:00'  ) {
@@ -2007,29 +2007,29 @@  discard block
 block discarded – undo
2007 2007
             return true;
2008 2008
         }
2009 2009
 
2010
-		$this->set_prop( 'completed_date', '' );
2010
+        $this->set_prop( 'completed_date', '' );
2011 2011
         return false;
2012 2012
 
2013 2013
     }
2014 2014
 
2015 2015
     /**
2016
-	 * Alias of self::set_completed_date().
2017
-	 *
2018
-	 * @since 1.0.19
2019
-	 * @param  string $value New name.
2020
-	 */
2021
-	public function set_date_completed( $value ) {
2022
-		$this->set_completed_date( $value );
2016
+     * Alias of self::set_completed_date().
2017
+     *
2018
+     * @since 1.0.19
2019
+     * @param  string $value New name.
2020
+     */
2021
+    public function set_date_completed( $value ) {
2022
+        $this->set_completed_date( $value );
2023 2023
     }
2024 2024
 
2025 2025
     /**
2026
-	 * Set date when the invoice was last modified.
2027
-	 *
2028
-	 * @since 1.0.19
2029
-	 * @param string $value Value to set.
2026
+     * Set date when the invoice was last modified.
2027
+     *
2028
+     * @since 1.0.19
2029
+     * @param string $value Value to set.
2030 2030
      * @return bool Whether or not the date was set.
2031
-	 */
2032
-	public function set_date_modified( $value ) {
2031
+     */
2032
+    public function set_date_modified( $value ) {
2033 2033
         $date = strtotime( $value );
2034 2034
 
2035 2035
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2037,706 +2037,706 @@  discard block
 block discarded – undo
2037 2037
             return true;
2038 2038
         }
2039 2039
 
2040
-		$this->set_prop( 'date_modified', '' );
2040
+        $this->set_prop( 'date_modified', '' );
2041 2041
         return false;
2042 2042
 
2043 2043
     }
2044 2044
 
2045 2045
     /**
2046
-	 * Set the invoice number.
2047
-	 *
2048
-	 * @since 1.0.19
2049
-	 * @param  string $value New number.
2050
-	 */
2051
-	public function set_number( $value ) {
2046
+     * Set the invoice number.
2047
+     *
2048
+     * @since 1.0.19
2049
+     * @param  string $value New number.
2050
+     */
2051
+    public function set_number( $value ) {
2052 2052
         $number = sanitize_text_field( $value );
2053
-		$this->set_prop( 'number', $number );
2053
+        $this->set_prop( 'number', $number );
2054 2054
     }
2055 2055
 
2056 2056
     /**
2057
-	 * Set the invoice type.
2058
-	 *
2059
-	 * @since 1.0.19
2060
-	 * @param  string $value Type.
2061
-	 */
2062
-	public function set_type( $value ) {
2057
+     * Set the invoice type.
2058
+     *
2059
+     * @since 1.0.19
2060
+     * @param  string $value Type.
2061
+     */
2062
+    public function set_type( $value ) {
2063 2063
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2064
-		$this->set_prop( 'type', $type );
2065
-	}
2064
+        $this->set_prop( 'type', $type );
2065
+    }
2066 2066
 
2067 2067
     /**
2068
-	 * Set the invoice post type.
2069
-	 *
2070
-	 * @since 1.0.19
2071
-	 * @param  string $value Post type.
2072
-	 */
2073
-	public function set_post_type( $value ) {
2068
+     * Set the invoice post type.
2069
+     *
2070
+     * @since 1.0.19
2071
+     * @param  string $value Post type.
2072
+     */
2073
+    public function set_post_type( $value ) {
2074 2074
         if ( getpaid_is_invoice_post_type( $value ) ) {
2075
-			$this->set_type( $value );
2075
+            $this->set_type( $value );
2076 2076
             $this->set_prop( 'post_type', $value );
2077 2077
         }
2078 2078
     }
2079 2079
 
2080 2080
     /**
2081
-	 * Set the invoice key.
2082
-	 *
2083
-	 * @since 1.0.19
2084
-	 * @param  string $value New key.
2085
-	 */
2086
-	public function set_key( $value ) {
2081
+     * Set the invoice key.
2082
+     *
2083
+     * @since 1.0.19
2084
+     * @param  string $value New key.
2085
+     */
2086
+    public function set_key( $value ) {
2087 2087
         $key = sanitize_text_field( $value );
2088
-		$this->set_prop( 'key', $key );
2088
+        $this->set_prop( 'key', $key );
2089 2089
     }
2090 2090
 
2091 2091
     /**
2092
-	 * Set the invoice mode.
2093
-	 *
2094
-	 * @since 1.0.19
2095
-	 * @param  string $value mode.
2096
-	 */
2097
-	public function set_mode( $value ) {
2092
+     * Set the invoice mode.
2093
+     *
2094
+     * @since 1.0.19
2095
+     * @param  string $value mode.
2096
+     */
2097
+    public function set_mode( $value ) {
2098 2098
         if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2099 2099
             $this->set_prop( 'value', $value );
2100 2100
         }
2101 2101
     }
2102 2102
 
2103 2103
     /**
2104
-	 * Set the invoice path.
2105
-	 *
2106
-	 * @since 1.0.19
2107
-	 * @param  string $value path.
2108
-	 */
2109
-	public function set_path( $value ) {
2104
+     * Set the invoice path.
2105
+     *
2106
+     * @since 1.0.19
2107
+     * @param  string $value path.
2108
+     */
2109
+    public function set_path( $value ) {
2110 2110
         $this->set_prop( 'path', $value );
2111 2111
     }
2112 2112
 
2113 2113
     /**
2114
-	 * Set the invoice name.
2115
-	 *
2116
-	 * @since 1.0.19
2117
-	 * @param  string $value New name.
2118
-	 */
2119
-	public function set_name( $value ) {
2114
+     * Set the invoice name.
2115
+     *
2116
+     * @since 1.0.19
2117
+     * @param  string $value New name.
2118
+     */
2119
+    public function set_name( $value ) {
2120 2120
         $name = sanitize_text_field( $value );
2121
-		$this->set_prop( 'name', $name );
2121
+        $this->set_prop( 'name', $name );
2122 2122
     }
2123 2123
 
2124 2124
     /**
2125
-	 * Alias of self::set_name().
2126
-	 *
2127
-	 * @since 1.0.19
2128
-	 * @param  string $value New name.
2129
-	 */
2130
-	public function set_title( $value ) {
2131
-		$this->set_name( $value );
2125
+     * Alias of self::set_name().
2126
+     *
2127
+     * @since 1.0.19
2128
+     * @param  string $value New name.
2129
+     */
2130
+    public function set_title( $value ) {
2131
+        $this->set_name( $value );
2132 2132
     }
2133 2133
 
2134 2134
     /**
2135
-	 * Set the invoice description.
2136
-	 *
2137
-	 * @since 1.0.19
2138
-	 * @param  string $value New description.
2139
-	 */
2140
-	public function set_description( $value ) {
2135
+     * Set the invoice description.
2136
+     *
2137
+     * @since 1.0.19
2138
+     * @param  string $value New description.
2139
+     */
2140
+    public function set_description( $value ) {
2141 2141
         $description = wp_kses_post( $value );
2142
-		return $this->set_prop( 'description', $description );
2142
+        return $this->set_prop( 'description', $description );
2143 2143
     }
2144 2144
 
2145 2145
     /**
2146
-	 * Alias of self::set_description().
2147
-	 *
2148
-	 * @since 1.0.19
2149
-	 * @param  string $value New description.
2150
-	 */
2151
-	public function set_excerpt( $value ) {
2152
-		$this->set_description( $value );
2146
+     * Alias of self::set_description().
2147
+     *
2148
+     * @since 1.0.19
2149
+     * @param  string $value New description.
2150
+     */
2151
+    public function set_excerpt( $value ) {
2152
+        $this->set_description( $value );
2153 2153
     }
2154 2154
 
2155 2155
     /**
2156
-	 * Alias of self::set_description().
2157
-	 *
2158
-	 * @since 1.0.19
2159
-	 * @param  string $value New description.
2160
-	 */
2161
-	public function set_summary( $value ) {
2162
-		$this->set_description( $value );
2156
+     * Alias of self::set_description().
2157
+     *
2158
+     * @since 1.0.19
2159
+     * @param  string $value New description.
2160
+     */
2161
+    public function set_summary( $value ) {
2162
+        $this->set_description( $value );
2163 2163
     }
2164 2164
 
2165 2165
     /**
2166
-	 * Set the receiver of the invoice.
2167
-	 *
2168
-	 * @since 1.0.19
2169
-	 * @param  int $value New author.
2170
-	 */
2171
-	public function set_author( $value ) {
2172
-		$user = get_user_by( 'id', (int) $value );
2166
+     * Set the receiver of the invoice.
2167
+     *
2168
+     * @since 1.0.19
2169
+     * @param  int $value New author.
2170
+     */
2171
+    public function set_author( $value ) {
2172
+        $user = get_user_by( 'id', (int) $value );
2173 2173
 
2174
-		if ( $user && $user->ID ) {
2175
-			$this->set_prop( 'author', $user->ID );
2176
-			$this->set_prop( 'email', $user->user_email );
2177
-		}
2174
+        if ( $user && $user->ID ) {
2175
+            $this->set_prop( 'author', $user->ID );
2176
+            $this->set_prop( 'email', $user->user_email );
2177
+        }
2178 2178
 		
2179 2179
     }
2180 2180
 
2181 2181
     /**
2182
-	 * Alias of self::set_author().
2183
-	 *
2184
-	 * @since 1.0.19
2185
-	 * @param  int $value New user id.
2186
-	 */
2187
-	public function set_user_id( $value ) {
2188
-		$this->set_author( $value );
2182
+     * Alias of self::set_author().
2183
+     *
2184
+     * @since 1.0.19
2185
+     * @param  int $value New user id.
2186
+     */
2187
+    public function set_user_id( $value ) {
2188
+        $this->set_author( $value );
2189
+    }
2190
+
2191
+    /**
2192
+     * Alias of self::set_author().
2193
+     *
2194
+     * @since 1.0.19
2195
+     * @param  int $value New user id.
2196
+     */
2197
+    public function set_customer_id( $value ) {
2198
+        $this->set_author( $value );
2199
+    }
2200
+
2201
+    /**
2202
+     * Set the customer's ip.
2203
+     *
2204
+     * @since 1.0.19
2205
+     * @param  string $value ip address.
2206
+     */
2207
+    public function set_ip( $value ) {
2208
+        $this->set_prop( 'ip', $value );
2209
+    }
2210
+
2211
+    /**
2212
+     * Alias of self::set_ip().
2213
+     *
2214
+     * @since 1.0.19
2215
+     * @param  string $value ip address.
2216
+     */
2217
+    public function set_user_ip( $value ) {
2218
+        $this->set_ip( $value );
2189 2219
     }
2190 2220
 
2191 2221
     /**
2192
-	 * Alias of self::set_author().
2193
-	 *
2194
-	 * @since 1.0.19
2195
-	 * @param  int $value New user id.
2196
-	 */
2197
-	public function set_customer_id( $value ) {
2198
-		$this->set_author( $value );
2222
+     * Set the customer's first name.
2223
+     *
2224
+     * @since 1.0.19
2225
+     * @param  string $value first name.
2226
+     */
2227
+    public function set_first_name( $value ) {
2228
+        $this->set_prop( 'first_name', $value );
2199 2229
     }
2200 2230
 
2201 2231
     /**
2202
-	 * Set the customer's ip.
2203
-	 *
2204
-	 * @since 1.0.19
2205
-	 * @param  string $value ip address.
2206
-	 */
2207
-	public function set_ip( $value ) {
2208
-		$this->set_prop( 'ip', $value );
2232
+     * Alias of self::set_first_name().
2233
+     *
2234
+     * @since 1.0.19
2235
+     * @param  string $value first name.
2236
+     */
2237
+    public function set_user_first_name( $value ) {
2238
+        $this->set_first_name( $value );
2209 2239
     }
2210 2240
 
2211 2241
     /**
2212
-	 * Alias of self::set_ip().
2213
-	 *
2214
-	 * @since 1.0.19
2215
-	 * @param  string $value ip address.
2216
-	 */
2217
-	public function set_user_ip( $value ) {
2218
-		$this->set_ip( $value );
2242
+     * Alias of self::set_first_name().
2243
+     *
2244
+     * @since 1.0.19
2245
+     * @param  string $value first name.
2246
+     */
2247
+    public function set_customer_first_name( $value ) {
2248
+        $this->set_first_name( $value );
2219 2249
     }
2220 2250
 
2221 2251
     /**
2222
-	 * Set the customer's first name.
2223
-	 *
2224
-	 * @since 1.0.19
2225
-	 * @param  string $value first name.
2226
-	 */
2227
-	public function set_first_name( $value ) {
2228
-		$this->set_prop( 'first_name', $value );
2252
+     * Set the customer's last name.
2253
+     *
2254
+     * @since 1.0.19
2255
+     * @param  string $value last name.
2256
+     */
2257
+    public function set_last_name( $value ) {
2258
+        $this->set_prop( 'last_name', $value );
2229 2259
     }
2230 2260
 
2231 2261
     /**
2232
-	 * Alias of self::set_first_name().
2233
-	 *
2234
-	 * @since 1.0.19
2235
-	 * @param  string $value first name.
2236
-	 */
2237
-	public function set_user_first_name( $value ) {
2238
-		$this->set_first_name( $value );
2262
+     * Alias of self::set_last_name().
2263
+     *
2264
+     * @since 1.0.19
2265
+     * @param  string $value last name.
2266
+     */
2267
+    public function set_user_last_name( $value ) {
2268
+        $this->set_last_name( $value );
2239 2269
     }
2240 2270
 
2241 2271
     /**
2242
-	 * Alias of self::set_first_name().
2243
-	 *
2244
-	 * @since 1.0.19
2245
-	 * @param  string $value first name.
2246
-	 */
2247
-	public function set_customer_first_name( $value ) {
2248
-		$this->set_first_name( $value );
2272
+     * Alias of self::set_last_name().
2273
+     *
2274
+     * @since 1.0.19
2275
+     * @param  string $value last name.
2276
+     */
2277
+    public function set_customer_last_name( $value ) {
2278
+        $this->set_last_name( $value );
2249 2279
     }
2250 2280
 
2251 2281
     /**
2252
-	 * Set the customer's last name.
2253
-	 *
2254
-	 * @since 1.0.19
2255
-	 * @param  string $value last name.
2256
-	 */
2257
-	public function set_last_name( $value ) {
2258
-		$this->set_prop( 'last_name', $value );
2282
+     * Set the customer's phone number.
2283
+     *
2284
+     * @since 1.0.19
2285
+     * @param  string $value phone.
2286
+     */
2287
+    public function set_phone( $value ) {
2288
+        $this->set_prop( 'phone', $value );
2259 2289
     }
2260 2290
 
2261 2291
     /**
2262
-	 * Alias of self::set_last_name().
2263
-	 *
2264
-	 * @since 1.0.19
2265
-	 * @param  string $value last name.
2266
-	 */
2267
-	public function set_user_last_name( $value ) {
2268
-		$this->set_last_name( $value );
2292
+     * Alias of self::set_phone().
2293
+     *
2294
+     * @since 1.0.19
2295
+     * @param  string $value phone.
2296
+     */
2297
+    public function set_user_phone( $value ) {
2298
+        $this->set_phone( $value );
2269 2299
     }
2270 2300
 
2271 2301
     /**
2272
-	 * Alias of self::set_last_name().
2273
-	 *
2274
-	 * @since 1.0.19
2275
-	 * @param  string $value last name.
2276
-	 */
2277
-	public function set_customer_last_name( $value ) {
2278
-		$this->set_last_name( $value );
2302
+     * Alias of self::set_phone().
2303
+     *
2304
+     * @since 1.0.19
2305
+     * @param  string $value phone.
2306
+     */
2307
+    public function set_customer_phone( $value ) {
2308
+        $this->set_phone( $value );
2279 2309
     }
2280 2310
 
2281 2311
     /**
2282
-	 * Set the customer's phone number.
2283
-	 *
2284
-	 * @since 1.0.19
2285
-	 * @param  string $value phone.
2286
-	 */
2287
-	public function set_phone( $value ) {
2288
-		$this->set_prop( 'phone', $value );
2312
+     * Alias of self::set_phone().
2313
+     *
2314
+     * @since 1.0.19
2315
+     * @param  string $value phone.
2316
+     */
2317
+    public function set_phone_number( $value ) {
2318
+        $this->set_phone( $value );
2289 2319
     }
2290 2320
 
2291 2321
     /**
2292
-	 * Alias of self::set_phone().
2293
-	 *
2294
-	 * @since 1.0.19
2295
-	 * @param  string $value phone.
2296
-	 */
2297
-	public function set_user_phone( $value ) {
2298
-		$this->set_phone( $value );
2322
+     * Set the customer's email address.
2323
+     *
2324
+     * @since 1.0.19
2325
+     * @param  string $value email address.
2326
+     */
2327
+    public function set_email( $value ) {
2328
+        $this->set_prop( 'email', $value );
2299 2329
     }
2300 2330
 
2301 2331
     /**
2302
-	 * Alias of self::set_phone().
2303
-	 *
2304
-	 * @since 1.0.19
2305
-	 * @param  string $value phone.
2306
-	 */
2307
-	public function set_customer_phone( $value ) {
2308
-		$this->set_phone( $value );
2332
+     * Alias of self::set_email().
2333
+     *
2334
+     * @since 1.0.19
2335
+     * @param  string $value email address.
2336
+     */
2337
+    public function set_user_email( $value ) {
2338
+        $this->set_email( $value );
2309 2339
     }
2310 2340
 
2311 2341
     /**
2312
-	 * Alias of self::set_phone().
2313
-	 *
2314
-	 * @since 1.0.19
2315
-	 * @param  string $value phone.
2316
-	 */
2317
-	public function set_phone_number( $value ) {
2318
-		$this->set_phone( $value );
2342
+     * Alias of self::set_email().
2343
+     *
2344
+     * @since 1.0.19
2345
+     * @param  string $value email address.
2346
+     */
2347
+    public function set_email_address( $value ) {
2348
+        $this->set_email( $value );
2319 2349
     }
2320 2350
 
2321 2351
     /**
2322
-	 * Set the customer's email address.
2323
-	 *
2324
-	 * @since 1.0.19
2325
-	 * @param  string $value email address.
2326
-	 */
2327
-	public function set_email( $value ) {
2328
-		$this->set_prop( 'email', $value );
2352
+     * Alias of self::set_email().
2353
+     *
2354
+     * @since 1.0.19
2355
+     * @param  string $value email address.
2356
+     */
2357
+    public function set_customer_email( $value ) {
2358
+        $this->set_email( $value );
2329 2359
     }
2330 2360
 
2331 2361
     /**
2332
-	 * Alias of self::set_email().
2333
-	 *
2334
-	 * @since 1.0.19
2335
-	 * @param  string $value email address.
2336
-	 */
2337
-	public function set_user_email( $value ) {
2338
-		$this->set_email( $value );
2362
+     * Set the customer's country.
2363
+     *
2364
+     * @since 1.0.19
2365
+     * @param  string $value country.
2366
+     */
2367
+    public function set_country( $value ) {
2368
+        $this->set_prop( 'country', $value );
2339 2369
     }
2340 2370
 
2341 2371
     /**
2342
-	 * Alias of self::set_email().
2343
-	 *
2344
-	 * @since 1.0.19
2345
-	 * @param  string $value email address.
2346
-	 */
2347
-	public function set_email_address( $value ) {
2348
-		$this->set_email( $value );
2372
+     * Alias of self::set_country().
2373
+     *
2374
+     * @since 1.0.19
2375
+     * @param  string $value country.
2376
+     */
2377
+    public function set_user_country( $value ) {
2378
+        $this->set_country( $value );
2349 2379
     }
2350 2380
 
2351 2381
     /**
2352
-	 * Alias of self::set_email().
2353
-	 *
2354
-	 * @since 1.0.19
2355
-	 * @param  string $value email address.
2356
-	 */
2357
-	public function set_customer_email( $value ) {
2358
-		$this->set_email( $value );
2382
+     * Alias of self::set_country().
2383
+     *
2384
+     * @since 1.0.19
2385
+     * @param  string $value country.
2386
+     */
2387
+    public function set_customer_country( $value ) {
2388
+        $this->set_country( $value );
2359 2389
     }
2360 2390
 
2361 2391
     /**
2362
-	 * Set the customer's country.
2363
-	 *
2364
-	 * @since 1.0.19
2365
-	 * @param  string $value country.
2366
-	 */
2367
-	public function set_country( $value ) {
2368
-		$this->set_prop( 'country', $value );
2392
+     * Set the customer's state.
2393
+     *
2394
+     * @since 1.0.19
2395
+     * @param  string $value state.
2396
+     */
2397
+    public function set_state( $value ) {
2398
+        $this->set_prop( 'state', $value );
2369 2399
     }
2370 2400
 
2371 2401
     /**
2372
-	 * Alias of self::set_country().
2373
-	 *
2374
-	 * @since 1.0.19
2375
-	 * @param  string $value country.
2376
-	 */
2377
-	public function set_user_country( $value ) {
2378
-		$this->set_country( $value );
2402
+     * Alias of self::set_state().
2403
+     *
2404
+     * @since 1.0.19
2405
+     * @param  string $value state.
2406
+     */
2407
+    public function set_user_state( $value ) {
2408
+        $this->set_state( $value );
2379 2409
     }
2380 2410
 
2381 2411
     /**
2382
-	 * Alias of self::set_country().
2383
-	 *
2384
-	 * @since 1.0.19
2385
-	 * @param  string $value country.
2386
-	 */
2387
-	public function set_customer_country( $value ) {
2388
-		$this->set_country( $value );
2412
+     * Alias of self::set_state().
2413
+     *
2414
+     * @since 1.0.19
2415
+     * @param  string $value state.
2416
+     */
2417
+    public function set_customer_state( $value ) {
2418
+        $this->set_state( $value );
2389 2419
     }
2390 2420
 
2391 2421
     /**
2392
-	 * Set the customer's state.
2393
-	 *
2394
-	 * @since 1.0.19
2395
-	 * @param  string $value state.
2396
-	 */
2397
-	public function set_state( $value ) {
2398
-		$this->set_prop( 'state', $value );
2422
+     * Set the customer's city.
2423
+     *
2424
+     * @since 1.0.19
2425
+     * @param  string $value city.
2426
+     */
2427
+    public function set_city( $value ) {
2428
+        $this->set_prop( 'city', $value );
2399 2429
     }
2400 2430
 
2401 2431
     /**
2402
-	 * Alias of self::set_state().
2403
-	 *
2404
-	 * @since 1.0.19
2405
-	 * @param  string $value state.
2406
-	 */
2407
-	public function set_user_state( $value ) {
2408
-		$this->set_state( $value );
2432
+     * Alias of self::set_city().
2433
+     *
2434
+     * @since 1.0.19
2435
+     * @param  string $value city.
2436
+     */
2437
+    public function set_user_city( $value ) {
2438
+        $this->set_city( $value );
2409 2439
     }
2410 2440
 
2411 2441
     /**
2412
-	 * Alias of self::set_state().
2413
-	 *
2414
-	 * @since 1.0.19
2415
-	 * @param  string $value state.
2416
-	 */
2417
-	public function set_customer_state( $value ) {
2418
-		$this->set_state( $value );
2442
+     * Alias of self::set_city().
2443
+     *
2444
+     * @since 1.0.19
2445
+     * @param  string $value city.
2446
+     */
2447
+    public function set_customer_city( $value ) {
2448
+        $this->set_city( $value );
2419 2449
     }
2420 2450
 
2421 2451
     /**
2422
-	 * Set the customer's city.
2423
-	 *
2424
-	 * @since 1.0.19
2425
-	 * @param  string $value city.
2426
-	 */
2427
-	public function set_city( $value ) {
2428
-		$this->set_prop( 'city', $value );
2452
+     * Set the customer's zip code.
2453
+     *
2454
+     * @since 1.0.19
2455
+     * @param  string $value zip.
2456
+     */
2457
+    public function set_zip( $value ) {
2458
+        $this->set_prop( 'zip', $value );
2429 2459
     }
2430 2460
 
2431 2461
     /**
2432
-	 * Alias of self::set_city().
2433
-	 *
2434
-	 * @since 1.0.19
2435
-	 * @param  string $value city.
2436
-	 */
2437
-	public function set_user_city( $value ) {
2438
-		$this->set_city( $value );
2462
+     * Alias of self::set_zip().
2463
+     *
2464
+     * @since 1.0.19
2465
+     * @param  string $value zip.
2466
+     */
2467
+    public function set_user_zip( $value ) {
2468
+        $this->set_zip( $value );
2439 2469
     }
2440 2470
 
2441 2471
     /**
2442
-	 * Alias of self::set_city().
2443
-	 *
2444
-	 * @since 1.0.19
2445
-	 * @param  string $value city.
2446
-	 */
2447
-	public function set_customer_city( $value ) {
2448
-		$this->set_city( $value );
2472
+     * Alias of self::set_zip().
2473
+     *
2474
+     * @since 1.0.19
2475
+     * @param  string $value zip.
2476
+     */
2477
+    public function set_customer_zip( $value ) {
2478
+        $this->set_zip( $value );
2449 2479
     }
2450 2480
 
2451 2481
     /**
2452
-	 * Set the customer's zip code.
2453
-	 *
2454
-	 * @since 1.0.19
2455
-	 * @param  string $value zip.
2456
-	 */
2457
-	public function set_zip( $value ) {
2458
-		$this->set_prop( 'zip', $value );
2482
+     * Set the customer's company.
2483
+     *
2484
+     * @since 1.0.19
2485
+     * @param  string $value company.
2486
+     */
2487
+    public function set_company( $value ) {
2488
+        $this->set_prop( 'company', $value );
2459 2489
     }
2460 2490
 
2461 2491
     /**
2462
-	 * Alias of self::set_zip().
2463
-	 *
2464
-	 * @since 1.0.19
2465
-	 * @param  string $value zip.
2466
-	 */
2467
-	public function set_user_zip( $value ) {
2468
-		$this->set_zip( $value );
2492
+     * Alias of self::set_company().
2493
+     *
2494
+     * @since 1.0.19
2495
+     * @param  string $value company.
2496
+     */
2497
+    public function set_user_company( $value ) {
2498
+        $this->set_company( $value );
2469 2499
     }
2470 2500
 
2471 2501
     /**
2472
-	 * Alias of self::set_zip().
2473
-	 *
2474
-	 * @since 1.0.19
2475
-	 * @param  string $value zip.
2476
-	 */
2477
-	public function set_customer_zip( $value ) {
2478
-		$this->set_zip( $value );
2502
+     * Alias of self::set_company().
2503
+     *
2504
+     * @since 1.0.19
2505
+     * @param  string $value company.
2506
+     */
2507
+    public function set_customer_company( $value ) {
2508
+        $this->set_company( $value );
2479 2509
     }
2480 2510
 
2481 2511
     /**
2482
-	 * Set the customer's company.
2483
-	 *
2484
-	 * @since 1.0.19
2485
-	 * @param  string $value company.
2486
-	 */
2487
-	public function set_company( $value ) {
2488
-		$this->set_prop( 'company', $value );
2512
+     * Set the customer's var number.
2513
+     *
2514
+     * @since 1.0.19
2515
+     * @param  string $value var number.
2516
+     */
2517
+    public function set_vat_number( $value ) {
2518
+        $this->set_prop( 'vat_number', $value );
2489 2519
     }
2490 2520
 
2491 2521
     /**
2492
-	 * Alias of self::set_company().
2493
-	 *
2494
-	 * @since 1.0.19
2495
-	 * @param  string $value company.
2496
-	 */
2497
-	public function set_user_company( $value ) {
2498
-		$this->set_company( $value );
2522
+     * Alias of self::set_vat_number().
2523
+     *
2524
+     * @since 1.0.19
2525
+     * @param  string $value var number.
2526
+     */
2527
+    public function set_user_vat_number( $value ) {
2528
+        $this->set_vat_number( $value );
2499 2529
     }
2500 2530
 
2501 2531
     /**
2502
-	 * Alias of self::set_company().
2503
-	 *
2504
-	 * @since 1.0.19
2505
-	 * @param  string $value company.
2506
-	 */
2507
-	public function set_customer_company( $value ) {
2508
-		$this->set_company( $value );
2532
+     * Alias of self::set_vat_number().
2533
+     *
2534
+     * @since 1.0.19
2535
+     * @param  string $value var number.
2536
+     */
2537
+    public function set_customer_vat_number( $value ) {
2538
+        $this->set_vat_number( $value );
2509 2539
     }
2510 2540
 
2511 2541
     /**
2512
-	 * Set the customer's var number.
2513
-	 *
2514
-	 * @since 1.0.19
2515
-	 * @param  string $value var number.
2516
-	 */
2517
-	public function set_vat_number( $value ) {
2518
-		$this->set_prop( 'vat_number', $value );
2542
+     * Set the customer's vat rate.
2543
+     *
2544
+     * @since 1.0.19
2545
+     * @param  string $value var rate.
2546
+     */
2547
+    public function set_vat_rate( $value ) {
2548
+        $this->set_prop( 'vat_rate', $value );
2519 2549
     }
2520 2550
 
2521 2551
     /**
2522
-	 * Alias of self::set_vat_number().
2523
-	 *
2524
-	 * @since 1.0.19
2525
-	 * @param  string $value var number.
2526
-	 */
2527
-	public function set_user_vat_number( $value ) {
2528
-		$this->set_vat_number( $value );
2552
+     * Alias of self::set_vat_rate().
2553
+     *
2554
+     * @since 1.0.19
2555
+     * @param  string $value var number.
2556
+     */
2557
+    public function set_user_vat_rate( $value ) {
2558
+        $this->set_vat_rate( $value );
2529 2559
     }
2530 2560
 
2531 2561
     /**
2532
-	 * Alias of self::set_vat_number().
2533
-	 *
2534
-	 * @since 1.0.19
2535
-	 * @param  string $value var number.
2536
-	 */
2537
-	public function set_customer_vat_number( $value ) {
2538
-		$this->set_vat_number( $value );
2562
+     * Alias of self::set_vat_rate().
2563
+     *
2564
+     * @since 1.0.19
2565
+     * @param  string $value var number.
2566
+     */
2567
+    public function set_customer_vat_rate( $value ) {
2568
+        $this->set_vat_rate( $value );
2539 2569
     }
2540 2570
 
2541 2571
     /**
2542
-	 * Set the customer's vat rate.
2543
-	 *
2544
-	 * @since 1.0.19
2545
-	 * @param  string $value var rate.
2546
-	 */
2547
-	public function set_vat_rate( $value ) {
2548
-		$this->set_prop( 'vat_rate', $value );
2572
+     * Set the customer's address.
2573
+     *
2574
+     * @since 1.0.19
2575
+     * @param  string $value address.
2576
+     */
2577
+    public function set_address( $value ) {
2578
+        $this->set_prop( 'address', $value );
2549 2579
     }
2550 2580
 
2551 2581
     /**
2552
-	 * Alias of self::set_vat_rate().
2553
-	 *
2554
-	 * @since 1.0.19
2555
-	 * @param  string $value var number.
2556
-	 */
2557
-	public function set_user_vat_rate( $value ) {
2558
-		$this->set_vat_rate( $value );
2582
+     * Alias of self::set_address().
2583
+     *
2584
+     * @since 1.0.19
2585
+     * @param  string $value address.
2586
+     */
2587
+    public function set_user_address( $value ) {
2588
+        $this->set_address( $value );
2559 2589
     }
2560 2590
 
2561 2591
     /**
2562
-	 * Alias of self::set_vat_rate().
2563
-	 *
2564
-	 * @since 1.0.19
2565
-	 * @param  string $value var number.
2566
-	 */
2567
-	public function set_customer_vat_rate( $value ) {
2568
-		$this->set_vat_rate( $value );
2592
+     * Alias of self::set_address().
2593
+     *
2594
+     * @since 1.0.19
2595
+     * @param  string $value address.
2596
+     */
2597
+    public function set_customer_address( $value ) {
2598
+        $this->set_address( $value );
2569 2599
     }
2570 2600
 
2571 2601
     /**
2572
-	 * Set the customer's address.
2573
-	 *
2574
-	 * @since 1.0.19
2575
-	 * @param  string $value address.
2576
-	 */
2577
-	public function set_address( $value ) {
2578
-		$this->set_prop( 'address', $value );
2602
+     * Set whether the customer has viewed the invoice or not.
2603
+     *
2604
+     * @since 1.0.19
2605
+     * @param  int|bool $value confirmed.
2606
+     */
2607
+    public function set_is_viewed( $value ) {
2608
+        $this->set_prop( 'is_viewed', $value );
2579 2609
     }
2580 2610
 
2581 2611
     /**
2582
-	 * Alias of self::set_address().
2583
-	 *
2584
-	 * @since 1.0.19
2585
-	 * @param  string $value address.
2586
-	 */
2587
-	public function set_user_address( $value ) {
2588
-		$this->set_address( $value );
2612
+     * Set extra email recipients.
2613
+     *
2614
+     * @since 1.0.19
2615
+     * @param  string $value email recipients.
2616
+     */
2617
+    public function set_email_cc( $value ) {
2618
+        $this->set_prop( 'email_cc', $value );
2589 2619
     }
2590 2620
 
2591 2621
     /**
2592
-	 * Alias of self::set_address().
2593
-	 *
2594
-	 * @since 1.0.19
2595
-	 * @param  string $value address.
2596
-	 */
2597
-	public function set_customer_address( $value ) {
2598
-		$this->set_address( $value );
2622
+     * Set the invoice template.
2623
+     *
2624
+     * @since 1.0.19
2625
+     * @param  string $value email recipients.
2626
+     */
2627
+    public function set_template( $value ) {
2628
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2629
+            $this->set_prop( 'template', $value );
2630
+        }
2599 2631
     }
2600 2632
 
2601 2633
     /**
2602
-	 * Set whether the customer has viewed the invoice or not.
2603
-	 *
2604
-	 * @since 1.0.19
2605
-	 * @param  int|bool $value confirmed.
2606
-	 */
2607
-	public function set_is_viewed( $value ) {
2608
-		$this->set_prop( 'is_viewed', $value );
2609
-	}
2610
-
2611
-	/**
2612
-	 * Set extra email recipients.
2613
-	 *
2614
-	 * @since 1.0.19
2615
-	 * @param  string $value email recipients.
2616
-	 */
2617
-	public function set_email_cc( $value ) {
2618
-		$this->set_prop( 'email_cc', $value );
2619
-	}
2620
-
2621
-	/**
2622
-	 * Set the invoice template.
2623
-	 *
2624
-	 * @since 1.0.19
2625
-	 * @param  string $value email recipients.
2626
-	 */
2627
-	public function set_template( $value ) {
2628
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2629
-			$this->set_prop( 'template', $value );
2630
-		}
2631
-	}
2632
-
2633
-	/**
2634
-	 * Set the customer's address confirmed status.
2635
-	 *
2636
-	 * @since 1.0.19
2637
-	 * @param  int|bool $value confirmed.
2638
-	 */
2639
-	public function set_address_confirmed( $value ) {
2640
-		$this->set_prop( 'address_confirmed', $value );
2634
+     * Set the customer's address confirmed status.
2635
+     *
2636
+     * @since 1.0.19
2637
+     * @param  int|bool $value confirmed.
2638
+     */
2639
+    public function set_address_confirmed( $value ) {
2640
+        $this->set_prop( 'address_confirmed', $value );
2641 2641
     }
2642 2642
 
2643 2643
     /**
2644
-	 * Alias of self::set_address_confirmed().
2645
-	 *
2646
-	 * @since 1.0.19
2647
-	 * @param  int|bool $value confirmed.
2648
-	 */
2649
-	public function set_user_address_confirmed( $value ) {
2650
-		$this->set_address_confirmed( $value );
2644
+     * Alias of self::set_address_confirmed().
2645
+     *
2646
+     * @since 1.0.19
2647
+     * @param  int|bool $value confirmed.
2648
+     */
2649
+    public function set_user_address_confirmed( $value ) {
2650
+        $this->set_address_confirmed( $value );
2651 2651
     }
2652 2652
 
2653 2653
     /**
2654
-	 * Alias of self::set_address_confirmed().
2655
-	 *
2656
-	 * @since 1.0.19
2657
-	 * @param  int|bool $value confirmed.
2658
-	 */
2659
-	public function set_customer_address_confirmed( $value ) {
2660
-		$this->set_address_confirmed( $value );
2654
+     * Alias of self::set_address_confirmed().
2655
+     *
2656
+     * @since 1.0.19
2657
+     * @param  int|bool $value confirmed.
2658
+     */
2659
+    public function set_customer_address_confirmed( $value ) {
2660
+        $this->set_address_confirmed( $value );
2661 2661
     }
2662 2662
 
2663 2663
     /**
2664
-	 * Set the invoice sub total.
2665
-	 *
2666
-	 * @since 1.0.19
2667
-	 * @param  float $value sub total.
2668
-	 */
2669
-	public function set_subtotal( $value ) {
2670
-		$this->set_prop( 'subtotal', $value );
2664
+     * Set the invoice sub total.
2665
+     *
2666
+     * @since 1.0.19
2667
+     * @param  float $value sub total.
2668
+     */
2669
+    public function set_subtotal( $value ) {
2670
+        $this->set_prop( 'subtotal', $value );
2671 2671
     }
2672 2672
 
2673 2673
     /**
2674
-	 * Set the invoice discount amount.
2675
-	 *
2676
-	 * @since 1.0.19
2677
-	 * @param  float $value discount total.
2678
-	 */
2679
-	public function set_total_discount( $value ) {
2680
-		$this->set_prop( 'total_discount', $value );
2674
+     * Set the invoice discount amount.
2675
+     *
2676
+     * @since 1.0.19
2677
+     * @param  float $value discount total.
2678
+     */
2679
+    public function set_total_discount( $value ) {
2680
+        $this->set_prop( 'total_discount', $value );
2681 2681
     }
2682 2682
 
2683 2683
     /**
2684
-	 * Alias of self::set_total_discount().
2685
-	 *
2686
-	 * @since 1.0.19
2687
-	 * @param  float $value discount total.
2688
-	 */
2689
-	public function set_discount( $value ) {
2690
-		$this->set_total_discount( $value );
2684
+     * Alias of self::set_total_discount().
2685
+     *
2686
+     * @since 1.0.19
2687
+     * @param  float $value discount total.
2688
+     */
2689
+    public function set_discount( $value ) {
2690
+        $this->set_total_discount( $value );
2691 2691
     }
2692 2692
 
2693 2693
     /**
2694
-	 * Set the invoice tax amount.
2695
-	 *
2696
-	 * @since 1.0.19
2697
-	 * @param  float $value tax total.
2698
-	 */
2699
-	public function set_total_tax( $value ) {
2700
-		$this->set_prop( 'total_tax', $value );
2694
+     * Set the invoice tax amount.
2695
+     *
2696
+     * @since 1.0.19
2697
+     * @param  float $value tax total.
2698
+     */
2699
+    public function set_total_tax( $value ) {
2700
+        $this->set_prop( 'total_tax', $value );
2701 2701
     }
2702 2702
 
2703 2703
     /**
2704
-	 * Alias of self::set_total_tax().
2705
-	 *
2706
-	 * @since 1.0.19
2707
-	 * @param  float $value tax total.
2708
-	 */
2709
-	public function set_tax_total( $value ) {
2710
-		$this->set_total_tax( $value );
2704
+     * Alias of self::set_total_tax().
2705
+     *
2706
+     * @since 1.0.19
2707
+     * @param  float $value tax total.
2708
+     */
2709
+    public function set_tax_total( $value ) {
2710
+        $this->set_total_tax( $value );
2711 2711
     }
2712 2712
 
2713 2713
     /**
2714
-	 * Set the invoice fees amount.
2715
-	 *
2716
-	 * @since 1.0.19
2717
-	 * @param  float $value fees total.
2718
-	 */
2719
-	public function set_total_fees( $value ) {
2720
-		$this->set_prop( 'total_fees', $value );
2714
+     * Set the invoice fees amount.
2715
+     *
2716
+     * @since 1.0.19
2717
+     * @param  float $value fees total.
2718
+     */
2719
+    public function set_total_fees( $value ) {
2720
+        $this->set_prop( 'total_fees', $value );
2721 2721
     }
2722 2722
 
2723 2723
     /**
2724
-	 * Alias of self::set_total_fees().
2725
-	 *
2726
-	 * @since 1.0.19
2727
-	 * @param  float $value fees total.
2728
-	 */
2729
-	public function set_fees_total( $value ) {
2730
-		$this->set_total_fees( $value );
2724
+     * Alias of self::set_total_fees().
2725
+     *
2726
+     * @since 1.0.19
2727
+     * @param  float $value fees total.
2728
+     */
2729
+    public function set_fees_total( $value ) {
2730
+        $this->set_total_fees( $value );
2731 2731
     }
2732 2732
 
2733 2733
     /**
2734
-	 * Set the invoice fees.
2735
-	 *
2736
-	 * @since 1.0.19
2737
-	 * @param  array $value fees.
2738
-	 */
2739
-	public function set_fees( $value ) {
2734
+     * Set the invoice fees.
2735
+     *
2736
+     * @since 1.0.19
2737
+     * @param  array $value fees.
2738
+     */
2739
+    public function set_fees( $value ) {
2740 2740
 
2741 2741
         $this->set_prop( 'fees', array() );
2742 2742
 
@@ -2754,23 +2754,23 @@  discard block
 block discarded – undo
2754 2754
     }
2755 2755
 
2756 2756
     /**
2757
-	 * Set the invoice taxes.
2758
-	 *
2759
-	 * @since 1.0.19
2760
-	 * @param  array $value taxes.
2761
-	 */
2762
-	public function set_taxes( $value ) {
2763
-		$this->set_prop( 'taxes', $value );
2757
+     * Set the invoice taxes.
2758
+     *
2759
+     * @since 1.0.19
2760
+     * @param  array $value taxes.
2761
+     */
2762
+    public function set_taxes( $value ) {
2763
+        $this->set_prop( 'taxes', $value );
2764 2764
     }
2765 2765
 
2766 2766
     /**
2767
-	 * Set the invoice discounts.
2768
-	 *
2769
-	 * @since 1.0.19
2770
-	 * @param  array $value discounts.
2771
-	 */
2772
-	public function set_discounts( $value ) {
2773
-		$this->set_prop( 'discounts', array() );
2767
+     * Set the invoice discounts.
2768
+     *
2769
+     * @since 1.0.19
2770
+     * @param  array $value discounts.
2771
+     */
2772
+    public function set_discounts( $value ) {
2773
+        $this->set_prop( 'discounts', array() );
2774 2774
 
2775 2775
         // Ensure that we have an array.
2776 2776
         if ( ! is_array( $value ) ) {
@@ -2785,12 +2785,12 @@  discard block
 block discarded – undo
2785 2785
     }
2786 2786
 
2787 2787
     /**
2788
-	 * Set the invoice items.
2789
-	 *
2790
-	 * @since 1.0.19
2791
-	 * @param  GetPaid_Form_Item[] $value items.
2792
-	 */
2793
-	public function set_items( $value ) {
2788
+     * Set the invoice items.
2789
+     *
2790
+     * @since 1.0.19
2791
+     * @param  GetPaid_Form_Item[] $value items.
2792
+     */
2793
+    public function set_items( $value ) {
2794 2794
 
2795 2795
         // Remove existing items.
2796 2796
         $this->set_prop( 'items', array() );
@@ -2807,95 +2807,95 @@  discard block
 block discarded – undo
2807 2807
     }
2808 2808
 
2809 2809
     /**
2810
-	 * Set the payment form.
2811
-	 *
2812
-	 * @since 1.0.19
2813
-	 * @param  int $value payment form.
2814
-	 */
2815
-	public function set_payment_form( $value ) {
2816
-		$this->set_prop( 'payment_form', $value );
2810
+     * Set the payment form.
2811
+     *
2812
+     * @since 1.0.19
2813
+     * @param  int $value payment form.
2814
+     */
2815
+    public function set_payment_form( $value ) {
2816
+        $this->set_prop( 'payment_form', $value );
2817 2817
     }
2818 2818
 
2819 2819
     /**
2820
-	 * Set the submission id.
2821
-	 *
2822
-	 * @since 1.0.19
2823
-	 * @param  string $value submission id.
2824
-	 */
2825
-	public function set_submission_id( $value ) {
2826
-		$this->set_prop( 'submission_id', $value );
2820
+     * Set the submission id.
2821
+     *
2822
+     * @since 1.0.19
2823
+     * @param  string $value submission id.
2824
+     */
2825
+    public function set_submission_id( $value ) {
2826
+        $this->set_prop( 'submission_id', $value );
2827 2827
     }
2828 2828
 
2829 2829
     /**
2830
-	 * Set the discount code.
2831
-	 *
2832
-	 * @since 1.0.19
2833
-	 * @param  string $value discount code.
2834
-	 */
2835
-	public function set_discount_code( $value ) {
2836
-		$this->set_prop( 'discount_code', $value );
2830
+     * Set the discount code.
2831
+     *
2832
+     * @since 1.0.19
2833
+     * @param  string $value discount code.
2834
+     */
2835
+    public function set_discount_code( $value ) {
2836
+        $this->set_prop( 'discount_code', $value );
2837 2837
     }
2838 2838
 
2839 2839
     /**
2840
-	 * Set the gateway.
2841
-	 *
2842
-	 * @since 1.0.19
2843
-	 * @param  string $value gateway.
2844
-	 */
2845
-	public function set_gateway( $value ) {
2846
-		$this->set_prop( 'gateway', $value );
2840
+     * Set the gateway.
2841
+     *
2842
+     * @since 1.0.19
2843
+     * @param  string $value gateway.
2844
+     */
2845
+    public function set_gateway( $value ) {
2846
+        $this->set_prop( 'gateway', $value );
2847 2847
     }
2848 2848
 
2849 2849
     /**
2850
-	 * Set the transaction id.
2851
-	 *
2852
-	 * @since 1.0.19
2853
-	 * @param  string $value transaction id.
2854
-	 */
2855
-	public function set_transaction_id( $value ) {
2856
-		if ( ! empty( $value ) ) {
2857
-			$this->set_prop( 'transaction_id', $value );
2858
-		}
2850
+     * Set the transaction id.
2851
+     *
2852
+     * @since 1.0.19
2853
+     * @param  string $value transaction id.
2854
+     */
2855
+    public function set_transaction_id( $value ) {
2856
+        if ( ! empty( $value ) ) {
2857
+            $this->set_prop( 'transaction_id', $value );
2858
+        }
2859 2859
     }
2860 2860
 
2861 2861
     /**
2862
-	 * Set the currency id.
2863
-	 *
2864
-	 * @since 1.0.19
2865
-	 * @param  string $value currency id.
2866
-	 */
2867
-	public function set_currency( $value ) {
2868
-		$this->set_prop( 'currency', $value );
2862
+     * Set the currency id.
2863
+     *
2864
+     * @since 1.0.19
2865
+     * @param  string $value currency id.
2866
+     */
2867
+    public function set_currency( $value ) {
2868
+        $this->set_prop( 'currency', $value );
2869 2869
     }
2870 2870
 
2871
-	/**
2872
-	 * Set whether to disable taxes.
2873
-	 *
2874
-	 * @since 1.0.19
2875
-	 * @param  bool $value value.
2876
-	 */
2877
-	public function set_disable_taxes( $value ) {
2878
-		$this->set_prop( 'disable_taxes', (bool) $value );
2879
-	}
2871
+    /**
2872
+     * Set whether to disable taxes.
2873
+     *
2874
+     * @since 1.0.19
2875
+     * @param  bool $value value.
2876
+     */
2877
+    public function set_disable_taxes( $value ) {
2878
+        $this->set_prop( 'disable_taxes', (bool) $value );
2879
+    }
2880 2880
 
2881 2881
     /**
2882
-	 * Set the subscription id.
2883
-	 *
2884
-	 * @since 1.0.19
2885
-	 * @param  string $value subscription id.
2886
-	 */
2887
-	public function set_subscription_id( $value ) {
2888
-		$this->set_prop( 'subscription_id', $value );
2889
-	}
2882
+     * Set the subscription id.
2883
+     *
2884
+     * @since 1.0.19
2885
+     * @param  string $value subscription id.
2886
+     */
2887
+    public function set_subscription_id( $value ) {
2888
+        $this->set_prop( 'subscription_id', $value );
2889
+    }
2890 2890
 	
2891
-	/**
2892
-	 * Set the remote subscription id.
2893
-	 *
2894
-	 * @since 1.0.19
2895
-	 * @param  string $value subscription id.
2896
-	 */
2897
-	public function set_remote_subscription_id( $value ) {
2898
-		$this->set_prop( 'remote_subscription_id', $value );
2891
+    /**
2892
+     * Set the remote subscription id.
2893
+     *
2894
+     * @since 1.0.19
2895
+     * @param  string $value subscription id.
2896
+     */
2897
+    public function set_remote_subscription_id( $value ) {
2898
+        $this->set_prop( 'remote_subscription_id', $value );
2899 2899
     }
2900 2900
 
2901 2901
     /*
@@ -2934,12 +2934,12 @@  discard block
 block discarded – undo
2934 2934
      */
2935 2935
     public function is_taxable() {
2936 2936
         return ! $this->get_disable_taxes();
2937
-	}
2937
+    }
2938 2938
 
2939
-	/**
2940
-	 * @deprecated
2941
-	 */
2942
-	public function has_vat() {
2939
+    /**
2940
+     * @deprecated
2941
+     */
2942
+    public function has_vat() {
2943 2943
         global $wpinv_euvat, $wpi_country;
2944 2944
 
2945 2945
         $requires_vat = false;
@@ -2950,17 +2950,17 @@  discard block
 block discarded – undo
2950 2950
         }
2951 2951
 
2952 2952
         return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2953
-	}
2953
+    }
2954 2954
 
2955
-	/**
2956
-	 * Checks to see if the invoice requires payment.
2957
-	 */
2958
-	public function is_free() {
2955
+    /**
2956
+     * Checks to see if the invoice requires payment.
2957
+     */
2958
+    public function is_free() {
2959 2959
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2960 2960
 
2961
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2962
-			$is_free = false;
2963
-		}
2961
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2962
+            $is_free = false;
2963
+        }
2964 2964
 
2965 2965
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2966 2966
     }
@@ -2971,46 +2971,46 @@  discard block
 block discarded – undo
2971 2971
     public function is_paid() {
2972 2972
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2973 2973
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2974
-	}
2974
+    }
2975 2975
 
2976
-	/**
2976
+    /**
2977 2977
      * Checks if the invoice needs payment.
2978 2978
      */
2979
-	public function needs_payment() {
2980
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2979
+    public function needs_payment() {
2980
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2981 2981
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2982 2982
     }
2983 2983
   
2984
-	/**
2984
+    /**
2985 2985
      * Checks if the invoice is refunded.
2986 2986
      */
2987
-	public function is_refunded() {
2987
+    public function is_refunded() {
2988 2988
         $is_refunded = $this->has_status( 'wpi-refunded' );
2989 2989
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2990
-	}
2990
+    }
2991 2991
 
2992
-	/**
2992
+    /**
2993 2993
      * Checks if the invoice is held.
2994 2994
      */
2995
-	public function is_held() {
2995
+    public function is_held() {
2996 2996
         $is_held = $this->has_status( 'wpi-onhold' );
2997 2997
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
2998
-	}
2998
+    }
2999 2999
 
3000
-	/**
3000
+    /**
3001 3001
      * Checks if the invoice is due.
3002 3002
      */
3003
-	public function is_due() {
3004
-		$due_date = $this->get_due_date();
3005
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3006
-	}
3003
+    public function is_due() {
3004
+        $due_date = $this->get_due_date();
3005
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3006
+    }
3007 3007
 
3008
-	/**
3008
+    /**
3009 3009
      * Checks if the invoice is draft.
3010 3010
      */
3011
-	public function is_draft() {
3011
+    public function is_draft() {
3012 3012
         return $this->has_status( 'draft, auto-draft' );
3013
-	}
3013
+    }
3014 3014
 
3015 3015
     /**
3016 3016
      * Checks if the invoice has a given status.
@@ -3018,9 +3018,9 @@  discard block
 block discarded – undo
3018 3018
     public function has_status( $status ) {
3019 3019
         $status = wpinv_parse_list( $status );
3020 3020
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3021
-	}
3021
+    }
3022 3022
 
3023
-	/**
3023
+    /**
3024 3024
      * Checks if the invoice is of a given type.
3025 3025
      */
3026 3026
     public function is_type( $type ) {
@@ -3043,25 +3043,25 @@  discard block
 block discarded – undo
3043 3043
      */
3044 3044
     public function has_free_trial() {
3045 3045
         return $this->is_recurring() && 0 == $this->get_initial_total();
3046
-	}
3046
+    }
3047 3047
 
3048
-	/**
3048
+    /**
3049 3049
      * @deprecated
3050 3050
      */
3051 3051
     public function is_free_trial() {
3052 3052
         $this->has_free_trial();
3053 3053
     }
3054 3054
 
3055
-	/**
3055
+    /**
3056 3056
      * Check if the initial payment if 0.
3057 3057
      *
3058 3058
      */
3059
-	public function is_initial_free() {
3059
+    public function is_initial_free() {
3060 3060
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3061 3061
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3062 3062
     }
3063 3063
 	
3064
-	/**
3064
+    /**
3065 3065
      * Check if the recurring item has a free trial.
3066 3066
      *
3067 3067
      */
@@ -3074,21 +3074,21 @@  discard block
 block discarded – undo
3074 3074
 
3075 3075
         $item = $this->get_recurring( true );
3076 3076
         return $item->has_free_trial();
3077
-	}
3077
+    }
3078 3078
 
3079
-	/**
3079
+    /**
3080 3080
      * Check if the free trial is a result of a discount.
3081 3081
      */
3082 3082
     public function is_free_trial_from_discount() {
3083
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3084
-	}
3083
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3084
+    }
3085 3085
 	
3086
-	/**
3086
+    /**
3087 3087
      * @deprecated
3088 3088
      */
3089 3089
     public function discount_first_payment_only() {
3090 3090
 
3091
-		$discount_code = $this->get_discount_code();
3091
+        $discount_code = $this->get_discount_code();
3092 3092
         if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3093 3093
             return true;
3094 3094
         }
@@ -3119,28 +3119,28 @@  discard block
 block discarded – undo
3119 3119
      */
3120 3120
     public function add_item( $item ) {
3121 3121
 
3122
-		if ( is_array( $item ) ) {
3123
-			$item = $this->process_array_item( $item );
3124
-		}
3122
+        if ( is_array( $item ) ) {
3123
+            $item = $this->process_array_item( $item );
3124
+        }
3125 3125
 
3126
-		if ( is_numeric( $item ) ) {
3127
-			$item = new GetPaid_Form_Item( $item );
3128
-		}
3126
+        if ( is_numeric( $item ) ) {
3127
+            $item = new GetPaid_Form_Item( $item );
3128
+        }
3129 3129
 
3130 3130
         // Make sure that it is available for purchase.
3131
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3132
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3131
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3132
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3133 3133
         }
3134 3134
 
3135 3135
         // Do we have a recurring item?
3136
-		if ( $item->is_recurring() ) {
3136
+        if ( $item->is_recurring() ) {
3137 3137
 
3138
-			// An invoice can only contain one recurring item.
3139
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3140
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3141
-			}
3138
+            // An invoice can only contain one recurring item.
3139
+            if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3140
+                return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3141
+            }
3142 3142
 
3143
-			$this->recurring_item = $item->get_id();
3143
+            $this->recurring_item = $item->get_id();
3144 3144
         }
3145 3145
 
3146 3146
         // Invoice id.
@@ -3151,60 +3151,60 @@  discard block
 block discarded – undo
3151 3151
         $items[ (int) $item->get_id() ] = $item;
3152 3152
 
3153 3153
         $this->set_prop( 'items', $items );
3154
-		return true;
3155
-	}
3154
+        return true;
3155
+    }
3156 3156
 	
3157
-	/**
3158
-	 * Converts an array to an item.
3159
-	 *
3160
-	 * @since 1.0.19
3161
-	 * @return GetPaid_Form_Item
3162
-	 */
3163
-	protected function process_array_item( $array ) {
3164
-
3165
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3166
-		$item    = new GetPaid_Form_Item( $item_id );
3167
-
3168
-		// Set item data.
3169
-		foreach( array( 'name', 'price', 'description' ) as $key ) {
3170
-			if ( isset( $array[ "item_$key" ] ) ) {
3171
-				$method = "set_$key";
3172
-				$item->$method( $array[ "item_$key" ] );
3173
-			}
3174
-		}
3175
-
3176
-		if ( isset( $array['quantity'] ) ) {
3177
-			$item->set_quantity( $array['quantity'] );
3178
-		}
3179
-
3180
-		// Set item meta.
3181
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3182
-			$item->set_item_meta( $array['meta'] );
3183
-		}
3184
-
3185
-		return $item;
3186
-
3187
-	}
3188
-
3189
-    /**
3190
-	 * Retrieves a specific item.
3191
-	 *
3192
-	 * @since 1.0.19
3193
-	 */
3194
-	public function get_item( $item_id ) {
3195
-		$items   = $this->get_items();
3196
-		$item_id = (int) $item_id;
3197
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3198
-    }
3199
-
3200
-    /**
3201
-	 * Removes a specific item.
3202
-	 *
3203
-	 * @since 1.0.19
3204
-	 */
3205
-	public function remove_item( $item_id ) {
3206
-		$items   = $this->get_items();
3207
-		$item_id = (int) $item_id;
3157
+    /**
3158
+     * Converts an array to an item.
3159
+     *
3160
+     * @since 1.0.19
3161
+     * @return GetPaid_Form_Item
3162
+     */
3163
+    protected function process_array_item( $array ) {
3164
+
3165
+        $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3166
+        $item    = new GetPaid_Form_Item( $item_id );
3167
+
3168
+        // Set item data.
3169
+        foreach( array( 'name', 'price', 'description' ) as $key ) {
3170
+            if ( isset( $array[ "item_$key" ] ) ) {
3171
+                $method = "set_$key";
3172
+                $item->$method( $array[ "item_$key" ] );
3173
+            }
3174
+        }
3175
+
3176
+        if ( isset( $array['quantity'] ) ) {
3177
+            $item->set_quantity( $array['quantity'] );
3178
+        }
3179
+
3180
+        // Set item meta.
3181
+        if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3182
+            $item->set_item_meta( $array['meta'] );
3183
+        }
3184
+
3185
+        return $item;
3186
+
3187
+    }
3188
+
3189
+    /**
3190
+     * Retrieves a specific item.
3191
+     *
3192
+     * @since 1.0.19
3193
+     */
3194
+    public function get_item( $item_id ) {
3195
+        $items   = $this->get_items();
3196
+        $item_id = (int) $item_id;
3197
+        return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3198
+    }
3199
+
3200
+    /**
3201
+     * Removes a specific item.
3202
+     *
3203
+     * @since 1.0.19
3204
+     */
3205
+    public function remove_item( $item_id ) {
3206
+        $items   = $this->get_items();
3207
+        $item_id = (int) $item_id;
3208 3208
 
3209 3209
         if ( $item_id == $this->recurring_item ) {
3210 3210
             $this->recurring_item = null;
@@ -3231,38 +3231,38 @@  discard block
 block discarded – undo
3231 3231
         if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) {
3232 3232
 
3233 3233
             $amount = $fees[ $fee ]['amount'] += $amount;
3234
-			$fees[ $fee ] = array(
3235
-				'amount'    => $amount,
3234
+            $fees[ $fee ] = array(
3235
+                'amount'    => $amount,
3236 3236
                 'recurring' => (bool) $recurring,
3237 3237
             );
3238 3238
 
3239
-		} else {
3240
-			$fees[ $fee ] = array(
3239
+        } else {
3240
+            $fees[ $fee ] = array(
3241 3241
                 'amount'    => $amount,
3242 3242
                 'recurring' => (bool) $recurring,
3243 3243
             );
3244
-		}
3244
+        }
3245 3245
 
3246 3246
         $this->set_prop( 'fees', $fee );
3247 3247
 
3248 3248
     }
3249 3249
 
3250 3250
     /**
3251
-	 * Retrieves a specific fee.
3252
-	 *
3253
-	 * @since 1.0.19
3254
-	 */
3255
-	public function get_fee( $fee ) {
3251
+     * Retrieves a specific fee.
3252
+     *
3253
+     * @since 1.0.19
3254
+     */
3255
+    public function get_fee( $fee ) {
3256 3256
         $fees = $this->get_fees();
3257
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3257
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3258 3258
     }
3259 3259
 
3260 3260
     /**
3261
-	 * Removes a specific fee.
3262
-	 *
3263
-	 * @since 1.0.19
3264
-	 */
3265
-	public function remove_fee( $fee ) {
3261
+     * Removes a specific fee.
3262
+     *
3263
+     * @since 1.0.19
3264
+     */
3265
+    public function remove_fee( $fee ) {
3266 3266
         $fees = $this->get_fees();
3267 3267
         if ( isset( $fees[ $fee ] ) ) {
3268 3268
             unset( $fees[ $fee ] );
@@ -3285,44 +3285,44 @@  discard block
 block discarded – undo
3285 3285
         if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) {
3286 3286
 
3287 3287
             $amount = $discounts[ $discount ]['amount'] += $amount;
3288
-			$discounts[ $discount ] = array(
3288
+            $discounts[ $discount ] = array(
3289 3289
                 'amount'    => $amount,
3290 3290
                 'recurring' => (bool) $recurring,
3291 3291
             );
3292 3292
 
3293
-		} else {
3294
-			$discounts[ $discount ] = array(
3293
+        } else {
3294
+            $discounts[ $discount ] = array(
3295 3295
                 'amount'    => $amount,
3296 3296
                 'recurring' => (bool) $recurring,
3297 3297
             );
3298
-		}
3298
+        }
3299 3299
 
3300 3300
         $this->set_prop( 'discounts', $discount );
3301 3301
 
3302 3302
     }
3303 3303
 
3304 3304
     /**
3305
-	 * Retrieves a specific discount.
3306
-	 *
3307
-	 * @since 1.0.19
3308
-	 */
3309
-	public function get_discount( $discount = false ) {
3305
+     * Retrieves a specific discount.
3306
+     *
3307
+     * @since 1.0.19
3308
+     */
3309
+    public function get_discount( $discount = false ) {
3310 3310
 
3311
-		// Backwards compatibilty.
3312
-		if ( empty( $discount ) ) {
3313
-			return $this->get_total_discount();
3314
-		}
3311
+        // Backwards compatibilty.
3312
+        if ( empty( $discount ) ) {
3313
+            return $this->get_total_discount();
3314
+        }
3315 3315
 
3316 3316
         $discounts = $this->get_discounts();
3317
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3317
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3318 3318
     }
3319 3319
 
3320 3320
     /**
3321
-	 * Removes a specific discount.
3322
-	 *
3323
-	 * @since 1.0.19
3324
-	 */
3325
-	public function remove_discount( $discount ) {
3321
+     * Removes a specific discount.
3322
+     *
3323
+     * @since 1.0.19
3324
+     */
3325
+    public function remove_discount( $discount ) {
3326 3326
         $discounts = $this->get_discounts();
3327 3327
         if ( isset( $discounts[ $discount ] ) ) {
3328 3328
             unset( $discounts[ $discount ] );
@@ -3348,44 +3348,44 @@  discard block
 block discarded – undo
3348 3348
         if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) {
3349 3349
 
3350 3350
             $amount = $taxes[ $tax ]['amount'] += $amount;
3351
-			$taxes[ $tax ] = array(
3351
+            $taxes[ $tax ] = array(
3352 3352
                 'amount'    => $amount,
3353 3353
                 'recurring' => (bool) $recurring,
3354 3354
             );
3355 3355
 
3356
-		} else {
3357
-			$taxes[ $tax ] = array(
3356
+        } else {
3357
+            $taxes[ $tax ] = array(
3358 3358
                 'amount'    => $amount,
3359 3359
                 'recurring' => (bool) $recurring,
3360 3360
             );
3361
-		}
3361
+        }
3362 3362
 
3363 3363
         $this->set_prop( 'taxes', $tax );
3364 3364
 
3365 3365
     }
3366 3366
 
3367 3367
     /**
3368
-	 * Retrieves a specific tax.
3369
-	 *
3370
-	 * @since 1.0.19
3371
-	 */
3372
-	public function get_tax( $tax = null ) {
3368
+     * Retrieves a specific tax.
3369
+     *
3370
+     * @since 1.0.19
3371
+     */
3372
+    public function get_tax( $tax = null ) {
3373 3373
 
3374
-		// Backwards compatility.
3375
-		if ( empty( $tax ) ) {
3376
-			return $this->get_total_tax();
3377
-		}
3374
+        // Backwards compatility.
3375
+        if ( empty( $tax ) ) {
3376
+            return $this->get_total_tax();
3377
+        }
3378 3378
 
3379 3379
         $taxes = $this->get_taxes();
3380
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3380
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3381 3381
     }
3382 3382
 
3383 3383
     /**
3384
-	 * Removes a specific tax.
3385
-	 *
3386
-	 * @since 1.0.19
3387
-	 */
3388
-	public function remove_tax( $tax ) {
3384
+     * Removes a specific tax.
3385
+     *
3386
+     * @since 1.0.19
3387
+     */
3388
+    public function remove_tax( $tax ) {
3389 3389
         $taxes = $this->get_discounts();
3390 3390
         if ( isset( $taxes[ $tax ] ) ) {
3391 3391
             unset( $taxes[ $tax ] );
@@ -3394,160 +3394,160 @@  discard block
 block discarded – undo
3394 3394
     }
3395 3395
 
3396 3396
     /**
3397
-	 * Recalculates the invoice subtotal.
3398
-	 *
3399
-	 * @since 1.0.19
3400
-	 * @return float The recalculated subtotal
3401
-	 */
3402
-	public function recalculate_subtotal() {
3397
+     * Recalculates the invoice subtotal.
3398
+     *
3399
+     * @since 1.0.19
3400
+     * @return float The recalculated subtotal
3401
+     */
3402
+    public function recalculate_subtotal() {
3403 3403
         $items     = $this->get_items();
3404
-		$subtotal  = 0;
3405
-		$recurring = 0;
3404
+        $subtotal  = 0;
3405
+        $recurring = 0;
3406 3406
 
3407 3407
         foreach ( $items as $item ) {
3408
-			$subtotal  += $item->get_sub_total();
3409
-			$recurring += $item->get_recurring_sub_total();
3408
+            $subtotal  += $item->get_sub_total();
3409
+            $recurring += $item->get_recurring_sub_total();
3410 3410
         }
3411 3411
 
3412
-		if ( $this->is_renewal() ) {
3413
-			$this->set_subtotal( $recurring );
3414
-		} else {
3415
-			$this->set_subtotal( $subtotal );
3416
-		}
3412
+        if ( $this->is_renewal() ) {
3413
+            $this->set_subtotal( $recurring );
3414
+        } else {
3415
+            $this->set_subtotal( $subtotal );
3416
+        }
3417 3417
 
3418
-		$this->totals['subtotal'] = array(
3419
-			'initial'   => $subtotal,
3420
-			'recurring' => $recurring,
3421
-		);
3418
+        $this->totals['subtotal'] = array(
3419
+            'initial'   => $subtotal,
3420
+            'recurring' => $recurring,
3421
+        );
3422 3422
 
3423 3423
         return $this->is_renewal() ? $recurring : $subtotal;
3424 3424
     }
3425 3425
 
3426 3426
     /**
3427
-	 * Recalculates the invoice discount total.
3428
-	 *
3429
-	 * @since 1.0.19
3430
-	 * @return float The recalculated discount
3431
-	 */
3432
-	public function recalculate_total_discount() {
3427
+     * Recalculates the invoice discount total.
3428
+     *
3429
+     * @since 1.0.19
3430
+     * @return float The recalculated discount
3431
+     */
3432
+    public function recalculate_total_discount() {
3433 3433
         $discounts = $this->get_discounts();
3434
-		$discount  = 0;
3435
-		$recurring = 0;
3434
+        $discount  = 0;
3435
+        $recurring = 0;
3436 3436
 
3437 3437
         foreach ( $discounts as $data ) {
3438 3438
 
3439
-			if ( $data['recurring'] ) {
3440
-				$recurring += $data['amount'];
3441
-			} else {
3442
-				$discount += $data['amount'];
3443
-			}
3439
+            if ( $data['recurring'] ) {
3440
+                $recurring += $data['amount'];
3441
+            } else {
3442
+                $discount += $data['amount'];
3443
+            }
3444 3444
 
3445
-		}
3445
+        }
3446 3446
 
3447
-		if ( $this->is_renewal() ) {
3448
-			$this->set_total_discount( $recurring );
3449
-		} else {
3450
-			$this->set_total_discount( $discount );
3451
-		}
3447
+        if ( $this->is_renewal() ) {
3448
+            $this->set_total_discount( $recurring );
3449
+        } else {
3450
+            $this->set_total_discount( $discount );
3451
+        }
3452 3452
 
3453
-		$this->totals['discount'] = array(
3454
-			'initial'   => $discount,
3455
-			'recurring' => $recurring,
3456
-		);
3453
+        $this->totals['discount'] = array(
3454
+            'initial'   => $discount,
3455
+            'recurring' => $recurring,
3456
+        );
3457 3457
 
3458
-		return $this->is_renewal() ? $recurring : $discount;
3458
+        return $this->is_renewal() ? $recurring : $discount;
3459 3459
 
3460 3460
     }
3461 3461
 
3462 3462
     /**
3463
-	 * Recalculates the invoice tax total.
3464
-	 *
3465
-	 * @since 1.0.19
3466
-	 * @return float The recalculated tax
3467
-	 */
3468
-	public function recalculate_total_tax() {
3463
+     * Recalculates the invoice tax total.
3464
+     *
3465
+     * @since 1.0.19
3466
+     * @return float The recalculated tax
3467
+     */
3468
+    public function recalculate_total_tax() {
3469 3469
         $taxes     = $this->get_taxes();
3470
-		$tax       = 0;
3471
-		$recurring = 0;
3470
+        $tax       = 0;
3471
+        $recurring = 0;
3472 3472
 
3473 3473
         foreach ( $taxes as $data ) {
3474 3474
 
3475
-			if ( $data['recurring'] ) {
3476
-				$recurring += $data['amount'];
3477
-			} else {
3478
-				$tax += $data['amount'];
3479
-			}
3475
+            if ( $data['recurring'] ) {
3476
+                $recurring += $data['amount'];
3477
+            } else {
3478
+                $tax += $data['amount'];
3479
+            }
3480 3480
 
3481
-		}
3481
+        }
3482 3482
 
3483
-		if ( $this->is_renewal() ) {
3484
-			$this->set_total_tax( $recurring );
3485
-		} else {
3486
-			$this->set_total_tax( $tax );
3487
-		}
3483
+        if ( $this->is_renewal() ) {
3484
+            $this->set_total_tax( $recurring );
3485
+        } else {
3486
+            $this->set_total_tax( $tax );
3487
+        }
3488 3488
 
3489
-		$this->totals['tax'] = array(
3490
-			'initial'   => $tax,
3491
-			'recurring' => $recurring,
3492
-		);
3489
+        $this->totals['tax'] = array(
3490
+            'initial'   => $tax,
3491
+            'recurring' => $recurring,
3492
+        );
3493 3493
 
3494
-		return $this->is_renewal() ? $recurring : $tax;
3494
+        return $this->is_renewal() ? $recurring : $tax;
3495 3495
 
3496 3496
     }
3497 3497
 
3498 3498
     /**
3499
-	 * Recalculates the invoice fees total.
3500
-	 *
3501
-	 * @since 1.0.19
3502
-	 * @return float The recalculated fee
3503
-	 */
3504
-	public function recalculate_total_fees() {
3505
-		$fees      = $this->get_fees();
3506
-		$fee       = 0;
3507
-		$recurring = 0;
3499
+     * Recalculates the invoice fees total.
3500
+     *
3501
+     * @since 1.0.19
3502
+     * @return float The recalculated fee
3503
+     */
3504
+    public function recalculate_total_fees() {
3505
+        $fees      = $this->get_fees();
3506
+        $fee       = 0;
3507
+        $recurring = 0;
3508 3508
 
3509 3509
         foreach ( $fees as $data ) {
3510 3510
 
3511
-			if ( $data['recurring'] ) {
3512
-				$recurring += $data['amount'];
3513
-			} else {
3514
-				$fee += $data['amount'];
3515
-			}
3511
+            if ( $data['recurring'] ) {
3512
+                $recurring += $data['amount'];
3513
+            } else {
3514
+                $fee += $data['amount'];
3515
+            }
3516 3516
 
3517
-		}
3517
+        }
3518 3518
 
3519 3519
         if ( $this->is_renewal() ) {
3520
-			$this->set_total_fees( $recurring );
3521
-		} else {
3522
-			$this->set_total_fees( $fee );
3523
-		}
3520
+            $this->set_total_fees( $recurring );
3521
+        } else {
3522
+            $this->set_total_fees( $fee );
3523
+        }
3524 3524
 
3525
-		$this->totals['fee'] = array(
3526
-			'initial'   => $fee,
3527
-			'recurring' => $recurring,
3528
-		);
3525
+        $this->totals['fee'] = array(
3526
+            'initial'   => $fee,
3527
+            'recurring' => $recurring,
3528
+        );
3529 3529
 
3530 3530
         $this->set_total_fees( $fee );
3531 3531
         return $this->is_renewal() ? $recurring : $fee;
3532 3532
     }
3533 3533
 
3534 3534
     /**
3535
-	 * Recalculates the invoice total.
3536
-	 *
3537
-	 * @since 1.0.19
3535
+     * Recalculates the invoice total.
3536
+     *
3537
+     * @since 1.0.19
3538 3538
      * @return float The invoice total
3539
-	 */
3540
-	public function recalculate_total() {
3539
+     */
3540
+    public function recalculate_total() {
3541 3541
         $this->recalculate_subtotal();
3542 3542
         $this->recalculate_total_fees();
3543 3543
         $this->recalculate_total_discount();
3544 3544
         $this->recalculate_total_tax();
3545
-		return $this->get_total();
3546
-	}
3545
+        return $this->get_total();
3546
+    }
3547 3547
 
3548
-	/**
3549
-	 * @deprecated
3550
-	 */
3548
+    /**
3549
+     * @deprecated
3550
+     */
3551 3551
     public function recalculate_totals( $temp = false ) {
3552 3552
         $this->update_items( $temp );
3553 3553
         $this->save( true );
@@ -3565,7 +3565,7 @@  discard block
 block discarded – undo
3565 3565
      * Adds a note to an invoice.
3566 3566
      *
3567 3567
      * @param string $note The note being added.
3568
-	 * @return int|false The new note's ID on success, false on failure.
3568
+     * @return int|false The new note's ID on success, false on failure.
3569 3569
      *
3570 3570
      */
3571 3571
     public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
@@ -3575,21 +3575,21 @@  discard block
 block discarded – undo
3575 3575
             return false;
3576 3576
         }
3577 3577
 
3578
-		$author       = 'System';
3579
-		$author_email = '[email protected]';
3578
+        $author       = 'System';
3579
+        $author_email = '[email protected]';
3580 3580
 
3581
-		// If this is an admin comment or it has been added by the user.
3582
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3583
-			$user         = get_user_by( 'id', get_current_user_id() );
3581
+        // If this is an admin comment or it has been added by the user.
3582
+        if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3583
+            $user         = get_user_by( 'id', get_current_user_id() );
3584 3584
             $author       = $user->display_name;
3585 3585
             $author_email = $user->user_email;
3586
-		}
3586
+        }
3587 3587
 
3588
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3588
+        return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3589 3589
 
3590
-	}
3590
+    }
3591 3591
 
3592
-	/**
3592
+    /**
3593 3593
      * Generates a unique key for the invoice.
3594 3594
      */
3595 3595
     public function generate_key( $string = '' ) {
@@ -3609,113 +3609,113 @@  discard block
 block discarded – undo
3609 3609
             $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3610 3610
         }
3611 3611
 
3612
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3612
+        return wpinv_format_invoice_number( $number, $this->get_post_type() );
3613 3613
 
3614
-	}
3614
+    }
3615 3615
 
3616
-	/**
3617
-	 * Handle the status transition.
3618
-	 */
3619
-	protected function status_transition() {
3620
-		$status_transition = $this->status_transition;
3616
+    /**
3617
+     * Handle the status transition.
3618
+     */
3619
+    protected function status_transition() {
3620
+        $status_transition = $this->status_transition;
3621 3621
 
3622
-		// Reset status transition variable.
3623
-		$this->status_transition = false;
3622
+        // Reset status transition variable.
3623
+        $this->status_transition = false;
3624 3624
 
3625
-		if ( $status_transition ) {
3626
-			try {
3625
+        if ( $status_transition ) {
3626
+            try {
3627 3627
 
3628
-				// Fire a hook for the status change.
3629
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3628
+                // Fire a hook for the status change.
3629
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3630 3630
 
3631
-				// @deprecated this is deprecated and will be removed in the future.
3632
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3631
+                // @deprecated this is deprecated and will be removed in the future.
3632
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3633 3633
 
3634
-				if ( ! empty( $status_transition['from'] ) ) {
3634
+                if ( ! empty( $status_transition['from'] ) ) {
3635 3635
 
3636
-					/* translators: 1: old invoice status 2: new invoice status */
3637
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3636
+                    /* translators: 1: old invoice status 2: new invoice status */
3637
+                    $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3638 3638
 
3639
-					// Fire another hook.
3640
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3641
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3639
+                    // Fire another hook.
3640
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3641
+                    do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3642 3642
 
3643
-					// @deprecated this is deprecated and will be removed in the future.
3644
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3643
+                    // @deprecated this is deprecated and will be removed in the future.
3644
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3645 3645
 
3646
-					// Note the transition occurred.
3647
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3646
+                    // Note the transition occurred.
3647
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3648 3648
 
3649
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3650
-					if (
3651
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3652
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3653
-					) {
3654
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3655
-					}
3649
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3650
+                    if (
3651
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3652
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3653
+                    ) {
3654
+                        do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3655
+                    }
3656 3656
 
3657
-					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3658
-					if (
3659
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3660
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3661
-					) {
3662
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3663
-					}
3664
-				} else {
3665
-					/* translators: %s: new invoice status */
3666
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3657
+                    // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3658
+                    if (
3659
+                        in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3660
+                        && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3661
+                    ) {
3662
+                        do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3663
+                    }
3664
+                } else {
3665
+                    /* translators: %s: new invoice status */
3666
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3667 3667
 
3668
-					// Note the transition occurred.
3669
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3668
+                    // Note the transition occurred.
3669
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3670 3670
 
3671
-				}
3672
-			} catch ( Exception $e ) {
3673
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3674
-			}
3675
-		}
3676
-	}
3671
+                }
3672
+            } catch ( Exception $e ) {
3673
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3674
+            }
3675
+        }
3676
+    }
3677 3677
 
3678
-	/**
3679
-	 * Updates an invoice status.
3680
-	 */
3681
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3678
+    /**
3679
+     * Updates an invoice status.
3680
+     */
3681
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3682 3682
 
3683
-		// Fires before updating a status.
3684
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3683
+        // Fires before updating a status.
3684
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3685 3685
 
3686
-		// Update the status.
3687
-		$this->set_status( $new_status, $note, $manual );
3686
+        // Update the status.
3687
+        $this->set_status( $new_status, $note, $manual );
3688 3688
 
3689
-		// Save the order.
3690
-		return $this->save();
3689
+        // Save the order.
3690
+        return $this->save();
3691 3691
 
3692
-	}
3692
+    }
3693 3693
 
3694
-	/**
3695
-	 * @deprecated
3696
-	 */
3697
-	public function refresh_item_ids() {
3694
+    /**
3695
+     * @deprecated
3696
+     */
3697
+    public function refresh_item_ids() {
3698 3698
         $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3699 3699
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3700
-	}
3700
+    }
3701 3701
 
3702
-	/**
3703
-	 * @deprecated
3704
-	 */
3705
-	public function update_items( $temp = false ) {
3702
+    /**
3703
+     * @deprecated
3704
+     */
3705
+    public function update_items( $temp = false ) {
3706 3706
 
3707
-		$this->set_items( $this->get_items() );
3707
+        $this->set_items( $this->get_items() );
3708 3708
 
3709
-		if ( ! $temp ) {
3710
-			$this->save();
3711
-		}
3709
+        if ( ! $temp ) {
3710
+            $this->save();
3711
+        }
3712 3712
 
3713 3713
         return $this;
3714
-	}
3714
+    }
3715 3715
 
3716
-	/**
3717
-	 * @deprecated
3718
-	 */
3716
+    /**
3717
+     * @deprecated
3718
+     */
3719 3719
     public function validate_discount() {
3720 3720
 
3721 3721
         $discount_code = $this->get_discount_code();
@@ -3731,97 +3731,97 @@  discard block
 block discarded – undo
3731 3731
 
3732 3732
     }
3733 3733
 
3734
-	/**
3735
-	 * Refunds an invoice.
3736
-	 */
3734
+    /**
3735
+     * Refunds an invoice.
3736
+     */
3737 3737
     public function refund() {
3738
-		$this->set_status( 'wpi-refunded' );
3738
+        $this->set_status( 'wpi-refunded' );
3739 3739
         $this->save();
3740
-	}
3740
+    }
3741 3741
 
3742
-	/**
3743
-	 * Marks an invoice as paid.
3744
-	 * 
3745
-	 * @param string $transaction_id
3746
-	 */
3742
+    /**
3743
+     * Marks an invoice as paid.
3744
+     * 
3745
+     * @param string $transaction_id
3746
+     */
3747 3747
     public function mark_paid( $transaction_id = null, $note = '' ) {
3748 3748
 
3749
-		// Set the transaction id.
3750
-		if ( empty( $transaction_id ) ) {
3751
-			$transaction_id = $this->generate_key('trans_');
3752
-		}
3749
+        // Set the transaction id.
3750
+        if ( empty( $transaction_id ) ) {
3751
+            $transaction_id = $this->generate_key('trans_');
3752
+        }
3753 3753
 
3754
-		if ( ! $this->get_transaction_id() ) {
3755
-			$this->set_transaction_id( $transaction_id );
3756
-		}
3754
+        if ( ! $this->get_transaction_id() ) {
3755
+            $this->set_transaction_id( $transaction_id );
3756
+        }
3757 3757
 
3758
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3759
-			return $this->save();
3760
-		}
3758
+        if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3759
+            return $this->save();
3760
+        }
3761 3761
 
3762
-		// Set the completed date.
3763
-		$this->set_date_completed( current_time( 'mysql' ) );
3762
+        // Set the completed date.
3763
+        $this->set_date_completed( current_time( 'mysql' ) );
3764 3764
 
3765
-		// Set the new status.
3766
-		if ( $this->is_renewal() ) {
3765
+        // Set the new status.
3766
+        if ( $this->is_renewal() ) {
3767 3767
 
3768
-			$_note = sprintf(
3769
-				__( 'Renewed via %s', 'invoicing' ),
3770
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3771
-			);
3768
+            $_note = sprintf(
3769
+                __( 'Renewed via %s', 'invoicing' ),
3770
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3771
+            );
3772 3772
 
3773
-			if ( 'none' == $this->get_gateway() ) {
3774
-				$_note = $note;
3775
-			}
3773
+            if ( 'none' == $this->get_gateway() ) {
3774
+                $_note = $note;
3775
+            }
3776 3776
 
3777
-			$this->set_status( 'wpi-renewal', $_note );
3777
+            $this->set_status( 'wpi-renewal', $_note );
3778 3778
 
3779
-		} else {
3779
+        } else {
3780 3780
 
3781
-			$_note = sprintf(
3782
-				__( 'Paid via %s', 'invoicing' ),
3783
-				$this->get_gateway() . empty( $note ) ? '' : " ($note)"
3784
-			);
3781
+            $_note = sprintf(
3782
+                __( 'Paid via %s', 'invoicing' ),
3783
+                $this->get_gateway() . empty( $note ) ? '' : " ($note)"
3784
+            );
3785 3785
 
3786
-			if ( 'none' == $this->get_gateway() ) {
3787
-				$_note = $note;
3788
-			}
3786
+            if ( 'none' == $this->get_gateway() ) {
3787
+                $_note = $note;
3788
+            }
3789 3789
 
3790
-			$this->set_status( 'publish',$_note );
3790
+            $this->set_status( 'publish',$_note );
3791 3791
 
3792
-		}
3792
+        }
3793 3793
 
3794
-		// Set checkout mode.
3795
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3796
-		$this->set_mode( $mode );
3794
+        // Set checkout mode.
3795
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3796
+        $this->set_mode( $mode );
3797 3797
 
3798
-		// Save the invoice.
3798
+        // Save the invoice.
3799 3799
         $this->save();
3800
-	}
3801
-
3802
-
3803
-	/**
3804
-	 * Save data to the database.
3805
-	 *
3806
-	 * @since 1.0.19
3807
-	 * @return int invoice ID
3808
-	 */
3809
-	public function save() {
3810
-		$this->maybe_set_date_paid();
3811
-		$this->maybe_set_key();
3812
-		parent::save();
3813
-		$this->clear_cache();
3814
-		$this->status_transition();
3815
-		return $this->get_id();
3816
-	}
3817
-
3818
-	/**
3800
+    }
3801
+
3802
+
3803
+    /**
3804
+     * Save data to the database.
3805
+     *
3806
+     * @since 1.0.19
3807
+     * @return int invoice ID
3808
+     */
3809
+    public function save() {
3810
+        $this->maybe_set_date_paid();
3811
+        $this->maybe_set_key();
3812
+        parent::save();
3813
+        $this->clear_cache();
3814
+        $this->status_transition();
3815
+        return $this->get_id();
3816
+    }
3817
+
3818
+    /**
3819 3819
      * Clears the subscription's cache.
3820 3820
      */
3821 3821
     public function clear_cache() {
3822
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3823
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3824
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3825
-	}
3822
+        wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3823
+        wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3824
+        wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3825
+    }
3826 3826
 
3827 3827
 }
Please login to merge, or discard this patch.
Spacing   +762 added lines, -762 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Invoice class.
@@ -134,40 +134,40 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
136 136
 	 */
137
-    public function __construct( $invoice = false ) {
137
+    public function __construct($invoice = false) {
138 138
 
139
-        parent::__construct( $invoice );
139
+        parent::__construct($invoice);
140 140
 
141
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
142
-			$this->set_id( $invoice );
143
-		} elseif ( $invoice instanceof self ) {
144
-			$this->set_id( $invoice->get_id() );
145
-		} elseif ( ! empty( $invoice->ID ) ) {
146
-			$this->set_id( $invoice->ID );
147
-		} elseif ( is_array( $invoice ) ) {
148
-			$this->set_props( $invoice );
141
+		if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type($invoice))) {
142
+			$this->set_id($invoice);
143
+		} elseif ($invoice instanceof self) {
144
+			$this->set_id($invoice->get_id());
145
+		} elseif (!empty($invoice->ID)) {
146
+			$this->set_id($invoice->ID);
147
+		} elseif (is_array($invoice)) {
148
+			$this->set_props($invoice);
149 149
 
150
-			if ( isset( $invoice['ID'] ) ) {
151
-				$this->set_id( $invoice['ID'] );
150
+			if (isset($invoice['ID'])) {
151
+				$this->set_id($invoice['ID']);
152 152
 			}
153 153
 
154
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
155
-			$this->set_id( $invoice_id );
156
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
157
-			$this->set_id( $invoice_id );
158
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
159
-			$this->set_id( $invoice_id );
160
-		}else {
161
-			$this->set_object_read( true );
154
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) {
155
+			$this->set_id($invoice_id);
156
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) {
157
+			$this->set_id($invoice_id);
158
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) {
159
+			$this->set_id($invoice_id);
160
+		} else {
161
+			$this->set_object_read(true);
162 162
 		}
163 163
 
164 164
         // Load the datastore.
165
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
165
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
166 166
 
167
-		if ( $this->get_id() > 0 ) {
168
-            $this->post = get_post( $this->get_id() );
167
+		if ($this->get_id() > 0) {
168
+            $this->post = get_post($this->get_id());
169 169
             $this->ID   = $this->get_id();
170
-			$this->data_store->read( $this );
170
+			$this->data_store->read($this);
171 171
         }
172 172
 
173 173
     }
@@ -182,38 +182,38 @@  discard block
 block discarded – undo
182 182
 	 * @since 1.0.15
183 183
 	 * @return int
184 184
 	 */
185
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
185
+	public static function get_invoice_id_by_field($value, $field = 'key') {
186 186
         global $wpdb;
187 187
 
188 188
 		// Trim the value.
189
-		$value = trim( $value );
189
+		$value = trim($value);
190 190
 
191
-		if ( empty( $value ) ) {
191
+		if (empty($value)) {
192 192
 			return 0;
193 193
 		}
194 194
 
195 195
         // Valid fields.
196
-        $fields = array( 'key', 'number', 'transaction_id' );
196
+        $fields = array('key', 'number', 'transaction_id');
197 197
 
198 198
 		// Ensure a field has been passed.
199
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
199
+		if (empty($field) || !in_array($field, $fields)) {
200 200
 			return 0;
201 201
 		}
202 202
 
203 203
 		// Maybe retrieve from the cache.
204
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
205
-		if ( false !== $invoice_id ) {
204
+		$invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids");
205
+		if (false !== $invoice_id) {
206 206
 			return $invoice_id;
207 207
 		}
208 208
 
209 209
         // Fetch from the db.
210 210
         $table       = $wpdb->prefix . 'getpaid_invoices';
211 211
         $invoice_id  = (int) $wpdb->get_var(
212
-            $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
212
+            $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
213 213
         );
214 214
 
215 215
 		// Update the cache with our data
216
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
216
+		wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids");
217 217
 
218 218
 		return $invoice_id;
219 219
     }
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
     /**
222 222
      * Checks if an invoice key is set.
223 223
      */
224
-    public function _isset( $key ) {
225
-        return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
224
+    public function _isset($key) {
225
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
226 226
     }
227 227
 
228 228
     /*
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
 	 * @param  string $context View or edit context.
248 248
 	 * @return int
249 249
 	 */
250
-	public function get_parent_id( $context = 'view' ) {
251
-		return (int) $this->get_prop( 'parent_id', $context );
250
+	public function get_parent_id($context = 'view') {
251
+		return (int) $this->get_prop('parent_id', $context);
252 252
     }
253 253
 
254 254
     /**
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	 * @return WPInv_Invoice
259 259
 	 */
260 260
     public function get_parent_payment() {
261
-        return new WPInv_Invoice( $this->get_parent_id() );
261
+        return new WPInv_Invoice($this->get_parent_id());
262 262
     }
263 263
 
264 264
     /**
@@ -278,8 +278,8 @@  discard block
 block discarded – undo
278 278
 	 * @param  string $context View or edit context.
279 279
 	 * @return string
280 280
 	 */
281
-	public function get_status( $context = 'view' ) {
282
-		return $this->get_prop( 'status', $context );
281
+	public function get_status($context = 'view') {
282
+		return $this->get_prop('status', $context);
283 283
 	}
284 284
 	
285 285
 	/**
@@ -290,10 +290,10 @@  discard block
 block discarded – undo
290 290
 	 */
291 291
 	public function get_all_statuses() {
292 292
 
293
-		$statuses = wpinv_get_invoice_statuses( true, true, $this );
293
+		$statuses = wpinv_get_invoice_statuses(true, true, $this);
294 294
 
295 295
 		// For backwards compatibility.
296
-		if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
296
+		if ($this->is_quote() && class_exists('Wpinv_Quotes_Shared')) {
297 297
             $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
298 298
 		}
299 299
 
@@ -309,9 +309,9 @@  discard block
 block discarded – undo
309 309
     public function get_status_nicename() {
310 310
 		$statuses = $this->get_all_statuses();
311 311
 
312
-        $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
312
+        $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status();
313 313
 
314
-        return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
314
+        return apply_filters('wpinv_get_invoice_status_nicename', $status, $this);
315 315
     }
316 316
 
317 317
 	/**
@@ -322,8 +322,8 @@  discard block
 block discarded – undo
322 322
      */
323 323
     public function get_status_label_html() {
324 324
 
325
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
326
-		$status       = sanitize_html_class( $this->get_status() );
325
+		$status_label = sanitize_text_field($this->get_status_nicename());
326
+		$status       = sanitize_html_class($this->get_status());
327 327
 
328 328
 		return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
329 329
 	}
@@ -335,23 +335,23 @@  discard block
 block discarded – undo
335 335
 	 * @param  string $context View or edit context.
336 336
 	 * @return string
337 337
 	 */
338
-	public function get_version( $context = 'view' ) {
339
-		return $this->get_prop( 'version', $context );
338
+	public function get_version($context = 'view') {
339
+		return $this->get_prop('version', $context);
340 340
 	}
341 341
 
342 342
 	/**
343 343
 	 * @deprecated
344 344
 	 */
345
-	public function get_invoice_date( $format = true ) {
346
-		$date      = getpaid_format_date( $this->get_date_completed() );
347
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
348
-		$formatted = getpaid_format_date( $date );
345
+	public function get_invoice_date($format = true) {
346
+		$date      = getpaid_format_date($this->get_date_completed());
347
+		$date      = empty($date) ? $this->get_date_created() : $this->get_date_completed();
348
+		$formatted = getpaid_format_date($date);
349 349
 
350
-		if ( $format ) {
350
+		if ($format) {
351 351
 			return $formatted;
352 352
 		}
353 353
 
354
-		return empty( $formatted ) ? '' : $date;
354
+		return empty($formatted) ? '' : $date;
355 355
 
356 356
     }
357 357
 
@@ -362,8 +362,8 @@  discard block
 block discarded – undo
362 362
 	 * @param  string $context View or edit context.
363 363
 	 * @return string
364 364
 	 */
365
-	public function get_date_created( $context = 'view' ) {
366
-		return $this->get_prop( 'date_created', $context );
365
+	public function get_date_created($context = 'view') {
366
+		return $this->get_prop('date_created', $context);
367 367
 	}
368 368
 	
369 369
 	/**
@@ -373,8 +373,8 @@  discard block
 block discarded – undo
373 373
 	 * @param  string $context View or edit context.
374 374
 	 * @return string
375 375
 	 */
376
-	public function get_created_date( $context = 'view' ) {
377
-		return $this->get_date_created( $context );
376
+	public function get_created_date($context = 'view') {
377
+		return $this->get_date_created($context);
378 378
     }
379 379
 
380 380
     /**
@@ -384,11 +384,11 @@  discard block
 block discarded – undo
384 384
 	 * @param  string $context View or edit context.
385 385
 	 * @return string
386 386
 	 */
387
-	public function get_date_created_gmt( $context = 'view' ) {
388
-        $date = $this->get_date_created( $context );
387
+	public function get_date_created_gmt($context = 'view') {
388
+        $date = $this->get_date_created($context);
389 389
 
390
-        if ( $date ) {
391
-            $date = get_gmt_from_date( $date );
390
+        if ($date) {
391
+            $date = get_gmt_from_date($date);
392 392
         }
393 393
 		return $date;
394 394
     }
@@ -400,8 +400,8 @@  discard block
 block discarded – undo
400 400
 	 * @param  string $context View or edit context.
401 401
 	 * @return string
402 402
 	 */
403
-	public function get_date_modified( $context = 'view' ) {
404
-		return $this->get_prop( 'date_modified', $context );
403
+	public function get_date_modified($context = 'view') {
404
+		return $this->get_prop('date_modified', $context);
405 405
 	}
406 406
 
407 407
 	/**
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
 	 * @param  string $context View or edit context.
412 412
 	 * @return string
413 413
 	 */
414
-	public function get_modified_date( $context = 'view' ) {
415
-		return $this->get_date_modified( $context );
414
+	public function get_modified_date($context = 'view') {
415
+		return $this->get_date_modified($context);
416 416
     }
417 417
 
418 418
     /**
@@ -422,11 +422,11 @@  discard block
 block discarded – undo
422 422
 	 * @param  string $context View or edit context.
423 423
 	 * @return string
424 424
 	 */
425
-	public function get_date_modified_gmt( $context = 'view' ) {
426
-        $date = $this->get_date_modified( $context );
425
+	public function get_date_modified_gmt($context = 'view') {
426
+        $date = $this->get_date_modified($context);
427 427
 
428
-        if ( $date ) {
429
-            $date = get_gmt_from_date( $date );
428
+        if ($date) {
429
+            $date = get_gmt_from_date($date);
430 430
         }
431 431
 		return $date;
432 432
     }
@@ -438,8 +438,8 @@  discard block
 block discarded – undo
438 438
 	 * @param  string $context View or edit context.
439 439
 	 * @return string
440 440
 	 */
441
-	public function get_due_date( $context = 'view' ) {
442
-		return $this->get_prop( 'due_date', $context );
441
+	public function get_due_date($context = 'view') {
442
+		return $this->get_prop('due_date', $context);
443 443
     }
444 444
 
445 445
     /**
@@ -449,8 +449,8 @@  discard block
 block discarded – undo
449 449
 	 * @param  string $context View or edit context.
450 450
 	 * @return string
451 451
 	 */
452
-	public function get_date_due( $context = 'view' ) {
453
-		return $this->get_due_date( $context );
452
+	public function get_date_due($context = 'view') {
453
+		return $this->get_due_date($context);
454 454
     }
455 455
 
456 456
     /**
@@ -460,11 +460,11 @@  discard block
 block discarded – undo
460 460
 	 * @param  string $context View or edit context.
461 461
 	 * @return string
462 462
 	 */
463
-	public function get_due_date_gmt( $context = 'view' ) {
464
-        $date = $this->get_due_date( $context );
463
+	public function get_due_date_gmt($context = 'view') {
464
+        $date = $this->get_due_date($context);
465 465
 
466
-        if ( $date ) {
467
-            $date = get_gmt_from_date( $date );
466
+        if ($date) {
467
+            $date = get_gmt_from_date($date);
468 468
         }
469 469
 		return $date;
470 470
     }
@@ -476,8 +476,8 @@  discard block
 block discarded – undo
476 476
 	 * @param  string $context View or edit context.
477 477
 	 * @return string
478 478
 	 */
479
-	public function get_gmt_date_due( $context = 'view' ) {
480
-		return $this->get_due_date_gmt( $context );
479
+	public function get_gmt_date_due($context = 'view') {
480
+		return $this->get_due_date_gmt($context);
481 481
     }
482 482
 
483 483
     /**
@@ -487,8 +487,8 @@  discard block
 block discarded – undo
487 487
 	 * @param  string $context View or edit context.
488 488
 	 * @return string
489 489
 	 */
490
-	public function get_completed_date( $context = 'view' ) {
491
-		return $this->get_prop( 'completed_date', $context );
490
+	public function get_completed_date($context = 'view') {
491
+		return $this->get_prop('completed_date', $context);
492 492
     }
493 493
 
494 494
     /**
@@ -498,8 +498,8 @@  discard block
 block discarded – undo
498 498
 	 * @param  string $context View or edit context.
499 499
 	 * @return string
500 500
 	 */
501
-	public function get_date_completed( $context = 'view' ) {
502
-		return $this->get_completed_date( $context );
501
+	public function get_date_completed($context = 'view') {
502
+		return $this->get_completed_date($context);
503 503
     }
504 504
 
505 505
     /**
@@ -509,11 +509,11 @@  discard block
 block discarded – undo
509 509
 	 * @param  string $context View or edit context.
510 510
 	 * @return string
511 511
 	 */
512
-	public function get_completed_date_gmt( $context = 'view' ) {
513
-        $date = $this->get_completed_date( $context );
512
+	public function get_completed_date_gmt($context = 'view') {
513
+        $date = $this->get_completed_date($context);
514 514
 
515
-        if ( $date ) {
516
-            $date = get_gmt_from_date( $date );
515
+        if ($date) {
516
+            $date = get_gmt_from_date($date);
517 517
         }
518 518
 		return $date;
519 519
     }
@@ -525,8 +525,8 @@  discard block
 block discarded – undo
525 525
 	 * @param  string $context View or edit context.
526 526
 	 * @return string
527 527
 	 */
528
-	public function get_gmt_completed_date( $context = 'view' ) {
529
-		return $this->get_completed_date_gmt( $context );
528
+	public function get_gmt_completed_date($context = 'view') {
529
+		return $this->get_completed_date_gmt($context);
530 530
     }
531 531
 
532 532
     /**
@@ -536,12 +536,12 @@  discard block
 block discarded – undo
536 536
 	 * @param  string $context View or edit context.
537 537
 	 * @return string
538 538
 	 */
539
-	public function get_number( $context = 'view' ) {
540
-		$number = $this->get_prop( 'number', $context );
539
+	public function get_number($context = 'view') {
540
+		$number = $this->get_prop('number', $context);
541 541
 
542
-		if ( empty( $number ) ) {
542
+		if (empty($number)) {
543 543
 			$number = $this->generate_number();
544
-			$this->set_number( $this->generate_number() );
544
+			$this->set_number($this->generate_number());
545 545
 		}
546 546
 
547 547
 		return $number;
@@ -555,8 +555,8 @@  discard block
 block discarded – undo
555 555
 	public function maybe_set_number() {
556 556
         $number = $this->get_number();
557 557
 
558
-        if ( empty( $number ) || $this->get_id() == $number ) {
559
-			$this->set_number( $this->generate_number() );
558
+        if (empty($number) || $this->get_id() == $number) {
559
+			$this->set_number($this->generate_number());
560 560
         }
561 561
 
562 562
 	}
@@ -568,8 +568,8 @@  discard block
 block discarded – undo
568 568
 	 * @param  string $context View or edit context.
569 569
 	 * @return string
570 570
 	 */
571
-	public function get_key( $context = 'view' ) {
572
-        return $this->get_prop( 'key', $context );
571
+	public function get_key($context = 'view') {
572
+        return $this->get_prop('key', $context);
573 573
 	}
574 574
 
575 575
 	/**
@@ -580,9 +580,9 @@  discard block
 block discarded – undo
580 580
 	public function maybe_set_key() {
581 581
         $key = $this->get_key();
582 582
 
583
-        if ( empty( $key ) ) {
584
-            $key = $this->generate_key( $this->get_type() . '_' );
585
-            $this->set_key( $key );
583
+        if (empty($key)) {
584
+            $key = $this->generate_key($this->get_type() . '_');
585
+            $this->set_key($key);
586 586
         }
587 587
 
588 588
     }
@@ -594,15 +594,15 @@  discard block
 block discarded – undo
594 594
 	 * @param  string $context View or edit context.
595 595
 	 * @return string
596 596
 	 */
597
-	public function get_type( $context = 'view' ) {
598
-        return $this->get_prop( 'type', $context );
597
+	public function get_type($context = 'view') {
598
+        return $this->get_prop('type', $context);
599 599
 	}
600 600
 
601 601
 	/**
602 602
 	 * @deprecated
603 603
 	 */
604 604
 	public function get_invoice_quote_type() {
605
-        ucfirst( $this->get_type() );
605
+        ucfirst($this->get_type());
606 606
     }
607 607
 
608 608
     /**
@@ -612,8 +612,8 @@  discard block
 block discarded – undo
612 612
 	 * @param  string $context View or edit context.
613 613
 	 * @return string
614 614
 	 */
615
-	public function get_post_type( $context = 'view' ) {
616
-        return $this->get_prop( 'post_type', $context );
615
+	public function get_post_type($context = 'view') {
616
+        return $this->get_prop('post_type', $context);
617 617
     }
618 618
 
619 619
     /**
@@ -623,8 +623,8 @@  discard block
 block discarded – undo
623 623
 	 * @param  string $context View or edit context.
624 624
 	 * @return string
625 625
 	 */
626
-	public function get_mode( $context = 'view' ) {
627
-        return $this->get_prop( 'mode', $context );
626
+	public function get_mode($context = 'view') {
627
+        return $this->get_prop('mode', $context);
628 628
     }
629 629
 
630 630
     /**
@@ -634,13 +634,13 @@  discard block
 block discarded – undo
634 634
 	 * @param  string $context View or edit context.
635 635
 	 * @return string
636 636
 	 */
637
-	public function get_path( $context = 'view' ) {
638
-        $path   = $this->get_prop( 'path', $context );
639
-		$prefix = wpinv_post_name_prefix( $this->get_post_type() );
637
+	public function get_path($context = 'view') {
638
+        $path = $this->get_prop('path', $context);
639
+		$prefix = wpinv_post_name_prefix($this->get_post_type());
640 640
 
641
-		if ( 0 !== strpos( $path, $prefix ) ) {
642
-			$path = sanitize_title(  $prefix . $this->get_id()  );
643
-			$this->set_path( $path );
641
+		if (0 !== strpos($path, $prefix)) {
642
+			$path = sanitize_title($prefix . $this->get_id());
643
+			$this->set_path($path);
644 644
 		}
645 645
 
646 646
 		return $path;
@@ -653,8 +653,8 @@  discard block
 block discarded – undo
653 653
 	 * @param  string $context View or edit context.
654 654
 	 * @return string
655 655
 	 */
656
-	public function get_name( $context = 'view' ) {
657
-        return $this->get_prop( 'title', $context );
656
+	public function get_name($context = 'view') {
657
+        return $this->get_prop('title', $context);
658 658
     }
659 659
 
660 660
     /**
@@ -664,8 +664,8 @@  discard block
 block discarded – undo
664 664
 	 * @param  string $context View or edit context.
665 665
 	 * @return string
666 666
 	 */
667
-	public function get_title( $context = 'view' ) {
668
-		return $this->get_name( $context );
667
+	public function get_title($context = 'view') {
668
+		return $this->get_name($context);
669 669
     }
670 670
 
671 671
     /**
@@ -675,8 +675,8 @@  discard block
 block discarded – undo
675 675
 	 * @param  string $context View or edit context.
676 676
 	 * @return string
677 677
 	 */
678
-	public function get_description( $context = 'view' ) {
679
-		return $this->get_prop( 'description', $context );
678
+	public function get_description($context = 'view') {
679
+		return $this->get_prop('description', $context);
680 680
     }
681 681
 
682 682
     /**
@@ -686,8 +686,8 @@  discard block
 block discarded – undo
686 686
 	 * @param  string $context View or edit context.
687 687
 	 * @return string
688 688
 	 */
689
-	public function get_excerpt( $context = 'view' ) {
690
-		return $this->get_description( $context );
689
+	public function get_excerpt($context = 'view') {
690
+		return $this->get_description($context);
691 691
     }
692 692
 
693 693
     /**
@@ -697,8 +697,8 @@  discard block
 block discarded – undo
697 697
 	 * @param  string $context View or edit context.
698 698
 	 * @return string
699 699
 	 */
700
-	public function get_summary( $context = 'view' ) {
701
-		return $this->get_description( $context );
700
+	public function get_summary($context = 'view') {
701
+		return $this->get_description($context);
702 702
     }
703 703
 
704 704
     /**
@@ -708,25 +708,25 @@  discard block
 block discarded – undo
708 708
      * @param  string $context View or edit context.
709 709
 	 * @return array
710 710
 	 */
711
-    public function get_user_info( $context = 'view' ) {
711
+    public function get_user_info($context = 'view') {
712 712
 
713 713
         $user_info = array(
714
-            'user_id'    => $this->get_user_id( $context ),
715
-            'email'      => $this->get_email( $context ),
716
-            'first_name' => $this->get_first_name( $context ),
717
-            'last_name'  => $this->get_last_name( $context ),
718
-            'address'    => $this->get_address( $context ),
719
-            'phone'      => $this->get_phone( $context ),
720
-            'city'       => $this->get_city( $context ),
721
-            'country'    => $this->get_country( $context ),
722
-            'state'      => $this->get_state( $context ),
723
-            'zip'        => $this->get_zip( $context ),
724
-            'company'    => $this->get_company( $context ),
725
-            'vat_number' => $this->get_vat_number( $context ),
726
-            'discount'   => $this->get_discount_code( $context ),
714
+            'user_id'    => $this->get_user_id($context),
715
+            'email'      => $this->get_email($context),
716
+            'first_name' => $this->get_first_name($context),
717
+            'last_name'  => $this->get_last_name($context),
718
+            'address'    => $this->get_address($context),
719
+            'phone'      => $this->get_phone($context),
720
+            'city'       => $this->get_city($context),
721
+            'country'    => $this->get_country($context),
722
+            'state'      => $this->get_state($context),
723
+            'zip'        => $this->get_zip($context),
724
+            'company'    => $this->get_company($context),
725
+            'vat_number' => $this->get_vat_number($context),
726
+            'discount'   => $this->get_discount_code($context),
727 727
 		);
728 728
 
729
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
729
+		return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this);
730 730
 
731 731
     }
732 732
 
@@ -737,8 +737,8 @@  discard block
 block discarded – undo
737 737
 	 * @param  string $context View or edit context.
738 738
 	 * @return int
739 739
 	 */
740
-	public function get_author( $context = 'view' ) {
741
-		return (int) $this->get_prop( 'author', $context );
740
+	public function get_author($context = 'view') {
741
+		return (int) $this->get_prop('author', $context);
742 742
     }
743 743
 
744 744
     /**
@@ -748,8 +748,8 @@  discard block
 block discarded – undo
748 748
 	 * @param  string $context View or edit context.
749 749
 	 * @return int
750 750
 	 */
751
-	public function get_user_id( $context = 'view' ) {
752
-		return $this->get_author( $context );
751
+	public function get_user_id($context = 'view') {
752
+		return $this->get_author($context);
753 753
     }
754 754
 
755 755
      /**
@@ -759,8 +759,8 @@  discard block
 block discarded – undo
759 759
 	 * @param  string $context View or edit context.
760 760
 	 * @return int
761 761
 	 */
762
-	public function get_customer_id( $context = 'view' ) {
763
-		return $this->get_author( $context );
762
+	public function get_customer_id($context = 'view') {
763
+		return $this->get_author($context);
764 764
     }
765 765
 
766 766
     /**
@@ -770,8 +770,8 @@  discard block
 block discarded – undo
770 770
 	 * @param  string $context View or edit context.
771 771
 	 * @return string
772 772
 	 */
773
-	public function get_ip( $context = 'view' ) {
774
-		return $this->get_prop( 'user_ip', $context );
773
+	public function get_ip($context = 'view') {
774
+		return $this->get_prop('user_ip', $context);
775 775
     }
776 776
 
777 777
     /**
@@ -781,8 +781,8 @@  discard block
 block discarded – undo
781 781
 	 * @param  string $context View or edit context.
782 782
 	 * @return string
783 783
 	 */
784
-	public function get_user_ip( $context = 'view' ) {
785
-		return $this->get_ip( $context );
784
+	public function get_user_ip($context = 'view') {
785
+		return $this->get_ip($context);
786 786
     }
787 787
 
788 788
      /**
@@ -792,8 +792,8 @@  discard block
 block discarded – undo
792 792
 	 * @param  string $context View or edit context.
793 793
 	 * @return string
794 794
 	 */
795
-	public function get_customer_ip( $context = 'view' ) {
796
-		return $this->get_ip( $context );
795
+	public function get_customer_ip($context = 'view') {
796
+		return $this->get_ip($context);
797 797
     }
798 798
 
799 799
     /**
@@ -803,8 +803,8 @@  discard block
 block discarded – undo
803 803
 	 * @param  string $context View or edit context.
804 804
 	 * @return string
805 805
 	 */
806
-	public function get_first_name( $context = 'view' ) {
807
-		return $this->get_prop( 'first_name', $context );
806
+	public function get_first_name($context = 'view') {
807
+		return $this->get_prop('first_name', $context);
808 808
     }
809 809
 
810 810
     /**
@@ -814,8 +814,8 @@  discard block
 block discarded – undo
814 814
 	 * @param  string $context View or edit context.
815 815
 	 * @return int
816 816
 	 */
817
-	public function get_user_first_name( $context = 'view' ) {
818
-		return $this->get_first_name( $context );
817
+	public function get_user_first_name($context = 'view') {
818
+		return $this->get_first_name($context);
819 819
     }
820 820
 
821 821
      /**
@@ -825,8 +825,8 @@  discard block
 block discarded – undo
825 825
 	 * @param  string $context View or edit context.
826 826
 	 * @return int
827 827
 	 */
828
-	public function get_customer_first_name( $context = 'view' ) {
829
-		return $this->get_first_name( $context );
828
+	public function get_customer_first_name($context = 'view') {
829
+		return $this->get_first_name($context);
830 830
     }
831 831
 
832 832
     /**
@@ -836,8 +836,8 @@  discard block
 block discarded – undo
836 836
 	 * @param  string $context View or edit context.
837 837
 	 * @return string
838 838
 	 */
839
-	public function get_last_name( $context = 'view' ) {
840
-		return $this->get_prop( 'last_name', $context );
839
+	public function get_last_name($context = 'view') {
840
+		return $this->get_prop('last_name', $context);
841 841
     }
842 842
 
843 843
     /**
@@ -847,8 +847,8 @@  discard block
 block discarded – undo
847 847
 	 * @param  string $context View or edit context.
848 848
 	 * @return int
849 849
 	 */
850
-	public function get_user_last_name( $context = 'view' ) {
851
-		return $this->get_last_name( $context );
850
+	public function get_user_last_name($context = 'view') {
851
+		return $this->get_last_name($context);
852 852
     }
853 853
 
854 854
     /**
@@ -858,8 +858,8 @@  discard block
 block discarded – undo
858 858
 	 * @param  string $context View or edit context.
859 859
 	 * @return int
860 860
 	 */
861
-	public function get_customer_last_name( $context = 'view' ) {
862
-		return $this->get_last_name( $context );
861
+	public function get_customer_last_name($context = 'view') {
862
+		return $this->get_last_name($context);
863 863
     }
864 864
 
865 865
     /**
@@ -869,8 +869,8 @@  discard block
 block discarded – undo
869 869
 	 * @param  string $context View or edit context.
870 870
 	 * @return string
871 871
 	 */
872
-	public function get_full_name( $context = 'view' ) {
873
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
872
+	public function get_full_name($context = 'view') {
873
+		return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context));
874 874
     }
875 875
 
876 876
     /**
@@ -880,8 +880,8 @@  discard block
 block discarded – undo
880 880
 	 * @param  string $context View or edit context.
881 881
 	 * @return int
882 882
 	 */
883
-	public function get_user_full_name( $context = 'view' ) {
884
-		return $this->get_full_name( $context );
883
+	public function get_user_full_name($context = 'view') {
884
+		return $this->get_full_name($context);
885 885
     }
886 886
 
887 887
     /**
@@ -891,8 +891,8 @@  discard block
 block discarded – undo
891 891
 	 * @param  string $context View or edit context.
892 892
 	 * @return int
893 893
 	 */
894
-	public function get_customer_full_name( $context = 'view' ) {
895
-		return $this->get_full_name( $context );
894
+	public function get_customer_full_name($context = 'view') {
895
+		return $this->get_full_name($context);
896 896
     }
897 897
 
898 898
     /**
@@ -902,8 +902,8 @@  discard block
 block discarded – undo
902 902
 	 * @param  string $context View or edit context.
903 903
 	 * @return string
904 904
 	 */
905
-	public function get_phone( $context = 'view' ) {
906
-		return $this->get_prop( 'phone', $context );
905
+	public function get_phone($context = 'view') {
906
+		return $this->get_prop('phone', $context);
907 907
     }
908 908
 
909 909
     /**
@@ -913,8 +913,8 @@  discard block
 block discarded – undo
913 913
 	 * @param  string $context View or edit context.
914 914
 	 * @return int
915 915
 	 */
916
-	public function get_phone_number( $context = 'view' ) {
917
-		return $this->get_phone( $context );
916
+	public function get_phone_number($context = 'view') {
917
+		return $this->get_phone($context);
918 918
     }
919 919
 
920 920
     /**
@@ -924,8 +924,8 @@  discard block
 block discarded – undo
924 924
 	 * @param  string $context View or edit context.
925 925
 	 * @return int
926 926
 	 */
927
-	public function get_user_phone( $context = 'view' ) {
928
-		return $this->get_phone( $context );
927
+	public function get_user_phone($context = 'view') {
928
+		return $this->get_phone($context);
929 929
     }
930 930
 
931 931
     /**
@@ -935,8 +935,8 @@  discard block
 block discarded – undo
935 935
 	 * @param  string $context View or edit context.
936 936
 	 * @return int
937 937
 	 */
938
-	public function get_customer_phone( $context = 'view' ) {
939
-		return $this->get_phone( $context );
938
+	public function get_customer_phone($context = 'view') {
939
+		return $this->get_phone($context);
940 940
     }
941 941
 
942 942
     /**
@@ -946,8 +946,8 @@  discard block
 block discarded – undo
946 946
 	 * @param  string $context View or edit context.
947 947
 	 * @return string
948 948
 	 */
949
-	public function get_email( $context = 'view' ) {
950
-		return $this->get_prop( 'email', $context );
949
+	public function get_email($context = 'view') {
950
+		return $this->get_prop('email', $context);
951 951
     }
952 952
 
953 953
     /**
@@ -957,8 +957,8 @@  discard block
 block discarded – undo
957 957
 	 * @param  string $context View or edit context.
958 958
 	 * @return string
959 959
 	 */
960
-	public function get_email_address( $context = 'view' ) {
961
-		return $this->get_email( $context );
960
+	public function get_email_address($context = 'view') {
961
+		return $this->get_email($context);
962 962
     }
963 963
 
964 964
     /**
@@ -968,8 +968,8 @@  discard block
 block discarded – undo
968 968
 	 * @param  string $context View or edit context.
969 969
 	 * @return int
970 970
 	 */
971
-	public function get_user_email( $context = 'view' ) {
972
-		return $this->get_email( $context );
971
+	public function get_user_email($context = 'view') {
972
+		return $this->get_email($context);
973 973
     }
974 974
 
975 975
     /**
@@ -979,8 +979,8 @@  discard block
 block discarded – undo
979 979
 	 * @param  string $context View or edit context.
980 980
 	 * @return int
981 981
 	 */
982
-	public function get_customer_email( $context = 'view' ) {
983
-		return $this->get_email( $context );
982
+	public function get_customer_email($context = 'view') {
983
+		return $this->get_email($context);
984 984
     }
985 985
 
986 986
     /**
@@ -990,9 +990,9 @@  discard block
 block discarded – undo
990 990
 	 * @param  string $context View or edit context.
991 991
 	 * @return string
992 992
 	 */
993
-	public function get_country( $context = 'view' ) {
994
-		$country = $this->get_prop( 'country', $context );
995
-		return empty( $country ) ? wpinv_get_default_country() : $country;
993
+	public function get_country($context = 'view') {
994
+		$country = $this->get_prop('country', $context);
995
+		return empty($country) ? wpinv_get_default_country() : $country;
996 996
     }
997 997
 
998 998
     /**
@@ -1002,8 +1002,8 @@  discard block
 block discarded – undo
1002 1002
 	 * @param  string $context View or edit context.
1003 1003
 	 * @return int
1004 1004
 	 */
1005
-	public function get_user_country( $context = 'view' ) {
1006
-		return $this->get_country( $context );
1005
+	public function get_user_country($context = 'view') {
1006
+		return $this->get_country($context);
1007 1007
     }
1008 1008
 
1009 1009
     /**
@@ -1013,8 +1013,8 @@  discard block
 block discarded – undo
1013 1013
 	 * @param  string $context View or edit context.
1014 1014
 	 * @return int
1015 1015
 	 */
1016
-	public function get_customer_country( $context = 'view' ) {
1017
-		return $this->get_country( $context );
1016
+	public function get_customer_country($context = 'view') {
1017
+		return $this->get_country($context);
1018 1018
     }
1019 1019
 
1020 1020
     /**
@@ -1024,9 +1024,9 @@  discard block
 block discarded – undo
1024 1024
 	 * @param  string $context View or edit context.
1025 1025
 	 * @return string
1026 1026
 	 */
1027
-	public function get_state( $context = 'view' ) {
1028
-		$state = $this->get_prop( 'state', $context );
1029
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1027
+	public function get_state($context = 'view') {
1028
+		$state = $this->get_prop('state', $context);
1029
+		return empty($state) ? wpinv_get_default_state() : $state;
1030 1030
     }
1031 1031
 
1032 1032
     /**
@@ -1036,8 +1036,8 @@  discard block
 block discarded – undo
1036 1036
 	 * @param  string $context View or edit context.
1037 1037
 	 * @return int
1038 1038
 	 */
1039
-	public function get_user_state( $context = 'view' ) {
1040
-		return $this->get_state( $context );
1039
+	public function get_user_state($context = 'view') {
1040
+		return $this->get_state($context);
1041 1041
     }
1042 1042
 
1043 1043
     /**
@@ -1047,8 +1047,8 @@  discard block
 block discarded – undo
1047 1047
 	 * @param  string $context View or edit context.
1048 1048
 	 * @return int
1049 1049
 	 */
1050
-	public function get_customer_state( $context = 'view' ) {
1051
-		return $this->get_state( $context );
1050
+	public function get_customer_state($context = 'view') {
1051
+		return $this->get_state($context);
1052 1052
     }
1053 1053
 
1054 1054
     /**
@@ -1058,8 +1058,8 @@  discard block
 block discarded – undo
1058 1058
 	 * @param  string $context View or edit context.
1059 1059
 	 * @return string
1060 1060
 	 */
1061
-	public function get_city( $context = 'view' ) {
1062
-		return $this->get_prop( 'city', $context );
1061
+	public function get_city($context = 'view') {
1062
+		return $this->get_prop('city', $context);
1063 1063
     }
1064 1064
 
1065 1065
     /**
@@ -1069,8 +1069,8 @@  discard block
 block discarded – undo
1069 1069
 	 * @param  string $context View or edit context.
1070 1070
 	 * @return string
1071 1071
 	 */
1072
-	public function get_user_city( $context = 'view' ) {
1073
-		return $this->get_city( $context );
1072
+	public function get_user_city($context = 'view') {
1073
+		return $this->get_city($context);
1074 1074
     }
1075 1075
 
1076 1076
     /**
@@ -1080,8 +1080,8 @@  discard block
 block discarded – undo
1080 1080
 	 * @param  string $context View or edit context.
1081 1081
 	 * @return string
1082 1082
 	 */
1083
-	public function get_customer_city( $context = 'view' ) {
1084
-		return $this->get_city( $context );
1083
+	public function get_customer_city($context = 'view') {
1084
+		return $this->get_city($context);
1085 1085
     }
1086 1086
 
1087 1087
     /**
@@ -1091,8 +1091,8 @@  discard block
 block discarded – undo
1091 1091
 	 * @param  string $context View or edit context.
1092 1092
 	 * @return string
1093 1093
 	 */
1094
-	public function get_zip( $context = 'view' ) {
1095
-		return $this->get_prop( 'zip', $context );
1094
+	public function get_zip($context = 'view') {
1095
+		return $this->get_prop('zip', $context);
1096 1096
     }
1097 1097
 
1098 1098
     /**
@@ -1102,8 +1102,8 @@  discard block
 block discarded – undo
1102 1102
 	 * @param  string $context View or edit context.
1103 1103
 	 * @return string
1104 1104
 	 */
1105
-	public function get_user_zip( $context = 'view' ) {
1106
-		return $this->get_zip( $context );
1105
+	public function get_user_zip($context = 'view') {
1106
+		return $this->get_zip($context);
1107 1107
     }
1108 1108
 
1109 1109
     /**
@@ -1113,8 +1113,8 @@  discard block
 block discarded – undo
1113 1113
 	 * @param  string $context View or edit context.
1114 1114
 	 * @return string
1115 1115
 	 */
1116
-	public function get_customer_zip( $context = 'view' ) {
1117
-		return $this->get_zip( $context );
1116
+	public function get_customer_zip($context = 'view') {
1117
+		return $this->get_zip($context);
1118 1118
     }
1119 1119
 
1120 1120
     /**
@@ -1124,8 +1124,8 @@  discard block
 block discarded – undo
1124 1124
 	 * @param  string $context View or edit context.
1125 1125
 	 * @return string
1126 1126
 	 */
1127
-	public function get_company( $context = 'view' ) {
1128
-		return $this->get_prop( 'company', $context );
1127
+	public function get_company($context = 'view') {
1128
+		return $this->get_prop('company', $context);
1129 1129
     }
1130 1130
 
1131 1131
     /**
@@ -1135,8 +1135,8 @@  discard block
 block discarded – undo
1135 1135
 	 * @param  string $context View or edit context.
1136 1136
 	 * @return string
1137 1137
 	 */
1138
-	public function get_user_company( $context = 'view' ) {
1139
-		return $this->get_company( $context );
1138
+	public function get_user_company($context = 'view') {
1139
+		return $this->get_company($context);
1140 1140
     }
1141 1141
 
1142 1142
     /**
@@ -1146,8 +1146,8 @@  discard block
 block discarded – undo
1146 1146
 	 * @param  string $context View or edit context.
1147 1147
 	 * @return string
1148 1148
 	 */
1149
-	public function get_customer_company( $context = 'view' ) {
1150
-		return $this->get_company( $context );
1149
+	public function get_customer_company($context = 'view') {
1150
+		return $this->get_company($context);
1151 1151
     }
1152 1152
 
1153 1153
     /**
@@ -1157,8 +1157,8 @@  discard block
 block discarded – undo
1157 1157
 	 * @param  string $context View or edit context.
1158 1158
 	 * @return string
1159 1159
 	 */
1160
-	public function get_vat_number( $context = 'view' ) {
1161
-		return $this->get_prop( 'vat_number', $context );
1160
+	public function get_vat_number($context = 'view') {
1161
+		return $this->get_prop('vat_number', $context);
1162 1162
     }
1163 1163
 
1164 1164
     /**
@@ -1168,8 +1168,8 @@  discard block
 block discarded – undo
1168 1168
 	 * @param  string $context View or edit context.
1169 1169
 	 * @return string
1170 1170
 	 */
1171
-	public function get_user_vat_number( $context = 'view' ) {
1172
-		return $this->get_vat_number( $context );
1171
+	public function get_user_vat_number($context = 'view') {
1172
+		return $this->get_vat_number($context);
1173 1173
     }
1174 1174
 
1175 1175
     /**
@@ -1179,8 +1179,8 @@  discard block
 block discarded – undo
1179 1179
 	 * @param  string $context View or edit context.
1180 1180
 	 * @return string
1181 1181
 	 */
1182
-	public function get_customer_vat_number( $context = 'view' ) {
1183
-		return $this->get_vat_number( $context );
1182
+	public function get_customer_vat_number($context = 'view') {
1183
+		return $this->get_vat_number($context);
1184 1184
     }
1185 1185
 
1186 1186
     /**
@@ -1190,8 +1190,8 @@  discard block
 block discarded – undo
1190 1190
 	 * @param  string $context View or edit context.
1191 1191
 	 * @return string
1192 1192
 	 */
1193
-	public function get_vat_rate( $context = 'view' ) {
1194
-		return $this->get_prop( 'vat_rate', $context );
1193
+	public function get_vat_rate($context = 'view') {
1194
+		return $this->get_prop('vat_rate', $context);
1195 1195
     }
1196 1196
 
1197 1197
     /**
@@ -1201,8 +1201,8 @@  discard block
 block discarded – undo
1201 1201
 	 * @param  string $context View or edit context.
1202 1202
 	 * @return string
1203 1203
 	 */
1204
-	public function get_user_vat_rate( $context = 'view' ) {
1205
-		return $this->get_vat_rate( $context );
1204
+	public function get_user_vat_rate($context = 'view') {
1205
+		return $this->get_vat_rate($context);
1206 1206
     }
1207 1207
 
1208 1208
     /**
@@ -1212,8 +1212,8 @@  discard block
 block discarded – undo
1212 1212
 	 * @param  string $context View or edit context.
1213 1213
 	 * @return string
1214 1214
 	 */
1215
-	public function get_customer_vat_rate( $context = 'view' ) {
1216
-		return $this->get_vat_rate( $context );
1215
+	public function get_customer_vat_rate($context = 'view') {
1216
+		return $this->get_vat_rate($context);
1217 1217
     }
1218 1218
 
1219 1219
     /**
@@ -1223,8 +1223,8 @@  discard block
 block discarded – undo
1223 1223
 	 * @param  string $context View or edit context.
1224 1224
 	 * @return string
1225 1225
 	 */
1226
-	public function get_address( $context = 'view' ) {
1227
-		return $this->get_prop( 'address', $context );
1226
+	public function get_address($context = 'view') {
1227
+		return $this->get_prop('address', $context);
1228 1228
     }
1229 1229
 
1230 1230
     /**
@@ -1234,8 +1234,8 @@  discard block
 block discarded – undo
1234 1234
 	 * @param  string $context View or edit context.
1235 1235
 	 * @return string
1236 1236
 	 */
1237
-	public function get_user_address( $context = 'view' ) {
1238
-		return $this->get_address( $context );
1237
+	public function get_user_address($context = 'view') {
1238
+		return $this->get_address($context);
1239 1239
     }
1240 1240
 
1241 1241
     /**
@@ -1245,8 +1245,8 @@  discard block
 block discarded – undo
1245 1245
 	 * @param  string $context View or edit context.
1246 1246
 	 * @return string
1247 1247
 	 */
1248
-	public function get_customer_address( $context = 'view' ) {
1249
-		return $this->get_address( $context );
1248
+	public function get_customer_address($context = 'view') {
1249
+		return $this->get_address($context);
1250 1250
     }
1251 1251
 
1252 1252
     /**
@@ -1256,8 +1256,8 @@  discard block
 block discarded – undo
1256 1256
 	 * @param  string $context View or edit context.
1257 1257
 	 * @return bool
1258 1258
 	 */
1259
-	public function get_is_viewed( $context = 'view' ) {
1260
-		return (bool) $this->get_prop( 'is_viewed', $context );
1259
+	public function get_is_viewed($context = 'view') {
1260
+		return (bool) $this->get_prop('is_viewed', $context);
1261 1261
 	}
1262 1262
 
1263 1263
 	/**
@@ -1267,8 +1267,8 @@  discard block
 block discarded – undo
1267 1267
 	 * @param  string $context View or edit context.
1268 1268
 	 * @return bool
1269 1269
 	 */
1270
-	public function get_email_cc( $context = 'view' ) {
1271
-		return $this->get_prop( 'email_cc', $context );
1270
+	public function get_email_cc($context = 'view') {
1271
+		return $this->get_prop('email_cc', $context);
1272 1272
 	}
1273 1273
 
1274 1274
 	/**
@@ -1278,8 +1278,8 @@  discard block
 block discarded – undo
1278 1278
 	 * @param  string $context View or edit context.
1279 1279
 	 * @return bool
1280 1280
 	 */
1281
-	public function get_template( $context = 'view' ) {
1282
-		return $this->get_prop( 'template', $context );
1281
+	public function get_template($context = 'view') {
1282
+		return $this->get_prop('template', $context);
1283 1283
 	}
1284 1284
 
1285 1285
 	/**
@@ -1289,8 +1289,8 @@  discard block
 block discarded – undo
1289 1289
 	 * @param  string $context View or edit context.
1290 1290
 	 * @return bool
1291 1291
 	 */
1292
-	public function get_address_confirmed( $context = 'view' ) {
1293
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1292
+	public function get_address_confirmed($context = 'view') {
1293
+		return (bool) $this->get_prop('address_confirmed', $context);
1294 1294
     }
1295 1295
 
1296 1296
     /**
@@ -1300,8 +1300,8 @@  discard block
 block discarded – undo
1300 1300
 	 * @param  string $context View or edit context.
1301 1301
 	 * @return bool
1302 1302
 	 */
1303
-	public function get_user_address_confirmed( $context = 'view' ) {
1304
-		return $this->get_address_confirmed( $context );
1303
+	public function get_user_address_confirmed($context = 'view') {
1304
+		return $this->get_address_confirmed($context);
1305 1305
     }
1306 1306
 
1307 1307
     /**
@@ -1311,8 +1311,8 @@  discard block
 block discarded – undo
1311 1311
 	 * @param  string $context View or edit context.
1312 1312
 	 * @return bool
1313 1313
 	 */
1314
-	public function get_customer_address_confirmed( $context = 'view' ) {
1315
-		return $this->get_address_confirmed( $context );
1314
+	public function get_customer_address_confirmed($context = 'view') {
1315
+		return $this->get_address_confirmed($context);
1316 1316
     }
1317 1317
 
1318 1318
     /**
@@ -1322,12 +1322,12 @@  discard block
 block discarded – undo
1322 1322
 	 * @param  string $context View or edit context.
1323 1323
 	 * @return float
1324 1324
 	 */
1325
-	public function get_subtotal( $context = 'view' ) {
1326
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1325
+	public function get_subtotal($context = 'view') {
1326
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1327 1327
 
1328 1328
         // Backwards compatibility.
1329
-        if ( is_bool( $context ) && $context ) {
1330
-            return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() );
1329
+        if (is_bool($context) && $context) {
1330
+            return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency());
1331 1331
         }
1332 1332
 
1333 1333
         return $subtotal;
@@ -1340,8 +1340,8 @@  discard block
 block discarded – undo
1340 1340
 	 * @param  string $context View or edit context.
1341 1341
 	 * @return float
1342 1342
 	 */
1343
-	public function get_total_discount( $context = 'view' ) {
1344
-		return (float) $this->get_prop( 'total_discount', $context );
1343
+	public function get_total_discount($context = 'view') {
1344
+		return (float) $this->get_prop('total_discount', $context);
1345 1345
     }
1346 1346
 
1347 1347
     /**
@@ -1351,18 +1351,18 @@  discard block
 block discarded – undo
1351 1351
 	 * @param  string $context View or edit context.
1352 1352
 	 * @return float
1353 1353
 	 */
1354
-	public function get_total_tax( $context = 'view' ) {
1355
-		return (float) $this->get_prop( 'total_tax', $context );
1354
+	public function get_total_tax($context = 'view') {
1355
+		return (float) $this->get_prop('total_tax', $context);
1356 1356
 	}
1357 1357
 
1358 1358
 	/**
1359 1359
 	 * @deprecated
1360 1360
 	 */
1361
-	public function get_final_tax( $currency = false ) {
1361
+	public function get_final_tax($currency = false) {
1362 1362
 		$tax = $this->get_total_tax();
1363 1363
 
1364
-        if ( $currency ) {
1365
-			return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1364
+        if ($currency) {
1365
+			return wpinv_price(wpinv_format_amount($tax, NULL, false), $this->get_currency());
1366 1366
         }
1367 1367
 
1368 1368
         return $tax;
@@ -1375,8 +1375,8 @@  discard block
 block discarded – undo
1375 1375
 	 * @param  string $context View or edit context.
1376 1376
 	 * @return float
1377 1377
 	 */
1378
-	public function get_total_fees( $context = 'view' ) {
1379
-		return (float) $this->get_prop( 'total_fees', $context );
1378
+	public function get_total_fees($context = 'view') {
1379
+		return (float) $this->get_prop('total_fees', $context);
1380 1380
     }
1381 1381
 
1382 1382
     /**
@@ -1386,8 +1386,8 @@  discard block
 block discarded – undo
1386 1386
 	 * @param  string $context View or edit context.
1387 1387
 	 * @return float
1388 1388
 	 */
1389
-	public function get_fees_total( $context = 'view' ) {
1390
-		return $this->get_total_fees( $context );
1389
+	public function get_fees_total($context = 'view') {
1390
+		return $this->get_total_fees($context);
1391 1391
     }
1392 1392
 
1393 1393
     /**
@@ -1398,7 +1398,7 @@  discard block
 block discarded – undo
1398 1398
 	 */
1399 1399
 	public function get_total() {
1400 1400
 		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1401
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1401
+		return apply_filters('getpaid_get_invoice_total_amount', $total, $this);
1402 1402
 	}
1403 1403
 	
1404 1404
 	/**
@@ -1420,7 +1420,7 @@  discard block
 block discarded – undo
1420 1420
 	 */
1421 1421
     public function get_initial_total() {
1422 1422
 
1423
-		if ( empty( $this->totals ) ) {
1423
+		if (empty($this->totals)) {
1424 1424
 			$this->recalculate_total();
1425 1425
 		}
1426 1426
 
@@ -1430,11 +1430,11 @@  discard block
 block discarded – undo
1430 1430
 		$subtotal = $this->totals['subtotal']['initial'];
1431 1431
 		$total    = $tax + $fee - $discount + $subtotal;
1432 1432
 
1433
-		if ( 0 > $total ) {
1433
+		if (0 > $total) {
1434 1434
 			$total = 0;
1435 1435
 		}
1436 1436
 
1437
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1437
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1438 1438
 	}
1439 1439
 
1440 1440
 	/**
@@ -1446,7 +1446,7 @@  discard block
 block discarded – undo
1446 1446
 	 */
1447 1447
     public function get_recurring_total() {
1448 1448
 
1449
-		if ( empty( $this->totals ) ) {
1449
+		if (empty($this->totals)) {
1450 1450
 			$this->recalculate_total();
1451 1451
 		}
1452 1452
 
@@ -1456,11 +1456,11 @@  discard block
 block discarded – undo
1456 1456
 		$subtotal = $this->totals['subtotal']['recurring'];
1457 1457
 		$total    = $tax + $fee - $discount + $subtotal;
1458 1458
 
1459
-		if ( 0 > $total ) {
1459
+		if (0 > $total) {
1460 1460
 			$total = 0;
1461 1461
 		}
1462 1462
 
1463
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1463
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1464 1464
 	}
1465 1465
 
1466 1466
 	/**
@@ -1471,10 +1471,10 @@  discard block
 block discarded – undo
1471 1471
 	 * @param string $currency Whether to include the currency.
1472 1472
      * @return float
1473 1473
 	 */
1474
-    public function get_recurring_details( $field = '', $currency = false ) {
1474
+    public function get_recurring_details($field = '', $currency = false) {
1475 1475
 
1476 1476
 		// Maybe recalculate totals.
1477
-		if ( empty( $this->totals ) ) {
1477
+		if (empty($this->totals)) {
1478 1478
 			$this->recalculate_total();
1479 1479
 		}
1480 1480
 
@@ -1494,8 +1494,8 @@  discard block
 block discarded – undo
1494 1494
 			$currency
1495 1495
 		);
1496 1496
 
1497
-        if ( isset( $data[$field] ) ) {
1498
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1497
+        if (isset($data[$field])) {
1498
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1499 1499
         }
1500 1500
 
1501 1501
         return $data;
@@ -1508,8 +1508,8 @@  discard block
 block discarded – undo
1508 1508
 	 * @param  string $context View or edit context.
1509 1509
 	 * @return array
1510 1510
 	 */
1511
-	public function get_fees( $context = 'view' ) {
1512
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1511
+	public function get_fees($context = 'view') {
1512
+		return wpinv_parse_list($this->get_prop('fees', $context));
1513 1513
     }
1514 1514
 
1515 1515
     /**
@@ -1519,8 +1519,8 @@  discard block
 block discarded – undo
1519 1519
 	 * @param  string $context View or edit context.
1520 1520
 	 * @return array
1521 1521
 	 */
1522
-	public function get_discounts( $context = 'view' ) {
1523
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1522
+	public function get_discounts($context = 'view') {
1523
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1524 1524
     }
1525 1525
 
1526 1526
     /**
@@ -1530,8 +1530,8 @@  discard block
 block discarded – undo
1530 1530
 	 * @param  string $context View or edit context.
1531 1531
 	 * @return array
1532 1532
 	 */
1533
-	public function get_taxes( $context = 'view' ) {
1534
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1533
+	public function get_taxes($context = 'view') {
1534
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1535 1535
     }
1536 1536
 
1537 1537
     /**
@@ -1541,8 +1541,8 @@  discard block
 block discarded – undo
1541 1541
 	 * @param  string $context View or edit context.
1542 1542
 	 * @return GetPaid_Form_Item[]
1543 1543
 	 */
1544
-	public function get_items( $context = 'view' ) {
1545
-        return $this->get_prop( 'items', $context );
1544
+	public function get_items($context = 'view') {
1545
+        return $this->get_prop('items', $context);
1546 1546
     }
1547 1547
 
1548 1548
     /**
@@ -1552,8 +1552,8 @@  discard block
 block discarded – undo
1552 1552
 	 * @param  string $context View or edit context.
1553 1553
 	 * @return int
1554 1554
 	 */
1555
-	public function get_payment_form( $context = 'view' ) {
1556
-		return intval( $this->get_prop( 'payment_form', $context ) );
1555
+	public function get_payment_form($context = 'view') {
1556
+		return intval($this->get_prop('payment_form', $context));
1557 1557
     }
1558 1558
 
1559 1559
     /**
@@ -1563,8 +1563,8 @@  discard block
 block discarded – undo
1563 1563
 	 * @param  string $context View or edit context.
1564 1564
 	 * @return string
1565 1565
 	 */
1566
-	public function get_submission_id( $context = 'view' ) {
1567
-		return $this->get_prop( 'submission_id', $context );
1566
+	public function get_submission_id($context = 'view') {
1567
+		return $this->get_prop('submission_id', $context);
1568 1568
     }
1569 1569
 
1570 1570
     /**
@@ -1574,8 +1574,8 @@  discard block
 block discarded – undo
1574 1574
 	 * @param  string $context View or edit context.
1575 1575
 	 * @return string
1576 1576
 	 */
1577
-	public function get_discount_code( $context = 'view' ) {
1578
-		return $this->get_prop( 'discount_code', $context );
1577
+	public function get_discount_code($context = 'view') {
1578
+		return $this->get_prop('discount_code', $context);
1579 1579
     }
1580 1580
 
1581 1581
     /**
@@ -1585,8 +1585,8 @@  discard block
 block discarded – undo
1585 1585
 	 * @param  string $context View or edit context.
1586 1586
 	 * @return string
1587 1587
 	 */
1588
-	public function get_gateway( $context = 'view' ) {
1589
-		return $this->get_prop( 'gateway', $context );
1588
+	public function get_gateway($context = 'view') {
1589
+		return $this->get_prop('gateway', $context);
1590 1590
     }
1591 1591
 
1592 1592
     /**
@@ -1596,8 +1596,8 @@  discard block
 block discarded – undo
1596 1596
 	 * @return string
1597 1597
 	 */
1598 1598
     public function get_gateway_title() {
1599
-        $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1600
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1599
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1600
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1601 1601
     }
1602 1602
 
1603 1603
     /**
@@ -1607,8 +1607,8 @@  discard block
 block discarded – undo
1607 1607
 	 * @param  string $context View or edit context.
1608 1608
 	 * @return string
1609 1609
 	 */
1610
-	public function get_transaction_id( $context = 'view' ) {
1611
-		return $this->get_prop( 'transaction_id', $context );
1610
+	public function get_transaction_id($context = 'view') {
1611
+		return $this->get_prop('transaction_id', $context);
1612 1612
     }
1613 1613
 
1614 1614
     /**
@@ -1618,9 +1618,9 @@  discard block
 block discarded – undo
1618 1618
 	 * @param  string $context View or edit context.
1619 1619
 	 * @return string
1620 1620
 	 */
1621
-	public function get_currency( $context = 'view' ) {
1622
-        $currency = $this->get_prop( 'currency', $context );
1623
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1621
+	public function get_currency($context = 'view') {
1622
+        $currency = $this->get_prop('currency', $context);
1623
+        return empty($currency) ? wpinv_get_currency() : $currency;
1624 1624
     }
1625 1625
 
1626 1626
     /**
@@ -1630,8 +1630,8 @@  discard block
 block discarded – undo
1630 1630
 	 * @param  string $context View or edit context.
1631 1631
 	 * @return bool
1632 1632
 	 */
1633
-	public function get_disable_taxes( $context = 'view' ) {
1634
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1633
+	public function get_disable_taxes($context = 'view') {
1634
+        return (bool) $this->get_prop('disable_taxes', $context);
1635 1635
     }
1636 1636
 
1637 1637
     /**
@@ -1641,8 +1641,8 @@  discard block
 block discarded – undo
1641 1641
 	 * @param  string $context View or edit context.
1642 1642
 	 * @return int
1643 1643
 	 */
1644
-    public function get_subscription_id( $context = 'view' ) {
1645
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1644
+    public function get_subscription_id($context = 'view') {
1645
+		return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context);
1646 1646
 	}
1647 1647
 
1648 1648
 	/**
@@ -1652,12 +1652,12 @@  discard block
 block discarded – undo
1652 1652
 	 * @param  string $context View or edit context.
1653 1653
 	 * @return int
1654 1654
 	 */
1655
-    public function get_remote_subscription_id( $context = 'view' ) {
1656
-        $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1655
+    public function get_remote_subscription_id($context = 'view') {
1656
+        $subscription_id = $this->get_prop('remote_subscription_id', $context);
1657 1657
 
1658
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1658
+        if (empty($subscription_id) && $this->is_renewal()) {
1659 1659
             $parent = $this->get_parent();
1660
-            return $parent->get_subscription_id( $context );
1660
+            return $parent->get_subscription_id($context);
1661 1661
         }
1662 1662
 
1663 1663
         return $subscription_id;
@@ -1670,20 +1670,20 @@  discard block
 block discarded – undo
1670 1670
 	 * @param  string $context View or edit context.
1671 1671
 	 * @return array
1672 1672
 	 */
1673
-    public function get_payment_meta( $context = 'view' ) {
1673
+    public function get_payment_meta($context = 'view') {
1674 1674
 
1675 1675
         return array(
1676
-            'price'        => $this->get_total( $context ),
1677
-            'date'         => $this->get_date_created( $context ),
1678
-            'user_email'   => $this->get_email( $context ),
1679
-            'invoice_key'  => $this->get_key( $context ),
1680
-            'currency'     => $this->get_currency( $context ),
1681
-            'items'        => $this->get_items( $context ),
1682
-            'user_info'    => $this->get_user_info( $context ),
1676
+            'price'        => $this->get_total($context),
1677
+            'date'         => $this->get_date_created($context),
1678
+            'user_email'   => $this->get_email($context),
1679
+            'invoice_key'  => $this->get_key($context),
1680
+            'currency'     => $this->get_currency($context),
1681
+            'items'        => $this->get_items($context),
1682
+            'user_info'    => $this->get_user_info($context),
1683 1683
             'cart_details' => $this->get_cart_details(),
1684
-            'status'       => $this->get_status( $context ),
1685
-            'fees'         => $this->get_fees( $context ),
1686
-            'taxes'        => $this->get_taxes( $context ),
1684
+            'status'       => $this->get_status($context),
1685
+            'fees'         => $this->get_fees($context),
1686
+            'taxes'        => $this->get_taxes($context),
1687 1687
         );
1688 1688
 
1689 1689
     }
@@ -1698,9 +1698,9 @@  discard block
 block discarded – undo
1698 1698
         $items        = $this->get_items();
1699 1699
         $cart_details = array();
1700 1700
 
1701
-        foreach ( $items as $item_id => $item ) {
1701
+        foreach ($items as $item_id => $item) {
1702 1702
 			$item->invoice_id = $this->get_id();
1703
-            $cart_details[]   = $item->prepare_data_for_saving();
1703
+            $cart_details[] = $item->prepare_data_for_saving();
1704 1704
         }
1705 1705
 
1706 1706
         return $cart_details;
@@ -1711,11 +1711,11 @@  discard block
 block discarded – undo
1711 1711
 	 *
1712 1712
 	 * @return null|GetPaid_Form_Item|int
1713 1713
 	 */
1714
-	public function get_recurring( $object = false ) {
1714
+	public function get_recurring($object = false) {
1715 1715
 
1716 1716
 		// Are we returning an object?
1717
-        if ( $object ) {
1718
-            return $this->get_item( $this->recurring_item );
1717
+        if ($object) {
1718
+            return $this->get_item($this->recurring_item);
1719 1719
         }
1720 1720
 
1721 1721
         return $this->recurring_item;
@@ -1730,15 +1730,15 @@  discard block
 block discarded – undo
1730 1730
 	public function get_subscription_name() {
1731 1731
 
1732 1732
 		// Retrieve the recurring name
1733
-        $item = $this->get_recurring( true );
1733
+        $item = $this->get_recurring(true);
1734 1734
 
1735 1735
 		// Abort if it does not exist.
1736
-        if ( empty( $item ) ) {
1736
+        if (empty($item)) {
1737 1737
             return '';
1738 1738
         }
1739 1739
 
1740 1740
 		// Return the item name.
1741
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1741
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1742 1742
 	}
1743 1743
 
1744 1744
 	/**
@@ -1748,9 +1748,9 @@  discard block
 block discarded – undo
1748 1748
 	 * @return string
1749 1749
 	 */
1750 1750
 	public function get_view_url() {
1751
-        $invoice_url = get_permalink( $this->get_id() );
1752
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1753
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1751
+        $invoice_url = get_permalink($this->get_id());
1752
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1753
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1754 1754
 	}
1755 1755
 
1756 1756
 	/**
@@ -1759,25 +1759,25 @@  discard block
 block discarded – undo
1759 1759
 	 * @since 1.0.19
1760 1760
 	 * @return string
1761 1761
 	 */
1762
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1762
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1763 1763
 
1764 1764
 		// Retrieve the checkout url.
1765 1765
         $pay_url = wpinv_get_checkout_uri();
1766 1766
 
1767 1767
 		// Maybe force ssl.
1768
-        if ( is_ssl() ) {
1769
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1768
+        if (is_ssl()) {
1769
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1770 1770
         }
1771 1771
 
1772 1772
 		// Add the invoice key.
1773
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1773
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1774 1774
 
1775 1775
 		// (Maybe?) add a secret
1776
-        if ( $secret ) {
1777
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1776
+        if ($secret) {
1777
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1778 1778
         }
1779 1779
 
1780
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1780
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1781 1781
 	}
1782 1782
 	
1783 1783
 	/**
@@ -1792,14 +1792,14 @@  discard block
 block discarded – undo
1792 1792
         $receipt_url = wpinv_get_success_page_uri();
1793 1793
 
1794 1794
 		// Maybe force ssl.
1795
-        if ( is_ssl() ) {
1796
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1795
+        if (is_ssl()) {
1796
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1797 1797
         }
1798 1798
 
1799 1799
 		// Add the invoice key.
1800
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1800
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1801 1801
 
1802
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1802
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1803 1803
     }
1804 1804
 
1805 1805
     /**
@@ -1812,8 +1812,8 @@  discard block
 block discarded – undo
1812 1812
 	 * @param  string $context View or edit context.
1813 1813
 	 * @return mixed Value of the given invoice property (if set).
1814 1814
 	 */
1815
-	public function get( $key, $context = 'view' ) {
1816
-        return $this->get_prop( $key, $context );
1815
+	public function get($key, $context = 'view') {
1816
+        return $this->get_prop($key, $context);
1817 1817
 	}
1818 1818
 
1819 1819
     /*
@@ -1836,11 +1836,11 @@  discard block
 block discarded – undo
1836 1836
 	 * @param  mixed $value new value.
1837 1837
 	 * @return mixed Value of the given invoice property (if set).
1838 1838
 	 */
1839
-	public function set( $key, $value ) {
1839
+	public function set($key, $value) {
1840 1840
 
1841 1841
         $setter = "set_$key";
1842
-        if ( is_callable( array( $this, $setter ) ) ) {
1843
-            $this->{$setter}( $value );
1842
+        if (is_callable(array($this, $setter))) {
1843
+            $this->{$setter}($value);
1844 1844
         }
1845 1845
 
1846 1846
 	}
@@ -1854,47 +1854,47 @@  discard block
 block discarded – undo
1854 1854
 	 * @param bool   $manual_update Is this a manual status change?.
1855 1855
 	 * @return array details of change.
1856 1856
 	 */
1857
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1857
+	public function set_status($new_status, $note = '', $manual_update = false) {
1858 1858
 		$old_status = $this->get_status();
1859 1859
 
1860 1860
 		$statuses = $this->get_all_statuses();
1861 1861
 
1862
-		if ( isset( $statuses[ 'draft' ] ) ) {
1863
-			unset( $statuses[ 'draft' ] );
1862
+		if (isset($statuses['draft'])) {
1863
+			unset($statuses['draft']);
1864 1864
 		}
1865 1865
 
1866
-		$this->set_prop( 'status', $new_status );
1866
+		$this->set_prop('status', $new_status);
1867 1867
 
1868 1868
 		// If setting the status, ensure it's set to a valid status.
1869
-		if ( true === $this->object_read ) {
1869
+		if (true === $this->object_read) {
1870 1870
 
1871 1871
 			// Only allow valid new status.
1872
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1872
+			if (!array_key_exists($new_status, $statuses)) {
1873 1873
 				$new_status = 'wpi-pending';
1874 1874
 			}
1875 1875
 
1876 1876
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1877
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1877
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
1878 1878
 				$old_status = 'wpi-pending';
1879 1879
 			}
1880 1880
 
1881 1881
 			// Paid - Renewal (i.e when duplicating a parent invoice )
1882
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1882
+			if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) {
1883 1883
 				$old_status = 'wpi-pending';
1884 1884
 			}
1885 1885
 
1886 1886
 		}
1887 1887
 
1888
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1888
+		if (true === $this->object_read && $old_status !== $new_status) {
1889 1889
 			$this->status_transition = array(
1890
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1890
+				'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
1891 1891
 				'to'     => $new_status,
1892 1892
 				'note'   => $note,
1893 1893
 				'manual' => (bool) $manual_update,
1894 1894
 			);
1895 1895
 
1896
-			if ( $manual_update ) {
1897
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1896
+			if ($manual_update) {
1897
+				do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
1898 1898
 			}
1899 1899
 
1900 1900
 			$this->maybe_set_date_paid();
@@ -1917,8 +1917,8 @@  discard block
 block discarded – undo
1917 1917
 	 */
1918 1918
 	public function maybe_set_date_paid() {
1919 1919
 
1920
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1921
-			$this->set_date_completed( current_time( 'mysql' ) );
1920
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
1921
+			$this->set_date_completed(current_time('mysql'));
1922 1922
 		}
1923 1923
 	}
1924 1924
 
@@ -1927,11 +1927,11 @@  discard block
 block discarded – undo
1927 1927
 	 *
1928 1928
 	 * @since 1.0.19
1929 1929
 	 */
1930
-	public function set_parent_id( $value ) {
1931
-		if ( $value && ( $value === $this->get_id() ) ) {
1930
+	public function set_parent_id($value) {
1931
+		if ($value && ($value === $this->get_id())) {
1932 1932
 			return;
1933 1933
 		}
1934
-		$this->set_prop( 'parent_id', absint( $value ) );
1934
+		$this->set_prop('parent_id', absint($value));
1935 1935
     }
1936 1936
 
1937 1937
     /**
@@ -1939,8 +1939,8 @@  discard block
 block discarded – undo
1939 1939
 	 *
1940 1940
 	 * @since 1.0.19
1941 1941
 	 */
1942
-	public function set_version( $value ) {
1943
-		$this->set_prop( 'version', $value );
1942
+	public function set_version($value) {
1943
+		$this->set_prop('version', $value);
1944 1944
     }
1945 1945
 
1946 1946
     /**
@@ -1950,15 +1950,15 @@  discard block
 block discarded – undo
1950 1950
 	 * @param string $value Value to set.
1951 1951
      * @return bool Whether or not the date was set.
1952 1952
 	 */
1953
-	public function set_date_created( $value ) {
1954
-        $date = strtotime( $value );
1953
+	public function set_date_created($value) {
1954
+        $date = strtotime($value);
1955 1955
 
1956
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1957
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
1956
+        if ($date && $value !== '0000-00-00 00:00:00') {
1957
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
1958 1958
             return true;
1959 1959
         }
1960 1960
 
1961
-        return $this->set_prop( 'date_created', '' );
1961
+        return $this->set_prop('date_created', '');
1962 1962
 
1963 1963
     }
1964 1964
 
@@ -1969,15 +1969,15 @@  discard block
 block discarded – undo
1969 1969
 	 * @param string $value Value to set.
1970 1970
      * @return bool Whether or not the date was set.
1971 1971
 	 */
1972
-	public function set_due_date( $value ) {
1973
-        $date = strtotime( $value );
1972
+	public function set_due_date($value) {
1973
+        $date = strtotime($value);
1974 1974
 
1975
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1976
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
1975
+        if ($date && $value !== '0000-00-00 00:00:00') {
1976
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
1977 1977
             return true;
1978 1978
         }
1979 1979
 
1980
-		$this->set_prop( 'due_date', '' );
1980
+		$this->set_prop('due_date', '');
1981 1981
         return false;
1982 1982
 
1983 1983
     }
@@ -1988,8 +1988,8 @@  discard block
 block discarded – undo
1988 1988
 	 * @since 1.0.19
1989 1989
 	 * @param  string $value New name.
1990 1990
 	 */
1991
-	public function set_date_due( $value ) {
1992
-		$this->set_due_date( $value );
1991
+	public function set_date_due($value) {
1992
+		$this->set_due_date($value);
1993 1993
     }
1994 1994
 
1995 1995
     /**
@@ -1999,15 +1999,15 @@  discard block
 block discarded – undo
1999 1999
 	 * @param string $value Value to set.
2000 2000
      * @return bool Whether or not the date was set.
2001 2001
 	 */
2002
-	public function set_completed_date( $value ) {
2003
-        $date = strtotime( $value );
2002
+	public function set_completed_date($value) {
2003
+        $date = strtotime($value);
2004 2004
 
2005
-        if ( $date && $value !== '0000-00-00 00:00:00'  ) {
2006
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
2005
+        if ($date && $value !== '0000-00-00 00:00:00') {
2006
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
2007 2007
             return true;
2008 2008
         }
2009 2009
 
2010
-		$this->set_prop( 'completed_date', '' );
2010
+		$this->set_prop('completed_date', '');
2011 2011
         return false;
2012 2012
 
2013 2013
     }
@@ -2018,8 +2018,8 @@  discard block
 block discarded – undo
2018 2018
 	 * @since 1.0.19
2019 2019
 	 * @param  string $value New name.
2020 2020
 	 */
2021
-	public function set_date_completed( $value ) {
2022
-		$this->set_completed_date( $value );
2021
+	public function set_date_completed($value) {
2022
+		$this->set_completed_date($value);
2023 2023
     }
2024 2024
 
2025 2025
     /**
@@ -2029,15 +2029,15 @@  discard block
 block discarded – undo
2029 2029
 	 * @param string $value Value to set.
2030 2030
      * @return bool Whether or not the date was set.
2031 2031
 	 */
2032
-	public function set_date_modified( $value ) {
2033
-        $date = strtotime( $value );
2032
+	public function set_date_modified($value) {
2033
+        $date = strtotime($value);
2034 2034
 
2035
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2036
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
2035
+        if ($date && $value !== '0000-00-00 00:00:00') {
2036
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
2037 2037
             return true;
2038 2038
         }
2039 2039
 
2040
-		$this->set_prop( 'date_modified', '' );
2040
+		$this->set_prop('date_modified', '');
2041 2041
         return false;
2042 2042
 
2043 2043
     }
@@ -2048,9 +2048,9 @@  discard block
 block discarded – undo
2048 2048
 	 * @since 1.0.19
2049 2049
 	 * @param  string $value New number.
2050 2050
 	 */
2051
-	public function set_number( $value ) {
2052
-        $number = sanitize_text_field( $value );
2053
-		$this->set_prop( 'number', $number );
2051
+	public function set_number($value) {
2052
+        $number = sanitize_text_field($value);
2053
+		$this->set_prop('number', $number);
2054 2054
     }
2055 2055
 
2056 2056
     /**
@@ -2059,9 +2059,9 @@  discard block
 block discarded – undo
2059 2059
 	 * @since 1.0.19
2060 2060
 	 * @param  string $value Type.
2061 2061
 	 */
2062
-	public function set_type( $value ) {
2063
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2064
-		$this->set_prop( 'type', $type );
2062
+	public function set_type($value) {
2063
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2064
+		$this->set_prop('type', $type);
2065 2065
 	}
2066 2066
 
2067 2067
     /**
@@ -2070,10 +2070,10 @@  discard block
 block discarded – undo
2070 2070
 	 * @since 1.0.19
2071 2071
 	 * @param  string $value Post type.
2072 2072
 	 */
2073
-	public function set_post_type( $value ) {
2074
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2075
-			$this->set_type( $value );
2076
-            $this->set_prop( 'post_type', $value );
2073
+	public function set_post_type($value) {
2074
+        if (getpaid_is_invoice_post_type($value)) {
2075
+			$this->set_type($value);
2076
+            $this->set_prop('post_type', $value);
2077 2077
         }
2078 2078
     }
2079 2079
 
@@ -2083,9 +2083,9 @@  discard block
 block discarded – undo
2083 2083
 	 * @since 1.0.19
2084 2084
 	 * @param  string $value New key.
2085 2085
 	 */
2086
-	public function set_key( $value ) {
2087
-        $key = sanitize_text_field( $value );
2088
-		$this->set_prop( 'key', $key );
2086
+	public function set_key($value) {
2087
+        $key = sanitize_text_field($value);
2088
+		$this->set_prop('key', $key);
2089 2089
     }
2090 2090
 
2091 2091
     /**
@@ -2094,9 +2094,9 @@  discard block
 block discarded – undo
2094 2094
 	 * @since 1.0.19
2095 2095
 	 * @param  string $value mode.
2096 2096
 	 */
2097
-	public function set_mode( $value ) {
2098
-        if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2099
-            $this->set_prop( 'value', $value );
2097
+	public function set_mode($value) {
2098
+        if (!in_array($value, array('live', 'test'))) {
2099
+            $this->set_prop('value', $value);
2100 2100
         }
2101 2101
     }
2102 2102
 
@@ -2106,8 +2106,8 @@  discard block
 block discarded – undo
2106 2106
 	 * @since 1.0.19
2107 2107
 	 * @param  string $value path.
2108 2108
 	 */
2109
-	public function set_path( $value ) {
2110
-        $this->set_prop( 'path', $value );
2109
+	public function set_path($value) {
2110
+        $this->set_prop('path', $value);
2111 2111
     }
2112 2112
 
2113 2113
     /**
@@ -2116,9 +2116,9 @@  discard block
 block discarded – undo
2116 2116
 	 * @since 1.0.19
2117 2117
 	 * @param  string $value New name.
2118 2118
 	 */
2119
-	public function set_name( $value ) {
2120
-        $name = sanitize_text_field( $value );
2121
-		$this->set_prop( 'name', $name );
2119
+	public function set_name($value) {
2120
+        $name = sanitize_text_field($value);
2121
+		$this->set_prop('name', $name);
2122 2122
     }
2123 2123
 
2124 2124
     /**
@@ -2127,8 +2127,8 @@  discard block
 block discarded – undo
2127 2127
 	 * @since 1.0.19
2128 2128
 	 * @param  string $value New name.
2129 2129
 	 */
2130
-	public function set_title( $value ) {
2131
-		$this->set_name( $value );
2130
+	public function set_title($value) {
2131
+		$this->set_name($value);
2132 2132
     }
2133 2133
 
2134 2134
     /**
@@ -2137,9 +2137,9 @@  discard block
 block discarded – undo
2137 2137
 	 * @since 1.0.19
2138 2138
 	 * @param  string $value New description.
2139 2139
 	 */
2140
-	public function set_description( $value ) {
2141
-        $description = wp_kses_post( $value );
2142
-		return $this->set_prop( 'description', $description );
2140
+	public function set_description($value) {
2141
+        $description = wp_kses_post($value);
2142
+		return $this->set_prop('description', $description);
2143 2143
     }
2144 2144
 
2145 2145
     /**
@@ -2148,8 +2148,8 @@  discard block
 block discarded – undo
2148 2148
 	 * @since 1.0.19
2149 2149
 	 * @param  string $value New description.
2150 2150
 	 */
2151
-	public function set_excerpt( $value ) {
2152
-		$this->set_description( $value );
2151
+	public function set_excerpt($value) {
2152
+		$this->set_description($value);
2153 2153
     }
2154 2154
 
2155 2155
     /**
@@ -2158,8 +2158,8 @@  discard block
 block discarded – undo
2158 2158
 	 * @since 1.0.19
2159 2159
 	 * @param  string $value New description.
2160 2160
 	 */
2161
-	public function set_summary( $value ) {
2162
-		$this->set_description( $value );
2161
+	public function set_summary($value) {
2162
+		$this->set_description($value);
2163 2163
     }
2164 2164
 
2165 2165
     /**
@@ -2168,12 +2168,12 @@  discard block
 block discarded – undo
2168 2168
 	 * @since 1.0.19
2169 2169
 	 * @param  int $value New author.
2170 2170
 	 */
2171
-	public function set_author( $value ) {
2172
-		$user = get_user_by( 'id', (int) $value );
2171
+	public function set_author($value) {
2172
+		$user = get_user_by('id', (int) $value);
2173 2173
 
2174
-		if ( $user && $user->ID ) {
2175
-			$this->set_prop( 'author', $user->ID );
2176
-			$this->set_prop( 'email', $user->user_email );
2174
+		if ($user && $user->ID) {
2175
+			$this->set_prop('author', $user->ID);
2176
+			$this->set_prop('email', $user->user_email);
2177 2177
 		}
2178 2178
 		
2179 2179
     }
@@ -2184,8 +2184,8 @@  discard block
 block discarded – undo
2184 2184
 	 * @since 1.0.19
2185 2185
 	 * @param  int $value New user id.
2186 2186
 	 */
2187
-	public function set_user_id( $value ) {
2188
-		$this->set_author( $value );
2187
+	public function set_user_id($value) {
2188
+		$this->set_author($value);
2189 2189
     }
2190 2190
 
2191 2191
     /**
@@ -2194,8 +2194,8 @@  discard block
 block discarded – undo
2194 2194
 	 * @since 1.0.19
2195 2195
 	 * @param  int $value New user id.
2196 2196
 	 */
2197
-	public function set_customer_id( $value ) {
2198
-		$this->set_author( $value );
2197
+	public function set_customer_id($value) {
2198
+		$this->set_author($value);
2199 2199
     }
2200 2200
 
2201 2201
     /**
@@ -2204,8 +2204,8 @@  discard block
 block discarded – undo
2204 2204
 	 * @since 1.0.19
2205 2205
 	 * @param  string $value ip address.
2206 2206
 	 */
2207
-	public function set_ip( $value ) {
2208
-		$this->set_prop( 'ip', $value );
2207
+	public function set_ip($value) {
2208
+		$this->set_prop('ip', $value);
2209 2209
     }
2210 2210
 
2211 2211
     /**
@@ -2214,8 +2214,8 @@  discard block
 block discarded – undo
2214 2214
 	 * @since 1.0.19
2215 2215
 	 * @param  string $value ip address.
2216 2216
 	 */
2217
-	public function set_user_ip( $value ) {
2218
-		$this->set_ip( $value );
2217
+	public function set_user_ip($value) {
2218
+		$this->set_ip($value);
2219 2219
     }
2220 2220
 
2221 2221
     /**
@@ -2224,8 +2224,8 @@  discard block
 block discarded – undo
2224 2224
 	 * @since 1.0.19
2225 2225
 	 * @param  string $value first name.
2226 2226
 	 */
2227
-	public function set_first_name( $value ) {
2228
-		$this->set_prop( 'first_name', $value );
2227
+	public function set_first_name($value) {
2228
+		$this->set_prop('first_name', $value);
2229 2229
     }
2230 2230
 
2231 2231
     /**
@@ -2234,8 +2234,8 @@  discard block
 block discarded – undo
2234 2234
 	 * @since 1.0.19
2235 2235
 	 * @param  string $value first name.
2236 2236
 	 */
2237
-	public function set_user_first_name( $value ) {
2238
-		$this->set_first_name( $value );
2237
+	public function set_user_first_name($value) {
2238
+		$this->set_first_name($value);
2239 2239
     }
2240 2240
 
2241 2241
     /**
@@ -2244,8 +2244,8 @@  discard block
 block discarded – undo
2244 2244
 	 * @since 1.0.19
2245 2245
 	 * @param  string $value first name.
2246 2246
 	 */
2247
-	public function set_customer_first_name( $value ) {
2248
-		$this->set_first_name( $value );
2247
+	public function set_customer_first_name($value) {
2248
+		$this->set_first_name($value);
2249 2249
     }
2250 2250
 
2251 2251
     /**
@@ -2254,8 +2254,8 @@  discard block
 block discarded – undo
2254 2254
 	 * @since 1.0.19
2255 2255
 	 * @param  string $value last name.
2256 2256
 	 */
2257
-	public function set_last_name( $value ) {
2258
-		$this->set_prop( 'last_name', $value );
2257
+	public function set_last_name($value) {
2258
+		$this->set_prop('last_name', $value);
2259 2259
     }
2260 2260
 
2261 2261
     /**
@@ -2264,8 +2264,8 @@  discard block
 block discarded – undo
2264 2264
 	 * @since 1.0.19
2265 2265
 	 * @param  string $value last name.
2266 2266
 	 */
2267
-	public function set_user_last_name( $value ) {
2268
-		$this->set_last_name( $value );
2267
+	public function set_user_last_name($value) {
2268
+		$this->set_last_name($value);
2269 2269
     }
2270 2270
 
2271 2271
     /**
@@ -2274,8 +2274,8 @@  discard block
 block discarded – undo
2274 2274
 	 * @since 1.0.19
2275 2275
 	 * @param  string $value last name.
2276 2276
 	 */
2277
-	public function set_customer_last_name( $value ) {
2278
-		$this->set_last_name( $value );
2277
+	public function set_customer_last_name($value) {
2278
+		$this->set_last_name($value);
2279 2279
     }
2280 2280
 
2281 2281
     /**
@@ -2284,8 +2284,8 @@  discard block
 block discarded – undo
2284 2284
 	 * @since 1.0.19
2285 2285
 	 * @param  string $value phone.
2286 2286
 	 */
2287
-	public function set_phone( $value ) {
2288
-		$this->set_prop( 'phone', $value );
2287
+	public function set_phone($value) {
2288
+		$this->set_prop('phone', $value);
2289 2289
     }
2290 2290
 
2291 2291
     /**
@@ -2294,8 +2294,8 @@  discard block
 block discarded – undo
2294 2294
 	 * @since 1.0.19
2295 2295
 	 * @param  string $value phone.
2296 2296
 	 */
2297
-	public function set_user_phone( $value ) {
2298
-		$this->set_phone( $value );
2297
+	public function set_user_phone($value) {
2298
+		$this->set_phone($value);
2299 2299
     }
2300 2300
 
2301 2301
     /**
@@ -2304,8 +2304,8 @@  discard block
 block discarded – undo
2304 2304
 	 * @since 1.0.19
2305 2305
 	 * @param  string $value phone.
2306 2306
 	 */
2307
-	public function set_customer_phone( $value ) {
2308
-		$this->set_phone( $value );
2307
+	public function set_customer_phone($value) {
2308
+		$this->set_phone($value);
2309 2309
     }
2310 2310
 
2311 2311
     /**
@@ -2314,8 +2314,8 @@  discard block
 block discarded – undo
2314 2314
 	 * @since 1.0.19
2315 2315
 	 * @param  string $value phone.
2316 2316
 	 */
2317
-	public function set_phone_number( $value ) {
2318
-		$this->set_phone( $value );
2317
+	public function set_phone_number($value) {
2318
+		$this->set_phone($value);
2319 2319
     }
2320 2320
 
2321 2321
     /**
@@ -2324,8 +2324,8 @@  discard block
 block discarded – undo
2324 2324
 	 * @since 1.0.19
2325 2325
 	 * @param  string $value email address.
2326 2326
 	 */
2327
-	public function set_email( $value ) {
2328
-		$this->set_prop( 'email', $value );
2327
+	public function set_email($value) {
2328
+		$this->set_prop('email', $value);
2329 2329
     }
2330 2330
 
2331 2331
     /**
@@ -2334,8 +2334,8 @@  discard block
 block discarded – undo
2334 2334
 	 * @since 1.0.19
2335 2335
 	 * @param  string $value email address.
2336 2336
 	 */
2337
-	public function set_user_email( $value ) {
2338
-		$this->set_email( $value );
2337
+	public function set_user_email($value) {
2338
+		$this->set_email($value);
2339 2339
     }
2340 2340
 
2341 2341
     /**
@@ -2344,8 +2344,8 @@  discard block
 block discarded – undo
2344 2344
 	 * @since 1.0.19
2345 2345
 	 * @param  string $value email address.
2346 2346
 	 */
2347
-	public function set_email_address( $value ) {
2348
-		$this->set_email( $value );
2347
+	public function set_email_address($value) {
2348
+		$this->set_email($value);
2349 2349
     }
2350 2350
 
2351 2351
     /**
@@ -2354,8 +2354,8 @@  discard block
 block discarded – undo
2354 2354
 	 * @since 1.0.19
2355 2355
 	 * @param  string $value email address.
2356 2356
 	 */
2357
-	public function set_customer_email( $value ) {
2358
-		$this->set_email( $value );
2357
+	public function set_customer_email($value) {
2358
+		$this->set_email($value);
2359 2359
     }
2360 2360
 
2361 2361
     /**
@@ -2364,8 +2364,8 @@  discard block
 block discarded – undo
2364 2364
 	 * @since 1.0.19
2365 2365
 	 * @param  string $value country.
2366 2366
 	 */
2367
-	public function set_country( $value ) {
2368
-		$this->set_prop( 'country', $value );
2367
+	public function set_country($value) {
2368
+		$this->set_prop('country', $value);
2369 2369
     }
2370 2370
 
2371 2371
     /**
@@ -2374,8 +2374,8 @@  discard block
 block discarded – undo
2374 2374
 	 * @since 1.0.19
2375 2375
 	 * @param  string $value country.
2376 2376
 	 */
2377
-	public function set_user_country( $value ) {
2378
-		$this->set_country( $value );
2377
+	public function set_user_country($value) {
2378
+		$this->set_country($value);
2379 2379
     }
2380 2380
 
2381 2381
     /**
@@ -2384,8 +2384,8 @@  discard block
 block discarded – undo
2384 2384
 	 * @since 1.0.19
2385 2385
 	 * @param  string $value country.
2386 2386
 	 */
2387
-	public function set_customer_country( $value ) {
2388
-		$this->set_country( $value );
2387
+	public function set_customer_country($value) {
2388
+		$this->set_country($value);
2389 2389
     }
2390 2390
 
2391 2391
     /**
@@ -2394,8 +2394,8 @@  discard block
 block discarded – undo
2394 2394
 	 * @since 1.0.19
2395 2395
 	 * @param  string $value state.
2396 2396
 	 */
2397
-	public function set_state( $value ) {
2398
-		$this->set_prop( 'state', $value );
2397
+	public function set_state($value) {
2398
+		$this->set_prop('state', $value);
2399 2399
     }
2400 2400
 
2401 2401
     /**
@@ -2404,8 +2404,8 @@  discard block
 block discarded – undo
2404 2404
 	 * @since 1.0.19
2405 2405
 	 * @param  string $value state.
2406 2406
 	 */
2407
-	public function set_user_state( $value ) {
2408
-		$this->set_state( $value );
2407
+	public function set_user_state($value) {
2408
+		$this->set_state($value);
2409 2409
     }
2410 2410
 
2411 2411
     /**
@@ -2414,8 +2414,8 @@  discard block
 block discarded – undo
2414 2414
 	 * @since 1.0.19
2415 2415
 	 * @param  string $value state.
2416 2416
 	 */
2417
-	public function set_customer_state( $value ) {
2418
-		$this->set_state( $value );
2417
+	public function set_customer_state($value) {
2418
+		$this->set_state($value);
2419 2419
     }
2420 2420
 
2421 2421
     /**
@@ -2424,8 +2424,8 @@  discard block
 block discarded – undo
2424 2424
 	 * @since 1.0.19
2425 2425
 	 * @param  string $value city.
2426 2426
 	 */
2427
-	public function set_city( $value ) {
2428
-		$this->set_prop( 'city', $value );
2427
+	public function set_city($value) {
2428
+		$this->set_prop('city', $value);
2429 2429
     }
2430 2430
 
2431 2431
     /**
@@ -2434,8 +2434,8 @@  discard block
 block discarded – undo
2434 2434
 	 * @since 1.0.19
2435 2435
 	 * @param  string $value city.
2436 2436
 	 */
2437
-	public function set_user_city( $value ) {
2438
-		$this->set_city( $value );
2437
+	public function set_user_city($value) {
2438
+		$this->set_city($value);
2439 2439
     }
2440 2440
 
2441 2441
     /**
@@ -2444,8 +2444,8 @@  discard block
 block discarded – undo
2444 2444
 	 * @since 1.0.19
2445 2445
 	 * @param  string $value city.
2446 2446
 	 */
2447
-	public function set_customer_city( $value ) {
2448
-		$this->set_city( $value );
2447
+	public function set_customer_city($value) {
2448
+		$this->set_city($value);
2449 2449
     }
2450 2450
 
2451 2451
     /**
@@ -2454,8 +2454,8 @@  discard block
 block discarded – undo
2454 2454
 	 * @since 1.0.19
2455 2455
 	 * @param  string $value zip.
2456 2456
 	 */
2457
-	public function set_zip( $value ) {
2458
-		$this->set_prop( 'zip', $value );
2457
+	public function set_zip($value) {
2458
+		$this->set_prop('zip', $value);
2459 2459
     }
2460 2460
 
2461 2461
     /**
@@ -2464,8 +2464,8 @@  discard block
 block discarded – undo
2464 2464
 	 * @since 1.0.19
2465 2465
 	 * @param  string $value zip.
2466 2466
 	 */
2467
-	public function set_user_zip( $value ) {
2468
-		$this->set_zip( $value );
2467
+	public function set_user_zip($value) {
2468
+		$this->set_zip($value);
2469 2469
     }
2470 2470
 
2471 2471
     /**
@@ -2474,8 +2474,8 @@  discard block
 block discarded – undo
2474 2474
 	 * @since 1.0.19
2475 2475
 	 * @param  string $value zip.
2476 2476
 	 */
2477
-	public function set_customer_zip( $value ) {
2478
-		$this->set_zip( $value );
2477
+	public function set_customer_zip($value) {
2478
+		$this->set_zip($value);
2479 2479
     }
2480 2480
 
2481 2481
     /**
@@ -2484,8 +2484,8 @@  discard block
 block discarded – undo
2484 2484
 	 * @since 1.0.19
2485 2485
 	 * @param  string $value company.
2486 2486
 	 */
2487
-	public function set_company( $value ) {
2488
-		$this->set_prop( 'company', $value );
2487
+	public function set_company($value) {
2488
+		$this->set_prop('company', $value);
2489 2489
     }
2490 2490
 
2491 2491
     /**
@@ -2494,8 +2494,8 @@  discard block
 block discarded – undo
2494 2494
 	 * @since 1.0.19
2495 2495
 	 * @param  string $value company.
2496 2496
 	 */
2497
-	public function set_user_company( $value ) {
2498
-		$this->set_company( $value );
2497
+	public function set_user_company($value) {
2498
+		$this->set_company($value);
2499 2499
     }
2500 2500
 
2501 2501
     /**
@@ -2504,8 +2504,8 @@  discard block
 block discarded – undo
2504 2504
 	 * @since 1.0.19
2505 2505
 	 * @param  string $value company.
2506 2506
 	 */
2507
-	public function set_customer_company( $value ) {
2508
-		$this->set_company( $value );
2507
+	public function set_customer_company($value) {
2508
+		$this->set_company($value);
2509 2509
     }
2510 2510
 
2511 2511
     /**
@@ -2514,8 +2514,8 @@  discard block
 block discarded – undo
2514 2514
 	 * @since 1.0.19
2515 2515
 	 * @param  string $value var number.
2516 2516
 	 */
2517
-	public function set_vat_number( $value ) {
2518
-		$this->set_prop( 'vat_number', $value );
2517
+	public function set_vat_number($value) {
2518
+		$this->set_prop('vat_number', $value);
2519 2519
     }
2520 2520
 
2521 2521
     /**
@@ -2524,8 +2524,8 @@  discard block
 block discarded – undo
2524 2524
 	 * @since 1.0.19
2525 2525
 	 * @param  string $value var number.
2526 2526
 	 */
2527
-	public function set_user_vat_number( $value ) {
2528
-		$this->set_vat_number( $value );
2527
+	public function set_user_vat_number($value) {
2528
+		$this->set_vat_number($value);
2529 2529
     }
2530 2530
 
2531 2531
     /**
@@ -2534,8 +2534,8 @@  discard block
 block discarded – undo
2534 2534
 	 * @since 1.0.19
2535 2535
 	 * @param  string $value var number.
2536 2536
 	 */
2537
-	public function set_customer_vat_number( $value ) {
2538
-		$this->set_vat_number( $value );
2537
+	public function set_customer_vat_number($value) {
2538
+		$this->set_vat_number($value);
2539 2539
     }
2540 2540
 
2541 2541
     /**
@@ -2544,8 +2544,8 @@  discard block
 block discarded – undo
2544 2544
 	 * @since 1.0.19
2545 2545
 	 * @param  string $value var rate.
2546 2546
 	 */
2547
-	public function set_vat_rate( $value ) {
2548
-		$this->set_prop( 'vat_rate', $value );
2547
+	public function set_vat_rate($value) {
2548
+		$this->set_prop('vat_rate', $value);
2549 2549
     }
2550 2550
 
2551 2551
     /**
@@ -2554,8 +2554,8 @@  discard block
 block discarded – undo
2554 2554
 	 * @since 1.0.19
2555 2555
 	 * @param  string $value var number.
2556 2556
 	 */
2557
-	public function set_user_vat_rate( $value ) {
2558
-		$this->set_vat_rate( $value );
2557
+	public function set_user_vat_rate($value) {
2558
+		$this->set_vat_rate($value);
2559 2559
     }
2560 2560
 
2561 2561
     /**
@@ -2564,8 +2564,8 @@  discard block
 block discarded – undo
2564 2564
 	 * @since 1.0.19
2565 2565
 	 * @param  string $value var number.
2566 2566
 	 */
2567
-	public function set_customer_vat_rate( $value ) {
2568
-		$this->set_vat_rate( $value );
2567
+	public function set_customer_vat_rate($value) {
2568
+		$this->set_vat_rate($value);
2569 2569
     }
2570 2570
 
2571 2571
     /**
@@ -2574,8 +2574,8 @@  discard block
 block discarded – undo
2574 2574
 	 * @since 1.0.19
2575 2575
 	 * @param  string $value address.
2576 2576
 	 */
2577
-	public function set_address( $value ) {
2578
-		$this->set_prop( 'address', $value );
2577
+	public function set_address($value) {
2578
+		$this->set_prop('address', $value);
2579 2579
     }
2580 2580
 
2581 2581
     /**
@@ -2584,8 +2584,8 @@  discard block
 block discarded – undo
2584 2584
 	 * @since 1.0.19
2585 2585
 	 * @param  string $value address.
2586 2586
 	 */
2587
-	public function set_user_address( $value ) {
2588
-		$this->set_address( $value );
2587
+	public function set_user_address($value) {
2588
+		$this->set_address($value);
2589 2589
     }
2590 2590
 
2591 2591
     /**
@@ -2594,8 +2594,8 @@  discard block
 block discarded – undo
2594 2594
 	 * @since 1.0.19
2595 2595
 	 * @param  string $value address.
2596 2596
 	 */
2597
-	public function set_customer_address( $value ) {
2598
-		$this->set_address( $value );
2597
+	public function set_customer_address($value) {
2598
+		$this->set_address($value);
2599 2599
     }
2600 2600
 
2601 2601
     /**
@@ -2604,8 +2604,8 @@  discard block
 block discarded – undo
2604 2604
 	 * @since 1.0.19
2605 2605
 	 * @param  int|bool $value confirmed.
2606 2606
 	 */
2607
-	public function set_is_viewed( $value ) {
2608
-		$this->set_prop( 'is_viewed', $value );
2607
+	public function set_is_viewed($value) {
2608
+		$this->set_prop('is_viewed', $value);
2609 2609
 	}
2610 2610
 
2611 2611
 	/**
@@ -2614,8 +2614,8 @@  discard block
 block discarded – undo
2614 2614
 	 * @since 1.0.19
2615 2615
 	 * @param  string $value email recipients.
2616 2616
 	 */
2617
-	public function set_email_cc( $value ) {
2618
-		$this->set_prop( 'email_cc', $value );
2617
+	public function set_email_cc($value) {
2618
+		$this->set_prop('email_cc', $value);
2619 2619
 	}
2620 2620
 
2621 2621
 	/**
@@ -2624,9 +2624,9 @@  discard block
 block discarded – undo
2624 2624
 	 * @since 1.0.19
2625 2625
 	 * @param  string $value email recipients.
2626 2626
 	 */
2627
-	public function set_template( $value ) {
2628
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2629
-			$this->set_prop( 'template', $value );
2627
+	public function set_template($value) {
2628
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2629
+			$this->set_prop('template', $value);
2630 2630
 		}
2631 2631
 	}
2632 2632
 
@@ -2636,8 +2636,8 @@  discard block
 block discarded – undo
2636 2636
 	 * @since 1.0.19
2637 2637
 	 * @param  int|bool $value confirmed.
2638 2638
 	 */
2639
-	public function set_address_confirmed( $value ) {
2640
-		$this->set_prop( 'address_confirmed', $value );
2639
+	public function set_address_confirmed($value) {
2640
+		$this->set_prop('address_confirmed', $value);
2641 2641
     }
2642 2642
 
2643 2643
     /**
@@ -2646,8 +2646,8 @@  discard block
 block discarded – undo
2646 2646
 	 * @since 1.0.19
2647 2647
 	 * @param  int|bool $value confirmed.
2648 2648
 	 */
2649
-	public function set_user_address_confirmed( $value ) {
2650
-		$this->set_address_confirmed( $value );
2649
+	public function set_user_address_confirmed($value) {
2650
+		$this->set_address_confirmed($value);
2651 2651
     }
2652 2652
 
2653 2653
     /**
@@ -2656,8 +2656,8 @@  discard block
 block discarded – undo
2656 2656
 	 * @since 1.0.19
2657 2657
 	 * @param  int|bool $value confirmed.
2658 2658
 	 */
2659
-	public function set_customer_address_confirmed( $value ) {
2660
-		$this->set_address_confirmed( $value );
2659
+	public function set_customer_address_confirmed($value) {
2660
+		$this->set_address_confirmed($value);
2661 2661
     }
2662 2662
 
2663 2663
     /**
@@ -2666,8 +2666,8 @@  discard block
 block discarded – undo
2666 2666
 	 * @since 1.0.19
2667 2667
 	 * @param  float $value sub total.
2668 2668
 	 */
2669
-	public function set_subtotal( $value ) {
2670
-		$this->set_prop( 'subtotal', $value );
2669
+	public function set_subtotal($value) {
2670
+		$this->set_prop('subtotal', $value);
2671 2671
     }
2672 2672
 
2673 2673
     /**
@@ -2676,8 +2676,8 @@  discard block
 block discarded – undo
2676 2676
 	 * @since 1.0.19
2677 2677
 	 * @param  float $value discount total.
2678 2678
 	 */
2679
-	public function set_total_discount( $value ) {
2680
-		$this->set_prop( 'total_discount', $value );
2679
+	public function set_total_discount($value) {
2680
+		$this->set_prop('total_discount', $value);
2681 2681
     }
2682 2682
 
2683 2683
     /**
@@ -2686,8 +2686,8 @@  discard block
 block discarded – undo
2686 2686
 	 * @since 1.0.19
2687 2687
 	 * @param  float $value discount total.
2688 2688
 	 */
2689
-	public function set_discount( $value ) {
2690
-		$this->set_total_discount( $value );
2689
+	public function set_discount($value) {
2690
+		$this->set_total_discount($value);
2691 2691
     }
2692 2692
 
2693 2693
     /**
@@ -2696,8 +2696,8 @@  discard block
 block discarded – undo
2696 2696
 	 * @since 1.0.19
2697 2697
 	 * @param  float $value tax total.
2698 2698
 	 */
2699
-	public function set_total_tax( $value ) {
2700
-		$this->set_prop( 'total_tax', $value );
2699
+	public function set_total_tax($value) {
2700
+		$this->set_prop('total_tax', $value);
2701 2701
     }
2702 2702
 
2703 2703
     /**
@@ -2706,8 +2706,8 @@  discard block
 block discarded – undo
2706 2706
 	 * @since 1.0.19
2707 2707
 	 * @param  float $value tax total.
2708 2708
 	 */
2709
-	public function set_tax_total( $value ) {
2710
-		$this->set_total_tax( $value );
2709
+	public function set_tax_total($value) {
2710
+		$this->set_total_tax($value);
2711 2711
     }
2712 2712
 
2713 2713
     /**
@@ -2716,8 +2716,8 @@  discard block
 block discarded – undo
2716 2716
 	 * @since 1.0.19
2717 2717
 	 * @param  float $value fees total.
2718 2718
 	 */
2719
-	public function set_total_fees( $value ) {
2720
-		$this->set_prop( 'total_fees', $value );
2719
+	public function set_total_fees($value) {
2720
+		$this->set_prop('total_fees', $value);
2721 2721
     }
2722 2722
 
2723 2723
     /**
@@ -2726,8 +2726,8 @@  discard block
 block discarded – undo
2726 2726
 	 * @since 1.0.19
2727 2727
 	 * @param  float $value fees total.
2728 2728
 	 */
2729
-	public function set_fees_total( $value ) {
2730
-		$this->set_total_fees( $value );
2729
+	public function set_fees_total($value) {
2730
+		$this->set_total_fees($value);
2731 2731
     }
2732 2732
 
2733 2733
     /**
@@ -2736,18 +2736,18 @@  discard block
 block discarded – undo
2736 2736
 	 * @since 1.0.19
2737 2737
 	 * @param  array $value fees.
2738 2738
 	 */
2739
-	public function set_fees( $value ) {
2739
+	public function set_fees($value) {
2740 2740
 
2741
-        $this->set_prop( 'fees', array() );
2741
+        $this->set_prop('fees', array());
2742 2742
 
2743 2743
         // Ensure that we have an array.
2744
-        if ( ! is_array( $value ) ) {
2744
+        if (!is_array($value)) {
2745 2745
             return;
2746 2746
         }
2747 2747
 
2748
-        foreach ( $value as $name => $data ) {
2749
-            if ( isset( $data['amount'] ) ) {
2750
-                $this->add_fee( $name, $data['amount'], $data['recurring'] );
2748
+        foreach ($value as $name => $data) {
2749
+            if (isset($data['amount'])) {
2750
+                $this->add_fee($name, $data['amount'], $data['recurring']);
2751 2751
             }
2752 2752
         }
2753 2753
 
@@ -2759,8 +2759,8 @@  discard block
 block discarded – undo
2759 2759
 	 * @since 1.0.19
2760 2760
 	 * @param  array $value taxes.
2761 2761
 	 */
2762
-	public function set_taxes( $value ) {
2763
-		$this->set_prop( 'taxes', $value );
2762
+	public function set_taxes($value) {
2763
+		$this->set_prop('taxes', $value);
2764 2764
     }
2765 2765
 
2766 2766
     /**
@@ -2769,17 +2769,17 @@  discard block
 block discarded – undo
2769 2769
 	 * @since 1.0.19
2770 2770
 	 * @param  array $value discounts.
2771 2771
 	 */
2772
-	public function set_discounts( $value ) {
2773
-		$this->set_prop( 'discounts', array() );
2772
+	public function set_discounts($value) {
2773
+		$this->set_prop('discounts', array());
2774 2774
 
2775 2775
         // Ensure that we have an array.
2776
-        if ( ! is_array( $value ) ) {
2776
+        if (!is_array($value)) {
2777 2777
             return;
2778 2778
         }
2779 2779
 
2780
-        foreach ( $value as $name => $data ) {
2781
-            if ( isset( $data['amount'] ) ) {
2782
-                $this->add_discount( $name, $data['amount'], $data['recurring'] );
2780
+        foreach ($value as $name => $data) {
2781
+            if (isset($data['amount'])) {
2782
+                $this->add_discount($name, $data['amount'], $data['recurring']);
2783 2783
             }
2784 2784
         }
2785 2785
     }
@@ -2790,18 +2790,18 @@  discard block
 block discarded – undo
2790 2790
 	 * @since 1.0.19
2791 2791
 	 * @param  GetPaid_Form_Item[] $value items.
2792 2792
 	 */
2793
-	public function set_items( $value ) {
2793
+	public function set_items($value) {
2794 2794
 
2795 2795
         // Remove existing items.
2796
-        $this->set_prop( 'items', array() );
2796
+        $this->set_prop('items', array());
2797 2797
 
2798 2798
         // Ensure that we have an array.
2799
-        if ( ! is_array( $value ) ) {
2799
+        if (!is_array($value)) {
2800 2800
             return;
2801 2801
         }
2802 2802
 
2803
-        foreach ( $value as $item ) {
2804
-            $this->add_item( $item );
2803
+        foreach ($value as $item) {
2804
+            $this->add_item($item);
2805 2805
         }
2806 2806
 
2807 2807
     }
@@ -2812,8 +2812,8 @@  discard block
 block discarded – undo
2812 2812
 	 * @since 1.0.19
2813 2813
 	 * @param  int $value payment form.
2814 2814
 	 */
2815
-	public function set_payment_form( $value ) {
2816
-		$this->set_prop( 'payment_form', $value );
2815
+	public function set_payment_form($value) {
2816
+		$this->set_prop('payment_form', $value);
2817 2817
     }
2818 2818
 
2819 2819
     /**
@@ -2822,8 +2822,8 @@  discard block
 block discarded – undo
2822 2822
 	 * @since 1.0.19
2823 2823
 	 * @param  string $value submission id.
2824 2824
 	 */
2825
-	public function set_submission_id( $value ) {
2826
-		$this->set_prop( 'submission_id', $value );
2825
+	public function set_submission_id($value) {
2826
+		$this->set_prop('submission_id', $value);
2827 2827
     }
2828 2828
 
2829 2829
     /**
@@ -2832,8 +2832,8 @@  discard block
 block discarded – undo
2832 2832
 	 * @since 1.0.19
2833 2833
 	 * @param  string $value discount code.
2834 2834
 	 */
2835
-	public function set_discount_code( $value ) {
2836
-		$this->set_prop( 'discount_code', $value );
2835
+	public function set_discount_code($value) {
2836
+		$this->set_prop('discount_code', $value);
2837 2837
     }
2838 2838
 
2839 2839
     /**
@@ -2842,8 +2842,8 @@  discard block
 block discarded – undo
2842 2842
 	 * @since 1.0.19
2843 2843
 	 * @param  string $value gateway.
2844 2844
 	 */
2845
-	public function set_gateway( $value ) {
2846
-		$this->set_prop( 'gateway', $value );
2845
+	public function set_gateway($value) {
2846
+		$this->set_prop('gateway', $value);
2847 2847
     }
2848 2848
 
2849 2849
     /**
@@ -2852,9 +2852,9 @@  discard block
 block discarded – undo
2852 2852
 	 * @since 1.0.19
2853 2853
 	 * @param  string $value transaction id.
2854 2854
 	 */
2855
-	public function set_transaction_id( $value ) {
2856
-		if ( ! empty( $value ) ) {
2857
-			$this->set_prop( 'transaction_id', $value );
2855
+	public function set_transaction_id($value) {
2856
+		if (!empty($value)) {
2857
+			$this->set_prop('transaction_id', $value);
2858 2858
 		}
2859 2859
     }
2860 2860
 
@@ -2864,8 +2864,8 @@  discard block
 block discarded – undo
2864 2864
 	 * @since 1.0.19
2865 2865
 	 * @param  string $value currency id.
2866 2866
 	 */
2867
-	public function set_currency( $value ) {
2868
-		$this->set_prop( 'currency', $value );
2867
+	public function set_currency($value) {
2868
+		$this->set_prop('currency', $value);
2869 2869
     }
2870 2870
 
2871 2871
 	/**
@@ -2874,8 +2874,8 @@  discard block
 block discarded – undo
2874 2874
 	 * @since 1.0.19
2875 2875
 	 * @param  bool $value value.
2876 2876
 	 */
2877
-	public function set_disable_taxes( $value ) {
2878
-		$this->set_prop( 'disable_taxes', (bool) $value );
2877
+	public function set_disable_taxes($value) {
2878
+		$this->set_prop('disable_taxes', (bool) $value);
2879 2879
 	}
2880 2880
 
2881 2881
     /**
@@ -2884,8 +2884,8 @@  discard block
 block discarded – undo
2884 2884
 	 * @since 1.0.19
2885 2885
 	 * @param  string $value subscription id.
2886 2886
 	 */
2887
-	public function set_subscription_id( $value ) {
2888
-		$this->set_prop( 'subscription_id', $value );
2887
+	public function set_subscription_id($value) {
2888
+		$this->set_prop('subscription_id', $value);
2889 2889
 	}
2890 2890
 	
2891 2891
 	/**
@@ -2894,8 +2894,8 @@  discard block
 block discarded – undo
2894 2894
 	 * @since 1.0.19
2895 2895
 	 * @param  string $value subscription id.
2896 2896
 	 */
2897
-	public function set_remote_subscription_id( $value ) {
2898
-		$this->set_prop( 'remote_subscription_id', $value );
2897
+	public function set_remote_subscription_id($value) {
2898
+		$this->set_prop('remote_subscription_id', $value);
2899 2899
     }
2900 2900
 
2901 2901
     /*
@@ -2912,28 +2912,28 @@  discard block
 block discarded – undo
2912 2912
      */
2913 2913
     public function is_parent() {
2914 2914
         $parent = $this->get_parent_id();
2915
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
2915
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
2916 2916
     }
2917 2917
 
2918 2918
     /**
2919 2919
      * Checks if this is a renewal invoice.
2920 2920
      */
2921 2921
     public function is_renewal() {
2922
-        return ! $this->is_parent();
2922
+        return !$this->is_parent();
2923 2923
     }
2924 2924
 
2925 2925
     /**
2926 2926
      * Checks if this is a recurring invoice.
2927 2927
      */
2928 2928
     public function is_recurring() {
2929
-        return $this->is_renewal() || ! empty( $this->recurring_item );
2929
+        return $this->is_renewal() || !empty($this->recurring_item);
2930 2930
     }
2931 2931
 
2932 2932
     /**
2933 2933
      * Checks if this is a taxable invoice.
2934 2934
      */
2935 2935
     public function is_taxable() {
2936
-        return ! $this->get_disable_taxes();
2936
+        return !$this->get_disable_taxes();
2937 2937
 	}
2938 2938
 
2939 2939
 	/**
@@ -2944,57 +2944,57 @@  discard block
 block discarded – undo
2944 2944
 
2945 2945
         $requires_vat = false;
2946 2946
 
2947
-        if ( $this->country ) {
2947
+        if ($this->country) {
2948 2948
             $wpi_country        = $this->country;
2949
-            $requires_vat       = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) );
2949
+            $requires_vat       = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this));
2950 2950
         }
2951 2951
 
2952
-        return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2952
+        return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this);
2953 2953
 	}
2954 2954
 
2955 2955
 	/**
2956 2956
 	 * Checks to see if the invoice requires payment.
2957 2957
 	 */
2958 2958
 	public function is_free() {
2959
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2959
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
2960 2960
 
2961
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2961
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
2962 2962
 			$is_free = false;
2963 2963
 		}
2964 2964
 
2965
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2965
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
2966 2966
     }
2967 2967
 
2968 2968
     /**
2969 2969
      * Checks if the invoice is paid.
2970 2970
      */
2971 2971
     public function is_paid() {
2972
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2973
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2972
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
2973
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
2974 2974
 	}
2975 2975
 
2976 2976
 	/**
2977 2977
      * Checks if the invoice needs payment.
2978 2978
      */
2979 2979
 	public function needs_payment() {
2980
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2981
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2980
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
2981
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
2982 2982
     }
2983 2983
   
2984 2984
 	/**
2985 2985
      * Checks if the invoice is refunded.
2986 2986
      */
2987 2987
 	public function is_refunded() {
2988
-        $is_refunded = $this->has_status( 'wpi-refunded' );
2989
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2988
+        $is_refunded = $this->has_status('wpi-refunded');
2989
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
2990 2990
 	}
2991 2991
 
2992 2992
 	/**
2993 2993
      * Checks if the invoice is held.
2994 2994
      */
2995 2995
 	public function is_held() {
2996
-        $is_held = $this->has_status( 'wpi-onhold' );
2997
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
2996
+        $is_held = $this->has_status('wpi-onhold');
2997
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
2998 2998
 	}
2999 2999
 
3000 3000
 	/**
@@ -3002,30 +3002,30 @@  discard block
 block discarded – undo
3002 3002
      */
3003 3003
 	public function is_due() {
3004 3004
 		$due_date = $this->get_due_date();
3005
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3005
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
3006 3006
 	}
3007 3007
 
3008 3008
 	/**
3009 3009
      * Checks if the invoice is draft.
3010 3010
      */
3011 3011
 	public function is_draft() {
3012
-        return $this->has_status( 'draft, auto-draft' );
3012
+        return $this->has_status('draft, auto-draft');
3013 3013
 	}
3014 3014
 
3015 3015
     /**
3016 3016
      * Checks if the invoice has a given status.
3017 3017
      */
3018
-    public function has_status( $status ) {
3019
-        $status = wpinv_parse_list( $status );
3020
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3018
+    public function has_status($status) {
3019
+        $status = wpinv_parse_list($status);
3020
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
3021 3021
 	}
3022 3022
 
3023 3023
 	/**
3024 3024
      * Checks if the invoice is of a given type.
3025 3025
      */
3026
-    public function is_type( $type ) {
3027
-        $type = wpinv_parse_list( $type );
3028
-        return in_array( $this->get_type(), $type );
3026
+    public function is_type($type) {
3027
+        $type = wpinv_parse_list($type);
3028
+        return in_array($this->get_type(), $type);
3029 3029
     }
3030 3030
 
3031 3031
     /**
@@ -3057,8 +3057,8 @@  discard block
 block discarded – undo
3057 3057
      *
3058 3058
      */
3059 3059
 	public function is_initial_free() {
3060
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3061
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3060
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3061
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3062 3062
     }
3063 3063
 	
3064 3064
 	/**
@@ -3068,11 +3068,11 @@  discard block
 block discarded – undo
3068 3068
     public function item_has_free_trial() {
3069 3069
 
3070 3070
         // Ensure we have a recurring item.
3071
-        if ( ! $this->is_recurring() ) {
3071
+        if (!$this->is_recurring()) {
3072 3072
             return false;
3073 3073
         }
3074 3074
 
3075
-        $item = $this->get_recurring( true );
3075
+        $item = $this->get_recurring(true);
3076 3076
         return $item->has_free_trial();
3077 3077
 	}
3078 3078
 
@@ -3080,7 +3080,7 @@  discard block
 block discarded – undo
3080 3080
      * Check if the free trial is a result of a discount.
3081 3081
      */
3082 3082
     public function is_free_trial_from_discount() {
3083
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3083
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3084 3084
 	}
3085 3085
 	
3086 3086
 	/**
@@ -3089,17 +3089,17 @@  discard block
 block discarded – undo
3089 3089
     public function discount_first_payment_only() {
3090 3090
 
3091 3091
 		$discount_code = $this->get_discount_code();
3092
-        if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3092
+        if (empty($this->discount_code) || !$this->is_recurring()) {
3093 3093
             return true;
3094 3094
         }
3095 3095
 
3096
-        $discount = wpinv_get_discount_obj( $discount_code );
3096
+        $discount = wpinv_get_discount_obj($discount_code);
3097 3097
 
3098
-        if ( ! $discount || ! $discount->exists() ) {
3098
+        if (!$discount || !$discount->exists()) {
3099 3099
             return true;
3100 3100
         }
3101 3101
 
3102
-        return ! $discount->get_is_recurring();
3102
+        return !$discount->get_is_recurring();
3103 3103
     }
3104 3104
 
3105 3105
     /*
@@ -3117,27 +3117,27 @@  discard block
 block discarded – undo
3117 3117
      * @param GetPaid_Form_Item|array $item
3118 3118
      * @return WP_Error|Bool
3119 3119
      */
3120
-    public function add_item( $item ) {
3120
+    public function add_item($item) {
3121 3121
 
3122
-		if ( is_array( $item ) ) {
3123
-			$item = $this->process_array_item( $item );
3122
+		if (is_array($item)) {
3123
+			$item = $this->process_array_item($item);
3124 3124
 		}
3125 3125
 
3126
-		if ( is_numeric( $item ) ) {
3127
-			$item = new GetPaid_Form_Item( $item );
3126
+		if (is_numeric($item)) {
3127
+			$item = new GetPaid_Form_Item($item);
3128 3128
 		}
3129 3129
 
3130 3130
         // Make sure that it is available for purchase.
3131
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3132
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3131
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3132
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3133 3133
         }
3134 3134
 
3135 3135
         // Do we have a recurring item?
3136
-		if ( $item->is_recurring() ) {
3136
+		if ($item->is_recurring()) {
3137 3137
 
3138 3138
 			// An invoice can only contain one recurring item.
3139
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3140
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3139
+			if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) {
3140
+				return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing'));
3141 3141
 			}
3142 3142
 
3143 3143
 			$this->recurring_item = $item->get_id();
@@ -3148,9 +3148,9 @@  discard block
 block discarded – undo
3148 3148
 
3149 3149
         // Retrieve all items.
3150 3150
         $items = $this->get_items();
3151
-        $items[ (int) $item->get_id() ] = $item;
3151
+        $items[(int) $item->get_id()] = $item;
3152 3152
 
3153
-        $this->set_prop( 'items', $items );
3153
+        $this->set_prop('items', $items);
3154 3154
 		return true;
3155 3155
 	}
3156 3156
 	
@@ -3160,26 +3160,26 @@  discard block
 block discarded – undo
3160 3160
 	 * @since 1.0.19
3161 3161
 	 * @return GetPaid_Form_Item
3162 3162
 	 */
3163
-	protected function process_array_item( $array ) {
3163
+	protected function process_array_item($array) {
3164 3164
 
3165
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3166
-		$item    = new GetPaid_Form_Item( $item_id );
3165
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3166
+		$item    = new GetPaid_Form_Item($item_id);
3167 3167
 
3168 3168
 		// Set item data.
3169
-		foreach( array( 'name', 'price', 'description' ) as $key ) {
3170
-			if ( isset( $array[ "item_$key" ] ) ) {
3169
+		foreach (array('name', 'price', 'description') as $key) {
3170
+			if (isset($array["item_$key"])) {
3171 3171
 				$method = "set_$key";
3172
-				$item->$method( $array[ "item_$key" ] );
3172
+				$item->$method($array["item_$key"]);
3173 3173
 			}
3174 3174
 		}
3175 3175
 
3176
-		if ( isset( $array['quantity'] ) ) {
3177
-			$item->set_quantity( $array['quantity'] );
3176
+		if (isset($array['quantity'])) {
3177
+			$item->set_quantity($array['quantity']);
3178 3178
 		}
3179 3179
 
3180 3180
 		// Set item meta.
3181
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3182
-			$item->set_item_meta( $array['meta'] );
3181
+		if (isset($array['meta']) && is_array($array['meta'])) {
3182
+			$item->set_item_meta($array['meta']);
3183 3183
 		}
3184 3184
 
3185 3185
 		return $item;
@@ -3191,10 +3191,10 @@  discard block
 block discarded – undo
3191 3191
 	 *
3192 3192
 	 * @since 1.0.19
3193 3193
 	 */
3194
-	public function get_item( $item_id ) {
3194
+	public function get_item($item_id) {
3195 3195
 		$items   = $this->get_items();
3196 3196
 		$item_id = (int) $item_id;
3197
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3197
+		return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null;
3198 3198
     }
3199 3199
 
3200 3200
     /**
@@ -3202,17 +3202,17 @@  discard block
 block discarded – undo
3202 3202
 	 *
3203 3203
 	 * @since 1.0.19
3204 3204
 	 */
3205
-	public function remove_item( $item_id ) {
3205
+	public function remove_item($item_id) {
3206 3206
 		$items   = $this->get_items();
3207 3207
 		$item_id = (int) $item_id;
3208 3208
 
3209
-        if ( $item_id == $this->recurring_item ) {
3209
+        if ($item_id == $this->recurring_item) {
3210 3210
             $this->recurring_item = null;
3211 3211
         }
3212 3212
 
3213
-        if ( isset( $items[ $item_id ] ) ) {
3214
-            unset( $items[ $item_id ] );
3215
-            $this->set_prop( 'items', $items );
3213
+        if (isset($items[$item_id])) {
3214
+            unset($items[$item_id]);
3215
+            $this->set_prop('items', $items);
3216 3216
         }
3217 3217
     }
3218 3218
 
@@ -3223,27 +3223,27 @@  discard block
 block discarded – undo
3223 3223
      * @param float $value
3224 3224
      * @return WP_Error|Bool
3225 3225
      */
3226
-    public function add_fee( $fee, $value, $recurring = false ) {
3226
+    public function add_fee($fee, $value, $recurring = false) {
3227 3227
 
3228
-        $amount = wpinv_sanitize_amount( $value );
3228
+        $amount = wpinv_sanitize_amount($value);
3229 3229
         $fees   = $this->get_fees();
3230 3230
 
3231
-        if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) {
3231
+        if (isset($fees[$fee]) && isset($fees[$fee]['amount'])) {
3232 3232
 
3233
-            $amount = $fees[ $fee ]['amount'] += $amount;
3234
-			$fees[ $fee ] = array(
3233
+            $amount = $fees[$fee]['amount'] += $amount;
3234
+			$fees[$fee] = array(
3235 3235
 				'amount'    => $amount,
3236 3236
                 'recurring' => (bool) $recurring,
3237 3237
             );
3238 3238
 
3239 3239
 		} else {
3240
-			$fees[ $fee ] = array(
3240
+			$fees[$fee] = array(
3241 3241
                 'amount'    => $amount,
3242 3242
                 'recurring' => (bool) $recurring,
3243 3243
             );
3244 3244
 		}
3245 3245
 
3246
-        $this->set_prop( 'fees', $fee );
3246
+        $this->set_prop('fees', $fee);
3247 3247
 
3248 3248
     }
3249 3249
 
@@ -3252,9 +3252,9 @@  discard block
 block discarded – undo
3252 3252
 	 *
3253 3253
 	 * @since 1.0.19
3254 3254
 	 */
3255
-	public function get_fee( $fee ) {
3255
+	public function get_fee($fee) {
3256 3256
         $fees = $this->get_fees();
3257
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3257
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3258 3258
     }
3259 3259
 
3260 3260
     /**
@@ -3262,11 +3262,11 @@  discard block
 block discarded – undo
3262 3262
 	 *
3263 3263
 	 * @since 1.0.19
3264 3264
 	 */
3265
-	public function remove_fee( $fee ) {
3265
+	public function remove_fee($fee) {
3266 3266
         $fees = $this->get_fees();
3267
-        if ( isset( $fees[ $fee ] ) ) {
3268
-            unset( $fees[ $fee ] );
3269
-            $this->set_prop( 'fees', $fees );
3267
+        if (isset($fees[$fee])) {
3268
+            unset($fees[$fee]);
3269
+            $this->set_prop('fees', $fees);
3270 3270
         }
3271 3271
     }
3272 3272
 
@@ -3277,27 +3277,27 @@  discard block
 block discarded – undo
3277 3277
      * @param float $value
3278 3278
      * @return WP_Error|Bool
3279 3279
      */
3280
-    public function add_discount( $discount, $value, $recurring = false ) {
3280
+    public function add_discount($discount, $value, $recurring = false) {
3281 3281
 
3282
-        $amount    = wpinv_sanitize_amount( $value );
3282
+        $amount    = wpinv_sanitize_amount($value);
3283 3283
         $discounts = $this->get_discounts();
3284 3284
 
3285
-        if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) {
3285
+        if (isset($discounts[$discount]) && isset($discounts[$discount]['amount'])) {
3286 3286
 
3287
-            $amount = $discounts[ $discount ]['amount'] += $amount;
3288
-			$discounts[ $discount ] = array(
3287
+            $amount = $discounts[$discount]['amount'] += $amount;
3288
+			$discounts[$discount] = array(
3289 3289
                 'amount'    => $amount,
3290 3290
                 'recurring' => (bool) $recurring,
3291 3291
             );
3292 3292
 
3293 3293
 		} else {
3294
-			$discounts[ $discount ] = array(
3294
+			$discounts[$discount] = array(
3295 3295
                 'amount'    => $amount,
3296 3296
                 'recurring' => (bool) $recurring,
3297 3297
             );
3298 3298
 		}
3299 3299
 
3300
-        $this->set_prop( 'discounts', $discount );
3300
+        $this->set_prop('discounts', $discount);
3301 3301
 
3302 3302
     }
3303 3303
 
@@ -3306,15 +3306,15 @@  discard block
 block discarded – undo
3306 3306
 	 *
3307 3307
 	 * @since 1.0.19
3308 3308
 	 */
3309
-	public function get_discount( $discount = false ) {
3309
+	public function get_discount($discount = false) {
3310 3310
 
3311 3311
 		// Backwards compatibilty.
3312
-		if ( empty( $discount ) ) {
3312
+		if (empty($discount)) {
3313 3313
 			return $this->get_total_discount();
3314 3314
 		}
3315 3315
 
3316 3316
         $discounts = $this->get_discounts();
3317
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3317
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3318 3318
     }
3319 3319
 
3320 3320
     /**
@@ -3322,11 +3322,11 @@  discard block
 block discarded – undo
3322 3322
 	 *
3323 3323
 	 * @since 1.0.19
3324 3324
 	 */
3325
-	public function remove_discount( $discount ) {
3325
+	public function remove_discount($discount) {
3326 3326
         $discounts = $this->get_discounts();
3327
-        if ( isset( $discounts[ $discount ] ) ) {
3328
-            unset( $discounts[ $discount ] );
3329
-            $this->set_prop( 'discounts', $discounts );
3327
+        if (isset($discounts[$discount])) {
3328
+            unset($discounts[$discount]);
3329
+            $this->set_prop('discounts', $discounts);
3330 3330
         }
3331 3331
     }
3332 3332
 
@@ -3336,31 +3336,31 @@  discard block
 block discarded – undo
3336 3336
      * @param string $tax
3337 3337
      * @param float $value
3338 3338
      */
3339
-    public function add_tax( $tax, $value, $recurring = true ) {
3339
+    public function add_tax($tax, $value, $recurring = true) {
3340 3340
 
3341
-        if ( ! $this->is_taxable() ) {
3341
+        if (!$this->is_taxable()) {
3342 3342
             return;
3343 3343
         }
3344 3344
 
3345
-        $amount    = wpinv_sanitize_amount( $value );
3345
+        $amount    = wpinv_sanitize_amount($value);
3346 3346
         $taxes     = $this->get_taxes();
3347 3347
 
3348
-        if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) {
3348
+        if (isset($taxes[$tax]) && isset($taxes[$tax]['amount'])) {
3349 3349
 
3350
-            $amount = $taxes[ $tax ]['amount'] += $amount;
3351
-			$taxes[ $tax ] = array(
3350
+            $amount = $taxes[$tax]['amount'] += $amount;
3351
+			$taxes[$tax] = array(
3352 3352
                 'amount'    => $amount,
3353 3353
                 'recurring' => (bool) $recurring,
3354 3354
             );
3355 3355
 
3356 3356
 		} else {
3357
-			$taxes[ $tax ] = array(
3357
+			$taxes[$tax] = array(
3358 3358
                 'amount'    => $amount,
3359 3359
                 'recurring' => (bool) $recurring,
3360 3360
             );
3361 3361
 		}
3362 3362
 
3363
-        $this->set_prop( 'taxes', $tax );
3363
+        $this->set_prop('taxes', $tax);
3364 3364
 
3365 3365
     }
3366 3366
 
@@ -3369,15 +3369,15 @@  discard block
 block discarded – undo
3369 3369
 	 *
3370 3370
 	 * @since 1.0.19
3371 3371
 	 */
3372
-	public function get_tax( $tax = null ) {
3372
+	public function get_tax($tax = null) {
3373 3373
 
3374 3374
 		// Backwards compatility.
3375
-		if ( empty( $tax ) ) {
3375
+		if (empty($tax)) {
3376 3376
 			return $this->get_total_tax();
3377 3377
 		}
3378 3378
 
3379 3379
         $taxes = $this->get_taxes();
3380
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3380
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3381 3381
     }
3382 3382
 
3383 3383
     /**
@@ -3385,11 +3385,11 @@  discard block
 block discarded – undo
3385 3385
 	 *
3386 3386
 	 * @since 1.0.19
3387 3387
 	 */
3388
-	public function remove_tax( $tax ) {
3388
+	public function remove_tax($tax) {
3389 3389
         $taxes = $this->get_discounts();
3390
-        if ( isset( $taxes[ $tax ] ) ) {
3391
-            unset( $taxes[ $tax ] );
3392
-            $this->set_prop( 'taxes', $taxes );
3390
+        if (isset($taxes[$tax])) {
3391
+            unset($taxes[$tax]);
3392
+            $this->set_prop('taxes', $taxes);
3393 3393
         }
3394 3394
     }
3395 3395
 
@@ -3400,19 +3400,19 @@  discard block
 block discarded – undo
3400 3400
 	 * @return float The recalculated subtotal
3401 3401
 	 */
3402 3402
 	public function recalculate_subtotal() {
3403
-        $items     = $this->get_items();
3403
+        $items = $this->get_items();
3404 3404
 		$subtotal  = 0;
3405 3405
 		$recurring = 0;
3406 3406
 
3407
-        foreach ( $items as $item ) {
3407
+        foreach ($items as $item) {
3408 3408
 			$subtotal  += $item->get_sub_total();
3409 3409
 			$recurring += $item->get_recurring_sub_total();
3410 3410
         }
3411 3411
 
3412
-		if ( $this->is_renewal() ) {
3413
-			$this->set_subtotal( $recurring );
3412
+		if ($this->is_renewal()) {
3413
+			$this->set_subtotal($recurring);
3414 3414
 		} else {
3415
-			$this->set_subtotal( $subtotal );
3415
+			$this->set_subtotal($subtotal);
3416 3416
 		}
3417 3417
 
3418 3418
 		$this->totals['subtotal'] = array(
@@ -3434,9 +3434,9 @@  discard block
 block discarded – undo
3434 3434
 		$discount  = 0;
3435 3435
 		$recurring = 0;
3436 3436
 
3437
-        foreach ( $discounts as $data ) {
3437
+        foreach ($discounts as $data) {
3438 3438
 
3439
-			if ( $data['recurring'] ) {
3439
+			if ($data['recurring']) {
3440 3440
 				$recurring += $data['amount'];
3441 3441
 			} else {
3442 3442
 				$discount += $data['amount'];
@@ -3444,10 +3444,10 @@  discard block
 block discarded – undo
3444 3444
 
3445 3445
 		}
3446 3446
 
3447
-		if ( $this->is_renewal() ) {
3448
-			$this->set_total_discount( $recurring );
3447
+		if ($this->is_renewal()) {
3448
+			$this->set_total_discount($recurring);
3449 3449
 		} else {
3450
-			$this->set_total_discount( $discount );
3450
+			$this->set_total_discount($discount);
3451 3451
 		}
3452 3452
 
3453 3453
 		$this->totals['discount'] = array(
@@ -3466,13 +3466,13 @@  discard block
 block discarded – undo
3466 3466
 	 * @return float The recalculated tax
3467 3467
 	 */
3468 3468
 	public function recalculate_total_tax() {
3469
-        $taxes     = $this->get_taxes();
3469
+        $taxes = $this->get_taxes();
3470 3470
 		$tax       = 0;
3471 3471
 		$recurring = 0;
3472 3472
 
3473
-        foreach ( $taxes as $data ) {
3473
+        foreach ($taxes as $data) {
3474 3474
 
3475
-			if ( $data['recurring'] ) {
3475
+			if ($data['recurring']) {
3476 3476
 				$recurring += $data['amount'];
3477 3477
 			} else {
3478 3478
 				$tax += $data['amount'];
@@ -3480,10 +3480,10 @@  discard block
 block discarded – undo
3480 3480
 
3481 3481
 		}
3482 3482
 
3483
-		if ( $this->is_renewal() ) {
3484
-			$this->set_total_tax( $recurring );
3483
+		if ($this->is_renewal()) {
3484
+			$this->set_total_tax($recurring);
3485 3485
 		} else {
3486
-			$this->set_total_tax( $tax );
3486
+			$this->set_total_tax($tax);
3487 3487
 		}
3488 3488
 
3489 3489
 		$this->totals['tax'] = array(
@@ -3506,9 +3506,9 @@  discard block
 block discarded – undo
3506 3506
 		$fee       = 0;
3507 3507
 		$recurring = 0;
3508 3508
 
3509
-        foreach ( $fees as $data ) {
3509
+        foreach ($fees as $data) {
3510 3510
 
3511
-			if ( $data['recurring'] ) {
3511
+			if ($data['recurring']) {
3512 3512
 				$recurring += $data['amount'];
3513 3513
 			} else {
3514 3514
 				$fee += $data['amount'];
@@ -3516,10 +3516,10 @@  discard block
 block discarded – undo
3516 3516
 
3517 3517
 		}
3518 3518
 
3519
-        if ( $this->is_renewal() ) {
3520
-			$this->set_total_fees( $recurring );
3519
+        if ($this->is_renewal()) {
3520
+			$this->set_total_fees($recurring);
3521 3521
 		} else {
3522
-			$this->set_total_fees( $fee );
3522
+			$this->set_total_fees($fee);
3523 3523
 		}
3524 3524
 
3525 3525
 		$this->totals['fee'] = array(
@@ -3527,7 +3527,7 @@  discard block
 block discarded – undo
3527 3527
 			'recurring' => $recurring,
3528 3528
 		);
3529 3529
 
3530
-        $this->set_total_fees( $fee );
3530
+        $this->set_total_fees($fee);
3531 3531
         return $this->is_renewal() ? $recurring : $fee;
3532 3532
     }
3533 3533
 
@@ -3548,9 +3548,9 @@  discard block
 block discarded – undo
3548 3548
 	/**
3549 3549
 	 * @deprecated
3550 3550
 	 */
3551
-    public function recalculate_totals( $temp = false ) {
3552
-        $this->update_items( $temp );
3553
-        $this->save( true );
3551
+    public function recalculate_totals($temp = false) {
3552
+        $this->update_items($temp);
3553
+        $this->save(true);
3554 3554
         return $this;
3555 3555
     }
3556 3556
 
@@ -3568,10 +3568,10 @@  discard block
 block discarded – undo
3568 3568
 	 * @return int|false The new note's ID on success, false on failure.
3569 3569
      *
3570 3570
      */
3571
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3571
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3572 3572
 
3573 3573
         // Bail if no note specified or this invoice is not yet saved.
3574
-        if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) {
3574
+        if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) {
3575 3575
             return false;
3576 3576
         }
3577 3577
 
@@ -3579,23 +3579,23 @@  discard block
 block discarded – undo
3579 3579
 		$author_email = '[email protected]';
3580 3580
 
3581 3581
 		// If this is an admin comment or it has been added by the user.
3582
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3583
-			$user         = get_user_by( 'id', get_current_user_id() );
3582
+		if (is_user_logged_in() && (!$system || $added_by_user)) {
3583
+			$user = get_user_by('id', get_current_user_id());
3584 3584
             $author       = $user->display_name;
3585 3585
             $author_email = $user->user_email;
3586 3586
 		}
3587 3587
 
3588
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3588
+		return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type);
3589 3589
 
3590 3590
 	}
3591 3591
 
3592 3592
 	/**
3593 3593
      * Generates a unique key for the invoice.
3594 3594
      */
3595
-    public function generate_key( $string = '' ) {
3596
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3595
+    public function generate_key($string = '') {
3596
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3597 3597
         return strtolower(
3598
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3598
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3599 3599
         );
3600 3600
     }
3601 3601
 
@@ -3605,11 +3605,11 @@  discard block
 block discarded – undo
3605 3605
     public function generate_number() {
3606 3606
         $number = $this->get_id();
3607 3607
 
3608
-        if ( wpinv_sequential_number_active( $this->get_post_type() ) ) {
3609
-            $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3608
+        if (wpinv_sequential_number_active($this->get_post_type())) {
3609
+            $number = wpinv_get_next_invoice_number($this->get_post_type());
3610 3610
         }
3611 3611
 
3612
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3612
+		return wpinv_format_invoice_number($number, $this->get_post_type());
3613 3613
 
3614 3614
 	}
3615 3615
 
@@ -3622,55 +3622,55 @@  discard block
 block discarded – undo
3622 3622
 		// Reset status transition variable.
3623 3623
 		$this->status_transition = false;
3624 3624
 
3625
-		if ( $status_transition ) {
3625
+		if ($status_transition) {
3626 3626
 			try {
3627 3627
 
3628 3628
 				// Fire a hook for the status change.
3629
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3629
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition);
3630 3630
 
3631 3631
 				// @deprecated this is deprecated and will be removed in the future.
3632
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3632
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3633 3633
 
3634
-				if ( ! empty( $status_transition['from'] ) ) {
3634
+				if (!empty($status_transition['from'])) {
3635 3635
 
3636 3636
 					/* translators: 1: old invoice status 2: new invoice status */
3637
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3637
+					$transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from']), wpinv_status_nicename($status_transition['to']));
3638 3638
 
3639 3639
 					// Fire another hook.
3640
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3641
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3640
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this);
3641
+					do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']);
3642 3642
 
3643 3643
 					// @deprecated this is deprecated and will be removed in the future.
3644
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3644
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3645 3645
 
3646 3646
 					// Note the transition occurred.
3647
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3647
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3648 3648
 
3649 3649
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3650 3650
 					if (
3651
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3652
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3651
+						in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3652
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3653 3653
 					) {
3654
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3654
+						do_action('getpaid_invoice_payment_status_changed', $this, $status_transition);
3655 3655
 					}
3656 3656
 
3657 3657
 					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3658 3658
 					if (
3659
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3660
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3659
+						in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3660
+						&& in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3661 3661
 					) {
3662
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3662
+						do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition);
3663 3663
 					}
3664 3664
 				} else {
3665 3665
 					/* translators: %s: new invoice status */
3666
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3666
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to']));
3667 3667
 
3668 3668
 					// Note the transition occurred.
3669
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3669
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3670 3670
 
3671 3671
 				}
3672
-			} catch ( Exception $e ) {
3673
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3672
+			} catch (Exception $e) {
3673
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
3674 3674
 			}
3675 3675
 		}
3676 3676
 	}
@@ -3678,13 +3678,13 @@  discard block
 block discarded – undo
3678 3678
 	/**
3679 3679
 	 * Updates an invoice status.
3680 3680
 	 */
3681
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3681
+	public function update_status($new_status = false, $note = '', $manual = false) {
3682 3682
 
3683 3683
 		// Fires before updating a status.
3684
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3684
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
3685 3685
 
3686 3686
 		// Update the status.
3687
-		$this->set_status( $new_status, $note, $manual );
3687
+		$this->set_status($new_status, $note, $manual);
3688 3688
 
3689 3689
 		// Save the order.
3690 3690
 		return $this->save();
@@ -3695,18 +3695,18 @@  discard block
 block discarded – undo
3695 3695
 	 * @deprecated
3696 3696
 	 */
3697 3697
 	public function refresh_item_ids() {
3698
-        $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3699
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3698
+        $item_ids = implode(',', array_unique(array_keys($this->get_items())));
3699
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
3700 3700
 	}
3701 3701
 
3702 3702
 	/**
3703 3703
 	 * @deprecated
3704 3704
 	 */
3705
-	public function update_items( $temp = false ) {
3705
+	public function update_items($temp = false) {
3706 3706
 
3707
-		$this->set_items( $this->get_items() );
3707
+		$this->set_items($this->get_items());
3708 3708
 
3709
-		if ( ! $temp ) {
3709
+		if (!$temp) {
3710 3710
 			$this->save();
3711 3711
 		}
3712 3712
 
@@ -3720,11 +3720,11 @@  discard block
 block discarded – undo
3720 3720
 
3721 3721
         $discount_code = $this->get_discount_code();
3722 3722
 
3723
-        if ( empty( $discount_code ) ) {
3723
+        if (empty($discount_code)) {
3724 3724
             return false;
3725 3725
         }
3726 3726
 
3727
-        $discount = wpinv_get_discount_obj( $discount_code );
3727
+        $discount = wpinv_get_discount_obj($discount_code);
3728 3728
 
3729 3729
         // Ensure it is active.
3730 3730
         return $discount->exists();
@@ -3735,7 +3735,7 @@  discard block
 block discarded – undo
3735 3735
 	 * Refunds an invoice.
3736 3736
 	 */
3737 3737
     public function refund() {
3738
-		$this->set_status( 'wpi-refunded' );
3738
+		$this->set_status('wpi-refunded');
3739 3739
         $this->save();
3740 3740
 	}
3741 3741
 
@@ -3744,56 +3744,56 @@  discard block
 block discarded – undo
3744 3744
 	 * 
3745 3745
 	 * @param string $transaction_id
3746 3746
 	 */
3747
-    public function mark_paid( $transaction_id = null, $note = '' ) {
3747
+    public function mark_paid($transaction_id = null, $note = '') {
3748 3748
 
3749 3749
 		// Set the transaction id.
3750
-		if ( empty( $transaction_id ) ) {
3750
+		if (empty($transaction_id)) {
3751 3751
 			$transaction_id = $this->generate_key('trans_');
3752 3752
 		}
3753 3753
 
3754
-		if ( ! $this->get_transaction_id() ) {
3755
-			$this->set_transaction_id( $transaction_id );
3754
+		if (!$this->get_transaction_id()) {
3755
+			$this->set_transaction_id($transaction_id);
3756 3756
 		}
3757 3757
 
3758
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3758
+		if ($this->is_paid() && 'wpi-processing' != $this->get_status()) {
3759 3759
 			return $this->save();
3760 3760
 		}
3761 3761
 
3762 3762
 		// Set the completed date.
3763
-		$this->set_date_completed( current_time( 'mysql' ) );
3763
+		$this->set_date_completed(current_time('mysql'));
3764 3764
 
3765 3765
 		// Set the new status.
3766
-		if ( $this->is_renewal() ) {
3766
+		if ($this->is_renewal()) {
3767 3767
 
3768 3768
 			$_note = sprintf(
3769
-				__( 'Renewed via %s', 'invoicing' ),
3770
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3769
+				__('Renewed via %s', 'invoicing'),
3770
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3771 3771
 			);
3772 3772
 
3773
-			if ( 'none' == $this->get_gateway() ) {
3773
+			if ('none' == $this->get_gateway()) {
3774 3774
 				$_note = $note;
3775 3775
 			}
3776 3776
 
3777
-			$this->set_status( 'wpi-renewal', $_note );
3777
+			$this->set_status('wpi-renewal', $_note);
3778 3778
 
3779 3779
 		} else {
3780 3780
 
3781 3781
 			$_note = sprintf(
3782
-				__( 'Paid via %s', 'invoicing' ),
3783
-				$this->get_gateway() . empty( $note ) ? '' : " ($note)"
3782
+				__('Paid via %s', 'invoicing'),
3783
+				$this->get_gateway() . empty($note) ? '' : " ($note)"
3784 3784
 			);
3785 3785
 
3786
-			if ( 'none' == $this->get_gateway() ) {
3786
+			if ('none' == $this->get_gateway()) {
3787 3787
 				$_note = $note;
3788 3788
 			}
3789 3789
 
3790
-			$this->set_status( 'publish',$_note );
3790
+			$this->set_status('publish', $_note);
3791 3791
 
3792 3792
 		}
3793 3793
 
3794 3794
 		// Set checkout mode.
3795
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3796
-		$this->set_mode( $mode );
3795
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
3796
+		$this->set_mode($mode);
3797 3797
 
3798 3798
 		// Save the invoice.
3799 3799
         $this->save();
@@ -3819,9 +3819,9 @@  discard block
 block discarded – undo
3819 3819
      * Clears the subscription's cache.
3820 3820
      */
3821 3821
     public function clear_cache() {
3822
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3823
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3824
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3822
+		wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids');
3823
+		wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids');
3824
+		wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids');
3825 3825
 	}
3826 3826
 
3827 3827
 }
Please login to merge, or discard this patch.
includes/class-getpaid-invoice-notification-emails.php 2 patches
Indentation   +386 added lines, -386 removed lines patch added patch discarded remove patch
@@ -12,438 +12,438 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Invoice_Notification_Emails {
14 14
 
15
-	/**
16
-	 * The array of invoice email actions.
17
-	 *
18
-	 * @param array
19
-	 */
20
-	public $invoice_actions;
21
-
22
-	/**
23
-	 * Class constructor
24
-	 *
25
-	 */
26
-	public function __construct() {
27
-
28
-		$this->invoice_actions = apply_filters(
29
-			'getpaid_notification_email_invoice_triggers',
30
-			array(
31
-				'getpaid_new_invoice'                   => array( 'new_invoice', 'user_invoice' ),
32
-				'getpaid_invoice_status_wpi-cancelled'  => 'cancelled_invoice',
33
-				'getpaid_invoice_status_wpi-failed'     => 'failed_invoice',
34
-				'getpaid_invoice_status_wpi-onhold'     => 'onhold_invoice',
35
-				'getpaid_invoice_status_wpi-processing' => 'processing_invoice',
36
-				'getpaid_invoice_status_publish'        => 'completed_invoice',
37
-				'getpaid_invoice_status_wpi-renewal'    => 'completed_invoice',
38
-				'getpaid_invoice_status_wpi-refunded'   => 'refunded_invoice',
39
-				'getpaid_new_customer_note'             => 'user_note',
40
-				'getpaid_daily_maintenance'             => 'overdue',
41
-			)
42
-		);
43
-
44
-		$this->init_hooks();
45
-
46
-	}
47
-
48
-	/**
49
-	 * Registers email hooks.
50
-	 */
51
-	public function init_hooks() {
52
-
53
-		add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 );
54
-		add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 );
55
-
56
-		foreach ( $this->invoice_actions as $hook => $email_type ) {
57
-			$this->init_email_type_hook( $hook, $email_type );
58
-		}
59
-	}
60
-
61
-	/**
62
-	 * Registers an email hook for an invoice action.
63
-	 * 
64
-	 * @param string $hook
65
-	 * @param string|array $email_type
66
-	 */
67
-	public function init_email_type_hook( $hook, $email_type ) {
68
-
69
-		$email_type = wpinv_parse_list( $email_type );
70
-
71
-		foreach ( $email_type as $type ) {
72
-
73
-			$email = new GetPaid_Notification_Email( $type );
74
-
75
-			// Abort if it is not active.
76
-			if ( ! $email->is_active() ) {
77
-				continue;
78
-			}
79
-
80
-			if ( method_exists( $this, $type ) ) {
81
-				add_action( $hook, array( $this, $type ), 100, 2 );
82
-				continue;
83
-			}
84
-
85
-			do_action( 'getpaid_invoice_init_email_type_hook', $type );
86
-		}
87
-
88
-	}
89
-
90
-	/**
91
-	 * Filters invoice merge tags.
92
-	 *
93
-	 * @param array $merge_tags
94
-	 * @param mixed|WPInv_Invoice|WPInv_Subscription $object
95
-	 */
96
-	public function invoice_merge_tags( $merge_tags, $object ) {
97
-
98
-		if ( is_a( $object, 'WPInv_Invoice' ) ) {
99
-			return array_merge(
100
-				$merge_tags,
101
-				$this->get_invoice_merge_tags( $object )
102
-			);
103
-		}
104
-
105
-		if ( is_a( $object, 'WPInv_Subscription' ) ) {
106
-			return array_merge(
107
-				$merge_tags,
108
-				$this->get_invoice_merge_tags( $object->get_parent_payment() )
109
-			);
110
-		}
111
-
112
-		return $merge_tags;
113
-
114
-	}
115
-
116
-	/**
117
-	 * Generates invoice merge tags.
118
-	 *
119
-	 * @param WPInv_Invoice $invoice
120
-	 * @return array
121
-	 */
122
-	public function get_invoice_merge_tags( $invoice ) {
123
-
124
-		// Abort if it does not exist.
125
-		if ( ! $invoice->get_id() ) {
126
-			return array();
127
-		}
128
-
129
-		return array(
130
-			'{name}'                => sanitize_text_field( $invoice->get_user_full_name() ),
131
-			'{full_name}'           => sanitize_text_field( $invoice->get_user_full_name() ),
132
-			'{first_name}'          => sanitize_text_field( $invoice->get_first_name() ),
133
-			'{last_name}'           => sanitize_text_field( $invoice->get_last_name() ),
134
-			'{email}'               => sanitize_email( $invoice->get_email() ),
135
-			'{invoice_number}'      => sanitize_text_field( $invoice->get_number() ),
136
-			'{invoice_currency}'    => sanitize_text_field( $invoice->get_currency() ),
137
-			'{invoice_total}'       => wpinv_price( wpinv_format_amount( $invoice->get_total() ) ),
138
-			'{invoice_link}'        => esc_url( $invoice->get_view_url() ),
139
-			'{invoice_pay_link}'    => esc_url( $invoice->get_checkout_payment_url() ),
140
-			'{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ),
141
-			'{invoice_date}'        => getpaid_format_date_value( $invoice->get_date_created() ),
142
-			'{invoice_due_date}'    => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ),
143
-			'{invoice_quote}'       => sanitize_text_field( $invoice->get_type() ),
144
-			'{invoice_label}'       => sanitize_text_field( ucfirst( $invoice->get_type() ) ),
145
-			'{invoice_description}' => wp_kses_post( $invoice->get_description() ),
146
-			'{subscription_name}'   => wp_kses_post( $invoice->get_subscription_name() ),
147
-			'{is_was}'              => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
148
-		);
149
-
150
-	}
151
-
152
-	/**
153
-	 * Helper function to send an email.
154
-	 *
155
-	 * @param WPInv_Invoice $invoice
156
-	 * @param GetPaid_Notification_Email $email
157
-	 * @param string $type
158
-	 * @param string|array $recipients
159
-	 * @param array $extra_args Extra template args.
160
-	 */
161
-	public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) {
162
-
163
-		do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email );
164
-
165
-		$mailer     = new GetPaid_Notification_Email_Sender();
166
-		$merge_tags = $email->get_merge_tags();
167
-
168
-		$result = $mailer->send(
169
-			apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ),
170
-			$email->add_merge_tags( $email->get_subject(), $merge_tags ),
171
-			$email->get_content( $merge_tags, $extra_args ),
172
-			$email->get_attachments()
173
-		);
174
-
175
-		// Maybe send a copy to the admin.
176
-		if ( $email->include_admin_bcc() ) {
177
-			$mailer->send(
178
-				wpinv_get_admin_email(),
179
-				$email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ),
180
-				$email->get_content( $merge_tags ),
181
-				$email->get_attachments()
182
-			);
183
-		}
184
-
185
-		if ( ! $result ) {
186
-			$invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true );
187
-		}
188
-
189
-		do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email );
190
-
191
-		return $result;
192
-	}
193
-
194
-	/**
195
-	 * Also send emails to any cc users.
196
-	 *
197
-	 * @param array $recipients
198
-	 * @param GetPaid_Notification_Email $email
199
-	 */
200
-	public function filter_email_recipients( $recipients, $email ) {
201
-
202
-		if ( ! $email->is_admin_email() ) {
203
-			$cc = $email->object->get_email_cc();
204
-
205
-			if ( ! empty( $cc ) ) {
206
-				$cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
207
-				$recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
208
-			}
209
-
210
-		}
211
-
212
-		return $recipients;
213
-
214
-	}
215
-
216
-	/**
217
-	 * Sends a new invoice notification.
218
-	 *
219
-	 * @param WPInv_Invoice $invoice
220
-	 */
221
-	public function new_invoice( $invoice ) {
222
-
223
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
224
-		$recipient = wpinv_get_admin_email();
225
-
226
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
227
-
228
-	}
229
-
230
-	/**
231
-	 * Sends a cancelled invoice notification.
232
-	 *
233
-	 * @param WPInv_Invoice $invoice
234
-	 */
235
-	public function cancelled_invoice( $invoice ) {
236
-
237
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
238
-		$recipient = wpinv_get_admin_email();
15
+    /**
16
+     * The array of invoice email actions.
17
+     *
18
+     * @param array
19
+     */
20
+    public $invoice_actions;
21
+
22
+    /**
23
+     * Class constructor
24
+     *
25
+     */
26
+    public function __construct() {
27
+
28
+        $this->invoice_actions = apply_filters(
29
+            'getpaid_notification_email_invoice_triggers',
30
+            array(
31
+                'getpaid_new_invoice'                   => array( 'new_invoice', 'user_invoice' ),
32
+                'getpaid_invoice_status_wpi-cancelled'  => 'cancelled_invoice',
33
+                'getpaid_invoice_status_wpi-failed'     => 'failed_invoice',
34
+                'getpaid_invoice_status_wpi-onhold'     => 'onhold_invoice',
35
+                'getpaid_invoice_status_wpi-processing' => 'processing_invoice',
36
+                'getpaid_invoice_status_publish'        => 'completed_invoice',
37
+                'getpaid_invoice_status_wpi-renewal'    => 'completed_invoice',
38
+                'getpaid_invoice_status_wpi-refunded'   => 'refunded_invoice',
39
+                'getpaid_new_customer_note'             => 'user_note',
40
+                'getpaid_daily_maintenance'             => 'overdue',
41
+            )
42
+        );
43
+
44
+        $this->init_hooks();
45
+
46
+    }
47
+
48
+    /**
49
+     * Registers email hooks.
50
+     */
51
+    public function init_hooks() {
52
+
53
+        add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 );
54
+        add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 );
55
+
56
+        foreach ( $this->invoice_actions as $hook => $email_type ) {
57
+            $this->init_email_type_hook( $hook, $email_type );
58
+        }
59
+    }
60
+
61
+    /**
62
+     * Registers an email hook for an invoice action.
63
+     * 
64
+     * @param string $hook
65
+     * @param string|array $email_type
66
+     */
67
+    public function init_email_type_hook( $hook, $email_type ) {
68
+
69
+        $email_type = wpinv_parse_list( $email_type );
70
+
71
+        foreach ( $email_type as $type ) {
72
+
73
+            $email = new GetPaid_Notification_Email( $type );
74
+
75
+            // Abort if it is not active.
76
+            if ( ! $email->is_active() ) {
77
+                continue;
78
+            }
79
+
80
+            if ( method_exists( $this, $type ) ) {
81
+                add_action( $hook, array( $this, $type ), 100, 2 );
82
+                continue;
83
+            }
84
+
85
+            do_action( 'getpaid_invoice_init_email_type_hook', $type );
86
+        }
87
+
88
+    }
89
+
90
+    /**
91
+     * Filters invoice merge tags.
92
+     *
93
+     * @param array $merge_tags
94
+     * @param mixed|WPInv_Invoice|WPInv_Subscription $object
95
+     */
96
+    public function invoice_merge_tags( $merge_tags, $object ) {
97
+
98
+        if ( is_a( $object, 'WPInv_Invoice' ) ) {
99
+            return array_merge(
100
+                $merge_tags,
101
+                $this->get_invoice_merge_tags( $object )
102
+            );
103
+        }
104
+
105
+        if ( is_a( $object, 'WPInv_Subscription' ) ) {
106
+            return array_merge(
107
+                $merge_tags,
108
+                $this->get_invoice_merge_tags( $object->get_parent_payment() )
109
+            );
110
+        }
111
+
112
+        return $merge_tags;
113
+
114
+    }
115
+
116
+    /**
117
+     * Generates invoice merge tags.
118
+     *
119
+     * @param WPInv_Invoice $invoice
120
+     * @return array
121
+     */
122
+    public function get_invoice_merge_tags( $invoice ) {
123
+
124
+        // Abort if it does not exist.
125
+        if ( ! $invoice->get_id() ) {
126
+            return array();
127
+        }
128
+
129
+        return array(
130
+            '{name}'                => sanitize_text_field( $invoice->get_user_full_name() ),
131
+            '{full_name}'           => sanitize_text_field( $invoice->get_user_full_name() ),
132
+            '{first_name}'          => sanitize_text_field( $invoice->get_first_name() ),
133
+            '{last_name}'           => sanitize_text_field( $invoice->get_last_name() ),
134
+            '{email}'               => sanitize_email( $invoice->get_email() ),
135
+            '{invoice_number}'      => sanitize_text_field( $invoice->get_number() ),
136
+            '{invoice_currency}'    => sanitize_text_field( $invoice->get_currency() ),
137
+            '{invoice_total}'       => wpinv_price( wpinv_format_amount( $invoice->get_total() ) ),
138
+            '{invoice_link}'        => esc_url( $invoice->get_view_url() ),
139
+            '{invoice_pay_link}'    => esc_url( $invoice->get_checkout_payment_url() ),
140
+            '{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ),
141
+            '{invoice_date}'        => getpaid_format_date_value( $invoice->get_date_created() ),
142
+            '{invoice_due_date}'    => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ),
143
+            '{invoice_quote}'       => sanitize_text_field( $invoice->get_type() ),
144
+            '{invoice_label}'       => sanitize_text_field( ucfirst( $invoice->get_type() ) ),
145
+            '{invoice_description}' => wp_kses_post( $invoice->get_description() ),
146
+            '{subscription_name}'   => wp_kses_post( $invoice->get_subscription_name() ),
147
+            '{is_was}'              => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
148
+        );
149
+
150
+    }
151
+
152
+    /**
153
+     * Helper function to send an email.
154
+     *
155
+     * @param WPInv_Invoice $invoice
156
+     * @param GetPaid_Notification_Email $email
157
+     * @param string $type
158
+     * @param string|array $recipients
159
+     * @param array $extra_args Extra template args.
160
+     */
161
+    public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) {
162
+
163
+        do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email );
164
+
165
+        $mailer     = new GetPaid_Notification_Email_Sender();
166
+        $merge_tags = $email->get_merge_tags();
167
+
168
+        $result = $mailer->send(
169
+            apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ),
170
+            $email->add_merge_tags( $email->get_subject(), $merge_tags ),
171
+            $email->get_content( $merge_tags, $extra_args ),
172
+            $email->get_attachments()
173
+        );
174
+
175
+        // Maybe send a copy to the admin.
176
+        if ( $email->include_admin_bcc() ) {
177
+            $mailer->send(
178
+                wpinv_get_admin_email(),
179
+                $email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ),
180
+                $email->get_content( $merge_tags ),
181
+                $email->get_attachments()
182
+            );
183
+        }
184
+
185
+        if ( ! $result ) {
186
+            $invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true );
187
+        }
188
+
189
+        do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email );
190
+
191
+        return $result;
192
+    }
193
+
194
+    /**
195
+     * Also send emails to any cc users.
196
+     *
197
+     * @param array $recipients
198
+     * @param GetPaid_Notification_Email $email
199
+     */
200
+    public function filter_email_recipients( $recipients, $email ) {
201
+
202
+        if ( ! $email->is_admin_email() ) {
203
+            $cc = $email->object->get_email_cc();
204
+
205
+            if ( ! empty( $cc ) ) {
206
+                $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
207
+                $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
208
+            }
209
+
210
+        }
211
+
212
+        return $recipients;
213
+
214
+    }
215
+
216
+    /**
217
+     * Sends a new invoice notification.
218
+     *
219
+     * @param WPInv_Invoice $invoice
220
+     */
221
+    public function new_invoice( $invoice ) {
222
+
223
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
224
+        $recipient = wpinv_get_admin_email();
225
+
226
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
227
+
228
+    }
229
+
230
+    /**
231
+     * Sends a cancelled invoice notification.
232
+     *
233
+     * @param WPInv_Invoice $invoice
234
+     */
235
+    public function cancelled_invoice( $invoice ) {
236
+
237
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
238
+        $recipient = wpinv_get_admin_email();
239 239
 
240
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
240
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
241 241
 
242
-	}
242
+    }
243 243
 
244
-	/**
245
-	 * Sends a failed invoice notification.
246
-	 *
247
-	 * @param WPInv_Invoice $invoice
248
-	 */
249
-	public function failed_invoice( $invoice ) {
244
+    /**
245
+     * Sends a failed invoice notification.
246
+     *
247
+     * @param WPInv_Invoice $invoice
248
+     */
249
+    public function failed_invoice( $invoice ) {
250 250
 
251
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
252
-		$recipient = wpinv_get_admin_email();
253
-
254
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
251
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
252
+        $recipient = wpinv_get_admin_email();
253
+
254
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
255 255
 
256
-	}
256
+    }
257 257
 
258
-	/**
259
-	 * Sends a notification whenever an invoice is put on hold.
260
-	 *
261
-	 * @param WPInv_Invoice $invoice
262
-	 */
263
-	public function onhold_invoice( $invoice ) {
258
+    /**
259
+     * Sends a notification whenever an invoice is put on hold.
260
+     *
261
+     * @param WPInv_Invoice $invoice
262
+     */
263
+    public function onhold_invoice( $invoice ) {
264 264
 
265
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
266
-		$recipient = $invoice->get_email();
265
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
266
+        $recipient = $invoice->get_email();
267 267
 
268
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
268
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
269 269
 
270
-	}
270
+    }
271 271
 
272
-	/**
273
-	 * Sends a notification whenever an invoice is marked as processing payment.
274
-	 *
275
-	 * @param WPInv_Invoice $invoice
276
-	 */
277
-	public function processing_invoice( $invoice ) {
272
+    /**
273
+     * Sends a notification whenever an invoice is marked as processing payment.
274
+     *
275
+     * @param WPInv_Invoice $invoice
276
+     */
277
+    public function processing_invoice( $invoice ) {
278 278
 
279
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
280
-		$recipient = $invoice->get_email();
279
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
280
+        $recipient = $invoice->get_email();
281 281
 
282
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
282
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
283 283
 
284
-	}
284
+    }
285 285
 
286
-	/**
287
-	 * Sends a notification whenever an invoice is paid.
288
-	 *
289
-	 * @param WPInv_Invoice $invoice
290
-	 */
291
-	public function completed_invoice( $invoice ) {
286
+    /**
287
+     * Sends a notification whenever an invoice is paid.
288
+     *
289
+     * @param WPInv_Invoice $invoice
290
+     */
291
+    public function completed_invoice( $invoice ) {
292 292
 
293
-		// (Maybe) abort if it is a renewal invoice.
294
-		if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) {
295
-			return;
296
-		}
293
+        // (Maybe) abort if it is a renewal invoice.
294
+        if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) {
295
+            return;
296
+        }
297 297
 
298
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
299
-		$recipient = $invoice->get_email();
298
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
299
+        $recipient = $invoice->get_email();
300 300
 
301
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
301
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
302 302
 
303
-	}
303
+    }
304 304
 
305
-	/**
306
-	 * Sends a notification whenever an invoice is refunded.
307
-	 *
308
-	 * @param WPInv_Invoice $invoice
309
-	 */
310
-	public function refunded_invoice( $invoice ) {
305
+    /**
306
+     * Sends a notification whenever an invoice is refunded.
307
+     *
308
+     * @param WPInv_Invoice $invoice
309
+     */
310
+    public function refunded_invoice( $invoice ) {
311 311
 
312
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
313
-		$recipient = $invoice->get_email();
312
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
313
+        $recipient = $invoice->get_email();
314 314
 
315
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
315
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
316 316
 
317
-	}
317
+    }
318 318
 
319
-	/**
320
-	 * Notifies a user about new invoices
321
-	 *
322
-	 * @param WPInv_Invoice $invoice
323
-	 */
324
-	public function user_invoice( $invoice ) {
319
+    /**
320
+     * Notifies a user about new invoices
321
+     *
322
+     * @param WPInv_Invoice $invoice
323
+     */
324
+    public function user_invoice( $invoice ) {
325 325
 
326
-		// Only send this email for invoices created via the admin page.
327
-		if ( $this->is_payment_form_invoice( $invoice->get_id() ) ) {
328
-			return;
329
-		}
326
+        // Only send this email for invoices created via the admin page.
327
+        if ( $this->is_payment_form_invoice( $invoice->get_id() ) ) {
328
+            return;
329
+        }
330 330
 
331
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
332
-		$recipient = $invoice->get_email();
331
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
332
+        $recipient = $invoice->get_email();
333 333
 
334
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
334
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
335 335
 
336
-	}
336
+    }
337 337
 
338
-	/**
339
-	 * Checks if an invoice is a payment form invoice.
340
-	 *
341
-	 * @param int $invoice
342
-	 * @return bool
343
-	 */
344
-	public function is_payment_form_invoice( $invoice ) {
345
-		return empty( $_GET['getpaid-admin-action'] ) && 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true );
346
-	}
338
+    /**
339
+     * Checks if an invoice is a payment form invoice.
340
+     *
341
+     * @param int $invoice
342
+     * @return bool
343
+     */
344
+    public function is_payment_form_invoice( $invoice ) {
345
+        return empty( $_GET['getpaid-admin-action'] ) && 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true );
346
+    }
347 347
 
348
-	/**
349
-	 * Notifies admin about new invoice notes
350
-	 *
351
-	 * @param WPInv_Invoice $invoice
352
-	 * @param string $note
353
-	 */
354
-	public function user_note( $invoice, $note ) {
348
+    /**
349
+     * Notifies admin about new invoice notes
350
+     *
351
+     * @param WPInv_Invoice $invoice
352
+     * @param string $note
353
+     */
354
+    public function user_note( $invoice, $note ) {
355 355
 
356
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
357
-		$recipient = $invoice->get_email();
358
-
359
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) );
360
-
361
-	}
356
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
357
+        $recipient = $invoice->get_email();
358
+
359
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) );
360
+
361
+    }
362 362
 
363
-	/**
364
-	 * (Force) Sends overdue notices.
365
-	 *
366
-	 * @param WPInv_Invoice $invoice
367
-	 */
368
-	public function force_send_overdue_notice( $invoice ) {
369
-		$email = new GetPaid_Notification_Email( 'overdue', $invoice );
370
-		return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() );
371
-	}
372
-
373
-	/**
374
-	 * Sends overdue notices.
375
-	 *
376
-	 * @TODO: Create an invoices query class.
377
-	 */
378
-	public function overdue() {
379
-		global $wpdb;
380
-
381
-		$email = new GetPaid_Notification_Email( __FUNCTION__ );
382
-
383
-		// Fetch reminder days.
384
-		$reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
385
-
386
-		// Abort if non is set.
387
-		if ( empty( $reminder_days ) ) {
388
-			return;
389
-		}
390
-
391
-		// Retrieve date query.
392
-		$date_query = $this->get_date_query( $reminder_days );
393
-
394
-		// Invoices table.
395
-		$table = $wpdb->prefix . 'getpaid_invoices';
396
-
397
-		// Fetch invoices.
398
-		$invoices  = $wpdb->get_col(
399
-			"SELECT posts.ID FROM $wpdb->posts as posts
363
+    /**
364
+     * (Force) Sends overdue notices.
365
+     *
366
+     * @param WPInv_Invoice $invoice
367
+     */
368
+    public function force_send_overdue_notice( $invoice ) {
369
+        $email = new GetPaid_Notification_Email( 'overdue', $invoice );
370
+        return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() );
371
+    }
372
+
373
+    /**
374
+     * Sends overdue notices.
375
+     *
376
+     * @TODO: Create an invoices query class.
377
+     */
378
+    public function overdue() {
379
+        global $wpdb;
380
+
381
+        $email = new GetPaid_Notification_Email( __FUNCTION__ );
382
+
383
+        // Fetch reminder days.
384
+        $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
385
+
386
+        // Abort if non is set.
387
+        if ( empty( $reminder_days ) ) {
388
+            return;
389
+        }
390
+
391
+        // Retrieve date query.
392
+        $date_query = $this->get_date_query( $reminder_days );
393
+
394
+        // Invoices table.
395
+        $table = $wpdb->prefix . 'getpaid_invoices';
396
+
397
+        // Fetch invoices.
398
+        $invoices  = $wpdb->get_col(
399
+            "SELECT posts.ID FROM $wpdb->posts as posts
400 400
 			LEFT JOIN $table as invoices ON invoices.post_id = posts.ID
401 401
 			WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query");
402 402
 
403
-		foreach ( $invoices as $invoice ) {
403
+        foreach ( $invoices as $invoice ) {
404 404
 
405
-			// Only send this email for invoices created via the admin page.
406
-			if ( ! $this->is_payment_form_invoice( $invoice ) ) {
407
-				$invoice       = new WPInv_Invoice( $invoice );
408
-				$email->object = $invoice;
405
+            // Only send this email for invoices created via the admin page.
406
+            if ( ! $this->is_payment_form_invoice( $invoice ) ) {
407
+                $invoice       = new WPInv_Invoice( $invoice );
408
+                $email->object = $invoice;
409 409
 
410
-				if ( $invoice->needs_payment() ) {
411
-					$this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() );
412
-				}
410
+                if ( $invoice->needs_payment() ) {
411
+                    $this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() );
412
+                }
413 413
 
414
-			}
414
+            }
415 415
 
416
-		}
416
+        }
417 417
 
418
-	}
418
+    }
419 419
 
420
-	/**
421
-	 * Calculates the date query for an invoices query
422
-	 *
423
-	 * @param array $reminder_days
424
-	 * @return string
425
-	 */
426
-	public function get_date_query( $reminder_days ) {
420
+    /**
421
+     * Calculates the date query for an invoices query
422
+     *
423
+     * @param array $reminder_days
424
+     * @return string
425
+     */
426
+    public function get_date_query( $reminder_days ) {
427 427
 
428
-		$date_query = array(
429
-			'relation'  => 'OR'
430
-		);
428
+        $date_query = array(
429
+            'relation'  => 'OR'
430
+        );
431 431
 
432
-		foreach ( $reminder_days as $days ) {
433
-			$date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) );
432
+        foreach ( $reminder_days as $days ) {
433
+            $date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) );
434 434
 
435
-			$date_query[] = array(
436
-				'year'  => $date['year'],
437
-				'month' => $date['month'],
438
-				'day'   => $date['day'],
439
-			);
435
+            $date_query[] = array(
436
+                'year'  => $date['year'],
437
+                'month' => $date['month'],
438
+                'day'   => $date['day'],
439
+            );
440 440
 
441
-		}
441
+        }
442 442
 
443
-		$date_query = new WP_Date_Query( $date_query, 'invoices.due_date' );
443
+        $date_query = new WP_Date_Query( $date_query, 'invoices.due_date' );
444 444
 
445
-		return $date_query->get_sql();
445
+        return $date_query->get_sql();
446 446
 
447
-	}
447
+    }
448 448
 
449 449
 }
Please login to merge, or discard this patch.
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * This class handles invoice notificaiton emails.
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 		$this->invoice_actions = apply_filters(
29 29
 			'getpaid_notification_email_invoice_triggers',
30 30
 			array(
31
-				'getpaid_new_invoice'                   => array( 'new_invoice', 'user_invoice' ),
31
+				'getpaid_new_invoice'                   => array('new_invoice', 'user_invoice'),
32 32
 				'getpaid_invoice_status_wpi-cancelled'  => 'cancelled_invoice',
33 33
 				'getpaid_invoice_status_wpi-failed'     => 'failed_invoice',
34 34
 				'getpaid_invoice_status_wpi-onhold'     => 'onhold_invoice',
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	public function init_hooks() {
52 52
 
53
-		add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 );
54
-		add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 );
53
+		add_filter('getpaid_get_email_merge_tags', array($this, 'invoice_merge_tags'), 10, 2);
54
+		add_filter('getpaid_invoice_email_recipients', array($this, 'filter_email_recipients'), 10, 2);
55 55
 
56
-		foreach ( $this->invoice_actions as $hook => $email_type ) {
57
-			$this->init_email_type_hook( $hook, $email_type );
56
+		foreach ($this->invoice_actions as $hook => $email_type) {
57
+			$this->init_email_type_hook($hook, $email_type);
58 58
 		}
59 59
 	}
60 60
 
@@ -64,25 +64,25 @@  discard block
 block discarded – undo
64 64
 	 * @param string $hook
65 65
 	 * @param string|array $email_type
66 66
 	 */
67
-	public function init_email_type_hook( $hook, $email_type ) {
67
+	public function init_email_type_hook($hook, $email_type) {
68 68
 
69
-		$email_type = wpinv_parse_list( $email_type );
69
+		$email_type = wpinv_parse_list($email_type);
70 70
 
71
-		foreach ( $email_type as $type ) {
71
+		foreach ($email_type as $type) {
72 72
 
73
-			$email = new GetPaid_Notification_Email( $type );
73
+			$email = new GetPaid_Notification_Email($type);
74 74
 
75 75
 			// Abort if it is not active.
76
-			if ( ! $email->is_active() ) {
76
+			if (!$email->is_active()) {
77 77
 				continue;
78 78
 			}
79 79
 
80
-			if ( method_exists( $this, $type ) ) {
81
-				add_action( $hook, array( $this, $type ), 100, 2 );
80
+			if (method_exists($this, $type)) {
81
+				add_action($hook, array($this, $type), 100, 2);
82 82
 				continue;
83 83
 			}
84 84
 
85
-			do_action( 'getpaid_invoice_init_email_type_hook', $type );
85
+			do_action('getpaid_invoice_init_email_type_hook', $type);
86 86
 		}
87 87
 
88 88
 	}
@@ -93,19 +93,19 @@  discard block
 block discarded – undo
93 93
 	 * @param array $merge_tags
94 94
 	 * @param mixed|WPInv_Invoice|WPInv_Subscription $object
95 95
 	 */
96
-	public function invoice_merge_tags( $merge_tags, $object ) {
96
+	public function invoice_merge_tags($merge_tags, $object) {
97 97
 
98
-		if ( is_a( $object, 'WPInv_Invoice' ) ) {
98
+		if (is_a($object, 'WPInv_Invoice')) {
99 99
 			return array_merge(
100 100
 				$merge_tags,
101
-				$this->get_invoice_merge_tags( $object )
101
+				$this->get_invoice_merge_tags($object)
102 102
 			);
103 103
 		}
104 104
 
105
-		if ( is_a( $object, 'WPInv_Subscription' ) ) {
105
+		if (is_a($object, 'WPInv_Subscription')) {
106 106
 			return array_merge(
107 107
 				$merge_tags,
108
-				$this->get_invoice_merge_tags( $object->get_parent_payment() )
108
+				$this->get_invoice_merge_tags($object->get_parent_payment())
109 109
 			);
110 110
 		}
111 111
 
@@ -119,32 +119,32 @@  discard block
 block discarded – undo
119 119
 	 * @param WPInv_Invoice $invoice
120 120
 	 * @return array
121 121
 	 */
122
-	public function get_invoice_merge_tags( $invoice ) {
122
+	public function get_invoice_merge_tags($invoice) {
123 123
 
124 124
 		// Abort if it does not exist.
125
-		if ( ! $invoice->get_id() ) {
125
+		if (!$invoice->get_id()) {
126 126
 			return array();
127 127
 		}
128 128
 
129 129
 		return array(
130
-			'{name}'                => sanitize_text_field( $invoice->get_user_full_name() ),
131
-			'{full_name}'           => sanitize_text_field( $invoice->get_user_full_name() ),
132
-			'{first_name}'          => sanitize_text_field( $invoice->get_first_name() ),
133
-			'{last_name}'           => sanitize_text_field( $invoice->get_last_name() ),
134
-			'{email}'               => sanitize_email( $invoice->get_email() ),
135
-			'{invoice_number}'      => sanitize_text_field( $invoice->get_number() ),
136
-			'{invoice_currency}'    => sanitize_text_field( $invoice->get_currency() ),
137
-			'{invoice_total}'       => wpinv_price( wpinv_format_amount( $invoice->get_total() ) ),
138
-			'{invoice_link}'        => esc_url( $invoice->get_view_url() ),
139
-			'{invoice_pay_link}'    => esc_url( $invoice->get_checkout_payment_url() ),
140
-			'{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ),
141
-			'{invoice_date}'        => getpaid_format_date_value( $invoice->get_date_created() ),
142
-			'{invoice_due_date}'    => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ),
143
-			'{invoice_quote}'       => sanitize_text_field( $invoice->get_type() ),
144
-			'{invoice_label}'       => sanitize_text_field( ucfirst( $invoice->get_type() ) ),
145
-			'{invoice_description}' => wp_kses_post( $invoice->get_description() ),
146
-			'{subscription_name}'   => wp_kses_post( $invoice->get_subscription_name() ),
147
-			'{is_was}'              => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
130
+			'{name}'                => sanitize_text_field($invoice->get_user_full_name()),
131
+			'{full_name}'           => sanitize_text_field($invoice->get_user_full_name()),
132
+			'{first_name}'          => sanitize_text_field($invoice->get_first_name()),
133
+			'{last_name}'           => sanitize_text_field($invoice->get_last_name()),
134
+			'{email}'               => sanitize_email($invoice->get_email()),
135
+			'{invoice_number}'      => sanitize_text_field($invoice->get_number()),
136
+			'{invoice_currency}'    => sanitize_text_field($invoice->get_currency()),
137
+			'{invoice_total}'       => wpinv_price(wpinv_format_amount($invoice->get_total())),
138
+			'{invoice_link}'        => esc_url($invoice->get_view_url()),
139
+			'{invoice_pay_link}'    => esc_url($invoice->get_checkout_payment_url()),
140
+			'{invoice_receipt_link}'=> esc_url($invoice->get_receipt_url()),
141
+			'{invoice_date}'        => getpaid_format_date_value($invoice->get_date_created()),
142
+			'{invoice_due_date}'    => getpaid_format_date_value($invoice->get_due_date(), __('on receipt', 'invoicing')),
143
+			'{invoice_quote}'       => sanitize_text_field($invoice->get_type()),
144
+			'{invoice_label}'       => sanitize_text_field(ucfirst($invoice->get_type())),
145
+			'{invoice_description}' => wp_kses_post($invoice->get_description()),
146
+			'{subscription_name}'   => wp_kses_post($invoice->get_subscription_name()),
147
+			'{is_was}'              => strtotime($invoice->get_due_date()) < current_time('timestamp') ? __('was', 'invoicing') : __('is', 'invoicing'),
148 148
 		);
149 149
 
150 150
 	}
@@ -158,35 +158,35 @@  discard block
 block discarded – undo
158 158
 	 * @param string|array $recipients
159 159
 	 * @param array $extra_args Extra template args.
160 160
 	 */
161
-	public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) {
161
+	public function send_email($invoice, $email, $type, $recipients, $extra_args = array()) {
162 162
 
163
-		do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email );
163
+		do_action('getpaid_before_send_invoice_notification', $type, $invoice, $email);
164 164
 
165 165
 		$mailer     = new GetPaid_Notification_Email_Sender();
166 166
 		$merge_tags = $email->get_merge_tags();
167 167
 
168 168
 		$result = $mailer->send(
169
-			apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ),
170
-			$email->add_merge_tags( $email->get_subject(), $merge_tags ),
171
-			$email->get_content( $merge_tags, $extra_args ),
169
+			apply_filters('getpaid_invoice_email_recipients', wpinv_parse_list($recipients), $email),
170
+			$email->add_merge_tags($email->get_subject(), $merge_tags),
171
+			$email->get_content($merge_tags, $extra_args),
172 172
 			$email->get_attachments()
173 173
 		);
174 174
 
175 175
 		// Maybe send a copy to the admin.
176
-		if ( $email->include_admin_bcc() ) {
176
+		if ($email->include_admin_bcc()) {
177 177
 			$mailer->send(
178 178
 				wpinv_get_admin_email(),
179
-				$email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ),
180
-				$email->get_content( $merge_tags ),
179
+				$email->add_merge_tags($email->get_subject() . __(' - ADMIN BCC COPY', 'invoicing'), $merge_tags),
180
+				$email->get_content($merge_tags),
181 181
 				$email->get_attachments()
182 182
 			);
183 183
 		}
184 184
 
185
-		if ( ! $result ) {
186
-			$invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true );
185
+		if (!$result) {
186
+			$invoice->add_note(sprintf(__('Failed sending %s notification email.', 'invoicing'), sanitize_key($type)), false, false, true);
187 187
 		}
188 188
 
189
-		do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email );
189
+		do_action('getpaid_after_send_invoice_notification', $type, $invoice, $email);
190 190
 
191 191
 		return $result;
192 192
 	}
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
 	 * @param array $recipients
198 198
 	 * @param GetPaid_Notification_Email $email
199 199
 	 */
200
-	public function filter_email_recipients( $recipients, $email ) {
200
+	public function filter_email_recipients($recipients, $email) {
201 201
 
202
-		if ( ! $email->is_admin_email() ) {
202
+		if (!$email->is_admin_email()) {
203 203
 			$cc = $email->object->get_email_cc();
204 204
 
205
-			if ( ! empty( $cc ) ) {
206
-				$cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
207
-				$recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
205
+			if (!empty($cc)) {
206
+				$cc = array_map('sanitize_email', wpinv_parse_list($cc));
207
+				$recipients = array_filter(array_unique(array_merge($recipients, $cc)));
208 208
 			}
209 209
 
210 210
 		}
@@ -218,12 +218,12 @@  discard block
 block discarded – undo
218 218
 	 *
219 219
 	 * @param WPInv_Invoice $invoice
220 220
 	 */
221
-	public function new_invoice( $invoice ) {
221
+	public function new_invoice($invoice) {
222 222
 
223
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
223
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
224 224
 		$recipient = wpinv_get_admin_email();
225 225
 
226
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
226
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
227 227
 
228 228
 	}
229 229
 
@@ -232,12 +232,12 @@  discard block
 block discarded – undo
232 232
 	 *
233 233
 	 * @param WPInv_Invoice $invoice
234 234
 	 */
235
-	public function cancelled_invoice( $invoice ) {
235
+	public function cancelled_invoice($invoice) {
236 236
 
237
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
237
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
238 238
 		$recipient = wpinv_get_admin_email();
239 239
 
240
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
240
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
241 241
 
242 242
 	}
243 243
 
@@ -246,12 +246,12 @@  discard block
 block discarded – undo
246 246
 	 *
247 247
 	 * @param WPInv_Invoice $invoice
248 248
 	 */
249
-	public function failed_invoice( $invoice ) {
249
+	public function failed_invoice($invoice) {
250 250
 
251
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
251
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
252 252
 		$recipient = wpinv_get_admin_email();
253 253
 
254
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
254
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
255 255
 
256 256
 	}
257 257
 
@@ -260,12 +260,12 @@  discard block
 block discarded – undo
260 260
 	 *
261 261
 	 * @param WPInv_Invoice $invoice
262 262
 	 */
263
-	public function onhold_invoice( $invoice ) {
263
+	public function onhold_invoice($invoice) {
264 264
 
265
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
265
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
266 266
 		$recipient = $invoice->get_email();
267 267
 
268
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
268
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
269 269
 
270 270
 	}
271 271
 
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @param WPInv_Invoice $invoice
276 276
 	 */
277
-	public function processing_invoice( $invoice ) {
277
+	public function processing_invoice($invoice) {
278 278
 
279
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
279
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
280 280
 		$recipient = $invoice->get_email();
281 281
 
282
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
282
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
283 283
 
284 284
 	}
285 285
 
@@ -288,17 +288,17 @@  discard block
 block discarded – undo
288 288
 	 *
289 289
 	 * @param WPInv_Invoice $invoice
290 290
 	 */
291
-	public function completed_invoice( $invoice ) {
291
+	public function completed_invoice($invoice) {
292 292
 
293 293
 		// (Maybe) abort if it is a renewal invoice.
294
-		if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) {
294
+		if ($invoice->is_renewal() && !wpinv_get_option('email_completed_invoice_renewal_active', false)) {
295 295
 			return;
296 296
 		}
297 297
 
298
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
298
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
299 299
 		$recipient = $invoice->get_email();
300 300
 
301
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
301
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
302 302
 
303 303
 	}
304 304
 
@@ -307,12 +307,12 @@  discard block
 block discarded – undo
307 307
 	 *
308 308
 	 * @param WPInv_Invoice $invoice
309 309
 	 */
310
-	public function refunded_invoice( $invoice ) {
310
+	public function refunded_invoice($invoice) {
311 311
 
312
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
312
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
313 313
 		$recipient = $invoice->get_email();
314 314
 
315
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
315
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
316 316
 
317 317
 	}
318 318
 
@@ -321,17 +321,17 @@  discard block
 block discarded – undo
321 321
 	 *
322 322
 	 * @param WPInv_Invoice $invoice
323 323
 	 */
324
-	public function user_invoice( $invoice ) {
324
+	public function user_invoice($invoice) {
325 325
 
326 326
 		// Only send this email for invoices created via the admin page.
327
-		if ( $this->is_payment_form_invoice( $invoice->get_id() ) ) {
327
+		if ($this->is_payment_form_invoice($invoice->get_id())) {
328 328
 			return;
329 329
 		}
330 330
 
331
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
331
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
332 332
 		$recipient = $invoice->get_email();
333 333
 
334
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
334
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
335 335
 
336 336
 	}
337 337
 
@@ -341,8 +341,8 @@  discard block
 block discarded – undo
341 341
 	 * @param int $invoice
342 342
 	 * @return bool
343 343
 	 */
344
-	public function is_payment_form_invoice( $invoice ) {
345
-		return empty( $_GET['getpaid-admin-action'] ) && 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true );
344
+	public function is_payment_form_invoice($invoice) {
345
+		return empty($_GET['getpaid-admin-action']) && 'payment_form' == get_post_meta($invoice, 'wpinv_created_via', true);
346 346
 	}
347 347
 
348 348
 	/**
@@ -351,12 +351,12 @@  discard block
 block discarded – undo
351 351
 	 * @param WPInv_Invoice $invoice
352 352
 	 * @param string $note
353 353
 	 */
354
-	public function user_note( $invoice, $note ) {
354
+	public function user_note($invoice, $note) {
355 355
 
356
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
356
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
357 357
 		$recipient = $invoice->get_email();
358 358
 
359
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) );
359
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient, array('customer_note' => $note));
360 360
 
361 361
 	}
362 362
 
@@ -365,9 +365,9 @@  discard block
 block discarded – undo
365 365
 	 *
366 366
 	 * @param WPInv_Invoice $invoice
367 367
 	 */
368
-	public function force_send_overdue_notice( $invoice ) {
369
-		$email = new GetPaid_Notification_Email( 'overdue', $invoice );
370
-		return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() );
368
+	public function force_send_overdue_notice($invoice) {
369
+		$email = new GetPaid_Notification_Email('overdue', $invoice);
370
+		return $this->send_email($invoice, $email, 'overdue', $invoice->get_email());
371 371
 	}
372 372
 
373 373
 	/**
@@ -378,37 +378,37 @@  discard block
 block discarded – undo
378 378
 	public function overdue() {
379 379
 		global $wpdb;
380 380
 
381
-		$email = new GetPaid_Notification_Email( __FUNCTION__ );
381
+		$email = new GetPaid_Notification_Email(__FUNCTION__);
382 382
 
383 383
 		// Fetch reminder days.
384
-		$reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
384
+		$reminder_days = array_unique(wp_parse_id_list($email->get_option('days')));
385 385
 
386 386
 		// Abort if non is set.
387
-		if ( empty( $reminder_days ) ) {
387
+		if (empty($reminder_days)) {
388 388
 			return;
389 389
 		}
390 390
 
391 391
 		// Retrieve date query.
392
-		$date_query = $this->get_date_query( $reminder_days );
392
+		$date_query = $this->get_date_query($reminder_days);
393 393
 
394 394
 		// Invoices table.
395 395
 		$table = $wpdb->prefix . 'getpaid_invoices';
396 396
 
397 397
 		// Fetch invoices.
398
-		$invoices  = $wpdb->get_col(
398
+		$invoices = $wpdb->get_col(
399 399
 			"SELECT posts.ID FROM $wpdb->posts as posts
400 400
 			LEFT JOIN $table as invoices ON invoices.post_id = posts.ID
401 401
 			WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query");
402 402
 
403
-		foreach ( $invoices as $invoice ) {
403
+		foreach ($invoices as $invoice) {
404 404
 
405 405
 			// Only send this email for invoices created via the admin page.
406
-			if ( ! $this->is_payment_form_invoice( $invoice ) ) {
407
-				$invoice       = new WPInv_Invoice( $invoice );
406
+			if (!$this->is_payment_form_invoice($invoice)) {
407
+				$invoice       = new WPInv_Invoice($invoice);
408 408
 				$email->object = $invoice;
409 409
 
410
-				if ( $invoice->needs_payment() ) {
411
-					$this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() );
410
+				if ($invoice->needs_payment()) {
411
+					$this->send_email($invoice, $email, __FUNCTION__, $invoice->get_email());
412 412
 				}
413 413
 
414 414
 			}
@@ -423,14 +423,14 @@  discard block
 block discarded – undo
423 423
 	 * @param array $reminder_days
424 424
 	 * @return string
425 425
 	 */
426
-	public function get_date_query( $reminder_days ) {
426
+	public function get_date_query($reminder_days) {
427 427
 
428 428
 		$date_query = array(
429 429
 			'relation'  => 'OR'
430 430
 		);
431 431
 
432
-		foreach ( $reminder_days as $days ) {
433
-			$date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) );
432
+		foreach ($reminder_days as $days) {
433
+			$date = date_parse(date('Y-m-d', strtotime("-$days days", current_time('timestamp'))));
434 434
 
435 435
 			$date_query[] = array(
436 436
 				'year'  => $date['year'],
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 
441 441
 		}
442 442
 
443
-		$date_query = new WP_Date_Query( $date_query, 'invoices.due_date' );
443
+		$date_query = new WP_Date_Query($date_query, 'invoices.due_date');
444 444
 
445 445
 		return $date_query->get_sql();
446 446
 
Please login to merge, or discard this patch.
includes/class-wpinv-ajax.php 1 patch
Spacing   +326 added lines, -326 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
  
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * WPInv_Ajax class.
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 	 * Hook in ajax handlers.
18 18
 	 */
19 19
 	public static function init() {
20
-		add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
-		add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
20
+		add_action('init', array(__CLASS__, 'define_ajax'), 0);
21
+		add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0);
22 22
 		self::add_ajax_events();
23 23
     }
24 24
 
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public static function define_ajax() {
29 29
 
30
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
-			getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
-			getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
-			if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
-				/** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
30
+		if (!empty($_GET['wpinv-ajax'])) {
31
+			getpaid_maybe_define_constant('DOING_AJAX', true);
32
+			getpaid_maybe_define_constant('WPInv_DOING_AJAX', true);
33
+			if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) {
34
+				/** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0);
35 35
 			}
36 36
 			$GLOBALS['wpdb']->hide_errors();
37 37
 		}
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 	 * @since 1.0.18
45 45
 	 */
46 46
 	private static function wpinv_ajax_headers() {
47
-		if ( ! headers_sent() ) {
47
+		if (!headers_sent()) {
48 48
 			send_origin_headers();
49 49
 			send_nosniff_header();
50 50
 			nocache_headers();
51
-			header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
-			header( 'X-Robots-Tag: noindex' );
53
-			status_header( 200 );
51
+			header('Content-Type: text/html; charset=' . get_option('blog_charset'));
52
+			header('X-Robots-Tag: noindex');
53
+			status_header(200);
54 54
 		}
55 55
     }
56 56
     
@@ -60,16 +60,16 @@  discard block
 block discarded – undo
60 60
 	public static function do_wpinv_ajax() {
61 61
 		global $wp_query;
62 62
 
63
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
-			$wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
63
+		if (!empty($_GET['wpinv-ajax'])) {
64
+			$wp_query->set('wpinv-ajax', sanitize_text_field(wp_unslash($_GET['wpinv-ajax'])));
65 65
 		}
66 66
 
67
-		$action = $wp_query->get( 'wpinv-ajax' );
67
+		$action = $wp_query->get('wpinv-ajax');
68 68
 
69
-		if ( $action ) {
69
+		if ($action) {
70 70
 			self::wpinv_ajax_headers();
71
-			$action = sanitize_text_field( $action );
72
-			do_action( 'wpinv_ajax_' . $action );
71
+			$action = sanitize_text_field($action);
72
+			do_action('wpinv_ajax_' . $action);
73 73
 			wp_die();
74 74
 		}
75 75
 
@@ -103,36 +103,36 @@  discard block
 block discarded – undo
103 103
             'ip_geolocation'              => true,
104 104
         );
105 105
 
106
-        foreach ( $ajax_events as $ajax_event => $nopriv ) {
107
-            add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
108
-            add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
106
+        foreach ($ajax_events as $ajax_event => $nopriv) {
107
+            add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
108
+            add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
109 109
 
110
-            if ( $nopriv ) {
111
-                add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
112
-                add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
113
-                add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) );
110
+            if ($nopriv) {
111
+                add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
112
+                add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
113
+                add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event));
114 114
             }
115 115
         }
116 116
     }
117 117
     
118 118
     public static function add_note() {
119
-        check_ajax_referer( 'add-invoice-note', '_nonce' );
119
+        check_ajax_referer('add-invoice-note', '_nonce');
120 120
 
121
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
121
+        if (!wpinv_current_user_can_manage_invoicing()) {
122 122
             die(-1);
123 123
         }
124 124
 
125
-        $post_id   = absint( $_POST['post_id'] );
126
-        $note      = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) );
127
-        $note_type = sanitize_text_field( $_POST['note_type'] );
125
+        $post_id   = absint($_POST['post_id']);
126
+        $note      = wp_kses_post(trim(stripslashes($_POST['note'])));
127
+        $note_type = sanitize_text_field($_POST['note_type']);
128 128
 
129 129
         $is_customer_note = $note_type == 'customer' ? 1 : 0;
130 130
 
131
-        if ( $post_id > 0 ) {
132
-            $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note );
131
+        if ($post_id > 0) {
132
+            $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note);
133 133
 
134
-            if ( $note_id > 0 && !is_wp_error( $note_id ) ) {
135
-                wpinv_get_invoice_note_line_item( $note_id );
134
+            if ($note_id > 0 && !is_wp_error($note_id)) {
135
+                wpinv_get_invoice_note_line_item($note_id);
136 136
             }
137 137
         }
138 138
 
@@ -140,16 +140,16 @@  discard block
 block discarded – undo
140 140
     }
141 141
 
142 142
     public static function delete_note() {
143
-        check_ajax_referer( 'delete-invoice-note', '_nonce' );
143
+        check_ajax_referer('delete-invoice-note', '_nonce');
144 144
 
145
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
145
+        if (!wpinv_current_user_can_manage_invoicing()) {
146 146
             die(-1);
147 147
         }
148 148
 
149
-        $note_id = (int)$_POST['note_id'];
149
+        $note_id = (int) $_POST['note_id'];
150 150
 
151
-        if ( $note_id > 0 ) {
152
-            wp_delete_comment( $note_id, true );
151
+        if ($note_id > 0) {
152
+            wp_delete_comment($note_id, true);
153 153
         }
154 154
 
155 155
         die();
@@ -167,34 +167,34 @@  discard block
 block discarded – undo
167 167
     public static function get_billing_details() {
168 168
 
169 169
         // Verify nonce.
170
-        check_ajax_referer( 'wpinv-nonce' );
170
+        check_ajax_referer('wpinv-nonce');
171 171
 
172 172
         // Can the user manage the plugin?
173
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
173
+        if (!wpinv_current_user_can_manage_invoicing()) {
174 174
             die(-1);
175 175
         }
176 176
 
177 177
         // Do we have a user id?
178 178
         $user_id = $_GET['user_id'];
179 179
 
180
-        if ( empty( $user_id ) || ! is_numeric( $user_id ) ) {
180
+        if (empty($user_id) || !is_numeric($user_id)) {
181 181
             die(-1);
182 182
         }
183 183
 
184 184
         // Fetch the billing details.
185
-        $billing_details    = wpinv_get_user_address( $user_id );
186
-        $billing_details    = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id );
185
+        $billing_details    = wpinv_get_user_address($user_id);
186
+        $billing_details    = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id);
187 187
 
188 188
         // unset the user id and email.
189
-        $to_ignore = array( 'user_id', 'email' );
189
+        $to_ignore = array('user_id', 'email');
190 190
 
191
-        foreach ( $to_ignore as $key ) {
192
-            if ( isset( $billing_details[ $key ] ) ) {
193
-                unset( $billing_details[ $key ] );
191
+        foreach ($to_ignore as $key) {
192
+            if (isset($billing_details[$key])) {
193
+                unset($billing_details[$key]);
194 194
             }
195 195
         }
196 196
 
197
-        wp_send_json_success( $billing_details );
197
+        wp_send_json_success($billing_details);
198 198
 
199 199
     }
200 200
 
@@ -204,47 +204,47 @@  discard block
 block discarded – undo
204 204
     public static function check_new_user_email() {
205 205
 
206 206
         // Verify nonce.
207
-        check_ajax_referer( 'wpinv-nonce' );
207
+        check_ajax_referer('wpinv-nonce');
208 208
 
209 209
         // Can the user manage the plugin?
210
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
210
+        if (!wpinv_current_user_can_manage_invoicing()) {
211 211
             die(-1);
212 212
         }
213 213
 
214 214
         // We need an email address.
215
-        if ( empty( $_GET['email'] ) ) {
216
-            _e( "Provide the new user's email address", 'invoicing' );
215
+        if (empty($_GET['email'])) {
216
+            _e("Provide the new user's email address", 'invoicing');
217 217
             exit;
218 218
         }
219 219
 
220 220
         // Ensure the email is valid.
221
-        $email = sanitize_text_field( $_GET['email'] );
222
-        if ( ! is_email( $email ) ) {
223
-            _e( 'Invalid email address', 'invoicing' );
221
+        $email = sanitize_text_field($_GET['email']);
222
+        if (!is_email($email)) {
223
+            _e('Invalid email address', 'invoicing');
224 224
             exit;
225 225
         }
226 226
 
227 227
         // And it does not exist.
228
-        if ( email_exists( $email ) ) {
229
-            _e( 'A user with this email address already exists', 'invoicing' );
228
+        if (email_exists($email)) {
229
+            _e('A user with this email address already exists', 'invoicing');
230 230
             exit;
231 231
         }
232 232
 
233
-        wp_send_json_success( true );
233
+        wp_send_json_success(true);
234 234
     }
235 235
     
236 236
     public static function run_tool() {
237
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
238
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
237
+        check_ajax_referer('wpinv-nonce', '_nonce');
238
+        if (!wpinv_current_user_can_manage_invoicing()) {
239 239
             die(-1);
240 240
         }
241 241
         
242
-        $tool = sanitize_text_field( $_POST['tool'] );
242
+        $tool = sanitize_text_field($_POST['tool']);
243 243
         
244
-        do_action( 'wpinv_run_tool' );
244
+        do_action('wpinv_run_tool');
245 245
         
246
-        if ( !empty( $tool ) ) {
247
-            do_action( 'wpinv_tool_' . $tool );
246
+        if (!empty($tool)) {
247
+            do_action('wpinv_tool_' . $tool);
248 248
         }
249 249
     }
250 250
 
@@ -254,30 +254,30 @@  discard block
 block discarded – undo
254 254
     public static function get_payment_form() {
255 255
 
256 256
         // Check nonce.
257
-        if ( ! isset( $_GET['nonce'] ) || ! wp_verify_nonce( $_GET['nonce'], 'getpaid_ajax_form' ) ) {
258
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
257
+        if (!isset($_GET['nonce']) || !wp_verify_nonce($_GET['nonce'], 'getpaid_ajax_form')) {
258
+            _e('Error: Reload the page and try again.', 'invoicing');
259 259
             exit;
260 260
         }
261 261
 
262 262
         // Is the request set up correctly?
263
-		if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
263
+		if (empty($_GET['form']) && empty($_GET['item'])) {
264 264
 			echo aui()->alert(
265 265
 				array(
266 266
 					'type'    => 'warning',
267
-					'content' => __( 'No payment form or item provided', 'invoicing' ),
267
+					'content' => __('No payment form or item provided', 'invoicing'),
268 268
 				)
269 269
             );
270 270
             exit;
271 271
         }
272 272
 
273 273
         // Payment form or button?
274
-		if ( ! empty( $_GET['form'] ) ) {
275
-            getpaid_display_payment_form( $_GET['form'] );
276
-		} else if( ! empty( $_GET['invoice'] ) ) {
277
-		    echo getpaid_display_invoice_payment_form( $_GET['invoice'] );
274
+		if (!empty($_GET['form'])) {
275
+            getpaid_display_payment_form($_GET['form']);
276
+		} else if (!empty($_GET['invoice'])) {
277
+		    echo getpaid_display_invoice_payment_form($_GET['invoice']);
278 278
         } else {
279
-			$items = getpaid_convert_items_to_array( $_GET['item'] );
280
-		    getpaid_display_item_payment_form( $items );
279
+			$items = getpaid_convert_items_to_array($_GET['item']);
280
+		    getpaid_display_item_payment_form($items);
281 281
         }
282 282
 
283 283
         exit;
@@ -293,11 +293,11 @@  discard block
 block discarded – undo
293 293
         global $invoicing;
294 294
 
295 295
         // Check nonce.
296
-        check_ajax_referer( 'getpaid_form_nonce' );
296
+        check_ajax_referer('getpaid_form_nonce');
297 297
 
298 298
         // ... form fields...
299
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
300
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
299
+        if (empty($_POST['getpaid_payment_form_submission'])) {
300
+            _e('Error: Reload the page and try again.', 'invoicing');
301 301
             exit;
302 302
         }
303 303
 
@@ -305,66 +305,66 @@  discard block
 block discarded – undo
305 305
         $submission = new GetPaid_Payment_Form_Submission();
306 306
 
307 307
         // Do we have an error?
308
-        if ( ! empty( $submission->last_error ) ) {
308
+        if (!empty($submission->last_error)) {
309 309
             echo $submission->last_error;
310 310
             exit;
311 311
         }
312 312
 
313 313
         // We need a billing email.
314
-        if ( ! $submission->has_billing_email() || ! is_email( $submission->get_billing_email() ) ) {
315
-            wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) );
314
+        if (!$submission->has_billing_email() || !is_email($submission->get_billing_email())) {
315
+            wp_send_json_error(__('Provide a valid billing email.', 'invoicing'));
316 316
         }
317 317
 
318 318
         // Clear any checkout errors.
319 319
         wpinv_clear_errors();
320 320
 
321 321
         // Validate the gateway.
322
-        wpinv_checkout_validate_gateway( $submission );
322
+        wpinv_checkout_validate_gateway($submission);
323 323
 
324 324
         // Allow themes and plugins to hook to errors
325
-        do_action( 'getpaid_checkout_error_checks', $submission );
325
+        do_action('getpaid_checkout_error_checks', $submission);
326 326
 
327 327
         // Do we have any errors?
328
-        if ( wpinv_get_errors() ) {
329
-            wp_send_json_error( getpaid_get_errors_html() );
328
+        if (wpinv_get_errors()) {
329
+            wp_send_json_error(getpaid_get_errors_html());
330 330
         }
331 331
 
332 332
         // Prepare items.
333 333
         $items = $submission->get_items();
334 334
 
335 335
         // Ensure that we have items.
336
-        if ( empty( $items ) && 0 == count( $submission->get_fees() ) ) {
337
-            wp_send_json_error( __( 'You have not selected any items.', 'invoicing' ) );
336
+        if (empty($items) && 0 == count($submission->get_fees())) {
337
+            wp_send_json_error(__('You have not selected any items.', 'invoicing'));
338 338
         }
339 339
 
340 340
         // Prepare the invoice.
341
-        if ( ! $submission->has_invoice() ) {
341
+        if (!$submission->has_invoice()) {
342 342
             $invoice = new WPInv_Invoice();
343 343
         } else {
344 344
             $invoice = $submission->get_invoice();
345 345
         }
346 346
 
347 347
         // Make sure that it is neither paid or refunded.
348
-        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
349
-            wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) );
348
+        if ($invoice->is_paid() || $invoice->is_refunded()) {
349
+            wp_send_json_error(__('This invoice has already been paid for.', 'invoicing'));
350 350
         }
351 351
 
352 352
         // Set the billing email.
353
-        $invoice->set_email( sanitize_email( $submission->get_billing_email() ) );
353
+        $invoice->set_email(sanitize_email($submission->get_billing_email()));
354 354
 
355 355
         // Payment form.
356
-        $invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) );
356
+        $invoice->set_payment_form(absint($submission->get_payment_form()->get_id()));
357 357
 
358 358
         // Discount code.
359
-        if ( $submission->has_discount_code() ) {
360
-            $invoice->set_discount_code( $submission->get_discount_code() );
359
+        if ($submission->has_discount_code()) {
360
+            $invoice->set_discount_code($submission->get_discount_code());
361 361
         }
362 362
 
363 363
         // Items, Fees, taxes and discounts.
364
-        $invoice->set_items( $items );
365
-        $invoice->set_fees( $submission->get_fees() );
366
-        $invoice->set_taxes( $submission->get_taxes() );
367
-        $invoice->set_discounts( $submission->get_discounts() );
364
+        $invoice->set_items($items);
365
+        $invoice->set_fees($submission->get_fees());
366
+        $invoice->set_taxes($submission->get_taxes());
367
+        $invoice->set_discounts($submission->get_discounts());
368 368
 
369 369
         // Prepared submission details.
370 370
         $prepared = array();
@@ -373,48 +373,48 @@  discard block
 block discarded – undo
373 373
         $data = $submission->get_data();
374 374
 
375 375
         // Loop throught the submitted details.
376
-        foreach ( $submission->get_payment_form()->get_elements() as $field ) {
376
+        foreach ($submission->get_payment_form()->get_elements() as $field) {
377 377
 
378
-            if ( ! empty( $field['premade'] ) ) {
378
+            if (!empty($field['premade'])) {
379 379
                 continue;
380 380
             }
381 381
 
382 382
             // If it is required and not set, abort.
383
-            if ( ! $submission->is_required_field_set( $field ) ) {
384
-                wp_send_json_error( __( 'Some required fields are not set.', 'invoicing' ) );
383
+            if (!$submission->is_required_field_set($field)) {
384
+                wp_send_json_error(__('Some required fields are not set.', 'invoicing'));
385 385
             }
386 386
 
387 387
             // Handle address fields.
388
-            if ( $field['type'] == 'address' ) {
388
+            if ($field['type'] == 'address') {
389 389
 
390
-                foreach ( $field['fields'] as $address_field ) {
390
+                foreach ($field['fields'] as $address_field) {
391 391
 
392 392
                     // skip if it is not visible.
393
-                    if ( empty( $address_field['visible'] ) ) {
393
+                    if (empty($address_field['visible'])) {
394 394
                         continue;
395 395
                     }
396 396
 
397 397
                     // If it is required and not set, abort
398
-                    if ( ! empty( $address_field['required'] ) && empty( $data[ $address_field['name'] ] ) ) {
399
-                        wp_send_json_error( __( 'Some required fields are not set.', 'invoicing' ) );
398
+                    if (!empty($address_field['required']) && empty($data[$address_field['name']])) {
399
+                        wp_send_json_error(__('Some required fields are not set.', 'invoicing'));
400 400
                     }
401 401
 
402
-                    if ( isset( $data[ $address_field['name'] ] ) ) {
403
-                        $name   = str_replace( 'wpinv_', '', $address_field['name'] );
402
+                    if (isset($data[$address_field['name']])) {
403
+                        $name   = str_replace('wpinv_', '', $address_field['name']);
404 404
                         $method = "set_$name";
405
-                        $invoice->$method( wpinv_clean( $data[ $address_field['name'] ] ) );
405
+                        $invoice->$method(wpinv_clean($data[$address_field['name']]));
406 406
                     }
407 407
 
408 408
                 }
409 409
 
410
-            } else if ( isset( $data[ $field['id'] ] ) ) {
410
+            } else if (isset($data[$field['id']])) {
411 411
                 $label = $field['id'];
412 412
 
413
-                if ( isset( $field['label'] ) ) {
413
+                if (isset($field['label'])) {
414 414
                     $label = $field['label'];
415 415
                 }
416 416
 
417
-                $prepared[ wpinv_clean( $label ) ] = wpinv_clean( $data[ $field['id'] ] );
417
+                $prepared[wpinv_clean($label)] = wpinv_clean($data[$field['id']]);
418 418
             }
419 419
 
420 420
         }
@@ -422,41 +422,41 @@  discard block
 block discarded – undo
422 422
         // (Maybe) create the user.
423 423
         $user = get_current_user_id();
424 424
 
425
-        if ( empty( $user ) ) {
426
-            $user = get_user_by( 'email', $submission->get_billing_email() );
425
+        if (empty($user)) {
426
+            $user = get_user_by('email', $submission->get_billing_email());
427 427
         }
428 428
 
429
-        if ( empty( $user ) ) {
430
-            $user = wpinv_create_user( $submission->get_billing_email() );
429
+        if (empty($user)) {
430
+            $user = wpinv_create_user($submission->get_billing_email());
431 431
         }
432 432
 
433
-        if ( is_wp_error( $user ) ) {
434
-            wp_send_json_error( $user->get_error_message() );
433
+        if (is_wp_error($user)) {
434
+            wp_send_json_error($user->get_error_message());
435 435
         }
436 436
 
437
-        if ( is_numeric( $user ) ) {
438
-            $user = get_user_by( 'id', $user );
437
+        if (is_numeric($user)) {
438
+            $user = get_user_by('id', $user);
439 439
         }
440 440
 
441
-        $invoice->set_user_id( $user->ID );
441
+        $invoice->set_user_id($user->ID);
442 442
 
443 443
         // User address.
444
-        $address_fields = wpinv_get_user_address( $user->ID );
444
+        $address_fields = wpinv_get_user_address($user->ID);
445 445
 
446
-        foreach ( $address_fields as $key => $value ) {
446
+        foreach ($address_fields as $key => $value) {
447 447
 
448
-            if ( is_callable( $invoice, "get_$key" ) ) {
449
-                $current = call_user_func( array( $invoice, "get_$key" ) );
448
+            if (is_callable($invoice, "get_$key")) {
449
+                $current = call_user_func(array($invoice, "get_$key"));
450 450
 
451
-                if ( empty( $current ) ) {
451
+                if (empty($current)) {
452 452
                     $method = "set_$key";
453
-                    $invoice->$method( $value );
453
+                    $invoice->$method($value);
454 454
                 }
455 455
             }
456 456
 
457 457
         }
458 458
         // Set gateway.
459
-        $invoice->set_gateway( $data['wpi-gateway'] );
459
+        $invoice->set_gateway($data['wpi-gateway']);
460 460
 
461 461
         $invoice->recalculate_total();
462 462
 
@@ -464,24 +464,24 @@  discard block
 block discarded – undo
464 464
         $invoice->save();
465 465
 
466 466
         // Was it saved successfully:
467
-        if ( $invoice->get_id() == 0 ) {
468
-            wp_send_json_error( __( 'An error occured while saving your invoice.', 'invoicing' ) );
467
+        if ($invoice->get_id() == 0) {
468
+            wp_send_json_error(__('An error occured while saving your invoice.', 'invoicing'));
469 469
         }
470 470
 
471
-        if ( ! $submission->has_invoice() ) {
472
-            update_post_meta( $invoice->get_id(), 'wpinv_created_via', 'payment_form' );
471
+        if (!$submission->has_invoice()) {
472
+            update_post_meta($invoice->get_id(), 'wpinv_created_via', 'payment_form');
473 473
         }
474 474
 
475 475
         // Save payment form data.
476
-        if ( ! empty( $prepared ) ) {
477
-            update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared );
476
+        if (!empty($prepared)) {
477
+            update_post_meta($invoice->get_id(), 'payment_form_data', $prepared);
478 478
         }
479 479
 
480 480
         // Process the checkout.
481
-        add_filter( 'wp_redirect', array( $invoicing->form_elements, 'send_redirect_response' ) );
482
-        add_action( 'wpinv_pre_send_back_to_checkout', array( $invoicing->form_elements, 'checkout_error' ) );
481
+        add_filter('wp_redirect', array($invoicing->form_elements, 'send_redirect_response'));
482
+        add_action('wpinv_pre_send_back_to_checkout', array($invoicing->form_elements, 'checkout_error'));
483 483
 
484
-        wpinv_process_checkout( $invoice, $submission );
484
+        wpinv_process_checkout($invoice, $submission);
485 485
 
486 486
         // If we are here, there was an error.
487 487
         $invoicing->form_elements->checkout_error();
@@ -497,51 +497,51 @@  discard block
 block discarded – undo
497 497
     public static function get_payment_form_states_field() {
498 498
         global $invoicing;
499 499
 
500
-        if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) {
500
+        if (empty($_GET['country']) || empty($_GET['form'])) {
501 501
             exit;
502 502
         }
503 503
 
504
-        $elements = $invoicing->form_elements->get_form_elements( $_GET['form'] );
504
+        $elements = $invoicing->form_elements->get_form_elements($_GET['form']);
505 505
 
506
-        if ( empty( $elements ) ) {
506
+        if (empty($elements)) {
507 507
             exit;
508 508
         }
509 509
 
510 510
         $address_fields = array();
511
-        foreach ( $elements as $element ) {
512
-            if ( 'address' === $element['type'] ) {
511
+        foreach ($elements as $element) {
512
+            if ('address' === $element['type']) {
513 513
                 $address_fields = $element;
514 514
                 break;
515 515
             }
516 516
         }
517 517
 
518
-        if ( empty( $address_fields ) ) {
518
+        if (empty($address_fields)) {
519 519
             exit;
520 520
         }
521 521
 
522
-        foreach( $address_fields['fields'] as $address_field ) {
522
+        foreach ($address_fields['fields'] as $address_field) {
523 523
 
524
-            if ( 'wpinv_state' == $address_field['name'] ) {
524
+            if ('wpinv_state' == $address_field['name']) {
525 525
 
526 526
                 $label = $address_field['label'];
527 527
 
528
-                if ( ! empty( $address_field['required'] ) ) {
528
+                if (!empty($address_field['required'])) {
529 529
                     $label .= "<span class='text-danger'> *</span>";
530 530
                 }
531 531
 
532
-                $states = wpinv_get_country_states( $_GET['country'] );
532
+                $states = wpinv_get_country_states($_GET['country']);
533 533
 
534
-                if ( ! empty( $states ) ) {
534
+                if (!empty($states)) {
535 535
 
536 536
                     $html = aui()->select(
537 537
                             array(
538 538
                                 'options'          => $states,
539
-                                'name'             => esc_attr( $address_field['name'] ),
540
-                                'id'               => esc_attr( $address_field['name'] ),
541
-                                'placeholder'      => esc_attr( $address_field['placeholder'] ),
539
+                                'name'             => esc_attr($address_field['name']),
540
+                                'id'               => esc_attr($address_field['name']),
541
+                                'placeholder'      => esc_attr($address_field['placeholder']),
542 542
                                 'required'         => (bool) $address_field['required'],
543 543
                                 'no_wrap'          => true,
544
-                                'label'            => wp_kses_post( $label ),
544
+                                'label'            => wp_kses_post($label),
545 545
                                 'select2'          => false,
546 546
                             )
547 547
                         );
@@ -550,10 +550,10 @@  discard block
 block discarded – undo
550 550
 
551 551
                     $html = aui()->input(
552 552
                             array(
553
-                                'name'       => esc_attr( $address_field['name'] ),
554
-                                'id'         => esc_attr( $address_field['name'] ),
553
+                                'name'       => esc_attr($address_field['name']),
554
+                                'id'         => esc_attr($address_field['name']),
555 555
                                 'required'   => (bool) $address_field['required'],
556
-                                'label'      => wp_kses_post( $label ),
556
+                                'label'      => wp_kses_post($label),
557 557
                                 'no_wrap'    => true,
558 558
                                 'type'       => 'text',
559 559
                             )
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
 
562 562
                 }
563 563
 
564
-                wp_send_json_success( str_replace( 'sr-only', '', $html ) );
564
+                wp_send_json_success(str_replace('sr-only', '', $html));
565 565
                 exit;
566 566
 
567 567
             }
@@ -577,56 +577,56 @@  discard block
 block discarded – undo
577 577
     public static function recalculate_invoice_totals() {
578 578
 
579 579
         // Verify nonce.
580
-        check_ajax_referer( 'wpinv-nonce' );
580
+        check_ajax_referer('wpinv-nonce');
581 581
 
582
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
582
+        if (!wpinv_current_user_can_manage_invoicing()) {
583 583
             exit;
584 584
         }
585 585
 
586 586
         // We need an invoice.
587
-        if ( empty( $_POST['post_id'] ) ) {
587
+        if (empty($_POST['post_id'])) {
588 588
             exit;
589 589
         }
590 590
 
591 591
         // Fetch the invoice.
592
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
592
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
593 593
 
594 594
         // Ensure it exists.
595
-        if ( ! $invoice->get_id() ) {
595
+        if (!$invoice->get_id()) {
596 596
             exit;
597 597
         }
598 598
 
599 599
         // Maybe set the country, state, currency.
600
-        foreach ( array( 'country', 'state', 'currency' ) as $key ) {
601
-            if ( isset( $_POST[ $key ] ) ) {
600
+        foreach (array('country', 'state', 'currency') as $key) {
601
+            if (isset($_POST[$key])) {
602 602
                 $method = "set_$key";
603
-                $invoice->$method( $_POST[ $key ] );
603
+                $invoice->$method($_POST[$key]);
604 604
             }
605 605
         }
606 606
 
607 607
         // Maybe disable taxes.
608
-        $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) );
608
+        $invoice->set_disable_taxes(!empty($_POST['taxes']));
609 609
 
610 610
         // Recalculate totals.
611 611
         $invoice->recalculate_total();
612 612
 
613
-        $total = wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() );
613
+        $total = wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency());
614 614
 
615
-        if ( $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) {
616
-            $recurring_total = wpinv_price( wpinv_format_amount( $invoice->get_recurring_total() ), $invoice->get_currency() );
617
-            $total          .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>';
615
+        if ($invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) {
616
+            $recurring_total = wpinv_price(wpinv_format_amount($invoice->get_recurring_total()), $invoice->get_currency());
617
+            $total          .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>';
618 618
         }
619 619
 
620 620
         $totals = array(
621
-            'subtotal' => wpinv_price( wpinv_format_amount( $invoice->get_subtotal() ), $invoice->get_currency() ),
622
-            'discount' => wpinv_price( wpinv_format_amount( $invoice->get_total_discount() ), $invoice->get_currency() ),
623
-            'tax'      => wpinv_price( wpinv_format_amount( $invoice->get_total_tax() ), $invoice->get_currency() ),
621
+            'subtotal' => wpinv_price(wpinv_format_amount($invoice->get_subtotal()), $invoice->get_currency()),
622
+            'discount' => wpinv_price(wpinv_format_amount($invoice->get_total_discount()), $invoice->get_currency()),
623
+            'tax'      => wpinv_price(wpinv_format_amount($invoice->get_total_tax()), $invoice->get_currency()),
624 624
             'total'    => $total,
625 625
         );
626 626
 
627
-        $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice );
627
+        $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice);
628 628
 
629
-        wp_send_json_success( compact( 'totals' ) );
629
+        wp_send_json_success(compact('totals'));
630 630
     }
631 631
 
632 632
     /**
@@ -635,33 +635,33 @@  discard block
 block discarded – undo
635 635
     public static function get_invoice_items() {
636 636
 
637 637
         // Verify nonce.
638
-        check_ajax_referer( 'wpinv-nonce' );
638
+        check_ajax_referer('wpinv-nonce');
639 639
 
640
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
640
+        if (!wpinv_current_user_can_manage_invoicing()) {
641 641
             exit;
642 642
         }
643 643
 
644 644
         // We need an invoice and items.
645
-        if ( empty( $_POST['post_id'] ) ) {
645
+        if (empty($_POST['post_id'])) {
646 646
             exit;
647 647
         }
648 648
 
649 649
         // Fetch the invoice.
650
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
650
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
651 651
 
652 652
         // Ensure it exists.
653
-        if ( ! $invoice->get_id() ) {
653
+        if (!$invoice->get_id()) {
654 654
             exit;
655 655
         }
656 656
 
657 657
         // Return an array of invoice items.
658 658
         $items = array();
659 659
 
660
-        foreach ( $invoice->get_items() as $item_id => $item ) {
661
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency()  );
660
+        foreach ($invoice->get_items() as $item_id => $item) {
661
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
662 662
         }
663 663
 
664
-        wp_send_json_success( compact( 'items' ) );
664
+        wp_send_json_success(compact('items'));
665 665
     }
666 666
 
667 667
     /**
@@ -670,50 +670,50 @@  discard block
 block discarded – undo
670 670
     public static function edit_invoice_item() {
671 671
 
672 672
         // Verify nonce.
673
-        check_ajax_referer( 'wpinv-nonce' );
673
+        check_ajax_referer('wpinv-nonce');
674 674
 
675
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
675
+        if (!wpinv_current_user_can_manage_invoicing()) {
676 676
             exit;
677 677
         }
678 678
 
679 679
         // We need an invoice and item details.
680
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) {
680
+        if (empty($_POST['post_id']) || empty($_POST['data'])) {
681 681
             exit;
682 682
         }
683 683
 
684 684
         // Fetch the invoice.
685
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
685
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
686 686
 
687 687
         // Ensure it exists and its not been paid for.
688
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
688
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
689 689
             exit;
690 690
         }
691 691
 
692 692
         // Format the data.
693
-        $data = wp_list_pluck( $_POST['data'], 'value', 'field' );
693
+        $data = wp_list_pluck($_POST['data'], 'value', 'field');
694 694
 
695 695
         // Ensure that we have an item id.
696
-        if ( empty( $data['id'] ) ) {
696
+        if (empty($data['id'])) {
697 697
             exit;
698 698
         }
699 699
 
700 700
         // Abort if the invoice does not have the specified item.
701
-        $item = $invoice->get_item( (int) $data['id'] );
701
+        $item = $invoice->get_item((int) $data['id']);
702 702
 
703
-        if ( empty( $item ) ) {
703
+        if (empty($item)) {
704 704
             exit;
705 705
         }
706 706
 
707 707
         // Update the item.
708
-        $item->set_price( $data['price'] );
709
-        $item->set_name( $data['name'] );
710
-        $item->set_description( $data['description'] );
711
-        $item->set_quantity( $data['quantity'] );
708
+        $item->set_price($data['price']);
709
+        $item->set_name($data['name']);
710
+        $item->set_description($data['description']);
711
+        $item->set_quantity($data['quantity']);
712 712
 
713 713
         // Add it to the invoice.
714
-        $error = $invoice->add_item( $item );
714
+        $error = $invoice->add_item($item);
715 715
         $alert = false;
716
-        if ( is_wp_error( $error ) ) {
716
+        if (is_wp_error($error)) {
717 717
             $alert = $error->get_error_message();
718 718
         }
719 719
 
@@ -726,11 +726,11 @@  discard block
 block discarded – undo
726 726
         // Return an array of invoice items.
727 727
         $items = array();
728 728
 
729
-        foreach ( $invoice->get_items() as $item_id => $item ) {
730
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency()  );
729
+        foreach ($invoice->get_items() as $item_id => $item) {
730
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
731 731
         }
732 732
 
733
-        wp_send_json_success( compact( 'items', 'alert' ) );
733
+        wp_send_json_success(compact('items', 'alert'));
734 734
     }
735 735
 
736 736
     /**
@@ -739,33 +739,33 @@  discard block
 block discarded – undo
739 739
     public static function remove_invoice_item() {
740 740
 
741 741
         // Verify nonce.
742
-        check_ajax_referer( 'wpinv-nonce' );
742
+        check_ajax_referer('wpinv-nonce');
743 743
 
744
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
744
+        if (!wpinv_current_user_can_manage_invoicing()) {
745 745
             exit;
746 746
         }
747 747
 
748 748
         // We need an invoice and an item.
749
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) {
749
+        if (empty($_POST['post_id']) || empty($_POST['item_id'])) {
750 750
             exit;
751 751
         }
752 752
 
753 753
         // Fetch the invoice.
754
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
754
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
755 755
 
756 756
         // Ensure it exists and its not been paid for.
757
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
757
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
758 758
             exit;
759 759
         }
760 760
 
761 761
         // Abort if the invoice does not have the specified item.
762
-        $item = $invoice->get_item( (int) $_POST['item_id'] );
762
+        $item = $invoice->get_item((int) $_POST['item_id']);
763 763
 
764
-        if ( empty( $item ) ) {
764
+        if (empty($item)) {
765 765
             exit;
766 766
         }
767 767
 
768
-        $invoice->remove_item( (int) $_POST['item_id'] );
768
+        $invoice->remove_item((int) $_POST['item_id']);
769 769
 
770 770
         // Update totals.
771 771
         $invoice->recalculate_total();
@@ -776,11 +776,11 @@  discard block
 block discarded – undo
776 776
         // Return an array of invoice items.
777 777
         $items = array();
778 778
 
779
-        foreach ( $invoice->get_items() as $item_id => $item ) {
780
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency()  );
779
+        foreach ($invoice->get_items() as $item_id => $item) {
780
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
781 781
         }
782 782
 
783
-        wp_send_json_success( compact( 'items' ) );
783
+        wp_send_json_success(compact('items'));
784 784
     }
785 785
 
786 786
     /**
@@ -789,39 +789,39 @@  discard block
 block discarded – undo
789 789
     public static function add_invoice_items() {
790 790
 
791 791
         // Verify nonce.
792
-        check_ajax_referer( 'wpinv-nonce' );
792
+        check_ajax_referer('wpinv-nonce');
793 793
 
794
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
794
+        if (!wpinv_current_user_can_manage_invoicing()) {
795 795
             exit;
796 796
         }
797 797
 
798 798
         // We need an invoice and items.
799
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) {
799
+        if (empty($_POST['post_id']) || empty($_POST['items'])) {
800 800
             exit;
801 801
         }
802 802
 
803 803
         // Fetch the invoice.
804
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
804
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
805 805
         $alert   = false;
806 806
 
807 807
         // Ensure it exists and its not been paid for.
808
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
808
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
809 809
             exit;
810 810
         }
811 811
 
812 812
         // Add the items.
813
-        foreach ( $_POST['items'] as $data ) {
813
+        foreach ($_POST['items'] as $data) {
814 814
 
815
-            $item = new GetPaid_Form_Item( $data[ 'id' ] );
815
+            $item = new GetPaid_Form_Item($data['id']);
816 816
 
817
-            if ( is_numeric( $data[ 'qty' ] ) && (int) $data[ 'qty' ] > 0 ) {
818
-                $item->set_quantity( $data[ 'qty' ] );
817
+            if (is_numeric($data['qty']) && (int) $data['qty'] > 0) {
818
+                $item->set_quantity($data['qty']);
819 819
             }
820 820
 
821
-            if ( $item->get_id() > 0 ) {
822
-                $error = $invoice->add_item( $item );
821
+            if ($item->get_id() > 0) {
822
+                $error = $invoice->add_item($item);
823 823
 
824
-                if ( is_wp_error( $error ) ) {
824
+                if (is_wp_error($error)) {
825 825
                     $alert = $error->get_error_message();
826 826
                 }
827 827
 
@@ -836,11 +836,11 @@  discard block
 block discarded – undo
836 836
         // Return an array of invoice items.
837 837
         $items = array();
838 838
 
839
-        foreach ( $invoice->get_items() as $item_id => $item ) {
840
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() );
839
+        foreach ($invoice->get_items() as $item_id => $item) {
840
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
841 841
         }
842 842
 
843
-        wp_send_json_success( compact( 'items', 'alert' ) );
843
+        wp_send_json_success(compact('items', 'alert'));
844 844
     }
845 845
 
846 846
     /**
@@ -849,15 +849,15 @@  discard block
 block discarded – undo
849 849
     public static function get_invoicing_items() {
850 850
 
851 851
         // Verify nonce.
852
-        check_ajax_referer( 'wpinv-nonce' );
852
+        check_ajax_referer('wpinv-nonce');
853 853
 
854
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
854
+        if (!wpinv_current_user_can_manage_invoicing()) {
855 855
             exit;
856 856
         }
857 857
 
858 858
         // We need a search term.
859
-        if ( empty( $_GET['search'] ) ) {
860
-            wp_send_json_success( array() );
859
+        if (empty($_GET['search'])) {
860
+            wp_send_json_success(array());
861 861
         }
862 862
 
863 863
         // Retrieve items.
@@ -866,8 +866,8 @@  discard block
 block discarded – undo
866 866
             'orderby'        => 'title',
867 867
             'order'          => 'ASC',
868 868
             'posts_per_page' => -1,
869
-            'post_status'    => array( 'publish' ),
870
-            's'              => trim( $_GET['search'] ),
869
+            'post_status'    => array('publish'),
870
+            's'              => trim($_GET['search']),
871 871
             'meta_query'     => array(
872 872
                 array(
873 873
                     'key'       => '_wpinv_type',
@@ -877,18 +877,18 @@  discard block
 block discarded – undo
877 877
             )
878 878
         );
879 879
 
880
-        $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) );
880
+        $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args));
881 881
         $data  = array();
882 882
 
883
-        foreach ( $items as $item ) {
884
-            $item      = new GetPaid_Form_Item( $item );
883
+        foreach ($items as $item) {
884
+            $item = new GetPaid_Form_Item($item);
885 885
             $data[] = array(
886 886
                 'id'   => $item->get_id(),
887 887
                 'text' => $item->get_name()
888 888
             );
889 889
         }
890 890
 
891
-        wp_send_json_success( $data );
891
+        wp_send_json_success($data);
892 892
 
893 893
     }
894 894
 
@@ -898,24 +898,24 @@  discard block
 block discarded – undo
898 898
     public static function get_aui_states_field() {
899 899
 
900 900
         // Verify nonce.
901
-        check_ajax_referer( 'wpinv-nonce' );
901
+        check_ajax_referer('wpinv-nonce');
902 902
 
903 903
         // We need a country.
904
-        if ( empty( $_GET['country'] ) ) {
904
+        if (empty($_GET['country'])) {
905 905
             exit;
906 906
         }
907 907
 
908
-        $states = wpinv_get_country_states( trim( $_GET['country'] ) );
909
-        $state  = isset( $_GET['state'] ) ? trim( $_GET['state'] ) : wpinv_get_default_state();
908
+        $states = wpinv_get_country_states(trim($_GET['country']));
909
+        $state  = isset($_GET['state']) ? trim($_GET['state']) : wpinv_get_default_state();
910 910
 
911
-        if ( empty( $states ) ) {
911
+        if (empty($states)) {
912 912
 
913 913
             $html = aui()->input(
914 914
                 array(
915 915
                     'type'        => 'text',
916 916
                     'id'          => 'wpinv_state',
917 917
                     'name'        => 'wpinv_state',
918
-                    'label'       => __( 'State', 'invoicing' ),
918
+                    'label'       => __('State', 'invoicing'),
919 919
                     'label_type'  => 'vertical',
920 920
                     'placeholder' => 'Liège',
921 921
                     'class'       => 'form-control-sm',
@@ -929,9 +929,9 @@  discard block
 block discarded – undo
929 929
                 array(
930 930
                     'id'          => 'wpinv_state',
931 931
                     'name'        => 'wpinv_state',
932
-                    'label'       => __( 'State', 'invoicing' ),
932
+                    'label'       => __('State', 'invoicing'),
933 933
                     'label_type'  => 'vertical',
934
-                    'placeholder' => __( 'Select a state', 'invoicing' ),
934
+                    'placeholder' => __('Select a state', 'invoicing'),
935 935
                     'class'       => 'form-control-sm',
936 936
                     'value'       => $state,
937 937
                     'options'     => $states,
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
         wp_send_json_success(
946 946
             array(
947 947
                 'html'   => $html,
948
-                'select' => ! empty ( $states )
948
+                'select' => !empty ($states)
949 949
             )
950 950
         );
951 951
 
@@ -959,46 +959,46 @@  discard block
 block discarded – undo
959 959
     public static function ip_geolocation() {
960 960
 
961 961
         // Check nonce.
962
-        check_ajax_referer( 'getpaid-ip-location' );
962
+        check_ajax_referer('getpaid-ip-location');
963 963
 
964 964
         // IP address.
965
-        if ( empty( $_GET['ip'] ) || ! rest_is_ip_address( $_GET['ip'] ) ) {
966
-            _e( 'Invalid IP Address.', 'invoicing' );
965
+        if (empty($_GET['ip']) || !rest_is_ip_address($_GET['ip'])) {
966
+            _e('Invalid IP Address.', 'invoicing');
967 967
             exit;
968 968
         }
969 969
 
970 970
         // Retrieve location info.
971
-        $location = getpaid_geolocate_ip_address( $_GET['ip'] );
971
+        $location = getpaid_geolocate_ip_address($_GET['ip']);
972 972
 
973
-        if ( empty( $location ) ) {
974
-            _e( 'Unable to find geolocation for the IP Address.', 'invoicing' );
973
+        if (empty($location)) {
974
+            _e('Unable to find geolocation for the IP Address.', 'invoicing');
975 975
             exit;
976 976
         }
977 977
 
978 978
         // Sorry.
979
-        extract( $location );
979
+        extract($location);
980 980
 
981 981
         // Prepare the address.
982 982
         $content = '';
983 983
 
984
-        if ( ! empty( $location['city'] ) ) {
985
-            $content .=  $location['city']  . ', ';
984
+        if (!empty($location['city'])) {
985
+            $content .= $location['city'] . ', ';
986 986
         }
987 987
         
988
-        if ( ! empty( $location['region'] ) ) {
989
-            $content .=  $location['region']  . ', ';
988
+        if (!empty($location['region'])) {
989
+            $content .= $location['region'] . ', ';
990 990
         }
991 991
         
992
-        $content .=  $location['country'] . ' (' . $location['iso'] . ')';
992
+        $content .= $location['country'] . ' (' . $location['iso'] . ')';
993 993
 
994 994
         $location['address'] = $content;
995 995
 
996
-        $content  = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $content ) . '</p>';
997
-        $content .= '<p>'. $location['credit'] . '</p>';
996
+        $content  = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $content) . '</p>';
997
+        $content .= '<p>' . $location['credit'] . '</p>';
998 998
 
999 999
         $location['content'] = $content;
1000 1000
 
1001
-        wpinv_get_template( 'geolocation.php', $location );
1001
+        wpinv_get_template('geolocation.php', $location);
1002 1002
 
1003 1003
         exit;
1004 1004
     }
@@ -1011,11 +1011,11 @@  discard block
 block discarded – undo
1011 1011
     public static function payment_form_refresh_prices() {
1012 1012
 
1013 1013
         // Check nonce.
1014
-        check_ajax_referer( 'getpaid_form_nonce' );
1014
+        check_ajax_referer('getpaid_form_nonce');
1015 1015
 
1016 1016
         // ... form fields...
1017
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
1018
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
1017
+        if (empty($_POST['getpaid_payment_form_submission'])) {
1018
+            _e('Error: Reload the page and try again.', 'invoicing');
1019 1019
             exit;
1020 1020
         }
1021 1021
 
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
         $submission = new GetPaid_Payment_Form_Submission();
1024 1024
 
1025 1025
         // Do we have an error?
1026
-        if ( ! empty( $submission->last_error ) ) {
1026
+        if (!empty($submission->last_error)) {
1027 1027
             echo $submission->last_error;
1028 1028
             exit;
1029 1029
         }
@@ -1036,43 +1036,43 @@  discard block
 block discarded – undo
1036 1036
             'is_free'       => $submission->get_payment_details(),
1037 1037
 
1038 1038
             'totals'        => array(
1039
-                'subtotal'  => wpinv_price( wpinv_format_amount( $submission->subtotal_amount ), $submission->get_currency() ),
1040
-                'discount'  => wpinv_price( wpinv_format_amount( $submission->get_total_discount() ), $submission->get_currency() ),
1041
-                'fees'      => wpinv_price( wpinv_format_amount( $submission->get_total_fees() ), $submission->get_currency() ),
1042
-                'tax'       => wpinv_price( wpinv_format_amount( $submission->get_total_tax() ), $submission->get_currency() ),
1043
-                'total'     => wpinv_price( wpinv_format_amount( $submission->get_total() ), $submission->get_currency() ),
1039
+                'subtotal'  => wpinv_price(wpinv_format_amount($submission->subtotal_amount), $submission->get_currency()),
1040
+                'discount'  => wpinv_price(wpinv_format_amount($submission->get_total_discount()), $submission->get_currency()),
1041
+                'fees'      => wpinv_price(wpinv_format_amount($submission->get_total_fees()), $submission->get_currency()),
1042
+                'tax'       => wpinv_price(wpinv_format_amount($submission->get_total_tax()), $submission->get_currency()),
1043
+                'total'     => wpinv_price(wpinv_format_amount($submission->get_total()), $submission->get_currency()),
1044 1044
             ),
1045 1045
 
1046 1046
             'texts'         => array(
1047
-                '.getpaid-checkout-total-payable' => wpinv_price( wpinv_format_amount( $submission->get_total() ), $submission->get_currency() ),
1047
+                '.getpaid-checkout-total-payable' => wpinv_price(wpinv_format_amount($submission->get_total()), $submission->get_currency()),
1048 1048
             )
1049 1049
 
1050 1050
         );
1051 1051
 
1052 1052
         // Add items.
1053 1053
         $items = $submission->get_items();
1054
-        if ( ! empty( $items ) ) {
1054
+        if (!empty($items)) {
1055 1055
             $result['items'] = array();
1056 1056
 
1057
-            foreach( $items as $item_id => $item ) {
1058
-                $result['items']["$item_id"] = wpinv_price( wpinv_format_amount( $item->get_price() * $item->get_quantity() ) );
1057
+            foreach ($items as $item_id => $item) {
1058
+                $result['items']["$item_id"] = wpinv_price(wpinv_format_amount($item->get_price() * $item->get_quantity()));
1059 1059
             }
1060 1060
         }
1061 1061
 
1062 1062
         // Add invoice.
1063
-        if ( $submission->has_invoice() ) {
1063
+        if ($submission->has_invoice()) {
1064 1064
             $result['invoice'] = $submission->get_invoice()->ID;
1065 1065
         }
1066 1066
 
1067 1067
         // Add discount code.
1068
-        if ( $submission->has_discount_code() ) {
1068
+        if ($submission->has_discount_code()) {
1069 1069
             $result['discount_code'] = $submission->get_discount_code();
1070 1070
         }
1071 1071
 
1072 1072
         // Filter the result.
1073
-        $result = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $result, $submission );
1073
+        $result = apply_filters('getpaid_payment_form_ajax_refresh_prices', $result, $submission);
1074 1074
 
1075
-        wp_send_json_success( $result );
1075
+        wp_send_json_success($result);
1076 1076
     }
1077 1077
 
1078 1078
     /**
@@ -1083,53 +1083,53 @@  discard block
 block discarded – undo
1083 1083
     public static function buy_items() {
1084 1084
         $user_id = get_current_user_id();
1085 1085
 
1086
-        if ( empty( $user_id ) ) { // If not logged in then lets redirect to the login page
1087
-            wp_send_json( array(
1088
-                'success' => wp_login_url( wp_get_referer() )
1089
-            ) );
1086
+        if (empty($user_id)) { // If not logged in then lets redirect to the login page
1087
+            wp_send_json(array(
1088
+                'success' => wp_login_url(wp_get_referer())
1089
+            ));
1090 1090
         } else {
1091 1091
             // Only check nonce if logged in as it could be cached when logged out.
1092
-            if ( ! isset( $_POST['wpinv_buy_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_buy_nonce'], 'wpinv_buy_items' ) ) {
1093
-                wp_send_json( array(
1094
-                    'error' => __( 'Security checks failed.', 'invoicing' )
1095
-                ) );
1092
+            if (!isset($_POST['wpinv_buy_nonce']) || !wp_verify_nonce($_POST['wpinv_buy_nonce'], 'wpinv_buy_items')) {
1093
+                wp_send_json(array(
1094
+                    'error' => __('Security checks failed.', 'invoicing')
1095
+                ));
1096 1096
                 wp_die();
1097 1097
             }
1098 1098
 
1099 1099
             // allow to set a custom price through post_id
1100 1100
             $items = $_POST['items'];
1101
-            $related_post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : 0;
1102
-            $custom_item_price = $related_post_id ? abs( get_post_meta( $related_post_id, '_wpi_custom_price', true ) ) : 0;
1101
+            $related_post_id = isset($_POST['post_id']) ? (int) $_POST['post_id'] : 0;
1102
+            $custom_item_price = $related_post_id ? abs(get_post_meta($related_post_id, '_wpi_custom_price', true)) : 0;
1103 1103
 
1104 1104
             $cart_items = array();
1105
-            if ( $items ) {
1106
-                $items = explode( ',', $items );
1105
+            if ($items) {
1106
+                $items = explode(',', $items);
1107 1107
 
1108
-                foreach( $items as $item ) {
1108
+                foreach ($items as $item) {
1109 1109
                     $item_id = $item;
1110 1110
                     $quantity = 1;
1111 1111
 
1112
-                    if ( strpos( $item, '|' ) !== false ) {
1113
-                        $item_parts = explode( '|', $item );
1112
+                    if (strpos($item, '|') !== false) {
1113
+                        $item_parts = explode('|', $item);
1114 1114
                         $item_id = $item_parts[0];
1115 1115
                         $quantity = $item_parts[1];
1116 1116
                     }
1117 1117
 
1118
-                    if ( $item_id && $quantity ) {
1118
+                    if ($item_id && $quantity) {
1119 1119
                         $cart_items_arr = array(
1120
-                            'id'            => (int)$item_id,
1121
-                            'quantity'      => (int)$quantity
1120
+                            'id'            => (int) $item_id,
1121
+                            'quantity'      => (int) $quantity
1122 1122
                         );
1123 1123
 
1124 1124
                         // If there is a related post id then add it to meta
1125
-                        if ( $related_post_id ) {
1125
+                        if ($related_post_id) {
1126 1126
                             $cart_items_arr['meta'] = array(
1127 1127
                                 'post_id'   => $related_post_id
1128 1128
                             );
1129 1129
                         }
1130 1130
 
1131 1131
                         // If there is a custom price then set it.
1132
-                        if ( $custom_item_price ) {
1132
+                        if ($custom_item_price) {
1133 1133
                             $cart_items_arr['custom_price'] = $custom_item_price;
1134 1134
                         }
1135 1135
 
@@ -1145,37 +1145,37 @@  discard block
 block discarded – undo
1145 1145
              * @param int $related_post_id The related post id if any.
1146 1146
              * @since 1.0.0
1147 1147
              */
1148
-            $cart_items = apply_filters( 'wpinv_buy_cart_items', $cart_items, $related_post_id );
1148
+            $cart_items = apply_filters('wpinv_buy_cart_items', $cart_items, $related_post_id);
1149 1149
 
1150 1150
             // Make sure its not in the cart already, if it is then redirect to checkout.
1151 1151
             $cart_invoice = wpinv_get_invoice_cart();
1152 1152
 
1153
-            if ( isset( $cart_invoice->items ) && !empty( $cart_invoice->items ) && !empty( $cart_items ) && serialize( $cart_invoice->items ) == serialize( $cart_items ) ) {
1154
-                wp_send_json( array(
1153
+            if (isset($cart_invoice->items) && !empty($cart_invoice->items) && !empty($cart_items) && serialize($cart_invoice->items) == serialize($cart_items)) {
1154
+                wp_send_json(array(
1155 1155
                     'success' =>  $cart_invoice->get_checkout_payment_url()
1156
-                ) );
1156
+                ));
1157 1157
                 wp_die();
1158 1158
             }
1159 1159
 
1160 1160
             // Check if user has invoice with same items waiting to be paid.
1161
-            $user_invoices = wpinv_get_users_invoices( $user_id , 10 , false , 'wpi-pending' );
1162
-            if ( !empty( $user_invoices ) ) {
1163
-                foreach( $user_invoices as $user_invoice ) {
1161
+            $user_invoices = wpinv_get_users_invoices($user_id, 10, false, 'wpi-pending');
1162
+            if (!empty($user_invoices)) {
1163
+                foreach ($user_invoices as $user_invoice) {
1164 1164
                     $user_cart_details = array();
1165
-                    $invoice  = wpinv_get_invoice( $user_invoice->ID );
1165
+                    $invoice = wpinv_get_invoice($user_invoice->ID);
1166 1166
                     $cart_details = $invoice->get_cart_details();
1167 1167
 
1168
-                    if ( !empty( $cart_details ) ) {
1169
-                        foreach ( $cart_details as $invoice_item ) {
1168
+                    if (!empty($cart_details)) {
1169
+                        foreach ($cart_details as $invoice_item) {
1170 1170
                             $ii_arr = array();
1171
-                            $ii_arr['id'] = (int)$invoice_item['id'];
1172
-                            $ii_arr['quantity'] = (int)$invoice_item['quantity'];
1171
+                            $ii_arr['id'] = (int) $invoice_item['id'];
1172
+                            $ii_arr['quantity'] = (int) $invoice_item['quantity'];
1173 1173
 
1174
-                            if (isset( $invoice_item['meta'] ) && !empty( $invoice_item['meta'] ) ) {
1174
+                            if (isset($invoice_item['meta']) && !empty($invoice_item['meta'])) {
1175 1175
                                 $ii_arr['meta'] = $invoice_item['meta'];
1176 1176
                             }
1177 1177
 
1178
-                            if ( isset( $invoice_item['custom_price'] ) && !empty( $invoice_item['custom_price'] ) ) {
1178
+                            if (isset($invoice_item['custom_price']) && !empty($invoice_item['custom_price'])) {
1179 1179
                                 $ii_arr['custom_price'] = $invoice_item['custom_price'];
1180 1180
                             }
1181 1181
 
@@ -1183,17 +1183,17 @@  discard block
 block discarded – undo
1183 1183
                         }
1184 1184
                     }
1185 1185
 
1186
-                    if ( !empty( $user_cart_details ) && serialize( $cart_items ) == serialize( $user_cart_details ) ) {
1187
-                        wp_send_json( array(
1186
+                    if (!empty($user_cart_details) && serialize($cart_items) == serialize($user_cart_details)) {
1187
+                        wp_send_json(array(
1188 1188
                             'success' =>  $invoice->get_checkout_payment_url()
1189
-                        ) );
1189
+                        ));
1190 1190
                         wp_die();
1191 1191
                     }
1192 1192
                 }
1193 1193
             }
1194 1194
 
1195 1195
             // Create invoice and send user to checkout
1196
-            if ( !empty( $cart_items ) ) {
1196
+            if (!empty($cart_items)) {
1197 1197
                 $invoice_data = array(
1198 1198
                     'status'        =>  'wpi-pending',
1199 1199
                     'created_via'   =>  'wpi',
@@ -1201,21 +1201,21 @@  discard block
 block discarded – undo
1201 1201
                     'cart_details'  =>  $cart_items,
1202 1202
                 );
1203 1203
 
1204
-                $invoice = wpinv_insert_invoice( $invoice_data, true );
1204
+                $invoice = wpinv_insert_invoice($invoice_data, true);
1205 1205
 
1206
-                if ( !empty( $invoice ) && isset( $invoice->ID ) ) {
1207
-                    wp_send_json( array(
1206
+                if (!empty($invoice) && isset($invoice->ID)) {
1207
+                    wp_send_json(array(
1208 1208
                         'success' =>  $invoice->get_checkout_payment_url()
1209
-                    ) );
1209
+                    ));
1210 1210
                 } else {
1211
-                    wp_send_json( array(
1212
-                        'error' => __( 'Invoice failed to create', 'invoicing' )
1213
-                    ) );
1211
+                    wp_send_json(array(
1212
+                        'error' => __('Invoice failed to create', 'invoicing')
1213
+                    ));
1214 1214
                 }
1215 1215
             } else {
1216
-                wp_send_json( array(
1217
-                    'error' => __( 'Items not valid.', 'invoicing' )
1218
-                ) );
1216
+                wp_send_json(array(
1217
+                    'error' => __('Items not valid.', 'invoicing')
1218
+                ));
1219 1219
             }
1220 1220
         }
1221 1221
 
Please login to merge, or discard this patch.
includes/class-getpaid-payment-form.php 2 patches
Indentation   +523 added lines, -523 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 /**
@@ -10,55 +10,55 @@  discard block
 block discarded – undo
10 10
 class GetPaid_Payment_Form extends GetPaid_Data {
11 11
 
12 12
     /**
13
-	 * Which data store to load.
14
-	 *
15
-	 * @var string
16
-	 */
13
+     * Which data store to load.
14
+     *
15
+     * @var string
16
+     */
17 17
     protected $data_store_name = 'payment_form';
18 18
 
19 19
     /**
20
-	 * This is the name of this object type.
21
-	 *
22
-	 * @var string
23
-	 */
24
-	protected $object_type = 'payment_form';
20
+     * This is the name of this object type.
21
+     *
22
+     * @var string
23
+     */
24
+    protected $object_type = 'payment_form';
25 25
 
26 26
     /**
27
-	 * Form Data array. This is the core form data exposed in APIs.
28
-	 *
29
-	 * @since 1.0.19
30
-	 * @var array
31
-	 */
32
-	protected $data = array(
33
-		'status'               => 'draft',
34
-		'version'              => '',
35
-		'date_created'         => null,
27
+     * Form Data array. This is the core form data exposed in APIs.
28
+     *
29
+     * @since 1.0.19
30
+     * @var array
31
+     */
32
+    protected $data = array(
33
+        'status'               => 'draft',
34
+        'version'              => '',
35
+        'date_created'         => null,
36 36
         'date_modified'        => null,
37 37
         'name'                 => '',
38 38
         'author'               => 1,
39 39
         'elements'             => null,
40
-		'items'                => null,
41
-		'earned'               => 0,
42
-		'refunded'             => 0,
43
-		'cancelled'            => 0,
44
-		'failed'               => 0,
45
-	);
46
-
47
-    /**
48
-	 * Stores meta in cache for future reads.
49
-	 *
50
-	 * A group must be set to to enable caching.
51
-	 *
52
-	 * @var string
53
-	 */
54
-	protected $cache_group = 'getpaid_forms';
55
-
56
-	/**
57
-	 * Stores a reference to the invoice if the form is for an invoice..
58
-	 *
59
-	 * @var WPInv_Invoice
60
-	 */
61
-	public $invoice = 0;
40
+        'items'                => null,
41
+        'earned'               => 0,
42
+        'refunded'             => 0,
43
+        'cancelled'            => 0,
44
+        'failed'               => 0,
45
+    );
46
+
47
+    /**
48
+     * Stores meta in cache for future reads.
49
+     *
50
+     * A group must be set to to enable caching.
51
+     *
52
+     * @var string
53
+     */
54
+    protected $cache_group = 'getpaid_forms';
55
+
56
+    /**
57
+     * Stores a reference to the invoice if the form is for an invoice..
58
+     *
59
+     * @var WPInv_Invoice
60
+     */
61
+    public $invoice = 0;
62 62
 
63 63
     /**
64 64
      * Stores a reference to the original WP_Post object
@@ -68,35 +68,35 @@  discard block
 block discarded – undo
68 68
     protected $post = null;
69 69
 
70 70
     /**
71
-	 * Get the form if ID is passed, otherwise the form is new and empty.
72
-	 *
73
-	 * @param  int|object|GetPaid_Payment_Form|WP_Post $form Form to read.
74
-	 */
75
-	public function __construct( $form = 0 ) {
76
-		parent::__construct( $form );
71
+     * Get the form if ID is passed, otherwise the form is new and empty.
72
+     *
73
+     * @param  int|object|GetPaid_Payment_Form|WP_Post $form Form to read.
74
+     */
75
+    public function __construct( $form = 0 ) {
76
+        parent::__construct( $form );
77 77
 
78
-		if ( is_numeric( $form ) && $form > 0 ) {
79
-			$this->set_id( $form );
80
-		} elseif ( $form instanceof self ) {
78
+        if ( is_numeric( $form ) && $form > 0 ) {
79
+            $this->set_id( $form );
80
+        } elseif ( $form instanceof self ) {
81 81
 
82
-			$this->set_id( $form->get_id() );
83
-			$this->invoice = $form->invoice;
82
+            $this->set_id( $form->get_id() );
83
+            $this->invoice = $form->invoice;
84 84
 
85
-		} elseif ( ! empty( $form->ID ) ) {
86
-			$this->set_id( $form->ID );
87
-		} else {
88
-			$this->set_object_read( true );
89
-		}
85
+        } elseif ( ! empty( $form->ID ) ) {
86
+            $this->set_id( $form->ID );
87
+        } else {
88
+            $this->set_object_read( true );
89
+        }
90 90
 
91 91
         // Load the datastore.
92
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
92
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
93 93
 
94
-		if ( $this->get_id() > 0 ) {
94
+        if ( $this->get_id() > 0 ) {
95 95
             $this->post = get_post( $this->get_id() );
96
-			$this->data_store->read( $this );
96
+            $this->data_store->read( $this );
97 97
         }
98 98
 
99
-	}
99
+    }
100 100
 
101 101
     /*
102 102
 	|--------------------------------------------------------------------------
@@ -114,349 +114,349 @@  discard block
 block discarded – undo
114 114
     */
115 115
 
116 116
     /**
117
-	 * Get plugin version when the form was created.
118
-	 *
119
-	 * @since 1.0.19
120
-	 * @param  string $context View or edit context.
121
-	 * @return string
122
-	 */
123
-	public function get_version( $context = 'view' ) {
124
-		return $this->get_prop( 'version', $context );
117
+     * Get plugin version when the form was created.
118
+     *
119
+     * @since 1.0.19
120
+     * @param  string $context View or edit context.
121
+     * @return string
122
+     */
123
+    public function get_version( $context = 'view' ) {
124
+        return $this->get_prop( 'version', $context );
125 125
     }
126 126
 
127 127
     /**
128
-	 * Get date when the form was created.
129
-	 *
130
-	 * @since 1.0.19
131
-	 * @param  string $context View or edit context.
132
-	 * @return string
133
-	 */
134
-	public function get_date_created( $context = 'view' ) {
135
-		return $this->get_prop( 'date_created', $context );
128
+     * Get date when the form was created.
129
+     *
130
+     * @since 1.0.19
131
+     * @param  string $context View or edit context.
132
+     * @return string
133
+     */
134
+    public function get_date_created( $context = 'view' ) {
135
+        return $this->get_prop( 'date_created', $context );
136 136
     }
137 137
 
138 138
     /**
139
-	 * Get GMT date when the form was created.
140
-	 *
141
-	 * @since 1.0.19
142
-	 * @param  string $context View or edit context.
143
-	 * @return string
144
-	 */
145
-	public function get_date_created_gmt( $context = 'view' ) {
139
+     * Get GMT date when the form was created.
140
+     *
141
+     * @since 1.0.19
142
+     * @param  string $context View or edit context.
143
+     * @return string
144
+     */
145
+    public function get_date_created_gmt( $context = 'view' ) {
146 146
         $date = $this->get_date_created( $context );
147 147
 
148 148
         if ( $date ) {
149 149
             $date = get_gmt_from_date( $date );
150 150
         }
151
-		return $date;
151
+        return $date;
152 152
     }
153 153
 
154 154
     /**
155
-	 * Get date when the form was last modified.
156
-	 *
157
-	 * @since 1.0.19
158
-	 * @param  string $context View or edit context.
159
-	 * @return string
160
-	 */
161
-	public function get_date_modified( $context = 'view' ) {
162
-		return $this->get_prop( 'date_modified', $context );
155
+     * Get date when the form was last modified.
156
+     *
157
+     * @since 1.0.19
158
+     * @param  string $context View or edit context.
159
+     * @return string
160
+     */
161
+    public function get_date_modified( $context = 'view' ) {
162
+        return $this->get_prop( 'date_modified', $context );
163 163
     }
164 164
 
165 165
     /**
166
-	 * Get GMT date when the form was last modified.
167
-	 *
168
-	 * @since 1.0.19
169
-	 * @param  string $context View or edit context.
170
-	 * @return string
171
-	 */
172
-	public function get_date_modified_gmt( $context = 'view' ) {
166
+     * Get GMT date when the form was last modified.
167
+     *
168
+     * @since 1.0.19
169
+     * @param  string $context View or edit context.
170
+     * @return string
171
+     */
172
+    public function get_date_modified_gmt( $context = 'view' ) {
173 173
         $date = $this->get_date_modified( $context );
174 174
 
175 175
         if ( $date ) {
176 176
             $date = get_gmt_from_date( $date );
177 177
         }
178
-		return $date;
178
+        return $date;
179 179
     }
180 180
 
181 181
     /**
182
-	 * Get the form name.
183
-	 *
184
-	 * @since 1.0.19
185
-	 * @param  string $context View or edit context.
186
-	 * @return string
187
-	 */
188
-	public function get_name( $context = 'view' ) {
189
-		return $this->get_prop( 'name', $context );
182
+     * Get the form name.
183
+     *
184
+     * @since 1.0.19
185
+     * @param  string $context View or edit context.
186
+     * @return string
187
+     */
188
+    public function get_name( $context = 'view' ) {
189
+        return $this->get_prop( 'name', $context );
190 190
     }
191 191
 
192 192
     /**
193
-	 * Alias of self::get_name().
194
-	 *
195
-	 * @since 1.0.19
196
-	 * @param  string $context View or edit context.
197
-	 * @return string
198
-	 */
199
-	public function get_title( $context = 'view' ) {
200
-		return $this->get_name( $context );
201
-	}
193
+     * Alias of self::get_name().
194
+     *
195
+     * @since 1.0.19
196
+     * @param  string $context View or edit context.
197
+     * @return string
198
+     */
199
+    public function get_title( $context = 'view' ) {
200
+        return $this->get_name( $context );
201
+    }
202 202
 
203 203
     /**
204
-	 * Get the owner of the form.
205
-	 *
206
-	 * @since 1.0.19
207
-	 * @param  string $context View or edit context.
208
-	 * @return int
209
-	 */
210
-	public function get_author( $context = 'view' ) {
211
-		return (int) $this->get_prop( 'author', $context );
204
+     * Get the owner of the form.
205
+     *
206
+     * @since 1.0.19
207
+     * @param  string $context View or edit context.
208
+     * @return int
209
+     */
210
+    public function get_author( $context = 'view' ) {
211
+        return (int) $this->get_prop( 'author', $context );
212 212
     }
213 213
 
214 214
     /**
215
-	 * Get the elements that make up the form.
216
-	 *
217
-	 * @since 1.0.19
218
-	 * @param  string $context View or edit context.
219
-	 * @return array
220
-	 */
221
-	public function get_elements( $context = 'view' ) {
222
-		$elements = $this->get_prop( 'elements', $context );
215
+     * Get the elements that make up the form.
216
+     *
217
+     * @since 1.0.19
218
+     * @param  string $context View or edit context.
219
+     * @return array
220
+     */
221
+    public function get_elements( $context = 'view' ) {
222
+        $elements = $this->get_prop( 'elements', $context );
223 223
 
224
-		if ( empty( $elements ) || ! is_array( $elements ) ) {
224
+        if ( empty( $elements ) || ! is_array( $elements ) ) {
225 225
             return wpinv_get_data( 'sample-payment-form' );
226
-		}
226
+        }
227 227
 
228
-		// Ensure that all required elements exist.
229
-		$_elements = array();
230
-		foreach ( $elements as $element ) {
228
+        // Ensure that all required elements exist.
229
+        $_elements = array();
230
+        foreach ( $elements as $element ) {
231 231
 
232
-			if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) {
232
+            if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) {
233 233
 
234
-				$_elements[] = array(
235
-					'text'        => __( 'Select Payment Method', 'invoicing' ),
236
-					'id'          => 'gtscicd',
237
-					'name'        => 'gtscicd',
238
-					'type'        => 'gateway_select',
239
-					'premade'     => true
234
+                $_elements[] = array(
235
+                    'text'        => __( 'Select Payment Method', 'invoicing' ),
236
+                    'id'          => 'gtscicd',
237
+                    'name'        => 'gtscicd',
238
+                    'type'        => 'gateway_select',
239
+                    'premade'     => true
240 240
 			
241
-				);
241
+                );
242 242
 
243
-			}
243
+            }
244 244
 
245
-			$_elements[] = $element;
245
+            $_elements[] = $element;
246 246
 
247
-		}
247
+        }
248 248
 
249 249
         return $_elements;
250
-	}
251
-
252
-	/**
253
-	 * Get the items sold via the form.
254
-	 *
255
-	 * @since 1.0.19
256
-	 * @param  string $context View or edit context.
257
-	 * @param  string $return objects or arrays.
258
-	 * @return GetPaid_Form_Item[]
259
-	 */
260
-	public function get_items( $context = 'view', $return = 'objects' ) {
261
-		$items = $this->get_prop( 'items', $context );
262
-
263
-		if ( empty( $items ) || ! is_array( $items ) ) {
250
+    }
251
+
252
+    /**
253
+     * Get the items sold via the form.
254
+     *
255
+     * @since 1.0.19
256
+     * @param  string $context View or edit context.
257
+     * @param  string $return objects or arrays.
258
+     * @return GetPaid_Form_Item[]
259
+     */
260
+    public function get_items( $context = 'view', $return = 'objects' ) {
261
+        $items = $this->get_prop( 'items', $context );
262
+
263
+        if ( empty( $items ) || ! is_array( $items ) ) {
264 264
             $items = wpinv_get_data( 'sample-payment-form-items' );
265
-		}
265
+        }
266
+
267
+        // Convert the items.
268
+        $prepared = array();
266 269
 
267
-		// Convert the items.
268
-		$prepared = array();
270
+        foreach ( $items as $key => $value ) {
269 271
 
270
-		foreach ( $items as $key => $value ) {
272
+            //Form items.
273
+            if ( $value instanceof GetPaid_Form_Item ) {
271 274
 
272
-			//Form items.
273
-			if ( $value instanceof GetPaid_Form_Item ) {
275
+                if ( $value->can_purchase() ) {
276
+                    $prepared[] = $value;
277
+                }
274 278
 
275
-				if ( $value->can_purchase() ) {
276
-					$prepared[] = $value;
277
-				}
279
+                continue;
278 280
 
279
-				continue;
281
+            }
280 282
 
281
-			}
283
+            // $item_id => $quantity
284
+            if ( is_numeric( $key ) && is_numeric( $value ) ) {
285
+                $item = new GetPaid_Form_Item( $key );
282 286
 
283
-			// $item_id => $quantity
284
-			if ( is_numeric( $key ) && is_numeric( $value ) ) {
285
-				$item = new GetPaid_Form_Item( $key );
287
+                if ( $item->can_purchase() ) {
288
+                    $item->set_quantity( $value );
289
+                    $prepared[] = $item;
290
+                }
286 291
 
287
-				if ( $item->can_purchase() ) {
288
-					$item->set_quantity( $value );
289
-					$prepared[] = $item;
290
-				}
292
+                continue;
293
+            }
291 294
 
292
-				continue;
293
-			}
295
+            // $item_id => array( 'price' => 10 )
296
+            if ( is_numeric( $key ) && is_array( $value ) ) {
297
+                $item = new GetPaid_Form_Item( $key );
294 298
 
295
-			// $item_id => array( 'price' => 10 )
296
-			if ( is_numeric( $key ) && is_array( $value ) ) {
297
-				$item = new GetPaid_Form_Item( $key );
299
+                if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) {
300
+                    $item->set_price( $value['price'] );
301
+                }
298 302
 
299
-				if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) {
300
-					$item->set_price( $value['price'] );
301
-				}
303
+                if ( $item->can_purchase() ) {
304
+                    $prepared[] = $item;
305
+                }
302 306
 
303
-				if ( $item->can_purchase() ) {
304
-					$prepared[] = $item;
305
-				}
307
+                continue;
308
+            }
306 309
 
307
-				continue;
308
-			}
310
+            if ( is_array( $value ) && isset( $value['id'] ) ) {
309 311
 
310
-			if ( is_array( $value ) && isset( $value['id'] ) ) {
312
+                $item = new GetPaid_Form_Item( $value['id'] );
311 313
 
312
-				$item = new GetPaid_Form_Item( $value['id'] );
314
+                if ( ! $item->can_purchase() ) {
315
+                    continue;
316
+                }
313 317
 
314
-				if ( ! $item->can_purchase() ) {
315
-					continue;
316
-				}
318
+                // Sub-total (Cart items).
319
+                if ( isset( $value['subtotal'] ) ) {
320
+                    $item->set_price( $value['subtotal'] );
321
+                }
317 322
 
318
-				// Sub-total (Cart items).
319
-				if ( isset( $value['subtotal'] ) ) {
320
-					$item->set_price( $value['subtotal'] );
321
-				}
323
+                if ( isset( $value['quantity'] ) ) {
324
+                    $item->set_quantity( $value['quantity'] );
325
+                }
326
+
327
+                if ( isset( $value['allow_quantities'] ) ) {
328
+                    $item->set_allow_quantities( $value['allow_quantities'] );
329
+                }
330
+
331
+                if ( isset( $value['required'] ) ) {
332
+                    $item->set_is_required( $value['required'] );
333
+                }
334
+
335
+                if ( isset( $value['description'] ) ) {
336
+                    $item->set_custom_description( $value['description'] );
337
+                }
338
+
339
+                $prepared[] = $item;
340
+                continue;
341
+
342
+            }
343
+        }
344
+
345
+        if ( 'objects' == $return && 'view' == $context ) {
346
+            return $prepared;
347
+        }
348
+
349
+        $items = array();
350
+        foreach ( $prepared as $item ) {
351
+            $items[] = $item->prepare_data_for_use();
352
+        }
353
+
354
+        return $items;
355
+    }
356
+
357
+    /**
358
+     * Get a single item belonging to the form.
359
+     *
360
+     * @since 1.0.19
361
+     * @param  int $item_id The item id to return.
362
+     * @return GetPaid_Form_Item|bool
363
+     */
364
+    public function get_item( $item_id ) {
365
+
366
+        if ( empty( $item_id ) || ! is_numeric( $item_id ) ) {
367
+            return false;
368
+        }
369
+
370
+        foreach( $this->get_items() as $item ) {
371
+            if ( $item->get_id() == (int) $item_id ) {
372
+                return $item;
373
+            }
374
+        }
375
+
376
+        return false;
377
+
378
+    }
379
+
380
+    /**
381
+     * Gets a single element.
382
+     *
383
+     * @since 1.0.19
384
+     * @param  string $element_type The element type to return.
385
+     * @return array|bool
386
+     */
387
+    public function get_element_type( $element_type ) {
388
+
389
+        if ( empty( $element_type ) || ! is_scalar( $element_type ) ) {
390
+            return false;
391
+        }
392
+
393
+        foreach ( $this->get_prop( 'elements' ) as $element ) {
394
+
395
+            if ( $element['type'] == $element_type ) {
396
+                return $element;
397
+            }
398
+
399
+        }
400
+
401
+        return false;
402
+
403
+    }
404
+
405
+    /**
406
+     * Get the total amount earned via this form.
407
+     *
408
+     * @since 1.0.19
409
+     * @param  string $context View or edit context.
410
+     * @return array
411
+     */
412
+    public function get_earned( $context = 'view' ) {
413
+        return $this->get_prop( 'earned', $context );
414
+    }
415
+
416
+    /**
417
+     * Get the total amount refunded via this form.
418
+     *
419
+     * @since 1.0.19
420
+     * @param  string $context View or edit context.
421
+     * @return array
422
+     */
423
+    public function get_refunded( $context = 'view' ) {
424
+        return $this->get_prop( 'refunded', $context );
425
+    }
322 426
 
323
-				if ( isset( $value['quantity'] ) ) {
324
-					$item->set_quantity( $value['quantity'] );
325
-				}
427
+    /**
428
+     * Get the total amount cancelled via this form.
429
+     *
430
+     * @since 1.0.19
431
+     * @param  string $context View or edit context.
432
+     * @return array
433
+     */
434
+    public function get_cancelled( $context = 'view' ) {
435
+        return $this->get_prop( 'cancelled', $context );
436
+    }
326 437
 
327
-				if ( isset( $value['allow_quantities'] ) ) {
328
-					$item->set_allow_quantities( $value['allow_quantities'] );
329
-				}
438
+    /**
439
+     * Get the total amount failed via this form.
440
+     *
441
+     * @since 1.0.19
442
+     * @param  string $context View or edit context.
443
+     * @return array
444
+     */
445
+    public function get_failed( $context = 'view' ) {
446
+        return $this->get_prop( 'failed', $context );
447
+    }
330 448
 
331
-				if ( isset( $value['required'] ) ) {
332
-					$item->set_is_required( $value['required'] );
333
-				}
334
-
335
-				if ( isset( $value['description'] ) ) {
336
-					$item->set_custom_description( $value['description'] );
337
-				}
338
-
339
-				$prepared[] = $item;
340
-				continue;
341
-
342
-			}
343
-		}
344
-
345
-		if ( 'objects' == $return && 'view' == $context ) {
346
-			return $prepared;
347
-		}
348
-
349
-		$items = array();
350
-		foreach ( $prepared as $item ) {
351
-			$items[] = $item->prepare_data_for_use();
352
-		}
353
-
354
-		return $items;
355
-	}
356
-
357
-	/**
358
-	 * Get a single item belonging to the form.
359
-	 *
360
-	 * @since 1.0.19
361
-	 * @param  int $item_id The item id to return.
362
-	 * @return GetPaid_Form_Item|bool
363
-	 */
364
-	public function get_item( $item_id ) {
365
-
366
-		if ( empty( $item_id ) || ! is_numeric( $item_id ) ) {
367
-			return false;
368
-		}
369
-
370
-		foreach( $this->get_items() as $item ) {
371
-			if ( $item->get_id() == (int) $item_id ) {
372
-				return $item;
373
-			}
374
-		}
375
-
376
-		return false;
377
-
378
-	}
379
-
380
-	/**
381
-	 * Gets a single element.
382
-	 *
383
-	 * @since 1.0.19
384
-	 * @param  string $element_type The element type to return.
385
-	 * @return array|bool
386
-	 */
387
-	public function get_element_type( $element_type ) {
388
-
389
-		if ( empty( $element_type ) || ! is_scalar( $element_type ) ) {
390
-			return false;
391
-		}
392
-
393
-		foreach ( $this->get_prop( 'elements' ) as $element ) {
394
-
395
-			if ( $element['type'] == $element_type ) {
396
-				return $element;
397
-			}
398
-
399
-		}
400
-
401
-		return false;
402
-
403
-	}
404
-
405
-	/**
406
-	 * Get the total amount earned via this form.
407
-	 *
408
-	 * @since 1.0.19
409
-	 * @param  string $context View or edit context.
410
-	 * @return array
411
-	 */
412
-	public function get_earned( $context = 'view' ) {
413
-		return $this->get_prop( 'earned', $context );
414
-	}
415
-
416
-	/**
417
-	 * Get the total amount refunded via this form.
418
-	 *
419
-	 * @since 1.0.19
420
-	 * @param  string $context View or edit context.
421
-	 * @return array
422
-	 */
423
-	public function get_refunded( $context = 'view' ) {
424
-		return $this->get_prop( 'refunded', $context );
425
-	}
426
-
427
-	/**
428
-	 * Get the total amount cancelled via this form.
429
-	 *
430
-	 * @since 1.0.19
431
-	 * @param  string $context View or edit context.
432
-	 * @return array
433
-	 */
434
-	public function get_cancelled( $context = 'view' ) {
435
-		return $this->get_prop( 'cancelled', $context );
436
-	}
437
-
438
-	/**
439
-	 * Get the total amount failed via this form.
440
-	 *
441
-	 * @since 1.0.19
442
-	 * @param  string $context View or edit context.
443
-	 * @return array
444
-	 */
445
-	public function get_failed( $context = 'view' ) {
446
-		return $this->get_prop( 'failed', $context );
447
-	}
448
-
449
-	/**
450
-	 * Get the currency.
451
-	 *
452
-	 * @since 1.0.19
453
-	 * @param  string $context View or edit context.
454
-	 * @return string
455
-	 */
456
-	public function get_currency() {
457
-		$currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency();
458
-		return apply_filters( 'getpaid-payment-form-currency', $currency, $this );
459
-	}
449
+    /**
450
+     * Get the currency.
451
+     *
452
+     * @since 1.0.19
453
+     * @param  string $context View or edit context.
454
+     * @return string
455
+     */
456
+    public function get_currency() {
457
+        $currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency();
458
+        return apply_filters( 'getpaid-payment-form-currency', $currency, $this );
459
+    }
460 460
 
461 461
     /*
462 462
 	|--------------------------------------------------------------------------
@@ -469,22 +469,22 @@  discard block
 block discarded – undo
469 469
     */
470 470
 
471 471
     /**
472
-	 * Set plugin version when the item was created.
473
-	 *
474
-	 * @since 1.0.19
475
-	 */
476
-	public function set_version( $value ) {
477
-		$this->set_prop( 'version', $value );
472
+     * Set plugin version when the item was created.
473
+     *
474
+     * @since 1.0.19
475
+     */
476
+    public function set_version( $value ) {
477
+        $this->set_prop( 'version', $value );
478 478
     }
479 479
 
480 480
     /**
481
-	 * Set date when the item was created.
482
-	 *
483
-	 * @since 1.0.19
484
-	 * @param string $value Value to set.
481
+     * Set date when the item was created.
482
+     *
483
+     * @since 1.0.19
484
+     * @param string $value Value to set.
485 485
      * @return bool Whether or not the date was set.
486
-	 */
487
-	public function set_date_created( $value ) {
486
+     */
487
+    public function set_date_created( $value ) {
488 488
         $date = strtotime( $value );
489 489
 
490 490
         if ( $date ) {
@@ -497,13 +497,13 @@  discard block
 block discarded – undo
497 497
     }
498 498
 
499 499
     /**
500
-	 * Set date when the item was last modified.
501
-	 *
502
-	 * @since 1.0.19
503
-	 * @param string $value Value to set.
500
+     * Set date when the item was last modified.
501
+     *
502
+     * @since 1.0.19
503
+     * @param string $value Value to set.
504 504
      * @return bool Whether or not the date was set.
505
-	 */
506
-	public function set_date_modified( $value ) {
505
+     */
506
+    public function set_date_modified( $value ) {
507 507
         $date = strtotime( $value );
508 508
 
509 509
         if ( $date ) {
@@ -516,122 +516,122 @@  discard block
 block discarded – undo
516 516
     }
517 517
 
518 518
     /**
519
-	 * Set the item name.
520
-	 *
521
-	 * @since 1.0.19
522
-	 * @param  string $value New name.
523
-	 */
524
-	public function set_name( $value ) {
525
-		$this->set_prop( 'name', sanitize_text_field( $value ) );
526
-    }
527
-
528
-    /**
529
-	 * Alias of self::set_name().
530
-	 *
531
-	 * @since 1.0.19
532
-	 * @param  string $value New name.
533
-	 */
534
-	public function set_title( $value ) {
535
-		$this->set_name( $value );
536
-    }
537
-
538
-    /**
539
-	 * Set the owner of the item.
540
-	 *
541
-	 * @since 1.0.19
542
-	 * @param  int $value New author.
543
-	 */
544
-	public function set_author( $value ) {
545
-		$this->set_prop( 'author', (int) $value );
546
-	}
547
-
548
-	/**
549
-	 * Set the form elements.
550
-	 *
551
-	 * @since 1.0.19
552
-	 * @param  array $value Form elements.
553
-	 */
554
-	public function set_elements( $value ) {
555
-		if ( is_array( $value ) ) {
556
-			$this->set_prop( 'elements', $value );
557
-		}
558
-	}
559
-
560
-	/**
561
-	 * Set the form items.
562
-	 *
563
-	 * @since 1.0.19
564
-	 * @param  array $value Form elements.
565
-	 */
566
-	public function set_items( $value ) {
567
-		if ( is_array( $value ) ) {
568
-			$this->set_prop( 'items', $value );
569
-		}
570
-	}
571
-
572
-	/**
573
-	 * Set the total amount earned via this form.
574
-	 *
575
-	 * @since 1.0.19
576
-	 * @param  float $value Amount earned.
577
-	 * @return array
578
-	 */
579
-	public function set_earned( $value ) {
580
-		$value = max( (float) $value, 0 );
581
-		return $this->set_prop( 'earned', $value );
582
-	}
583
-
584
-	/**
585
-	 * Set the total amount refunded via this form.
586
-	 *
587
-	 * @since 1.0.19
588
-	 * @param  float $value Amount refunded.
589
-	 * @return array
590
-	 */
591
-	public function set_refunded( $value ) {
592
-		$value = max( (float) $value, 0 );
593
-		return $this->set_prop( 'refunded', $value );
594
-	}
595
-
596
-	/**
597
-	 * Set the total amount cancelled via this form.
598
-	 *
599
-	 * @since 1.0.19
600
-	 * @param  float $value Amount cancelled.
601
-	 * @return array
602
-	 */
603
-	public function set_cancelled( $value ) {
604
-		$value = max( (float) $value, 0 );
605
-		return $this->set_prop( 'cancelled', $value );
606
-	}
607
-
608
-	/**
609
-	 * Set the total amount failed via this form.
610
-	 *
611
-	 * @since 1.0.19
612
-	 * @param  float $value Amount cancelled.
613
-	 * @return array
614
-	 */
615
-	public function set_failed( $value ) {
616
-		$value = max( (float) $value, 0 );
617
-		return $this->set_prop( 'failed', $value );
618
-	}
519
+     * Set the item name.
520
+     *
521
+     * @since 1.0.19
522
+     * @param  string $value New name.
523
+     */
524
+    public function set_name( $value ) {
525
+        $this->set_prop( 'name', sanitize_text_field( $value ) );
526
+    }
527
+
528
+    /**
529
+     * Alias of self::set_name().
530
+     *
531
+     * @since 1.0.19
532
+     * @param  string $value New name.
533
+     */
534
+    public function set_title( $value ) {
535
+        $this->set_name( $value );
536
+    }
537
+
538
+    /**
539
+     * Set the owner of the item.
540
+     *
541
+     * @since 1.0.19
542
+     * @param  int $value New author.
543
+     */
544
+    public function set_author( $value ) {
545
+        $this->set_prop( 'author', (int) $value );
546
+    }
547
+
548
+    /**
549
+     * Set the form elements.
550
+     *
551
+     * @since 1.0.19
552
+     * @param  array $value Form elements.
553
+     */
554
+    public function set_elements( $value ) {
555
+        if ( is_array( $value ) ) {
556
+            $this->set_prop( 'elements', $value );
557
+        }
558
+    }
559
+
560
+    /**
561
+     * Set the form items.
562
+     *
563
+     * @since 1.0.19
564
+     * @param  array $value Form elements.
565
+     */
566
+    public function set_items( $value ) {
567
+        if ( is_array( $value ) ) {
568
+            $this->set_prop( 'items', $value );
569
+        }
570
+    }
571
+
572
+    /**
573
+     * Set the total amount earned via this form.
574
+     *
575
+     * @since 1.0.19
576
+     * @param  float $value Amount earned.
577
+     * @return array
578
+     */
579
+    public function set_earned( $value ) {
580
+        $value = max( (float) $value, 0 );
581
+        return $this->set_prop( 'earned', $value );
582
+    }
583
+
584
+    /**
585
+     * Set the total amount refunded via this form.
586
+     *
587
+     * @since 1.0.19
588
+     * @param  float $value Amount refunded.
589
+     * @return array
590
+     */
591
+    public function set_refunded( $value ) {
592
+        $value = max( (float) $value, 0 );
593
+        return $this->set_prop( 'refunded', $value );
594
+    }
595
+
596
+    /**
597
+     * Set the total amount cancelled via this form.
598
+     *
599
+     * @since 1.0.19
600
+     * @param  float $value Amount cancelled.
601
+     * @return array
602
+     */
603
+    public function set_cancelled( $value ) {
604
+        $value = max( (float) $value, 0 );
605
+        return $this->set_prop( 'cancelled', $value );
606
+    }
607
+
608
+    /**
609
+     * Set the total amount failed via this form.
610
+     *
611
+     * @since 1.0.19
612
+     * @param  float $value Amount cancelled.
613
+     * @return array
614
+     */
615
+    public function set_failed( $value ) {
616
+        $value = max( (float) $value, 0 );
617
+        return $this->set_prop( 'failed', $value );
618
+    }
619 619
 
620 620
     /**
621 621
      * Create an item. For backwards compatibilty.
622 622
      *
623 623
      * @deprecated
624
-	 * @return int item id
624
+     * @return int item id
625 625
      */
626 626
     public function create( $data = array() ) {
627 627
 
628
-		// Set the properties.
629
-		if ( is_array( $data ) ) {
630
-			$this->set_props( $data );
631
-		}
628
+        // Set the properties.
629
+        if ( is_array( $data ) ) {
630
+            $this->set_props( $data );
631
+        }
632 632
 
633
-		// Save the item.
634
-		return $this->save();
633
+        // Save the item.
634
+        return $this->save();
635 635
 
636 636
     }
637 637
 
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
      * Updates an item. For backwards compatibilty.
640 640
      *
641 641
      * @deprecated
642
-	 * @return int item id
642
+     * @return int item id
643 643
      */
644 644
     public function update( $data = array() ) {
645 645
         return $this->create( $data );
@@ -655,22 +655,22 @@  discard block
 block discarded – undo
655 655
 	*/
656 656
 
657 657
     /**
658
-	 * Checks whether this is the default payment form.
659
-	 *
660
-	 * @since 1.0.19
661
-	 * @return bool
662
-	 */
658
+     * Checks whether this is the default payment form.
659
+     *
660
+     * @since 1.0.19
661
+     * @return bool
662
+     */
663 663
     public function is_default() {
664 664
         $is_default = $this->get_id() == wpinv_get_default_payment_form();
665 665
         return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this );
666
-	}
666
+    }
667 667
 
668 668
     /**
669
-	 * Checks whether the form is active.
670
-	 *
671
-	 * @since 1.0.19
672
-	 * @return bool
673
-	 */
669
+     * Checks whether the form is active.
670
+     *
671
+     * @since 1.0.19
672
+     * @return bool
673
+     */
674 674
     public function is_active() {
675 675
         $is_active = 0 !== (int) $this->get_id();
676 676
 
@@ -679,70 +679,70 @@  discard block
 block discarded – undo
679 679
         }
680 680
 
681 681
         return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this );
682
-	}
683
-
684
-	/**
685
-	 * Checks whether the form has a given item.
686
-	 *
687
-	 * @since 1.0.19
688
-	 * @return bool
689
-	 */
682
+    }
683
+
684
+    /**
685
+     * Checks whether the form has a given item.
686
+     *
687
+     * @since 1.0.19
688
+     * @return bool
689
+     */
690 690
     public function has_item( $item_id ) {
691 691
         return false !== $this->get_item( $item_id );
692
-	}
693
-
694
-	/**
695
-	 * Checks whether the form has a given element.
696
-	 *
697
-	 * @since 1.0.19
698
-	 * @return bool
699
-	 */
692
+    }
693
+
694
+    /**
695
+     * Checks whether the form has a given element.
696
+     *
697
+     * @since 1.0.19
698
+     * @return bool
699
+     */
700 700
     public function has_element_type( $element_type ) {
701 701
         return false !== $this->get_element_type( $element_type );
702
-	}
703
-
704
-	/**
705
-	 * Checks whether this form is recurring or not.
706
-	 *
707
-	 * @since 1.0.19
708
-	 * @return bool
709
-	 */
702
+    }
703
+
704
+    /**
705
+     * Checks whether this form is recurring or not.
706
+     *
707
+     * @since 1.0.19
708
+     * @return bool
709
+     */
710 710
     public function is_recurring() {
711 711
 
712
-		if ( ! empty( $this->invoice ) ) {
713
-			return $this->invoice->is_recurring();
714
-		}
712
+        if ( ! empty( $this->invoice ) ) {
713
+            return $this->invoice->is_recurring();
714
+        }
715 715
 
716
-		foreach ( $this->get_items() as $item ) {
716
+        foreach ( $this->get_items() as $item ) {
717 717
 
718
-			if ( $item->is_recurring() ) {
719
-				return true;
720
-			}
718
+            if ( $item->is_recurring() ) {
719
+                return true;
720
+            }
721 721
 
722
-		}
722
+        }
723 723
 
724 724
         return false;
725
-	}
725
+    }
726 726
 
727
-	/**
728
-	 * Retrieves the form's html.
729
-	 *
730
-	 * @since 1.0.19
731
-	 */
727
+    /**
728
+     * Retrieves the form's html.
729
+     *
730
+     * @since 1.0.19
731
+     */
732 732
     public function get_html() {
733 733
 
734
-		// Return the HTML.
735
-		return wpinv_get_template_html( 'payment-forms/form.php', array( 'form' => $this ) );
734
+        // Return the HTML.
735
+        return wpinv_get_template_html( 'payment-forms/form.php', array( 'form' => $this ) );
736 736
 
737
-	}
737
+    }
738 738
 
739
-	/**
740
-	 * Displays the payment form.
741
-	 *
742
-	 * @since 1.0.19
743
-	 */
739
+    /**
740
+     * Displays the payment form.
741
+     *
742
+     * @since 1.0.19
743
+     */
744 744
     public function display() {
745
-		echo $this->get_html();
745
+        echo $this->get_html();
746 746
     }
747 747
 
748 748
 }
Please login to merge, or discard this patch.
Spacing   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -72,28 +72,28 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @param  int|object|GetPaid_Payment_Form|WP_Post $form Form to read.
74 74
 	 */
75
-	public function __construct( $form = 0 ) {
76
-		parent::__construct( $form );
75
+	public function __construct($form = 0) {
76
+		parent::__construct($form);
77 77
 
78
-		if ( is_numeric( $form ) && $form > 0 ) {
79
-			$this->set_id( $form );
80
-		} elseif ( $form instanceof self ) {
78
+		if (is_numeric($form) && $form > 0) {
79
+			$this->set_id($form);
80
+		} elseif ($form instanceof self) {
81 81
 
82
-			$this->set_id( $form->get_id() );
82
+			$this->set_id($form->get_id());
83 83
 			$this->invoice = $form->invoice;
84 84
 
85
-		} elseif ( ! empty( $form->ID ) ) {
86
-			$this->set_id( $form->ID );
85
+		} elseif (!empty($form->ID)) {
86
+			$this->set_id($form->ID);
87 87
 		} else {
88
-			$this->set_object_read( true );
88
+			$this->set_object_read(true);
89 89
 		}
90 90
 
91 91
         // Load the datastore.
92
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
92
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
93 93
 
94
-		if ( $this->get_id() > 0 ) {
95
-            $this->post = get_post( $this->get_id() );
96
-			$this->data_store->read( $this );
94
+		if ($this->get_id() > 0) {
95
+            $this->post = get_post($this->get_id());
96
+			$this->data_store->read($this);
97 97
         }
98 98
 
99 99
 	}
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
 	 * @param  string $context View or edit context.
121 121
 	 * @return string
122 122
 	 */
123
-	public function get_version( $context = 'view' ) {
124
-		return $this->get_prop( 'version', $context );
123
+	public function get_version($context = 'view') {
124
+		return $this->get_prop('version', $context);
125 125
     }
126 126
 
127 127
     /**
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 	 * @param  string $context View or edit context.
132 132
 	 * @return string
133 133
 	 */
134
-	public function get_date_created( $context = 'view' ) {
135
-		return $this->get_prop( 'date_created', $context );
134
+	public function get_date_created($context = 'view') {
135
+		return $this->get_prop('date_created', $context);
136 136
     }
137 137
 
138 138
     /**
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
 	 * @param  string $context View or edit context.
143 143
 	 * @return string
144 144
 	 */
145
-	public function get_date_created_gmt( $context = 'view' ) {
146
-        $date = $this->get_date_created( $context );
145
+	public function get_date_created_gmt($context = 'view') {
146
+        $date = $this->get_date_created($context);
147 147
 
148
-        if ( $date ) {
149
-            $date = get_gmt_from_date( $date );
148
+        if ($date) {
149
+            $date = get_gmt_from_date($date);
150 150
         }
151 151
 		return $date;
152 152
     }
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 * @param  string $context View or edit context.
159 159
 	 * @return string
160 160
 	 */
161
-	public function get_date_modified( $context = 'view' ) {
162
-		return $this->get_prop( 'date_modified', $context );
161
+	public function get_date_modified($context = 'view') {
162
+		return $this->get_prop('date_modified', $context);
163 163
     }
164 164
 
165 165
     /**
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
 	 * @param  string $context View or edit context.
170 170
 	 * @return string
171 171
 	 */
172
-	public function get_date_modified_gmt( $context = 'view' ) {
173
-        $date = $this->get_date_modified( $context );
172
+	public function get_date_modified_gmt($context = 'view') {
173
+        $date = $this->get_date_modified($context);
174 174
 
175
-        if ( $date ) {
176
-            $date = get_gmt_from_date( $date );
175
+        if ($date) {
176
+            $date = get_gmt_from_date($date);
177 177
         }
178 178
 		return $date;
179 179
     }
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
 	 * @param  string $context View or edit context.
186 186
 	 * @return string
187 187
 	 */
188
-	public function get_name( $context = 'view' ) {
189
-		return $this->get_prop( 'name', $context );
188
+	public function get_name($context = 'view') {
189
+		return $this->get_prop('name', $context);
190 190
     }
191 191
 
192 192
     /**
@@ -196,8 +196,8 @@  discard block
 block discarded – undo
196 196
 	 * @param  string $context View or edit context.
197 197
 	 * @return string
198 198
 	 */
199
-	public function get_title( $context = 'view' ) {
200
-		return $this->get_name( $context );
199
+	public function get_title($context = 'view') {
200
+		return $this->get_name($context);
201 201
 	}
202 202
 
203 203
     /**
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 	 * @param  string $context View or edit context.
208 208
 	 * @return int
209 209
 	 */
210
-	public function get_author( $context = 'view' ) {
211
-		return (int) $this->get_prop( 'author', $context );
210
+	public function get_author($context = 'view') {
211
+		return (int) $this->get_prop('author', $context);
212 212
     }
213 213
 
214 214
     /**
@@ -218,21 +218,21 @@  discard block
 block discarded – undo
218 218
 	 * @param  string $context View or edit context.
219 219
 	 * @return array
220 220
 	 */
221
-	public function get_elements( $context = 'view' ) {
222
-		$elements = $this->get_prop( 'elements', $context );
221
+	public function get_elements($context = 'view') {
222
+		$elements = $this->get_prop('elements', $context);
223 223
 
224
-		if ( empty( $elements ) || ! is_array( $elements ) ) {
225
-            return wpinv_get_data( 'sample-payment-form' );
224
+		if (empty($elements) || !is_array($elements)) {
225
+            return wpinv_get_data('sample-payment-form');
226 226
 		}
227 227
 
228 228
 		// Ensure that all required elements exist.
229 229
 		$_elements = array();
230
-		foreach ( $elements as $element ) {
230
+		foreach ($elements as $element) {
231 231
 
232
-			if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) {
232
+			if ($element['type'] == 'pay_button' && !$this->has_element_type('gateway_select')) {
233 233
 
234 234
 				$_elements[] = array(
235
-					'text'        => __( 'Select Payment Method', 'invoicing' ),
235
+					'text'        => __('Select Payment Method', 'invoicing'),
236 236
 					'id'          => 'gtscicd',
237 237
 					'name'        => 'gtscicd',
238 238
 					'type'        => 'gateway_select',
@@ -257,22 +257,22 @@  discard block
 block discarded – undo
257 257
 	 * @param  string $return objects or arrays.
258 258
 	 * @return GetPaid_Form_Item[]
259 259
 	 */
260
-	public function get_items( $context = 'view', $return = 'objects' ) {
261
-		$items = $this->get_prop( 'items', $context );
260
+	public function get_items($context = 'view', $return = 'objects') {
261
+		$items = $this->get_prop('items', $context);
262 262
 
263
-		if ( empty( $items ) || ! is_array( $items ) ) {
264
-            $items = wpinv_get_data( 'sample-payment-form-items' );
263
+		if (empty($items) || !is_array($items)) {
264
+            $items = wpinv_get_data('sample-payment-form-items');
265 265
 		}
266 266
 
267 267
 		// Convert the items.
268 268
 		$prepared = array();
269 269
 
270
-		foreach ( $items as $key => $value ) {
270
+		foreach ($items as $key => $value) {
271 271
 
272 272
 			//Form items.
273
-			if ( $value instanceof GetPaid_Form_Item ) {
273
+			if ($value instanceof GetPaid_Form_Item) {
274 274
 
275
-				if ( $value->can_purchase() ) {
275
+				if ($value->can_purchase()) {
276 276
 					$prepared[] = $value;
277 277
 				}
278 278
 
@@ -281,11 +281,11 @@  discard block
 block discarded – undo
281 281
 			}
282 282
 
283 283
 			// $item_id => $quantity
284
-			if ( is_numeric( $key ) && is_numeric( $value ) ) {
285
-				$item = new GetPaid_Form_Item( $key );
284
+			if (is_numeric($key) && is_numeric($value)) {
285
+				$item = new GetPaid_Form_Item($key);
286 286
 
287
-				if ( $item->can_purchase() ) {
288
-					$item->set_quantity( $value );
287
+				if ($item->can_purchase()) {
288
+					$item->set_quantity($value);
289 289
 					$prepared[] = $item;
290 290
 				}
291 291
 
@@ -293,47 +293,47 @@  discard block
 block discarded – undo
293 293
 			}
294 294
 
295 295
 			// $item_id => array( 'price' => 10 )
296
-			if ( is_numeric( $key ) && is_array( $value ) ) {
297
-				$item = new GetPaid_Form_Item( $key );
296
+			if (is_numeric($key) && is_array($value)) {
297
+				$item = new GetPaid_Form_Item($key);
298 298
 
299
-				if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) {
300
-					$item->set_price( $value['price'] );
299
+				if (isset($value['price']) && $item->user_can_set_their_price()) {
300
+					$item->set_price($value['price']);
301 301
 				}
302 302
 
303
-				if ( $item->can_purchase() ) {
303
+				if ($item->can_purchase()) {
304 304
 					$prepared[] = $item;
305 305
 				}
306 306
 
307 307
 				continue;
308 308
 			}
309 309
 
310
-			if ( is_array( $value ) && isset( $value['id'] ) ) {
310
+			if (is_array($value) && isset($value['id'])) {
311 311
 
312
-				$item = new GetPaid_Form_Item( $value['id'] );
312
+				$item = new GetPaid_Form_Item($value['id']);
313 313
 
314
-				if ( ! $item->can_purchase() ) {
314
+				if (!$item->can_purchase()) {
315 315
 					continue;
316 316
 				}
317 317
 
318 318
 				// Sub-total (Cart items).
319
-				if ( isset( $value['subtotal'] ) ) {
320
-					$item->set_price( $value['subtotal'] );
319
+				if (isset($value['subtotal'])) {
320
+					$item->set_price($value['subtotal']);
321 321
 				}
322 322
 
323
-				if ( isset( $value['quantity'] ) ) {
324
-					$item->set_quantity( $value['quantity'] );
323
+				if (isset($value['quantity'])) {
324
+					$item->set_quantity($value['quantity']);
325 325
 				}
326 326
 
327
-				if ( isset( $value['allow_quantities'] ) ) {
328
-					$item->set_allow_quantities( $value['allow_quantities'] );
327
+				if (isset($value['allow_quantities'])) {
328
+					$item->set_allow_quantities($value['allow_quantities']);
329 329
 				}
330 330
 
331
-				if ( isset( $value['required'] ) ) {
332
-					$item->set_is_required( $value['required'] );
331
+				if (isset($value['required'])) {
332
+					$item->set_is_required($value['required']);
333 333
 				}
334 334
 
335
-				if ( isset( $value['description'] ) ) {
336
-					$item->set_custom_description( $value['description'] );
335
+				if (isset($value['description'])) {
336
+					$item->set_custom_description($value['description']);
337 337
 				}
338 338
 
339 339
 				$prepared[] = $item;
@@ -342,12 +342,12 @@  discard block
 block discarded – undo
342 342
 			}
343 343
 		}
344 344
 
345
-		if ( 'objects' == $return && 'view' == $context ) {
345
+		if ('objects' == $return && 'view' == $context) {
346 346
 			return $prepared;
347 347
 		}
348 348
 
349 349
 		$items = array();
350
-		foreach ( $prepared as $item ) {
350
+		foreach ($prepared as $item) {
351 351
 			$items[] = $item->prepare_data_for_use();
352 352
 		}
353 353
 
@@ -361,14 +361,14 @@  discard block
 block discarded – undo
361 361
 	 * @param  int $item_id The item id to return.
362 362
 	 * @return GetPaid_Form_Item|bool
363 363
 	 */
364
-	public function get_item( $item_id ) {
364
+	public function get_item($item_id) {
365 365
 
366
-		if ( empty( $item_id ) || ! is_numeric( $item_id ) ) {
366
+		if (empty($item_id) || !is_numeric($item_id)) {
367 367
 			return false;
368 368
 		}
369 369
 
370
-		foreach( $this->get_items() as $item ) {
371
-			if ( $item->get_id() == (int) $item_id ) {
370
+		foreach ($this->get_items() as $item) {
371
+			if ($item->get_id() == (int) $item_id) {
372 372
 				return $item;
373 373
 			}
374 374
 		}
@@ -384,15 +384,15 @@  discard block
 block discarded – undo
384 384
 	 * @param  string $element_type The element type to return.
385 385
 	 * @return array|bool
386 386
 	 */
387
-	public function get_element_type( $element_type ) {
387
+	public function get_element_type($element_type) {
388 388
 
389
-		if ( empty( $element_type ) || ! is_scalar( $element_type ) ) {
389
+		if (empty($element_type) || !is_scalar($element_type)) {
390 390
 			return false;
391 391
 		}
392 392
 
393
-		foreach ( $this->get_prop( 'elements' ) as $element ) {
393
+		foreach ($this->get_prop('elements') as $element) {
394 394
 
395
-			if ( $element['type'] == $element_type ) {
395
+			if ($element['type'] == $element_type) {
396 396
 				return $element;
397 397
 			}
398 398
 
@@ -409,8 +409,8 @@  discard block
 block discarded – undo
409 409
 	 * @param  string $context View or edit context.
410 410
 	 * @return array
411 411
 	 */
412
-	public function get_earned( $context = 'view' ) {
413
-		return $this->get_prop( 'earned', $context );
412
+	public function get_earned($context = 'view') {
413
+		return $this->get_prop('earned', $context);
414 414
 	}
415 415
 
416 416
 	/**
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
 	 * @param  string $context View or edit context.
421 421
 	 * @return array
422 422
 	 */
423
-	public function get_refunded( $context = 'view' ) {
424
-		return $this->get_prop( 'refunded', $context );
423
+	public function get_refunded($context = 'view') {
424
+		return $this->get_prop('refunded', $context);
425 425
 	}
426 426
 
427 427
 	/**
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 	 * @param  string $context View or edit context.
432 432
 	 * @return array
433 433
 	 */
434
-	public function get_cancelled( $context = 'view' ) {
435
-		return $this->get_prop( 'cancelled', $context );
434
+	public function get_cancelled($context = 'view') {
435
+		return $this->get_prop('cancelled', $context);
436 436
 	}
437 437
 
438 438
 	/**
@@ -442,8 +442,8 @@  discard block
 block discarded – undo
442 442
 	 * @param  string $context View or edit context.
443 443
 	 * @return array
444 444
 	 */
445
-	public function get_failed( $context = 'view' ) {
446
-		return $this->get_prop( 'failed', $context );
445
+	public function get_failed($context = 'view') {
446
+		return $this->get_prop('failed', $context);
447 447
 	}
448 448
 
449 449
 	/**
@@ -454,8 +454,8 @@  discard block
 block discarded – undo
454 454
 	 * @return string
455 455
 	 */
456 456
 	public function get_currency() {
457
-		$currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency();
458
-		return apply_filters( 'getpaid-payment-form-currency', $currency, $this );
457
+		$currency = empty($this->invoice) ? wpinv_get_currency() : $this->invoice->get_currency();
458
+		return apply_filters('getpaid-payment-form-currency', $currency, $this);
459 459
 	}
460 460
 
461 461
     /*
@@ -473,8 +473,8 @@  discard block
 block discarded – undo
473 473
 	 *
474 474
 	 * @since 1.0.19
475 475
 	 */
476
-	public function set_version( $value ) {
477
-		$this->set_prop( 'version', $value );
476
+	public function set_version($value) {
477
+		$this->set_prop('version', $value);
478 478
     }
479 479
 
480 480
     /**
@@ -484,11 +484,11 @@  discard block
 block discarded – undo
484 484
 	 * @param string $value Value to set.
485 485
      * @return bool Whether or not the date was set.
486 486
 	 */
487
-	public function set_date_created( $value ) {
488
-        $date = strtotime( $value );
487
+	public function set_date_created($value) {
488
+        $date = strtotime($value);
489 489
 
490
-        if ( $date ) {
491
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
490
+        if ($date) {
491
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
492 492
             return true;
493 493
         }
494 494
 
@@ -503,11 +503,11 @@  discard block
 block discarded – undo
503 503
 	 * @param string $value Value to set.
504 504
      * @return bool Whether or not the date was set.
505 505
 	 */
506
-	public function set_date_modified( $value ) {
507
-        $date = strtotime( $value );
506
+	public function set_date_modified($value) {
507
+        $date = strtotime($value);
508 508
 
509
-        if ( $date ) {
510
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
509
+        if ($date) {
510
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
511 511
             return true;
512 512
         }
513 513
 
@@ -521,8 +521,8 @@  discard block
 block discarded – undo
521 521
 	 * @since 1.0.19
522 522
 	 * @param  string $value New name.
523 523
 	 */
524
-	public function set_name( $value ) {
525
-		$this->set_prop( 'name', sanitize_text_field( $value ) );
524
+	public function set_name($value) {
525
+		$this->set_prop('name', sanitize_text_field($value));
526 526
     }
527 527
 
528 528
     /**
@@ -531,8 +531,8 @@  discard block
 block discarded – undo
531 531
 	 * @since 1.0.19
532 532
 	 * @param  string $value New name.
533 533
 	 */
534
-	public function set_title( $value ) {
535
-		$this->set_name( $value );
534
+	public function set_title($value) {
535
+		$this->set_name($value);
536 536
     }
537 537
 
538 538
     /**
@@ -541,8 +541,8 @@  discard block
 block discarded – undo
541 541
 	 * @since 1.0.19
542 542
 	 * @param  int $value New author.
543 543
 	 */
544
-	public function set_author( $value ) {
545
-		$this->set_prop( 'author', (int) $value );
544
+	public function set_author($value) {
545
+		$this->set_prop('author', (int) $value);
546 546
 	}
547 547
 
548 548
 	/**
@@ -551,9 +551,9 @@  discard block
 block discarded – undo
551 551
 	 * @since 1.0.19
552 552
 	 * @param  array $value Form elements.
553 553
 	 */
554
-	public function set_elements( $value ) {
555
-		if ( is_array( $value ) ) {
556
-			$this->set_prop( 'elements', $value );
554
+	public function set_elements($value) {
555
+		if (is_array($value)) {
556
+			$this->set_prop('elements', $value);
557 557
 		}
558 558
 	}
559 559
 
@@ -563,9 +563,9 @@  discard block
 block discarded – undo
563 563
 	 * @since 1.0.19
564 564
 	 * @param  array $value Form elements.
565 565
 	 */
566
-	public function set_items( $value ) {
567
-		if ( is_array( $value ) ) {
568
-			$this->set_prop( 'items', $value );
566
+	public function set_items($value) {
567
+		if (is_array($value)) {
568
+			$this->set_prop('items', $value);
569 569
 		}
570 570
 	}
571 571
 
@@ -576,9 +576,9 @@  discard block
 block discarded – undo
576 576
 	 * @param  float $value Amount earned.
577 577
 	 * @return array
578 578
 	 */
579
-	public function set_earned( $value ) {
580
-		$value = max( (float) $value, 0 );
581
-		return $this->set_prop( 'earned', $value );
579
+	public function set_earned($value) {
580
+		$value = max((float) $value, 0);
581
+		return $this->set_prop('earned', $value);
582 582
 	}
583 583
 
584 584
 	/**
@@ -588,9 +588,9 @@  discard block
 block discarded – undo
588 588
 	 * @param  float $value Amount refunded.
589 589
 	 * @return array
590 590
 	 */
591
-	public function set_refunded( $value ) {
592
-		$value = max( (float) $value, 0 );
593
-		return $this->set_prop( 'refunded', $value );
591
+	public function set_refunded($value) {
592
+		$value = max((float) $value, 0);
593
+		return $this->set_prop('refunded', $value);
594 594
 	}
595 595
 
596 596
 	/**
@@ -600,9 +600,9 @@  discard block
 block discarded – undo
600 600
 	 * @param  float $value Amount cancelled.
601 601
 	 * @return array
602 602
 	 */
603
-	public function set_cancelled( $value ) {
604
-		$value = max( (float) $value, 0 );
605
-		return $this->set_prop( 'cancelled', $value );
603
+	public function set_cancelled($value) {
604
+		$value = max((float) $value, 0);
605
+		return $this->set_prop('cancelled', $value);
606 606
 	}
607 607
 
608 608
 	/**
@@ -612,9 +612,9 @@  discard block
 block discarded – undo
612 612
 	 * @param  float $value Amount cancelled.
613 613
 	 * @return array
614 614
 	 */
615
-	public function set_failed( $value ) {
616
-		$value = max( (float) $value, 0 );
617
-		return $this->set_prop( 'failed', $value );
615
+	public function set_failed($value) {
616
+		$value = max((float) $value, 0);
617
+		return $this->set_prop('failed', $value);
618 618
 	}
619 619
 
620 620
     /**
@@ -623,11 +623,11 @@  discard block
 block discarded – undo
623 623
      * @deprecated
624 624
 	 * @return int item id
625 625
      */
626
-    public function create( $data = array() ) {
626
+    public function create($data = array()) {
627 627
 
628 628
 		// Set the properties.
629
-		if ( is_array( $data ) ) {
630
-			$this->set_props( $data );
629
+		if (is_array($data)) {
630
+			$this->set_props($data);
631 631
 		}
632 632
 
633 633
 		// Save the item.
@@ -641,8 +641,8 @@  discard block
 block discarded – undo
641 641
      * @deprecated
642 642
 	 * @return int item id
643 643
      */
644
-    public function update( $data = array() ) {
645
-        return $this->create( $data );
644
+    public function update($data = array()) {
645
+        return $this->create($data);
646 646
     }
647 647
 
648 648
     /*
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 	 */
663 663
     public function is_default() {
664 664
         $is_default = $this->get_id() == wpinv_get_default_payment_form();
665
-        return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this );
665
+        return (bool) apply_filters('wpinv_is_default_payment_form', $is_default, $this->get_id(), $this);
666 666
 	}
667 667
 
668 668
     /**
@@ -674,11 +674,11 @@  discard block
 block discarded – undo
674 674
     public function is_active() {
675 675
         $is_active = 0 !== (int) $this->get_id();
676 676
 
677
-        if ( $is_active && ! current_user_can( 'edit_post', $this->get_id() ) && $this->get_status() != 'publish' ) {
677
+        if ($is_active && !current_user_can('edit_post', $this->get_id()) && $this->get_status() != 'publish') {
678 678
             $is_active = false;
679 679
         }
680 680
 
681
-        return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this );
681
+        return (bool) apply_filters('wpinv_is_payment_form_active', $is_active, $this);
682 682
 	}
683 683
 
684 684
 	/**
@@ -687,8 +687,8 @@  discard block
 block discarded – undo
687 687
 	 * @since 1.0.19
688 688
 	 * @return bool
689 689
 	 */
690
-    public function has_item( $item_id ) {
691
-        return false !== $this->get_item( $item_id );
690
+    public function has_item($item_id) {
691
+        return false !== $this->get_item($item_id);
692 692
 	}
693 693
 
694 694
 	/**
@@ -697,8 +697,8 @@  discard block
 block discarded – undo
697 697
 	 * @since 1.0.19
698 698
 	 * @return bool
699 699
 	 */
700
-    public function has_element_type( $element_type ) {
701
-        return false !== $this->get_element_type( $element_type );
700
+    public function has_element_type($element_type) {
701
+        return false !== $this->get_element_type($element_type);
702 702
 	}
703 703
 
704 704
 	/**
@@ -709,13 +709,13 @@  discard block
 block discarded – undo
709 709
 	 */
710 710
     public function is_recurring() {
711 711
 
712
-		if ( ! empty( $this->invoice ) ) {
712
+		if (!empty($this->invoice)) {
713 713
 			return $this->invoice->is_recurring();
714 714
 		}
715 715
 
716
-		foreach ( $this->get_items() as $item ) {
716
+		foreach ($this->get_items() as $item) {
717 717
 
718
-			if ( $item->is_recurring() ) {
718
+			if ($item->is_recurring()) {
719 719
 				return true;
720 720
 			}
721 721
 
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
     public function get_html() {
733 733
 
734 734
 		// Return the HTML.
735
-		return wpinv_get_template_html( 'payment-forms/form.php', array( 'form' => $this ) );
735
+		return wpinv_get_template_html('payment-forms/form.php', array('form' => $this));
736 736
 
737 737
 	}
738 738
 
Please login to merge, or discard this patch.
includes/class-getpaid-notification-email.php 2 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -13,36 +13,36 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Notification_Email {
14 14
 
15 15
     /**
16
-	 * Contains the type of this notification email.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Contains the type of this notification email.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id;
21 21
 
22 22
     /**
23
-	 * Contains any object to use in filters.
24
-	 *
25
-	 * @var false|WPInv_Invoice|WPInv_Item|WPInv_Subscription
26
-	 */
23
+     * Contains any object to use in filters.
24
+     *
25
+     * @var false|WPInv_Invoice|WPInv_Item|WPInv_Subscription
26
+     */
27 27
     public $object;
28 28
 
29 29
     /**
30
-	 * Class constructor.
31
-	 *
30
+     * Class constructor.
31
+     *
32 32
      * @param string $id Email Type.
33 33
      * @param mixed $object Optional. Associated object.
34
-	 */
35
-	public function __construct( $id, $object = false ) {
34
+     */
35
+    public function __construct( $id, $object = false ) {
36 36
         $this->id     = $id;
37 37
         $this->object = $object;
38 38
     }
39 39
 
40 40
     /**
41
-	 * Retrieves an option
42
-	 *
41
+     * Retrieves an option
42
+     *
43 43
      * @return mixed
44
-	 */
45
-	public function get_option( $key ) {
44
+     */
45
+    public function get_option( $key ) {
46 46
 
47 47
         $key   = "email_{$this->id}_$key";
48 48
         $value = wpinv_get_option( $key, null );
@@ -60,80 +60,80 @@  discard block
 block discarded – undo
60 60
     }
61 61
 
62 62
     /**
63
-	 * Retrieves the email body.
64
-	 *
63
+     * Retrieves the email body.
64
+     *
65 65
      * @return string
66
-	 */
67
-	public function get_body() {
66
+     */
67
+    public function get_body() {
68 68
         $body = $this->get_option( 'body' );
69 69
         return apply_filters( 'getpaid_get_email_body', $body, $this->id, $this->object );
70 70
     }
71 71
 
72 72
     /**
73
-	 * Retrieves the email subject.
74
-	 *
73
+     * Retrieves the email subject.
74
+     *
75 75
      * @return string
76
-	 */
77
-	public function get_subject() {
76
+     */
77
+    public function get_subject() {
78 78
         $subject = $this->get_option( 'subject' );
79 79
         return apply_filters( 'getpaid_get_email_subject', $subject, $this->id, $this->object );
80 80
     }
81 81
 
82 82
     /**
83
-	 * Retrieves the email heading.
84
-	 *
83
+     * Retrieves the email heading.
84
+     *
85 85
      * @return string
86
-	 */
87
-	public function get_heading() {
86
+     */
87
+    public function get_heading() {
88 88
         $heading = $this->get_option( 'heading' );
89 89
         return apply_filters( 'getpaid_get_email_heading', $heading, $this->id, $this->object );
90 90
     }
91 91
 
92 92
     /**
93
-	 * Checks if an email is active.
94
-	 *
93
+     * Checks if an email is active.
94
+     *
95 95
      * @return bool
96
-	 */
97
-	public function is_active() {
96
+     */
97
+    public function is_active() {
98 98
         $is_active = ! empty( $this->get_option( 'active' ) );
99 99
         return apply_filters( 'getpaid_email_type_is_active', $is_active, $this->id, $this->object );
100 100
     }
101 101
 
102 102
     /**
103
-	 * Checks if the site's admin should receive email notifications.
104
-	 *
103
+     * Checks if the site's admin should receive email notifications.
104
+     *
105 105
      * @return bool
106
-	 */
107
-	public function include_admin_bcc() {
106
+     */
107
+    public function include_admin_bcc() {
108 108
         $include_admin_bcc = ! empty( $this->get_option( 'admin_bcc' ) );
109 109
         return apply_filters( 'getpaid_email_type_include_admin_bcc', $include_admin_bcc, $this->id, $this->object );
110 110
     }
111 111
 
112 112
     /**
113
-	 * Checks whether this email should be sent to the customer or admin.
114
-	 *
113
+     * Checks whether this email should be sent to the customer or admin.
114
+     *
115 115
      * @return bool
116
-	 */
117
-	public function is_admin_email() {
116
+     */
117
+    public function is_admin_email() {
118 118
         $is_admin_email = in_array( $this->id, array( 'new_invoice', 'cancelled_invoice', 'failed_invoice' ) );
119 119
         return apply_filters( 'getpaid_email_type_is_admin_email', $is_admin_email, $this->id, $this->object );
120 120
     }
121 121
 
122 122
     /**
123
-	 * Returns email attachments.
124
-	 *
123
+     * Returns email attachments.
124
+     *
125 125
      * @return array
126
-	 */
127
-	public function get_attachments() {
126
+     */
127
+    public function get_attachments() {
128 128
         return apply_filters( 'getpaid_get_email_attachments', array(), $this->id, $this->object );
129 129
     }
130 130
 
131 131
     /**
132
-	 * Returns an array of merge tags.
133
-	 *
132
+     * Returns an array of merge tags.
133
+     *
134 134
      * @return array
135
-	 */
136
-	public function get_merge_tags() {
135
+     */
136
+    public function get_merge_tags() {
137 137
 
138 138
         $merge_tags = array(
139 139
             '{site_title}' => wpinv_get_blogname(),
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
     }
145 145
 
146 146
     /**
147
-	 * Adds merge tags to a text.
148
-	 *
147
+     * Adds merge tags to a text.
148
+     *
149 149
      * @param string string $text
150 150
      * @param array $merge_tags
151 151
      * @return string
152
-	 */
153
-	public function add_merge_tags( $text, $merge_tags = array() ) {
152
+     */
153
+    public function add_merge_tags( $text, $merge_tags = array() ) {
154 154
 
155 155
         foreach ( $merge_tags as $key => $value ) {
156 156
             $text = str_replace( $key, $value, $text );
@@ -160,13 +160,13 @@  discard block
 block discarded – undo
160 160
     }
161 161
 
162 162
     /**
163
-	 * Returns the email content
164
-	 *
163
+     * Returns the email content
164
+     *
165 165
      * @param array $merge_tags
166 166
      * @param array $extra_args Extra template args
167 167
      * @return string
168
-	 */
169
-	public function get_content( $merge_tags = array(), $extra_args = array() ) {
168
+     */
169
+    public function get_content( $merge_tags = array(), $extra_args = array() ) {
170 170
 
171 171
         $content = wpinv_get_template_html(
172 172
             "emails/wpinv-email-{$this->id}.php",
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Represents a single email type.
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      * @param string $id Email Type.
33 33
      * @param mixed $object Optional. Associated object.
34 34
 	 */
35
-	public function __construct( $id, $object = false ) {
35
+	public function __construct($id, $object = false) {
36 36
         $this->id     = $id;
37 37
         $this->object = $object;
38 38
     }
@@ -42,18 +42,18 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
      * @return mixed
44 44
 	 */
45
-	public function get_option( $key ) {
45
+	public function get_option($key) {
46 46
 
47 47
         $key   = "email_{$this->id}_$key";
48
-        $value = wpinv_get_option( $key, null );
49
-        if ( is_null( $value ) ) {
48
+        $value = wpinv_get_option($key, null);
49
+        if (is_null($value)) {
50 50
             $options = wpinv_get_emails();
51 51
 
52
-            if ( ! isset( $options[ $this->id ] ) || ! isset( $options[ $this->id ][ $key ] ) ) {
52
+            if (!isset($options[$this->id]) || !isset($options[$this->id][$key])) {
53 53
                 return '';
54 54
             }
55 55
 
56
-            $value = isset( $options[ $this->id ][ $key ]['std'] ) ? $options[ $this->id ][ $key ]['std'] : '';
56
+            $value = isset($options[$this->id][$key]['std']) ? $options[$this->id][$key]['std'] : '';
57 57
         }
58 58
 
59 59
         return $value;
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
      * @return string
66 66
 	 */
67 67
 	public function get_body() {
68
-        $body = $this->get_option( 'body' );
69
-        return apply_filters( 'getpaid_get_email_body', $body, $this->id, $this->object );
68
+        $body = $this->get_option('body');
69
+        return apply_filters('getpaid_get_email_body', $body, $this->id, $this->object);
70 70
     }
71 71
 
72 72
     /**
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
      * @return string
76 76
 	 */
77 77
 	public function get_subject() {
78
-        $subject = $this->get_option( 'subject' );
79
-        return apply_filters( 'getpaid_get_email_subject', $subject, $this->id, $this->object );
78
+        $subject = $this->get_option('subject');
79
+        return apply_filters('getpaid_get_email_subject', $subject, $this->id, $this->object);
80 80
     }
81 81
 
82 82
     /**
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
      * @return string
86 86
 	 */
87 87
 	public function get_heading() {
88
-        $heading = $this->get_option( 'heading' );
89
-        return apply_filters( 'getpaid_get_email_heading', $heading, $this->id, $this->object );
88
+        $heading = $this->get_option('heading');
89
+        return apply_filters('getpaid_get_email_heading', $heading, $this->id, $this->object);
90 90
     }
91 91
 
92 92
     /**
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
      * @return bool
96 96
 	 */
97 97
 	public function is_active() {
98
-        $is_active = ! empty( $this->get_option( 'active' ) );
99
-        return apply_filters( 'getpaid_email_type_is_active', $is_active, $this->id, $this->object );
98
+        $is_active = !empty($this->get_option('active'));
99
+        return apply_filters('getpaid_email_type_is_active', $is_active, $this->id, $this->object);
100 100
     }
101 101
 
102 102
     /**
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
      * @return bool
106 106
 	 */
107 107
 	public function include_admin_bcc() {
108
-        $include_admin_bcc = ! empty( $this->get_option( 'admin_bcc' ) );
109
-        return apply_filters( 'getpaid_email_type_include_admin_bcc', $include_admin_bcc, $this->id, $this->object );
108
+        $include_admin_bcc = !empty($this->get_option('admin_bcc'));
109
+        return apply_filters('getpaid_email_type_include_admin_bcc', $include_admin_bcc, $this->id, $this->object);
110 110
     }
111 111
 
112 112
     /**
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
      * @return bool
116 116
 	 */
117 117
 	public function is_admin_email() {
118
-        $is_admin_email = in_array( $this->id, array( 'new_invoice', 'cancelled_invoice', 'failed_invoice' ) );
119
-        return apply_filters( 'getpaid_email_type_is_admin_email', $is_admin_email, $this->id, $this->object );
118
+        $is_admin_email = in_array($this->id, array('new_invoice', 'cancelled_invoice', 'failed_invoice'));
119
+        return apply_filters('getpaid_email_type_is_admin_email', $is_admin_email, $this->id, $this->object);
120 120
     }
121 121
 
122 122
     /**
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      * @return array
126 126
 	 */
127 127
 	public function get_attachments() {
128
-        return apply_filters( 'getpaid_get_email_attachments', array(), $this->id, $this->object );
128
+        return apply_filters('getpaid_get_email_attachments', array(), $this->id, $this->object);
129 129
     }
130 130
 
131 131
     /**
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
 
138 138
         $merge_tags = array(
139 139
             '{site_title}' => wpinv_get_blogname(),
140
-            '{date}'       => getpaid_format_date_value( current_time( 'mysql' ) ),
140
+            '{date}'       => getpaid_format_date_value(current_time('mysql')),
141 141
         );
142 142
 
143
-        return apply_filters( 'getpaid_get_email_merge_tags', $merge_tags, $this->object, $this->id );
143
+        return apply_filters('getpaid_get_email_merge_tags', $merge_tags, $this->object, $this->id);
144 144
     }
145 145
 
146 146
     /**
@@ -150,13 +150,13 @@  discard block
 block discarded – undo
150 150
      * @param array $merge_tags
151 151
      * @return string
152 152
 	 */
153
-	public function add_merge_tags( $text, $merge_tags = array() ) {
153
+	public function add_merge_tags($text, $merge_tags = array()) {
154 154
 
155
-        foreach ( $merge_tags as $key => $value ) {
156
-            $text = str_replace( $key, $value, $text );
155
+        foreach ($merge_tags as $key => $value) {
156
+            $text = str_replace($key, $value, $text);
157 157
         }
158 158
 
159
-        return wptexturize( $text );
159
+        return wptexturize($text);
160 160
     }
161 161
 
162 162
     /**
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
      * @param array $extra_args Extra template args
167 167
      * @return string
168 168
 	 */
169
-	public function get_content( $merge_tags = array(), $extra_args = array() ) {
169
+	public function get_content($merge_tags = array(), $extra_args = array()) {
170 170
 
171 171
         $content = wpinv_get_template_html(
172 172
             "emails/wpinv-email-{$this->id}.php",
@@ -176,15 +176,15 @@  discard block
 block discarded – undo
176 176
                     'invoice'       => $this->object, // Backwards compat.
177 177
                     'object'        => $this->object,
178 178
                     'email_type'    => $this->id,
179
-                    'email_heading' => $this->add_merge_tags( $this->get_heading(), $merge_tags ),
179
+                    'email_heading' => $this->add_merge_tags($this->get_heading(), $merge_tags),
180 180
                     'sent_to_admin' => $this->is_admin_email(),
181 181
                     'plain_text'    => false,
182
-                    'message_body'  => wpautop( $this->add_merge_tags( $this->get_body(), $merge_tags ) ),
182
+                    'message_body'  => wpautop($this->add_merge_tags($this->get_body(), $merge_tags)),
183 183
                 )
184 184
             )
185 185
         );
186 186
 
187
-        return wpinv_email_style_body( $content );
187
+        return wpinv_email_style_body($content);
188 188
     }
189 189
 
190 190
 }
Please login to merge, or discard this patch.
includes/class-wpinv.php 2 patches
Indentation   +484 added lines, -484 removed lines patch added patch discarded remove patch
@@ -14,427 +14,427 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class WPInv_Plugin {
16 16
 
17
-	/**
18
-	 * GetPaid version.
19
-	 *
20
-	 * @var string
21
-	 */
22
-	public $version;
23
-
24
-	/**
25
-	 * Data container.
26
-	 *
27
-	 * @var array
28
-	 */
29
-	protected $data = array();
30
-
31
-	/**
32
-	 * Form elements instance.
33
-	 *
34
-	 * @var WPInv_Payment_Form_Elements
35
-	 */
36
-	public $form_elements;
37
-
38
-	/**
39
-	 * Tax instance.
40
-	 *
41
-	 * @var WPInv_EUVat
42
-	 */
43
-	public $tax;
44
-
45
-	/**
46
-	 * @param array An array of payment gateways.
47
-	 */
48
-	public $gateways;
49
-
50
-	/**
51
-	 * Class constructor.
52
-	 */
53
-	public function __construct() {
54
-		$this->define_constants();
55
-		$this->includes();
56
-		$this->init_hooks();
57
-		$this->set_properties();
58
-	}
59
-
60
-	/**
61
-	 * Sets a custom data property.
62
-	 * 
63
-	 * @param string $prop The prop to set.
64
-	 * @param mixed $value The value to retrieve.
65
-	 */
66
-	public function set( $prop, $value ) {
67
-		$this->data[ $prop ] = $value;
68
-	}
69
-
70
-	/**
71
-	 * Gets a custom data property.
72
-	 *
73
-	 * @param string $prop The prop to set.
74
-	 * @return mixed The value.
75
-	 */
76
-	public function get( $prop ) {
77
-
78
-		if ( isset( $this->data[ $prop ] ) ) {
79
-			return $this->data[ $prop ];
80
-		}
81
-
82
-		return null;
83
-	}
84
-
85
-	/**
86
-	 * Define class properties.
87
-	 */
88
-	public function set_properties() {
89
-
90
-		// Sessions.
91
-		$this->set( 'session', new WPInv_Session_Handler() );
92
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
93
-		$this->form_elements = new WPInv_Payment_Form_Elements();
94
-		$this->tax           = new WPInv_EUVat();
95
-		$this->tax->init();
96
-		$GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility.
97
-
98
-		// Init other objects.
99
-		$this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor.
100
-		$this->set( 'session', new WPInv_Session_Handler() );
101
-		$this->set( 'notes', new WPInv_Notes() );
102
-		$this->set( 'api', new WPInv_API() );
103
-		$this->set( 'post_types', new GetPaid_Post_Types() );
104
-		$this->set( 'template', new GetPaid_Template() );
105
-		$this->set( 'admin', new GetPaid_Admin() );
106
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
107
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
108
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
109
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
110
-		$this->set( 'payment_forms', new GetPaid_Payment_Forms() );
111
-
112
-	}
113
-
114
-	 /**
115
-	 * Define plugin constants.
116
-	 */
117
-	public function define_constants() {
118
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
119
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
120
-		$this->version = WPINV_VERSION;
121
-	}
122
-
123
-	/**
124
-	 * Hook into actions and filters.
125
-	 *
126
-	 * @since 1.0.19
127
-	 */
128
-	protected function init_hooks() {
129
-		/* Internationalize the text strings used. */
130
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
131
-
132
-		// Init the plugin after WordPress inits.
133
-		add_action( 'init', array( $this, 'init' ), 1 );
134
-		add_action( 'getpaid_init', array( $this, 'maybe_process_ipn' ), 5 );
135
-		add_action( 'init', array( &$this, 'wpinv_actions' ) );
136
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
137
-
138
-		if ( class_exists( 'BuddyPress' ) ) {
139
-			add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
140
-		}
141
-
142
-		add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
143
-		add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
144
-		add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
145
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
146
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
147
-
148
-		// Fires after registering actions.
149
-		do_action( 'wpinv_actions', $this );
150
-		do_action( 'getpaid_actions', $this );
151
-
152
-	}
153
-
154
-	public function plugins_loaded() {
155
-		/* Internationalize the text strings used. */
156
-		$this->load_textdomain();
157
-
158
-		do_action( 'wpinv_loaded' );
159
-
160
-		// Fix oxygen page builder conflict
161
-		if ( function_exists( 'ct_css_output' ) ) {
162
-			wpinv_oxygen_fix_conflict();
163
-		}
164
-	}
165
-
166
-	/**
167
-	 * Load the translation of the plugin.
168
-	 *
169
-	 * @since 1.0
170
-	 */
171
-	public function load_textdomain( $locale = NULL ) {
172
-		if ( empty( $locale ) ) {
173
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
174
-		}
175
-
176
-		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
177
-
178
-		unload_textdomain( 'invoicing' );
179
-		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
180
-		load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
181
-
182
-		/**
183
-		 * Define language constants.
184
-		 */
185
-		require_once( WPINV_PLUGIN_DIR . 'language.php' );
186
-	}
187
-
188
-	/**
189
-	 * Include required core files used in admin and on the frontend.
190
-	 */
191
-	public function includes() {
192
-
193
-		// Start with the settings.
194
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
195
-
196
-		// Packages/libraries.
197
-		require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
198
-		require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
199
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' );
200
-
201
-		// Load functions.
202
-		require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
203
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
204
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
205
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
206
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
207
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
208
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
209
-		require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
210
-		require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
211
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
212
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
213
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
214
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
215
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
216
-		require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
217
-
218
-		// Register autoloader.
219
-		try {
220
-			spl_autoload_register( array( $this, 'autoload' ), true );
221
-		} catch ( Exception $e ) {
222
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
223
-		}
224
-
225
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
226
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
227
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
228
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
229
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
230
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
231
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
232
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
233
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
234
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
235
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
236
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
237
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
238
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
239
-		require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
240
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
241
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
242
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
243
-		require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
244
-		require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
245
-		require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
246
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
247
-
248
-		/**
249
-		 * Load the tax class.
250
-		 */
251
-		if ( ! class_exists( 'WPInv_EUVat' ) ) {
252
-			require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
253
-		}
254
-
255
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
256
-			GetPaid_Post_Types_Admin::init();
257
-
258
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
259
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
260
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
261
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
262
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
263
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
264
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
265
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
266
-			// load the user class only on the users.php page
267
-			global $pagenow;
268
-			if($pagenow=='users.php'){
269
-				new WPInv_Admin_Users();
270
-			}
271
-		}
272
-
273
-		// Register cli commands
274
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
275
-			require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
276
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
277
-		}
278
-
279
-		// include css inliner
280
-		if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
281
-			include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
282
-		}
283
-
284
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
285
-	}
286
-
287
-	/**
288
-	 * Class autoloader
289
-	 *
290
-	 * @param       string $class_name The name of the class to load.
291
-	 * @access      public
292
-	 * @since       1.0.19
293
-	 * @return      void
294
-	 */
295
-	public function autoload( $class_name ) {
296
-
297
-		// Normalize the class name...
298
-		$class_name  = strtolower( $class_name );
299
-
300
-		// ... and make sure it is our class.
301
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
302
-			return;
303
-		}
304
-
305
-		// Next, prepare the file name from the class.
306
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
307
-
308
-		// Base path of the classes.
309
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
310
-
311
-		// And an array of possible locations in order of importance.
312
-		$locations = array(
313
-			"$plugin_path/includes",
314
-			"$plugin_path/includes/data-stores",
315
-			"$plugin_path/includes/gateways",
316
-			"$plugin_path/includes/api",
317
-			"$plugin_path/includes/admin",
318
-			"$plugin_path/includes/admin/meta-boxes",
319
-		);
320
-
321
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
322
-
323
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
324
-				include trailingslashit( $location ) . $file_name;
325
-				break;
326
-			}
327
-
328
-		}
329
-
330
-	}
331
-
332
-	/**
333
-	 * Inits hooks etc.
334
-	 */
335
-	public function init() {
336
-
337
-		// Fires before getpaid inits.
338
-		do_action( 'before_getpaid_init', $this );
339
-
340
-		// Load default gateways.
341
-		$gateways = apply_filters(
342
-			'getpaid_default_gateways',
343
-			array(
344
-				'manual'        => 'GetPaid_Manual_Gateway',
345
-				'paypal'        => 'GetPaid_Paypal_Gateway',
346
-				'worldpay'      => 'GetPaid_Worldpay_Gateway',
347
-				'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
348
-				'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
349
-			)
350
-		);
351
-
352
-		foreach ( $gateways as $id => $class ) {
353
-			$this->gateways[ $id ] = new $class();
354
-		}
355
-
356
-		// Fires after getpaid inits.
357
-		do_action( 'getpaid_init', $this );
358
-
359
-	}
360
-
361
-	/**
362
-	 * Checks if this is an IPN request and processes it.
363
-	 */
364
-	public function maybe_process_ipn() {
365
-
366
-		// Ensure that this is an IPN request.
367
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
368
-			return;
369
-		}
370
-
371
-		$gateway = wpinv_clean( $_GET['wpi-gateway'] );
372
-
373
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
374
-		do_action( "wpinv_verify_{$gateway}_ipn" );
375
-		exit;
376
-
377
-	}
378
-
379
-	public function enqueue_scripts() {
380
-		$suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
381
-
382
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
383
-		wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
384
-		wp_enqueue_style( 'wpinv_front_style' );
385
-
386
-		// Register scripts
387
-		wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
388
-		wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) );
389
-
390
-		$localize                         = array();
391
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
392
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
393
-		$localize['currency_symbol']      = wpinv_currency_symbol();
394
-		$localize['currency_pos']         = wpinv_currency_position();
395
-		$localize['thousand_sep']         = wpinv_thousands_separator();
396
-		$localize['decimal_sep']          = wpinv_decimal_separator();
397
-		$localize['decimals']             = wpinv_decimals();
398
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
399
-		$localize['UseTaxes']             = wpinv_use_taxes();
400
-		$localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
401
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
402
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
403
-
404
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
405
-
406
-		wp_enqueue_script( 'jquery-blockui' );
407
-		$autofill_api = wpinv_get_option('address_autofill_api');
408
-		$autofill_active = wpinv_get_option('address_autofill_active');
409
-		if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
410
-			if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
411
-				wp_dequeue_script( 'google-maps-api' );
412
-			}
413
-			wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
414
-			wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
415
-		}
416
-
417
-		wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
418
-		wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
419
-
420
-		wp_enqueue_script( 'wpinv-front-script' );
421
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
422
-
423
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
424
-		wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
425
-	}
426
-
427
-	public function wpinv_actions() {
428
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
429
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
430
-		}
431
-	}
432
-
433
-	/**
17
+    /**
18
+     * GetPaid version.
19
+     *
20
+     * @var string
21
+     */
22
+    public $version;
23
+
24
+    /**
25
+     * Data container.
26
+     *
27
+     * @var array
28
+     */
29
+    protected $data = array();
30
+
31
+    /**
32
+     * Form elements instance.
33
+     *
34
+     * @var WPInv_Payment_Form_Elements
35
+     */
36
+    public $form_elements;
37
+
38
+    /**
39
+     * Tax instance.
40
+     *
41
+     * @var WPInv_EUVat
42
+     */
43
+    public $tax;
44
+
45
+    /**
46
+     * @param array An array of payment gateways.
47
+     */
48
+    public $gateways;
49
+
50
+    /**
51
+     * Class constructor.
52
+     */
53
+    public function __construct() {
54
+        $this->define_constants();
55
+        $this->includes();
56
+        $this->init_hooks();
57
+        $this->set_properties();
58
+    }
59
+
60
+    /**
61
+     * Sets a custom data property.
62
+     * 
63
+     * @param string $prop The prop to set.
64
+     * @param mixed $value The value to retrieve.
65
+     */
66
+    public function set( $prop, $value ) {
67
+        $this->data[ $prop ] = $value;
68
+    }
69
+
70
+    /**
71
+     * Gets a custom data property.
72
+     *
73
+     * @param string $prop The prop to set.
74
+     * @return mixed The value.
75
+     */
76
+    public function get( $prop ) {
77
+
78
+        if ( isset( $this->data[ $prop ] ) ) {
79
+            return $this->data[ $prop ];
80
+        }
81
+
82
+        return null;
83
+    }
84
+
85
+    /**
86
+     * Define class properties.
87
+     */
88
+    public function set_properties() {
89
+
90
+        // Sessions.
91
+        $this->set( 'session', new WPInv_Session_Handler() );
92
+        $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
93
+        $this->form_elements = new WPInv_Payment_Form_Elements();
94
+        $this->tax           = new WPInv_EUVat();
95
+        $this->tax->init();
96
+        $GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility.
97
+
98
+        // Init other objects.
99
+        $this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor.
100
+        $this->set( 'session', new WPInv_Session_Handler() );
101
+        $this->set( 'notes', new WPInv_Notes() );
102
+        $this->set( 'api', new WPInv_API() );
103
+        $this->set( 'post_types', new GetPaid_Post_Types() );
104
+        $this->set( 'template', new GetPaid_Template() );
105
+        $this->set( 'admin', new GetPaid_Admin() );
106
+        $this->set( 'subscriptions', new WPInv_Subscriptions() );
107
+        $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
108
+        $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
109
+        $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
110
+        $this->set( 'payment_forms', new GetPaid_Payment_Forms() );
111
+
112
+    }
113
+
114
+        /**
115
+         * Define plugin constants.
116
+         */
117
+    public function define_constants() {
118
+        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
119
+        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
120
+        $this->version = WPINV_VERSION;
121
+    }
122
+
123
+    /**
124
+     * Hook into actions and filters.
125
+     *
126
+     * @since 1.0.19
127
+     */
128
+    protected function init_hooks() {
129
+        /* Internationalize the text strings used. */
130
+        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
131
+
132
+        // Init the plugin after WordPress inits.
133
+        add_action( 'init', array( $this, 'init' ), 1 );
134
+        add_action( 'getpaid_init', array( $this, 'maybe_process_ipn' ), 5 );
135
+        add_action( 'init', array( &$this, 'wpinv_actions' ) );
136
+        add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
137
+
138
+        if ( class_exists( 'BuddyPress' ) ) {
139
+            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
140
+        }
141
+
142
+        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
143
+        add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
144
+        add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
145
+        add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
146
+        add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
147
+
148
+        // Fires after registering actions.
149
+        do_action( 'wpinv_actions', $this );
150
+        do_action( 'getpaid_actions', $this );
151
+
152
+    }
153
+
154
+    public function plugins_loaded() {
155
+        /* Internationalize the text strings used. */
156
+        $this->load_textdomain();
157
+
158
+        do_action( 'wpinv_loaded' );
159
+
160
+        // Fix oxygen page builder conflict
161
+        if ( function_exists( 'ct_css_output' ) ) {
162
+            wpinv_oxygen_fix_conflict();
163
+        }
164
+    }
165
+
166
+    /**
167
+     * Load the translation of the plugin.
168
+     *
169
+     * @since 1.0
170
+     */
171
+    public function load_textdomain( $locale = NULL ) {
172
+        if ( empty( $locale ) ) {
173
+            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
174
+        }
175
+
176
+        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
177
+
178
+        unload_textdomain( 'invoicing' );
179
+        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
180
+        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
181
+
182
+        /**
183
+         * Define language constants.
184
+         */
185
+        require_once( WPINV_PLUGIN_DIR . 'language.php' );
186
+    }
187
+
188
+    /**
189
+     * Include required core files used in admin and on the frontend.
190
+     */
191
+    public function includes() {
192
+
193
+        // Start with the settings.
194
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
195
+
196
+        // Packages/libraries.
197
+        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
198
+        require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
199
+        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' );
200
+
201
+        // Load functions.
202
+        require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
203
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
204
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
205
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
206
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
207
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
208
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
209
+        require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
210
+        require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
211
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
212
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
213
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
214
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
215
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
216
+        require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
217
+
218
+        // Register autoloader.
219
+        try {
220
+            spl_autoload_register( array( $this, 'autoload' ), true );
221
+        } catch ( Exception $e ) {
222
+            wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
223
+        }
224
+
225
+        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
226
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
227
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
228
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
229
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
230
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
231
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
232
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
233
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
234
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
235
+        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
236
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
237
+        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
238
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
239
+        require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
240
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
241
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
242
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
243
+        require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
244
+        require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
245
+        require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
246
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
247
+
248
+        /**
249
+         * Load the tax class.
250
+         */
251
+        if ( ! class_exists( 'WPInv_EUVat' ) ) {
252
+            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
253
+        }
254
+
255
+        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
256
+            GetPaid_Post_Types_Admin::init();
257
+
258
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
259
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
260
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
261
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
262
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
263
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
264
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
265
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
266
+            // load the user class only on the users.php page
267
+            global $pagenow;
268
+            if($pagenow=='users.php'){
269
+                new WPInv_Admin_Users();
270
+            }
271
+        }
272
+
273
+        // Register cli commands
274
+        if ( defined( 'WP_CLI' ) && WP_CLI ) {
275
+            require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
276
+            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
277
+        }
278
+
279
+        // include css inliner
280
+        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
281
+            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
282
+        }
283
+
284
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
285
+    }
286
+
287
+    /**
288
+     * Class autoloader
289
+     *
290
+     * @param       string $class_name The name of the class to load.
291
+     * @access      public
292
+     * @since       1.0.19
293
+     * @return      void
294
+     */
295
+    public function autoload( $class_name ) {
296
+
297
+        // Normalize the class name...
298
+        $class_name  = strtolower( $class_name );
299
+
300
+        // ... and make sure it is our class.
301
+        if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
302
+            return;
303
+        }
304
+
305
+        // Next, prepare the file name from the class.
306
+        $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
307
+
308
+        // Base path of the classes.
309
+        $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
310
+
311
+        // And an array of possible locations in order of importance.
312
+        $locations = array(
313
+            "$plugin_path/includes",
314
+            "$plugin_path/includes/data-stores",
315
+            "$plugin_path/includes/gateways",
316
+            "$plugin_path/includes/api",
317
+            "$plugin_path/includes/admin",
318
+            "$plugin_path/includes/admin/meta-boxes",
319
+        );
320
+
321
+        foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
322
+
323
+            if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
324
+                include trailingslashit( $location ) . $file_name;
325
+                break;
326
+            }
327
+
328
+        }
329
+
330
+    }
331
+
332
+    /**
333
+     * Inits hooks etc.
334
+     */
335
+    public function init() {
336
+
337
+        // Fires before getpaid inits.
338
+        do_action( 'before_getpaid_init', $this );
339
+
340
+        // Load default gateways.
341
+        $gateways = apply_filters(
342
+            'getpaid_default_gateways',
343
+            array(
344
+                'manual'        => 'GetPaid_Manual_Gateway',
345
+                'paypal'        => 'GetPaid_Paypal_Gateway',
346
+                'worldpay'      => 'GetPaid_Worldpay_Gateway',
347
+                'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
348
+                'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
349
+            )
350
+        );
351
+
352
+        foreach ( $gateways as $id => $class ) {
353
+            $this->gateways[ $id ] = new $class();
354
+        }
355
+
356
+        // Fires after getpaid inits.
357
+        do_action( 'getpaid_init', $this );
358
+
359
+    }
360
+
361
+    /**
362
+     * Checks if this is an IPN request and processes it.
363
+     */
364
+    public function maybe_process_ipn() {
365
+
366
+        // Ensure that this is an IPN request.
367
+        if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
368
+            return;
369
+        }
370
+
371
+        $gateway = wpinv_clean( $_GET['wpi-gateway'] );
372
+
373
+        do_action( 'wpinv_verify_payment_ipn', $gateway );
374
+        do_action( "wpinv_verify_{$gateway}_ipn" );
375
+        exit;
376
+
377
+    }
378
+
379
+    public function enqueue_scripts() {
380
+        $suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
381
+
382
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
383
+        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
384
+        wp_enqueue_style( 'wpinv_front_style' );
385
+
386
+        // Register scripts
387
+        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
388
+        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) );
389
+
390
+        $localize                         = array();
391
+        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
392
+        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
393
+        $localize['currency_symbol']      = wpinv_currency_symbol();
394
+        $localize['currency_pos']         = wpinv_currency_position();
395
+        $localize['thousand_sep']         = wpinv_thousands_separator();
396
+        $localize['decimal_sep']          = wpinv_decimal_separator();
397
+        $localize['decimals']             = wpinv_decimals();
398
+        $localize['txtComplete']          = __( 'Continue', 'invoicing' );
399
+        $localize['UseTaxes']             = wpinv_use_taxes();
400
+        $localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
401
+        $localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
402
+        $localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
403
+
404
+        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
405
+
406
+        wp_enqueue_script( 'jquery-blockui' );
407
+        $autofill_api = wpinv_get_option('address_autofill_api');
408
+        $autofill_active = wpinv_get_option('address_autofill_active');
409
+        if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
410
+            if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
411
+                wp_dequeue_script( 'google-maps-api' );
412
+            }
413
+            wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
414
+            wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
415
+        }
416
+
417
+        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
418
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
419
+
420
+        wp_enqueue_script( 'wpinv-front-script' );
421
+        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
422
+
423
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
424
+        wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
425
+    }
426
+
427
+    public function wpinv_actions() {
428
+        if ( isset( $_REQUEST['wpi_action'] ) ) {
429
+            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
430
+        }
431
+    }
432
+
433
+    /**
434 434
      * Fires an action after verifying that a user can fire them.
435
-	 *
436
-	 * Note: If the action is on an invoice, subscription etc, esure that the
437
-	 * current user owns the invoice/subscription.
435
+     *
436
+     * Note: If the action is on an invoice, subscription etc, esure that the
437
+     * current user owns the invoice/subscription.
438 438
      */
439 439
     public function maybe_do_authenticated_action() {
440 440
 
@@ -445,82 +445,82 @@  discard block
 block discarded – undo
445 445
 
446 446
     }
447 447
 
448
-	public function pre_get_posts( $wp_query ) {
449
-		if ( ! is_admin() && !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
450
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
451
-		}
452
-
453
-		return $wp_query;
454
-	}
455
-
456
-	public function bp_invoicing_init() {
457
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
458
-	}
459
-
460
-	/**
461
-	 * Register widgets
462
-	 *
463
-	 */
464
-	public function register_widgets() {
465
-		$widgets = apply_filters(
466
-			'getpaid_widget_classes',
467
-			array(
468
-				'WPInv_Checkout_Widget',
469
-				'WPInv_History_Widget',
470
-				'WPInv_Receipt_Widget',
471
-				'WPInv_Subscriptions_Widget',
472
-				'WPInv_Buy_Item_Widget',
473
-				'WPInv_Messages_Widget',
474
-				'WPInv_GetPaid_Widget'
475
-			)
476
-		);
477
-
478
-		foreach ( $widgets as $widget ) {
479
-			register_widget( $widget );
480
-		}
448
+    public function pre_get_posts( $wp_query ) {
449
+        if ( ! is_admin() && !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
450
+            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
451
+        }
452
+
453
+        return $wp_query;
454
+    }
455
+
456
+    public function bp_invoicing_init() {
457
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
458
+    }
459
+
460
+    /**
461
+     * Register widgets
462
+     *
463
+     */
464
+    public function register_widgets() {
465
+        $widgets = apply_filters(
466
+            'getpaid_widget_classes',
467
+            array(
468
+                'WPInv_Checkout_Widget',
469
+                'WPInv_History_Widget',
470
+                'WPInv_Receipt_Widget',
471
+                'WPInv_Subscriptions_Widget',
472
+                'WPInv_Buy_Item_Widget',
473
+                'WPInv_Messages_Widget',
474
+                'WPInv_GetPaid_Widget'
475
+            )
476
+        );
477
+
478
+        foreach ( $widgets as $widget ) {
479
+            register_widget( $widget );
480
+        }
481 481
 		
482
-	}
482
+    }
483 483
 
484
-	/**
485
-	 * Remove our pages from yoast sitemaps.
486
-	 *
487
-	 * @since 1.0.19
488
-	 * @param int[] $excluded_posts_ids
489
-	 */
490
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
484
+    /**
485
+     * Remove our pages from yoast sitemaps.
486
+     *
487
+     * @since 1.0.19
488
+     * @param int[] $excluded_posts_ids
489
+     */
490
+    public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
491 491
 
492
-		// Ensure that we have an array.
493
-		if ( ! is_array( $excluded_posts_ids ) ) {
494
-			$excluded_posts_ids = array();
495
-		}
492
+        // Ensure that we have an array.
493
+        if ( ! is_array( $excluded_posts_ids ) ) {
494
+            $excluded_posts_ids = array();
495
+        }
496 496
 
497
-		// Prepare our pages.
498
-		$our_pages = array();
497
+        // Prepare our pages.
498
+        $our_pages = array();
499 499
 
500
-		// Checkout page.
501
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
500
+        // Checkout page.
501
+        $our_pages[] = wpinv_get_option( 'checkout_page', false );
502 502
 
503
-		// Success page.
504
-		$our_pages[] = wpinv_get_option( 'success_page', false );
503
+        // Success page.
504
+        $our_pages[] = wpinv_get_option( 'success_page', false );
505 505
 
506
-		// Failure page.
507
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
506
+        // Failure page.
507
+        $our_pages[] = wpinv_get_option( 'failure_page', false );
508 508
 
509
-		// History page.
510
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
509
+        // History page.
510
+        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
511 511
 
512
-		// Subscriptions page.
513
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
512
+        // Subscriptions page.
513
+        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
514 514
 
515
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
515
+        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
516 516
 
517
-		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
518
-		return array_unique( $excluded_posts_ids );
517
+        $excluded_posts_ids = $excluded_posts_ids + $our_pages;
518
+        return array_unique( $excluded_posts_ids );
519 519
 
520
-	}
520
+    }
521 521
 
522
-	public function wp_footer() {
523
-		echo '
522
+    public function wp_footer() {
523
+        echo '
524 524
 			<div class="bsui">
525 525
 				<div  id="getpaid-payment-modal" class="modal" tabindex="-1" role="dialog">
526 526
 					<div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;">
@@ -531,6 +531,6 @@  discard block
 block discarded – undo
531 531
 				</div>
532 532
 			</div>
533 533
 		';
534
-	}
534
+    }
535 535
 
536 536
 }
Please login to merge, or discard this patch.
Spacing   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   1.0.0
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Main Invoicing class.
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 	 * @param string $prop The prop to set.
64 64
 	 * @param mixed $value The value to retrieve.
65 65
 	 */
66
-	public function set( $prop, $value ) {
67
-		$this->data[ $prop ] = $value;
66
+	public function set($prop, $value) {
67
+		$this->data[$prop] = $value;
68 68
 	}
69 69
 
70 70
 	/**
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
 	 * @param string $prop The prop to set.
74 74
 	 * @return mixed The value.
75 75
 	 */
76
-	public function get( $prop ) {
76
+	public function get($prop) {
77 77
 
78
-		if ( isset( $this->data[ $prop ] ) ) {
79
-			return $this->data[ $prop ];
78
+		if (isset($this->data[$prop])) {
79
+			return $this->data[$prop];
80 80
 		}
81 81
 
82 82
 		return null;
@@ -88,26 +88,26 @@  discard block
 block discarded – undo
88 88
 	public function set_properties() {
89 89
 
90 90
 		// Sessions.
91
-		$this->set( 'session', new WPInv_Session_Handler() );
92
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
91
+		$this->set('session', new WPInv_Session_Handler());
92
+		$GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility.
93 93
 		$this->form_elements = new WPInv_Payment_Form_Elements();
94 94
 		$this->tax           = new WPInv_EUVat();
95 95
 		$this->tax->init();
96 96
 		$GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility.
97 97
 
98 98
 		// Init other objects.
99
-		$this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor.
100
-		$this->set( 'session', new WPInv_Session_Handler() );
101
-		$this->set( 'notes', new WPInv_Notes() );
102
-		$this->set( 'api', new WPInv_API() );
103
-		$this->set( 'post_types', new GetPaid_Post_Types() );
104
-		$this->set( 'template', new GetPaid_Template() );
105
-		$this->set( 'admin', new GetPaid_Admin() );
106
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
107
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
108
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
109
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
110
-		$this->set( 'payment_forms', new GetPaid_Payment_Forms() );
99
+		$this->set('reports', new WPInv_Reports()); // TODO: Refactor.
100
+		$this->set('session', new WPInv_Session_Handler());
101
+		$this->set('notes', new WPInv_Notes());
102
+		$this->set('api', new WPInv_API());
103
+		$this->set('post_types', new GetPaid_Post_Types());
104
+		$this->set('template', new GetPaid_Template());
105
+		$this->set('admin', new GetPaid_Admin());
106
+		$this->set('subscriptions', new WPInv_Subscriptions());
107
+		$this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails());
108
+		$this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails());
109
+		$this->set('daily_maintenace', new GetPaid_Daily_Maintenance());
110
+		$this->set('payment_forms', new GetPaid_Payment_Forms());
111 111
 
112 112
 	}
113 113
 
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 	 * Define plugin constants.
116 116
 	 */
117 117
 	public function define_constants() {
118
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
119
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
118
+		define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
119
+		define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
120 120
 		$this->version = WPINV_VERSION;
121 121
 	}
122 122
 
@@ -127,27 +127,27 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	protected function init_hooks() {
129 129
 		/* Internationalize the text strings used. */
130
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
130
+		add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
131 131
 
132 132
 		// Init the plugin after WordPress inits.
133
-		add_action( 'init', array( $this, 'init' ), 1 );
134
-		add_action( 'getpaid_init', array( $this, 'maybe_process_ipn' ), 5 );
135
-		add_action( 'init', array( &$this, 'wpinv_actions' ) );
136
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
133
+		add_action('init', array($this, 'init'), 1);
134
+		add_action('getpaid_init', array($this, 'maybe_process_ipn'), 5);
135
+		add_action('init', array(&$this, 'wpinv_actions'));
136
+		add_action('init', array($this, 'maybe_do_authenticated_action'), 100);
137 137
 
138
-		if ( class_exists( 'BuddyPress' ) ) {
139
-			add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
138
+		if (class_exists('BuddyPress')) {
139
+			add_action('bp_include', array(&$this, 'bp_invoicing_init'));
140 140
 		}
141 141
 
142
-		add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
143
-		add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
144
-		add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
145
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
146
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
142
+		add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
143
+		add_action('wp_footer', array(&$this, 'wp_footer'));
144
+		add_action('widgets_init', array(&$this, 'register_widgets'));
145
+		add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids'));
146
+		add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
147 147
 
148 148
 		// Fires after registering actions.
149
-		do_action( 'wpinv_actions', $this );
150
-		do_action( 'getpaid_actions', $this );
149
+		do_action('wpinv_actions', $this);
150
+		do_action('getpaid_actions', $this);
151 151
 
152 152
 	}
153 153
 
@@ -155,10 +155,10 @@  discard block
 block discarded – undo
155 155
 		/* Internationalize the text strings used. */
156 156
 		$this->load_textdomain();
157 157
 
158
-		do_action( 'wpinv_loaded' );
158
+		do_action('wpinv_loaded');
159 159
 
160 160
 		// Fix oxygen page builder conflict
161
-		if ( function_exists( 'ct_css_output' ) ) {
161
+		if (function_exists('ct_css_output')) {
162 162
 			wpinv_oxygen_fix_conflict();
163 163
 		}
164 164
 	}
@@ -168,21 +168,21 @@  discard block
 block discarded – undo
168 168
 	 *
169 169
 	 * @since 1.0
170 170
 	 */
171
-	public function load_textdomain( $locale = NULL ) {
172
-		if ( empty( $locale ) ) {
173
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
171
+	public function load_textdomain($locale = NULL) {
172
+		if (empty($locale)) {
173
+			$locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
174 174
 		}
175 175
 
176
-		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
176
+		$locale = apply_filters('plugin_locale', $locale, 'invoicing');
177 177
 
178
-		unload_textdomain( 'invoicing' );
179
-		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
180
-		load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
178
+		unload_textdomain('invoicing');
179
+		load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
180
+		load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
181 181
 
182 182
 		/**
183 183
 		 * Define language constants.
184 184
 		 */
185
-		require_once( WPINV_PLUGIN_DIR . 'language.php' );
185
+		require_once(WPINV_PLUGIN_DIR . 'language.php');
186 186
 	}
187 187
 
188 188
 	/**
@@ -191,97 +191,97 @@  discard block
 block discarded – undo
191 191
 	public function includes() {
192 192
 
193 193
 		// Start with the settings.
194
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
194
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
195 195
 
196 196
 		// Packages/libraries.
197
-		require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
198
-		require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
199
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' );
197
+		require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
198
+		require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php');
199
+		require_once(WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php');
200 200
 
201 201
 		// Load functions.
202
-		require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
203
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
204
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
205
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
206
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
207
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
208
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
209
-		require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
210
-		require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
211
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
212
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
213
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
214
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
215
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
216
-		require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
202
+		require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php');
203
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
204
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
205
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
206
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
207
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
208
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
209
+		require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php');
210
+		require_once(WPINV_PLUGIN_DIR . 'includes/subscription-functions.php');
211
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
212
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
213
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
214
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
215
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
216
+		require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php');
217 217
 
218 218
 		// Register autoloader.
219 219
 		try {
220
-			spl_autoload_register( array( $this, 'autoload' ), true );
221
-		} catch ( Exception $e ) {
222
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
220
+			spl_autoload_register(array($this, 'autoload'), true);
221
+		} catch (Exception $e) {
222
+			wpinv_error_log($e->getMessage(), '', __FILE__, 149, true);
223 223
 		}
224 224
 
225
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
226
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
227
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
228
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
229
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
230
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
231
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
232
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
233
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
234
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
235
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
236
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
237
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
238
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
239
-		require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
240
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
241
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
242
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
243
-		require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
244
-		require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
245
-		require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
246
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
225
+		require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php');
226
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php');
227
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
228
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
229
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
230
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
231
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
232
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
233
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
234
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
235
+		require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php');
236
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
237
+		require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php');
238
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php');
239
+		require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php');
240
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php');
241
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php');
242
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php');
243
+		require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php');
244
+		require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php');
245
+		require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php');
246
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php');
247 247
 
248 248
 		/**
249 249
 		 * Load the tax class.
250 250
 		 */
251
-		if ( ! class_exists( 'WPInv_EUVat' ) ) {
252
-			require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
251
+		if (!class_exists('WPInv_EUVat')) {
252
+			require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
253 253
 		}
254 254
 
255
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
255
+		if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
256 256
 			GetPaid_Post_Types_Admin::init();
257 257
 
258
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
259
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
260
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
261
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
262
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
263
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
264
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
265
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
258
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
259
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
260
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php');
261
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
262
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
263
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
264
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
265
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php');
266 266
 			// load the user class only on the users.php page
267 267
 			global $pagenow;
268
-			if($pagenow=='users.php'){
268
+			if ($pagenow == 'users.php') {
269 269
 				new WPInv_Admin_Users();
270 270
 			}
271 271
 		}
272 272
 
273 273
 		// Register cli commands
274
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
275
-			require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
276
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
274
+		if (defined('WP_CLI') && WP_CLI) {
275
+			require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php');
276
+			WP_CLI::add_command('invoicing', 'WPInv_CLI');
277 277
 		}
278 278
 
279 279
 		// include css inliner
280
-		if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
281
-			include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
280
+		if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
281
+			include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
282 282
 		}
283 283
 
284
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
284
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
285 285
 	}
286 286
 
287 287
 	/**
@@ -292,21 +292,21 @@  discard block
 block discarded – undo
292 292
 	 * @since       1.0.19
293 293
 	 * @return      void
294 294
 	 */
295
-	public function autoload( $class_name ) {
295
+	public function autoload($class_name) {
296 296
 
297 297
 		// Normalize the class name...
298
-		$class_name  = strtolower( $class_name );
298
+		$class_name = strtolower($class_name);
299 299
 
300 300
 		// ... and make sure it is our class.
301
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
301
+		if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) {
302 302
 			return;
303 303
 		}
304 304
 
305 305
 		// Next, prepare the file name from the class.
306
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
306
+		$file_name = 'class-' . str_replace('_', '-', $class_name) . '.php';
307 307
 
308 308
 		// Base path of the classes.
309
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
309
+		$plugin_path = untrailingslashit(WPINV_PLUGIN_DIR);
310 310
 
311 311
 		// And an array of possible locations in order of importance.
312 312
 		$locations = array(
@@ -318,10 +318,10 @@  discard block
 block discarded – undo
318 318
 			"$plugin_path/includes/admin/meta-boxes",
319 319
 		);
320 320
 
321
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
321
+		foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) {
322 322
 
323
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
324
-				include trailingslashit( $location ) . $file_name;
323
+			if (file_exists(trailingslashit($location) . $file_name)) {
324
+				include trailingslashit($location) . $file_name;
325 325
 				break;
326 326
 			}
327 327
 
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 	public function init() {
336 336
 
337 337
 		// Fires before getpaid inits.
338
-		do_action( 'before_getpaid_init', $this );
338
+		do_action('before_getpaid_init', $this);
339 339
 
340 340
 		// Load default gateways.
341 341
 		$gateways = apply_filters(
@@ -349,12 +349,12 @@  discard block
 block discarded – undo
349 349
 			)
350 350
 		);
351 351
 
352
-		foreach ( $gateways as $id => $class ) {
353
-			$this->gateways[ $id ] = new $class();
352
+		foreach ($gateways as $id => $class) {
353
+			$this->gateways[$id] = new $class();
354 354
 		}
355 355
 
356 356
 		// Fires after getpaid inits.
357
-		do_action( 'getpaid_init', $this );
357
+		do_action('getpaid_init', $this);
358 358
 
359 359
 	}
360 360
 
@@ -364,69 +364,69 @@  discard block
 block discarded – undo
364 364
 	public function maybe_process_ipn() {
365 365
 
366 366
 		// Ensure that this is an IPN request.
367
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
367
+		if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) {
368 368
 			return;
369 369
 		}
370 370
 
371
-		$gateway = wpinv_clean( $_GET['wpi-gateway'] );
371
+		$gateway = wpinv_clean($_GET['wpi-gateway']);
372 372
 
373
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
374
-		do_action( "wpinv_verify_{$gateway}_ipn" );
373
+		do_action('wpinv_verify_payment_ipn', $gateway);
374
+		do_action("wpinv_verify_{$gateway}_ipn");
375 375
 		exit;
376 376
 
377 377
 	}
378 378
 
379 379
 	public function enqueue_scripts() {
380
-		$suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
380
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
381 381
 
382
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
383
-		wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
384
-		wp_enqueue_style( 'wpinv_front_style' );
382
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css');
383
+		wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version);
384
+		wp_enqueue_style('wpinv_front_style');
385 385
 
386 386
 		// Register scripts
387
-		wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
388
-		wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) );
387
+		wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
388
+		wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), filemtime(WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js'));
389 389
 
390 390
 		$localize                         = array();
391
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
392
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
391
+		$localize['ajax_url']             = admin_url('admin-ajax.php');
392
+		$localize['nonce']                = wp_create_nonce('wpinv-nonce');
393 393
 		$localize['currency_symbol']      = wpinv_currency_symbol();
394 394
 		$localize['currency_pos']         = wpinv_currency_position();
395 395
 		$localize['thousand_sep']         = wpinv_thousands_separator();
396 396
 		$localize['decimal_sep']          = wpinv_decimal_separator();
397 397
 		$localize['decimals']             = wpinv_decimals();
398
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
398
+		$localize['txtComplete']          = __('Continue', 'invoicing');
399 399
 		$localize['UseTaxes']             = wpinv_use_taxes();
400
-		$localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
401
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
402
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
400
+		$localize['checkoutNonce']        = wp_create_nonce('wpinv_checkout_nonce');
401
+		$localize['formNonce']            = wp_create_nonce('getpaid_form_nonce');
402
+		$localize['connectionError']      = __('Could not establish a connection to the server.', 'invoicing');
403 403
 
404
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
404
+		$localize = apply_filters('wpinv_front_js_localize', $localize);
405 405
 
406
-		wp_enqueue_script( 'jquery-blockui' );
406
+		wp_enqueue_script('jquery-blockui');
407 407
 		$autofill_api = wpinv_get_option('address_autofill_api');
408 408
 		$autofill_active = wpinv_get_option('address_autofill_active');
409
-		if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
410
-			if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
411
-				wp_dequeue_script( 'google-maps-api' );
409
+		if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
410
+			if (wp_script_is('google-maps-api', 'enqueued')) {
411
+				wp_dequeue_script('google-maps-api');
412 412
 			}
413
-			wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
414
-			wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
413
+			wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
414
+			wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
415 415
 		}
416 416
 
417
-		wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
418
-		wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
417
+		wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
418
+		wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
419 419
 
420
-		wp_enqueue_script( 'wpinv-front-script' );
421
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
420
+		wp_enqueue_script('wpinv-front-script');
421
+		wp_localize_script('wpinv-front-script', 'WPInv', $localize);
422 422
 
423
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
424
-		wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
423
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js');
424
+		wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script', 'wp-hooks'), $version, true);
425 425
 	}
426 426
 
427 427
 	public function wpinv_actions() {
428
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
429
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
428
+		if (isset($_REQUEST['wpi_action'])) {
429
+			do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
430 430
 		}
431 431
 	}
432 432
 
@@ -438,23 +438,23 @@  discard block
 block discarded – undo
438 438
      */
439 439
     public function maybe_do_authenticated_action() {
440 440
 
441
-        if ( is_user_logged_in() && isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
442
-            $key = sanitize_key( $_REQUEST['getpaid-action'] );
443
-            do_action( "getpaid_authenticated_action_$key", $_REQUEST );
441
+        if (is_user_logged_in() && isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
442
+            $key = sanitize_key($_REQUEST['getpaid-action']);
443
+            do_action("getpaid_authenticated_action_$key", $_REQUEST);
444 444
         }
445 445
 
446 446
     }
447 447
 
448
-	public function pre_get_posts( $wp_query ) {
449
-		if ( ! is_admin() && !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
450
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
448
+	public function pre_get_posts($wp_query) {
449
+		if (!is_admin() && !empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
450
+			$wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
451 451
 		}
452 452
 
453 453
 		return $wp_query;
454 454
 	}
455 455
 
456 456
 	public function bp_invoicing_init() {
457
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
457
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
458 458
 	}
459 459
 
460 460
 	/**
@@ -475,8 +475,8 @@  discard block
 block discarded – undo
475 475
 			)
476 476
 		);
477 477
 
478
-		foreach ( $widgets as $widget ) {
479
-			register_widget( $widget );
478
+		foreach ($widgets as $widget) {
479
+			register_widget($widget);
480 480
 		}
481 481
 		
482 482
 	}
@@ -487,10 +487,10 @@  discard block
 block discarded – undo
487 487
 	 * @since 1.0.19
488 488
 	 * @param int[] $excluded_posts_ids
489 489
 	 */
490
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
490
+	public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) {
491 491
 
492 492
 		// Ensure that we have an array.
493
-		if ( ! is_array( $excluded_posts_ids ) ) {
493
+		if (!is_array($excluded_posts_ids)) {
494 494
 			$excluded_posts_ids = array();
495 495
 		}
496 496
 
@@ -498,24 +498,24 @@  discard block
 block discarded – undo
498 498
 		$our_pages = array();
499 499
 
500 500
 		// Checkout page.
501
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
501
+		$our_pages[] = wpinv_get_option('checkout_page', false);
502 502
 
503 503
 		// Success page.
504
-		$our_pages[] = wpinv_get_option( 'success_page', false );
504
+		$our_pages[] = wpinv_get_option('success_page', false);
505 505
 
506 506
 		// Failure page.
507
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
507
+		$our_pages[] = wpinv_get_option('failure_page', false);
508 508
 
509 509
 		// History page.
510
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
510
+		$our_pages[] = wpinv_get_option('invoice_history_page', false);
511 511
 
512 512
 		// Subscriptions page.
513
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
513
+		$our_pages[] = wpinv_get_option('invoice_subscription_page', false);
514 514
 
515
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
515
+		$our_pages   = array_map('intval', array_filter($our_pages));
516 516
 
517 517
 		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
518
-		return array_unique( $excluded_posts_ids );
518
+		return array_unique($excluded_posts_ids);
519 519
 
520 520
 	}
521 521
 
Please login to merge, or discard this patch.
includes/data/email-settings.php 1 patch
Spacing   +236 added lines, -236 removed lines patch added patch discarded remove patch
@@ -8,24 +8,24 @@  discard block
 block discarded – undo
8 8
  * @version 1.0.19
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 // Prepare the due date reminder options.
14 14
 $overdue_days_options       = array();
15
-$overdue_days_options['0']  = __( 'On the Due Date', 'invoicing' );
16
-$overdue_days_options['1']  = __( '1 day after Due Date', 'invoicing' );
15
+$overdue_days_options['0']  = __('On the Due Date', 'invoicing');
16
+$overdue_days_options['1']  = __('1 day after Due Date', 'invoicing');
17 17
 
18
-for ( $i = 2; $i <= 10; $i++ ) {
19
-    $overdue_days_options["$i"] = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i );
18
+for ($i = 2; $i <= 10; $i++) {
19
+    $overdue_days_options["$i"] = wp_sprintf(__('%d days after Due Date', 'invoicing'), $i);
20 20
 }
21 21
 
22 22
 // Prepare up coming renewal reminder options.
23 23
 $renewal_days_options       = array();
24
-$renewal_days_options['0']  = __( 'On the renewal date', 'invoicing' );
25
-$renewal_days_options['1']  = __( '1 day before the renewal date', 'invoicing' );
24
+$renewal_days_options['0']  = __('On the renewal date', 'invoicing');
25
+$renewal_days_options['1']  = __('1 day before the renewal date', 'invoicing');
26 26
 
27
-for ( $i = 2; $i <= 10; $i++ ) {
28
-    $renewal_days_options["$i"]   = wp_sprintf( __( '%d days before the renewal date', 'invoicing' ), $i );
27
+for ($i = 2; $i <= 10; $i++) {
28
+    $renewal_days_options["$i"] = wp_sprintf(__('%d days before the renewal date', 'invoicing'), $i);
29 29
 }
30 30
 
31 31
 // Default, built-in gateways
@@ -34,45 +34,45 @@  discard block
 block discarded – undo
34 34
 
35 35
         'email_new_invoice_header' => array(
36 36
             'id'       => 'email_new_invoice_header',
37
-            'name'     => '<h3>' . __( 'New Invoice', 'invoicing' ) . '</h3>',
38
-            'desc'     => __( 'These emails are sent to the site admin whenever there is a new invoice.', 'invoicing' ),
37
+            'name'     => '<h3>' . __('New Invoice', 'invoicing') . '</h3>',
38
+            'desc'     => __('These emails are sent to the site admin whenever there is a new invoice.', 'invoicing'),
39 39
             'type'     => 'header',
40 40
         ),
41 41
 
42 42
         'email_new_invoice_active' => array(
43 43
             'id'       => 'email_new_invoice_active',
44
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
45
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
44
+            'name'     => __('Enable/Disable', 'invoicing'),
45
+            'desc'     => __('Enable this email notification', 'invoicing'),
46 46
             'type'     => 'checkbox',
47 47
             'std'      => 1
48 48
         ),
49 49
 
50 50
         'email_new_invoice_subject' => array(
51 51
             'id'       => 'email_new_invoice_subject',
52
-            'name'     => __( 'Subject', 'invoicing' ),
53
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
52
+            'name'     => __('Subject', 'invoicing'),
53
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
54 54
             'help-tip' => true,
55 55
             'type'     => 'text',
56
-            'std'      => __( '[{site_title}] We sent your invoice ({invoice_number}) for {invoice_total} {invoice_currency}', 'invoicing' ),
56
+            'std'      => __('[{site_title}] We sent your invoice ({invoice_number}) for {invoice_total} {invoice_currency}', 'invoicing'),
57 57
             'size'     => 'large'
58 58
         ),
59 59
 
60 60
         'email_new_invoice_heading' => array(
61 61
             'id'       => 'email_new_invoice_heading',
62
-            'name'     => __( 'Email Heading', 'invoicing' ),
63
-            'desc'     => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
62
+            'name'     => __('Email Heading', 'invoicing'),
63
+            'desc'     => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
64 64
             'help-tip' => true,
65 65
             'type'     => 'text',
66
-            'std'      => __( 'Invoice sent', 'invoicing' ),
66
+            'std'      => __('Invoice sent', 'invoicing'),
67 67
             'size'     => 'large'
68 68
         ),
69 69
 
70 70
         'email_new_invoice_body' => array(
71 71
             'id'       => 'email_new_invoice_body',
72
-            'name'     => __( 'Email Content', 'invoicing' ),
73
-            'desc'     => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
72
+            'name'     => __('Email Content', 'invoicing'),
73
+            'desc'     => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
74 74
             'type'     => 'rich_editor',
75
-            'std'      => __( '<p>We sent your invoice <a href="{invoice_link}">({invoice_number})</a> to {name} for {invoice_total} {invoice_currency}.</p>', 'invoicing' ),
75
+            'std'      => __('<p>We sent your invoice <a href="{invoice_link}">({invoice_number})</a> to {name} for {invoice_total} {invoice_currency}.</p>', 'invoicing'),
76 76
             'class'    => 'large',
77 77
             'size'     => '10'
78 78
         ),
@@ -82,45 +82,45 @@  discard block
 block discarded – undo
82 82
 
83 83
         'email_cancelled_invoice_header' => array(
84 84
             'id'       => 'email_cancelled_invoice_header',
85
-            'name'     => '<h3>' . __( 'Cancelled Invoice', 'invoicing' ) . '</h3>',
86
-            'desc'     => __( 'These emails are sent to the site admin whenever invoices are cancelled.', 'invoicing' ),
85
+            'name'     => '<h3>' . __('Cancelled Invoice', 'invoicing') . '</h3>',
86
+            'desc'     => __('These emails are sent to the site admin whenever invoices are cancelled.', 'invoicing'),
87 87
             'type'     => 'header',
88 88
         ),
89 89
 
90 90
         'email_cancelled_invoice_active' => array(
91 91
             'id'       => 'email_cancelled_invoice_active',
92
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
93
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
92
+            'name'     => __('Enable/Disable', 'invoicing'),
93
+            'desc'     => __('Enable this email notification', 'invoicing'),
94 94
             'type'     => 'checkbox',
95 95
             'std'      => 1
96 96
         ),
97 97
 
98 98
         'email_cancelled_invoice_subject' => array(
99 99
             'id'       => 'email_cancelled_invoice_subject',
100
-            'name'     => __( 'Subject', 'invoicing' ),
101
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
100
+            'name'     => __('Subject', 'invoicing'),
101
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
102 102
             'help-tip' => true,
103 103
             'type'     => 'text',
104
-            'std'      => __( '[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing' ),
104
+            'std'      => __('[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing'),
105 105
             'size'     => 'large'
106 106
         ),
107 107
 
108 108
         'email_cancelled_invoice_heading' => array(
109 109
             'id'       => 'email_cancelled_invoice_heading',
110
-            'name'     => __( 'Email Heading', 'invoicing' ),
111
-            'desc'     => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
110
+            'name'     => __('Email Heading', 'invoicing'),
111
+            'desc'     => __('Enter the main heading contained within the email notification.', 'invoicing'),
112 112
             'help-tip' => true,
113 113
             'type'     => 'text',
114
-            'std'      => __( 'Cancelled Invoice', 'invoicing' ),
114
+            'std'      => __('Cancelled Invoice', 'invoicing'),
115 115
             'size'     => 'large'
116 116
         ),
117 117
 
118 118
         'email_cancelled_invoice_body' => array(
119 119
             'id'       => 'email_cancelled_invoice_body',
120
-            'name'     => __( 'Email Content', 'invoicing' ),
121
-            'desc'     => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
120
+            'name'     => __('Email Content', 'invoicing'),
121
+            'desc'     => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
122 122
             'type'     => 'rich_editor',
123
-            'std'      => __( '<p>The invoice <a href="{invoice_link}">#{invoice_number}</a> created for {name} on {site_title} has been cancelled.</p>', 'invoicing' ),
123
+            'std'      => __('<p>The invoice <a href="{invoice_link}">#{invoice_number}</a> created for {name} on {site_title} has been cancelled.</p>', 'invoicing'),
124 124
             'class'    => 'large',
125 125
             'size'     => '10'
126 126
         ),
@@ -131,45 +131,45 @@  discard block
 block discarded – undo
131 131
 
132 132
         'email_failed_invoice_header' => array(
133 133
             'id'       => 'email_failed_invoice_header',
134
-            'name'     => '<h3>' . __( 'Failed Invoice', 'invoicing' ) . '</h3>',
135
-            'desc'     => __( 'Failed invoice emails are sent to the site admin when invoice payments fail.', 'invoicing' ),
134
+            'name'     => '<h3>' . __('Failed Invoice', 'invoicing') . '</h3>',
135
+            'desc'     => __('Failed invoice emails are sent to the site admin when invoice payments fail.', 'invoicing'),
136 136
             'type'     => 'header',
137 137
         ),
138 138
 
139 139
         'email_failed_invoice_active' => array(
140 140
             'id'       => 'email_failed_invoice_active',
141
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
142
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
141
+            'name'     => __('Enable/Disable', 'invoicing'),
142
+            'desc'     => __('Enable this email notification', 'invoicing'),
143 143
             'type'     => 'checkbox',
144 144
             'std'      => 1
145 145
         ),
146 146
 
147 147
         'email_failed_invoice_subject' => array(
148 148
             'id'       => 'email_failed_invoice_subject',
149
-            'name'     => __( 'Subject', 'invoicing' ),
150
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
149
+            'name'     => __('Subject', 'invoicing'),
150
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
151 151
             'help-tip' => true,
152 152
             'type'     => 'text',
153
-            'std'      => __( '[{site_title}] Failed invoice ({invoice_number})', 'invoicing' ),
153
+            'std'      => __('[{site_title}] Failed invoice ({invoice_number})', 'invoicing'),
154 154
             'size'     => 'large'
155 155
         ),
156 156
 
157 157
         'email_failed_invoice_heading' => array(
158 158
             'id'       => 'email_failed_invoice_heading',
159
-            'name'     => __( 'Email Heading', 'invoicing' ),
160
-            'desc'     => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
159
+            'name'     => __('Email Heading', 'invoicing'),
160
+            'desc'     => __('Enter the main heading contained within the email notification.', 'invoicing'),
161 161
             'help-tip' => true,
162 162
             'type'     => 'text',
163
-            'std'      => __( 'Failed invoice', 'invoicing' ),
163
+            'std'      => __('Failed invoice', 'invoicing'),
164 164
             'size'     => 'large'
165 165
         ),
166 166
 
167 167
         'email_failed_invoice_body' => array(
168 168
             'id'       => 'email_failed_invoice_body',
169
-            'name'     => __( 'Email Content', 'invoicing' ),
170
-            'desc'     => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
169
+            'name'     => __('Email Content', 'invoicing'),
170
+            'desc'     => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
171 171
             'type'     => 'rich_editor',
172
-            'std'      => __( '<p>Payment for the invoice <a href="{invoice_link}">#{invoice_number}</a> on {site_title} has failed to go through.</p>', 'invoicing' ),
172
+            'std'      => __('<p>Payment for the invoice <a href="{invoice_link}">#{invoice_number}</a> on {site_title} has failed to go through.</p>', 'invoicing'),
173 173
             'class'    => 'large',
174 174
             'size'     => '10'
175 175
         ),
@@ -179,53 +179,53 @@  discard block
 block discarded – undo
179 179
 
180 180
         'email_onhold_invoice_header' => array(
181 181
             'id'       => 'email_onhold_invoice_header',
182
-            'name'     => '<h3>' . __( 'On Hold Invoice', 'invoicing' ) . '</h3>',
183
-            'desc'     => __( 'These emails are sent to customers whenever their invoices are held.', 'invoicing' ),
182
+            'name'     => '<h3>' . __('On Hold Invoice', 'invoicing') . '</h3>',
183
+            'desc'     => __('These emails are sent to customers whenever their invoices are held.', 'invoicing'),
184 184
             'type'     => 'header',
185 185
         ),
186 186
 
187 187
         'email_onhold_invoice_active' => array(
188 188
             'id'       => 'email_onhold_invoice_active',
189
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
190
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
189
+            'name'     => __('Enable/Disable', 'invoicing'),
190
+            'desc'     => __('Enable this email notification', 'invoicing'),
191 191
             'type'     => 'checkbox',
192 192
             'std'      => 1
193 193
         ),
194 194
 
195 195
         'email_onhold_invoice_admin_bcc' => array(
196 196
             'id'       => 'email_onhold_invoice_admin_bcc',
197
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
198
-            'desc'     => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
197
+            'name'     => __('Enable Admin BCC', 'invoicing'),
198
+            'desc'     => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
199 199
             'type'     => 'checkbox',
200 200
             'std'      => 1
201 201
         ),
202 202
 
203 203
         'email_onhold_invoice_subject' => array(
204 204
             'id'       => 'email_onhold_invoice_subject',
205
-            'name'     => __( 'Subject', 'invoicing' ),
206
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
205
+            'name'     => __('Subject', 'invoicing'),
206
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
207 207
             'help-tip' => true,
208 208
             'type'     => 'text',
209
-            'std'      => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ),
209
+            'std'      => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'),
210 210
             'size'     => 'large'
211 211
         ),
212 212
 
213 213
         'email_onhold_invoice_heading' => array(
214 214
             'id'       => 'email_onhold_invoice_heading',
215
-            'name'     => __( 'Email Heading', 'invoicing' ),
216
-            'desc'     => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
215
+            'name'     => __('Email Heading', 'invoicing'),
216
+            'desc'     => __('Enter the main heading contained within the email notification.', 'invoicing'),
217 217
             'help-tip' => true,
218 218
             'type'     => 'text',
219
-            'std'      => __( 'Thank you for your invoice', 'invoicing' ),
219
+            'std'      => __('Thank you for your invoice', 'invoicing'),
220 220
             'size'     => 'large'
221 221
         ),
222 222
 
223 223
         'email_onhold_invoice_body' => array(
224 224
             'id'       => 'email_onhold_invoice_body',
225
-            'name'     => __( 'Email Content', 'invoicing' ),
226
-            'desc'     => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
225
+            'name'     => __('Email Content', 'invoicing'),
226
+            'desc'     => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
227 227
             'type'     => 'rich_editor',
228
-            'std'      => __( '<p>Hi {name},</p><p>Your invoice is on-hold and will be processed when we receive your payment.</p>', 'invoicing' ),
228
+            'std'      => __('<p>Hi {name},</p><p>Your invoice is on-hold and will be processed when we receive your payment.</p>', 'invoicing'),
229 229
             'class'    => 'large',
230 230
             'size'     => '10'
231 231
         ),
@@ -236,53 +236,53 @@  discard block
 block discarded – undo
236 236
 
237 237
         'email_processing_invoice_header' => array(
238 238
             'id'       => 'email_processing_invoice_header',
239
-            'name'     => '<h3>' . __( 'Processing Invoice', 'invoicing' ) . '</h3>',
240
-            'desc'     => __( 'These emails are sent to users whenever payments for their invoices are processing.', 'invoicing' ),
239
+            'name'     => '<h3>' . __('Processing Invoice', 'invoicing') . '</h3>',
240
+            'desc'     => __('These emails are sent to users whenever payments for their invoices are processing.', 'invoicing'),
241 241
             'type'     => 'header',
242 242
         ),
243 243
 
244 244
         'email_processing_invoice_active' => array(
245 245
             'id'       => 'email_processing_invoice_active',
246
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
247
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
246
+            'name'     => __('Enable/Disable', 'invoicing'),
247
+            'desc'     => __('Enable this email notification', 'invoicing'),
248 248
             'type'     => 'checkbox',
249 249
             'std'      => 1
250 250
         ),
251 251
 
252 252
         'email_processing_invoice_admin_bcc' => array(
253 253
             'id'       => 'email_processing_invoice_admin_bcc',
254
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
255
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
254
+            'name'     => __('Enable Admin BCC', 'invoicing'),
255
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
256 256
             'type'     => 'checkbox',
257 257
             'std'      => 1
258 258
         ),
259 259
 
260 260
         'email_processing_invoice_subject' => array(
261 261
             'id'       => 'email_processing_invoice_subject',
262
-            'name'     => __( 'Subject', 'invoicing' ),
263
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
262
+            'name'     => __('Subject', 'invoicing'),
263
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
264 264
             'help-tip' => true,
265 265
             'type'     => 'text',
266
-            'std'      => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ),
266
+            'std'      => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'),
267 267
             'size'     => 'large'
268 268
         ),
269 269
 
270 270
         'email_processing_invoice_heading' => array(
271 271
             'id'       => 'email_processing_invoice_heading',
272
-            'name'     => __( 'Email Heading', 'invoicing' ),
273
-            'desc'     => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
272
+            'name'     => __('Email Heading', 'invoicing'),
273
+            'desc'     => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
274 274
             'help-tip' => true,
275 275
             'type'     => 'text',
276
-            'std'      => __( 'Thank you for your invoice', 'invoicing' ),
276
+            'std'      => __('Thank you for your invoice', 'invoicing'),
277 277
             'size'     => 'large'
278 278
         ),
279 279
 
280 280
         'email_processing_invoice_body' => array(
281 281
             'id'       => 'email_processing_invoice_body',
282
-            'name'     => __( 'Email Content', 'invoicing' ),
283
-            'desc'     => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
282
+            'name'     => __('Email Content', 'invoicing'),
283
+            'desc'     => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
284 284
             'type'     => 'rich_editor',
285
-            'std'      => __( '<p>Hi {name},</p><p>I would like to let you know that we have received and are currently processing your payment for the invoice <a href="{invoice_link}">#{invoice_number}</a> on {site_title}.</p>', 'invoicing' ),
285
+            'std'      => __('<p>Hi {name},</p><p>I would like to let you know that we have received and are currently processing your payment for the invoice <a href="{invoice_link}">#{invoice_number}</a> on {site_title}.</p>', 'invoicing'),
286 286
             'class'    => 'large',
287 287
             'size'     => '10'
288 288
         ),
@@ -293,61 +293,61 @@  discard block
 block discarded – undo
293 293
 
294 294
         'email_completed_invoice_header' => array(
295 295
             'id'       => 'email_completed_invoice_header',
296
-            'name'     => '<h3>' . __( 'Paid Invoice', 'invoicing' ) . '</h3>',
297
-            'desc'     => __( 'These emails are sent to customers when their invoices are marked as paid.', 'invoicing' ),
296
+            'name'     => '<h3>' . __('Paid Invoice', 'invoicing') . '</h3>',
297
+            'desc'     => __('These emails are sent to customers when their invoices are marked as paid.', 'invoicing'),
298 298
             'type'     => 'header',
299 299
         ),
300 300
 
301 301
         'email_completed_invoice_active' => array(
302 302
             'id'       => 'email_completed_invoice_active',
303
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
304
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
303
+            'name'     => __('Enable/Disable', 'invoicing'),
304
+            'desc'     => __('Enable this email notification', 'invoicing'),
305 305
             'type'     => 'checkbox',
306 306
             'std'      => 1
307 307
         ),
308 308
 
309 309
         'email_completed_invoice_renewal_active' => array(
310 310
             'id'       => 'email_completed_invoice_renewal_active',
311
-            'name'     => __( 'Enable renewal notification', 'invoicing' ),
312
-            'desc'     => __( 'Should this email be sent for renewals too?', 'invoicing' ),
311
+            'name'     => __('Enable renewal notification', 'invoicing'),
312
+            'desc'     => __('Should this email be sent for renewals too?', 'invoicing'),
313 313
             'type'     => 'checkbox',
314 314
             'std'      => 1
315 315
         ),
316 316
 
317 317
         'email_completed_invoice_admin_bcc' => array(
318 318
             'id'       => 'email_completed_invoice_admin_bcc',
319
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
320
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
319
+            'name'     => __('Enable Admin BCC', 'invoicing'),
320
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
321 321
             'type'     => 'checkbox',
322 322
             'std'      => 1,
323 323
         ),
324 324
 
325 325
         'email_completed_invoice_subject' => array(
326 326
             'id'       => 'email_completed_invoice_subject',
327
-            'name'     => __( 'Subject', 'invoicing' ),
328
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
327
+            'name'     => __('Subject', 'invoicing'),
328
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
329 329
             'help-tip' => true,
330 330
             'type'     => 'text',
331
-            'std'      => __( '[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing' ),
331
+            'std'      => __('[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing'),
332 332
             'size'     => 'large'
333 333
         ),
334 334
 
335 335
         'email_completed_invoice_heading' => array(
336 336
             'id'       => 'email_completed_invoice_heading',
337
-            'name'     => __( 'Email Heading', 'invoicing' ),
338
-            'desc'     => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
337
+            'name'     => __('Email Heading', 'invoicing'),
338
+            'desc'     => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
339 339
             'help-tip' => true,
340 340
             'type'     => 'text',
341
-            'std'      => __( 'Your invoice has been paid', 'invoicing' ),
341
+            'std'      => __('Your invoice has been paid', 'invoicing'),
342 342
             'size'     => 'large'
343 343
         ),
344 344
 
345 345
         'email_completed_invoice_body' => array(
346 346
             'id'       => 'email_completed_invoice_body',
347
-            'name'     => __( 'Email Content', 'invoicing' ),
348
-            'desc'     => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
347
+            'name'     => __('Email Content', 'invoicing'),
348
+            'desc'     => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
349 349
             'type'     => 'rich_editor',
350
-            'std'      => __( '<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing' ),
350
+            'std'      => __('<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing'),
351 351
             'class'    => 'large',
352 352
             'size'     => '10'
353 353
         ),
@@ -358,53 +358,53 @@  discard block
 block discarded – undo
358 358
 
359 359
         'email_refunded_invoice_header' => array(
360 360
             'id'       => 'email_refunded_invoice_header',
361
-            'name'     => '<h3>' . __( 'Refunded Invoice', 'invoicing' ) . '</h3>',
362
-            'desc'     => __( 'These emails are sent to users when their invoices are marked as refunded.', 'invoicing' ),
361
+            'name'     => '<h3>' . __('Refunded Invoice', 'invoicing') . '</h3>',
362
+            'desc'     => __('These emails are sent to users when their invoices are marked as refunded.', 'invoicing'),
363 363
             'type'     => 'header',
364 364
         ),
365 365
 
366 366
         'email_refunded_invoice_active' => array(
367 367
             'id'       => 'email_refunded_invoice_active',
368
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
369
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
368
+            'name'     => __('Enable/Disable', 'invoicing'),
369
+            'desc'     => __('Enable this email notification', 'invoicing'),
370 370
             'type'     => 'checkbox',
371 371
             'std'      => 1
372 372
         ),
373 373
 
374 374
         'email_refunded_invoice_admin_bcc' => array(
375 375
             'id'       => 'email_refunded_invoice_admin_bcc',
376
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
377
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
376
+            'name'     => __('Enable Admin BCC', 'invoicing'),
377
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
378 378
             'type'     => 'checkbox',
379 379
             'std'      => 1
380 380
         ),
381 381
 
382 382
         'email_refunded_invoice_subject' => array(
383 383
             'id'       => 'email_refunded_invoice_subject',
384
-            'name'     => __( 'Subject', 'invoicing' ),
385
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
384
+            'name'     => __('Subject', 'invoicing'),
385
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
386 386
             'help-tip' => true,
387 387
             'type'     => 'text',
388
-            'std'      => __( '[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing' ),
388
+            'std'      => __('[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing'),
389 389
             'size'     => 'large'
390 390
         ),
391 391
 
392 392
         'email_refunded_invoice_heading' => array(
393 393
             'id'       => 'email_refunded_invoice_heading',
394
-            'name'     => __( 'Email Heading', 'invoicing' ),
395
-            'desc'     => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
394
+            'name'     => __('Email Heading', 'invoicing'),
395
+            'desc'     => __('Enter the main heading contained within the email notification.', 'invoicing'),
396 396
             'help-tip' => true,
397 397
             'type'     => 'text',
398
-            'std'      => __( 'Your invoice has been refunded', 'invoicing' ),
398
+            'std'      => __('Your invoice has been refunded', 'invoicing'),
399 399
             'size'     => 'large'
400 400
         ),
401 401
 
402 402
         'email_refunded_invoice_body' => array(
403 403
             'id'       => 'email_refunded_invoice_body',
404
-            'name'     => __( 'Email Content', 'invoicing' ),
405
-            'desc'     => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
404
+            'name'     => __('Email Content', 'invoicing'),
405
+            'desc'     => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
406 406
             'type'     => 'rich_editor',
407
-            'std'      => __( '<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing' ),
407
+            'std'      => __('<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing'),
408 408
             'class'    => 'large',
409 409
             'size'     => '10'
410 410
         ),
@@ -415,53 +415,53 @@  discard block
 block discarded – undo
415 415
 
416 416
         'email_user_invoice_header' => array(
417 417
             'id'       => 'email_user_invoice_header',
418
-            'name'     => '<h3>' . __( 'Customer Invoice', 'invoicing' ) . '</h3>',
419
-            'desc'     => __( 'These emails are sent to customers containing their invoice information and payment links.', 'invoicing' ),
418
+            'name'     => '<h3>' . __('Customer Invoice', 'invoicing') . '</h3>',
419
+            'desc'     => __('These emails are sent to customers containing their invoice information and payment links.', 'invoicing'),
420 420
             'type'     => 'header',
421 421
         ),
422 422
 
423 423
         'email_user_invoice_active' => array(
424 424
             'id'       => 'email_user_invoice_active',
425
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
426
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
425
+            'name'     => __('Enable/Disable', 'invoicing'),
426
+            'desc'     => __('Enable this email notification', 'invoicing'),
427 427
             'type'     => 'checkbox',
428 428
             'std'      => 1
429 429
         ),
430 430
 
431 431
         'email_user_invoice_admin_bcc' => array(
432 432
             'id'       => 'email_user_invoice_admin_bcc',
433
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
434
-            'desc'     => __( 'Check if you want to send a copy of this notification email to to the site admin.', 'invoicing' ),
433
+            'name'     => __('Enable Admin BCC', 'invoicing'),
434
+            'desc'     => __('Check if you want to send a copy of this notification email to to the site admin.', 'invoicing'),
435 435
             'type'     => 'checkbox',
436 436
             'std'      => 0
437 437
         ),
438 438
 
439 439
         'email_user_invoice_subject' => array(
440 440
             'id'       => 'email_user_invoice_subject',
441
-            'name'     => __( 'Subject', 'invoicing' ),
442
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
441
+            'name'     => __('Subject', 'invoicing'),
442
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
443 443
             'help-tip' => true,
444 444
             'type'     => 'text',
445
-            'std'      => __( '[{site_title}] Your invoice from {invoice_date}', 'invoicing' ),
445
+            'std'      => __('[{site_title}] Your invoice from {invoice_date}', 'invoicing'),
446 446
             'size'     => 'large'
447 447
         ),
448 448
 
449 449
         'email_user_invoice_heading' => array(
450 450
             'id'       => 'email_user_invoice_heading',
451
-            'name'     => __( 'Email Heading', 'invoicing' ),
452
-            'desc'     => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
451
+            'name'     => __('Email Heading', 'invoicing'),
452
+            'desc'     => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
453 453
             'help-tip' => true,
454 454
             'type'     => 'text',
455
-            'std'      => __( 'Your invoice {invoice_number} details', 'invoicing' ),
455
+            'std'      => __('Your invoice {invoice_number} details', 'invoicing'),
456 456
             'size'     => 'large'
457 457
         ),
458 458
 
459 459
         'email_user_invoice_body' => array(
460 460
             'id'       => 'email_user_invoice_body',
461
-            'name'     => __( 'Email Content', 'invoicing' ),
462
-            'desc'     => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
461
+            'name'     => __('Email Content', 'invoicing'),
462
+            'desc'     => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
463 463
             'type'     => 'rich_editor',
464
-            'std'      => __( '<p>Hi {name},</p><p>An invoice of {invoice_total} has been created for you on {site_title}. You can <a href="{invoice_link}">view</a> or <a href="{invoice_pay_link}">pay</a> the invoice. Please reply to this email if you have any questions about the invoice.', 'invoicing' ),
464
+            'std'      => __('<p>Hi {name},</p><p>An invoice of {invoice_total} has been created for you on {site_title}. You can <a href="{invoice_link}">view</a> or <a href="{invoice_pay_link}">pay</a> the invoice. Please reply to this email if you have any questions about the invoice.', 'invoicing'),
465 465
             'class'    => 'large',
466 466
             'size'     => '10'
467 467
         ),
@@ -471,53 +471,53 @@  discard block
 block discarded – undo
471 471
 
472 472
         'email_user_note_header' => array(
473 473
             'id'       => 'email_user_note_header',
474
-            'name'     => '<h3>' . __( 'Customer Note', 'invoicing' ) . '</h3>',
475
-            'desc'     => __( 'These emails are sent when you add a customer note to an invoice/quote.', 'invoicing' ),
474
+            'name'     => '<h3>' . __('Customer Note', 'invoicing') . '</h3>',
475
+            'desc'     => __('These emails are sent when you add a customer note to an invoice/quote.', 'invoicing'),
476 476
             'type'     => 'header',
477 477
         ),
478 478
 
479 479
         'email_user_note_active' => array(
480 480
             'id'       => 'email_user_note_active',
481
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
482
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
481
+            'name'     => __('Enable/Disable', 'invoicing'),
482
+            'desc'     => __('Enable this email notification', 'invoicing'),
483 483
             'type'     => 'checkbox',
484 484
             'std'      => 1
485 485
         ),
486 486
 
487 487
         'email_user_note_admin_bcc' => array(
488 488
             'id'       => 'email_user_note_admin_bcc',
489
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
490
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
489
+            'name'     => __('Enable Admin BCC', 'invoicing'),
490
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
491 491
             'type'     => 'checkbox',
492 492
             'std'      => 0
493 493
         ),
494 494
 
495 495
         'email_user_note_subject' => array(
496 496
             'id'       => 'email_user_note_subject',
497
-            'name'     => __( 'Subject', 'invoicing' ),
498
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
497
+            'name'     => __('Subject', 'invoicing'),
498
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
499 499
             'help-tip' => true,
500 500
             'type'     => 'text',
501
-            'std'      => __( '[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing' ),
501
+            'std'      => __('[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing'),
502 502
             'size'     => 'large'
503 503
         ),
504 504
 
505 505
         'email_user_note_heading' => array(
506 506
             'id'       => 'email_user_note_heading',
507
-            'name'     => __( 'Email Heading', 'invoicing' ),
508
-            'desc'     => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
507
+            'name'     => __('Email Heading', 'invoicing'),
508
+            'desc'     => __('Enter the main heading contained within the email notification.', 'invoicing'),
509 509
             'help-tip' => true,
510 510
             'type'     => 'text',
511
-            'std'      => __( 'A note has been added to your {invoice_label}', 'invoicing' ),
511
+            'std'      => __('A note has been added to your {invoice_label}', 'invoicing'),
512 512
             'size'     => 'large'
513 513
         ),
514 514
 
515 515
         'email_user_note_body' => array(
516 516
             'id'       => 'email_user_note_body',
517
-            'name'     => __( 'Email Content', 'invoicing' ),
518
-            'desc'     => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
517
+            'name'     => __('Email Content', 'invoicing'),
518
+            'desc'     => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
519 519
             'type'     => 'rich_editor',
520
-            'std'      => __( '<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing' ),
520
+            'std'      => __('<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing'),
521 521
             'class'    => 'large',
522 522
             'size'     => '10'
523 523
         ),
@@ -528,63 +528,63 @@  discard block
 block discarded – undo
528 528
 
529 529
         'email_overdue_header' => array(
530 530
             'id'       => 'email_overdue_header',
531
-            'name'     => '<h3>' . __( 'Payment Reminder', 'invoicing' ) . '</h3>',
532
-            'desc'     => __( 'Payment reminder emails are sent to customers whenever their invoices are due.', 'invoicing' ),
531
+            'name'     => '<h3>' . __('Payment Reminder', 'invoicing') . '</h3>',
532
+            'desc'     => __('Payment reminder emails are sent to customers whenever their invoices are due.', 'invoicing'),
533 533
             'type'     => 'header',
534 534
         ),
535 535
 
536 536
         'email_overdue_active' => array(
537 537
             'id'       => 'email_overdue_active',
538
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
539
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
538
+            'name'     => __('Enable/Disable', 'invoicing'),
539
+            'desc'     => __('Enable this email notification', 'invoicing'),
540 540
             'type'     => 'checkbox',
541 541
             'std'      => 1
542 542
         ),
543 543
 
544 544
         'email_overdue_admin_bcc' => array(
545 545
             'id'       => 'email_overdue_admin_bcc',
546
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
547
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
546
+            'name'     => __('Enable Admin BCC', 'invoicing'),
547
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
548 548
             'type'     => 'checkbox',
549 549
             'std'      => 0
550 550
         ),
551 551
 
552 552
         'email_overdue_days' => array(
553 553
             'id'       => 'email_overdue_days',
554
-            'name'     => __( 'When to Send', 'invoicing' ),
555
-            'desc'     => __( 'Check when you would like payment reminders sent out.', 'invoicing' ),
554
+            'name'     => __('When to Send', 'invoicing'),
555
+            'desc'     => __('Check when you would like payment reminders sent out.', 'invoicing'),
556 556
             'help-tip' => true,
557
-            'std'      => array( '1' ),
557
+            'std'      => array('1'),
558 558
             'type'     => 'multicheck',
559 559
             'options'  => $overdue_days_options,
560 560
         ),
561 561
 
562 562
         'email_overdue_subject' => array(
563 563
             'id'       => 'email_overdue_subject',
564
-            'name'     => __( 'Subject', 'invoicing' ),
565
-            'desc'     => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
564
+            'name'     => __('Subject', 'invoicing'),
565
+            'desc'     => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
566 566
             'help-tip' => true,
567 567
             'type'     => 'text',
568
-            'std'      => __( '[{site_title}] Payment Reminder', 'invoicing' ),
568
+            'std'      => __('[{site_title}] Payment Reminder', 'invoicing'),
569 569
             'size'     => 'large'
570 570
         ),
571 571
 
572 572
         'email_overdue_heading' => array(
573 573
             'id'       => 'email_overdue_heading',
574
-            'name'     => __( 'Email Heading', 'invoicing' ),
575
-            'desc'     => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
574
+            'name'     => __('Email Heading', 'invoicing'),
575
+            'desc'     => __('Enter the main heading contained within the email notification.', 'invoicing'),
576 576
             'help-tip' => true,
577 577
             'type'     => 'text',
578
-            'std'      => __( 'Payment reminder for your invoice', 'invoicing' ),
578
+            'std'      => __('Payment reminder for your invoice', 'invoicing'),
579 579
             'size'     => 'large'
580 580
         ),
581 581
 
582 582
         'email_overdue_body' => array(
583 583
             'id'       => 'email_overdue_body',
584
-            'name'     => __( 'Email Content', 'invoicing' ),
585
-            'desc'     => __( 'The content of the email.', 'invoicing' ),
584
+            'name'     => __('Email Content', 'invoicing'),
585
+            'desc'     => __('The content of the email.', 'invoicing'),
586 586
             'type'     => 'rich_editor',
587
-            'std'      => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
587
+            'std'      => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
588 588
             'class'    => 'large',
589 589
             'size'     => 10,
590 590
         ),
@@ -595,63 +595,63 @@  discard block
 block discarded – undo
595 595
 
596 596
         'email_renewal_reminder_header' => array(
597 597
             'id'       => 'email_renewal_reminder_header',
598
-            'name'     => '<h3>' . __( 'Renewal Reminder', 'invoicing' ) . '</h3>',
599
-            'desc'     => __( 'These emails are sent to customers whenever their subscription is about to expire.', 'invoicing' ),
598
+            'name'     => '<h3>' . __('Renewal Reminder', 'invoicing') . '</h3>',
599
+            'desc'     => __('These emails are sent to customers whenever their subscription is about to expire.', 'invoicing'),
600 600
             'type'     => 'header',
601 601
         ),
602 602
 
603 603
         'email_renewal_reminder_active' => array(
604 604
             'id'       => 'email_renewal_reminder_active',
605
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
606
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
605
+            'name'     => __('Enable/Disable', 'invoicing'),
606
+            'desc'     => __('Enable this email notification', 'invoicing'),
607 607
             'type'     => 'checkbox',
608 608
             'std'      => 0
609 609
         ),
610 610
 
611 611
         'email_renewal_reminder_admin_bcc' => array(
612 612
             'id'       => 'email_renewal_reminder_admin_bcc',
613
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
614
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
613
+            'name'     => __('Enable Admin BCC', 'invoicing'),
614
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
615 615
             'type'     => 'checkbox',
616 616
             'std'      => 0
617 617
         ),
618 618
 
619 619
         'email_renewal_reminder_days' => array(
620 620
             'id'       => 'email_renewal_reminder_days',
621
-            'name'     => __( 'When to Send', 'invoicing' ),
622
-            'desc'     => __( 'Check when you would like renewal reminders sent out.', 'invoicing' ),
621
+            'name'     => __('When to Send', 'invoicing'),
622
+            'desc'     => __('Check when you would like renewal reminders sent out.', 'invoicing'),
623 623
             'help-tip' => true,
624
-            'std'      => array( '1', '5', '10' ),
624
+            'std'      => array('1', '5', '10'),
625 625
             'type'     => 'multicheck',
626 626
             'options'  => $renewal_days_options,
627 627
         ),
628 628
 
629 629
         'email_renewal_reminder_subject' => array(
630 630
             'id'       => 'email_renewal_reminder_subject',
631
-            'name'     => __( 'Subject', 'invoicing' ),
632
-            'desc'     => __( 'Enter the subject line for the email.', 'invoicing' ),
631
+            'name'     => __('Subject', 'invoicing'),
632
+            'desc'     => __('Enter the subject line for the email.', 'invoicing'),
633 633
             'help-tip' => true,
634 634
             'type'     => 'text',
635
-            'std'      => __( '[{site_title}] Renewal Reminder', 'invoicing' ),
635
+            'std'      => __('[{site_title}] Renewal Reminder', 'invoicing'),
636 636
             'size'     => 'large'
637 637
         ),
638 638
 
639 639
         'email_renewal_reminder_heading' => array(
640 640
             'id'       => 'email_renewal_reminder_heading',
641
-            'name'     => __( 'Email Heading', 'invoicing' ),
642
-            'desc'     => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
641
+            'name'     => __('Email Heading', 'invoicing'),
642
+            'desc'     => __('Enter the main heading contained within the email notification.', 'invoicing'),
643 643
             'help-tip' => true,
644 644
             'type'     => 'text',
645
-            'std'      => __( 'Upcoming renewal reminder', 'invoicing' ),
645
+            'std'      => __('Upcoming renewal reminder', 'invoicing'),
646 646
             'size'     => 'large'
647 647
         ),
648 648
 
649 649
         'email_renewal_reminder_body' => array(
650 650
             'id'       => 'email_renewal_reminder_body',
651
-            'name'     => __( 'Email Content', 'invoicing' ),
652
-            'desc'     => __( 'The content of the email.', 'invoicing' ),
651
+            'name'     => __('Email Content', 'invoicing'),
652
+            'desc'     => __('The content of the email.', 'invoicing'),
653 653
             'type'     => 'rich_editor',
654
-            'std'      => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your subscription for invoice <a href="{invoice_link}">#{invoice_number}</a> will renew on {subscription_renewal_date}.</p>', 'invoicing' ),
654
+            'std'      => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your subscription for invoice <a href="{invoice_link}">#{invoice_number}</a> will renew on {subscription_renewal_date}.</p>', 'invoicing'),
655 655
             'class'    => 'large',
656 656
             'size'     => 10,
657 657
         ),
@@ -662,53 +662,53 @@  discard block
 block discarded – undo
662 662
 
663 663
         'email_subscription_trial_header' => array(
664 664
             'id'       => 'email_subscription_trial_header',
665
-            'name'     => '<h3>' . __( 'Trial Started', 'invoicing' ) . '</h3>',
666
-            'desc'     => __( 'These emails are sent when a customer starts a subscription trial.', 'invoicing' ),
665
+            'name'     => '<h3>' . __('Trial Started', 'invoicing') . '</h3>',
666
+            'desc'     => __('These emails are sent when a customer starts a subscription trial.', 'invoicing'),
667 667
             'type'     => 'header',
668 668
         ),
669 669
 
670 670
         'email_subscription_trial_active' => array(
671 671
             'id'       => 'email_subscription_trial_active',
672
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
673
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
672
+            'name'     => __('Enable/Disable', 'invoicing'),
673
+            'desc'     => __('Enable this email notification', 'invoicing'),
674 674
             'type'     => 'checkbox',
675 675
             'std'      => 0
676 676
         ),
677 677
 
678 678
         'email_subscription_trial_bcc' => array(
679 679
             'id'       => 'email_subscription_trial_admin_bcc',
680
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
681
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
680
+            'name'     => __('Enable Admin BCC', 'invoicing'),
681
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
682 682
             'type'     => 'checkbox',
683 683
             'std'      => 0
684 684
         ),
685 685
 
686 686
         'email_subscription_trial_subject' => array(
687 687
             'id'       => 'email_subscription_trial_subject',
688
-            'name'     => __( 'Subject', 'invoicing' ),
689
-            'desc'     => __( 'Enter the subject line for the subscription trial email.', 'invoicing' ),
688
+            'name'     => __('Subject', 'invoicing'),
689
+            'desc'     => __('Enter the subject line for the subscription trial email.', 'invoicing'),
690 690
             'help-tip' => true,
691 691
             'type'     => 'text',
692
-            'std'      => __( '[{site_title}] Trial Started', 'invoicing' ),
692
+            'std'      => __('[{site_title}] Trial Started', 'invoicing'),
693 693
             'size'     => 'large'
694 694
         ),
695 695
 
696 696
         'email_subscription_trial_heading' => array(
697 697
             'id'       => 'email_subscription_trial_heading',
698
-            'name'     => __( 'Email Heading', 'invoicing' ),
699
-            'desc'     => __( 'Enter the main heading of this email.', 'invoicing' ),
698
+            'name'     => __('Email Heading', 'invoicing'),
699
+            'desc'     => __('Enter the main heading of this email.', 'invoicing'),
700 700
             'help-tip' => true,
701 701
             'type'     => 'text',
702
-            'std'      => __( 'Trial Started', 'invoicing' ),
702
+            'std'      => __('Trial Started', 'invoicing'),
703 703
             'size'     => 'large'
704 704
         ),
705 705
 
706 706
         'email_subscription_trial_body' => array(
707 707
             'id'       => 'email_trial_body',
708
-            'name'     => __( 'Email Content', 'invoicing' ),
709
-            'desc'     => __( 'The content of the email.', 'invoicing' ),
708
+            'name'     => __('Email Content', 'invoicing'),
709
+            'desc'     => __('The content of the email.', 'invoicing'),
710 710
             'type'     => 'rich_editor',
711
-            'std'      => __( '<p>Hi {first_name},</p><p>Your trial for {subscription_name} is now active and will renew on {subscription_renewal_date}.</p>', 'invoicing' ),
711
+            'std'      => __('<p>Hi {first_name},</p><p>Your trial for {subscription_name} is now active and will renew on {subscription_renewal_date}.</p>', 'invoicing'),
712 712
             'class'    => 'large',
713 713
             'size'     => 10,
714 714
         ),
@@ -718,53 +718,53 @@  discard block
 block discarded – undo
718 718
 
719 719
         'email_subscription_cancelled_header' => array(
720 720
             'id'       => 'email_subscription_cancelled_header',
721
-            'name'     => '<h3>' . __( 'Subscription Cancelled', 'invoicing' ) . '</h3>',
722
-            'desc'     => __( 'These emails are sent when a customer cancels their subscription.', 'invoicing' ),
721
+            'name'     => '<h3>' . __('Subscription Cancelled', 'invoicing') . '</h3>',
722
+            'desc'     => __('These emails are sent when a customer cancels their subscription.', 'invoicing'),
723 723
             'type'     => 'header',
724 724
         ),
725 725
 
726 726
         'email_subscription_cancelled_active' => array(
727 727
             'id'       => 'email_subscription_cancelled_active',
728
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
729
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
728
+            'name'     => __('Enable/Disable', 'invoicing'),
729
+            'desc'     => __('Enable this email notification', 'invoicing'),
730 730
             'type'     => 'checkbox',
731 731
             'std'      => 1
732 732
         ),
733 733
 
734 734
         'email_subscription_cancelled_bcc' => array(
735 735
             'id'       => 'email_subscription_cancelled_admin_bcc',
736
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
737
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
736
+            'name'     => __('Enable Admin BCC', 'invoicing'),
737
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
738 738
             'type'     => 'checkbox',
739 739
             'std'      => 1
740 740
         ),
741 741
 
742 742
         'email_subscription_cancelled_subject' => array(
743 743
             'id'       => 'email_subscription_cancelled_subject',
744
-            'name'     => __( 'Subject', 'invoicing' ),
745
-            'desc'     => __( 'Enter the subject line for the subscription cancelled email.', 'invoicing' ),
744
+            'name'     => __('Subject', 'invoicing'),
745
+            'desc'     => __('Enter the subject line for the subscription cancelled email.', 'invoicing'),
746 746
             'help-tip' => true,
747 747
             'type'     => 'text',
748
-            'std'      => __( '[{site_title}] Subscription Cancelled', 'invoicing' ),
748
+            'std'      => __('[{site_title}] Subscription Cancelled', 'invoicing'),
749 749
             'size'     => 'large'
750 750
         ),
751 751
 
752 752
         'email_subscription_cancelled_heading' => array(
753 753
             'id'       => 'email_subscription_complete_heading',
754
-            'name'     => __( 'Email Heading', 'invoicing' ),
755
-            'desc'     => __( 'Enter the main heading of this email.', 'invoicing' ),
754
+            'name'     => __('Email Heading', 'invoicing'),
755
+            'desc'     => __('Enter the main heading of this email.', 'invoicing'),
756 756
             'help-tip' => true,
757 757
             'type'     => 'text',
758
-            'std'      => __( 'Subscription Cancelled', 'invoicing' ),
758
+            'std'      => __('Subscription Cancelled', 'invoicing'),
759 759
             'size'     => 'large'
760 760
         ),
761 761
 
762 762
         'email_subscription_cancelled_body' => array(
763 763
             'id'       => 'email_cancelled_body',
764
-            'name'     => __( 'Email Content', 'invoicing' ),
765
-            'desc'     => __( 'The content of the email.', 'invoicing' ),
764
+            'name'     => __('Email Content', 'invoicing'),
765
+            'desc'     => __('The content of the email.', 'invoicing'),
766 766
             'type'     => 'rich_editor',
767
-            'std'      => __( '<p>Hi {first_name},</p><p>Your subscription for {subscription_name} has been cancelled and will no longer renew.</p>', 'invoicing' ),
767
+            'std'      => __('<p>Hi {first_name},</p><p>Your subscription for {subscription_name} has been cancelled and will no longer renew.</p>', 'invoicing'),
768 768
             'class'    => 'large',
769 769
             'size'     => 10,
770 770
         ),
@@ -774,53 +774,53 @@  discard block
 block discarded – undo
774 774
 
775 775
         'email_subscription_expired_header' => array(
776 776
             'id'       => 'email_subscription_expired_header',
777
-            'name'     => '<h3>' . __( 'Subscription Expired', 'invoicing' ) . '</h3>',
778
-            'desc'     => __( "These emails are sent when a customer's subscription expires and automatic renewal fails.", 'invoicing' ),
777
+            'name'     => '<h3>' . __('Subscription Expired', 'invoicing') . '</h3>',
778
+            'desc'     => __("These emails are sent when a customer's subscription expires and automatic renewal fails.", 'invoicing'),
779 779
             'type'     => 'header',
780 780
         ),
781 781
 
782 782
         'email_subscription_expired_active' => array(
783 783
             'id'       => 'email_subscription_expired_active',
784
-            'name'     => __( 'Enable/Disable', 'invoicing' ),
785
-            'desc'     => __( 'Enable this email notification', 'invoicing' ),
784
+            'name'     => __('Enable/Disable', 'invoicing'),
785
+            'desc'     => __('Enable this email notification', 'invoicing'),
786 786
             'type'     => 'checkbox',
787 787
             'std'      => 1
788 788
         ),
789 789
 
790 790
         'email_subscription_expired_bcc' => array(
791 791
             'id'       => 'email_subscription_expired_admin_bcc',
792
-            'name'     => __( 'Enable Admin BCC', 'invoicing' ),
793
-            'desc'     => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
792
+            'name'     => __('Enable Admin BCC', 'invoicing'),
793
+            'desc'     => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
794 794
             'type'     => 'checkbox',
795 795
             'std'      => 1
796 796
         ),
797 797
 
798 798
         'email_subscription_expired_subject' => array(
799 799
             'id'       => 'email_subscription_expired_subject',
800
-            'name'     => __( 'Subject', 'invoicing' ),
801
-            'desc'     => __( 'Enter the subject line for the subscription expired email.', 'invoicing' ),
800
+            'name'     => __('Subject', 'invoicing'),
801
+            'desc'     => __('Enter the subject line for the subscription expired email.', 'invoicing'),
802 802
             'help-tip' => true,
803 803
             'type'     => 'text',
804
-            'std'      => __( '[{site_title}] Subscription Expired', 'invoicing' ),
804
+            'std'      => __('[{site_title}] Subscription Expired', 'invoicing'),
805 805
             'size'     => 'large'
806 806
         ),
807 807
 
808 808
         'email_subscription_expired_heading' => array(
809 809
             'id'       => 'email_subscription_expired_heading',
810
-            'name'     => __( 'Email Heading', 'invoicing' ),
811
-            'desc'     => __( 'Enter the main heading of this email.', 'invoicing' ),
810
+            'name'     => __('Email Heading', 'invoicing'),
811
+            'desc'     => __('Enter the main heading of this email.', 'invoicing'),
812 812
             'type'     => 'text',
813
-            'std'      => __( 'Subscription Expired', 'invoicing' ),
813
+            'std'      => __('Subscription Expired', 'invoicing'),
814 814
             'help-tip' => true,
815 815
             'size'     => 'large'
816 816
         ),
817 817
 
818 818
         'email_subscription_expired_body' => array(
819 819
             'id'       => 'email_expired_body',
820
-            'name'     => __( 'Email Content', 'invoicing' ),
821
-            'desc'     => __( 'The content of the email.', 'invoicing' ),
820
+            'name'     => __('Email Content', 'invoicing'),
821
+            'desc'     => __('The content of the email.', 'invoicing'),
822 822
             'type'     => 'rich_editor',
823
-            'std'      => __( '<p>Hi {first_name},</p><p>Your subscription for {subscription_name} has expired.</p>', 'invoicing' ),
823
+            'std'      => __('<p>Hi {first_name},</p><p>Your subscription for {subscription_name} has expired.</p>', 'invoicing'),
824 824
             'class'    => 'large',
825 825
             'size'     => 10,
826 826
         ),
@@ -830,53 +830,53 @@  discard block
 block discarded – undo
830 830
 
831 831
         'email_subscription_complete_header' => array(
832 832
             'id'     => 'email_subscription_complete_header',
833
-            'name'   => '<h3>' . __( 'Subscription Complete', 'invoicing' ) . '</h3>',
834
-            'desc'   => __( 'These emails are sent when a customer completes their subscription.', 'invoicing' ),
833
+            'name'   => '<h3>' . __('Subscription Complete', 'invoicing') . '</h3>',
834
+            'desc'   => __('These emails are sent when a customer completes their subscription.', 'invoicing'),
835 835
             'type'   => 'header',
836 836
         ),
837 837
 
838 838
         'email_subscription_complete_active' => array(
839 839
             'id'      => 'email_subscription_complete_active',
840
-            'name'    => __( 'Enable/Disable', 'invoicing' ),
841
-            'desc'    => __( 'Enable this email notification', 'invoicing' ),
840
+            'name'    => __('Enable/Disable', 'invoicing'),
841
+            'desc'    => __('Enable this email notification', 'invoicing'),
842 842
             'type'    => 'checkbox',
843 843
             'std'     => 1
844 844
         ),
845 845
 
846 846
         'email_subscription_complete_bcc' => array(
847 847
             'id'      => 'email_subscription_complete_admin_bcc',
848
-            'name'    => __( 'Enable Admin BCC', 'invoicing' ),
849
-            'desc'    => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ),
848
+            'name'    => __('Enable Admin BCC', 'invoicing'),
849
+            'desc'    => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'),
850 850
             'type'    => 'checkbox',
851 851
             'std'     => 1
852 852
         ),
853 853
 
854 854
         'email_subscription_complete_subject' => array(
855 855
             'id'       => 'email_subscription_complete_subject',
856
-            'name'     => __( 'Subject', 'invoicing' ),
857
-            'desc'     => __( 'Enter the subject line for the subscription complete email.', 'invoicing' ),
856
+            'name'     => __('Subject', 'invoicing'),
857
+            'desc'     => __('Enter the subject line for the subscription complete email.', 'invoicing'),
858 858
             'help-tip' => true,
859 859
             'type'     => 'text',
860
-            'std'      => __( '[{site_title}] Subscription Complete', 'invoicing' ),
860
+            'std'      => __('[{site_title}] Subscription Complete', 'invoicing'),
861 861
             'size'     => 'large'
862 862
         ),
863 863
 
864 864
         'email_subscription_complete_heading' => array(
865 865
             'id'       => 'email_subscription_complete_heading',
866
-            'name'     => __( 'Email Heading', 'invoicing' ),
867
-            'desc'     => __( 'Enter the main heading of this email.', 'invoicing' ),
866
+            'name'     => __('Email Heading', 'invoicing'),
867
+            'desc'     => __('Enter the main heading of this email.', 'invoicing'),
868 868
             'help-tip' => true,
869 869
             'type'     => 'text',
870
-            'std'      => __( 'Subscription Complete', 'invoicing' ),
870
+            'std'      => __('Subscription Complete', 'invoicing'),
871 871
             'size'     => 'large'
872 872
         ),
873 873
 
874 874
         'email_subscription_complete_body' => array(
875 875
             'id'       => 'email_complete_body',
876
-            'name'     => __( 'Email Content', 'invoicing' ),
877
-            'desc'     => __( 'The content of the email.', 'invoicing' ),
876
+            'name'     => __('Email Content', 'invoicing'),
877
+            'desc'     => __('The content of the email.', 'invoicing'),
878 878
             'type'     => 'rich_editor',
879
-            'std'      => __( '<p>Hi {first_name},</p><p>Your subscription for {subscription_name} is now complete.</p>', 'invoicing' ),
879
+            'std'      => __('<p>Hi {first_name},</p><p>Your subscription for {subscription_name} is now complete.</p>', 'invoicing'),
880 880
             'class'    => 'large',
881 881
             'size'     => 10,
882 882
         ),
Please login to merge, or discard this patch.