Passed
Push — master ( 5bb76a...9b8253 )
by Brian
09:28 queued 05:23
created
includes/class-wpinv-ajax.php 1 patch
Spacing   +210 added lines, -210 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,51 +311,51 @@  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
-                $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] );
341
-                $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] );
342
-                $value       = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_state', true ) : '';
343
-                $label       = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] );
340
+                $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']);
341
+                $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']);
342
+                $value       = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_state', true) : '';
343
+                $label       = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']);
344 344
 
345
-                if ( ! empty( $address_field['required'] ) ) {
345
+                if (!empty($address_field['required'])) {
346 346
                     $label .= "<span class='text-danger'> *</span>";
347 347
                 }
348 348
 
349
-                $html = getpaid_get_states_select_markup (
350
-                    sanitize_text_field( $_GET['country'] ),
349
+                $html = getpaid_get_states_select_markup(
350
+                    sanitize_text_field($_GET['country']),
351 351
                     $value,
352 352
                     $placeholder,
353 353
                     $label,
354 354
                     $description,
355
-                    ! empty( $address_field['required'] )
355
+                    !empty($address_field['required'])
356 356
                 );
357 357
 
358
-                wp_send_json_success( $html );
358
+                wp_send_json_success($html);
359 359
                 exit;
360 360
 
361 361
             }
@@ -371,56 +371,56 @@  discard block
 block discarded – undo
371 371
     public static function recalculate_invoice_totals() {
372 372
 
373 373
         // Verify nonce.
374
-        check_ajax_referer( 'wpinv-nonce' );
374
+        check_ajax_referer('wpinv-nonce');
375 375
 
376
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
376
+        if (!wpinv_current_user_can_manage_invoicing()) {
377 377
             exit;
378 378
         }
379 379
 
380 380
         // We need an invoice.
381
-        if ( empty( $_POST['post_id'] ) ) {
381
+        if (empty($_POST['post_id'])) {
382 382
             exit;
383 383
         }
384 384
 
385 385
         // Fetch the invoice.
386
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
386
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
387 387
 
388 388
         // Ensure it exists.
389
-        if ( ! $invoice->get_id() ) {
389
+        if (!$invoice->get_id()) {
390 390
             exit;
391 391
         }
392 392
 
393 393
         // Maybe set the country, state, currency.
394
-        foreach ( array( 'country', 'state', 'currency' ) as $key ) {
395
-            if ( isset( $_POST[ $key ] ) ) {
394
+        foreach (array('country', 'state', 'currency') as $key) {
395
+            if (isset($_POST[$key])) {
396 396
                 $method = "set_$key";
397
-                $invoice->$method( $_POST[ $key ] );
397
+                $invoice->$method($_POST[$key]);
398 398
             }
399 399
         }
400 400
 
401 401
         // Maybe disable taxes.
402
-        $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) );
402
+        $invoice->set_disable_taxes(!empty($_POST['taxes']));
403 403
 
404 404
         // Recalculate totals.
405 405
         $invoice->recalculate_total();
406 406
 
407
-        $total = wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() );
407
+        $total = wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency());
408 408
 
409
-        if ( $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) {
410
-            $recurring_total = wpinv_price( wpinv_format_amount( $invoice->get_recurring_total() ), $invoice->get_currency() );
411
-            $total          .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>';
409
+        if ($invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) {
410
+            $recurring_total = wpinv_price(wpinv_format_amount($invoice->get_recurring_total()), $invoice->get_currency());
411
+            $total          .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>';
412 412
         }
413 413
 
414 414
         $totals = array(
415
-            'subtotal' => wpinv_price( wpinv_format_amount( $invoice->get_subtotal() ), $invoice->get_currency() ),
416
-            'discount' => wpinv_price( wpinv_format_amount( $invoice->get_total_discount() ), $invoice->get_currency() ),
417
-            'tax'      => wpinv_price( wpinv_format_amount( $invoice->get_total_tax() ), $invoice->get_currency() ),
415
+            'subtotal' => wpinv_price(wpinv_format_amount($invoice->get_subtotal()), $invoice->get_currency()),
416
+            'discount' => wpinv_price(wpinv_format_amount($invoice->get_total_discount()), $invoice->get_currency()),
417
+            'tax'      => wpinv_price(wpinv_format_amount($invoice->get_total_tax()), $invoice->get_currency()),
418 418
             'total'    => $total,
419 419
         );
420 420
 
421
-        $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice );
421
+        $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice);
422 422
 
423
-        wp_send_json_success( compact( 'totals' ) );
423
+        wp_send_json_success(compact('totals'));
424 424
     }
425 425
 
