Passed
Push — master ( 47b6fc...99ae46 )
by Brian
05:46 queued 20s
created
includes/admin/meta-boxes/class-getpaid-meta-box-payment-form-info.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,54 +21,54 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the form.
27
-        $form = new GetPaid_Payment_Form( $post );
27
+        $form = new GetPaid_Payment_Form($post);
28 28
 
29 29
         ?>
30 30
 
31 31
         <div class='bsui' style='padding-top: 10px;'>
32
-            <?php do_action( 'wpinv_payment_form_before_info_metabox', $form ); ?>
32
+            <?php do_action('wpinv_payment_form_before_info_metabox', $form); ?>
33 33
 
34 34
             <div class="wpinv_payment_form_shortcode form-group row">
35 35
                 <label for="wpinv_payment_form_shortcode" class="col-sm-12 col-form-label">
36
-                    <?php esc_html_e( 'Payment Form Shortcode', 'invoicing' ); ?>
37
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a payment form', 'invoicing' ); ?>"></span>
36
+                    <?php esc_html_e('Payment Form Shortcode', 'invoicing'); ?>
37
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a payment form', 'invoicing'); ?>"></span>
38 38
                 </label>
39 39
 
40 40
                 <div class="col-sm-12">
41
-                    <input  onClick="this.select()" type="text" id="wpinv_payment_form_shortcode" value="[getpaid form=<?php echo esc_attr( $form->get_id() ); ?>]" style="width: 100%;" />
41
+                    <input  onClick="this.select()" type="text" id="wpinv_payment_form_shortcode" value="[getpaid form=<?php echo esc_attr($form->get_id()); ?>]" style="width: 100%;" />
42 42
                 </div>
43 43
             </div>
44 44
 
45 45
             <div class="wpinv_payment_form_buy_shortcode form-group row">
46 46
                 <label for="wpinv_payment_form_buy_shortcode" class="col-sm-12 col-form-label">
47
-                    <?php esc_html_e( 'Payment Button Shortcode', 'invoicing' ); ?>
48
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a buy now button', 'invoicing' ); ?>"></span>
47
+                    <?php esc_html_e('Payment Button Shortcode', 'invoicing'); ?>
48
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a buy now button', 'invoicing'); ?>"></span>
49 49
                 </label>
50 50
 
51 51
                 <div class="col-sm-12">
52
-                    <input onClick="this.select()" type="text" id="wpinv_payment_form_buy_shortcode" value="[getpaid form=<?php echo esc_attr( $form->get_id() ); ?> button='Buy Now']" style="width: 100%;" />
52
+                    <input onClick="this.select()" type="text" id="wpinv_payment_form_buy_shortcode" value="[getpaid form=<?php echo esc_attr($form->get_id()); ?> button='Buy Now']" style="width: 100%;" />
53 53
                     <small class="form-text text-muted">
54
-                        <?php esc_html_e( 'Or use the following URL in a link:', 'invoicing' ); ?>
55
-                        <code>#getpaid-form-<?php echo intval( $form->get_id() ); ?></code>
54
+                        <?php esc_html_e('Or use the following URL in a link:', 'invoicing'); ?>
55
+                        <code>#getpaid-form-<?php echo intval($form->get_id()); ?></code>
56 56
                     </small>
57 57
                 </div>
58 58
             </div>
59 59
 
60 60
             <div class="wpinv_item_buy_url form-group row">
61 61
                 <label for="wpinv_item_buy_url" class="col-sm-12 col-form-label">
62
-                    <?php esc_html_e( 'Direct Payment URL', 'invoicing' ); ?>
63
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'You can use this in an iFrame to embed the payment form on another website', 'invoicing' ); ?>"></span>
62
+                    <?php esc_html_e('Direct Payment URL', 'invoicing'); ?>
63
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('You can use this in an iFrame to embed the payment form on another website', 'invoicing'); ?>"></span>
64 64
                 </label>
65 65
 
66 66
                 <div class="col-sm-12">
67
-                    <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url( getpaid_embed_url( $form->get_id(), false ) ); ?>" style="width: 100%;" readonly/>
67
+                    <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url(getpaid_embed_url($form->get_id(), false)); ?>" style="width: 100%;" readonly/>
68 68
                 </div>
69 69
             </div>
70 70
 
71
-            <?php do_action( 'wpinv_payment_form_info_metabox', $form ); ?>
71
+            <?php do_action('wpinv_payment_form_info_metabox', $form); ?>
72 72
         </div>
73 73
         <?php
74 74
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-item-info.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,20 +21,20 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the item.
27
-        $item = new WPInv_Item( $post );
27
+        $item = new WPInv_Item($post);
28 28
 
29 29
         ?>
30 30
 
31 31
         <div class='bsui' style='padding-top: 10px;'>
32
-            <?php do_action( 'wpinv_item_before_info_metabox', $item ); ?>
32
+            <?php do_action('wpinv_item_before_info_metabox', $item); ?>
33 33
 
34 34
             <div class="wpinv_item_type form-group row">
35 35
                 <label for="wpinv_item_type" class="col-sm-12 col-form-label">
36
-                    <?php esc_html_e( 'Item Type', 'invoicing' ); ?>
37
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php echo esc_attr( self::get_tooltip( $post ) ); ?>"></span>
36
+                    <?php esc_html_e('Item Type', 'invoicing'); ?>
37
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php echo esc_attr(self::get_tooltip($post)); ?>"></span>
38 38
                 </label>
39 39
 
40 40
                 <div class="col-sm-12">
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
                             array(
45 45
                                 'id'               => 'wpinv_item_type',
46 46
                                 'name'             => 'wpinv_item_type',
47
-                                'placeholder'      => __( 'Select item type', 'invoicing' ),
48
-                                'value'            => $item->get_type( 'edit' ),
47
+                                'placeholder'      => __('Select item type', 'invoicing'),
48
+                                'value'            => $item->get_type('edit'),
49 49
                                 'select2'          => true,
50 50
                                 'data-allow-clear' => 'false',
51 51
                                 'no_wrap'          => true,
@@ -57,59 +57,59 @@  discard block
 block discarded – undo
57 57
                 </div>
58 58
             </div>
59 59
 
60
-            <?php if ( 'fee' === $item->get_type( 'edit' ) || 'custom' === $item->get_type( 'edit' ) ) : ?>
60
+            <?php if ('fee' === $item->get_type('edit') || 'custom' === $item->get_type('edit')) : ?>
61 61
 
62 62
                 <div class="wpinv_item_shortcode form-group row">
63 63
                     <label for="wpinv_item_shortcode" class="col-sm-12 col-form-label">
64
-                        <?php esc_html_e( 'Payment Form Shortcode', 'invoicing' ); ?>
65
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a payment form', 'invoicing' ); ?>"></span>
64
+                        <?php esc_html_e('Payment Form Shortcode', 'invoicing'); ?>
65
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a payment form', 'invoicing'); ?>"></span>
66 66
                     </label>
67 67
 
68 68
                     <div class="col-sm-12">
69
-                        <input  onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?>]" style="width: 100%;" readonly/>
69
+                        <input  onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr($item->get_id()); ?>]" style="width: 100%;" readonly/>
70 70
                     </div>
71 71
                 </div>
72 72
 
73 73
                 <div class="wpinv_item_buy_shortcode form-group row">
74 74
                     <label for="wpinv_item_button_shortcode" class="col-sm-12 col-form-label">
75
-                        <?php esc_html_e( 'Payment Button Shortcode', 'invoicing' ); ?>
76
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a buy now button', 'invoicing' ); ?>"></span>
75
+                        <?php esc_html_e('Payment Button Shortcode', 'invoicing'); ?>
76
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a buy now button', 'invoicing'); ?>"></span>
77 77
                     </label>
78 78
 
79 79
                     <div class="col-sm-12">
80
-                        <input onClick="this.select()" type="text" id="wpinv_item_button_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?> button='Buy Now']" style="width: 100%;" readonly/>
80
+                        <input onClick="this.select()" type="text" id="wpinv_item_button_shortcode" value="[getpaid item=<?php echo esc_attr($item->get_id()); ?> button='Buy Now']" style="width: 100%;" readonly/>
81 81
                         <small class="form-text text-muted">
82
-                            <?php esc_html_e( 'Or use the following URL in a link:', 'invoicing' ); ?>
83
-                            <code>#getpaid-item-<?php echo intval( $item->get_id() ); ?>|0</code>
82
+                            <?php esc_html_e('Or use the following URL in a link:', 'invoicing'); ?>
83
+                            <code>#getpaid-item-<?php echo intval($item->get_id()); ?>|0</code>
84 84
                         </small>
85 85
                     </div>
86 86
                 </div>
87 87
 
88 88
                 <div class="wpinv_item_buy_url form-group row">
89 89
                     <label for="wpinv_item_buy_url" class="col-sm-12 col-form-label">
90
-                        <?php esc_html_e( 'Direct Payment URL', 'invoicing' ); ?>
91
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'You can use this in an iFrame to embed the payment form on another website', 'invoicing' ); ?>"></span>
90
+                        <?php esc_html_e('Direct Payment URL', 'invoicing'); ?>
91
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('You can use this in an iFrame to embed the payment form on another website', 'invoicing'); ?>"></span>
92 92
                     </label>
93 93
 
94 94
                     <div class="col-sm-12">
95
-                        <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url( getpaid_embed_url( false, $item->get_id() . '|0' ) ); ?>" style="width: 100%;" readonly/>
95
+                        <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url(getpaid_embed_url(false, $item->get_id() . '|0')); ?>" style="width: 100%;" readonly/>
96 96
                     </div>
97 97
                 </div>
98 98
 
99 99
             <?php endif; ?>
100 100
 
101 101
             <div class="wpinv_item_custom_id form-group">
102
-                <?php esc_html_e( 'Custom ID', 'invoicing' ); ?> &mdash; <?php echo esc_html( $item->get_custom_id() ); ?>
102
+                <?php esc_html_e('Custom ID', 'invoicing'); ?> &mdash; <?php echo esc_html($item->get_custom_id()); ?>
103 103
             </div>
104 104
 
105
-            <?php do_action( 'wpinv_meta_values_metabox_before', $post ); ?>
106
-            <?php foreach ( apply_filters( 'wpinv_show_meta_values_for_keys', array() ) as $meta_key ) : ?>
105
+            <?php do_action('wpinv_meta_values_metabox_before', $post); ?>
106
+            <?php foreach (apply_filters('wpinv_show_meta_values_for_keys', array()) as $meta_key) : ?>
107 107
                 <div class="wpinv_item_custom_id form-group">
108
-                    <?php echo esc_html( $meta_key ); ?> &mdash; <?php echo esc_html( get_post_meta( $item->get_id(), '_wpinv_' . $meta_key, true ) ); ?>
108
+                    <?php echo esc_html($meta_key); ?> &mdash; <?php echo esc_html(get_post_meta($item->get_id(), '_wpinv_' . $meta_key, true)); ?>
109 109
                 </div>
110 110
             <?php endforeach; ?>
111
-            <?php do_action( 'wpinv_meta_values_metabox_after', $post ); ?>
112
-            <?php do_action( 'wpinv_item_info_metabox', $item ); ?>
111
+            <?php do_action('wpinv_meta_values_metabox_after', $post); ?>
112
+            <?php do_action('wpinv_item_info_metabox', $item); ?>
113 113
         </div>
114 114
         <?php
115 115
 
@@ -119,16 +119,16 @@  discard block
 block discarded – undo
119 119
 	 * Returns item type tolltip.
120 120
 	 *
121 121
 	 */
