Passed
Push — master ( b3b246...bcec86 )
by Brian
05:30
created
templates/invoice-history.php 2 patches
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -40,86 +40,86 @@  discard block
 block discarded – undo
40 40
 				<tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
41 41
 					<?php
42 42
 
43
-						foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) :
43
+                        foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) :
44 44
 
45
-							$column_id = sanitize_html_class( $column_id );
46
-							$class     = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] );
45
+                            $column_id = sanitize_html_class( $column_id );
46
+                            $class     = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] );
47 47
 
48
-							echo "<td class='$column_id $class'>";
49
-							switch ( $column_id ) {
48
+                            echo "<td class='$column_id $class'>";
49
+                            switch ( $column_id ) {
50 50
 
51
-								case 'invoice-number':
52
-									echo wpinv_invoice_link( $invoice );
53
-									break;
51
+                                case 'invoice-number':
52
+                                    echo wpinv_invoice_link( $invoice );
53
+                                    break;
54 54
 
55
-								case 'created-date':
56
-									echo getpaid_format_date_value( $invoice->get_date_created() );
57
-									break;
55
+                                case 'created-date':
56
+                                    echo getpaid_format_date_value( $invoice->get_date_created() );
57
+                                    break;
58 58
 
59
-								case 'payment-date':
59
+                                case 'payment-date':
60 60
 
61
-									if ( $invoice->needs_payment() ) {
62
-										echo "&mdash;";
63
-									} else {
64
-										echo getpaid_format_date_value( $invoice->get_date_completed() );
65
-									}
61
+                                    if ( $invoice->needs_payment() ) {
62
+                                        echo "&mdash;";
63
+                                    } else {
64
+                                        echo getpaid_format_date_value( $invoice->get_date_completed() );
65
+                                    }
66 66
 									
67
-									break;
67
+                                    break;
68 68
 
69
-								case 'invoice-status':
70
-									echo $invoice->get_status_label_html();
69
+                                case 'invoice-status':
70
+                                    echo $invoice->get_status_label_html();
71 71
 									
72
-									break;
72
+                                    break;
73 73
 
74
-								case 'invoice-total':
75
-									echo wpinv_price( wpinv_format_amount( $invoice->get_total() ) );
74
+                                case 'invoice-total':
75
+                                    echo wpinv_price( wpinv_format_amount( $invoice->get_total() ) );
76 76
 									
77
-									break;
77
+                                    break;
78 78
 
79
-								case 'invoice-actions':
79
+                                case 'invoice-actions':
80 80
 
81
-									$actions = array(
81
+                                    $actions = array(
82 82
 
83
-										'pay'       => array(
84
-											'url'   => $invoice->get_checkout_payment_url(),
85
-											'name'  => __( 'Pay Now', 'invoicing' ),
83
+                                        'pay'       => array(
84
+                                            'url'   => $invoice->get_checkout_payment_url(),
85
+                                            'name'  => __( 'Pay Now', 'invoicing' ),
86 86
                                             'class' => 'btn-success'
87
-										),
87
+                                        ),
88 88
 
89 89
                                         'print'     => array(
90
-											'url'   => $invoice->get_view_url(),
91
-											'name'  => __( 'View Invoice', 'invoicing' ),
90
+                                            'url'   => $invoice->get_view_url(),
91
+                                            'name'  => __( 'View Invoice', 'invoicing' ),
92 92
                                             'class' => 'btn-secondary',
93 93
                                             'attrs' => 'target="_blank"'
94
-										)
95
-									);
94
+                                        )
95
+                                    );
96 96
 
97
-									if ( ! $invoice->needs_payment() ) {
98
-										unset( $actions['pay'] );
99
-									}
97
+                                    if ( ! $invoice->needs_payment() ) {
98
+                                        unset( $actions['pay'] );
99
+                                    }
100 100
 
101
-									$actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice );
101
+                                    $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice );
102 102
 
103
-									foreach ( $actions as $key => $action ) {
104
-										$class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
105
-										echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
106
-									}
103
+                                    foreach ( $actions as $key => $action ) {
104
+                                        $class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
105
+                                        echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
106
+                                    }
107 107
 									
108
-									break;
108
+                                    break;
109 109
 
110
-								default:
111
-									do_action( "wpinv_user_invoices_column_$column_id", $invoice );
112
-									break;
110
+                                default:
111
+                                    do_action( "wpinv_user_invoices_column_$column_id", $invoice );
112
+                                    break;
113 113
 
114 114
 								
115
-							}
115
+                            }
116 116
 
117
-							do_action( "wpinv_user_invoices_column_after_$column_id", $invoice );
117
+                            do_action( "wpinv_user_invoices_column_after_$column_id", $invoice );
118 118
 						
119
-							echo '</td>';
119
+                            echo '</td>';
120 120
 
121
-						endforeach;
122
-					?>
121
+                        endforeach;
122
+                    ?>
123 123
 				</tr>
124 124
 
125 125
 			<?php endforeach; ?>
@@ -132,14 +132,14 @@  discard block
 block discarded – undo
132 132
 	<?php if ( 1 < $invoices->max_num_pages ) : ?>
133 133
 		<div class="invoicing-Pagination">
134 134
 			<?php
135
-			$big = 999999;
136
-
137
-			echo paginate_links( array(
138
-				'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
139
-				'format'  => '?paged=%#%',
140
-				'total'   => $invoices->max_num_pages,
141
-			) );
142
-			?>
135
+            $big = 999999;
136
+
137
+            echo paginate_links( array(
138
+                'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
139
+                'format'  => '?paged=%#%',
140
+                'total'   => $invoices->max_num_pages,
141
+            ) );
142
+            ?>
143 143
 		</div>
144 144
 	<?php endif; ?>
145 145
 
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  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
 // Current page.
13
-$current_page   = empty( $_GET[ 'page' ] ) ? 1 : absint( $_GET[ 'page' ] );
13
+$current_page = empty($_GET['page']) ? 1 : absint($_GET['page']);
14 14
 
15 15
 // Fires before displaying user invoices.
16
-do_action( 'wpinv_before_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages );
16
+do_action('wpinv_before_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages);
17 17
 
18 18
 ?>
19 19
 
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
 		<thead>
24 24
 			<tr>
25 25
 
26
-				<?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
27
-					<th class="<?php echo sanitize_html_class( $column_id ); ?> <?php echo ( ! empty( $column_name['class'] ) ? sanitize_html_class( $column_name['class'] ) : '');?> border-bottom-0">
28
-						<span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span>
26
+				<?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?>
27
+					<th class="<?php echo sanitize_html_class($column_id); ?> <?php echo (!empty($column_name['class']) ? sanitize_html_class($column_name['class']) : ''); ?> border-bottom-0">
28
+						<span class="nobr"><?php echo esc_html($column_name['title']); ?></span>
29 29
 					</th>
30 30
 				<?php endforeach; ?>
31 31
 
@@ -35,33 +35,33 @@  discard block
 block discarded – undo
35 35
 
36 36
 		
37 37
 		<tbody>
38
-			<?php foreach ( $invoices->invoices as $invoice ) : ?>
38
+			<?php foreach ($invoices->invoices as $invoice) : ?>
39 39
 
40 40
 				<tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
41 41
 					<?php
42 42
 
43
-						foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) :
43
+						foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) :
44 44
 
45
-							$column_id = sanitize_html_class( $column_id );
46
-							$class     = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] );
45
+							$column_id = sanitize_html_class($column_id);
46
+							$class     = empty($column_name['class']) ? '' : sanitize_html_class($column_name['class']);
47 47
 
48 48
 							echo "<td class='$column_id $class'>";