426 426
     /**
@@ -429,33 +429,33 @@  discard block
 block discarded – undo
429 429
     public static function get_invoice_items() {
430 430
 
431 431
         // Verify nonce.
432
-        check_ajax_referer( 'wpinv-nonce' );
432
+        check_ajax_referer('wpinv-nonce');
433 433
 
434
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
434
+        if (!wpinv_current_user_can_manage_invoicing()) {
435 435
             exit;
436 436
         }
437 437
 
438 438
         // We need an invoice and items.
439
-        if ( empty( $_POST['post_id'] ) ) {
439
+        if (empty($_POST['post_id'])) {
440 440
             exit;
441 441
         }
442 442
 
443 443
         // Fetch the invoice.
444
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
444
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
445 445
 
446 446
         // Ensure it exists.
447
-        if ( ! $invoice->get_id() ) {
447
+        if (!$invoice->get_id()) {
448 448
             exit;
449 449
         }
450 450
 
451 451
         // Return an array of invoice items.
452 452
         $items = array();
453 453
 
454
-        foreach ( $invoice->get_items() as $item_id => $item ) {
455
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency()  );
454
+        foreach ($invoice->get_items() as $item_id => $item) {
455
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
456 456
         }
457 457
 
458
-        wp_send_json_success( compact( 'items' ) );
458
+        wp_send_json_success(compact('items'));
459 459
     }
460 460
 
461 461
     /**
@@ -464,50 +464,50 @@  discard block
 block discarded – undo
464 464
     public static function edit_invoice_item() {
465 465
 
466 466
         // Verify nonce.
467
-        check_ajax_referer( 'wpinv-nonce' );
467
+        check_ajax_referer('wpinv-nonce');
468 468
 
469
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
469
+        if (!wpinv_current_user_can_manage_invoicing()) {
470 470
             exit;
471 471
         }
472 472
 
473 473
         // We need an invoice and item details.
474
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) {
474
+        if (empty($_POST['post_id']) || empty($_POST['data'])) {
475 475
             exit;
476 476
         }
477 477
 
478 478
         // Fetch the invoice.
479
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
479
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
480 480
 
481 481
         // Ensure it exists and its not been paid for.
482
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
482
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
483 483
             exit;
484 484
         }
485 485
 
486 486
         // Format the data.
487
-        $data = wp_list_pluck( $_POST['data'], 'value', 'field' );
487
+        $data = wp_list_pluck($_POST['data'], 'value', 'field');
488 488
 
489 489
         // Ensure that we have an item id.
490
-        if ( empty( $data['id'] ) ) {
490
+        if (empty($data['id'])) {
491 491
             exit;
492 492
         }
493 493
 
494 494
         // Abort if the invoice does not have the specified item.
495
-        $item = $invoice->get_item( (int) $data['id'] );
495
+        $item = $invoice->get_item((int) $data['id']);
496 496
 
497
-        if ( empty( $item ) ) {
497
+        if (empty($item)) {
498 498
             exit;
499 499
         }
500 500
 
501 501
         // Update the item.
502
-        $item->set_price( $data['price'] );
503
-        $item->set_name( $data['name'] );
504
-        $item->set_description( $data['description'] );
505
-        $item->set_quantity( $data['quantity'] );
502
+        $item->set_price($data['price']);
503
+        $item->set_name($data['name']);
504
+        $item->set_description($data['description']);
505
+        $item->set_quantity($data['quantity']);
506 506
 
507 507
         // Add it to the invoice.
508
-        $error = $invoice->add_item( $item );
508
+        $error = $invoice->add_item($item);
509 509
         $alert = false;
510
-        if ( is_wp_error( $error ) ) {
510
+        if (is_wp_error($error)) {
511 511
             $alert = $error->get_error_message();
512 512
         }
513 513
 
@@ -520,11 +520,11 @@  discard block
 block discarded – undo
520 520
         // Return an array of invoice items.
521 521
         $items = array();
522 522
 
523
-        foreach ( $invoice->get_items() as $item_id => $item ) {
524
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency()  );
523
+        foreach ($invoice->get_items() as $item_id => $item) {
524
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
525 525
         }
526 526
 
527
-        wp_send_json_success( compact( 'items', 'alert' ) );
527
+        wp_send_json_success(compact('items', 'alert'));
528 528
     }
529 529
 
530 530
     /**
@@ -533,33 +533,33 @@  discard block
 block discarded – undo
533 533
     public static function remove_invoice_item() {
534 534
 
535 535
         // Verify nonce.
536
-        check_ajax_referer( 'wpinv-nonce' );
536
+        check_ajax_referer('wpinv-nonce');
537 537
 
538
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
538
+        if (!wpinv_current_user_can_manage_invoicing()) {
539 539
             exit;
540 540
         }
541 541
 
542 542
         // We need an invoice and an item.
543
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) {
543
+        if (empty($_POST['post_id']) || empty($_POST['item_id'])) {
544 544
             exit;
545 545
         }
546 546
 
547 547
         // Fetch the invoice.
548
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
548
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
549 549
 
550 550
         // Ensure it exists and its not been paid for.
551
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
551
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
552 552
             exit;
553 553
         }
554 554
 
555 555
         // Abort if the invoice does not have the specified item.
556
-        $item = $invoice->get_item( (int) $_POST['item_id'] );
556
+        $item = $invoice->get_item((int) $_POST['item_id']);
557 557
 
558
-        if ( empty( $item ) ) {
558
+        if (empty($item)) {
559 559
             exit;
560 560
         }
561 561
 
562
-        $invoice->remove_item( (int) $_POST['item_id'] );
562
+        $invoice->remove_item((int) $_POST['item_id']);
563 563
 
564 564
         // Update totals.
565 565
         $invoice->recalculate_total();
@@ -570,11 +570,11 @@  discard block
 block discarded – undo
570 570
         // Return an array of invoice items.
571 571
         $items = array();
572 572
 
573
-        foreach ( $invoice->get_items() as $item_id => $item ) {
574
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency()  );
573
+        foreach ($invoice->get_items() as $item_id => $item) {
574
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
575 575
         }
576 576
 
577
-        wp_send_json_success( compact( 'items' ) );
577
+        wp_send_json_success(compact('items'));
578 578
     }
579 579
 
580 580
     /**
@@ -583,39 +583,39 @@  discard block
 block discarded – undo
583 583
     public static function add_invoice_items() {
584 584
 
585 585
         // Verify nonce.
586
-        check_ajax_referer( 'wpinv-nonce' );
586
+        check_ajax_referer('wpinv-nonce');
587 587
 
588
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
588
+        if (!wpinv_current_user_can_manage_invoicing()) {
589 589
             exit;
590 590
         }
591 591
 
592 592
         // We need an invoice and items.
593
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) {
593
+        if (empty($_POST['post_id']) || empty($_POST['items'])) {
594 594
             exit;
595 595
         }
596 596
 
597 597
         // Fetch the invoice.
598
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
598
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
599 599
         $alert   = false;
600 600
 
601 601
         // Ensure it exists and its not been paid for.
602
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
602
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
603 603
             exit;
604 604
         }
605 605
 
606 606
         // Add the items.
607
-        foreach ( $_POST['items'] as $data ) {
607
+        foreach ($_POST['items'] as $data) {
608 608
 
609
-            $item = new GetPaid_Form_Item( $data[ 'id' ] );
609
+            $item = new GetPaid_Form_Item($data['id']);
610 610
 
611
-            if ( is_numeric( $data[ 'qty' ] ) && (int) $data[ 'qty' ] > 0 ) {
612
-                $item->set_quantity( $data[ 'qty' ] );
611
+            if (is_numeric($data['qty']) && (int) $data['qty'] > 0) {
612
+                $item->set_quantity($data['qty']);
613 613
             }
614 614
 
615
-            if ( $item->get_id() > 0 ) {
616
-                $error = $invoice->add_item( $item );
615
+            if ($item->get_id() > 0) {
616
+                $error = $invoice->add_item($item);
617 617
 
618
-                if ( is_wp_error( $error ) ) {
618
+                if (is_wp_error($error)) {
619 619
                     $alert = $error->get_error_message();
620 620
                 }
621 621
 
@@ -630,11 +630,11 @@  discard block
 block discarded – undo
630 630
         // Return an array of invoice items.
631 631
         $items = array();
632 632
 
633
-        foreach ( $invoice->get_items() as $item_id => $item ) {
634
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() );
633
+        foreach ($invoice->get_items() as $item_id => $item) {
634
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
635 635
         }
636 636
 
637
-        wp_send_json_success( compact( 'items', 'alert' ) );
637
+        wp_send_json_success(compact('items', 'alert'));
638 638
     }
639 639
 
640 640
     /**
@@ -643,15 +643,15 @@  discard block
 block discarded – undo
643 643
     public static function get_invoicing_items() {
644 644
 
645 645
         // Verify nonce.
646
-        check_ajax_referer( 'wpinv-nonce' );
646
+        check_ajax_referer('wpinv-nonce');
647 647
 
648
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
648
+        if (!wpinv_current_user_can_manage_invoicing()) {
649 649
             exit;
650 650
         }
651 651
 
652 652
         // We need a search term.
653
-        if ( empty( $_GET['search'] ) ) {
654
-            wp_send_json_success( array() );
653
+        if (empty($_GET['search'])) {
654
+            wp_send_json_success(array());
655 655
         }
656 656
 
657 657
         // Retrieve items.
@@ -660,8 +660,8 @@  discard block
 block discarded – undo
660 660
             'orderby'        => 'title',
661 661
             'order'          => 'ASC',
662 662
             'posts_per_page' => -1,
663
-            'post_status'    => array( 'publish' ),
664
-            's'              => trim( $_GET['search'] ),
663
+            'post_status'    => array('publish'),
664
+            's'              => trim($_GET['search']),
665 665
             'meta_query'     => array(
666 666
                 array(
667 667
                     'key'       => '_wpinv_type',
@@ -671,22 +671,22 @@  discard block
 block discarded – undo
671 671
             )
672 672
         );
673 673
 
674
-        $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) );
674
+        $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args));
675 675
         $data  = array();
676 676
 
677 677
 
678
-        $is_payment_form = ( ! empty( $_GET['post_id'] ) && 'wpi_payment_form' == get_post_type( $_GET['post_id'] ) );
678
+        $is_payment_form = (!empty($_GET['post_id']) && 'wpi_payment_form' == get_post_type($_GET['post_id']));
679 679
 
680
-        foreach ( $items as $item ) {
681
-            $item      = new GetPaid_Form_Item( $item );
680
+        foreach ($items as $item) {
681
+            $item = new GetPaid_Form_Item($item);
682 682
             $data[] = array(
683 683
                 'id'        => (int) $item->get_id(),
684
-                'text'      => strip_tags( $item->get_name() ),
685
-                'form_data' => $is_payment_form ? $item->prepare_data_for_use( false ) : '',
684
+                'text'      => strip_tags($item->get_name()),
685
+                'form_data' => $is_payment_form ? $item->prepare_data_for_use(false) : '',
686 686
             );
687 687
         }
688 688
 
689
-        wp_send_json_success( $data );
689
+        wp_send_json_success($data);
690 690
 
691 691
     }
692 692
 
@@ -696,24 +696,24 @@  discard block
 block discarded – undo
696 696
     public static function get_aui_states_field() {
697 697
 
698 698
         // Verify nonce.
699
-        check_ajax_referer( 'wpinv-nonce' );
699
+        check_ajax_referer('wpinv-nonce');
700 700
 
701 701
         // We need a country.
702
-        if ( empty( $_GET['country'] ) ) {
702
+        if (empty($_GET['country'])) {
703 703
             exit;
704 704
         }
705 705
 
706
-        $states = wpinv_get_country_states( trim( $_GET['country'] ) );
707
-        $state  = isset( $_GET['state'] ) ? trim( $_GET['state'] ) : wpinv_get_default_state();
706
+        $states = wpinv_get_country_states(trim($_GET['country']));
707
+        $state  = isset($_GET['state']) ? trim($_GET['state']) : wpinv_get_default_state();
708 708
 
709
-        if ( empty( $states ) ) {
709
+        if (empty($states)) {
710 710
 
711 711
             $html = aui()->input(
712 712
                 array(
713 713
                     'type'        => 'text',
714 714
                     'id'          => 'wpinv_state',
715 715
                     'name'        => 'wpinv_state',
716
-                    'label'       => __( 'State', 'invoicing' ),
716
+                    'label'       => __('State', 'invoicing'),
717 717
                     'label_type'  => 'vertical',
718 718
                     'placeholder' => 'Liège',
719 719
                     'class'       => 'form-control-sm',
@@ -727,9 +727,9 @@  discard block
 block discarded – undo
727 727
                 array(
728 728
                     'id'          => 'wpinv_state',
729 729
                     'name'        => 'wpinv_state',
730
-                    'label'       => __( 'State', 'invoicing' ),
730
+                    'label'       => __('State', 'invoicing'),
731 731
                     'label_type'  => 'vertical',
732
-                    'placeholder' => __( 'Select a state', 'invoicing' ),
732
+                    'placeholder' => __('Select a state', 'invoicing'),
733 733
                     'class'       => 'form-control-sm',
734 734
                     'value'       => $state,
735 735
                     'options'     => $states,
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
         wp_send_json_success(
744 744
             array(
745 745
                 'html'   => $html,
746
-                'select' => ! empty ( $states )
746
+                'select' => !empty ($states)
747 747
             )
748 748
         );
749 749
 
@@ -757,46 +757,46 @@  discard block
 block discarded – undo
757 757
     public static function ip_geolocation() {
758 758
 
759 759
         // Check nonce.
760
-        check_ajax_referer( 'getpaid-ip-location' );
760
+        check_ajax_referer('getpaid-ip-location');
761 761
 
762 762
         // IP address.
763
-        if ( empty( $_GET['ip'] ) || ! rest_is_ip_address( $_GET['ip'] ) ) {
764
-            _e( 'Invalid IP Address.', 'invoicing' );
763
+        if (empty($_GET['ip']) || !rest_is_ip_address($_GET['ip'])) {
764
+            _e('Invalid IP Address.', 'invoicing');
765 765
             exit;
766 766
         }
767 767
 
768 768
         // Retrieve location info.
769
-        $location = getpaid_geolocate_ip_address( $_GET['ip'] );
769
+        $location = getpaid_geolocate_ip_address($_GET['ip']);
770 770
 
771
-        if ( empty( $location ) ) {
772
-            _e( 'Unable to find geolocation for the IP Address.', 'invoicing' );
771
+        if (empty($location)) {
772
+            _e('Unable to find geolocation for the IP Address.', 'invoicing');
773 773
             exit;
774 774
         }
775 775
 
776 776
         // Sorry.
777
-        extract( $location );
777
+        extract($location);
778 778
 
779 779
         // Prepare the address.
780 780
         $content = '';
781 781
 
782
-        if ( ! empty( $location['city'] ) ) {
783
-            $content .=  $location['city']  . ', ';
782
+        if (!empty($location['city'])) {
783
+            $content .= $location['city'] . ', ';
784 784
         }
785 785
         
786
-        if ( ! empty( $location['region'] ) ) {
787
-            $content .=  $location['region']  . ', ';
786
+        if (!empty($location['region'])) {
787
+            $content .= $location['region'] . ', ';
788 788
         }
789 789
         
790
-        $content .=  $location['country'] . ' (' . $location['iso'] . ')';
790
+        $content .= $location['country'] . ' (' . $location['iso'] . ')';
791 791
 
792 792
         $location['address'] = $content;
793 793
 
794
-        $content  = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $content ) . '</p>';
795
-        $content .= '<p>'. $location['credit'] . '</p>';
794
+        $content  = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $content) . '</p>';
795
+        $content .= '<p>' . $location['credit'] . '</p>';
796 796
 
797 797
         $location['content'] = $content;
798 798
 
799
-        wpinv_get_template( 'geolocation.php', $location );
799
+        wpinv_get_template('geolocation.php', $location);
800 800
 
801 801
         exit;
802 802
     }
@@ -809,11 +809,11 @@  discard block
 block discarded – undo
809 809
     public static function payment_form_refresh_prices() {
810 810
 
811 811
         // Check nonce.
812
-        check_ajax_referer( 'getpaid_form_nonce' );
812
+        check_ajax_referer('getpaid_form_nonce');
813 813
 
814 814
         // ... form fields...
815
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
816
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
815
+        if (empty($_POST['getpaid_payment_form_submission'])) {
816
+            _e('Error: Reload the page and try again.', 'invoicing');
817 817
             exit;
818 818
         }
819 819
 
@@ -821,18 +821,18 @@  discard block
 block discarded – undo
821 821
         $submission = new GetPaid_Payment_Form_Submission();
822 822
 
823 823
         // Do we have an error?
824
-        if ( ! empty( $submission->last_error ) ) {
824
+        if (!empty($submission->last_error)) {
825 825
             echo $submission->last_error;
826 826
             exit;
827 827
         }
828 828
 
829 829
         // Prepare the response.
830
-        $response = new GetPaid_Payment_Form_Submission_Refresh_Prices( $submission );
830
+        $response = new GetPaid_Payment_Form_Submission_Refresh_Prices($submission);
831 831
         
832 832
         // Filter the response.
833
-        $response = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $response->response, $submission );
833
+        $response = apply_filters('getpaid_payment_form_ajax_refresh_prices', $response->response, $submission);
834 834
 
835
-        wp_send_json_success( $response );
835
+        wp_send_json_success($response);
836 836
     }
837 837
 
838 838
 }
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 1 patch
Spacing   +475 added lines, -475 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 ) {
1637
+function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false) {
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'  => 'getpaid-address-field-wrapper getpaid-address-field-wrapper__state',
1673 1673
             'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state',
Please login to merge, or discard this patch.
templates/payment-forms/form.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -7,64 +7,64 @@  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
-        foreach ( $form->get_elements() as $element ) {
51
-            if ( isset( $element['type'] ) ) {
52
-                do_action( 'getpaid_payment_form_element', $element, $form );
53
-                do_action( "getpaid_payment_form_element_{$element['type']}_template", $element, $form );
50
+        foreach ($form->get_elements() as $element) {
51
+            if (isset($element['type'])) {
52
+                do_action('getpaid_payment_form_element', $element, $form);
53
+                do_action("getpaid_payment_form_element_{$element['type']}_template", $element, $form);
54 54
             }
55 55
         }
56 56
 
57 57
         // Fires after displaying payment form elements.
58
-        do_action( 'getpaid_payment_form_after_elements', $form );
58
+        do_action('getpaid_payment_form_after_elements', $form);
59 59
 
60 60
         echo "<div class='getpaid-payment-form-errors alert alert-danger d-none'></div>";
61 61
 
62
-        if ( wpinv_current_user_can_manage_invoicing() ) {
62
+        if (wpinv_current_user_can_manage_invoicing()) {
63 63
 
64 64
             edit_post_link(
65
-                __( 'Edit this form.', 'invoicing' ),
65
+                __('Edit this form.', 'invoicing'),
66 66
                 '<small class="form-text text-muted">',
67
-                '&nbsp;' . __( 'This is only visible to website administators.', 'invoicing' ) . '</small>',
67
+                '&nbsp;' . __('This is only visible to website administators.', 'invoicing') . '</small>',
68 68
                 $form->get_id(),
69 69
                 'text-danger'
70 70
             );
@@ -79,4 +79,4 @@  discard block
 block discarded – undo
79 79
 <?php
80 80
 
81 81
 // Fires after displaying a payment form.
82
-do_action( 'getpaid_after_payment_form', $form );
82
+do_action('getpaid_after_payment_form', $form);
Please login to merge, or discard this patch.
templates/payment-forms/elements/address.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -7,47 +7,47 @@  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
-foreach ( $fields as $address_field ) {
23
+foreach ($fields as $address_field) {
24 24
 
25 25
     // Skip if it is hidden.
26
-    if ( empty( $address_field['visible'] ) ) {
26
+    if (empty($address_field['visible'])) {
27 27
         continue;
28 28
     }
29 29
 
30
-    $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] );
31
-    $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] );
32
-    $value       = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_' . $address_field['name'], true ) : '';
33
-    $label       = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] );
30
+    $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']);
31
+    $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']);
32
+    $value       = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_' . $address_field['name'], true) : '';
33
+    $label       = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']);
34 34
 
35
-    if ( ! empty( $address_field['required'] ) ) {
35
+    if (!empty($address_field['required'])) {
36 36
         $label .= "<span class='text-danger'> *</span>";
37 37
     }
38 38
 
39 39
     // Display the country.
40
-    if ( 'wpinv_country' == $address_field['name'] ) {
40
+    if ('wpinv_country' == $address_field['name']) {
41 41
 
42 42
         echo aui()->select(
43 43
             array(
44 44
                 'options'     => wpinv_get_country_list(),
45 45
                 'name'        => 'wpinv_country',
46 46
                 'id'          => 'wpinv_country' . $uniqid,
47
-                'value'       => sanitize_text_field( $country ),
47
+                'value'       => sanitize_text_field($country),
48 48
                 'placeholder' => $placeholder,
49
-                'required'    => ! empty( $address_field['required'] ),
50
-                'label'       => wp_kses_post( $label ),
49
+                'required'    => !empty($address_field['required']),
50
+                'label'       => wp_kses_post($label),
51 51
                 'label_type'  => 'vertical',
52 52
                 'help_text'   => $description,
53 53
                 'class'       => 'getpaid-address-field wpinv_country',
@@ -60,38 +60,38 @@  discard block
 block discarded – undo
60 60
     }
61 61
 
62 62
     // Display the state.
63
-    if ( 'wpinv_state' == $address_field['name'] ) {
63
+    if ('wpinv_state' == $address_field['name']) {
64 64
 
65
-        if ( empty( $value ) ) {
65
+        if (empty($value)) {
66 66
             $value = wpinv_get_default_state();
67 67
         }
68 68
 
69
-        echo getpaid_get_states_select_markup (
69
+        echo getpaid_get_states_select_markup(
70 70
             $country,
71 71
             $value,
72 72
             $placeholder,
73 73
             $label,
74 74
             $description,
75
-            ! empty( $address_field['required'] )
75
+            !empty($address_field['required'])
76 76
         );
77 77
 
78 78
         continue;
79 79
     }
80 80
 
81
-    $key = str_replace( 'wpinv_', '', $address_field['name'] );
82
-    $key = esc_attr( str_replace( '_', '-', $key ) );
81
+    $key = str_replace('wpinv_', '', $address_field['name']);
82
+    $key = esc_attr(str_replace('_', '-', $key));
83 83
     echo aui()->input(
84 84
         array(
85
-            'name'        => esc_attr( $address_field['name'] ),
86
-            'id'          => esc_attr( $address_field['name'] ) . $uniqid,
87
-            'required'    => ! empty( $address_field['required'] ),
85
+            'name'        => esc_attr($address_field['name']),
86
+            'id'          => esc_attr($address_field['name']) . $uniqid,
87
+            'required'    => !empty($address_field['required']),
88 88
             'placeholder' => $placeholder,
89
-            'label'       => wp_kses_post( $label ),
89
+            'label'       => wp_kses_post($label),
90 90
             'label_type'  => 'vertical',
91 91
             'help_text'   => $description,
92 92
             'type'        => 'text',
93 93
             'value'       => $value,
94
-            'class'       => 'getpaid-address-field ' . esc_attr( $address_field['name'] ),
94
+            'class'       => 'getpaid-address-field ' . esc_attr($address_field['name']),
95 95
             'wrap_class'  => 'getpaid-address-field-wrapper getpaid-address-field-wrapper__' . $key,
96 96
             'label_class' => 'getpaid-address-field-label getpaid-address-field-label__' . $key,
97 97
         )
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-input.php 3 patches
Indentation   +1002 added lines, -1002 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,1012 +11,1012 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Input {
13 13
 
14
-	/**
15
-	 * Build the component.
16
-	 *
17
-	 * @param array $args
18
-	 *
19
-	 * @return string The rendered component.
20
-	 */
21
-	public static function input($args = array()){
22
-		$defaults = array(
23
-			'type'       => 'text',
24
-			'name'       => '',
25
-			'class'      => '',
26
-			'wrap_class' => '',
27
-			'id'         => '',
28
-			'placeholder'=> '',
29
-			'title'      => '',
30
-			'value'      => '',
31
-			'required'   => false,
32
-			'label'      => '',
33
-			'label_after'=> false,
34
-			'label_class'=> '',
35
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
36
-			'help_text'  => '',
37
-			'validation_text'   => '',
38
-			'validation_pattern' => '',
39
-			'no_wrap'    => false,
40
-			'input_group_right' => '',
41
-			'input_group_left' => '',
42
-			'input_group_right_inside' => false, // forces the input group inside the input
43
-			'input_group_left_inside' => false, // forces the input group inside the input
44
-			'step'       => '',
45
-			'switch'     => false, // to show checkbox as a switch
46
-			'checked'   => false, // set a checkbox or radio as selected
47
-			'password_toggle' => true, // toggle view/hide password
48
-			'element_require'   => '', // [%element_id%] == "1"
49
-			'extra_attributes'  => array() // an array of extra attributes
50
-		);
51
-
52
-		/**
53
-		 * Parse incoming $args into an array and merge it with $defaults
54
-		 */
55
-		$args   = wp_parse_args( $args, $defaults );
56
-		$output = '';
57
-		if ( ! empty( $args['type'] ) ) {
58
-			// hidden label option needs to be empty
59
-			$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
60
-
61
-			$type = sanitize_html_class( $args['type'] );
62
-
63
-			$help_text = '';
64
-			$label = '';
65
-			$label_after = $args['label_after'];
66
-			$label_args = array(
67
-				'title'=> $args['label'],
68
-				'for'=> $args['id'],
69
-				'class' => $args['label_class']." ",
70
-				'label_type' => $args['label_type']
71
-			);
72
-
73
-			// floating labels need label after
74
-			if( $args['label_type'] == 'floating' && $type != 'checkbox' ){
75
-				$label_after = true;
76
-				$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
77
-			}
78
-
79
-			// Some special sauce for files
80
-			if($type=='file' ){
81
-				$label_after = true; // if type file we need the label after
82
-				$args['class'] .= ' custom-file-input ';
83
-			}elseif($type=='checkbox'){
84
-				$label_after = true; // if type file we need the label after
85
-				$args['class'] .= ' custom-control-input ';
86
-			}elseif($type=='datepicker' || $type=='timepicker'){
87
-				$type = 'text';
88
-				//$args['class'] .= ' aui-flatpickr bg-initial ';
89
-				$args['class'] .= ' bg-initial ';
90
-
91
-				$args['extra_attributes']['data-aui-init'] = 'flatpickr';
92
-				// enqueue the script
93
-				$aui_settings = AyeCode_UI_Settings::instance();
94
-				$aui_settings->enqueue_flatpickr();
95
-			}
96
-
97
-
98
-			// open/type
99
-			$output .= '<input type="' . $type . '" ';
100
-
101
-			// name
102
-			if(!empty($args['name'])){
103
-				$output .= ' name="'.esc_attr($args['name']).'" ';
104
-			}
105
-
106
-			// id
107
-			if(!empty($args['id'])){
108
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
109
-			}
110
-
111
-			// placeholder
112
-			if(isset($args['placeholder']) && '' != $args['placeholder'] ){
113
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
114
-			}
115
-
116
-			// title
117
-			if(!empty($args['title'])){
118
-				$output .= ' title="'.esc_attr($args['title']).'" ';
119
-			}
120
-
121
-			// value
122
-			if(!empty($args['value'])){
123
-				$output .= ' value="'.sanitize_text_field($args['value']).'" ';
124
-			}
125
-
126
-			// checked, for radio and checkboxes
127
-			if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){
128
-				$output .= ' checked ';
129
-			}
130
-
131
-			// validation text
132
-			if(!empty($args['validation_text'])){
133
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
134
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
135
-			}
136
-
137
-			// validation_pattern
138
-			if(!empty($args['validation_pattern'])){
139
-				$output .= ' pattern="'.$args['validation_pattern'].'" ';
140
-			}
141
-
142
-			// step (for numbers)
143
-			if(!empty($args['step'])){
144
-				$output .= ' step="'.$args['step'].'" ';
145
-			}
146
-
147
-			// required
148
-			if(!empty($args['required'])){
149
-				$output .= ' required ';
150
-			}
151
-
152
-			// class
153
-			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
154
-			$output .= ' class="form-control '.$class.'" ';
155
-
156
-			// data-attributes
157
-			$output .= AUI_Component_Helper::data_attributes($args);
158
-
159
-			// extra attributes
160
-			if(!empty($args['extra_attributes'])){
161
-				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
162
-			}
163
-
164
-			// close
165
-			$output .= ' >';
166
-
167
-
168
-			// label
169
-			if(!empty($args['label'])){
170
-				if($type == 'file'){$label_args['class'] .= 'custom-file-label';}
171
-				elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
172
-				$label = self::label( $label_args, $type );
173
-			}
174
-
175
-			// help text
176
-			if(!empty($args['help_text'])){
177
-				$help_text = AUI_Component_Helper::help_text($args['help_text']);
178
-			}
179
-
180
-
181
-			// set help text in the correct possition
182
-			if($label_after){
183
-				$output .= $label . $help_text;
184
-			}
185
-
186
-			// some input types need a separate wrap
187
-			if($type == 'file') {
188
-				$output = self::wrap( array(
189
-					'content' => $output,
190
-					'class'   => 'form-group custom-file'
191
-				) );
192
-			}elseif($type == 'checkbox'){
193
-				$wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
194
-				$output = self::wrap( array(
195
-					'content' => $output,
196
-					'class'   => 'custom-control '.$wrap_class
197
-				) );
198
-
199
-				if($args['label_type']=='horizontal'){
200
-					$output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
201
-				}
202
-			}elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
203
-
204
-
205
-				// allow password field to toggle view
206
-				$args['input_group_right'] = '<span class="input-group-text c-pointer px-3" 
14
+    /**
15
+     * Build the component.
16
+     *
17
+     * @param array $args
18
+     *
19
+     * @return string The rendered component.
20
+     */
21
+    public static function input($args = array()){
22
+        $defaults = array(
23
+            'type'       => 'text',
24
+            'name'       => '',
25
+            'class'      => '',
26
+            'wrap_class' => '',
27
+            'id'         => '',
28
+            'placeholder'=> '',
29
+            'title'      => '',
30
+            'value'      => '',
31
+            'required'   => false,
32
+            'label'      => '',
33
+            'label_after'=> false,
34
+            'label_class'=> '',
35
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
36
+            'help_text'  => '',
37
+            'validation_text'   => '',
38
+            'validation_pattern' => '',
39
+            'no_wrap'    => false,
40
+            'input_group_right' => '',
41
+            'input_group_left' => '',
42
+            'input_group_right_inside' => false, // forces the input group inside the input
43
+            'input_group_left_inside' => false, // forces the input group inside the input
44
+            'step'       => '',
45
+            'switch'     => false, // to show checkbox as a switch
46
+            'checked'   => false, // set a checkbox or radio as selected
47
+            'password_toggle' => true, // toggle view/hide password
48
+            'element_require'   => '', // [%element_id%] == "1"
49
+            'extra_attributes'  => array() // an array of extra attributes
50
+        );
51
+
52
+        /**
53
+         * Parse incoming $args into an array and merge it with $defaults
54
+         */
55
+        $args   = wp_parse_args( $args, $defaults );
56
+        $output = '';
57
+        if ( ! empty( $args['type'] ) ) {
58
+            // hidden label option needs to be empty
59
+            $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
60
+
61
+            $type = sanitize_html_class( $args['type'] );
62
+
63
+            $help_text = '';
64
+            $label = '';
65
+            $label_after = $args['label_after'];
66
+            $label_args = array(
67
+                'title'=> $args['label'],
68
+                'for'=> $args['id'],
69
+                'class' => $args['label_class']." ",
70
+                'label_type' => $args['label_type']
71
+            );
72
+
73
+            // floating labels need label after
74
+            if( $args['label_type'] == 'floating' && $type != 'checkbox' ){
75
+                $label_after = true;
76
+                $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
77
+            }
78
+
79
+            // Some special sauce for files
80
+            if($type=='file' ){
81
+                $label_after = true; // if type file we need the label after
82
+                $args['class'] .= ' custom-file-input ';
83
+            }elseif($type=='checkbox'){
84
+                $label_after = true; // if type file we need the label after
85
+                $args['class'] .= ' custom-control-input ';
86
+            }elseif($type=='datepicker' || $type=='timepicker'){
87
+                $type = 'text';
88
+                //$args['class'] .= ' aui-flatpickr bg-initial ';
89
+                $args['class'] .= ' bg-initial ';
90
+
91
+                $args['extra_attributes']['data-aui-init'] = 'flatpickr';
92
+                // enqueue the script
93
+                $aui_settings = AyeCode_UI_Settings::instance();
94
+                $aui_settings->enqueue_flatpickr();
95
+            }
96
+
97
+
98
+            // open/type
99
+            $output .= '<input type="' . $type . '" ';
100
+
101
+            // name
102
+            if(!empty($args['name'])){
103
+                $output .= ' name="'.esc_attr($args['name']).'" ';
104
+            }
105
+
106
+            // id
107
+            if(!empty($args['id'])){
108
+                $output .= ' id="'.sanitize_html_class($args['id']).'" ';
109
+            }
110
+
111
+            // placeholder
112
+            if(isset($args['placeholder']) && '' != $args['placeholder'] ){
113
+                $output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
114
+            }
115
+
116
+            // title
117
+            if(!empty($args['title'])){
118
+                $output .= ' title="'.esc_attr($args['title']).'" ';
119
+            }
120
+
121
+            // value
122
+            if(!empty($args['value'])){
123
+                $output .= ' value="'.sanitize_text_field($args['value']).'" ';
124
+            }
125
+
126
+            // checked, for radio and checkboxes
127
+            if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){
128
+                $output .= ' checked ';
129
+            }
130
+
131
+            // validation text
132
+            if(!empty($args['validation_text'])){
133
+                $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
134
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
135
+            }
136
+
137
+            // validation_pattern
138
+            if(!empty($args['validation_pattern'])){
139
+                $output .= ' pattern="'.$args['validation_pattern'].'" ';
140
+            }
141
+
142
+            // step (for numbers)
143
+            if(!empty($args['step'])){
144
+                $output .= ' step="'.$args['step'].'" ';
145
+            }
146
+
147
+            // required
148
+            if(!empty($args['required'])){
149
+                $output .= ' required ';
150
+            }
151
+
152
+            // class
153
+            $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
154
+            $output .= ' class="form-control '.$class.'" ';
155
+
156
+            // data-attributes
157
+            $output .= AUI_Component_Helper::data_attributes($args);
158
+
159
+            // extra attributes
160
+            if(!empty($args['extra_attributes'])){
161
+                $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
162
+            }
163
+
164
+            // close
165
+            $output .= ' >';
166
+
167
+
168
+            // label
169
+            if(!empty($args['label'])){
170
+                if($type == 'file'){$label_args['class'] .= 'custom-file-label';}
171
+                elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
172
+                $label = self::label( $label_args, $type );
173
+            }
174
+
175
+            // help text
176
+            if(!empty($args['help_text'])){
177
+                $help_text = AUI_Component_Helper::help_text($args['help_text']);
178
+            }
179
+
180
+
181
+            // set help text in the correct possition
182
+            if($label_after){
183
+                $output .= $label . $help_text;
184
+            }
185
+
186
+            // some input types need a separate wrap
187
+            if($type == 'file') {
188
+                $output = self::wrap( array(
189
+                    'content' => $output,
190
+                    'class'   => 'form-group custom-file'
191
+                ) );
192
+            }elseif($type == 'checkbox'){
193
+                $wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
194
+                $output = self::wrap( array(
195
+                    'content' => $output,
196
+                    'class'   => 'custom-control '.$wrap_class
197
+                ) );
198
+
199
+                if($args['label_type']=='horizontal'){
200
+                    $output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
201
+                }
202
+            }elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
203
+
204
+
205
+                // allow password field to toggle view
206
+                $args['input_group_right'] = '<span class="input-group-text c-pointer px-3" 
207 207
 onclick="var $el = jQuery(this).find(\'i\');$el.toggleClass(\'fa-eye fa-eye-slash\');
208 208
 var $eli = jQuery(this).parent().parent().find(\'input\');
209 209
 if($el.hasClass(\'fa-eye\'))
210 210
 {$eli.attr(\'type\',\'text\');}
211 211
 else{$eli.attr(\'type\',\'password\');}"
212 212
 ><i class="far fa-fw fa-eye-slash"></i></span>';
213
-			}
214
-
215
-			// input group wraps
216
-			if($args['input_group_left'] || $args['input_group_right']){
217
-				$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
218
-				if($args['input_group_left']){
219
-					$output = self::wrap( array(
220
-						'content' => $output,
221
-						'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100  : 'input-group',
222
-						'input_group_left' => $args['input_group_left'],
223
-						'input_group_left_inside'    => $args['input_group_left_inside']
224
-					) );
225
-				}
226
-				if($args['input_group_right']){
227
-					$output = self::wrap( array(
228
-						'content' => $output,
229
-						'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group',
230
-						'input_group_right' => $args['input_group_right'],
231
-						'input_group_right_inside'    => $args['input_group_right_inside']
232
-					) );
233
-				}
234
-
235
-			}
236
-
237
-			if(!$label_after){
238
-				$output .= $help_text;
239
-			}
240
-
241
-
242
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
243
-				$output = self::wrap( array(
244
-					'content' => $output,
245
-					'class'   => 'col-sm-10',
246
-				) );
247
-			}
248
-
249
-			if(!$label_after){
250
-				$output = $label . $output;
251
-			}
252
-
253
-			// wrap
254
-			if(!$args['no_wrap']){
255
-
256
-				$form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
257
-				$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
258
-				$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
259
-				$output = self::wrap(array(
260
-					'content' => $output,
261
-					'class'   => $wrap_class,
262
-					'element_require'   => $args['element_require'],
263
-					'argument_id'  => $args['id']
264
-				));
265
-			}
266
-
267
-
268
-
269
-		}
270
-
271
-		return $output;
272
-	}
273
-
274
-	/**
275
-	 * Build the component.
276
-	 *
277
-	 * @param array $args
278
-	 *
279
-	 * @return string The rendered component.
280
-	 */
281
-	public static function textarea($args = array()){
282
-		$defaults = array(
283
-			'name'       => '',
284
-			'class'      => '',
285
-			'wrap_class' => '',
286
-			'id'         => '',
287
-			'placeholder'=> '',
288
-			'title'      => '',
289
-			'value'      => '',
290
-			'required'   => false,
291
-			'label'      => '',
292
-			'label_after'=> false,
293
-			'label_class'      => '',
294
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
295
-			'help_text'  => '',
296
-			'validation_text'   => '',
297
-			'validation_pattern' => '',
298
-			'no_wrap'    => false,
299
-			'rows'      => '',
300
-			'wysiwyg'   => false,
301
-			'element_require'   => '', // [%element_id%] == "1"
302
-		);
303
-
304
-		/**
305
-		 * Parse incoming $args into an array and merge it with $defaults
306
-		 */
307
-		$args   = wp_parse_args( $args, $defaults );
308
-		$output = '';
309
-
310
-		// hidden label option needs to be empty
311
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
312
-
313
-		// floating labels don't work with wysiwyg so set it as top
314
-		if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){
315
-			$args['label_type'] = 'top';
316
-		}
317
-
318
-		$label_after = $args['label_after'];
319
-
320
-		// floating labels need label after
321
-		if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){
322
-			$label_after = true;
323
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
324
-		}
325
-
326
-		// label
327
-		if(!empty($args['label']) && is_array($args['label'])){
328
-		}elseif(!empty($args['label']) && !$label_after){
329
-			$label_args = array(
330
-				'title'=> $args['label'],
331
-				'for'=> $args['id'],
332
-				'class' => $args['label_class']." ",
333
-				'label_type' => $args['label_type']
334
-			);
335
-			$output .= self::label( $label_args );
336
-		}
337
-
338
-		// maybe horizontal label
339
-		if($args['label_type']=='horizontal'){
340
-			$output .= '<div class="col-sm-10">';
341
-		}
342
-
343
-		if(!empty($args['wysiwyg'])){
344
-			ob_start();
345
-			$content = $args['value'];
346
-			$editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
347
-			$settings = array(
348
-				'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4,
349
-				'quicktags'     => false,
350
-				'media_buttons' => false,
351
-				'editor_class'  => 'form-control',
352
-				'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']),
353
-				'teeny'         => true,
354
-			);
355
-
356
-			// maybe set settings if array
357
-			if(is_array($args['wysiwyg'])){
358
-				$settings  = wp_parse_args( $args['wysiwyg'], $settings );
359
-			}
360
-
361
-			wp_editor( $content, $editor_id, $settings );
362
-			$output .= ob_get_clean();
363
-		}else{
364
-
365
-			// open
366
-			$output .= '<textarea ';
367
-
368
-			// name
369
-			if(!empty($args['name'])){
370
-				$output .= ' name="'.sanitize_html_class($args['name']).'" ';
371
-			}
372
-
373
-			// id
374
-			if(!empty($args['id'])){
375
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
376
-			}
377
-
378
-			// placeholder
379
-			if(isset($args['placeholder']) && '' != $args['placeholder']){
380
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
381
-			}
382
-
383
-			// title
384
-			if(!empty($args['title'])){
385
-				$output .= ' title="'.esc_attr($args['title']).'" ';
386
-			}
387
-
388
-			// validation text
389
-			if(!empty($args['validation_text'])){
390
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
391
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
392
-			}
393
-
394
-			// validation_pattern
395
-			if(!empty($args['validation_pattern'])){
396
-				$output .= ' pattern="'.$args['validation_pattern'].'" ';
397
-			}
398
-
399
-			// required
400
-			if(!empty($args['required'])){
401
-				$output .= ' required ';
402
-			}
403
-
404
-			// rows
405
-			if(!empty($args['rows'])){
406
-				$output .= ' rows="'.absint($args['rows']).'" ';
407
-			}
408
-
409
-
410
-			// class
411
-			$class = !empty($args['class']) ? $args['class'] : '';
412
-			$output .= ' class="form-control '.$class.'" ';
413
-
414
-
415
-			// close tag
416
-			$output .= ' >';
417
-
418
-			// value
419
-			if(!empty($args['value'])){
420
-				$output .= sanitize_textarea_field($args['value']);
421
-			}
422
-
423
-			// closing tag
424
-			$output .= '</textarea>';
425
-
426
-		}
427
-
428
-		if(!empty($args['label']) && $label_after){
429
-			$label_args = array(
430
-				'title'=> $args['label'],
431
-				'for'=> $args['id'],
432
-				'class' => $args['label_class']." ",
433
-				'label_type' => $args['label_type']
434
-			);
435
-			$output .= self::label( $label_args );
436
-		}
437
-
438
-		// help text
439
-		if(!empty($args['help_text'])){
440
-			$output .= AUI_Component_Helper::help_text($args['help_text']);
441
-		}
442
-
443
-		// maybe horizontal label
444
-		if($args['label_type']=='horizontal'){
445
-			$output .= '</div>';
446
-		}
447
-
448
-
449
-		// wrap
450
-		if(!$args['no_wrap']){
451
-			$form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group';
452
-			$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
453
-			$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
454
-			$output = self::wrap(array(
455
-				'content' => $output,
456
-				'class'   => $wrap_class,
457
-				'element_require'   => $args['element_require'],
458
-				'argument_id'  => $args['id']
459
-			));
460
-		}
461
-
462
-
463
-		return $output;
464
-	}
465
-
466
-	public static function label($args = array(), $type = ''){
467
-		//<label for="exampleInputEmail1">Email address</label>
468
-		$defaults = array(
469
-			'title'       => 'div',
470
-			'for'      => '',
471
-			'class'      => '',
472
-			'label_type'    => '', // empty = hidden, top, horizontal
473
-		);
474
-
475
-		/**
476
-		 * Parse incoming $args into an array and merge it with $defaults
477
-		 */
478
-		$args   = wp_parse_args( $args, $defaults );
479
-		$output = '';
480
-
481
-		if($args['title']){
482
-
483
-			// maybe hide labels //@todo set a global option for visibility class
484
-			if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
485
-				$class = $args['class'];
486
-			}else{
487
-				$class = 'sr-only '.$args['class'];
488
-			}
489
-
490
-			// maybe horizontal
491
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
492
-				$class .= ' col-sm-2 col-form-label';
493
-			}
494
-
495
-			// open
496
-			$output .= '<label ';
497
-
498
-			// for
499
-			if(!empty($args['for'])){
500
-				$output .= ' for="'.sanitize_text_field($args['for']).'" ';
501
-			}
502
-
503
-			// class
504
-			$class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
505
-			$output .= ' class="'.$class.'" ';
506
-
507
-			// close
508
-			$output .= '>';
509
-
510
-
511
-			// title, don't escape fully as can contain html
512
-			if(!empty($args['title'])){
513
-				$output .= wp_kses_post($args['title']);
514
-			}
515
-
516
-			// close wrap
517
-			$output .= '</label>';
518
-
519
-
520
-		}
521
-
522
-
523
-		return $output;
524
-	}
525
-
526
-	/**
527
-	 * Wrap some content in a HTML wrapper.
528
-	 *
529
-	 * @param array $args
530
-	 *
531
-	 * @return string
532
-	 */
533
-	public static function wrap($args = array()){
534
-		$defaults = array(
535
-			'type'       => 'div',
536
-			'class'      => 'form-group',
537
-			'content'   => '',
538
-			'input_group_left' => '',
539
-			'input_group_right' => '',
540
-			'input_group_left_inside' => false,
541
-			'input_group_right_inside' => false,
542
-			'element_require'   => '',
543
-			'argument_id'   => '',
544
-		);
545
-
546
-		/**
547
-		 * Parse incoming $args into an array and merge it with $defaults
548
-		 */
549
-		$args   = wp_parse_args( $args, $defaults );
550
-		$output = '';
551
-		if($args['type']){
552
-
553
-			// open
554
-			$output .= '<'.sanitize_html_class($args['type']);
555
-
556
-			// element require
557
-			if(!empty($args['element_require'])){
558
-				$output .= AUI_Component_Helper::element_require($args['element_require']);
559
-				$args['class'] .= " aui-conditional-field";
560
-			}
561
-
562
-			// argument_id
563
-			if( !empty($args['argument_id']) ){
564
-				$output .= ' data-argument="'.esc_attr($args['argument_id']).'"';
565
-			}
566
-
567
-			// class
568
-			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
569
-			$output .= ' class="'.$class.'" ';
570
-
571
-			// close wrap
572
-			$output .= ' >';
573
-
574
-
575
-			// Input group left
576
-			if(!empty($args['input_group_left'])){
577
-				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
578
-				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>';
579
-				$output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>';
580
-			}
581
-
582
-			// content
583
-			$output .= $args['content'];
584
-
585
-			// Input group right
586
-			if(!empty($args['input_group_right'])){
587
-				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
588
-				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>';
589
-				$output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>';
590
-			}
591
-
592
-
593
-			// close wrap
594
-			$output .= '</'.sanitize_html_class($args['type']).'>';
595
-
596
-
597
-		}else{
598
-			$output = $args['content'];
599
-		}
600
-
601
-		return $output;
602
-	}
603
-
604
-	/**
605
-	 * Build the component.
606
-	 *
607
-	 * @param array $args
608
-	 *
609
-	 * @return string The rendered component.
610
-	 */
611
-	public static function select($args = array()){
612
-		$defaults = array(
613
-			'class'      => '',
614
-			'wrap_class' => '',
615
-			'id'         => '',
616
-			'title'      => '',
617
-			'value'      => '', // can be an array or a string
618
-			'required'   => false,
619
-			'label'      => '',
620
-			'label_after'=> false,
621
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
622
-			'label_class'      => '',
623
-			'help_text'  => '',
624
-			'placeholder'=> '',
625
-			'options'    => array(), // array or string
626
-			'icon'       => '',
627
-			'multiple'   => false,
628
-			'select2'    => false,
629
-			'no_wrap'    => false,
630
-			'element_require'   => '', // [%element_id%] == "1"
631
-			'extra_attributes'  => array(), // an array of extra attributes
632
-		);
633
-
634
-		/**
635
-		 * Parse incoming $args into an array and merge it with $defaults
636
-		 */
637
-		$args   = wp_parse_args( $args, $defaults );
638
-		$output = '';
639
-
640
-		// for now lets hide floating labels
641
-		if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';}
642
-
643
-		// hidden label option needs to be empty
644
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
645
-
646
-
647
-		$label_after = $args['label_after'];
648
-
649
-		// floating labels need label after
650
-		if( $args['label_type'] == 'floating' ){
651
-			$label_after = true;
652
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
653
-		}
654
-
655
-		// Maybe setup select2
656
-		$is_select2 = false;
657
-		if(!empty($args['select2'])){
658
-			$args['class'] .= ' aui-select2';
659
-			$is_select2 = true;
660
-		}elseif( strpos($args['class'], 'aui-select2') !== false){
661
-			$is_select2 = true;
662
-		}
663
-
664
-		// select2 tags
665
-		if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason
666
-			$args['data-tags'] = 'true';
667
-			$args['data-token-separators'] = "[',']";
668
-			$args['multiple'] = true;
669
-		}
670
-
671
-		// select2 placeholder
672
-		if($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])){
673
-			$args['data-placeholder'] = esc_attr($args['placeholder']);
674
-			$args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true;
675
-		}
676
-
677
-		// label
678
-		if(!empty($args['label']) && is_array($args['label'])){
679
-		}elseif(!empty($args['label']) && !$label_after){
680
-			$label_args = array(
681
-				'title'=> $args['label'],
682
-				'for'=> $args['id'],
683
-				'class' => $args['label_class']." ",
684
-				'label_type' => $args['label_type']
685
-			);
686
-			$output .= self::label($label_args);
687
-		}
688
-
689
-		// maybe horizontal label
690
-		if($args['label_type']=='horizontal'){
691
-			$output .= '<div class="col-sm-10">';
692
-		}
693
-
694
-		// open/type
695
-		$output .= '<select ';
696
-
697
-		// style
698
-		if($is_select2){
699
-			$output .= " style='width:100%;' ";
700
-		}
701
-
702
-		// element require
703
-		if(!empty($args['element_require'])){
704
-			$output .= AUI_Component_Helper::element_require($args['element_require']);
705
-			$args['class'] .= " aui-conditional-field";
706
-		}
707
-
708
-		// class
709
-		$class = !empty($args['class']) ? $args['class'] : '';
710
-		$output .= AUI_Component_Helper::class_attr('custom-select '.$class);
711
-
712
-		// name
713
-		if(!empty($args['name'])){
714
-			$output .= AUI_Component_Helper::name($args['name'],$args['multiple']);
715
-		}
716
-
717
-		// id
718
-		if(!empty($args['id'])){
719
-			$output .= AUI_Component_Helper::id($args['id']);
720
-		}
721
-
722
-		// title
723
-		if(!empty($args['title'])){
724
-			$output .= AUI_Component_Helper::title($args['title']);
725
-		}
726
-
727
-		// data-attributes
728
-		$output .= AUI_Component_Helper::data_attributes($args);
729
-
730
-		// aria-attributes
731
-		$output .= AUI_Component_Helper::aria_attributes($args);
732
-
733
-		// extra attributes
734
-		if(!empty($args['extra_attributes'])){
735
-			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
736
-		}
737
-
738
-		// required
739
-		if(!empty($args['required'])){
740
-			$output .= ' required ';
741
-		}
742
-
743
-		// multiple
744
-		if(!empty($args['multiple'])){
745
-			$output .= ' multiple ';
746
-		}
747
-
748
-		// close opening tag
749
-		$output .= ' >';
750
-
751
-		// placeholder
752
-		if(isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2){
753
-			$output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
754
-		}elseif($is_select2 && !empty($args['placeholder'])){
755
-			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
756
-		}
757
-
758
-		// Options
759
-		if(!empty($args['options'])){
760
-
761
-			if(!is_array($args['options'])){
762
-				$output .= $args['options']; // not the preferred way but an option
763
-			}else{
764
-				foreach($args['options'] as $val => $name){
765
-					$selected = '';
766
-					if(is_array($name)){
767
-						if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
768
-							$option_label = isset($name['label']) ? $name['label'] : '';
769
-
770
-							$output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
771
-						} else {
772
-							$option_label = isset($name['label']) ? $name['label'] : '';
773
-							$option_value = isset($name['value']) ? $name['value'] : '';
774
-							if(!empty($args['multiple']) && !empty($args['value']) && is_array($args['value']) ){
775
-								$selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
776
-							} elseif(!empty($args['value'])) {
777
-								$selected = selected($option_value,stripslashes_deep($args['value']), false);
778
-							}
779
-
780
-							$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
781
-						}
782
-					}else{
783
-						if(!empty($args['value'])){
784
-							if(is_array($args['value'])){
785
-								$selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
786
-							} elseif(!empty($args['value'])) {
787
-								$selected = selected( $args['value'], $val, false);
788
-							}
789
-						}
790
-						$output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>';
791
-					}
792
-				}
793
-			}
794
-
795
-		}
796
-
797
-		// closing tag
798
-		$output .= '</select>';
799
-
800
-		if(!empty($args['label']) && $label_after){
801
-			$label_args = array(
802
-				'title'=> $args['label'],
803
-				'for'=> $args['id'],
804
-				'class' => $args['label_class']." ",
805
-				'label_type' => $args['label_type']
806
-			);
807
-			$output .= self::label($label_args);
808
-		}
809
-
810
-		// help text
811
-		if(!empty($args['help_text'])){
812
-			$output .= AUI_Component_Helper::help_text($args['help_text']);
813
-		}
814
-
815
-		// maybe horizontal label
816
-		if($args['label_type']=='horizontal'){
817
-			$output .= '</div>';
818
-		}
819
-
820
-
821
-		// wrap
822
-		if(!$args['no_wrap']){
823
-			$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
824
-			$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
825
-			$output = self::wrap(array(
826
-				'content' => $output,
827
-				'class'   => $wrap_class,
828
-				'element_require'   => $args['element_require'],
829
-				'argument_id'  => $args['id']
830
-			));
831
-		}
832
-
833
-
834
-		return $output;
835
-	}
836
-
837
-	/**
838
-	 * Build the component.
839
-	 *
840
-	 * @param array $args
841
-	 *
842
-	 * @return string The rendered component.
843
-	 */
844
-	public static function radio($args = array()){
845
-		$defaults = array(
846
-			'class'      => '',
847
-			'wrap_class' => '',
848
-			'id'         => '',
849
-			'title'      => '',
850
-			'horizontal' => false, // sets the lable horizontal
851
-			'value'      => '',
852
-			'label'      => '',
853
-			'label_class'=> '',
854
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
855
-			'inline'     => true,
856
-			'required'   => false,
857
-			'options'    => array(),
858
-			'icon'       => '',
859
-			'no_wrap'    => false,
860
-			'element_require'   => '', // [%element_id%] == "1"
861
-			'extra_attributes'  => array() // an array of extra attributes
862
-		);
863
-
864
-		/**
865
-		 * Parse incoming $args into an array and merge it with $defaults
866
-		 */
867
-		$args   = wp_parse_args( $args, $defaults );
868
-
869
-		// for now lets use horizontal for floating
870
-		if( $args['label_type'] == 'floating' ){$args['label_type'] = 'horizontal';}
871
-
872
-		$label_args = array(
873
-			'title'=> $args['label'],
874
-			'class' => $args['label_class']." pt-0 ",
875
-			'label_type' => $args['label_type']
876
-		);
877
-
878
-		$output = '';
879
-
880
-
881
-
882
-		// label before
883
-		if(!empty($args['label'])){
884
-			$output .= self::label( $label_args, 'radio' );
885
-		}
886
-
887
-		// maybe horizontal label
888
-		if($args['label_type']=='horizontal'){
889
-			$output .= '<div class="col-sm-10">';
890
-		}
891
-
892
-		if(!empty($args['options'])){
893
-			$count = 0;
894
-			foreach($args['options'] as $value => $label){
895
-				$option_args = $args;
896
-				$option_args['value'] = $value;
897
-				$option_args['label'] = $label;
898
-				$option_args['checked'] = $value == $args['value'] ? true : false;
899
-				$output .= self::radio_option($option_args,$count);
900
-				$count++;
901
-			}
902
-		}
903
-
904
-		// maybe horizontal label
905
-		if($args['label_type']=='horizontal'){
906
-			$output .= '</div>';
907
-		}
908
-
909
-
910
-		// wrap
911
-		$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
912
-		$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
913
-		$output = self::wrap(array(
914
-			'content' => $output,
915
-			'class'   => $wrap_class,
916
-			'element_require'   => $args['element_require'],
917
-			'argument_id'  => $args['id']
918
-		));
919
-
920
-
921
-		return $output;
922
-	}
923
-
924
-	/**
925
-	 * Build the component.
926
-	 *
927
-	 * @param array $args
928
-	 *
929
-	 * @return string The rendered component.
930
-	 */
931
-	public static function radio_option($args = array(),$count = ''){
932
-		$defaults = array(
933
-			'class'      => '',
934
-			'id'         => '',
935
-			'title'      => '',
936
-			'value'      => '',
937
-			'required'   => false,
938
-			'inline'     => true,
939
-			'label'      => '',
940
-			'options'    => array(),
941
-			'icon'       => '',
942
-			'no_wrap'    => false,
943
-			'extra_attributes'  => array() // an array of extra attributes
944
-		);
945
-
946
-		/**
947
-		 * Parse incoming $args into an array and merge it with $defaults
948
-		 */
949
-		$args   = wp_parse_args( $args, $defaults );
950
-
951
-		$output = '';
952
-
953
-		// open/type
954
-		$output .= '<input type="radio"';
955
-
956
-		// class
957
-		$output .= ' class="form-check-input" ';
958
-
959
-		// name
960
-		if(!empty($args['name'])){
961
-			$output .= AUI_Component_Helper::name($args['name']);
962
-		}
963
-
964
-		// id
965
-		if(!empty($args['id'])){
966
-			$output .= AUI_Component_Helper::id($args['id'].$count);
967
-		}
968
-
969
-		// title
970
-		if(!empty($args['title'])){
971
-			$output .= AUI_Component_Helper::title($args['title']);
972
-		}
973
-
974
-		// value
975
-		if(isset($args['value'])){
976
-			$output .= ' value="'.sanitize_text_field($args['value']).'" ';
977
-		}
978
-
979
-		// checked, for radio and checkboxes
980
-		if( $args['checked'] ){
981
-			$output .= ' checked ';
982
-		}
983
-
984
-		// data-attributes
985
-		$output .= AUI_Component_Helper::data_attributes($args);
986
-
987
-		// aria-attributes
988
-		$output .= AUI_Component_Helper::aria_attributes($args);
989
-
990
-		// extra attributes
991
-		if(!empty($args['extra_attributes'])){
992
-			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
993
-		}
994
-
995
-		// required
996
-		if(!empty($args['required'])){
997
-			$output .= ' required ';
998
-		}
999
-
1000
-		// close opening tag
1001
-		$output .= ' >';
1002
-
1003
-		// label
1004
-		if(!empty($args['label']) && is_array($args['label'])){
1005
-		}elseif(!empty($args['label'])){
1006
-			$output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
1007
-		}
1008
-
1009
-		// wrap
1010
-		if(!$args['no_wrap']){
1011
-			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1012
-			$output = self::wrap(array(
1013
-				'content' => $output,
1014
-				'class' => $wrap_class
1015
-			));
1016
-		}
1017
-
1018
-
1019
-		return $output;
1020
-	}
213
+            }
214
+
215
+            // input group wraps
216
+            if($args['input_group_left'] || $args['input_group_right']){
217
+                $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
218
+                if($args['input_group_left']){
219
+                    $output = self::wrap( array(
220
+                        'content' => $output,
221
+                        'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100  : 'input-group',
222
+                        'input_group_left' => $args['input_group_left'],
223
+                        'input_group_left_inside'    => $args['input_group_left_inside']
224
+                    ) );
225
+                }
226
+                if($args['input_group_right']){
227
+                    $output = self::wrap( array(
228
+                        'content' => $output,
229
+                        'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group',
230
+                        'input_group_right' => $args['input_group_right'],
231
+                        'input_group_right_inside'    => $args['input_group_right_inside']
232
+                    ) );
233
+                }
234
+
235
+            }
236
+
237
+            if(!$label_after){
238
+                $output .= $help_text;
239
+            }
240
+
241
+
242
+            if($args['label_type']=='horizontal' && $type != 'checkbox'){
243
+                $output = self::wrap( array(
244
+                    'content' => $output,
245
+                    'class'   => 'col-sm-10',
246
+                ) );
247
+            }
248
+
249
+            if(!$label_after){
250
+                $output = $label . $output;
251
+            }
252
+
253
+            // wrap
254
+            if(!$args['no_wrap']){
255
+
256
+                $form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
257
+                $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
258
+                $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
259
+                $output = self::wrap(array(
260
+                    'content' => $output,
261
+                    'class'   => $wrap_class,
262
+                    'element_require'   => $args['element_require'],
263
+                    'argument_id'  => $args['id']
264
+                ));
265
+            }
266
+
267
+
268
+
269
+        }
270
+
271
+        return $output;
272
+    }
273
+
274
+    /**
275
+     * Build the component.
276
+     *
277
+     * @param array $args
278
+     *
279
+     * @return string The rendered component.
280
+     */
281
+    public static function textarea($args = array()){
282
+        $defaults = array(
283
+            'name'       => '',
284
+            'class'      => '',
285
+            'wrap_class' => '',
286
+            'id'         => '',
287
+            'placeholder'=> '',
288
+            'title'      => '',
289
+            'value'      => '',
290
+            'required'   => false,
291
+            'label'      => '',
292
+            'label_after'=> false,
293
+            'label_class'      => '',
294
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
295
+            'help_text'  => '',
296
+            'validation_text'   => '',
297
+            'validation_pattern' => '',
298
+            'no_wrap'    => false,
299
+            'rows'      => '',
300
+            'wysiwyg'   => false,
301
+            'element_require'   => '', // [%element_id%] == "1"
302
+        );
303
+
304
+        /**
305
+         * Parse incoming $args into an array and merge it with $defaults
306
+         */
307
+        $args   = wp_parse_args( $args, $defaults );
308
+        $output = '';
309
+
310
+        // hidden label option needs to be empty
311
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
312
+
313
+        // floating labels don't work with wysiwyg so set it as top
314
+        if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){
315
+            $args['label_type'] = 'top';
316
+        }
317
+
318
+        $label_after = $args['label_after'];
319
+
320
+        // floating labels need label after
321
+        if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){
322
+            $label_after = true;
323
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
324
+        }
325
+
326
+        // label
327
+        if(!empty($args['label']) && is_array($args['label'])){
328
+        }elseif(!empty($args['label']) && !$label_after){
329
+            $label_args = array(
330
+                'title'=> $args['label'],
331
+                'for'=> $args['id'],
332
+                'class' => $args['label_class']." ",
333
+                'label_type' => $args['label_type']
334
+            );
335
+            $output .= self::label( $label_args );
336
+        }
337
+
338
+        // maybe horizontal label
339
+        if($args['label_type']=='horizontal'){
340
+            $output .= '<div class="col-sm-10">';
341
+        }
342
+
343
+        if(!empty($args['wysiwyg'])){
344
+            ob_start();
345
+            $content = $args['value'];
346
+            $editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
347
+            $settings = array(
348
+                'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4,
349
+                'quicktags'     => false,
350
+                'media_buttons' => false,
351
+                'editor_class'  => 'form-control',
352
+                'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']),
353
+                'teeny'         => true,
354
+            );
355
+
356
+            // maybe set settings if array
357
+            if(is_array($args['wysiwyg'])){
358
+                $settings  = wp_parse_args( $args['wysiwyg'], $settings );
359
+            }
360
+
361
+            wp_editor( $content, $editor_id, $settings );
362
+            $output .= ob_get_clean();
363
+        }else{
364
+
365
+            // open
366
+            $output .= '<textarea ';
367
+
368
+            // name
369
+            if(!empty($args['name'])){
370
+                $output .= ' name="'.sanitize_html_class($args['name']).'" ';
371
+            }
372
+
373
+            // id
374
+            if(!empty($args['id'])){
375
+                $output .= ' id="'.sanitize_html_class($args['id']).'" ';
376
+            }
377
+
378
+            // placeholder
379
+            if(isset($args['placeholder']) && '' != $args['placeholder']){
380
+                $output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
381
+            }
382
+
383
+            // title
384
+            if(!empty($args['title'])){
385
+                $output .= ' title="'.esc_attr($args['title']).'" ';
386
+            }
387
+
388
+            // validation text
389
+            if(!empty($args['validation_text'])){
390
+                $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
391
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
392
+            }
393
+
394
+            // validation_pattern
395
+            if(!empty($args['validation_pattern'])){
396
+                $output .= ' pattern="'.$args['validation_pattern'].'" ';
397
+            }
398
+
399
+            // required
400
+            if(!empty($args['required'])){
401
+                $output .= ' required ';
402
+            }
403
+
404
+            // rows
405
+            if(!empty($args['rows'])){
406
+                $output .= ' rows="'.absint($args['rows']).'" ';
407
+            }
408
+
409
+
410
+            // class
411
+            $class = !empty($args['class']) ? $args['class'] : '';
412
+            $output .= ' class="form-control '.$class.'" ';
413
+
414
+
415
+            // close tag
416
+            $output .= ' >';
417
+
418
+            // value
419
+            if(!empty($args['value'])){
420
+                $output .= sanitize_textarea_field($args['value']);
421
+            }
422
+
423
+            // closing tag
424
+            $output .= '</textarea>';
425
+
426
+        }
427
+
428
+        if(!empty($args['label']) && $label_after){
429
+            $label_args = array(
430
+                'title'=> $args['label'],
431
+                'for'=> $args['id'],
432
+                'class' => $args['label_class']." ",
433
+                'label_type' => $args['label_type']
434
+            );
435
+            $output .= self::label( $label_args );
436
+        }
437
+
438
+        // help text
439
+        if(!empty($args['help_text'])){
440
+            $output .= AUI_Component_Helper::help_text($args['help_text']);
441
+        }
442
+
443
+        // maybe horizontal label
444
+        if($args['label_type']=='horizontal'){
445
+            $output .= '</div>';
446
+        }
447
+
448
+
449
+        // wrap
450
+        if(!$args['no_wrap']){
451
+            $form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group';
452
+            $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
453
+            $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
454
+            $output = self::wrap(array(
455
+                'content' => $output,
456
+                'class'   => $wrap_class,
457
+                'element_require'   => $args['element_require'],
458
+                'argument_id'  => $args['id']
459
+            ));
460
+        }
461
+
462
+
463
+        return $output;
464
+    }
465
+
466
+    public static function label($args = array(), $type = ''){
467
+        //<label for="exampleInputEmail1">Email address</label>
468
+        $defaults = array(
469
+            'title'       => 'div',
470
+            'for'      => '',
471
+            'class'      => '',
472
+            'label_type'    => '', // empty = hidden, top, horizontal
473
+        );
474
+
475
+        /**
476
+         * Parse incoming $args into an array and merge it with $defaults
477
+         */
478
+        $args   = wp_parse_args( $args, $defaults );
479
+        $output = '';
480
+
481
+        if($args['title']){
482
+
483
+            // maybe hide labels //@todo set a global option for visibility class
484
+            if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
485
+                $class = $args['class'];
486
+            }else{
487
+                $class = 'sr-only '.$args['class'];
488
+            }
489
+
490
+            // maybe horizontal
491
+            if($args['label_type']=='horizontal' && $type != 'checkbox'){
492
+                $class .= ' col-sm-2 col-form-label';
493
+            }
494
+
495
+            // open
496
+            $output .= '<label ';
497
+
498
+            // for
499
+            if(!empty($args['for'])){
500
+                $output .= ' for="'.sanitize_text_field($args['for']).'" ';
501
+            }
502
+
503
+            // class
504
+            $class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
505
+            $output .= ' class="'.$class.'" ';
506
+
507
+            // close
508
+            $output .= '>';
509
+
510
+
511
+            // title, don't escape fully as can contain html
512
+            if(!empty($args['title'])){
513
+                $output .= wp_kses_post($args['title']);
514
+            }
515
+
516
+            // close wrap
517
+            $output .= '</label>';
518
+
519
+
520
+        }
521
+
522
+
523
+        return $output;
524
+    }
525
+
526
+    /**
527
+     * Wrap some content in a HTML wrapper.
528
+     *
529
+     * @param array $args
530
+     *
531
+     * @return string
532
+     */
533
+    public static function wrap($args = array()){
534
+        $defaults = array(
535
+            'type'       => 'div',
536
+            'class'      => 'form-group',
537
+            'content'   => '',
538
+            'input_group_left' => '',
539
+            'input_group_right' => '',
540
+            'input_group_left_inside' => false,
541
+            'input_group_right_inside' => false,
542
+            'element_require'   => '',
543
+            'argument_id'   => '',
544
+        );
545
+
546
+        /**
547
+         * Parse incoming $args into an array and merge it with $defaults
548
+         */
549
+        $args   = wp_parse_args( $args, $defaults );
550
+        $output = '';
551
+        if($args['type']){
552
+
553
+            // open
554
+            $output .= '<'.sanitize_html_class($args['type']);
555
+
556
+            // element require
557
+            if(!empty($args['element_require'])){
558
+                $output .= AUI_Component_Helper::element_require($args['element_require']);
559
+                $args['class'] .= " aui-conditional-field";
560
+            }
561
+
562
+            // argument_id
563
+            if( !empty($args['argument_id']) ){
564
+                $output .= ' data-argument="'.esc_attr($args['argument_id']).'"';
565
+            }
566
+
567
+            // class
568
+            $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
569
+            $output .= ' class="'.$class.'" ';
570
+
571
+            // close wrap
572
+            $output .= ' >';
573
+
574
+
575
+            // Input group left
576
+            if(!empty($args['input_group_left'])){
577
+                $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
578
+                $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>';
579
+                $output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>';
580
+            }
581
+
582
+            // content
583
+            $output .= $args['content'];
584
+
585
+            // Input group right
586
+            if(!empty($args['input_group_right'])){
587
+                $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
588
+                $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>';
589
+                $output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>';
590
+            }
591
+
592
+
593
+            // close wrap
594
+            $output .= '</'.sanitize_html_class($args['type']).'>';
595
+
596
+
597
+        }else{
598
+            $output = $args['content'];
599
+        }
600
+
601
+        return $output;
602
+    }
603
+
604
+    /**
605
+     * Build the component.
606
+     *
607
+     * @param array $args
608
+     *
609
+     * @return string The rendered component.
610
+     */
611
+    public static function select($args = array()){
612
+        $defaults = array(
613
+            'class'      => '',
614
+            'wrap_class' => '',
615
+            'id'         => '',
616
+            'title'      => '',
617
+            'value'      => '', // can be an array or a string
618
+            'required'   => false,
619
+            'label'      => '',
620
+            'label_after'=> false,
621
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
622
+            'label_class'      => '',
623
+            'help_text'  => '',
624
+            'placeholder'=> '',
625
+            'options'    => array(), // array or string
626
+            'icon'       => '',
627
+            'multiple'   => false,
628
+            'select2'    => false,
629
+            'no_wrap'    => false,
630
+            'element_require'   => '', // [%element_id%] == "1"
631
+            'extra_attributes'  => array(), // an array of extra attributes
632
+        );
633
+
634
+        /**
635
+         * Parse incoming $args into an array and merge it with $defaults
636
+         */
637
+        $args   = wp_parse_args( $args, $defaults );
638
+        $output = '';
639
+
640
+        // for now lets hide floating labels
641
+        if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';}
642
+
643
+        // hidden label option needs to be empty
644
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
645
+
646
+
647
+        $label_after = $args['label_after'];
648
+
649
+        // floating labels need label after
650
+        if( $args['label_type'] == 'floating' ){
651
+            $label_after = true;
652
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
653
+        }
654
+
655
+        // Maybe setup select2
656
+        $is_select2 = false;
657
+        if(!empty($args['select2'])){
658
+            $args['class'] .= ' aui-select2';
659
+            $is_select2 = true;
660
+        }elseif( strpos($args['class'], 'aui-select2') !== false){
661
+            $is_select2 = true;
662
+        }
663
+
664
+        // select2 tags
665
+        if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason
666
+            $args['data-tags'] = 'true';
667
+            $args['data-token-separators'] = "[',']";
668
+            $args['multiple'] = true;
669
+        }
670
+
671
+        // select2 placeholder
672
+        if($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])){
673
+            $args['data-placeholder'] = esc_attr($args['placeholder']);
674
+            $args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true;
675
+        }
676
+
677
+        // label
678
+        if(!empty($args['label']) && is_array($args['label'])){
679
+        }elseif(!empty($args['label']) && !$label_after){
680
+            $label_args = array(
681
+                'title'=> $args['label'],
682
+                'for'=> $args['id'],
683
+                'class' => $args['label_class']." ",
684
+                'label_type' => $args['label_type']
685
+            );
686
+            $output .= self::label($label_args);
687
+        }
688
+
689
+        // maybe horizontal label
690
+        if($args['label_type']=='horizontal'){
691
+            $output .= '<div class="col-sm-10">';
692
+        }
693
+
694
+        // open/type
695
+        $output .= '<select ';
696
+
697
+        // style
698
+        if($is_select2){
699
+            $output .= " style='width:100%;' ";
700
+        }
701
+
702
+        // element require
703
+        if(!empty($args['element_require'])){
704
+            $output .= AUI_Component_Helper::element_require($args['element_require']);
705
+            $args['class'] .= " aui-conditional-field";
706
+        }
707
+
708
+        // class
709
+        $class = !empty($args['class']) ? $args['class'] : '';
710
+        $output .= AUI_Component_Helper::class_attr('custom-select '.$class);
711
+
712
+        // name
713
+        if(!empty($args['name'])){
714
+            $output .= AUI_Component_Helper::name($args['name'],$args['multiple']);
715
+        }
716
+
717
+        // id
718
+        if(!empty($args['id'])){
719
+            $output .= AUI_Component_Helper::id($args['id']);
720
+        }
721
+
722
+        // title
723
+        if(!empty($args['title'])){
724
+            $output .= AUI_Component_Helper::title($args['title']);
725
+        }
726
+
727
+        // data-attributes
728
+        $output .= AUI_Component_Helper::data_attributes($args);
729
+
730
+        // aria-attributes
731
+        $output .= AUI_Component_Helper::aria_attributes($args);
732
+
733
+        // extra attributes
734
+        if(!empty($args['extra_attributes'])){
735
+            $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
736
+        }
737
+
738
+        // required
739
+        if(!empty($args['required'])){
740
+            $output .= ' required ';
741
+        }
742
+
743
+        // multiple
744
+        if(!empty($args['multiple'])){
745
+            $output .= ' multiple ';
746
+        }
747
+
748
+        // close opening tag
749
+        $output .= ' >';
750
+
751
+        // placeholder
752
+        if(isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2){
753
+            $output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
754
+        }elseif($is_select2 && !empty($args['placeholder'])){
755
+            $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
756
+        }
757
+
758
+        // Options
759
+        if(!empty($args['options'])){
760
+
761
+            if(!is_array($args['options'])){
762
+                $output .= $args['options']; // not the preferred way but an option
763
+            }else{
764
+                foreach($args['options'] as $val => $name){
765
+                    $selected = '';
766
+                    if(is_array($name)){
767
+                        if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
768
+                            $option_label = isset($name['label']) ? $name['label'] : '';
769
+
770
+                            $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
771
+                        } else {
772
+                            $option_label = isset($name['label']) ? $name['label'] : '';
773
+                            $option_value = isset($name['value']) ? $name['value'] : '';
774
+                            if(!empty($args['multiple']) && !empty($args['value']) && is_array($args['value']) ){
775
+                                $selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
776
+                            } elseif(!empty($args['value'])) {
777
+                                $selected = selected($option_value,stripslashes_deep($args['value']), false);
778
+                            }
779
+
780
+                            $output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
781
+                        }
782
+                    }else{
783
+                        if(!empty($args['value'])){
784
+                            if(is_array($args['value'])){
785
+                                $selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
786
+                            } elseif(!empty($args['value'])) {
787
+                                $selected = selected( $args['value'], $val, false);
788
+                            }
789
+                        }
790
+                        $output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>';
791
+                    }
792
+                }
793
+            }
794
+
795
+        }
796
+
797
+        // closing tag
798
+        $output .= '</select>';
799
+
800
+        if(!empty($args['label']) && $label_after){
801
+            $label_args = array(
802
+                'title'=> $args['label'],
803
+                'for'=> $args['id'],
804
+                'class' => $args['label_class']." ",
805
+                'label_type' => $args['label_type']
806
+            );
807
+            $output .= self::label($label_args);
808
+        }
809
+
810
+        // help text
811
+        if(!empty($args['help_text'])){
812
+            $output .= AUI_Component_Helper::help_text($args['help_text']);
813
+        }
814
+
815
+        // maybe horizontal label
816
+        if($args['label_type']=='horizontal'){
817
+            $output .= '</div>';
818
+        }
819
+
820
+
821
+        // wrap
822
+        if(!$args['no_wrap']){
823
+            $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
824
+            $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
825
+            $output = self::wrap(array(
826
+                'content' => $output,
827
+                'class'   => $wrap_class,
828
+                'element_require'   => $args['element_require'],
829
+                'argument_id'  => $args['id']
830
+            ));
831
+        }
832
+
833
+
834
+        return $output;
835
+    }
836
+
837
+    /**
838
+     * Build the component.
839
+     *
840
+     * @param array $args
841
+     *
842
+     * @return string The rendered component.
843
+     */
844
+    public static function radio($args = array()){
845
+        $defaults = array(
846
+            'class'      => '',
847
+            'wrap_class' => '',
848
+            'id'         => '',
849
+            'title'      => '',
850
+            'horizontal' => false, // sets the lable horizontal
851
+            'value'      => '',
852
+            'label'      => '',
853
+            'label_class'=> '',
854
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
855
+            'inline'     => true,
856
+            'required'   => false,
857
+            'options'    => array(),
858
+            'icon'       => '',
859
+            'no_wrap'    => false,
860
+            'element_require'   => '', // [%element_id%] == "1"
861
+            'extra_attributes'  => array() // an array of extra attributes
862
+        );
863
+
864
+        /**
865
+         * Parse incoming $args into an array and merge it with $defaults
866
+         */
867
+        $args   = wp_parse_args( $args, $defaults );
868
+
869
+        // for now lets use horizontal for floating
870
+        if( $args['label_type'] == 'floating' ){$args['label_type'] = 'horizontal';}
871
+
872
+        $label_args = array(
873
+            'title'=> $args['label'],
874
+            'class' => $args['label_class']." pt-0 ",
875
+            'label_type' => $args['label_type']
876
+        );
877
+
878
+        $output = '';
879
+
880
+
881
+
882
+        // label before
883
+        if(!empty($args['label'])){
884
+            $output .= self::label( $label_args, 'radio' );
885
+        }
886
+
887
+        // maybe horizontal label
888
+        if($args['label_type']=='horizontal'){
889
+            $output .= '<div class="col-sm-10">';
890
+        }
891
+
892
+        if(!empty($args['options'])){
893
+            $count = 0;
894
+            foreach($args['options'] as $value => $label){
895
+                $option_args = $args;
896
+                $option_args['value'] = $value;
897
+                $option_args['label'] = $label;
898
+                $option_args['checked'] = $value == $args['value'] ? true : false;
899
+                $output .= self::radio_option($option_args,$count);
900
+                $count++;
901
+            }
902
+        }
903
+
904
+        // maybe horizontal label
905
+        if($args['label_type']=='horizontal'){
906
+            $output .= '</div>';
907
+        }
908
+
909
+
910
+        // wrap
911
+        $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
912
+        $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
913
+        $output = self::wrap(array(
914
+            'content' => $output,
915
+            'class'   => $wrap_class,
916
+            'element_require'   => $args['element_require'],
917
+            'argument_id'  => $args['id']
918
+        ));
919
+
920
+
921
+        return $output;
922
+    }
923
+
924
+    /**
925
+     * Build the component.
926
+     *
927
+     * @param array $args
928
+     *
929
+     * @return string The rendered component.
930
+     */
931
+    public static function radio_option($args = array(),$count = ''){
932
+        $defaults = array(
933
+            'class'      => '',
934
+            'id'         => '',
935
+            'title'      => '',
936
+            'value'      => '',
937
+            'required'   => false,
938
+            'inline'     => true,
939
+            'label'      => '',
940
+            'options'    => array(),
941
+            'icon'       => '',
942
+            'no_wrap'    => false,
943
+            'extra_attributes'  => array() // an array of extra attributes
944
+        );
945
+
946
+        /**
947
+         * Parse incoming $args into an array and merge it with $defaults
948
+         */
949
+        $args   = wp_parse_args( $args, $defaults );
950
+
951
+        $output = '';
952
+
953
+        // open/type
954
+        $output .= '<input type="radio"';
955
+
956
+        // class
957
+        $output .= ' class="form-check-input" ';
958
+
959
+        // name
960
+        if(!empty($args['name'])){
961
+            $output .= AUI_Component_Helper::name($args['name']);
962
+        }
963
+
964
+        // id
965
+        if(!empty($args['id'])){
966
+            $output .= AUI_Component_Helper::id($args['id'].$count);
967
+        }
968
+
969
+        // title
970
+        if(!empty($args['title'])){
971
+            $output .= AUI_Component_Helper::title($args['title']);
972
+        }
973
+
974
+        // value
975
+        if(isset($args['value'])){
976
+            $output .= ' value="'.sanitize_text_field($args['value']).'" ';
977
+        }
978
+
979
+        // checked, for radio and checkboxes
980
+        if( $args['checked'] ){
981
+            $output .= ' checked ';
982
+        }
983
+
984
+        // data-attributes
985
+        $output .= AUI_Component_Helper::data_attributes($args);
986
+
987
+        // aria-attributes
988
+        $output .= AUI_Component_Helper::aria_attributes($args);
989
+
990
+        // extra attributes
991
+        if(!empty($args['extra_attributes'])){
992
+            $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
993
+        }
994
+
995
+        // required
996
+        if(!empty($args['required'])){
997
+            $output .= ' required ';
998
+        }
999
+
1000
+        // close opening tag
1001
+        $output .= ' >';
1002
+
1003
+        // label
1004
+        if(!empty($args['label']) && is_array($args['label'])){
1005
+        }elseif(!empty($args['label'])){
1006
+            $output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
1007
+        }
1008
+
1009
+        // wrap
1010
+        if(!$args['no_wrap']){
1011
+            $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1012
+            $output = self::wrap(array(
1013
+                'content' => $output,
1014
+                'class' => $wrap_class
1015
+            ));
1016
+        }
1017
+
1018
+
1019
+        return $output;
1020
+    }
1021 1021
 