122
-    public static function get_tooltip( $post ) {
122
+    public static function get_tooltip($post) {
123 123
 
124 124
         ob_start();
125 125
         ?>
126 126
 
127
-        <?php esc_html_e( 'Standard: Standard item type', 'invoicing' ); ?>
128
-        <?php esc_html_e( 'Fee: Like Registration Fee, Sign up Fee etc', 'invoicing' ); ?>
127
+        <?php esc_html_e('Standard: Standard item type', 'invoicing'); ?>
128
+        <?php esc_html_e('Fee: Like Registration Fee, Sign up Fee etc', 'invoicing'); ?>
129 129
 
130 130
         <?php
131
-        do_action( 'wpinv_item_info_metabox_after', $post );
131
+        do_action('wpinv_item_info_metabox_after', $post);
132 132
 
133 133
         return ob_get_clean();
134 134
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-items.php 1 patch
Spacing   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -16,82 +16,82 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class GetPaid_Meta_Box_Invoice_Items {
18 18
 
19
-    public static function get_columns( $invoice ) {
19
+    public static function get_columns($invoice) {
20 20
         $use_taxes          = $invoice->is_taxable() && wpinv_use_taxes();
21 21
         $columns            = array(
22
-            'id'     => __( 'ID', 'invoicing' ),
23
-            'title'  => __( 'Item', 'invoicing' ),
22
+            'id'     => __('ID', 'invoicing'),
23
+            'title'  => __('Item', 'invoicing'),
24 24
             'price'  => sprintf(
25 25
                 '<span class="getpaid-hide-if-hours getpaid-hide-if-quantity">%s</span>
26 26
                 <span class="getpaid-hide-if-hours hide-if-amount">%s</span>
27 27
                 <span class="getpaid-hide-if-quantity hide-if-amount">%s</span>',
28
-                __( 'Amount', 'invoicing' ),
29
-                __( 'Price', 'invoicing' ),
30
-                __( 'Rate', 'invoicing' )
28
+                __('Amount', 'invoicing'),
29
+                __('Price', 'invoicing'),
30
+                __('Rate', 'invoicing')
31 31
             ),
32 32
             'qty'    => sprintf(
33 33
                 '<span class="getpaid-hide-if-hours">%s</span><span class="getpaid-hide-if-quantity">%s</span>',
34
-                __( 'Quantity', 'invoicing' ),
35
-                __( 'Hours', 'invoicing' )
34
+                __('Quantity', 'invoicing'),
35
+                __('Hours', 'invoicing')
36 36
             ),
37
-            'total'  => __( 'Total', 'invoicing' ),
38
-            'tax'    => __( 'Tax (%)', 'invoicing' ),
37
+            'total'  => __('Total', 'invoicing'),
38
+            'tax'    => __('Tax (%)', 'invoicing'),
39 39
             'action' => '',
40 40
         );
41 41
 
42
-        if ( ! $use_taxes ) {
43
-            unset( $columns['tax'] );
42
+        if (!$use_taxes) {
43
+            unset($columns['tax']);
44 44
         }
45 45
 
46 46
         return $columns;
47 47
     }
48 48
 
49
-    public static function output( $post, $invoice = false ) {
49
+    public static function output($post, $invoice = false) {
50 50
 
51
-        if ( apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) {
52
-            return self::output2( $post );
51
+        if (apply_filters('getpaid_use_new_invoice_items_metabox', false)) {
52
+            return self::output2($post);
53 53
         }
54 54
 
55
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
56
-        $invoice            = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice( $post_id );
55
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
56
+        $invoice            = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice($post_id);
57 57
         $use_taxes          = $invoice->is_taxable() && wpinv_use_taxes();
58
-        $item_types         = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post );
59
-        $columns            = self::get_columns( $invoice );
60
-        $cols               = count( $columns );
58
+        $item_types         = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post);
59
+        $columns            = self::get_columns($invoice);
60
+        $cols               = count($columns);
61 61
         $class              = '';
62 62
 
63
-        unset( $item_types['adv'] );
64
-        unset( $item_types['package'] );
63
+        unset($item_types['adv']);
64
+        unset($item_types['package']);
65 65
 
66
-        if ( $invoice->is_paid() ) {
66
+        if ($invoice->is_paid()) {
67 67
             $class .= ' wpinv-paid';
68 68
         }
69 69
 
70
-        if ( $invoice->is_refunded() ) {
70
+        if ($invoice->is_refunded()) {
71 71
             $class .= ' wpinv-refunded';
72 72
         }
73 73
 
74
-        if ( $invoice->is_recurring() ) {
74
+        if ($invoice->is_recurring()) {
75 75
             $class .= ' wpi-recurring';
76 76
         }
77 77
 
78 78
     ?>
79 79
 
80
-        <div class="wpinv-items-wrap<?php echo esc_attr( $class ); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr( $invoice->get_status() ); ?>">
80
+        <div class="wpinv-items-wrap<?php echo esc_attr($class); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr($invoice->get_status()); ?>">
81 81
             <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0">
82 82
 
83 83
                 <thead>
84 84
                     <tr>
85
-                        <?php foreach ( $columns as $key => $label ) : ?>
86
-                            <th class="<?php echo esc_attr( $key ); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post( $label ); ?></th>
85
+                        <?php foreach ($columns as $key => $label) : ?>
86
+                            <th class="<?php echo esc_attr($key); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post($label); ?></th>
87 87
                         <?php endforeach; ?>
88 88
                     </tr>
89 89
                 </thead>
90 90
 
91 91
                 <tbody class="wpinv-line-items">
92 92
                     <?php
93
-                        foreach ( $invoice->get_items() as $int => $item ) {
94
-                            self::output_row( $columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd' );
93
+                        foreach ($invoice->get_items() as $int => $item) {
94
+                            self::output_row($columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd');
95 95
                         }
96 96
                     ?>
97 97
                 </tbody>
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                                             <div class="wp-clearfix">
109 109
                                                 <label class="wpi-item-name">
110 110
                                                     <span class="input-text-wrap">
111
-                                                        <input type="text" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' );?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]">
111
+                                                        <input type="text" style="width: 100%" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]">
112 112
                                                     </span>
113 113
                                                 </label>
114 114
                                             </div>
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
                                             <div class="wp-clearfix">
117 117
                                                 <label class="wpi-item-price">
118 118
                                                     <span class="input-text-wrap">
119
-                                                    <input type="text" style="width: 200px" placeholder="<?php esc_attr_e( 'Item Price', 'invoicing' );?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]">
120
-                                                        &times; <input type="text" style="width: 140px" placeholder="<?php esc_attr_e( 'Item Quantity', 'invoicing' );?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]">
119
+                                                    <input type="text" style="width: 200px" placeholder="<?php esc_attr_e('Item Price', 'invoicing'); ?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]">
120
+                                                        &times; <input type="text" style="width: 140px" placeholder="<?php esc_attr_e('Item Quantity', 'invoicing'); ?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]">
121 121
                                                     </span>
122 122
                                                 </label>
123 123
                                             </div>
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
                                             <div class="wp-clearfix">
126 126
                                                 <label class="wpi-item-name">
127 127
                                                     <span class="input-text-wrap">
128
-                                                        <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Description', 'invoicing' );?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea>
128
+                                                        <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e('Item Description', 'invoicing'); ?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea>
129 129
                                                     </span>
130 130
                                                 </label>
131 131
                                             </div>
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
                                             <div class="wp-clearfix">
134 134
                                                 <label class="wpi-item-type">
135 135
                                                     <span class="input-text-wrap">
136
-                                                        <?php echo wpinv_html_select( array(
136
+                                                        <?php echo wpinv_html_select(array(
137 137
                                                             'options'          => $item_types,
138 138
                                                             'name'             => '_wpinv_quick[type]',
139 139
                                                             'id'               => '_wpinv_quick_type',
@@ -141,19 +141,19 @@  discard block
 block discarded – undo
141 141
                                                             'show_option_all'  => false,
142 142
                                                             'show_option_none' => false,
143 143
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-type',
144
-                                                        ) ); ?>
144
+                                                        )); ?>
145 145
                                                     </span>
146 146
                                                 </label>
147 147
                                             </div>
148 148
 
149
-                                            <?php if ( $use_taxes ) : ?>
149
+                                            <?php if ($use_taxes) : ?>
150 150
                                                 <div class="wp-clearfix">
151 151
                                                     <label class="wpi-vat-rule">
152 152
                                                         <span class="input-text-wrap">
153 153
                                                             <?php
154
-                                                                echo wpinv_html_select( array(
154
+                                                                echo wpinv_html_select(array(
155 155
                                                                     'options'          => array_merge(
156
-                                                                        array( '' => __( 'Select VAT Rule', 'invoicing' ) ),
156
+                                                                        array('' => __('Select VAT Rule', 'invoicing')),
157 157
                                                                         getpaid_get_tax_rules()
158 158
                                                                     ),
159 159
                                                                     'name'             => '_wpinv_quick[vat_rule]',
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
                                                                     'show_option_all'  => false,
162 162
                                                                     'show_option_none' => false,
163 163
                                                                     'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule',
164
-                                                                ) );
164
+                                                                ));
165 165
                                                             ?>
166 166
                                                         </span>
167 167
                                                     </label>
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
                                                     <label class="wpi-vat-class">
171 171
                                                         <span class="input-text-wrap">
172 172
                                                             <?php
173
-                                                                echo wpinv_html_select( array(
173
+                                                                echo wpinv_html_select(array(
174 174
                                                                     'options'          => array_merge(
175
-                                                                        array( '' => __( 'Select VAT Class', 'invoicing' ) ),
175
+                                                                        array('' => __('Select VAT Class', 'invoicing')),
176 176
                                                                         getpaid_get_tax_classes()
177 177
                                                                     ),
178 178
                                                                     'name'             => '_wpinv_quick[vat_class]',
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
                                                                     'show_option_all'  => false,
181 181
                                                                     'show_option_none' => false,
182 182
                                                                     'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class',
183
-                                                                ) );
183
+                                                                ));
184 184
                                                             ?>
185 185
                                                         </span>
186 186
                                                     </label>
@@ -201,29 +201,29 @@  discard block
 block discarded – undo
201 201
                         </td>
202 202
                     </tr>
203 203
                     <tr class="totals">
204
-                        <td colspan="<?php echo ( (int) $cols - 4 ); ?>"></td>
204
+                        <td colspan="<?php echo ((int) $cols - 4); ?>"></td>
205 205
                         <td colspan="4">
206 206
                             <table cellspacing="0" cellpadding="0">
207 207
                                 <tr class="subtotal">
208
-                                    <td class="name"><?php esc_html_e( 'Sub Total:', 'invoicing' );?></td>
209
-                                    <td class="total"><?php echo wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() );?></td>
208
+                                    <td class="name"><?php esc_html_e('Sub Total:', 'invoicing'); ?></td>
209
+                                    <td class="total"><?php echo wpinv_price($invoice->get_subtotal(), $invoice->get_currency()); ?></td>
210 210
                                     <td class="action"></td>
211 211
                                 </tr>
212 212
                                 <tr class="discount">
213
-                                    <td class="name"><?php esc_html_e( 'Discount:', 'invoicing' ) ; ?></td>
214
-                                    <td class="total"><?php echo wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() );?></td>
213
+                                    <td class="name"><?php esc_html_e('Discount:', 'invoicing'); ?></td>
214
+                                    <td class="total"><?php echo wpinv_price($invoice->get_total_discount(), $invoice->get_currency()); ?></td>
215 215
                                     <td class="action"></td>
216 216
                                 </tr>
217
-                                <?php if ( $use_taxes ) : ?>
217
+                                <?php if ($use_taxes) : ?>
218 218
                                 <tr class="tax">
219
-                                    <td class="name"><?php esc_html_e( 'Tax:', 'invoicing' );?></td>
220
-                                    <td class="total"><?php echo wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() );?></td>
219
+                                    <td class="name"><?php esc_html_e('Tax:', 'invoicing'); ?></td>
220
+                                    <td class="total"><?php echo wpinv_price($invoice->get_total_tax(), $invoice->get_currency()); ?></td>
221 221
                                     <td class="action"></td>
222 222
                                 </tr>
223 223
                                 <?php endif; ?>
224 224
                                 <tr class="total">
225
-                                    <td class="name"><?php esc_html_e( 'Total:', 'invoicing' );?></td>
226
-                                    <td class="total"><?php echo wpinv_price( $invoice->get_total(), $invoice->get_currency() );?></td>
225
+                                    <td class="name"><?php esc_html_e('Total:', 'invoicing'); ?></td>
226
+                                    <td class="total"><?php echo wpinv_price($invoice->get_total(), $invoice->get_currency()); ?></td>
227 227
                                     <td class="action"></td>
228 228
                                 </tr>
229 229
                             </table>
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
             </table>
235 235
             <div class="wpinv-actions">
236 236
                 <?php
237
-                    if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
237
+                    if (!$invoice->is_paid() && !$invoice->is_refunded()) {
238 238
                         echo wpinv_item_dropdown(
239 239
                             array(
240 240
                                 'name'             => 'wpinv_invoice_item',
@@ -244,61 +244,61 @@  discard block
 block discarded – undo
244 244
                             )
245 245
                         );
246 246
 
247
-                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-add-item">' . sprintf( esc_html__( 'Add item to %s', 'invoicing' ), $invoice->get_label() ) . '</button>';
248
-                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__( 'Create new item', 'invoicing' ) . '</button>';
249
-                        echo "&nbsp;" . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__( 'Recalculate Totals', 'invoicing' ) . '</button>';
247
+                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-add-item">' . sprintf(esc_html__('Add item to %s', 'invoicing'), $invoice->get_label()) . '</button>';
248
+                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__('Create new item', 'invoicing') . '</button>';
249
+                        echo "&nbsp;" . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__('Recalculate Totals', 'invoicing') . '</button>';
250 250
 
251 251
                     }
252 252
                 ?>
253
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
253
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
254 254
             </div>
255 255
         </div>
256 256
         <?php
257 257
     }
258 258
 
259
-    public static function output_row( $columns, $item, $invoice, $class='even' ) {
259
+    public static function output_row($columns, $item, $invoice, $class = 'even') {
260 260
 
261 261
     ?>
262
-        <tr class="item item-<?php echo esc_attr( $class ); ?>" data-item-id="<?php echo esc_attr( $item->get_id() ); ?>">
263
-            <?php foreach ( array_keys( $columns ) as $column ) : ?>
264
-                <td class="<?php echo esc_attr( $column ); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>">
262
+        <tr class="item item-<?php echo esc_attr($class); ?>" data-item-id="<?php echo esc_attr($item->get_id()); ?>">
263
+            <?php foreach (array_keys($columns) as $column) : ?>
264
+                <td class="<?php echo esc_attr($column); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>">
265 265
                     <?php
266
-                        switch ( $column ) {
266
+                        switch ($column) {
267 267
                             case 'id':
268 268
                                 echo (int) $item->get_id();
269 269
                                 break;
270 270
                             case 'title':
271 271
                                 printf(
272 272
                                     '<a href="%s" target="_blank">%s</a>',
273
-                                    get_edit_post_link( $item->get_id() ),
274
-                                    esc_html( $item->get_raw_name() )
273
+                                    get_edit_post_link($item->get_id()),
274
+                                    esc_html($item->get_raw_name())
275 275
                                 );
276 276
 
277
-                                $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice );
278
-                                if ( $summary !== '' ) {
277
+                                $summary = apply_filters('getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice);
278
+                                if ($summary !== '') {
279 279
                                     printf(
280 280
                                         '<span class="meta">%s</span>',
281
-                                        wpautop( wp_kses_post( $summary ) )
281
+                                        wpautop(wp_kses_post($summary))
282 282
                                     );
283 283
                                 }
284 284
 
285 285
                                 printf(
286 286
                                     '<input type="hidden" value="%s" name="getpaid_items[%s][name]" class="getpaid-recalculate-prices-on-change" />',
287
-                                    esc_attr( $item->get_raw_name() ),
287
+                                    esc_attr($item->get_raw_name()),
288 288
                                     (int) $item->get_id()
289 289
                                 );
290 290
 
291 291
                                 printf(
292 292
                                     '<textarea style="display: none;" name="getpaid_items[%s][description]" class="getpaid-recalculate-prices-on-change">%s</textarea>',
293 293
                                     (int) $item->get_id(),
294
-                                    esc_attr( $item->get_description() )
294
+                                    esc_attr($item->get_description())
295 295
                                 );
296 296
 
297 297
                                 break;
298 298
                             case 'price':
299 299
                                 printf(
300 300
                                     '<input type="text" value="%s" name="getpaid_items[%s][price]" style="width: 100px;" class="getpaid-admin-invoice-item-price getpaid-recalculate-prices-on-change" />',
301
-                                    esc_attr( getpaid_unstandardize_amount( $item->get_price() ) ),
301
+                                    esc_attr(getpaid_unstandardize_amount($item->get_price())),
302 302
                                     (int) $item->get_id()
303 303
                                 );
304 304
 
@@ -306,26 +306,26 @@  discard block
 block discarded – undo
306 306
                             case 'qty':
307 307
                                 printf(
308 308
                                     '<input type="text" style="width: 100px;" value="%s" name="getpaid_items[%s][quantity]" class="getpaid-admin-invoice-item-quantity getpaid-recalculate-prices-on-change" />',
309
-                                    floatval( $item->get_quantity() ),
309
+                                    floatval($item->get_quantity()),
310 310
                                     (int) $item->get_id()
311 311
                                 );
312 312
 
313 313
                                 break;
314 314
                             case 'total':
315
-                                echo wpinv_price( $item->get_sub_total(), $invoice->get_currency() );
315
+                                echo wpinv_price($item->get_sub_total(), $invoice->get_currency());
316 316
 
317 317
                                 break;
318 318
                             case 'tax':
319
-                                echo wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) . '%';
319
+                                echo wpinv_round_amount(getpaid_get_invoice_tax_rate($invoice, $item), 2) . '%';
320 320
 
321 321
                                 break;
322 322
                             case 'action':
323
-                                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
323
+                                if (!$invoice->is_paid() && !$invoice->is_refunded()) {
324 324
                                     echo '<i class="fa fa-trash wpinv-item-remove"></i>';
325 325
                                 }
326 326
                                 break;
327 327
                         }
328
-                        do_action( 'getpaid_admin_edit_invoice_item_' . $column, $item, $invoice );
328
+                        do_action('getpaid_admin_edit_invoice_item_' . $column, $item, $invoice);
329 329
                     ?>
330 330
                 </td>
331 331
             <?php endforeach; ?>
@@ -338,10 +338,10 @@  discard block
 block discarded – undo
338 338
 	 *
339 339
 	 * @param WP_Post $post
340 340
 	 */
341
-    public static function output2( $post ) {
341
+    public static function output2($post) {
342 342
 
343 343
         // Prepare the invoice.
344
-        $invoice = new WPInv_Invoice( $post );
344
+        $invoice = new WPInv_Invoice($post);
345 345
 
346 346
         // Invoice items.
347 347
         $items = $invoice->get_items();
@@ -349,28 +349,28 @@  discard block
 block discarded – undo
349 349
         $totals = array(
350 350
 
351 351
             'subtotal'  => array(
352
-                'label' => __( 'Items Subtotal', 'invoicing' ),
353
-                'value' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ),
352
+                'label' => __('Items Subtotal', 'invoicing'),
353
+                'value' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()),
354 354
             ),
355 355
 
356 356
             'discount'  => array(
357
-                'label' => __( 'Total Discount', 'invoicing' ),
358
-                'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ),
357
+                'label' => __('Total Discount', 'invoicing'),
358
+                'value' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()),
359 359
             ),
360 360
 
361 361
             'tax'       => array(
362
-                'label' => __( 'Total Tax', 'invoicing' ),
363
-                'value' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ),
362
+                'label' => __('Total Tax', 'invoicing'),
363
+                'value' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()),
364 364
             ),
365 365
 
366 366
             'total'     => array(
367
-                'label' => __( 'Invoice Total', 'invoicing' ),
368
-                'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ),
367
+                'label' => __('Invoice Total', 'invoicing'),
368
+                'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()),
369 369
             )
370 370
         );
371 371
 
372
-        if ( ! wpinv_use_taxes() ) {
373
-            unset( $totals['tax'] );
372
+        if (!wpinv_use_taxes()) {
373
+            unset($totals['tax']);
374 374
         }
375 375
 
376 376
         $item_args = array(
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
             'orderby'        => 'title',
379 379
             'order'          => 'ASC',
380 380
             'posts_per_page' => -1,
381
-            'post_status'    => array( 'publish' ),
381
+            'post_status'    => array('publish'),
382 382
             'meta_query'     => array(
383 383
                 array(
384 384
                     'key'       => '_wpinv_type',
@@ -402,10 +402,10 @@  discard block
 block discarded – undo
402 402
             }
403 403
         </style>
404 404
 
405
-                <div class="bsui getpaid-invoice-items-inner <?php echo empty( $items ) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;">
405
+                <div class="bsui getpaid-invoice-items-inner <?php echo empty($items) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;">
406 406
 
407
-                    <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
408
-                        <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?>
407
+                    <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
408
+                        <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?>
409 409
 
410 410
                         <div class="row">
411 411
                             <div class="col-12 col-sm-6">
@@ -414,15 +414,15 @@  discard block
 block discarded – undo
414 414
                                         array(
415 415
                                             'id'          => 'wpinv_template',
416 416
                                             'name'        => 'wpinv_template',
417
-                                            'label'       => __( 'Template', 'invoicing' ),
417
+                                            'label'       => __('Template', 'invoicing'),
418 418
                                             'label_type'  => 'vertical',
419
-                                            'placeholder' => __( 'Choose a template', 'invoicing' ),
419
+                                            'placeholder' => __('Choose a template', 'invoicing'),
420 420
                                             'class'       => 'form-control-sm',
421
-                                            'value'       => $invoice->get_template( 'edit' ),
421
+                                            'value'       => $invoice->get_template('edit'),
422 422
                                             'options'     => array(
423
-                                                'quantity' => __( 'Quantity', 'invoicing' ),
424
-                                                'hours'    => __( 'Hours', 'invoicing' ),
425
-                                                'amount'   => __( 'Amount Only', 'invoicing' ),
423
+                                                'quantity' => __('Quantity', 'invoicing'),
424
+                                                'hours'    => __('Hours', 'invoicing'),
425
+                                                'amount'   => __('Amount Only', 'invoicing'),
426 426
                                             ),
427 427
                                             'data-allow-clear' => 'false',
428 428
                                             'select2'          => true,
@@ -438,11 +438,11 @@  discard block
 block discarded – undo
438 438
                                         array(
439 439
                                             'id'          => 'wpinv_currency',
440 440
                                             'name'        => 'wpinv_currency',
441
-                                            'label'       => __( 'Currency', 'invoicing' ),
441
+                                            'label'       => __('Currency', 'invoicing'),
442 442
                                             'label_type'  => 'vertical',
443
-                                            'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
443
+                                            'placeholder' => __('Select Invoice Currency', 'invoicing'),
444 444
                                             'class'       => 'form-control-sm',
445
-                                            'value'       => $invoice->get_currency( 'edit' ),
445
+                                            'value'       => $invoice->get_currency('edit'),
446 446
                                             'required'    => false,
447 447
                                             'data-allow-clear' => 'false',
448 448
                                             'select2'          => true,
@@ -454,24 +454,24 @@  discard block
 block discarded – undo
454 454
                             </div>
455 455
                         </div>
456 456
 
457
-                        <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?>
457
+                        <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?>
458 458
                     <?php endif; ?>
459 459
 
460 460
                     <table cellpadding="0" cellspacing="0" class="getpaid_invoice_items">
461 461
                         <thead>
462 462
                             <tr>
463
-                                <th class="getpaid-item" colspan="2"><?php esc_html_e( 'Item', 'invoicing' ) ?></th>
463
+                                <th class="getpaid-item" colspan="2"><?php esc_html_e('Item', 'invoicing') ?></th>
464 464
                                 <th class="getpaid-quantity hide-if-amount text-right">
465
-                                    <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Quantity', 'invoicing' ) ?></span>
466
-                                    <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Hours', 'invoicing' ) ?></span>
465
+                                    <span class="getpaid-hide-if-hours"><?php esc_html_e('Quantity', 'invoicing') ?></span>
466
+                                    <span class="getpaid-hide-if-quantity"><?php esc_html_e('Hours', 'invoicing') ?></span>
467 467
                                 </th>
468 468
                                 <th class="getpaid-price hide-if-amount text-right">
469
-                                    <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Price', 'invoicing' ) ?></span>
470
-                                    <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Rate', 'invoicing' ) ?></span>
469
+                                    <span class="getpaid-hide-if-hours"><?php esc_html_e('Price', 'invoicing') ?></span>
470
+                                    <span class="getpaid-hide-if-quantity"><?php esc_html_e('Rate', 'invoicing') ?></span>
471 471
                                 </th>
472 472
                                 <th class="getpaid-item-subtotal text-right">
473
-                                    <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php esc_html_e( 'Amount', 'invoicing' ) ?></span>
474
-                                    <span class="hide-if-amount"><?php esc_html_e( 'Total', 'invoicing' ) ?></span>
473
+                                    <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php esc_html_e('Amount', 'invoicing') ?></span>
474
+                                    <span class="hide-if-amount"><?php esc_html_e('Total', 'invoicing') ?></span>
475 475
                                 </th>
476 476
                                 <th class="getpaid-item-actions hide-if-not-editable" width="70px">&nbsp;</th>
477 477
                             </tr>
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
 		                <tbody class="getpaid_invoice_line_items">
480 480
                             <tr class="hide-if-has-items hide-if-not-editable">
481 481
                                 <td colspan="2" class="pt-4 pb-4">
482
-                                    <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e( 'Add Existing Items', 'invoicing' ) ?></button>
483
-                                    <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e( 'Create New Item', 'invoicing' ) ?></button>
482
+                                    <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e('Add Existing Items', 'invoicing') ?></button>
483
+                                    <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e('Create New Item', 'invoicing') ?></button>
484 484
                                 </td>
485 485
                                 <td class="hide-if-amount">&nbsp;</th>
486 486
                                 <td class="hide-if-amount">&nbsp;</th>
@@ -512,11 +512,11 @@  discard block
 block discarded – undo
512 512
                             <div class="col-12 col-sm-6 offset-sm-6">
513 513
                                 <table class="getpaid-invoice-totals text-right w-100">
514 514
                                     <tbody>
515
-                                        <?php foreach ( apply_filters( 'getpaid_invoice_subtotal_rows', $totals, $invoice ) as $key => $data ) : ?>
516
-                                            <tr class="getpaid-totals-<?php echo sanitize_html_class( $key ); ?>">
517
-                                                <td class="label"><?php echo esc_html( $data['label'] ) ?>:</td>
515
+                                        <?php foreach (apply_filters('getpaid_invoice_subtotal_rows', $totals, $invoice) as $key => $data) : ?>
516
+                                            <tr class="getpaid-totals-<?php echo sanitize_html_class($key); ?>">
517
+                                                <td class="label"><?php echo esc_html($data['label']) ?>:</td>
518 518
                                                 <td width="1%"></td>
519
-                                                <td class="value"><?php echo wp_kses_post( $data['value'] ) ?></td>
519
+                                                <td class="value"><?php echo wp_kses_post($data['value']) ?></td>
520 520
                                             </tr>
521 521
                                         <?php endforeach; ?>
522 522
                                     </tbody>
@@ -529,18 +529,18 @@  discard block
 block discarded – undo
529 529
                     <div class="getpaid-invoice-item-actions hide-if-no-items hide-if-not-editable">
530 530
                         <div class="row">
531 531
                             <div class="text-left col-12 col-sm-8">
532
-                                <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e( 'Add Existing Item', 'invoicing' ) ?></button>
533
-                                <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e( 'Create New Item', 'invoicing' ) ?></button>
534
-                                <?php do_action( 'getpaid-invoice-items-actions', $invoice ); ?>
532
+                                <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e('Add Existing Item', 'invoicing') ?></button>
533
+                                <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e('Create New Item', 'invoicing') ?></button>
534
+                                <?php do_action('getpaid-invoice-items-actions', $invoice); ?>
535 535
                             </div>
536 536
                             <div class="text-right col-12 col-sm-4">
537
-                                <button type="button" class="button button-primary recalculate-totals-button"><?php esc_html_e( 'Recalculate Totals', 'invoicing' ) ?></button>
537
+                                <button type="button" class="button button-primary recalculate-totals-button"><?php esc_html_e('Recalculate Totals', 'invoicing') ?></button>
538 538
                             </div>
539 539
                         </div>
540 540
                     </div>
541 541
 
542 542
                     <div class="getpaid-invoice-item-actions hide-if-editable">
543
-                        <p class="description m-2 text-right text-muted"><?php esc_html_e( 'This invoice is no longer editable', 'invoicing' ); ?></p>
543
+                        <p class="description m-2 text-right text-muted"><?php esc_html_e('This invoice is no longer editable', 'invoicing'); ?></p>
544 544
                     </div>
545 545
 
546 546
                     <!-- Add items to an invoice -->
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
                         <div class="modal-dialog modal-dialog-centered" role="document">
549 549
                             <div class="modal-content">
550 550
                                 <div class="modal-header">
551
-                                    <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php esc_html_e( "Add Item(s)", 'invoicing' ); ?></h5>
552
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e( "Close", 'invoicing' ); ?>">
551
+                                    <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php esc_html_e("Add Item(s)", 'invoicing'); ?></h5>
552
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e("Close", 'invoicing'); ?>">
553 553
                                         <span aria-hidden="true">&times;</span>
554 554
                                     </button>
555 555
                                 </div>
@@ -557,10 +557,10 @@  discard block
 block discarded – undo
557 557
                                     <table class="widefat">
558 558
                                         <thead>
559 559
                                             <tr>
560
-                                                <th class="pl-0 text-left"><?php esc_html_e( 'Item', 'invoicing' ) ?></th>
560
+                                                <th class="pl-0 text-left"><?php esc_html_e('Item', 'invoicing') ?></th>
561 561
                                                 <th class="pr-0 text-right hide-if-amount">
562
-                                                    <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Quantity', 'invoicing' ) ?></span>
563
-                                                    <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Hours', 'invoicing' ) ?></span>
562
+                                                    <span class="getpaid-hide-if-hours"><?php esc_html_e('Quantity', 'invoicing') ?></span>
563
+                                                    <span class="getpaid-hide-if-quantity"><?php esc_html_e('Hours', 'invoicing') ?></span>
564 564
                                                 </th>
565 565
                                             </tr>
566 566
                                         </thead>
@@ -568,9 +568,9 @@  discard block
 block discarded – undo
568 568
 								            <tr>
569 569
 									            <td class="pl-0 text-left">
570 570
                                                     <select class="regular-text getpaid-add-invoice-item-select">
571
-                                                        <option value="" selected="selected" disabled><?php esc_html_e( 'Select an item…', 'invoicing' ); ?></option>
572
-                                                        <?php foreach ( get_posts( $item_args ) as $item ) : ?>
573
-                                                        <option value="<?php echo (int) $item->ID; ?>"><?php echo esc_html( $item->post_title ); ?></option>
571
+                                                        <option value="" selected="selected" disabled><?php esc_html_e('Select an item…', 'invoicing'); ?></option>
572
+                                                        <?php foreach (get_posts($item_args) as $item) : ?>
573
+                                                        <option value="<?php echo (int) $item->ID; ?>"><?php echo esc_html($item->post_title); ?></option>
574 574
                                                         <?php endforeach; ?>
575 575
                                                     </select>
576 576
                                                 </td>
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
 						            </table>
583 583
                                 </div>
584 584
                                 <div class="modal-footer">
585
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button>
586
-                                    <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php esc_html_e( 'Add', 'invoicing' ); ?></button>
585
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button>
586
+                                    <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php esc_html_e('Add', 'invoicing'); ?></button>
587 587
                                 </div>
588 588
                             </div>
589 589
                         </div>
@@ -594,8 +594,8 @@  discard block
 block discarded – undo
594 594
                         <div class="modal-dialog modal-dialog-centered" role="document">
595 595
                             <div class="modal-content">
596 596
                                 <div class="modal-header">
597
-                                    <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php esc_html_e( "Create Item", 'invoicing' ); ?></h5>
598
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e( "Close", 'invoicing' ); ?>">
597
+                                    <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php esc_html_e("Create Item", 'invoicing'); ?></h5>
598
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e("Close", 'invoicing'); ?>">
599 599
                                         <span aria-hidden="true">&times;</span>
600 600
                                     </button>
601 601
                                 </div>
@@ -603,27 +603,27 @@  discard block
 block discarded – undo
603 603
                                     <div class="getpaid-create-item-div">
604 604
                                         <input type="hidden" name="id" value="new" class="form-control form-control-sm item-id">
605 605
                                         <label class="form-group w-100">
606
-                                            <span><?php esc_html_e( 'Name', 'invoicing' ); ?></span>
607
-                                            <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name">
606
+                                            <span><?php esc_html_e('Name', 'invoicing'); ?></span>
607
+                                            <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name">
608 608
                                         </label>
609 609
                                         <label class="form-group w-100">
610
-                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span>
611
-                                            <span class="hide-if-amount"><?php esc_html_e( 'Price', 'invoicing' ); ?></span>
612
-                                            <input type="text" name="price" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control form-control-sm item-price">
610
+                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e('Amount', 'invoicing'); ?></span>
611
+                                            <span class="hide-if-amount"><?php esc_html_e('Price', 'invoicing'); ?></span>
612
+                                            <input type="text" name="price" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control form-control-sm item-price">
613 613
                                         </label>
614 614
                                         <label class="form-group w-100 hide-if-amount">
615
-                                            <span><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span>
615
+                                            <span><?php esc_html_e('Quantity', 'invoicing'); ?></span>
616 616
                                             <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity">
617 617
                                         </label>
618 618
                                         <label class="form-group w-100">
619
-                                            <span><?php esc_html_e( 'Item Description', 'invoicing' ); ?></span>
620
-                                            <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea>
619
+                                            <span><?php esc_html_e('Item Description', 'invoicing'); ?></span>
620
+                                            <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea>
621 621
                                         </label>
622 622
                                     </div>
623 623
                                 </div>
624 624
                                 <div class="modal-footer">
625
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button>
626
-                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e( 'Create', 'invoicing' ); ?></button>
625
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button>
626
+                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e('Create', 'invoicing'); ?></button>
627 627
                                 </div>
628 628
                             </div>
629 629
                         </div>
@@ -634,8 +634,8 @@  discard block
 block discarded – undo
634 634
                         <div class="modal-dialog modal-dialog-centered" role="document">
635 635
                             <div class="modal-content">
636 636
                                 <div class="modal-header">
637
-                                    <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php esc_html_e( "Edit Item", 'invoicing' ); ?></h5>
638
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e( "Close", 'invoicing' ); ?>">
637
+                                    <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php esc_html_e("Edit Item", 'invoicing'); ?></h5>
638
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e("Close", 'invoicing'); ?>">
639 639
                                         <span aria-hidden="true">&times;</span>
640 640
                                     </button>
641 641
                                 </div>
@@ -643,27 +643,27 @@  discard block
 block discarded – undo
643 643
                                     <div class="getpaid-edit-item-div">
644 644
                                         <input type="hidden" name="id" class="form-control form-control-sm item-id">
645 645
                                         <label class="form-group w-100">
646
-                                            <span><?php esc_html_e( 'Name', 'invoicing' ); ?></span>
647
-                                            <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name">
646
+                                            <span><?php esc_html_e('Name', 'invoicing'); ?></span>
647
+                                            <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name">
648 648
                                         </label>
649 649
                                         <label class="form-group w-100">
650
-                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span>
651
-                                            <span class="hide-if-amount"><?php esc_html_e( 'Price', 'invoicing' ); ?></span>
652
-                                            <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price">
650
+                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e('Amount', 'invoicing'); ?></span>
651
+                                            <span class="hide-if-amount"><?php esc_html_e('Price', 'invoicing'); ?></span>
652
+                                            <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price">
653 653
                                         </label>
654 654
                                         <label class="form-group w-100 hide-if-amount">
655
-                                            <span><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span>
655
+                                            <span><?php esc_html_e('Quantity', 'invoicing'); ?></span>
656 656
                                             <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity">
657 657
                                         </label>
658 658
                                         <label class="form-group w-100">
659
-                                            <span><?php esc_html_e( 'Item Description', 'invoicing' ); ?></span>
660
-                                            <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea>
659
+                                            <span><?php esc_html_e('Item Description', 'invoicing'); ?></span>
660
+                                            <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea>
661 661
                                         </label>
662 662
                                     </div>
663 663
                                 </div>
664 664
                                 <div class="modal-footer">
665
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button>
666
-                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e( 'Save', 'invoicing' ); ?></button>
665
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button>
666
+                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e('Save', 'invoicing'); ?></button>
667 667
                                 </div>
668 668
                             </div>
669 669
                         </div>
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-payment-form.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  *
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if (!defined('ABSPATH')) {
10 10
 	exit; // Exit if accessed directly
11 11
 }
12 12
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @param WP_Post $post
22 22
 	 */
23
-    public static function output( $post ) {
23
+    public static function output($post) {
24 24
         ?>
25 25
         <style>
26 26
             .wpinv-form-builder-edit-field-wrapper label.d-block > span:first-child{
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
                 <div class="col-sm-4">
34 34
 
35 35
                     <!-- Builder tabs -->
36
-                    <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php esc_html_e( 'Go Back', 'invoicing' ); ?></button>
36
+                    <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php esc_html_e('Go Back', 'invoicing'); ?></button>
37 37
 
38 38
                     <!-- Builder tab content -->
39 39
                     <div class="mt-4">
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
                         <!-- Available builder elements -->
42 42
                         <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='new_item'">
43 43
                             <div class="wpinv-form-builder-add-field-types">
44
-                                <small class='form-text text-muted'><?php esc_html_e( 'Add an element by dragging it to the payment form.', 'invoicing' ); ?></small>
44
+                                <small class='form-text text-muted'><?php esc_html_e('Add an element by dragging it to the payment form.', 'invoicing'); ?></small>
45 45
                                 <draggable class="section mt-2" style="display: flex; flex-flow: wrap; justify-content: space-between;" v-model="elements" :group="{ name: 'fields', pull: 'clone', put: false }" :sort="false" :clone="addDraggedField" tag="ul" filter=".wpinv-undraggable">
46 46
                                     <li v-for="element in elements" class= "wpinv-payment-form-left-fields-field" @click.prevent="addField(element)" :class="{ 'd-none': element.defaults.premade }">
47 47
                                         <button class="button btn text-dark">
@@ -56,18 +56,18 @@  discard block
 block discarded – undo
56 56
                         <!-- Edit an element -->
57 57
                         <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='edit_item'" style="font-size: 14px;">
58 58
                             <div class="wpinv-form-builder-edit-field-wrapper">
59
-                                <?php do_action( 'wpinv_payment_form_edit_element_template', 'active_form_element', $post ); ?>
60
-                                <?php do_action( 'getpaid_payment_form_edit_element_template', $post ); ?>
59
+                                <?php do_action('wpinv_payment_form_edit_element_template', 'active_form_element', $post); ?>
60
+                                <?php do_action('getpaid_payment_form_edit_element_template', $post); ?>
61 61
                                 <div class='form-group'>
62
-                                    <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e( 'Width', 'invoicing' ); ?></label>
62
+                                    <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e('Width', 'invoicing'); ?></label>
63 63
                                     <select class='form-control custom-select' :id="active_form_element.id + '_grid_width'" v-model='gridWidth'>
64
-                                        <option value='full'><?php esc_html_e( 'Full Width', 'invoicing' ); ?></option>
65
-                                        <option value='half'><?php esc_html_e( 'Half Width', 'invoicing' ); ?></option>
66
-                                        <option value='third'><?php esc_html_e( '1/3 Width', 'invoicing' ); ?></option>
64
+                                        <option value='full'><?php esc_html_e('Full Width', 'invoicing'); ?></option>
65
+                                        <option value='half'><?php esc_html_e('Half Width', 'invoicing'); ?></option>
66
+                                        <option value='third'><?php esc_html_e('1/3 Width', 'invoicing'); ?></option>
67 67
                                     </select>
68 68
                                 </div>
69 69
                                 <div>
70
-                                    <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php esc_html_e( 'Delete Element', 'invoicing' ); ?></button>
70
+                                    <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php esc_html_e('Delete Element', 'invoicing'); ?></button>
71 71
                                 </div>
72 72
                             </div>
73 73
                         </div>
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
 
77 77
                 </div>
78 78
                 <div class="col-sm-8 border-left">
79
-                    <small class='form-text text-muted' v-if='form_elements.length'><?php esc_html_e( 'Click on any element to edit or delete it.', 'invoicing' ); ?></small>
80
-                    <p class='form-text text-muted' v-if='! form_elements.length'><?php esc_html_e( 'This form is empty. Add new elements by dragging them from the right.', 'invoicing' ); ?></p>
79
+                    <small class='form-text text-muted' v-if='form_elements.length'><?php esc_html_e('Click on any element to edit or delete it.', 'invoicing'); ?></small>
80
+                    <p class='form-text text-muted' v-if='! form_elements.length'><?php esc_html_e('This form is empty. Add new elements by dragging them from the right.', 'invoicing'); ?></p>
81 81
 
82 82
                     <div class="container-fluid">
83 83
                         <draggable class="section row" v-model="form_elements" @add="highlightLastDroppedField" group="fields" tag="div" style="min-height: 100%; font-size: 14px;">
84 84
                             <div v-for="form_element in form_elements" class="wpinv-form-builder-element-preview" :class="[{ active: active_form_element==form_element &&  active_tab=='edit_item' }, form_element.type, grid_class( form_element ) ]" @click="active_tab = 'edit_item'; active_form_element = form_element">
85 85
                                 <div class="wpinv-form-builder-element-preview-inner">
86 86
                                     <div class="wpinv-payment-form-field-preview-overlay"></div>
87
-                                    <?php do_action( 'wpinv_payment_form_render_element_template', 'form_element', $post ); ?>
87
+                                    <?php do_action('wpinv_payment_form_render_element_template', 'form_element', $post); ?>
88 88
                                 </div>
89 89
                             </div>
90 90
                         </draggable>
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         </script>
104 104
         <?php
105 105
 
106
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
106
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
107 107
     }
108 108
 
109 109
     /**
@@ -111,33 +111,33 @@  discard block
 block discarded – undo
111 111
 	 *
112 112
 	 * @param int $post_id
113 113
 	 */
114
-	public static function save( $post_id ) {
114
+	public static function save($post_id) {
115 115
 
116 116
         // Prepare the form.
117
-        $form = new GetPaid_Payment_Form( $post_id );
117
+        $form = new GetPaid_Payment_Form($post_id);
118 118
 
119 119
         // Fetch form items.
120
-        $form_items = json_decode( wp_unslash( $_POST['wpinv_form_items'] ), true );
120
+        $form_items = json_decode(wp_unslash($_POST['wpinv_form_items']), true);
121 121
 
122 122
         // Ensure that we have an array...
123
-        if ( empty( $form_items ) ) {
123
+        if (empty($form_items)) {
124 124
             $form_items = array();
125 125
         }
126 126
 
127 127
         // Add it to the form.
128
-        $form->set_items( self::item_to_objects( wp_kses_post_deep( $form_items ) ) );
128
+        $form->set_items(self::item_to_objects(wp_kses_post_deep($form_items)));
129 129
 
130 130
         // Save form elements.
131
-        $form_elements = json_decode( wp_unslash( $_POST['wpinv_form_elements'] ), true );
132
-        if ( empty( $form_elements ) ) {
131
+        $form_elements = json_decode(wp_unslash($_POST['wpinv_form_elements']), true);
132
+        if (empty($form_elements)) {
133 133
             $form_elements = array();
134 134
         }
135 135
 
136
-        $form->set_elements( wp_kses_post_deep( $form_elements ) );
136
+        $form->set_elements(wp_kses_post_deep($form_elements));
137 137
 
138 138
         // Persist data to the datastore.
139 139
         $form->save();
140
-        do_action( 'getpaid_payment_form_metabox_save', $post_id, $form );
140
+        do_action('getpaid_payment_form_metabox_save', $post_id, $form);
141 141
 
142 142
     }
143 143
 
@@ -146,14 +146,14 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @param array $items
148 148
 	 */
149
-	public static function item_to_objects( $items ) {
149
+	public static function item_to_objects($items) {
150 150
 
151 151
         $objects = array();
152 152
 
153
-        foreach ( $items as $item ) {
154
-            $_item = new GetPaid_Form_Item( $item['id'] );
155
-            $_item->set_allow_quantities( (bool) $item['allow_quantities'] );
156
-            $_item->set_is_required( (bool) $item['required'] );
153
+        foreach ($items as $item) {
154
+            $_item = new GetPaid_Form_Item($item['id']);
155
+            $_item->set_allow_quantities((bool) $item['allow_quantities']);
156
+            $_item->set_is_required((bool) $item['required']);
157 157
             $objects[] = $_item;
158 158
         }
159 159
 
Please login to merge, or discard this patch.
includes/admin/register-settings.php 1 patch
Spacing   +366 added lines, -366 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
  * Retrieves all default settings.
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 function wpinv_get_settings() {
17 17
     $defaults = array();
18 18
 
19
-    foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) {
19
+    foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) {
20 20
 
21
-        foreach ( array_values( $tab_settings ) as $section_settings ) {
21
+        foreach (array_values($tab_settings) as $section_settings) {
22 22
 
23
-            foreach ( $section_settings as $key => $setting ) {
24
-                if ( isset( $setting['std'] ) ) {
25
-                    $defaults[ $key ] = $setting['std'];
23
+            foreach ($section_settings as $key => $setting) {
24
+                if (isset($setting['std'])) {
25
+                    $defaults[$key] = $setting['std'];
26 26
                 }
27 27
             }
28 28
 }
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
     global $wpinv_options;
42 42
 
43 43
     // Try fetching the saved options.
44
-    if ( empty( $wpinv_options ) ) {
45
-        $wpinv_options = get_option( 'wpinv_settings' );
44
+    if (empty($wpinv_options)) {
45
+        $wpinv_options = get_option('wpinv_settings');
46 46
     }
47 47
 
48 48
     // If that fails, don't fetch the default settings to prevent a loop.
49
-    if ( ! is_array( $wpinv_options ) ) {
49
+    if (!is_array($wpinv_options)) {
50 50
         $wpinv_options = array();
51 51
     }
52 52
 
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
  * @param mixed $default The default value to use if the setting has not been set.
61 61
  * @return mixed
62 62
  */
63
-function wpinv_get_option( $key = '', $default = false ) {
63
+function wpinv_get_option($key = '', $default = false) {
64 64
 
65 65
     $options = wpinv_get_options();
66
-    $value   = isset( $options[ $key ] ) ? $options[ $key ] : $default;
67
-    $value   = apply_filters( 'wpinv_get_option', $value, $key, $default );
66
+    $value   = isset($options[$key]) ? $options[$key] : $default;
67
+    $value   = apply_filters('wpinv_get_option', $value, $key, $default);
68 68
 
69
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
69
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
70 70
 }
71 71
 
72 72
 /**
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
  * @param array $options the new options.
76 76
  * @return bool
77 77
  */
78
-function wpinv_update_options( $options ) {
78
+function wpinv_update_options($options) {
79 79
     global $wpinv_options;
80 80
 
81 81
     // update the option.
82
-    if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) {
82
+    if (is_array($options) && update_option('wpinv_settings', $options)) {
83 83
         $wpinv_options = $options;
84 84
         return true;
85 85
     }
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
  * @param mixed $value The setting value.
95 95
  * @return bool
96 96
  */
97
-function wpinv_update_option( $key = '', $value = false ) {
97
+function wpinv_update_option($key = '', $value = false) {
98 98
 
99 99
     // If no key, exit.
100
-    if ( empty( $key ) ) {
100
+    if (empty($key)) {
101 101
         return false;
102 102
     }
103 103
 
104 104
     // Maybe delete the option instead.
105
-    if ( is_null( $value ) ) {
106
-        return wpinv_delete_option( $key );
105
+    if (is_null($value)) {
106
+        return wpinv_delete_option($key);
107 107
     }
108 108
 
109 109
     // Prepare the new options.
110 110
     $options         = wpinv_get_options();
111
-    $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key );
111
+    $options[$key] = apply_filters('wpinv_update_option', $value, $key);
112 112
 
113 113
     // Save the new options.
114
-    return wpinv_update_options( $options );
114
+    return wpinv_update_options($options);
115 115
 
116 116
 }
117 117
 
@@ -121,18 +121,18 @@  discard block
 block discarded – undo
121 121
  * @param string $key the setting key.
122 122
  * @return bool
123 123
  */
124
-function wpinv_delete_option( $key = '' ) {
124
+function wpinv_delete_option($key = '') {
125 125
 
126 126
     // If no key, exit
127
-    if ( empty( $key ) ) {
127
+    if (empty($key)) {
128 128
         return false;
129 129
     }
130 130
 
131 131
     $options = wpinv_get_options();
132 132
 
133
-    if ( isset( $options[ $key ] ) ) {
134
-        unset( $options[ $key ] );
135
-        return wpinv_update_options( $options );
133
+    if (isset($options[$key])) {
134
+        unset($options[$key]);
135
+        return wpinv_update_options($options);
136 136
     }
137 137
 
138 138
     return true;
@@ -146,14 +146,14 @@  discard block
 block discarded – undo
146 146
 function wpinv_register_settings() {
147 147
 
148 148
     // Loop through all tabs.
149
-    foreach ( wpinv_get_registered_settings() as $tab => $sections ) {
149
+    foreach (wpinv_get_registered_settings() as $tab => $sections) {
150 150
 
151 151
         // In each tab, loop through sections.
152
-        foreach ( $sections as $section => $settings ) {
152
+        foreach ($sections as $section => $settings) {
153 153
 
154 154
             // Check for backwards compatibility
155
-            $section_tabs = wpinv_get_settings_tab_sections( $tab );
156
-            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
155
+            $section_tabs = wpinv_get_settings_tab_sections($tab);
156
+            if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) {
157 157
                 $section = 'main';
158 158
                 $settings = $sections;
159 159
             }
@@ -166,18 +166,18 @@  discard block
 block discarded – undo
166 166
                 'wpinv_settings_' . $tab . '_' . $section
167 167
             );
168 168
 
169
-            foreach ( $settings as $option ) {
170
-                if ( ! empty( $option['id'] ) ) {
171
-                    wpinv_register_settings_option( $tab, $section, $option );
169
+            foreach ($settings as $option) {
170
+                if (!empty($option['id'])) {
171
+                    wpinv_register_settings_option($tab, $section, $option);
172 172
                 }
173 173
             }
174 174
 }
175 175
     }
176 176
 
177 177
     // Creates our settings in the options table.
178
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
178
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
179 179
 }
180
-add_action( 'admin_init', 'wpinv_register_settings' );
180
+add_action('admin_init', 'wpinv_register_settings');
181 181
 
182 182
 /**
183 183
  * Register a single settings option.
@@ -187,49 +187,49 @@  discard block
 block discarded – undo
187 187
  * @param string $option
188 188
  *
189 189
  */
190
-function wpinv_register_settings_option( $tab, $section, $option ) {
190
+function wpinv_register_settings_option($tab, $section, $option) {
191 191
 
192
-    $name       = isset( $option['name'] ) ? $option['name'] : '';
192
+    $name       = isset($option['name']) ? $option['name'] : '';
193 193
     $cb         = "wpinv_{$option['type']}_callback";
194 194
     $section    = "wpinv_settings_{$tab}_$section";
195
-	$is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
195
+	$is_wizzard = is_admin() && isset($_GET['page']) && 'gp-setup' == $_GET['page'];
196 196
 
197
-	if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
198
-		$tip   = wpinv_clean( $option['desc'] );
197
+	if (isset($option['desc']) && (!$is_wizzard && !empty($option['help-tip']))) {
198
+		$tip   = wpinv_clean($option['desc']);
199 199
 		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
200
-		unset( $option['desc'] );
200
+		unset($option['desc']);
201 201
 	}
202 202
 
203 203
     // Loop through all tabs.
204 204
     add_settings_field(
205 205
         'wpinv_settings[' . $option['id'] . ']',
206 206
         $name,
207
-        function_exists( $cb ) ? $cb : 'wpinv_missing_callback',
207
+        function_exists($cb) ? $cb : 'wpinv_missing_callback',
208 208
         $section,
209 209
         $section,
210 210
         array(
211 211
             'section'         => $section,
212
-            'id'              => isset( $option['id'] ) ? $option['id'] : uniqid( 'wpinv-' ),
213
-            'desc'            => isset( $option['desc'] ) ? $option['desc'] : '',
212
+            'id'              => isset($option['id']) ? $option['id'] : uniqid('wpinv-'),
213
+            'desc'            => isset($option['desc']) ? $option['desc'] : '',
214 214
             'name'            => $name,
215
-            'size'            => isset( $option['size'] ) ? $option['size'] : null,
216
-            'options'         => isset( $option['options'] ) ? $option['options'] : '',
217
-            'selected'        => isset( $option['selected'] ) ? $option['selected'] : null,
218
-            'std'             => isset( $option['std'] ) ? $option['std'] : '',
219
-            'min'             => isset( $option['min'] ) ? $option['min'] : 0,
220
-            'max'             => isset( $option['max'] ) ? $option['max'] : 999999,
221
-            'step'            => isset( $option['step'] ) ? $option['step'] : 1,
222
-            'placeholder'     => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
223
-            'allow_blank'     => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
224
-            'readonly'        => isset( $option['readonly'] ) ? $option['readonly'] : false,
225
-            'faux'            => isset( $option['faux'] ) ? $option['faux'] : false,
226
-            'onchange'        => isset( $option['onchange'] ) ? $option['onchange'] : '',
227
-            'custom'          => isset( $option['custom'] ) ? $option['custom'] : '',
228
-			'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '',
229
-			'class'           => isset( $option['class'] ) ? $option['class'] : '',
230
-			'style'           => isset( $option['style'] ) ? $option['style'] : '',
231
-            'cols'            => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
232
-            'rows'            => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
215
+            'size'            => isset($option['size']) ? $option['size'] : null,
216
+            'options'         => isset($option['options']) ? $option['options'] : '',
217
+            'selected'        => isset($option['selected']) ? $option['selected'] : null,
218
+            'std'             => isset($option['std']) ? $option['std'] : '',
219
+            'min'             => isset($option['min']) ? $option['min'] : 0,
220
+            'max'             => isset($option['max']) ? $option['max'] : 999999,
221
+            'step'            => isset($option['step']) ? $option['step'] : 1,
222
+            'placeholder'     => isset($option['placeholder']) ? $option['placeholder'] : null,
223
+            'allow_blank'     => isset($option['allow_blank']) ? $option['allow_blank'] : true,
224
+            'readonly'        => isset($option['readonly']) ? $option['readonly'] : false,
225
+            'faux'            => isset($option['faux']) ? $option['faux'] : false,
226
+            'onchange'        => isset($option['onchange']) ? $option['onchange'] : '',
227
+            'custom'          => isset($option['custom']) ? $option['custom'] : '',
228
+			'default_content' => isset($option['default_content']) ? $option['default_content'] : '',
229
+			'class'           => isset($option['class']) ? $option['class'] : '',
230
+			'style'           => isset($option['style']) ? $option['style'] : '',
231
+            'cols'            => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
232
+            'rows'            => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
233 233
         )
234 234
     );
235 235
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
  * @return array
242 242
  */
243 243
 function wpinv_get_registered_settings() {
244
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
244
+	return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings')));
245 245
 }
246 246
 
247 247
 /**
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
  * @return array
251 251
  */
252 252
 function getpaid_get_integration_settings() {
253
-    return apply_filters( 'getpaid_integration_settings', array() );
253
+    return apply_filters('getpaid_integration_settings', array());
254 254
 }
255 255
 
256 256
 /**
@@ -258,126 +258,126 @@  discard block
 block discarded – undo
258 258
  *
259 259
  * @return array
260 260
  */
261
-function wpinv_settings_sanitize( $input = array() ) {
261
+function wpinv_settings_sanitize($input = array()) {
262 262
 
263 263
 	$wpinv_options = wpinv_get_options();
264 264
 	$raw_referrer  = wp_get_raw_referer();
265 265
 
266
-    if ( empty( $raw_referrer ) ) {
267
-		return array_merge( $wpinv_options, $input );
266
+    if (empty($raw_referrer)) {
267
+		return array_merge($wpinv_options, $input);
268 268
     }
269 269
 
270
-    wp_parse_str( $raw_referrer, $referrer );
270
+    wp_parse_str($raw_referrer, $referrer);
271 271
 
272
-	if ( in_array( 'gp-setup', $referrer ) ) {
273
-		return array_merge( $wpinv_options, $input );
272
+	if (in_array('gp-setup', $referrer)) {
273
+		return array_merge($wpinv_options, $input);
274 274
 	}
275 275
 
276 276
     $settings = wpinv_get_registered_settings();
277
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
278
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
277
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
278
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
279 279
 
280 280
     $input = $input ? $input : array();
281
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
282
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
281
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
282
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
283 283
 
284 284
     // Loop through each setting being saved and pass it through a sanitization filter
285
-    foreach ( $input as $key => $value ) {
285
+    foreach ($input as $key => $value) {
286 286
 
287 287
         // Get the setting type (checkbox, select, etc)
288
-        $type = isset( $settings[ $tab ][ $section ][ $key ]['type'] ) ? $settings[ $tab ][ $section ][ $key ]['type'] : false;
288
+        $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false;
289 289
 
290
-        if ( $type ) {
290
+        if ($type) {
291 291
             // Field type specific filter
292
-            $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$type", $value, $key );
292
+            $input[$key] = apply_filters("wpinv_settings_sanitize_$type", $value, $key);
293 293
         }
294 294
 
295 295
         // General filter
296
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
296
+		$input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
297 297
 
298 298
 		// Key specific filter.
299
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
299
+		$input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]);
300 300
     }
301 301
 
302 302
     // Loop through the whitelist and unset any that are empty for the tab being saved
303
-    $main_settings    = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
304
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
303
+    $main_settings    = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
304
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
305 305
 
306
-    $found_settings   = array_merge( $main_settings, $section_settings );
306
+    $found_settings   = array_merge($main_settings, $section_settings);
307 307
 
308
-    if ( ! empty( $found_settings ) ) {
309
-        foreach ( $found_settings as $key => $value ) {
308
+    if (!empty($found_settings)) {
309
+        foreach ($found_settings as $key => $value) {
310 310
 
311 311
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
312
-            if ( is_numeric( $key ) ) {
312
+            if (is_numeric($key)) {
313 313
                 $key = $value['id'];
314 314
             }
315 315
 
316
-            if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) {
317
-                unset( $wpinv_options[ $key ] );
316
+            if (!isset($input[$key]) && isset($wpinv_options[$key])) {
317
+                unset($wpinv_options[$key]);
318 318
             }
319 319
         }
320 320
     }
321 321
 
322 322
     // Merge our new settings with the existing
323
-    $output = array_merge( $wpinv_options, $input );
323
+    $output = array_merge($wpinv_options, $input);
324 324
 
325
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
325
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
326 326
 
327 327
     return $output;
328 328
 }
329
-add_filter( 'wpinv_settings_sanitize_text', 'trim', 10, 1 );
330
-add_filter( 'wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount' );
329
+add_filter('wpinv_settings_sanitize_text', 'trim', 10, 1);
330
+add_filter('wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount');
331 331
 
332
-function wpinv_settings_sanitize_tax_rates( $input ) {
333
-    if ( ! wpinv_current_user_can_manage_invoicing() ) {
332
+function wpinv_settings_sanitize_tax_rates($input) {
333
+    if (!wpinv_current_user_can_manage_invoicing()) {
334 334
         return $input;
335 335
     }
336 336
 
337
-    $new_rates = ! empty( $_POST['tax_rates'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rates'] ) ) : array();
337
+    $new_rates = !empty($_POST['tax_rates']) ? wp_kses_post_deep(array_values($_POST['tax_rates'])) : array();
338 338
     $tax_rates = array();
339 339
 
340
-    foreach ( $new_rates as $rate ) {
340
+    foreach ($new_rates as $rate) {
341 341
 
342
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
343
-		$rate['name']    = sanitize_text_field( $rate['name'] );
344
-		$rate['state']   = sanitize_text_field( $rate['state'] );
345
-		$rate['country'] = sanitize_text_field( $rate['country'] );
346
-		$rate['global']  = empty( $rate['state'] );
342
+		$rate['rate']    = wpinv_sanitize_amount($rate['rate']);
343
+		$rate['name']    = sanitize_text_field($rate['name']);
344
+		$rate['state']   = sanitize_text_field($rate['state']);
345
+		$rate['country'] = sanitize_text_field($rate['country']);
346
+		$rate['global']  = empty($rate['state']);
347 347
 		$tax_rates[]     = $rate;
348 348
 
349 349
 	}
350 350
 
351
-    update_option( 'wpinv_tax_rates', $tax_rates );
351
+    update_option('wpinv_tax_rates', $tax_rates);
352 352
 
353 353
     return $input;
354 354
 }
355
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
355
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
356 356
 
357 357
 function wpinv_get_settings_tabs() {
358 358
     $tabs             = array();
359
-    $tabs['general']  = __( 'General', 'invoicing' );
360
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
361
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
362
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
359
+    $tabs['general']  = __('General', 'invoicing');
360
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
361
+    $tabs['taxes']    = __('Taxes', 'invoicing');
362
+	$tabs['emails'] = __('Emails', 'invoicing');
363 363
 
364
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
365
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
364
+	if (count(getpaid_get_integration_settings()) > 0) {
365
+		$tabs['integrations'] = __('Integrations', 'invoicing');
366 366
 	}
367 367
 
368
-    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
369
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
370
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
368
+    $tabs['privacy']  = __('Privacy', 'invoicing');
369
+    $tabs['misc']     = __('Misc', 'invoicing');
370
+    $tabs['tools']    = __('Tools', 'invoicing');
371 371
 
372
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
372
+    return apply_filters('wpinv_settings_tabs', $tabs);
373 373
 }
374 374
 
375
-function wpinv_get_settings_tab_sections( $tab = false ) {
375
+function wpinv_get_settings_tab_sections($tab = false) {
376 376
     $tabs     = false;
377 377
     $sections = wpinv_get_registered_settings_sections();
378 378
 
379
-    if ( $tab && ! empty( $sections[ $tab ] ) ) {
380
-        $tabs = $sections[ $tab ];
379
+    if ($tab && !empty($sections[$tab])) {
380
+        $tabs = $sections[$tab];
381 381
     }
382 382
 
383 383
     return $tabs;
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 function wpinv_get_registered_settings_sections() {
387 387
     static $sections = false;
388 388
 
389
-    if ( false !== $sections ) {
389
+    if (false !== $sections) {
390 390
         return $sections;
391 391
     }
392 392
 
@@ -394,230 +394,230 @@  discard block
 block discarded – undo
394 394
         'general'      => apply_filters(
395 395
             'wpinv_settings_sections_general',
396 396
             array(
397
-				'main'             => __( 'General Settings', 'invoicing' ),
398
-				'page_section'     => __( 'Page Settings', 'invoicing' ),
399
-				'currency_section' => __( 'Currency Settings', 'invoicing' ),
400
-				'labels'           => __( 'Label Texts', 'invoicing' ),
397
+				'main'             => __('General Settings', 'invoicing'),
398
+				'page_section'     => __('Page Settings', 'invoicing'),
399
+				'currency_section' => __('Currency Settings', 'invoicing'),
400
+				'labels'           => __('Label Texts', 'invoicing'),
401 401
             )
402 402
         ),
403 403
         'gateways'     => apply_filters(
404 404
             'wpinv_settings_sections_gateways',
405 405
             array(
406
-				'main' => __( 'Gateway Settings', 'invoicing' ),
406
+				'main' => __('Gateway Settings', 'invoicing'),
407 407
             )
408 408
         ),
409 409
         'taxes'        => apply_filters(
410 410
             'wpinv_settings_sections_taxes',
411 411
             array(
412
-				'main'  => __( 'Tax Settings', 'invoicing' ),
413
-				'rates' => __( 'Tax Rates', 'invoicing' ),
414
-				'vat'   => __( 'EU VAT Settings', 'invoicing' ),
412
+				'main'  => __('Tax Settings', 'invoicing'),
413
+				'rates' => __('Tax Rates', 'invoicing'),
414
+				'vat'   => __('EU VAT Settings', 'invoicing'),
415 415
             )
416 416
         ),
417 417
         'emails'       => apply_filters(
418 418
             'wpinv_settings_sections_emails',
419 419
             array(
420
-				'main' => __( 'Email Settings', 'invoicing' ),
420
+				'main' => __('Email Settings', 'invoicing'),
421 421
             )
422 422
         ),
423 423
 
424
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
424
+		'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'),
425 425
 
426 426
         'privacy'      => apply_filters(
427 427
             'wpinv_settings_sections_privacy',
428 428
             array(
429
-				'main' => __( 'Privacy policy', 'invoicing' ),
429
+				'main' => __('Privacy policy', 'invoicing'),
430 430
             )
431 431
         ),
432 432
         'misc'         => apply_filters(
433 433
             'wpinv_settings_sections_misc',
434 434
             array(
435
-				'main'       => __( 'Miscellaneous', 'invoicing' ),
436
-				'custom-css' => __( 'Custom CSS', 'invoicing' ),
435
+				'main'       => __('Miscellaneous', 'invoicing'),
436
+				'custom-css' => __('Custom CSS', 'invoicing'),
437 437
             )
438 438
         ),
439 439
         'tools'        => apply_filters(
440 440
             'wpinv_settings_sections_tools',
441 441
             array(
442
-				'main' => __( 'Diagnostic Tools', 'invoicing' ),
442
+				'main' => __('Diagnostic Tools', 'invoicing'),
443 443
             )
444 444
         ),
445 445
     );
446 446
 
447
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
447
+    $sections = apply_filters('wpinv_settings_sections', $sections);
448 448
 
449 449
     return $sections;
450 450
 }
451 451
 
452
-function wpinv_get_pages( $with_slug = false, $default_label = null ) {
452
+function wpinv_get_pages($with_slug = false, $default_label = null) {
453 453
 	$pages_options = array();
454 454
 
455
-	if ( $default_label !== null && $default_label !== false ) {
456
-		$pages_options = array( '' => $default_label ); // Blank option
455
+	if ($default_label !== null && $default_label !== false) {
456
+		$pages_options = array('' => $default_label); // Blank option
457 457
 	}
458 458
 
459 459
 	$pages = get_pages();
460
-	if ( $pages ) {
461
-		foreach ( $pages as $page ) {
460
+	if ($pages) {
461
+		foreach ($pages as $page) {
462 462
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
463
-            $pages_options[ $page->ID ] = $title;
463
+            $pages_options[$page->ID] = $title;
464 464
 		}
465 465
 	}
466 466
 
467 467
 	return $pages_options;
468 468
 }
469 469
 
470
-function wpinv_header_callback( $args ) {
471
-	if ( ! empty( $args['desc'] ) ) {
472
-        echo wp_kses_post( $args['desc'] );
470
+function wpinv_header_callback($args) {
471
+	if (!empty($args['desc'])) {
472
+        echo wp_kses_post($args['desc']);
473 473
     }
474 474
 }
475 475
 
476
-function wpinv_hidden_callback( $args ) {
476
+function wpinv_hidden_callback($args) {
477 477
 
478
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
479
-	$value   = wpinv_get_option( $args['id'], $std );
478
+	$std     = isset($args['std']) ? $args['std'] : '';
479
+	$value   = wpinv_get_option($args['id'], $std);
480 480
 
481
-	if ( isset( $args['set_value'] ) ) {
481
+	if (isset($args['set_value'])) {
482 482
 		$value = $args['set_value'];
483 483
 	}
484 484
 
485
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
485
+	if (isset($args['faux']) && true === $args['faux']) {
486 486
 		$args['readonly'] = true;
487
-		$name  = '';
487
+		$name = '';
488 488
 	} else {
489
-		$name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']';
489
+		$name = 'wpinv_settings[' . esc_attr($args['id']) . ']';
490 490
 	}
491 491
 
492
-	echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />';
492
+	echo '<input type="hidden" id="wpinv_settings[' . esc_attr($args['id']) . ']" name="' . esc_attr($name) . '" value="' . esc_attr(stripslashes($value)) . '" />';
493 493
 
494 494
 }
495 495
 
496 496
 /**
497 497
  * Displays a checkbox settings callback.
498 498
  */
499
-function wpinv_checkbox_callback( $args ) {
499
+function wpinv_checkbox_callback($args) {
500 500
 
501
-	$std = isset( $args['std'] ) ? $args['std'] : '';
502
-	$std = wpinv_get_option( $args['id'], $std );
503
-	$id  = esc_attr( $args['id'] );
501
+	$std = isset($args['std']) ? $args['std'] : '';
502
+	$std = wpinv_get_option($args['id'], $std);
503
+	$id  = esc_attr($args['id']);
504 504
 
505
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
505
+	getpaid_hidden_field("wpinv_settings[$id]", '0');
506 506
 	?>
507 507
 		<fieldset>
508 508
 			<label>
509
-				<input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
510
-				<?php echo wp_kses_post( $args['desc'] ); ?>
509
+				<input id="wpinv-settings-<?php echo esc_attr($id); ?>" name="wpinv_settings[<?php echo esc_attr($id); ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox">
510
+				<?php echo wp_kses_post($args['desc']); ?>
511 511
 			</label>
512 512
 		</fieldset>
513 513
 	<?php
514 514
 }
515 515
 
516
-function wpinv_multicheck_callback( $args ) {
516
+function wpinv_multicheck_callback($args) {
517 517
 
518
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
519
-	$class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
518
+	$sanitize_id = wpinv_sanitize_key($args['id']);
519
+	$class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
520 520
 
521
-	if ( ! empty( $args['options'] ) ) {
521
+	if (!empty($args['options'])) {
522 522
 
523
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
524
-		$value   = wpinv_get_option( $args['id'], $std );
523
+		$std     = isset($args['std']) ? $args['std'] : array();
524
+		$value   = wpinv_get_option($args['id'], $std);
525 525
 
526
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">';
527
-        foreach ( $args['options'] as $key => $option ) :
528
-			$sanitize_key = esc_attr( wpinv_sanitize_key( $key ) );
529
-			if ( in_array( $sanitize_key, $value ) ) {
526
+		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr($sanitize_id . $class) . '">';
527
+        foreach ($args['options'] as $key => $option) :
528
+			$sanitize_key = esc_attr(wpinv_sanitize_key($key));
529
+			if (in_array($sanitize_key, $value)) {
530 530
 				$enabled = $sanitize_key;
531 531
 			} else {
532 532
 				$enabled = null;
533 533
 			}
534
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
535
-			echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>';
534
+			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/>&nbsp;';
535
+			echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']">' . wp_kses_post($option) . '</label></div>';
536 536
 		endforeach;
537 537
 		echo '</div>';
538
-		echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
538
+		echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>';
539 539
 	}
540 540
 }
541 541
 
542
-function wpinv_payment_icons_callback( $args ) {
542
+function wpinv_payment_icons_callback($args) {
543 543
 
544
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
545
-	$value   = wpinv_get_option( $args['id'], false );
544
+    $sanitize_id = wpinv_sanitize_key($args['id']);
545
+	$value = wpinv_get_option($args['id'], false);
546 546
 
547
-	if ( ! empty( $args['options'] ) ) {
548
-		foreach ( $args['options'] as $key => $option ) {
549
-            $sanitize_key = wpinv_sanitize_key( $key );
547
+	if (!empty($args['options'])) {
548
+		foreach ($args['options'] as $key => $option) {
549
+            $sanitize_key = wpinv_sanitize_key($key);
550 550
 
551
-			if ( empty( $value ) ) {
551
+			if (empty($value)) {
552 552
 				$enabled = $option;
553 553
 			} else {
554 554
 				$enabled = null;
555 555
 			}
556 556
 
557
-			echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
557
+			echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
558 558
 
559
-				echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
559
+				echo '<input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/>&nbsp;';
560 560
 
561
-				if ( wpinv_string_is_image_url( $key ) ) {
562
-				echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
561
+				if (wpinv_string_is_image_url($key)) {
562
+				echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
563 563
 				} else {
564
-				$card = strtolower( str_replace( ' ', '', $option ) );
564
+				$card = strtolower(str_replace(' ', '', $option));
565 565
 
566
-				if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
567
-					$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
566
+				if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
567
+					$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
568 568
 					} else {
569
-					$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
569
+					$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
570 570
 					$content_dir = WP_CONTENT_DIR;
571 571
 
572
-					if ( function_exists( 'wp_normalize_path' ) ) {
572
+					if (function_exists('wp_normalize_path')) {
573 573
 						// Replaces backslashes with forward slashes for Windows systems
574
-						$image = wp_normalize_path( $image );
575
-						$content_dir = wp_normalize_path( $content_dir );
574
+						$image = wp_normalize_path($image);
575
+						$content_dir = wp_normalize_path($content_dir);
576 576
 						}
577 577
 
578
-					$image = str_replace( $content_dir, content_url(), $image );
578
+					$image = str_replace($content_dir, content_url(), $image);
579 579
 					}
580 580
 
581
-				echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
581
+				echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
582 582
 				}
583
-			echo wp_kses_post( $option ) . '</label>';
583
+			echo wp_kses_post($option) . '</label>';
584 584
 		}
585
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
585
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
586 586
 	}
587 587
 }
588 588
 
589 589
 /**
590 590
  * Displays a radio settings field.
591 591
  */
592
-function wpinv_radio_callback( $args ) {
592
+function wpinv_radio_callback($args) {
593 593
 
594
-	$std = isset( $args['std'] ) ? $args['std'] : '';
595
-	$std = wpinv_get_option( $args['id'], $std );
594
+	$std = isset($args['std']) ? $args['std'] : '';
595
+	$std = wpinv_get_option($args['id'], $std);
596 596
 	?>
597 597
 		<fieldset>
598
-			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
599
-				<?php foreach ( $args['options'] as $key => $option ) : ?>
598
+			<ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;">
599
+				<?php foreach ($args['options'] as $key => $option) : ?>
600 600
 					<li>
601 601
 						<label>
602
-							<input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio">
603
-							<?php echo wp_kses_post( $option ); ?>
602
+							<input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio">
603
+							<?php echo wp_kses_post($option); ?>
604 604
 						</label>
605 605
 					</li>
606 606
 				<?php endforeach; ?>
607 607
 			</ul>
608 608
 		</fieldset>
609 609
 	<?php
610
-	getpaid_settings_description_callback( $args );
610
+	getpaid_settings_description_callback($args);
611 611
 }
612 612
 
613 613
 /**
614 614
  * Displays a description if available.
615 615
  */
616
-function getpaid_settings_description_callback( $args ) {
616
+function getpaid_settings_description_callback($args) {
617 617
 
618
-	if ( ! empty( $args['desc'] ) ) {
618
+	if (!empty($args['desc'])) {
619 619
 		$description = $args['desc'];
620
-		echo wp_kses_post( "<p class='description'>$description</p>" );
620
+		echo wp_kses_post("<p class='description'>$description</p>");
621 621
 	}
622 622
 
623 623
 }
@@ -632,35 +632,35 @@  discard block
 block discarded – undo
632 632
 	</tr>
633 633
 	<tr class="bsui">
634 634
     	<td colspan="2" class="p-0">
635
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?>
635
+			<?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?>
636 636
 
637 637
 	<?php
638 638
 }
639 639
 
640
-function wpinv_gateway_select_callback( $args ) {
640
+function wpinv_gateway_select_callback($args) {
641 641
 
642
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
643
-    $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
644
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
645
-	$value   = wpinv_get_option( $args['id'], $std );
642
+    $sanitize_id = wpinv_sanitize_key($args['id']);
643
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
644
+	$std     = isset($args['std']) ? $args['std'] : '';
645
+	$value   = wpinv_get_option($args['id'], $std);
646 646
 
647
-	echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >';
647
+	echo '<select name="wpinv_settings[' . esc_attr($sanitize_id) . ']"" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" class="' . esc_attr($class) . '" >';
648 648
 
649
-	foreach ( $args['options'] as $key => $option ) :
649
+	foreach ($args['options'] as $key => $option) :
650 650
 
651
-		echo '<option value="' . esc_attr( $key ) . '" ';
651
+		echo '<option value="' . esc_attr($key) . '" ';
652 652
 
653
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
654
-            selected( $key, $args['selected'] );
653
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
654
+            selected($key, $args['selected']);
655 655
         } else {
656
-            selected( $key, $value );
656
+            selected($key, $value);
657 657
         }
658 658
 
659
-		echo '>' . esc_html( $option['admin_label'] ) . '</option>';
659
+		echo '>' . esc_html($option['admin_label']) . '</option>';
660 660
 	endforeach;
661 661
 
662 662
 	echo '</select>';
663
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
663
+	echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
664 664
 }
665 665
 
666 666
 /**
@@ -669,28 +669,28 @@  discard block
 block discarded – undo
669 669
  * @param array $args
670 670
  * @return string
671 671
  */
672
-function wpinv_settings_attrs_helper( $args ) {
672
+function wpinv_settings_attrs_helper($args) {
673 673
 
674
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
675
-	$id           = esc_attr( $args['id'] );
676
-	$placeholder  = esc_attr( $args['placeholder'] );
674
+	$value        = isset($args['std']) ? $args['std'] : '';
675
+	$id           = esc_attr($args['id']);
676
+	$placeholder  = esc_attr($args['placeholder']);
677 677
 
678
-	if ( ! empty( $args['faux'] ) ) {
678
+	if (!empty($args['faux'])) {
679 679
 		$args['readonly'] = true;
680 680
 		$name             = '';
681 681
 	} else {
682
-		$value  = wpinv_get_option( $args['id'], $value );
682
+		$value  = wpinv_get_option($args['id'], $value);
683 683
 		$name   = "wpinv_settings[$id]";
684 684
 	}
685 685
 
686
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
687
-	$class    = esc_attr( $args['class'] );
688
-	$style    = esc_attr( $args['style'] );
689
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
686
+	$value    = is_scalar($value) ? esc_attr($value) : '';
687
+	$class    = esc_attr($args['class']);
688
+	$style    = esc_attr($args['style']);
689
+	$readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"';
690 690
 
691 691
 	$onchange = '';
692
-    if ( ! empty( $args['onchange'] ) ) {
693
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
692
+    if (!empty($args['onchange'])) {
693
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
694 694
 	}
695 695
 
696 696
 	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
@@ -699,14 +699,14 @@  discard block
 block discarded – undo
699 699
 /**
700 700
  * Displays a text input settings callback.
701 701
  */
702
-function wpinv_text_callback( $args ) {
702
+function wpinv_text_callback($args) {
703 703
 
704
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
704
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
705 705
 
706 706
 	?>
707 707
 		<label style="width: 100%;">
708
-			<input type="text" <?php echo wpinv_settings_attrs_helper( $args ); ?>>
709
-			<?php echo wp_kses_post( $desc ); ?>
708
+			<input type="text" <?php echo wpinv_settings_attrs_helper($args); ?>>
709
+			<?php echo wp_kses_post($desc); ?>
710 710
 		</label>
711 711
 	<?php
712 712
 
@@ -715,49 +715,49 @@  discard block
 block discarded – undo
715 715
 /**
716 716
  * Displays a number input settings callback.
717 717
  */
718
-function wpinv_number_callback( $args ) {
718
+function wpinv_number_callback($args) {
719 719
 
720
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
721
-	$attr = wpinv_settings_attrs_helper( $args );
720
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
721
+	$attr = wpinv_settings_attrs_helper($args);
722 722
 
723 723
 	?>
724 724
 		<label style="width: 100%;">
725
-			<input type="number" step="<?php echo floatval( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php echo $attr; ?>>
726
-			<?php echo wp_kses_post( $desc ); ?>
725
+			<input type="number" step="<?php echo floatval($args['step']); ?>" max="<?php echo intval($args['max']); ?>" min="<?php echo intval($args['min']); ?>" <?php echo $attr; ?>>
726
+			<?php echo wp_kses_post($desc); ?>
727 727
 		</label>
728 728
 	<?php
729 729
 
730 730
 }
731 731
 
732
-function wpinv_textarea_callback( $args ) {
732
+function wpinv_textarea_callback($args) {
733 733
 
734
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
735
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
736
-	$value   = wpinv_get_option( $args['id'], $std );
734
+    $sanitize_id = wpinv_sanitize_key($args['id']);
735
+	$std     = isset($args['std']) ? $args['std'] : '';
736
+	$value   = wpinv_get_option($args['id'], $std);
737 737
 
738
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
739
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
738
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
739
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
740 740
 
741
-	echo '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
742
-	echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
741
+	echo '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>';
742
+	echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
743 743
 
744 744
 }
745 745
 
746
-function wpinv_password_callback( $args ) {
746
+function wpinv_password_callback($args) {
747 747
 
748
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
749
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
750
-	$value   = wpinv_get_option( $args['id'], $std );
748
+    $sanitize_id = wpinv_sanitize_key($args['id']);
749
+	$std     = isset($args['std']) ? $args['std'] : '';
750
+	$value   = wpinv_get_option($args['id'], $std);
751 751
 
752
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
753
-	echo '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
754
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
752
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
753
+	echo '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>';
754
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
755 755
 
756 756
 }
757 757
 
758
-function wpinv_missing_callback( $args ) {
758
+function wpinv_missing_callback($args) {
759 759
 	printf(
760
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
760
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
761 761
 		'<strong>' . $args['id'] . '</strong>'
762 762
 	);
763 763
 }
@@ -765,35 +765,35 @@  discard block
 block discarded – undo
765 765
 /**
766 766
  * Displays a number input settings callback.
767 767
  */
768
-function wpinv_select_callback( $args ) {
768
+function wpinv_select_callback($args) {
769 769
 
770
-	$desc   = wp_kses_post( $args['desc'] );
771
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
772
-	$attr   = wpinv_settings_attrs_helper( $args );
773
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
774
-	$value  = wpinv_get_option( $args['id'], $value );
775
-	$rand   = uniqid( 'random_id' );
770
+	$desc   = wp_kses_post($args['desc']);
771
+	$desc   = empty($desc) ? '' : "<p class='description'>$desc</p>";
772
+	$attr   = wpinv_settings_attrs_helper($args);
773
+	$value  = isset($args['std']) ? $args['std'] : '';
774
+	$value  = wpinv_get_option($args['id'], $value);
775
+	$rand   = uniqid('random_id');
776 776
 
777 777
 	?>
778 778
 		<label style="width: 100%;">
779 779
 			<select <?php echo $attr; ?> data-allow-clear="true">
780
-				<?php foreach ( $args['options'] as $option => $name ) : ?>
781
-					<option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo wpinv_clean( $name ); ?></option>
780
+				<?php foreach ($args['options'] as $option => $name) : ?>
781
+					<option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo wpinv_clean($name); ?></option>
782 782
 				<?php endforeach; ?>
783 783
 			</select>
784 784
 
785
-			<?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?>
786
-				<a href="<?php echo get_edit_post_link( $value ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e( 'Edit Page', 'invoicing' ); ?></a>
785
+			<?php if (substr($args['id'], -5) === '_page' && is_numeric($value)) : ?>
786
+				<a href="<?php echo get_edit_post_link($value); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e('Edit Page', 'invoicing'); ?></a>
787 787
 			<?php endif; ?>
788 788
 
789
-			<?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?>
790
-				&nbsp;<a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e( 'View Default Content', 'invoicing' ); ?></a>
789
+			<?php if (substr($args['id'], -5) === '_page' && !empty($args['default_content'])) : ?>
790
+				&nbsp;<a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e('View Default Content', 'invoicing'); ?></a>
791 791
 				<div id='<?php echo $rand; ?>' style='display:none;'>
792 792
 					<div>
793
-						<h3><?php esc_html_e( 'Original Content', 'invoicing' ); ?></h3>
794
-						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines( wp_kses_post( $args['default_content'] ) ); ?></textarea>
795
-						<h3><?php esc_html_e( 'Current Content', 'invoicing' ); ?></h3>
796
-						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : gepaid_trim_lines( wp_kses_post( $_post->post_content ) ); ?></textarea>
793
+						<h3><?php esc_html_e('Original Content', 'invoicing'); ?></h3>
794
+						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines(wp_kses_post($args['default_content'])); ?></textarea>
795
+						<h3><?php esc_html_e('Current Content', 'invoicing'); ?></h3>
796
+						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post($value); echo empty($_post) ? '' : gepaid_trim_lines(wp_kses_post($_post->post_content)); ?></textarea>
797 797
 					</div>
798 798
 				</div>
799 799
 			<?php endif; ?>
@@ -804,89 +804,89 @@  discard block
 block discarded – undo
804 804
 
805 805
 }
806 806
 
807
-function wpinv_color_select_callback( $args ) {
807
+function wpinv_color_select_callback($args) {
808 808
 
809
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
810
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
811
-	$value   = wpinv_get_option( $args['id'], $std );
809
+    $sanitize_id = wpinv_sanitize_key($args['id']);
810
+	$std     = isset($args['std']) ? $args['std'] : '';
811
+	$value   = wpinv_get_option($args['id'], $std);
812 812
 
813
-	echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
813
+	echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
814 814
 
815
-	foreach ( $args['options'] as $option => $color ) {
816
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>';
815
+	foreach ($args['options'] as $option => $color) {
816
+		echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($color['label']) . '</option>';
817 817
 	}
818 818
 
819 819
 	echo '</select>';
820
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
820
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
821 821
 
822 822
 }
823 823
 
824
-function wpinv_rich_editor_callback( $args ) {
824
+function wpinv_rich_editor_callback($args) {
825 825
 	global $wp_version;
826 826
 
827
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
827
+    $sanitize_id = wpinv_sanitize_key($args['id']);
828 828
 
829
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
830
-	$value   = wpinv_get_option( $args['id'], $std );
829
+	$std     = isset($args['std']) ? $args['std'] : '';
830
+	$value   = wpinv_get_option($args['id'], $std);
831 831
 
832
-	if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
832
+	if (!empty($args['allow_blank']) && empty($value)) {
833 833
 		$value = $std;
834 834
 	}
835 835
 
836
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
836
+	$rows = isset($args['size']) ? $args['size'] : 20;
837 837
 
838 838
 	echo '<div class="getpaid-settings-editor-input">';
839
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
839
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
840 840
 		wp_editor(
841
-            stripslashes( $value ),
842
-            'wpinv_settings_' . esc_attr( $args['id'] ),
841
+            stripslashes($value),
842
+            'wpinv_settings_' . esc_attr($args['id']),
843 843
             array(
844
-				'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']',
845
-				'textarea_rows' => absint( $rows ),
844
+				'textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']',
845
+				'textarea_rows' => absint($rows),
846 846
 				'media_buttons' => false,
847 847
             )
848 848
         );
849 849
 	} else {
850
-		echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
850
+		echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>';
851 851
 	}
852 852
 
853
-	echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
853
+	echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
854 854
 
855 855
 }
856 856
 
857
-function wpinv_upload_callback( $args ) {
857
+function wpinv_upload_callback($args) {
858 858
 
859
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
859
+    $sanitize_id = wpinv_sanitize_key($args['id']);
860 860
 
861
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
862
-	$value   = wpinv_get_option( $args['id'], $std );
861
+	$std     = isset($args['std']) ? $args['std'] : '';
862
+	$value   = wpinv_get_option($args['id'], $std);
863 863
 
864
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
865
-	echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
866
-	echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
867
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
864
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
865
+	echo '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>';
866
+	echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
867
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
868 868
 
869 869
 }
870 870
 
871
-function wpinv_color_callback( $args ) {
871
+function wpinv_color_callback($args) {
872 872
 
873
-	$std         = isset( $args['std'] ) ? $args['std'] : '';
874
-	$value       = wpinv_get_option( $args['id'], $std );
875
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
873
+	$std         = isset($args['std']) ? $args['std'] : '';
874
+	$value       = wpinv_get_option($args['id'], $std);
875
+    $sanitize_id = wpinv_sanitize_key($args['id']);
876 876
 
877
-	echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
878
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
877
+	echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($std) . '" />';
878
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
879 879
 
880 880
 }
881 881
 
882
-function wpinv_country_states_callback( $args ) {
882
+function wpinv_country_states_callback($args) {
883 883
 
884
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
885
-	$value   = wpinv_get_option( $args['id'], $std );
884
+	$std     = isset($args['std']) ? $args['std'] : '';
885
+	$value   = wpinv_get_option($args['id'], $std);
886 886
 
887
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
887
+    $sanitize_id = wpinv_sanitize_key($args['id']);
888 888
 
889
-	if ( isset( $args['placeholder'] ) ) {
889
+	if (isset($args['placeholder'])) {
890 890
 		$placeholder = $args['placeholder'];
891 891
 	} else {
892 892
 		$placeholder = '';
@@ -894,15 +894,15 @@  discard block
 block discarded – undo
894 894
 
895 895
 	$states = wpinv_get_country_states();
896 896
 
897
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
898
-	echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
897
+	$class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
898
+	echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
899 899
 
900
-	foreach ( $states as $option => $name ) {
901
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>';
900
+	foreach ($states as $option => $name) {
901
+		echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($name) . '</option>';
902 902
 	}
903 903
 
904 904
 	echo '</select>';
905
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
905
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
906 906
 
907 907
 }
908 908
 
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
 	</tr>
917 917
 	<tr class="bsui">
918 918
     	<td colspan="2" class="p-0">
919
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?>
919
+			<?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?>
920 920
 
921 921
 	<?php
922 922
 
@@ -925,14 +925,14 @@  discard block
 block discarded – undo
925 925
 /**
926 926
  * Displays a tax rate' edit row.
927 927
  */
928
-function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
928
+function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) {
929 929
 	ob_start();
930 930
 
931
-	$key                      = sanitize_key( $key );
932
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
933
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
931
+	$key                      = sanitize_key($key);
932
+	$tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate'];
933
+	include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php';
934 934
 
935
-	if ( $echo ) {
935
+	if ($echo) {
936 936
 		echo ob_get_clean();
937 937
 	} else {
938 938
 		return ob_get_clean();
@@ -941,152 +941,152 @@  discard block
 block discarded – undo
941 941
 }
942 942
 
943 943
 
944
-function wpinv_tools_callback( $args ) {
944
+function wpinv_tools_callback($args) {
945 945
     ?>
946 946
     </td><tr>
947 947
     <td colspan="2" class="wpinv_tools_tdbox">
948 948
     <?php
949
-    if ( $args['desc'] ) {
949
+    if ($args['desc']) {
950 950
 ?>
951 951
 <p><?php echo $args['desc']; ?></p><?php } ?>
952
-    <?php do_action( 'wpinv_tools_before' ); ?>
952
+    <?php do_action('wpinv_tools_before'); ?>
953 953
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
954 954
         <thead>
955 955
             <tr>
956
-                <th scope="col" class="wpinv-th-tool"><?php esc_html_e( 'Tool', 'invoicing' ); ?></th>
957
-                <th scope="col" class="wpinv-th-desc"><?php esc_html_e( 'Description', 'invoicing' ); ?></th>
958
-                <th scope="col" class="wpinv-th-action"><?php esc_html_e( 'Action', 'invoicing' ); ?></th>
956
+                <th scope="col" class="wpinv-th-tool"><?php esc_html_e('Tool', 'invoicing'); ?></th>
957
+                <th scope="col" class="wpinv-th-desc"><?php esc_html_e('Description', 'invoicing'); ?></th>
958
+                <th scope="col" class="wpinv-th-action"><?php esc_html_e('Action', 'invoicing'); ?></th>
959 959
             </tr>
960 960
         </thead>
961 961
 
962 962
         <tbody>
963 963
 			<tr>
964
-                <td><?php esc_html_e( 'Check Pages', 'invoicing' ); ?></td>
964
+                <td><?php esc_html_e('Check Pages', 'invoicing'); ?></td>
965 965
                 <td>
966
-                    <small><?php esc_html_e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small>
966
+                    <small><?php esc_html_e('Creates any missing GetPaid pages.', 'invoicing'); ?></small>
967 967
                 </td>
968 968
                 <td>
969 969
 					<a href="
970 970
                     <?php
971 971
 						echo esc_url(
972 972
 							wp_nonce_url(
973
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
973
+								add_query_arg('getpaid-admin-action', 'create_missing_pages'),
974 974
 								'getpaid-nonce',
975 975
 								'getpaid-nonce'
976 976
 							)
977 977
 						);
978 978
 					?>
979
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
979
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
980 980
                 </td>
981 981
             </tr>
982 982
 			<tr>
983
-                <td><?php esc_html_e( 'Create Database Tables', 'invoicing' ); ?></td>
983
+                <td><?php esc_html_e('Create Database Tables', 'invoicing'); ?></td>
984 984
                 <td>
985
-                    <small><?php esc_html_e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small>
985
+                    <small><?php esc_html_e('Run this tool to create any missing database tables.', 'invoicing'); ?></small>
986 986
                 </td>
987 987
                 <td>
988 988
 					<a href="
989 989
                     <?php
990 990
 						echo esc_url(
991 991
 							wp_nonce_url(
992
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
992
+								add_query_arg('getpaid-admin-action', 'create_missing_tables'),
993 993
 								'getpaid-nonce',
994 994
 								'getpaid-nonce'
995 995
 							)
996 996
 						);
997 997
 					?>
998
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
998
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
999 999
                 </td>
1000 1000
             </tr>
1001 1001
 			<tr>
1002
-                <td><?php esc_html_e( 'Migrate old invoices', 'invoicing' ); ?></td>
1002
+                <td><?php esc_html_e('Migrate old invoices', 'invoicing'); ?></td>
1003 1003
                 <td>
1004
-                    <small><?php esc_html_e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small>
1004
+                    <small><?php esc_html_e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small>
1005 1005
                 </td>
1006 1006
                 <td>
1007 1007
 					<a href="
1008 1008
                     <?php
1009 1009
 						echo esc_url(
1010 1010
 							wp_nonce_url(
1011
-								add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1011
+								add_query_arg('getpaid-admin-action', 'migrate_old_invoices'),
1012 1012
 								'getpaid-nonce',
1013 1013
 								'getpaid-nonce'
1014 1014
 							)
1015 1015
 						);
1016 1016
 					?>
1017
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1017
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
1018 1018
                 </td>
1019 1019
             </tr>
1020 1020
 
1021 1021
 			<tr>
1022
-                <td><?php esc_html_e( 'Recalculate Discounts', 'invoicing' ); ?></td>
1022
+                <td><?php esc_html_e('Recalculate Discounts', 'invoicing'); ?></td>
1023 1023
                 <td>
1024
-                    <small><?php esc_html_e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small>
1024
+                    <small><?php esc_html_e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small>
1025 1025
                 </td>
1026 1026
                 <td>
1027 1027
 					<a href="
1028 1028
                     <?php
1029 1029
 						echo esc_url(
1030 1030
 							wp_nonce_url(
1031
-								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1031
+								add_query_arg('getpaid-admin-action', 'recalculate_discounts'),
1032 1032
 								'getpaid-nonce',
1033 1033
 								'getpaid-nonce'
1034 1034
 							)
1035 1035
 						);
1036 1036
 					?>
1037
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1037
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
1038 1038
                 </td>
1039 1039
             </tr>
1040 1040
 
1041 1041
 			<tr>
1042
-                <td><?php esc_html_e( 'Set-up Wizard', 'invoicing' ); ?></td>
1042
+                <td><?php esc_html_e('Set-up Wizard', 'invoicing'); ?></td>
1043 1043
                 <td>
1044
-                    <small><?php esc_html_e( 'Launch the quick set-up wizard.', 'invoicing' ); ?></small>
1044
+                    <small><?php esc_html_e('Launch the quick set-up wizard.', 'invoicing'); ?></small>
1045 1045
                 </td>
1046 1046
                 <td>
1047 1047
 					<a href="
1048 1048
                     <?php
1049
-						echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1049
+						echo esc_url(admin_url('index.php?page=gp-setup'));
1050 1050
 					?>
1051
-                    " class="button button-primary"><?php esc_html_e( 'Launch', 'invoicing' ); ?></a>
1051
+                    " class="button button-primary"><?php esc_html_e('Launch', 'invoicing'); ?></a>
1052 1052
                 </td>
1053 1053
             </tr>
1054 1054
 
1055
-			<?php do_action( 'wpinv_tools_row' ); ?>
1055
+			<?php do_action('wpinv_tools_row'); ?>
1056 1056
         </tbody>
1057 1057
     </table>
1058
-    <?php do_action( 'wpinv_tools_after' ); ?>
1058
+    <?php do_action('wpinv_tools_after'); ?>
1059 1059
     <?php
1060 1060
 }
1061 1061
 
1062 1062
 
1063
-function wpinv_descriptive_text_callback( $args ) {
1064
-	echo wp_kses_post( $args['desc'] );
1063
+function wpinv_descriptive_text_callback($args) {
1064
+	echo wp_kses_post($args['desc']);
1065 1065
 }
1066 1066
 
1067
-function wpinv_raw_html_callback( $args ) {
1068
-	echo wp_kses_post( $args['desc'] );
1067
+function wpinv_raw_html_callback($args) {
1068
+	echo wp_kses_post($args['desc']);
1069 1069
 }
1070 1070
 
1071
-function wpinv_hook_callback( $args ) {
1072
-	do_action( 'wpinv_' . $args['id'], $args );
1071
+function wpinv_hook_callback($args) {
1072
+	do_action('wpinv_' . $args['id'], $args);
1073 1073
 }
1074 1074
 
1075 1075
 function wpinv_set_settings_cap() {
1076 1076
 	return wpinv_get_capability();
1077 1077
 }
1078
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1078
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1079 1079
 
1080 1080
 
1081
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1082
-    $old = ! empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1083
-    $new = ! empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1081
+function wpinv_on_update_settings($old_value, $value, $option) {
1082
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1083
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1084 1084
 
1085
-    if ( $old != $new ) {
1086
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1085
+    if ($old != $new) {
1086
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1087 1087
     }
1088 1088
 }
1089
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1089
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1090 1090
 
1091 1091
 /**
1092 1092
  * Returns the merge tags help text.
@@ -1095,16 +1095,16 @@  discard block
 block discarded – undo
1095 1095
  *
1096 1096
  * @return string
1097 1097
  */
1098
-function wpinv_get_merge_tags_help_text( $subscription = false ) {
1098
+function wpinv_get_merge_tags_help_text($subscription = false) {
1099 1099
 
1100 1100
 	$url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1101 1101
 	$link = sprintf(
1102 1102
 		'<strong><a href="%s" target="_blank">%s</a></strong>',
1103 1103
 		$url,
1104
-		esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1104
+		esc_html__('View available merge tags.', 'wpinv-quotes')
1105 1105
 	);
1106 1106
 
1107
-	$description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1107
+	$description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing');
1108 1108
 
1109 1109
 	return "$description $link";
1110 1110
 
Please login to merge, or discard this patch.
includes/admin/wpinv-admin-functions.php 1 patch
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -7,81 +7,81 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // MUST have WordPress.
10
-if ( ! defined( 'WPINC' ) ) {
10
+if (!defined('WPINC')) {
11 11
     exit;
12 12
 }
13 13
 
14
-function wpinv_bulk_actions( $actions ) {
15
-    if ( isset( $actions['edit'] ) ) {
16
-        unset( $actions['edit'] );
14
+function wpinv_bulk_actions($actions) {
15
+    if (isset($actions['edit'])) {
16
+        unset($actions['edit']);
17 17
     }
18 18
 
19 19
     return $actions;
20 20
 }
21
-add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' );
22
-add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' );
21
+add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions');
22
+add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions');
23 23
 
24
-function wpinv_admin_post_id( $id = 0 ) {
24
+function wpinv_admin_post_id($id = 0) {
25 25
     global $post;
26 26
 
27
-    if ( isset( $id ) && ! empty( $id ) ) {
28
-        return (int)$id;
29
-    } elseif ( get_the_ID() ) {
27
+    if (isset($id) && !empty($id)) {
28
+        return (int) $id;
29
+    } elseif (get_the_ID()) {
30 30
         return (int) get_the_ID();
31
-    } elseif ( isset( $post->ID ) && ! empty( $post->ID ) ) {
31
+    } elseif (isset($post->ID) && !empty($post->ID)) {
32 32
         return (int) $post->ID;
33
-    } elseif ( isset( $_GET['post'] ) && ! empty( $_GET['post'] ) ) {
33
+    } elseif (isset($_GET['post']) && !empty($_GET['post'])) {
34 34
         return (int) $_GET['post'];
35
-    } elseif ( isset( $_GET['id'] ) && ! empty( $_GET['id'] ) ) {
35
+    } elseif (isset($_GET['id']) && !empty($_GET['id'])) {
36 36
         return (int) $_GET['id'];
37
-    } elseif ( isset( $_POST['id'] ) && ! empty( $_POST['id'] ) ) {
37
+    } elseif (isset($_POST['id']) && !empty($_POST['id'])) {
38 38
         return (int) $_POST['id'];
39 39
     }
40 40
 
41 41
     return null;
42 42
 }
43 43
 
44
-function wpinv_admin_post_type( $id = 0 ) {
45
-    if ( ! $id ) {
44
+function wpinv_admin_post_type($id = 0) {
45
+    if (!$id) {
46 46
         $id = wpinv_admin_post_id();
47 47
     }
48 48
 
49
-    $type = get_post_type( $id );
49
+    $type = get_post_type($id);
50 50
 
51
-    if ( ! $type ) {
52
-        $type = isset( $_GET['post_type'] ) && ! empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : null;
51
+    if (!$type) {
52
+        $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : null;
53 53
     }
54 54
 
55
-    return apply_filters( 'wpinv_admin_post_type', $type, $id );
55
+    return apply_filters('wpinv_admin_post_type', $type, $id);
56 56
 }
57 57
 
58 58
 function wpinv_admin_messages() {
59
-	settings_errors( 'wpinv-notices' );
59
+	settings_errors('wpinv-notices');
60 60
 }
61
-add_action( 'admin_notices', 'wpinv_admin_messages' );
61
+add_action('admin_notices', 'wpinv_admin_messages');
62 62
 
63
-add_action( 'admin_init', 'wpinv_show_test_payment_gateway_notice' );
63
+add_action('admin_init', 'wpinv_show_test_payment_gateway_notice');
64 64
 function wpinv_show_test_payment_gateway_notice() {
65
-    add_action( 'admin_notices', 'wpinv_test_payment_gateway_messages' );
65
+    add_action('admin_notices', 'wpinv_test_payment_gateway_messages');
66 66
 }
67 67
 
68 68
 function wpinv_test_payment_gateway_messages() {
69 69
     $gateways = wpinv_get_enabled_payment_gateways();
70 70
     $name = array(); $test_gateways = '';
71
-    if ( $gateways ) {
72
-        foreach ( $gateways as $id => $gateway ) {
73
-            if ( wpinv_is_test_mode( $id ) ) {
71
+    if ($gateways) {
72
+        foreach ($gateways as $id => $gateway) {
73
+            if (wpinv_is_test_mode($id)) {
74 74
                 $name[] = $gateway['checkout_label'];
75 75
             }
76 76
         }
77
-        $test_gateways = implode( ', ', $name );
77
+        $test_gateways = implode(', ', $name);
78 78
     }
79
-    if ( isset( $test_gateways ) && ! empty( $test_gateways ) && wpinv_current_user_can_manage_invoicing() ) {
80
-        $link = admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
81
-        $notice = wp_sprintf( __( '<strong>Important:</strong> Payment Gateway(s) %1$s are in testing mode and will not receive real payments. Go to <a href="%2$s"> Gateway Settings</a>.', 'invoicing' ), $test_gateways, $link );
79
+    if (isset($test_gateways) && !empty($test_gateways) && wpinv_current_user_can_manage_invoicing()) {
80
+        $link = admin_url('admin.php?page=wpinv-settings&tab=gateways');
81
+        $notice = wp_sprintf(__('<strong>Important:</strong> Payment Gateway(s) %1$s are in testing mode and will not receive real payments. Go to <a href="%2$s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link);
82 82
         ?>
83 83
         <div class="notice notice-warning is-dismissible">
84
-            <p><?php echo wp_kses_post( $notice ); ?></p>
84
+            <p><?php echo wp_kses_post($notice); ?></p>
85 85
         </div>
86 86
         <?php
87 87
     }
@@ -95,37 +95,37 @@  discard block
 block discarded – undo
95 95
     global $wpdb;
96 96
 
97 97
     // Only do this on our settings page.
98
-    if ( empty( $_GET['page'] ) || 'wpinv-settings' !== $_GET['page'] ) {
98
+    if (empty($_GET['page']) || 'wpinv-settings' !== $_GET['page']) {
99 99
         return;
100 100
     }
101 101
 
102 102
     // Check tables.
103
-    $tables             = array(
103
+    $tables = array(
104 104
         "{$wpdb->prefix}wpinv_subscriptions",
105 105
         "{$wpdb->prefix}getpaid_invoices",
106 106
         "{$wpdb->prefix}getpaid_invoice_items",
107 107
     );
108 108
 
109
-    foreach ( $tables as $table ) {
110
-        if ( $table != $wpdb->get_var( "SHOW TABLES LIKE '$table'" ) ) {
109
+    foreach ($tables as $table) {
110
+        if ($table != $wpdb->get_var("SHOW TABLES LIKE '$table'")) {
111 111
 
112
-            $url     = wp_nonce_url(
113
-                add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
112
+            $url = wp_nonce_url(
113
+                add_query_arg('getpaid-admin-action', 'create_missing_tables'),
114 114
                 'getpaid-nonce',
115 115
                 'getpaid-nonce'
116 116
             );
117
-            $message  = __( 'Some GetPaid database tables are missing. To use GetPaid without any issues, click on the button below to create the missing tables.', 'invoicing' );
118
-            $message2 = __( 'Create Tables', 'invoicing' );
119
-            echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" );
117
+            $message  = __('Some GetPaid database tables are missing. To use GetPaid without any issues, click on the button below to create the missing tables.', 'invoicing');
118
+            $message2 = __('Create Tables', 'invoicing');
119
+            echo wp_kses_post("<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>");
120 120
             break;
121 121
 
122 122
         }
123 123
     }
124 124
 
125 125
 }
126
-add_action( 'admin_notices', 'wpinv_check_for_missing_tables' );
126
+add_action('admin_notices', 'wpinv_check_for_missing_tables');
127 127
 
128
-add_action( 'admin_init', 'wpinv_admin_search_by_invoice' );
128
+add_action('admin_init', 'wpinv_admin_search_by_invoice');
129 129
 
130 130
 /**
131 131
  * hook the posts search if we're on the admin page for our type
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 function wpinv_admin_search_by_invoice() {
134 134
     global $typenow;
135 135
 
136
-    if ( $typenow === 'wpi_invoice' || $typenow === 'wpi_quote' ) {
137
-        add_filter( 'posts_search', 'wpinv_posts_search_example_type', 10, 2 );
136
+    if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote') {
137
+        add_filter('posts_search', 'wpinv_posts_search_example_type', 10, 2);
138 138
     }
139 139
 }
140 140
 
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
  * @param WP_Query $query
145 145
  * @return string
146 146
  */
147
-function wpinv_posts_search_example_type( $search, $query ) {
147
+function wpinv_posts_search_example_type($search, $query) {
148 148
     global $wpdb;
149 149
 
150
-    if ( $query->is_main_query() && ! empty( $query->query['s'] ) ) {
151
-        $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql( $query->query['s'] ) . "%' )";
152
-        if ( ! empty( $search ) ) {
153
-            $search = preg_replace( '/^ AND /', '', $search );
150
+    if ($query->is_main_query() && !empty($query->query['s'])) {
151
+        $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql($query->query['s']) . "%' )";
152
+        if (!empty($search)) {
153
+            $search = preg_replace('/^ AND /', '', $search);
154 154
             $search = " AND ( {$search} OR ( {$conditions_str} ) )";
155 155
         } else {
156 156
             $search = " AND ( {$conditions_str} )";
@@ -164,16 +164,16 @@  discard block
 block discarded – undo
164 164
  * Resets invoice counts.
165 165
  */
166 166
 function wpinv_reset_invoice_count() {
167
-    if ( ! empty( $_GET['reset_invoice_count'] ) && isset( $_GET['_nonce'] ) && wp_verify_nonce( sanitize_text_field( $_GET['_nonce'] ), 'reset_invoice_count' ) ) {
168
-        wpinv_update_option( 'invoice_sequence_start', 1 );
169
-        delete_option( 'wpinv_last_invoice_number' );
170
-        getpaid_admin()->show_success( __( 'Invoice number sequence reset successfully.', 'invoicing' ) );
171
-        $url = remove_query_arg( array( 'reset_invoice_count', '_nonce' ) );
172
-        wp_redirect( $url );
167
+    if (!empty($_GET['reset_invoice_count']) && isset($_GET['_nonce']) && wp_verify_nonce(sanitize_text_field($_GET['_nonce']), 'reset_invoice_count')) {
168
+        wpinv_update_option('invoice_sequence_start', 1);
169
+        delete_option('wpinv_last_invoice_number');
170
+        getpaid_admin()->show_success(__('Invoice number sequence reset successfully.', 'invoicing'));
171
+        $url = remove_query_arg(array('reset_invoice_count', '_nonce'));
172
+        wp_redirect($url);
173 173
         exit();
174 174
     }
175 175
 }
176
-add_action( 'admin_init', 'wpinv_reset_invoice_count' );
176
+add_action('admin_init', 'wpinv_reset_invoice_count');
177 177
 
178 178
 /**
179 179
  * Displays line items on the invoice edit page.
@@ -182,29 +182,29 @@  discard block
 block discarded – undo
182 182
  * @param array $columns
183 183
  * @return string
184 184
  */
185
-function wpinv_admin_get_line_items( $invoice, $columns ) {
185
+function wpinv_admin_get_line_items($invoice, $columns) {
186 186
 
187 187
     ob_start();
188 188
 
189
-    do_action( 'getpaid_admin_before_line_items', $invoice );
189
+    do_action('getpaid_admin_before_line_items', $invoice);
190 190
 
191 191
     $count = 0;
192
-    foreach ( $invoice->get_items() as $item ) {
192
+    foreach ($invoice->get_items() as $item) {
193 193
 
194
-        $item_price     = wpinv_price( $item->get_price(), $invoice->get_currency() );
194
+        $item_price     = wpinv_price($item->get_price(), $invoice->get_currency());
195 195
         $quantity       = (int) $item->get_quantity();
196
-        $item_subtotal  = wpinv_price( $item->get_sub_total(), $invoice->get_currency() );
197
-        $summary        = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice );
196
+        $item_subtotal  = wpinv_price($item->get_sub_total(), $invoice->get_currency());
197
+        $summary        = apply_filters('getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice);
198 198
         $item_tax       = $item->item_tax;
199
-        $tax_rate       = wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2, true ) . '%';
200
-        $tax_rate       = empty( $tax_rate ) ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : '';
199
+        $tax_rate       = wpinv_round_amount(getpaid_get_invoice_tax_rate($invoice, $item), 2, true) . '%';
200
+        $tax_rate       = empty($tax_rate) ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : '';
201 201
         $line_item_tax  = $item_tax . $tax_rate;
202
-        $line_item      = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . esc_attr( $item->get_id() ) . '">';
202
+        $line_item      = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . esc_attr($item->get_id()) . '">';
203 203
         $line_item     .= '<td class="id">' . (int) $item->get_id() . '</td>';
204
-        $line_item     .= '<td class="title"><a href="' . get_edit_post_link( $item->get_id() ) . '" target="_blank">' . $item->get_name() . '</a>';
204
+        $line_item     .= '<td class="title"><a href="' . get_edit_post_link($item->get_id()) . '" target="_blank">' . $item->get_name() . '</a>';
205 205
 
206
-        if ( $summary !== '' ) {
207
-            $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>';
206
+        if ($summary !== '') {
207
+            $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>';
208 208
         }
209 209
 
210 210
         $line_item .= '</td>';
@@ -212,23 +212,23 @@  discard block
 block discarded – undo
212 212
         $line_item .= '<td class="qty" data-quantity="' . $quantity . '">&nbsp;&times;&nbsp;' . $quantity . '</td>';
213 213
         $line_item .= '<td class="total">' . $item_subtotal . '</td>';
214 214
 
215
-        if ( wpinv_use_taxes() && $invoice->is_taxable() ) {
215
+        if (wpinv_use_taxes() && $invoice->is_taxable()) {
216 216
             $line_item .= '<td class="tax">' . $line_item_tax . '</td>';
217 217
         }
218 218
 
219 219
         $line_item .= '<td class="action">';
220
-        if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
220
+        if (!$invoice->is_paid() && !$invoice->is_refunded()) {
221 221
             $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>';
222 222
         }
223 223
         $line_item .= '</td>';
224 224
         $line_item .= '</tr>';
225 225
 
226
-        echo wp_kses_post( apply_filters( 'getpaid_admin_line_item', $line_item, $item, $invoice ) );
226
+        echo wp_kses_post(apply_filters('getpaid_admin_line_item', $line_item, $item, $invoice));
227 227
 
228 228
         $count++;
229 229
     }
230 230
 
231
-    do_action( 'getpaid_admin_after_line_items', $invoice );
231
+    do_action('getpaid_admin_after_line_items', $invoice);
232 232
 
233 233
     return ob_get_clean();
234 234
 }
Please login to merge, or discard this patch.
includes/wpinv-helper-functions.php 1 patch
Spacing   +288 added lines, -288 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
  * Are we supporting item quantities?
@@ -20,35 +20,35 @@  discard block
 block discarded – undo
20 20
  */
21 21
 function wpinv_get_ip() {
22 22
 
23
-    if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) {
24
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) );
23
+    if (isset($_SERVER['HTTP_X_REAL_IP'])) {
24
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_X_REAL_IP']));
25 25
     }
26 26
 
27
-    if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
27
+    if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
28 28
         // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2
29 29
         // Make sure we always only send through the first IP in the list which should always be the client IP.
30
-        return (string) rest_is_ip_address( trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) );
30
+        return (string) rest_is_ip_address(trim(current(preg_split('/,/', sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR']))))));
31 31
     }
32 32
 
33
-    if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) {
34
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) );
33
+    if (isset($_SERVER['HTTP_CLIENT_IP'])) {
34
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_CLIENT_IP']));
35 35
     }
36 36
 
37
-    if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
38
-        return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
37
+    if (isset($_SERVER['REMOTE_ADDR'])) {
38
+        return sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR']));
39 39
     }
40 40
 
41 41
     return '';
42 42
 }
43 43
 
44 44
 function wpinv_get_user_agent() {
45
-    if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
46
-        $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] );
45
+    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
46
+        $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']);
47 47
     } else {
48 48
         $user_agent = '';
49 49
     }
50 50
 
51
-    return apply_filters( 'wpinv_get_user_agent', $user_agent );
51
+    return apply_filters('wpinv_get_user_agent', $user_agent);
52 52
 }
53 53
 
54 54
 /**
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
  * @param string $amount The amount to sanitize.
58 58
  * @return float
59 59
  */
60
-function getpaid_standardize_amount( $amount ) {
60
+function getpaid_standardize_amount($amount) {
61 61
 
62
-    $amount = str_replace( wpinv_thousands_separator(), '', $amount );
63
-    $amount = str_replace( wpinv_decimal_separator(), '.', $amount );
64
-    if ( is_numeric( $amount ) ) {
65
-        return floatval( $amount );
62
+    $amount = str_replace(wpinv_thousands_separator(), '', $amount);
63
+    $amount = str_replace(wpinv_decimal_separator(), '.', $amount);
64
+    if (is_numeric($amount)) {
65
+        return floatval($amount);
66 66
     }
67 67
 
68 68
     // Cast the remaining to a float.
69
-    return wpinv_round_amount( preg_replace( '/[^0-9\.\-]/', '', $amount ) );
69
+    return wpinv_round_amount(preg_replace('/[^0-9\.\-]/', '', $amount));
70 70
 
71 71
 }
72 72
 
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
  *
76 76
  * @param string $amount The amount to sanitize.
77 77
  */
78
-function getpaid_unstandardize_amount( $amount ) {
79
-    return str_replace( '.', wpinv_decimal_separator(), $amount );
78
+function getpaid_unstandardize_amount($amount) {
79
+    return str_replace('.', wpinv_decimal_separator(), $amount);
80 80
 }
81 81
 
82 82
 /**
@@ -84,23 +84,23 @@  discard block
 block discarded – undo
84 84
  *
85 85
  * @param string $amount The amount to sanitize.
86 86
  */
87
-function wpinv_sanitize_amount( $amount ) {
87
+function wpinv_sanitize_amount($amount) {
88 88
 
89
-    if ( is_numeric( $amount ) ) {
90
-        return floatval( $amount );
89
+    if (is_numeric($amount)) {
90
+        return floatval($amount);
91 91
     }
92 92
 
93 93
     // Separate the decimals and thousands.
94
-    $amount    = explode( wpinv_decimal_separator(), $amount );
94
+    $amount    = explode(wpinv_decimal_separator(), $amount);
95 95
 
96 96
     // Remove thousands.
97
-    $amount[0] = str_replace( wpinv_thousands_separator(), '', $amount[0] );
97
+    $amount[0] = str_replace(wpinv_thousands_separator(), '', $amount[0]);
98 98
 
99 99
     // Convert back to string.
100
-    $amount = count( $amount ) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0];
100
+    $amount = count($amount) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0];
101 101
 
102 102
     // Cast the remaining to a float.
103
-    return (float) preg_replace( '/[^0-9\.\-]/', '', $amount );
103
+    return (float) preg_replace('/[^0-9\.\-]/', '', $amount);
104 104
 
105 105
 }
106 106
 
@@ -110,19 +110,19 @@  discard block
 block discarded – undo
110 110
  * @param float $amount
111 111
  * @param float|string|int|null $decimals
112 112
  */
113
-function wpinv_round_amount( $amount, $decimals = null, $use_sprintf = false ) {
113
+function wpinv_round_amount($amount, $decimals = null, $use_sprintf = false) {
114 114
 
115
-    if ( $decimals === null ) {
115
+    if ($decimals === null) {
116 116
         $decimals = wpinv_decimals();
117 117
     }
118 118
 
119
-    if ( $use_sprintf ) {
120
-        $amount = sprintf( "%.{$decimals}f", (float) $amount );
119
+    if ($use_sprintf) {
120
+        $amount = sprintf("%.{$decimals}f", (float) $amount);
121 121
     } else {
122
-        $amount = round( (float) $amount, absint( $decimals ) );
122
+        $amount = round((float) $amount, absint($decimals));
123 123
     }
124 124
 
125
-    return apply_filters( 'wpinv_round_amount', $amount, $decimals );
125
+    return apply_filters('wpinv_round_amount', $amount, $decimals);
126 126
 }
127 127
 
128 128
 /**
@@ -134,32 +134,32 @@  discard block
 block discarded – undo
134 134
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
135 135
  * @return array
136 136
  */
137
-function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
137
+function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) {
138 138
 
139 139
 	$invoice_statuses = array(
140
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
141
-        'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
142
-        'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
143
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
144
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
145
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
146
-        'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
147
-        'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
140
+		'wpi-pending'    => _x('Pending payment', 'Invoice status', 'invoicing'),
141
+        'publish'        => _x('Paid', 'Invoice status', 'invoicing'),
142
+        'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'),
143
+		'wpi-onhold'     => _x('On hold', 'Invoice status', 'invoicing'),
144
+		'wpi-cancelled'  => _x('Cancelled', 'Invoice status', 'invoicing'),
145
+		'wpi-refunded'   => _x('Refunded', 'Invoice status', 'invoicing'),
146
+        'wpi-failed'     => _x('Failed', 'Invoice status', 'invoicing'),
147
+        'wpi-renewal'    => _x('Renewal Payment', 'Invoice status', 'invoicing'),
148 148
     );
149 149
 
150
-    if ( $draft ) {
151
-        $invoice_statuses['draft'] = __( 'Draft', 'invoicing' );
150
+    if ($draft) {
151
+        $invoice_statuses['draft'] = __('Draft', 'invoicing');
152 152
     }
153 153
 
154
-    if ( $trashed ) {
155
-        $invoice_statuses['trash'] = __( 'Trash', 'invoicing' );
154
+    if ($trashed) {
155
+        $invoice_statuses['trash'] = __('Trash', 'invoicing');
156 156
     }
157 157
 
158
-    if ( $invoice instanceof WPInv_Invoice ) {
158
+    if ($invoice instanceof WPInv_Invoice) {
159 159
         $invoice = $invoice->get_post_type();
160 160
     }
161 161
 
162
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
162
+	return apply_filters('wpinv_statuses', $invoice_statuses, $invoice);
163 163
 }
164 164
 
165 165
 /**
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
  * @param string $status The raw status
169 169
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
170 170
  */
171
-function wpinv_status_nicename( $status, $invoice = false ) {
172
-    $statuses = wpinv_get_invoice_statuses( true, true, $invoice );
173
-    $status   = isset( $statuses[ $status ] ) ? $statuses[ $status ] : $status;
171
+function wpinv_status_nicename($status, $invoice = false) {
172
+    $statuses = wpinv_get_invoice_statuses(true, true, $invoice);
173
+    $status   = isset($statuses[$status]) ? $statuses[$status] : $status;
174 174
 
175
-    return sanitize_text_field( $status );
175
+    return sanitize_text_field($status);
176 176
 }
177 177
 
178 178
 /**
@@ -180,13 +180,13 @@  discard block
 block discarded – undo
180 180
  *
181 181
  * @param string $current
182 182
  */
183
-function wpinv_get_currency( $current = '' ) {
183
+function wpinv_get_currency($current = '') {
184 184
 
185
-    if ( empty( $current ) ) {
186
-        $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) );
185
+    if (empty($current)) {
186
+        $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD'));
187 187
     }
188 188
 
189
-    return trim( strtoupper( $current ) );
189
+    return trim(strtoupper($current));
190 190
 }
191 191
 
192 192
 /**
@@ -194,25 +194,25 @@  discard block
 block discarded – undo
194 194
  *
195 195
  * @param string|null $currency The currency code. Defaults to the default currency.
196 196
  */
197
-function wpinv_currency_symbol( $currency = null ) {
197
+function wpinv_currency_symbol($currency = null) {
198 198
 
199 199
     // Prepare the currency.
200
-    $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency );
200
+    $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency);
201 201
 
202 202
     // Fetch all symbols.
203 203
     $symbols = wpinv_get_currency_symbols();
204 204
 
205 205
     // Fetch this currencies symbol.
206
-    $currency_symbol = isset( $symbols[ $currency ] ) ? $symbols[ $currency ] : $currency;
206
+    $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency;
207 207
 
208 208
     // Filter the symbol.
209
-    return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency );
209
+    return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency);
210 210
 }
211 211
 
212 212
 function wpinv_currency_position() {
213
-    $position = wpinv_get_option( 'currency_position', 'left' );
213
+    $position = wpinv_get_option('currency_position', 'left');
214 214
 
215
-    return apply_filters( 'wpinv_currency_position', $position );
215
+    return apply_filters('wpinv_currency_position', $position);
216 216
 }
217 217
 
218 218
 /**
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
  *
221 221
  * @param $string|null $current
222 222
  */
223
-function wpinv_thousands_separator( $current = null ) {
223
+function wpinv_thousands_separator($current = null) {
224 224
 
225
-    if ( null == $current ) {
226
-        $current = wpinv_get_option( 'thousands_separator', ',' );
225
+    if (null == $current) {
226
+        $current = wpinv_get_option('thousands_separator', ',');
227 227
     }
228 228
 
229
-    return trim( $current );
229
+    return trim($current);
230 230
 }
231 231
 
232 232
 /**
@@ -234,13 +234,13 @@  discard block
 block discarded – undo
234 234
  *
235 235
  * @param $string|null $current
236 236
  */
237
-function wpinv_decimal_separator( $current = null ) {
237
+function wpinv_decimal_separator($current = null) {
238 238
 
239
-    if ( null == $current ) {
240
-        $current = wpinv_get_option( 'decimal_separator', '.' );
239
+    if (null == $current) {
240
+        $current = wpinv_get_option('decimal_separator', '.');
241 241
     }
242 242
 
243
-    return trim( $current );
243
+    return trim($current);
244 244
 }
245 245
 
246 246
 /**
@@ -248,27 +248,27 @@  discard block
 block discarded – undo
248 248
  *
249 249
  * @param $string|null $current
250 250
  */
251
-function wpinv_decimals( $current = null ) {
251
+function wpinv_decimals($current = null) {
252 252
 
253
-    if ( null == $current ) {
254
-        $current = wpinv_get_option( 'decimals', 2 );
253
+    if (null == $current) {
254
+        $current = wpinv_get_option('decimals', 2);
255 255
     }
256 256
 
257
-    return absint( $current );
257
+    return absint($current);
258 258
 }
259 259
 
260 260
 /**
261 261
  * Retrieves a list of all supported currencies.
262 262
  */
263 263
 function wpinv_get_currencies() {
264
-    return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) );
264
+    return apply_filters('wpinv_currencies', wpinv_get_data('currencies'));
265 265
 }
266 266
 
267 267
 /**
268 268
  * Retrieves a list of all currency symbols.
269 269
  */
270 270
 function wpinv_get_currency_symbols() {
271
-    return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) );
271
+    return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols'));
272 272
 }
273 273
 
274 274
 /**
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	$currency_pos = wpinv_currency_position();
281 281
 	$format       = '%1$s%2$s';
282 282
 
283
-	switch ( $currency_pos ) {
283
+	switch ($currency_pos) {
284 284
 		case 'left':
285 285
 			$format = '%1$s%2$s';
286 286
 			break;
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 			break;
296 296
 	}
297 297
 
298
-	return apply_filters( 'getpaid_price_format', $format, $currency_pos );
298
+	return apply_filters('getpaid_price_format', $format, $currency_pos);
299 299
 }
300 300
 
301 301
 /**
@@ -305,25 +305,25 @@  discard block
 block discarded – undo
305 305
  * @param  string $currency Currency.
306 306
  * @return string
307 307
  */
308
-function wpinv_price( $amount = 0, $currency = '' ) {
308
+function wpinv_price($amount = 0, $currency = '') {
309 309
 
310 310
     // Backwards compatibility.
311
-    $amount             = wpinv_sanitize_amount( $amount );
311
+    $amount             = wpinv_sanitize_amount($amount);
312 312
 
313 313
     // Prepare variables.
314
-    $currency           = wpinv_get_currency( $currency );
314
+    $currency           = wpinv_get_currency($currency);
315 315
     $amount             = (float) $amount;
316 316
     $unformatted_amount = $amount;
317 317
     $negative           = $amount < 0;
318
-    $amount             = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) );
319
-    $amount             = wpinv_format_amount( $amount );
318
+    $amount             = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount));
319
+    $amount             = wpinv_format_amount($amount);
320 320
 
321 321
     // Format the amount.
322 322
     $format             = getpaid_get_price_format();
323
-    $formatted_amount   = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount );
323
+    $formatted_amount   = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount);
324 324
 
325 325
     // Filter the formatting.
326
-    return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount );
326
+    return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount);
327 327
 }
328 328
 
329 329
 /**
@@ -334,25 +334,25 @@  discard block
 block discarded – undo
334 334
  * @param  bool     $calculate Whether or not to apply separators.
335 335
  * @return string
336 336
  */
337
-function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) {
337
+function wpinv_format_amount($amount, $decimals = null, $calculate = false) {
338 338
     $thousands_sep = wpinv_thousands_separator();
339 339
     $decimal_sep   = wpinv_decimal_separator();
340
-    $decimals      = wpinv_decimals( $decimals );
341
-    $amount        = wpinv_sanitize_amount( $amount );
340
+    $decimals      = wpinv_decimals($decimals);
341
+    $amount        = wpinv_sanitize_amount($amount);
342 342
 
343
-    if ( $calculate ) {
343
+    if ($calculate) {
344 344
         return $amount;
345 345
     }
346 346
 
347 347
     // Fomart the amount.
348
-    return number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
348
+    return number_format($amount, $decimals, $decimal_sep, $thousands_sep);
349 349
 }
350 350
 
351
-function wpinv_sanitize_key( $key ) {
351
+function wpinv_sanitize_key($key) {
352 352
     $raw_key = $key;
353
-    $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
353
+    $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key);
354 354
 
355
-    return apply_filters( 'wpinv_sanitize_key', $key, $raw_key );
355
+    return apply_filters('wpinv_sanitize_key', $key, $raw_key);
356 356
 }
357 357
 
358 358
 /**
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
  *
361 361
  * @param $str the file whose extension should be retrieved.
362 362
  */
363
-function wpinv_get_file_extension( $str ) {
364
-    $filetype = wp_check_filetype( $str );
363
+function wpinv_get_file_extension($str) {
364
+    $filetype = wp_check_filetype($str);
365 365
     return $filetype['ext'];
366 366
 }
367 367
 
@@ -370,16 +370,16 @@  discard block
 block discarded – undo
370 370
  *
371 371
  * @param string $string
372 372
  */
373
-function wpinv_string_is_image_url( $string ) {
374
-    $extension = strtolower( wpinv_get_file_extension( $string ) );
375
-    return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true );
373
+function wpinv_string_is_image_url($string) {
374
+    $extension = strtolower(wpinv_get_file_extension($string));
375
+    return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true);
376 376
 }
377 377
 
378 378
 /**
379 379
  * Returns the current URL.
380 380
  */
381 381
 function wpinv_get_current_page_url() {
382
-    return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
382
+    return (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
383 383
 }
384 384
 
385 385
 /**
@@ -389,46 +389,46 @@  discard block
 block discarded – undo
389 389
  * @param string $name  Constant name.
390 390
  * @param mixed  $value Value.
391 391
  */
392
-function getpaid_maybe_define_constant( $name, $value ) {
393
-	if ( ! defined( $name ) ) {
394
-		define( $name, $value );
392
+function getpaid_maybe_define_constant($name, $value) {
393
+	if (!defined($name)) {
394
+		define($name, $value);
395 395
 	}
396 396
 }
397 397
 
398 398
 function wpinv_get_php_arg_separator_output() {
399
-	return ini_get( 'arg_separator.output' );
399
+	return ini_get('arg_separator.output');
400 400
 }
401 401
 
402
-function wpinv_rgb_from_hex( $color ) {
403
-    $color = str_replace( '#', '', $color );
402
+function wpinv_rgb_from_hex($color) {
403
+    $color = str_replace('#', '', $color);
404 404
 
405 405
     // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF"
406
-    $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color );
407
-    if ( empty( $color ) ) {
406
+    $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color);
407
+    if (empty($color)) {
408 408
         return null;
409 409
     }
410 410
 
411
-    $color = str_split( $color );
411
+    $color = str_split($color);
412 412
 
413 413
     $rgb      = array();
414
-    $rgb['R'] = hexdec( $color[0] . $color[1] );
415
-    $rgb['G'] = hexdec( $color[2] . $color[3] );
416
-    $rgb['B'] = hexdec( $color[4] . $color[5] );
414
+    $rgb['R'] = hexdec($color[0] . $color[1]);
415
+    $rgb['G'] = hexdec($color[2] . $color[3]);
416
+    $rgb['B'] = hexdec($color[4] . $color[5]);
417 417
 
418 418
     return $rgb;
419 419
 }
420 420
 
421
-function wpinv_hex_darker( $color, $factor = 30 ) {
422
-    $base  = wpinv_rgb_from_hex( $color );
421
+function wpinv_hex_darker($color, $factor = 30) {
422
+    $base  = wpinv_rgb_from_hex($color);
423 423
     $color = '#';
424 424
 
425
-    foreach ( $base as $k => $v ) {
425
+    foreach ($base as $k => $v) {
426 426
         $amount      = $v / 100;
427
-        $amount      = round( $amount * $factor );
427
+        $amount      = round($amount * $factor);
428 428
         $new_decimal = $v - $amount;
429 429
 
430
-        $new_hex_component = dechex( $new_decimal );
431
-        if ( strlen( $new_hex_component ) < 2 ) {
430
+        $new_hex_component = dechex($new_decimal);
431
+        if (strlen($new_hex_component) < 2) {
432 432
             $new_hex_component = '0' . $new_hex_component;
433 433
         }
434 434
         $color .= $new_hex_component;
@@ -437,18 +437,18 @@  discard block
 block discarded – undo
437 437
     return $color;
438 438
 }
439 439
 
440
-function wpinv_hex_lighter( $color, $factor = 30 ) {
441
-    $base  = wpinv_rgb_from_hex( $color );
440
+function wpinv_hex_lighter($color, $factor = 30) {
441
+    $base  = wpinv_rgb_from_hex($color);
442 442
     $color = '#';
443 443
 
444
-    foreach ( $base as $k => $v ) {
444
+    foreach ($base as $k => $v) {
445 445
         $amount      = 255 - $v;
446 446
         $amount      = $amount / 100;
447
-        $amount      = round( $amount * $factor );
447
+        $amount      = round($amount * $factor);
448 448
         $new_decimal = $v + $amount;
449 449
 
450
-        $new_hex_component = dechex( $new_decimal );
451
-        if ( strlen( $new_hex_component ) < 2 ) {
450
+        $new_hex_component = dechex($new_decimal);
451
+        if (strlen($new_hex_component) < 2) {
452 452
             $new_hex_component = '0' . $new_hex_component;
453 453
         }
454 454
         $color .= $new_hex_component;
@@ -457,22 +457,22 @@  discard block
 block discarded – undo
457 457
     return $color;
458 458
 }
459 459
 
460
-function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
461
-    $hex = str_replace( '#', '', $color );
460
+function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') {
461
+    $hex = str_replace('#', '', $color);
462 462
 
463
-    $c_r = hexdec( substr( $hex, 0, 2 ) );
464
-    $c_g = hexdec( substr( $hex, 2, 2 ) );
465
-    $c_b = hexdec( substr( $hex, 4, 2 ) );
463
+    $c_r = hexdec(substr($hex, 0, 2));
464
+    $c_g = hexdec(substr($hex, 2, 2));
465
+    $c_b = hexdec(substr($hex, 4, 2));
466 466
 
467
-    $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
467
+    $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000;
468 468
 
469 469
     return $brightness > 155 ? $dark : $light;
470 470
 }
471 471
 
472
-function wpinv_format_hex( $hex ) {
473
-    $hex = trim( str_replace( '#', '', $hex ) );
472
+function wpinv_format_hex($hex) {
473
+    $hex = trim(str_replace('#', '', $hex));
474 474
 
475
-    if ( strlen( $hex ) == 3 ) {
475
+    if (strlen($hex) == 3) {
476 476
         $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
477 477
     }
478 478
 
@@ -492,12 +492,12 @@  discard block
 block discarded – undo
492 492
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
493 493
  * @return string
494 494
  */
495
-function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
496
-    if ( function_exists( 'mb_strimwidth' ) ) {
497
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
495
+function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') {
496
+    if (function_exists('mb_strimwidth')) {
497
+        return mb_strimwidth($str, $start, $width, $trimmaker, $encoding);
498 498
     }
499 499
 
500
-    return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
500
+    return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker;
501 501
 }
502 502
 
503 503
 /**
@@ -509,28 +509,28 @@  discard block
 block discarded – undo
509 509
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
510 510
  * @return int Returns the number of characters in string.
511 511
  */
512
-function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) {
513
-    if ( function_exists( 'mb_strlen' ) ) {
514
-        return mb_strlen( $str, $encoding );
512
+function wpinv_utf8_strlen($str, $encoding = 'UTF-8') {
513
+    if (function_exists('mb_strlen')) {
514
+        return mb_strlen($str, $encoding);
515 515
     }
516 516
 
517
-    return strlen( $str );
517
+    return strlen($str);
518 518
 }
519 519
 
520
-function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) {
521
-    if ( function_exists( 'mb_strtolower' ) ) {
522
-        return mb_strtolower( $str, $encoding );
520
+function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') {
521
+    if (function_exists('mb_strtolower')) {
522
+        return mb_strtolower($str, $encoding);
523 523
     }
524 524
 
525
-    return strtolower( $str );
525
+    return strtolower($str);
526 526
 }
527 527
 
528
-function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) {
529
-    if ( function_exists( 'mb_strtoupper' ) ) {
530
-        return mb_strtoupper( $str, $encoding );
528
+function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') {
529
+    if (function_exists('mb_strtoupper')) {
530
+        return mb_strtoupper($str, $encoding);
531 531
     }
532 532
 
533
-    return strtoupper( $str );
533
+    return strtoupper($str);
534 534
 }
535 535
 
536 536
 /**
@@ -544,12 +544,12 @@  discard block
 block discarded – undo
544 544
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
545 545
  * @return int Returns the position of the first occurrence of search in the string.
546 546
  */
547
-function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
548
-    if ( function_exists( 'mb_strpos' ) ) {
549
-        return mb_strpos( $str, $find, $offset, $encoding );
547
+function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
548
+    if (function_exists('mb_strpos')) {
549
+        return mb_strpos($str, $find, $offset, $encoding);
550 550
     }
551 551
 
552
-    return strpos( $str, $find, $offset );
552
+    return strpos($str, $find, $offset);
553 553
 }
554 554
 
555 555
 /**
@@ -563,12 +563,12 @@  discard block
 block discarded – undo
563 563
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
564 564
  * @return int Returns the position of the last occurrence of search.
565 565
  */
566
-function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
567
-    if ( function_exists( 'mb_strrpos' ) ) {
568
-        return mb_strrpos( $str, $find, $offset, $encoding );
566
+function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
567
+    if (function_exists('mb_strrpos')) {
568
+        return mb_strrpos($str, $find, $offset, $encoding);
569 569
     }
570 570
 
571
-    return strrpos( $str, $find, $offset );
571
+    return strrpos($str, $find, $offset);
572 572
 }
573 573
 
574 574
 /**
@@ -583,16 +583,16 @@  discard block
 block discarded – undo
583 583
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
584 584
  * @return string
585 585
  */
586
-function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
587
-    if ( function_exists( 'mb_substr' ) ) {
588
-        if ( $length === null ) {
589
-            return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding );
586
+function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') {
587
+    if (function_exists('mb_substr')) {
588
+        if ($length === null) {
589
+            return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding);
590 590
         } else {
591
-            return mb_substr( $str, $start, $length, $encoding );
591
+            return mb_substr($str, $start, $length, $encoding);
592 592
         }
593 593
     }
594 594
 
595
-    return substr( $str, $start, $length );
595
+    return substr($str, $start, $length);
596 596
 }
597 597
 
598 598
 /**
@@ -604,48 +604,48 @@  discard block
 block discarded – undo
604 604
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
605 605
  * @return string The width of string.
606 606
  */
607
-function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
608
-    if ( function_exists( 'mb_strwidth' ) ) {
609
-        return mb_strwidth( $str, $encoding );
607
+function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') {
608
+    if (function_exists('mb_strwidth')) {
609
+        return mb_strwidth($str, $encoding);
610 610
     }
611 611
 
612
-    return wpinv_utf8_strlen( $str, $encoding );
612
+    return wpinv_utf8_strlen($str, $encoding);
613 613
 }
614 614
 
615
-function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) {
616
-    if ( function_exists( 'mb_strlen' ) ) {
617
-        $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding );
615
+function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') {
616
+    if (function_exists('mb_strlen')) {
617
+        $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding);
618 618
         $str_end = '';
619 619
 
620
-        if ( $lower_str_end ) {
621
-            $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding );
620
+        if ($lower_str_end) {
621
+            $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding);
622 622
         } else {
623
-            $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding );
623
+            $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding);
624 624
         }
625 625
 
626 626
         return $first_letter . $str_end;
627 627
     }
628 628
 
629
-    return ucfirst( $str );
629
+    return ucfirst($str);
630 630
 }
631 631
 
632
-function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) {
633
-    if ( function_exists( 'mb_convert_case' ) ) {
634
-        return mb_convert_case( $str, MB_CASE_TITLE, $encoding );
632
+function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') {
633
+    if (function_exists('mb_convert_case')) {
634
+        return mb_convert_case($str, MB_CASE_TITLE, $encoding);
635 635
     }
636 636
 
637
-    return ucwords( $str );
637
+    return ucwords($str);
638 638
 }
639 639
 
640
-function wpinv_period_in_days( $period, $unit ) {
641
-    $period = absint( $period );
640
+function wpinv_period_in_days($period, $unit) {
641
+    $period = absint($period);
642 642
 
643
-    if ( $period > 0 ) {
644
-        if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) {
643
+    if ($period > 0) {
644
+        if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) {
645 645
             $period = $period * 7;
646
-        } elseif ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) {
646
+        } elseif (in_array(strtolower($unit), array('m', 'month', 'months'))) {
647 647
             $period = $period * 30;
648
-        } elseif ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) {
648
+        } elseif (in_array(strtolower($unit), array('y', 'year', 'years'))) {
649 649
             $period = $period * 365;
650 650
         }
651 651
     }
@@ -653,14 +653,14 @@  discard block
 block discarded – undo
653 653
     return $period;
654 654
 }
655 655
 
656
-function wpinv_cal_days_in_month( $calendar, $month, $year ) {
657
-    if ( function_exists( 'cal_days_in_month' ) ) {
658
-        return cal_days_in_month( $calendar, $month, $year );
656
+function wpinv_cal_days_in_month($calendar, $month, $year) {
657
+    if (function_exists('cal_days_in_month')) {
658
+        return cal_days_in_month($calendar, $month, $year);
659 659
     }
660 660
 
661 661
     // Fallback in case the calendar extension is not loaded in PHP
662 662
     // Only supports Gregorian calendar
663
-    return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
663
+    return date('t', mktime(0, 0, 0, $month, 1, $year));
664 664
 }
665 665
 
666 666
 /**
@@ -671,28 +671,28 @@  discard block
 block discarded – undo
671 671
  *
672 672
  * @return string
673 673
  */
674
-function wpi_help_tip( $tip, $allow_html = false, $is_vue = false, $echo = false ) {
674
+function wpi_help_tip($tip, $allow_html = false, $is_vue = false, $echo = false) {
675 675
 
676
-    if ( $allow_html ) {
677
-        $tip = wpi_sanitize_tooltip( $tip );
676
+    if ($allow_html) {
677
+        $tip = wpi_sanitize_tooltip($tip);
678 678
     } else {
679
-        $tip = strip_tags( $tip );
679
+        $tip = strip_tags($tip);
680 680
     }
681 681
 
682
-    if ( $is_vue ) {
682
+    if ($is_vue) {
683 683
 
684
-        if ( $echo ) {
685
-            echo '<span class="dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>';
684
+        if ($echo) {
685
+            echo '<span class="dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>';
686 686
         } else {
687
-            return '<span class="dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>';
687
+            return '<span class="dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>';
688 688
         }
689 689
 
690 690
     }
691 691
 
692
-    if ( $echo ) {
693
-        echo '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>';
692
+    if ($echo) {
693
+        echo '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>';
694 694
     } else {
695
-        return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>';
695
+        return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>';
696 696
     }
697 697
 }
698 698
 
@@ -704,9 +704,9 @@  discard block
 block discarded – undo
704 704
  * @param string $var
705 705
  * @return string
706 706
  */
707
-function wpi_sanitize_tooltip( $var ) {
707
+function wpi_sanitize_tooltip($var) {
708 708
     return wp_kses(
709
-        html_entity_decode( $var ),
709
+        html_entity_decode($var),
710 710
         array(
711 711
 			'br'     => array(),
712 712
 			'em'     => array(),
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
  */
730 730
 function wpinv_get_screen_ids() {
731 731
 
732
-    $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) );
732
+    $screen_id = sanitize_title(__('Invoicing', 'invoicing'));
733 733
 
734 734
     $screen_ids = array(
735 735
         'toplevel_page_' . $screen_id,
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
         'gp-setup', // setup wizard
752 752
     );
753 753
 
754
-    return apply_filters( 'wpinv_screen_ids', $screen_ids );
754
+    return apply_filters('wpinv_screen_ids', $screen_ids);
755 755
 }
756 756
 
757 757
 /**
@@ -762,14 +762,14 @@  discard block
 block discarded – undo
762 762
  * @param array|string $list List of values.
763 763
  * @return array Sanitized array of values.
764 764
  */
765
-function wpinv_parse_list( $list ) {
765
+function wpinv_parse_list($list) {
766 766
 
767
-    if ( empty( $list ) ) {
767
+    if (empty($list)) {
768 768
         $list = array();
769 769
     }
770 770
 
771
-	if ( ! is_array( $list ) ) {
772
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
771
+	if (!is_array($list)) {
772
+		return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY);
773 773
 	}
774 774
 
775 775
 	return $list;
@@ -783,16 +783,16 @@  discard block
 block discarded – undo
783 783
  * @param string $key Type of data to fetch.
784 784
  * @return mixed Fetched data.
785 785
  */
786
-function wpinv_get_data( $key ) {
786
+function wpinv_get_data($key) {
787 787
 
788 788
     // Try fetching it from the cache.
789
-    $data = wp_cache_get( "wpinv-data-$key", 'wpinv' );
790
-    if ( $data ) {
789
+    $data = wp_cache_get("wpinv-data-$key", 'wpinv');
790
+    if ($data) {
791 791
         return $data;
792 792
     }
793 793
 
794
-    $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" );
795
-	wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
794
+    $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php");
795
+	wp_cache_set("wpinv-data-$key", $data, 'wpinv');
796 796
 
797 797
 	return $data;
798 798
 }
@@ -806,10 +806,10 @@  discard block
 block discarded – undo
806 806
  * @param bool $first_empty Whether or not the first item in the list should be empty
807 807
  * @return mixed Fetched data.
808 808
  */
809
-function wpinv_maybe_add_empty_option( $options, $first_empty ) {
809
+function wpinv_maybe_add_empty_option($options, $first_empty) {
810 810
 
811
-    if ( ! empty( $options ) && $first_empty ) {
812
-        return array_merge( array( '' => '' ), $options );
811
+    if (!empty($options) && $first_empty) {
812
+        return array_merge(array('' => ''), $options);
813 813
     }
814 814
     return $options;
815 815
 
@@ -821,21 +821,21 @@  discard block
 block discarded – undo
821 821
  * @param mixed $var Data to sanitize.
822 822
  * @return string|array
823 823
  */
824
-function wpinv_clean( $var ) {
824
+function wpinv_clean($var) {
825 825
 
826
-	if ( is_array( $var ) ) {
827
-		return array_map( 'wpinv_clean', $var );
826
+	if (is_array($var)) {
827
+		return array_map('wpinv_clean', $var);
828 828
     }
829 829
 
830
-    if ( is_object( $var ) ) {
831
-		$object_vars = get_object_vars( $var );
832
-		foreach ( $object_vars as $property_name => $property_value ) {
833
-			$var->$property_name = wpinv_clean( $property_value );
830
+    if (is_object($var)) {
831
+		$object_vars = get_object_vars($var);
832
+		foreach ($object_vars as $property_name => $property_value) {
833
+			$var->$property_name = wpinv_clean($property_value);
834 834
         }
835 835
         return $var;
836 836
 	}
837 837
 
838
-    return is_string( $var ) ? sanitize_text_field( stripslashes( $var ) ) : $var;
838
+    return is_string($var) ? sanitize_text_field(stripslashes($var)) : $var;
839 839
 }
840 840
 
841 841
 /**
@@ -844,43 +844,43 @@  discard block
 block discarded – undo
844 844
  * @param string $str Data to convert.
845 845
  * @return string|array
846 846
  */
847
-function getpaid_convert_price_string_to_options( $str ) {
847
+function getpaid_convert_price_string_to_options($str) {
848 848
 
849
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
850
-    $options     = array();
849
+	$raw_options = array_map('trim', explode(',', $str));
850
+    $options = array();
851 851
 
852
-    foreach ( $raw_options as $option ) {
852
+    foreach ($raw_options as $option) {
853 853
 
854
-        if ( '' == $option ) {
854
+        if ('' == $option) {
855 855
             continue;
856 856
         }
857 857
 
858
-        $option = array_map( 'trim', explode( '|', $option ) );
858
+        $option = array_map('trim', explode('|', $option));
859 859
 
860 860
         $price = null;
861 861
         $label = null;
862 862
 
863
-        if ( isset( $option[0] ) && '' != $option[0] ) {
864
-            $label  = $option[0];
863
+        if (isset($option[0]) && '' != $option[0]) {
864
+            $label = $option[0];
865 865
         }
866 866
 
867
-        if ( isset( $option[1] ) && '' != $option[1] ) {
867
+        if (isset($option[1]) && '' != $option[1]) {
868 868
             $price = $option[1];
869 869
         }
870 870
 
871
-        if ( ! isset( $price ) ) {
871
+        if (!isset($price)) {
872 872
             $price = $label;
873 873
         }
874 874
 
875
-        if ( ! isset( $price ) || ! is_numeric( $price ) ) {
875
+        if (!isset($price) || !is_numeric($price)) {
876 876
             continue;
877 877
         }
878 878
 
879
-        if ( ! isset( $label ) ) {
879
+        if (!isset($label)) {
880 880
             $label = $price;
881 881
         }
882 882
 
883
-        $options[ "$label|$price" ] = $label;
883
+        $options["$label|$price"] = $label;
884 884
     }
885 885
 
886 886
     return $options;
@@ -889,27 +889,27 @@  discard block
 block discarded – undo
889 889
 /**
890 890
  * Returns the help tip.
891 891
  */
892
-function getpaid_get_help_tip( $tip, $additional_classes = '' ) {
893
-    $additional_classes = sanitize_html_class( $additional_classes );
894
-    $tip                = esc_attr__( $tip );
892
+function getpaid_get_help_tip($tip, $additional_classes = '') {
893
+    $additional_classes = sanitize_html_class($additional_classes);
894
+    $tip                = esc_attr__($tip);
895 895
     return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>";
896 896
 }
897 897
 
898 898
 /**
899 899
  * Formats a date
900 900
  */
901
-function getpaid_format_date( $date, $with_time = false ) {
901
+function getpaid_format_date($date, $with_time = false) {
902 902
 
903
-    if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) {
903
+    if (empty($date) || $date == '0000-00-00 00:00:00') {
904 904
         return '';
905 905
     }
906 906
 
907 907
     $format = getpaid_date_format();
908 908
 
909
-    if ( $with_time ) {
909
+    if ($with_time) {
910 910
         $format .= ' ' . getpaid_time_format();
911 911
     }
912
-    return date_i18n( $format, strtotime( $date ) );
912
+    return date_i18n($format, strtotime($date));
913 913
 
914 914
 }
915 915
 
@@ -918,9 +918,9 @@  discard block
 block discarded – undo
918 918
  *
919 919
  * @return string
920 920
  */
921
-function getpaid_format_date_value( $date, $default = '&mdash;', $with_time = false ) {
922
-    $date = getpaid_format_date( $date, $with_time );
923
-    return empty( $date ) ? $default : $date;
921
+function getpaid_format_date_value($date, $default = '&mdash;', $with_time = false) {
922
+    $date = getpaid_format_date($date, $with_time);
923
+    return empty($date) ? $default : $date;
924 924
 }
925 925
 
926 926
 /**
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
  * @return string
930 930
  */
931 931
 function getpaid_date_format() {
932
-	return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
932
+	return apply_filters('getpaid_date_format', get_option('date_format'));
933 933
 }
934 934
 
935 935
 /**
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
  * @return string
939 939
  */
940 940
 function getpaid_time_format() {
941
-	return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
941
+	return apply_filters('getpaid_time_format', get_option('time_format'));
942 942
 }
943 943
 
944 944
 /**
@@ -948,16 +948,16 @@  discard block
 block discarded – undo
948 948
  * @param  integer $limit Limit size in characters.
949 949
  * @return string
950 950
  */
951
-function getpaid_limit_length( $string, $limit ) {
951
+function getpaid_limit_length($string, $limit) {
952 952
     $str_limit = $limit - 3;
953 953
 
954
-	if ( function_exists( 'mb_strimwidth' ) ) {
955
-		if ( mb_strlen( $string ) > $limit ) {
956
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
954
+	if (function_exists('mb_strimwidth')) {
955
+		if (mb_strlen($string) > $limit) {
956
+			$string = mb_strimwidth($string, 0, $str_limit) . '...';
957 957
 		}
958 958
 	} else {
959
-		if ( strlen( $string ) > $limit ) {
960
-			$string = substr( $string, 0, $str_limit ) . '...';
959
+		if (strlen($string) > $limit) {
960
+			$string = substr($string, 0, $str_limit) . '...';
961 961
 		}
962 962
 	}
963 963
     return $string;
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
  * @since 1.0.19
972 972
  */
973 973
 function getpaid_api() {
974
-    return getpaid()->get( 'api' );
974
+    return getpaid()->get('api');
975 975
 }
976 976
 
977 977
 /**
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
  * @since 1.0.19
982 982
  */
983 983
 function getpaid_post_types() {
984
-    return getpaid()->get( 'post_types' );
984
+    return getpaid()->get('post_types');
985 985
 }
986 986
 
987 987
 /**
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
  * @since 1.0.19
992 992
  */
993 993
 function getpaid_session() {
994
-    return getpaid()->get( 'session' );
994
+    return getpaid()->get('session');
995 995
 }
996 996
 
997 997
 /**
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
  * @since 1.0.19
1002 1002
  */
1003 1003
 function getpaid_notes() {
1004
-    return getpaid()->get( 'notes' );
1004
+    return getpaid()->get('notes');
1005 1005
 }
1006 1006
 
1007 1007
 /**
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
  * @return GetPaid_Admin
1011 1011
  */
1012 1012
 function getpaid_admin() {
1013
-    return getpaid()->get( 'admin' );
1013
+    return getpaid()->get('admin');
1014 1014
 }
1015 1015
 
1016 1016
 /**
@@ -1020,8 +1020,8 @@  discard block
 block discarded – undo
1020 1020
  * @param string $base the base url
1021 1021
  * @return string
1022 1022
  */
1023
-function getpaid_get_authenticated_action_url( $action, $base = false ) {
1024
-    return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' );
1023
+function getpaid_get_authenticated_action_url($action, $base = false) {
1024
+    return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce');
1025 1025
 }
1026 1026
 
1027 1027
 /**
@@ -1029,11 +1029,11 @@  discard block
 block discarded – undo
1029 1029
  *
1030 1030
  * @return string
1031 1031
  */
1032
-function getpaid_get_post_type_label( $post_type, $plural = true ) {
1032
+function getpaid_get_post_type_label($post_type, $plural = true) {
1033 1033
 
1034
-    $post_type = get_post_type_object( $post_type );
1034
+    $post_type = get_post_type_object($post_type);
1035 1035
 
1036
-    if ( ! is_object( $post_type ) ) {
1036
+    if (!is_object($post_type)) {
1037 1037
         return null;
1038 1038
     }
1039 1039
 
@@ -1046,18 +1046,18 @@  discard block
 block discarded – undo
1046 1046
  *
1047 1047
  * @return mixed|null
1048 1048
  */
1049
-function getpaid_get_array_field( $array, $key, $secondary_key = null ) {
1049
+function getpaid_get_array_field($array, $key, $secondary_key = null) {
1050 1050
 
1051
-    if ( ! is_array( $array ) ) {
1051
+    if (!is_array($array)) {
1052 1052
         return null;
1053 1053
     }
1054 1054
 
1055
-    if ( ! empty( $secondary_key ) ) {
1056
-        $array = isset( $array[ $secondary_key ] ) ? $array[ $secondary_key ] : array();
1057
-        return getpaid_get_array_field( $array, $key );
1055
+    if (!empty($secondary_key)) {
1056
+        $array = isset($array[$secondary_key]) ? $array[$secondary_key] : array();
1057
+        return getpaid_get_array_field($array, $key);
1058 1058
     }
1059 1059
 
1060
-    return isset( $array[ $key ] ) ? $array[ $key ] : null;
1060
+    return isset($array[$key]) ? $array[$key] : null;
1061 1061
 
1062 1062
 }
1063 1063
 
@@ -1066,12 +1066,12 @@  discard block
 block discarded – undo
1066 1066
  *
1067 1067
  * @return array
1068 1068
  */
1069
-function getpaid_array_merge_if_empty( $args, $defaults ) {
1069
+function getpaid_array_merge_if_empty($args, $defaults) {
1070 1070
 
1071
-    foreach ( $defaults as $key => $value ) {
1071
+    foreach ($defaults as $key => $value) {
1072 1072
 
1073
-        if ( array_key_exists( $key, $args ) && empty( $args[ $key ] ) ) {
1074
-            $args[ $key ] = $value;
1073
+        if (array_key_exists($key, $args) && empty($args[$key])) {
1074
+            $args[$key] = $value;
1075 1075
         }
1076 1076
 }
1077 1077
 
@@ -1088,12 +1088,12 @@  discard block
 block discarded – undo
1088 1088
 
1089 1089
     $types = get_allowed_mime_types();
1090 1090
 
1091
-    if ( isset( $types['htm|html'] ) ) {
1092
-		unset( $types['htm|html'] );
1091
+    if (isset($types['htm|html'])) {
1092
+		unset($types['htm|html']);
1093 1093
 	}
1094 1094
 
1095
-    if ( isset( $types['js'] ) ) {
1096
-		unset( $types['js'] );
1095
+    if (isset($types['js'])) {
1096
+		unset($types['js']);
1097 1097
 	}
1098 1098
 
1099 1099
     return $types;
@@ -1101,34 +1101,34 @@  discard block
 block discarded – undo
1101 1101
 }
1102 1102
 
1103 1103
 
1104
-function getpaid_user_delete_invoice( $data ) {
1104
+function getpaid_user_delete_invoice($data) {
1105 1105
 
1106 1106
     // Ensure there is an invoice to delete.
1107
-    if ( empty( $data['invoice_id'] ) ) {
1107
+    if (empty($data['invoice_id'])) {
1108 1108
         return;
1109 1109
     }
1110 1110
 
1111
-    $invoice = new WPInv_Invoice( (int) $data['invoice_id'] );
1111
+    $invoice = new WPInv_Invoice((int) $data['invoice_id']);
1112 1112
 
1113 1113
     // Ensure that it exists and that it belongs to the current user.
1114
-    if ( ! $invoice->exists() || $invoice->get_customer_id() != get_current_user_id() ) {
1115
-        wpinv_set_error( 'invalid_invoice', __( 'You do not have permission to delete this invoice', 'invoicing' ) );
1114
+    if (!$invoice->exists() || $invoice->get_customer_id() != get_current_user_id()) {
1115
+        wpinv_set_error('invalid_invoice', __('You do not have permission to delete this invoice', 'invoicing'));
1116 1116
 
1117 1117
     // Can it be deleted?
1118
-    } elseif ( ! $invoice->needs_payment() ) {
1119
-        wpinv_set_error( 'cannot_delete', __( 'This invoice cannot be deleted as it has already been paid.', 'invoicing' ) );
1118
+    } elseif (!$invoice->needs_payment()) {
1119
+        wpinv_set_error('cannot_delete', __('This invoice cannot be deleted as it has already been paid.', 'invoicing'));
1120 1120
 
1121 1121
     // Delete it.
1122 1122
     } else {
1123 1123
 
1124 1124
         $invoice->delete();
1125
-        wpinv_set_error( 'delete', __( 'The invoice has been deleted.', 'invoicing' ), 'info' );
1125
+        wpinv_set_error('delete', __('The invoice has been deleted.', 'invoicing'), 'info');
1126 1126
     }
1127 1127
 
1128
-    $redirect = remove_query_arg( array( 'getpaid-action', 'getpaid-nonce', 'invoice_id' ) );
1128
+    $redirect = remove_query_arg(array('getpaid-action', 'getpaid-nonce', 'invoice_id'));
1129 1129
 
1130
-    wp_safe_redirect( $redirect );
1130
+    wp_safe_redirect($redirect);
1131 1131
     exit;
1132 1132
 
1133 1133
 }
1134
-add_action( 'getpaid_authenticated_action_delete_invoice', 'getpaid_user_delete_invoice' );
1134
+add_action('getpaid_authenticated_action_delete_invoice', 'getpaid_user_delete_invoice');
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-payment-gateway.php 1 patch
Spacing   +127 added lines, -127 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
  * Abstaract Payment Gateway class.
@@ -139,50 +139,50 @@  discard block
 block discarded – undo
139 139
 	public function __construct() {
140 140
 
141 141
 		// Register gateway.
142
-		add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) );
142
+		add_filter('wpinv_payment_gateways', array($this, 'register_gateway'));
143 143
 
144
-		$this->enabled = wpinv_is_gateway_active( $this->id );
144
+		$this->enabled = wpinv_is_gateway_active($this->id);
145 145
 
146 146
 		// Add support for various features.
147
-		foreach ( $this->supports as $feature ) {
148
-			add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' );
149
-			add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' );
150
-			add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' );
147
+		foreach ($this->supports as $feature) {
148
+			add_filter("wpinv_{$this->id}_support_{$feature}", '__return_true');
149
+			add_filter("getpaid_{$this->id}_support_{$feature}", '__return_true');
150
+			add_filter("getpaid_{$this->id}_supports_{$feature}", '__return_true');
151 151
 		}
152 152
 
153 153
 		// Invoice addons.
154
-		if ( $this->supports( 'addons' ) ) {
155
-			add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 );
154
+		if ($this->supports('addons')) {
155
+			add_action("getpaid_process_{$this->id}_invoice_addons", array($this, 'process_addons'), 10, 2);
156 156
 		}
157 157
 
158 158
 		// Gateway settings.
159
-		add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) );
159
+		add_filter("wpinv_gateway_settings_{$this->id}", array($this, 'admin_settings'));
160 160
 
161 161
 		// Gateway checkout fiellds.
162
-		add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 );
162
+		add_action("wpinv_{$this->id}_cc_form", array($this, 'payment_fields'), 10, 2);
163 163
 
164 164
 		// Process payment.
165
-		add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 );
165
+		add_action("getpaid_gateway_{$this->id}", array($this, 'process_payment'), 10, 3);
166 166
 
167 167
 		// Change the checkout button text.
168
-		if ( ! empty( $this->checkout_button_text ) ) {
169
-			add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) );
168
+		if (!empty($this->checkout_button_text)) {
169
+			add_filter("getpaid_gateway_{$this->id}_checkout_button_label", array($this, 'rename_checkout_button'));
170 170
 		}
171 171
 
172 172
 		// Check if a gateway is valid for a given currency.
173
-		add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 );
173
+		add_filter("getpaid_gateway_{$this->id}_is_valid_for_currency", array($this, 'validate_currency'), 10, 2);
174 174
 
175 175
 		// Generate the transaction url.
176
-		add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 );
176
+		add_filter("getpaid_gateway_{$this->id}_transaction_url", array($this, 'filter_transaction_url'), 10, 2);
177 177
 
178 178
 		// Generate the subscription url.
179
-		add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 );
179
+		add_filter('getpaid_remote_subscription_profile_url', array($this, 'generate_subscription_url'), 10, 2);
180 180
 
181 181
 		// Confirm payments.
182
-		add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 );
182
+		add_filter("wpinv_payment_confirm_{$this->id}", array($this, 'confirm_payment'), 10, 2);
183 183
 
184 184
 		// Verify IPNs.
185
-		add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) );
185
+		add_action("wpinv_verify_{$this->id}_ipn", array($this, 'verify_ipn'));
186 186
 
187 187
 	}
188 188
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 * @since 1.0.19
193 193
 	 * @return bool
194 194
 	 */
195
-	public function is( $gateway ) {
195
+	public function is($gateway) {
196 196
 		return $gateway == $this->id;
197 197
 	}
198 198
 
@@ -202,23 +202,23 @@  discard block
 block discarded – undo
202 202
 	 * @since 1.0.19
203 203
 	 * @return array
204 204
 	 */
205
-	public function get_tokens( $sandbox = null ) {
205
+	public function get_tokens($sandbox = null) {
206 206
 
207
-		if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) {
208
-			$tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true );
207
+		if (is_user_logged_in() && $this->supports('tokens') && 0 == count($this->tokens)) {
208
+			$tokens = get_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", true);
209 209
 
210
-			if ( is_array( $tokens ) ) {
210
+			if (is_array($tokens)) {
211 211
 				$this->tokens = $tokens;
212 212
 			}
213 213
 }
214 214
 
215
-		if ( ! is_bool( $sandbox ) ) {
215
+		if (!is_bool($sandbox)) {
216 216
 			return $this->tokens;
217 217
 		}
218 218
 
219 219
 		// Filter tokens.
220
-		$args = array( 'type' => $sandbox ? 'sandbox' : 'live' );
221
-		return wp_list_filter( $this->tokens, $args );
220
+		$args = array('type' => $sandbox ? 'sandbox' : 'live');
221
+		return wp_list_filter($this->tokens, $args);
222 222
 
223 223
 	}
224 224
 
@@ -227,12 +227,12 @@  discard block
 block discarded – undo
227 227
 	 *
228 228
 	 * @since 1.0.19
229 229
 	 */
230
-	public function save_token( $token ) {
230
+	public function save_token($token) {
231 231
 
232 232
 		$tokens   = $this->get_tokens();
233 233
 		$tokens[] = $token;
234 234
 
235
-		update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens );
235
+		update_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens);
236 236
 
237 237
 		$this->tokens = $tokens;
238 238
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 	 * @return string
245 245
 	 */
246 246
 	public function get_method_title() {
247
-		return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this );
247
+		return apply_filters('getpaid_gateway_method_title', $this->method_title, $this);
248 248
 	}
249 249
 
250 250
 	/**
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 	 * @return string
254 254
 	 */
255 255
 	public function get_method_description() {
256
-		return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this );
256
+		return apply_filters('getpaid_gateway_method_description', $this->method_description, $this);
257 257
 	}
258 258
 
259 259
 	/**
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	 * @param WPInv_Invoice $invoice Invoice object.
263 263
 	 * @return string
264 264
 	 */
265
-	public function get_return_url( $invoice ) {
265
+	public function get_return_url($invoice) {
266 266
 
267 267
 		// Payment success url
268 268
 		$return_url = add_query_arg(
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 			wpinv_get_success_page_uri()
275 275
 		);
276 276
 
277
-		return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this );
277
+		return apply_filters('getpaid_gateway_success_url', $return_url, $invoice, $this);
278 278
 	}
279 279
 
280 280
 	/**
@@ -283,24 +283,24 @@  discard block
 block discarded – undo
283 283
 	 * @param string $content Success page content.
284 284
 	 * @return string
285 285
 	 */
286
-	public function confirm_payment( $content ) {
286
+	public function confirm_payment($content) {
287 287
 
288 288
 		// Retrieve the invoice.
289 289
 		$invoice_id = getpaid_get_current_invoice_id();
290
-		$invoice    = wpinv_get_invoice( $invoice_id );
290
+		$invoice    = wpinv_get_invoice($invoice_id);
291 291
 
292 292
 		// Ensure that it exists and that it is pending payment.
293
-		if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) {
293
+		if (empty($invoice_id) || !$invoice->needs_payment()) {
294 294
 			return $content;
295 295
 		}
296 296
 
297 297
 		// Can the user view this invoice??
298
-		if ( ! wpinv_user_can_view_invoice( $invoice ) ) {
298
+		if (!wpinv_user_can_view_invoice($invoice)) {
299 299
 			return $content;
300 300
 		}
301 301
 
302 302
 		// Show payment processing indicator.
303
-		return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) );
303
+		return wpinv_get_template_html('wpinv-payment-processing.php', compact('invoice'));
304 304
 	}
305 305
 
306 306
 	/**
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 	 * @param GetPaid_Form_Item[] $items
318 318
 	 * @return WPInv_Invoice
319 319
 	 */
320
-	public function process_addons( $invoice, $items ) {
320
+	public function process_addons($invoice, $items) {
321 321
 
322 322
 	}
323 323
 
@@ -328,14 +328,14 @@  discard block
 block discarded – undo
328 328
 	 * @param WPInv_Invoice $invoice Invoice object.
329 329
 	 * @return string transaction URL, or empty string.
330 330
 	 */
331
-	public function filter_transaction_url( $transaction_url, $invoice ) {
331
+	public function filter_transaction_url($transaction_url, $invoice) {
332 332
 
333
-		$transaction_id  = $invoice->get_transaction_id();
333
+		$transaction_id = $invoice->get_transaction_id();
334 334
 
335
-		if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) {
336
-			$transaction_url = sprintf( $this->view_transaction_url, $transaction_id );
337
-			$replace         = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
338
-			$transaction_url = str_replace( '{sandbox}', $replace, $transaction_url );
335
+		if (!empty($this->view_transaction_url) && !empty($transaction_id)) {
336
+			$transaction_url = sprintf($this->view_transaction_url, $transaction_id);
337
+			$replace         = $this->is_sandbox($invoice) ? 'sandbox' : '';
338
+			$transaction_url = str_replace('{sandbox}', $replace, $transaction_url);
339 339
 		}
340 340
 
341 341
 		return $transaction_url;
@@ -348,15 +348,15 @@  discard block
 block discarded – undo
348 348
 	 * @param WPInv_Subscription $subscription Subscription objectt.
349 349
 	 * @return string subscription URL, or empty string.
350 350
 	 */
351
-	public function generate_subscription_url( $subscription_url, $subscription ) {
351
+	public function generate_subscription_url($subscription_url, $subscription) {
352 352
 
353
-		$profile_id      = $subscription->get_profile_id();
353
+		$profile_id = $subscription->get_profile_id();
354 354
 
355
-		if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) {
355
+		if ($this->id == $subscription->get_gateway() && !empty($this->view_subscription_url) && !empty($profile_id)) {
356 356
 
357
-			$subscription_url = sprintf( $this->view_subscription_url, $profile_id );
358
-			$replace          = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : '';
359
-			$subscription_url = str_replace( '{sandbox}', $replace, $subscription_url );
357
+			$subscription_url = sprintf($this->view_subscription_url, $profile_id);
358
+			$replace          = $this->is_sandbox($subscription->get_parent_invoice()) ? 'sandbox' : '';
359
+			$subscription_url = str_replace('{sandbox}', $replace, $subscription_url);
360 360
 
361 361
 		}
362 362
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	 * @return bool
370 370
 	 */
371 371
 	public function is_available() {
372
-		return ! empty( $this->enabled );
372
+		return !empty($this->enabled);
373 373
 	}
374 374
 
375 375
 	/**
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 	 * @return string
379 379
 	 */
380 380
 	public function get_title() {
381
-		return apply_filters( 'getpaid_gateway_title', $this->title, $this );
381
+		return apply_filters('getpaid_gateway_title', $this->title, $this);
382 382
 	}
383 383
 
384 384
 	/**
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	 * @return string
388 388
 	 */
389 389
 	public function get_description() {
390
-		return apply_filters( 'getpaid_gateway_description', $this->description, $this );
390
+		return apply_filters('getpaid_gateway_description', $this->description, $this);
391 391
 	}
392 392
 
393 393
 	/**
@@ -399,9 +399,9 @@  discard block
 block discarded – undo
399 399
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
400 400
 	 * @return void
401 401
 	 */
402
-	public function process_payment( $invoice, $submission_data, $submission ) {
402
+	public function process_payment($invoice, $submission_data, $submission) {
403 403
 		// Process the payment then either redirect to the success page or the gateway.
404
-		do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission );
404
+		do_action('getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission);
405 405
 	}
406 406
 
407 407
 	/**
@@ -415,8 +415,8 @@  discard block
 block discarded – undo
415 415
 	 * @param  string $reason Refund reason.
416 416
 	 * @return WP_Error|bool True or false based on success, or a WP_Error object.
417 417
 	 */
418
-	public function process_refund( $invoice, $amount = null, $reason = '' ) {
419
-		return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason );
418
+	public function process_refund($invoice, $amount = null, $reason = '') {
419
+		return apply_filters('getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason);
420 420
 	}
421 421
 
422 422
 	/**
@@ -425,8 +425,8 @@  discard block
 block discarded – undo
425 425
 	 * @param int $invoice_id 0 or invoice id.
426 426
 	 * @param GetPaid_Payment_Form $form Current payment form.
427 427
 	 */
428
-	public function payment_fields( $invoice_id, $form ) {
429
-		do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form );
428
+	public function payment_fields($invoice_id, $form) {
429
+		do_action('getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form);
430 430
 	}
431 431
 
432 432
 	/**
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 	 *
435 435
 	 * @param array $admin_settings
436 436
 	 */
437
-	public function admin_settings( $admin_settings ) {
437
+	public function admin_settings($admin_settings) {
438 438
 		return $admin_settings;
439 439
 	}
440 440
 
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
 	 *
444 444
 	 * @param string $option
445 445
 	 */
446
-	public function get_option( $option, $default = false ) {
447
-		return wpinv_get_option( $this->id . '_' . $option, $default );
446
+	public function get_option($option, $default = false) {
447
+		return wpinv_get_option($this->id . '_' . $option, $default);
448 448
 	}
449 449
 
450 450
 	/**
@@ -457,8 +457,8 @@  discard block
 block discarded – undo
457 457
 	 * @return bool True if the gateway supports the feature, false otherwise.
458 458
 	 * @since 1.0.19
459 459
 	 */
460
-	public function supports( $feature ) {
461
-		return getpaid_payment_gateway_supports( $this->id, $feature );
460
+	public function supports($feature) {
461
+		return getpaid_payment_gateway_supports($this->id, $feature);
462 462
 	}
463 463
 
464 464
 	/**
@@ -466,36 +466,36 @@  discard block
 block discarded – undo
466 466
 	 *
467 467
 	 * @param bool $save whether or not to display the save button.
468 468
 	 */
469
-    public function get_cc_form( $save = false ) {
469
+    public function get_cc_form($save = false) {
470 470
 
471 471
 		ob_start();
472 472
 
473
-        $id_prefix = esc_attr( uniqid( $this->id ) );
473
+        $id_prefix = esc_attr(uniqid($this->id));
474 474
 
475 475
         $months = array(
476
-            '01' => __( 'January', 'invoicing' ),
477
-            '02' => __( 'February', 'invoicing' ),
478
-            '03' => __( 'March', 'invoicing' ),
479
-            '04' => __( 'April', 'invoicing' ),
480
-            '05' => __( 'May', 'invoicing' ),
481
-            '06' => __( 'June', 'invoicing' ),
482
-            '07' => __( 'July', 'invoicing' ),
483
-            '08' => __( 'August', 'invoicing' ),
484
-            '09' => __( 'September', 'invoicing' ),
485
-            '10' => __( 'October', 'invoicing' ),
486
-            '11' => __( 'November', 'invoicing' ),
487
-            '12' => __( 'December', 'invoicing' ),
476
+            '01' => __('January', 'invoicing'),
477
+            '02' => __('February', 'invoicing'),
478
+            '03' => __('March', 'invoicing'),
479
+            '04' => __('April', 'invoicing'),
480
+            '05' => __('May', 'invoicing'),
481
+            '06' => __('June', 'invoicing'),
482
+            '07' => __('July', 'invoicing'),
483
+            '08' => __('August', 'invoicing'),
484
+            '09' => __('September', 'invoicing'),
485
+            '10' => __('October', 'invoicing'),
486
+            '11' => __('November', 'invoicing'),
487
+            '12' => __('December', 'invoicing'),
488 488
         );
489 489
 
490
-        $year  = (int) date( 'Y', current_time( 'timestamp' ) );
490
+        $year  = (int) date('Y', current_time('timestamp'));
491 491
         $years = array();
492 492
 
493
-        for ( $i = 0; $i <= 10; $i++ ) {
494
-            $years[ $year + $i ] = $year + $i;
493
+        for ($i = 0; $i <= 10; $i++) {
494
+            $years[$year + $i] = $year + $i;
495 495
         }
496 496
 
497 497
         ?>
498
-            <div class="<?php echo esc_attr( $this->id ); ?>-cc-form getpaid-cc-form mt-1">
498
+            <div class="<?php echo esc_attr($this->id); ?>-cc-form getpaid-cc-form mt-1">
499 499
 
500 500
 
501 501
                 <div class="getpaid-cc-card-inner">
@@ -504,14 +504,14 @@  discard block
 block discarded – undo
504 504
                         <div class="col-12">
505 505
 
506 506
 							<div class="form-group">
507
-								<label for="<?php echo esc_attr( "$id_prefix-cc-number" ); ?>"><?php esc_html_e( 'Card number', 'invoicing' ); ?></label>
507
+								<label for="<?php echo esc_attr("$id_prefix-cc-number"); ?>"><?php esc_html_e('Card number', 'invoicing'); ?></label>
508 508
 								<div class="input-group input-group-sm">
509 509
 									<div class="input-group-prepend ">
510 510
 										<span class="input-group-text">
511 511
 											<i class="fa fa-credit-card"></i>
512 512
 										</span>
513 513
 									</div>
514
-									<input type="text" name="<?php echo esc_attr( $this->id . '[cc_number]' ); ?>" id="<?php echo esc_attr( "$id_prefix-cc-number" ); ?>" class="form-control form-control-sm" autocomplete="cc-number">
514
+									<input type="text" name="<?php echo esc_attr($this->id . '[cc_number]'); ?>" id="<?php echo esc_attr("$id_prefix-cc-number"); ?>" class="form-control form-control-sm" autocomplete="cc-number">
515 515
 								</div>
516 516
 							</div>
517 517
 
@@ -519,17 +519,17 @@  discard block
 block discarded – undo
519 519
 
520 520
                         <div class="col-12">
521 521
                             <div class="form-group">
522
-                                <label><?php esc_html_e( 'Expiration', 'invoicing' ); ?></label>
522
+                                <label><?php esc_html_e('Expiration', 'invoicing'); ?></label>
523 523
                                 <div class="form-row">
524 524
 
525 525
                                     <div class="col">
526
-                                        <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr( $this->id ); ?>[cc_expire_month]">
527
-                                            <option disabled selected="selected"><?php esc_html_e( 'MM', 'invoicing' ); ?></option>
526
+                                        <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr($this->id); ?>[cc_expire_month]">
527
+                                            <option disabled selected="selected"><?php esc_html_e('MM', 'invoicing'); ?></option>
528 528
 
529 529
                                             <?php
530
-                                                foreach ( $months as $key => $month ) {
531
-												$key   = esc_attr( $key );
532
-												$month = esc_html( $month );
530
+                                                foreach ($months as $key => $month) {
531
+												$key   = esc_attr($key);
532
+												$month = esc_html($month);
533 533
 												echo "<option value='$key'>$month</option>" . PHP_EOL;
534 534
                                                 }
535 535
                                             ?>
@@ -538,13 +538,13 @@  discard block
 block discarded – undo
538 538
                                     </div>
539 539
 
540 540
                                     <div class="col">
541
-                                        <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr( $this->id ); ?>[cc_expire_year]">
542
-                                            <option disabled selected="selected"><?php esc_html_e( 'YY', 'invoicing' ); ?></option>
541
+                                        <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr($this->id); ?>[cc_expire_year]">
542
+                                            <option disabled selected="selected"><?php esc_html_e('YY', 'invoicing'); ?></option>
543 543
 
544 544
                                             <?php
545
-                                                foreach ( $years as $key => $year ) {
546
-												$key   = esc_attr( $key );
547
-												$year  = esc_html( $year );
545
+                                                foreach ($years as $key => $year) {
546
+												$key   = esc_attr($key);
547
+												$year  = esc_html($year);
548 548
 												echo "<option value='$key'>$year</option>" . PHP_EOL;
549 549
                                                 }
550 550
                                             ?>
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
                                     array(
563 563
                                         'name'             => $this->id . '[cc_cvv2]',
564 564
                                         'id'               => "$id_prefix-cc-cvv2",
565
-                                        'label'            => __( 'CCV', 'invoicing' ),
565
+                                        'label'            => __('CCV', 'invoicing'),
566 566
 										'label_type'       => 'vertical',
567 567
 										'class'            => 'form-control-sm',
568 568
 										'extra_attributes' => array(
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 					
578 578
 					<?php
579 579
 
580
-						if ( $save ) {
580
+						if ($save) {
581 581
 						echo $this->save_payment_method_checkbox();
582 582
 						}
583 583
 
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 	 *
597 597
 	 * @since 1.0.19
598 598
 	 */
599
-	public function new_payment_method_entry( $form ) {
599
+	public function new_payment_method_entry($form) {
600 600
 		echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>";
601 601
 	}
602 602
 
@@ -606,16 +606,16 @@  discard block
 block discarded – undo
606 606
 	 * @since 1.0.19
607 607
 	 */
608 608
 	public function saved_payment_methods() {
609
-		$html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">';
609
+		$html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr(count($this->get_tokens($this->is_sandbox()))) . '">';
610 610
 
611
-		foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) {
612
-			$html .= $this->get_saved_payment_method_option_html( $token );
611
+		foreach ($this->get_tokens($this->is_sandbox()) as $token) {
612
+			$html .= $this->get_saved_payment_method_option_html($token);
613 613
 		}
614 614
 
615 615
 		$html .= $this->get_new_payment_method_option_html();
616 616
 		$html .= '</ul>';
617 617
 
618
-		echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this );
618
+		echo apply_filters('getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this);
619 619
 	}
620 620
 
621 621
 	/**
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
 	 * @param  array $token Payment Token.
626 626
 	 * @return string Generated payment method HTML
627 627
 	 */
628
-	public function get_saved_payment_method_option_html( $token ) {
628
+	public function get_saved_payment_method_option_html($token) {
629 629
 
630 630
 		return sprintf(
631 631
 			'<li class="getpaid-payment-method form-group">
@@ -634,11 +634,11 @@  discard block
 block discarded – undo
634 634
 					<span>%3$s</span>
635 635
 				</label>
636 636
 			</li>',
637
-			esc_attr( $this->id ),
638
-			esc_attr( $token['id'] ),
639
-			esc_html( $token['name'] ),
640
-			checked( empty( $token['default'] ), false, false ),
641
-			empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] )
637
+			esc_attr($this->id),
638
+			esc_attr($token['id']),
639
+			esc_html($token['name']),
640
+			checked(empty($token['default']), false, false),
641
+			empty($token['currency']) ? 'none' : esc_attr($token['currency'])
642 642
 		);
643 643
 
644 644
 	}
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 	 */
651 651
 	public function get_new_payment_method_option_html() {
652 652
 
653
-		$label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this );
653
+		$label = apply_filters('getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __('Use a new payment method', 'invoicing'), $this);
654 654
 
655 655
 		return sprintf(
656 656
 			'<li class="getpaid-new-payment-method">
@@ -659,8 +659,8 @@  discard block
 block discarded – undo
659 659
 					<span>%2$s</span>
660 660
 				</label>
661 661
 			</li>',
662
-			esc_attr( $this->id ),
663
-			esc_html( $label )
662
+			esc_attr($this->id),
663
+			esc_html($label)
664 664
 		);
665 665
 
666 666
 	}
@@ -675,10 +675,10 @@  discard block
 block discarded – undo
675 675
 		return aui()->input(
676 676
 			array(
677 677
 				'type'       => 'checkbox',
678
-				'name'       => esc_attr( "getpaid-$this->id-new-payment-method" ),
679
-				'id'         => esc_attr( uniqid( $this->id ) ),
678
+				'name'       => esc_attr("getpaid-$this->id-new-payment-method"),
679
+				'id'         => esc_attr(uniqid($this->id)),
680 680
 				'required'   => false,
681
-				'label'      => esc_html__( 'Save payment method', 'invoicing' ),
681
+				'label'      => esc_html__('Save payment method', 'invoicing'),
682 682
 				'value'      => 'true',
683 683
 				'checked'    => true,
684 684
 				'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1',
@@ -692,9 +692,9 @@  discard block
 block discarded – undo
692 692
 	 *
693 693
 	 * @return array
694 694
 	 */
695
-	public function register_gateway( $gateways ) {
695
+	public function register_gateway($gateways) {
696 696
 
697
-		$gateways[ $this->id ] = array(
697
+		$gateways[$this->id] = array(
698 698
 
699 699
 			'admin_label'    => $this->method_title,
700 700
             'checkout_label' => $this->title,
@@ -712,13 +712,13 @@  discard block
 block discarded – undo
712 712
 	 * @param  WPInv_Invoice|null $invoice Invoice object or null.
713 713
 	 * @return bool
714 714
 	 */
715
-	public function is_sandbox( $invoice = null ) {
715
+	public function is_sandbox($invoice = null) {
716 716
 
717
-		if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) {
717
+		if (!empty($invoice) && !$invoice->needs_payment()) {
718 718
 			return $invoice->get_mode() == 'test';
719 719
 		}
720 720
 
721
-		return wpinv_is_test_mode( $this->id );
721
+		return wpinv_is_test_mode($this->id);
722 722
 
723 723
 	}
724 724
 
@@ -736,15 +736,15 @@  discard block
 block discarded – undo
736 736
 	 *
737 737
 	 * @return bool
738 738
 	 */
739
-	public function validate_currency( $validation, $currency ) {
739
+	public function validate_currency($validation, $currency) {
740 740
 
741 741
 		// Required currencies.
742
-		if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) {
742
+		if (!empty($this->currencies) && !in_array($currency, $this->currencies)) {
743 743
 			return false;
744 744
 		}
745 745
 
746 746
 		// Excluded currencies.
747
-		if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) {
747
+		if (!empty($this->exclude_currencies) && in_array($currency, $this->exclude_currencies)) {
748 748
 			return false;
749 749
 		}
750 750
 
@@ -755,13 +755,13 @@  discard block
 block discarded – undo
755 755
 	 * Displays an error
756 756
 	 *
757 757
 	 */
758
-	public function show_error( $code, $message, $type ) {
758
+	public function show_error($code, $message, $type) {
759 759
 
760
-		if ( is_admin() ) {
761
-			getpaid_admin()->{"show_$type"}( $message );
760
+		if (is_admin()) {
761
+			getpaid_admin()->{"show_$type"}($message);
762 762
 		}
763 763
 
764
-		wpinv_set_error( $code, $message, $type );
764
+		wpinv_set_error($code, $message, $type);
765 765
 
766 766
 	}
767 767
 
Please login to merge, or discard this patch.
templates/payment-forms-admin/edit/email.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -7,49 +7,49 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
14 14
 <div class='form-group'>
15 15
     <label class="d-block">
16
-        <span><?php esc_html_e( 'Field Label', 'invoicing' ); ?></span>
16
+        <span><?php esc_html_e('Field Label', 'invoicing'); ?></span>
17 17
         <input v-model='active_form_element.label' class='form-control' type="text"/>
18 18
     </label>
19 19
 </div>
20 20
 
21 21
 <div class='form-group'>
22 22
     <label class="d-block">
23
-        <span><?php esc_html_e( 'Placeholder text', 'invoicing' ); ?></span>
23
+        <span><?php esc_html_e('Placeholder text', 'invoicing'); ?></span>
24 24
         <input v-model='active_form_element.placeholder' class='form-control' type="text"/>
25 25
     </label>
26 26
 </div>
27 27
 
28 28
 <div class='form-group'>
29 29
     <label class="d-block">
30
-        <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span>
31
-        <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea>
32
-        <small class="form-text text-muted"><?php esc_html_e( 'HTML is allowed', 'invoicing' ); ?></small>
30
+        <span><?php esc_html_e('Help Text', 'invoicing'); ?></span>
31
+        <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea>
32
+        <small class="form-text text-muted"><?php esc_html_e('HTML is allowed', 'invoicing'); ?></small>
33 33
     </label>
34 34
 </div>
35 35
 
36 36
 <div class='form-group form-check'>
37 37
     <input :id="active_form_element.id + '_edit'" v-model='active_form_element.required' type='checkbox' class='form-check-input' />
38
-    <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e( 'Is this field required?', 'invoicing' ); ?></label>
38
+    <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e('Is this field required?', 'invoicing'); ?></label>
39 39
 </div>
40 40
 
41 41
 <div class='form-group form-check'>
42 42
     <input :id="active_form_element.id + '_add_meta'" v-model='active_form_element.add_meta' type='checkbox' class='form-check-input' />
43
-    <label class='form-check-label' :for="active_form_element.id + '_add_meta'"><?php esc_html_e( 'Show this field in receipts and emails?', 'invoicing' ); ?></label>
43
+    <label class='form-check-label' :for="active_form_element.id + '_add_meta'"><?php esc_html_e('Show this field in receipts and emails?', 'invoicing'); ?></label>
44 44
 </div>
45 45
 
46 46
 <hr class='featurette-divider mt-4'>
47 47
 
48 48
 <div class='form-group'>
49 49
     <label class="d-block">
50
-        <span><?php esc_html_e( 'Email Merge Tag', 'invoicing' ); ?></span>
50
+        <span><?php esc_html_e('Email Merge Tag', 'invoicing'); ?></span>
51 51
         <input :value='active_form_element.label | formatMergeTag' class='form-control bg-white' type="text" readonly onclick="this.select()" />
52
-        <span class="form-text text-muted"><?php esc_html_e( 'You can use this merge tag in notification emails', 'invoicing' ); ?></span>
52
+        <span class="form-text text-muted"><?php esc_html_e('You can use this merge tag in notification emails', 'invoicing'); ?></span>
53 53
     </label>
54 54
 </div>
55 55
 
Please login to merge, or discard this patch.