49
-							switch ( $column_id ) {
49
+							switch ($column_id) {
50 50
 
51 51
 								case 'invoice-number':
52
-									echo wpinv_invoice_link( $invoice );
52
+									echo wpinv_invoice_link($invoice);
53 53
 									break;
54 54
 
55 55
 								case 'created-date':
56
-									echo getpaid_format_date_value( $invoice->get_date_created() );
56
+									echo getpaid_format_date_value($invoice->get_date_created());
57 57
 									break;
58 58
 
59 59
 								case 'payment-date':
60 60
 
61
-									if ( $invoice->needs_payment() ) {
61
+									if ($invoice->needs_payment()) {
62 62
 										echo "&mdash;";
63 63
 									} else {
64
-										echo getpaid_format_date_value( $invoice->get_date_completed() );
64
+										echo getpaid_format_date_value($invoice->get_date_completed());
65 65
 									}
66 66
 									
67 67
 									break;
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 									break;
73 73
 
74 74
 								case 'invoice-total':
75
-									echo wpinv_price( wpinv_format_amount( $invoice->get_total() ) );
75
+									echo wpinv_price(wpinv_format_amount($invoice->get_total()));
76 76
 									
77 77
 									break;
78 78
 
@@ -82,39 +82,39 @@  discard block
 block discarded – undo
82 82
 
83 83
 										'pay'       => array(
84 84
 											'url'   => $invoice->get_checkout_payment_url(),
85
-											'name'  => __( 'Pay Now', 'invoicing' ),
85
+											'name'  => __('Pay Now', 'invoicing'),
86 86
                                             'class' => 'btn-success'
87 87
 										),
88 88
 
89 89
                                         'print'     => array(
90 90
 											'url'   => $invoice->get_view_url(),
91
-											'name'  => __( 'View Invoice', 'invoicing' ),
91
+											'name'  => __('View Invoice', 'invoicing'),
92 92
                                             'class' => 'btn-secondary',
93 93
                                             'attrs' => 'target="_blank"'
94 94
 										)
95 95
 									);
96 96
 
97
-									if ( ! $invoice->needs_payment() ) {
98
-										unset( $actions['pay'] );
97
+									if (!$invoice->needs_payment()) {
98
+										unset($actions['pay']);
99 99
 									}
100 100
 
101
-									$actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice );
101
+									$actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice);
102 102
 
103
-									foreach ( $actions as $key => $action ) {
103
+									foreach ($actions as $key => $action) {
104 104
 										$class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
105
-										echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
105
+										echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>';
106 106
 									}
107 107
 									
108 108
 									break;
109 109
 
110 110
 								default:
111
-									do_action( "wpinv_user_invoices_column_$column_id", $invoice );
111
+									do_action("wpinv_user_invoices_column_$column_id", $invoice);
112 112
 									break;
113 113
 
114 114
 								
115 115
 							}
116 116
 
117
-							do_action( "wpinv_user_invoices_column_after_$column_id", $invoice );
117
+							do_action("wpinv_user_invoices_column_after_$column_id", $invoice);
118 118
 						
119 119
 							echo '</td>';
120 120
 
@@ -127,20 +127,20 @@  discard block
 block discarded – undo
127 127
 		</tbody>
128 128
 	</table>
129 129
 
130
-	<?php do_action( 'wpinv_before_user_invoices_pagination' ); ?>
130
+	<?php do_action('wpinv_before_user_invoices_pagination'); ?>
131 131
 
132
-	<?php if ( 1 < $invoices->max_num_pages ) : ?>
132
+	<?php if (1 < $invoices->max_num_pages) : ?>
133 133
 		<div class="invoicing-Pagination">
134 134
 			<?php
135 135
 			$big = 999999;
136 136
 
137
-			echo paginate_links( array(
138
-				'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
137
+			echo paginate_links(array(
138
+				'base'    => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
139 139
 				'format'  => '?paged=%#%',
140 140
 				'total'   => $invoices->max_num_pages,
141
-			) );
141
+			));
142 142
 			?>
143 143
 		</div>
144 144
 	<?php endif; ?>
145 145
 
146
-<?php do_action( 'wpinv_after_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages  ); ?>
146
+<?php do_action('wpinv_after_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages); ?>
Please login to merge, or discard this patch.
templates/invoice-receipt.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -7,54 +7,54 @@  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
 // Fetch the invoice.
13
-$invoice = new WPInv_Invoice( $invoice );
13
+$invoice = new WPInv_Invoice($invoice);
14 14
 
15 15
 // @deprecated
16
-do_action( 'wpinv_success_content_before', $invoice );
17
-do_action( 'wpinv_before_receipt', $invoice );
16
+do_action('wpinv_success_content_before', $invoice);
17
+do_action('wpinv_before_receipt', $invoice);
18 18
 
19 19
 
20 20
 // Prepare header text.
21
-if ( $invoice->is_paid() ) {
21
+if ($invoice->is_paid()) {
22 22
 
23 23
     $alert = aui()->alert(
24 24
         array(
25 25
             'type'    => 'success',
26
-            'content' => __( 'Thank you for your payment!', 'invoicing' ),
26
+            'content' => __('Thank you for your payment!', 'invoicing'),
27 27
         )
28 28
     );
29 29
 
30
-} else if ( $invoice->is_refunded() ) {
30
+} else if ($invoice->is_refunded()) {
31 31
 
32 32
     $alert = aui()->alert(
33 33
         array(
34 34
             'type'    => 'info',
35
-            'content' => __( 'This invoice was refunded.', 'invoicing' ),
35
+            'content' => __('This invoice was refunded.', 'invoicing'),
36 36
         )
37 37
     );
38 38
 
39
-} else if ( $invoice->is_held() ) {
39
+} else if ($invoice->is_held()) {
40 40
 
41 41
     $alert = aui()->alert(
42 42
         array(
43 43
             'type'    => 'info',
44
-            'content' => __( 'This invoice will be processed as soon we verify your payment.', 'invoicing' ),
44
+            'content' => __('This invoice will be processed as soon we verify your payment.', 'invoicing'),
45 45
         )
46 46
     );
47 47
 
48
-} else if ( $invoice->needs_payment() ) {
48
+} else if ($invoice->needs_payment()) {
49 49
 
50
-    if ( $invoice->is_due() ) {
50
+    if ($invoice->is_due()) {
51 51
 
52 52
         $alert = aui()->alert(
53 53
             array(
54 54
                 'type'    => 'danger',
55 55
                 'content' => sprintf(
56
-                    __( 'This invoice was due on %.', 'invoicing' ),
57
-                    getpaid_format_date_value( $invoice->get_due_date() )
56
+                    __('This invoice was due on %.', 'invoicing'),
57
+                    getpaid_format_date_value($invoice->get_due_date())
58 58
                 ),
59 59
             )
60 60
         );
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         $alert = aui()->alert(
65 65
             array(
66 66
                 'type'    => 'warning',
67
-                'content' => __( 'This invoice needs payment.', 'invoicing' ),
67
+                'content' => __('This invoice needs payment.', 'invoicing'),
68 68
             )
69 69
         );
70 70
 
@@ -79,19 +79,19 @@  discard block
 block discarded – undo
79 79
 
80 80
         'pay' => array(
81 81
             'url'   => $invoice->get_checkout_payment_url(),
82
-            'name'  => __( 'Pay For Invoice', 'invoicing' ),
82
+            'name'  => __('Pay For Invoice', 'invoicing'),
83 83
             'class' => 'btn-success',
84 84
         ),
85 85
 
86 86
         'view' => array(
87 87
             'url'   => $invoice->get_view_url(),
88
-            'name'  => __( 'View Invoice', 'invoicing' ),
88
+            'name'  => __('View Invoice', 'invoicing'),
89 89
             'class' => 'btn-primary',
90 90
         ),
91 91
 
92 92
         'history' => array(
93 93
             'url'   => wpinv_get_history_page_uri(),
94
-            'name'  => __( 'Invoice History', 'invoicing' ),
94
+            'name'  => __('Invoice History', 'invoicing'),
95 95
             'class' => 'btn-warning',
96 96
         ),
97 97
 
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
 
101 101
 );
102 102
 
103
-if ( ( ! $invoice->needs_payment() || $invoice->is_held() ) && isset( $actions['pay'] ) ) {
104
-    unset( $actions['pay'] );
103
+if ((!$invoice->needs_payment() || $invoice->is_held()) && isset($actions['pay'])) {
104
+    unset($actions['pay']);
105 105
 }
106 106
 
107
-if ( ! is_user_logged_in() && isset( $actions['history'] ) ) {
108
-    unset( $actions['history'] );
107
+if (!is_user_logged_in() && isset($actions['history'])) {
108
+    unset($actions['history']);
109 109
 }
110 110
 
111 111
 ?>
@@ -114,19 +114,19 @@  discard block
 block discarded – undo
114 114
 
115 115
         <?php
116 116
         
117
-            do_action( 'wpinv_receipt_start', $invoice );
117
+            do_action('wpinv_receipt_start', $invoice);
118 118
 
119
-            if ( ! empty( $actions ) ) {
119
+            if (!empty($actions)) {
120 120
 
121 121
                 echo '<div class="wpinv-receipt-actions text-right mt-1 mb-4">';
122 122
 
123
-                foreach ( $actions as $key => $action ) {
123
+                foreach ($actions as $key => $action) {
124 124
 
125
-                    $key    = sanitize_html_class( $key );
126
-                    $class  = empty( $action['class'] ) ? 'btn-dark' : sanitize_html_class( $action['class'] );
127
-                    $url    = empty( $action['url'] ) ? '#' : esc_url( $action['url'] );
128
-                    $attrs  = empty( $action['attrs'] ) ? '' : $action['attrs'];
129
-                    $anchor = sanitize_text_field( $action['name'] );
125
+                    $key    = sanitize_html_class($key);
126
+                    $class  = empty($action['class']) ? 'btn-dark' : sanitize_html_class($action['class']);
127
+                    $url    = empty($action['url']) ? '#' : esc_url($action['url']);
128
+                    $attrs  = empty($action['attrs']) ? '' : $action['attrs'];
129
+                    $anchor = sanitize_text_field($action['name']);
130 130
 
131 131
                     echo "<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>";
132 132
                 }
@@ -142,20 +142,20 @@  discard block
 block discarded – undo
142 142
         <div class="wpinv-receipt-details">
143 143
 
144 144
             <h4 class="wpinv-details-t mb-3 mt-3">
145
-                <?php echo apply_filters( 'wpinv_receipt_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ); ?>
145
+                <?php echo apply_filters('wpinv_receipt_details_title', __('Invoice Details', 'invoicing'), $invoice); ?>
146 146
             </h4>
147 147
 
148
-            <?php getpaid_invoice_meta( $invoice ); ?>
148
+            <?php getpaid_invoice_meta($invoice); ?>
149 149
 
150 150
         </div>
151 151
 
152 152
 
153
-        <?php do_action( 'wpinv_receipt_end', $invoice ); ?>
153
+        <?php do_action('wpinv_receipt_end', $invoice); ?>
154 154
 
155 155
     </div>
156 156
 
157 157
 <?php
158 158
 
159 159
 // @deprecated
160
-do_action( 'wpinv_success_content_after', $invoice );
161
-do_action( 'wpinv_after_receipt', $invoice );
160
+do_action('wpinv_success_content_after', $invoice);
161
+do_action('wpinv_after_receipt', $invoice);
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-input.php 3 patches
Indentation   +986 added lines, -986 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,996 +11,996 @@  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
-			'id'         => '',
27
-			'placeholder'=> '',
28
-			'title'      => '',
29
-			'value'      => '',
30
-			'required'   => false,
31
-			'label'      => '',
32
-			'label_after'=> false,
33
-			'label_class'=> '',
34
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
35
-			'help_text'  => '',
36
-			'validation_text'   => '',
37
-			'validation_pattern' => '',
38
-			'no_wrap'    => false,
39
-			'input_group_right' => '',
40
-			'input_group_left' => '',
41
-			'input_group_right_inside' => false, // forces the input group inside the input
42
-			'input_group_left_inside' => false, // forces the input group inside the input
43
-			'step'       => '',
44
-			'switch'     => false, // to show checkbox as a switch
45
-			'checked'   => false, // set a checkbox or radio as selected
46
-			'password_toggle' => true, // toggle view/hide password
47
-			'element_require'   => '', // [%element_id%] == "1"
48
-			'extra_attributes'  => array() // an array of extra attributes
49
-		);
50
-
51
-		/**
52
-		 * Parse incoming $args into an array and merge it with $defaults
53
-		 */
54
-		$args   = wp_parse_args( $args, $defaults );
55
-		$output = '';
56
-		if ( ! empty( $args['type'] ) ) {
57
-			// hidden label option needs to be empty
58
-			$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
59
-
60
-			$type = sanitize_html_class( $args['type'] );
61
-
62
-			$help_text = '';
63
-			$label = '';
64
-			$label_after = $args['label_after'];
65
-			$label_args = array(
66
-				'title'=> $args['label'],
67
-				'for'=> $args['id'],
68
-				'class' => $args['label_class']." ",
69
-				'label_type' => $args['label_type']
70
-			);
71
-
72
-			// floating labels need label after
73
-			if( $args['label_type'] == 'floating' && $type != 'checkbox' ){
74
-				$label_after = true;
75
-				$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
76
-			}
77
-
78
-			// Some special sauce for files
79
-			if($type=='file' ){
80
-				$label_after = true; // if type file we need the label after
81
-				$args['class'] .= ' custom-file-input ';
82
-			}elseif($type=='checkbox'){
83
-				$label_after = true; // if type file we need the label after
84
-				$args['class'] .= ' custom-control-input ';
85
-			}elseif($type=='datepicker' || $type=='timepicker'){
86
-				$type = 'text';
87
-				//$args['class'] .= ' aui-flatpickr bg-initial ';
88
-				$args['class'] .= ' bg-initial ';
89
-
90
-				$args['extra_attributes']['data-aui-init'] = 'flatpickr';
91
-				// enqueue the script
92
-				$aui_settings = AyeCode_UI_Settings::instance();
93
-				$aui_settings->enqueue_flatpickr();
94
-			}
95
-
96
-
97
-			// open/type
98
-			$output .= '<input type="' . $type . '" ';
99
-
100
-			// name
101
-			if(!empty($args['name'])){
102
-				$output .= ' name="'.esc_attr($args['name']).'" ';
103
-			}
104
-
105
-			// id
106
-			if(!empty($args['id'])){
107
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
108
-			}
109
-
110
-			// placeholder
111
-			if(!empty($args['placeholder'])){
112
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
113
-			}
114
-
115
-			// title
116
-			if(!empty($args['title'])){
117
-				$output .= ' title="'.esc_attr($args['title']).'" ';
118
-			}
119
-
120
-			// value
121
-			if(!empty($args['value'])){
122
-				$output .= ' value="'.sanitize_text_field($args['value']).'" ';
123
-			}
124
-
125
-			// checked, for radio and checkboxes
126
-			if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){
127
-				$output .= ' checked ';
128
-			}
129
-
130
-			// validation text
131
-			if(!empty($args['validation_text'])){
132
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
133
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
134
-			}
135
-
136
-			// validation_pattern
137
-			if(!empty($args['validation_pattern'])){
138
-				$output .= ' pattern="'.$args['validation_pattern'].'" ';
139
-			}
140
-
141
-			// step (for numbers)
142
-			if(!empty($args['step'])){
143
-				$output .= ' step="'.$args['step'].'" ';
144
-			}
145
-
146
-			// required
147
-			if(!empty($args['required'])){
148
-				$output .= ' required ';
149
-			}
150
-
151
-			// class
152
-			$class = !empty($args['class']) ? $args['class'] : '';
153
-			$output .= ' class="form-control '.$class.'" ';
154
-
155
-			// data-attributes
156
-			$output .= AUI_Component_Helper::data_attributes($args);
157
-
158
-			// extra attributes
159
-			if(!empty($args['extra_attributes'])){
160
-				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
161
-			}
162
-
163
-			// close
164
-			$output .= ' >';
165
-
166
-
167
-			// label
168
-			if(!empty($args['label'])){
169
-				if($type == 'file'){$label_args['class'] .= 'custom-file-label';}
170
-				elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
171
-				$label = self::label( $label_args, $type );
172
-			}
173
-
174
-			// help text
175
-			if(!empty($args['help_text'])){
176
-				$help_text = AUI_Component_Helper::help_text($args['help_text']);
177
-			}
178
-
179
-
180
-			// set help text in the correct possition
181
-			if($label_after){
182
-				$output .= $label . $help_text;
183
-			}
184
-
185
-			// some input types need a separate wrap
186
-			if($type == 'file') {
187
-				$output = self::wrap( array(
188
-					'content' => $output,
189
-					'class'   => 'form-group custom-file'
190
-				) );
191
-			}elseif($type == 'checkbox'){
192
-				$wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
193
-				$output = self::wrap( array(
194
-					'content' => $output,
195
-					'class'   => 'custom-control '.$wrap_class
196
-				) );
197
-
198
-				if($args['label_type']=='horizontal'){
199
-					$output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
200
-				}
201
-			}elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
202
-
203
-
204
-				// allow password field to toggle view
205
-				$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
+            'id'         => '',
27
+            'placeholder'=> '',
28
+            'title'      => '',
29
+            'value'      => '',
30
+            'required'   => false,
31
+            'label'      => '',
32
+            'label_after'=> false,
33
+            'label_class'=> '',
34
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
35
+            'help_text'  => '',
36
+            'validation_text'   => '',
37
+            'validation_pattern' => '',
38
+            'no_wrap'    => false,
39
+            'input_group_right' => '',
40
+            'input_group_left' => '',
41
+            'input_group_right_inside' => false, // forces the input group inside the input
42
+            'input_group_left_inside' => false, // forces the input group inside the input
43
+            'step'       => '',
44
+            'switch'     => false, // to show checkbox as a switch
45
+            'checked'   => false, // set a checkbox or radio as selected
46
+            'password_toggle' => true, // toggle view/hide password
47
+            'element_require'   => '', // [%element_id%] == "1"
48
+            'extra_attributes'  => array() // an array of extra attributes
49
+        );
50
+
51
+        /**
52
+         * Parse incoming $args into an array and merge it with $defaults
53
+         */
54
+        $args   = wp_parse_args( $args, $defaults );
55
+        $output = '';
56
+        if ( ! empty( $args['type'] ) ) {
57
+            // hidden label option needs to be empty
58
+            $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
59
+
60
+            $type = sanitize_html_class( $args['type'] );
61
+
62
+            $help_text = '';
63
+            $label = '';
64
+            $label_after = $args['label_after'];
65
+            $label_args = array(
66
+                'title'=> $args['label'],
67
+                'for'=> $args['id'],
68
+                'class' => $args['label_class']." ",
69
+                'label_type' => $args['label_type']
70
+            );
71
+
72
+            // floating labels need label after
73
+            if( $args['label_type'] == 'floating' && $type != 'checkbox' ){
74
+                $label_after = true;
75
+                $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
76
+            }
77
+
78
+            // Some special sauce for files
79
+            if($type=='file' ){
80
+                $label_after = true; // if type file we need the label after
81
+                $args['class'] .= ' custom-file-input ';
82
+            }elseif($type=='checkbox'){
83
+                $label_after = true; // if type file we need the label after
84
+                $args['class'] .= ' custom-control-input ';
85
+            }elseif($type=='datepicker' || $type=='timepicker'){
86
+                $type = 'text';
87
+                //$args['class'] .= ' aui-flatpickr bg-initial ';
88
+                $args['class'] .= ' bg-initial ';
89
+
90
+                $args['extra_attributes']['data-aui-init'] = 'flatpickr';
91
+                // enqueue the script
92
+                $aui_settings = AyeCode_UI_Settings::instance();
93
+                $aui_settings->enqueue_flatpickr();
94
+            }
95
+
96
+
97
+            // open/type
98
+            $output .= '<input type="' . $type . '" ';
99
+
100
+            // name
101
+            if(!empty($args['name'])){
102
+                $output .= ' name="'.esc_attr($args['name']).'" ';
103
+            }
104
+
105
+            // id
106
+            if(!empty($args['id'])){
107
+                $output .= ' id="'.sanitize_html_class($args['id']).'" ';
108
+            }
109
+
110
+            // placeholder
111
+            if(!empty($args['placeholder'])){
112
+                $output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
113
+            }
114
+
115
+            // title
116
+            if(!empty($args['title'])){
117
+                $output .= ' title="'.esc_attr($args['title']).'" ';
118
+            }
119
+
120
+            // value
121
+            if(!empty($args['value'])){
122
+                $output .= ' value="'.sanitize_text_field($args['value']).'" ';
123
+            }
124
+
125
+            // checked, for radio and checkboxes
126
+            if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){
127
+                $output .= ' checked ';
128
+            }
129
+
130
+            // validation text
131
+            if(!empty($args['validation_text'])){
132
+                $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
133
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
134
+            }
135
+
136
+            // validation_pattern
137
+            if(!empty($args['validation_pattern'])){
138
+                $output .= ' pattern="'.$args['validation_pattern'].'" ';
139
+            }
140
+
141
+            // step (for numbers)
142
+            if(!empty($args['step'])){
143
+                $output .= ' step="'.$args['step'].'" ';
144
+            }
145
+
146
+            // required
147
+            if(!empty($args['required'])){
148
+                $output .= ' required ';
149
+            }
150
+
151
+            // class
152
+            $class = !empty($args['class']) ? $args['class'] : '';
153
+            $output .= ' class="form-control '.$class.'" ';
154
+
155
+            // data-attributes
156
+            $output .= AUI_Component_Helper::data_attributes($args);
157
+
158
+            // extra attributes
159
+            if(!empty($args['extra_attributes'])){
160
+                $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
161
+            }
162
+
163
+            // close
164
+            $output .= ' >';
165
+
166
+
167
+            // label
168
+            if(!empty($args['label'])){
169
+                if($type == 'file'){$label_args['class'] .= 'custom-file-label';}
170
+                elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
171
+                $label = self::label( $label_args, $type );
172
+            }
173
+
174
+            // help text
175
+            if(!empty($args['help_text'])){
176
+                $help_text = AUI_Component_Helper::help_text($args['help_text']);
177
+            }
178
+
179
+
180
+            // set help text in the correct possition
181
+            if($label_after){
182
+                $output .= $label . $help_text;
183
+            }
184
+
185
+            // some input types need a separate wrap
186
+            if($type == 'file') {
187
+                $output = self::wrap( array(
188
+                    'content' => $output,
189
+                    'class'   => 'form-group custom-file'
190
+                ) );
191
+            }elseif($type == 'checkbox'){
192
+                $wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
193
+                $output = self::wrap( array(
194
+                    'content' => $output,
195
+                    'class'   => 'custom-control '.$wrap_class
196
+                ) );
197
+
198
+                if($args['label_type']=='horizontal'){
199
+                    $output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
200
+                }
201
+            }elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
202
+
203
+
204
+                // allow password field to toggle view
205
+                $args['input_group_right'] = '<span class="input-group-text c-pointer px-3" 
206 206
 onclick="var $el = jQuery(this).find(\'i\');$el.toggleClass(\'fa-eye fa-eye-slash\');
207 207
 var $eli = jQuery(this).parent().parent().find(\'input\');
208 208
 if($el.hasClass(\'fa-eye\'))
209 209
 {$eli.attr(\'type\',\'text\');}
210 210
 else{$eli.attr(\'type\',\'password\');}"
211 211
 ><i class="far fa-fw fa-eye-slash"></i></span>';
212
-			}
213
-
214
-			// input group wraps
215
-			if($args['input_group_left'] || $args['input_group_right']){
216
-				$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
217
-				if($args['input_group_left']){
218
-					$output = self::wrap( array(
219
-						'content' => $output,
220
-						'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100  : 'input-group',
221
-						'input_group_left' => $args['input_group_left'],
222
-						'input_group_left_inside'    => $args['input_group_left_inside']
223
-					) );
224
-				}
225
-				if($args['input_group_right']){
226
-					$output = self::wrap( array(
227
-						'content' => $output,
228
-						'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group',
229
-						'input_group_right' => $args['input_group_right'],
230
-						'input_group_right_inside'    => $args['input_group_right_inside']
231
-					) );
232
-				}
233
-
234
-			}
235
-
236
-			if(!$label_after){
237
-				$output .= $help_text;
238
-			}
239
-
240
-
241
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
242
-				$output = self::wrap( array(
243
-					'content' => $output,
244
-					'class'   => 'col-sm-10',
245
-				) );
246
-			}
247
-
248
-			if(!$label_after){
249
-				$output = $label . $output;
250
-			}
251
-
252
-			// wrap
253
-			if(!$args['no_wrap']){
254
-
255
-				$form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
256
-				$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
257
-				$output = self::wrap(array(
258
-					'content' => $output,
259
-					'class'   => $wrap_class,
260
-					'element_require'   => $args['element_require'],
261
-					'argument_id'  => $args['id']
262
-				));
263
-			}
264
-
265
-
266
-
267
-		}
268
-
269
-		return $output;
270
-	}
271
-
272
-	/**
273
-	 * Build the component.
274
-	 *
275
-	 * @param array $args
276
-	 *
277
-	 * @return string The rendered component.
278
-	 */
279
-	public static function textarea($args = array()){
280
-		$defaults = array(
281
-			'name'       => '',
282
-			'class'      => '',
283
-			'id'         => '',
284
-			'placeholder'=> '',
285
-			'title'      => '',
286
-			'value'      => '',
287
-			'required'   => false,
288
-			'label'      => '',
289
-			'label_after'=> false,
290
-			'label_class'      => '',
291
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
292
-			'help_text'  => '',
293
-			'validation_text'   => '',
294
-			'validation_pattern' => '',
295
-			'no_wrap'    => false,
296
-			'rows'      => '',
297
-			'wysiwyg'   => false,
298
-			'element_require'   => '', // [%element_id%] == "1"
299
-		);
300
-
301
-		/**
302
-		 * Parse incoming $args into an array and merge it with $defaults
303
-		 */
304
-		$args   = wp_parse_args( $args, $defaults );
305
-		$output = '';
306
-
307
-		// hidden label option needs to be empty
308
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
309
-
310
-		// floating labels don't work with wysiwyg so set it as top
311
-		if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){
312
-			$args['label_type'] = 'top';
313
-		}
314
-
315
-		$label_after = $args['label_after'];
316
-
317
-		// floating labels need label after
318
-		if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){
319
-			$label_after = true;
320
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
321
-		}
322
-
323
-		// label
324
-		if(!empty($args['label']) && is_array($args['label'])){
325
-		}elseif(!empty($args['label']) && !$label_after){
326
-			$label_args = array(
327
-				'title'=> $args['label'],
328
-				'for'=> $args['id'],
329
-				'class' => $args['label_class']." ",
330
-				'label_type' => $args['label_type']
331
-			);
332
-			$output .= self::label( $label_args );
333
-		}
334
-
335
-		// maybe horizontal label
336
-		if($args['label_type']=='horizontal'){
337
-			$output .= '<div class="col-sm-10">';
338
-		}
339
-
340
-		if(!empty($args['wysiwyg'])){
341
-			ob_start();
342
-			$content = $args['value'];
343
-			$editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
344
-			$settings = array(
345
-				'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4,
346
-				'quicktags'     => false,
347
-				'media_buttons' => false,
348
-				'editor_class'  => 'form-control',
349
-				'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']),
350
-				'teeny'         => true,
351
-			);
352
-
353
-			// maybe set settings if array
354
-			if(is_array($args['wysiwyg'])){
355
-				$settings  = wp_parse_args( $args['wysiwyg'], $settings );
356
-			}
357
-
358
-			wp_editor( $content, $editor_id, $settings );
359
-			$output .= ob_get_clean();
360
-		}else{
361
-
362
-			// open
363
-			$output .= '<textarea ';
364
-
365
-			// name
366
-			if(!empty($args['name'])){
367
-				$output .= ' name="'.sanitize_html_class($args['name']).'" ';
368
-			}
369
-
370
-			// id
371
-			if(!empty($args['id'])){
372
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
373
-			}
374
-
375
-			// placeholder
376
-			if(!empty($args['placeholder'])){
377
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
378
-			}
379
-
380
-			// title
381
-			if(!empty($args['title'])){
382
-				$output .= ' title="'.esc_attr($args['title']).'" ';
383
-			}
384
-
385
-			// validation text
386
-			if(!empty($args['validation_text'])){
387
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
388
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
389
-			}
390
-
391
-			// validation_pattern
392
-			if(!empty($args['validation_pattern'])){
393
-				$output .= ' pattern="'.$args['validation_pattern'].'" ';
394
-			}
395
-
396
-			// required
397
-			if(!empty($args['required'])){
398
-				$output .= ' required ';
399
-			}
400
-
401
-			// rows
402
-			if(!empty($args['rows'])){
403
-				$output .= ' rows="'.absint($args['rows']).'" ';
404
-			}
405
-
406
-
407
-			// class
408
-			$class = !empty($args['class']) ? $args['class'] : '';
409
-			$output .= ' class="form-control '.$class.'" ';
410
-
411
-
412
-			// close tag
413
-			$output .= ' >';
414
-
415
-			// value
416
-			if(!empty($args['value'])){
417
-				$output .= sanitize_textarea_field($args['value']);
418
-			}
419
-
420
-			// closing tag
421
-			$output .= '</textarea>';
422
-
423
-		}
424
-
425
-		if(!empty($args['label']) && $label_after){
426
-			$label_args = array(
427
-				'title'=> $args['label'],
428
-				'for'=> $args['id'],
429
-				'class' => $args['label_class']." ",
430
-				'label_type' => $args['label_type']
431
-			);
432
-			$output .= self::label( $label_args );
433
-		}
434
-
435
-		// help text
436
-		if(!empty($args['help_text'])){
437
-			$output .= AUI_Component_Helper::help_text($args['help_text']);
438
-		}
439
-
440
-		// maybe horizontal label
441
-		if($args['label_type']=='horizontal'){
442
-			$output .= '</div>';
443
-		}
444
-
445
-
446
-		// wrap
447
-		if(!$args['no_wrap']){
448
-			$form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group';
449
-			$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
450
-			$output = self::wrap(array(
451
-				'content' => $output,
452
-				'class'   => $wrap_class,
453
-				'element_require'   => $args['element_require'],
454
-				'argument_id'  => $args['id']
455
-			));
456
-		}
457
-
458
-
459
-		return $output;
460
-	}
461
-
462
-	public static function label($args = array(), $type = ''){
463
-		//<label for="exampleInputEmail1">Email address</label>
464
-		$defaults = array(
465
-			'title'       => 'div',
466
-			'for'      => '',
467
-			'class'      => '',
468
-			'label_type'    => '', // empty = hidden, top, horizontal
469
-		);
470
-
471
-		/**
472
-		 * Parse incoming $args into an array and merge it with $defaults
473
-		 */
474
-		$args   = wp_parse_args( $args, $defaults );
475
-		$output = '';
476
-
477
-		if($args['title']){
478
-
479
-			// maybe hide labels //@todo set a global option for visibility class
480
-			if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
481
-				$class = $args['class'];
482
-			}else{
483
-				$class = 'sr-only '.$args['class'];
484
-			}
485
-
486
-			// maybe horizontal
487
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
488
-				$class .= ' col-sm-2 col-form-label';
489
-			}
490
-
491
-			// open
492
-			$output .= '<label ';
493
-
494
-			// for
495
-			if(!empty($args['for'])){
496
-				$output .= ' for="'.sanitize_text_field($args['for']).'" ';
497
-			}
498
-
499
-			// class
500
-			$output .= ' class="'.$class.'" ';
501
-
502
-			// close
503
-			$output .= '>';
504
-
505
-
506
-			// title, don't escape fully as can contain html
507
-			if(!empty($args['title'])){
508
-				$output .= wp_kses_post($args['title']);
509
-			}
510
-
511
-			// close wrap
512
-			$output .= '</label>';
513
-
514
-
515
-		}
516
-
517
-
518
-		return $output;
519
-	}
520
-
521
-	public static function wrap($args = array()){
522
-		$defaults = array(
523
-			'type'       => 'div',
524
-			'class'      => 'form-group',
525
-			'content'   => '',
526
-			'input_group_left' => '',
527
-			'input_group_right' => '',
528
-			'input_group_left_inside' => false,
529
-			'input_group_right_inside' => false,
530
-			'element_require'   => '',
531
-			'argument_id'   => '',
532
-		);
533
-
534
-		/**
535
-		 * Parse incoming $args into an array and merge it with $defaults
536
-		 */
537
-		$args   = wp_parse_args( $args, $defaults );
538
-		$output = '';
539
-		if($args['type']){
540
-
541
-			// open
542
-			$output .= '<'.sanitize_html_class($args['type']);
543
-
544
-			// element require
545
-			if(!empty($args['element_require'])){
546
-				$output .= AUI_Component_Helper::element_require($args['element_require']);
547
-				$args['class'] .= " aui-conditional-field";
548
-			}
549
-
550
-			// argument_id
551
-			if( !empty($args['argument_id']) ){
552
-				$output .= ' data-argument="'.esc_attr($args['argument_id']).'"';
553
-			}
554
-
555
-			// class
556
-			$class = !empty($args['class']) ? $args['class'] : '';
557
-			$output .= ' class="'.$class.'" ';
558
-
559
-			// close wrap
560
-			$output .= ' >';
561
-
562
-
563
-			// Input group left
564
-			if(!empty($args['input_group_left'])){
565
-				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
566
-				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>';
567
-				$output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>';
568
-			}
569
-
570
-			// content
571
-			$output .= $args['content'];
572
-
573
-			// Input group right
574
-			if(!empty($args['input_group_right'])){
575
-				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
576
-				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>';
577
-				$output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>';
578
-			}
579
-
580
-
581
-			// close wrap
582
-			$output .= '</'.sanitize_html_class($args['type']).'>';
583
-
584
-
585
-		}else{
586
-			$output = $args['content'];
587
-		}
588
-
589
-		return $output;
590
-	}
591
-
592
-	/**
593
-	 * Build the component.
594
-	 *
595
-	 * @param array $args
596
-	 *
597
-	 * @return string The rendered component.
598
-	 */
599
-	public static function select($args = array()){
600
-		$defaults = array(
601
-			'class'      => '',
602
-			'id'         => '',
603
-			'title'      => '',
604
-			'value'      => '', // can be an array or a string
605
-			'required'   => false,
606
-			'label'      => '',
607
-			'label_after'=> false,
608
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
609
-			'label_class'      => '',
610
-			'help_text'  => '',
611
-			'placeholder'=> '',
612
-			'options'    => array(), // array or string
613
-			'icon'       => '',
614
-			'multiple'   => false,
615
-			'select2'    => false,
616
-			'no_wrap'    => false,
617
-			'element_require'   => '', // [%element_id%] == "1"
618
-			'extra_attributes'  => array(), // an array of extra attributes
619
-		);
620
-
621
-		/**
622
-		 * Parse incoming $args into an array and merge it with $defaults
623
-		 */
624
-		$args   = wp_parse_args( $args, $defaults );
625
-		$output = '';
626
-
627
-		// for now lets hide floating labels
628
-		if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';}
629
-
630
-		// hidden label option needs to be empty
631
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
632
-
633
-
634
-		$label_after = $args['label_after'];
635
-
636
-		// floating labels need label after
637
-		if( $args['label_type'] == 'floating' ){
638
-			$label_after = true;
639
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
640
-		}
641
-
642
-		// Maybe setup select2
643
-		$is_select2 = false;
644
-		if(!empty($args['select2'])){
645
-			$args['class'] .= ' aui-select2';
646
-			$is_select2 = true;
647
-		}elseif( strpos($args['class'], 'aui-select2') !== false){
648
-			$is_select2 = true;
649
-		}
650
-
651
-		// select2 tags
652
-		if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason
653
-			$args['data-tags'] = 'true';
654
-			$args['data-token-separators'] = "[',']";
655
-			$args['multiple'] = true;
656
-		}
657
-
658
-		// select2 placeholder
659
-		if($is_select2 && !empty($args['placeholder']) && empty($args['data-placeholder'])){
660
-			$args['data-placeholder'] = esc_attr($args['placeholder']);
661
-			$args['data-allow-clear'] = empty($args['data-allow-clear']) ? true : esc_attr($args['data-allow-clear']);
662
-		}
663
-
664
-		// label
665
-		if(!empty($args['label']) && is_array($args['label'])){
666
-		}elseif(!empty($args['label']) && !$label_after){
667
-			$label_args = array(
668
-				'title'=> $args['label'],
669
-				'for'=> $args['id'],
670
-				'class' => $args['label_class']." ",
671
-				'label_type' => $args['label_type']
672
-			);
673
-			$output .= self::label($label_args);
674
-		}
675
-
676
-		// maybe horizontal label
677
-		if($args['label_type']=='horizontal'){
678
-			$output .= '<div class="col-sm-10">';
679
-		}
680
-
681
-		// open/type
682
-		$output .= '<select ';
683
-
684
-		// style
685
-		if($is_select2){
686
-			$output .= " style='width:100%;' ";
687
-		}
688
-
689
-		// element require
690
-		if(!empty($args['element_require'])){
691
-			$output .= AUI_Component_Helper::element_require($args['element_require']);
692
-			$args['class'] .= " aui-conditional-field";
693
-		}
694
-
695
-		// class
696
-		$class = !empty($args['class']) ? $args['class'] : '';
697
-		$output .= AUI_Component_Helper::class_attr('custom-select '.$class);
698
-
699
-		// name
700
-		if(!empty($args['name'])){
701
-			$output .= AUI_Component_Helper::name($args['name'],$args['multiple']);
702
-		}
703
-
704
-		// id
705
-		if(!empty($args['id'])){
706
-			$output .= AUI_Component_Helper::id($args['id']);
707
-		}
708
-
709
-		// title
710
-		if(!empty($args['title'])){
711
-			$output .= AUI_Component_Helper::title($args['title']);
712
-		}
713
-
714
-		// data-attributes
715
-		$output .= AUI_Component_Helper::data_attributes($args);
716
-
717
-		// aria-attributes
718
-		$output .= AUI_Component_Helper::aria_attributes($args);
719
-
720
-		// extra attributes
721
-		if(!empty($args['extra_attributes'])){
722
-			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
723
-		}
724
-
725
-		// required
726
-		if(!empty($args['required'])){
727
-			$output .= ' required ';
728
-		}
729
-
730
-		// multiple
731
-		if(!empty($args['multiple'])){
732
-			$output .= ' multiple ';
733
-		}
734
-
735
-		// close opening tag
736
-		$output .= ' >';
737
-
738
-		// placeholder
739
-		if(!empty($args['placeholder']) && !$is_select2){
740
-			$output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
741
-		}elseif($is_select2 && !empty($args['placeholder'])){
742
-			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
743
-		}
744
-
745
-		// Options
746
-		if(!empty($args['options'])){
747
-
748
-			if(!is_array($args['options'])){
749
-				$output .= $args['options']; // not the preferred way but an option
750
-			}else{
751
-				foreach($args['options'] as $val => $name){
752
-					$selected = '';
753
-					if(is_array($name)){
754
-						if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
755
-							$option_label = isset($name['label']) ? $name['label'] : '';
756
-
757
-							$output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
758
-						} else {
759
-							$option_label = isset($name['label']) ? $name['label'] : '';
760
-							$option_value = isset($name['value']) ? $name['value'] : '';
761
-							if(!empty($args['multiple']) && !empty($args['value'])){
762
-								$selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
763
-							} elseif(!empty($args['value'])) {
764
-								$selected = selected($option_value,stripslashes_deep($args['value']), false);
765
-							}
766
-
767
-							$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
768
-						}
769
-					}else{
770
-						if(!empty($args['value'])){
771
-							if(is_array($args['value'])){
772
-								$selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
773
-							} elseif(!empty($args['value'])) {
774
-								$selected = selected( $args['value'], $val, false);
775
-							}
776
-						}
777
-						$output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>';
778
-					}
779
-				}
780
-			}
781
-
782
-		}
783
-
784
-		// closing tag
785
-		$output .= '</select>';
786
-
787
-		if(!empty($args['label']) && $label_after){
788
-			$label_args = array(
789
-				'title'=> $args['label'],
790
-				'for'=> $args['id'],
791
-				'class' => $args['label_class']." ",
792
-				'label_type' => $args['label_type']
793
-			);
794
-			$output .= self::label($label_args);
795
-		}
796
-
797
-		// help text
798
-		if(!empty($args['help_text'])){
799
-			$output .= AUI_Component_Helper::help_text($args['help_text']);
800
-		}
801
-
802
-		// maybe horizontal label
803
-		if($args['label_type']=='horizontal'){
804
-			$output .= '</div>';
805
-		}
806
-
807
-
808
-		// wrap
809
-		if(!$args['no_wrap']){
810
-			$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
811
-			$output = self::wrap(array(
812
-				'content' => $output,
813
-				'class'   => $wrap_class,
814
-				'element_require'   => $args['element_require'],
815
-				'argument_id'  => $args['id']
816
-			));
817
-		}
818
-
819
-
820
-		return $output;
821
-	}
822
-
823
-	/**
824
-	 * Build the component.
825
-	 *
826
-	 * @param array $args
827
-	 *
828
-	 * @return string The rendered component.
829
-	 */
830
-	public static function radio($args = array()){
831
-		$defaults = array(
832
-			'class'      => '',
833
-			'id'         => '',
834
-			'title'      => '',
835
-			'horizontal' => false, // sets the lable horizontal
836
-			'value'      => '',
837
-			'label'      => '',
838
-			'label_class'=> '',
839
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
840
-			'inline'     => true,
841
-			'required'   => false,
842
-			'options'    => array(),
843
-			'icon'       => '',
844
-			'no_wrap'    => false,
845
-			'element_require'   => '', // [%element_id%] == "1"
846
-			'extra_attributes'  => array() // an array of extra attributes
847
-		);
848
-
849
-		/**
850
-		 * Parse incoming $args into an array and merge it with $defaults
851
-		 */
852
-		$args   = wp_parse_args( $args, $defaults );
853
-
854
-		// for now lets use horizontal for floating
855
-		if( $args['label_type'] != 'hidden' ){$args['label_type'] = 'horizontal';}
856
-
857
-		$label_args = array(
858
-			'title'=> $args['label'],
859
-			'class' => $args['label_class']." pt-0 ",
860
-			'label_type' => $args['label_type']
861
-		);
862
-
863
-		$output = '';
864
-
865
-
866
-
867
-		// label before
868
-		if(!empty($args['label'])){
869
-			$output .= self::label( $label_args, 'radio' );
870
-		}
871
-
872
-		// maybe horizontal label
873
-		if($args['label_type']=='horizontal'){
874
-			$output .= '<div class="col-sm-10">';
875
-		}
876
-
877
-		if(!empty($args['options'])){
878
-			$count = 0;
879
-			foreach($args['options'] as $value => $label){
880
-				$option_args = $args;
881
-				$option_args['value'] = $value;
882
-				$option_args['label'] = $label;
883
-				$option_args['checked'] = $value == $args['value'] ? true : false;
884
-				$output .= self::radio_option($option_args,$count);
885
-				$count++;
886
-			}
887
-		}
888
-
889
-		// maybe horizontal label
890
-		if($args['label_type']=='horizontal'){
891
-			$output .= '</div>';
892
-		}
893
-
894
-
895
-		// wrap
896
-		$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
897
-		$output = self::wrap(array(
898
-			'content' => $output,
899
-			'class'   => $wrap_class,
900
-			'element_require'   => $args['element_require'],
901
-			'argument_id'  => $args['id']
902
-		));
903
-
904
-
905
-		return $output;
906
-	}
907
-
908
-	/**
909
-	 * Build the component.
910
-	 *
911
-	 * @param array $args
912
-	 *
913
-	 * @return string The rendered component.
914
-	 */
915
-	public static function radio_option($args = array(),$count = ''){
916
-		$defaults = array(
917
-			'class'      => '',
918
-			'id'         => '',
919
-			'title'      => '',
920
-			'value'      => '',
921
-			'required'   => false,
922
-			'inline'     => true,
923
-			'label'      => '',
924
-			'options'    => array(),
925
-			'icon'       => '',
926
-			'no_wrap'    => false,
927
-			'extra_attributes'  => array() // an array of extra attributes
928
-		);
929
-
930
-		/**
931
-		 * Parse incoming $args into an array and merge it with $defaults
932
-		 */
933
-		$args   = wp_parse_args( $args, $defaults );
934
-
935
-		$output = '';
936
-
937
-		// open/type
938
-		$output .= '<input type="radio"';
939
-
940
-		// class
941
-		$output .= ' class="form-check-input" ';
942
-
943
-		// name
944
-		if(!empty($args['name'])){
945
-			$output .= AUI_Component_Helper::name($args['name']);
946
-		}
947
-
948
-		// id
949
-		if(!empty($args['id'])){
950
-			$output .= AUI_Component_Helper::id($args['id'].$count);
951
-		}
952
-
953
-		// title
954
-		if(!empty($args['title'])){
955
-			$output .= AUI_Component_Helper::title($args['title']);
956
-		}
957
-
958
-		// value
959
-		if(isset($args['value'])){
960
-			$output .= ' value="'.sanitize_text_field($args['value']).'" ';
961
-		}
962
-
963
-		// checked, for radio and checkboxes
964
-		if( $args['checked'] ){
965
-			$output .= ' checked ';
966
-		}
967
-
968
-		// data-attributes
969
-		$output .= AUI_Component_Helper::data_attributes($args);
970
-
971
-		// aria-attributes
972
-		$output .= AUI_Component_Helper::aria_attributes($args);
973
-
974
-		// extra attributes
975
-		if(!empty($args['extra_attributes'])){
976
-			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
977
-		}
978
-
979
-		// required
980
-		if(!empty($args['required'])){
981
-			$output .= ' required ';
982
-		}
983
-
984
-		// close opening tag
985
-		$output .= ' >';
986
-
987
-		// label
988
-		if(!empty($args['label']) && is_array($args['label'])){
989
-		}elseif(!empty($args['label'])){
990
-			$output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
991
-		}
992
-
993
-		// wrap
994
-		if(!$args['no_wrap']){
995
-			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
996
-			$output = self::wrap(array(
997
-				'content' => $output,
998
-				'class' => $wrap_class
999
-			));
1000
-		}
1001
-
1002
-
1003
-		return $output;
1004
-	}
212
+            }
213
+
214
+            // input group wraps
215
+            if($args['input_group_left'] || $args['input_group_right']){
216
+                $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
217
+                if($args['input_group_left']){
218
+                    $output = self::wrap( array(
219
+                        'content' => $output,
220
+                        'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100  : 'input-group',
221
+                        'input_group_left' => $args['input_group_left'],
222
+                        'input_group_left_inside'    => $args['input_group_left_inside']
223
+                    ) );
224
+                }
225
+                if($args['input_group_right']){
226
+                    $output = self::wrap( array(
227
+                        'content' => $output,
228
+                        'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group',
229
+                        'input_group_right' => $args['input_group_right'],
230
+                        'input_group_right_inside'    => $args['input_group_right_inside']
231
+                    ) );
232
+                }
233
+
234
+            }
235
+
236
+            if(!$label_after){
237
+                $output .= $help_text;
238
+            }
239
+
240
+
241
+            if($args['label_type']=='horizontal' && $type != 'checkbox'){
242
+                $output = self::wrap( array(
243
+                    'content' => $output,
244
+                    'class'   => 'col-sm-10',
245
+                ) );
246
+            }
247
+
248
+            if(!$label_after){
249
+                $output = $label . $output;
250
+            }
251
+
252
+            // wrap
253
+            if(!$args['no_wrap']){
254
+
255
+                $form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
256
+                $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
257
+                $output = self::wrap(array(
258
+                    'content' => $output,
259
+                    'class'   => $wrap_class,
260
+                    'element_require'   => $args['element_require'],
261
+                    'argument_id'  => $args['id']
262
+                ));
263
+            }
264
+
265
+
266
+
267
+        }
268
+
269
+        return $output;
270
+    }
271
+
272
+    /**
273
+     * Build the component.
274
+     *
275
+     * @param array $args
276
+     *
277
+     * @return string The rendered component.
278
+     */
279
+    public static function textarea($args = array()){
280
+        $defaults = array(
281
+            'name'       => '',
282
+            'class'      => '',
283
+            'id'         => '',
284
+            'placeholder'=> '',
285
+            'title'      => '',
286
+            'value'      => '',
287
+            'required'   => false,
288
+            'label'      => '',
289
+            'label_after'=> false,
290
+            'label_class'      => '',
291
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
292
+            'help_text'  => '',
293
+            'validation_text'   => '',
294
+            'validation_pattern' => '',
295
+            'no_wrap'    => false,
296
+            'rows'      => '',
297
+            'wysiwyg'   => false,
298
+            'element_require'   => '', // [%element_id%] == "1"
299
+        );
300
+
301
+        /**
302
+         * Parse incoming $args into an array and merge it with $defaults
303
+         */
304
+        $args   = wp_parse_args( $args, $defaults );
305
+        $output = '';
306
+
307
+        // hidden label option needs to be empty
308
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
309
+
310
+        // floating labels don't work with wysiwyg so set it as top
311
+        if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){
312
+            $args['label_type'] = 'top';
313
+        }
314
+
315
+        $label_after = $args['label_after'];
316
+
317
+        // floating labels need label after
318
+        if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){
319
+            $label_after = true;
320
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
321
+        }
322
+
323
+        // label
324
+        if(!empty($args['label']) && is_array($args['label'])){
325
+        }elseif(!empty($args['label']) && !$label_after){
326
+            $label_args = array(
327
+                'title'=> $args['label'],
328
+                'for'=> $args['id'],
329
+                'class' => $args['label_class']." ",
330
+                'label_type' => $args['label_type']
331
+            );
332
+            $output .= self::label( $label_args );
333
+        }
334
+
335
+        // maybe horizontal label
336
+        if($args['label_type']=='horizontal'){
337
+            $output .= '<div class="col-sm-10">';
338
+        }
339
+
340
+        if(!empty($args['wysiwyg'])){
341
+            ob_start();
342
+            $content = $args['value'];
343
+            $editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
344
+            $settings = array(
345
+                'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4,
346
+                'quicktags'     => false,
347
+                'media_buttons' => false,
348
+                'editor_class'  => 'form-control',
349
+                'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']),
350
+                'teeny'         => true,
351
+            );
352
+
353
+            // maybe set settings if array
354
+            if(is_array($args['wysiwyg'])){
355
+                $settings  = wp_parse_args( $args['wysiwyg'], $settings );
356
+            }
357
+
358
+            wp_editor( $content, $editor_id, $settings );
359
+            $output .= ob_get_clean();
360
+        }else{
361
+
362
+            // open
363
+            $output .= '<textarea ';
364
+
365
+            // name
366
+            if(!empty($args['name'])){
367
+                $output .= ' name="'.sanitize_html_class($args['name']).'" ';
368
+            }
369
+
370
+            // id
371
+            if(!empty($args['id'])){
372
+                $output .= ' id="'.sanitize_html_class($args['id']).'" ';
373
+            }
374
+
375
+            // placeholder
376
+            if(!empty($args['placeholder'])){
377
+                $output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
378
+            }
379
+
380
+            // title
381
+            if(!empty($args['title'])){
382
+                $output .= ' title="'.esc_attr($args['title']).'" ';
383
+            }
384
+
385
+            // validation text
386
+            if(!empty($args['validation_text'])){
387
+                $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
388
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
389
+            }
390
+
391
+            // validation_pattern
392
+            if(!empty($args['validation_pattern'])){
393
+                $output .= ' pattern="'.$args['validation_pattern'].'" ';
394
+            }
395
+
396
+            // required
397
+            if(!empty($args['required'])){
398
+                $output .= ' required ';
399
+            }
400
+
401
+            // rows
402
+            if(!empty($args['rows'])){
403
+                $output .= ' rows="'.absint($args['rows']).'" ';
404
+            }
405
+
406
+
407
+            // class
408
+            $class = !empty($args['class']) ? $args['class'] : '';
409
+            $output .= ' class="form-control '.$class.'" ';
410
+
411
+
412
+            // close tag
413
+            $output .= ' >';
414
+
415
+            // value
416
+            if(!empty($args['value'])){
417
+                $output .= sanitize_textarea_field($args['value']);
418
+            }
419
+
420
+            // closing tag
421
+            $output .= '</textarea>';
422
+
423
+        }
424
+
425
+        if(!empty($args['label']) && $label_after){
426
+            $label_args = array(
427
+                'title'=> $args['label'],
428
+                'for'=> $args['id'],
429
+                'class' => $args['label_class']." ",
430
+                'label_type' => $args['label_type']
431
+            );
432
+            $output .= self::label( $label_args );
433
+        }
434
+
435
+        // help text
436
+        if(!empty($args['help_text'])){
437
+            $output .= AUI_Component_Helper::help_text($args['help_text']);
438
+        }
439
+
440
+        // maybe horizontal label
441
+        if($args['label_type']=='horizontal'){
442
+            $output .= '</div>';
443
+        }
444
+
445
+
446
+        // wrap
447
+        if(!$args['no_wrap']){
448
+            $form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group';
449
+            $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
450
+            $output = self::wrap(array(
451
+                'content' => $output,
452
+                'class'   => $wrap_class,
453
+                'element_require'   => $args['element_require'],
454
+                'argument_id'  => $args['id']
455
+            ));
456
+        }
457
+
458
+
459
+        return $output;
460
+    }
461
+
462
+    public static function label($args = array(), $type = ''){
463
+        //<label for="exampleInputEmail1">Email address</label>
464
+        $defaults = array(
465
+            'title'       => 'div',
466
+            'for'      => '',
467
+            'class'      => '',
468
+            'label_type'    => '', // empty = hidden, top, horizontal
469
+        );
470
+
471
+        /**
472
+         * Parse incoming $args into an array and merge it with $defaults
473
+         */
474
+        $args   = wp_parse_args( $args, $defaults );
475
+        $output = '';
476
+
477
+        if($args['title']){
478
+
479
+            // maybe hide labels //@todo set a global option for visibility class
480
+            if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
481
+                $class = $args['class'];
482
+            }else{
483
+                $class = 'sr-only '.$args['class'];
484
+            }
485
+
486
+            // maybe horizontal
487
+            if($args['label_type']=='horizontal' && $type != 'checkbox'){
488
+                $class .= ' col-sm-2 col-form-label';
489
+            }
490
+
491
+            // open
492
+            $output .= '<label ';
493
+
494
+            // for
495
+            if(!empty($args['for'])){
496
+                $output .= ' for="'.sanitize_text_field($args['for']).'" ';
497
+            }
498
+
499
+            // class
500
+            $output .= ' class="'.$class.'" ';
501
+
502
+            // close
503
+            $output .= '>';
504
+
505
+
506
+            // title, don't escape fully as can contain html
507
+            if(!empty($args['title'])){
508
+                $output .= wp_kses_post($args['title']);
509
+            }
510
+
511
+            // close wrap
512
+            $output .= '</label>';
513
+
514
+
515
+        }
516
+
517
+
518
+        return $output;
519
+    }
520
+
521
+    public static function wrap($args = array()){
522
+        $defaults = array(
523
+            'type'       => 'div',
524
+            'class'      => 'form-group',
525
+            'content'   => '',
526
+            'input_group_left' => '',
527
+            'input_group_right' => '',
528
+            'input_group_left_inside' => false,
529
+            'input_group_right_inside' => false,
530
+            'element_require'   => '',
531
+            'argument_id'   => '',
532
+        );
533
+
534
+        /**
535
+         * Parse incoming $args into an array and merge it with $defaults
536
+         */
537
+        $args   = wp_parse_args( $args, $defaults );
538
+        $output = '';
539
+        if($args['type']){
540
+
541
+            // open
542
+            $output .= '<'.sanitize_html_class($args['type']);
543
+
544
+            // element require
545
+            if(!empty($args['element_require'])){
546
+                $output .= AUI_Component_Helper::element_require($args['element_require']);
547
+                $args['class'] .= " aui-conditional-field";
548
+            }
549
+
550
+            // argument_id
551
+            if( !empty($args['argument_id']) ){
552
+                $output .= ' data-argument="'.esc_attr($args['argument_id']).'"';
553
+            }
554
+
555
+            // class
556
+            $class = !empty($args['class']) ? $args['class'] : '';
557
+            $output .= ' class="'.$class.'" ';
558
+
559
+            // close wrap
560
+            $output .= ' >';
561
+
562
+
563
+            // Input group left
564
+            if(!empty($args['input_group_left'])){
565
+                $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
566
+                $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>';
567
+                $output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>';
568
+            }
569
+
570
+            // content
571
+            $output .= $args['content'];
572
+
573
+            // Input group right
574
+            if(!empty($args['input_group_right'])){
575
+                $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
576
+                $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>';
577
+                $output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>';
578
+            }
579
+
580
+
581
+            // close wrap
582
+            $output .= '</'.sanitize_html_class($args['type']).'>';
583
+
584
+
585
+        }else{
586
+            $output = $args['content'];
587
+        }
588
+
589
+        return $output;
590
+    }
591
+
592
+    /**
593
+     * Build the component.
594
+     *
595
+     * @param array $args
596
+     *
597
+     * @return string The rendered component.
598
+     */
599
+    public static function select($args = array()){
600
+        $defaults = array(
601
+            'class'      => '',
602
+            'id'         => '',
603
+            'title'      => '',
604
+            'value'      => '', // can be an array or a string
605
+            'required'   => false,
606
+            'label'      => '',
607
+            'label_after'=> false,
608
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
609
+            'label_class'      => '',
610
+            'help_text'  => '',
611
+            'placeholder'=> '',
612
+            'options'    => array(), // array or string
613
+            'icon'       => '',
614
+            'multiple'   => false,
615
+            'select2'    => false,
616
+            'no_wrap'    => false,
617
+            'element_require'   => '', // [%element_id%] == "1"
618
+            'extra_attributes'  => array(), // an array of extra attributes
619
+        );
620
+
621
+        /**
622
+         * Parse incoming $args into an array and merge it with $defaults
623
+         */
624
+        $args   = wp_parse_args( $args, $defaults );
625
+        $output = '';
626
+
627
+        // for now lets hide floating labels
628
+        if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';}
629
+
630
+        // hidden label option needs to be empty
631
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
632
+
633
+
634
+        $label_after = $args['label_after'];
635
+
636
+        // floating labels need label after
637
+        if( $args['label_type'] == 'floating' ){
638
+            $label_after = true;
639
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
640
+        }
641
+
642
+        // Maybe setup select2
643
+        $is_select2 = false;
644
+        if(!empty($args['select2'])){
645
+            $args['class'] .= ' aui-select2';
646
+            $is_select2 = true;
647
+        }elseif( strpos($args['class'], 'aui-select2') !== false){
648
+            $is_select2 = true;
649
+        }
650
+
651
+        // select2 tags
652
+        if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason
653
+            $args['data-tags'] = 'true';
654
+            $args['data-token-separators'] = "[',']";
655
+            $args['multiple'] = true;
656
+        }
657
+
658
+        // select2 placeholder
659
+        if($is_select2 && !empty($args['placeholder']) && empty($args['data-placeholder'])){
660
+            $args['data-placeholder'] = esc_attr($args['placeholder']);
661
+            $args['data-allow-clear'] = empty($args['data-allow-clear']) ? true : esc_attr($args['data-allow-clear']);
662
+        }
663
+
664
+        // label
665
+        if(!empty($args['label']) && is_array($args['label'])){
666
+        }elseif(!empty($args['label']) && !$label_after){
667
+            $label_args = array(
668
+                'title'=> $args['label'],
669
+                'for'=> $args['id'],
670
+                'class' => $args['label_class']." ",
671
+                'label_type' => $args['label_type']
672
+            );
673
+            $output .= self::label($label_args);
674
+        }
675
+
676
+        // maybe horizontal label
677
+        if($args['label_type']=='horizontal'){
678
+            $output .= '<div class="col-sm-10">';
679
+        }
680
+
681
+        // open/type
682
+        $output .= '<select ';
683
+
684
+        // style
685
+        if($is_select2){
686
+            $output .= " style='width:100%;' ";
687
+        }
688
+
689
+        // element require
690
+        if(!empty($args['element_require'])){
691
+            $output .= AUI_Component_Helper::element_require($args['element_require']);
692
+            $args['class'] .= " aui-conditional-field";
693
+        }
694
+
695
+        // class
696
+        $class = !empty($args['class']) ? $args['class'] : '';
697
+        $output .= AUI_Component_Helper::class_attr('custom-select '.$class);
698
+
699
+        // name
700
+        if(!empty($args['name'])){
701
+            $output .= AUI_Component_Helper::name($args['name'],$args['multiple']);
702
+        }
703
+
704
+        // id
705
+        if(!empty($args['id'])){
706
+            $output .= AUI_Component_Helper::id($args['id']);
707
+        }
708
+
709
+        // title
710
+        if(!empty($args['title'])){
711
+            $output .= AUI_Component_Helper::title($args['title']);
712
+        }
713
+
714
+        // data-attributes
715
+        $output .= AUI_Component_Helper::data_attributes($args);
716
+
717
+        // aria-attributes
718
+        $output .= AUI_Component_Helper::aria_attributes($args);
719
+
720
+        // extra attributes
721
+        if(!empty($args['extra_attributes'])){
722
+            $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
723
+        }
724
+
725
+        // required
726
+        if(!empty($args['required'])){
727
+            $output .= ' required ';
728
+        }
729
+
730
+        // multiple
731
+        if(!empty($args['multiple'])){
732
+            $output .= ' multiple ';
733
+        }
734
+
735
+        // close opening tag
736
+        $output .= ' >';
737
+
738
+        // placeholder
739
+        if(!empty($args['placeholder']) && !$is_select2){
740
+            $output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
741
+        }elseif($is_select2 && !empty($args['placeholder'])){
742
+            $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
743
+        }
744
+
745
+        // Options
746
+        if(!empty($args['options'])){
747
+
748
+            if(!is_array($args['options'])){
749
+                $output .= $args['options']; // not the preferred way but an option
750
+            }else{
751
+                foreach($args['options'] as $val => $name){
752
+                    $selected = '';
753
+                    if(is_array($name)){
754
+                        if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
755
+                            $option_label = isset($name['label']) ? $name['label'] : '';
756
+
757
+                            $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
758
+                        } else {
759
+                            $option_label = isset($name['label']) ? $name['label'] : '';
760
+                            $option_value = isset($name['value']) ? $name['value'] : '';
761
+                            if(!empty($args['multiple']) && !empty($args['value'])){
762
+                                $selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
763
+                            } elseif(!empty($args['value'])) {
764
+                                $selected = selected($option_value,stripslashes_deep($args['value']), false);
765
+                            }
766
+
767
+                            $output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
768
+                        }
769
+                    }else{
770
+                        if(!empty($args['value'])){
771
+                            if(is_array($args['value'])){
772
+                                $selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
773
+                            } elseif(!empty($args['value'])) {
774
+                                $selected = selected( $args['value'], $val, false);
775
+                            }
776
+                        }
777
+                        $output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>';
778
+                    }
779
+                }
780
+            }
781
+
782
+        }
783
+
784
+        // closing tag
785
+        $output .= '</select>';
786
+
787
+        if(!empty($args['label']) && $label_after){
788
+            $label_args = array(
789
+                'title'=> $args['label'],
790
+                'for'=> $args['id'],
791
+                'class' => $args['label_class']." ",
792
+                'label_type' => $args['label_type']
793
+            );
794
+            $output .= self::label($label_args);
795
+        }
796
+
797
+        // help text
798
+        if(!empty($args['help_text'])){
799
+            $output .= AUI_Component_Helper::help_text($args['help_text']);
800
+        }
801
+
802
+        // maybe horizontal label
803
+        if($args['label_type']=='horizontal'){
804
+            $output .= '</div>';
805
+        }
806
+
807
+
808
+        // wrap
809
+        if(!$args['no_wrap']){
810
+            $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
811
+            $output = self::wrap(array(
812
+                'content' => $output,
813
+                'class'   => $wrap_class,
814
+                'element_require'   => $args['element_require'],
815
+                'argument_id'  => $args['id']
816
+            ));
817
+        }
818
+
819
+
820
+        return $output;
821
+    }
822
+
823
+    /**
824
+     * Build the component.
825
+     *
826
+     * @param array $args
827
+     *
828
+     * @return string The rendered component.
829
+     */
830
+    public static function radio($args = array()){
831
+        $defaults = array(
832
+            'class'      => '',
833
+            'id'         => '',
834
+            'title'      => '',
835
+            'horizontal' => false, // sets the lable horizontal
836
+            'value'      => '',
837
+            'label'      => '',
838
+            'label_class'=> '',
839
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
840
+            'inline'     => true,
841
+            'required'   => false,
842
+            'options'    => array(),
843
+            'icon'       => '',
844
+            'no_wrap'    => false,
845
+            'element_require'   => '', // [%element_id%] == "1"
846
+            'extra_attributes'  => array() // an array of extra attributes
847
+        );
848
+
849
+        /**
850
+         * Parse incoming $args into an array and merge it with $defaults
851
+         */
852
+        $args   = wp_parse_args( $args, $defaults );
853
+
854
+        // for now lets use horizontal for floating
855
+        if( $args['label_type'] != 'hidden' ){$args['label_type'] = 'horizontal';}
856
+
857
+        $label_args = array(
858
+            'title'=> $args['label'],
859
+            'class' => $args['label_class']." pt-0 ",
860
+            'label_type' => $args['label_type']
861
+        );
862
+
863
+        $output = '';
864
+
865
+
866
+
867
+        // label before
868
+        if(!empty($args['label'])){
869
+            $output .= self::label( $label_args, 'radio' );
870
+        }
871
+
872
+        // maybe horizontal label
873
+        if($args['label_type']=='horizontal'){
874
+            $output .= '<div class="col-sm-10">';
875
+        }
876
+
877
+        if(!empty($args['options'])){
878
+            $count = 0;
879
+            foreach($args['options'] as $value => $label){
880
+                $option_args = $args;
881
+                $option_args['value'] = $value;
882
+                $option_args['label'] = $label;
883
+                $option_args['checked'] = $value == $args['value'] ? true : false;
884
+                $output .= self::radio_option($option_args,$count);
885
+                $count++;
886
+            }
887
+        }
888
+
889
+        // maybe horizontal label
890
+        if($args['label_type']=='horizontal'){
891
+            $output .= '</div>';
892
+        }
893
+
894
+
895
+        // wrap
896
+        $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
897
+        $output = self::wrap(array(
898
+            'content' => $output,
899
+            'class'   => $wrap_class,
900
+            'element_require'   => $args['element_require'],
901
+            'argument_id'  => $args['id']
902
+        ));
903
+
904
+
905
+        return $output;
906
+    }
907
+
908
+    /**
909
+     * Build the component.
910
+     *
911
+     * @param array $args
912
+     *
913
+     * @return string The rendered component.
914
+     */
915
+    public static function radio_option($args = array(),$count = ''){
916
+        $defaults = array(
917
+            'class'      => '',
918
+            'id'         => '',
919
+            'title'      => '',
920
+            'value'      => '',
921
+            'required'   => false,
922
+            'inline'     => true,
923
+            'label'      => '',
924
+            'options'    => array(),
925
+            'icon'       => '',
926
+            'no_wrap'    => false,
927
+            'extra_attributes'  => array() // an array of extra attributes
928
+        );
929
+
930
+        /**
931
+         * Parse incoming $args into an array and merge it with $defaults
932
+         */
933
+        $args   = wp_parse_args( $args, $defaults );
934
+
935
+        $output = '';
936
+
937
+        // open/type
938
+        $output .= '<input type="radio"';
939
+
940
+        // class
941
+        $output .= ' class="form-check-input" ';
942
+
943
+        // name
944
+        if(!empty($args['name'])){
945
+            $output .= AUI_Component_Helper::name($args['name']);
946
+        }
947
+
948
+        // id
949
+        if(!empty($args['id'])){
950
+            $output .= AUI_Component_Helper::id($args['id'].$count);
951
+        }
952
+
953
+        // title
954
+        if(!empty($args['title'])){
955
+            $output .= AUI_Component_Helper::title($args['title']);
956
+        }
957
+
958
+        // value
959
+        if(isset($args['value'])){
960
+            $output .= ' value="'.sanitize_text_field($args['value']).'" ';
961
+        }
962
+
963
+        // checked, for radio and checkboxes
964
+        if( $args['checked'] ){
965
+            $output .= ' checked ';
966
+        }
967
+
968
+        // data-attributes
969
+        $output .= AUI_Component_Helper::data_attributes($args);
970
+
971
+        // aria-attributes
972
+        $output .= AUI_Component_Helper::aria_attributes($args);
973
+
974
+        // extra attributes
975
+        if(!empty($args['extra_attributes'])){
976
+            $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
977
+        }
978
+
979
+        // required
980
+        if(!empty($args['required'])){
981
+            $output .= ' required ';
982
+        }
983
+
984
+        // close opening tag
985
+        $output .= ' >';
986
+
987
+        // label
988
+        if(!empty($args['label']) && is_array($args['label'])){
989
+        }elseif(!empty($args['label'])){
990
+            $output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
991
+        }
992
+
993
+        // wrap
994
+        if(!$args['no_wrap']){
995
+            $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
996
+            $output = self::wrap(array(
997
+                'content' => $output,
998
+                'class' => $wrap_class
999
+            ));
1000
+        }
1001
+
1002
+
1003
+        return $output;
1004
+    }
1005 1005
 