1022 1022
 }
1023 1023
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +208 added lines, -208 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return string The rendered component.
20 20
 	 */
21
-	public static function input($args = array()){
21
+	public static function input($args = array()) {
22 22
 		$defaults = array(
23 23
 			'type'       => 'text',
24 24
 			'name'       => '',
@@ -52,13 +52,13 @@  discard block
 block discarded – undo
52 52
 		/**
53 53
 		 * Parse incoming $args into an array and merge it with $defaults
54 54
 		 */
55
-		$args   = wp_parse_args( $args, $defaults );
55
+		$args   = wp_parse_args($args, $defaults);
56 56
 		$output = '';
57
-		if ( ! empty( $args['type'] ) ) {
57
+		if (!empty($args['type'])) {
58 58
 			// hidden label option needs to be empty
59 59
 			$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
60 60
 
61
-			$type = sanitize_html_class( $args['type'] );
61
+			$type = sanitize_html_class($args['type']);
62 62
 
63 63
 			$help_text = '';
64 64
 			$label = '';
@@ -66,24 +66,24 @@  discard block
 block discarded – undo
66 66
 			$label_args = array(
67 67
 				'title'=> $args['label'],
68 68
 				'for'=> $args['id'],
69
-				'class' => $args['label_class']." ",
69
+				'class' => $args['label_class'] . " ",
70 70
 				'label_type' => $args['label_type']
71 71
 			);
72 72
 
73 73
 			// floating labels need label after
74
-			if( $args['label_type'] == 'floating' && $type != 'checkbox' ){
74
+			if ($args['label_type'] == 'floating' && $type != 'checkbox') {
75 75
 				$label_after = true;
76 76
 				$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
77 77
 			}
78 78
 
79 79
 			// Some special sauce for files
80
-			if($type=='file' ){
80
+			if ($type == 'file') {
81 81
 				$label_after = true; // if type file we need the label after
82 82
 				$args['class'] .= ' custom-file-input ';
83
-			}elseif($type=='checkbox'){
83
+			}elseif ($type == 'checkbox') {
84 84
 				$label_after = true; // if type file we need the label after
85 85
 				$args['class'] .= ' custom-control-input ';
86
-			}elseif($type=='datepicker' || $type=='timepicker'){
86
+			}elseif ($type == 'datepicker' || $type == 'timepicker') {
87 87
 				$type = 'text';
88 88
 				//$args['class'] .= ' aui-flatpickr bg-initial ';
89 89
 				$args['class'] .= ' bg-initial ';
@@ -99,65 +99,65 @@  discard block
 block discarded – undo
99 99
 			$output .= '<input type="' . $type . '" ';
100 100
 
101 101
 			// name
102
-			if(!empty($args['name'])){
103
-				$output .= ' name="'.esc_attr($args['name']).'" ';
102
+			if (!empty($args['name'])) {
103
+				$output .= ' name="' . esc_attr($args['name']) . '" ';
104 104
 			}
105 105
 
106 106
 			// id
107
-			if(!empty($args['id'])){
108
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
107
+			if (!empty($args['id'])) {
108
+				$output .= ' id="' . sanitize_html_class($args['id']) . '" ';
109 109
 			}
110 110
 
111 111
 			// placeholder
112
-			if(isset($args['placeholder']) && '' != $args['placeholder'] ){
113
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
112
+			if (isset($args['placeholder']) && '' != $args['placeholder']) {
113
+				$output .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
114 114
 			}
115 115
 
116 116
 			// title
117
-			if(!empty($args['title'])){
118
-				$output .= ' title="'.esc_attr($args['title']).'" ';
117
+			if (!empty($args['title'])) {
118
+				$output .= ' title="' . esc_attr($args['title']) . '" ';
119 119
 			}
120 120
 
121 121
 			// value
122
-			if(!empty($args['value'])){
123
-				$output .= ' value="'.sanitize_text_field($args['value']).'" ';
122
+			if (!empty($args['value'])) {
123
+				$output .= ' value="' . sanitize_text_field($args['value']) . '" ';
124 124
 			}
125 125
 
126 126
 			// checked, for radio and checkboxes
127
-			if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){
127
+			if (($type == 'checkbox' || $type == 'radio') && $args['checked']) {
128 128
 				$output .= ' checked ';
129 129
 			}
130 130
 
131 131
 			// validation text
132
-			if(!empty($args['validation_text'])){
133
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
132
+			if (!empty($args['validation_text'])) {
133
+				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" ';
134 134
 				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
135 135
 			}
136 136
 
137 137
 			// validation_pattern
138
-			if(!empty($args['validation_pattern'])){
139
-				$output .= ' pattern="'.$args['validation_pattern'].'" ';
138
+			if (!empty($args['validation_pattern'])) {
139
+				$output .= ' pattern="' . $args['validation_pattern'] . '" ';
140 140
 			}
141 141
 
142 142
 			// step (for numbers)
143
-			if(!empty($args['step'])){
144
-				$output .= ' step="'.$args['step'].'" ';
143
+			if (!empty($args['step'])) {
144
+				$output .= ' step="' . $args['step'] . '" ';
145 145
 			}
146 146
 
147 147
 			// required
148
-			if(!empty($args['required'])){
148
+			if (!empty($args['required'])) {
149 149
 				$output .= ' required ';
150 150
 			}
151 151
 
152 152
 			// class
153
-			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
154
-			$output .= ' class="form-control '.$class.'" ';
153
+			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : '';
154
+			$output .= ' class="form-control ' . $class . '" ';
155 155
 
156 156
 			// data-attributes
157 157
 			$output .= AUI_Component_Helper::data_attributes($args);
158 158
 
159 159
 			// extra attributes
160
-			if(!empty($args['extra_attributes'])){
160
+			if (!empty($args['extra_attributes'])) {
161 161
 				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
162 162
 			}
163 163
 
@@ -166,40 +166,40 @@  discard block
 block discarded – undo
166 166
 
167 167
 
168 168
 			// label
169
-			if(!empty($args['label'])){
170
-				if($type == 'file'){$label_args['class'] .= 'custom-file-label';}
171
-				elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
172
-				$label = self::label( $label_args, $type );
169
+			if (!empty($args['label'])) {
170
+				if ($type == 'file') {$label_args['class'] .= 'custom-file-label'; }
171
+				elseif ($type == 'checkbox') {$label_args['class'] .= 'custom-control-label'; }
172
+				$label = self::label($label_args, $type);
173 173
 			}
174 174
 
175 175
 			// help text
176
-			if(!empty($args['help_text'])){
176
+			if (!empty($args['help_text'])) {
177 177
 				$help_text = AUI_Component_Helper::help_text($args['help_text']);
178 178
 			}
179 179
 
180 180
 
181 181
 			// set help text in the correct possition
182
-			if($label_after){
182
+			if ($label_after) {
183 183
 				$output .= $label . $help_text;
184 184
 			}
185 185
 
186 186
 			// some input types need a separate wrap
187
-			if($type == 'file') {
188
-				$output = self::wrap( array(
187
+			if ($type == 'file') {
188
+				$output = self::wrap(array(
189 189
 					'content' => $output,
190 190
 					'class'   => 'form-group custom-file'
191
-				) );
192
-			}elseif($type == 'checkbox'){
191
+				));
192
+			}elseif ($type == 'checkbox') {
193 193
 				$wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
194
-				$output = self::wrap( array(
194
+				$output = self::wrap(array(
195 195
 					'content' => $output,
196
-					'class'   => 'custom-control '.$wrap_class
197
-				) );
196
+					'class'   => 'custom-control ' . $wrap_class
197
+				));
198 198
 
199
-				if($args['label_type']=='horizontal'){
199
+				if ($args['label_type'] == 'horizontal') {
200 200
 					$output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
201 201
 				}
202
-			}elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
202
+			}elseif ($type == 'password' && $args['password_toggle'] && !$args['input_group_right']) {
203 203
 
204 204
 
205 205
 				// allow password field to toggle view
@@ -213,49 +213,49 @@  discard block
 block discarded – undo
213 213
 			}
214 214
 
215 215
 			// input group wraps
216
-			if($args['input_group_left'] || $args['input_group_right']){
216
+			if ($args['input_group_left'] || $args['input_group_right']) {
217 217
 				$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
218
-				if($args['input_group_left']){
219
-					$output = self::wrap( array(
218
+				if ($args['input_group_left']) {
219
+					$output = self::wrap(array(
220 220
 						'content' => $output,
221
-						'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100  : 'input-group',
221
+						'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
222 222
 						'input_group_left' => $args['input_group_left'],
223 223
 						'input_group_left_inside'    => $args['input_group_left_inside']
224
-					) );
224
+					));
225 225
 				}
226
-				if($args['input_group_right']){
227
-					$output = self::wrap( array(
226
+				if ($args['input_group_right']) {
227
+					$output = self::wrap(array(
228 228
 						'content' => $output,
229
-						'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group',
229
+						'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
230 230
 						'input_group_right' => $args['input_group_right'],
231 231
 						'input_group_right_inside'    => $args['input_group_right_inside']
232
-					) );
232
+					));
233 233
 				}
234 234
 
235 235
 			}
236 236
 
237
-			if(!$label_after){
237
+			if (!$label_after) {
238 238
 				$output .= $help_text;
239 239
 			}
240 240
 
241 241
 
242
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
243
-				$output = self::wrap( array(
242
+			if ($args['label_type'] == 'horizontal' && $type != 'checkbox') {
243
+				$output = self::wrap(array(
244 244
 					'content' => $output,
245 245
 					'class'   => 'col-sm-10',
246
-				) );
246
+				));
247 247
 			}
248 248
 
249
-			if(!$label_after){
249
+			if (!$label_after) {
250 250
 				$output = $label . $output;
251 251
 			}
252 252
 
253 253
 			// wrap
254
-			if(!$args['no_wrap']){
254
+			if (!$args['no_wrap']) {
255 255
 
256
-				$form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
257
-				$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
258
-				$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
256
+				$form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
257
+				$wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
258
+				$wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
259 259
 				$output = self::wrap(array(
260 260
 					'content' => $output,
261 261
 					'class'   => $wrap_class,
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 *
279 279
 	 * @return string The rendered component.
280 280
 	 */
281
-	public static function textarea($args = array()){
281
+	public static function textarea($args = array()) {
282 282
 		$defaults = array(
283 283
 			'name'       => '',
284 284
 			'class'      => '',
@@ -304,43 +304,43 @@  discard block
 block discarded – undo
304 304
 		/**
305 305
 		 * Parse incoming $args into an array and merge it with $defaults
306 306
 		 */
307
-		$args   = wp_parse_args( $args, $defaults );
307
+		$args   = wp_parse_args($args, $defaults);
308 308
 		$output = '';
309 309
 
310 310
 		// hidden label option needs to be empty
311 311
 		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
312 312
 
313 313
 		// floating labels don't work with wysiwyg so set it as top
314
-		if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){
314
+		if ($args['label_type'] == 'floating' && !empty($args['wysiwyg'])) {
315 315
 			$args['label_type'] = 'top';
316 316
 		}
317 317
 
318 318
 		$label_after = $args['label_after'];
319 319
 
320 320
 		// floating labels need label after
321
-		if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){
321
+		if ($args['label_type'] == 'floating' && empty($args['wysiwyg'])) {
322 322
 			$label_after = true;
323 323
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
324 324
 		}
325 325
 
326 326
 		// label
327
-		if(!empty($args['label']) && is_array($args['label'])){
328
-		}elseif(!empty($args['label']) && !$label_after){
327
+		if (!empty($args['label']) && is_array($args['label'])) {
328
+		}elseif (!empty($args['label']) && !$label_after) {
329 329
 			$label_args = array(
330 330
 				'title'=> $args['label'],
331 331
 				'for'=> $args['id'],
332
-				'class' => $args['label_class']." ",
332
+				'class' => $args['label_class'] . " ",
333 333
 				'label_type' => $args['label_type']
334 334
 			);
335
-			$output .= self::label( $label_args );
335
+			$output .= self::label($label_args);
336 336
 		}
337 337
 
338 338
 		// maybe horizontal label
339
-		if($args['label_type']=='horizontal'){
339
+		if ($args['label_type'] == 'horizontal') {
340 340
 			$output .= '<div class="col-sm-10">';
341 341
 		}
342 342
 
343
-		if(!empty($args['wysiwyg'])){
343
+		if (!empty($args['wysiwyg'])) {
344 344
 			ob_start();
345 345
 			$content = $args['value'];
346 346
 			$editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
@@ -354,69 +354,69 @@  discard block
 block discarded – undo
354 354
 			);
355 355
 
356 356
 			// maybe set settings if array
357
-			if(is_array($args['wysiwyg'])){
358
-				$settings  = wp_parse_args( $args['wysiwyg'], $settings );
357
+			if (is_array($args['wysiwyg'])) {
358
+				$settings = wp_parse_args($args['wysiwyg'], $settings);
359 359
 			}
360 360
 
361
-			wp_editor( $content, $editor_id, $settings );
361
+			wp_editor($content, $editor_id, $settings);
362 362
 			$output .= ob_get_clean();
363
-		}else{
363
+		} else {
364 364
 
365 365
 			// open
366 366
 			$output .= '<textarea ';
367 367
 
368 368
 			// name
369
-			if(!empty($args['name'])){
370
-				$output .= ' name="'.sanitize_html_class($args['name']).'" ';
369
+			if (!empty($args['name'])) {
370
+				$output .= ' name="' . sanitize_html_class($args['name']) . '" ';
371 371
 			}
372 372
 
373 373
 			// id
374
-			if(!empty($args['id'])){
375
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
374
+			if (!empty($args['id'])) {
375
+				$output .= ' id="' . sanitize_html_class($args['id']) . '" ';
376 376
 			}
377 377
 
378 378
 			// placeholder
379
-			if(isset($args['placeholder']) && '' != $args['placeholder']){
380
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
379
+			if (isset($args['placeholder']) && '' != $args['placeholder']) {
380
+				$output .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
381 381
 			}
382 382
 
383 383
 			// title
384
-			if(!empty($args['title'])){
385
-				$output .= ' title="'.esc_attr($args['title']).'" ';
384
+			if (!empty($args['title'])) {
385
+				$output .= ' title="' . esc_attr($args['title']) . '" ';
386 386
 			}
387 387
 
388 388
 			// validation text
389
-			if(!empty($args['validation_text'])){
390
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
389
+			if (!empty($args['validation_text'])) {
390
+				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" ';
391 391
 				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
392 392
 			}
393 393
 
394 394
 			// validation_pattern
395
-			if(!empty($args['validation_pattern'])){
396
-				$output .= ' pattern="'.$args['validation_pattern'].'" ';
395
+			if (!empty($args['validation_pattern'])) {
396
+				$output .= ' pattern="' . $args['validation_pattern'] . '" ';
397 397
 			}
398 398
 
399 399
 			// required
400
-			if(!empty($args['required'])){
400
+			if (!empty($args['required'])) {
401 401
 				$output .= ' required ';
402 402
 			}
403 403
 
404 404
 			// rows
405
-			if(!empty($args['rows'])){
406
-				$output .= ' rows="'.absint($args['rows']).'" ';
405
+			if (!empty($args['rows'])) {
406
+				$output .= ' rows="' . absint($args['rows']) . '" ';
407 407
 			}
408 408
 
409 409
 
410 410
 			// class
411 411
 			$class = !empty($args['class']) ? $args['class'] : '';
412
-			$output .= ' class="form-control '.$class.'" ';
412
+			$output .= ' class="form-control ' . $class . '" ';
413 413
 
414 414
 
415 415
 			// close tag
416 416
 			$output .= ' >';
417 417
 
418 418
 			// value
419
-			if(!empty($args['value'])){
419
+			if (!empty($args['value'])) {
420 420
 				$output .= sanitize_textarea_field($args['value']);
421 421
 			}
422 422
 
@@ -425,32 +425,32 @@  discard block
 block discarded – undo
425 425
 
426 426
 		}
427 427
 
428
-		if(!empty($args['label']) && $label_after){
428
+		if (!empty($args['label']) && $label_after) {
429 429
 			$label_args = array(
430 430
 				'title'=> $args['label'],
431 431
 				'for'=> $args['id'],
432
-				'class' => $args['label_class']." ",
432
+				'class' => $args['label_class'] . " ",
433 433
 				'label_type' => $args['label_type']
434 434
 			);
435
-			$output .= self::label( $label_args );
435
+			$output .= self::label($label_args);
436 436
 		}
437 437
 
438 438
 		// help text
439
-		if(!empty($args['help_text'])){
439
+		if (!empty($args['help_text'])) {
440 440
 			$output .= AUI_Component_Helper::help_text($args['help_text']);
441 441
 		}
442 442
 
443 443
 		// maybe horizontal label
444
-		if($args['label_type']=='horizontal'){
444
+		if ($args['label_type'] == 'horizontal') {
445 445
 			$output .= '</div>';
446 446
 		}
447 447
 
448 448
 
449 449
 		// wrap
450
-		if(!$args['no_wrap']){
451
-			$form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group';
452
-			$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
453
-			$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
450
+		if (!$args['no_wrap']) {
451
+			$form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group';
452
+			$wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
453
+			$wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
454 454
 			$output = self::wrap(array(
455 455
 				'content' => $output,
456 456
 				'class'   => $wrap_class,
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 		return $output;
464 464
 	}
465 465
 
466
-	public static function label($args = array(), $type = ''){
466
+	public static function label($args = array(), $type = '') {
467 467
 		//<label for="exampleInputEmail1">Email address</label>
468 468
 		$defaults = array(
469 469
 			'title'       => 'div',
@@ -475,20 +475,20 @@  discard block
 block discarded – undo
475 475
 		/**
476 476
 		 * Parse incoming $args into an array and merge it with $defaults
477 477
 		 */
478
-		$args   = wp_parse_args( $args, $defaults );
478
+		$args   = wp_parse_args($args, $defaults);
479 479
 		$output = '';
480 480
 
481
-		if($args['title']){
481
+		if ($args['title']) {
482 482
 
483 483
 			// maybe hide labels //@todo set a global option for visibility class
484
-			if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
484
+			if ($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type'])) {
485 485
 				$class = $args['class'];
486
-			}else{
487
-				$class = 'sr-only '.$args['class'];
486
+			} else {
487
+				$class = 'sr-only ' . $args['class'];
488 488
 			}
489 489
 
490 490
 			// maybe horizontal
491
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
491
+			if ($args['label_type'] == 'horizontal' && $type != 'checkbox') {
492 492
 				$class .= ' col-sm-2 col-form-label';
493 493
 			}
494 494
 
@@ -496,20 +496,20 @@  discard block
 block discarded – undo
496 496
 			$output .= '<label ';
497 497
 
498 498
 			// for
499
-			if(!empty($args['for'])){
500
-				$output .= ' for="'.sanitize_text_field($args['for']).'" ';
499
+			if (!empty($args['for'])) {
500
+				$output .= ' for="' . sanitize_text_field($args['for']) . '" ';
501 501
 			}
502 502
 
503 503
 			// class
504
-			$class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
505
-			$output .= ' class="'.$class.'" ';
504
+			$class = $class ? AUI_Component_Helper::esc_classes($class) : '';
505
+			$output .= ' class="' . $class . '" ';
506 506
 
507 507
 			// close
508 508
 			$output .= '>';
509 509
 
510 510
 
511 511
 			// title, don't escape fully as can contain html
512
-			if(!empty($args['title'])){
512
+			if (!empty($args['title'])) {
513 513
 				$output .= wp_kses_post($args['title']);
514 514
 			}
515 515
 
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 	 *
531 531
 	 * @return string
532 532
 	 */
533
-	public static function wrap($args = array()){
533
+	public static function wrap($args = array()) {
534 534
 		$defaults = array(
535 535
 			'type'       => 'div',
536 536
 			'class'      => 'form-group',
@@ -546,55 +546,55 @@  discard block
 block discarded – undo
546 546
 		/**
547 547
 		 * Parse incoming $args into an array and merge it with $defaults
548 548
 		 */
549
-		$args   = wp_parse_args( $args, $defaults );
549
+		$args   = wp_parse_args($args, $defaults);
550 550
 		$output = '';
551
-		if($args['type']){
551
+		if ($args['type']) {
552 552
 
553 553
 			// open
554
-			$output .= '<'.sanitize_html_class($args['type']);
554
+			$output .= '<' . sanitize_html_class($args['type']);
555 555
 
556 556
 			// element require
557
-			if(!empty($args['element_require'])){
557
+			if (!empty($args['element_require'])) {
558 558
 				$output .= AUI_Component_Helper::element_require($args['element_require']);
559 559
 				$args['class'] .= " aui-conditional-field";
560 560
 			}
561 561
 
562 562
 			// argument_id
563
-			if( !empty($args['argument_id']) ){
564
-				$output .= ' data-argument="'.esc_attr($args['argument_id']).'"';
563
+			if (!empty($args['argument_id'])) {
564
+				$output .= ' data-argument="' . esc_attr($args['argument_id']) . '"';
565 565
 			}
566 566
 
567 567
 			// class
568
-			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
569
-			$output .= ' class="'.$class.'" ';
568
+			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : '';
569
+			$output .= ' class="' . $class . '" ';
570 570
 
571 571
 			// close wrap
572 572
 			$output .= ' >';
573 573
 
574 574
 
575 575
 			// Input group left
576
-			if(!empty($args['input_group_left'])){
576
+			if (!empty($args['input_group_left'])) {
577 577
 				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
578
-				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>';
579
-				$output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>';
578
+				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
579
+				$output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
580 580
 			}
581 581
 
582 582
 			// content
583 583
 			$output .= $args['content'];
584 584
 
585 585
 			// Input group right
586
-			if(!empty($args['input_group_right'])){
586
+			if (!empty($args['input_group_right'])) {
587 587
 				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
588
-				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>';
589
-				$output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>';
588
+				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
589
+				$output .= '<div class="input-group-append ' . $position_class . '">' . $input_group_right . '</div>';
590 590
 			}
591 591
 
592 592
 
593 593
 			// close wrap
594
-			$output .= '</'.sanitize_html_class($args['type']).'>';
594
+			$output .= '</' . sanitize_html_class($args['type']) . '>';
595 595
 
596 596
 
597
-		}else{
597
+		} else {
598 598
 			$output = $args['content'];
599 599
 		}
600 600
 
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 	 *
609 609
 	 * @return string The rendered component.
610 610
 	 */
611
-	public static function select($args = array()){
611
+	public static function select($args = array()) {
612 612
 		$defaults = array(
613 613
 			'class'      => '',
614 614
 			'wrap_class' => '',
@@ -634,11 +634,11 @@  discard block
 block discarded – undo
634 634
 		/**
635 635
 		 * Parse incoming $args into an array and merge it with $defaults
636 636
 		 */
637
-		$args   = wp_parse_args( $args, $defaults );
637
+		$args   = wp_parse_args($args, $defaults);
638 638
 		$output = '';
639 639
 
640 640
 		// for now lets hide floating labels
641
-		if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';}
641
+		if ($args['label_type'] == 'floating') {$args['label_type'] = 'hidden'; }
642 642
 
643 643
 		// hidden label option needs to be empty
644 644
 		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
@@ -647,47 +647,47 @@  discard block
 block discarded – undo
647 647
 		$label_after = $args['label_after'];
648 648
 
649 649
 		// floating labels need label after
650
-		if( $args['label_type'] == 'floating' ){
650
+		if ($args['label_type'] == 'floating') {
651 651
 			$label_after = true;
652 652
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
653 653
 		}
654 654
 
655 655
 		// Maybe setup select2
656 656
 		$is_select2 = false;
657
-		if(!empty($args['select2'])){
657
+		if (!empty($args['select2'])) {
658 658
 			$args['class'] .= ' aui-select2';
659 659
 			$is_select2 = true;
660
-		}elseif( strpos($args['class'], 'aui-select2') !== false){
660
+		}elseif (strpos($args['class'], 'aui-select2') !== false) {
661 661
 			$is_select2 = true;
662 662
 		}
663 663
 
664 664
 		// select2 tags
665
-		if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason
665
+		if (!empty($args['select2']) && $args['select2'] === 'tags') { // triple equals needed here for some reason
666 666
 			$args['data-tags'] = 'true';
667 667
 			$args['data-token-separators'] = "[',']";
668 668
 			$args['multiple'] = true;
669 669
 		}
670 670
 
671 671
 		// select2 placeholder
672
-		if($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])){
672
+		if ($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])) {
673 673
 			$args['data-placeholder'] = esc_attr($args['placeholder']);
674 674
 			$args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true;
675 675
 		}
676 676
 
677 677
 		// label
678
-		if(!empty($args['label']) && is_array($args['label'])){
679
-		}elseif(!empty($args['label']) && !$label_after){
678
+		if (!empty($args['label']) && is_array($args['label'])) {
679
+		}elseif (!empty($args['label']) && !$label_after) {
680 680
 			$label_args = array(
681 681
 				'title'=> $args['label'],
682 682
 				'for'=> $args['id'],
683
-				'class' => $args['label_class']." ",
683
+				'class' => $args['label_class'] . " ",
684 684
 				'label_type' => $args['label_type']
685 685
 			);
686 686
 			$output .= self::label($label_args);
687 687
 		}
688 688
 
689 689
 		// maybe horizontal label
690
-		if($args['label_type']=='horizontal'){
690
+		if ($args['label_type'] == 'horizontal') {
691 691
 			$output .= '<div class="col-sm-10">';
692 692
 		}
693 693
 
@@ -695,32 +695,32 @@  discard block
 block discarded – undo
695 695
 		$output .= '<select ';
696 696
 
697 697
 		// style
698
-		if($is_select2){
698
+		if ($is_select2) {
699 699
 			$output .= " style='width:100%;' ";
700 700
 		}
701 701
 
702 702
 		// element require
703
-		if(!empty($args['element_require'])){
703
+		if (!empty($args['element_require'])) {
704 704
 			$output .= AUI_Component_Helper::element_require($args['element_require']);
705 705
 			$args['class'] .= " aui-conditional-field";
706 706
 		}
707 707
 
708 708
 		// class
709 709
 		$class = !empty($args['class']) ? $args['class'] : '';
710
-		$output .= AUI_Component_Helper::class_attr('custom-select '.$class);
710
+		$output .= AUI_Component_Helper::class_attr('custom-select ' . $class);
711 711
 
712 712
 		// name
713
-		if(!empty($args['name'])){
714
-			$output .= AUI_Component_Helper::name($args['name'],$args['multiple']);
713
+		if (!empty($args['name'])) {
714
+			$output .= AUI_Component_Helper::name($args['name'], $args['multiple']);
715 715
 		}
716 716
 
717 717
 		// id
718
-		if(!empty($args['id'])){
718
+		if (!empty($args['id'])) {
719 719
 			$output .= AUI_Component_Helper::id($args['id']);
720 720
 		}
721 721
 
722 722
 		// title
723
-		if(!empty($args['title'])){
723
+		if (!empty($args['title'])) {
724 724
 			$output .= AUI_Component_Helper::title($args['title']);
725 725
 		}
726 726
 
@@ -731,17 +731,17 @@  discard block
 block discarded – undo
731 731
 		$output .= AUI_Component_Helper::aria_attributes($args);
732 732
 
733 733
 		// extra attributes
734
-		if(!empty($args['extra_attributes'])){
734
+		if (!empty($args['extra_attributes'])) {
735 735
 			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
736 736
 		}
737 737
 
738 738
 		// required
739
-		if(!empty($args['required'])){
739
+		if (!empty($args['required'])) {
740 740
 			$output .= ' required ';
741 741
 		}
742 742
 
743 743
 		// multiple
744
-		if(!empty($args['multiple'])){
744
+		if (!empty($args['multiple'])) {
745 745
 			$output .= ' multiple ';
746 746
 		}
747 747
 
@@ -749,21 +749,21 @@  discard block
 block discarded – undo
749 749
 		$output .= ' >';
750 750
 
751 751
 		// placeholder
752
-		if(isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2){
753
-			$output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
754
-		}elseif($is_select2 && !empty($args['placeholder'])){
752
+		if (isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2) {
753
+			$output .= '<option value="" disabled selected hidden>' . esc_attr($args['placeholder']) . '</option>';
754
+		}elseif ($is_select2 && !empty($args['placeholder'])) {
755 755
 			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
756 756
 		}
757 757
 
758 758
 		// Options
759
-		if(!empty($args['options'])){
759
+		if (!empty($args['options'])) {
760 760
 
761
-			if(!is_array($args['options'])){
761
+			if (!is_array($args['options'])) {
762 762
 				$output .= $args['options']; // not the preferred way but an option
763
-			}else{
764
-				foreach($args['options'] as $val => $name){
763
+			} else {
764
+				foreach ($args['options'] as $val => $name) {
765 765
 					$selected = '';
766
-					if(is_array($name)){
766
+					if (is_array($name)) {
767 767
 						if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
768 768
 							$option_label = isset($name['label']) ? $name['label'] : '';
769 769
 
@@ -771,23 +771,23 @@  discard block
 block discarded – undo
771 771
 						} else {
772 772
 							$option_label = isset($name['label']) ? $name['label'] : '';
773 773
 							$option_value = isset($name['value']) ? $name['value'] : '';
774
-							if(!empty($args['multiple']) && !empty($args['value']) && is_array($args['value']) ){
774
+							if (!empty($args['multiple']) && !empty($args['value']) && is_array($args['value'])) {
775 775
 								$selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
776
-							} elseif(!empty($args['value'])) {
777
-								$selected = selected($option_value,stripslashes_deep($args['value']), false);
776
+							} elseif (!empty($args['value'])) {
777
+								$selected = selected($option_value, stripslashes_deep($args['value']), false);
778 778
 							}
779 779
 
780 780
 							$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
781 781
 						}
782
-					}else{
783
-						if(!empty($args['value'])){
784
-							if(is_array($args['value'])){
785
-								$selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
786
-							} elseif(!empty($args['value'])) {
787
-								$selected = selected( $args['value'], $val, false);
782
+					} else {
783
+						if (!empty($args['value'])) {
784
+							if (is_array($args['value'])) {
785
+								$selected = in_array($val, $args['value']) ? 'selected="selected"' : '';
786
+							} elseif (!empty($args['value'])) {
787
+								$selected = selected($args['value'], $val, false);
788 788
 							}
789 789
 						}
790
-						$output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>';
790
+						$output .= '<option value="' . esc_attr($val) . '" ' . $selected . '>' . esc_attr($name) . '</option>';
791 791
 					}
792 792
 				}
793 793
 			}
@@ -797,31 +797,31 @@  discard block
 block discarded – undo
797 797
 		// closing tag
798 798
 		$output .= '</select>';
799 799
 
800
-		if(!empty($args['label']) && $label_after){
800
+		if (!empty($args['label']) && $label_after) {
801 801
 			$label_args = array(
802 802
 				'title'=> $args['label'],
803 803
 				'for'=> $args['id'],
804
-				'class' => $args['label_class']." ",
804
+				'class' => $args['label_class'] . " ",
805 805
 				'label_type' => $args['label_type']
806 806
 			);
807 807
 			$output .= self::label($label_args);
808 808
 		}
809 809
 
810 810
 		// help text
811
-		if(!empty($args['help_text'])){
811
+		if (!empty($args['help_text'])) {
812 812
 			$output .= AUI_Component_Helper::help_text($args['help_text']);
813 813
 		}
814 814
 
815 815
 		// maybe horizontal label
816
-		if($args['label_type']=='horizontal'){
816
+		if ($args['label_type'] == 'horizontal') {
817 817
 			$output .= '</div>';
818 818
 		}
819 819
 
820 820
 
821 821
 		// wrap
822
-		if(!$args['no_wrap']){
823
-			$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
824
-			$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
822
+		if (!$args['no_wrap']) {
823
+			$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
824
+			$wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
825 825
 			$output = self::wrap(array(
826 826
 				'content' => $output,
827 827
 				'class'   => $wrap_class,
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 	 *
842 842
 	 * @return string The rendered component.
843 843
 	 */
844
-	public static function radio($args = array()){
844
+	public static function radio($args = array()) {
845 845
 		$defaults = array(
846 846
 			'class'      => '',
847 847
 			'wrap_class' => '',
@@ -864,14 +864,14 @@  discard block
 block discarded – undo
864 864
 		/**
865 865
 		 * Parse incoming $args into an array and merge it with $defaults
866 866
 		 */
867
-		$args   = wp_parse_args( $args, $defaults );
867
+		$args = wp_parse_args($args, $defaults);
868 868
 
869 869
 		// for now lets use horizontal for floating
870
-		if( $args['label_type'] == 'floating' ){$args['label_type'] = 'horizontal';}
870
+		if ($args['label_type'] == 'floating') {$args['label_type'] = 'horizontal'; }
871 871
 
872 872
 		$label_args = array(
873 873
 			'title'=> $args['label'],
874
-			'class' => $args['label_class']." pt-0 ",
874
+			'class' => $args['label_class'] . " pt-0 ",
875 875
 			'label_type' => $args['label_type']
876 876
 		);
877 877
 
@@ -880,36 +880,36 @@  discard block
 block discarded – undo
880 880
 
881 881
 
882 882
 		// label before
883
-		if(!empty($args['label'])){
884
-			$output .= self::label( $label_args, 'radio' );
883
+		if (!empty($args['label'])) {
884
+			$output .= self::label($label_args, 'radio');
885 885
 		}
886 886
 
887 887
 		// maybe horizontal label
888
-		if($args['label_type']=='horizontal'){
888
+		if ($args['label_type'] == 'horizontal') {
889 889
 			$output .= '<div class="col-sm-10">';
890 890
 		}
891 891
 
892
-		if(!empty($args['options'])){
892
+		if (!empty($args['options'])) {
893 893
 			$count = 0;
894
-			foreach($args['options'] as $value => $label){
894
+			foreach ($args['options'] as $value => $label) {
895 895
 				$option_args = $args;
896 896
 				$option_args['value'] = $value;
897 897
 				$option_args['label'] = $label;
898 898
 				$option_args['checked'] = $value == $args['value'] ? true : false;
899
-				$output .= self::radio_option($option_args,$count);
899
+				$output .= self::radio_option($option_args, $count);
900 900
 				$count++;
901 901
 			}
902 902
 		}
903 903
 
904 904
 		// maybe horizontal label
905
-		if($args['label_type']=='horizontal'){
905
+		if ($args['label_type'] == 'horizontal') {
906 906
 			$output .= '</div>';
907 907
 		}
908 908
 
909 909
 
910 910
 		// wrap
911
-		$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
912
-		$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
911
+		$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
912
+		$wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
913 913
 		$output = self::wrap(array(
914 914
 			'content' => $output,
915 915
 			'class'   => $wrap_class,
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 	 *
929 929
 	 * @return string The rendered component.
930 930
 	 */
931
-	public static function radio_option($args = array(),$count = ''){
931
+	public static function radio_option($args = array(), $count = '') {
932 932
 		$defaults = array(
933 933
 			'class'      => '',
934 934
 			'id'         => '',
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
 		/**
947 947
 		 * Parse incoming $args into an array and merge it with $defaults
948 948
 		 */
949
-		$args   = wp_parse_args( $args, $defaults );
949
+		$args   = wp_parse_args($args, $defaults);
950 950
 
951 951
 		$output = '';
952 952
 
@@ -957,27 +957,27 @@  discard block
 block discarded – undo
957 957
 		$output .= ' class="form-check-input" ';
958 958
 
959 959
 		// name
960
-		if(!empty($args['name'])){
960
+		if (!empty($args['name'])) {
961 961
 			$output .= AUI_Component_Helper::name($args['name']);
962 962
 		}
963 963
 
964 964
 		// id
965
-		if(!empty($args['id'])){
966
-			$output .= AUI_Component_Helper::id($args['id'].$count);
965
+		if (!empty($args['id'])) {
966
+			$output .= AUI_Component_Helper::id($args['id'] . $count);
967 967
 		}
968 968
 
969 969
 		// title
970
-		if(!empty($args['title'])){
970
+		if (!empty($args['title'])) {
971 971
 			$output .= AUI_Component_Helper::title($args['title']);
972 972
 		}
973 973
 
974 974
 		// value
975
-		if(isset($args['value'])){
976
-			$output .= ' value="'.sanitize_text_field($args['value']).'" ';
975
+		if (isset($args['value'])) {
976
+			$output .= ' value="' . sanitize_text_field($args['value']) . '" ';
977 977
 		}
978 978
 
979 979
 		// checked, for radio and checkboxes
980
-		if( $args['checked'] ){
980
+		if ($args['checked']) {
981 981
 			$output .= ' checked ';
982 982
 		}
983 983
 
@@ -988,12 +988,12 @@  discard block
 block discarded – undo
988 988
 		$output .= AUI_Component_Helper::aria_attributes($args);
989 989
 
990 990
 		// extra attributes
991
-		if(!empty($args['extra_attributes'])){
991
+		if (!empty($args['extra_attributes'])) {
992 992
 			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
993 993
 		}
994 994
 
995 995
 		// required
996
-		if(!empty($args['required'])){
996
+		if (!empty($args['required'])) {
997 997
 			$output .= ' required ';
998 998
 		}
999 999
 
@@ -1001,13 +1001,13 @@  discard block
 block discarded – undo
1001 1001
 		$output .= ' >';
1002 1002
 
1003 1003
 		// label
1004
-		if(!empty($args['label']) && is_array($args['label'])){
1005
-		}elseif(!empty($args['label'])){
1006
-			$output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
1004
+		if (!empty($args['label']) && is_array($args['label'])) {
1005
+		}elseif (!empty($args['label'])) {
1006
+			$output .= self::label(array('title'=>$args['label'], 'for'=>$args['id'] . $count, 'class'=>'form-check-label'), 'radio');
1007 1007
 		}
1008 1008
 
1009 1009
 		// wrap
1010
-		if(!$args['no_wrap']){
1010
+		if (!$args['no_wrap']) {
1011 1011
 			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1012 1012
 			$output = self::wrap(array(
1013 1013
 				'content' => $output,
Please login to merge, or discard this patch.
Braces   +15 added lines, -16 removed lines patch added patch discarded remove patch
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 			if($type=='file' ){
81 81
 				$label_after = true; // if type file we need the label after
82 82
 				$args['class'] .= ' custom-file-input ';
83
-			}elseif($type=='checkbox'){
83
+			} elseif($type=='checkbox'){
84 84
 				$label_after = true; // if type file we need the label after
85 85
 				$args['class'] .= ' custom-control-input ';
86
-			}elseif($type=='datepicker' || $type=='timepicker'){
86
+			} elseif($type=='datepicker' || $type=='timepicker'){
87 87
 				$type = 'text';
88 88
 				//$args['class'] .= ' aui-flatpickr bg-initial ';
89 89
 				$args['class'] .= ' bg-initial ';
@@ -167,8 +167,7 @@  discard block
 block discarded – undo
167 167
 
168 168
 			// label
169 169
 			if(!empty($args['label'])){
170
-				if($type == 'file'){$label_args['class'] .= 'custom-file-label';}
171
-				elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
170
+				if($type == 'file'){$label_args['class'] .= 'custom-file-label';} elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
172 171
 				$label = self::label( $label_args, $type );
173 172
 			}
174 173
 
@@ -189,7 +188,7 @@  discard block
 block discarded – undo
189 188
 					'content' => $output,
190 189
 					'class'   => 'form-group custom-file'
191 190
 				) );
192
-			}elseif($type == 'checkbox'){
191
+			} elseif($type == 'checkbox'){
193 192
 				$wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
194 193
 				$output = self::wrap( array(
195 194
 					'content' => $output,
@@ -199,7 +198,7 @@  discard block
 block discarded – undo
199 198
 				if($args['label_type']=='horizontal'){
200 199
 					$output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
201 200
 				}
202
-			}elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
201
+			} elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
203 202
 
204 203
 
205 204
 				// allow password field to toggle view
@@ -325,7 +324,7 @@  discard block
 block discarded – undo
325 324
 
326 325
 		// label
327 326
 		if(!empty($args['label']) && is_array($args['label'])){
328
-		}elseif(!empty($args['label']) && !$label_after){
327
+		} elseif(!empty($args['label']) && !$label_after){
329 328
 			$label_args = array(
330 329
 				'title'=> $args['label'],
331 330
 				'for'=> $args['id'],
@@ -360,7 +359,7 @@  discard block
 block discarded – undo
360 359
 
361 360
 			wp_editor( $content, $editor_id, $settings );
362 361
 			$output .= ob_get_clean();
363
-		}else{
362
+		} else{
364 363
 
365 364
 			// open
366 365
 			$output .= '<textarea ';
@@ -483,7 +482,7 @@  discard block
 block discarded – undo
483 482
 			// maybe hide labels //@todo set a global option for visibility class
484 483
 			if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
485 484
 				$class = $args['class'];
486
-			}else{
485
+			} else{
487 486
 				$class = 'sr-only '.$args['class'];
488 487
 			}
489 488
 
@@ -594,7 +593,7 @@  discard block
 block discarded – undo
594 593
 			$output .= '</'.sanitize_html_class($args['type']).'>';
595 594
 
596 595
 
597
-		}else{
596
+		} else{
598 597
 			$output = $args['content'];
599 598
 		}
600 599
 
@@ -657,7 +656,7 @@  discard block
 block discarded – undo
657 656
 		if(!empty($args['select2'])){
658 657
 			$args['class'] .= ' aui-select2';
659 658
 			$is_select2 = true;
660
-		}elseif( strpos($args['class'], 'aui-select2') !== false){
659
+		} elseif( strpos($args['class'], 'aui-select2') !== false){
661 660
 			$is_select2 = true;
662 661
 		}
663 662
 
@@ -676,7 +675,7 @@  discard block
 block discarded – undo
676 675
 
677 676
 		// label
678 677
 		if(!empty($args['label']) && is_array($args['label'])){
679
-		}elseif(!empty($args['label']) && !$label_after){
678
+		} elseif(!empty($args['label']) && !$label_after){
680 679
 			$label_args = array(
681 680
 				'title'=> $args['label'],
682 681
 				'for'=> $args['id'],
@@ -751,7 +750,7 @@  discard block
 block discarded – undo
751 750
 		// placeholder
752 751
 		if(isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2){
753 752
 			$output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
754
-		}elseif($is_select2 && !empty($args['placeholder'])){
753
+		} elseif($is_select2 && !empty($args['placeholder'])){
755 754
 			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
756 755
 		}
757 756
 
@@ -760,7 +759,7 @@  discard block
 block discarded – undo
760 759
 
761 760
 			if(!is_array($args['options'])){
762 761
 				$output .= $args['options']; // not the preferred way but an option
763
-			}else{
762
+			} else{
764 763
 				foreach($args['options'] as $val => $name){
765 764
 					$selected = '';
766 765
 					if(is_array($name)){
@@ -779,7 +778,7 @@  discard block
 block discarded – undo
779 778
 
780 779
 							$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
781 780
 						}
782
-					}else{
781
+					} else{
783 782
 						if(!empty($args['value'])){
784 783
 							if(is_array($args['value'])){
785 784
 								$selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
@@ -1002,7 +1001,7 @@  discard block
 block discarded – undo
1002 1001
 
1003 1002
 		// label
1004 1003
 		if(!empty($args['label']) && is_array($args['label'])){
1005
-		}elseif(!empty($args['label'])){
1004
+		} elseif(!empty($args['label'])){
1006 1005
 			$output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
1007 1006
 		}
1008 1007
 
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-helper.php 2 patches
Indentation   +246 added lines, -246 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,250 +11,250 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Helper {
13 13
 
14
-	/**
15
-	 * A component helper for generating a input name.
16
-	 *
17
-	 * @param $text
18
-	 * @param $multiple bool If the name is set to be multiple but no brackets found then we add some.
19
-	 *
20
-	 * @return string
21
-	 */
22
-	public static function name($text,$multiple = false){
23
-		$output = '';
24
-
25
-		if($text){
26
-			$is_multiple = strpos($text, '[') === false && $multiple  ? '[]' : '';
27
-			$output = ' name="'.esc_attr($text).$is_multiple.'" ';
28
-		}
29
-
30
-		return $output;
31
-	}
32
-
33
-	/**
34
-	 * A component helper for generating a item id.
35
-	 *
36
-	 * @param $text string The text to be used as the value.
37
-	 *
38
-	 * @return string The sanitized item.
39
-	 */
40
-	public static function id($text){
41
-		$output = '';
42
-
43
-		if($text){
44
-			$output = ' id="'.sanitize_html_class($text).'" ';
45
-		}
46
-
47
-		return $output;
48
-	}
49
-
50
-	/**
51
-	 * A component helper for generating a item title.
52
-	 *
53
-	 * @param $text string The text to be used as the value.
54
-	 *
55
-	 * @return string The sanitized item.
56
-	 */
57
-	public static function title($text){
58
-		$output = '';
59
-
60
-		if($text){
61
-			$output = ' title="'.esc_attr($text).'" ';
62
-		}
63
-
64
-		return $output;
65
-	}
66
-
67
-	/**
68
-	 * A component helper for generating a item value.
69
-	 *
70
-	 * @param $text string The text to be used as the value.
71
-	 *
72
-	 * @return string The sanitized item.
73
-	 */
74
-	public static function value($text){
75
-		$output = '';
76
-
77
-		if($text){
78
-			$output = ' value="'.sanitize_text_field($text).'" ';
79
-		}
80
-
81
-		return $output;
82
-	}
83
-
84
-	/**
85
-	 * A component helper for generating a item class attribute.
86
-	 *
87
-	 * @param $text string The text to be used as the value.
88
-	 *
89
-	 * @return string The sanitized item.
90
-	 */
91
-	public static function class_attr($text){
92
-		$output = '';
93
-
94
-		if($text){
95
-			$classes = self::esc_classes($text);
96
-			if(!empty($classes)){
97
-				$output = ' class="'.$classes.'" ';
98
-			}
99
-		}
100
-
101
-		return $output;
102
-	}
103
-
104
-	/**
105
-	 * Escape a string of classes.
106
-	 *
107
-	 * @param $text
108
-	 *
109
-	 * @return string
110
-	 */
111
-	public static function esc_classes($text){
112
-		$output = '';
113
-
114
-		if($text){
115
-			$classes = explode(" ",$text);
116
-			$classes = array_map("trim",$classes);
117
-			$classes = array_map("sanitize_html_class",$classes);
118
-			if(!empty($classes)){
119
-				$output = implode(" ",$classes);
120
-			}
121
-		}
122
-
123
-		return $output;
124
-
125
-	}
126
-
127
-	/**
128
-	 * @param $args
129
-	 *
130
-	 * @return string
131
-	 */
132
-	public static function data_attributes($args){
133
-		$output = '';
134
-
135
-		if(!empty($args)){
136
-
137
-			foreach($args as $key => $val){
138
-				if(substr( $key, 0, 5 ) === "data-"){
139
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
140
-				}
141
-			}
142
-		}
143
-
144
-		return $output;
145
-	}
146
-
147
-	/**
148
-	 * @param $args
149
-	 *
150
-	 * @return string
151
-	 */
152
-	public static function aria_attributes($args){
153
-		$output = '';
154
-
155
-		if(!empty($args)){
156
-
157
-			foreach($args as $key => $val){
158
-				if(substr( $key, 0, 5 ) === "aria-"){
159
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
160
-				}
161
-			}
162
-		}
163
-
164
-		return $output;
165
-	}
166
-
167
-	/**
168
-	 * Build a font awesome icon from a class.
169
-	 *
170
-	 * @param $class
171
-	 * @param bool $space_after
172
-	 * @param array $extra_attributes An array of extra attributes.
173
-	 *
174
-	 * @return string
175
-	 */
176
-	public static function icon($class,$space_after = false, $extra_attributes = array()){
177
-		$output = '';
178
-
179
-		if($class){
180
-			$classes = self::esc_classes($class);
181
-			if(!empty($classes)){
182
-				$output = '<i class="'.$classes.'" ';
183
-				// extra attributes
184
-				if(!empty($extra_attributes)){
185
-					$output .= AUI_Component_Helper::extra_attributes($extra_attributes);
186
-				}
187
-				$output .= '></i>';
188
-				if($space_after){
189
-					$output .= " ";
190
-				}
191
-			}
192
-		}
193
-
194
-		return $output;
195
-	}
196
-
197
-	/**
198
-	 * @param $args
199
-	 *
200
-	 * @return string
201
-	 */
202
-	public static function extra_attributes($args){
203
-		$output = '';
204
-
205
-		if(!empty($args)){
206
-
207
-			if( is_array($args) ){
208
-				foreach($args as $key => $val){
209
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
210
-				}
211
-			}else{
212
-				$output .= ' '.$args.' ';
213
-			}
214
-
215
-		}
216
-
217
-		return $output;
218
-	}
219
-
220
-	/**
221
-	 * @param $args
222
-	 *
223
-	 * @return string
224
-	 */
225
-	public static function help_text($text){
226
-		$output = '';
227
-
228
-		if($text){
229
-			$output .= '<small class="form-text text-muted">'.wp_kses_post($text).'</small>';
230
-		}
231
-
232
-
233
-		return $output;
234
-	}
235
-
236
-	/**
237
-	 * Replace element require context with JS.
238
-	 *
239
-	 * @param $input
240
-	 *
241
-	 * @return string|void
242
-	 */
243
-	public static function element_require( $input ) {
244
-
245
-		$input = str_replace( "'", '"', $input );// we only want double quotes
246
-
247
-		$output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
248
-			"jQuery(form).find('[data-argument=\"",
249
-			"\"]').find('input,select,textarea').val()",
250
-			"\"]').find('input:checked').val()",
251
-		), $input ) );
252
-
253
-		if($output){
254
-			$output = ' data-element-require="'.$output.'" ';
255
-		}
256
-
257
-		return $output;
258
-	}
14
+    /**
15
+     * A component helper for generating a input name.
16
+     *
17
+     * @param $text
18
+     * @param $multiple bool If the name is set to be multiple but no brackets found then we add some.
19
+     *
20
+     * @return string
21
+     */
22
+    public static function name($text,$multiple = false){
23
+        $output = '';
24
+
25
+        if($text){
26
+            $is_multiple = strpos($text, '[') === false && $multiple  ? '[]' : '';
27
+            $output = ' name="'.esc_attr($text).$is_multiple.'" ';
28
+        }
29
+
30
+        return $output;
31
+    }
32
+
33
+    /**
34
+     * A component helper for generating a item id.
35
+     *
36
+     * @param $text string The text to be used as the value.
37
+     *
38
+     * @return string The sanitized item.
39
+     */
40
+    public static function id($text){
41
+        $output = '';
42
+
43
+        if($text){
44
+            $output = ' id="'.sanitize_html_class($text).'" ';
45
+        }
46
+
47
+        return $output;
48
+    }
49
+
50
+    /**
51
+     * A component helper for generating a item title.
52
+     *
53
+     * @param $text string The text to be used as the value.
54
+     *
55
+     * @return string The sanitized item.
56
+     */
57
+    public static function title($text){
58
+        $output = '';
59
+
60
+        if($text){
61
+            $output = ' title="'.esc_attr($text).'" ';
62
+        }
63
+
64
+        return $output;
65
+    }
66
+
67
+    /**
68
+     * A component helper for generating a item value.
69
+     *
70
+     * @param $text string The text to be used as the value.
71
+     *
72
+     * @return string The sanitized item.
73
+     */
74
+    public static function value($text){
75
+        $output = '';
76
+
77
+        if($text){
78
+            $output = ' value="'.sanitize_text_field($text).'" ';
79
+        }
80
+
81
+        return $output;
82
+    }
83
+
84
+    /**
85
+     * A component helper for generating a item class attribute.
86
+     *
87
+     * @param $text string The text to be used as the value.
88
+     *
89
+     * @return string The sanitized item.
90
+     */
91
+    public static function class_attr($text){
92
+        $output = '';
93
+
94
+        if($text){
95
+            $classes = self::esc_classes($text);
96
+            if(!empty($classes)){
97
+                $output = ' class="'.$classes.'" ';
98
+            }
99
+        }
100
+
101
+        return $output;
102
+    }
103
+
104
+    /**
105
+     * Escape a string of classes.
106
+     *
107
+     * @param $text
108
+     *
109
+     * @return string
110
+     */
111
+    public static function esc_classes($text){
112
+        $output = '';
113
+
114
+        if($text){
115
+            $classes = explode(" ",$text);
116
+            $classes = array_map("trim",$classes);
117
+            $classes = array_map("sanitize_html_class",$classes);
118
+            if(!empty($classes)){
119
+                $output = implode(" ",$classes);
120
+            }
121
+        }
122
+
123
+        return $output;
124
+
125
+    }
126
+
127
+    /**
128
+     * @param $args
129
+     *
130
+     * @return string
131
+     */
132
+    public static function data_attributes($args){
133
+        $output = '';
134
+
135
+        if(!empty($args)){
136
+
137
+            foreach($args as $key => $val){
138
+                if(substr( $key, 0, 5 ) === "data-"){
139
+                    $output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
140
+                }
141
+            }
142
+        }
143
+
144
+        return $output;
145
+    }
146
+
147
+    /**
148
+     * @param $args
149
+     *
150
+     * @return string
151
+     */
152
+    public static function aria_attributes($args){
153
+        $output = '';
154
+
155
+        if(!empty($args)){
156
+
157
+            foreach($args as $key => $val){
158
+                if(substr( $key, 0, 5 ) === "aria-"){
159
+                    $output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
160
+                }
161
+            }
162
+        }
163
+
164
+        return $output;
165
+    }
166
+
167
+    /**
168
+     * Build a font awesome icon from a class.
169
+     *
170
+     * @param $class
171
+     * @param bool $space_after
172
+     * @param array $extra_attributes An array of extra attributes.
173
+     *
174
+     * @return string
175
+     */
176
+    public static function icon($class,$space_after = false, $extra_attributes = array()){
177
+        $output = '';
178
+
179
+        if($class){
180
+            $classes = self::esc_classes($class);
181
+            if(!empty($classes)){
182
+                $output = '<i class="'.$classes.'" ';
183
+                // extra attributes
184
+                if(!empty($extra_attributes)){
185
+                    $output .= AUI_Component_Helper::extra_attributes($extra_attributes);
186
+                }
187
+                $output .= '></i>';
188
+                if($space_after){
189
+                    $output .= " ";
190
+                }
191
+            }
192
+        }
193
+
194
+        return $output;
195
+    }
196
+
197
+    /**
198
+     * @param $args
199
+     *
200
+     * @return string
201
+     */
202
+    public static function extra_attributes($args){
203
+        $output = '';
204
+
205
+        if(!empty($args)){
206
+
207
+            if( is_array($args) ){
208
+                foreach($args as $key => $val){
209
+                    $output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
210
+                }
211
+            }else{
212
+                $output .= ' '.$args.' ';
213
+            }
214
+
215
+        }
216
+
217
+        return $output;
218
+    }
219
+
220
+    /**
221
+     * @param $args
222
+     *
223
+     * @return string
224
+     */
225
+    public static function help_text($text){
226
+        $output = '';
227
+
228
+        if($text){
229
+            $output .= '<small class="form-text text-muted">'.wp_kses_post($text).'</small>';
230
+        }
231
+
232
+
233
+        return $output;
234
+    }
235
+
236
+    /**
237
+     * Replace element require context with JS.
238
+     *
239
+     * @param $input
240
+     *
241
+     * @return string|void
242
+     */
243
+    public static function element_require( $input ) {
244
+
245
+        $input = str_replace( "'", '"', $input );// we only want double quotes
246
+
247
+        $output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
248
+            "jQuery(form).find('[data-argument=\"",
249
+            "\"]').find('input,select,textarea').val()",
250
+            "\"]').find('input:checked').val()",
251
+        ), $input ) );
252
+
253
+        if($output){
254
+            $output = ' data-element-require="'.$output.'" ';
255
+        }
256
+
257
+        return $output;
258
+    }
259 259
 
260 260
 }
261 261
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
 	 *
20 20
 	 * @return string
21 21
 	 */
22
-	public static function name($text,$multiple = false){
22
+	public static function name($text, $multiple = false) {
23 23
 		$output = '';
24 24
 
25
-		if($text){
26
-			$is_multiple = strpos($text, '[') === false && $multiple  ? '[]' : '';
27
-			$output = ' name="'.esc_attr($text).$is_multiple.'" ';
25
+		if ($text) {
26
+			$is_multiple = strpos($text, '[') === false && $multiple ? '[]' : '';
27
+			$output = ' name="' . esc_attr($text) . $is_multiple . '" ';
28 28
 		}
29 29
 
30 30
 		return $output;
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @return string The sanitized item.
39 39
 	 */
40
-	public static function id($text){
40
+	public static function id($text) {
41 41
 		$output = '';
42 42
 
43
-		if($text){
44
-			$output = ' id="'.sanitize_html_class($text).'" ';
43
+		if ($text) {
44
+			$output = ' id="' . sanitize_html_class($text) . '" ';
45 45
 		}
46 46
 
47 47
 		return $output;
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @return string The sanitized item.
56 56
 	 */
57
-	public static function title($text){
57
+	public static function title($text) {
58 58
 		$output = '';
59 59
 
60
-		if($text){
61
-			$output = ' title="'.esc_attr($text).'" ';
60
+		if ($text) {
61
+			$output = ' title="' . esc_attr($text) . '" ';
62 62
 		}
63 63
 
64 64
 		return $output;
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @return string The sanitized item.
73 73
 	 */
74
-	public static function value($text){
74
+	public static function value($text) {
75 75
 		$output = '';
76 76
 
77
-		if($text){
78
-			$output = ' value="'.sanitize_text_field($text).'" ';
77
+		if ($text) {
78
+			$output = ' value="' . sanitize_text_field($text) . '" ';
79 79
 		}
80 80
 
81 81
 		return $output;
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @return string The sanitized item.
90 90
 	 */
91
-	public static function class_attr($text){
91
+	public static function class_attr($text) {
92 92
 		$output = '';
93 93
 
94
-		if($text){
94
+		if ($text) {
95 95
 			$classes = self::esc_classes($text);
96
-			if(!empty($classes)){
97
-				$output = ' class="'.$classes.'" ';
96
+			if (!empty($classes)) {
97
+				$output = ' class="' . $classes . '" ';
98 98
 			}
99 99
 		}
100 100
 
@@ -108,15 +108,15 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @return string
110 110
 	 */
111
-	public static function esc_classes($text){
111
+	public static function esc_classes($text) {
112 112
 		$output = '';
113 113
 
114
-		if($text){
115
-			$classes = explode(" ",$text);
116
-			$classes = array_map("trim",$classes);
117
-			$classes = array_map("sanitize_html_class",$classes);
118
-			if(!empty($classes)){
119
-				$output = implode(" ",$classes);
114
+		if ($text) {
115
+			$classes = explode(" ", $text);
116
+			$classes = array_map("trim", $classes);
117
+			$classes = array_map("sanitize_html_class", $classes);
118
+			if (!empty($classes)) {
119
+				$output = implode(" ", $classes);
120 120
 			}
121 121
 		}
122 122
 
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @return string
131 131
 	 */
132
-	public static function data_attributes($args){
132
+	public static function data_attributes($args) {
133 133
 		$output = '';
134 134
 
135
-		if(!empty($args)){
135
+		if (!empty($args)) {
136 136
 
137
-			foreach($args as $key => $val){
138
-				if(substr( $key, 0, 5 ) === "data-"){
139
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
137
+			foreach ($args as $key => $val) {
138
+				if (substr($key, 0, 5) === "data-") {
139
+					$output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" ';
140 140
 				}
141 141
 			}
142 142
 		}
@@ -149,14 +149,14 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @return string
151 151
 	 */
152
-	public static function aria_attributes($args){
152
+	public static function aria_attributes($args) {
153 153
 		$output = '';
154 154
 
155
-		if(!empty($args)){
155
+		if (!empty($args)) {
156 156
 
157
-			foreach($args as $key => $val){
158
-				if(substr( $key, 0, 5 ) === "aria-"){
159
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
157
+			foreach ($args as $key => $val) {
158
+				if (substr($key, 0, 5) === "aria-") {
159
+					$output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" ';
160 160
 				}
161 161
 			}
162 162
 		}
@@ -173,19 +173,19 @@  discard block
 block discarded – undo
173 173
 	 *
174 174
 	 * @return string
175 175
 	 */
176
-	public static function icon($class,$space_after = false, $extra_attributes = array()){
176
+	public static function icon($class, $space_after = false, $extra_attributes = array()) {
177 177
 		$output = '';
178 178
 
179
-		if($class){
179
+		if ($class) {
180 180
 			$classes = self::esc_classes($class);
181
-			if(!empty($classes)){
182
-				$output = '<i class="'.$classes.'" ';
181
+			if (!empty($classes)) {
182
+				$output = '<i class="' . $classes . '" ';
183 183
 				// extra attributes
184
-				if(!empty($extra_attributes)){
184
+				if (!empty($extra_attributes)) {
185 185
 					$output .= AUI_Component_Helper::extra_attributes($extra_attributes);
186 186
 				}
187 187
 				$output .= '></i>';
188
-				if($space_after){
188
+				if ($space_after) {
189 189
 					$output .= " ";
190 190
 				}
191 191
 			}
@@ -199,17 +199,17 @@  discard block
 block discarded – undo
199 199
 	 *
200 200
 	 * @return string
201 201
 	 */
202
-	public static function extra_attributes($args){
202
+	public static function extra_attributes($args) {
203 203
 		$output = '';
204 204
 
205
-		if(!empty($args)){
205
+		if (!empty($args)) {
206 206
 
207
-			if( is_array($args) ){
208
-				foreach($args as $key => $val){
209
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
207
+			if (is_array($args)) {
208
+				foreach ($args as $key => $val) {
209
+					$output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" ';
210 210
 				}
211
-			}else{
212
-				$output .= ' '.$args.' ';
211
+			} else {
212
+				$output .= ' ' . $args . ' ';
213 213
 			}
214 214
 
215 215
 		}
@@ -222,11 +222,11 @@  discard block
 block discarded – undo
222 222
 	 *
223 223
 	 * @return string
224 224
 	 */
225
-	public static function help_text($text){
225
+	public static function help_text($text) {
226 226
 		$output = '';
227 227
 
228
-		if($text){
229
-			$output .= '<small class="form-text text-muted">'.wp_kses_post($text).'</small>';
228
+		if ($text) {
229
+			$output .= '<small class="form-text text-muted">' . wp_kses_post($text) . '</small>';
230 230
 		}
231 231
 
232 232
 
@@ -240,18 +240,18 @@  discard block
 block discarded – undo
240 240
 	 *
241 241
 	 * @return string|void
242 242
 	 */
243
-	public static function element_require( $input ) {
243
+	public static function element_require($input) {
244 244
 
245
-		$input = str_replace( "'", '"', $input );// we only want double quotes
245
+		$input = str_replace("'", '"', $input); // we only want double quotes
246 246
 
247
-		$output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
247
+		$output = esc_attr(str_replace(array("[%", "%]", "%:checked]"), array(
248 248
 			"jQuery(form).find('[data-argument=\"",
249 249
 			"\"]').find('input,select,textarea').val()",
250 250
 			"\"]').find('input:checked').val()",
251
-		), $input ) );
251
+		), $input));
252 252
 
253
-		if($output){
254
-			$output = ' data-element-require="'.$output.'" ';
253
+		if ($output) {
254
+			$output = ' data-element-require="' . $output . '" ';
255 255
 		}
256 256
 
257 257
 		return $output;
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/includes/class-aui.php 1 patch
Indentation   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,231 +11,231 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI {
13 13
 
14
-	/**
15
-	 * Holds the class instance.
16
-	 *
17
-	 * @since 1.0.0
18
-	 * @var null
19
-	 */
20
-	private static $instance = null;
21
-
22
-	/**
23
-	 * Holds the current AUI version number.
24
-	 *
25
-	 * @var string $ver The current version number.
26
-	 */
27
-	public static $ver = '0.1.35';
28
-
29
-	public static $options = null;
30
-
31
-	/**
32
-	 * There can be only one.
33
-	 *
34
-	 * @since 1.0.0
35
-	 * @return AUI|null
36
-	 */
37
-	public static function instance() {
38
-		if ( self::$instance == null ) {
39
-			self::$instance = new AUI();
40
-		}
41
-
42
-		return self::$instance;
43
-	}
44
-
45
-	/**
46
-	 * AUI constructor.
47
-	 *
48
-	 * @since 1.0.0
49
-	 */
50
-	private function __construct() {
51
-		if ( function_exists( "__autoload" ) ) {
52
-			spl_autoload_register( "__autoload" );
53
-		}
54
-		spl_autoload_register( array( $this, 'autoload' ) );
55
-
56
-		// load options
57
-		self::$options = get_option('aui_options');
58
-	}
59
-
60
-	/**
61
-	 * Autoload any components on the fly.
62
-	 *
63
-	 * @since 1.0.0
64
-	 *
65
-	 * @param $classname
66
-	 */
67
-	private function autoload( $classname ) {
68
-		$class     = str_replace( '_', '-', strtolower( $classname ) );
69
-		$file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php';
70
-		if ( $file_path && is_readable( $file_path ) ) {
71
-			include_once( $file_path );
72
-		}
73
-	}
74
-
75
-	/**
76
-	 * Get the AUI options.
77
-	 *
78
-	 * @param $option
79
-	 *
80
-	 * @return string|void
81
-	 */
82
-	public function get_option( $option ){
83
-		$result = isset(self::$options[$option]) ? esc_attr(self::$options[$option]) : '';
84
-
85
-		if ( ! $result && $option) {
86
-			if( $option == 'color_primary' ){
87
-				$result = AUI_PRIMARY_COLOR;
88
-			}elseif( $option == 'color_secondary' ){
89
-				$result = AUI_SECONDARY_COLOR;
90
-			}
91
-		}
92
-		return $result;
93
-	}
94
-
95
-	public function render( $items = array() ) {
96
-		$output = '';
97
-
98
-		if ( ! empty( $items ) ) {
99
-			foreach ( $items as $args ) {
100
-				$render = isset( $args['render'] ) ? $args['render'] : '';
101
-				if ( $render && method_exists( __CLASS__, $render ) ) {
102
-					$output .= $this->$render( $args );
103
-				}
104
-			}
105
-		}
106
-
107
-		return $output;
108
-	}
109
-
110
-	/**
111
-	 * Render and return a bootstrap alert component.
112
-	 *
113
-	 * @since 1.0.0
114
-	 *
115
-	 * @param array $args
116
-	 *
117
-	 * @return string The rendered component.
118
-	 */
119
-	public function alert( $args = array() ) {
120
-		return AUI_Component_Alert::get( $args );
121
-	}
122
-
123
-	/**
124
-	 * Render and return a bootstrap input component.
125
-	 *
126
-	 * @since 1.0.0
127
-	 *
128
-	 * @param array $args
129
-	 *
130
-	 * @return string The rendered component.
131
-	 */
132
-	public function input( $args = array() ) {
133
-		return AUI_Component_Input::input( $args );
134
-	}
135
-
136
-	/**
137
-	 * Render and return a bootstrap textarea component.
138
-	 *
139
-	 * @since 1.0.0
140
-	 *
141
-	 * @param array $args
142
-	 *
143
-	 * @return string The rendered component.
144
-	 */
145
-	public function textarea( $args = array() ) {
146
-		return AUI_Component_Input::textarea( $args );
147
-	}
148
-
149
-	/**
150
-	 * Render and return a bootstrap button component.
151
-	 *
152
-	 * @since 1.0.0
153
-	 *
154
-	 * @param array $args
155
-	 *
156
-	 * @return string The rendered component.
157
-	 */
158
-	public function button( $args = array() ) {
159
-		return AUI_Component_Button::get( $args );
160
-	}
161
-
162
-	/**
163
-	 * Render and return a bootstrap button component.
164
-	 *
165
-	 * @since 1.0.0
166
-	 *
167
-	 * @param array $args
168
-	 *
169
-	 * @return string The rendered component.
170
-	 */
171
-	public function badge( $args = array() ) {
172
-		$defaults = array(
173
-			'class' => 'badge badge-primary align-middle',
174
-		);
175
-
176
-		// maybe set type
177
-		if ( empty( $args['href'] ) ) {
178
-			$defaults['type'] = 'badge';
179
-		}
180
-
181
-		/**
182
-		 * Parse incoming $args into an array and merge it with $defaults
183
-		 */
184
-		$args = wp_parse_args( $args, $defaults );
185
-
186
-		return AUI_Component_Button::get( $args );
187
-	}
188
-
189
-	/**
190
-	 * Render and return a bootstrap dropdown component.
191
-	 *
192
-	 * @since 1.0.0
193
-	 *
194
-	 * @param array $args
195
-	 *
196
-	 * @return string The rendered component.
197
-	 */
198
-	public function dropdown( $args = array() ) {
199
-		return AUI_Component_Dropdown::get( $args );
200
-	}
201
-
202
-	/**
203
-	 * Render and return a bootstrap select component.
204
-	 *
205
-	 * @since 1.0.0
206
-	 *
207
-	 * @param array $args
208
-	 *
209
-	 * @return string The rendered component.
210
-	 */
211
-	public function select( $args = array() ) {
212
-		return AUI_Component_Input::select( $args );
213
-	}
214
-
215
-	/**
216
-	 * Render and return a bootstrap radio component.
217
-	 *
218
-	 * @since 1.0.0
219
-	 *
220
-	 * @param array $args
221
-	 *
222
-	 * @return string The rendered component.
223
-	 */
224
-	public function radio( $args = array() ) {
225
-		return AUI_Component_Input::radio( $args );
226
-	}
227
-
228
-	/**
229
-	 * Render and return a bootstrap pagination component.
230
-	 *
231
-	 * @since 1.0.0
232
-	 *
233
-	 * @param array $args
234
-	 *
235
-	 * @return string The rendered component.
236
-	 */
237
-	public function pagination( $args = array() ) {
238
-		return AUI_Component_Pagination::get( $args );
239
-	}
14
+    /**
15
+     * Holds the class instance.
16
+     *
17
+     * @since 1.0.0
18
+     * @var null
19
+     */
20
+    private static $instance = null;
21
+
22
+    /**
23
+     * Holds the current AUI version number.
24
+     *
25
+     * @var string $ver The current version number.
26
+     */
27
+    public static $ver = '0.1.35';
28
+
29
+    public static $options = null;
30
+
31
+    /**
32
+     * There can be only one.
33
+     *
34
+     * @since 1.0.0
35
+     * @return AUI|null
36
+     */
37
+    public static function instance() {
38
+        if ( self::$instance == null ) {
39
+            self::$instance = new AUI();
40
+        }
41
+
42
+        return self::$instance;
43
+    }
44
+
45
+    /**
46
+     * AUI constructor.
47
+     *
48
+     * @since 1.0.0
49
+     */
50
+    private function __construct() {
51
+        if ( function_exists( "__autoload" ) ) {
52
+            spl_autoload_register( "__autoload" );
53
+        }
54
+        spl_autoload_register( array( $this, 'autoload' ) );
55
+
56
+        // load options
57
+        self::$options = get_option('aui_options');
58
+    }
59
+
60
+    /**
61
+     * Autoload any components on the fly.
62
+     *
63
+     * @since 1.0.0
64
+     *
65
+     * @param $classname
66
+     */
67
+    private function autoload( $classname ) {
68
+        $class     = str_replace( '_', '-', strtolower( $classname ) );
69
+        $file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php';
70
+        if ( $file_path && is_readable( $file_path ) ) {
71
+            include_once( $file_path );
72
+        }
73
+    }
74
+
75
+    /**
76
+     * Get the AUI options.
77
+     *
78
+     * @param $option
79
+     *
80
+     * @return string|void
81
+     */
82
+    public function get_option( $option ){
83
+        $result = isset(self::$options[$option]) ? esc_attr(self::$options[$option]) : '';
84
+
85
+        if ( ! $result && $option) {
86
+            if( $option == 'color_primary' ){
87
+                $result = AUI_PRIMARY_COLOR;
88
+            }elseif( $option == 'color_secondary' ){
89
+                $result = AUI_SECONDARY_COLOR;
90
+            }
91
+        }
92
+        return $result;
93
+    }
94
+
95
+    public function render( $items = array() ) {
96
+        $output = '';
97
+
98
+        if ( ! empty( $items ) ) {
99
+            foreach ( $items as $args ) {
100
+                $render = isset( $args['render'] ) ? $args['render'] : '';
101
+                if ( $render && method_exists( __CLASS__, $render ) ) {
102
+                    $output .= $this->$render( $args );
103
+                }
104
+            }
105
+        }
106
+
107
+        return $output;
108
+    }
109
+
110
+    /**
111
+     * Render and return a bootstrap alert component.
112
+     *
113
+     * @since 1.0.0
114
+     *
115
+     * @param array $args
116
+     *
117
+     * @return string The rendered component.
118
+     */
119
+    public function alert( $args = array() ) {
120
+        return AUI_Component_Alert::get( $args );
121
+    }
122
+
123
+    /**
124
+     * Render and return a bootstrap input component.
125
+     *
126
+     * @since 1.0.0
127
+     *
128
+     * @param array $args
129
+     *
130
+     * @return string The rendered component.
131
+     */
132
+    public function input( $args = array() ) {
133
+        return AUI_Component_Input::input( $args );
134
+    }
135
+
136
+    /**
137
+     * Render and return a bootstrap textarea component.
138
+     *
139
+     * @since 1.0.0
140
+     *
141
+     * @param array $args
142
+     *
143
+     * @return string The rendered component.
144
+     */
145
+    public function textarea( $args = array() ) {
146
+        return AUI_Component_Input::textarea( $args );
147
+    }
148
+
149
+    /**
150
+     * Render and return a bootstrap button component.
151
+     *
152
+     * @since 1.0.0
153
+     *
154
+     * @param array $args
155
+     *
156
+     * @return string The rendered component.
157
+     */
158
+    public function button( $args = array() ) {
159
+        return AUI_Component_Button::get( $args );
160
+    }
161
+
162
+    /**
163
+     * Render and return a bootstrap button component.
164
+     *
165
+     * @since 1.0.0
166
+     *
167
+     * @param array $args
168
+     *
169
+     * @return string The rendered component.
170
+     */
171
+    public function badge( $args = array() ) {
172
+        $defaults = array(
173
+            'class' => 'badge badge-primary align-middle',
174
+        );
175
+
176
+        // maybe set type
177
+        if ( empty( $args['href'] ) ) {
178
+            $defaults['type'] = 'badge';
179
+        }
180
+
181
+        /**
182
+         * Parse incoming $args into an array and merge it with $defaults
183
+         */
184
+        $args = wp_parse_args( $args, $defaults );
185
+
186
+        return AUI_Component_Button::get( $args );
187
+    }
188
+
189
+    /**
190
+     * Render and return a bootstrap dropdown component.
191
+     *
192
+     * @since 1.0.0
193
+     *
194
+     * @param array $args
195
+     *
196
+     * @return string The rendered component.
197
+     */
198
+    public function dropdown( $args = array() ) {
199
+        return AUI_Component_Dropdown::get( $args );
200
+    }
201
+
202
+    /**
203
+     * Render and return a bootstrap select component.
204
+     *
205
+     * @since 1.0.0
206
+     *
207
+     * @param array $args
208
+     *
209
+     * @return string The rendered component.
210
+     */
211
+    public function select( $args = array() ) {
212
+        return AUI_Component_Input::select( $args );
213
+    }
214
+
215
+    /**
216
+     * Render and return a bootstrap radio component.
217
+     *
218
+     * @since 1.0.0
219
+     *
220
+     * @param array $args
221
+     *
222
+     * @return string The rendered component.
223
+     */
224
+    public function radio( $args = array() ) {
225
+        return AUI_Component_Input::radio( $args );
226
+    }
227
+
228
+    /**
229
+     * Render and return a bootstrap pagination component.
230
+     *
231
+     * @since 1.0.0
232
+     *
233
+     * @param array $args
234
+     *
235
+     * @return string The rendered component.
236
+     */
237
+    public function pagination( $args = array() ) {
238
+        return AUI_Component_Pagination::get( $args );
239
+    }
240 240
 
241 241
 }
242 242
\ No newline at end of file
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@
 block discarded – undo
7 7
  * Bail if we are not in WP.
8 8
  */
9 9
 if ( ! defined( 'ABSPATH' ) ) {
10
-	exit;
10
+    exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Set the version only if its the current newest while loading.
15 15
  */
16 16
 add_action('after_setup_theme', function () {
17
-	global $ayecode_ui_version,$ayecode_ui_file_key;
18
-	$this_version = "0.1.35";
19
-	if(version_compare($this_version , $ayecode_ui_version, '>')){
20
-		$ayecode_ui_version = $this_version ;
21
-		$ayecode_ui_file_key = wp_hash( __FILE__ );
22
-	}
17
+    global $ayecode_ui_version,$ayecode_ui_file_key;
18
+    $this_version = "0.1.35";
19
+    if(version_compare($this_version , $ayecode_ui_version, '>')){
20
+        $ayecode_ui_version = $this_version ;
21
+        $ayecode_ui_file_key = wp_hash( __FILE__ );
22
+    }
23 23
 },0);
24 24
 
25 25
 /**
26 26
  * Load this version of WP Bootstrap Settings only if the file hash is the current one.
27 27
  */
28 28
 add_action('after_setup_theme', function () {
29
-	global $ayecode_ui_file_key;
30
-	if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
-		include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
-		include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
33
-	}
29
+    global $ayecode_ui_file_key;
30
+    if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
+        include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
+        include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
33
+    }
34 34
 },1);
35 35
 
36 36
 /**
37 37
  * Add the function that calls the class.
38 38
  */
39 39
 if(!function_exists('aui')){
40
-	function aui(){
41
-		if(!class_exists("AUI",false)){
42
-			return false;
43
-		}
44
-		return AUI::instance();
45
-	}
40
+    function aui(){
41
+        if(!class_exists("AUI",false)){
42
+            return false;
43
+        }
44
+        return AUI::instance();
45
+    }
46 46
 }
47 47
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,39 +6,39 @@
 block discarded – undo
6 6
 /**
7 7
  * Bail if we are not in WP.
8 8
  */
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if (!defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Set the version only if its the current newest while loading.
15 15
  */
16
-add_action('after_setup_theme', function () {
17
-	global $ayecode_ui_version,$ayecode_ui_file_key;
16
+add_action('after_setup_theme', function() {
17
+	global $ayecode_ui_version, $ayecode_ui_file_key;
18 18
 	$this_version = "0.1.35";
19
-	if(version_compare($this_version , $ayecode_ui_version, '>')){
20
-		$ayecode_ui_version = $this_version ;
21
-		$ayecode_ui_file_key = wp_hash( __FILE__ );
19
+	if (version_compare($this_version, $ayecode_ui_version, '>')) {
20
+		$ayecode_ui_version = $this_version;
21
+		$ayecode_ui_file_key = wp_hash(__FILE__);
22 22
 	}
23 23
 },0);
24 24
 
25 25
 /**
26 26
  * Load this version of WP Bootstrap Settings only if the file hash is the current one.
27 27
  */
28
-add_action('after_setup_theme', function () {
28
+add_action('after_setup_theme', function() {
29 29
 	global $ayecode_ui_file_key;
30
-	if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
-		include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
-		include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
30
+	if ($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash(__FILE__)) {
31
+		include_once(dirname(__FILE__) . '/includes/class-aui.php');
32
+		include_once(dirname(__FILE__) . '/includes/ayecode-ui-settings.php');
33 33
 	}
34 34
 },1);
35 35
 
36 36
 /**
37 37
  * Add the function that calls the class.
38 38
  */
39
-if(!function_exists('aui')){
40
-	function aui(){
41
-		if(!class_exists("AUI",false)){
39
+if (!function_exists('aui')) {
40
+	function aui() {
41
+		if (!class_exists("AUI", false)) {
42 42
 			return false;
43 43
 		}
44 44
 		return AUI::instance();
Please login to merge, or discard this patch.
vendor/composer/InstalledVersions.php 2 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
 class InstalledVersions
13 13
 {
14 14
 private static $installed = array (
15
-  'root' => 
16
-  array (
15
+    'root' => 
16
+    array (
17 17
     'pretty_version' => 'dev-master',
18 18
     'version' => 'dev-master',
19 19
     'aliases' => 
@@ -21,78 +21,78 @@  discard block
 block discarded – undo
21 21
     ),
22 22
     'reference' => '5bb76a7b209229589b146996e14f6d6ee9eb39d8',
23 23
     'name' => 'ayecode/invoicing',
24
-  ),
25
-  'versions' => 
26
-  array (
24
+    ),
25
+    'versions' => 
26
+    array (
27 27
     'ayecode/ayecode-connect-helper' => 
28 28
     array (
29
-      'pretty_version' => '1.0.3',
30
-      'version' => '1.0.3.0',
31
-      'aliases' => 
32
-      array (
33
-      ),
34
-      'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4',
29
+        'pretty_version' => '1.0.3',
30
+        'version' => '1.0.3.0',
31
+        'aliases' => 
32
+        array (
33
+        ),
34
+        'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4',
35 35
     ),
36 36
     'ayecode/invoicing' => 
37 37
     array (
38
-      'pretty_version' => 'dev-master',
39
-      'version' => 'dev-master',
40
-      'aliases' => 
41
-      array (
42
-      ),
43
-      'reference' => '5bb76a7b209229589b146996e14f6d6ee9eb39d8',
38
+        'pretty_version' => 'dev-master',
39
+        'version' => 'dev-master',
40
+        'aliases' => 
41
+        array (
42
+        ),
43
+        'reference' => '5bb76a7b209229589b146996e14f6d6ee9eb39d8',
44 44
     ),
45 45
     'ayecode/wp-ayecode-ui' => 
46 46
     array (
47
-      'pretty_version' => '0.1.35',
48
-      'version' => '0.1.35.0',
49
-      'aliases' => 
50
-      array (
51
-      ),
52
-      'reference' => 'e5d7955f648c6b350a8fe72e0110b8d78645c60f',
47
+        'pretty_version' => '0.1.35',
48
+        'version' => '0.1.35.0',
49
+        'aliases' => 
50
+        array (
51
+        ),
52
+        'reference' => 'e5d7955f648c6b350a8fe72e0110b8d78645c60f',
53 53
     ),
54 54
     'ayecode/wp-font-awesome-settings' => 
55 55
     array (
56
-      'pretty_version' => '1.0.12',
57
-      'version' => '1.0.12.0',
58
-      'aliases' => 
59
-      array (
60
-      ),
61
-      'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288',
56
+        'pretty_version' => '1.0.12',
57
+        'version' => '1.0.12.0',
58
+        'aliases' => 
59
+        array (
60
+        ),
61
+        'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288',
62 62
     ),
63 63
     'ayecode/wp-super-duper' => 
64 64
     array (
65
-      'pretty_version' => '1.0.22',
66
-      'version' => '1.0.22.0',
67
-      'aliases' => 
68
-      array (
69
-      ),
70
-      'reference' => '42b638502c9e4be0877f27903df7c7ed2080bdac',
65
+        'pretty_version' => '1.0.22',
66
+        'version' => '1.0.22.0',
67
+        'aliases' => 
68
+        array (
69
+        ),
70
+        'reference' => '42b638502c9e4be0877f27903df7c7ed2080bdac',
71 71
     ),
72 72
     'composer/installers' => 
73 73
     array (
74
-      'pretty_version' => 'v1.9.0',
75
-      'version' => '1.9.0.0',
76
-      'aliases' => 
77
-      array (
78
-      ),
79
-      'reference' => 'b93bcf0fa1fccb0b7d176b0967d969691cd74cca',
74
+        'pretty_version' => 'v1.9.0',
75
+        'version' => '1.9.0.0',
76
+        'aliases' => 
77
+        array (
78
+        ),
79
+        'reference' => 'b93bcf0fa1fccb0b7d176b0967d969691cd74cca',
80 80
     ),
81 81
     'roundcube/plugin-installer' => 
82 82
     array (
83
-      'replaced' => 
84
-      array (
83
+        'replaced' => 
84
+        array (
85 85
         0 => '*',
86
-      ),
86
+        ),
87 87
     ),
88 88
     'shama/baton' => 
89 89
     array (
90
-      'replaced' => 
91
-      array (
90
+        'replaced' => 
91
+        array (
92 92
         0 => '*',
93
-      ),
93
+        ),
94
+    ),
94 95
     ),
95
-  ),
96 96
 );
97 97
 
98 98
 
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -11,84 +11,84 @@
 block discarded – undo
11 11
 
12 12
 class InstalledVersions
13 13
 {
14
-private static $installed = array (
14
+private static $installed = array(
15 15
   'root' => 
16
-  array (
16
+  array(
17 17
     'pretty_version' => 'dev-master',
18 18
     'version' => 'dev-master',
19 19
     'aliases' => 
20
-    array (
20
+    array(
21 21
     ),
22 22
     'reference' => '5bb76a7b209229589b146996e14f6d6ee9eb39d8',
23 23
     'name' => 'ayecode/invoicing',
24 24
   ),
25 25
   'versions' => 
26
-  array (
26
+  array(
27 27
     'ayecode/ayecode-connect-helper' => 
28
-    array (
28
+    array(
29 29
       'pretty_version' => '1.0.3',
30 30
       'version' => '1.0.3.0',
31 31
       'aliases' => 
32
-      array (
32
+      array(
33 33
       ),
34 34
       'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4',
35 35
     ),
36 36
     'ayecode/invoicing' => 
37
-    array (
37
+    array(
38 38
       'pretty_version' => 'dev-master',
39 39
       'version' => 'dev-master',
40 40
       'aliases' => 
41
-      array (
41
+      array(
42 42
       ),
43 43
       'reference' => '5bb76a7b209229589b146996e14f6d6ee9eb39d8',
44 44
     ),
45 45
     'ayecode/wp-ayecode-ui' => 
46
-    array (
46
+    array(
47 47
       'pretty_version' => '0.1.35',
48 48
       'version' => '0.1.35.0',
49 49
       'aliases' => 
50
-      array (
50
+      array(
51 51
       ),
52 52
       'reference' => 'e5d7955f648c6b350a8fe72e0110b8d78645c60f',
53 53
     ),
54 54
     'ayecode/wp-font-awesome-settings' => 
55
-    array (
55
+    array(
56 56
       'pretty_version' => '1.0.12',
57 57
       'version' => '1.0.12.0',
58 58
       'aliases' => 
59
-      array (
59
+      array(
60 60
       ),
61 61
       'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288',
62 62
     ),
63 63
     'ayecode/wp-super-duper' => 
64
-    array (
64
+    array(
65 65
       'pretty_version' => '1.0.22',
66 66
       'version' => '1.0.22.0',
67 67
       'aliases' => 
68
-      array (
68
+      array(
69 69
       ),
70 70
       'reference' => '42b638502c9e4be0877f27903df7c7ed2080bdac',
71 71
     ),
72 72
     'composer/installers' => 
73
-    array (
73
+    array(
74 74
       'pretty_version' => 'v1.9.0',
75 75
       'version' => '1.9.0.0',
76 76
       'aliases' => 
77
-      array (
77
+      array(
78 78
       ),
79 79
       'reference' => 'b93bcf0fa1fccb0b7d176b0967d969691cd74cca',
80 80
     ),
81 81
     'roundcube/plugin-installer' => 
82
-    array (
82
+    array(
83 83
       'replaced' => 
84
-      array (
84
+      array(
85 85
         0 => '*',
86 86
       ),
87 87
     ),
88 88
     'shama/baton' => 
89
-    array (
89
+    array(
90 90
       'replaced' => 
91
-      array (
91
+      array(
92 92
         0 => '*',
93 93
       ),
94 94
     ),
Please login to merge, or discard this patch.