Completed
Push — master ( 9b8253...a465f2 )
by Brian
29s queued 14s
created
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,14 +20,14 @@  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
         <div id="wpinv-form-builder" class="bsui">
26 26
             <div class="row">
27 27
                 <div class="col-sm-4">
28 28
 
29 29
                     <!-- Builder tabs -->
30
-                    <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php _e( 'Go Back', 'invoicing' ); ?></button>
30
+                    <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php _e('Go Back', 'invoicing'); ?></button>
31 31
 
32 32
                     <!-- Builder tab content -->
33 33
                     <div class="mt-4">
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
                         <!-- Available builder elements -->
36 36
                         <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='new_item'">
37 37
                             <div class="wpinv-form-builder-add-field-types">
38
-                                <small class='form-text text-muted'><?php _e( 'Add an element by dragging it to the payment form.', 'invoicing' ); ?></small>
38
+                                <small class='form-text text-muted'><?php _e('Add an element by dragging it to the payment form.', 'invoicing'); ?></small>
39 39
                                 <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">
40 40
                                     <li v-for="element in elements" class= "wpinv-payment-form-left-fields-field" @click.prevent="addField(element)" :class="{ 'd-none': element.defaults.premade }">
41 41
                                         <button class="button btn">
@@ -50,18 +50,18 @@  discard block
 block discarded – undo
50 50
                         <!-- Edit an element -->
51 51
                         <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='edit_item'" style="font-size: 14px;">
52 52
                             <div class="wpinv-form-builder-edit-field-wrapper">
53
-                                <?php do_action( 'wpinv_payment_form_edit_element_template', 'active_form_element', $post ); ?>
54
-                                <?php do_action( 'getpaid_payment_form_edit_element_template', $post ); ?>
53
+                                <?php do_action('wpinv_payment_form_edit_element_template', 'active_form_element', $post); ?>
54
+                                <?php do_action('getpaid_payment_form_edit_element_template', $post); ?>
55 55
                                 <div class='form-group'>
56
-                                    <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e( 'Width', 'invoicing' ) ?></label>
56
+                                    <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e('Width', 'invoicing') ?></label>
57 57
                                     <select class='form-control custom-select' :id="active_form_element.id + '_grid_width'" v-model='gridWidth'>
58
-                                        <option value='full'><?php esc_html_e( 'Full Width', 'invoicing' ); ?></option>
59
-                                        <option value='half'><?php esc_html_e( 'Half Width', 'invoicing' ); ?></option>
60
-                                        <option value='third'><?php esc_html_e( '1/3 Width', 'invoicing' ); ?></option>
58
+                                        <option value='full'><?php esc_html_e('Full Width', 'invoicing'); ?></option>
59
+                                        <option value='half'><?php esc_html_e('Half Width', 'invoicing'); ?></option>
60
+                                        <option value='third'><?php esc_html_e('1/3 Width', 'invoicing'); ?></option>
61 61
                                     </select>
62 62
                                 </div>
63 63
                                 <div>
64
-                                    <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php _e( 'Delete Element', 'invoicing' ); ?></button>
64
+                                    <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php _e('Delete Element', 'invoicing'); ?></button>
65 65
                                 </div>
66 66
                             </div>
67 67
                         </div>
@@ -70,15 +70,15 @@  discard block
 block discarded – undo
70 70
 
71 71
                 </div>
72 72
                 <div class="col-sm-8 border-left">
73
-                    <small class='form-text text-muted' v-if='form_elements.length'><?php _e( 'Click on any element to edit or delete it.', 'invoicing' ); ?></small>
74
-                    <p class='form-text text-muted' v-if='! form_elements.length'><?php _e( 'This form is empty. Add new elements by dragging them from the right.', 'invoicing' ); ?></p>
73
+                    <small class='form-text text-muted' v-if='form_elements.length'><?php _e('Click on any element to edit or delete it.', 'invoicing'); ?></small>
74
+                    <p class='form-text text-muted' v-if='! form_elements.length'><?php _e('This form is empty. Add new elements by dragging them from the right.', 'invoicing'); ?></p>
75 75
 
76 76
                     <div class="container-fluid">
77 77
                         <draggable class="section row" v-model="form_elements" @add="highlightLastDroppedField" group="fields" tag="div" style="min-height: 100%; font-size: 14px;">
78 78
                             <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">
79 79
                                 <div class="wpinv-form-builder-element-preview-inner">
80 80
                                     <div class="wpinv-payment-form-field-preview-overlay"></div>
81
-                                    <?php do_action( 'wpinv_payment_form_render_element_template', 'form_element', $post ); ?>
81
+                                    <?php do_action('wpinv_payment_form_render_element_template', 'form_element', $post); ?>
82 82
                                 </div>
83 83
                             </div>
84 84
                         </draggable>
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         </div>
93 93
         <?php
94 94
 
95
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
95
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
96 96
     }
97 97
 
98 98
     /**
@@ -100,33 +100,33 @@  discard block
 block discarded – undo
100 100
 	 *
101 101
 	 * @param int $post_id
102 102
 	 */