1006 1006
 }
1007 1007
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +201 added lines, -201 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'       => '',
@@ -51,13 +51,13 @@  discard block
 block discarded – undo
51 51
 		/**
52 52
 		 * Parse incoming $args into an array and merge it with $defaults
53 53
 		 */
54
-		$args   = wp_parse_args( $args, $defaults );
54
+		$args   = wp_parse_args($args, $defaults);
55 55
 		$output = '';
56
-		if ( ! empty( $args['type'] ) ) {
56
+		if (!empty($args['type'])) {
57 57
 			// hidden label option needs to be empty
58 58
 			$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
59 59
 
60
-			$type = sanitize_html_class( $args['type'] );
60
+			$type = sanitize_html_class($args['type']);
61 61
 
62 62
 			$help_text = '';
63 63
 			$label = '';
@@ -65,24 +65,24 @@  discard block
 block discarded – undo
65 65
 			$label_args = array(
66 66
 				'title'=> $args['label'],
67 67
 				'for'=> $args['id'],
68
-				'class' => $args['label_class']." ",
68
+				'class' => $args['label_class'] . " ",
69 69
 				'label_type' => $args['label_type']
70 70
 			);
71 71
 
72 72
 			// floating labels need label after
73
-			if( $args['label_type'] == 'floating' && $type != 'checkbox' ){
73
+			if ($args['label_type'] == 'floating' && $type != 'checkbox') {
74 74
 				$label_after = true;
75 75
 				$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
76 76
 			}
77 77
 
78 78
 			// Some special sauce for files
79
-			if($type=='file' ){
79
+			if ($type == 'file') {
80 80
 				$label_after = true; // if type file we need the label after
81 81
 				$args['class'] .= ' custom-file-input ';
82
-			}elseif($type=='checkbox'){
82
+			}elseif ($type == 'checkbox') {
83 83
 				$label_after = true; // if type file we need the label after
84 84
 				$args['class'] .= ' custom-control-input ';
85
-			}elseif($type=='datepicker' || $type=='timepicker'){
85
+			}elseif ($type == 'datepicker' || $type == 'timepicker') {
86 86
 				$type = 'text';
87 87
 				//$args['class'] .= ' aui-flatpickr bg-initial ';
88 88
 				$args['class'] .= ' bg-initial ';
@@ -98,65 +98,65 @@  discard block
 block discarded – undo
98 98
 			$output .= '<input type="' . $type . '" ';
99 99
 
100 100
 			// name
101
-			if(!empty($args['name'])){
102
-				$output .= ' name="'.esc_attr($args['name']).'" ';
101
+			if (!empty($args['name'])) {
102
+				$output .= ' name="' . esc_attr($args['name']) . '" ';
103 103
 			}
104 104
 
105 105
 			// id
106
-			if(!empty($args['id'])){
107
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
106
+			if (!empty($args['id'])) {
107
+				$output .= ' id="' . sanitize_html_class($args['id']) . '" ';
108 108
 			}
109 109
 
110 110
 			// placeholder
111
-			if(!empty($args['placeholder'])){
112
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
111
+			if (!empty($args['placeholder'])) {
112
+				$output .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
113 113
 			}
114 114
 
115 115
 			// title
116
-			if(!empty($args['title'])){
117
-				$output .= ' title="'.esc_attr($args['title']).'" ';
116
+			if (!empty($args['title'])) {
117
+				$output .= ' title="' . esc_attr($args['title']) . '" ';
118 118
 			}
119 119
 
120 120
 			// value
121
-			if(!empty($args['value'])){
122
-				$output .= ' value="'.sanitize_text_field($args['value']).'" ';
121
+			if (!empty($args['value'])) {
122
+				$output .= ' value="' . sanitize_text_field($args['value']) . '" ';
123 123
 			}
124 124
 
125 125
 			// checked, for radio and checkboxes
126
-			if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){
126
+			if (($type == 'checkbox' || $type == 'radio') && $args['checked']) {
127 127
 				$output .= ' checked ';
128 128
 			}
129 129
 
130 130
 			// validation text
131
-			if(!empty($args['validation_text'])){
132
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
131
+			if (!empty($args['validation_text'])) {
132
+				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" ';
133 133
 				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
134 134
 			}
135 135
 
136 136
 			// validation_pattern
137
-			if(!empty($args['validation_pattern'])){
138
-				$output .= ' pattern="'.$args['validation_pattern'].'" ';
137
+			if (!empty($args['validation_pattern'])) {
138
+				$output .= ' pattern="' . $args['validation_pattern'] . '" ';
139 139
 			}
140 140
 
141 141
 			// step (for numbers)
142
-			if(!empty($args['step'])){
143
-				$output .= ' step="'.$args['step'].'" ';
142
+			if (!empty($args['step'])) {
143
+				$output .= ' step="' . $args['step'] . '" ';
144 144
 			}
145 145
 
146 146
 			// required
147
-			if(!empty($args['required'])){
147
+			if (!empty($args['required'])) {
148 148
 				$output .= ' required ';
149 149
 			}
150 150
 
151 151
 			// class
152 152
 			$class = !empty($args['class']) ? $args['class'] : '';
153
-			$output .= ' class="form-control '.$class.'" ';
153
+			$output .= ' class="form-control ' . $class . '" ';
154 154
 
155 155
 			// data-attributes
156 156
 			$output .= AUI_Component_Helper::data_attributes($args);
157 157
 
158 158
 			// extra attributes
159
-			if(!empty($args['extra_attributes'])){
159
+			if (!empty($args['extra_attributes'])) {
160 160
 				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
161 161
 			}
162 162
 
@@ -165,40 +165,40 @@  discard block
 block discarded – undo
165 165
 
166 166
 
167 167
 			// label
168
-			if(!empty($args['label'])){
169
-				if($type == 'file'){$label_args['class'] .= 'custom-file-label';}
170
-				elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
171
-				$label = self::label( $label_args, $type );
168
+			if (!empty($args['label'])) {
169
+				if ($type == 'file') {$label_args['class'] .= 'custom-file-label'; }
170
+				elseif ($type == 'checkbox') {$label_args['class'] .= 'custom-control-label'; }
171
+				$label = self::label($label_args, $type);
172 172
 			}
173 173
 
174 174
 			// help text
175
-			if(!empty($args['help_text'])){
175
+			if (!empty($args['help_text'])) {
176 176
 				$help_text = AUI_Component_Helper::help_text($args['help_text']);
177 177
 			}
178 178
 
179 179
 
180 180
 			// set help text in the correct possition
181
-			if($label_after){
181
+			if ($label_after) {
182 182
 				$output .= $label . $help_text;
183 183
 			}
184 184
 
185 185
 			// some input types need a separate wrap
186
-			if($type == 'file') {
187
-				$output = self::wrap( array(
186
+			if ($type == 'file') {
187
+				$output = self::wrap(array(
188 188
 					'content' => $output,
189 189
 					'class'   => 'form-group custom-file'
190
-				) );
191
-			}elseif($type == 'checkbox'){
190
+				));
191
+			}elseif ($type == 'checkbox') {
192 192
 				$wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
193
-				$output = self::wrap( array(
193
+				$output = self::wrap(array(
194 194
 					'content' => $output,
195
-					'class'   => 'custom-control '.$wrap_class
196
-				) );
195
+					'class'   => 'custom-control ' . $wrap_class
196
+				));
197 197
 
198
-				if($args['label_type']=='horizontal'){
198
+				if ($args['label_type'] == 'horizontal') {
199 199
 					$output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
200 200
 				}
201
-			}elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
201
+			}elseif ($type == 'password' && $args['password_toggle'] && !$args['input_group_right']) {
202 202
 
203 203
 
204 204
 				// allow password field to toggle view
@@ -212,48 +212,48 @@  discard block
 block discarded – undo
212 212
 			}
213 213
 
214 214
 			// input group wraps
215
-			if($args['input_group_left'] || $args['input_group_right']){
215
+			if ($args['input_group_left'] || $args['input_group_right']) {
216 216
 				$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
217
-				if($args['input_group_left']){
218
-					$output = self::wrap( array(
217
+				if ($args['input_group_left']) {
218
+					$output = self::wrap(array(
219 219
 						'content' => $output,
220
-						'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100  : 'input-group',
220
+						'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
221 221
 						'input_group_left' => $args['input_group_left'],
222 222
 						'input_group_left_inside'    => $args['input_group_left_inside']
223
-					) );
223
+					));
224 224
 				}
225
-				if($args['input_group_right']){
226
-					$output = self::wrap( array(
225
+				if ($args['input_group_right']) {
226
+					$output = self::wrap(array(
227 227
 						'content' => $output,
228
-						'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group',
228
+						'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
229 229
 						'input_group_right' => $args['input_group_right'],
230 230
 						'input_group_right_inside'    => $args['input_group_right_inside']
231
-					) );
231
+					));
232 232
 				}
233 233
 
234 234
 			}
235 235
 
236
-			if(!$label_after){
236
+			if (!$label_after) {
237 237
 				$output .= $help_text;
238 238
 			}
239 239
 
240 240
 
241
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
242
-				$output = self::wrap( array(
241
+			if ($args['label_type'] == 'horizontal' && $type != 'checkbox') {
242
+				$output = self::wrap(array(
243 243
 					'content' => $output,
244 244
 					'class'   => 'col-sm-10',
245
-				) );
245
+				));
246 246
 			}
247 247
 
248
-			if(!$label_after){
248
+			if (!$label_after) {
249 249
 				$output = $label . $output;
250 250
 			}
251 251
 
252 252
 			// wrap
253
-			if(!$args['no_wrap']){
253
+			if (!$args['no_wrap']) {
254 254
 
255
-				$form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
256
-				$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
255
+				$form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
256
+				$wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
257 257
 				$output = self::wrap(array(
258 258
 					'content' => $output,
259 259
 					'class'   => $wrap_class,
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 *
277 277
 	 * @return string The rendered component.
278 278
 	 */
279
-	public static function textarea($args = array()){
279
+	public static function textarea($args = array()) {
280 280
 		$defaults = array(
281 281
 			'name'       => '',
282 282
 			'class'      => '',
@@ -301,43 +301,43 @@  discard block
 block discarded – undo
301 301
 		/**
302 302
 		 * Parse incoming $args into an array and merge it with $defaults
303 303
 		 */
304
-		$args   = wp_parse_args( $args, $defaults );
304
+		$args   = wp_parse_args($args, $defaults);
305 305
 		$output = '';
306 306
 
307 307
 		// hidden label option needs to be empty
308 308
 		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
309 309
 
310 310
 		// floating labels don't work with wysiwyg so set it as top
311
-		if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){
311
+		if ($args['label_type'] == 'floating' && !empty($args['wysiwyg'])) {
312 312
 			$args['label_type'] = 'top';
313 313
 		}
314 314
 
315 315
 		$label_after = $args['label_after'];
316 316
 
317 317
 		// floating labels need label after
318
-		if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){
318
+		if ($args['label_type'] == 'floating' && empty($args['wysiwyg'])) {
319 319
 			$label_after = true;
320 320
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
321 321
 		}
322 322
 
323 323
 		// label
324
-		if(!empty($args['label']) && is_array($args['label'])){
325
-		}elseif(!empty($args['label']) && !$label_after){
324
+		if (!empty($args['label']) && is_array($args['label'])) {
325
+		}elseif (!empty($args['label']) && !$label_after) {
326 326
 			$label_args = array(
327 327
 				'title'=> $args['label'],
328 328
 				'for'=> $args['id'],
329
-				'class' => $args['label_class']." ",
329
+				'class' => $args['label_class'] . " ",
330 330
 				'label_type' => $args['label_type']
331 331
 			);
332
-			$output .= self::label( $label_args );
332
+			$output .= self::label($label_args);
333 333
 		}
334 334
 
335 335
 		// maybe horizontal label
336
-		if($args['label_type']=='horizontal'){
336
+		if ($args['label_type'] == 'horizontal') {
337 337
 			$output .= '<div class="col-sm-10">';
338 338
 		}
339 339
 
340
-		if(!empty($args['wysiwyg'])){
340
+		if (!empty($args['wysiwyg'])) {
341 341
 			ob_start();
342 342
 			$content = $args['value'];
343 343
 			$editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
@@ -351,69 +351,69 @@  discard block
 block discarded – undo
351 351
 			);
352 352
 
353 353
 			// maybe set settings if array
354
-			if(is_array($args['wysiwyg'])){
355
-				$settings  = wp_parse_args( $args['wysiwyg'], $settings );
354
+			if (is_array($args['wysiwyg'])) {
355
+				$settings = wp_parse_args($args['wysiwyg'], $settings);
356 356
 			}
357 357
 
358
-			wp_editor( $content, $editor_id, $settings );
358
+			wp_editor($content, $editor_id, $settings);
359 359
 			$output .= ob_get_clean();
360
-		}else{
360
+		} else {
361 361
 
362 362
 			// open
363 363
 			$output .= '<textarea ';
364 364
 
365 365
 			// name
366
-			if(!empty($args['name'])){
367
-				$output .= ' name="'.sanitize_html_class($args['name']).'" ';
366
+			if (!empty($args['name'])) {
367
+				$output .= ' name="' . sanitize_html_class($args['name']) . '" ';
368 368
 			}
369 369
 
370 370
 			// id
371
-			if(!empty($args['id'])){
372
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
371
+			if (!empty($args['id'])) {
372
+				$output .= ' id="' . sanitize_html_class($args['id']) . '" ';
373 373
 			}
374 374
 
375 375
 			// placeholder
376
-			if(!empty($args['placeholder'])){
377
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
376
+			if (!empty($args['placeholder'])) {
377
+				$output .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
378 378
 			}
379 379
 
380 380
 			// title
381
-			if(!empty($args['title'])){
382
-				$output .= ' title="'.esc_attr($args['title']).'" ';
381
+			if (!empty($args['title'])) {
382
+				$output .= ' title="' . esc_attr($args['title']) . '" ';
383 383
 			}
384 384
 
385 385
 			// validation text
386
-			if(!empty($args['validation_text'])){
387
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
386
+			if (!empty($args['validation_text'])) {
387
+				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" ';
388 388
 				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
389 389
 			}
390 390
 
391 391
 			// validation_pattern
392
-			if(!empty($args['validation_pattern'])){
393
-				$output .= ' pattern="'.$args['validation_pattern'].'" ';
392
+			if (!empty($args['validation_pattern'])) {
393
+				$output .= ' pattern="' . $args['validation_pattern'] . '" ';
394 394
 			}
395 395
 
396 396
 			// required
397
-			if(!empty($args['required'])){
397
+			if (!empty($args['required'])) {
398 398
 				$output .= ' required ';
399 399
 			}
400 400
 
401 401
 			// rows
402
-			if(!empty($args['rows'])){
403
-				$output .= ' rows="'.absint($args['rows']).'" ';
402
+			if (!empty($args['rows'])) {
403
+				$output .= ' rows="' . absint($args['rows']) . '" ';
404 404
 			}
405 405
 
406 406
 
407 407
 			// class
408 408
 			$class = !empty($args['class']) ? $args['class'] : '';
409
-			$output .= ' class="form-control '.$class.'" ';
409
+			$output .= ' class="form-control ' . $class . '" ';
410 410
 
411 411
 
412 412
 			// close tag
413 413
 			$output .= ' >';
414 414
 
415 415
 			// value
416
-			if(!empty($args['value'])){
416
+			if (!empty($args['value'])) {
417 417
 				$output .= sanitize_textarea_field($args['value']);
418 418
 			}
419 419
 
@@ -422,31 +422,31 @@  discard block
 block discarded – undo
422 422
 
423 423
 		}
424 424
 
425
-		if(!empty($args['label']) && $label_after){
425
+		if (!empty($args['label']) && $label_after) {
426 426
 			$label_args = array(
427 427
 				'title'=> $args['label'],
428 428
 				'for'=> $args['id'],
429
-				'class' => $args['label_class']." ",
429
+				'class' => $args['label_class'] . " ",
430 430
 				'label_type' => $args['label_type']
431 431
 			);
432
-			$output .= self::label( $label_args );
432
+			$output .= self::label($label_args);
433 433
 		}
434 434
 
435 435
 		// help text
436
-		if(!empty($args['help_text'])){
436
+		if (!empty($args['help_text'])) {
437 437
 			$output .= AUI_Component_Helper::help_text($args['help_text']);
438 438
 		}
439 439
 
440 440
 		// maybe horizontal label
441
-		if($args['label_type']=='horizontal'){
441
+		if ($args['label_type'] == 'horizontal') {
442 442
 			$output .= '</div>';
443 443
 		}
444 444
 
445 445
 
446 446
 		// wrap
447
-		if(!$args['no_wrap']){
448
-			$form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group';
449
-			$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
447
+		if (!$args['no_wrap']) {
448
+			$form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group';
449
+			$wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
450 450
 			$output = self::wrap(array(
451 451
 				'content' => $output,
452 452
 				'class'   => $wrap_class,
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 		return $output;
460 460
 	}
461 461
 
462
-	public static function label($args = array(), $type = ''){
462
+	public static function label($args = array(), $type = '') {
463 463
 		//<label for="exampleInputEmail1">Email address</label>
464 464
 		$defaults = array(
465 465
 			'title'       => 'div',
@@ -471,20 +471,20 @@  discard block
 block discarded – undo
471 471
 		/**
472 472
 		 * Parse incoming $args into an array and merge it with $defaults
473 473
 		 */
474
-		$args   = wp_parse_args( $args, $defaults );
474
+		$args   = wp_parse_args($args, $defaults);
475 475
 		$output = '';
476 476
 
477
-		if($args['title']){
477
+		if ($args['title']) {
478 478
 
479 479
 			// maybe hide labels //@todo set a global option for visibility class
480
-			if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
480
+			if ($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type'])) {
481 481
 				$class = $args['class'];
482
-			}else{
483
-				$class = 'sr-only '.$args['class'];
482
+			} else {
483
+				$class = 'sr-only ' . $args['class'];
484 484
 			}
485 485
 
486 486
 			// maybe horizontal
487
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
487
+			if ($args['label_type'] == 'horizontal' && $type != 'checkbox') {
488 488
 				$class .= ' col-sm-2 col-form-label';
489 489
 			}
490 490
 
@@ -492,19 +492,19 @@  discard block
 block discarded – undo
492 492
 			$output .= '<label ';
493 493
 
494 494
 			// for
495
-			if(!empty($args['for'])){
496
-				$output .= ' for="'.sanitize_text_field($args['for']).'" ';
495
+			if (!empty($args['for'])) {
496
+				$output .= ' for="' . sanitize_text_field($args['for']) . '" ';
497 497
 			}
498 498
 
499 499
 			// class
500
-			$output .= ' class="'.$class.'" ';
500
+			$output .= ' class="' . $class . '" ';
501 501
 
502 502
 			// close
503 503
 			$output .= '>';
504 504
 
505 505
 
506 506
 			// title, don't escape fully as can contain html
507
-			if(!empty($args['title'])){
507
+			if (!empty($args['title'])) {
508 508
 				$output .= wp_kses_post($args['title']);
509 509
 			}
510 510
 
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 		return $output;
519 519
 	}
520 520
 
521
-	public static function wrap($args = array()){
521
+	public static function wrap($args = array()) {
522 522
 		$defaults = array(
523 523
 			'type'       => 'div',
524 524
 			'class'      => 'form-group',
@@ -534,55 +534,55 @@  discard block
 block discarded – undo
534 534
 		/**
535 535
 		 * Parse incoming $args into an array and merge it with $defaults
536 536
 		 */
537
-		$args   = wp_parse_args( $args, $defaults );
537
+		$args   = wp_parse_args($args, $defaults);
538 538
 		$output = '';
539
-		if($args['type']){
539
+		if ($args['type']) {
540 540
 
541 541
 			// open
542
-			$output .= '<'.sanitize_html_class($args['type']);
542
+			$output .= '<' . sanitize_html_class($args['type']);
543 543
 
544 544
 			// element require
545
-			if(!empty($args['element_require'])){
545
+			if (!empty($args['element_require'])) {
546 546
 				$output .= AUI_Component_Helper::element_require($args['element_require']);
547 547
 				$args['class'] .= " aui-conditional-field";
548 548
 			}
549 549
 
550 550
 			// argument_id
551
-			if( !empty($args['argument_id']) ){
552
-				$output .= ' data-argument="'.esc_attr($args['argument_id']).'"';
551
+			if (!empty($args['argument_id'])) {
552
+				$output .= ' data-argument="' . esc_attr($args['argument_id']) . '"';
553 553
 			}
554 554
 
555 555
 			// class
556 556
 			$class = !empty($args['class']) ? $args['class'] : '';
557
-			$output .= ' class="'.$class.'" ';
557
+			$output .= ' class="' . $class . '" ';
558 558
 
559 559
 			// close wrap
560 560
 			$output .= ' >';
561 561
 
562 562
 
563 563
 			// Input group left
564
-			if(!empty($args['input_group_left'])){
564
+			if (!empty($args['input_group_left'])) {
565 565
 				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
566
-				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>';
567
-				$output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>';
566
+				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
567
+				$output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
568 568
 			}
569 569
 
570 570
 			// content
571 571
 			$output .= $args['content'];
572 572
 
573 573
 			// Input group right
574
-			if(!empty($args['input_group_right'])){
574
+			if (!empty($args['input_group_right'])) {
575 575
 				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
576
-				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>';
577
-				$output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>';
576
+				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
577
+				$output .= '<div class="input-group-append ' . $position_class . '">' . $input_group_right . '</div>';
578 578
 			}
579 579
 
580 580
 
581 581
 			// close wrap
582
-			$output .= '</'.sanitize_html_class($args['type']).'>';
582
+			$output .= '</' . sanitize_html_class($args['type']) . '>';
583 583
 
584 584
 
585
-		}else{
585
+		} else {
586 586
 			$output = $args['content'];
587 587
 		}
588 588
 
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 	 *
597 597
 	 * @return string The rendered component.
598 598
 	 */
599
-	public static function select($args = array()){
599
+	public static function select($args = array()) {
600 600
 		$defaults = array(
601 601
 			'class'      => '',
602 602
 			'id'         => '',
@@ -621,11 +621,11 @@  discard block
 block discarded – undo
621 621
 		/**
622 622
 		 * Parse incoming $args into an array and merge it with $defaults
623 623
 		 */
624
-		$args   = wp_parse_args( $args, $defaults );
624
+		$args   = wp_parse_args($args, $defaults);
625 625
 		$output = '';
626 626
 
627 627
 		// for now lets hide floating labels
628
-		if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';}
628
+		if ($args['label_type'] == 'floating') {$args['label_type'] = 'hidden'; }
629 629
 
630 630
 		// hidden label option needs to be empty
631 631
 		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
@@ -634,47 +634,47 @@  discard block
 block discarded – undo
634 634
 		$label_after = $args['label_after'];
635 635
 
636 636
 		// floating labels need label after
637
-		if( $args['label_type'] == 'floating' ){
637
+		if ($args['label_type'] == 'floating') {
638 638
 			$label_after = true;
639 639
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
640 640
 		}
641 641
 
642 642
 		// Maybe setup select2
643 643
 		$is_select2 = false;
644
-		if(!empty($args['select2'])){
644
+		if (!empty($args['select2'])) {
645 645
 			$args['class'] .= ' aui-select2';
646 646
 			$is_select2 = true;
647
-		}elseif( strpos($args['class'], 'aui-select2') !== false){
647
+		}elseif (strpos($args['class'], 'aui-select2') !== false) {
648 648
 			$is_select2 = true;
649 649
 		}
650 650
 
651 651
 		// select2 tags
652
-		if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason
652
+		if (!empty($args['select2']) && $args['select2'] === 'tags') { // triple equals needed here for some reason
653 653
 			$args['data-tags'] = 'true';
654 654
 			$args['data-token-separators'] = "[',']";
655 655
 			$args['multiple'] = true;
656 656
 		}
657 657
 
658 658
 		// select2 placeholder
659
-		if($is_select2 && !empty($args['placeholder']) && empty($args['data-placeholder'])){
659
+		if ($is_select2 && !empty($args['placeholder']) && empty($args['data-placeholder'])) {
660 660
 			$args['data-placeholder'] = esc_attr($args['placeholder']);
661 661
 			$args['data-allow-clear'] = empty($args['data-allow-clear']) ? true : esc_attr($args['data-allow-clear']);
662 662
 		}
663 663
 
664 664
 		// label
665
-		if(!empty($args['label']) && is_array($args['label'])){
666
-		}elseif(!empty($args['label']) && !$label_after){
665
+		if (!empty($args['label']) && is_array($args['label'])) {
666
+		}elseif (!empty($args['label']) && !$label_after) {
667 667
 			$label_args = array(
668 668
 				'title'=> $args['label'],
669 669
 				'for'=> $args['id'],
670
-				'class' => $args['label_class']." ",
670
+				'class' => $args['label_class'] . " ",
671 671
 				'label_type' => $args['label_type']
672 672
 			);
673 673
 			$output .= self::label($label_args);
674 674
 		}
675 675
 
676 676
 		// maybe horizontal label
677
-		if($args['label_type']=='horizontal'){
677
+		if ($args['label_type'] == 'horizontal') {
678 678
 			$output .= '<div class="col-sm-10">';
679 679
 		}
680 680
 
@@ -682,32 +682,32 @@  discard block
 block discarded – undo
682 682
 		$output .= '<select ';
683 683
 
684 684
 		// style
685
-		if($is_select2){
685
+		if ($is_select2) {
686 686
 			$output .= " style='width:100%;' ";
687 687
 		}
688 688
 
689 689
 		// element require
690
-		if(!empty($args['element_require'])){
690
+		if (!empty($args['element_require'])) {
691 691
 			$output .= AUI_Component_Helper::element_require($args['element_require']);
692 692
 			$args['class'] .= " aui-conditional-field";
693 693
 		}
694 694
 
695 695
 		// class
696 696
 		$class = !empty($args['class']) ? $args['class'] : '';
697
-		$output .= AUI_Component_Helper::class_attr('custom-select '.$class);
697
+		$output .= AUI_Component_Helper::class_attr('custom-select ' . $class);
698 698
 
699 699
 		// name
700
-		if(!empty($args['name'])){
701
-			$output .= AUI_Component_Helper::name($args['name'],$args['multiple']);
700
+		if (!empty($args['name'])) {
701
+			$output .= AUI_Component_Helper::name($args['name'], $args['multiple']);
702 702
 		}
703 703
 
704 704
 		// id
705
-		if(!empty($args['id'])){
705
+		if (!empty($args['id'])) {
706 706
 			$output .= AUI_Component_Helper::id($args['id']);
707 707
 		}
708 708
 
709 709
 		// title
710
-		if(!empty($args['title'])){
710
+		if (!empty($args['title'])) {
711 711
 			$output .= AUI_Component_Helper::title($args['title']);
712 712
 		}
713 713
 
@@ -718,17 +718,17 @@  discard block
 block discarded – undo
718 718
 		$output .= AUI_Component_Helper::aria_attributes($args);
719 719
 
720 720
 		// extra attributes
721
-		if(!empty($args['extra_attributes'])){
721
+		if (!empty($args['extra_attributes'])) {
722 722
 			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
723 723
 		}
724 724
 
725 725
 		// required
726
-		if(!empty($args['required'])){
726
+		if (!empty($args['required'])) {
727 727
 			$output .= ' required ';
728 728
 		}
729 729
 
730 730
 		// multiple
731
-		if(!empty($args['multiple'])){
731
+		if (!empty($args['multiple'])) {
732 732
 			$output .= ' multiple ';
733 733
 		}
734 734
 
@@ -736,21 +736,21 @@  discard block
 block discarded – undo
736 736
 		$output .= ' >';
737 737
 
738 738
 		// placeholder
739
-		if(!empty($args['placeholder']) && !$is_select2){
740
-			$output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
741
-		}elseif($is_select2 && !empty($args['placeholder'])){
739
+		if (!empty($args['placeholder']) && !$is_select2) {
740
+			$output .= '<option value="" disabled selected hidden>' . esc_attr($args['placeholder']) . '</option>';
741
+		}elseif ($is_select2 && !empty($args['placeholder'])) {
742 742
 			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
743 743
 		}
744 744
 
745 745
 		// Options
746
-		if(!empty($args['options'])){
746
+		if (!empty($args['options'])) {
747 747
 
748
-			if(!is_array($args['options'])){
748
+			if (!is_array($args['options'])) {
749 749
 				$output .= $args['options']; // not the preferred way but an option
750
-			}else{
751
-				foreach($args['options'] as $val => $name){
750
+			} else {
751
+				foreach ($args['options'] as $val => $name) {
752 752
 					$selected = '';
753
-					if(is_array($name)){
753
+					if (is_array($name)) {
754 754
 						if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
755 755
 							$option_label = isset($name['label']) ? $name['label'] : '';
756 756
 
@@ -758,23 +758,23 @@  discard block
 block discarded – undo
758 758
 						} else {
759 759
 							$option_label = isset($name['label']) ? $name['label'] : '';
760 760
 							$option_value = isset($name['value']) ? $name['value'] : '';
761
-							if(!empty($args['multiple']) && !empty($args['value'])){
761
+							if (!empty($args['multiple']) && !empty($args['value'])) {
762 762
 								$selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
763
-							} elseif(!empty($args['value'])) {
764
-								$selected = selected($option_value,stripslashes_deep($args['value']), false);
763
+							} elseif (!empty($args['value'])) {
764
+								$selected = selected($option_value, stripslashes_deep($args['value']), false);
765 765
 							}
766 766
 
767 767
 							$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
768 768
 						}
769
-					}else{
770
-						if(!empty($args['value'])){
771
-							if(is_array($args['value'])){
772
-								$selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
773
-							} elseif(!empty($args['value'])) {
774
-								$selected = selected( $args['value'], $val, false);
769
+					} else {
770
+						if (!empty($args['value'])) {
771
+							if (is_array($args['value'])) {
772
+								$selected = in_array($val, $args['value']) ? 'selected="selected"' : '';
773
+							} elseif (!empty($args['value'])) {
774
+								$selected = selected($args['value'], $val, false);
775 775
 							}
776 776
 						}
777
-						$output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>';
777
+						$output .= '<option value="' . esc_attr($val) . '" ' . $selected . '>' . esc_attr($name) . '</option>';
778 778
 					}
779 779
 				}
780 780
 			}
@@ -784,30 +784,30 @@  discard block
 block discarded – undo
784 784
 		// closing tag
785 785
 		$output .= '</select>';
786 786
 
787
-		if(!empty($args['label']) && $label_after){
787
+		if (!empty($args['label']) && $label_after) {
788 788
 			$label_args = array(
789 789
 				'title'=> $args['label'],
790 790
 				'for'=> $args['id'],
791
-				'class' => $args['label_class']." ",
791
+				'class' => $args['label_class'] . " ",
792 792
 				'label_type' => $args['label_type']
793 793
 			);
794 794
 			$output .= self::label($label_args);
795 795
 		}
796 796
 
797 797
 		// help text
798
-		if(!empty($args['help_text'])){
798
+		if (!empty($args['help_text'])) {
799 799
 			$output .= AUI_Component_Helper::help_text($args['help_text']);
800 800
 		}
801 801
 
802 802
 		// maybe horizontal label
803
-		if($args['label_type']=='horizontal'){
803
+		if ($args['label_type'] == 'horizontal') {
804 804
 			$output .= '</div>';
805 805
 		}
806 806
 
807 807
 
808 808
 		// wrap
809
-		if(!$args['no_wrap']){
810
-			$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
809
+		if (!$args['no_wrap']) {
810
+			$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
811 811
 			$output = self::wrap(array(
812 812
 				'content' => $output,
813 813
 				'class'   => $wrap_class,
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 	 *
828 828
 	 * @return string The rendered component.
829 829
 	 */
830
-	public static function radio($args = array()){
830
+	public static function radio($args = array()) {
831 831
 		$defaults = array(
832 832
 			'class'      => '',
833 833
 			'id'         => '',
@@ -849,14 +849,14 @@  discard block
 block discarded – undo
849 849
 		/**
850 850
 		 * Parse incoming $args into an array and merge it with $defaults
851 851
 		 */
852
-		$args   = wp_parse_args( $args, $defaults );
852
+		$args = wp_parse_args($args, $defaults);
853 853
 
854 854
 		// for now lets use horizontal for floating
855
-		if( $args['label_type'] != 'hidden' ){$args['label_type'] = 'horizontal';}
855
+		if ($args['label_type'] != 'hidden') {$args['label_type'] = 'horizontal'; }
856 856
 
857 857
 		$label_args = array(
858 858
 			'title'=> $args['label'],
859
-			'class' => $args['label_class']." pt-0 ",
859
+			'class' => $args['label_class'] . " pt-0 ",
860 860
 			'label_type' => $args['label_type']
861 861
 		);
862 862
 
@@ -865,35 +865,35 @@  discard block
 block discarded – undo
865 865
 
866 866
 
867 867
 		// label before
868
-		if(!empty($args['label'])){
869
-			$output .= self::label( $label_args, 'radio' );
868
+		if (!empty($args['label'])) {
869
+			$output .= self::label($label_args, 'radio');
870 870
 		}
871 871
 
872 872
 		// maybe horizontal label
873
-		if($args['label_type']=='horizontal'){
873
+		if ($args['label_type'] == 'horizontal') {
874 874
 			$output .= '<div class="col-sm-10">';
875 875
 		}
876 876
 
877
-		if(!empty($args['options'])){
877
+		if (!empty($args['options'])) {
878 878
 			$count = 0;
879
-			foreach($args['options'] as $value => $label){
879
+			foreach ($args['options'] as $value => $label) {
880 880
 				$option_args = $args;
881 881
 				$option_args['value'] = $value;
882 882
 				$option_args['label'] = $label;
883 883
 				$option_args['checked'] = $value == $args['value'] ? true : false;
884
-				$output .= self::radio_option($option_args,$count);
884
+				$output .= self::radio_option($option_args, $count);
885 885
 				$count++;
886 886
 			}
887 887
 		}
888 888
 
889 889
 		// maybe horizontal label
890
-		if($args['label_type']=='horizontal'){
890
+		if ($args['label_type'] == 'horizontal') {
891 891
 			$output .= '</div>';
892 892
 		}
893 893
 
894 894
 
895 895
 		// wrap
896
-		$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
896
+		$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
897 897
 		$output = self::wrap(array(
898 898
 			'content' => $output,
899 899
 			'class'   => $wrap_class,
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 	 *
913 913
 	 * @return string The rendered component.
914 914
 	 */
915
-	public static function radio_option($args = array(),$count = ''){
915
+	public static function radio_option($args = array(), $count = '') {
916 916
 		$defaults = array(
917 917
 			'class'      => '',
918 918
 			'id'         => '',
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 		/**
931 931
 		 * Parse incoming $args into an array and merge it with $defaults
932 932
 		 */
933
-		$args   = wp_parse_args( $args, $defaults );
933
+		$args   = wp_parse_args($args, $defaults);
934 934
 
935 935
 		$output = '';
936 936
 
@@ -941,27 +941,27 @@  discard block
 block discarded – undo
941 941
 		$output .= ' class="form-check-input" ';
942 942
 
943 943
 		// name
944
-		if(!empty($args['name'])){
944
+		if (!empty($args['name'])) {
945 945
 			$output .= AUI_Component_Helper::name($args['name']);
946 946
 		}
947 947
 
948 948
 		// id
949
-		if(!empty($args['id'])){
950
-			$output .= AUI_Component_Helper::id($args['id'].$count);
949
+		if (!empty($args['id'])) {
950
+			$output .= AUI_Component_Helper::id($args['id'] . $count);
951 951
 		}
952 952
 
953 953
 		// title
954
-		if(!empty($args['title'])){
954
+		if (!empty($args['title'])) {
955 955
 			$output .= AUI_Component_Helper::title($args['title']);
956 956
 		}
957 957
 
958 958
 		// value
959
-		if(isset($args['value'])){
960
-			$output .= ' value="'.sanitize_text_field($args['value']).'" ';
959
+		if (isset($args['value'])) {
960
+			$output .= ' value="' . sanitize_text_field($args['value']) . '" ';
961 961
 		}
962 962
 
963 963
 		// checked, for radio and checkboxes
964
-		if( $args['checked'] ){
964
+		if ($args['checked']) {
965 965
 			$output .= ' checked ';
966 966
 		}
967 967
 
@@ -972,12 +972,12 @@  discard block
 block discarded – undo
972 972
 		$output .= AUI_Component_Helper::aria_attributes($args);
973 973
 
974 974
 		// extra attributes
975
-		if(!empty($args['extra_attributes'])){
975
+		if (!empty($args['extra_attributes'])) {
976 976
 			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
977 977
 		}
978 978
 
979 979
 		// required
980
-		if(!empty($args['required'])){
980
+		if (!empty($args['required'])) {
981 981
 			$output .= ' required ';
982 982
 		}
983 983
 
@@ -985,13 +985,13 @@  discard block
 block discarded – undo
985 985
 		$output .= ' >';
986 986
 
987 987
 		// label
988
-		if(!empty($args['label']) && is_array($args['label'])){
989
-		}elseif(!empty($args['label'])){
990
-			$output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
988
+		if (!empty($args['label']) && is_array($args['label'])) {
989
+		}elseif (!empty($args['label'])) {
990
+			$output .= self::label(array('title'=>$args['label'], 'for'=>$args['id'] . $count, 'class'=>'form-check-label'), 'radio');
991 991
 		}
992 992
 
993 993
 		// wrap
994
-		if(!$args['no_wrap']){
994
+		if (!$args['no_wrap']) {
995 995
 			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
996 996
 			$output = self::wrap(array(
997 997
 				'content' => $output,
Please login to merge, or discard this patch.
Braces   +15 added lines, -16 removed lines patch added patch discarded remove patch
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
 			if($type=='file' ){
80 80
 				$label_after = true; // if type file we need the label after
81 81
 				$args['class'] .= ' custom-file-input ';
82
-			}elseif($type=='checkbox'){
82
+			} elseif($type=='checkbox'){
83 83
 				$label_after = true; // if type file we need the label after
84 84
 				$args['class'] .= ' custom-control-input ';
85
-			}elseif($type=='datepicker' || $type=='timepicker'){
85
+			} elseif($type=='datepicker' || $type=='timepicker'){
86 86
 				$type = 'text';
87 87
 				//$args['class'] .= ' aui-flatpickr bg-initial ';
88 88
 				$args['class'] .= ' bg-initial ';
@@ -166,8 +166,7 @@  discard block
 block discarded – undo
166 166
 
167 167
 			// label
168 168
 			if(!empty($args['label'])){
169
-				if($type == 'file'){$label_args['class'] .= 'custom-file-label';}
170
-				elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
169
+				if($type == 'file'){$label_args['class'] .= 'custom-file-label';} elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
171 170
 				$label = self::label( $label_args, $type );
172 171
 			}
173 172
 
@@ -188,7 +187,7 @@  discard block
 block discarded – undo
188 187
 					'content' => $output,
189 188
 					'class'   => 'form-group custom-file'
190 189
 				) );
191
-			}elseif($type == 'checkbox'){
190
+			} elseif($type == 'checkbox'){
192 191
 				$wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
193 192
 				$output = self::wrap( array(
194 193
 					'content' => $output,
@@ -198,7 +197,7 @@  discard block
 block discarded – undo
198 197
 				if($args['label_type']=='horizontal'){
199 198
 					$output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
200 199
 				}
201
-			}elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
200
+			} elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
202 201
 
203 202
 
204 203
 				// allow password field to toggle view
@@ -322,7 +321,7 @@  discard block
 block discarded – undo
322 321
 
323 322
 		// label
324 323
 		if(!empty($args['label']) && is_array($args['label'])){
325
-		}elseif(!empty($args['label']) && !$label_after){
324
+		} elseif(!empty($args['label']) && !$label_after){
326 325
 			$label_args = array(
327 326
 				'title'=> $args['label'],
328 327
 				'for'=> $args['id'],
@@ -357,7 +356,7 @@  discard block
 block discarded – undo
357 356
 
358 357
 			wp_editor( $content, $editor_id, $settings );
359 358
 			$output .= ob_get_clean();
360
-		}else{
359
+		} else{
361 360
 
362 361
 			// open
363 362
 			$output .= '<textarea ';
@@ -479,7 +478,7 @@  discard block
 block discarded – undo
479 478
 			// maybe hide labels //@todo set a global option for visibility class
480 479
 			if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
481 480
 				$class = $args['class'];
482
-			}else{
481
+			} else{
483 482
 				$class = 'sr-only '.$args['class'];
484 483
 			}
485 484
 
@@ -582,7 +581,7 @@  discard block
 block discarded – undo
582 581
 			$output .= '</'.sanitize_html_class($args['type']).'>';
583 582
 
584 583
 
585
-		}else{
584
+		} else{
586 585
 			$output = $args['content'];
587 586
 		}
588 587
 
@@ -644,7 +643,7 @@  discard block
 block discarded – undo
644 643
 		if(!empty($args['select2'])){
645 644
 			$args['class'] .= ' aui-select2';
646 645
 			$is_select2 = true;
647
-		}elseif( strpos($args['class'], 'aui-select2') !== false){
646
+		} elseif( strpos($args['class'], 'aui-select2') !== false){
648 647
 			$is_select2 = true;
649 648
 		}
650 649
 
@@ -663,7 +662,7 @@  discard block
 block discarded – undo
663 662
 
664 663
 		// label
665 664
 		if(!empty($args['label']) && is_array($args['label'])){
666
-		}elseif(!empty($args['label']) && !$label_after){
665
+		} elseif(!empty($args['label']) && !$label_after){
667 666
 			$label_args = array(
668 667
 				'title'=> $args['label'],
669 668
 				'for'=> $args['id'],
@@ -738,7 +737,7 @@  discard block
 block discarded – undo
738 737
 		// placeholder
739 738
 		if(!empty($args['placeholder']) && !$is_select2){
740 739
 			$output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
741
-		}elseif($is_select2 && !empty($args['placeholder'])){
740
+		} elseif($is_select2 && !empty($args['placeholder'])){
742 741
 			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
743 742
 		}
744 743
 
@@ -747,7 +746,7 @@  discard block
 block discarded – undo
747 746
 
748 747
 			if(!is_array($args['options'])){
749 748
 				$output .= $args['options']; // not the preferred way but an option
750
-			}else{
749
+			} else{
751 750
 				foreach($args['options'] as $val => $name){
752 751
 					$selected = '';
753 752
 					if(is_array($name)){
@@ -766,7 +765,7 @@  discard block
 block discarded – undo
766 765
 
767 766
 							$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
768 767
 						}
769
-					}else{
768
+					} else{
770 769
 						if(!empty($args['value'])){
771 770
 							if(is_array($args['value'])){
772 771
 								$selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
@@ -986,7 +985,7 @@  discard block
 block discarded – undo
986 985
 
987 986
 		// label
988 987
 		if(!empty($args['label']) && is_array($args['label'])){
989
-		}elseif(!empty($args['label'])){
988
+		} elseif(!empty($args['label'])){
990 989
 			$output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
991 990
 		}
992 991
 
Please login to merge, or discard this patch.
wp-ayecode-ui/includes/components/class-aui-component-pagination.php 2 patches
Indentation   +73 added lines, -73 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,77 +11,77 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Pagination {
13 13
 
14
-	/**
15
-	 * Build the component.
16
-	 *
17
-	 * @param array $args
18
-	 *
19
-	 * @return string The rendered component.
20
-	 */
21
-	public static function get( $args = array() ) {
22
-		global $wp_query;
23
-
24
-		$defaults = array(
25
-			'class'              => '',
26
-			'mid_size'           => 2,
27
-			'prev_text'          => '<i class="fas fa-chevron-left"></i>',
28
-			'next_text'          => '<i class="fas fa-chevron-right"></i>',
29
-			'screen_reader_text' => __( 'Posts navigation' ),
30
-			'before_paging' => '',
31
-			'after_paging'  => '',
32
-			'type'               => 'array',
33
-			'total'              => isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1,
34
-			'links'              => array() // an array of links if using custom links, this includes the a tag.
35
-		);
36
-
37
-		/**
38
-		 * Parse incoming $args into an array and merge it with $defaults
39
-		 */
40
-		$args = wp_parse_args( $args, $defaults );
41
-
42
-		$output = '';
43
-
44
-		// Don't print empty markup if there's only one page.
45
-		if ( $args['total'] > 1 ) {
46
-
47
-			// Set up paginated links.
48
-			$links = !empty(  $args['links'] ) ? $args['links'] :  paginate_links( $args );
49
-
50
-			$class = !empty($args['class']) ? $args['class'] : '';
51
-
52
-			// make the output bootstrap ready
53
-			$links_html = "<ul class='pagination m-0 p-0 $class'>";
54
-			if ( ! empty( $links ) ) {
55
-				foreach ( $links as $link ) {
56
-					$active = strpos( $link, 'current' ) !== false ? 'active' : '';
57
-					$links_html .= "<li class='page-item $active'>";
58
-					$links_html .= str_replace( "page-numbers", "page-link", $link );
59
-					$links_html .= "</li>";
60
-				}
61
-			}
62
-			$links_html .= "</ul>";
63
-
64
-			if ( $links ) {
65
-				$output .= '<section class="px-0 py-2 w-100">';
66
-				$output .= _navigation_markup( $links_html, 'aui-pagination', $args['screen_reader_text'] );
67
-				$output .= '</section>';
68
-			}
69
-
70
-			$output = str_replace( "screen-reader-text", "screen-reader-text sr-only", $output );
71
-			$output = str_replace( "nav-links", "aui-nav-links", $output );
72
-		}
73
-
74
-		if ( $output ) {
75
-			if ( ! empty( $args['before_paging'] ) ) {
76
-				$output = $args['before_paging'] . $output;
77
-			}
78
-
79
-			if ( ! empty( $args['after_paging'] ) ) {
80
-				$output = $output . $args['after_paging'];
81
-			}
82
-		}
83
-
84
-		return $output;
85
-	}
14
+    /**
15
+     * Build the component.
16
+     *
17
+     * @param array $args
18
+     *
19
+     * @return string The rendered component.
20
+     */
21
+    public static function get( $args = array() ) {
22
+        global $wp_query;
23
+
24
+        $defaults = array(
25
+            'class'              => '',
26
+            'mid_size'           => 2,
27
+            'prev_text'          => '<i class="fas fa-chevron-left"></i>',
28
+            'next_text'          => '<i class="fas fa-chevron-right"></i>',
29
+            'screen_reader_text' => __( 'Posts navigation' ),
30
+            'before_paging' => '',
31
+            'after_paging'  => '',
32
+            'type'               => 'array',
33
+            'total'              => isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1,
34
+            'links'              => array() // an array of links if using custom links, this includes the a tag.
35
+        );
36
+
37
+        /**
38
+         * Parse incoming $args into an array and merge it with $defaults
39
+         */
40
+        $args = wp_parse_args( $args, $defaults );
41
+
42
+        $output = '';
43
+
44
+        // Don't print empty markup if there's only one page.
45
+        if ( $args['total'] > 1 ) {
46
+
47
+            // Set up paginated links.
48
+            $links = !empty(  $args['links'] ) ? $args['links'] :  paginate_links( $args );
49
+
50
+            $class = !empty($args['class']) ? $args['class'] : '';
51
+
52
+            // make the output bootstrap ready
53
+            $links_html = "<ul class='pagination m-0 p-0 $class'>";
54
+            if ( ! empty( $links ) ) {
55
+                foreach ( $links as $link ) {
56
+                    $active = strpos( $link, 'current' ) !== false ? 'active' : '';
57
+                    $links_html .= "<li class='page-item $active'>";
58
+                    $links_html .= str_replace( "page-numbers", "page-link", $link );
59
+                    $links_html .= "</li>";
60
+                }
61
+            }
62
+            $links_html .= "</ul>";
63
+
64
+            if ( $links ) {
65
+                $output .= '<section class="px-0 py-2 w-100">';
66
+                $output .= _navigation_markup( $links_html, 'aui-pagination', $args['screen_reader_text'] );
67
+                $output .= '</section>';
68
+            }
69
+
70
+            $output = str_replace( "screen-reader-text", "screen-reader-text sr-only", $output );
71
+            $output = str_replace( "nav-links", "aui-nav-links", $output );
72
+        }
73
+
74
+        if ( $output ) {
75
+            if ( ! empty( $args['before_paging'] ) ) {
76
+                $output = $args['before_paging'] . $output;
77
+            }
78
+
79
+            if ( ! empty( $args['after_paging'] ) ) {
80
+                $output = $output . $args['after_paging'];
81
+            }
82
+        }
83
+
84
+        return $output;
85
+    }
86 86
 
87 87
 }
88 88
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 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 get( $args = array() ) {
21
+	public static function get($args = array()) {
22 22
 		global $wp_query;
23 23
 
24 24
 		$defaults = array(
@@ -26,57 +26,57 @@  discard block
 block discarded – undo
26 26
 			'mid_size'           => 2,
27 27
 			'prev_text'          => '<i class="fas fa-chevron-left"></i>',
28 28
 			'next_text'          => '<i class="fas fa-chevron-right"></i>',
29
-			'screen_reader_text' => __( 'Posts navigation' ),
29
+			'screen_reader_text' => __('Posts navigation'),
30 30
 			'before_paging' => '',
31 31
 			'after_paging'  => '',
32 32
 			'type'               => 'array',
33
-			'total'              => isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1,
33
+			'total'              => isset($wp_query->max_num_pages) ? $wp_query->max_num_pages : 1,
34 34
 			'links'              => array() // an array of links if using custom links, this includes the a tag.
35 35
 		);
36 36
 
37 37
 		/**
38 38
 		 * Parse incoming $args into an array and merge it with $defaults
39 39
 		 */
40
-		$args = wp_parse_args( $args, $defaults );
40
+		$args = wp_parse_args($args, $defaults);
41 41
 
42 42
 		$output = '';
43 43
 
44 44
 		// Don't print empty markup if there's only one page.
45
-		if ( $args['total'] > 1 ) {
45
+		if ($args['total'] > 1) {
46 46
 
47 47
 			// Set up paginated links.
48
-			$links = !empty(  $args['links'] ) ? $args['links'] :  paginate_links( $args );
48
+			$links = !empty($args['links']) ? $args['links'] : paginate_links($args);
49 49
 
50 50
 			$class = !empty($args['class']) ? $args['class'] : '';
51 51
 
52 52
 			// make the output bootstrap ready
53 53
 			$links_html = "<ul class='pagination m-0 p-0 $class'>";
54
-			if ( ! empty( $links ) ) {
55
-				foreach ( $links as $link ) {
56
-					$active = strpos( $link, 'current' ) !== false ? 'active' : '';
54
+			if (!empty($links)) {
55
+				foreach ($links as $link) {
56
+					$active = strpos($link, 'current') !== false ? 'active' : '';
57 57
 					$links_html .= "<li class='page-item $active'>";
58
-					$links_html .= str_replace( "page-numbers", "page-link", $link );
58
+					$links_html .= str_replace("page-numbers", "page-link", $link);
59 59
 					$links_html .= "</li>";
60 60
 				}
61 61
 			}
62 62
 			$links_html .= "</ul>";
63 63
 
64
-			if ( $links ) {
64
+			if ($links) {
65 65
 				$output .= '<section class="px-0 py-2 w-100">';
66
-				$output .= _navigation_markup( $links_html, 'aui-pagination', $args['screen_reader_text'] );
66
+				$output .= _navigation_markup($links_html, 'aui-pagination', $args['screen_reader_text']);
67 67
 				$output .= '</section>';
68 68
 			}
69 69
 
70
-			$output = str_replace( "screen-reader-text", "screen-reader-text sr-only", $output );
71
-			$output = str_replace( "nav-links", "aui-nav-links", $output );
70
+			$output = str_replace("screen-reader-text", "screen-reader-text sr-only", $output);
71
+			$output = str_replace("nav-links", "aui-nav-links", $output);
72 72
 		}
73 73
 
74
-		if ( $output ) {
75
-			if ( ! empty( $args['before_paging'] ) ) {
74
+		if ($output) {
75
+			if (!empty($args['before_paging'])) {
76 76
 				$output = $args['before_paging'] . $output;
77 77
 			}
78 78
 
79
-			if ( ! empty( $args['after_paging'] ) ) {
79
+			if (!empty($args['after_paging'])) {
80 80
 				$output = $output . $args['after_paging'];
81 81
 			}
82 82
 		}
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-helper.php 3 patches
Indentation   +245 added lines, -245 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,249 +11,249 @@  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
-	 *
19
-	 * @return string
20
-	 */
21
-	public static function name($text,$multiple = false){
22
-		$output = '';
23
-
24
-		if($text){
25
-			$is_multiple = strpos($text, '[]') !== false ? '[]' : '';
26
-			$output = ' name="'.sanitize_html_class($text).$is_multiple.'" ';
27
-		}
28
-
29
-		return $output;
30
-	}
31
-
32
-	/**
33
-	 * A component helper for generating a item id.
34
-	 *
35
-	 * @param $text string The text to be used as the value.
36
-	 *
37
-	 * @return string The sanitized item.
38
-	 */
39
-	public static function id($text){
40
-		$output = '';
41
-
42
-		if($text){
43
-			$output = ' id="'.sanitize_html_class($text).'" ';
44
-		}
45
-
46
-		return $output;
47
-	}
48
-
49
-	/**
50
-	 * A component helper for generating a item title.
51
-	 *
52
-	 * @param $text string The text to be used as the value.
53
-	 *
54
-	 * @return string The sanitized item.
55
-	 */
56
-	public static function title($text){
57
-		$output = '';
58
-
59
-		if($text){
60
-			$output = ' title="'.esc_attr($text).'" ';
61
-		}
62
-
63
-		return $output;
64
-	}
65
-
66
-	/**
67
-	 * A component helper for generating a item value.
68
-	 *
69
-	 * @param $text string The text to be used as the value.
70
-	 *
71
-	 * @return string The sanitized item.
72
-	 */
73
-	public static function value($text){
74
-		$output = '';
75
-
76
-		if($text){
77
-			$output = ' value="'.sanitize_text_field($text).'" ';
78
-		}
79
-
80
-		return $output;
81
-	}
82
-
83
-	/**
84
-	 * A component helper for generating a item class attribute.
85
-	 *
86
-	 * @param $text string The text to be used as the value.
87
-	 *
88
-	 * @return string The sanitized item.
89
-	 */
90
-	public static function class_attr($text){
91
-		$output = '';
92
-
93
-		if($text){
94
-			$classes = self::esc_classes($text);
95
-			if(!empty($classes)){
96
-				$output = ' class="'.$classes.'" ';
97
-			}
98
-		}
99
-
100
-		return $output;
101
-	}
102
-
103
-	/**
104
-	 * Escape a string of classes.
105
-	 *
106
-	 * @param $text
107
-	 *
108
-	 * @return string
109
-	 */
110
-	public static function esc_classes($text){
111
-		$output = '';
112
-
113
-		if($text){
114
-			$classes = explode(" ",$text);
115
-			$classes = array_map("trim",$classes);
116
-			$classes = array_map("sanitize_html_class",$classes);
117
-			if(!empty($classes)){
118
-				$output = implode(" ",$classes);
119
-			}
120
-		}
121
-
122
-		return $output;
123
-
124
-	}
125
-
126
-	/**
127
-	 * @param $args
128
-	 *
129
-	 * @return string
130
-	 */
131
-	public static function data_attributes($args){
132
-		$output = '';
133
-
134
-		if(!empty($args)){
135
-
136
-			foreach($args as $key => $val){
137
-				if(substr( $key, 0, 5 ) === "data-"){
138
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
139
-				}
140
-			}
141
-		}
142
-
143
-		return $output;
144
-	}
145
-
146
-	/**
147
-	 * @param $args
148
-	 *
149
-	 * @return string
150
-	 */
151
-	public static function aria_attributes($args){
152
-		$output = '';
153
-
154
-		if(!empty($args)){
155
-
156
-			foreach($args as $key => $val){
157
-				if(substr( $key, 0, 5 ) === "aria-"){
158
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
159
-				}
160
-			}
161
-		}
162
-
163
-		return $output;
164
-	}
165
-
166
-	/**
167
-	 * Build a font awesome icon from a class.
168
-	 *
169
-	 * @param $class
170
-	 * @param bool $space_after
171
-	 * @param array $extra_attributes An array of extra attributes.
172
-	 *
173
-	 * @return string
174
-	 */
175
-	public static function icon($class,$space_after = false, $extra_attributes = array()){
176
-		$output = '';
177
-
178
-		if($class){
179
-			$classes = self::esc_classes($class);
180
-			if(!empty($classes)){
181
-				$output = '<i class="'.$classes.'" ';
182
-				// extra attributes
183
-				if(!empty($extra_attributes)){
184
-					$output .= AUI_Component_Helper::extra_attributes($extra_attributes);
185
-				}
186
-				$output .= '></i>';
187
-				if($space_after){
188
-					$output .= " ";
189
-				}
190
-			}
191
-		}
192
-
193
-		return $output;
194
-	}
195
-
196
-	/**
197
-	 * @param $args
198
-	 *
199
-	 * @return string
200
-	 */
201
-	public static function extra_attributes($args){
202
-		$output = '';
203
-
204
-		if(!empty($args)){
205
-
206
-			if( is_array($args) ){
207
-				foreach($args as $key => $val){
208
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
209
-				}
210
-			}else{
211
-				$output .= ' '.$args.' ';
212
-			}
213
-
214
-		}
215
-
216
-		return $output;
217
-	}
218
-
219
-	/**
220
-	 * @param $args
221
-	 *
222
-	 * @return string
223
-	 */
224
-	public static function help_text($text){
225
-		$output = '';
226
-
227
-		if($text){
228
-			$output .= '<small class="form-text text-muted">'.wp_kses_post($text).'</small>';
229
-		}
230
-
231
-
232
-		return $output;
233
-	}
234
-
235
-	/**
236
-	 * Replace element require context with JS.
237
-	 *
238
-	 * @param $input
239
-	 *
240
-	 * @return string|void
241
-	 */
242
-	public static function element_require( $input ) {
243
-
244
-		$input = str_replace( "'", '"', $input );// we only want double quotes
245
-
246
-		$output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
247
-			"jQuery(form).find('[data-argument=\"",
248
-			"\"]').find('input,select,textarea').val()",
249
-			"\"]').find('input:checked').val()",
250
-		), $input ) );
251
-
252
-		if($output){
253
-			$output = ' data-element-require="'.$output.'" ';
254
-		}
255
-
256
-		return $output;
257
-	}
14
+    /**
15
+     * A component helper for generating a input name.
16
+     *
17
+     * @param $text
18
+     *
19
+     * @return string
20
+     */
21
+    public static function name($text,$multiple = false){
22
+        $output = '';
23
+
24
+        if($text){
25
+            $is_multiple = strpos($text, '[]') !== false ? '[]' : '';
26
+            $output = ' name="'.sanitize_html_class($text).$is_multiple.'" ';
27
+        }
28
+
29
+        return $output;
30
+    }
31
+
32
+    /**
33
+     * A component helper for generating a item id.
34
+     *
35
+     * @param $text string The text to be used as the value.
36
+     *
37
+     * @return string The sanitized item.
38
+     */
39
+    public static function id($text){
40
+        $output = '';
41
+
42
+        if($text){
43
+            $output = ' id="'.sanitize_html_class($text).'" ';
44
+        }
45
+
46
+        return $output;
47
+    }
48
+
49
+    /**
50
+     * A component helper for generating a item title.
51
+     *
52
+     * @param $text string The text to be used as the value.
53
+     *
54
+     * @return string The sanitized item.
55
+     */
56
+    public static function title($text){
57
+        $output = '';
58
+
59
+        if($text){
60
+            $output = ' title="'.esc_attr($text).'" ';
61
+        }
62
+
63
+        return $output;
64
+    }
65
+
66
+    /**
67
+     * A component helper for generating a item value.
68
+     *
69
+     * @param $text string The text to be used as the value.
70
+     *
71
+     * @return string The sanitized item.
72
+     */
73
+    public static function value($text){
74
+        $output = '';
75
+
76
+        if($text){
77
+            $output = ' value="'.sanitize_text_field($text).'" ';
78
+        }
79
+
80
+        return $output;
81
+    }
82
+
83
+    /**
84
+     * A component helper for generating a item class attribute.
85
+     *
86
+     * @param $text string The text to be used as the value.
87
+     *
88
+     * @return string The sanitized item.
89
+     */
90
+    public static function class_attr($text){
91
+        $output = '';
92
+
93
+        if($text){
94
+            $classes = self::esc_classes($text);
95
+            if(!empty($classes)){
96
+                $output = ' class="'.$classes.'" ';
97
+            }
98
+        }
99
+
100
+        return $output;
101
+    }
102
+
103
+    /**
104
+     * Escape a string of classes.
105
+     *
106
+     * @param $text
107
+     *
108
+     * @return string
109
+     */
110
+    public static function esc_classes($text){
111
+        $output = '';
112
+
113
+        if($text){
114
+            $classes = explode(" ",$text);
115
+            $classes = array_map("trim",$classes);
116
+            $classes = array_map("sanitize_html_class",$classes);
117
+            if(!empty($classes)){
118
+                $output = implode(" ",$classes);
119
+            }
120
+        }
121
+
122
+        return $output;
123
+
124
+    }
125
+
126
+    /**
127
+     * @param $args
128
+     *
129
+     * @return string
130
+     */
131
+    public static function data_attributes($args){
132
+        $output = '';
133
+
134
+        if(!empty($args)){
135
+
136
+            foreach($args as $key => $val){
137
+                if(substr( $key, 0, 5 ) === "data-"){
138
+                    $output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
139
+                }
140
+            }
141
+        }
142
+
143
+        return $output;
144
+    }
145
+
146
+    /**
147
+     * @param $args
148
+     *
149
+     * @return string
150
+     */
151
+    public static function aria_attributes($args){
152
+        $output = '';
153
+
154
+        if(!empty($args)){
155
+
156
+            foreach($args as $key => $val){
157
+                if(substr( $key, 0, 5 ) === "aria-"){
158
+                    $output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
159
+                }
160
+            }
161
+        }
162
+
163
+        return $output;
164
+    }
165
+
166
+    /**
167
+     * Build a font awesome icon from a class.
168
+     *
169
+     * @param $class
170
+     * @param bool $space_after
171
+     * @param array $extra_attributes An array of extra attributes.
172
+     *
173
+     * @return string
174
+     */
175
+    public static function icon($class,$space_after = false, $extra_attributes = array()){
176
+        $output = '';
177
+
178
+        if($class){
179
+            $classes = self::esc_classes($class);
180
+            if(!empty($classes)){
181
+                $output = '<i class="'.$classes.'" ';
182
+                // extra attributes
183
+                if(!empty($extra_attributes)){
184
+                    $output .= AUI_Component_Helper::extra_attributes($extra_attributes);
185
+                }
186
+                $output .= '></i>';
187
+                if($space_after){
188
+                    $output .= " ";
189
+                }
190
+            }
191
+        }
192
+
193
+        return $output;
194
+    }
195
+
196
+    /**
197
+     * @param $args
198
+     *
199
+     * @return string
200
+     */
201
+    public static function extra_attributes($args){
202
+        $output = '';
203
+
204
+        if(!empty($args)){
205
+
206
+            if( is_array($args) ){
207
+                foreach($args as $key => $val){
208
+                    $output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
209
+                }
210
+            }else{
211
+                $output .= ' '.$args.' ';
212
+            }
213
+
214
+        }
215
+
216
+        return $output;
217
+    }
218
+
219
+    /**
220
+     * @param $args
221
+     *
222
+     * @return string
223
+     */
224
+    public static function help_text($text){
225
+        $output = '';
226
+
227
+        if($text){
228
+            $output .= '<small class="form-text text-muted">'.wp_kses_post($text).'</small>';
229
+        }
230
+
231
+
232
+        return $output;
233
+    }
234
+
235
+    /**
236
+     * Replace element require context with JS.
237
+     *
238
+     * @param $input
239
+     *
240
+     * @return string|void
241
+     */
242
+    public static function element_require( $input ) {
243
+
244
+        $input = str_replace( "'", '"', $input );// we only want double quotes
245
+
246
+        $output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
247
+            "jQuery(form).find('[data-argument=\"",
248
+            "\"]').find('input,select,textarea').val()",
249
+            "\"]').find('input:checked').val()",
250
+        ), $input ) );
251
+
252
+        if($output){
253
+            $output = ' data-element-require="'.$output.'" ';
254
+        }
255
+
256
+        return $output;
257
+    }
258 258
 
259 259
 }
260 260
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 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,12 +18,12 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return string
20 20
 	 */
21
-	public static function name($text,$multiple = false){
21
+	public static function name($text, $multiple = false) {
22 22
 		$output = '';
23 23
 
24
-		if($text){
24
+		if ($text) {
25 25
 			$is_multiple = strpos($text, '[]') !== false ? '[]' : '';
26
-			$output = ' name="'.sanitize_html_class($text).$is_multiple.'" ';
26
+			$output = ' name="' . sanitize_html_class($text) . $is_multiple . '" ';
27 27
 		}
28 28
 
29 29
 		return $output;
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @return string The sanitized item.
38 38
 	 */
39
-	public static function id($text){
39
+	public static function id($text) {
40 40
 		$output = '';
41 41
 
42
-		if($text){
43
-			$output = ' id="'.sanitize_html_class($text).'" ';
42
+		if ($text) {
43
+			$output = ' id="' . sanitize_html_class($text) . '" ';
44 44
 		}
45 45
 
46 46
 		return $output;
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @return string The sanitized item.
55 55
 	 */
56
-	public static function title($text){
56
+	public static function title($text) {
57 57
 		$output = '';
58 58
 
59
-		if($text){
60
-			$output = ' title="'.esc_attr($text).'" ';
59
+		if ($text) {
60
+			$output = ' title="' . esc_attr($text) . '" ';
61 61
 		}
62 62
 
63 63
 		return $output;
@@ -70,11 +70,11 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @return string The sanitized item.
72 72
 	 */
73
-	public static function value($text){
73
+	public static function value($text) {
74 74
 		$output = '';
75 75
 
76
-		if($text){
77
-			$output = ' value="'.sanitize_text_field($text).'" ';
76
+		if ($text) {
77
+			$output = ' value="' . sanitize_text_field($text) . '" ';
78 78
 		}
79 79
 
80 80
 		return $output;
@@ -87,13 +87,13 @@  discard block
 block discarded – undo
87 87
 	 *
88 88
 	 * @return string The sanitized item.
89 89
 	 */
90
-	public static function class_attr($text){
90
+	public static function class_attr($text) {
91 91
 		$output = '';
92 92
 
93
-		if($text){
93
+		if ($text) {
94 94
 			$classes = self::esc_classes($text);
95
-			if(!empty($classes)){
96
-				$output = ' class="'.$classes.'" ';
95
+			if (!empty($classes)) {
96
+				$output = ' class="' . $classes . '" ';
97 97
 			}
98 98
 		}
99 99
 
@@ -107,15 +107,15 @@  discard block
 block discarded – undo
107 107
 	 *
108 108
 	 * @return string
109 109
 	 */
110
-	public static function esc_classes($text){
110
+	public static function esc_classes($text) {
111 111
 		$output = '';
112 112
 
113
-		if($text){
114
-			$classes = explode(" ",$text);
115
-			$classes = array_map("trim",$classes);
116
-			$classes = array_map("sanitize_html_class",$classes);
117
-			if(!empty($classes)){
118
-				$output = implode(" ",$classes);
113
+		if ($text) {
114
+			$classes = explode(" ", $text);
115
+			$classes = array_map("trim", $classes);
116
+			$classes = array_map("sanitize_html_class", $classes);
117
+			if (!empty($classes)) {
118
+				$output = implode(" ", $classes);
119 119
 			}
120 120
 		}
121 121
 
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
 	 *
129 129
 	 * @return string
130 130
 	 */
131
-	public static function data_attributes($args){
131
+	public static function data_attributes($args) {
132 132
 		$output = '';
133 133
 
134
-		if(!empty($args)){
134
+		if (!empty($args)) {
135 135
 
136
-			foreach($args as $key => $val){
137
-				if(substr( $key, 0, 5 ) === "data-"){
138
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
136
+			foreach ($args as $key => $val) {
137
+				if (substr($key, 0, 5) === "data-") {
138
+					$output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" ';
139 139
 				}
140 140
 			}
141 141
 		}
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return string
150 150
 	 */
151
-	public static function aria_attributes($args){
151
+	public static function aria_attributes($args) {
152 152
 		$output = '';
153 153
 
154
-		if(!empty($args)){
154
+		if (!empty($args)) {
155 155
 
156
-			foreach($args as $key => $val){
157
-				if(substr( $key, 0, 5 ) === "aria-"){
158
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
156
+			foreach ($args as $key => $val) {
157
+				if (substr($key, 0, 5) === "aria-") {
158
+					$output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" ';
159 159
 				}
160 160
 			}
161 161
 		}
@@ -172,19 +172,19 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @return string
174 174
 	 */
175
-	public static function icon($class,$space_after = false, $extra_attributes = array()){
175
+	public static function icon($class, $space_after = false, $extra_attributes = array()) {
176 176
 		$output = '';
177 177
 
178
-		if($class){
178
+		if ($class) {
179 179
 			$classes = self::esc_classes($class);
180
-			if(!empty($classes)){
181
-				$output = '<i class="'.$classes.'" ';
180
+			if (!empty($classes)) {
181
+				$output = '<i class="' . $classes . '" ';
182 182
 				// extra attributes
183
-				if(!empty($extra_attributes)){
183
+				if (!empty($extra_attributes)) {
184 184
 					$output .= AUI_Component_Helper::extra_attributes($extra_attributes);
185 185
 				}
186 186
 				$output .= '></i>';
187
-				if($space_after){
187
+				if ($space_after) {
188 188
 					$output .= " ";
189 189
 				}
190 190
 			}
@@ -198,17 +198,17 @@  discard block
 block discarded – undo
198 198
 	 *
199 199
 	 * @return string
200 200
 	 */
201
-	public static function extra_attributes($args){
201
+	public static function extra_attributes($args) {
202 202
 		$output = '';
203 203
 
204
-		if(!empty($args)){
204
+		if (!empty($args)) {
205 205
 
206
-			if( is_array($args) ){
207
-				foreach($args as $key => $val){
208
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
206
+			if (is_array($args)) {
207
+				foreach ($args as $key => $val) {
208
+					$output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" ';
209 209
 				}
210
-			}else{
211
-				$output .= ' '.$args.' ';
210
+			} else {
211
+				$output .= ' ' . $args . ' ';
212 212
 			}
213 213
 
214 214
 		}
@@ -221,11 +221,11 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @return string
223 223
 	 */
224
-	public static function help_text($text){
224
+	public static function help_text($text) {
225 225
 		$output = '';
226 226
 
227
-		if($text){
228
-			$output .= '<small class="form-text text-muted">'.wp_kses_post($text).'</small>';
227
+		if ($text) {
228
+			$output .= '<small class="form-text text-muted">' . wp_kses_post($text) . '</small>';
229 229
 		}
230 230
 
231 231
 
@@ -239,18 +239,18 @@  discard block
 block discarded – undo
239 239
 	 *
240 240
 	 * @return string|void
241 241
 	 */
242
-	public static function element_require( $input ) {
242
+	public static function element_require($input) {
243 243
 
244
-		$input = str_replace( "'", '"', $input );// we only want double quotes
244
+		$input = str_replace("'", '"', $input); // we only want double quotes
245 245
 
246
-		$output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
246
+		$output = esc_attr(str_replace(array("[%", "%]", "%:checked]"), array(
247 247
 			"jQuery(form).find('[data-argument=\"",
248 248
 			"\"]').find('input,select,textarea').val()",
249 249
 			"\"]').find('input:checked').val()",
250
-		), $input ) );
250
+		), $input));
251 251
 
252
-		if($output){
253
-			$output = ' data-element-require="'.$output.'" ';
252
+		if ($output) {
253
+			$output = ' data-element-require="' . $output . '" ';
254 254
 		}
255 255
 
256 256
 		return $output;
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@
 block discarded – undo
207 207
 				foreach($args as $key => $val){
208 208
 					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
209 209
 				}
210
-			}else{
210
+			} else{
211 211
 				$output .= ' '.$args.' ';
212 212
 			}
213 213
 
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.24";
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.24";
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.24";
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.
includes/admin/class-getpaid-metaboxes.php 2 patches
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -12,186 +12,186 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Metaboxes {
14 14
 
15
-	/**
16
-	 * Only save metaboxes once.
17
-	 *
18
-	 * @var boolean
19
-	 */
20
-	private static $saved_meta_boxes = false;
15
+    /**
16
+     * Only save metaboxes once.
17
+     *
18
+     * @var boolean
19
+     */
20
+    private static $saved_meta_boxes = false;
21 21
 
22 22
     /**
23
-	 * Hook in methods.
24
-	 */
25
-	public static function init() {
26
-
27
-		// Register metaboxes.
28
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 );
29
-
30
-		// Remove metaboxes.
31
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 );
32
-
33
-		// Rename metaboxes.
34
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 );
35
-
36
-		// Save metaboxes.
37
-		add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 );
38
-	}
39
-
40
-	/**
41
-	 * Register core metaboxes.
42
-	 */
43
-	public static function add_meta_boxes( $post_type, $post ) {
44
-		global $wpinv_euvat;
45
-
46
-		// For invoices...
47
-		if ( $post_type == 'wpi_invoice' ) {
48
-			$invoice = new WPInv_Invoice( $post );
49
-
50
-			// Resend invoice.
51
-			if ( ! $invoice->is_draft() && ! $invoice->is_paid() ) {
52
-				add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'GetPaid_Meta_Box_Resend_Invoice::output', 'wpi_invoice', 'side', 'low' );
53
-			}
54
-
55
-			// Subscriptions.
56
-			$subscription = getpaid_get_invoice_subscription( $invoice );
57
-			if ( ! empty( $subscription ) ) {
58
-				add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', 'wpi_invoice', 'advanced' );
59
-				add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', 'wpi_invoice', 'advanced' );
60
-			}
61
-
62
-			// Invoice details.
63
-			add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Details::output', 'wpi_invoice', 'side', 'default' );
23
+     * Hook in methods.
24
+     */
25
+    public static function init() {
26
+
27
+        // Register metaboxes.
28
+        add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 );
29
+
30
+        // Remove metaboxes.
31
+        add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 );
32
+
33
+        // Rename metaboxes.
34
+        add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 );
35
+
36
+        // Save metaboxes.
37
+        add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 );
38
+    }
39
+
40
+    /**
41
+     * Register core metaboxes.
42
+     */
43
+    public static function add_meta_boxes( $post_type, $post ) {
44
+        global $wpinv_euvat;
45
+
46
+        // For invoices...
47
+        if ( $post_type == 'wpi_invoice' ) {
48
+            $invoice = new WPInv_Invoice( $post );
49
+
50
+            // Resend invoice.
51
+            if ( ! $invoice->is_draft() && ! $invoice->is_paid() ) {
52
+                add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'GetPaid_Meta_Box_Resend_Invoice::output', 'wpi_invoice', 'side', 'low' );
53
+            }
54
+
55
+            // Subscriptions.
56
+            $subscription = getpaid_get_invoice_subscription( $invoice );
57
+            if ( ! empty( $subscription ) ) {
58
+                add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', 'wpi_invoice', 'advanced' );
59
+                add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', 'wpi_invoice', 'advanced' );
60
+            }
61
+
62
+            // Invoice details.
63
+            add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Details::output', 'wpi_invoice', 'side', 'default' );
64 64
 			
65
-			// Payment details.
66
-			if ( ! $invoice->is_draft() ) {
67
-				add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', 'wpi_invoice', 'side', 'default' );
68
-			}
65
+            // Payment details.
66
+            if ( ! $invoice->is_draft() ) {
67
+                add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', 'wpi_invoice', 'side', 'default' );
68
+            }
69 69
 
70
-			// Billing details.
71
-			add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', 'wpi_invoice', 'normal', 'high' );
70
+            // Billing details.
71
+            add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', 'wpi_invoice', 'normal', 'high' );
72 72
 			
73
-			// Invoice items.
74
-			add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Items::output', 'wpi_invoice', 'normal', 'high' );
73
+            // Invoice items.
74
+            add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Items::output', 'wpi_invoice', 'normal', 'high' );
75 75
 			
76
-			// Invoice notes.
77
-			add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'side', 'low' );
76
+            // Invoice notes.
77
+            add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'side', 'low' );
78 78
 
79
-			// Payment form information.
80
-			if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) {
81
-				add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high' );
82
-			}
83
-		}
79
+            // Payment form information.
80
+            if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) {
81
+                add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high' );
82
+            }
83
+        }
84 84
 
85
-		// For payment forms.
86
-		if ( $post_type == 'wpi_payment_form' ) {
85
+        // For payment forms.
86
+        if ( $post_type == 'wpi_payment_form' ) {
87 87
 
88
-			// Design payment form.
89
-			add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
88
+            // Design payment form.
89
+            add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
90 90
 
91
-			// Payment form information.
92
-			add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' );
91
+            // Payment form information.
92
+            add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' );
93 93
 
94
-		}
94
+        }
95 95
 
96
-		// For invoice items.
97
-		if ( $post_type == 'wpi_item' ) {
96
+        // For invoice items.
97
+        if ( $post_type == 'wpi_item' ) {
98 98
 
99
-			// Item details.
100
-			add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' );
99
+            // Item details.
100
+            add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' );
101 101
 
102
-			// If taxes are enabled, register the tax metabox.
103
-			if ( $wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes() ) {
104
-				add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' );
105
-			}
102
+            // If taxes are enabled, register the tax metabox.
103
+            if ( $wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes() ) {
104
+                add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' );
105
+            }
106 106
 
107
-			// Item info.
108
-			add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' );
107
+            // Item info.
108
+            add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' );
109 109
 
110
-		}
110
+        }
111 111
 
112
-		// For invoice discounts.
113
-		if ( $post_type == 'wpi_discount' ) {
114
-			add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' );
115
-		}
112
+        // For invoice discounts.
113
+        if ( $post_type == 'wpi_discount' ) {
114
+            add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' );
115
+        }
116 116
 		
117 117
 
118
-	}
118
+    }
119 119
 
120
-	/**
121
-	 * Remove some metaboxes.
122
-	 */
123
-	public static function remove_meta_boxes() {
124
-		remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' );
125
-	}
120
+    /**
121
+     * Remove some metaboxes.
122
+     */
123
+    public static function remove_meta_boxes() {
124
+        remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' );
125
+    }
126 126
 
127
-	/**
128
-	 * Rename other metaboxes.
129
-	 */
130
-	public static function rename_meta_boxes() {
127
+    /**
128
+     * Rename other metaboxes.
129
+     */
130
+    public static function rename_meta_boxes() {
131 131
 		
132
-	}
133
-
134
-	/**
135
-	 * Check if we're saving, then trigger an action based on the post type.
136
-	 *
137
-	 * @param  int    $post_id Post ID.
138
-	 * @param  object $post Post object.
139
-	 */
140
-	public static function save_meta_boxes( $post_id, $post ) {
141
-		$post_id = absint( $post_id );
142
-		$data    = wp_unslash( $_POST );
143
-
144
-		// Do not save for ajax requests.
145
-		if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
146
-			return;
147
-		}
148
-
149
-		// $post_id and $post are required
150
-		if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) {
151
-			return;
152
-		}
153
-
154
-		// Dont' save meta boxes for revisions or autosaves.
155
-		if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
156
-			return;
157
-		}
158
-
159
-		// Check the nonce.
160
-		if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) {
161
-			return;
162
-		}
163
-
164
-		// Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
165
-		if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) {
166
-			return;
167
-		}
168
-
169
-		// Check user has permission to edit.
170
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
171
-			return;
172
-		}
173
-
174
-		// Ensure this is our post type.
175
-		$post_types_map = array(
176
-			'wpi_invoice'      => 'GetPaid_Meta_Box_Invoice_Address',
177
-			'wpi_quote'        => 'GetPaid_Meta_Box_Invoice_Address',
178
-			'wpi_item'         => 'GetPaid_Meta_Box_Item_Details',
179
-			'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form',
180
-			'wpi_discount'     => 'GetPaid_Meta_Box_Discount_Details',
181
-		);
182
-
183
-		// Is this our post type?
184
-		if ( empty( $post->post_type ) || ! isset( $post_types_map[ $post->post_type ] ) ) {
185
-			return;
186
-		}
187
-
188
-		// We need this save event to run once to avoid potential endless loops.
189
-		self::$saved_meta_boxes = true;
132
+    }
133
+
134
+    /**
135
+     * Check if we're saving, then trigger an action based on the post type.
136
+     *
137
+     * @param  int    $post_id Post ID.
138
+     * @param  object $post Post object.
139
+     */
140
+    public static function save_meta_boxes( $post_id, $post ) {
141
+        $post_id = absint( $post_id );
142
+        $data    = wp_unslash( $_POST );
143
+
144
+        // Do not save for ajax requests.
145
+        if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
146
+            return;
147
+        }
148
+
149
+        // $post_id and $post are required
150
+        if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) {
151
+            return;
152
+        }
153
+
154
+        // Dont' save meta boxes for revisions or autosaves.
155
+        if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
156
+            return;
157
+        }
158
+
159
+        // Check the nonce.
160
+        if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) {
161
+            return;
162
+        }
163
+
164
+        // Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
165
+        if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) {
166
+            return;
167
+        }
168
+
169
+        // Check user has permission to edit.
170
+        if ( ! current_user_can( 'edit_post', $post_id ) ) {
171
+            return;
172
+        }
173
+
174
+        // Ensure this is our post type.
175
+        $post_types_map = array(
176
+            'wpi_invoice'      => 'GetPaid_Meta_Box_Invoice_Address',
177
+            'wpi_quote'        => 'GetPaid_Meta_Box_Invoice_Address',
178
+            'wpi_item'         => 'GetPaid_Meta_Box_Item_Details',
179
+            'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form',
180
+            'wpi_discount'     => 'GetPaid_Meta_Box_Discount_Details',
181
+        );
182
+
183
+        // Is this our post type?
184
+        if ( empty( $post->post_type ) || ! isset( $post_types_map[ $post->post_type ] ) ) {
185
+            return;
186
+        }
187
+
188
+        // We need this save event to run once to avoid potential endless loops.
189
+        self::$saved_meta_boxes = true;
190 190
 		
191
-		// Save the post.
192
-		$class = $post_types_map[ $post->post_type ];
193
-		$class::save( $post_id, $_POST, $post );
191
+        // Save the post.
192
+        $class = $post_types_map[ $post->post_type ];
193
+        $class::save( $post_id, $_POST, $post );
194 194
 
195
-	}
195
+    }
196 196
 
197 197
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Metaboxes Admin Class
@@ -25,93 +25,93 @@  discard block
 block discarded – undo
25 25
 	public static function init() {
26 26
 
27 27
 		// Register metaboxes.
28
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 );
28
+		add_action('add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2);
29 29
 
30 30
 		// Remove metaboxes.
31
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 );
31
+		add_action('add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30);
32 32
 
33 33
 		// Rename metaboxes.
34
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 );
34
+		add_action('add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45);
35 35
 
36 36
 		// Save metaboxes.
37
-		add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 );
37
+		add_action('save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2);
38 38
 	}
39 39
 
40 40
 	/**
41 41
 	 * Register core metaboxes.
42 42
 	 */
43
-	public static function add_meta_boxes( $post_type, $post ) {
43
+	public static function add_meta_boxes($post_type, $post) {
44 44
 		global $wpinv_euvat;
45 45
 
46 46
 		// For invoices...
47
-		if ( $post_type == 'wpi_invoice' ) {
48
-			$invoice = new WPInv_Invoice( $post );
47
+		if ($post_type == 'wpi_invoice') {
48
+			$invoice = new WPInv_Invoice($post);
49 49
 
50 50
 			// Resend invoice.
51
-			if ( ! $invoice->is_draft() && ! $invoice->is_paid() ) {
52
-				add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'GetPaid_Meta_Box_Resend_Invoice::output', 'wpi_invoice', 'side', 'low' );
51
+			if (!$invoice->is_draft() && !$invoice->is_paid()) {
52
+				add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'GetPaid_Meta_Box_Resend_Invoice::output', 'wpi_invoice', 'side', 'low');
53 53
 			}
54 54
 
55 55
 			// Subscriptions.
56
-			$subscription = getpaid_get_invoice_subscription( $invoice );
57
-			if ( ! empty( $subscription ) ) {
58
-				add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', 'wpi_invoice', 'advanced' );
59
-				add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', 'wpi_invoice', 'advanced' );
56
+			$subscription = getpaid_get_invoice_subscription($invoice);
57
+			if (!empty($subscription)) {
58
+				add_meta_box('wpinv-mb-subscriptions', __('Subscription Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output', 'wpi_invoice', 'advanced');
59
+				add_meta_box('wpinv-mb-subscription-invoices', __('Related Payments', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', 'wpi_invoice', 'advanced');
60 60
 			}
61 61
 
62 62
 			// Invoice details.
63
-			add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Details::output', 'wpi_invoice', 'side', 'default' );
63
+			add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Details::output', 'wpi_invoice', 'side', 'default');
64 64
 			
65 65
 			// Payment details.
66
-			if ( ! $invoice->is_draft() ) {
67
-				add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', 'wpi_invoice', 'side', 'default' );
66
+			if (!$invoice->is_draft()) {
67
+				add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', 'wpi_invoice', 'side', 'default');
68 68
 			}
69 69
 
70 70
 			// Billing details.
71
-			add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', 'wpi_invoice', 'normal', 'high' );
71
+			add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Address::output', 'wpi_invoice', 'normal', 'high');
72 72
 			
73 73
 			// Invoice items.
74
-			add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Items::output', 'wpi_invoice', 'normal', 'high' );
74
+			add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Items::output', 'wpi_invoice', 'normal', 'high');
75 75
 			
76 76
 			// Invoice notes.
77
-			add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'side', 'low' );
77
+			add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'side', 'low');
78 78
 
79 79
 			// Payment form information.
80
-			if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) {
81
-				add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high' );
80
+			if (!empty($post->ID) && get_post_meta($post->ID, 'payment_form_data', true)) {
81
+				add_meta_box('wpinv-invoice-payment-form-details', __('Payment Form Details', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high');
82 82
 			}
83 83
 		}
84 84
 
85 85
 		// For payment forms.
86
-		if ( $post_type == 'wpi_payment_form' ) {
86
+		if ($post_type == 'wpi_payment_form') {
87 87
 
88 88
 			// Design payment form.
89
-			add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
89
+			add_meta_box('wpinv-payment-form-design', __('Payment Form', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal');
90 90
 
91 91
 			// Payment form information.
92
-			add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' );
92
+			add_meta_box('wpinv-payment-form-info', __('Details', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side');
93 93
 
94 94
 		}
95 95
 
96 96
 		// For invoice items.
97
-		if ( $post_type == 'wpi_item' ) {
97
+		if ($post_type == 'wpi_item') {
98 98
 
99 99
 			// Item details.
100
-			add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' );
100
+			add_meta_box('wpinv_item_details', __('Item Details', 'invoicing'), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high');
101 101
 
102 102
 			// If taxes are enabled, register the tax metabox.
103
-			if ( $wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes() ) {
104
-				add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' );
103
+			if ($wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes()) {
104
+				add_meta_box('wpinv_item_vat', __('VAT / Tax', 'invoicing'), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high');
105 105
 			}
106 106
 
107 107
 			// Item info.
108
-			add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' );
108
+			add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core');
109 109
 
110 110
 		}
111 111
 
112 112
 		// For invoice discounts.
113
-		if ( $post_type == 'wpi_discount' ) {
114
-			add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' );
113
+		if ($post_type == 'wpi_discount') {
114
+			add_meta_box('wpinv_discount_details', __('Discount Details', 'invoicing'), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high');
115 115
 		}
116 116
 		
117 117
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * Remove some metaboxes.
122 122
 	 */
123 123
 	public static function remove_meta_boxes() {
124
-		remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' );
124
+		remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal');
125 125
 	}
126 126
 
127 127
 	/**
@@ -137,37 +137,37 @@  discard block
 block discarded – undo
137 137
 	 * @param  int    $post_id Post ID.
138 138
 	 * @param  object $post Post object.
139 139
 	 */
140
-	public static function save_meta_boxes( $post_id, $post ) {
141
-		$post_id = absint( $post_id );
142
-		$data    = wp_unslash( $_POST );
140
+	public static function save_meta_boxes($post_id, $post) {
141
+		$post_id = absint($post_id);
142
+		$data    = wp_unslash($_POST);
143 143
 
144 144
 		// Do not save for ajax requests.
145
-		if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
145
+		if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
146 146
 			return;
147 147
 		}
148 148
 
149 149
 		// $post_id and $post are required
150
-		if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) {
150
+		if (empty($post_id) || empty($post) || self::$saved_meta_boxes) {
151 151
 			return;
152 152
 		}
153 153
 
154 154
 		// Dont' save meta boxes for revisions or autosaves.
155
-		if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
155
+		if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
156 156
 			return;
157 157
 		}
158 158
 
159 159
 		// Check the nonce.
160
-		if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) {
160
+		if (empty($data['getpaid_meta_nonce']) || !wp_verify_nonce($data['getpaid_meta_nonce'], 'getpaid_meta_nonce')) {
161 161
 			return;
162 162
 		}
163 163
 
164 164
 		// Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
165
-		if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) {
165
+		if (empty($data['post_ID']) || absint($data['post_ID']) !== $post_id) {
166 166
 			return;
167 167
 		}
168 168
 
169 169
 		// Check user has permission to edit.
170
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
170
+		if (!current_user_can('edit_post', $post_id)) {
171 171
 			return;
172 172
 		}
173 173
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 		);
182 182
 
183 183
 		// Is this our post type?
184
-		if ( empty( $post->post_type ) || ! isset( $post_types_map[ $post->post_type ] ) ) {
184
+		if (empty($post->post_type) || !isset($post_types_map[$post->post_type])) {
185 185
 			return;
186 186
 		}
187 187
 
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
 		self::$saved_meta_boxes = true;
190 190
 		
191 191
 		// Save the post.
192
-		$class = $post_types_map[ $post->post_type ];
193
-		$class::save( $post_id, $_POST, $post );
192
+		$class = $post_types_map[$post->post_type];
193
+		$class::save($post_id, $_POST, $post);
194 194
 
195 195
 	}
196 196
 
Please login to merge, or discard this patch.
includes/admin/subscriptions.php 2 patches
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  */
15 15
 function wpinv_subscriptions_page() {
16 16
 
17
-	?>
17
+    ?>
18 18
 
19 19
 	<div class="wrap">
20 20
 		<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
@@ -22,27 +22,27 @@  discard block
 block discarded – undo
22 22
 
23 23
 			<?php
24 24
 
25
-				// Verify user permissions.
26
-				if ( ! wpinv_current_user_can_manage_invoicing() ) {
25
+                // Verify user permissions.
26
+                if ( ! wpinv_current_user_can_manage_invoicing() ) {
27 27
 
28
-					echo aui()->alert(
29
-						array(
30
-							'type'    => 'danger',
31
-							'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
32
-						)
33
-					);
28
+                    echo aui()->alert(
29
+                        array(
30
+                            'type'    => 'danger',
31
+                            'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
32
+                        )
33
+                    );
34 34
 
35
-				} else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
35
+                } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
36 36
 
37
-					// Display a single subscription.
38
-					wpinv_recurring_subscription_details();
39
-				} else {
37
+                    // Display a single subscription.
38
+                    wpinv_recurring_subscription_details();
39
+                } else {
40 40
 
41
-					// Display a list of available subscriptions.
42
-					getpaid_print_subscriptions_list();
43
-				}
41
+                    // Display a list of available subscriptions.
42
+                    getpaid_print_subscriptions_list();
43
+                }
44 44
 
45
-			?>
45
+            ?>
46 46
 
47 47
 		</div>
48 48
 	</div>
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
  */
60 60
 function getpaid_print_subscriptions_list() {
61 61
 
62
-	$subscribers_table = new WPInv_Subscriptions_List_Table();
63
-	$subscribers_table->prepare_items();
62
+    $subscribers_table = new WPInv_Subscriptions_List_Table();
63
+    $subscribers_table->prepare_items();
64 64
 
65
-	?>
65
+    ?>
66 66
 	<form id="subscribers-filter" class="bsui" method="get">
67 67
 		<input type="hidden" name="page" value="wpinv-subscriptions" />
68 68
 		<?php $subscribers_table->views(); ?>
@@ -80,27 +80,27 @@  discard block
 block discarded – undo
80 80
  */
81 81
 function wpinv_recurring_subscription_details() {
82 82
 
83
-	// Fetch the subscription.
84
-	$sub = new WPInv_Subscription( (int) $_GET['id'] );
85
-	if ( ! $sub->get_id() ) {
83
+    // Fetch the subscription.
84
+    $sub = new WPInv_Subscription( (int) $_GET['id'] );
85
+    if ( ! $sub->get_id() ) {
86 86
 
87
-		echo aui()->alert(
88
-			array(
89
-				'type'    => 'danger',
90
-				'content' => __( 'Subscription not found.', 'invoicing' ),
91
-			)
92
-		);
87
+        echo aui()->alert(
88
+            array(
89
+                'type'    => 'danger',
90
+                'content' => __( 'Subscription not found.', 'invoicing' ),
91
+            )
92
+        );
93 93
 
94
-		return;
95
-	}
94
+        return;
95
+    }
96 96
 
97
-	// Use metaboxes to display the subscription details.
98
-	add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal' );
99
-	add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
100
-	add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
101
-	do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
97
+    // Use metaboxes to display the subscription details.
98
+    add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal' );
99
+    add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
100
+    add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
101
+    do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
102 102
 
103
-	?>
103
+    ?>
104 104
 
105 105
 		<form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>">
106 106
 
@@ -140,41 +140,41 @@  discard block
 block discarded – undo
140 140
  */
141 141
 function getpaid_admin_subscription_details_metabox( $sub ) {
142 142
 
143
-	// Prepare subscription detail columns.
144
-	$fields = apply_filters(
145
-		'getpaid_subscription_admin_page_fields',
146
-		array(
147
-			'subscription'   => __( 'Subscription', 'invoicing' ),
148
-			'customer'       => __( 'Customer', 'invoicing' ),
149
-			'amount'         => __( 'Amount', 'invoicing' ),
150
-			'start_date'     => __( 'Start Date', 'invoicing' ),
151
-			'renews_on'      => __( 'Next Payment', 'invoicing' ),
152
-			'renewals'       => __( 'Renewals', 'invoicing' ),
153
-			'item'           => __( 'Item', 'invoicing' ),
154
-			'gateway'        => __( 'Payment Method', 'invoicing' ),
155
-			'profile_id'     => __( 'Profile ID', 'invoicing' ),
156
-			'status'         => __( 'Status', 'invoicing' ),
157
-		)
158
-	);
159
-
160
-	if ( ! $sub->is_active() ) {
161
-
162
-		if ( isset( $fields['renews_on'] ) ) {
163
-			unset( $fields['renews_on'] );
164
-		}
165
-
166
-		if ( isset( $fields['gateway'] ) ) {
167
-			unset( $fields['gateway'] );
168
-		}
143
+    // Prepare subscription detail columns.
144
+    $fields = apply_filters(
145
+        'getpaid_subscription_admin_page_fields',
146
+        array(
147
+            'subscription'   => __( 'Subscription', 'invoicing' ),
148
+            'customer'       => __( 'Customer', 'invoicing' ),
149
+            'amount'         => __( 'Amount', 'invoicing' ),
150
+            'start_date'     => __( 'Start Date', 'invoicing' ),
151
+            'renews_on'      => __( 'Next Payment', 'invoicing' ),
152
+            'renewals'       => __( 'Renewals', 'invoicing' ),
153
+            'item'           => __( 'Item', 'invoicing' ),
154
+            'gateway'        => __( 'Payment Method', 'invoicing' ),
155
+            'profile_id'     => __( 'Profile ID', 'invoicing' ),
156
+            'status'         => __( 'Status', 'invoicing' ),
157
+        )
158
+    );
159
+
160
+    if ( ! $sub->is_active() ) {
161
+
162
+        if ( isset( $fields['renews_on'] ) ) {
163
+            unset( $fields['renews_on'] );
164
+        }
165
+
166
+        if ( isset( $fields['gateway'] ) ) {
167
+            unset( $fields['gateway'] );
168
+        }
169 169
 		
170
-	}
170
+    }
171 171
 
172
-	$profile_id = $sub->get_profile_id();
173
-	if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
174
-		unset( $fields['profile_id'] );
175
-	}
172
+    $profile_id = $sub->get_profile_id();
173
+    if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
174
+        unset( $fields['profile_id'] );
175
+    }
176 176
 
177
-	?>
177
+    ?>
178 178
 
179 179
 		<table class="table table-borderless" style="font-size: 14px;">
180 180
 			<tbody>
@@ -208,20 +208,20 @@  discard block
 block discarded – undo
208 208
  */
209 209
 function getpaid_admin_subscription_metabox_display_customer( $subscription ) {
210 210
 
211
-	$username = __( '(Missing User)', 'invoicing' );
211
+    $username = __( '(Missing User)', 'invoicing' );
212 212
 
213
-	$user = get_userdata( $subscription->get_customer_id() );
214
-	if ( $user ) {
213
+    $user = get_userdata( $subscription->get_customer_id() );
214
+    if ( $user ) {
215 215
 
216
-		$username = sprintf(
217
-			'<a href="user-edit.php?user_id=%s">%s</a>',
218
-			absint( $user->ID ),
219
-			! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email )
220
-		);
216
+        $username = sprintf(
217
+            '<a href="user-edit.php?user_id=%s">%s</a>',
218
+            absint( $user->ID ),
219
+            ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email )
220
+        );
221 221
 
222
-	}
222
+    }
223 223
 
224
-	echo  $username;
224
+    echo  $username;
225 225
 }
226 226
 add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' );
227 227
 
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
  * @param WPInv_Subscription $subscription
232 232
  */
233 233
 function getpaid_admin_subscription_metabox_display_amount( $subscription ) {
234
-	$amount    = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) );
235
-	echo "<span>$amount</span>";
234
+    $amount    = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) );
235
+    echo "<span>$amount</span>";
236 236
 }
237 237
 add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' );
238 238
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
  * @param WPInv_Subscription $subscription
243 243
  */
244 244
 function getpaid_admin_subscription_metabox_display_id( $subscription ) {
245
-	echo  '#' . absint( $subscription->get_id() );
245
+    echo  '#' . absint( $subscription->get_id() );
246 246
 }
247 247
 add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' );
248 248
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
  * @param WPInv_Subscription $subscription
253 253
  */
254 254
 function getpaid_admin_subscription_metabox_display_start_date( $subscription ) {
255
-	echo getpaid_format_date_value( $subscription->get_date_created() );
255
+    echo getpaid_format_date_value( $subscription->get_date_created() );
256 256
 }
257 257
 add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' );
258 258
 
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
  * @param WPInv_Subscription $subscription
263 263
  */
264 264
 function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) {
265
-	echo getpaid_format_date_value( $subscription->get_expiration() );
265
+    echo getpaid_format_date_value( $subscription->get_expiration() );
266 266
 }
267 267
 add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' );
268 268
 
@@ -272,8 +272,8 @@  discard block
 block discarded – undo
272 272
  * @param WPInv_Subscription $subscription
273 273
  */
274 274
 function getpaid_admin_subscription_metabox_display_renewals( $subscription ) {
275
-	$max_bills = $subscription->get_bill_times();
276
-	echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
275
+    $max_bills = $subscription->get_bill_times();
276
+    echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
277 277
 }
278 278
 add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' );
279 279
 /**
@@ -283,16 +283,16 @@  discard block
 block discarded – undo
283 283
  */
284 284
 function getpaid_admin_subscription_metabox_display_item( $subscription ) {
285 285
 
286
-	$item = get_post( $subscription->get_product_id() );
286
+    $item = get_post( $subscription->get_product_id() );
287 287
 
288
-	if ( ! empty( $item ) ) {
289
-		$link = get_edit_post_link( $item );
290
-		$link = esc_url( $link );
291
-		$name = esc_html( get_the_title( $item ) );
292
-		echo "<a href='$link'>$name</a>";
293
-	} else {
294
-		echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() );
295
-	}
288
+    if ( ! empty( $item ) ) {
289
+        $link = get_edit_post_link( $item );
290
+        $link = esc_url( $link );
291
+        $name = esc_html( get_the_title( $item ) );
292
+        echo "<a href='$link'>$name</a>";
293
+    } else {
294
+        echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() );
295
+    }
296 296
 
297 297
 }
298 298
 add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item' );
@@ -304,13 +304,13 @@  discard block
 block discarded – undo
304 304
  */
305 305
 function getpaid_admin_subscription_metabox_display_gateway( $subscription ) {
306 306
 
307
-	$gateway = $subscription->get_gateway();
307
+    $gateway = $subscription->get_gateway();
308 308
 
309
-	if ( ! empty( $gateway ) ) {
310
-		echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) );
311
-	} else {
312
-		echo "&mdash;";
313
-	}
309
+    if ( ! empty( $gateway ) ) {
310
+        echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) );
311
+    } else {
312
+        echo "&mdash;";
313
+    }
314 314
 
315 315
 }
316 316
 add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' );
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
  * @param WPInv_Subscription $subscription
322 322
  */
323 323
 function getpaid_admin_subscription_metabox_display_status( $subscription ) {
324
-	echo $subscription->get_status_label_html();
324
+    echo $subscription->get_status_label_html();
325 325
 }
326 326
 add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' );
327 327
 
@@ -332,14 +332,14 @@  discard block
 block discarded – undo
332 332
  */
333 333
 function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) {
334 334
 
335
-	$profile_id = $subscription->get_profile_id();
335
+    $profile_id = $subscription->get_profile_id();
336 336
 
337
-	if ( ! empty( $profile_id ) ) {
338
-		$profile_id = sanitize_text_field( $profile_id );
339
-		echo apply_filters( 'getpaid_subscription_profile_id_display', $profile_id, $subscription );
340
-	} else {
341
-		echo "&mdash;";
342
-	}
337
+    if ( ! empty( $profile_id ) ) {
338
+        $profile_id = sanitize_text_field( $profile_id );
339
+        echo apply_filters( 'getpaid_subscription_profile_id_display', $profile_id, $subscription );
340
+    } else {
341
+        echo "&mdash;";
342
+    }
343 343
 
344 344
 }
345 345
 add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' );
@@ -351,39 +351,39 @@  discard block
 block discarded – undo
351 351
  */
352 352
 function getpaid_admin_subscription_update_metabox( $subscription ) {
353 353
 
354
-	?>
354
+    ?>
355 355
 	<div class="mt-3">
356 356
 
357 357
 		<?php
358
-			echo aui()->select(
359
-				array(
360
-					'options'          => getpaid_get_subscription_statuses(),
361
-					'name'             => 'subscription_status',
362
-					'id'               => 'subscription_status_update_select',
363
-					'required'         => true,
364
-					'no_wrap'          => false,
365
-					'label'            => __( 'Subscription Status', 'invoicing' ),
366
-					'help_text'        => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
367
-					'select2'          => true,
368
-					'value'            => $subscription->get_status( 'edit' ),
369
-				)
370
-			);
371
-		?>
358
+            echo aui()->select(
359
+                array(
360
+                    'options'          => getpaid_get_subscription_statuses(),
361
+                    'name'             => 'subscription_status',
362
+                    'id'               => 'subscription_status_update_select',
363
+                    'required'         => true,
364
+                    'no_wrap'          => false,
365
+                    'label'            => __( 'Subscription Status', 'invoicing' ),
366
+                    'help_text'        => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
367
+                    'select2'          => true,
368
+                    'value'            => $subscription->get_status( 'edit' ),
369
+                )
370
+            );
371
+        ?>
372 372
 
373 373
 		<div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;">
374 374
 	
375 375
 		<?php
376
-			submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
376
+            submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
377 377
 
378
-			$url    = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) );
379
-			$anchor = __( 'Renew Subscription', 'invoicing' );
380
-			$title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
378
+            $url    = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) );
379
+            $anchor = __( 'Renew Subscription', 'invoicing' );
380
+            $title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
381 381
 
382
-			if ( $subscription->is_active() ) {
383
-				echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>";
384
-			}
382
+            if ( $subscription->is_active() ) {
383
+                echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>";
384
+            }
385 385
 
386
-	echo '</div></div>';
386
+    echo '</div></div>';
387 387
 }
388 388
 
389 389
 /**
@@ -393,33 +393,33 @@  discard block
 block discarded – undo
393 393
  */
394 394
 function getpaid_admin_subscription_invoice_details_metabox( $subscription ) {
395 395
 
396
-	$columns = apply_filters(
397
-		'getpaid_subscription_related_invoices_columns',
398
-		array(
399
-			'invoice'      => __( 'Invoice', 'invoicing' ),
400
-			'relationship' => __( 'Relationship', 'invoicing' ),
401
-			'date'         => __( 'Date', 'invoicing' ),
402
-			'status'       => __( 'Status', 'invoicing' ),
403
-			'total'        => __( 'Total', 'invoicing' ),
404
-		),
405
-		$subscription
406
-	);
407
-
408
-	// Prepare the invoices.
409
-	$payments = $subscription->get_child_payments();
410
-	$parent   = $subscription->get_parent_invoice();
411
-
412
-	if ( $parent->get_id() ) {
413
-		$payments = array_merge( array( $parent ), $payments );
414
-	}
396
+    $columns = apply_filters(
397
+        'getpaid_subscription_related_invoices_columns',
398
+        array(
399
+            'invoice'      => __( 'Invoice', 'invoicing' ),
400
+            'relationship' => __( 'Relationship', 'invoicing' ),
401
+            'date'         => __( 'Date', 'invoicing' ),
402
+            'status'       => __( 'Status', 'invoicing' ),
403
+            'total'        => __( 'Total', 'invoicing' ),
404
+        ),
405
+        $subscription
406
+    );
407
+
408
+    // Prepare the invoices.
409
+    $payments = $subscription->get_child_payments();
410
+    $parent   = $subscription->get_parent_invoice();
411
+
412
+    if ( $parent->get_id() ) {
413
+        $payments = array_merge( array( $parent ), $payments );
414
+    }
415 415
 	
416
-	$table_class = 'w-100 bg-white';
416
+    $table_class = 'w-100 bg-white';
417 417
 
418
-	if ( ! is_admin() ) {
419
-		$table_class = 'table table-bordered table-striped';
420
-	}
418
+    if ( ! is_admin() ) {
419
+        $table_class = 'table table-bordered table-striped';
420
+    }
421 421
 
422
-	?>
422
+    ?>
423 423
 		<div class="m-0" style="overflow: auto;">
424 424
 
425 425
 			<table class="<?php echo $table_class; ?>">
@@ -427,13 +427,13 @@  discard block
 block discarded – undo
427 427
 				<thead>
428 428
 					<tr>
429 429
 						<?php
430
-							foreach ( $columns as $key => $label ) {
431
-								$key   = esc_attr( $key );
432
-								$label = sanitize_text_field( $label );
430
+                            foreach ( $columns as $key => $label ) {
431
+                                $key   = esc_attr( $key );
432
+                                $label = sanitize_text_field( $label );
433 433
 
434
-								echo "<th class='subscription-invoice-field-$key bg-light p-2 text-left color-dark'>$label</th>";
435
-							}
436
-						?>
434
+                                echo "<th class='subscription-invoice-field-$key bg-light p-2 text-left color-dark'>$label</th>";
435
+                            }
436
+                        ?>
437 437
 					</tr>
438 438
 				</thead>
439 439
 
@@ -449,66 +449,66 @@  discard block
 block discarded – undo
449 449
 
450 450
 					<?php
451 451
 
452
-						foreach( $payments as $payment ) :
452
+                        foreach( $payments as $payment ) :
453 453
 
454
-							// Ensure that we have an invoice.
455
-							$payment = new WPInv_Invoice( $payment );
454
+                            // Ensure that we have an invoice.
455
+                            $payment = new WPInv_Invoice( $payment );
456 456
 
457
-							// Abort if the invoice is invalid.
458
-							if ( ! $payment->get_id() ) {
459
-								continue;
460
-							}
457
+                            // Abort if the invoice is invalid.
458
+                            if ( ! $payment->get_id() ) {
459
+                                continue;
460
+                            }
461 461
 
462
-							echo '<tr>';
462
+                            echo '<tr>';
463 463
 
464
-								foreach ( array_keys( $columns ) as $key ) {
464
+                                foreach ( array_keys( $columns ) as $key ) {
465 465
 									
466
-									echo '<td class="p-2 text-left">';
466
+                                    echo '<td class="p-2 text-left">';
467 467
 
468
-										switch( $key ) {
468
+                                        switch( $key ) {
469 469
 
470
-											case 'total':
471
-												echo '<strong>' . wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $payment->get_total ) ), $payment->get_currency() ) . '</strong>';
472
-												break;
470
+                                            case 'total':
471
+                                                echo '<strong>' . wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $payment->get_total ) ), $payment->get_currency() ) . '</strong>';
472
+                                                break;
473 473
 
474
-											case 'relationship':
475
-												echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' );
476
-												break;
474
+                                            case 'relationship':
475
+                                                echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' );
476
+                                                break;
477 477
 
478
-											case 'date':
479
-												echo getpaid_format_date_value( $payment->get_date_created() );
480
-												break;
478
+                                            case 'date':
479
+                                                echo getpaid_format_date_value( $payment->get_date_created() );
480
+                                                break;
481 481
 
482
-											case 'status':
482
+                                            case 'status':
483 483
 
484
-												$status = $payment->get_status_nicename();
485
-												if ( is_admin() ) {
486
-													$status = $payment->get_status_label_html();
487
-												}
484
+                                                $status = $payment->get_status_nicename();
485
+                                                if ( is_admin() ) {
486
+                                                    $status = $payment->get_status_label_html();
487
+                                                }
488 488
 
489
-												echo $status;
490
-												break;
489
+                                                echo $status;
490
+                                                break;
491 491
 
492
-											case 'invoice':
493
-												$link    = esc_url( get_edit_post_link( $payment->get_id() ) );
492
+                                            case 'invoice':
493
+                                                $link    = esc_url( get_edit_post_link( $payment->get_id() ) );
494 494
 
495
-												if ( ! is_admin() ) {
496
-													$link = esc_url( $payment->get_view_url() );
497
-												}
495
+                                                if ( ! is_admin() ) {
496
+                                                    $link = esc_url( $payment->get_view_url() );
497
+                                                }
498 498
 
499
-												$invoice = sanitize_text_field( $payment->get_number() );
500
-												echo "<a href='$link'>$invoice</a>";
501
-												break;
502
-										}
499
+                                                $invoice = sanitize_text_field( $payment->get_number() );
500
+                                                echo "<a href='$link'>$invoice</a>";
501
+                                                break;
502
+                                        }
503 503
 
504
-									echo '</td>';
504
+                                    echo '</td>';
505 505
 
506
-								}
506
+                                }
507 507
 
508
-							echo '</tr>';
508
+                            echo '</tr>';
509 509
 
510
-						endforeach;
511
-					?>
510
+                        endforeach;
511
+                    ?>
512 512
 
513 513
 				</tbody>
514 514
 
Please login to merge, or discard this patch.
Spacing   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Contains functions that display the subscriptions admin page.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * Render the Subscriptions page
@@ -17,22 +17,22 @@  discard block
 block discarded – undo
17 17
 	?>
18 18
 
19 19
 	<div class="wrap">
20
-		<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
20
+		<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
21 21
 		<div class="bsui">
22 22
 
23 23
 			<?php
24 24
 
25 25
 				// Verify user permissions.
26
-				if ( ! wpinv_current_user_can_manage_invoicing() ) {
26
+				if (!wpinv_current_user_can_manage_invoicing()) {
27 27
 
28 28
 					echo aui()->alert(
29 29
 						array(
30 30
 							'type'    => 'danger',
31
-							'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
31
+							'content' => __('You are not permitted to view this page.', 'invoicing'),
32 32
 						)
33 33
 					);
34 34
 
35
-				} else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
35
+				} else if (!empty($_GET['id']) && is_numeric($_GET['id'])) {
36 36
 
37 37
 					// Display a single subscription.
38 38
 					wpinv_recurring_subscription_details();
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
 function wpinv_recurring_subscription_details() {
82 82
 
83 83
 	// Fetch the subscription.
84
-	$sub = new WPInv_Subscription( (int) $_GET['id'] );
85
-	if ( ! $sub->get_id() ) {
84
+	$sub = new WPInv_Subscription((int) $_GET['id']);
85
+	if (!$sub->get_id()) {
86 86
 
87 87
 		echo aui()->alert(
88 88
 			array(
89 89
 				'type'    => 'danger',
90
-				'content' => __( 'Subscription not found.', 'invoicing' ),
90
+				'content' => __('Subscription not found.', 'invoicing'),
91 91
 			)
92 92
 		);
93 93
 
@@ -95,31 +95,31 @@  discard block
 block discarded – undo
95 95
 	}
96 96
 
97 97
 	// Use metaboxes to display the subscription details.
98
-	add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal' );
99
-	add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
100
-	add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
101
-	do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
98
+	add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal');
99
+	add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side');
100
+	add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced');
101
+	do_action('getpaid_admin_single_subscription_register_metabox', $sub);
102 102
 
103 103
 	?>
104 104
 
105
-		<form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>">
105
+		<form method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id())); ?>">
106 106
 
107
-			<?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?>
108
-			<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
109
-			<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
107
+			<?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?>
108
+			<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?>
109
+			<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?>
110 110
 			<input type="hidden" name="getpaid-admin-action" value="update_single_subscription" />
111
-			<input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id() ;?>" />
111
+			<input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" />
112 112
 
113 113
 			<div id="poststuff">
114 114
 				<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
115 115
 
116 116
 					<div id="postbox-container-1" class="postbox-container">
117
-						<?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?>
117
+						<?php do_meta_boxes(get_current_screen(), 'side', $sub); ?>
118 118
 					</div>
119 119
 
120 120
 					<div id="postbox-container-2" class="postbox-container">
121
-						<?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?>
122
-						<?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?>
121
+						<?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?>
122
+						<?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?>
123 123
 					</div>
124 124
 
125 125
 				</div>
@@ -138,40 +138,40 @@  discard block
 block discarded – undo
138 138
  *
139 139
  * @param WPInv_Subscription $sub
140 140
  */
141
-function getpaid_admin_subscription_details_metabox( $sub ) {
141
+function getpaid_admin_subscription_details_metabox($sub) {
142 142
 
143 143
 	// Prepare subscription detail columns.
144 144
 	$fields = apply_filters(
145 145
 		'getpaid_subscription_admin_page_fields',
146 146
 		array(
147
-			'subscription'   => __( 'Subscription', 'invoicing' ),
148
-			'customer'       => __( 'Customer', 'invoicing' ),
149
-			'amount'         => __( 'Amount', 'invoicing' ),
150
-			'start_date'     => __( 'Start Date', 'invoicing' ),
151
-			'renews_on'      => __( 'Next Payment', 'invoicing' ),
152
-			'renewals'       => __( 'Renewals', 'invoicing' ),
153
-			'item'           => __( 'Item', 'invoicing' ),
154
-			'gateway'        => __( 'Payment Method', 'invoicing' ),
155
-			'profile_id'     => __( 'Profile ID', 'invoicing' ),
156
-			'status'         => __( 'Status', 'invoicing' ),
147
+			'subscription'   => __('Subscription', 'invoicing'),
148
+			'customer'       => __('Customer', 'invoicing'),
149
+			'amount'         => __('Amount', 'invoicing'),
150
+			'start_date'     => __('Start Date', 'invoicing'),
151
+			'renews_on'      => __('Next Payment', 'invoicing'),
152
+			'renewals'       => __('Renewals', 'invoicing'),
153
+			'item'           => __('Item', 'invoicing'),
154
+			'gateway'        => __('Payment Method', 'invoicing'),
155
+			'profile_id'     => __('Profile ID', 'invoicing'),
156
+			'status'         => __('Status', 'invoicing'),
157 157
 		)
158 158
 	);
159 159
 
160
-	if ( ! $sub->is_active() ) {
160
+	if (!$sub->is_active()) {
161 161
 
162
-		if ( isset( $fields['renews_on'] ) ) {
163
-			unset( $fields['renews_on'] );
162
+		if (isset($fields['renews_on'])) {
163
+			unset($fields['renews_on']);
164 164
 		}
165 165
 
166
-		if ( isset( $fields['gateway'] ) ) {
167
-			unset( $fields['gateway'] );
166
+		if (isset($fields['gateway'])) {
167
+			unset($fields['gateway']);
168 168
 		}
169 169
 		
170 170
 	}
171 171
 
172 172
 	$profile_id = $sub->get_profile_id();
173
-	if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
174
-		unset( $fields['profile_id'] );
173
+	if (empty($profile_id) && isset($fields['profile_id'])) {
174
+		unset($fields['profile_id']);
175 175
 	}
176 176
 
177 177
 	?>
@@ -179,16 +179,16 @@  discard block
 block discarded – undo
179 179
 		<table class="table table-borderless" style="font-size: 14px;">
180 180
 			<tbody>
181 181
 
182
-				<?php foreach ( $fields as $key => $label ) : ?>
182
+				<?php foreach ($fields as $key => $label) : ?>
183 183
 
184
-					<tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>">
184
+					<tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>">
185 185
 
186 186
 						<th class="w-25" style="font-weight: 500;">
187
-							<?php echo sanitize_text_field( $label ); ?>
187
+							<?php echo sanitize_text_field($label); ?>
188 188
 						</th>
189 189
 
190 190
 						<td class="w-75 text-muted">
191
-							<?php do_action( 'getpaid_subscription_admin_display_' . sanitize_text_field( $key ), $sub ); ?>
191
+							<?php do_action('getpaid_subscription_admin_display_' . sanitize_text_field($key), $sub); ?>
192 192
 						</td>
193 193
 
194 194
 					</tr>
@@ -206,150 +206,150 @@  discard block
 block discarded – undo
206 206
  *
207 207
  * @param WPInv_Subscription $subscription
208 208
  */
209
-function getpaid_admin_subscription_metabox_display_customer( $subscription ) {
209
+function getpaid_admin_subscription_metabox_display_customer($subscription) {
210 210
 
211
-	$username = __( '(Missing User)', 'invoicing' );
211
+	$username = __('(Missing User)', 'invoicing');
212 212
 
213
-	$user = get_userdata( $subscription->get_customer_id() );
214
-	if ( $user ) {
213
+	$user = get_userdata($subscription->get_customer_id());
214
+	if ($user) {
215 215
 
216 216
 		$username = sprintf(
217 217
 			'<a href="user-edit.php?user_id=%s">%s</a>',
218
-			absint( $user->ID ),
219
-			! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email )
218
+			absint($user->ID),
219
+			!empty($user->display_name) ? sanitize_text_field($user->display_name) : sanitize_email($user->user_email)
220 220
 		);
221 221
 
222 222
 	}
223 223
 
224 224
 	echo  $username;
225 225
 }
226
-add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' );
226
+add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer');
227 227
 
228 228
 /**
229 229
  * Displays the subscription amount.
230 230
  *
231 231
  * @param WPInv_Subscription $subscription
232 232
  */
233
-function getpaid_admin_subscription_metabox_display_amount( $subscription ) {
234
-	$amount    = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) );
233
+function getpaid_admin_subscription_metabox_display_amount($subscription) {
234
+	$amount = sanitize_text_field(getpaid_get_formatted_subscription_amount($subscription));
235 235
 	echo "<span>$amount</span>";
236 236
 }
237
-add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' );
237
+add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount');
238 238
 
239 239
 /**
240 240
  * Displays the subscription id.
241 241
  *
242 242
  * @param WPInv_Subscription $subscription
243 243
  */
244
-function getpaid_admin_subscription_metabox_display_id( $subscription ) {
245
-	echo  '#' . absint( $subscription->get_id() );
244
+function getpaid_admin_subscription_metabox_display_id($subscription) {
245
+	echo  '#' . absint($subscription->get_id());
246 246
 }
247
-add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' );
247
+add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id');
248 248
 
249 249
 /**
250 250
  * Displays the subscription renewal date.
251 251
  *
252 252
  * @param WPInv_Subscription $subscription
253 253
  */
254
-function getpaid_admin_subscription_metabox_display_start_date( $subscription ) {
255
-	echo getpaid_format_date_value( $subscription->get_date_created() );
254
+function getpaid_admin_subscription_metabox_display_start_date($subscription) {
255
+	echo getpaid_format_date_value($subscription->get_date_created());
256 256
 }
257
-add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' );
257
+add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date');
258 258
 
259 259
 /**
260 260
  * Displays the subscription renewal date.
261 261
  *
262 262
  * @param WPInv_Subscription $subscription
263 263
  */
264
-function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) {
265
-	echo getpaid_format_date_value( $subscription->get_expiration() );
264
+function getpaid_admin_subscription_metabox_display_renews_on($subscription) {
265
+	echo getpaid_format_date_value($subscription->get_expiration());
266 266
 }
267
-add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' );
267
+add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on');
268 268
 
269 269
 /**
270 270
  * Displays the subscription renewal count.
271 271
  *
272 272
  * @param WPInv_Subscription $subscription
273 273
  */
274
-function getpaid_admin_subscription_metabox_display_renewals( $subscription ) {
274
+function getpaid_admin_subscription_metabox_display_renewals($subscription) {
275 275
 	$max_bills = $subscription->get_bill_times();
276
-	echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
276
+	echo $subscription->get_times_billed() . ' / ' . (empty($max_bills) ? "&infin;" : $max_bills);
277 277
 }
278
-add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' );
278
+add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals');
279 279
 /**
280 280
  * Displays the subscription item.
281 281
  *
282 282
  * @param WPInv_Subscription $subscription
283 283
  */
284
-function getpaid_admin_subscription_metabox_display_item( $subscription ) {
284
+function getpaid_admin_subscription_metabox_display_item($subscription) {
285 285
 
286
-	$item = get_post( $subscription->get_product_id() );
286
+	$item = get_post($subscription->get_product_id());
287 287
 
288
-	if ( ! empty( $item ) ) {
289
-		$link = get_edit_post_link( $item );
290
-		$link = esc_url( $link );
291
-		$name = esc_html( get_the_title( $item ) );
288
+	if (!empty($item)) {
289
+		$link = get_edit_post_link($item);
290
+		$link = esc_url($link);
291
+		$name = esc_html(get_the_title($item));
292 292
 		echo "<a href='$link'>$name</a>";
293 293
 	} else {
294
-		echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() );
294
+		echo sprintf(__('Item #%s', 'invoicing'), $subscription->get_product_id());
295 295
 	}
296 296
 
297 297
 }
298
-add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item' );
298
+add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item');
299 299
 
300 300
 /**
301 301
  * Displays the subscription gateway.
302 302
  *
303 303
  * @param WPInv_Subscription $subscription
304 304
  */
305
-function getpaid_admin_subscription_metabox_display_gateway( $subscription ) {
305
+function getpaid_admin_subscription_metabox_display_gateway($subscription) {
306 306
 
307 307
 	$gateway = $subscription->get_gateway();
308 308
 
309
-	if ( ! empty( $gateway ) ) {
310
-		echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) );
309
+	if (!empty($gateway)) {
310
+		echo sanitize_text_field(wpinv_get_gateway_admin_label($gateway));
311 311
 	} else {
312 312
 		echo "&mdash;";
313 313
 	}
314 314
 
315 315
 }
316
-add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' );
316
+add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway');
317 317
 
318 318
 /**
319 319
  * Displays the subscription status.
320 320
  *
321 321
  * @param WPInv_Subscription $subscription
322 322
  */
323
-function getpaid_admin_subscription_metabox_display_status( $subscription ) {
323
+function getpaid_admin_subscription_metabox_display_status($subscription) {
324 324
 	echo $subscription->get_status_label_html();
325 325
 }
326
-add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' );
326
+add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status');
327 327
 
328 328
 /**
329 329
  * Displays the subscription profile id.
330 330
  *
331 331
  * @param WPInv_Subscription $subscription
332 332
  */
333
-function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) {
333
+function getpaid_admin_subscription_metabox_display_profile_id($subscription) {
334 334
 
335 335
 	$profile_id = $subscription->get_profile_id();
336 336
 
337
-	if ( ! empty( $profile_id ) ) {
338
-		$profile_id = sanitize_text_field( $profile_id );
339
-		echo apply_filters( 'getpaid_subscription_profile_id_display', $profile_id, $subscription );
337
+	if (!empty($profile_id)) {
338
+		$profile_id = sanitize_text_field($profile_id);
339
+		echo apply_filters('getpaid_subscription_profile_id_display', $profile_id, $subscription);
340 340
 	} else {
341 341
 		echo "&mdash;";
342 342
 	}
343 343
 
344 344
 }
345
-add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' );
345
+add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id');
346 346
 
347 347
 /**
348 348
  * Displays the subscriptions update metabox.
349 349
  * 
350 350
  * @param WPInv_Subscription $subscription
351 351
  */
352
-function getpaid_admin_subscription_update_metabox( $subscription ) {
352
+function getpaid_admin_subscription_update_metabox($subscription) {
353 353
 
354 354
 	?>
355 355
 	<div class="mt-3">
@@ -362,10 +362,10 @@  discard block
 block discarded – undo
362 362
 					'id'               => 'subscription_status_update_select',
363 363
 					'required'         => true,
364 364
 					'no_wrap'          => false,
365
-					'label'            => __( 'Subscription Status', 'invoicing' ),
366
-					'help_text'        => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
365
+					'label'            => __('Subscription Status', 'invoicing'),
366
+					'help_text'        => __('Updating the status will trigger related actions and hooks', 'invoicing'),
367 367
 					'select2'          => true,
368
-					'value'            => $subscription->get_status( 'edit' ),
368
+					'value'            => $subscription->get_status('edit'),
369 369
 				)
370 370
 			);
371 371
 		?>
@@ -373,13 +373,13 @@  discard block
 block discarded – undo
373 373
 		<div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;">
374 374
 	
375 375
 		<?php
376
-			submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
376
+			submit_button(__('Update', 'invoicing'), 'primary', 'submit', false);
377 377
 
378
-			$url    = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) );
379
-			$anchor = __( 'Renew Subscription', 'invoicing' );
380
-			$title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
378
+			$url    = esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce'));
379
+			$anchor = __('Renew Subscription', 'invoicing');
380
+			$title  = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing');
381 381
 
382
-			if ( $subscription->is_active() ) {
382
+			if ($subscription->is_active()) {
383 383
 				echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>";
384 384
 			}
385 385
 
@@ -391,16 +391,16 @@  discard block
 block discarded – undo
391 391
  * 
392 392
  * @param WPInv_Subscription $subscription
393 393
  */
394
-function getpaid_admin_subscription_invoice_details_metabox( $subscription ) {
394
+function getpaid_admin_subscription_invoice_details_metabox($subscription) {
395 395
 
396 396
 	$columns = apply_filters(
397 397
 		'getpaid_subscription_related_invoices_columns',
398 398
 		array(
399
-			'invoice'      => __( 'Invoice', 'invoicing' ),
400
-			'relationship' => __( 'Relationship', 'invoicing' ),
401
-			'date'         => __( 'Date', 'invoicing' ),
402
-			'status'       => __( 'Status', 'invoicing' ),
403
-			'total'        => __( 'Total', 'invoicing' ),
399
+			'invoice'      => __('Invoice', 'invoicing'),
400
+			'relationship' => __('Relationship', 'invoicing'),
401
+			'date'         => __('Date', 'invoicing'),
402
+			'status'       => __('Status', 'invoicing'),
403
+			'total'        => __('Total', 'invoicing'),
404 404
 		),
405 405
 		$subscription
406 406
 	);
@@ -409,13 +409,13 @@  discard block
 block discarded – undo
409 409
 	$payments = $subscription->get_child_payments();
410 410
 	$parent   = $subscription->get_parent_invoice();
411 411
 
412
-	if ( $parent->get_id() ) {
413
-		$payments = array_merge( array( $parent ), $payments );
412
+	if ($parent->get_id()) {
413
+		$payments = array_merge(array($parent), $payments);
414 414
 	}
415 415
 	
416 416
 	$table_class = 'w-100 bg-white';
417 417
 
418
-	if ( ! is_admin() ) {
418
+	if (!is_admin()) {
419 419
 		$table_class = 'table table-bordered table-striped';
420 420
 	}
421 421
 
@@ -427,9 +427,9 @@  discard block
 block discarded – undo
427 427
 				<thead>
428 428
 					<tr>
429 429
 						<?php
430
-							foreach ( $columns as $key => $label ) {
431
-								$key   = esc_attr( $key );
432
-								$label = sanitize_text_field( $label );
430
+							foreach ($columns as $key => $label) {
431
+								$key   = esc_attr($key);
432
+								$label = sanitize_text_field($label);
433 433
 
434 434
 								echo "<th class='subscription-invoice-field-$key bg-light p-2 text-left color-dark'>$label</th>";
435 435
 							}
@@ -439,50 +439,50 @@  discard block
 block discarded – undo
439 439
 
440 440
 				<tbody>
441 441
 
442
-					<?php if ( empty( $payments ) ) : ?>
442
+					<?php if (empty($payments)) : ?>
443 443
 						<tr>
444 444
 							<td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted">
445
-								<?php _e( 'This subscription has no invoices.', 'invoicing' ); ?>
445
+								<?php _e('This subscription has no invoices.', 'invoicing'); ?>
446 446
 							</td>
447 447
 						</tr>
448 448
 					<?php endif; ?>
449 449
 
450 450
 					<?php
451 451
 
452
-						foreach( $payments as $payment ) :
452
+						foreach ($payments as $payment) :
453 453
 
454 454
 							// Ensure that we have an invoice.
455
-							$payment = new WPInv_Invoice( $payment );
455
+							$payment = new WPInv_Invoice($payment);
456 456
 
457 457
 							// Abort if the invoice is invalid.
458
-							if ( ! $payment->get_id() ) {
458
+							if (!$payment->get_id()) {
459 459
 								continue;
460 460
 							}
461 461
 
462 462
 							echo '<tr>';
463 463
 
464
-								foreach ( array_keys( $columns ) as $key ) {
464
+								foreach (array_keys($columns) as $key) {
465 465
 									
466 466
 									echo '<td class="p-2 text-left">';
467 467
 
468
-										switch( $key ) {
468
+										switch ($key) {
469 469
 
470 470
 											case 'total':
471
-												echo '<strong>' . wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $payment->get_total ) ), $payment->get_currency() ) . '</strong>';
471
+												echo '<strong>' . wpinv_price(wpinv_format_amount(wpinv_sanitize_amount($payment->get_total)), $payment->get_currency()) . '</strong>';
472 472
 												break;
473 473
 
474 474
 											case 'relationship':
475
-												echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' );
475
+												echo $payment->is_renewal() ? __('Renewal Invoice', 'invoicing') : __('Initial Invoice', 'invoicing');
476 476
 												break;
477 477
 
478 478
 											case 'date':
479
-												echo getpaid_format_date_value( $payment->get_date_created() );
479
+												echo getpaid_format_date_value($payment->get_date_created());
480 480
 												break;
481 481
 
482 482
 											case 'status':
483 483
 
484 484
 												$status = $payment->get_status_nicename();
485
-												if ( is_admin() ) {
485
+												if (is_admin()) {
486 486
 													$status = $payment->get_status_label_html();
487 487
 												}
488 488
 
@@ -490,13 +490,13 @@  discard block
 block discarded – undo
490 490
 												break;
491 491
 
492 492
 											case 'invoice':
493
-												$link    = esc_url( get_edit_post_link( $payment->get_id() ) );
493
+												$link = esc_url(get_edit_post_link($payment->get_id()));
494 494
 
495
-												if ( ! is_admin() ) {
496
-													$link = esc_url( $payment->get_view_url() );
495
+												if (!is_admin()) {
496
+													$link = esc_url($payment->get_view_url());
497 497
 												}
498 498
 
499
-												$invoice = sanitize_text_field( $payment->get_number() );
499
+												$invoice = sanitize_text_field($payment->get_number());
500 500
 												echo "<a href='$link'>$invoice</a>";
501 501
 												break;
502 502
 										}
Please login to merge, or discard this patch.
includes/admin/wpinv-upgrade-functions.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -11,55 +11,55 @@  discard block
 block discarded – undo
11 11
  * @since 1.0.0
12 12
 */
13 13
 function wpinv_automatic_upgrade() {
14
-    $wpi_version = get_option( 'wpinv_version' );
14
+    $wpi_version = get_option('wpinv_version');
15 15
 
16 16
     // Update tables.
17
-    if ( ! get_option( 'getpaid_created_invoice_tables' ) ) {
17
+    if (!get_option('getpaid_created_invoice_tables')) {
18 18
         wpinv_v119_upgrades();
19
-        update_option( 'getpaid_created_invoice_tables', true );
19
+        update_option('getpaid_created_invoice_tables', true);
20 20
     }
21 21
 
22
-    if ( $wpi_version == WPINV_VERSION ) {
22
+    if ($wpi_version == WPINV_VERSION) {
23 23
         return;
24 24
     }
25 25
 
26
-    if ( version_compare( $wpi_version, '0.0.5', '<' ) ) {
26
+    if (version_compare($wpi_version, '0.0.5', '<')) {
27 27
         wpinv_v005_upgrades();
28 28
     }
29 29
 
30
-    if ( version_compare( $wpi_version, '1.0.3', '<' ) ) {
30
+    if (version_compare($wpi_version, '1.0.3', '<')) {
31 31
         wpinv_v110_upgrades();
32 32
     }
33 33
 
34
-    update_option( 'wpinv_version', WPINV_VERSION );
34
+    update_option('wpinv_version', WPINV_VERSION);
35 35
 }
36
-add_action( 'admin_init', 'wpinv_automatic_upgrade' );
36
+add_action('admin_init', 'wpinv_automatic_upgrade');
37 37
 
38 38
 function wpinv_v005_upgrades() {
39 39
     global $wpdb;
40 40
 
41 41
     // Invoices status
42
-    $results = $wpdb->get_results( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
43
-    if ( !empty( $results ) ) {
44
-        $wpdb->query( "UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
42
+    $results = $wpdb->get_results("SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
43
+    if (!empty($results)) {
44
+        $wpdb->query("UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
45 45
 
46 46
         // Clean post cache
47
-        foreach ( $results as $row ) {
48
-            clean_post_cache( $row->ID );
47
+        foreach ($results as $row) {
48
+            clean_post_cache($row->ID);
49 49
         }
50 50
     }
51 51
 
52 52
     // Item meta key changes
53 53
     $query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
54
-    $results = $wpdb->get_results( $query );
54
+    $results = $wpdb->get_results($query);
55 55
 
56
-    if ( !empty( $results ) ) {
57
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
58
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
59
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
56
+    if (!empty($results)) {
57
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )");
58
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'");
59
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'");
60 60
         
61
-        foreach ( $results as $row ) {
62
-            clean_post_cache( $row->post_id );
61
+        foreach ($results as $row) {
62
+            clean_post_cache($row->post_id);
63 63
         }
64 64
     }
65 65
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 function wpinv_create_invoices_table() {
89 89
     global $wpdb;
90 90
 
91
-    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
91
+    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
92 92
 
93 93
     // Create invoices table.
94 94
     $table = $wpdb->prefix . 'getpaid_invoices';
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
             KEY `key` ( `key` )
133 133
             ) CHARACTER SET utf8 COLLATE utf8_general_ci;";
134 134
 
135
-    dbDelta( $sql );
135
+    dbDelta($sql);
136 136
 
137 137
     // Create invoice items table.
138 138
     $table = $wpdb->prefix . 'getpaid_invoice_items';
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
             KEY post_id ( post_id )
161 161
             ) CHARACTER SET utf8 COLLATE utf8_general_ci;";
162 162
 
163
-    dbDelta( $sql );
163
+    dbDelta($sql);
164 164
 }
165 165
 
166 166
 /**
@@ -172,29 +172,29 @@  discard block
 block discarded – undo
172 172
     $invoices = array_unique(
173 173
         get_posts(
174 174
             array(
175
-                'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
175
+                'post_type'      => array('wpi_invoice', 'wpi_quote'),
176 176
                 'posts_per_page' => -1,
177 177
                 'fields'         => 'ids',
178
-                'post_status'    => array_keys( wpinv_get_invoice_statuses( true ) ),
178
+                'post_status'    => array_keys(wpinv_get_invoice_statuses(true)),
179 179
             )
180 180
         )
181 181
     );
182 182
     $invoices_table = $wpdb->prefix . 'getpaid_invoices';
183 183
     $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
184 184
 
185
-    if ( ! class_exists( 'WPInv_Legacy_Invoice' ) ) {
186
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php' );
185
+    if (!class_exists('WPInv_Legacy_Invoice')) {
186
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php');
187 187
     }
188 188
 
189 189
     $invoice_rows = array();
190
-    foreach ( $invoices as $invoice ) {
190
+    foreach ($invoices as $invoice) {
191 191
 
192
-        $invoice = new WPInv_Legacy_Invoice( $invoice );
193
-        $fields = array (
192
+        $invoice = new WPInv_Legacy_Invoice($invoice);
193
+        $fields = array(
194 194
             'post_id'        => $invoice->ID,
195 195
             'number'         => $invoice->get_number(),
196 196
             'key'            => $invoice->get_key(),
197
-            'type'           => str_replace( 'wpi_', '', $invoice->post_type ),
197
+            'type'           => str_replace('wpi_', '', $invoice->post_type),
198 198
             'mode'           => $invoice->mode,
199 199
             'user_ip'        => $invoice->get_ip(),
200 200
             'first_name'     => $invoice->get_first_name(),
@@ -223,27 +223,27 @@  discard block
 block discarded – undo
223 223
             'custom_meta'    => $invoice->payment_meta
224 224
         );
225 225
 
226
-        foreach ( $fields as $key => $val ) {
227
-            if ( is_null( $val ) ) {
226
+        foreach ($fields as $key => $val) {
227
+            if (is_null($val)) {
228 228
                 $val = '';
229 229
             }
230
-            $val = maybe_serialize( $val );
231
-            $fields[ $key ] = $wpdb->prepare( '%s', $val );
230
+            $val = maybe_serialize($val);
231
+            $fields[$key] = $wpdb->prepare('%s', $val);
232 232
         }
233 233
 
234
-        $fields = implode( ', ', $fields );
234
+        $fields = implode(', ', $fields);
235 235
         $invoice_rows[] = "($fields)";
236 236
 
237 237
         $item_rows    = array();
238 238
         $item_columns = array();
239
-        foreach ( $invoice->get_cart_details() as $details ) {
239
+        foreach ($invoice->get_cart_details() as $details) {
240 240
             $fields = array(
241 241
                 'post_id'          => $invoice->ID,
242 242
                 'item_id'          => $details['id'],
243 243
                 'item_name'        => $details['name'],
244
-                'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
244
+                'item_description' => empty($details['meta']['description']) ? '' : $details['meta']['description'],
245 245
                 'vat_rate'         => $details['vat_rate'],
246
-                'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
246
+                'vat_class'        => empty($details['vat_class']) ? '_standard' : $details['vat_class'],
247 247
                 'tax'              => $details['tax'],
248 248
                 'item_price'       => $details['item_price'],
249 249
                 'custom_price'     => $details['custom_price'],
@@ -255,26 +255,26 @@  discard block
 block discarded – undo
255 255
                 'fees'             => $details['fees'],
256 256
             );
257 257
 
258
-            $item_columns = array_keys ( $fields );
258
+            $item_columns = array_keys($fields);
259 259
 
260
-            foreach ( $fields as $key => $val ) {
261
-                if ( is_null( $val ) ) {
260
+            foreach ($fields as $key => $val) {
261
+                if (is_null($val)) {
262 262
                     $val = '';
263 263
                 }
264
-                $val = maybe_serialize( $val );
265
-                $fields[ $key ] = $wpdb->prepare( '%s', $val );
264
+                $val = maybe_serialize($val);
265
+                $fields[$key] = $wpdb->prepare('%s', $val);
266 266
             }
267 267
 
268
-            $fields = implode( ', ', $fields );
268
+            $fields = implode(', ', $fields);
269 269
             $item_rows[] = "($fields)";
270 270
         }
271 271
 
272
-        $item_rows    = implode( ', ', $item_rows );
273
-        $item_columns = implode( ', ', $item_columns );
274
-        $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
272
+        $item_rows    = implode(', ', $item_rows);
273
+        $item_columns = implode(', ', $item_columns);
274
+        $wpdb->query("INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows");
275 275
     }
276 276
 
277
-    $invoice_rows = implode( ', ', $invoice_rows );
278
-    $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
277
+    $invoice_rows = implode(', ', $invoice_rows);
278
+    $wpdb->query("INSERT INTO $invoices_table VALUES $invoice_rows");
279 279
 
280 280
 }
Please login to merge, or discard this patch.