103
-	public static function save( $post_id ) {
103
+	public static function save($post_id) {
104 104
 
105 105
         // Prepare the form.
106
-        $form = new GetPaid_Payment_Form( $post_id );
106
+        $form = new GetPaid_Payment_Form($post_id);
107 107
 
108 108
         // Fetch form items.
109
-        $form_items = json_decode( wp_unslash( $_POST['wpinv_form_items'] ), true );
109
+        $form_items = json_decode(wp_unslash($_POST['wpinv_form_items']), true);
110 110
 
111 111
         // Ensure that we have an array...
112
-        if ( empty( $form_items ) ) {
112
+        if (empty($form_items)) {
113 113
             $form_items = array();
114 114
         }
115 115
 
116 116
         // Add it to the form.
117
-        $form->set_items( self::item_to_objects( $form_items ) );
117
+        $form->set_items(self::item_to_objects($form_items));
118 118
 
119 119
         // Save form elements.
120
-        $form_elements = json_decode( wp_unslash( $_POST['wpinv_form_elements'] ), true );
121
-        if ( empty( $form_elements ) ) {
120
+        $form_elements = json_decode(wp_unslash($_POST['wpinv_form_elements']), true);
121
+        if (empty($form_elements)) {
122 122
             $form_elements = array();
123 123
         }
124 124
 
125
-        $form->set_elements( $form_elements );
125
+        $form->set_elements($form_elements);
126 126
 
127 127
         // Persist data to the datastore.
128 128
         $form->save();
129
-        do_action( 'getpaid_payment_form_metabox_save', $post_id, $form );
129
+        do_action('getpaid_payment_form_metabox_save', $post_id, $form);
130 130
 
131 131
     }
132 132
 
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @param array $items
137 137
 	 */
138
-	public static function item_to_objects( $items ) {
138
+	public static function item_to_objects($items) {
139 139
 
140 140
         $objects = array();
141 141
 
142
-        foreach ( $items as $item ) {
143
-            $_item = new GetPaid_Form_Item( $item['id'] );
144
-            $_item->set_allow_quantities( (bool) $item['allow_quantities'] );
145
-            $_item->set_is_required( (bool) $item['required'] );
142
+        foreach ($items as $item) {
143
+            $_item = new GetPaid_Form_Item($item['id']);
144
+            $_item->set_allow_quantities((bool) $item['allow_quantities']);
145
+            $_item->set_is_required((bool) $item['required']);
146 146
             $objects[] = $_item;
147 147
         }
148 148
 
Please login to merge, or discard this patch.
includes/class-wpinv-ajax.php 1 patch
Spacing   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
  
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * WPInv_Ajax class.
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 	 * Hook in ajax handlers.
18 18
 	 */
19 19
 	public static function init() {
20
-		add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
-		add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
20
+		add_action('init', array(__CLASS__, 'define_ajax'), 0);
21
+		add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0);
22 22
 		self::add_ajax_events();
23 23
     }
24 24
 
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public static function define_ajax() {
29 29
 
30
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
-			getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
-			getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
-			if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
-				/** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
30
+		if (!empty($_GET['wpinv-ajax'])) {
31
+			getpaid_maybe_define_constant('DOING_AJAX', true);
32
+			getpaid_maybe_define_constant('WPInv_DOING_AJAX', true);
33
+			if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) {
34
+				/** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0);
35 35
 			}
36 36
 			$GLOBALS['wpdb']->hide_errors();
37 37
 		}
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 	 * @since 1.0.18
45 45
 	 */
46 46
 	private static function wpinv_ajax_headers() {
47
-		if ( ! headers_sent() ) {
47
+		if (!headers_sent()) {
48 48
 			send_origin_headers();
49 49
 			send_nosniff_header();
50 50
 			nocache_headers();
51
-			header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
-			header( 'X-Robots-Tag: noindex' );
53
-			status_header( 200 );
51
+			header('Content-Type: text/html; charset=' . get_option('blog_charset'));
52
+			header('X-Robots-Tag: noindex');
53
+			status_header(200);
54 54
 		}
55 55
     }
56 56
     
@@ -60,16 +60,16 @@  discard block
 block discarded – undo
60 60
 	public static function do_wpinv_ajax() {
61 61
 		global $wp_query;
62 62
 
63
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
-			$wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
63
+		if (!empty($_GET['wpinv-ajax'])) {
64
+			$wp_query->set('wpinv-ajax', sanitize_text_field(wp_unslash($_GET['wpinv-ajax'])));
65 65
 		}
66 66
 
67
-		$action = $wp_query->get( 'wpinv-ajax' );
67
+		$action = $wp_query->get('wpinv-ajax');
68 68
 
69
-		if ( $action ) {
69
+		if ($action) {
70 70
 			self::wpinv_ajax_headers();
71
-			$action = sanitize_text_field( $action );
72
-			do_action( 'wpinv_ajax_' . $action );
71
+			$action = sanitize_text_field($action);
72
+			do_action('wpinv_ajax_' . $action);
73 73
 			wp_die();
74 74
 		}
75 75
 
@@ -102,36 +102,36 @@  discard block
 block discarded – undo
102 102
             'ip_geolocation'              => true,
103 103
         );
104 104
 
105
-        foreach ( $ajax_events as $ajax_event => $nopriv ) {
106
-            add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
107
-            add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
105
+        foreach ($ajax_events as $ajax_event => $nopriv) {
106
+            add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
107
+            add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
108 108
 
109
-            if ( $nopriv ) {
110
-                add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
111
-                add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
112
-                add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) );
109
+            if ($nopriv) {
110
+                add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
111
+                add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
112
+                add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event));
113 113
             }
114 114
         }
115 115
     }
116 116
     
117 117
     public static function add_note() {
118
-        check_ajax_referer( 'add-invoice-note', '_nonce' );
118
+        check_ajax_referer('add-invoice-note', '_nonce');
119 119
 
120
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
120
+        if (!wpinv_current_user_can_manage_invoicing()) {
121 121
             die(-1);
122 122
         }
123 123
 
124
-        $post_id   = absint( $_POST['post_id'] );
125
-        $note      = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) );
126
-        $note_type = sanitize_text_field( $_POST['note_type'] );
124
+        $post_id   = absint($_POST['post_id']);
125
+        $note      = wp_kses_post(trim(stripslashes($_POST['note'])));
126
+        $note_type = sanitize_text_field($_POST['note_type']);
127 127
 
128 128
         $is_customer_note = $note_type == 'customer' ? 1 : 0;
129 129
 
130
-        if ( $post_id > 0 ) {
131
-            $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note );
130
+        if ($post_id > 0) {
131
+            $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note);
132 132
 
133
-            if ( $note_id > 0 && !is_wp_error( $note_id ) ) {
134
-                wpinv_get_invoice_note_line_item( $note_id );
133
+            if ($note_id > 0 && !is_wp_error($note_id)) {
134
+                wpinv_get_invoice_note_line_item($note_id);
135 135
             }
136 136
         }
137 137
 
@@ -139,16 +139,16 @@  discard block
 block discarded – undo
139 139
     }
140 140
 
141 141
     public static function delete_note() {
142
-        check_ajax_referer( 'delete-invoice-note', '_nonce' );
142
+        check_ajax_referer('delete-invoice-note', '_nonce');
143 143
 
144
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
144
+        if (!wpinv_current_user_can_manage_invoicing()) {
145 145
             die(-1);
146 146
         }
147 147
 
148
-        $note_id = (int)$_POST['note_id'];
148
+        $note_id = (int) $_POST['note_id'];
149 149
 
150
-        if ( $note_id > 0 ) {
151
-            wp_delete_comment( $note_id, true );
150
+        if ($note_id > 0) {
151
+            wp_delete_comment($note_id, true);
152 152
         }
153 153
 
154 154
         die();
@@ -166,34 +166,34 @@  discard block
 block discarded – undo
166 166
     public static function get_billing_details() {
167 167
 
168 168
         // Verify nonce.
169
-        check_ajax_referer( 'wpinv-nonce' );
169
+        check_ajax_referer('wpinv-nonce');
170 170
 
171 171
         // Can the user manage the plugin?
172
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
172
+        if (!wpinv_current_user_can_manage_invoicing()) {
173 173
             die(-1);
174 174
         }
175 175
 
176 176
         // Do we have a user id?
177 177
         $user_id = $_GET['user_id'];
178 178
 
179
-        if ( empty( $user_id ) || ! is_numeric( $user_id ) ) {
179
+        if (empty($user_id) || !is_numeric($user_id)) {
180 180
             die(-1);
181 181
         }
182 182
 
183 183
         // Fetch the billing details.
184
-        $billing_details    = wpinv_get_user_address( $user_id );
185
-        $billing_details    = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id );
184
+        $billing_details    = wpinv_get_user_address($user_id);
185
+        $billing_details    = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id);
186 186
 
187 187
         // unset the user id and email.
188
-        $to_ignore = array( 'user_id', 'email' );
188
+        $to_ignore = array('user_id', 'email');
189 189
 
190
-        foreach ( $to_ignore as $key ) {
191
-            if ( isset( $billing_details[ $key ] ) ) {
192
-                unset( $billing_details[ $key ] );
190
+        foreach ($to_ignore as $key) {
191
+            if (isset($billing_details[$key])) {
192
+                unset($billing_details[$key]);
193 193
             }
194 194
         }
195 195
 
196
-        wp_send_json_success( $billing_details );
196
+        wp_send_json_success($billing_details);
197 197
 
198 198
     }
199 199
 
@@ -203,47 +203,47 @@  discard block
 block discarded – undo
203 203
     public static function check_new_user_email() {
204 204
 
205 205
         // Verify nonce.
206
-        check_ajax_referer( 'wpinv-nonce' );
206
+        check_ajax_referer('wpinv-nonce');
207 207
 
208 208
         // Can the user manage the plugin?
209
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
209
+        if (!wpinv_current_user_can_manage_invoicing()) {
210 210
             die(-1);
211 211
         }
212 212
 
213 213
         // We need an email address.
214
-        if ( empty( $_GET['email'] ) ) {
215
-            _e( "Provide the new user's email address", 'invoicing' );
214
+        if (empty($_GET['email'])) {
215
+            _e("Provide the new user's email address", 'invoicing');
216 216
             exit;
217 217
         }
218 218
 
219 219
         // Ensure the email is valid.
220
-        $email = sanitize_text_field( $_GET['email'] );
221
-        if ( ! is_email( $email ) ) {
222
-            _e( 'Invalid email address', 'invoicing' );
220
+        $email = sanitize_text_field($_GET['email']);
221
+        if (!is_email($email)) {
222
+            _e('Invalid email address', 'invoicing');
223 223
             exit;
224 224
         }
225 225
 
226 226
         // And it does not exist.
227
-        if ( email_exists( $email ) ) {
228
-            _e( 'A user with this email address already exists', 'invoicing' );
227
+        if (email_exists($email)) {
228
+            _e('A user with this email address already exists', 'invoicing');
229 229
             exit;
230 230
         }
231 231
 
232
-        wp_send_json_success( true );
232
+        wp_send_json_success(true);
233 233
     }
234 234
     
235 235
     public static function run_tool() {
236
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
237
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
236
+        check_ajax_referer('wpinv-nonce', '_nonce');
237
+        if (!wpinv_current_user_can_manage_invoicing()) {
238 238
             die(-1);
239 239
         }
240 240
         
241
-        $tool = sanitize_text_field( $_POST['tool'] );
241
+        $tool = sanitize_text_field($_POST['tool']);
242 242
         
243
-        do_action( 'wpinv_run_tool' );
243
+        do_action('wpinv_run_tool');
244 244
         
245
-        if ( !empty( $tool ) ) {
246
-            do_action( 'wpinv_tool_' . $tool );
245
+        if (!empty($tool)) {
246
+            do_action('wpinv_tool_' . $tool);
247 247
         }
248 248
     }
249 249
 
@@ -253,27 +253,27 @@  discard block
 block discarded – undo
253 253
     public static function get_payment_form() {
254 254
 
255 255
         // Check nonce.
256
-        check_ajax_referer( 'getpaid_form_nonce' );
256
+        check_ajax_referer('getpaid_form_nonce');
257 257
 
258 258
         // Is the request set up correctly?
259
-		if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
259
+		if (empty($_GET['form']) && empty($_GET['item'])) {
260 260
 			echo aui()->alert(
261 261
 				array(
262 262
 					'type'    => 'warning',
263
-					'content' => __( 'No payment form or item provided', 'invoicing' ),
263
+					'content' => __('No payment form or item provided', 'invoicing'),
264 264
 				)
265 265
             );
266 266
             exit;
267 267
         }
268 268
 
269 269
         // Payment form or button?
270
-		if ( ! empty( $_GET['form'] ) ) {
271
-            getpaid_display_payment_form( $_GET['form'] );
272
-		} else if( ! empty( $_GET['invoice'] ) ) {
273
-		    getpaid_display_invoice_payment_form( $_GET['invoice'] );
270
+		if (!empty($_GET['form'])) {
271
+            getpaid_display_payment_form($_GET['form']);
272
+		} else if (!empty($_GET['invoice'])) {
273
+		    getpaid_display_invoice_payment_form($_GET['invoice']);
274 274
         } else {
275
-			$items = getpaid_convert_items_to_array( $_GET['item'] );
276
-		    getpaid_display_item_payment_form( $items );
275
+			$items = getpaid_convert_items_to_array($_GET['item']);
276
+		    getpaid_display_item_payment_form($items);
277 277
         }
278 278
 
279 279
         exit;
@@ -288,17 +288,17 @@  discard block
 block discarded – undo
288 288
     public static function payment_form() {
289 289
 
290 290
         // Check nonce.
291
-        check_ajax_referer( 'getpaid_form_nonce' );
291
+        check_ajax_referer('getpaid_form_nonce');
292 292
 
293 293
         // ... form fields...
294
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
295
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
294
+        if (empty($_POST['getpaid_payment_form_submission'])) {
295
+            _e('Error: Reload the page and try again.', 'invoicing');
296 296
             exit;
297 297
         }
298 298
 
299 299
         // Process the payment form.
300
-        $checkout_class = apply_filters( 'getpaid_checkout_class', 'GetPaid_Checkout' );
301
-        $checkout       = new $checkout_class( new GetPaid_Payment_Form_Submission() );
300
+        $checkout_class = apply_filters('getpaid_checkout_class', 'GetPaid_Checkout');
301
+        $checkout       = new $checkout_class(new GetPaid_Payment_Form_Submission());
302 302
         $checkout->process_checkout();
303 303
 
304 304
         exit;
@@ -311,54 +311,54 @@  discard block
 block discarded – undo
311 311
      */
312 312
     public static function get_payment_form_states_field() {
313 313
 
314
-        if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) {
314
+        if (empty($_GET['country']) || empty($_GET['form'])) {
315 315
             exit;
316 316
         }
317 317
 
318
-        $elements = getpaid_get_payment_form_elements( $_GET['form'] );
318
+        $elements = getpaid_get_payment_form_elements($_GET['form']);
319 319
 
320
-        if ( empty( $elements ) ) {
320
+        if (empty($elements)) {
321 321
             exit;
322 322
         }
323 323
 
324 324
         $address_fields = array();
325
-        foreach ( $elements as $element ) {
326
-            if ( 'address' === $element['type'] ) {
325
+        foreach ($elements as $element) {
326
+            if ('address' === $element['type']) {
327 327
                 $address_fields = $element;
328 328
                 break;
329 329
             }
330 330
         }
331 331
 
332
-        if ( empty( $address_fields ) ) {
332
+        if (empty($address_fields)) {
333 333
             exit;
334 334
         }
335 335
 
336
-        foreach ( $address_fields['fields'] as $address_field ) {
336
+        foreach ($address_fields['fields'] as $address_field) {
337 337
 
338
-            if ( 'wpinv_state' == $address_field['name'] ) {
338
+            if ('wpinv_state' == $address_field['name']) {
339 339
 
340
-                $wrap_class  = getpaid_get_form_element_grid_class( $address_field );
341
-                $wrap_class  = esc_attr( "$wrap_class getpaid-address-field-wrapper" );
342
-                $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] );
343
-                $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] );
344
-                $value       = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_state', true ) : '';
345
-                $label       = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] );
340
+                $wrap_class  = getpaid_get_form_element_grid_class($address_field);
341
+                $wrap_class  = esc_attr("$wrap_class getpaid-address-field-wrapper");
342
+                $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']);
343
+                $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']);
344
+                $value       = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_state', true) : '';
345
+                $label       = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']);
346 346
 
347
-                if ( ! empty( $address_field['required'] ) ) {
347
+                if (!empty($address_field['required'])) {
348 348
                     $label .= "<span class='text-danger'> *</span>";
349 349
                 }
350 350
 
351
-                $html = getpaid_get_states_select_markup (
352
-                    sanitize_text_field( $_GET['country'] ),
351
+                $html = getpaid_get_states_select_markup(
352
+                    sanitize_text_field($_GET['country']),
353 353
                     $value,
354 354
                     $placeholder,
355 355
                     $label,
356 356
                     $description,
357
-                    ! empty( $address_field['required'] ),
357
+                    !empty($address_field['required']),
358 358
                     $wrap_class
359 359
                 );
360 360
 
361
-                wp_send_json_success( $html );
361
+                wp_send_json_success($html);
362 362
                 exit;
363 363
 
364 364
             }
@@ -374,56 +374,56 @@  discard block
 block discarded – undo
374 374
     public static function recalculate_invoice_totals() {
375 375
 
376 376
         // Verify nonce.
377
-        check_ajax_referer( 'wpinv-nonce' );
377
+        check_ajax_referer('wpinv-nonce');
378 378
 
379
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
379
+        if (!wpinv_current_user_can_manage_invoicing()) {
380 380
             exit;
381 381
         }
382 382
 
383 383
         // We need an invoice.
384
-        if ( empty( $_POST['post_id'] ) ) {
384
+        if (empty($_POST['post_id'])) {
385 385
             exit;
386 386
         }
387 387
 
388 388
         // Fetch the invoice.
389
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
389
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
390 390
 
391 391
         // Ensure it exists.
392
-        if ( ! $invoice->get_id() ) {
392
+        if (!$invoice->get_id()) {
393 393
             exit;
394 394
         }
395 395
 
396 396
         // Maybe set the country, state, currency.
397
-        foreach ( array( 'country', 'state', 'currency' ) as $key ) {
398
-            if ( isset( $_POST[ $key ] ) ) {
397
+        foreach (array('country', 'state', 'currency') as $key) {
398
+            if (isset($_POST[$key])) {
399 399
                 $method = "set_$key";
400
-                $invoice->$method( $_POST[ $key ] );
400
+                $invoice->$method($_POST[$key]);
401 401
             }
402 402
         }
403 403
 
404 404
         // Maybe disable taxes.
405
-        $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) );
405
+        $invoice->set_disable_taxes(!empty($_POST['taxes']));
406 406
 
407 407
         // Recalculate totals.
408 408
         $invoice->recalculate_total();
409 409
 
410
-        $total = wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() );
410
+        $total = wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency());
411 411
 
412
-        if ( $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) {
413
-            $recurring_total = wpinv_price( wpinv_format_amount( $invoice->get_recurring_total() ), $invoice->get_currency() );
414
-            $total          .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>';
412
+        if ($invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) {
413
+            $recurring_total = wpinv_price(wpinv_format_amount($invoice->get_recurring_total()), $invoice->get_currency());
414
+            $total          .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>';
415 415
         }
416 416
 
417 417
         $totals = array(
418
-            'subtotal' => wpinv_price( wpinv_format_amount( $invoice->get_subtotal() ), $invoice->get_currency() ),
419
-            'discount' => wpinv_price( wpinv_format_amount( $invoice->get_total_discount() ), $invoice->get_currency() ),
420
-            'tax'      => wpinv_price( wpinv_format_amount( $invoice->get_total_tax() ), $invoice->get_currency() ),
418
+            'subtotal' => wpinv_price(wpinv_format_amount($invoice->get_subtotal()), $invoice->get_currency()),
419
+            'discount' => wpinv_price(wpinv_format_amount($invoice->get_total_discount()), $invoice->get_currency()),
420
+            'tax'      => wpinv_price(wpinv_format_amount($invoice->get_total_tax()), $invoice->get_currency()),
421 421
             'total'    => $total,
422 422
         );
423 423
 
424
-        $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice );
424
+        $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice);
425 425
 
426
-        wp_send_json_success( compact( 'totals' ) );
426
+        wp_send_json_success(compact('totals'));
427 427
     }
428 428
 
429 429
     /**
@@ -432,33 +432,33 @@  discard block
 block discarded – undo
432 432
     public static function get_invoice_items() {
433 433
 
434 434
         // Verify nonce.
435
-        check_ajax_referer( 'wpinv-nonce' );
435
+        check_ajax_referer('wpinv-nonce');
436 436
 
437
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
437
+        if (!wpinv_current_user_can_manage_invoicing()) {
438 438
             exit;
439 439
         }
440 440
 
441 441
         // We need an invoice and items.
442
-        if ( empty( $_POST['post_id'] ) ) {
442
+        if (empty($_POST['post_id'])) {
443 443
             exit;
444 444
         }
445 445
 
446 446
         // Fetch the invoice.
447
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
447
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
448 448
 
449 449
         // Ensure it exists.
450
-        if ( ! $invoice->get_id() ) {
450
+        if (!$invoice->get_id()) {
451 451
             exit;
452 452
         }
453 453
 
454 454
         // Return an array of invoice items.
455 455
         $items = array();
456 456
 
457
-        foreach ( $invoice->get_items() as $item_id => $item ) {
458
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency()  );
457
+        foreach ($invoice->get_items() as $item_id => $item) {
458
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
459 459
         }
460 460
 
461
-        wp_send_json_success( compact( 'items' ) );
461
+        wp_send_json_success(compact('items'));
462 462
     }
463 463
 
464 464
     /**
@@ -467,50 +467,50 @@  discard block
 block discarded – undo
467 467
     public static function edit_invoice_item() {
468 468
 
469 469
         // Verify nonce.
470
-        check_ajax_referer( 'wpinv-nonce' );
470
+        check_ajax_referer('wpinv-nonce');
471 471
 
472
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
472
+        if (!wpinv_current_user_can_manage_invoicing()) {
473 473
             exit;
474 474
         }
475 475
 
476 476
         // We need an invoice and item details.
477
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) {
477
+        if (empty($_POST['post_id']) || empty($_POST['data'])) {
478 478
             exit;
479 479
         }
480 480
 
481 481
         // Fetch the invoice.
482
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
482
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
483 483
 
484 484
         // Ensure it exists and its not been paid for.
485
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
485
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
486 486
             exit;
487 487
         }
488 488
 
489 489
         // Format the data.
490
-        $data = wp_list_pluck( $_POST['data'], 'value', 'field' );
490
+        $data = wp_list_pluck($_POST['data'], 'value', 'field');
491 491
 
492 492
         // Ensure that we have an item id.
493
-        if ( empty( $data['id'] ) ) {
493
+        if (empty($data['id'])) {
494 494
             exit;
495 495
         }
496 496
 
497 497
         // Abort if the invoice does not have the specified item.
498
-        $item = $invoice->get_item( (int) $data['id'] );
498
+        $item = $invoice->get_item((int) $data['id']);
499 499
 
500
-        if ( empty( $item ) ) {
500
+        if (empty($item)) {
501 501
             exit;
502 502
         }
503 503
 
504 504
         // Update the item.
505
-        $item->set_price( $data['price'] );
506
-        $item->set_name( $data['name'] );
507
-        $item->set_description( $data['description'] );
508
-        $item->set_quantity( $data['quantity'] );
505
+        $item->set_price($data['price']);
506
+        $item->set_name($data['name']);
507
+        $item->set_description($data['description']);
508
+        $item->set_quantity($data['quantity']);
509 509
 
510 510
         // Add it to the invoice.
511
-        $error = $invoice->add_item( $item );
511
+        $error = $invoice->add_item($item);
512 512
         $alert = false;
513
-        if ( is_wp_error( $error ) ) {
513
+        if (is_wp_error($error)) {
514 514
             $alert = $error->get_error_message();
515 515
         }
516 516
 
@@ -523,11 +523,11 @@  discard block
 block discarded – undo
523 523
         // Return an array of invoice items.
524 524
         $items = array();
525 525
 
526
-        foreach ( $invoice->get_items() as $item_id => $item ) {
527
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency()  );
526
+        foreach ($invoice->get_items() as $item_id => $item) {
527
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
528 528
         }
529 529
 
530
-        wp_send_json_success( compact( 'items', 'alert' ) );
530
+        wp_send_json_success(compact('items', 'alert'));
531 531
     }
532 532
 
533 533
     /**
@@ -536,33 +536,33 @@  discard block
 block discarded – undo
536 536
     public static function remove_invoice_item() {
537 537
 
538 538
         // Verify nonce.
539
-        check_ajax_referer( 'wpinv-nonce' );
539
+        check_ajax_referer('wpinv-nonce');
540 540
 
541
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
541
+        if (!wpinv_current_user_can_manage_invoicing()) {
542 542
             exit;
543 543
         }
544 544
 
545 545
         // We need an invoice and an item.
546
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) {
546
+        if (empty($_POST['post_id']) || empty($_POST['item_id'])) {
547 547
             exit;
548 548
         }
549 549
 
550 550
         // Fetch the invoice.
551
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
551
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
552 552
 
553 553
         // Ensure it exists and its not been paid for.
554
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
554
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
555 555
             exit;
556 556
         }
557 557
 
558 558
         // Abort if the invoice does not have the specified item.
559
-        $item = $invoice->get_item( (int) $_POST['item_id'] );
559
+        $item = $invoice->get_item((int) $_POST['item_id']);
560 560
 
561
-        if ( empty( $item ) ) {
561
+        if (empty($item)) {
562 562
             exit;
563 563
         }
564 564
 
565
-        $invoice->remove_item( (int) $_POST['item_id'] );
565
+        $invoice->remove_item((int) $_POST['item_id']);
566 566
 
567 567
         // Update totals.
568 568
         $invoice->recalculate_total();
@@ -573,11 +573,11 @@  discard block
 block discarded – undo
573 573
         // Return an array of invoice items.
574 574
         $items = array();
575 575
 
576
-        foreach ( $invoice->get_items() as $item_id => $item ) {
577
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency()  );
576
+        foreach ($invoice->get_items() as $item_id => $item) {
577
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
578 578
         }
579 579
 
580
-        wp_send_json_success( compact( 'items' ) );
580
+        wp_send_json_success(compact('items'));
581 581
     }
582 582
 
583 583
     /**
@@ -586,39 +586,39 @@  discard block
 block discarded – undo
586 586
     public static function add_invoice_items() {
587 587
 
588 588
         // Verify nonce.
589
-        check_ajax_referer( 'wpinv-nonce' );
589
+        check_ajax_referer('wpinv-nonce');
590 590
 
591
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
591
+        if (!wpinv_current_user_can_manage_invoicing()) {
592 592
             exit;
593 593
         }
594 594
 
595 595
         // We need an invoice and items.
596
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) {
596
+        if (empty($_POST['post_id']) || empty($_POST['items'])) {
597 597
             exit;
598 598
         }
599 599
 
600 600
         // Fetch the invoice.
601
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
601
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
602 602
         $alert   = false;
603 603
 
604 604
         // Ensure it exists and its not been paid for.
605
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
605
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
606 606
             exit;
607 607
         }
608 608
 
609 609
         // Add the items.
610
-        foreach ( $_POST['items'] as $data ) {
610
+        foreach ($_POST['items'] as $data) {
611 611
 
612
-            $item = new GetPaid_Form_Item( $data[ 'id' ] );
612
+            $item = new GetPaid_Form_Item($data['id']);
613 613
 
614
-            if ( is_numeric( $data[ 'qty' ] ) && (int) $data[ 'qty' ] > 0 ) {
615
-                $item->set_quantity( $data[ 'qty' ] );
614
+            if (is_numeric($data['qty']) && (int) $data['qty'] > 0) {
615
+                $item->set_quantity($data['qty']);
616 616
             }
617 617
 
618
-            if ( $item->get_id() > 0 ) {
619
-                $error = $invoice->add_item( $item );
618
+            if ($item->get_id() > 0) {
619
+                $error = $invoice->add_item($item);
620 620
 
621
-                if ( is_wp_error( $error ) ) {
621
+                if (is_wp_error($error)) {
622 622
                     $alert = $error->get_error_message();
623 623
                 }
624 624
 
@@ -633,11 +633,11 @@  discard block
 block discarded – undo
633 633
         // Return an array of invoice items.
634 634
         $items = array();
635 635
 
636
-        foreach ( $invoice->get_items() as $item_id => $item ) {
637
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() );
636
+        foreach ($invoice->get_items() as $item_id => $item) {
637
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
638 638
         }
639 639
 
640
-        wp_send_json_success( compact( 'items', 'alert' ) );
640
+        wp_send_json_success(compact('items', 'alert'));
641 641
     }
642 642
 
643 643
     /**
@@ -646,15 +646,15 @@  discard block
 block discarded – undo
646 646
     public static function get_invoicing_items() {
647 647
 
648 648
         // Verify nonce.
649
-        check_ajax_referer( 'wpinv-nonce' );
649
+        check_ajax_referer('wpinv-nonce');
650 650
 
651
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
651
+        if (!wpinv_current_user_can_manage_invoicing()) {
652 652
             exit;
653 653
         }
654 654
 
655 655
         // We need a search term.
656
-        if ( empty( $_GET['search'] ) ) {
657
-            wp_send_json_success( array() );
656
+        if (empty($_GET['search'])) {
657
+            wp_send_json_success(array());
658 658
         }
659 659
 
660 660
         // Retrieve items.
@@ -663,8 +663,8 @@  discard block
 block discarded – undo
663 663
             'orderby'        => 'title',
664 664
             'order'          => 'ASC',
665 665
             'posts_per_page' => -1,
666
-            'post_status'    => array( 'publish' ),
667
-            's'              => trim( $_GET['search'] ),
666
+            'post_status'    => array('publish'),
667
+            's'              => trim($_GET['search']),
668 668
             'meta_query'     => array(
669 669
                 array(
670 670
                     'key'       => '_wpinv_type',
@@ -674,22 +674,22 @@  discard block
 block discarded – undo
674 674
             )
675 675
         );
676 676
 
677
-        $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) );
677
+        $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args));
678 678
         $data  = array();
679 679
 
680 680
 
681
-        $is_payment_form = ( ! empty( $_GET['post_id'] ) && 'wpi_payment_form' == get_post_type( $_GET['post_id'] ) );
681
+        $is_payment_form = (!empty($_GET['post_id']) && 'wpi_payment_form' == get_post_type($_GET['post_id']));
682 682
 
683
-        foreach ( $items as $item ) {
684
-            $item      = new GetPaid_Form_Item( $item );
683
+        foreach ($items as $item) {
684
+            $item = new GetPaid_Form_Item($item);
685 685
             $data[] = array(
686 686
                 'id'        => (int) $item->get_id(),
687
-                'text'      => strip_tags( $item->get_name() ),
688
-                'form_data' => $is_payment_form ? $item->prepare_data_for_use( false ) : '',
687
+                'text'      => strip_tags($item->get_name()),
688
+                'form_data' => $is_payment_form ? $item->prepare_data_for_use(false) : '',
689 689
             );
690 690
         }
691 691
 
692
-        wp_send_json_success( $data );
692
+        wp_send_json_success($data);
693 693
 
694 694
     }
695 695
 
@@ -699,24 +699,24 @@  discard block
 block discarded – undo
699 699
     public static function get_aui_states_field() {
700 700
 
701 701
         // Verify nonce.
702
-        check_ajax_referer( 'wpinv-nonce' );
702
+        check_ajax_referer('wpinv-nonce');
703 703
 
704 704
         // We need a country.
705
-        if ( empty( $_GET['country'] ) ) {
705
+        if (empty($_GET['country'])) {
706 706
             exit;
707 707
         }
708 708
 
709
-        $states = wpinv_get_country_states( trim( $_GET['country'] ) );
710
-        $state  = isset( $_GET['state'] ) ? trim( $_GET['state'] ) : wpinv_get_default_state();
709
+        $states = wpinv_get_country_states(trim($_GET['country']));
710
+        $state  = isset($_GET['state']) ? trim($_GET['state']) : wpinv_get_default_state();
711 711
 
712
-        if ( empty( $states ) ) {
712
+        if (empty($states)) {
713 713
 
714 714
             $html = aui()->input(
715 715
                 array(
716 716
                     'type'        => 'text',
717 717
                     'id'          => 'wpinv_state',
718 718
                     'name'        => 'wpinv_state',
719
-                    'label'       => __( 'State', 'invoicing' ),
719
+                    'label'       => __('State', 'invoicing'),
720 720
                     'label_type'  => 'vertical',
721 721
                     'placeholder' => 'Liège',
722 722
                     'class'       => 'form-control-sm',
@@ -730,9 +730,9 @@  discard block
 block discarded – undo
730 730
                 array(
731 731
                     'id'          => 'wpinv_state',
732 732
                     'name'        => 'wpinv_state',
733
-                    'label'       => __( 'State', 'invoicing' ),
733
+                    'label'       => __('State', 'invoicing'),
734 734
                     'label_type'  => 'vertical',
735
-                    'placeholder' => __( 'Select a state', 'invoicing' ),
735
+                    'placeholder' => __('Select a state', 'invoicing'),
736 736
                     'class'       => 'form-control-sm',
737 737
                     'value'       => $state,
738 738
                     'options'     => $states,
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
         wp_send_json_success(
747 747
             array(
748 748
                 'html'   => $html,
749
-                'select' => ! empty ( $states )
749
+                'select' => !empty ($states)
750 750
             )
751 751
         );
752 752
 
@@ -760,46 +760,46 @@  discard block
 block discarded – undo
760 760
     public static function ip_geolocation() {
761 761
 
762 762
         // Check nonce.
763
-        check_ajax_referer( 'getpaid-ip-location' );
763
+        check_ajax_referer('getpaid-ip-location');
764 764
 
765 765
         // IP address.
766
-        if ( empty( $_GET['ip'] ) || ! rest_is_ip_address( $_GET['ip'] ) ) {
767
-            _e( 'Invalid IP Address.', 'invoicing' );
766
+        if (empty($_GET['ip']) || !rest_is_ip_address($_GET['ip'])) {
767
+            _e('Invalid IP Address.', 'invoicing');
768 768
             exit;
769 769
         }
770 770
 
771 771
         // Retrieve location info.
772
-        $location = getpaid_geolocate_ip_address( $_GET['ip'] );
772
+        $location = getpaid_geolocate_ip_address($_GET['ip']);
773 773
 
774
-        if ( empty( $location ) ) {
775
-            _e( 'Unable to find geolocation for the IP Address.', 'invoicing' );
774
+        if (empty($location)) {
775
+            _e('Unable to find geolocation for the IP Address.', 'invoicing');
776 776
             exit;
777 777
         }
778 778
 
779 779
         // Sorry.
780
-        extract( $location );
780
+        extract($location);
781 781
 
782 782
         // Prepare the address.
783 783
         $content = '';
784 784
 
785
-        if ( ! empty( $location['city'] ) ) {
786
-            $content .=  $location['city']  . ', ';
785
+        if (!empty($location['city'])) {
786
+            $content .= $location['city'] . ', ';
787 787
         }
788 788
         
789
-        if ( ! empty( $location['region'] ) ) {
790
-            $content .=  $location['region']  . ', ';
789
+        if (!empty($location['region'])) {
790
+            $content .= $location['region'] . ', ';
791 791
         }
792 792
         
793
-        $content .=  $location['country'] . ' (' . $location['iso'] . ')';
793
+        $content .= $location['country'] . ' (' . $location['iso'] . ')';
794 794
 
795 795
         $location['address'] = $content;
796 796
 
797
-        $content  = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $content ) . '</p>';
798
-        $content .= '<p>'. $location['credit'] . '</p>';
797
+        $content  = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $content) . '</p>';
798
+        $content .= '<p>' . $location['credit'] . '</p>';
799 799
 
800 800
         $location['content'] = $content;
801 801
 
802
-        wpinv_get_template( 'geolocation.php', $location );
802
+        wpinv_get_template('geolocation.php', $location);
803 803
 
804 804
         exit;
805 805
     }
@@ -812,11 +812,11 @@  discard block
 block discarded – undo
812 812
     public static function payment_form_refresh_prices() {
813 813
 
814 814
         // Check nonce.
815
-        check_ajax_referer( 'getpaid_form_nonce' );
815
+        check_ajax_referer('getpaid_form_nonce');
816 816
 
817 817
         // ... form fields...
818
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
819
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
818
+        if (empty($_POST['getpaid_payment_form_submission'])) {
819
+            _e('Error: Reload the page and try again.', 'invoicing');
820 820
             exit;
821 821
         }
822 822
 
@@ -824,18 +824,18 @@  discard block
 block discarded – undo
824 824
         $submission = new GetPaid_Payment_Form_Submission();
825 825
 
826 826
         // Do we have an error?
827
-        if ( ! empty( $submission->last_error ) ) {
827
+        if (!empty($submission->last_error)) {
828 828
             echo $submission->last_error;
829 829
             exit;
830 830
         }
831 831
 
832 832
         // Prepare the response.
833
-        $response = new GetPaid_Payment_Form_Submission_Refresh_Prices( $submission );
833
+        $response = new GetPaid_Payment_Form_Submission_Refresh_Prices($submission);
834 834
         
835 835
         // Filter the response.
836
-        $response = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $response->response, $submission );
836
+        $response = apply_filters('getpaid_payment_form_ajax_refresh_prices', $response->response, $submission);
837 837
 
838
-        wp_send_json_success( $response );
838
+        wp_send_json_success($response);
839 839
     }
840 840
 
841 841
 }
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 1 patch
Spacing   +479 added lines, -479 removed lines patch added patch discarded remove patch
@@ -4,99 +4,99 @@  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
  * Displays an invoice.
11 11
  * 
12 12
  * @param WPInv_Invoice $invoice.
13 13
  */
14
-function getpaid_invoice( $invoice ) {
15
-    if ( ! empty( $invoice ) ) {
16
-        wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) );
14
+function getpaid_invoice($invoice) {
15
+    if (!empty($invoice)) {
16
+        wpinv_get_template('invoice/invoice.php', compact('invoice'));
17 17
     }
18 18
 }
19
-add_action( 'getpaid_invoice', 'getpaid_invoice', 10 );
19
+add_action('getpaid_invoice', 'getpaid_invoice', 10);
20 20
 
21 21
 /**
22 22
  * Displays the invoice footer.
23 23
  */
24
-function getpaid_invoice_footer( $invoice ) {
25
-    if ( ! empty( $invoice ) ) {
26
-        wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) );
24
+function getpaid_invoice_footer($invoice) {
25
+    if (!empty($invoice)) {
26
+        wpinv_get_template('invoice/footer.php', compact('invoice'));
27 27
     }
28 28
 }
29
-add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 );
29
+add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10);
30 30
 
31 31
 /**
32 32
  * Displays the invoice top bar.
33 33
  */
34
-function getpaid_invoice_header( $invoice ) {
35
-    if ( ! empty( $invoice ) ) {
36
-        wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) );
34
+function getpaid_invoice_header($invoice) {
35
+    if (!empty($invoice)) {
36
+        wpinv_get_template('invoice/header.php', compact('invoice'));
37 37
     }
38 38
 }
39
-add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 );
39
+add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10);
40 40
 
41 41
 /**
42 42
  * Displays actions on the left side of the header.
43 43
  */
44
-function getpaid_invoice_header_left_actions( $invoice ) {
45
-    if ( ! empty( $invoice ) ) {
46
-        wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) );
44
+function getpaid_invoice_header_left_actions($invoice) {
45
+    if (!empty($invoice)) {
46
+        wpinv_get_template('invoice/header-left-actions.php', compact('invoice'));
47 47
     }
48 48
 }
49
-add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 );
49
+add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10);
50 50
 
51 51
 /**
52 52
  * Displays actions on the right side of the invoice top bar.
53 53
  */
54
-function getpaid_invoice_header_right_actions( $invoice ) {
55
-    if ( ! empty( $invoice ) ) {
56
-        wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) );
54
+function getpaid_invoice_header_right_actions($invoice) {
55
+    if (!empty($invoice)) {
56
+        wpinv_get_template('invoice/header-right-actions.php', compact('invoice'));
57 57
     }
58 58
 }
59
-add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 );
59
+add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10);
60 60
 
61 61
 /**
62 62
  * Displays the invoice title, watermark, logo etc.
63 63
  */
64
-function getpaid_invoice_details_top( $invoice ) {
65
-    if ( ! empty( $invoice ) ) {
66
-        wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) );
64
+function getpaid_invoice_details_top($invoice) {
65
+    if (!empty($invoice)) {
66
+        wpinv_get_template('invoice/details-top.php', compact('invoice'));
67 67
     }
68 68
 }
69
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 );
69
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10);
70 70
 
71 71
 /**
72 72
  * Displays the company logo.
73 73
  */
74
-function getpaid_invoice_logo( $invoice ) {
75
-    if ( ! empty( $invoice ) ) {
76
-        wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) );
74
+function getpaid_invoice_logo($invoice) {
75
+    if (!empty($invoice)) {
76
+        wpinv_get_template('invoice/invoice-logo.php', compact('invoice'));
77 77
     }
78 78
 }
79
-add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' );
79
+add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo');
80 80
 
81 81
 /**
82 82
  * Displays the type of invoice.
83 83
  */
84
-function getpaid_invoice_type( $invoice ) {
85
-    if ( ! empty( $invoice ) ) {
86
-        wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) );
84
+function getpaid_invoice_type($invoice) {
85
+    if (!empty($invoice)) {
86
+        wpinv_get_template('invoice/invoice-type.php', compact('invoice'));
87 87
     }
88 88
 }
89
-add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' );
89
+add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type');
90 90
 
91 91
 /**
92 92
  * Displays the invoice details.
93 93
  */
94
-function getpaid_invoice_details_main( $invoice ) {
95
-    if ( ! empty( $invoice ) ) {
96
-        wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) );
94
+function getpaid_invoice_details_main($invoice) {
95
+    if (!empty($invoice)) {
96
+        wpinv_get_template('invoice/details.php', compact('invoice'));
97 97
     }
98 98
 }
99
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 );
99
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50);
100 100
 
101 101
 /**
102 102
  * Returns a path to the templates directory.
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
126 126
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
127 127
  */
128
-function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
129
-    return getpaid_template()->display_template( $template_name, $args, $template_path, $default_path );
128
+function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
129
+    return getpaid_template()->display_template($template_name, $args, $template_path, $default_path);
130 130
 }
131 131
 
132 132
 /**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
140 140
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
141 141
  */
142
-function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
143
-	return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path );
142
+function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') {
143
+	return getpaid_template()->get_template($template_name, $args, $template_path, $default_path);
144 144
 }
145 145
 
146 146
 /**
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
  * @return string
150 150
  */
151 151
 function wpinv_template_path() {
152
-    return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() );
152
+    return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name());
153 153
 }
154 154
 
155 155
 /**
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
  * @return string
159 159
  */
160 160
 function wpinv_get_theme_template_dir_name() {
161
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
161
+	return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing'));
162 162
 }
163 163
 
164 164
 /**
@@ -170,56 +170,56 @@  discard block
 block discarded – undo
170 170
  * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'.
171 171
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
172 172
  */
173
-function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
174
-    return getpaid_template()->locate_template( $template_name, $template_path, $default_path );
173
+function wpinv_locate_template($template_name, $template_path = '', $default_path = '') {
174
+    return getpaid_template()->locate_template($template_name, $template_path, $default_path);
175 175
 }
176 176
 
177
-function wpinv_get_template_part( $slug, $name = null, $load = true ) {
178
-	do_action( 'get_template_part_' . $slug, $slug, $name );
177
+function wpinv_get_template_part($slug, $name = null, $load = true) {
178
+	do_action('get_template_part_' . $slug, $slug, $name);
179 179
 
180 180
 	// Setup possible parts
181 181
 	$templates = array();
182
-	if ( isset( $name ) )
182
+	if (isset($name))
183 183
 		$templates[] = $slug . '-' . $name . '.php';
184 184
 	$templates[] = $slug . '.php';
185 185
 
186 186
 	// Allow template parts to be filtered
187
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
187
+	$templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name);
188 188
 
189 189
 	// Return the part that is found
190
-	return wpinv_locate_tmpl( $templates, $load, false );
190
+	return wpinv_locate_tmpl($templates, $load, false);
191 191
 }
192 192
 
193
-function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
193
+function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) {
194 194
 	// No file found yet
195 195
 	$located = false;
196 196
 
197 197
 	// Try to find a template file
198
-	foreach ( (array)$template_names as $template_name ) {
198
+	foreach ((array) $template_names as $template_name) {
199 199
 
200 200
 		// Continue if template is empty
201
-		if ( empty( $template_name ) )
201
+		if (empty($template_name))
202 202
 			continue;
203 203
 
204 204
 		// Trim off any slashes from the template name
205
-		$template_name = ltrim( $template_name, '/' );
205
+		$template_name = ltrim($template_name, '/');
206 206
 
207 207
 		// try locating this template file by looping through the template paths
208
-		foreach( wpinv_get_theme_template_paths() as $template_path ) {
208
+		foreach (wpinv_get_theme_template_paths() as $template_path) {
209 209
 
210
-			if( file_exists( $template_path . $template_name ) ) {
210
+			if (file_exists($template_path . $template_name)) {
211 211
 				$located = $template_path . $template_name;
212 212
 				break;
213 213
 			}
214 214
 		}
215 215
 
216
-		if( !empty( $located ) ) {
216
+		if (!empty($located)) {
217 217
 			break;
218 218
 		}
219 219
 	}
220 220
 
221
-	if ( ( true == $load ) && ! empty( $located ) )
222
-		load_template( $located, $require_once );
221
+	if ((true == $load) && !empty($located))
222
+		load_template($located, $require_once);
223 223
 
224 224
 	return $located;
225 225
 }
@@ -228,155 +228,155 @@  discard block
 block discarded – undo
228 228
 	$template_dir = wpinv_get_theme_template_dir_name();
229 229
 
230 230
 	$file_paths = array(
231
-		1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
232
-		10 => trailingslashit( get_template_directory() ) . $template_dir,
231
+		1 => trailingslashit(get_stylesheet_directory()) . $template_dir,
232
+		10 => trailingslashit(get_template_directory()) . $template_dir,
233 233
 		100 => wpinv_get_templates_dir()
234 234
 	);
235 235
 
236
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
236
+	$file_paths = apply_filters('wpinv_template_paths', $file_paths);
237 237
 
238 238
 	// sort the file paths based on priority
239
-	ksort( $file_paths, SORT_NUMERIC );
239
+	ksort($file_paths, SORT_NUMERIC);
240 240
 
241
-	return array_map( 'trailingslashit', $file_paths );
241
+	return array_map('trailingslashit', $file_paths);
242 242
 }
243 243
 
244 244
 function wpinv_checkout_meta_tags() {
245 245
 
246 246
 	$pages   = array();
247
-	$pages[] = wpinv_get_option( 'success_page' );
248
-	$pages[] = wpinv_get_option( 'failure_page' );
249
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
250
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
247
+	$pages[] = wpinv_get_option('success_page');
248
+	$pages[] = wpinv_get_option('failure_page');
249
+	$pages[] = wpinv_get_option('invoice_history_page');
250
+	$pages[] = wpinv_get_option('invoice_subscription_page');
251 251
 
252
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
252
+	if (!wpinv_is_checkout() && !is_page($pages)) {
253 253
 		return;
254 254
 	}
255 255
 
256 256
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
257 257
 }
258
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
258
+add_action('wp_head', 'wpinv_checkout_meta_tags');
259 259
 
260
-function wpinv_add_body_classes( $class ) {
261
-	$classes = (array)$class;
260
+function wpinv_add_body_classes($class) {
261
+	$classes = (array) $class;
262 262
 
263
-	if( wpinv_is_checkout() ) {
263
+	if (wpinv_is_checkout()) {
264 264
 		$classes[] = 'wpinv-checkout';
265 265
 		$classes[] = 'wpinv-page';
266 266
 	}
267 267
 
268
-	if( wpinv_is_success_page() ) {
268
+	if (wpinv_is_success_page()) {
269 269
 		$classes[] = 'wpinv-success';
270 270
 		$classes[] = 'wpinv-page';
271 271
 	}
272 272
 
273
-	if( wpinv_is_failed_transaction_page() ) {
273
+	if (wpinv_is_failed_transaction_page()) {
274 274
 		$classes[] = 'wpinv-failed-transaction';
275 275
 		$classes[] = 'wpinv-page';
276 276
 	}
277 277
 
278
-	if( wpinv_is_invoice_history_page() ) {
278
+	if (wpinv_is_invoice_history_page()) {
279 279
 		$classes[] = 'wpinv-history';
280 280
 		$classes[] = 'wpinv-page';
281 281
 	}
282 282
 
283
-	if( wpinv_is_subscriptions_history_page() ) {
283
+	if (wpinv_is_subscriptions_history_page()) {
284 284
 		$classes[] = 'wpinv-subscription';
285 285
 		$classes[] = 'wpinv-page';
286 286
 	}
287 287
 
288
-	if( wpinv_is_test_mode() ) {
288
+	if (wpinv_is_test_mode()) {
289 289
 		$classes[] = 'wpinv-test-mode';
290 290
 		$classes[] = 'wpinv-page';
291 291
 	}
292 292
 
293
-	return array_unique( $classes );
293
+	return array_unique($classes);
294 294
 }
295
-add_filter( 'body_class', 'wpinv_add_body_classes' );
295
+add_filter('body_class', 'wpinv_add_body_classes');
296 296
 
297
-function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) {
298
-    $args = array( 'nopaging' => true );
297
+function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') {
298
+    $args = array('nopaging' => true);
299 299
 
300
-    if ( ! empty( $status ) )
300
+    if (!empty($status))
301 301
         $args['post_status'] = $status;
302 302
 
303
-    $discounts = wpinv_get_discounts( $args );
303
+    $discounts = wpinv_get_discounts($args);
304 304
     $options   = array();
305 305
 
306
-    if ( $discounts ) {
307
-        foreach ( $discounts as $discount ) {
308
-            $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) );
306
+    if ($discounts) {
307
+        foreach ($discounts as $discount) {
308
+            $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID));
309 309
         }
310 310
     } else {
311
-        $options[0] = __( 'No discounts found', 'invoicing' );
311
+        $options[0] = __('No discounts found', 'invoicing');
312 312
     }
313 313
 
314
-    $output = wpinv_html_select( array(
314
+    $output = wpinv_html_select(array(
315 315
         'name'             => $name,
316 316
         'selected'         => $selected,
317 317
         'options'          => $options,
318 318
         'show_option_all'  => false,
319 319
         'show_option_none' => false,
320
-    ) );
320
+    ));
321 321
 
322 322
     return $output;
323 323
 }
324 324
 
325
-function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
326
-    $current     = date( 'Y' );
327
-    $start_year  = $current - absint( $years_before );
328
-    $end_year    = $current + absint( $years_after );
329
-    $selected    = empty( $selected ) ? date( 'Y' ) : $selected;
325
+function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
326
+    $current     = date('Y');
327
+    $start_year  = $current - absint($years_before);
328
+    $end_year    = $current + absint($years_after);
329
+    $selected    = empty($selected) ? date('Y') : $selected;
330 330
     $options     = array();
331 331
 
332
-    while ( $start_year <= $end_year ) {
333
-        $options[ absint( $start_year ) ] = $start_year;
332
+    while ($start_year <= $end_year) {
333
+        $options[absint($start_year)] = $start_year;
334 334
         $start_year++;
335 335
     }
336 336
 
337
-    $output = wpinv_html_select( array(
337
+    $output = wpinv_html_select(array(
338 338
         'name'             => $name,
339 339
         'selected'         => $selected,
340 340
         'options'          => $options,
341 341
         'show_option_all'  => false,
342 342
         'show_option_none' => false
343
-    ) );
343
+    ));
344 344
 
345 345
     return $output;
346 346
 }
347 347
 
348
-function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) {
348
+function wpinv_html_month_dropdown($name = 'month', $selected = 0) {
349 349
 
350 350
     $options = array(
351
-        '1'  => __( 'January', 'invoicing' ),
352
-        '2'  => __( 'February', 'invoicing' ),
353
-        '3'  => __( 'March', 'invoicing' ),
354
-        '4'  => __( 'April', 'invoicing' ),
355
-        '5'  => __( 'May', 'invoicing' ),
356
-        '6'  => __( 'June', 'invoicing' ),
357
-        '7'  => __( 'July', 'invoicing' ),
358
-        '8'  => __( 'August', 'invoicing' ),
359
-        '9'  => __( 'September', 'invoicing' ),
360
-        '10' => __( 'October', 'invoicing' ),
361
-        '11' => __( 'November', 'invoicing' ),
362
-        '12' => __( 'December', 'invoicing' ),
351
+        '1'  => __('January', 'invoicing'),
352
+        '2'  => __('February', 'invoicing'),
353
+        '3'  => __('March', 'invoicing'),
354
+        '4'  => __('April', 'invoicing'),
355
+        '5'  => __('May', 'invoicing'),
356
+        '6'  => __('June', 'invoicing'),
357
+        '7'  => __('July', 'invoicing'),
358
+        '8'  => __('August', 'invoicing'),
359
+        '9'  => __('September', 'invoicing'),
360
+        '10' => __('October', 'invoicing'),
361
+        '11' => __('November', 'invoicing'),
362
+        '12' => __('December', 'invoicing'),
363 363
     );
364 364
 
365 365
     // If no month is selected, default to the current month
366
-    $selected = empty( $selected ) ? date( 'n' ) : $selected;
366
+    $selected = empty($selected) ? date('n') : $selected;
367 367
 
368
-    $output = wpinv_html_select( array(
368
+    $output = wpinv_html_select(array(
369 369
         'name'             => $name,
370 370
         'selected'         => $selected,
371 371
         'options'          => $options,
372 372
         'show_option_all'  => false,
373 373
         'show_option_none' => false
374
-    ) );
374
+    ));
375 375
 
376 376
     return $output;
377 377
 }
378 378
 
379
-function wpinv_html_select( $args = array() ) {
379
+function wpinv_html_select($args = array()) {
380 380
     $defaults = array(
381 381
         'options'          => array(),
382 382
         'name'             => null,
@@ -385,8 +385,8 @@  discard block
 block discarded – undo
385 385
         'selected'         => 0,
386 386
         'placeholder'      => null,
387 387
         'multiple'         => false,
388
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
389
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
388
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
389
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
390 390
         'data'             => array(),
391 391
         'onchange'         => null,
392 392
         'required'         => false,
@@ -394,74 +394,74 @@  discard block
 block discarded – undo
394 394
         'readonly'         => false,
395 395
     );
396 396
 
397
-    $args = wp_parse_args( $args, $defaults );
397
+    $args = wp_parse_args($args, $defaults);
398 398
 
399 399
     $data_elements = '';
400
-    foreach ( $args['data'] as $key => $value ) {
401
-        $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
400
+    foreach ($args['data'] as $key => $value) {
401
+        $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"';
402 402
     }
403 403
 
404
-    if( $args['multiple'] ) {
404
+    if ($args['multiple']) {
405 405
         $multiple = ' MULTIPLE';
406 406
     } else {
407 407
         $multiple = '';
408 408
     }
409 409
 
410
-    if( $args['placeholder'] ) {
410
+    if ($args['placeholder']) {
411 411
         $placeholder = $args['placeholder'];
412 412
     } else {
413 413
         $placeholder = '';
414 414
     }
415 415
     
416 416
     $options = '';
417
-    if( !empty( $args['onchange'] ) ) {
418
-        $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"';
417
+    if (!empty($args['onchange'])) {
418
+        $options .= ' onchange="' . esc_attr($args['onchange']) . '"';
419 419
     }
420 420
     
421
-    if( !empty( $args['required'] ) ) {
421
+    if (!empty($args['required'])) {
422 422
         $options .= ' required="required"';
423 423
     }
424 424
     
425
-    if( !empty( $args['disabled'] ) ) {
425
+    if (!empty($args['disabled'])) {
426 426
         $options .= ' disabled';
427 427
     }
428 428
     
429
-    if( !empty( $args['readonly'] ) ) {
429
+    if (!empty($args['readonly'])) {
430 430
         $options .= ' readonly';
431 431
     }
432 432
 
433
-    $class  = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
434
-    $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>';
433
+    $class  = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
434
+    $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>';
435 435
 
436
-    if ( $args['show_option_all'] ) {
437
-        if( $args['multiple'] ) {
438
-            $selected = selected( true, in_array( 0, $args['selected'] ), false );
436
+    if ($args['show_option_all']) {
437
+        if ($args['multiple']) {
438
+            $selected = selected(true, in_array(0, $args['selected']), false);
439 439
         } else {
440
-            $selected = selected( $args['selected'], 0, false );
440
+            $selected = selected($args['selected'], 0, false);
441 441
         }
442
-        $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
442
+        $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>';
443 443
     }
444 444
 
445
-    if ( !empty( $args['options'] ) ) {
445
+    if (!empty($args['options'])) {
446 446
 
447
-        if ( $args['show_option_none'] ) {
448
-            if( $args['multiple'] ) {
449
-                $selected = selected( true, in_array( "", $args['selected'] ), false );
447
+        if ($args['show_option_none']) {
448
+            if ($args['multiple']) {
449
+                $selected = selected(true, in_array("", $args['selected']), false);
450 450
             } else {
451
-                $selected = selected( $args['selected'] === "", true, false );
451
+                $selected = selected($args['selected'] === "", true, false);
452 452
             }
453
-            $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
453
+            $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>';
454 454
         }
455 455
 
456
-        foreach( $args['options'] as $key => $option ) {
456
+        foreach ($args['options'] as $key => $option) {
457 457
 
458
-            if( $args['multiple'] && is_array( $args['selected'] ) ) {
459
-                $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false );
458
+            if ($args['multiple'] && is_array($args['selected'])) {
459
+                $selected = selected(true, (bool) in_array($key, $args['selected']), false);
460 460
             } else {
461
-                $selected = selected( $args['selected'], $key, false );
461
+                $selected = selected($args['selected'], $key, false);
462 462
             }
463 463
 
464
-            $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
464
+            $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>';
465 465
         }
466 466
     }
467 467
 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
     return $output;
471 471
 }
472 472
 
473
-function wpinv_item_dropdown( $args = array() ) {
473
+function wpinv_item_dropdown($args = array()) {
474 474
     $defaults = array(
475 475
         'name'              => 'wpi_item',
476 476
         'id'                => 'wpi_item',
@@ -478,14 +478,14 @@  discard block
 block discarded – undo
478 478
         'multiple'          => false,
479 479
         'selected'          => 0,
480 480
         'number'            => 100,
481
-        'placeholder'       => __( 'Choose a item', 'invoicing' ),
482
-        'data'              => array( 'search-type' => 'item' ),
481
+        'placeholder'       => __('Choose a item', 'invoicing'),
482
+        'data'              => array('search-type' => 'item'),
483 483
         'show_option_all'   => false,
484 484
         'show_option_none'  => false,
485 485
         'show_recurring'    => false,
486 486
     );
487 487
 
488
-    $args = wp_parse_args( $args, $defaults );
488
+    $args = wp_parse_args($args, $defaults);
489 489
 
490 490
     $item_args = array(
491 491
         'post_type'      => 'wpi_item',
@@ -494,44 +494,44 @@  discard block
 block discarded – undo
494 494
         'posts_per_page' => $args['number']
495 495
     );
496 496
 
497
-    $item_args  = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults );
497
+    $item_args  = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults);
498 498
 
499
-    $items      = get_posts( $item_args );
499
+    $items      = get_posts($item_args);
500 500
     $options    = array();
501
-    if ( $items ) {
502
-        foreach ( $items as $item ) {
503
-            $title = esc_html( $item->post_title );
501
+    if ($items) {
502
+        foreach ($items as $item) {
503
+            $title = esc_html($item->post_title);
504 504
             
505
-            if ( !empty( $args['show_recurring'] ) ) {
506
-                $title .= wpinv_get_item_suffix( $item->ID, false );
505
+            if (!empty($args['show_recurring'])) {
506
+                $title .= wpinv_get_item_suffix($item->ID, false);
507 507
             }
508 508
             
509
-            $options[ absint( $item->ID ) ] = $title;
509
+            $options[absint($item->ID)] = $title;
510 510
         }
511 511
     }
512 512
 
513 513
     // This ensures that any selected items are included in the drop down
514
-    if( is_array( $args['selected'] ) ) {
515
-        foreach( $args['selected'] as $item ) {
516
-            if( ! in_array( $item, $options ) ) {
517
-                $title = get_the_title( $item );
518
-                if ( !empty( $args['show_recurring'] ) ) {
519
-                    $title .= wpinv_get_item_suffix( $item, false );
514
+    if (is_array($args['selected'])) {
515
+        foreach ($args['selected'] as $item) {
516
+            if (!in_array($item, $options)) {
517
+                $title = get_the_title($item);
518
+                if (!empty($args['show_recurring'])) {
519
+                    $title .= wpinv_get_item_suffix($item, false);
520 520
                 }
521 521
                 $options[$item] = $title;
522 522
             }
523 523
         }
524
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
525
-        if ( ! in_array( $args['selected'], $options ) ) {
526
-            $title = get_the_title( $args['selected'] );
527
-            if ( !empty( $args['show_recurring'] ) ) {
528
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
524
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
525
+        if (!in_array($args['selected'], $options)) {
526
+            $title = get_the_title($args['selected']);
527
+            if (!empty($args['show_recurring'])) {
528
+                $title .= wpinv_get_item_suffix($args['selected'], false);
529 529
             }
530
-            $options[$args['selected']] = get_the_title( $args['selected'] );
530
+            $options[$args['selected']] = get_the_title($args['selected']);
531 531
         }
532 532
     }
533 533
 
534
-    $output = wpinv_html_select( array(
534
+    $output = wpinv_html_select(array(
535 535
         'name'             => $args['name'],
536 536
         'selected'         => $args['selected'],
537 537
         'id'               => $args['id'],
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
         'show_option_all'  => $args['show_option_all'],
543 543
         'show_option_none' => $args['show_option_none'],
544 544
         'data'             => $args['data'],
545
-    ) );
545
+    ));
546 546
 
547 547
     return $output;
548 548
 }
@@ -562,16 +562,16 @@  discard block
 block discarded – undo
562 562
     );
563 563
 
564 564
     $options = array();
565
-    if ( $items ) {
566
-        foreach ( $items as $item ) {
567
-            $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false );
565
+    if ($items) {
566
+        foreach ($items as $item) {
567
+            $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false);
568 568
         }
569 569
     }
570 570
 
571 571
     return $options;
572 572
 }
573 573
 
574
-function wpinv_html_checkbox( $args = array() ) {
574
+function wpinv_html_checkbox($args = array()) {
575 575
     $defaults = array(
576 576
         'name'     => null,
577 577
         'current'  => null,
@@ -582,17 +582,17 @@  discard block
 block discarded – undo
582 582
         )
583 583
     );
584 584
 
585
-    $args = wp_parse_args( $args, $defaults );
585
+    $args = wp_parse_args($args, $defaults);
586 586
 
587
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
587
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
588 588
     $options = '';
589
-    if ( ! empty( $args['options']['disabled'] ) ) {
589
+    if (!empty($args['options']['disabled'])) {
590 590
         $options .= ' disabled="disabled"';
591
-    } elseif ( ! empty( $args['options']['readonly'] ) ) {
591
+    } elseif (!empty($args['options']['readonly'])) {
592 592
         $options .= ' readonly';
593 593
     }
594 594
 
595
-    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
595
+    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />';
596 596
 
597 597
     return $output;
598 598
 }
@@ -600,30 +600,30 @@  discard block
 block discarded – undo
600 600
 /**
601 601
  * Displays a hidden field.
602 602
  */
603
-function getpaid_hidden_field( $name, $value ) {
604
-    $name  = sanitize_text_field( $name );
605
-    $value = esc_attr( $value );
603
+function getpaid_hidden_field($name, $value) {
604
+    $name  = sanitize_text_field($name);
605
+    $value = esc_attr($value);
606 606
 
607 607
     echo "<input type='hidden' name='$name' value='$value' />";
608 608
 }
609 609
 
610
-function wpinv_html_text( $args = array() ) {
610
+function wpinv_html_text($args = array()) {
611 611
     // Backwards compatibility
612
-    if ( func_num_args() > 1 ) {
612
+    if (func_num_args() > 1) {
613 613
         $args = func_get_args();
614 614
 
615 615
         $name  = $args[0];
616
-        $value = isset( $args[1] ) ? $args[1] : '';
617
-        $label = isset( $args[2] ) ? $args[2] : '';
618
-        $desc  = isset( $args[3] ) ? $args[3] : '';
616
+        $value = isset($args[1]) ? $args[1] : '';
617
+        $label = isset($args[2]) ? $args[2] : '';
618
+        $desc  = isset($args[3]) ? $args[3] : '';
619 619
     }
620 620
 
621 621
     $defaults = array(
622 622
         'id'           => '',
623
-        'name'         => isset( $name )  ? $name  : 'text',
624
-        'value'        => isset( $value ) ? $value : null,
625
-        'label'        => isset( $label ) ? $label : null,
626
-        'desc'         => isset( $desc )  ? $desc  : null,
623
+        'name'         => isset($name) ? $name : 'text',
624
+        'value'        => isset($value) ? $value : null,
625
+        'label'        => isset($label) ? $label : null,
626
+        'desc'         => isset($desc) ? $desc : null,
627 627
         'placeholder'  => '',
628 628
         'class'        => 'regular-text',
629 629
         'disabled'     => false,
@@ -633,51 +633,51 @@  discard block
 block discarded – undo
633 633
         'data'         => false
634 634
     );
635 635
 
636
-    $args = wp_parse_args( $args, $defaults );
636
+    $args = wp_parse_args($args, $defaults);
637 637
 
638
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
638
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
639 639
     $options = '';
640
-    if( $args['required'] ) {
640
+    if ($args['required']) {
641 641
         $options .= ' required="required"';
642 642
     }
643
-    if( $args['readonly'] ) {
643
+    if ($args['readonly']) {
644 644
         $options .= ' readonly';
645 645
     }
646
-    if( $args['readonly'] ) {
646
+    if ($args['readonly']) {
647 647
         $options .= ' readonly';
648 648
     }
649 649
 
650 650
     $data = '';
651
-    if ( !empty( $args['data'] ) ) {
652
-        foreach ( $args['data'] as $key => $value ) {
653
-            $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
651
+    if (!empty($args['data'])) {
652
+        foreach ($args['data'] as $key => $value) {
653
+            $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" ';
654 654
         }
655 655
     }
656 656
 
657
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
658
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
659
-    if ( ! empty( $args['desc'] ) ) {
660
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
657
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
658
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>';
659
+    if (!empty($args['desc'])) {
660
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
661 661
     }
662 662
 
663
-    $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] )  . '" autocomplete="' . esc_attr( $args['autocomplete'] )  . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>';
663
+    $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>';
664 664
 
665 665
     $output .= '</span>';
666 666
 
667 667
     return $output;
668 668
 }
669 669
 
670
-function wpinv_html_date_field( $args = array() ) {
671
-    if( empty( $args['class'] ) ) {
670
+function wpinv_html_date_field($args = array()) {
671
+    if (empty($args['class'])) {
672 672
         $args['class'] = 'wpiDatepicker';
673
-    } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) {
673
+    } elseif (!strpos($args['class'], 'wpiDatepicker')) {
674 674
         $args['class'] .= ' wpiDatepicker';
675 675
     }
676 676
 
677
-    return wpinv_html_text( $args );
677
+    return wpinv_html_text($args);
678 678
 }
679 679
 
680
-function wpinv_html_textarea( $args = array() ) {
680
+function wpinv_html_textarea($args = array()) {
681 681
     $defaults = array(
682 682
         'name'        => 'textarea',
683 683
         'value'       => null,
@@ -688,31 +688,31 @@  discard block
 block discarded – undo
688 688
         'placeholder' => '',
689 689
     );
690 690
 
691
-    $args = wp_parse_args( $args, $defaults );
691
+    $args = wp_parse_args($args, $defaults);
692 692
 
693
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
693
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
694 694
     $disabled = '';
695
-    if( $args['disabled'] ) {
695
+    if ($args['disabled']) {
696 696
         $disabled = ' disabled="disabled"';
697 697
     }
698 698
 
699
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
700
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
701
-    $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
699
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
700
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
701
+    $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>';
702 702
 
703
-    if ( ! empty( $args['desc'] ) ) {
704
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
703
+    if (!empty($args['desc'])) {
704
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
705 705
     }
706 706
     $output .= '</span>';
707 707
 
708 708
     return $output;
709 709
 }
710 710
 
711
-function wpinv_html_ajax_user_search( $args = array() ) {
711
+function wpinv_html_ajax_user_search($args = array()) {
712 712
     $defaults = array(
713 713
         'name'        => 'user_id',
714 714
         'value'       => null,
715
-        'placeholder' => __( 'Enter username', 'invoicing' ),
715
+        'placeholder' => __('Enter username', 'invoicing'),
716 716
         'label'       => null,
717 717
         'desc'        => null,
718 718
         'class'       => '',
@@ -721,13 +721,13 @@  discard block
 block discarded – undo
721 721
         'data'        => false
722 722
     );
723 723
 
724
-    $args = wp_parse_args( $args, $defaults );
724
+    $args = wp_parse_args($args, $defaults);
725 725
 
726 726
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
727 727
 
728 728
     $output  = '<span class="wpinv_user_search_wrap">';
729
-        $output .= wpinv_html_text( $args );
730
-        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>';
729
+        $output .= wpinv_html_text($args);
730
+        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>';
731 731
     $output .= '</span>';
732 732
 
733 733
     return $output;
@@ -743,20 +743,20 @@  discard block
 block discarded – undo
743 743
  * 
744 744
  * @param string $template the template that is currently being used.
745 745
  */
746
-function wpinv_template( $template ) {
746
+function wpinv_template($template) {
747 747
     global $post;
748 748
 
749
-    if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) {
749
+    if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) {
750 750
 
751 751
         // If the user can view this invoice, display it.
752
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
752
+        if (wpinv_user_can_view_invoice($post->ID)) {
753 753
 
754
-            return wpinv_get_template_part( 'wpinv-invoice-print', false, false );
754
+            return wpinv_get_template_part('wpinv-invoice-print', false, false);
755 755
 
756 756
         // Else display an error message.
757 757
         } else {
758 758
 
759
-            return wpinv_get_template_part( 'wpinv-invalid-access', false, false );
759
+            return wpinv_get_template_part('wpinv-invalid-access', false, false);
760 760
 
761 761
         }
762 762
 
@@ -764,46 +764,46 @@  discard block
 block discarded – undo
764 764
 
765 765
     return $template;
766 766
 }
767
-add_filter( 'template_include', 'wpinv_template', 10, 1 );
767
+add_filter('template_include', 'wpinv_template', 10, 1);
768 768
 
769 769
 function wpinv_get_business_address() {
770 770
     $business_address   = wpinv_store_address();
771
-    $business_address   = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : '';
771
+    $business_address   = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : '';
772 772
     
773 773
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
774 774
     
775
-    return apply_filters( 'wpinv_get_business_address', $business_address );
775
+    return apply_filters('wpinv_get_business_address', $business_address);
776 776
 }
777 777
 
778 778
 /**
779 779
  * Displays the company address.
780 780
  */
781 781
 function wpinv_display_from_address() {
782
-    wpinv_get_template( 'invoice/company-address.php' );
782
+    wpinv_get_template('invoice/company-address.php');
783 783
 }
784
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 );
784
+add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10);
785 785
 
786
-function wpinv_watermark( $id = 0 ) {
787
-    $output = wpinv_get_watermark( $id );
788
-    return apply_filters( 'wpinv_get_watermark', $output, $id );
786
+function wpinv_watermark($id = 0) {
787
+    $output = wpinv_get_watermark($id);
788
+    return apply_filters('wpinv_get_watermark', $output, $id);
789 789
 }
790 790
 
791
-function wpinv_get_watermark( $id ) {
792
-    if ( !$id > 0 ) {
791
+function wpinv_get_watermark($id) {
792
+    if (!$id > 0) {
793 793
         return NULL;
794 794
     }
795 795
 
796
-    $invoice = wpinv_get_invoice( $id );
796
+    $invoice = wpinv_get_invoice($id);
797 797
     
798
-    if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) {
799
-        if ( $invoice->is_paid() ) {
800
-            return __( 'Paid', 'invoicing' );
798
+    if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) {
799
+        if ($invoice->is_paid()) {
800
+            return __('Paid', 'invoicing');
801 801
         }
802
-        if ( $invoice->is_refunded() ) {
803
-            return __( 'Refunded', 'invoicing' );
802
+        if ($invoice->is_refunded()) {
803
+            return __('Refunded', 'invoicing');
804 804
         }
805
-        if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) {
806
-            return __( 'Cancelled', 'invoicing' );
805
+        if ($invoice->has_status(array('wpi-cancelled'))) {
806
+            return __('Cancelled', 'invoicing');
807 807
         }
808 808
     }
809 809
     
@@ -813,30 +813,30 @@  discard block
 block discarded – undo
813 813
 /**
814 814
  * @deprecated
815 815
  */
816
-function wpinv_display_invoice_details( $invoice ) {
817
-    return getpaid_invoice_meta( $invoice );
816
+function wpinv_display_invoice_details($invoice) {
817
+    return getpaid_invoice_meta($invoice);
818 818
 }
819 819
 
820 820
 /**
821 821
  * Displays invoice meta.
822 822
  */
823
-function getpaid_invoice_meta( $invoice ) {
823
+function getpaid_invoice_meta($invoice) {
824 824
 
825
-    $invoice = new WPInv_Invoice( $invoice );
825
+    $invoice = new WPInv_Invoice($invoice);
826 826
 
827 827
     // Ensure that we have an invoice.
828
-    if ( 0 == $invoice->get_id() ) {
828
+    if (0 == $invoice->get_id()) {
829 829
         return;
830 830
     }
831 831
 
832 832
     // Get the invoice meta.
833
-    $meta = getpaid_get_invoice_meta( $invoice );
833
+    $meta = getpaid_get_invoice_meta($invoice);
834 834
 
835 835
     // Display the meta.
836
-    wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) );
836
+    wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta'));
837 837
 
838 838
 }
839
-add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 );
839
+add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10);
840 840
 
841 841
 /**
842 842
  * Retrieves the address markup to use on Invoices.
@@ -848,29 +848,29 @@  discard block
 block discarded – undo
848 848
  * @param  string $separator How to separate address lines.
849 849
  * @return string
850 850
  */
851
-function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) {
851
+function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') {
852 852
 
853 853
     // Retrieve the address markup...
854
-    $country= empty( $billing_details['country'] ) ? '' : $billing_details['country'];
855
-    $format = wpinv_get_full_address_format( $country );
854
+    $country = empty($billing_details['country']) ? '' : $billing_details['country'];
855
+    $format = wpinv_get_full_address_format($country);
856 856
 
857 857
     // ... and the replacements.
858
-    $replacements = wpinv_get_invoice_address_replacements( $billing_details );
858
+    $replacements = wpinv_get_invoice_address_replacements($billing_details);
859 859
 
860
-    $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
860
+    $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format);
861 861
     
862 862
 	// Remove unavailable tags.
863
-    $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address );
863
+    $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address);
864 864
 
865 865
     // Clean up white space.
866
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
867
-    $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
866
+	$formatted_address = preg_replace('/  +/', ' ', trim($formatted_address));
867
+    $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address);
868 868
     
869 869
     // Break newlines apart and remove empty lines/trim commas and white space.
870
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
870
+	$formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address)));
871 871
 
872 872
     // Add html breaks.
873
-	$formatted_address = implode( $separator, $formatted_address );
873
+	$formatted_address = implode($separator, $formatted_address);
874 874
 
875 875
 	// We're done!
876 876
 	return $formatted_address;
@@ -882,88 +882,88 @@  discard block
 block discarded – undo
882 882
  * 
883 883
  * @param WPInv_Invoice $invoice
884 884
  */
885
-function wpinv_display_to_address( $invoice = 0 ) {
886
-    if ( ! empty( $invoice ) ) {
887
-        wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) );
885
+function wpinv_display_to_address($invoice = 0) {
886
+    if (!empty($invoice)) {
887
+        wpinv_get_template('invoice/billing-address.php', compact('invoice'));
888 888
     }
889 889
 }
890
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 );
890
+add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40);
891 891
 
892 892
 
893 893
 /**
894 894
  * Displays invoice line items.
895 895
  */
896
-function wpinv_display_line_items( $invoice_id = 0 ) {
896
+function wpinv_display_line_items($invoice_id = 0) {
897 897
 
898 898
     // Prepare the invoice.
899
-    $invoice = new WPInv_Invoice( $invoice_id );
899
+    $invoice = new WPInv_Invoice($invoice_id);
900 900
 
901 901
     // Abort if there is no invoice.
902
-    if ( 0 == $invoice->get_id() ) {
902
+    if (0 == $invoice->get_id()) {
903 903
         return;
904 904
     }
905 905
 
906 906
     // Line item columns.
907
-    $columns = getpaid_invoice_item_columns( $invoice );
908
-    $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice );
907
+    $columns = getpaid_invoice_item_columns($invoice);
908
+    $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice);
909 909
 
910
-    wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) );
910
+    wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns'));
911 911
 }
912
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 );
912
+add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10);
913 913
 
914 914
 /**
915 915
  * Displays invoice notices on invoices.
916 916
  */
917 917
 function wpinv_display_invoice_notice() {
918 918
 
919
-    $label  = wpinv_get_option( 'vat_invoice_notice_label' );
920
-    $notice = wpinv_get_option( 'vat_invoice_notice' );
919
+    $label  = wpinv_get_option('vat_invoice_notice_label');
920
+    $notice = wpinv_get_option('vat_invoice_notice');
921 921
 
922
-    if ( empty( $label ) && empty( $notice ) ) {
922
+    if (empty($label) && empty($notice)) {
923 923
         return;
924 924
     }
925 925
 
926 926
     echo '<div class="mt-4 mb-4 wpinv-vat-notice">';
927 927
 
928
-    if ( ! empty( $label ) ) {
929
-        $label = sanitize_text_field( $label );
928
+    if (!empty($label)) {
929
+        $label = sanitize_text_field($label);
930 930
         echo "<h5>$label</h5>";
931 931
     }
932 932
 
933
-    if ( ! empty( $notice ) ) {
934
-        echo '<small class="form-text text-muted">' . wpautop( wptexturize( $notice ) ) . '</small>';
933
+    if (!empty($notice)) {
934
+        echo '<small class="form-text text-muted">' . wpautop(wptexturize($notice)) . '</small>';
935 935
     }
936 936
 
937 937
     echo '</div>';
938 938
 }
939
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 );
939
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100);
940 940
 
941 941
 /**
942 942
  * @param WPInv_Invoice $invoice
943 943
  */
944
-function wpinv_display_invoice_notes( $invoice ) {
944
+function wpinv_display_invoice_notes($invoice) {
945 945
 
946 946
     // Retrieve the notes.
947
-    $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' );
947
+    $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer');
948 948
 
949 949
     // Abort if we have non.
950
-    if ( empty( $notes ) ) {
950
+    if (empty($notes)) {
951 951
         return;
952 952
     }
953 953
 
954 954
     // Echo the note.
955 955
     echo '<div class="getpaid-invoice-notes-wrapper border position-relative w-100 mb-4 p-0">';
956
-    echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __( 'Notes', 'invoicing' ) .'</h3>';
956
+    echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __('Notes', 'invoicing') . '</h3>';
957 957
     echo '<ul class="getpaid-invoice-notes mt-4 p-0">';
958 958
 
959
-    foreach( $notes as $note ) {
960
-        wpinv_get_invoice_note_line_item( $note );
959
+    foreach ($notes as $note) {
960
+        wpinv_get_invoice_note_line_item($note);
961 961
     }
962 962
 
963 963
     echo '</ul>';
964 964
     echo '</div>';
965 965
 }
966
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 );
966
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60);
967 967
 
968 968
 /**
969 969
  * Loads scripts on our invoice templates.
@@ -971,32 +971,32 @@  discard block
 block discarded – undo
971 971
 function wpinv_display_style() {
972 972
 
973 973
     // Make sure that all scripts have been loaded.
974
-    if ( ! did_action( 'wp_enqueue_scripts' ) ) {
975
-        do_action( 'wp_enqueue_scripts' );
974
+    if (!did_action('wp_enqueue_scripts')) {
975
+        do_action('wp_enqueue_scripts');
976 976
     }
977 977
 
978 978
     // Register the invoices style.
979
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) );
979
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css'));
980 980
 
981 981
     // Load required styles
982
-    wp_print_styles( 'open-sans' );
983
-    wp_print_styles( 'wpinv-single-style' );
984
-    wp_print_styles( 'ayecode-ui' );
982
+    wp_print_styles('open-sans');
983
+    wp_print_styles('wpinv-single-style');
984
+    wp_print_styles('ayecode-ui');
985 985
 
986 986
     // Maybe load custom css.
987
-    $custom_css = wpinv_get_option( 'template_custom_css' );
987
+    $custom_css = wpinv_get_option('template_custom_css');
988 988
 
989
-    if ( isset( $custom_css ) && ! empty( $custom_css ) ) {
990
-        $custom_css     = wp_kses( $custom_css, array( '\'', '\"' ) );
991
-        $custom_css     = str_replace( '&gt;', '>', $custom_css );
989
+    if (isset($custom_css) && !empty($custom_css)) {
990
+        $custom_css     = wp_kses($custom_css, array('\'', '\"'));
991
+        $custom_css     = str_replace('&gt;', '>', $custom_css);
992 992
         echo '<style type="text/css">';
993 993
         echo $custom_css;
994 994
         echo '</style>';
995 995
     }
996 996
 
997 997
 }
998
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
999
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
998
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
999
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
1000 1000
 
1001 1001
 
1002 1002
 /**
@@ -1008,41 +1008,41 @@  discard block
 block discarded – undo
1008 1008
     // Retrieve the current invoice.
1009 1009
     $invoice_id = getpaid_get_current_invoice_id();
1010 1010
 
1011
-    if ( empty( $invoice_id ) ) {
1011
+    if (empty($invoice_id)) {
1012 1012
 
1013 1013
         return aui()->alert(
1014 1014
             array(
1015 1015
                 'type'    => 'warning',
1016
-                'content' => __( 'Invalid invoice', 'invoicing' ),
1016
+                'content' => __('Invalid invoice', 'invoicing'),
1017 1017
             )
1018 1018
         );
1019 1019
 
1020 1020
     }
1021 1021
 
1022 1022
     // Can the user view this invoice?
1023
-    if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) {
1023
+    if (!wpinv_user_can_view_invoice($invoice_id)) {
1024 1024
 
1025 1025
         return aui()->alert(
1026 1026
             array(
1027 1027
                 'type'    => 'warning',
1028
-                'content' => __( 'You are not allowed to view this invoice', 'invoicing' ),
1028
+                'content' => __('You are not allowed to view this invoice', 'invoicing'),
1029 1029
             )
1030 1030
         );
1031 1031
 
1032 1032
     }
1033 1033
 
1034 1034
     // Ensure that it is not yet paid for.
1035
-    $invoice = new WPInv_Invoice( $invoice_id );
1035
+    $invoice = new WPInv_Invoice($invoice_id);
1036 1036
 
1037 1037
     // Maybe mark it as viewed.
1038
-    getpaid_maybe_mark_invoice_as_viewed( $invoice );
1038
+    getpaid_maybe_mark_invoice_as_viewed($invoice);
1039 1039
 
1040
-    if ( $invoice->is_paid() ) {
1040
+    if ($invoice->is_paid()) {
1041 1041
 
1042 1042
         return aui()->alert(
1043 1043
             array(
1044 1044
                 'type'    => 'success',
1045
-                'content' => __( 'This invoice has already been paid.', 'invoicing' ),
1045
+                'content' => __('This invoice has already been paid.', 'invoicing'),
1046 1046
             )
1047 1047
         );
1048 1048
 
@@ -1052,14 +1052,14 @@  discard block
 block discarded – undo
1052 1052
     $wpi_checkout_id = $invoice_id;
1053 1053
 
1054 1054
     // We'll display this invoice via the default form.
1055
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1055
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1056 1056
 
1057
-    if ( 0 == $form->get_id() ) {
1057
+    if (0 == $form->get_id()) {
1058 1058
 
1059 1059
         return aui()->alert(
1060 1060
             array(
1061 1061
                 'type'    => 'warning',
1062
-                'content' => __( 'Error loading the payment form', 'invoicing' ),
1062
+                'content' => __('Error loading the payment form', 'invoicing'),
1063 1063
             )
1064 1064
         );
1065 1065
 
@@ -1067,7 +1067,7 @@  discard block
 block discarded – undo
1067 1067
 
1068 1068
     // Set the invoice.
1069 1069
     $form->invoice = $invoice;
1070
-    $form->set_items( $invoice->get_items() );
1070
+    $form->set_items($invoice->get_items());
1071 1071
 
1072 1072
     // Generate the html.
1073 1073
     return $form->get_html();
@@ -1075,7 +1075,7 @@  discard block
 block discarded – undo
1075 1075
 }
1076 1076
 
1077 1077
 function wpinv_empty_cart_message() {
1078
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1078
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1079 1079
 }
1080 1080
 
1081 1081
 /**
@@ -1092,38 +1092,38 @@  discard block
 block discarded – undo
1092 1092
         )
1093 1093
     );
1094 1094
 }
1095
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1095
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1096 1096
 
1097
-function wpinv_receipt_billing_address( $invoice_id = 0 ) {
1098
-    $invoice = wpinv_get_invoice( $invoice_id );
1097
+function wpinv_receipt_billing_address($invoice_id = 0) {
1098
+    $invoice = wpinv_get_invoice($invoice_id);
1099 1099
 
1100
-    if ( empty( $invoice ) ) {
1100
+    if (empty($invoice)) {
1101 1101
         return NULL;
1102 1102
     }
1103 1103
 
1104 1104
     $billing_details = $invoice->get_user_info();
1105
-    $address_row = wpinv_get_invoice_address_markup( $billing_details );
1105
+    $address_row = wpinv_get_invoice_address_markup($billing_details);
1106 1106
 
1107 1107
     ob_start();
1108 1108
     ?>
1109 1109
     <table class="table table-bordered table-sm wpi-billing-details">
1110 1110
         <tbody>
1111 1111
             <tr class="wpi-receipt-name">
1112
-                <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th>
1113
-                <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td>
1112
+                <th class="text-left"><?php _e('Name', 'invoicing'); ?></th>
1113
+                <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td>
1114 1114
             </tr>
1115 1115
             <tr class="wpi-receipt-email">
1116
-                <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th>
1117
-                <td><?php echo $billing_details['email'] ;?></td>
1116
+                <th class="text-left"><?php _e('Email', 'invoicing'); ?></th>
1117
+                <td><?php echo $billing_details['email']; ?></td>
1118 1118
             </tr>
1119 1119
             <tr class="wpi-receipt-address">
1120
-                <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th>
1121
-                <td><?php echo $address_row ;?></td>
1120
+                <th class="text-left"><?php _e('Address', 'invoicing'); ?></th>
1121
+                <td><?php echo $address_row; ?></td>
1122 1122
             </tr>
1123
-            <?php if ( $billing_details['phone'] ) { ?>
1123
+            <?php if ($billing_details['phone']) { ?>
1124 1124
             <tr class="wpi-receipt-phone">
1125
-                <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th>
1126
-                <td><?php echo esc_html( $billing_details['phone'] ) ;?></td>
1125
+                <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th>
1126
+                <td><?php echo esc_html($billing_details['phone']); ?></td>
1127 1127
             </tr>
1128 1128
             <?php } ?>
1129 1129
         </tbody>
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
     <?php
1132 1132
     $output = ob_get_clean();
1133 1133
     
1134
-    $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id );
1134
+    $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id);
1135 1135
 
1136 1136
     echo $output;
1137 1137
 }
@@ -1139,66 +1139,66 @@  discard block
 block discarded – undo
1139 1139
 /**
1140 1140
  * Filters the receipt page.
1141 1141
  */
1142
-function wpinv_filter_success_page_content( $content ) {
1142
+function wpinv_filter_success_page_content($content) {
1143 1143
 
1144 1144
     // Ensure this is our page.
1145
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1145
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1146 1146
 
1147
-        $gateway = sanitize_text_field( $_GET['payment-confirm'] );
1148
-        return apply_filters( "wpinv_payment_confirm_$gateway", $content );
1147
+        $gateway = sanitize_text_field($_GET['payment-confirm']);
1148
+        return apply_filters("wpinv_payment_confirm_$gateway", $content);
1149 1149
 
1150 1150
     }
1151 1151
 
1152 1152
     return $content;
1153 1153
 }
1154
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1154
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1155 1155
 
1156
-function wpinv_invoice_link( $invoice_id ) {
1157
-    $invoice = wpinv_get_invoice( $invoice_id );
1156
+function wpinv_invoice_link($invoice_id) {
1157
+    $invoice = wpinv_get_invoice($invoice_id);
1158 1158
 
1159
-    if ( empty( $invoice ) ) {
1159
+    if (empty($invoice)) {
1160 1160
         return NULL;
1161 1161
     }
1162 1162
 
1163
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1163
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1164 1164
 
1165
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1165
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1166 1166
 }
1167 1167
 
1168
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
1169
-    if ( empty( $note ) ) {
1168
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
1169
+    if (empty($note)) {
1170 1170
         return NULL;
1171 1171
     }
1172 1172
 
1173
-    if ( is_int( $note ) ) {
1174
-        $note = get_comment( $note );
1173
+    if (is_int($note)) {
1174
+        $note = get_comment($note);
1175 1175
     }
1176 1176
 
1177
-    if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
1177
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
1178 1178
         return NULL;
1179 1179
     }
1180 1180
 
1181
-    $note_classes   = array( 'note' );
1182
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
1181
+    $note_classes   = array('note');
1182
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
1183 1183
     $note_classes[] = $note->comment_author === 'System' ? 'system-note' : '';
1184
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
1185
-    $note_classes   = !empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
1184
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
1185
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
1186 1186
 
1187 1187
     ob_start();
1188 1188
     ?>
1189
-    <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?> mt-4 pl-3 pr-3">
1189
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mt-4 pl-3 pr-3">
1190 1190
         <div class="note_content bg-light border position-relative p-4">
1191 1191
 
1192
-            <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
1192
+            <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?>
1193 1193
 
1194
-            <?php if ( ! is_admin() ) : ?>
1194
+            <?php if (!is_admin()) : ?>
1195 1195
                 <em class="meta position-absolute form-text">
1196 1196
                     <?php
1197 1197
                         printf(
1198
-                            __( '%1$s - %2$s at %3$s', 'invoicing' ),
1198
+                            __('%1$s - %2$s at %3$s', 'invoicing'),
1199 1199
                             $note->comment_author,
1200
-                            getpaid_format_date_value( $note->comment_date ),
1201
-                            date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) )
1200
+                            getpaid_format_date_value($note->comment_date),
1201
+                            date_i18n(get_option('time_format'), strtotime($note->comment_date))
1202 1202
                         );
1203 1203
                     ?>
1204 1204
                 </em>
@@ -1206,21 +1206,21 @@  discard block
 block discarded – undo
1206 1206
 
1207 1207
         </div>
1208 1208
 
1209
-        <?php if ( is_admin() ) : ?>
1209
+        <?php if (is_admin()) : ?>
1210 1210
 
1211 1211
             <p class="meta px-4 py-2">
1212
-                <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>">
1212
+                <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>">
1213 1213
                     <?php
1214 1214
                         printf(
1215
-                            __( '%1$s - %2$s at %3$s', 'invoicing' ),
1215
+                            __('%1$s - %2$s at %3$s', 'invoicing'),
1216 1216
                             $note->comment_author,
1217
-                            getpaid_format_date_value( $note->comment_date ),
1218
-                            date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) )
1217
+                            getpaid_format_date_value($note->comment_date),
1218
+                            date_i18n(get_option('time_format'), strtotime($note->comment_date))
1219 1219
                         );
1220 1220
                     ?>
1221 1221
                 </abbr>&nbsp;&nbsp;
1222
-                <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?>
1223
-                    <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a>
1222
+                <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?>
1223
+                    <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a>
1224 1224
                 <?php } ?>
1225 1225
             </p>
1226 1226
 
@@ -1229,9 +1229,9 @@  discard block
 block discarded – undo
1229 1229
     </li>
1230 1230
     <?php
1231 1231
     $note_content = ob_get_clean();
1232
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
1232
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
1233 1233
 
1234
-    if ( $echo ) {
1234
+    if ($echo) {
1235 1235
         echo $note_content;
1236 1236
     } else {
1237 1237
         return $note_content;
@@ -1241,36 +1241,36 @@  discard block
 block discarded – undo
1241 1241
 function wpinv_invalid_invoice_content() {
1242 1242
     global $post;
1243 1243
 
1244
-    $invoice = wpinv_get_invoice( $post->ID );
1244
+    $invoice = wpinv_get_invoice($post->ID);
1245 1245
 
1246
-    $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' );
1247
-    if ( !empty( $invoice->get_id() ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
1248
-        if ( is_user_logged_in() ) {
1249
-            if ( wpinv_require_login_to_checkout() ) {
1250
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
1251
-                    $error = __( 'You are not allowed to view this invoice.', 'invoicing' );
1246
+    $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing');
1247
+    if (!empty($invoice->get_id()) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
1248
+        if (is_user_logged_in()) {
1249
+            if (wpinv_require_login_to_checkout()) {
1250
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
1251
+                    $error = __('You are not allowed to view this invoice.', 'invoicing');
1252 1252
                 }
1253 1253
             }
1254 1254
         } else {
1255
-            if ( wpinv_require_login_to_checkout() ) {
1256
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
1257
-                    $error = __( 'You must be logged in to view this invoice.', 'invoicing' );
1255
+            if (wpinv_require_login_to_checkout()) {
1256
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
1257
+                    $error = __('You must be logged in to view this invoice.', 'invoicing');
1258 1258
                 }
1259 1259
             }
1260 1260
         }
1261 1261
     } else {
1262
-        $error = __( 'This invoice is deleted or does not exist.', 'invoicing' );
1262
+        $error = __('This invoice is deleted or does not exist.', 'invoicing');
1263 1263
     }
1264 1264
     ?>
1265 1265
     <div class="row wpinv-row-invalid">
1266 1266
         <div class="col-md-6 col-md-offset-3 wpinv-message error">
1267
-            <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3>
1267
+            <h3><?php _e('Access Denied', 'invoicing'); ?></h3>
1268 1268
             <p class="wpinv-msg-text"><?php echo $error; ?></p>
1269 1269
         </div>
1270 1270
     </div>
1271 1271
     <?php
1272 1272
 }
1273
-add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' );
1273
+add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content');
1274 1274
 
1275 1275
 /**
1276 1276
  * Function to get privacy policy text.
@@ -1279,21 +1279,21 @@  discard block
 block discarded – undo
1279 1279
  * @return string
1280 1280
  */
1281 1281
 function wpinv_get_policy_text() {
1282
-    $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 );
1282
+    $privacy_page_id = get_option('wp_page_for_privacy_policy', 0);
1283 1283
 
1284
-    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ));
1284
+    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]'));
1285 1285
 
1286
-    if(!$privacy_page_id){
1287
-        $privacy_page_id = wpinv_get_option( 'privacy_page', 0 );
1286
+    if (!$privacy_page_id) {
1287
+        $privacy_page_id = wpinv_get_option('privacy_page', 0);
1288 1288
     }
1289 1289
 
1290
-    $privacy_link    = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' );
1290
+    $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing');
1291 1291
 
1292 1292
     $find_replace = array(
1293 1293
         '[wpinv_privacy_policy]' => $privacy_link,
1294 1294
     );
1295 1295
 
1296
-    $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text );
1296
+    $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text);
1297 1297
 
1298 1298
     return wp_kses_post(wpautop($privacy_text));
1299 1299
 }
@@ -1301,21 +1301,21 @@  discard block
 block discarded – undo
1301 1301
 function wpinv_oxygen_fix_conflict() {
1302 1302
     global $ct_ignore_post_types;
1303 1303
 
1304
-    if ( ! is_array( $ct_ignore_post_types ) ) {
1304
+    if (!is_array($ct_ignore_post_types)) {
1305 1305
         $ct_ignore_post_types = array();
1306 1306
     }
1307 1307
 
1308
-    $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' );
1308
+    $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item');
1309 1309
 
1310
-    foreach ( $post_types as $post_type ) {
1310
+    foreach ($post_types as $post_type) {
1311 1311
         $ct_ignore_post_types[] = $post_type;
1312 1312
 
1313 1313
         // Ignore post type
1314
-        add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 );
1314
+        add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999);
1315 1315
     }
1316 1316
 
1317
-    remove_filter( 'template_include', 'wpinv_template', 10, 1 );
1318
-    add_filter( 'template_include', 'wpinv_template', 999, 1 );
1317
+    remove_filter('template_include', 'wpinv_template', 10, 1);
1318
+    add_filter('template_include', 'wpinv_template', 999, 1);
1319 1319
 }
1320 1320
 
1321 1321
 /**
@@ -1323,10 +1323,10 @@  discard block
 block discarded – undo
1323 1323
  * 
1324 1324
  * @param GetPaid_Payment_Form $form
1325 1325
  */
1326
-function getpaid_display_payment_form( $form ) {
1326
+function getpaid_display_payment_form($form) {
1327 1327
 
1328
-    if ( is_numeric( $form ) ) {
1329
-        $form = new GetPaid_Payment_Form( $form );
1328
+    if (is_numeric($form)) {
1329
+        $form = new GetPaid_Payment_Form($form);
1330 1330
     }
1331 1331
 
1332 1332
     $form->display();
@@ -1336,55 +1336,55 @@  discard block
 block discarded – undo
1336 1336
 /**
1337 1337
  * Helper function to display a item payment form on the frontend.
1338 1338
  */
1339
-function getpaid_display_item_payment_form( $items ) {
1339
+function getpaid_display_item_payment_form($items) {
1340 1340
 
1341
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1342
-    $form->set_items( $items );
1341
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1342
+    $form->set_items($items);
1343 1343
 
1344
-    if ( 0 == count( $form->get_items() ) ) {
1344
+    if (0 == count($form->get_items())) {
1345 1345
         echo aui()->alert(
1346 1346
 			array(
1347 1347
 				'type'    => 'warning',
1348
-				'content' => __( 'No published items found', 'invoicing' ),
1348
+				'content' => __('No published items found', 'invoicing'),
1349 1349
 			)
1350 1350
         );
1351 1351
         return;
1352 1352
     }
1353 1353
 
1354
-    $form_items = esc_attr( getpaid_convert_items_to_string( $items ) );
1354
+    $form_items = esc_attr(getpaid_convert_items_to_string($items));
1355 1355
     $form_items = "<input type='hidden' name='getpaid-form-items' value='$form_items' />";
1356
-    $form->display( $form_items );
1356
+    $form->display($form_items);
1357 1357
 }
1358 1358
 
1359 1359
 /**
1360 1360
  * Helper function to display an invoice payment form on the frontend.
1361 1361
  */
1362
-function getpaid_display_invoice_payment_form( $invoice_id ) {
1362
+function getpaid_display_invoice_payment_form($invoice_id) {
1363 1363
 
1364
-    $invoice = wpinv_get_invoice( $invoice_id );
1364
+    $invoice = wpinv_get_invoice($invoice_id);
1365 1365
 
1366
-    if ( empty( $invoice ) ) {
1366
+    if (empty($invoice)) {
1367 1367
 		echo aui()->alert(
1368 1368
 			array(
1369 1369
 				'type'    => 'warning',
1370
-				'content' => __( 'Invoice not found', 'invoicing' ),
1370
+				'content' => __('Invoice not found', 'invoicing'),
1371 1371
 			)
1372 1372
         );
1373 1373
         return;
1374 1374
     }
1375 1375
 
1376
-    if ( $invoice->is_paid() ) {
1376
+    if ($invoice->is_paid()) {
1377 1377
 		echo aui()->alert(
1378 1378
 			array(
1379 1379
 				'type'    => 'warning',
1380
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
1380
+				'content' => __('Invoice has already been paid', 'invoicing'),
1381 1381
 			)
1382 1382
         );
1383 1383
         return;
1384 1384
     }
1385 1385
 
1386
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1387
-    $form->set_items( $invoice->get_items() );
1386
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1387
+    $form->set_items($invoice->get_items());
1388 1388
 
1389 1389
     $form->display();
1390 1390
 }
@@ -1392,23 +1392,23 @@  discard block
 block discarded – undo
1392 1392
 /**
1393 1393
  * Helper function to convert item string to array.
1394 1394
  */
1395
-function getpaid_convert_items_to_array( $items ) {
1396
-    $items    = array_filter( array_map( 'trim', explode( ',', $items ) ) );
1395
+function getpaid_convert_items_to_array($items) {
1396
+    $items    = array_filter(array_map('trim', explode(',', $items)));
1397 1397
     $prepared = array();
1398 1398
 
1399
-    foreach ( $items as $item ) {
1400
-        $data = array_map( 'trim', explode( '|', $item ) );
1399
+    foreach ($items as $item) {
1400
+        $data = array_map('trim', explode('|', $item));
1401 1401
 
1402
-        if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) {
1402
+        if (empty($data[0]) || !is_numeric($data[0])) {
1403 1403
             continue;
1404 1404
         }
1405 1405
 
1406 1406
         $quantity = 1;
1407
-        if ( isset( $data[1] ) && is_numeric( $data[1] ) ) {
1407
+        if (isset($data[1]) && is_numeric($data[1])) {
1408 1408
             $quantity = (int) $data[1];
1409 1409
         }
1410 1410
 
1411
-        $prepared[ $data[0] ] = $quantity;
1411
+        $prepared[$data[0]] = $quantity;
1412 1412
 
1413 1413
     }
1414 1414
 
@@ -1418,13 +1418,13 @@  discard block
 block discarded – undo
1418 1418
 /**
1419 1419
  * Helper function to convert item array to string.
1420 1420
  */
1421
-function getpaid_convert_items_to_string( $items ) {
1421
+function getpaid_convert_items_to_string($items) {
1422 1422
     $prepared = array();
1423 1423
 
1424
-    foreach ( $items as $item => $quantity ) {
1424
+    foreach ($items as $item => $quantity) {
1425 1425
         $prepared[] = "$item|$quantity";
1426 1426
     }
1427
-    return implode( ',', $prepared );
1427
+    return implode(',', $prepared);
1428 1428
 }
1429 1429
 
1430 1430
 /**
@@ -1432,21 +1432,21 @@  discard block
 block discarded – undo
1432 1432
  * 
1433 1433
  * Provide a label and one of $form, $items or $invoice.
1434 1434
  */
1435
-function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) {
1436
-    $label = sanitize_text_field( $label );
1435
+function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) {
1436
+    $label = sanitize_text_field($label);
1437 1437
 
1438
-    if ( ! empty( $form ) ) {
1439
-        $form  = esc_attr( $form );
1438
+    if (!empty($form)) {
1439
+        $form = esc_attr($form);
1440 1440
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; 
1441 1441
     }
1442 1442
 	
1443
-	if ( ! empty( $items ) ) {
1444
-        $items  = esc_attr( $items );
1443
+	if (!empty($items)) {
1444
+        $items = esc_attr($items);
1445 1445
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; 
1446 1446
     }
1447 1447
     
1448
-    if ( ! empty( $invoice ) ) {
1449
-        $invoice  = esc_attr( $invoice );
1448
+    if (!empty($invoice)) {
1449
+        $invoice = esc_attr($invoice);
1450 1450
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>"; 
1451 1451
     }
1452 1452
 
@@ -1457,17 +1457,17 @@  discard block
 block discarded – undo
1457 1457
  *
1458 1458
  * @param WPInv_Invoice $invoice
1459 1459
  */
1460
-function getpaid_the_invoice_description( $invoice ) {
1460
+function getpaid_the_invoice_description($invoice) {
1461 1461
     $description = $invoice->get_description();
1462 1462
 
1463
-    if ( empty( $description ) ) {
1463
+    if (empty($description)) {
1464 1464
         return;
1465 1465
     }
1466 1466
 
1467
-    $description = wp_kses_post( $description );
1467
+    $description = wp_kses_post($description);
1468 1468
     echo "<small class='getpaid-invoice-description text-dark p-2 form-text'><em>$description</em></small>";
1469 1469
 }
1470
-add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 );
1470
+add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100);
1471 1471
 
1472 1472
 /**
1473 1473
  * Render element on a form.
@@ -1475,60 +1475,60 @@  discard block
 block discarded – undo
1475 1475
  * @param array $element
1476 1476
  * @param GetPaid_Payment_Form $form
1477 1477
  */
1478
-function getpaid_payment_form_element( $element, $form ) {
1478
+function getpaid_payment_form_element($element, $form) {
1479 1479
 
1480 1480
     // Set up the args.
1481
-    $element_type    = trim( $element['type'] );
1481
+    $element_type    = trim($element['type']);
1482 1482
     $element['form'] = $form;
1483
-    extract( $element );
1483
+    extract($element);
1484 1484
 
1485 1485
     // Try to locate the appropriate template.
1486
-    $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" );
1486
+    $located = wpinv_locate_template("payment-forms/elements/$element_type.php");
1487 1487
     
1488 1488
     // Abort if this is not our element.
1489
-    if ( empty( $located ) || ! file_exists( $located ) ) {
1489
+    if (empty($located) || !file_exists($located)) {
1490 1490
         return;
1491 1491
     }
1492 1492
 
1493 1493
     // Generate the class and id of the element.
1494
-    $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) );
1495
-    $id            = isset( $id ) ? $id : uniqid( 'gp' );
1494
+    $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type));
1495
+    $id            = isset($id) ? $id : uniqid('gp');
1496 1496
 
1497 1497
     // Echo the opening wrapper.
1498 1498
     echo "<div class='getpaid-payment-form-element $wrapper_class'>";
1499 1499
 
1500 1500
     // Fires before displaying a given element type's content.
1501
-    do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form );
1501
+    do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form);
1502 1502
 
1503 1503
     // Include the template for the element.
1504 1504
     include $located;
1505 1505
 
1506 1506
     // Fires after displaying a given element type's content.
1507
-    do_action( "getpaid_payment_form_{$element_type}_element", $element, $form );
1507
+    do_action("getpaid_payment_form_{$element_type}_element", $element, $form);
1508 1508
 
1509 1509
     // Echo the closing wrapper.
1510 1510
     echo '</div>';
1511 1511
 }
1512
-add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 );
1512
+add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2);
1513 1513
 
1514 1514
 /**
1515 1515
  * Render an element's edit page.
1516 1516
  *
1517 1517
  * @param WP_Post $post
1518 1518
  */
1519
-function getpaid_payment_form_edit_element_template( $post ) {
1519
+function getpaid_payment_form_edit_element_template($post) {
1520 1520
 
1521 1521
     // Retrieve all elements.
1522
-    $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' );
1522
+    $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type');
1523 1523
 
1524
-    foreach ( $all_elements as $element ) {
1524
+    foreach ($all_elements as $element) {
1525 1525
 
1526 1526
         // Try to locate the appropriate template.
1527
-        $element = sanitize_key( $element );
1528
-        $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" );
1527
+        $element = sanitize_key($element);
1528
+        $located = wpinv_locate_template("payment-forms-admin/edit/$element.php");
1529 1529
 
1530 1530
         // Continue if this is not our element.
1531
-        if ( empty( $located ) || ! file_exists( $located ) ) {
1531
+        if (empty($located) || !file_exists($located)) {
1532 1532
             continue;
1533 1533
         }
1534 1534
 
@@ -1539,7 +1539,7 @@  discard block
 block discarded – undo
1539 1539
     }
1540 1540
 
1541 1541
 }
1542
-add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' );
1542
+add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template');
1543 1543
 
1544 1544
 /**
1545 1545
  * Render an element's preview.
@@ -1548,16 +1548,16 @@  discard block
 block discarded – undo
1548 1548
 function getpaid_payment_form_render_element_preview_template() {
1549 1549
 
1550 1550
     // Retrieve all elements.
1551
-    $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' );
1551
+    $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type');
1552 1552
 
1553
-    foreach ( $all_elements as $element ) {
1553
+    foreach ($all_elements as $element) {
1554 1554
 
1555 1555
         // Try to locate the appropriate template.
1556
-        $element = sanitize_key( $element );
1557
-        $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" );
1556
+        $element = sanitize_key($element);
1557
+        $located = wpinv_locate_template("payment-forms-admin/previews/$element.php");
1558 1558
 
1559 1559
         // Continue if this is not our element.
1560
-        if ( empty( $located ) || ! file_exists( $located ) ) {
1560
+        if (empty($located) || !file_exists($located)) {
1561 1561
             continue;
1562 1562
         }
1563 1563
 
@@ -1568,7 +1568,7 @@  discard block
 block discarded – undo
1568 1568
     }
1569 1569
 
1570 1570
 }
1571
-add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' );
1571
+add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template');
1572 1572
 
1573 1573
 /**
1574 1574
  * Shows a list of gateways that support recurring payments.
@@ -1576,17 +1576,17 @@  discard block
 block discarded – undo
1576 1576
 function wpinv_get_recurring_gateways_text() {
1577 1577
     $gateways = array();
1578 1578
 
1579
-    foreach ( wpinv_get_payment_gateways() as $key => $gateway ) {
1580
-        if ( wpinv_gateway_support_subscription( $key ) ) {
1581
-            $gateways[] = sanitize_text_field( $gateway['admin_label'] );
1579
+    foreach (wpinv_get_payment_gateways() as $key => $gateway) {
1580
+        if (wpinv_gateway_support_subscription($key)) {
1581
+            $gateways[] = sanitize_text_field($gateway['admin_label']);
1582 1582
         }
1583 1583
     }
1584 1584
 
1585
-    if ( empty( $gateways ) ) {
1586
-        return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) ."</span>";
1585
+    if (empty($gateways)) {
1586
+        return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . "</span>";
1587 1587
     }
1588 1588
 
1589
-    return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>";
1589
+    return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>";
1590 1590
 
1591 1591
 }
1592 1592
 
@@ -1596,7 +1596,7 @@  discard block
 block discarded – undo
1596 1596
  * @return GetPaid_Template
1597 1597
  */
1598 1598
 function getpaid_template() {
1599
-    return getpaid()->get( 'template' );
1599
+    return getpaid()->get('template');
1600 1600
 }
1601 1601
 
1602 1602
 /**
@@ -1605,23 +1605,23 @@  discard block
 block discarded – undo
1605 1605
  * @param array args
1606 1606
  * @return string
1607 1607
  */
1608
-function getpaid_paginate_links( $args ) {
1608
+function getpaid_paginate_links($args) {
1609 1609
 
1610 1610
     $args['type']     = 'array';
1611 1611
     $args['mid_size'] = 1;
1612
-    $pages        = paginate_links( $args );
1612
+    $pages = paginate_links($args);
1613 1613
 
1614
-    if ( ! is_array( $pages ) ) {
1614
+    if (!is_array($pages)) {
1615 1615
         return '';
1616 1616
     }
1617 1617
 
1618 1618
     $_pages = array();
1619
-    foreach ( $pages as $page ) {
1620
-        $_pages[] = str_replace( 'page-numbers', 'page-link text-decoration-none', $page );
1619
+    foreach ($pages as $page) {
1620
+        $_pages[] = str_replace('page-numbers', 'page-link text-decoration-none', $page);
1621 1621
     }
1622 1622
 
1623 1623
     $links  = "<nav>\n\t<ul class='pagination justify-content-end m-0'>\n\t\t<li class='page-item'>";
1624
-    $links .= join( "</li>\n\t\t<li class='page-item'>", $_pages );
1624
+    $links .= join("</li>\n\t\t<li class='page-item'>", $_pages);
1625 1625
     $links .= "</li>\n\t</ul>\n</nav>\n";
1626 1626
 
1627 1627
     return $links;
@@ -1634,21 +1634,21 @@  discard block
 block discarded – undo
1634 1634
  * @param string state
1635 1635
  * @return string
1636 1636
  */
1637
-function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12' ) {
1637
+function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12') {
1638 1638
 
1639
-    $states = wpinv_get_country_states( $country );
1640
-    $uniqid = uniqid( '_' );
1639
+    $states = wpinv_get_country_states($country);
1640
+    $uniqid = uniqid('_');
1641 1641
 
1642
-    if ( ! empty( $states ) ) {
1642
+    if (!empty($states)) {
1643 1643
 
1644
-        return aui()->select( array(
1644
+        return aui()->select(array(
1645 1645
             'options'          => $states,
1646 1646
             'name'             => 'wpinv_state',
1647 1647
             'id'               => 'wpinv_state' . $uniqid,
1648
-            'value'            => sanitize_text_field( $state ),
1648
+            'value'            => sanitize_text_field($state),
1649 1649
             'placeholder'      => $placeholder,
1650 1650
             'required'         => $required,
1651
-            'label'            => wp_kses_post( $label ),
1651
+            'label'            => wp_kses_post($label),
1652 1652
             'label_type'       => 'vertical',
1653 1653
             'help_text'        => $help_text,
1654 1654
             'class'            => 'getpaid-address-field wpinv_state',
@@ -1664,10 +1664,10 @@  discard block
 block discarded – undo
1664 1664
             'id'          => 'wpinv_state' . $uniqid,
1665 1665
             'placeholder' => $placeholder,
1666 1666
             'required'    => $required,
1667
-            'label'       => wp_kses_post( $label ),
1667
+            'label'       => wp_kses_post($label),
1668 1668
             'label_type'  => 'vertical',
1669 1669
             'help_text'   => $help_text,
1670
-            'value'       => sanitize_text_field( $state ),
1670
+            'value'       => sanitize_text_field($state),
1671 1671
             'class'       => 'getpaid-address-field wpinv_state',
1672 1672
             'wrap_class'  => "$wrapper_class getpaid-address-field-wrapper__state",
1673 1673
             'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state',
@@ -1682,16 +1682,16 @@  discard block
 block discarded – undo
1682 1682
  * @param array element
1683 1683
  * @return string
1684 1684
  */
1685
-function getpaid_get_form_element_grid_class( $element ) {
1685
+function getpaid_get_form_element_grid_class($element) {
1686 1686
 
1687 1687
     $class = "col-12";
1688
-    $width = empty( $element['grid_width'] ) ? 'full' : $element['grid_width'];
1688
+    $width = empty($element['grid_width']) ? 'full' : $element['grid_width'];
1689 1689
 
1690
-    if ( $width == 'half' ) {
1690
+    if ($width == 'half') {
1691 1691
         $class = "col-12 col-md-6";
1692 1692
     }
1693 1693
 
1694
-    if ( $width == 'third' ) {
1694
+    if ($width == 'third') {
1695 1695
         $class = "col-12 col-md-4";
1696 1696
     }
1697 1697
 
Please login to merge, or discard this patch.
templates/payment-forms-admin/edit/address.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 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
 
@@ -31,44 +31,44 @@  discard block
 block discarded – undo
31 31
 
32 32
                 <div class='form-group'>
33 33
                     <label class="d-block">
34
-                        <span><?php esc_html_e( 'Field Label', 'invoicing' ); ?></span>
34
+                        <span><?php esc_html_e('Field Label', 'invoicing'); ?></span>
35 35
                         <input v-model='field.label' class='form-control' type="text"/>
36 36
                     </label>
37 37
                 </div>
38 38
 
39 39
                 <div class='form-group'>
40 40
                     <label class="d-block">
41
-                        <span><?php esc_html_e( 'Placeholder text', 'invoicing' ); ?></span>
41
+                        <span><?php esc_html_e('Placeholder text', 'invoicing'); ?></span>
42 42
                         <input v-model='field.placeholder' class='form-control' type="text"/>
43 43
                     </label>
44 44
                 </div>
45 45
 
46 46
                 <div class='form-group'>
47 47
                     <label class="d-block">
48
-                        <span><?php esc_html_e( 'Width', 'invoicing' ) ?></span>
48
+                        <span><?php esc_html_e('Width', 'invoicing') ?></span>
49 49
                         <select class='form-control custom-select' v-model='field.grid_width'>
50
-                            <option value='full'><?php esc_html_e( 'Full Width', 'invoicing' ); ?></option>
51
-                            <option value='half'><?php esc_html_e( 'Half Width', 'invoicing' ); ?></option>
52
-                            <option value='third'><?php esc_html_e( '1/3 Width', 'invoicing' ); ?></option>
50
+                            <option value='full'><?php esc_html_e('Full Width', 'invoicing'); ?></option>
51
+                            <option value='half'><?php esc_html_e('Half Width', 'invoicing'); ?></option>
52
+                            <option value='third'><?php esc_html_e('1/3 Width', 'invoicing'); ?></option>
53 53
                         </select>
54 54
                     </label>
55 55
                 </div>
56 56
 
57 57
                 <div class='form-group'>
58 58
                     <label class="d-block">
59
-                        <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span>
60
-                        <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='field.description' class='form-control' rows='3'></textarea>
59
+                        <span><?php esc_html_e('Help Text', 'invoicing'); ?></span>
60
+                        <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='field.description' class='form-control' rows='3'></textarea>
61 61
                     </label>
62 62
                 </div>
63 63
 
64 64
                 <div class='form-group form-check'>
65 65
                     <input :id="active_form_element.id + '_edit_required' + index" v-model='field.required' type='checkbox' class='form-check-input' />
66
-                    <label class='form-check-label' :for="active_form_element.id + '_edit_required' + index"><?php esc_html_e( 'Is required', 'invoicing' ); ?></label>
66
+                    <label class='form-check-label' :for="active_form_element.id + '_edit_required' + index"><?php esc_html_e('Is required', 'invoicing'); ?></label>
67 67
                 </div>
68 68
 
69 69
                 <div class='form-group form-check'>
70 70
                     <input :id="active_form_element.id + '_edit_visible' + index" v-model='field.visible' type='checkbox' class='form-check-input' />
71
-                    <label class='form-check-label' :for="active_form_element.id + '_edit_visible' + index"><?php esc_html_e( 'Is visible', 'invoicing' ); ?></label>
71
+                    <label class='form-check-label' :for="active_form_element.id + '_edit_visible' + index"><?php esc_html_e('Is visible', 'invoicing'); ?></label>
72 72
                 </div>
73 73
 
74 74
             </div>
Please login to merge, or discard this patch.
templates/payment-forms/form.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -7,44 +7,44 @@  discard block
 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
 // Make sure that the form is active.
13
-if ( ! $form->is_active() ) {
13
+if (!$form->is_active()) {
14 14
     echo aui()->alert(
15 15
         array(
16 16
             'type'    => 'warning',
17
-            'content' => __( 'This payment form is no longer active', 'invoicing' ),
17
+            'content' => __('This payment form is no longer active', 'invoicing'),
18 18
         )
19 19
     );
20 20
     return;
21 21
 }
22 22
 
23 23
 // Fires before displaying a payment form.
24
-do_action( 'getpaid_before_payment_form', $form );
24
+do_action('getpaid_before_payment_form', $form);
25 25
 ?>
26 26
 
27
-<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint( $form->get_id() ); ?> bsui' method='POST' data-key='<?php echo uniqid('gpf'); ?>'>
27
+<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint($form->get_id()); ?> bsui' method='POST' data-key='<?php echo uniqid('gpf'); ?>'>
28 28
 
29 29
 
30 30
     <?php 
31 31
     
32 32
         // Fires when printing the top of a payment form.
33
-        do_action( 'getpaid_payment_form_top', $form );
33
+        do_action('getpaid_payment_form_top', $form);
34 34
 
35 35
         // And the optional invoice id.
36
-        if ( ! empty( $form->invoice ) ) {
37
-            echo getpaid_hidden_field( 'invoice_id', $form->invoice->get_id() );
36
+        if (!empty($form->invoice)) {
37
+            echo getpaid_hidden_field('invoice_id', $form->invoice->get_id());
38 38
         }
39 39
 
40 40
         // We also want to include the form id.
41
-        echo getpaid_hidden_field( 'form_id', $form->get_id() );
41
+        echo getpaid_hidden_field('form_id', $form->get_id());
42 42
 
43 43
         // And an indication that this is a payment form submission.
44
-        echo getpaid_hidden_field( 'getpaid_payment_form_submission', '1' );
44
+        echo getpaid_hidden_field('getpaid_payment_form_submission', '1');
45 45
 
46 46
         // Fires before displaying payment form elements.
47
-        do_action( 'getpaid_payment_form_before_elements', $form );
47
+        do_action('getpaid_payment_form_before_elements', $form);
48 48
 
49 49
         // Display the elements.
50 50
         ?>
@@ -52,13 +52,13 @@  discard block
 block discarded – undo
52 52
             <div class="row">
53 53
                 <?php
54 54
 
55
-                    foreach ( $form->get_elements() as $element ) {
55
+                    foreach ($form->get_elements() as $element) {
56 56
 
57
-                        if ( isset( $element['type'] ) ) {
58
-                            $grid_class = esc_attr( getpaid_get_form_element_grid_class( $element ) );
57
+                        if (isset($element['type'])) {
58
+                            $grid_class = esc_attr(getpaid_get_form_element_grid_class($element));
59 59
                             echo "<div class='$grid_class'>";
60
-                            do_action( 'getpaid_payment_form_element', $element, $form );
61
-                            do_action( "getpaid_payment_form_element_{$element['type']}_template", $element, $form );
60
+                            do_action('getpaid_payment_form_element', $element, $form);
61
+                            do_action("getpaid_payment_form_element_{$element['type']}_template", $element, $form);
62 62
                             echo "</div>";
63 63
                         }
64 64
 
@@ -70,16 +70,16 @@  discard block
 block discarded – undo
70 70
 
71 71
         <?php
72 72
         // Fires after displaying payment form elements.
73
-        do_action( 'getpaid_payment_form_after_elements', $form );
73
+        do_action('getpaid_payment_form_after_elements', $form);
74 74
 
75 75
         echo "<div class='getpaid-payment-form-errors alert alert-danger d-none'></div>";
76 76
 
77
-        if ( wpinv_current_user_can_manage_invoicing() ) {
77
+        if (wpinv_current_user_can_manage_invoicing()) {
78 78
 
79 79
             edit_post_link(
80
-                __( 'Edit this form.', 'invoicing' ),
80
+                __('Edit this form.', 'invoicing'),
81 81
                 '<small class="form-text text-muted">',
82
-                '&nbsp;' . __( 'This is only visible to website administators.', 'invoicing' ) . '</small>',
82
+                '&nbsp;' . __('This is only visible to website administators.', 'invoicing') . '</small>',
83 83
                 $form->get_id(),
84 84
                 'text-danger'
85 85
             );
@@ -94,4 +94,4 @@  discard block
 block discarded – undo
94 94
 <?php
95 95
 
96 96
 // Fires after displaying a payment form.
97
-do_action( 'getpaid_after_payment_form', $form );
97
+do_action('getpaid_after_payment_form', $form);
Please login to merge, or discard this patch.
templates/payment-forms/elements/address.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -7,50 +7,50 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-if ( empty( $fields ) ) {
12
+if (empty($fields)) {
13 13
     return;
14 14
 }
15 15
 
16 16
 // Prepare the user's country.
17
-$country = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_country', true ) : '';
18
-$country = empty( $country ) ? wpinv_get_default_country() : $country;
17
+$country = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_country', true) : '';
18
+$country = empty($country) ? wpinv_get_default_country() : $country;
19 19
 
20 20
 // A prefix for all ids (so that a form can be included in the same page multiple times).
21
-$uniqid = uniqid( '_' );
21
+$uniqid = uniqid('_');
22 22
 
23 23
 echo "<div class='row'>";
24
-foreach ( $fields as $address_field ) {
24
+foreach ($fields as $address_field) {
25 25
 
26 26
     // Skip if it is hidden.
27
-    if ( empty( $address_field['visible'] ) ) {
27
+    if (empty($address_field['visible'])) {
28 28
         continue;
29 29
     }
30 30
 
31
-    $wrap_class  = getpaid_get_form_element_grid_class( $address_field );
32
-    $wrap_class  = esc_attr( "$wrap_class getpaid-address-field-wrapper" );
33
-    $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] );
34
-    $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] );
35
-    $value       = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_' . $address_field['name'], true ) : '';
36
-    $label       = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] );
31
+    $wrap_class  = getpaid_get_form_element_grid_class($address_field);
32
+    $wrap_class  = esc_attr("$wrap_class getpaid-address-field-wrapper");
33
+    $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']);
34
+    $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']);
35
+    $value       = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_' . $address_field['name'], true) : '';
36
+    $label       = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']);
37 37
 
38
-    if ( ! empty( $address_field['required'] ) ) {
38
+    if (!empty($address_field['required'])) {
39 39
         $label .= "<span class='text-danger'> *</span>";
40 40
     }
41 41
 
42 42
     // Display the country.
43
-    if ( 'wpinv_country' == $address_field['name'] ) {
43
+    if ('wpinv_country' == $address_field['name']) {
44 44
 
45 45
         echo aui()->select(
46 46
             array(
47 47
                 'options'     => wpinv_get_country_list(),
48 48
                 'name'        => 'wpinv_country',
49 49
                 'id'          => 'wpinv_country' . $uniqid,
50
-                'value'       => sanitize_text_field( $country ),
50
+                'value'       => sanitize_text_field($country),
51 51
                 'placeholder' => $placeholder,
52
-                'required'    => ! empty( $address_field['required'] ),
53
-                'label'       => wp_kses_post( $label ),
52
+                'required'    => !empty($address_field['required']),
53
+                'label'       => wp_kses_post($label),
54 54
                 'label_type'  => 'vertical',
55 55
                 'help_text'   => $description,
56 56
                 'class'       => 'getpaid-address-field wpinv_country',
@@ -63,39 +63,39 @@  discard block
 block discarded – undo
63 63
     }
64 64
 
65 65
     // Display the state.
66
-    if ( 'wpinv_state' == $address_field['name'] ) {
66
+    if ('wpinv_state' == $address_field['name']) {
67 67
 
68
-        if ( empty( $value ) ) {
68
+        if (empty($value)) {
69 69
             $value = wpinv_get_default_state();
70 70
         }
71 71
 
72
-        echo getpaid_get_states_select_markup (
72
+        echo getpaid_get_states_select_markup(
73 73
             $country,
74 74
             $value,
75 75
             $placeholder,
76 76
             $label,
77 77
             $description,
78
-            ! empty( $address_field['required'] ),
78
+            !empty($address_field['required']),
79 79
             $wrap_class
80 80
         );
81 81
 
82 82
         continue;
83 83
     }
84 84
 
85
-    $key = str_replace( 'wpinv_', '', $address_field['name'] );
86
-    $key = esc_attr( str_replace( '_', '-', $key ) );
85
+    $key = str_replace('wpinv_', '', $address_field['name']);
86
+    $key = esc_attr(str_replace('_', '-', $key));
87 87
     echo aui()->input(
88 88
         array(
89
-            'name'        => esc_attr( $address_field['name'] ),
90
-            'id'          => esc_attr( $address_field['name'] ) . $uniqid,
91
-            'required'    => ! empty( $address_field['required'] ),
89
+            'name'        => esc_attr($address_field['name']),
90
+            'id'          => esc_attr($address_field['name']) . $uniqid,
91
+            'required'    => !empty($address_field['required']),
92 92
             'placeholder' => $placeholder,
93
-            'label'       => wp_kses_post( $label ),
93
+            'label'       => wp_kses_post($label),
94 94
             'label_type'  => 'vertical',
95 95
             'help_text'   => $description,
96 96
             'type'        => 'text',
97 97
             'value'       => $value,
98
-            'class'       => 'getpaid-address-field ' . esc_attr( $address_field['name'] ),
98
+            'class'       => 'getpaid-address-field ' . esc_attr($address_field['name']),
99 99
             'wrap_class'  => "$wrap_class getpaid-address-field-wrapper__$key",
100 100
             'label_class' => 'getpaid-address-field-label getpaid-address-field-label__' . $key,
101 101
         )
Please login to merge, or discard this patch.