@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,10 +21,10 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the invoice. |
27 | - $invoice = new WPInv_Invoice( $post ); |
|
27 | + $invoice = new WPInv_Invoice($post); |
|
28 | 28 | |
29 | 29 | ?> |
30 | 30 | |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | 'id' => 'wpinv_key', |
48 | 48 | 'name' => 'wpinv_key', |
49 | 49 | 'label' => sprintf( |
50 | - __( '%s Key:', 'invoicing' ), |
|
51 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
50 | + __('%s Key:', 'invoicing'), |
|
51 | + ucfirst($invoice->get_invoice_quote_type()) |
|
52 | 52 | ), |
53 | 53 | 'label_type' => 'vertical', |
54 | 54 | 'class' => 'form-control-sm', |
55 | - 'value' => $invoice->get_key( 'edit' ), |
|
55 | + 'value' => $invoice->get_key('edit'), |
|
56 | 56 | 'extra_attributes' => array( |
57 | 57 | 'onclick' => 'this.select();', |
58 | 58 | 'readonly' => 'true', |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | 'id' => 'wpinv_view_url', |
68 | 68 | 'name' => 'wpinv_view_url', |
69 | 69 | 'label' => sprintf( |
70 | - __( '%s URL:', 'invoicing' ), |
|
71 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
70 | + __('%s URL:', 'invoicing'), |
|
71 | + ucfirst($invoice->get_invoice_quote_type()) |
|
72 | 72 | ), |
73 | 73 | 'label_type' => 'vertical', |
74 | 74 | 'class' => 'form-control-sm', |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | ); |
82 | 82 | |
83 | 83 | // If the invoice is paid... |
84 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
84 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
85 | 85 | |
86 | 86 | // Payment date. |
87 | 87 | echo aui()->input( |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | 'type' => 'datepicker', |
90 | 90 | 'id' => 'wpinv_date_completed', |
91 | 91 | 'name' => 'date_completed', |
92 | - 'label' => __( 'Payment Date:', 'invoicing' ), |
|
92 | + 'label' => __('Payment Date:', 'invoicing'), |
|
93 | 93 | 'label_type' => 'vertical', |
94 | 94 | 'placeholder' => 'YYYY-MM-DD 00:00', |
95 | 95 | 'class' => 'form-control-sm', |
96 | - 'value' => $invoice->get_date_completed( 'edit' ), |
|
96 | + 'value' => $invoice->get_date_completed('edit'), |
|
97 | 97 | 'extra_attributes' => array( |
98 | 98 | 'data-enable-time' => 'true', |
99 | 99 | 'data-time_24hr' => 'true', |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | 'type' => 'text', |
109 | 109 | 'id' => 'wpinv_gateway', |
110 | 110 | 'name' => '', |
111 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
111 | + 'label' => __('Gateway:', 'invoicing'), |
|
112 | 112 | 'label_type' => 'vertical', |
113 | 113 | 'class' => 'form-control-sm', |
114 | - 'value' => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ), |
|
114 | + 'value' => wpinv_get_gateway_admin_label($invoice->get_gateway('edit')), |
|
115 | 115 | 'extra_attributes' => array( |
116 | 116 | 'onclick' => 'this.select();', |
117 | 117 | 'readonly' => 'true', |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | 'type' => 'text', |
126 | 126 | 'id' => 'wpinv_transaction_id', |
127 | 127 | 'name' => 'wpinv_transaction_id', |
128 | - 'label' => __( 'Transaction ID:', 'invoicing' ), |
|
128 | + 'label' => __('Transaction ID:', 'invoicing'), |
|
129 | 129 | 'label_type' => 'vertical', |
130 | 130 | 'class' => 'form-control-sm', |
131 | - 'value' => $invoice->get_transaction_id( 'edit' ), |
|
132 | - 'help_text' => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ), |
|
131 | + 'value' => $invoice->get_transaction_id('edit'), |
|
132 | + 'help_text' => apply_filters('wpinv_invoice_transaction_link_' . $invoice->get_gateway('edit'), '', $invoice->get_transaction_id(), $invoice), |
|
133 | 133 | 'extra_attributes' => array( |
134 | 134 | 'onclick' => 'this.select();', |
135 | 135 | 'readonly' => 'true', |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | 'type' => 'text', |
144 | 144 | 'id' => 'wpinv_currency', |
145 | 145 | 'name' => 'wpinv_currency', |
146 | - 'label' => __( 'Currency:', 'invoicing' ), |
|
146 | + 'label' => __('Currency:', 'invoicing'), |
|
147 | 147 | 'label_type' => 'vertical', |
148 | 148 | 'class' => 'form-control-sm', |
149 | - 'value' => $invoice->get_currency( 'edit' ), |
|
149 | + 'value' => $invoice->get_currency('edit'), |
|
150 | 150 | 'extra_attributes' => array( |
151 | 151 | 'onclick' => 'this.select();', |
152 | 152 | 'readonly' => 'true', |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | } else { |
158 | 158 | |
159 | - if ( 'wpi_invoice' == $invoice->get_post_type() ) { |
|
159 | + if ('wpi_invoice' == $invoice->get_post_type()) { |
|
160 | 160 | |
161 | 161 | // Payment URL. |
162 | 162 | echo aui()->input( |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | 'type' => 'text', |
165 | 165 | 'id' => 'wpinv_payment_url', |
166 | 166 | 'name' => 'wpinv_payment_url', |
167 | - 'label' => __( 'Payment URL:', 'invoicing' ), |
|
167 | + 'label' => __('Payment URL:', 'invoicing'), |
|
168 | 168 | 'label_type' => 'vertical', |
169 | 169 | 'class' => 'form-control-sm', |
170 | 170 | 'value' => $invoice->get_checkout_payment_url(), |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | array( |
181 | 181 | 'id' => 'wpinv_gateway', |
182 | 182 | 'name' => 'wpinv_gateway', |
183 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
183 | + 'label' => __('Gateway:', 'invoicing'), |
|
184 | 184 | 'label_type' => 'vertical', |
185 | - 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
186 | - 'value' => $invoice->get_gateway( 'edit' ), |
|
185 | + 'placeholder' => __('Select Gateway', 'invoicing'), |
|
186 | + 'value' => $invoice->get_gateway('edit'), |
|
187 | 187 | 'select2' => true, |
188 | 188 | 'data-allow-clear' => 'false', |
189 | - 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
189 | + 'options' => wp_list_pluck(wpinv_get_enabled_payment_gateways(true), 'admin_label'), |
|
190 | 190 | ) |
191 | 191 | ); |
192 | 192 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the invoice. |
27 | - $invoice = new WPInv_Invoice( $post ); |
|
28 | - $customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id(); |
|
29 | - $customer = new WP_User( $customer ); |
|
30 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email ); |
|
31 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
27 | + $invoice = new WPInv_Invoice($post); |
|
28 | + $customer = $invoice->exists() ? $invoice->get_user_id('edit') : get_current_user_id(); |
|
29 | + $customer = new WP_User($customer); |
|
30 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email); |
|
31 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
32 | 32 | |
33 | 33 | ?> |
34 | 34 | |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | <div class="col-12 col-sm-6"> |
44 | 44 | <div id="getpaid-invoice-user-id-wrapper" class="form-group"> |
45 | 45 | <div> |
46 | - <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label> |
|
46 | + <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label> |
|
47 | 47 | </div> |
48 | 48 | <div> |
49 | - <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e( 'Search for a customer by email or name', 'invoicing' ); ?>"> |
|
50 | - <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo sanitize_text_field( $display ); ?> </option>) |
|
49 | + <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e('Search for a customer by email or name', 'invoicing'); ?>"> |
|
50 | + <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo sanitize_text_field($display); ?> </option>) |
|
51 | 51 | </select> |
52 | 52 | </div> |
53 | 53 | </div> |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | 'type' => 'text', |
61 | 61 | 'id' => 'getpaid-invoice-new-user-email', |
62 | 62 | 'name' => 'wpinv_email', |
63 | - 'label' => __( 'Email', 'invoicing' ) . '<span class="required">*</span>', |
|
63 | + 'label' => __('Email', 'invoicing') . '<span class="required">*</span>', |
|
64 | 64 | 'label_type' => 'vertical', |
65 | 65 | 'placeholder' => '[email protected]', |
66 | 66 | 'class' => 'form-control-sm', |
@@ -70,18 +70,18 @@ discard block |
||
70 | 70 | </div> |
71 | 71 | </div> |
72 | 72 | <div class="col-12 col-sm-6 form-group mt-sm-4"> |
73 | - <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
|
73 | + <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?> |
|
74 | 74 | <a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)"> |
75 | 75 | <i aria-hidden="true" class="fa fa-refresh"></i> |
76 | - <?php _e( 'Fill User Details', 'invoicing' );?> |
|
76 | + <?php _e('Fill User Details', 'invoicing'); ?> |
|
77 | 77 | </a> |
78 | 78 | <a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)"> |
79 | 79 | <i aria-hidden="true" class="fa fa-plus"></i> |
80 | - <?php _e( 'Add New User', 'invoicing' );?> |
|
80 | + <?php _e('Add New User', 'invoicing'); ?> |
|
81 | 81 | </a> |
82 | 82 | <a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)"> |
83 | 83 | <i aria-hidden="true" class="fa fa-close"></i> |
84 | - <?php _e( 'Cancel', 'invoicing' );?> |
|
84 | + <?php _e('Cancel', 'invoicing'); ?> |
|
85 | 85 | </a> |
86 | 86 | <?php endif; ?> |
87 | 87 | </div> |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | 'type' => 'text', |
95 | 95 | 'id' => 'wpinv_first_name', |
96 | 96 | 'name' => 'wpinv_first_name', |
97 | - 'label' => __( 'First Name', 'invoicing' ), |
|
97 | + 'label' => __('First Name', 'invoicing'), |
|
98 | 98 | 'label_type' => 'vertical', |
99 | 99 | 'placeholder' => '', |
100 | 100 | 'class' => 'form-control-sm', |
101 | - 'value' => $invoice->get_first_name( 'edit' ), |
|
101 | + 'value' => $invoice->get_first_name('edit'), |
|
102 | 102 | ) |
103 | 103 | ); |
104 | 104 | ?> |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | 'type' => 'text', |
111 | 111 | 'id' => 'wpinv_last_name', |
112 | 112 | 'name' => 'wpinv_last_name', |
113 | - 'label' => __( 'Last Name', 'invoicing' ), |
|
113 | + 'label' => __('Last Name', 'invoicing'), |
|
114 | 114 | 'label_type' => 'vertical', |
115 | 115 | 'placeholder' => '', |
116 | 116 | 'class' => 'form-control-sm', |
117 | - 'value' => $invoice->get_last_name( 'edit' ), |
|
117 | + 'value' => $invoice->get_last_name('edit'), |
|
118 | 118 | ) |
119 | 119 | ); |
120 | 120 | ?> |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | 'type' => 'text', |
130 | 130 | 'id' => 'wpinv_company', |
131 | 131 | 'name' => 'wpinv_company', |
132 | - 'label' => __( 'Company', 'invoicing' ), |
|
132 | + 'label' => __('Company', 'invoicing'), |
|
133 | 133 | 'label_type' => 'vertical', |
134 | 134 | 'placeholder' => '', |
135 | 135 | 'class' => 'form-control-sm', |
136 | - 'value' => $invoice->get_company( 'edit' ), |
|
136 | + 'value' => $invoice->get_company('edit'), |
|
137 | 137 | ) |
138 | 138 | ); |
139 | 139 | ?> |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | 'type' => 'text', |
146 | 146 | 'id' => 'wpinv_vat_number', |
147 | 147 | 'name' => 'wpinv_vat_number', |
148 | - 'label' => __( 'Vat Number', 'invoicing' ), |
|
148 | + 'label' => __('Vat Number', 'invoicing'), |
|
149 | 149 | 'label_type' => 'vertical', |
150 | 150 | 'placeholder' => '', |
151 | 151 | 'class' => 'form-control-sm', |
152 | - 'value' => $invoice->get_vat_number( 'edit' ), |
|
152 | + 'value' => $invoice->get_vat_number('edit'), |
|
153 | 153 | ) |
154 | 154 | ); |
155 | 155 | ?> |
@@ -164,11 +164,11 @@ discard block |
||
164 | 164 | 'type' => 'text', |
165 | 165 | 'id' => 'wpinv_address', |
166 | 166 | 'name' => 'wpinv_address', |
167 | - 'label' => __( 'Address', 'invoicing' ), |
|
167 | + 'label' => __('Address', 'invoicing'), |
|
168 | 168 | 'label_type' => 'vertical', |
169 | 169 | 'placeholder' => '', |
170 | 170 | 'class' => 'form-control-sm', |
171 | - 'value' => $invoice->get_address( 'edit' ), |
|
171 | + 'value' => $invoice->get_address('edit'), |
|
172 | 172 | ) |
173 | 173 | ); |
174 | 174 | ?> |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | 'type' => 'text', |
181 | 181 | 'id' => 'wpinv_city', |
182 | 182 | 'name' => 'wpinv_city', |
183 | - 'label' => __( 'City', 'invoicing' ), |
|
183 | + 'label' => __('City', 'invoicing'), |
|
184 | 184 | 'label_type' => 'vertical', |
185 | 185 | 'placeholder' => '', |
186 | 186 | 'class' => 'form-control-sm', |
187 | - 'value' => $invoice->get_city( 'edit' ), |
|
187 | + 'value' => $invoice->get_city('edit'), |
|
188 | 188 | ) |
189 | 189 | ); |
190 | 190 | ?> |
@@ -198,11 +198,11 @@ discard block |
||
198 | 198 | array( |
199 | 199 | 'id' => 'wpinv_country', |
200 | 200 | 'name' => 'wpinv_country', |
201 | - 'label' => __( 'Country', 'invoicing' ), |
|
201 | + 'label' => __('Country', 'invoicing'), |
|
202 | 202 | 'label_type' => 'vertical', |
203 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
203 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
204 | 204 | 'class' => 'form-control-sm', |
205 | - 'value' => $invoice->get_country( 'edit' ), |
|
205 | + 'value' => $invoice->get_country('edit'), |
|
206 | 206 | 'options' => wpinv_get_country_list(), |
207 | 207 | 'data-allow-clear' => 'false', |
208 | 208 | 'select2' => true, |
@@ -213,20 +213,20 @@ discard block |
||
213 | 213 | <div class="col-12 col-sm-6"> |
214 | 214 | <?php |
215 | 215 | |
216 | - $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) ); |
|
216 | + $states = wpinv_get_country_states($invoice->get_country('edit')); |
|
217 | 217 | |
218 | - if ( empty( $states ) ) { |
|
218 | + if (empty($states)) { |
|
219 | 219 | |
220 | 220 | echo aui()->input( |
221 | 221 | array( |
222 | 222 | 'type' => 'text', |
223 | 223 | 'id' => 'wpinv_state', |
224 | 224 | 'name' => 'wpinv_state', |
225 | - 'label' => __( 'State', 'invoicing' ), |
|
225 | + 'label' => __('State', 'invoicing'), |
|
226 | 226 | 'label_type' => 'vertical', |
227 | 227 | 'placeholder' => '', |
228 | 228 | 'class' => 'form-control-sm', |
229 | - 'value' => $invoice->get_state( 'edit' ), |
|
229 | + 'value' => $invoice->get_state('edit'), |
|
230 | 230 | ) |
231 | 231 | ); |
232 | 232 | |
@@ -236,11 +236,11 @@ discard block |
||
236 | 236 | array( |
237 | 237 | 'id' => 'wpinv_state', |
238 | 238 | 'name' => 'wpinv_state', |
239 | - 'label' => __( 'State', 'invoicing' ), |
|
239 | + 'label' => __('State', 'invoicing'), |
|
240 | 240 | 'label_type' => 'vertical', |
241 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
241 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
242 | 242 | 'class' => 'form-control-sm', |
243 | - 'value' => $invoice->get_state( 'edit' ), |
|
243 | + 'value' => $invoice->get_state('edit'), |
|
244 | 244 | 'options' => $states, |
245 | 245 | 'data-allow-clear' => 'false', |
246 | 246 | 'select2' => true, |
@@ -261,11 +261,11 @@ discard block |
||
261 | 261 | 'type' => 'text', |
262 | 262 | 'id' => 'wpinv_zip', |
263 | 263 | 'name' => 'wpinv_zip', |
264 | - 'label' => __( 'Zip / Postal Code', 'invoicing' ), |
|
264 | + 'label' => __('Zip / Postal Code', 'invoicing'), |
|
265 | 265 | 'label_type' => 'vertical', |
266 | 266 | 'placeholder' => '', |
267 | 267 | 'class' => 'form-control-sm', |
268 | - 'value' => $invoice->get_zip( 'edit' ), |
|
268 | + 'value' => $invoice->get_zip('edit'), |
|
269 | 269 | ) |
270 | 270 | ); |
271 | 271 | ?> |
@@ -277,11 +277,11 @@ discard block |
||
277 | 277 | 'type' => 'text', |
278 | 278 | 'id' => 'wpinv_phone', |
279 | 279 | 'name' => 'wpinv_phone', |
280 | - 'label' => __( 'Phone', 'invoicing' ), |
|
280 | + 'label' => __('Phone', 'invoicing'), |
|
281 | 281 | 'label_type' => 'vertical', |
282 | 282 | 'placeholder' => '', |
283 | 283 | 'class' => 'form-control-sm', |
284 | - 'value' => $invoice->get_phone( 'edit' ), |
|
284 | + 'value' => $invoice->get_phone('edit'), |
|
285 | 285 | ) |
286 | 286 | ); |
287 | 287 | ?> |
@@ -297,49 +297,49 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @param int $post_id |
299 | 299 | */ |
300 | - public static function save( $post_id ) { |
|
300 | + public static function save($post_id) { |
|
301 | 301 | |
302 | 302 | // Prepare the invoice. |
303 | - $invoice = new WPInv_Invoice( $post_id ); |
|
303 | + $invoice = new WPInv_Invoice($post_id); |
|
304 | 304 | |
305 | 305 | // Load new data. |
306 | 306 | $invoice->set_props( |
307 | 307 | array( |
308 | - 'template' => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null, |
|
309 | - 'email_cc' => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null, |
|
310 | - 'disable_taxes' => isset( $_POST['disable_taxes'] ), |
|
311 | - 'currency' => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null, |
|
312 | - 'gateway' => ( $invoice->needs_payment() && isset( $_POST['wpinv_gateway'] ) ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null, |
|
313 | - 'address' => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null, |
|
314 | - 'vat_number' => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null, |
|
315 | - 'company' => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null, |
|
316 | - 'zip' => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null, |
|
317 | - 'state' => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null, |
|
318 | - 'city' => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null, |
|
319 | - 'country' => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null, |
|
320 | - 'phone' => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null, |
|
321 | - 'first_name' => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null, |
|
322 | - 'last_name' => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null, |
|
323 | - 'author' => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null, |
|
324 | - 'date_created' => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null, |
|
325 | - 'due_date' => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null, |
|
326 | - 'number' => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null, |
|
327 | - 'status' => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null, |
|
308 | + 'template' => isset($_POST['wpinv_template']) ? wpinv_clean($_POST['wpinv_template']) : null, |
|
309 | + 'email_cc' => isset($_POST['wpinv_cc']) ? wpinv_clean($_POST['wpinv_cc']) : null, |
|
310 | + 'disable_taxes' => isset($_POST['disable_taxes']), |
|
311 | + 'currency' => isset($_POST['wpinv_currency']) ? wpinv_clean($_POST['wpinv_currency']) : null, |
|
312 | + 'gateway' => ($invoice->needs_payment() && isset($_POST['wpinv_gateway'])) ? wpinv_clean($_POST['wpinv_gateway']) : null, |
|
313 | + 'address' => isset($_POST['wpinv_address']) ? wpinv_clean($_POST['wpinv_address']) : null, |
|
314 | + 'vat_number' => isset($_POST['wpinv_vat_number']) ? wpinv_clean($_POST['wpinv_vat_number']) : null, |
|
315 | + 'company' => isset($_POST['wpinv_company']) ? wpinv_clean($_POST['wpinv_company']) : null, |
|
316 | + 'zip' => isset($_POST['wpinv_zip']) ? wpinv_clean($_POST['wpinv_zip']) : null, |
|
317 | + 'state' => isset($_POST['wpinv_state']) ? wpinv_clean($_POST['wpinv_state']) : null, |
|
318 | + 'city' => isset($_POST['wpinv_city']) ? wpinv_clean($_POST['wpinv_city']) : null, |
|
319 | + 'country' => isset($_POST['wpinv_country']) ? wpinv_clean($_POST['wpinv_country']) : null, |
|
320 | + 'phone' => isset($_POST['wpinv_phone']) ? wpinv_clean($_POST['wpinv_phone']) : null, |
|
321 | + 'first_name' => isset($_POST['wpinv_first_name']) ? wpinv_clean($_POST['wpinv_first_name']) : null, |
|
322 | + 'last_name' => isset($_POST['wpinv_last_name']) ? wpinv_clean($_POST['wpinv_last_name']) : null, |
|
323 | + 'author' => isset($_POST['post_author_override']) ? wpinv_clean($_POST['post_author_override']) : null, |
|
324 | + 'date_created' => isset($_POST['date_created']) ? wpinv_clean($_POST['date_created']) : null, |
|
325 | + 'due_date' => isset($_POST['wpinv_due_date']) ? wpinv_clean($_POST['wpinv_due_date']) : null, |
|
326 | + 'number' => isset($_POST['wpinv_number']) ? wpinv_clean($_POST['wpinv_number']) : null, |
|
327 | + 'status' => isset($_POST['wpinv_status']) ? wpinv_clean($_POST['wpinv_status']) : null, |
|
328 | 328 | ) |
329 | 329 | ); |
330 | 330 | |
331 | 331 | // Discount code. |
332 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
332 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
333 | 333 | |
334 | - if ( isset( $_POST['wpinv_discount_code'] ) ) { |
|
335 | - $invoice->set_discount_code( $_POST['wpinv_discount_code'] ); |
|
334 | + if (isset($_POST['wpinv_discount_code'])) { |
|
335 | + $invoice->set_discount_code($_POST['wpinv_discount_code']); |
|
336 | 336 | } |
337 | 337 | |
338 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
339 | - if ( $discount->exists() ) { |
|
340 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
338 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
339 | + if ($discount->exists()) { |
|
340 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
341 | 341 | } else { |
342 | - $invoice->remove_discount( 'discount_code' ); |
|
342 | + $invoice->remove_discount('discount_code'); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | // Recalculate totals. |
@@ -348,17 +348,17 @@ discard block |
||
348 | 348 | } |
349 | 349 | |
350 | 350 | // If we're creating a new user... |
351 | - if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( $_POST['wpinv_email'] ) ) { |
|
351 | + if (!empty($_POST['wpinv_new_user']) && is_email($_POST['wpinv_email'])) { |
|
352 | 352 | |
353 | 353 | // Attempt to create the user. |
354 | - $user = wpinv_create_user( sanitize_email( $_POST['wpinv_email'] ) ); |
|
354 | + $user = wpinv_create_user(sanitize_email($_POST['wpinv_email'])); |
|
355 | 355 | |
356 | 356 | |
357 | 357 | // If successful, update the invoice author. |
358 | - if ( is_numeric( $user ) ) { |
|
359 | - $invoice->set_author( $user ); |
|
358 | + if (is_numeric($user)) { |
|
359 | + $invoice->set_author($user); |
|
360 | 360 | } else { |
361 | - wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ ); |
|
361 | + wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__); |
|
362 | 362 | } |
363 | 363 | } |
364 | 364 | |
@@ -372,23 +372,23 @@ discard block |
||
372 | 372 | $GLOBALS['wpinv_skip_invoice_notification'] = false; |
373 | 373 | |
374 | 374 | // (Maybe) send new user notification. |
375 | - if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', true ) ) { |
|
376 | - wp_send_new_user_notifications( $user, 'user' ); |
|
375 | + if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', true)) { |
|
376 | + wp_send_new_user_notifications($user, 'user'); |
|
377 | 377 | } |
378 | 378 | |
379 | - if ( ! empty( $_POST['send_to_customer'] ) && ! $invoice->is_draft() ) { |
|
379 | + if (!empty($_POST['send_to_customer']) && !$invoice->is_draft()) { |
|
380 | 380 | |
381 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true ); |
|
381 | + $sent = getpaid()->get('invoice_emails')->user_invoice($invoice, true); |
|
382 | 382 | |
383 | - if ( $sent ) { |
|
384 | - getpaid_admin()->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
383 | + if ($sent) { |
|
384 | + getpaid_admin()->show_success(__('Invoice was successfully sent to the customer', 'invoicing')); |
|
385 | 385 | } else { |
386 | - getpaid_admin()->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) ); |
|
386 | + getpaid_admin()->show_error(__('Could not send the invoice to the customer', 'invoicing')); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | } |
390 | 390 | |
391 | 391 | // Fires after an invoice is saved. |
392 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
392 | + do_action('wpinv_invoice_metabox_saved', $invoice); |
|
393 | 393 | } |
394 | 394 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Authorize.net Payment Gateway class. |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @var array |
26 | 26 | */ |
27 | - protected $supports = array( 'subscription', 'sandbox', 'tokens', 'addons' ); |
|
27 | + protected $supports = array('subscription', 'sandbox', 'tokens', 'addons'); |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Payment method order. |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @var array |
54 | 54 | */ |
55 | - public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' ); |
|
55 | + public $currencies = array('USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD'); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * URL to view a transaction. |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function __construct() { |
68 | 68 | |
69 | - $this->title = __( 'Credit Card / Debit Card', 'invoicing' ); |
|
70 | - $this->method_title = __( 'Authorize.Net', 'invoicing' ); |
|
71 | - $this->notify_url = wpinv_get_ipn_url( $this->id ); |
|
69 | + $this->title = __('Credit Card / Debit Card', 'invoicing'); |
|
70 | + $this->method_title = __('Authorize.Net', 'invoicing'); |
|
71 | + $this->notify_url = wpinv_get_ipn_url($this->id); |
|
72 | 72 | |
73 | - add_filter( 'getpaid_daily_maintenance_should_expire_subscription', array( $this, 'maybe_renew_subscription' ), 10, 2 ); |
|
74 | - add_filter( 'getpaid_authorizenet_sandbox_notice', array( $this, 'sandbox_notice' ) ); |
|
73 | + add_filter('getpaid_daily_maintenance_should_expire_subscription', array($this, 'maybe_renew_subscription'), 10, 2); |
|
74 | + add_filter('getpaid_authorizenet_sandbox_notice', array($this, 'sandbox_notice')); |
|
75 | 75 | parent::__construct(); |
76 | 76 | } |
77 | 77 | |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | * @param int $invoice_id 0 or invoice id. |
82 | 82 | * @param GetPaid_Payment_Form $form Current payment form. |
83 | 83 | */ |
84 | - public function payment_fields( $invoice_id, $form ) { |
|
84 | + public function payment_fields($invoice_id, $form) { |
|
85 | 85 | |
86 | 86 | // Let the user select a payment method. |
87 | 87 | echo $this->saved_payment_methods(); |
88 | 88 | |
89 | 89 | // Show the credit card entry form. |
90 | - echo $this->new_payment_method_entry( $this->get_cc_form( true ) ); |
|
90 | + echo $this->new_payment_method_entry($this->get_cc_form(true)); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -100,64 +100,64 @@ discard block |
||
100 | 100 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
101 | 101 | * @return string|WP_Error Payment profile id. |
102 | 102 | */ |
103 | - public function create_customer_profile( $invoice, $submission_data, $save = true ) { |
|
103 | + public function create_customer_profile($invoice, $submission_data, $save = true) { |
|
104 | 104 | |
105 | 105 | // Remove non-digits from the number |
106 | - $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
|
106 | + $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']); |
|
107 | 107 | |
108 | 108 | // Generate args. |
109 | 109 | $args = array( |
110 | 110 | 'createCustomerProfileRequest' => array( |
111 | 111 | 'merchantAuthentication' => $this->get_auth_params(), |
112 | 112 | 'profile' => array( |
113 | - 'merchantCustomerId' => getpaid_limit_length( $invoice->get_user_id(), 20 ), |
|
114 | - 'description' => getpaid_limit_length( $invoice->get_full_name(), 255 ), |
|
115 | - 'email' => getpaid_limit_length( $invoice->get_email(), 255 ), |
|
113 | + 'merchantCustomerId' => getpaid_limit_length($invoice->get_user_id(), 20), |
|
114 | + 'description' => getpaid_limit_length($invoice->get_full_name(), 255), |
|
115 | + 'email' => getpaid_limit_length($invoice->get_email(), 255), |
|
116 | 116 | 'paymentProfiles' => array( |
117 | 117 | 'customerType' => 'individual', |
118 | 118 | |
119 | 119 | // Billing information. |
120 | 120 | 'billTo' => array( |
121 | - 'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ), |
|
122 | - 'lastName' => getpaid_limit_length( $invoice->get_last_name(), 50 ), |
|
123 | - 'address' => getpaid_limit_length( $invoice->get_address(), 60 ), |
|
124 | - 'city' => getpaid_limit_length( $invoice->get_city(), 40 ), |
|
125 | - 'state' => getpaid_limit_length( $invoice->get_state(), 40 ), |
|
126 | - 'zip' => getpaid_limit_length( $invoice->get_zip(), 20 ), |
|
127 | - 'country' => getpaid_limit_length( $invoice->get_country(), 60 ), |
|
121 | + 'firstName' => getpaid_limit_length($invoice->get_first_name(), 50), |
|
122 | + 'lastName' => getpaid_limit_length($invoice->get_last_name(), 50), |
|
123 | + 'address' => getpaid_limit_length($invoice->get_address(), 60), |
|
124 | + 'city' => getpaid_limit_length($invoice->get_city(), 40), |
|
125 | + 'state' => getpaid_limit_length($invoice->get_state(), 40), |
|
126 | + 'zip' => getpaid_limit_length($invoice->get_zip(), 20), |
|
127 | + 'country' => getpaid_limit_length($invoice->get_country(), 60), |
|
128 | 128 | ), |
129 | 129 | |
130 | 130 | // Payment information. |
131 | - 'payment' => $this->get_payment_information( $submission_data['authorizenet'] ), |
|
131 | + 'payment' => $this->get_payment_information($submission_data['authorizenet']), |
|
132 | 132 | ) |
133 | 133 | ), |
134 | - 'validationMode' => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode', |
|
134 | + 'validationMode' => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode', |
|
135 | 135 | ) |
136 | 136 | ); |
137 | 137 | |
138 | - $response = $this->post( apply_filters( 'getpaid_authorizenet_customer_profile_args', $args, $invoice ), $invoice ); |
|
138 | + $response = $this->post(apply_filters('getpaid_authorizenet_customer_profile_args', $args, $invoice), $invoice); |
|
139 | 139 | |
140 | - if ( is_wp_error( $response ) ) { |
|
140 | + if (is_wp_error($response)) { |
|
141 | 141 | return $response; |
142 | 142 | } |
143 | 143 | |
144 | - update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $response->customerProfileId ); |
|
144 | + update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $response->customerProfileId); |
|
145 | 145 | |
146 | 146 | // Save the payment token. |
147 | - if ( $save ) { |
|
147 | + if ($save) { |
|
148 | 148 | $this->save_token( |
149 | 149 | array( |
150 | 150 | 'id' => $response->customerPaymentProfileIdList[0], |
151 | - 'name' => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . '····' . substr( $submission_data['authorizenet']['cc_number'], -4 ), |
|
151 | + 'name' => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . '····' . substr($submission_data['authorizenet']['cc_number'], -4), |
|
152 | 152 | 'default' => true, |
153 | - 'type' => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live', |
|
153 | + 'type' => $this->is_sandbox($invoice) ? 'sandbox' : 'live', |
|
154 | 154 | ) |
155 | 155 | ); |
156 | 156 | } |
157 | 157 | |
158 | 158 | // Add a note about the validation response. |
159 | 159 | $invoice->add_note( |
160 | - sprintf( __( 'Created Authorize.NET customer profile: %s', 'invoicing' ), $response->validationDirectResponseList[0] ), |
|
160 | + sprintf(__('Created Authorize.NET customer profile: %s', 'invoicing'), $response->validationDirectResponseList[0]), |
|
161 | 161 | false, |
162 | 162 | false, |
163 | 163 | true |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @return string|WP_Error Profile id. |
175 | 175 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile |
176 | 176 | */ |
177 | - public function get_customer_profile( $profile_id ) { |
|
177 | + public function get_customer_profile($profile_id) { |
|
178 | 178 | |
179 | 179 | // Generate args. |
180 | 180 | $args = array( |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | ) |
185 | 185 | ); |
186 | 186 | |
187 | - return $this->post( $args, false ); |
|
187 | + return $this->post($args, false); |
|
188 | 188 | |
189 | 189 | } |
190 | 190 | |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
200 | 200 | * @return string|WP_Error Profile id. |
201 | 201 | */ |
202 | - public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) { |
|
202 | + public function create_customer_payment_profile($customer_profile, $invoice, $submission_data, $save) { |
|
203 | 203 | |
204 | 204 | // Remove non-digits from the number |
205 | - $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
|
205 | + $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']); |
|
206 | 206 | |
207 | 207 | // Generate args. |
208 | 208 | $args = array( |
@@ -213,34 +213,34 @@ discard block |
||
213 | 213 | |
214 | 214 | // Billing information. |
215 | 215 | 'billTo' => array( |
216 | - 'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ), |
|
217 | - 'lastName' => getpaid_limit_length( $invoice->get_last_name(), 50 ), |
|
218 | - 'address' => getpaid_limit_length( $invoice->get_address(), 60 ), |
|
219 | - 'city' => getpaid_limit_length( $invoice->get_city(), 40 ), |
|
220 | - 'state' => getpaid_limit_length( $invoice->get_state(), 40 ), |
|
221 | - 'zip' => getpaid_limit_length( $invoice->get_zip(), 20 ), |
|
222 | - 'country' => getpaid_limit_length( $invoice->get_country(), 60 ), |
|
216 | + 'firstName' => getpaid_limit_length($invoice->get_first_name(), 50), |
|
217 | + 'lastName' => getpaid_limit_length($invoice->get_last_name(), 50), |
|
218 | + 'address' => getpaid_limit_length($invoice->get_address(), 60), |
|
219 | + 'city' => getpaid_limit_length($invoice->get_city(), 40), |
|
220 | + 'state' => getpaid_limit_length($invoice->get_state(), 40), |
|
221 | + 'zip' => getpaid_limit_length($invoice->get_zip(), 20), |
|
222 | + 'country' => getpaid_limit_length($invoice->get_country(), 60), |
|
223 | 223 | ), |
224 | 224 | |
225 | 225 | // Payment information. |
226 | - 'payment' => $this->get_payment_information( $submission_data['authorizenet'] ) |
|
226 | + 'payment' => $this->get_payment_information($submission_data['authorizenet']) |
|
227 | 227 | ), |
228 | - 'validationMode' => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode', |
|
228 | + 'validationMode' => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode', |
|
229 | 229 | ) |
230 | 230 | ); |
231 | 231 | |
232 | - $response = $this->post( apply_filters( 'getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice ), $invoice ); |
|
232 | + $response = $this->post(apply_filters('getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice), $invoice); |
|
233 | 233 | |
234 | - if ( is_wp_error( $response ) ) { |
|
234 | + if (is_wp_error($response)) { |
|
235 | 235 | return $response; |
236 | 236 | } |
237 | 237 | |
238 | 238 | // Save the payment token. |
239 | - if ( $save ) { |
|
239 | + if ($save) { |
|
240 | 240 | $this->save_token( |
241 | 241 | array( |
242 | 242 | 'id' => $response->customerPaymentProfileId, |
243 | - 'name' => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . ' ···· ' . substr( $submission_data['authorizenet']['cc_number'], -4 ), |
|
243 | + 'name' => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . ' ···· ' . substr($submission_data['authorizenet']['cc_number'], -4), |
|
244 | 244 | 'default' => true |
245 | 245 | ) |
246 | 246 | ); |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | |
249 | 249 | // Add a note about the validation response. |
250 | 250 | $invoice->add_note( |
251 | - sprintf( __( 'Saved Authorize.NET payment profile: %s', 'invoicing' ), $response->validationDirectResponse ), |
|
251 | + sprintf(__('Saved Authorize.NET payment profile: %s', 'invoicing'), $response->validationDirectResponse), |
|
252 | 252 | false, |
253 | 253 | false, |
254 | 254 | true |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @return string|WP_Error Profile id. |
268 | 268 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile |
269 | 269 | */ |
270 | - public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) { |
|
270 | + public function get_customer_payment_profile($customer_profile_id, $payment_profile_id) { |
|
271 | 271 | |
272 | 272 | // Generate args. |
273 | 273 | $args = array( |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | ) |
279 | 279 | ); |
280 | 280 | |
281 | - return $this->post( $args, false ); |
|
281 | + return $this->post($args, false); |
|
282 | 282 | |
283 | 283 | } |
284 | 284 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile |
292 | 292 | * @return WP_Error|object |
293 | 293 | */ |
294 | - public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) { |
|
294 | + public function charge_customer_payment_profile($customer_profile_id, $payment_profile_id, $invoice) { |
|
295 | 295 | |
296 | 296 | // Generate args. |
297 | 297 | $args = array( |
@@ -311,28 +311,28 @@ discard block |
||
311 | 311 | ) |
312 | 312 | ), |
313 | 313 | 'order' => array( |
314 | - 'invoiceNumber' => getpaid_limit_length( $invoice->get_number(), 20 ), |
|
314 | + 'invoiceNumber' => getpaid_limit_length($invoice->get_number(), 20), |
|
315 | 315 | ), |
316 | - 'lineItems' => array( 'lineItem' => $this->get_line_items( $invoice ) ), |
|
316 | + 'lineItems' => array('lineItem' => $this->get_line_items($invoice)), |
|
317 | 317 | 'tax' => array( |
318 | 318 | 'amount' => $invoice->get_total_tax(), |
319 | - 'name' => __( 'TAX', 'invoicing' ), |
|
319 | + 'name' => __('TAX', 'invoicing'), |
|
320 | 320 | ), |
321 | - 'poNumber' => getpaid_limit_length( $invoice->get_number(), 25 ), |
|
321 | + 'poNumber' => getpaid_limit_length($invoice->get_number(), 25), |
|
322 | 322 | 'customer' => array( |
323 | - 'id' => getpaid_limit_length( $invoice->get_user_id(), 25 ), |
|
324 | - 'email' => getpaid_limit_length( $invoice->get_email(), 25 ), |
|
323 | + 'id' => getpaid_limit_length($invoice->get_user_id(), 25), |
|
324 | + 'email' => getpaid_limit_length($invoice->get_email(), 25), |
|
325 | 325 | ), |
326 | 326 | 'customerIP' => $invoice->get_ip(), |
327 | 327 | ) |
328 | 328 | ) |
329 | 329 | ); |
330 | 330 | |
331 | - if ( 0 == $invoice->get_total_tax() ) { |
|
332 | - unset( $args['createTransactionRequest']['transactionRequest']['tax'] ); |
|
331 | + if (0 == $invoice->get_total_tax()) { |
|
332 | + unset($args['createTransactionRequest']['transactionRequest']['tax']); |
|
333 | 333 | } |
334 | 334 | |
335 | - return $this->post( apply_filters( 'getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice ), $invoice ); |
|
335 | + return $this->post(apply_filters('getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice), $invoice); |
|
336 | 336 | |
337 | 337 | } |
338 | 338 | |
@@ -342,29 +342,29 @@ discard block |
||
342 | 342 | * @param stdClass $result Api response. |
343 | 343 | * @param WPInv_Invoice $invoice Invoice. |
344 | 344 | */ |
345 | - public function process_charge_response( $result, $invoice ) { |
|
345 | + public function process_charge_response($result, $invoice) { |
|
346 | 346 | |
347 | 347 | wpinv_clear_errors(); |
348 | 348 | $response_code = (int) $result->transactionResponse->responseCode; |
349 | 349 | |
350 | 350 | // Succeeded. |
351 | - if ( 1 == $response_code || 4 == $response_code ) { |
|
351 | + if (1 == $response_code || 4 == $response_code) { |
|
352 | 352 | |
353 | 353 | // Maybe set a transaction id. |
354 | - if ( ! empty( $result->transactionResponse->transId ) ) { |
|
355 | - $invoice->set_transaction_id( $result->transactionResponse->transId ); |
|
354 | + if (!empty($result->transactionResponse->transId)) { |
|
355 | + $invoice->set_transaction_id($result->transactionResponse->transId); |
|
356 | 356 | } |
357 | 357 | |
358 | - $invoice->add_note( sprintf( __( 'Authentication code: %s (%s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true ); |
|
358 | + $invoice->add_note(sprintf(__('Authentication code: %s (%s).', 'invoicing'), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber), false, false, true); |
|
359 | 359 | |
360 | - if ( 1 == $response_code ) { |
|
360 | + if (1 == $response_code) { |
|
361 | 361 | return $invoice->mark_paid(); |
362 | 362 | } |
363 | 363 | |
364 | - $invoice->set_status( 'wpi-onhold' ); |
|
364 | + $invoice->set_status('wpi-onhold'); |
|
365 | 365 | $invoice->add_note( |
366 | 366 | sprintf( |
367 | - __( 'Held for review: %s', 'invoicing' ), |
|
367 | + __('Held for review: %s', 'invoicing'), |
|
368 | 368 | $result->transactionResponse->messages->message[0]->description |
369 | 369 | ) |
370 | 370 | ); |
@@ -373,11 +373,11 @@ discard block |
||
373 | 373 | |
374 | 374 | } |
375 | 375 | |
376 | - wpinv_set_error( 'card_declined', __( 'Credit card declined.', 'invoicing' ) ); |
|
376 | + wpinv_set_error('card_declined', __('Credit card declined.', 'invoicing')); |
|
377 | 377 | |
378 | - if ( ! empty( $result->transactionResponse->errors ) ) { |
|
378 | + if (!empty($result->transactionResponse->errors)) { |
|
379 | 379 | $errors = (object) $result->transactionResponse->errors; |
380 | - wpinv_set_error( $errors->error[0]->errorCode, esc_html( $errors->error[0]->errorText ) ); |
|
380 | + wpinv_set_error($errors->error[0]->errorCode, esc_html($errors->error[0]->errorText)); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | } |
@@ -389,10 +389,10 @@ discard block |
||
389 | 389 | * @param array $card Card details. |
390 | 390 | * @return array |
391 | 391 | */ |
392 | - public function get_payment_information( $card ) { |
|
392 | + public function get_payment_information($card) { |
|
393 | 393 | return array( |
394 | 394 | |
395 | - 'creditCard' => array ( |
|
395 | + 'creditCard' => array( |
|
396 | 396 | 'cardNumber' => $card['cc_number'], |
397 | 397 | 'expirationDate' => $card['cc_expire_year'] . '-' . $card['cc_expire_month'], |
398 | 398 | 'cardCode' => $card['cc_cvv2'], |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | * @param WPInv_Invoice $invoice Invoice. |
409 | 409 | * @return string |
410 | 410 | */ |
411 | - public function get_customer_profile_meta_name( $invoice ) { |
|
412 | - return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id'; |
|
411 | + public function get_customer_profile_meta_name($invoice) { |
|
412 | + return $this->is_sandbox($invoice) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id'; |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
@@ -420,34 +420,34 @@ discard block |
||
420 | 420 | * @param WPInv_Invoice $invoice |
421 | 421 | * @return WP_Error|string The payment profile id |
422 | 422 | */ |
423 | - public function validate_submission_data( $submission_data, $invoice ) { |
|
423 | + public function validate_submission_data($submission_data, $invoice) { |
|
424 | 424 | |
425 | 425 | // Validate authentication details. |
426 | 426 | $auth = $this->get_auth_params(); |
427 | 427 | |
428 | - if ( empty( $auth['name'] ) || empty( $auth['transactionKey'] ) ) { |
|
429 | - return new WP_Error( 'invalid_settings', __( 'Please set-up your login id and transaction key before using this gateway.', 'invoicing') ); |
|
428 | + if (empty($auth['name']) || empty($auth['transactionKey'])) { |
|
429 | + return new WP_Error('invalid_settings', __('Please set-up your login id and transaction key before using this gateway.', 'invoicing')); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | // Validate the payment method. |
433 | - if ( empty( $submission_data['getpaid-authorizenet-payment-method'] ) ) { |
|
434 | - return new WP_Error( 'invalid_payment_method', __( 'Please select a different payment method or add a new card.', 'invoicing') ); |
|
433 | + if (empty($submission_data['getpaid-authorizenet-payment-method'])) { |
|
434 | + return new WP_Error('invalid_payment_method', __('Please select a different payment method or add a new card.', 'invoicing')); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | // Are we adding a new payment method? |
438 | - if ( 'new' != $submission_data['getpaid-authorizenet-payment-method'] ) { |
|
438 | + if ('new' != $submission_data['getpaid-authorizenet-payment-method']) { |
|
439 | 439 | return $submission_data['getpaid-authorizenet-payment-method']; |
440 | 440 | } |
441 | 441 | |
442 | 442 | // Retrieve the customer profile id. |
443 | - $profile_id = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
443 | + $profile_id = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
444 | 444 | |
445 | 445 | // Create payment method. |
446 | - if ( empty( $profile_id ) ) { |
|
447 | - return $this->create_customer_profile( $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) ); |
|
446 | + if (empty($profile_id)) { |
|
447 | + return $this->create_customer_profile($invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method'])); |
|
448 | 448 | } |
449 | 449 | |
450 | - return $this->create_customer_payment_profile( $profile_id, $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) ); |
|
450 | + return $this->create_customer_payment_profile($profile_id, $invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method'])); |
|
451 | 451 | |
452 | 452 | } |
453 | 453 | |
@@ -458,16 +458,16 @@ discard block |
||
458 | 458 | * @param WPInv_Invoice $invoice Invoice. |
459 | 459 | * @return array |
460 | 460 | */ |
461 | - public function get_line_items( $invoice ) { |
|
461 | + public function get_line_items($invoice) { |
|
462 | 462 | $items = array(); |
463 | 463 | |
464 | - foreach ( $invoice->get_items() as $item ) { |
|
464 | + foreach ($invoice->get_items() as $item) { |
|
465 | 465 | |
466 | 466 | $amount = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
467 | 467 | $items[] = array( |
468 | - 'itemId' => getpaid_limit_length( $item->get_id(), 31 ), |
|
469 | - 'name' => getpaid_limit_length( $item->get_raw_name(), 31 ), |
|
470 | - 'description' => getpaid_limit_length( $item->get_description(), 255 ), |
|
468 | + 'itemId' => getpaid_limit_length($item->get_id(), 31), |
|
469 | + 'name' => getpaid_limit_length($item->get_raw_name(), 31), |
|
470 | + 'description' => getpaid_limit_length($item->get_description(), 255), |
|
471 | 471 | 'quantity' => (string) $invoice->get_template() == 'amount' ? 1 : $item->get_quantity(), |
472 | 472 | 'unitPrice' => (float) $amount, |
473 | 473 | 'taxable' => wpinv_use_taxes() && $invoice->is_taxable() && 'tax-exempt' != $item->get_vat_rule(), |
@@ -475,15 +475,15 @@ discard block |
||
475 | 475 | |
476 | 476 | } |
477 | 477 | |
478 | - foreach ( $invoice->get_fees() as $fee_name => $fee ) { |
|
478 | + foreach ($invoice->get_fees() as $fee_name => $fee) { |
|
479 | 479 | |
480 | - $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee']; |
|
480 | + $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee']; |
|
481 | 481 | |
482 | - if ( $amount > 0 ) { |
|
482 | + if ($amount > 0) { |
|
483 | 483 | $items[] = array( |
484 | - 'itemId' => getpaid_limit_length( $fee_name, 31 ), |
|
485 | - 'name' => getpaid_limit_length( $fee_name, 31 ), |
|
486 | - 'description' => getpaid_limit_length( $fee_name, 255 ), |
|
484 | + 'itemId' => getpaid_limit_length($fee_name, 31), |
|
485 | + 'name' => getpaid_limit_length($fee_name, 31), |
|
486 | + 'description' => getpaid_limit_length($fee_name, 255), |
|
487 | 487 | 'quantity' => '1', |
488 | 488 | 'unitPrice' => (float) $amount, |
489 | 489 | 'taxable' => false, |
@@ -504,36 +504,36 @@ discard block |
||
504 | 504 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
505 | 505 | * @return array |
506 | 506 | */ |
507 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
507 | + public function process_payment($invoice, $submission_data, $submission) { |
|
508 | 508 | |
509 | 509 | // Validate the submitted data. |
510 | - $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice ); |
|
510 | + $payment_profile_id = $this->validate_submission_data($submission_data, $invoice); |
|
511 | 511 | |
512 | 512 | // Do we have an error? |
513 | - if ( is_wp_error( $payment_profile_id ) ) { |
|
514 | - wpinv_set_error( $payment_profile_id->get_error_code(), $payment_profile_id->get_error_message() ); |
|
515 | - wpinv_send_back_to_checkout( $invoice ); |
|
513 | + if (is_wp_error($payment_profile_id)) { |
|
514 | + wpinv_set_error($payment_profile_id->get_error_code(), $payment_profile_id->get_error_message()); |
|
515 | + wpinv_send_back_to_checkout($invoice); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | // Save the payment method to the order. |
519 | - update_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id ); |
|
519 | + update_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id); |
|
520 | 520 | |
521 | 521 | // Check if this is a subscription or not. |
522 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
523 | - if ( ! empty( $subscription ) ) { |
|
524 | - $this->process_subscription( $invoice, $subscription ); |
|
522 | + $subscription = getpaid_get_invoice_subscription($invoice); |
|
523 | + if (!empty($subscription)) { |
|
524 | + $this->process_subscription($invoice, $subscription); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | // If it is free, send to the success page. |
528 | - if ( ! $invoice->needs_payment() ) { |
|
528 | + if (!$invoice->needs_payment()) { |
|
529 | 529 | $invoice->mark_paid(); |
530 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
530 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | // Charge the payment profile. |
534 | - $this->process_initial_payment( $invoice ); |
|
534 | + $this->process_initial_payment($invoice); |
|
535 | 535 | |
536 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
536 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
537 | 537 | |
538 | 538 | exit; |
539 | 539 | |
@@ -544,23 +544,23 @@ discard block |
||
544 | 544 | * |
545 | 545 | * @param WPInv_Invoice $invoice Invoice. |
546 | 546 | */ |
547 | - protected function process_initial_payment( $invoice ) { |
|
547 | + protected function process_initial_payment($invoice) { |
|
548 | 548 | |
549 | - $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
550 | - $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
551 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
549 | + $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
550 | + $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
551 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice); |
|
552 | 552 | |
553 | 553 | // Do we have an error? |
554 | - if ( is_wp_error( $result ) ) { |
|
555 | - wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
556 | - wpinv_send_back_to_checkout( $invoice ); |
|
554 | + if (is_wp_error($result)) { |
|
555 | + wpinv_set_error($result->get_error_code(), $result->get_error_message()); |
|
556 | + wpinv_send_back_to_checkout($invoice); |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | // Process the response. |
560 | - $this->process_charge_response( $result, $invoice ); |
|
560 | + $this->process_charge_response($result, $invoice); |
|
561 | 561 | |
562 | - if ( wpinv_get_errors() ) { |
|
563 | - wpinv_send_back_to_checkout( $invoice ); |
|
562 | + if (wpinv_get_errors()) { |
|
563 | + wpinv_send_back_to_checkout($invoice); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | } |
@@ -571,24 +571,24 @@ discard block |
||
571 | 571 | * @param WPInv_Invoice $invoice Invoice. |
572 | 572 | * @param WPInv_Subscription $subscription Subscription. |
573 | 573 | */ |
574 | - public function process_subscription( $invoice, $subscription ) { |
|
574 | + public function process_subscription($invoice, $subscription) { |
|
575 | 575 | |
576 | 576 | // Check if there is an initial amount to charge. |
577 | - if ( (float) $invoice->get_total() > 0 ) { |
|
578 | - $this->process_initial_payment( $invoice ); |
|
577 | + if ((float) $invoice->get_total() > 0) { |
|
578 | + $this->process_initial_payment($invoice); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | // Activate the subscription. |
582 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
583 | - $expiry = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
582 | + $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created()); |
|
583 | + $expiry = date('Y-m-d H:i:s', (current_time('timestamp') + $duration)); |
|
584 | 584 | |
585 | - $subscription->set_next_renewal_date( $expiry ); |
|
586 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
587 | - $subscription->set_profile_id( $invoice->generate_key() ); |
|
585 | + $subscription->set_next_renewal_date($expiry); |
|
586 | + $subscription->set_date_created(current_time('mysql')); |
|
587 | + $subscription->set_profile_id($invoice->generate_key()); |
|
588 | 588 | $subscription->activate(); |
589 | 589 | |
590 | 590 | // Redirect to the success page. |
591 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
591 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
592 | 592 | |
593 | 593 | } |
594 | 594 | |
@@ -599,20 +599,20 @@ discard block |
||
599 | 599 | * @param bool $should_expire |
600 | 600 | * @param WPInv_Subscription $subscription |
601 | 601 | */ |
602 | - public function maybe_renew_subscription( $should_expire, $subscription ) { |
|
602 | + public function maybe_renew_subscription($should_expire, $subscription) { |
|
603 | 603 | |
604 | 604 | // Ensure its our subscription && it's active. |
605 | - if ( $this->id != $subscription->get_gateway() || ! $subscription->has_status( 'active trialling' ) ) { |
|
605 | + if ($this->id != $subscription->get_gateway() || !$subscription->has_status('active trialling')) { |
|
606 | 606 | return $should_expire; |
607 | 607 | } |
608 | 608 | |
609 | 609 | // If this is the last renewal, complete the subscription. |
610 | - if ( $subscription->is_last_renewal() ) { |
|
610 | + if ($subscription->is_last_renewal()) { |
|
611 | 611 | $subscription->complete(); |
612 | 612 | return false; |
613 | 613 | } |
614 | 614 | |
615 | - $this->renew_subscription( $subscription ); |
|
615 | + $this->renew_subscription($subscription); |
|
616 | 616 | |
617 | 617 | return false; |
618 | 618 | |
@@ -623,28 +623,28 @@ discard block |
||
623 | 623 | * |
624 | 624 | * @param WPInv_Subscription $subscription |
625 | 625 | */ |
626 | - public function renew_subscription( $subscription ) { |
|
626 | + public function renew_subscription($subscription) { |
|
627 | 627 | |
628 | 628 | // Generate the renewal invoice. |
629 | 629 | $new_invoice = $subscription->create_payment(); |
630 | 630 | $old_invoice = $subscription->get_parent_payment(); |
631 | 631 | |
632 | - if ( empty( $new_invoice ) ) { |
|
633 | - $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false ); |
|
632 | + if (empty($new_invoice)) { |
|
633 | + $old_invoice->add_note(__('Error generating a renewal invoice.', 'invoicing'), false, false, false); |
|
634 | 634 | $subscription->failing(); |
635 | 635 | return; |
636 | 636 | } |
637 | 637 | |
638 | 638 | // Charge the payment method. |
639 | - $payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
640 | - $customer_profile = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true ); |
|
641 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice ); |
|
639 | + $payment_profile_id = get_post_meta($old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
640 | + $customer_profile = get_user_meta($old_invoice->get_user_id(), $this->get_customer_profile_meta_name($old_invoice), true); |
|
641 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $new_invoice); |
|
642 | 642 | |
643 | 643 | // Do we have an error? |
644 | - if ( is_wp_error( $result ) ) { |
|
644 | + if (is_wp_error($result)) { |
|
645 | 645 | |
646 | 646 | $old_invoice->add_note( |
647 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ), |
|
647 | + sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), $result->get_error_message()), |
|
648 | 648 | true, |
649 | 649 | false, |
650 | 650 | true |
@@ -655,12 +655,12 @@ discard block |
||
655 | 655 | } |
656 | 656 | |
657 | 657 | // Process the response. |
658 | - $this->process_charge_response( $result, $new_invoice ); |
|
658 | + $this->process_charge_response($result, $new_invoice); |
|
659 | 659 | |
660 | - if ( wpinv_get_errors() ) { |
|
660 | + if (wpinv_get_errors()) { |
|
661 | 661 | |
662 | 662 | $old_invoice->add_note( |
663 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ), |
|
663 | + sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), getpaid_get_errors_html()), |
|
664 | 664 | true, |
665 | 665 | false, |
666 | 666 | true |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | |
671 | 671 | } |
672 | 672 | |
673 | - $subscription->add_payment( array(), $new_invoice ); |
|
673 | + $subscription->add_payment(array(), $new_invoice); |
|
674 | 674 | $subscription->renew(); |
675 | 675 | } |
676 | 676 | |
@@ -681,34 +681,34 @@ discard block |
||
681 | 681 | * @param GetPaid_Form_Item[] $items |
682 | 682 | * @return WPInv_Invoice |
683 | 683 | */ |
684 | - public function process_addons( $invoice, $items ) { |
|
684 | + public function process_addons($invoice, $items) { |
|
685 | 685 | |
686 | 686 | global $getpaid_authorize_addons; |
687 | 687 | |
688 | 688 | $getpaid_authorize_addons = array(); |
689 | - foreach ( $items as $item ) { |
|
689 | + foreach ($items as $item) { |
|
690 | 690 | |
691 | - if ( is_null( $invoice->get_item( $item->get_id() ) ) && ! is_wp_error( $invoice->add_item( $item ) ) ) { |
|
691 | + if (is_null($invoice->get_item($item->get_id())) && !is_wp_error($invoice->add_item($item))) { |
|
692 | 692 | $getpaid_authorize_addons[] = $item; |
693 | 693 | } |
694 | 694 | |
695 | 695 | } |
696 | 696 | |
697 | - if ( empty( $getpaid_authorize_addons ) ) { |
|
697 | + if (empty($getpaid_authorize_addons)) { |
|
698 | 698 | return; |
699 | 699 | } |
700 | 700 | |
701 | 701 | $invoice->recalculate_total(); |
702 | 702 | |
703 | - $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
704 | - $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
703 | + $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
704 | + $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
705 | 705 | |
706 | - add_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ), 10, 2 ); |
|
707 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
708 | - remove_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ) ); |
|
706 | + add_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request'), 10, 2); |
|
707 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice); |
|
708 | + remove_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request')); |
|
709 | 709 | |
710 | - if ( is_wp_error( $result ) ) { |
|
711 | - wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
710 | + if (is_wp_error($result)) { |
|
711 | + wpinv_set_error($result->get_error_code(), $result->get_error_message()); |
|
712 | 712 | return; |
713 | 713 | } |
714 | 714 | |
@@ -721,19 +721,19 @@ discard block |
||
721 | 721 | * @param array $args |
722 | 722 | * @return array |
723 | 723 | */ |
724 | - public function filter_addons_request( $args ) { |
|
724 | + public function filter_addons_request($args) { |
|
725 | 725 | |
726 | 726 | global $getpaid_authorize_addons; |
727 | 727 | $total = 0; |
728 | 728 | |
729 | - foreach ( $getpaid_authorize_addons as $addon ) { |
|
729 | + foreach ($getpaid_authorize_addons as $addon) { |
|
730 | 730 | $total += $addon->get_sub_total(); |
731 | 731 | } |
732 | 732 | |
733 | 733 | $args['createTransactionRequest']['transactionRequest']['amount'] = $total; |
734 | 734 | |
735 | - if ( isset( $args['createTransactionRequest']['transactionRequest']['tax'] ) ) { |
|
736 | - unset( $args['createTransactionRequest']['transactionRequest']['tax'] ); |
|
735 | + if (isset($args['createTransactionRequest']['transactionRequest']['tax'])) { |
|
736 | + unset($args['createTransactionRequest']['transactionRequest']['tax']); |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | return $args; |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | public function sandbox_notice() { |
747 | 747 | |
748 | 748 | return sprintf( |
749 | - __( 'SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing' ), |
|
749 | + __('SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing'), |
|
750 | 750 | '<a href="https://developer.authorize.net/hello_world/testing_guide.html">', |
751 | 751 | '</a>' |
752 | 752 | ); |
@@ -758,42 +758,42 @@ discard block |
||
758 | 758 | * |
759 | 759 | * @param array $admin_settings |
760 | 760 | */ |
761 | - public function admin_settings( $admin_settings ) { |
|
761 | + public function admin_settings($admin_settings) { |
|
762 | 762 | |
763 | 763 | $currencies = sprintf( |
764 | - __( 'Supported Currencies: %s', 'invoicing' ), |
|
765 | - implode( ', ', $this->currencies ) |
|
764 | + __('Supported Currencies: %s', 'invoicing'), |
|
765 | + implode(', ', $this->currencies) |
|
766 | 766 | ); |
767 | 767 | |
768 | 768 | $admin_settings['authorizenet_active']['desc'] .= " ($currencies)"; |
769 | - $admin_settings['authorizenet_desc']['std'] = __( 'Pay securely using your credit or debit card.', 'invoicing' ); |
|
769 | + $admin_settings['authorizenet_desc']['std'] = __('Pay securely using your credit or debit card.', 'invoicing'); |
|
770 | 770 | |
771 | 771 | $admin_settings['authorizenet_login_id'] = array( |
772 | 772 | 'type' => 'text', |
773 | 773 | 'id' => 'authorizenet_login_id', |
774 | - 'name' => __( 'API Login ID', 'invoicing' ), |
|
775 | - 'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __( 'How do I obtain my API Login ID and Transaction Key?', 'invoicing' ) . '</em></a>', |
|
774 | + 'name' => __('API Login ID', 'invoicing'), |
|
775 | + 'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __('How do I obtain my API Login ID and Transaction Key?', 'invoicing') . '</em></a>', |
|
776 | 776 | ); |
777 | 777 | |
778 | 778 | $admin_settings['authorizenet_transaction_key'] = array( |
779 | 779 | 'type' => 'text', |
780 | 780 | 'id' => 'authorizenet_transaction_key', |
781 | - 'name' => __( 'Transaction Key', 'invoicing' ), |
|
781 | + 'name' => __('Transaction Key', 'invoicing'), |
|
782 | 782 | ); |
783 | 783 | |
784 | 784 | $admin_settings['authorizenet_signature_key'] = array( |
785 | 785 | 'type' => 'text', |
786 | 786 | 'id' => 'authorizenet_signature_key', |
787 | - 'name' => __( 'Signature Key', 'invoicing' ), |
|
788 | - 'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>', |
|
787 | + 'name' => __('Signature Key', 'invoicing'), |
|
788 | + 'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __('Learn more.', 'invoicing') . '</em></a>', |
|
789 | 789 | ); |
790 | 790 | |
791 | 791 | $admin_settings['authorizenet_ipn_url'] = array( |
792 | 792 | 'type' => 'ipn_url', |
793 | 793 | 'id' => 'authorizenet_ipn_url', |
794 | - 'name' => __( 'Webhook URL', 'invoicing' ), |
|
794 | + 'name' => __('Webhook URL', 'invoicing'), |
|
795 | 795 | 'std' => $this->notify_url, |
796 | - 'desc' => __( 'Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing' ) . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>', |
|
796 | + 'desc' => __('Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing') . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __('Learn more.', 'invoicing') . '</em></a>', |
|
797 | 797 | 'custom' => 'authorizenet', |
798 | 798 | 'readonly' => true, |
799 | 799 | ); |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Main Invoicing class. |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param string $prop The prop to set. |
57 | 57 | * @param mixed $value The value to retrieve. |
58 | 58 | */ |
59 | - public function set( $prop, $value ) { |
|
60 | - $this->data[ $prop ] = $value; |
|
59 | + public function set($prop, $value) { |
|
60 | + $this->data[$prop] = $value; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | * @param string $prop The prop to set. |
67 | 67 | * @return mixed The value. |
68 | 68 | */ |
69 | - public function get( $prop ) { |
|
69 | + public function get($prop) { |
|
70 | 70 | |
71 | - if ( isset( $this->data[ $prop ] ) ) { |
|
72 | - return $this->data[ $prop ]; |
|
71 | + if (isset($this->data[$prop])) { |
|
72 | + return $this->data[$prop]; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | return null; |
@@ -81,23 +81,23 @@ discard block |
||
81 | 81 | public function set_properties() { |
82 | 82 | |
83 | 83 | // Sessions. |
84 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
85 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
84 | + $this->set('session', new WPInv_Session_Handler()); |
|
85 | + $GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility. |
|
86 | 86 | $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility. |
87 | 87 | |
88 | 88 | // Init other objects. |
89 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
90 | - $this->set( 'notes', new WPInv_Notes() ); |
|
91 | - $this->set( 'api', new WPInv_API() ); |
|
92 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
93 | - $this->set( 'template', new GetPaid_Template() ); |
|
94 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
95 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
96 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
97 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
98 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
99 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
100 | - $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
89 | + $this->set('session', new WPInv_Session_Handler()); |
|
90 | + $this->set('notes', new WPInv_Notes()); |
|
91 | + $this->set('api', new WPInv_API()); |
|
92 | + $this->set('post_types', new GetPaid_Post_Types()); |
|
93 | + $this->set('template', new GetPaid_Template()); |
|
94 | + $this->set('admin', new GetPaid_Admin()); |
|
95 | + $this->set('subscriptions', new WPInv_Subscriptions()); |
|
96 | + $this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails()); |
|
97 | + $this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails()); |
|
98 | + $this->set('daily_maintenace', new GetPaid_Daily_Maintenance()); |
|
99 | + $this->set('payment_forms', new GetPaid_Payment_Forms()); |
|
100 | + $this->set('maxmind', new GetPaid_MaxMind_Geolocation()); |
|
101 | 101 | |
102 | 102 | } |
103 | 103 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * Define plugin constants. |
106 | 106 | */ |
107 | 107 | public function define_constants() { |
108 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
109 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
108 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
109 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
110 | 110 | $this->version = WPINV_VERSION; |
111 | 111 | } |
112 | 112 | |
@@ -117,23 +117,23 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function init_hooks() { |
119 | 119 | /* Internationalize the text strings used. */ |
120 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
120 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
121 | 121 | |
122 | 122 | // Init the plugin after WordPress inits. |
123 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
124 | - add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
125 | - add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
126 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
127 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 ); |
|
128 | - add_action( 'wp_footer', array( $this, 'wp_footer' ) ); |
|
129 | - add_action( 'wp_head', array( $this, 'wp_head' ) ); |
|
130 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
131 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
132 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
123 | + add_action('init', array($this, 'init'), 1); |
|
124 | + add_action('init', array($this, 'maybe_process_ipn'), 10); |
|
125 | + add_action('init', array($this, 'wpinv_actions')); |
|
126 | + add_action('init', array($this, 'maybe_do_authenticated_action'), 100); |
|
127 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 11); |
|
128 | + add_action('wp_footer', array($this, 'wp_footer')); |
|
129 | + add_action('wp_head', array($this, 'wp_head')); |
|
130 | + add_action('widgets_init', array(&$this, 'register_widgets')); |
|
131 | + add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids')); |
|
132 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
133 | 133 | |
134 | 134 | // Fires after registering actions. |
135 | - do_action( 'wpinv_actions', $this ); |
|
136 | - do_action( 'getpaid_actions', $this ); |
|
135 | + do_action('wpinv_actions', $this); |
|
136 | + do_action('getpaid_actions', $this); |
|
137 | 137 | |
138 | 138 | } |
139 | 139 | |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | /* Internationalize the text strings used. */ |
142 | 142 | $this->load_textdomain(); |
143 | 143 | |
144 | - do_action( 'wpinv_loaded' ); |
|
144 | + do_action('wpinv_loaded'); |
|
145 | 145 | |
146 | 146 | // Fix oxygen page builder conflict |
147 | - if ( function_exists( 'ct_css_output' ) ) { |
|
147 | + if (function_exists('ct_css_output')) { |
|
148 | 148 | wpinv_oxygen_fix_conflict(); |
149 | 149 | } |
150 | 150 | } |
@@ -154,21 +154,21 @@ discard block |
||
154 | 154 | * |
155 | 155 | * @since 1.0 |
156 | 156 | */ |
157 | - public function load_textdomain( $locale = NULL ) { |
|
158 | - if ( empty( $locale ) ) { |
|
159 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
157 | + public function load_textdomain($locale = NULL) { |
|
158 | + if (empty($locale)) { |
|
159 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
160 | 160 | } |
161 | 161 | |
162 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
162 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
163 | 163 | |
164 | - unload_textdomain( 'invoicing' ); |
|
165 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
166 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
164 | + unload_textdomain('invoicing'); |
|
165 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
166 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
167 | 167 | |
168 | 168 | /** |
169 | 169 | * Define language constants. |
170 | 170 | */ |
171 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
171 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -177,78 +177,78 @@ discard block |
||
177 | 177 | public function includes() { |
178 | 178 | |
179 | 179 | // Start with the settings. |
180 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
180 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
181 | 181 | |
182 | 182 | // Packages/libraries. |
183 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
184 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
183 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
184 | + require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php'); |
|
185 | 185 | |
186 | 186 | // Load functions. |
187 | - require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
188 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
189 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
190 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
191 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
192 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
193 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
194 | - require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
195 | - require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
196 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
197 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
198 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
199 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
200 | - require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' ); |
|
201 | - require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
187 | + require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php'); |
|
188 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
189 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
190 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
191 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
192 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
193 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
194 | + require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php'); |
|
195 | + require_once(WPINV_PLUGIN_DIR . 'includes/subscription-functions.php'); |
|
196 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
197 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
198 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
199 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
200 | + require_once(WPINV_PLUGIN_DIR . 'includes/user-functions.php'); |
|
201 | + require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php'); |
|
202 | 202 | |
203 | 203 | // Register autoloader. |
204 | 204 | try { |
205 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
206 | - } catch ( Exception $e ) { |
|
207 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
205 | + spl_autoload_register(array($this, 'autoload'), true); |
|
206 | + } catch (Exception $e) { |
|
207 | + wpinv_error_log($e->getMessage(), '', __FILE__, 149, true); |
|
208 | 208 | } |
209 | 209 | |
210 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
211 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
212 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
213 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
214 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
215 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
216 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
217 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
218 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
219 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
220 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
221 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
222 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
223 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
224 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
225 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
226 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
227 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
228 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
229 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
230 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
231 | - |
|
232 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
210 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
211 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
212 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
213 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
214 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
215 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
216 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
217 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
218 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
219 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
220 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
221 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
222 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
223 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
224 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
225 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
226 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
227 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
228 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
229 | + require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php'); |
|
230 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
231 | + |
|
232 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
233 | 233 | GetPaid_Post_Types_Admin::init(); |
234 | 234 | |
235 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
236 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
237 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
238 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
239 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
240 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
235 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
236 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php'); |
|
237 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
238 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
239 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
240 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php'); |
|
241 | 241 | // load the user class only on the users.php page |
242 | 242 | global $pagenow; |
243 | - if($pagenow=='users.php'){ |
|
243 | + if ($pagenow == 'users.php') { |
|
244 | 244 | new WPInv_Admin_Users(); |
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
248 | 248 | // Register cli commands |
249 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
250 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
251 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
249 | + if (defined('WP_CLI') && WP_CLI) { |
|
250 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
251 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | } |
@@ -261,21 +261,21 @@ discard block |
||
261 | 261 | * @since 1.0.19 |
262 | 262 | * @return void |
263 | 263 | */ |
264 | - public function autoload( $class_name ) { |
|
264 | + public function autoload($class_name) { |
|
265 | 265 | |
266 | 266 | // Normalize the class name... |
267 | - $class_name = strtolower( $class_name ); |
|
267 | + $class_name = strtolower($class_name); |
|
268 | 268 | |
269 | 269 | // ... and make sure it is our class. |
270 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
270 | + if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) { |
|
271 | 271 | return; |
272 | 272 | } |
273 | 273 | |
274 | 274 | // Next, prepare the file name from the class. |
275 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
275 | + $file_name = 'class-' . str_replace('_', '-', $class_name) . '.php'; |
|
276 | 276 | |
277 | 277 | // Base path of the classes. |
278 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
278 | + $plugin_path = untrailingslashit(WPINV_PLUGIN_DIR); |
|
279 | 279 | |
280 | 280 | // And an array of possible locations in order of importance. |
281 | 281 | $locations = array( |
@@ -290,10 +290,10 @@ discard block |
||
290 | 290 | "$plugin_path/includes/admin/meta-boxes", |
291 | 291 | ); |
292 | 292 | |
293 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
293 | + foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) { |
|
294 | 294 | |
295 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
296 | - include trailingslashit( $location ) . $file_name; |
|
295 | + if (file_exists(trailingslashit($location) . $file_name)) { |
|
296 | + include trailingslashit($location) . $file_name; |
|
297 | 297 | break; |
298 | 298 | } |
299 | 299 | |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | public function init() { |
308 | 308 | |
309 | 309 | // Fires before getpaid inits. |
310 | - do_action( 'before_getpaid_init', $this ); |
|
310 | + do_action('before_getpaid_init', $this); |
|
311 | 311 | |
312 | 312 | // Maybe upgrade. |
313 | 313 | $this->maybe_upgrade_database(); |
@@ -324,17 +324,17 @@ discard block |
||
324 | 324 | ) |
325 | 325 | ); |
326 | 326 | |
327 | - foreach ( $gateways as $id => $class ) { |
|
328 | - $this->gateways[ $id ] = new $class(); |
|
327 | + foreach ($gateways as $id => $class) { |
|
328 | + $this->gateways[$id] = new $class(); |
|
329 | 329 | } |
330 | 330 | |
331 | - if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) { |
|
331 | + if ('yes' != get_option('wpinv_renamed_gateways')) { |
|
332 | 332 | GetPaid_Installer::rename_gateways_label(); |
333 | - update_option( 'wpinv_renamed_gateways', 'yes' ); |
|
333 | + update_option('wpinv_renamed_gateways', 'yes'); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | // Fires after getpaid inits. |
337 | - do_action( 'getpaid_init', $this ); |
|
337 | + do_action('getpaid_init', $this); |
|
338 | 338 | |
339 | 339 | } |
340 | 340 | |
@@ -344,14 +344,14 @@ discard block |
||
344 | 344 | public function maybe_process_ipn() { |
345 | 345 | |
346 | 346 | // Ensure that this is an IPN request. |
347 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
347 | + if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) { |
|
348 | 348 | return; |
349 | 349 | } |
350 | 350 | |
351 | - $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
351 | + $gateway = wpinv_clean($_GET['wpi-gateway']); |
|
352 | 352 | |
353 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
354 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
353 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
354 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
355 | 355 | exit; |
356 | 356 | |
357 | 357 | } |
@@ -359,27 +359,27 @@ discard block |
||
359 | 359 | public function enqueue_scripts() { |
360 | 360 | |
361 | 361 | // Fires before adding scripts. |
362 | - do_action( 'getpaid_enqueue_scripts' ); |
|
362 | + do_action('getpaid_enqueue_scripts'); |
|
363 | 363 | |
364 | 364 | $localize = array(); |
365 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
366 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
367 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
365 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
366 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
367 | + $localize['txtComplete'] = __('Continue', 'invoicing'); |
|
368 | 368 | $localize['UseTaxes'] = wpinv_use_taxes(); |
369 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
370 | - $localize['loading'] = __( 'Loading...', 'invoicing' ); |
|
371 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
369 | + $localize['formNonce'] = wp_create_nonce('getpaid_form_nonce'); |
|
370 | + $localize['loading'] = __('Loading...', 'invoicing'); |
|
371 | + $localize['connectionError'] = __('Could not establish a connection to the server.', 'invoicing'); |
|
372 | 372 | |
373 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
373 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
374 | 374 | |
375 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
376 | - wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true ); |
|
377 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
375 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js'); |
|
376 | + wp_enqueue_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('jquery'), $version, true); |
|
377 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | public function wpinv_actions() { |
381 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
382 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
381 | + if (isset($_REQUEST['wpi_action'])) { |
|
382 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
383 | 383 | } |
384 | 384 | } |
385 | 385 | |
@@ -391,24 +391,24 @@ discard block |
||
391 | 391 | */ |
392 | 392 | public function maybe_do_authenticated_action() { |
393 | 393 | |
394 | - if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
394 | + if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
395 | 395 | |
396 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
397 | - $data = wp_unslash( $_REQUEST ); |
|
398 | - if ( is_user_logged_in() ) { |
|
399 | - do_action( "getpaid_authenticated_action_$key", $data ); |
|
396 | + $key = sanitize_key($_REQUEST['getpaid-action']); |
|
397 | + $data = wp_unslash($_REQUEST); |
|
398 | + if (is_user_logged_in()) { |
|
399 | + do_action("getpaid_authenticated_action_$key", $data); |
|
400 | 400 | } |
401 | 401 | |
402 | - do_action( "getpaid_unauthenticated_action_$key", $data ); |
|
402 | + do_action("getpaid_unauthenticated_action_$key", $data); |
|
403 | 403 | |
404 | 404 | } |
405 | 405 | |
406 | 406 | } |
407 | 407 | |
408 | - public function pre_get_posts( $wp_query ) { |
|
408 | + public function pre_get_posts($wp_query) { |
|
409 | 409 | |
410 | - if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
411 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
410 | + if (!is_admin() && !empty($wp_query->query_vars['post_type']) && getpaid_is_invoice_post_type($wp_query->query_vars['post_type']) && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
411 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type'])); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | return $wp_query; |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | |
423 | 423 | // Currently, UX Builder does not work particulaly well with SuperDuper. |
424 | 424 | // So we disable our widgets when editing a page with UX Builder. |
425 | - if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) { |
|
425 | + if (function_exists('ux_builder_is_active') && ux_builder_is_active()) { |
|
426 | 426 | return; |
427 | 427 | } |
428 | 428 | |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | ) |
440 | 440 | ); |
441 | 441 | |
442 | - foreach ( $widgets as $widget ) { |
|
443 | - register_widget( $widget ); |
|
442 | + foreach ($widgets as $widget) { |
|
443 | + register_widget($widget); |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | } |
@@ -452,29 +452,29 @@ discard block |
||
452 | 452 | */ |
453 | 453 | public function maybe_upgrade_database() { |
454 | 454 | |
455 | - $wpi_version = get_option( 'wpinv_version', 0 ); |
|
455 | + $wpi_version = get_option('wpinv_version', 0); |
|
456 | 456 | |
457 | - if ( $wpi_version == WPINV_VERSION ) { |
|
457 | + if ($wpi_version == WPINV_VERSION) { |
|
458 | 458 | return; |
459 | 459 | } |
460 | 460 | |
461 | 461 | $installer = new GetPaid_Installer(); |
462 | 462 | |
463 | - if ( empty( $wpi_version ) ) { |
|
464 | - return $installer->upgrade_db( 0 ); |
|
463 | + if (empty($wpi_version)) { |
|
464 | + return $installer->upgrade_db(0); |
|
465 | 465 | } |
466 | 466 | |
467 | - $upgrades = array( |
|
467 | + $upgrades = array( |
|
468 | 468 | '0.0.5' => '004', |
469 | 469 | '1.0.3' => '102', |
470 | 470 | '2.0.0' => '118', |
471 | 471 | '2.0.8' => '207', |
472 | 472 | ); |
473 | 473 | |
474 | - foreach ( $upgrades as $key => $method ) { |
|
474 | + foreach ($upgrades as $key => $method) { |
|
475 | 475 | |
476 | - if ( version_compare( $wpi_version, $key, '<' ) ) { |
|
477 | - return $installer->upgrade_db( $method ); |
|
476 | + if (version_compare($wpi_version, $key, '<')) { |
|
477 | + return $installer->upgrade_db($method); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | } |
@@ -488,11 +488,11 @@ discard block |
||
488 | 488 | */ |
489 | 489 | public function maybe_flush_permalinks() { |
490 | 490 | |
491 | - $flush = get_option( 'wpinv_flush_permalinks', 0 ); |
|
491 | + $flush = get_option('wpinv_flush_permalinks', 0); |
|
492 | 492 | |
493 | - if ( ! empty( $flush ) ) { |
|
493 | + if (!empty($flush)) { |
|
494 | 494 | flush_rewrite_rules(); |
495 | - delete_option( 'wpinv_flush_permalinks' ); |
|
495 | + delete_option('wpinv_flush_permalinks'); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | } |
@@ -503,10 +503,10 @@ discard block |
||
503 | 503 | * @since 1.0.19 |
504 | 504 | * @param int[] $excluded_posts_ids |
505 | 505 | */ |
506 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
506 | + public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) { |
|
507 | 507 | |
508 | 508 | // Ensure that we have an array. |
509 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
509 | + if (!is_array($excluded_posts_ids)) { |
|
510 | 510 | $excluded_posts_ids = array(); |
511 | 511 | } |
512 | 512 | |
@@ -514,24 +514,24 @@ discard block |
||
514 | 514 | $our_pages = array(); |
515 | 515 | |
516 | 516 | // Checkout page. |
517 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
517 | + $our_pages[] = wpinv_get_option('checkout_page', false); |
|
518 | 518 | |
519 | 519 | // Success page. |
520 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
520 | + $our_pages[] = wpinv_get_option('success_page', false); |
|
521 | 521 | |
522 | 522 | // Failure page. |
523 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
523 | + $our_pages[] = wpinv_get_option('failure_page', false); |
|
524 | 524 | |
525 | 525 | // History page. |
526 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
526 | + $our_pages[] = wpinv_get_option('invoice_history_page', false); |
|
527 | 527 | |
528 | 528 | // Subscriptions page. |
529 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
529 | + $our_pages[] = wpinv_get_option('invoice_subscription_page', false); |
|
530 | 530 | |
531 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
531 | + $our_pages = array_map('intval', array_filter($our_pages)); |
|
532 | 532 | |
533 | 533 | $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
534 | - return array_unique( $excluded_posts_ids ); |
|
534 | + return array_unique($excluded_posts_ids); |
|
535 | 535 | |
536 | 536 | } |
537 | 537 | |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | * @since 2.0.0 |
542 | 542 | */ |
543 | 543 | public function wp_footer() { |
544 | - wpinv_get_template( 'frontend-footer.php' ); |
|
544 | + wpinv_get_template('frontend-footer.php'); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | * @since 2.0.0 |
551 | 551 | */ |
552 | 552 | public function wp_head() { |
553 | - wpinv_get_template( 'frontend-head.php' ); |
|
553 | + wpinv_get_template('frontend-head.php'); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the invoice. |
27 | - $invoice = new WPInv_Invoice( $post ); |
|
27 | + $invoice = new WPInv_Invoice($post); |
|
28 | 28 | |
29 | 29 | // Nonce field. |
30 | - wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ; |
|
30 | + wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); |
|
31 | 31 | |
32 | 32 | |
33 | 33 | ?> |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | |
47 | 47 | <div class="bsui" style="margin-top: 1.5rem"> |
48 | 48 | |
49 | - <?php do_action( 'getpaid_invoice_edit_before_viewed_by_customer', $invoice ); ?> |
|
50 | - <?php if ( ! $invoice->is_draft() ) : ?> |
|
49 | + <?php do_action('getpaid_invoice_edit_before_viewed_by_customer', $invoice); ?> |
|
50 | + <?php if (!$invoice->is_draft()) : ?> |
|
51 | 51 | <div class="form-group"> |
52 | - <strong><?php _e( 'Viewed by Customer:', 'invoicing' );?></strong> |
|
53 | - <?php ( $invoice->get_is_viewed() ) ? _e( 'Yes', 'invoicing' ) : _e( 'No', 'invoicing' ); ?> |
|
52 | + <strong><?php _e('Viewed by Customer:', 'invoicing'); ?></strong> |
|
53 | + <?php ($invoice->get_is_viewed()) ? _e('Yes', 'invoicing') : _e('No', 'invoicing'); ?> |
|
54 | 54 | </div> |
55 | 55 | <?php endif; ?> |
56 | 56 | |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | |
59 | 59 | // Date created. |
60 | 60 | $label = sprintf( |
61 | - __( '%s Date:', 'invoicing' ), |
|
62 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
61 | + __('%s Date:', 'invoicing'), |
|
62 | + ucfirst($invoice->get_invoice_quote_type()) |
|
63 | 63 | ); |
64 | 64 | |
65 | - $info = sprintf( |
|
66 | - __( 'The date this %s was created.', 'invoicing' ), |
|
67 | - strtolower( $invoice->get_invoice_quote_type() ) |
|
65 | + $info = sprintf( |
|
66 | + __('The date this %s was created.', 'invoicing'), |
|
67 | + strtolower($invoice->get_invoice_quote_type()) |
|
68 | 68 | ); |
69 | 69 | |
70 | 70 | echo aui()->input( |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | 'type' => 'datepicker', |
73 | 73 | 'id' => 'wpinv_date_created', |
74 | 74 | 'name' => 'date_created', |
75 | - 'label' => $label . getpaid_get_help_tip( $info ), |
|
75 | + 'label' => $label . getpaid_get_help_tip($info), |
|
76 | 76 | 'label_type' => 'vertical', |
77 | 77 | 'placeholder' => 'YYYY-MM-DD 00:00', |
78 | 78 | 'class' => 'form-control-sm', |
79 | - 'value' => $invoice->get_date_created( 'edit' ), |
|
79 | + 'value' => $invoice->get_date_created('edit'), |
|
80 | 80 | 'extra_attributes' => array( |
81 | 81 | 'data-enable-time' => 'true', |
82 | 82 | 'data-time_24hr' => 'true', |
@@ -87,15 +87,15 @@ discard block |
||
87 | 87 | ); |
88 | 88 | |
89 | 89 | // Date paid. |
90 | - $date_paid = $invoice->get_date_completed( 'edit' ); |
|
91 | - if ( ! empty( $date_paid ) && $invoice->is_paid() ) { |
|
90 | + $date_paid = $invoice->get_date_completed('edit'); |
|
91 | + if (!empty($date_paid) && $invoice->is_paid()) { |
|
92 | 92 | |
93 | 93 | echo aui()->input( |
94 | 94 | array( |
95 | 95 | 'type' => 'text', |
96 | 96 | 'id' => 'wpinv_date_completed', |
97 | 97 | 'name' => 'wpinv_date_completed', |
98 | - 'label' => __( 'Date Completed:', 'invoicing' ), |
|
98 | + 'label' => __('Date Completed:', 'invoicing'), |
|
99 | 99 | 'label_type' => 'vertical', |
100 | 100 | 'class' => 'form-control-sm', |
101 | 101 | 'value' => $date_paid, |
@@ -109,18 +109,18 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | // Due date. |
112 | - if ( $invoice->is_type( 'invoice' ) && wpinv_get_option( 'overdue_active' ) && ( ! $invoice->is_paid() || $invoice->is_draft() ) ) { |
|
112 | + if ($invoice->is_type('invoice') && wpinv_get_option('overdue_active') && (!$invoice->is_paid() || $invoice->is_draft())) { |
|
113 | 113 | |
114 | 114 | echo aui()->input( |
115 | 115 | array( |
116 | 116 | 'type' => 'datepicker', |
117 | 117 | 'id' => 'wpinv_due_date', |
118 | 118 | 'name' => 'wpinv_due_date', |
119 | - 'label' => __( 'Due Date:', 'invoicing' ) . getpaid_get_help_tip( __( 'Leave blank to disable automated reminder emails for this invoice.', 'invoicing' ) ), |
|
119 | + 'label' => __('Due Date:', 'invoicing') . getpaid_get_help_tip(__('Leave blank to disable automated reminder emails for this invoice.', 'invoicing')), |
|
120 | 120 | 'label_type' => 'vertical', |
121 | - 'placeholder' => __( 'No due date', 'invoicing' ), |
|
121 | + 'placeholder' => __('No due date', 'invoicing'), |
|
122 | 122 | 'class' => 'form-control-sm', |
123 | - 'value' => $invoice->get_due_date( 'edit' ), |
|
123 | + 'value' => $invoice->get_due_date('edit'), |
|
124 | 124 | 'extra_attributes' => array( |
125 | 125 | 'data-enable-time' => 'true', |
126 | 126 | 'data-time_24hr' => 'true', |
@@ -132,39 +132,39 @@ discard block |
||
132 | 132 | |
133 | 133 | } |
134 | 134 | |
135 | - do_action( 'wpinv_meta_box_details_after_due_date', $invoice->get_id() ); |
|
136 | - do_action( 'getpaid_metabox_after_due_date', $invoice ); |
|
135 | + do_action('wpinv_meta_box_details_after_due_date', $invoice->get_id()); |
|
136 | + do_action('getpaid_metabox_after_due_date', $invoice); |
|
137 | 137 | |
138 | 138 | // Status. |
139 | 139 | $label = sprintf( |
140 | - __( '%s Status:', 'invoicing' ), |
|
141 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
140 | + __('%s Status:', 'invoicing'), |
|
141 | + ucfirst($invoice->get_invoice_quote_type()) |
|
142 | 142 | ); |
143 | 143 | |
144 | - $status = $invoice->get_status( 'edit' ); |
|
144 | + $status = $invoice->get_status('edit'); |
|
145 | 145 | echo aui()->select( |
146 | 146 | array( |
147 | 147 | 'id' => 'wpinv_status', |
148 | 148 | 'name' => 'wpinv_status', |
149 | 149 | 'label' => $label, |
150 | 150 | 'label_type' => 'vertical', |
151 | - 'placeholder' => __( 'Select Status', 'invoicing' ), |
|
152 | - 'value' => array_key_exists( $status, $invoice->get_all_statuses() ) ? $status : $invoice->get_default_status(), |
|
151 | + 'placeholder' => __('Select Status', 'invoicing'), |
|
152 | + 'value' => array_key_exists($status, $invoice->get_all_statuses()) ? $status : $invoice->get_default_status(), |
|
153 | 153 | 'select2' => true, |
154 | 154 | 'data-allow-clear' => 'false', |
155 | - 'options' => wpinv_get_invoice_statuses( true, false, $invoice ) |
|
155 | + 'options' => wpinv_get_invoice_statuses(true, false, $invoice) |
|
156 | 156 | ) |
157 | 157 | ); |
158 | 158 | |
159 | 159 | // Invoice number. |
160 | 160 | $label = sprintf( |
161 | - __( '%s Number:', 'invoicing' ), |
|
162 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
161 | + __('%s Number:', 'invoicing'), |
|
162 | + ucfirst($invoice->get_invoice_quote_type()) |
|
163 | 163 | ); |
164 | 164 | |
165 | - $info = sprintf( |
|
166 | - __( 'Each %s number must be unique.', 'invoicing' ), |
|
167 | - strtolower( $invoice->get_invoice_quote_type() ) |
|
165 | + $info = sprintf( |
|
166 | + __('Each %s number must be unique.', 'invoicing'), |
|
167 | + strtolower($invoice->get_invoice_quote_type()) |
|
168 | 168 | ); |
169 | 169 | |
170 | 170 | echo aui()->input( |
@@ -172,11 +172,11 @@ discard block |
||
172 | 172 | 'type' => 'text', |
173 | 173 | 'id' => 'wpinv_number', |
174 | 174 | 'name' => 'wpinv_number', |
175 | - 'label' => $label . getpaid_get_help_tip( $info ), |
|
175 | + 'label' => $label . getpaid_get_help_tip($info), |
|
176 | 176 | 'label_type' => 'vertical', |
177 | - 'placeholder' => __( 'Autogenerate', 'invoicing' ), |
|
177 | + 'placeholder' => __('Autogenerate', 'invoicing'), |
|
178 | 178 | 'class' => 'form-control-sm', |
179 | - 'value' => $invoice->get_number( 'edit' ), |
|
179 | + 'value' => $invoice->get_number('edit'), |
|
180 | 180 | ) |
181 | 181 | ); |
182 | 182 | |
@@ -186,15 +186,15 @@ discard block |
||
186 | 186 | 'type' => 'text', |
187 | 187 | 'id' => 'wpinv_cc', |
188 | 188 | 'name' => 'wpinv_cc', |
189 | - 'label' => __( 'Email CC:', 'invoicing' ) . getpaid_get_help_tip( __( 'Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing' ) ), |
|
189 | + 'label' => __('Email CC:', 'invoicing') . getpaid_get_help_tip(__('Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing')), |
|
190 | 190 | 'label_type' => 'vertical', |
191 | - 'placeholder' => __( '[email protected], [email protected]', 'invoicing' ), |
|
191 | + 'placeholder' => __('[email protected], [email protected]', 'invoicing'), |
|
192 | 192 | 'class' => 'form-control-sm', |
193 | - 'value' => $invoice->get_email_cc( 'edit' ), |
|
193 | + 'value' => $invoice->get_email_cc('edit'), |
|
194 | 194 | ) |
195 | 195 | ); |
196 | 196 | |
197 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
197 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
198 | 198 | |
199 | 199 | // Apply a discount. |
200 | 200 | echo aui()->input( |
@@ -202,25 +202,25 @@ discard block |
||
202 | 202 | 'type' => 'text', |
203 | 203 | 'id' => 'wpinv_discount_code', |
204 | 204 | 'name' => 'wpinv_discount_code', |
205 | - 'label' => __( 'Discount Code:', 'invoicing' ), |
|
206 | - 'placeholder' => __( 'Apply Discount', 'invoicing' ), |
|
205 | + 'label' => __('Discount Code:', 'invoicing'), |
|
206 | + 'placeholder' => __('Apply Discount', 'invoicing'), |
|
207 | 207 | 'label_type' => 'vertical', |
208 | 208 | 'class' => 'form-control-sm', |
209 | - 'value' => $invoice->get_discount_code( 'edit' ), |
|
209 | + 'value' => $invoice->get_discount_code('edit'), |
|
210 | 210 | ) |
211 | 211 | ); |
212 | 212 | |
213 | - } else if ( $invoice->get_discount_code( 'edit' ) ) { |
|
213 | + } else if ($invoice->get_discount_code('edit')) { |
|
214 | 214 | |
215 | 215 | echo aui()->input( |
216 | 216 | array( |
217 | 217 | 'type' => 'text', |
218 | 218 | 'id' => 'wpinv_discount_code', |
219 | 219 | 'name' => 'wpinv_discount_code', |
220 | - 'label' => __( 'Discount Code:', 'invoicing' ), |
|
220 | + 'label' => __('Discount Code:', 'invoicing'), |
|
221 | 221 | 'label_type' => 'vertical', |
222 | 222 | 'class' => 'form-control-sm', |
223 | - 'value' => $invoice->get_discount_code( 'edit' ), |
|
223 | + 'value' => $invoice->get_discount_code('edit'), |
|
224 | 224 | 'extra_attributes' => array( |
225 | 225 | 'onclick' => 'this.select();', |
226 | 226 | 'readonly' => 'true', |
@@ -230,17 +230,17 @@ discard block |
||
230 | 230 | |
231 | 231 | } |
232 | 232 | |
233 | - do_action( 'wpinv_meta_box_details_inner', $invoice->get_id() ); |
|
233 | + do_action('wpinv_meta_box_details_inner', $invoice->get_id()); |
|
234 | 234 | |
235 | 235 | // Disable taxes. |
236 | - if ( wpinv_use_taxes() && ! ( $invoice->is_paid() || $invoice->is_refunded() ) ) { |
|
236 | + if (wpinv_use_taxes() && !($invoice->is_paid() || $invoice->is_refunded())) { |
|
237 | 237 | |
238 | 238 | echo aui()->input( |
239 | 239 | array( |
240 | 240 | 'id' => 'wpinv_taxable', |
241 | 241 | 'name' => 'disable_taxes', |
242 | 242 | 'type' => 'checkbox', |
243 | - 'label' => __( 'Disable taxes', 'invoicing' ), |
|
243 | + 'label' => __('Disable taxes', 'invoicing'), |
|
244 | 244 | 'value' => '1', |
245 | 245 | 'checked' => (bool) $invoice->get_disable_taxes(), |
246 | 246 | ) |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | |
249 | 249 | } |
250 | 250 | |
251 | - if ( $invoice->is_type( 'invoice' ) ) { |
|
251 | + if ($invoice->is_type('invoice')) { |
|
252 | 252 | |
253 | 253 | // Send to customer. |
254 | 254 | echo aui()->input( |
@@ -256,15 +256,15 @@ discard block |
||
256 | 256 | 'id' => 'wpinv_send_to_customer', |
257 | 257 | 'name' => 'send_to_customer', |
258 | 258 | 'type' => 'checkbox', |
259 | - 'label' => __( 'Send invoice to customer after saving', 'invoicing' ), |
|
259 | + 'label' => __('Send invoice to customer after saving', 'invoicing'), |
|
260 | 260 | 'value' => '1', |
261 | - 'checked' => $invoice->is_draft() && (bool) wpinv_get_option( 'email_user_invoice_active', true ), |
|
261 | + 'checked' => $invoice->is_draft() && (bool) wpinv_get_option('email_user_invoice_active', true), |
|
262 | 262 | ) |
263 | 263 | ); |
264 | 264 | |
265 | 265 | } |
266 | 266 | |
267 | - do_action( 'getpaid_metabox_after_invoice_details', $invoice ); |
|
267 | + do_action('getpaid_metabox_after_invoice_details', $invoice); |
|
268 | 268 | |
269 | 269 | ?> |
270 | 270 |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Paypal Payment Gateway class. |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @var array |
26 | 26 | */ |
27 | - protected $supports = array( 'subscription', 'sandbox' ); |
|
27 | + protected $supports = array('subscription', 'sandbox'); |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Payment method order. |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @var array |
61 | 61 | */ |
62 | - public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' ); |
|
62 | + public $currencies = array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR'); |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * URL to view a transaction. |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function __construct() { |
82 | 82 | |
83 | - $this->title = __( 'PayPal Standard', 'invoicing' ); |
|
84 | - $this->method_title = __( 'PayPal Standard', 'invoicing' ); |
|
85 | - $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' ); |
|
86 | - $this->notify_url = wpinv_get_ipn_url( $this->id ); |
|
83 | + $this->title = __('PayPal Standard', 'invoicing'); |
|
84 | + $this->method_title = __('PayPal Standard', 'invoicing'); |
|
85 | + $this->checkout_button_text = __('Proceed to PayPal', 'invoicing'); |
|
86 | + $this->notify_url = wpinv_get_ipn_url($this->id); |
|
87 | 87 | |
88 | - add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 ); |
|
89 | - add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) ); |
|
88 | + add_filter('getpaid_paypal_args', array($this, 'process_subscription'), 10, 2); |
|
89 | + add_filter('getpaid_paypal_sandbox_notice', array($this, 'sandbox_notice')); |
|
90 | 90 | |
91 | 91 | parent::__construct(); |
92 | 92 | } |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
101 | 101 | * @return array |
102 | 102 | */ |
103 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
103 | + public function process_payment($invoice, $submission_data, $submission) { |
|
104 | 104 | |
105 | 105 | // Get redirect url. |
106 | - $paypal_redirect = $this->get_request_url( $invoice ); |
|
106 | + $paypal_redirect = $this->get_request_url($invoice); |
|
107 | 107 | |
108 | 108 | // Add a note about the request url. |
109 | 109 | $invoice->add_note( |
110 | 110 | sprintf( |
111 | - __( 'Redirecting to PayPal: %s', 'invoicing' ), |
|
112 | - esc_url( $paypal_redirect ) |
|
111 | + __('Redirecting to PayPal: %s', 'invoicing'), |
|
112 | + esc_url($paypal_redirect) |
|
113 | 113 | ), |
114 | 114 | false, |
115 | 115 | false, |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | ); |
118 | 118 | |
119 | 119 | // Redirect to PayPal |
120 | - wp_redirect( $paypal_redirect ); |
|
120 | + wp_redirect($paypal_redirect); |
|
121 | 121 | exit; |
122 | 122 | |
123 | 123 | } |
@@ -128,21 +128,21 @@ discard block |
||
128 | 128 | * @param WPInv_Invoice $invoice Invoice object. |
129 | 129 | * @return string |
130 | 130 | */ |
131 | - public function get_request_url( $invoice ) { |
|
131 | + public function get_request_url($invoice) { |
|
132 | 132 | |
133 | 133 | // Endpoint for this request |
134 | - $this->endpoint = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?'; |
|
134 | + $this->endpoint = $this->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?'; |
|
135 | 135 | |
136 | 136 | // Retrieve paypal args. |
137 | - $paypal_args = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' ); |
|
137 | + $paypal_args = map_deep($this->get_paypal_args($invoice), 'urlencode'); |
|
138 | 138 | |
139 | - if ( $invoice->is_recurring() ) { |
|
139 | + if ($invoice->is_recurring()) { |
|
140 | 140 | $paypal_args['bn'] = 'GetPaid_Subscribe_WPS_US'; |
141 | 141 | } else { |
142 | 142 | $paypal_args['bn'] = 'GetPaid_ShoppingCart_WPS_US'; |
143 | 143 | } |
144 | 144 | |
145 | - return add_query_arg( $paypal_args, $this->endpoint ); |
|
145 | + return add_query_arg($paypal_args, $this->endpoint); |
|
146 | 146 | |
147 | 147 | } |
148 | 148 | |
@@ -152,25 +152,25 @@ discard block |
||
152 | 152 | * @param WPInv_Invoice $invoice Invoice object. |
153 | 153 | * @return array |
154 | 154 | */ |
155 | - protected function get_paypal_args( $invoice ) { |
|
155 | + protected function get_paypal_args($invoice) { |
|
156 | 156 | |
157 | 157 | // Whether or not to send the line items as one item. |
158 | - $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', false, $invoice ); |
|
158 | + $force_one_line_item = apply_filters('getpaid_paypal_force_one_line_item', false, $invoice); |
|
159 | 159 | |
160 | - if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) { |
|
160 | + if ($invoice->is_recurring() || (wpinv_use_taxes() && wpinv_prices_include_tax())) { |
|
161 | 161 | $force_one_line_item = true; |
162 | 162 | } |
163 | 163 | |
164 | 164 | $paypal_args = apply_filters( |
165 | 165 | 'getpaid_paypal_args', |
166 | 166 | array_merge( |
167 | - $this->get_transaction_args( $invoice ), |
|
168 | - $this->get_line_item_args( $invoice, $force_one_line_item ) |
|
167 | + $this->get_transaction_args($invoice), |
|
168 | + $this->get_line_item_args($invoice, $force_one_line_item) |
|
169 | 169 | ), |
170 | 170 | $invoice |
171 | 171 | ); |
172 | 172 | |
173 | - return $this->fix_request_length( $invoice, $paypal_args ); |
|
173 | + return $this->fix_request_length($invoice, $paypal_args); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | * @param WPInv_Invoice $invoice Invoice object. |
180 | 180 | * @return array |
181 | 181 | */ |
182 | - protected function get_transaction_args( $invoice ) { |
|
182 | + protected function get_transaction_args($invoice) { |
|
183 | 183 | |
184 | 184 | return array( |
185 | 185 | 'cmd' => '_cart', |
186 | - 'business' => wpinv_get_option( 'paypal_email', false ), |
|
186 | + 'business' => wpinv_get_option('paypal_email', false), |
|
187 | 187 | 'no_shipping' => '1', |
188 | 188 | 'shipping' => '0', |
189 | 189 | 'no_note' => '1', |
@@ -191,16 +191,16 @@ discard block |
||
191 | 191 | 'rm' => is_ssl() ? 2 : 1, |
192 | 192 | 'upload' => 1, |
193 | 193 | 'currency_code' => $invoice->get_currency(), // https://developer.paypal.com/docs/nvp-soap-api/currency-codes/#paypal |
194 | - 'return' => esc_url_raw( $this->get_return_url( $invoice ) ), |
|
195 | - 'cancel_return' => esc_url_raw( $invoice->get_checkout_payment_url() ), |
|
196 | - 'notify_url' => getpaid_limit_length( $this->notify_url, 255 ), |
|
197 | - 'invoice' => getpaid_limit_length( $invoice->get_number(), 127 ), |
|
194 | + 'return' => esc_url_raw($this->get_return_url($invoice)), |
|
195 | + 'cancel_return' => esc_url_raw($invoice->get_checkout_payment_url()), |
|
196 | + 'notify_url' => getpaid_limit_length($this->notify_url, 255), |
|
197 | + 'invoice' => getpaid_limit_length($invoice->get_number(), 127), |
|
198 | 198 | 'custom' => $invoice->get_id(), |
199 | - 'first_name' => getpaid_limit_length( $invoice->get_first_name(), 32 ), |
|
200 | - 'last_name' => getpaid_limit_length( $invoice->get_last_name(), 64 ), |
|
201 | - 'country' => getpaid_limit_length( $invoice->get_country(), 2 ), |
|
202 | - 'email' => getpaid_limit_length( $invoice->get_email(), 127 ), |
|
203 | - 'cbt' => get_bloginfo( 'name' ) |
|
199 | + 'first_name' => getpaid_limit_length($invoice->get_first_name(), 32), |
|
200 | + 'last_name' => getpaid_limit_length($invoice->get_last_name(), 64), |
|
201 | + 'country' => getpaid_limit_length($invoice->get_country(), 2), |
|
202 | + 'email' => getpaid_limit_length($invoice->get_email(), 127), |
|
203 | + 'cbt' => get_bloginfo('name') |
|
204 | 204 | ); |
205 | 205 | |
206 | 206 | } |
@@ -212,30 +212,30 @@ discard block |
||
212 | 212 | * @param bool $force_one_line_item Create only one item for this invoice. |
213 | 213 | * @return array |
214 | 214 | */ |
215 | - protected function get_line_item_args( $invoice, $force_one_line_item = false ) { |
|
215 | + protected function get_line_item_args($invoice, $force_one_line_item = false) { |
|
216 | 216 | |
217 | 217 | // Maybe send invoice as a single item. |
218 | - if ( $force_one_line_item ) { |
|
219 | - return $this->get_line_item_args_single_item( $invoice ); |
|
218 | + if ($force_one_line_item) { |
|
219 | + return $this->get_line_item_args_single_item($invoice); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | // Send each line item individually. |
223 | 223 | $line_item_args = array(); |
224 | 224 | |
225 | 225 | // Prepare line items. |
226 | - $this->prepare_line_items( $invoice ); |
|
226 | + $this->prepare_line_items($invoice); |
|
227 | 227 | |
228 | 228 | // Add taxes to the cart |
229 | - if ( wpinv_use_taxes() && $invoice->is_taxable() ) { |
|
230 | - $line_item_args['tax_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_tax(), 2 ); |
|
229 | + if (wpinv_use_taxes() && $invoice->is_taxable()) { |
|
230 | + $line_item_args['tax_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_tax(), 2); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | // Add discount. |
234 | - if ( $invoice->get_total_discount() > 0 ) { |
|
235 | - $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 ); |
|
234 | + if ($invoice->get_total_discount() > 0) { |
|
235 | + $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_discount(), 2); |
|
236 | 236 | } |
237 | 237 | |
238 | - return array_merge( $line_item_args, $this->get_line_items() ); |
|
238 | + return array_merge($line_item_args, $this->get_line_items()); |
|
239 | 239 | |
240 | 240 | } |
241 | 241 | |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | * @param WPInv_Invoice $invoice Invoice object. |
246 | 246 | * @return array |
247 | 247 | */ |
248 | - protected function get_line_item_args_single_item( $invoice ) { |
|
248 | + protected function get_line_item_args_single_item($invoice) { |
|
249 | 249 | $this->delete_line_items(); |
250 | 250 | |
251 | - $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() ); |
|
252 | - $this->add_line_item( $item_name, 1, wpinv_sanitize_amount( (float) $invoice->get_total(), 2 ), $invoice->get_id() ); |
|
251 | + $item_name = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number()); |
|
252 | + $this->add_line_item($item_name, 1, wpinv_sanitize_amount((float) $invoice->get_total(), 2), $invoice->get_id()); |
|
253 | 253 | |
254 | 254 | return $this->get_line_items(); |
255 | 255 | } |
@@ -273,19 +273,19 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @param WPInv_Invoice $invoice Invoice object. |
275 | 275 | */ |
276 | - protected function prepare_line_items( $invoice ) { |
|
276 | + protected function prepare_line_items($invoice) { |
|
277 | 277 | $this->delete_line_items(); |
278 | 278 | |
279 | 279 | // Items. |
280 | - foreach ( $invoice->get_items() as $item ) { |
|
280 | + foreach ($invoice->get_items() as $item) { |
|
281 | 281 | $amount = $item->get_price(); |
282 | 282 | $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity(); |
283 | - $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() ); |
|
283 | + $this->add_line_item($item->get_raw_name(), $quantity, $amount, $item->get_id()); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | // Fees. |
287 | - foreach ( $invoice->get_fees() as $fee => $data ) { |
|
288 | - $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) ); |
|
287 | + foreach ($invoice->get_fees() as $fee => $data) { |
|
288 | + $this->add_line_item($fee, 1, wpinv_sanitize_amount($data['initial_fee'])); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | } |
@@ -298,15 +298,15 @@ discard block |
||
298 | 298 | * @param float $amount Amount. |
299 | 299 | * @param string $item_number Item number. |
300 | 300 | */ |
301 | - protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) { |
|
302 | - $index = ( count( $this->line_items ) / 4 ) + 1; |
|
301 | + protected function add_line_item($item_name, $quantity = 1, $amount = 0.0, $item_number = '') { |
|
302 | + $index = (count($this->line_items) / 4) + 1; |
|
303 | 303 | |
304 | 304 | $item = apply_filters( |
305 | 305 | 'getpaid_paypal_line_item', |
306 | 306 | array( |
307 | - 'item_name' => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ), |
|
307 | + 'item_name' => html_entity_decode(getpaid_limit_length($item_name ? wp_strip_all_tags($item_name) : __('Item', 'invoicing'), 127), ENT_NOQUOTES, 'UTF-8'), |
|
308 | 308 | 'quantity' => (float) $quantity, |
309 | - 'amount' => wpinv_sanitize_amount( (float) $amount, 2 ), |
|
309 | + 'amount' => wpinv_sanitize_amount((float) $amount, 2), |
|
310 | 310 | 'item_number' => $item_number, |
311 | 311 | ), |
312 | 312 | $item_name, |
@@ -315,12 +315,12 @@ discard block |
||
315 | 315 | $item_number |
316 | 316 | ); |
317 | 317 | |
318 | - $this->line_items[ 'item_name_' . $index ] = getpaid_limit_length( $item['item_name'], 127 ); |
|
319 | - $this->line_items[ 'quantity_' . $index ] = $item['quantity']; |
|
318 | + $this->line_items['item_name_' . $index] = getpaid_limit_length($item['item_name'], 127); |
|
319 | + $this->line_items['quantity_' . $index] = $item['quantity']; |
|
320 | 320 | |
321 | 321 | // The price or amount of the product, service, or contribution, not including shipping, handling, or tax. |
322 | - $this->line_items[ 'amount_' . $index ] = $item['amount']; |
|
323 | - $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 ); |
|
322 | + $this->line_items['amount_' . $index] = $item['amount']; |
|
323 | + $this->line_items['item_number_' . $index] = getpaid_limit_length($item['item_number'], 127); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
@@ -332,19 +332,19 @@ discard block |
||
332 | 332 | * @param array $paypal_args Arguments sent to Paypal in the request. |
333 | 333 | * @return array |
334 | 334 | */ |
335 | - protected function fix_request_length( $invoice, $paypal_args ) { |
|
335 | + protected function fix_request_length($invoice, $paypal_args) { |
|
336 | 336 | $max_paypal_length = 2083; |
337 | - $query_candidate = http_build_query( $paypal_args, '', '&' ); |
|
337 | + $query_candidate = http_build_query($paypal_args, '', '&'); |
|
338 | 338 | |
339 | - if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) { |
|
339 | + if (strlen($this->endpoint . $query_candidate) <= $max_paypal_length) { |
|
340 | 340 | return $paypal_args; |
341 | 341 | } |
342 | 342 | |
343 | 343 | return apply_filters( |
344 | 344 | 'getpaid_paypal_args', |
345 | 345 | array_merge( |
346 | - $this->get_transaction_args( $invoice ), |
|
347 | - $this->get_line_item_args( $invoice, true ) |
|
346 | + $this->get_transaction_args($invoice), |
|
347 | + $this->get_line_item_args($invoice, true) |
|
348 | 348 | ), |
349 | 349 | $invoice |
350 | 350 | ); |
@@ -357,10 +357,10 @@ discard block |
||
357 | 357 | * @param array $paypal_args PayPal args. |
358 | 358 | * @param WPInv_Invoice $invoice Invoice object. |
359 | 359 | */ |
360 | - public function process_subscription( $paypal_args, $invoice ) { |
|
360 | + public function process_subscription($paypal_args, $invoice) { |
|
361 | 361 | |
362 | 362 | // Make sure this is a subscription. |
363 | - if ( ! $invoice->is_recurring() || ! $subscription = wpinv_get_subscription( $invoice ) ) { |
|
363 | + if (!$invoice->is_recurring() || !$subscription = wpinv_get_subscription($invoice)) { |
|
364 | 364 | return $paypal_args; |
365 | 365 | } |
366 | 366 | |
@@ -368,17 +368,17 @@ discard block |
||
368 | 368 | $paypal_args['cmd'] = '_xclick-subscriptions'; |
369 | 369 | |
370 | 370 | // Subscription name. |
371 | - $paypal_args['item_name'] = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() ); |
|
371 | + $paypal_args['item_name'] = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number()); |
|
372 | 372 | |
373 | 373 | // Get subscription args. |
374 | - $period = strtoupper( substr( $subscription->get_period(), 0, 1) ); |
|
374 | + $period = strtoupper(substr($subscription->get_period(), 0, 1)); |
|
375 | 375 | $interval = (int) $subscription->get_frequency(); |
376 | 376 | $bill_times = (int) $subscription->get_bill_times(); |
377 | - $initial_amount = (float) wpinv_sanitize_amount( $invoice->get_initial_total(), 2 ); |
|
378 | - $recurring_amount = (float) wpinv_sanitize_amount( $invoice->get_recurring_total(), 2 ); |
|
379 | - $subscription_item = $invoice->get_recurring( true ); |
|
377 | + $initial_amount = (float) wpinv_sanitize_amount($invoice->get_initial_total(), 2); |
|
378 | + $recurring_amount = (float) wpinv_sanitize_amount($invoice->get_recurring_total(), 2); |
|
379 | + $subscription_item = $invoice->get_recurring(true); |
|
380 | 380 | |
381 | - if ( $subscription_item->has_free_trial() ) { |
|
381 | + if ($subscription_item->has_free_trial()) { |
|
382 | 382 | |
383 | 383 | $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount; |
384 | 384 | |
@@ -388,28 +388,28 @@ discard block |
||
388 | 388 | // Trial period. |
389 | 389 | $paypal_args['t1'] = $subscription_item->get_trial_period(); |
390 | 390 | |
391 | - } else if ( $initial_amount != $recurring_amount ) { |
|
391 | + } else if ($initial_amount != $recurring_amount) { |
|
392 | 392 | |
393 | 393 | // No trial period, but initial amount includes a sign-up fee and/or other items, so charge it as a separate period. |
394 | 394 | |
395 | - if ( 1 == $bill_times ) { |
|
395 | + if (1 == $bill_times) { |
|
396 | 396 | $param_number = 3; |
397 | 397 | } else { |
398 | 398 | $param_number = 1; |
399 | 399 | } |
400 | 400 | |
401 | - $paypal_args[ 'a' . $param_number ] = $initial_amount ? $initial_amount : 0; |
|
401 | + $paypal_args['a' . $param_number] = $initial_amount ? $initial_amount : 0; |
|
402 | 402 | |
403 | 403 | // Sign Up interval |
404 | - $paypal_args[ 'p' . $param_number ] = $interval; |
|
404 | + $paypal_args['p' . $param_number] = $interval; |
|
405 | 405 | |
406 | 406 | // Sign Up unit of duration |
407 | - $paypal_args[ 't' . $param_number ] = $period; |
|
407 | + $paypal_args['t' . $param_number] = $period; |
|
408 | 408 | |
409 | 409 | } |
410 | 410 | |
411 | 411 | // We have a recurring payment |
412 | - if ( ! isset( $param_number ) || 1 == $param_number ) { |
|
412 | + if (!isset($param_number) || 1 == $param_number) { |
|
413 | 413 | |
414 | 414 | // Subscription price |
415 | 415 | $paypal_args['a3'] = $recurring_amount; |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | } |
424 | 424 | |
425 | 425 | // Recurring payments |
426 | - if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) { |
|
426 | + if (1 == $bill_times || ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial() && 2 == $bill_times)) { |
|
427 | 427 | |
428 | 428 | // Non-recurring payments |
429 | 429 | $paypal_args['src'] = 0; |
@@ -432,15 +432,15 @@ discard block |
||
432 | 432 | |
433 | 433 | $paypal_args['src'] = 1; |
434 | 434 | |
435 | - if ( $bill_times > 0 ) { |
|
435 | + if ($bill_times > 0) { |
|
436 | 436 | |
437 | 437 | // An initial period is being used to charge a sign-up fee |
438 | - if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) { |
|
438 | + if ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial()) { |
|
439 | 439 | $bill_times--; |
440 | 440 | } |
441 | 441 | |
442 | 442 | // Make sure it's not over the max of 52 |
443 | - $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 ); |
|
443 | + $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52); |
|
444 | 444 | |
445 | 445 | } |
446 | 446 | } |
@@ -449,10 +449,10 @@ discard block |
||
449 | 449 | $paypal_args['rm'] = 2; |
450 | 450 | |
451 | 451 | // Get rid of redudant items. |
452 | - foreach ( array( 'item_name_1', 'quantity_1', 'amount_1', 'item_number_1' ) as $arg ) { |
|
452 | + foreach (array('item_name_1', 'quantity_1', 'amount_1', 'item_number_1') as $arg) { |
|
453 | 453 | |
454 | - if ( isset( $paypal_args[ $arg ] ) ) { |
|
455 | - unset( $paypal_args[ $arg ] ); |
|
454 | + if (isset($paypal_args[$arg])) { |
|
455 | + unset($paypal_args[$arg]); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | } |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | * @return void |
472 | 472 | */ |
473 | 473 | public function verify_ipn() { |
474 | - new GetPaid_Paypal_Gateway_IPN_Handler( $this ); |
|
474 | + new GetPaid_Paypal_Gateway_IPN_Handler($this); |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | /** |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | public function sandbox_notice() { |
481 | 481 | |
482 | 482 | return sprintf( |
483 | - __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ), |
|
483 | + __('SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing'), |
|
484 | 484 | '<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">', |
485 | 485 | '</a>' |
486 | 486 | ); |
@@ -8,20 +8,20 @@ |
||
8 | 8 | * @var GetPaid_Payment_Form $form The current payment form |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | -$placeholder = esc_attr( $input_label ); |
|
14 | -$label = sanitize_text_field( $button_label ); |
|
13 | +$placeholder = esc_attr($input_label); |
|
14 | +$label = sanitize_text_field($button_label); |
|
15 | 15 | |
16 | -if ( ! empty( $description ) ) { |
|
16 | +if (!empty($description)) { |
|
17 | 17 | $description = "<small class='form-text text-muted'>$description</small>"; |
18 | 18 | } else { |
19 | 19 | $description = ''; |
20 | 20 | } |
21 | 21 | |
22 | 22 | $discount_code = ''; |
23 | -if ( ! empty( $form->invoice ) ) { |
|
24 | - $discount_code = esc_attr( $form->invoice->get_discount_code() ); |
|
23 | +if (!empty($form->invoice)) { |
|
24 | + $discount_code = esc_attr($form->invoice->get_discount_code()); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | ?> |
@@ -1,6 +1,6 @@ discard block |
||
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 |
||
18 | 18 | * |
19 | 19 | * @return string The rendered component. |
20 | 20 | */ |
21 | - public static function input($args = array()){ |
|
21 | + public static function input($args = array()) { |
|
22 | 22 | $defaults = array( |
23 | 23 | 'type' => 'text', |
24 | 24 | 'name' => '', |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * Parse incoming $args into an array and merge it with $defaults |
54 | 54 | */ |
55 | - $args = wp_parse_args( $args, $defaults ); |
|
55 | + $args = wp_parse_args($args, $defaults); |
|
56 | 56 | $output = ''; |
57 | - if ( ! empty( $args['type'] ) ) { |
|
57 | + if (!empty($args['type'])) { |
|
58 | 58 | // hidden label option needs to be empty |
59 | 59 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
60 | 60 | |
61 | - $type = sanitize_html_class( $args['type'] ); |
|
61 | + $type = sanitize_html_class($args['type']); |
|
62 | 62 | |
63 | 63 | $help_text = ''; |
64 | 64 | $label = ''; |
@@ -66,24 +66,24 @@ discard block |
||
66 | 66 | $label_args = array( |
67 | 67 | 'title'=> $args['label'], |
68 | 68 | 'for'=> $args['id'], |
69 | - 'class' => $args['label_class']." ", |
|
69 | + 'class' => $args['label_class'] . " ", |
|
70 | 70 | 'label_type' => $args['label_type'] |
71 | 71 | ); |
72 | 72 | |
73 | 73 | // floating labels need label after |
74 | - if( $args['label_type'] == 'floating' && $type != 'checkbox' ){ |
|
74 | + if ($args['label_type'] == 'floating' && $type != 'checkbox') { |
|
75 | 75 | $label_after = true; |
76 | 76 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
77 | 77 | } |
78 | 78 | |
79 | 79 | // Some special sauce for files |
80 | - if($type=='file' ){ |
|
80 | + if ($type == 'file') { |
|
81 | 81 | $label_after = true; // if type file we need the label after |
82 | 82 | $args['class'] .= ' custom-file-input '; |
83 | - }elseif($type=='checkbox'){ |
|
83 | + }elseif ($type == 'checkbox') { |
|
84 | 84 | $label_after = true; // if type file we need the label after |
85 | 85 | $args['class'] .= ' custom-control-input '; |
86 | - }elseif($type=='datepicker' || $type=='timepicker'){ |
|
86 | + }elseif ($type == 'datepicker' || $type == 'timepicker') { |
|
87 | 87 | $type = 'text'; |
88 | 88 | //$args['class'] .= ' aui-flatpickr bg-initial '; |
89 | 89 | $args['class'] .= ' bg-initial '; |
@@ -99,65 +99,65 @@ discard block |
||
99 | 99 | $output .= '<input type="' . $type . '" '; |
100 | 100 | |
101 | 101 | // name |
102 | - if(!empty($args['name'])){ |
|
103 | - $output .= ' name="'.esc_attr($args['name']).'" '; |
|
102 | + if (!empty($args['name'])) { |
|
103 | + $output .= ' name="' . esc_attr($args['name']) . '" '; |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | // id |
107 | - if(!empty($args['id'])){ |
|
108 | - $output .= ' id="'.sanitize_html_class($args['id']).'" '; |
|
107 | + if (!empty($args['id'])) { |
|
108 | + $output .= ' id="' . sanitize_html_class($args['id']) . '" '; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | // placeholder |
112 | - if(isset($args['placeholder']) && '' != $args['placeholder'] ){ |
|
113 | - $output .= ' placeholder="'.esc_attr($args['placeholder']).'" '; |
|
112 | + if (isset($args['placeholder']) && '' != $args['placeholder']) { |
|
113 | + $output .= ' placeholder="' . esc_attr($args['placeholder']) . '" '; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | // title |
117 | - if(!empty($args['title'])){ |
|
118 | - $output .= ' title="'.esc_attr($args['title']).'" '; |
|
117 | + if (!empty($args['title'])) { |
|
118 | + $output .= ' title="' . esc_attr($args['title']) . '" '; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | // value |
122 | - if(!empty($args['value'])){ |
|
123 | - $output .= ' value="'.sanitize_text_field($args['value']).'" '; |
|
122 | + if (!empty($args['value'])) { |
|
123 | + $output .= ' value="' . sanitize_text_field($args['value']) . '" '; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | // checked, for radio and checkboxes |
127 | - if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){ |
|
127 | + if (($type == 'checkbox' || $type == 'radio') && $args['checked']) { |
|
128 | 128 | $output .= ' checked '; |
129 | 129 | } |
130 | 130 | |
131 | 131 | // validation text |
132 | - if(!empty($args['validation_text'])){ |
|
133 | - $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" '; |
|
132 | + if (!empty($args['validation_text'])) { |
|
133 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" '; |
|
134 | 134 | $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
135 | 135 | } |
136 | 136 | |
137 | 137 | // validation_pattern |
138 | - if(!empty($args['validation_pattern'])){ |
|
139 | - $output .= ' pattern="'.$args['validation_pattern'].'" '; |
|
138 | + if (!empty($args['validation_pattern'])) { |
|
139 | + $output .= ' pattern="' . $args['validation_pattern'] . '" '; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | // step (for numbers) |
143 | - if(!empty($args['step'])){ |
|
144 | - $output .= ' step="'.$args['step'].'" '; |
|
143 | + if (!empty($args['step'])) { |
|
144 | + $output .= ' step="' . $args['step'] . '" '; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | // required |
148 | - if(!empty($args['required'])){ |
|
148 | + if (!empty($args['required'])) { |
|
149 | 149 | $output .= ' required '; |
150 | 150 | } |
151 | 151 | |
152 | 152 | // class |
153 | - $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
154 | - $output .= ' class="form-control '.$class.'" '; |
|
153 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : ''; |
|
154 | + $output .= ' class="form-control ' . $class . '" '; |
|
155 | 155 | |
156 | 156 | // data-attributes |
157 | 157 | $output .= AUI_Component_Helper::data_attributes($args); |
158 | 158 | |
159 | 159 | // extra attributes |
160 | - if(!empty($args['extra_attributes'])){ |
|
160 | + if (!empty($args['extra_attributes'])) { |
|
161 | 161 | $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
162 | 162 | } |
163 | 163 | |
@@ -166,40 +166,40 @@ discard block |
||
166 | 166 | |
167 | 167 | |
168 | 168 | // label |
169 | - if(!empty($args['label'])){ |
|
170 | - if($type == 'file'){$label_args['class'] .= 'custom-file-label';} |
|
171 | - elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';} |
|
172 | - $label = self::label( $label_args, $type ); |
|
169 | + if (!empty($args['label'])) { |
|
170 | + if ($type == 'file') {$label_args['class'] .= 'custom-file-label'; } |
|
171 | + elseif ($type == 'checkbox') {$label_args['class'] .= 'custom-control-label'; } |
|
172 | + $label = self::label($label_args, $type); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | // help text |
176 | - if(!empty($args['help_text'])){ |
|
176 | + if (!empty($args['help_text'])) { |
|
177 | 177 | $help_text = AUI_Component_Helper::help_text($args['help_text']); |
178 | 178 | } |
179 | 179 | |
180 | 180 | |
181 | 181 | // set help text in the correct possition |
182 | - if($label_after){ |
|
182 | + if ($label_after) { |
|
183 | 183 | $output .= $label . $help_text; |
184 | 184 | } |
185 | 185 | |
186 | 186 | // some input types need a separate wrap |
187 | - if($type == 'file') { |
|
188 | - $output = self::wrap( array( |
|
187 | + if ($type == 'file') { |
|
188 | + $output = self::wrap(array( |
|
189 | 189 | 'content' => $output, |
190 | 190 | 'class' => 'form-group custom-file' |
191 | - ) ); |
|
192 | - }elseif($type == 'checkbox'){ |
|
191 | + )); |
|
192 | + }elseif ($type == 'checkbox') { |
|
193 | 193 | $wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox'; |
194 | - $output = self::wrap( array( |
|
194 | + $output = self::wrap(array( |
|
195 | 195 | 'content' => $output, |
196 | - 'class' => 'custom-control '.$wrap_class |
|
197 | - ) ); |
|
196 | + 'class' => 'custom-control ' . $wrap_class |
|
197 | + )); |
|
198 | 198 | |
199 | - if($args['label_type']=='horizontal'){ |
|
199 | + if ($args['label_type'] == 'horizontal') { |
|
200 | 200 | $output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>'; |
201 | 201 | } |
202 | - }elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){ |
|
202 | + }elseif ($type == 'password' && $args['password_toggle'] && !$args['input_group_right']) { |
|
203 | 203 | |
204 | 204 | |
205 | 205 | // allow password field to toggle view |
@@ -213,49 +213,49 @@ discard block |
||
213 | 213 | } |
214 | 214 | |
215 | 215 | // input group wraps |
216 | - if($args['input_group_left'] || $args['input_group_right']){ |
|
216 | + if ($args['input_group_left'] || $args['input_group_right']) { |
|
217 | 217 | $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
218 | - if($args['input_group_left']){ |
|
219 | - $output = self::wrap( array( |
|
218 | + if ($args['input_group_left']) { |
|
219 | + $output = self::wrap(array( |
|
220 | 220 | 'content' => $output, |
221 | - 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group', |
|
221 | + 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
222 | 222 | 'input_group_left' => $args['input_group_left'], |
223 | 223 | 'input_group_left_inside' => $args['input_group_left_inside'] |
224 | - ) ); |
|
224 | + )); |
|
225 | 225 | } |
226 | - if($args['input_group_right']){ |
|
227 | - $output = self::wrap( array( |
|
226 | + if ($args['input_group_right']) { |
|
227 | + $output = self::wrap(array( |
|
228 | 228 | 'content' => $output, |
229 | - 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group', |
|
229 | + 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
230 | 230 | 'input_group_right' => $args['input_group_right'], |
231 | 231 | 'input_group_right_inside' => $args['input_group_right_inside'] |
232 | - ) ); |
|
232 | + )); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | } |
236 | 236 | |
237 | - if(!$label_after){ |
|
237 | + if (!$label_after) { |
|
238 | 238 | $output .= $help_text; |
239 | 239 | } |
240 | 240 | |
241 | 241 | |
242 | - if($args['label_type']=='horizontal' && $type != 'checkbox'){ |
|
243 | - $output = self::wrap( array( |
|
242 | + if ($args['label_type'] == 'horizontal' && $type != 'checkbox') { |
|
243 | + $output = self::wrap(array( |
|
244 | 244 | 'content' => $output, |
245 | 245 | 'class' => 'col-sm-10', |
246 | - ) ); |
|
246 | + )); |
|
247 | 247 | } |
248 | 248 | |
249 | - if(!$label_after){ |
|
249 | + if (!$label_after) { |
|
250 | 250 | $output = $label . $output; |
251 | 251 | } |
252 | 252 | |
253 | 253 | // wrap |
254 | - if(!$args['no_wrap']){ |
|
254 | + if (!$args['no_wrap']) { |
|
255 | 255 | |
256 | - $form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group'; |
|
257 | - $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
258 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
256 | + $form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group'; |
|
257 | + $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
258 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
259 | 259 | $output = self::wrap(array( |
260 | 260 | 'content' => $output, |
261 | 261 | 'class' => $wrap_class, |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @return string The rendered component. |
280 | 280 | */ |
281 | - public static function textarea($args = array()){ |
|
281 | + public static function textarea($args = array()) { |
|
282 | 282 | $defaults = array( |
283 | 283 | 'name' => '', |
284 | 284 | 'class' => '', |
@@ -306,43 +306,43 @@ discard block |
||
306 | 306 | /** |
307 | 307 | * Parse incoming $args into an array and merge it with $defaults |
308 | 308 | */ |
309 | - $args = wp_parse_args( $args, $defaults ); |
|
309 | + $args = wp_parse_args($args, $defaults); |
|
310 | 310 | $output = ''; |
311 | 311 | |
312 | 312 | // hidden label option needs to be empty |
313 | 313 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
314 | 314 | |
315 | 315 | // floating labels don't work with wysiwyg so set it as top |
316 | - if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){ |
|
316 | + if ($args['label_type'] == 'floating' && !empty($args['wysiwyg'])) { |
|
317 | 317 | $args['label_type'] = 'top'; |
318 | 318 | } |
319 | 319 | |
320 | 320 | $label_after = $args['label_after']; |
321 | 321 | |
322 | 322 | // floating labels need label after |
323 | - if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){ |
|
323 | + if ($args['label_type'] == 'floating' && empty($args['wysiwyg'])) { |
|
324 | 324 | $label_after = true; |
325 | 325 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
326 | 326 | } |
327 | 327 | |
328 | 328 | // label |
329 | - if(!empty($args['label']) && is_array($args['label'])){ |
|
330 | - }elseif(!empty($args['label']) && !$label_after){ |
|
329 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
330 | + }elseif (!empty($args['label']) && !$label_after) { |
|
331 | 331 | $label_args = array( |
332 | 332 | 'title'=> $args['label'], |
333 | 333 | 'for'=> $args['id'], |
334 | - 'class' => $args['label_class']." ", |
|
334 | + 'class' => $args['label_class'] . " ", |
|
335 | 335 | 'label_type' => $args['label_type'] |
336 | 336 | ); |
337 | - $output .= self::label( $label_args ); |
|
337 | + $output .= self::label($label_args); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | // maybe horizontal label |
341 | - if($args['label_type']=='horizontal'){ |
|
341 | + if ($args['label_type'] == 'horizontal') { |
|
342 | 342 | $output .= '<div class="col-sm-10">'; |
343 | 343 | } |
344 | 344 | |
345 | - if(!empty($args['wysiwyg'])){ |
|
345 | + if (!empty($args['wysiwyg'])) { |
|
346 | 346 | ob_start(); |
347 | 347 | $content = $args['value']; |
348 | 348 | $editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor'; |
@@ -356,65 +356,65 @@ discard block |
||
356 | 356 | ); |
357 | 357 | |
358 | 358 | // maybe set settings if array |
359 | - if(is_array($args['wysiwyg'])){ |
|
360 | - $settings = wp_parse_args( $args['wysiwyg'], $settings ); |
|
359 | + if (is_array($args['wysiwyg'])) { |
|
360 | + $settings = wp_parse_args($args['wysiwyg'], $settings); |
|
361 | 361 | } |
362 | 362 | |
363 | - wp_editor( $content, $editor_id, $settings ); |
|
363 | + wp_editor($content, $editor_id, $settings); |
|
364 | 364 | $output .= ob_get_clean(); |
365 | - }else{ |
|
365 | + } else { |
|
366 | 366 | |
367 | 367 | // open |
368 | 368 | $output .= '<textarea '; |
369 | 369 | |
370 | 370 | // name |
371 | - if(!empty($args['name'])){ |
|
372 | - $output .= ' name="'.sanitize_html_class($args['name']).'" '; |
|
371 | + if (!empty($args['name'])) { |
|
372 | + $output .= ' name="' . sanitize_html_class($args['name']) . '" '; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | // id |
376 | - if(!empty($args['id'])){ |
|
377 | - $output .= ' id="'.sanitize_html_class($args['id']).'" '; |
|
376 | + if (!empty($args['id'])) { |
|
377 | + $output .= ' id="' . sanitize_html_class($args['id']) . '" '; |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | // placeholder |
381 | - if(isset($args['placeholder']) && '' != $args['placeholder']){ |
|
382 | - $output .= ' placeholder="'.esc_attr($args['placeholder']).'" '; |
|
381 | + if (isset($args['placeholder']) && '' != $args['placeholder']) { |
|
382 | + $output .= ' placeholder="' . esc_attr($args['placeholder']) . '" '; |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | // title |
386 | - if(!empty($args['title'])){ |
|
387 | - $output .= ' title="'.esc_attr($args['title']).'" '; |
|
386 | + if (!empty($args['title'])) { |
|
387 | + $output .= ' title="' . esc_attr($args['title']) . '" '; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | // validation text |
391 | - if(!empty($args['validation_text'])){ |
|
392 | - $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" '; |
|
391 | + if (!empty($args['validation_text'])) { |
|
392 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" '; |
|
393 | 393 | $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
394 | 394 | } |
395 | 395 | |
396 | 396 | // validation_pattern |
397 | - if(!empty($args['validation_pattern'])){ |
|
398 | - $output .= ' pattern="'.$args['validation_pattern'].'" '; |
|
397 | + if (!empty($args['validation_pattern'])) { |
|
398 | + $output .= ' pattern="' . $args['validation_pattern'] . '" '; |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | // required |
402 | - if(!empty($args['required'])){ |
|
402 | + if (!empty($args['required'])) { |
|
403 | 403 | $output .= ' required '; |
404 | 404 | } |
405 | 405 | |
406 | 406 | // rows |
407 | - if(!empty($args['rows'])){ |
|
408 | - $output .= ' rows="'.absint($args['rows']).'" '; |
|
407 | + if (!empty($args['rows'])) { |
|
408 | + $output .= ' rows="' . absint($args['rows']) . '" '; |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | |
412 | 412 | // class |
413 | 413 | $class = !empty($args['class']) ? $args['class'] : ''; |
414 | - $output .= ' class="form-control '.$class.'" '; |
|
414 | + $output .= ' class="form-control ' . $class . '" '; |
|
415 | 415 | |
416 | 416 | // extra attributes |
417 | - if(!empty($args['extra_attributes'])){ |
|
417 | + if (!empty($args['extra_attributes'])) { |
|
418 | 418 | $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
419 | 419 | } |
420 | 420 | |
@@ -422,11 +422,11 @@ discard block |
||
422 | 422 | $output .= ' >'; |
423 | 423 | |
424 | 424 | // value |
425 | - if ( ! empty( $args['value'] ) ) { |
|
426 | - if ( ! empty( $args['allow_tags'] ) ) { |
|
427 | - $output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML. |
|
425 | + if (!empty($args['value'])) { |
|
426 | + if (!empty($args['allow_tags'])) { |
|
427 | + $output .= AUI_Component_Helper::sanitize_html_field($args['value'], $args); // Sanitize HTML. |
|
428 | 428 | } else { |
429 | - $output .= sanitize_textarea_field( $args['value'] ); |
|
429 | + $output .= sanitize_textarea_field($args['value']); |
|
430 | 430 | } |
431 | 431 | } |
432 | 432 | |
@@ -435,32 +435,32 @@ discard block |
||
435 | 435 | |
436 | 436 | } |
437 | 437 | |
438 | - if(!empty($args['label']) && $label_after){ |
|
438 | + if (!empty($args['label']) && $label_after) { |
|
439 | 439 | $label_args = array( |
440 | 440 | 'title'=> $args['label'], |
441 | 441 | 'for'=> $args['id'], |
442 | - 'class' => $args['label_class']." ", |
|
442 | + 'class' => $args['label_class'] . " ", |
|
443 | 443 | 'label_type' => $args['label_type'] |
444 | 444 | ); |
445 | - $output .= self::label( $label_args ); |
|
445 | + $output .= self::label($label_args); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | // help text |
449 | - if(!empty($args['help_text'])){ |
|
449 | + if (!empty($args['help_text'])) { |
|
450 | 450 | $output .= AUI_Component_Helper::help_text($args['help_text']); |
451 | 451 | } |
452 | 452 | |
453 | 453 | // maybe horizontal label |
454 | - if($args['label_type']=='horizontal'){ |
|
454 | + if ($args['label_type'] == 'horizontal') { |
|
455 | 455 | $output .= '</div>'; |
456 | 456 | } |
457 | 457 | |
458 | 458 | |
459 | 459 | // wrap |
460 | - if(!$args['no_wrap']){ |
|
461 | - $form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group'; |
|
462 | - $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
463 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
460 | + if (!$args['no_wrap']) { |
|
461 | + $form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group'; |
|
462 | + $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
463 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
464 | 464 | $output = self::wrap(array( |
465 | 465 | 'content' => $output, |
466 | 466 | 'class' => $wrap_class, |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | return $output; |
474 | 474 | } |
475 | 475 | |
476 | - public static function label($args = array(), $type = ''){ |
|
476 | + public static function label($args = array(), $type = '') { |
|
477 | 477 | //<label for="exampleInputEmail1">Email address</label> |
478 | 478 | $defaults = array( |
479 | 479 | 'title' => 'div', |
@@ -485,20 +485,20 @@ discard block |
||
485 | 485 | /** |
486 | 486 | * Parse incoming $args into an array and merge it with $defaults |
487 | 487 | */ |
488 | - $args = wp_parse_args( $args, $defaults ); |
|
488 | + $args = wp_parse_args($args, $defaults); |
|
489 | 489 | $output = ''; |
490 | 490 | |
491 | - if($args['title']){ |
|
491 | + if ($args['title']) { |
|
492 | 492 | |
493 | 493 | // maybe hide labels //@todo set a global option for visibility class |
494 | - if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){ |
|
494 | + if ($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type'])) { |
|
495 | 495 | $class = $args['class']; |
496 | - }else{ |
|
497 | - $class = 'sr-only '.$args['class']; |
|
496 | + } else { |
|
497 | + $class = 'sr-only ' . $args['class']; |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | // maybe horizontal |
501 | - if($args['label_type']=='horizontal' && $type != 'checkbox'){ |
|
501 | + if ($args['label_type'] == 'horizontal' && $type != 'checkbox') { |
|
502 | 502 | $class .= ' col-sm-2 col-form-label'; |
503 | 503 | } |
504 | 504 | |
@@ -506,20 +506,20 @@ discard block |
||
506 | 506 | $output .= '<label '; |
507 | 507 | |
508 | 508 | // for |
509 | - if(!empty($args['for'])){ |
|
510 | - $output .= ' for="'.sanitize_text_field($args['for']).'" '; |
|
509 | + if (!empty($args['for'])) { |
|
510 | + $output .= ' for="' . sanitize_text_field($args['for']) . '" '; |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | // class |
514 | - $class = $class ? AUI_Component_Helper::esc_classes( $class ) : ''; |
|
515 | - $output .= ' class="'.$class.'" '; |
|
514 | + $class = $class ? AUI_Component_Helper::esc_classes($class) : ''; |
|
515 | + $output .= ' class="' . $class . '" '; |
|
516 | 516 | |
517 | 517 | // close |
518 | 518 | $output .= '>'; |
519 | 519 | |
520 | 520 | |
521 | 521 | // title, don't escape fully as can contain html |
522 | - if(!empty($args['title'])){ |
|
522 | + if (!empty($args['title'])) { |
|
523 | 523 | $output .= wp_kses_post($args['title']); |
524 | 524 | } |
525 | 525 | |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | * |
541 | 541 | * @return string |
542 | 542 | */ |
543 | - public static function wrap($args = array()){ |
|
543 | + public static function wrap($args = array()) { |
|
544 | 544 | $defaults = array( |
545 | 545 | 'type' => 'div', |
546 | 546 | 'class' => 'form-group', |
@@ -556,55 +556,55 @@ discard block |
||
556 | 556 | /** |
557 | 557 | * Parse incoming $args into an array and merge it with $defaults |
558 | 558 | */ |
559 | - $args = wp_parse_args( $args, $defaults ); |
|
559 | + $args = wp_parse_args($args, $defaults); |
|
560 | 560 | $output = ''; |
561 | - if($args['type']){ |
|
561 | + if ($args['type']) { |
|
562 | 562 | |
563 | 563 | // open |
564 | - $output .= '<'.sanitize_html_class($args['type']); |
|
564 | + $output .= '<' . sanitize_html_class($args['type']); |
|
565 | 565 | |
566 | 566 | // element require |
567 | - if(!empty($args['element_require'])){ |
|
567 | + if (!empty($args['element_require'])) { |
|
568 | 568 | $output .= AUI_Component_Helper::element_require($args['element_require']); |
569 | 569 | $args['class'] .= " aui-conditional-field"; |
570 | 570 | } |
571 | 571 | |
572 | 572 | // argument_id |
573 | - if( !empty($args['argument_id']) ){ |
|
574 | - $output .= ' data-argument="'.esc_attr($args['argument_id']).'"'; |
|
573 | + if (!empty($args['argument_id'])) { |
|
574 | + $output .= ' data-argument="' . esc_attr($args['argument_id']) . '"'; |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | // class |
578 | - $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
579 | - $output .= ' class="'.$class.'" '; |
|
578 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : ''; |
|
579 | + $output .= ' class="' . $class . '" '; |
|
580 | 580 | |
581 | 581 | // close wrap |
582 | 582 | $output .= ' >'; |
583 | 583 | |
584 | 584 | |
585 | 585 | // Input group left |
586 | - if(!empty($args['input_group_left'])){ |
|
586 | + if (!empty($args['input_group_left'])) { |
|
587 | 587 | $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : ''; |
588 | - $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>'; |
|
589 | - $output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>'; |
|
588 | + $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>'; |
|
589 | + $output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>'; |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | // content |
593 | 593 | $output .= $args['content']; |
594 | 594 | |
595 | 595 | // Input group right |
596 | - if(!empty($args['input_group_right'])){ |
|
596 | + if (!empty($args['input_group_right'])) { |
|
597 | 597 | $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : ''; |
598 | - $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>'; |
|
599 | - $output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>'; |
|
598 | + $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>'; |
|
599 | + $output .= '<div class="input-group-append ' . $position_class . '">' . $input_group_right . '</div>'; |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | |
603 | 603 | // close wrap |
604 | - $output .= '</'.sanitize_html_class($args['type']).'>'; |
|
604 | + $output .= '</' . sanitize_html_class($args['type']) . '>'; |
|
605 | 605 | |
606 | 606 | |
607 | - }else{ |
|
607 | + } else { |
|
608 | 608 | $output = $args['content']; |
609 | 609 | } |
610 | 610 | |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | * |
619 | 619 | * @return string The rendered component. |
620 | 620 | */ |
621 | - public static function select($args = array()){ |
|
621 | + public static function select($args = array()) { |
|
622 | 622 | $defaults = array( |
623 | 623 | 'class' => '', |
624 | 624 | 'wrap_class' => '', |
@@ -644,11 +644,11 @@ discard block |
||
644 | 644 | /** |
645 | 645 | * Parse incoming $args into an array and merge it with $defaults |
646 | 646 | */ |
647 | - $args = wp_parse_args( $args, $defaults ); |
|
647 | + $args = wp_parse_args($args, $defaults); |
|
648 | 648 | $output = ''; |
649 | 649 | |
650 | 650 | // for now lets hide floating labels |
651 | - if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';} |
|
651 | + if ($args['label_type'] == 'floating') {$args['label_type'] = 'hidden'; } |
|
652 | 652 | |
653 | 653 | // hidden label option needs to be empty |
654 | 654 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
@@ -657,47 +657,47 @@ discard block |
||
657 | 657 | $label_after = $args['label_after']; |
658 | 658 | |
659 | 659 | // floating labels need label after |
660 | - if( $args['label_type'] == 'floating' ){ |
|
660 | + if ($args['label_type'] == 'floating') { |
|
661 | 661 | $label_after = true; |
662 | 662 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
663 | 663 | } |
664 | 664 | |
665 | 665 | // Maybe setup select2 |
666 | 666 | $is_select2 = false; |
667 | - if(!empty($args['select2'])){ |
|
667 | + if (!empty($args['select2'])) { |
|
668 | 668 | $args['class'] .= ' aui-select2'; |
669 | 669 | $is_select2 = true; |
670 | - }elseif( strpos($args['class'], 'aui-select2') !== false){ |
|
670 | + }elseif (strpos($args['class'], 'aui-select2') !== false) { |
|
671 | 671 | $is_select2 = true; |
672 | 672 | } |
673 | 673 | |
674 | 674 | // select2 tags |
675 | - if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason |
|
675 | + if (!empty($args['select2']) && $args['select2'] === 'tags') { // triple equals needed here for some reason |
|
676 | 676 | $args['data-tags'] = 'true'; |
677 | 677 | $args['data-token-separators'] = "[',']"; |
678 | 678 | $args['multiple'] = true; |
679 | 679 | } |
680 | 680 | |
681 | 681 | // select2 placeholder |
682 | - if($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])){ |
|
682 | + if ($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])) { |
|
683 | 683 | $args['data-placeholder'] = esc_attr($args['placeholder']); |
684 | 684 | $args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true; |
685 | 685 | } |
686 | 686 | |
687 | 687 | // label |
688 | - if(!empty($args['label']) && is_array($args['label'])){ |
|
689 | - }elseif(!empty($args['label']) && !$label_after){ |
|
688 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
689 | + }elseif (!empty($args['label']) && !$label_after) { |
|
690 | 690 | $label_args = array( |
691 | 691 | 'title'=> $args['label'], |
692 | 692 | 'for'=> $args['id'], |
693 | - 'class' => $args['label_class']." ", |
|
693 | + 'class' => $args['label_class'] . " ", |
|
694 | 694 | 'label_type' => $args['label_type'] |
695 | 695 | ); |
696 | 696 | $output .= self::label($label_args); |
697 | 697 | } |
698 | 698 | |
699 | 699 | // maybe horizontal label |
700 | - if($args['label_type']=='horizontal'){ |
|
700 | + if ($args['label_type'] == 'horizontal') { |
|
701 | 701 | $output .= '<div class="col-sm-10">'; |
702 | 702 | } |
703 | 703 | |
@@ -705,32 +705,32 @@ discard block |
||
705 | 705 | $output .= '<select '; |
706 | 706 | |
707 | 707 | // style |
708 | - if($is_select2){ |
|
708 | + if ($is_select2) { |
|
709 | 709 | $output .= " style='width:100%;' "; |
710 | 710 | } |
711 | 711 | |
712 | 712 | // element require |
713 | - if(!empty($args['element_require'])){ |
|
713 | + if (!empty($args['element_require'])) { |
|
714 | 714 | $output .= AUI_Component_Helper::element_require($args['element_require']); |
715 | 715 | $args['class'] .= " aui-conditional-field"; |
716 | 716 | } |
717 | 717 | |
718 | 718 | // class |
719 | 719 | $class = !empty($args['class']) ? $args['class'] : ''; |
720 | - $output .= AUI_Component_Helper::class_attr('custom-select '.$class); |
|
720 | + $output .= AUI_Component_Helper::class_attr('custom-select ' . $class); |
|
721 | 721 | |
722 | 722 | // name |
723 | - if(!empty($args['name'])){ |
|
724 | - $output .= AUI_Component_Helper::name($args['name'],$args['multiple']); |
|
723 | + if (!empty($args['name'])) { |
|
724 | + $output .= AUI_Component_Helper::name($args['name'], $args['multiple']); |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | // id |
728 | - if(!empty($args['id'])){ |
|
728 | + if (!empty($args['id'])) { |
|
729 | 729 | $output .= AUI_Component_Helper::id($args['id']); |
730 | 730 | } |
731 | 731 | |
732 | 732 | // title |
733 | - if(!empty($args['title'])){ |
|
733 | + if (!empty($args['title'])) { |
|
734 | 734 | $output .= AUI_Component_Helper::title($args['title']); |
735 | 735 | } |
736 | 736 | |
@@ -741,17 +741,17 @@ discard block |
||
741 | 741 | $output .= AUI_Component_Helper::aria_attributes($args); |
742 | 742 | |
743 | 743 | // extra attributes |
744 | - if(!empty($args['extra_attributes'])){ |
|
744 | + if (!empty($args['extra_attributes'])) { |
|
745 | 745 | $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
746 | 746 | } |
747 | 747 | |
748 | 748 | // required |
749 | - if(!empty($args['required'])){ |
|
749 | + if (!empty($args['required'])) { |
|
750 | 750 | $output .= ' required '; |
751 | 751 | } |
752 | 752 | |
753 | 753 | // multiple |
754 | - if(!empty($args['multiple'])){ |
|
754 | + if (!empty($args['multiple'])) { |
|
755 | 755 | $output .= ' multiple '; |
756 | 756 | } |
757 | 757 | |
@@ -759,21 +759,21 @@ discard block |
||
759 | 759 | $output .= ' >'; |
760 | 760 | |
761 | 761 | // placeholder |
762 | - if(isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2){ |
|
763 | - $output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>'; |
|
764 | - }elseif($is_select2 && !empty($args['placeholder'])){ |
|
762 | + if (isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2) { |
|
763 | + $output .= '<option value="" disabled selected hidden>' . esc_attr($args['placeholder']) . '</option>'; |
|
764 | + }elseif ($is_select2 && !empty($args['placeholder'])) { |
|
765 | 765 | $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder |
766 | 766 | } |
767 | 767 | |
768 | 768 | // Options |
769 | - if(!empty($args['options'])){ |
|
769 | + if (!empty($args['options'])) { |
|
770 | 770 | |
771 | - if(!is_array($args['options'])){ |
|
771 | + if (!is_array($args['options'])) { |
|
772 | 772 | $output .= $args['options']; // not the preferred way but an option |
773 | - }else{ |
|
774 | - foreach($args['options'] as $val => $name){ |
|
773 | + } else { |
|
774 | + foreach ($args['options'] as $val => $name) { |
|
775 | 775 | $selected = ''; |
776 | - if(is_array($name)){ |
|
776 | + if (is_array($name)) { |
|
777 | 777 | if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) { |
778 | 778 | $option_label = isset($name['label']) ? $name['label'] : ''; |
779 | 779 | |
@@ -781,23 +781,23 @@ discard block |
||
781 | 781 | } else { |
782 | 782 | $option_label = isset($name['label']) ? $name['label'] : ''; |
783 | 783 | $option_value = isset($name['value']) ? $name['value'] : ''; |
784 | - if(!empty($args['multiple']) && !empty($args['value']) && is_array($args['value']) ){ |
|
784 | + if (!empty($args['multiple']) && !empty($args['value']) && is_array($args['value'])) { |
|
785 | 785 | $selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : ""; |
786 | - } elseif(!empty($args['value'])) { |
|
787 | - $selected = selected($option_value,stripslashes_deep($args['value']), false); |
|
786 | + } elseif (!empty($args['value'])) { |
|
787 | + $selected = selected($option_value, stripslashes_deep($args['value']), false); |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | $output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>'; |
791 | 791 | } |
792 | - }else{ |
|
793 | - if(!empty($args['value'])){ |
|
794 | - if(is_array($args['value'])){ |
|
795 | - $selected = in_array($val,$args['value']) ? 'selected="selected"' : ''; |
|
796 | - } elseif(!empty($args['value'])) { |
|
797 | - $selected = selected( $args['value'], $val, false); |
|
792 | + } else { |
|
793 | + if (!empty($args['value'])) { |
|
794 | + if (is_array($args['value'])) { |
|
795 | + $selected = in_array($val, $args['value']) ? 'selected="selected"' : ''; |
|
796 | + } elseif (!empty($args['value'])) { |
|
797 | + $selected = selected($args['value'], $val, false); |
|
798 | 798 | } |
799 | 799 | } |
800 | - $output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>'; |
|
800 | + $output .= '<option value="' . esc_attr($val) . '" ' . $selected . '>' . esc_attr($name) . '</option>'; |
|
801 | 801 | } |
802 | 802 | } |
803 | 803 | } |
@@ -807,31 +807,31 @@ discard block |
||
807 | 807 | // closing tag |
808 | 808 | $output .= '</select>'; |
809 | 809 | |
810 | - if(!empty($args['label']) && $label_after){ |
|
810 | + if (!empty($args['label']) && $label_after) { |
|
811 | 811 | $label_args = array( |
812 | 812 | 'title'=> $args['label'], |
813 | 813 | 'for'=> $args['id'], |
814 | - 'class' => $args['label_class']." ", |
|
814 | + 'class' => $args['label_class'] . " ", |
|
815 | 815 | 'label_type' => $args['label_type'] |
816 | 816 | ); |
817 | 817 | $output .= self::label($label_args); |
818 | 818 | } |
819 | 819 | |
820 | 820 | // help text |
821 | - if(!empty($args['help_text'])){ |
|
821 | + if (!empty($args['help_text'])) { |
|
822 | 822 | $output .= AUI_Component_Helper::help_text($args['help_text']); |
823 | 823 | } |
824 | 824 | |
825 | 825 | // maybe horizontal label |
826 | - if($args['label_type']=='horizontal'){ |
|
826 | + if ($args['label_type'] == 'horizontal') { |
|
827 | 827 | $output .= '</div>'; |
828 | 828 | } |
829 | 829 | |
830 | 830 | |
831 | 831 | // wrap |
832 | - if(!$args['no_wrap']){ |
|
833 | - $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group'; |
|
834 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
832 | + if (!$args['no_wrap']) { |
|
833 | + $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group'; |
|
834 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
835 | 835 | $output = self::wrap(array( |
836 | 836 | 'content' => $output, |
837 | 837 | 'class' => $wrap_class, |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | * |
852 | 852 | * @return string The rendered component. |
853 | 853 | */ |
854 | - public static function radio($args = array()){ |
|
854 | + public static function radio($args = array()) { |
|
855 | 855 | $defaults = array( |
856 | 856 | 'class' => '', |
857 | 857 | 'wrap_class' => '', |
@@ -875,14 +875,14 @@ discard block |
||
875 | 875 | /** |
876 | 876 | * Parse incoming $args into an array and merge it with $defaults |
877 | 877 | */ |
878 | - $args = wp_parse_args( $args, $defaults ); |
|
878 | + $args = wp_parse_args($args, $defaults); |
|
879 | 879 | |
880 | 880 | // for now lets use horizontal for floating |
881 | - if( $args['label_type'] == 'floating' ){$args['label_type'] = 'horizontal';} |
|
881 | + if ($args['label_type'] == 'floating') {$args['label_type'] = 'horizontal'; } |
|
882 | 882 | |
883 | 883 | $label_args = array( |
884 | 884 | 'title'=> $args['label'], |
885 | - 'class' => $args['label_class']." pt-0 ", |
|
885 | + 'class' => $args['label_class'] . " pt-0 ", |
|
886 | 886 | 'label_type' => $args['label_type'] |
887 | 887 | ); |
888 | 888 | |
@@ -891,39 +891,39 @@ discard block |
||
891 | 891 | |
892 | 892 | |
893 | 893 | // label before |
894 | - if(!empty($args['label'])){ |
|
895 | - $output .= self::label( $label_args, 'radio' ); |
|
894 | + if (!empty($args['label'])) { |
|
895 | + $output .= self::label($label_args, 'radio'); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | // maybe horizontal label |
899 | - if($args['label_type']=='horizontal'){ |
|
899 | + if ($args['label_type'] == 'horizontal') { |
|
900 | 900 | $output .= '<div class="col-sm-10">'; |
901 | 901 | } |
902 | 902 | |
903 | - if(!empty($args['options'])){ |
|
903 | + if (!empty($args['options'])) { |
|
904 | 904 | $count = 0; |
905 | - foreach($args['options'] as $value => $label){ |
|
905 | + foreach ($args['options'] as $value => $label) { |
|
906 | 906 | $option_args = $args; |
907 | 907 | $option_args['value'] = $value; |
908 | 908 | $option_args['label'] = $label; |
909 | 909 | $option_args['checked'] = $value == $args['value'] ? true : false; |
910 | - $output .= self::radio_option($option_args,$count); |
|
910 | + $output .= self::radio_option($option_args, $count); |
|
911 | 911 | $count++; |
912 | 912 | } |
913 | 913 | } |
914 | 914 | |
915 | 915 | // help text |
916 | - $help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : ''; |
|
916 | + $help_text = !empty($args['help_text']) ? AUI_Component_Helper::help_text($args['help_text']) : ''; |
|
917 | 917 | $output .= $help_text; |
918 | 918 | |
919 | 919 | // maybe horizontal label |
920 | - if($args['label_type']=='horizontal'){ |
|
920 | + if ($args['label_type'] == 'horizontal') { |
|
921 | 921 | $output .= '</div>'; |
922 | 922 | } |
923 | 923 | |
924 | 924 | // wrap |
925 | - $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group'; |
|
926 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
925 | + $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group'; |
|
926 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
927 | 927 | $output = self::wrap(array( |
928 | 928 | 'content' => $output, |
929 | 929 | 'class' => $wrap_class, |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | * |
943 | 943 | * @return string The rendered component. |
944 | 944 | */ |
945 | - public static function radio_option($args = array(),$count = ''){ |
|
945 | + public static function radio_option($args = array(), $count = '') { |
|
946 | 946 | $defaults = array( |
947 | 947 | 'class' => '', |
948 | 948 | 'id' => '', |
@@ -960,7 +960,7 @@ discard block |
||
960 | 960 | /** |
961 | 961 | * Parse incoming $args into an array and merge it with $defaults |
962 | 962 | */ |
963 | - $args = wp_parse_args( $args, $defaults ); |
|
963 | + $args = wp_parse_args($args, $defaults); |
|
964 | 964 | |
965 | 965 | $output = ''; |
966 | 966 | |
@@ -971,27 +971,27 @@ discard block |
||
971 | 971 | $output .= ' class="form-check-input" '; |
972 | 972 | |
973 | 973 | // name |
974 | - if(!empty($args['name'])){ |
|
974 | + if (!empty($args['name'])) { |
|
975 | 975 | $output .= AUI_Component_Helper::name($args['name']); |
976 | 976 | } |
977 | 977 | |
978 | 978 | // id |
979 | - if(!empty($args['id'])){ |
|
980 | - $output .= AUI_Component_Helper::id($args['id'].$count); |
|
979 | + if (!empty($args['id'])) { |
|
980 | + $output .= AUI_Component_Helper::id($args['id'] . $count); |
|
981 | 981 | } |
982 | 982 | |
983 | 983 | // title |
984 | - if(!empty($args['title'])){ |
|
984 | + if (!empty($args['title'])) { |
|
985 | 985 | $output .= AUI_Component_Helper::title($args['title']); |
986 | 986 | } |
987 | 987 | |
988 | 988 | // value |
989 | - if(isset($args['value'])){ |
|
990 | - $output .= ' value="'.sanitize_text_field($args['value']).'" '; |
|
989 | + if (isset($args['value'])) { |
|
990 | + $output .= ' value="' . sanitize_text_field($args['value']) . '" '; |
|
991 | 991 | } |
992 | 992 | |
993 | 993 | // checked, for radio and checkboxes |
994 | - if( $args['checked'] ){ |
|
994 | + if ($args['checked']) { |
|
995 | 995 | $output .= ' checked '; |
996 | 996 | } |
997 | 997 | |
@@ -1002,12 +1002,12 @@ discard block |
||
1002 | 1002 | $output .= AUI_Component_Helper::aria_attributes($args); |
1003 | 1003 | |
1004 | 1004 | // extra attributes |
1005 | - if(!empty($args['extra_attributes'])){ |
|
1005 | + if (!empty($args['extra_attributes'])) { |
|
1006 | 1006 | $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
1007 | 1007 | } |
1008 | 1008 | |
1009 | 1009 | // required |
1010 | - if(!empty($args['required'])){ |
|
1010 | + if (!empty($args['required'])) { |
|
1011 | 1011 | $output .= ' required '; |
1012 | 1012 | } |
1013 | 1013 | |
@@ -1015,13 +1015,13 @@ discard block |
||
1015 | 1015 | $output .= ' >'; |
1016 | 1016 | |
1017 | 1017 | // label |
1018 | - if(!empty($args['label']) && is_array($args['label'])){ |
|
1019 | - }elseif(!empty($args['label'])){ |
|
1020 | - $output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio'); |
|
1018 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
1019 | + }elseif (!empty($args['label'])) { |
|
1020 | + $output .= self::label(array('title'=>$args['label'], 'for'=>$args['id'] . $count, 'class'=>'form-check-label'), 'radio'); |
|
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | // wrap |
1024 | - if(!$args['no_wrap']){ |
|
1024 | + if (!$args['no_wrap']) { |
|
1025 | 1025 | $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check'; |
1026 | 1026 | $output = self::wrap(array( |
1027 | 1027 | 'content' => $output, |
@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | /** |
13 | 13 | * Bail if we are not in WP. |
14 | 14 | */ |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if (!defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Only add if the class does not already exist. |
21 | 21 | */ |
22 | -if ( ! class_exists( 'AyeCode_UI_Settings' ) ) { |
|
22 | +if (!class_exists('AyeCode_UI_Settings')) { |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * A Class to be able to change settings for Font Awesome. |
@@ -98,23 +98,23 @@ discard block |
||
98 | 98 | * @return AyeCode_UI_Settings - Main instance. |
99 | 99 | */ |
100 | 100 | public static function instance() { |
101 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
101 | + if (!isset(self::$instance) && !(self::$instance instanceof AyeCode_UI_Settings)) { |
|
102 | 102 | |
103 | 103 | self::$instance = new AyeCode_UI_Settings; |
104 | 104 | |
105 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
105 | + add_action('init', array(self::$instance, 'init')); // set settings |
|
106 | 106 | |
107 | - if ( is_admin() ) { |
|
108 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
109 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
107 | + if (is_admin()) { |
|
108 | + add_action('admin_menu', array(self::$instance, 'menu_item')); |
|
109 | + add_action('admin_init', array(self::$instance, 'register_settings')); |
|
110 | 110 | |
111 | 111 | // Maybe show example page |
112 | - add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
112 | + add_action('template_redirect', array(self::$instance, 'maybe_show_examples')); |
|
113 | 113 | } |
114 | 114 | |
115 | - add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
115 | + add_action('customize_register', array(self::$instance, 'customizer_settings')); |
|
116 | 116 | |
117 | - do_action( 'ayecode_ui_settings_loaded' ); |
|
117 | + do_action('ayecode_ui_settings_loaded'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | return self::$instance; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | /** |
124 | 124 | * Setup some constants. |
125 | 125 | */ |
126 | - public function constants(){ |
|
126 | + public function constants() { |
|
127 | 127 | define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
128 | 128 | define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
129 | 129 | if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
@@ -143,25 +143,25 @@ discard block |
||
143 | 143 | * |
144 | 144 | * We load super early in case there is a theme version that might change the colors |
145 | 145 | */ |
146 | - if ( $this->settings['css'] ) { |
|
147 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
146 | + if ($this->settings['css']) { |
|
147 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 1); |
|
148 | 148 | } |
149 | - if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
150 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
149 | + if ($this->settings['css_backend'] && $this->load_admin_scripts()) { |
|
150 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 1); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // maybe load JS |
154 | - if ( $this->settings['js'] ) { |
|
154 | + if ($this->settings['js']) { |
|
155 | 155 | $priority = $this->is_bs3_compat() ? 100 : 1; |
156 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
156 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), $priority); |
|
157 | 157 | } |
158 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
159 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
158 | + if ($this->settings['js_backend'] && $this->load_admin_scripts()) { |
|
159 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 1); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | // Maybe set the HTML font size |
163 | - if ( $this->settings['html_font_size'] ) { |
|
164 | - add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
163 | + if ($this->settings['html_font_size']) { |
|
164 | + add_action('wp_footer', array($this, 'html_font_size'), 10); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -172,14 +172,14 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return bool |
174 | 174 | */ |
175 | - public function load_admin_scripts(){ |
|
175 | + public function load_admin_scripts() { |
|
176 | 176 | $result = true; |
177 | 177 | |
178 | 178 | // check if specifically disabled |
179 | - if(!empty($this->settings['disable_admin'])){ |
|
180 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
181 | - foreach($url_parts as $part){ |
|
182 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
179 | + if (!empty($this->settings['disable_admin'])) { |
|
180 | + $url_parts = explode("\n", $this->settings['disable_admin']); |
|
181 | + foreach ($url_parts as $part) { |
|
182 | + if (strpos($_SERVER['REQUEST_URI'], trim($part)) !== false) { |
|
183 | 183 | return false; // return early, no point checking further |
184 | 184 | } |
185 | 185 | } |
@@ -191,9 +191,9 @@ discard block |
||
191 | 191 | /** |
192 | 192 | * Add a html font size to the footer. |
193 | 193 | */ |
194 | - public function html_font_size(){ |
|
194 | + public function html_font_size() { |
|
195 | 195 | $this->settings = $this->get_settings(); |
196 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
196 | + echo "<style>html{font-size:" . absint($this->settings['html_font_size']) . "px;}</style>"; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -201,10 +201,10 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @return bool |
203 | 203 | */ |
204 | - public function is_aui_screen(){ |
|
204 | + public function is_aui_screen() { |
|
205 | 205 | $load = false; |
206 | 206 | // check if we should load or not |
207 | - if ( is_admin() ) { |
|
207 | + if (is_admin()) { |
|
208 | 208 | // Only enable on set pages |
209 | 209 | $aui_screens = array( |
210 | 210 | 'page', |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | 'settings_page_ayecode-ui-settings', |
213 | 213 | 'appearance_page_gutenberg-widgets' |
214 | 214 | ); |
215 | - $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
215 | + $screen_ids = apply_filters('aui_screen_ids', $aui_screens); |
|
216 | 216 | |
217 | 217 | $screen = get_current_screen(); |
218 | 218 | |
219 | 219 | // echo '###'.$screen->id; |
220 | 220 | |
221 | - if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
221 | + if ($screen && in_array($screen->id, $screen_ids)) { |
|
222 | 222 | $load = true; |
223 | 223 | } |
224 | 224 | } |
@@ -231,25 +231,25 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function enqueue_style() { |
233 | 233 | |
234 | - if( is_admin() && !$this->is_aui_screen()){ |
|
234 | + if (is_admin() && !$this->is_aui_screen()) { |
|
235 | 235 | // don't add wp-admin scripts if not requested to |
236 | - }else{ |
|
236 | + } else { |
|
237 | 237 | $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
238 | 238 | |
239 | 239 | $rtl = is_rtl() ? '-rtl' : ''; |
240 | 240 | |
241 | - if($this->settings[$css_setting]){ |
|
242 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
243 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
244 | - wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
|
245 | - wp_enqueue_style( 'ayecode-ui' ); |
|
241 | + if ($this->settings[$css_setting]) { |
|
242 | + $compatibility = $this->settings[$css_setting] == 'core' ? false : true; |
|
243 | + $url = $this->settings[$css_setting] == 'core' ? $this->url . 'assets/css/ayecode-ui' . $rtl . '.css' : $this->url . 'assets/css/ayecode-ui-compatibility' . $rtl . '.css'; |
|
244 | + wp_register_style('ayecode-ui', $url, array(), $this->latest); |
|
245 | + wp_enqueue_style('ayecode-ui'); |
|
246 | 246 | |
247 | 247 | // flatpickr |
248 | - wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
248 | + wp_register_style('flatpickr', $this->url . 'assets/css/flatpickr.min.css', array(), $this->latest); |
|
249 | 249 | |
250 | 250 | |
251 | 251 | // fix some wp-admin issues |
252 | - if(is_admin()){ |
|
252 | + if (is_admin()) { |
|
253 | 253 | $custom_css = " |
254 | 254 | body{ |
255 | 255 | background-color: #f1f1f1; |
@@ -295,11 +295,11 @@ discard block |
||
295 | 295 | padding: 0; |
296 | 296 | } |
297 | 297 | "; |
298 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
298 | + wp_add_inline_style('ayecode-ui', $custom_css); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | // custom changes |
302 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
302 | + wp_add_inline_style('ayecode-ui', self::custom_css($compatibility)); |
|
303 | 303 | |
304 | 304 | } |
305 | 305 | } |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | function aui_init_flatpickr(){ |
559 | 559 | if ( typeof jQuery.fn.flatpickr === "function" && !$aui_doing_init_flatpickr) { |
560 | 560 | $aui_doing_init_flatpickr = true; |
561 | - <?php if ( ! empty( $flatpickr_locale ) ) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
561 | + <?php if (!empty($flatpickr_locale)) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
562 | 562 | jQuery('input[data-aui-init="flatpickr"]:not(.flatpickr-input)').flatpickr(); |
563 | 563 | } |
564 | 564 | $aui_doing_init_flatpickr = false; |
@@ -858,10 +858,10 @@ discard block |
||
858 | 858 | /* |
859 | 859 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
860 | 860 | */ |
861 | - return str_replace( array( |
|
861 | + return str_replace(array( |
|
862 | 862 | '<script>', |
863 | 863 | '</script>' |
864 | - ), '', $output ); |
|
864 | + ), '', $output); |
|
865 | 865 | } |
866 | 866 | |
867 | 867 | |
@@ -875,13 +875,13 @@ discard block |
||
875 | 875 | ob_start(); |
876 | 876 | ?> |
877 | 877 | <script> |
878 | - <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
|
878 | + <?php if (defined('FUSION_BUILDER_VERSION')) { ?> |
|
879 | 879 | /* With Avada builder */ |
880 | 880 | |
881 | 881 | <?php } ?> |
882 | 882 | </script> |
883 | 883 | <?php |
884 | - return str_replace( array( |
|
884 | + return str_replace(array( |
|
885 | 885 | '<script>', |
886 | 886 | '</script>' |
887 | 887 | ), '', ob_get_clean()); |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | * |
893 | 893 | * If this remains small then its best to use this than to add another JS file. |
894 | 894 | */ |
895 | - public function inline_script_file_browser(){ |
|
895 | + public function inline_script_file_browser() { |
|
896 | 896 | ob_start(); |
897 | 897 | ?> |
898 | 898 | <script> |
@@ -907,10 +907,10 @@ discard block |
||
907 | 907 | /* |
908 | 908 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
909 | 909 | */ |
910 | - return str_replace( array( |
|
910 | + return str_replace(array( |
|
911 | 911 | '<script>', |
912 | 912 | '</script>' |
913 | - ), '', $output ); |
|
913 | + ), '', $output); |
|
914 | 914 | } |
915 | 915 | |
916 | 916 | /** |
@@ -918,50 +918,50 @@ discard block |
||
918 | 918 | */ |
919 | 919 | public function enqueue_scripts() { |
920 | 920 | |
921 | - if( is_admin() && !$this->is_aui_screen()){ |
|
921 | + if (is_admin() && !$this->is_aui_screen()) { |
|
922 | 922 | // don't add wp-admin scripts if not requested to |
923 | - }else { |
|
923 | + } else { |
|
924 | 924 | |
925 | 925 | $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
926 | 926 | |
927 | 927 | // select2 |
928 | - wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
928 | + wp_register_script('select2', $this->url . 'assets/js/select2.min.js', array('jquery'), $this->select2_version); |
|
929 | 929 | |
930 | 930 | // flatpickr |
931 | - wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
931 | + wp_register_script('flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest); |
|
932 | 932 | |
933 | 933 | // Bootstrap file browser |
934 | - wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
935 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
934 | + wp_register_script('aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version); |
|
935 | + wp_add_inline_script('aui-custom-file-input', $this->inline_script_file_browser()); |
|
936 | 936 | |
937 | 937 | $load_inline = false; |
938 | 938 | |
939 | - if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
939 | + if ($this->settings[$js_setting] == 'core-popper') { |
|
940 | 940 | // Bootstrap bundle |
941 | 941 | $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
942 | - wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
942 | + wp_register_script('bootstrap-js-bundle', $url, array( |
|
943 | 943 | 'select2', |
944 | 944 | 'jquery' |
945 | - ), $this->latest, $this->is_bs3_compat() ); |
|
945 | + ), $this->latest, $this->is_bs3_compat()); |
|
946 | 946 | // if in admin then add to footer for compatibility. |
947 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
947 | + is_admin() ? wp_enqueue_script('bootstrap-js-bundle', '', null, null, true) : wp_enqueue_script('bootstrap-js-bundle'); |
|
948 | 948 | $script = $this->inline_script(); |
949 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
950 | - } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
949 | + wp_add_inline_script('bootstrap-js-bundle', $script); |
|
950 | + } elseif ($this->settings[$js_setting] == 'popper') { |
|
951 | 951 | $url = $this->url . 'assets/js/popper.min.js'; |
952 | - wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->latest ); |
|
953 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
952 | + wp_register_script('bootstrap-js-popper', $url, array('select2', 'jquery'), $this->latest); |
|
953 | + wp_enqueue_script('bootstrap-js-popper'); |
|
954 | 954 | $load_inline = true; |
955 | 955 | } else { |
956 | 956 | $load_inline = true; |
957 | 957 | } |
958 | 958 | |
959 | 959 | // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
960 | - if ( $load_inline ) { |
|
961 | - wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
962 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
960 | + if ($load_inline) { |
|
961 | + wp_register_script('bootstrap-dummy', '', array('select2', 'jquery')); |
|
962 | + wp_enqueue_script('bootstrap-dummy'); |
|
963 | 963 | $script = $this->inline_script(); |
964 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
964 | + wp_add_inline_script('bootstrap-dummy', $script); |
|
965 | 965 | } |
966 | 966 | } |
967 | 967 | |
@@ -970,9 +970,9 @@ discard block |
||
970 | 970 | /** |
971 | 971 | * Enqueue flatpickr if called. |
972 | 972 | */ |
973 | - public function enqueue_flatpickr(){ |
|
974 | - wp_enqueue_style( 'flatpickr' ); |
|
975 | - wp_enqueue_script( 'flatpickr' ); |
|
973 | + public function enqueue_flatpickr() { |
|
974 | + wp_enqueue_style('flatpickr'); |
|
975 | + wp_enqueue_script('flatpickr'); |
|
976 | 976 | } |
977 | 977 | |
978 | 978 | /** |
@@ -984,15 +984,15 @@ discard block |
||
984 | 984 | |
985 | 985 | $url = ''; |
986 | 986 | // check if we are inside a plugin |
987 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
987 | + $file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__))); |
|
988 | 988 | |
989 | 989 | // add check in-case user has changed wp-content dir name. |
990 | 990 | $wp_content_folder_name = basename(WP_CONTENT_DIR); |
991 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
992 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
991 | + $dir_parts = explode("/$wp_content_folder_name/", $file_dir); |
|
992 | + $url_parts = explode("/$wp_content_folder_name/", plugins_url()); |
|
993 | 993 | |
994 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
995 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
994 | + if (!empty($url_parts[0]) && !empty($dir_parts[1])) { |
|
995 | + $url = trailingslashit($url_parts[0] . "/$wp_content_folder_name/" . $dir_parts[1]); |
|
996 | 996 | } |
997 | 997 | |
998 | 998 | return $url; |
@@ -1002,7 +1002,7 @@ discard block |
||
1002 | 1002 | * Register the database settings with WordPress. |
1003 | 1003 | */ |
1004 | 1004 | public function register_settings() { |
1005 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
1005 | + register_setting('ayecode-ui-settings', 'ayecode-ui-settings'); |
|
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | /** |
@@ -1011,10 +1011,10 @@ discard block |
||
1011 | 1011 | */ |
1012 | 1012 | public function menu_item() { |
1013 | 1013 | $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
1014 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
1014 | + call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
1015 | 1015 | $this, |
1016 | 1016 | 'settings_page' |
1017 | - ) ); |
|
1017 | + )); |
|
1018 | 1018 | } |
1019 | 1019 | |
1020 | 1020 | /** |
@@ -1022,7 +1022,7 @@ discard block |
||
1022 | 1022 | * |
1023 | 1023 | * @return array |
1024 | 1024 | */ |
1025 | - public function theme_js_settings(){ |
|
1025 | + public function theme_js_settings() { |
|
1026 | 1026 | return array( |
1027 | 1027 | 'ayetheme' => 'popper', |
1028 | 1028 | 'listimia' => 'required', |
@@ -1038,17 +1038,17 @@ discard block |
||
1038 | 1038 | */ |
1039 | 1039 | public function get_settings() { |
1040 | 1040 | |
1041 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
1041 | + $db_settings = get_option('ayecode-ui-settings'); |
|
1042 | 1042 | $js_default = 'core-popper'; |
1043 | 1043 | $js_default_backend = $js_default; |
1044 | 1044 | |
1045 | 1045 | // maybe set defaults (if no settings set) |
1046 | - if(empty($db_settings)){ |
|
1047 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
1046 | + if (empty($db_settings)) { |
|
1047 | + $active_theme = strtolower(get_template()); // active parent theme. |
|
1048 | 1048 | $theme_js_settings = self::theme_js_settings(); |
1049 | - if(isset($theme_js_settings[$active_theme])){ |
|
1049 | + if (isset($theme_js_settings[$active_theme])) { |
|
1050 | 1050 | $js_default = $theme_js_settings[$active_theme]; |
1051 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
1051 | + $js_default_backend = isset($theme_js_settings[$active_theme . "_backend"]) ? $theme_js_settings[$active_theme . "_backend"] : $js_default; |
|
1052 | 1052 | } |
1053 | 1053 | } |
1054 | 1054 | |
@@ -1061,14 +1061,14 @@ discard block |
||
1061 | 1061 | 'disable_admin' => '', // URL snippets to disable loading on admin |
1062 | 1062 | ); |
1063 | 1063 | |
1064 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
1064 | + $settings = wp_parse_args($db_settings, $defaults); |
|
1065 | 1065 | |
1066 | 1066 | /** |
1067 | 1067 | * Filter the Bootstrap settings. |
1068 | 1068 | * |
1069 | 1069 | * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
1070 | 1070 | */ |
1071 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
1071 | + return $this->settings = apply_filters('ayecode-ui-settings', $settings, $db_settings, $defaults); |
|
1072 | 1072 | } |
1073 | 1073 | |
1074 | 1074 | |
@@ -1076,90 +1076,90 @@ discard block |
||
1076 | 1076 | * The settings page html output. |
1077 | 1077 | */ |
1078 | 1078 | public function settings_page() { |
1079 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
1080 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
1079 | + if (!current_user_can('manage_options')) { |
|
1080 | + wp_die(__('You do not have sufficient permissions to access this page.', 'aui')); |
|
1081 | 1081 | } |
1082 | 1082 | ?> |
1083 | 1083 | <div class="wrap"> |
1084 | 1084 | <h1><?php echo $this->name; ?></h1> |
1085 | - <p><?php _e("Here you can adjust settings if you are having compatibility issues.",'aui');?></p> |
|
1085 | + <p><?php _e("Here you can adjust settings if you are having compatibility issues.", 'aui'); ?></p> |
|
1086 | 1086 | <form method="post" action="options.php"> |
1087 | 1087 | <?php |
1088 | - settings_fields( 'ayecode-ui-settings' ); |
|
1089 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
1088 | + settings_fields('ayecode-ui-settings'); |
|
1089 | + do_settings_sections('ayecode-ui-settings'); |
|
1090 | 1090 | ?> |
1091 | 1091 | |
1092 | - <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
|
1092 | + <h2><?php _e('Frontend', 'aui'); ?></h2> |
|
1093 | 1093 | <table class="form-table wpbs-table-settings"> |
1094 | 1094 | <tr valign="top"> |
1095 | 1095 | <th scope="row"><label |
1096 | - for="wpbs-css"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
1096 | + for="wpbs-css"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
1097 | 1097 | <td> |
1098 | 1098 | <select name="ayecode-ui-settings[css]" id="wpbs-css"> |
1099 | - <option value="compatibility" <?php selected( $this->settings['css'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option> |
|
1100 | - <option value="core" <?php selected( $this->settings['css'], 'core' ); ?>><?php _e( 'Full Mode', 'aui' ); ?></option> |
|
1101 | - <option value="" <?php selected( $this->settings['css'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
1099 | + <option value="compatibility" <?php selected($this->settings['css'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option> |
|
1100 | + <option value="core" <?php selected($this->settings['css'], 'core'); ?>><?php _e('Full Mode', 'aui'); ?></option> |
|
1101 | + <option value="" <?php selected($this->settings['css'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
1102 | 1102 | </select> |
1103 | 1103 | </td> |
1104 | 1104 | </tr> |
1105 | 1105 | |
1106 | 1106 | <tr valign="top"> |
1107 | 1107 | <th scope="row"><label |
1108 | - for="wpbs-js"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
1108 | + for="wpbs-js"><?php _e('Load JS', 'aui'); ?></label></th> |
|
1109 | 1109 | <td> |
1110 | 1110 | <select name="ayecode-ui-settings[js]" id="wpbs-js"> |
1111 | - <option value="core-popper" <?php selected( $this->settings['js'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
1112 | - <option value="popper" <?php selected( $this->settings['js'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
1113 | - <option value="required" <?php selected( $this->settings['js'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
1114 | - <option value="" <?php selected( $this->settings['js'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
1111 | + <option value="core-popper" <?php selected($this->settings['js'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
1112 | + <option value="popper" <?php selected($this->settings['js'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
1113 | + <option value="required" <?php selected($this->settings['js'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
1114 | + <option value="" <?php selected($this->settings['js'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
1115 | 1115 | </select> |
1116 | 1116 | </td> |
1117 | 1117 | </tr> |
1118 | 1118 | |
1119 | 1119 | <tr valign="top"> |
1120 | 1120 | <th scope="row"><label |
1121 | - for="wpbs-font_size"><?php _e( 'HTML Font Size (px)', 'aui' ); ?></label></th> |
|
1121 | + for="wpbs-font_size"><?php _e('HTML Font Size (px)', 'aui'); ?></label></th> |
|
1122 | 1122 | <td> |
1123 | - <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint( $this->settings['html_font_size']); ?>" placeholder="16" /> |
|
1124 | - <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.",'aui');?></p> |
|
1123 | + <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint($this->settings['html_font_size']); ?>" placeholder="16" /> |
|
1124 | + <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.", 'aui'); ?></p> |
|
1125 | 1125 | </td> |
1126 | 1126 | </tr> |
1127 | 1127 | |
1128 | 1128 | </table> |
1129 | 1129 | |
1130 | - <h2><?php _e( 'Backend', 'aui' ); ?> (wp-admin)</h2> |
|
1130 | + <h2><?php _e('Backend', 'aui'); ?> (wp-admin)</h2> |
|
1131 | 1131 | <table class="form-table wpbs-table-settings"> |
1132 | 1132 | <tr valign="top"> |
1133 | 1133 | <th scope="row"><label |
1134 | - for="wpbs-css-admin"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
1134 | + for="wpbs-css-admin"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
1135 | 1135 | <td> |
1136 | 1136 | <select name="ayecode-ui-settings[css_backend]" id="wpbs-css-admin"> |
1137 | - <option value="compatibility" <?php selected( $this->settings['css_backend'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option> |
|
1138 | - <option value="core" <?php selected( $this->settings['css_backend'], 'core' ); ?>><?php _e( 'Full Mode (will cause style issues)', 'aui' ); ?></option> |
|
1139 | - <option value="" <?php selected( $this->settings['css_backend'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
1137 | + <option value="compatibility" <?php selected($this->settings['css_backend'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option> |
|
1138 | + <option value="core" <?php selected($this->settings['css_backend'], 'core'); ?>><?php _e('Full Mode (will cause style issues)', 'aui'); ?></option> |
|
1139 | + <option value="" <?php selected($this->settings['css_backend'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
1140 | 1140 | </select> |
1141 | 1141 | </td> |
1142 | 1142 | </tr> |
1143 | 1143 | |
1144 | 1144 | <tr valign="top"> |
1145 | 1145 | <th scope="row"><label |
1146 | - for="wpbs-js-admin"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
1146 | + for="wpbs-js-admin"><?php _e('Load JS', 'aui'); ?></label></th> |
|
1147 | 1147 | <td> |
1148 | 1148 | <select name="ayecode-ui-settings[js_backend]" id="wpbs-js-admin"> |
1149 | - <option value="core-popper" <?php selected( $this->settings['js_backend'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
1150 | - <option value="popper" <?php selected( $this->settings['js_backend'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
1151 | - <option value="required" <?php selected( $this->settings['js_backend'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
1152 | - <option value="" <?php selected( $this->settings['js_backend'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
1149 | + <option value="core-popper" <?php selected($this->settings['js_backend'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
1150 | + <option value="popper" <?php selected($this->settings['js_backend'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
1151 | + <option value="required" <?php selected($this->settings['js_backend'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
1152 | + <option value="" <?php selected($this->settings['js_backend'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
1153 | 1153 | </select> |
1154 | 1154 | </td> |
1155 | 1155 | </tr> |
1156 | 1156 | |
1157 | 1157 | <tr valign="top"> |
1158 | 1158 | <th scope="row"><label |
1159 | - for="wpbs-disable-admin"><?php _e( 'Disable load on URL', 'aui' ); ?></label></th> |
|
1159 | + for="wpbs-disable-admin"><?php _e('Disable load on URL', 'aui'); ?></label></th> |
|
1160 | 1160 | <td> |
1161 | - <p><?php _e( 'If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui' ); ?></p> |
|
1162 | - <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php action=go"><?php echo $this->settings['disable_admin'];?></textarea> |
|
1161 | + <p><?php _e('If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui'); ?></p> |
|
1162 | + <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php action=go"><?php echo $this->settings['disable_admin']; ?></textarea> |
|
1163 | 1163 | |
1164 | 1164 | </td> |
1165 | 1165 | </tr> |
@@ -1177,9 +1177,9 @@ discard block |
||
1177 | 1177 | <?php |
1178 | 1178 | } |
1179 | 1179 | |
1180 | - public function customizer_settings($wp_customize){ |
|
1180 | + public function customizer_settings($wp_customize) { |
|
1181 | 1181 | $wp_customize->add_section('aui_settings', array( |
1182 | - 'title' => __('AyeCode UI','aui'), |
|
1182 | + 'title' => __('AyeCode UI', 'aui'), |
|
1183 | 1183 | 'priority' => 120, |
1184 | 1184 | )); |
1185 | 1185 | |
@@ -1193,8 +1193,8 @@ discard block |
||
1193 | 1193 | 'type' => 'option', |
1194 | 1194 | 'transport' => 'refresh', |
1195 | 1195 | )); |
1196 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1197 | - 'label' => __('Primary Color','aui'), |
|
1196 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1197 | + 'label' => __('Primary Color', 'aui'), |
|
1198 | 1198 | 'section' => 'aui_settings', |
1199 | 1199 | 'settings' => 'aui_options[color_primary]', |
1200 | 1200 | ))); |
@@ -1206,8 +1206,8 @@ discard block |
||
1206 | 1206 | 'type' => 'option', |
1207 | 1207 | 'transport' => 'refresh', |
1208 | 1208 | )); |
1209 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1210 | - 'label' => __('Secondary Color','aui'), |
|
1209 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1210 | + 'label' => __('Secondary Color', 'aui'), |
|
1211 | 1211 | 'section' => 'aui_settings', |
1212 | 1212 | 'settings' => 'aui_options[color_secondary]', |
1213 | 1213 | ))); |
@@ -1233,12 +1233,12 @@ discard block |
||
1233 | 1233 | .collapse.show:not(.in){display: inherit;} |
1234 | 1234 | .fade.show{opacity: 1;} |
1235 | 1235 | |
1236 | - <?php if( defined( 'SVQ_THEME_VERSION' ) ){ ?> |
|
1236 | + <?php if (defined('SVQ_THEME_VERSION')) { ?> |
|
1237 | 1237 | /* KLEO theme specific */ |
1238 | 1238 | .kleo-main-header .navbar-collapse.collapse.show:not(.in){display: inherit !important;} |
1239 | 1239 | <?php } ?> |
1240 | 1240 | |
1241 | - <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
|
1241 | + <?php if (defined('FUSION_BUILDER_VERSION')) { ?> |
|
1242 | 1242 | /* With Avada builder */ |
1243 | 1243 | body.modal-open .modal.in {opacity:1;z-index: 99999} |
1244 | 1244 | body.modal-open .modal.bsui.in .modal-content {box-shadow: none;} |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | <?php } ?> |
1247 | 1247 | </style> |
1248 | 1248 | <?php |
1249 | - return str_replace( array( |
|
1249 | + return str_replace(array( |
|
1250 | 1250 | '<style>', |
1251 | 1251 | '</style>' |
1252 | 1252 | ), '', ob_get_clean()); |
@@ -1266,16 +1266,16 @@ discard block |
||
1266 | 1266 | <?php |
1267 | 1267 | |
1268 | 1268 | // BS v3 compat |
1269 | - if( self::is_bs3_compat() ){ |
|
1269 | + if (self::is_bs3_compat()) { |
|
1270 | 1270 | echo self::bs3_compat_css(); |
1271 | 1271 | } |
1272 | 1272 | |
1273 | - if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
1274 | - echo self::css_primary($primary_color,$compatibility); |
|
1273 | + if (!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL) { |
|
1274 | + echo self::css_primary($primary_color, $compatibility); |
|
1275 | 1275 | } |
1276 | 1276 | |
1277 | - if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
1278 | - echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
1277 | + if (!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL) { |
|
1278 | + echo self::css_secondary($settings['color_secondary'], $compatibility); |
|
1279 | 1279 | } |
1280 | 1280 | |
1281 | 1281 | // Set admin bar z-index lower when modal is open. |
@@ -1288,7 +1288,7 @@ discard block |
||
1288 | 1288 | /* |
1289 | 1289 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1290 | 1290 | */ |
1291 | - return str_replace( array( |
|
1291 | + return str_replace(array( |
|
1292 | 1292 | '<style>', |
1293 | 1293 | '</style>' |
1294 | 1294 | ), '', ob_get_clean()); |
@@ -1299,48 +1299,48 @@ discard block |
||
1299 | 1299 | * |
1300 | 1300 | * @return bool |
1301 | 1301 | */ |
1302 | - public static function is_bs3_compat(){ |
|
1302 | + public static function is_bs3_compat() { |
|
1303 | 1303 | return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
1304 | 1304 | } |
1305 | 1305 | |
1306 | - public static function css_primary($color_code,$compatibility){; |
|
1306 | + public static function css_primary($color_code, $compatibility) {; |
|
1307 | 1307 | $color_code = sanitize_hex_color($color_code); |
1308 | - if(!$color_code){return '';} |
|
1308 | + if (!$color_code) {return ''; } |
|
1309 | 1309 | /** |
1310 | 1310 | * c = color, b = background color, o = border-color, f = fill |
1311 | 1311 | */ |
1312 | 1312 | $selectors = array( |
1313 | 1313 | 'a' => array('c'), |
1314 | - '.btn-primary' => array('b','o'), |
|
1315 | - '.btn-primary.disabled' => array('b','o'), |
|
1316 | - '.btn-primary:disabled' => array('b','o'), |
|
1317 | - '.btn-outline-primary' => array('c','o'), |
|
1318 | - '.btn-outline-primary:hover' => array('b','o'), |
|
1319 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1320 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1321 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
1314 | + '.btn-primary' => array('b', 'o'), |
|
1315 | + '.btn-primary.disabled' => array('b', 'o'), |
|
1316 | + '.btn-primary:disabled' => array('b', 'o'), |
|
1317 | + '.btn-outline-primary' => array('c', 'o'), |
|
1318 | + '.btn-outline-primary:hover' => array('b', 'o'), |
|
1319 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
1320 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
1321 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b', 'o'), |
|
1322 | 1322 | '.btn-link' => array('c'), |
1323 | 1323 | '.dropdown-item.active' => array('b'), |
1324 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
1325 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
1324 | + '.custom-control-input:checked~.custom-control-label::before' => array('b', 'o'), |
|
1325 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b', 'o'), |
|
1326 | 1326 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
1327 | 1327 | // '.custom-range::-moz-range-thumb' => array('b'), |
1328 | 1328 | // '.custom-range::-ms-thumb' => array('b'), |
1329 | 1329 | '.nav-pills .nav-link.active' => array('b'), |
1330 | 1330 | '.nav-pills .show>.nav-link' => array('b'), |
1331 | 1331 | '.page-link' => array('c'), |
1332 | - '.page-item.active .page-link' => array('b','o'), |
|
1332 | + '.page-item.active .page-link' => array('b', 'o'), |
|
1333 | 1333 | '.badge-primary' => array('b'), |
1334 | - '.alert-primary' => array('b','o'), |
|
1334 | + '.alert-primary' => array('b', 'o'), |
|
1335 | 1335 | '.progress-bar' => array('b'), |
1336 | - '.list-group-item.active' => array('b','o'), |
|
1337 | - '.bg-primary' => array('b','f'), |
|
1336 | + '.list-group-item.active' => array('b', 'o'), |
|
1337 | + '.bg-primary' => array('b', 'f'), |
|
1338 | 1338 | '.btn-link.btn-primary' => array('c'), |
1339 | 1339 | '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
1340 | 1340 | ); |
1341 | 1341 | |
1342 | 1342 | $important_selectors = array( |
1343 | - '.bg-primary' => array('b','f'), |
|
1343 | + '.bg-primary' => array('b', 'f'), |
|
1344 | 1344 | '.border-primary' => array('o'), |
1345 | 1345 | '.text-primary' => array('c'), |
1346 | 1346 | ); |
@@ -1357,116 +1357,116 @@ discard block |
||
1357 | 1357 | $output = ''; |
1358 | 1358 | |
1359 | 1359 | // build rules into each type |
1360 | - foreach($selectors as $selector => $types){ |
|
1361 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1362 | - $types = array_combine($types,$types); |
|
1363 | - if(isset($types['c'])){$color[] = $selector;} |
|
1364 | - if(isset($types['b'])){$background[] = $selector;} |
|
1365 | - if(isset($types['o'])){$border[] = $selector;} |
|
1366 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1360 | + foreach ($selectors as $selector => $types) { |
|
1361 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1362 | + $types = array_combine($types, $types); |
|
1363 | + if (isset($types['c'])) {$color[] = $selector; } |
|
1364 | + if (isset($types['b'])) {$background[] = $selector; } |
|
1365 | + if (isset($types['o'])) {$border[] = $selector; } |
|
1366 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
1367 | 1367 | } |
1368 | 1368 | |
1369 | 1369 | // build rules into each type |
1370 | - foreach($important_selectors as $selector => $types){ |
|
1371 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1372 | - $types = array_combine($types,$types); |
|
1373 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1374 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1375 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1376 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1370 | + foreach ($important_selectors as $selector => $types) { |
|
1371 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1372 | + $types = array_combine($types, $types); |
|
1373 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
1374 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
1375 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
1376 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
1377 | 1377 | } |
1378 | 1378 | |
1379 | 1379 | // add any color rules |
1380 | - if(!empty($color)){ |
|
1381 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1380 | + if (!empty($color)) { |
|
1381 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
1382 | 1382 | } |
1383 | - if(!empty($color_i)){ |
|
1384 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1383 | + if (!empty($color_i)) { |
|
1384 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
1385 | 1385 | } |
1386 | 1386 | |
1387 | 1387 | // add any background color rules |
1388 | - if(!empty($background)){ |
|
1389 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1388 | + if (!empty($background)) { |
|
1389 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
1390 | 1390 | } |
1391 | - if(!empty($background_i)){ |
|
1392 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1391 | + if (!empty($background_i)) { |
|
1392 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
1393 | 1393 | } |
1394 | 1394 | |
1395 | 1395 | // add any border color rules |
1396 | - if(!empty($border)){ |
|
1397 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1396 | + if (!empty($border)) { |
|
1397 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
1398 | 1398 | } |
1399 | - if(!empty($border_i)){ |
|
1400 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1399 | + if (!empty($border_i)) { |
|
1400 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
1401 | 1401 | } |
1402 | 1402 | |
1403 | 1403 | // add any fill color rules |
1404 | - if(!empty($fill)){ |
|
1405 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1404 | + if (!empty($fill)) { |
|
1405 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
1406 | 1406 | } |
1407 | - if(!empty($fill_i)){ |
|
1408 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1407 | + if (!empty($fill_i)) { |
|
1408 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
1409 | 1409 | } |
1410 | 1410 | |
1411 | 1411 | |
1412 | 1412 | $prefix = $compatibility ? ".bsui " : ""; |
1413 | 1413 | |
1414 | 1414 | // darken |
1415 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1416 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1417 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1415 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
1416 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
1417 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
1418 | 1418 | |
1419 | 1419 | // lighten |
1420 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1420 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
1421 | 1421 | |
1422 | 1422 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
1423 | - $op_25 = $color_code."40"; // 25% opacity |
|
1423 | + $op_25 = $color_code . "40"; // 25% opacity |
|
1424 | 1424 | |
1425 | 1425 | |
1426 | 1426 | // button states |
1427 | - $output .= $prefix ." .btn-primary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1428 | - $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1429 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
1430 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1427 | + $output .= $prefix . " .btn-primary:hover{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
1428 | + $output .= $prefix . " .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1429 | + $output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: " . $darker_10 . "; border-color: " . $darker_125 . ";} "; |
|
1430 | + $output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1431 | 1431 | |
1432 | 1432 | |
1433 | 1433 | // dropdown's |
1434 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1434 | + $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1435 | 1435 | |
1436 | 1436 | |
1437 | 1437 | // input states |
1438 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1438 | + $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1439 | 1439 | |
1440 | 1440 | // page link |
1441 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1441 | + $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1442 | 1442 | |
1443 | 1443 | return $output; |
1444 | 1444 | } |
1445 | 1445 | |
1446 | - public static function css_secondary($color_code,$compatibility){; |
|
1446 | + public static function css_secondary($color_code, $compatibility) {; |
|
1447 | 1447 | $color_code = sanitize_hex_color($color_code); |
1448 | - if(!$color_code){return '';} |
|
1448 | + if (!$color_code) {return ''; } |
|
1449 | 1449 | /** |
1450 | 1450 | * c = color, b = background color, o = border-color, f = fill |
1451 | 1451 | */ |
1452 | 1452 | $selectors = array( |
1453 | - '.btn-secondary' => array('b','o'), |
|
1454 | - '.btn-secondary.disabled' => array('b','o'), |
|
1455 | - '.btn-secondary:disabled' => array('b','o'), |
|
1456 | - '.btn-outline-secondary' => array('c','o'), |
|
1457 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
1453 | + '.btn-secondary' => array('b', 'o'), |
|
1454 | + '.btn-secondary.disabled' => array('b', 'o'), |
|
1455 | + '.btn-secondary:disabled' => array('b', 'o'), |
|
1456 | + '.btn-outline-secondary' => array('c', 'o'), |
|
1457 | + '.btn-outline-secondary:hover' => array('b', 'o'), |
|
1458 | 1458 | '.btn-outline-secondary.disabled' => array('c'), |
1459 | 1459 | '.btn-outline-secondary:disabled' => array('c'), |
1460 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1461 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1462 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
1460 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
1461 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
1462 | + '.btn-outline-secondary.dropdown-toggle' => array('b', 'o'), |
|
1463 | 1463 | '.badge-secondary' => array('b'), |
1464 | - '.alert-secondary' => array('b','o'), |
|
1464 | + '.alert-secondary' => array('b', 'o'), |
|
1465 | 1465 | '.btn-link.btn-secondary' => array('c'), |
1466 | 1466 | ); |
1467 | 1467 | |
1468 | 1468 | $important_selectors = array( |
1469 | - '.bg-secondary' => array('b','f'), |
|
1469 | + '.bg-secondary' => array('b', 'f'), |
|
1470 | 1470 | '.border-secondary' => array('o'), |
1471 | 1471 | '.text-secondary' => array('c'), |
1472 | 1472 | ); |
@@ -1483,77 +1483,77 @@ discard block |
||
1483 | 1483 | $output = ''; |
1484 | 1484 | |
1485 | 1485 | // build rules into each type |
1486 | - foreach($selectors as $selector => $types){ |
|
1487 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1488 | - $types = array_combine($types,$types); |
|
1489 | - if(isset($types['c'])){$color[] = $selector;} |
|
1490 | - if(isset($types['b'])){$background[] = $selector;} |
|
1491 | - if(isset($types['o'])){$border[] = $selector;} |
|
1492 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1486 | + foreach ($selectors as $selector => $types) { |
|
1487 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1488 | + $types = array_combine($types, $types); |
|
1489 | + if (isset($types['c'])) {$color[] = $selector; } |
|
1490 | + if (isset($types['b'])) {$background[] = $selector; } |
|
1491 | + if (isset($types['o'])) {$border[] = $selector; } |
|
1492 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
1493 | 1493 | } |
1494 | 1494 | |
1495 | 1495 | // build rules into each type |
1496 | - foreach($important_selectors as $selector => $types){ |
|
1497 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1498 | - $types = array_combine($types,$types); |
|
1499 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1500 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1501 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1502 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1496 | + foreach ($important_selectors as $selector => $types) { |
|
1497 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1498 | + $types = array_combine($types, $types); |
|
1499 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
1500 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
1501 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
1502 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
1503 | 1503 | } |
1504 | 1504 | |
1505 | 1505 | // add any color rules |
1506 | - if(!empty($color)){ |
|
1507 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1506 | + if (!empty($color)) { |
|
1507 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
1508 | 1508 | } |
1509 | - if(!empty($color_i)){ |
|
1510 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1509 | + if (!empty($color_i)) { |
|
1510 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
1511 | 1511 | } |
1512 | 1512 | |
1513 | 1513 | // add any background color rules |
1514 | - if(!empty($background)){ |
|
1515 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1514 | + if (!empty($background)) { |
|
1515 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
1516 | 1516 | } |
1517 | - if(!empty($background_i)){ |
|
1518 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1517 | + if (!empty($background_i)) { |
|
1518 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
1519 | 1519 | } |
1520 | 1520 | |
1521 | 1521 | // add any border color rules |
1522 | - if(!empty($border)){ |
|
1523 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1522 | + if (!empty($border)) { |
|
1523 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
1524 | 1524 | } |
1525 | - if(!empty($border_i)){ |
|
1526 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1525 | + if (!empty($border_i)) { |
|
1526 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
1527 | 1527 | } |
1528 | 1528 | |
1529 | 1529 | // add any fill color rules |
1530 | - if(!empty($fill)){ |
|
1531 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1530 | + if (!empty($fill)) { |
|
1531 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
1532 | 1532 | } |
1533 | - if(!empty($fill_i)){ |
|
1534 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1533 | + if (!empty($fill_i)) { |
|
1534 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
1535 | 1535 | } |
1536 | 1536 | |
1537 | 1537 | |
1538 | 1538 | $prefix = $compatibility ? ".bsui " : ""; |
1539 | 1539 | |
1540 | 1540 | // darken |
1541 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1542 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1543 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1541 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
1542 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
1543 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
1544 | 1544 | |
1545 | 1545 | // lighten |
1546 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1546 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
1547 | 1547 | |
1548 | 1548 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
1549 | - $op_25 = $color_code."40"; // 25% opacity |
|
1549 | + $op_25 = $color_code . "40"; // 25% opacity |
|
1550 | 1550 | |
1551 | 1551 | |
1552 | 1552 | // button states |
1553 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1554 | - $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1555 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
1556 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1553 | + $output .= $prefix . " .btn-secondary:hover{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
1554 | + $output .= $prefix . " .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1555 | + $output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: " . $darker_10 . "; border-color: " . $darker_125 . ";} "; |
|
1556 | + $output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1557 | 1557 | |
1558 | 1558 | |
1559 | 1559 | return $output; |
@@ -1589,8 +1589,8 @@ discard block |
||
1589 | 1589 | /** |
1590 | 1590 | * Check if we should display examples. |
1591 | 1591 | */ |
1592 | - public function maybe_show_examples(){ |
|
1593 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
1592 | + public function maybe_show_examples() { |
|
1593 | + if (current_user_can('manage_options') && isset($_REQUEST['preview-aui'])) { |
|
1594 | 1594 | echo "<head>"; |
1595 | 1595 | wp_head(); |
1596 | 1596 | echo "</head>"; |
@@ -1606,7 +1606,7 @@ discard block |
||
1606 | 1606 | * |
1607 | 1607 | * @return string |
1608 | 1608 | */ |
1609 | - public function get_examples(){ |
|
1609 | + public function get_examples() { |
|
1610 | 1610 | $output = ''; |
1611 | 1611 | |
1612 | 1612 | |
@@ -1712,74 +1712,74 @@ discard block |
||
1712 | 1712 | */ |
1713 | 1713 | public static function calendar_params() { |
1714 | 1714 | $params = array( |
1715 | - 'month_long_1' => __( 'January', 'aui' ), |
|
1716 | - 'month_long_2' => __( 'February', 'aui' ), |
|
1717 | - 'month_long_3' => __( 'March', 'aui' ), |
|
1718 | - 'month_long_4' => __( 'April', 'aui' ), |
|
1719 | - 'month_long_5' => __( 'May', 'aui' ), |
|
1720 | - 'month_long_6' => __( 'June', 'aui' ), |
|
1721 | - 'month_long_7' => __( 'July', 'aui' ), |
|
1722 | - 'month_long_8' => __( 'August', 'aui' ), |
|
1723 | - 'month_long_9' => __( 'September', 'aui' ), |
|
1724 | - 'month_long_10' => __( 'October', 'aui' ), |
|
1725 | - 'month_long_11' => __( 'November', 'aui' ), |
|
1726 | - 'month_long_12' => __( 'December', 'aui' ), |
|
1727 | - 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
|
1728 | - 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
|
1729 | - 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
|
1730 | - 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
|
1731 | - 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
|
1732 | - 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
|
1733 | - 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
|
1734 | - 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
|
1735 | - 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
|
1736 | - 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
|
1737 | - 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
|
1738 | - 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
|
1739 | - 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
|
1740 | - 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
|
1741 | - 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
|
1742 | - 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
|
1743 | - 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
|
1744 | - 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
|
1745 | - 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
|
1746 | - 'day_s2_1' => __( 'Su', 'aui' ), |
|
1747 | - 'day_s2_2' => __( 'Mo', 'aui' ), |
|
1748 | - 'day_s2_3' => __( 'Tu', 'aui' ), |
|
1749 | - 'day_s2_4' => __( 'We', 'aui' ), |
|
1750 | - 'day_s2_5' => __( 'Th', 'aui' ), |
|
1751 | - 'day_s2_6' => __( 'Fr', 'aui' ), |
|
1752 | - 'day_s2_7' => __( 'Sa', 'aui' ), |
|
1753 | - 'day_s3_1' => __( 'Sun', 'aui' ), |
|
1754 | - 'day_s3_2' => __( 'Mon', 'aui' ), |
|
1755 | - 'day_s3_3' => __( 'Tue', 'aui' ), |
|
1756 | - 'day_s3_4' => __( 'Wed', 'aui' ), |
|
1757 | - 'day_s3_5' => __( 'Thu', 'aui' ), |
|
1758 | - 'day_s3_6' => __( 'Fri', 'aui' ), |
|
1759 | - 'day_s3_7' => __( 'Sat', 'aui' ), |
|
1760 | - 'day_s5_1' => __( 'Sunday', 'aui' ), |
|
1761 | - 'day_s5_2' => __( 'Monday', 'aui' ), |
|
1762 | - 'day_s5_3' => __( 'Tuesday', 'aui' ), |
|
1763 | - 'day_s5_4' => __( 'Wednesday', 'aui' ), |
|
1764 | - 'day_s5_5' => __( 'Thursday', 'aui' ), |
|
1765 | - 'day_s5_6' => __( 'Friday', 'aui' ), |
|
1766 | - 'day_s5_7' => __( 'Saturday', 'aui' ), |
|
1767 | - 'am_lower' => __( 'am', 'aui' ), |
|
1768 | - 'pm_lower' => __( 'pm', 'aui' ), |
|
1769 | - 'am_upper' => __( 'AM', 'aui' ), |
|
1770 | - 'pm_upper' => __( 'PM', 'aui' ), |
|
1771 | - 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
1715 | + 'month_long_1' => __('January', 'aui'), |
|
1716 | + 'month_long_2' => __('February', 'aui'), |
|
1717 | + 'month_long_3' => __('March', 'aui'), |
|
1718 | + 'month_long_4' => __('April', 'aui'), |
|
1719 | + 'month_long_5' => __('May', 'aui'), |
|
1720 | + 'month_long_6' => __('June', 'aui'), |
|
1721 | + 'month_long_7' => __('July', 'aui'), |
|
1722 | + 'month_long_8' => __('August', 'aui'), |
|
1723 | + 'month_long_9' => __('September', 'aui'), |
|
1724 | + 'month_long_10' => __('October', 'aui'), |
|
1725 | + 'month_long_11' => __('November', 'aui'), |
|
1726 | + 'month_long_12' => __('December', 'aui'), |
|
1727 | + 'month_s_1' => _x('Jan', 'January abbreviation', 'aui'), |
|
1728 | + 'month_s_2' => _x('Feb', 'February abbreviation', 'aui'), |
|
1729 | + 'month_s_3' => _x('Mar', 'March abbreviation', 'aui'), |
|
1730 | + 'month_s_4' => _x('Apr', 'April abbreviation', 'aui'), |
|
1731 | + 'month_s_5' => _x('May', 'May abbreviation', 'aui'), |
|
1732 | + 'month_s_6' => _x('Jun', 'June abbreviation', 'aui'), |
|
1733 | + 'month_s_7' => _x('Jul', 'July abbreviation', 'aui'), |
|
1734 | + 'month_s_8' => _x('Aug', 'August abbreviation', 'aui'), |
|
1735 | + 'month_s_9' => _x('Sep', 'September abbreviation', 'aui'), |
|
1736 | + 'month_s_10' => _x('Oct', 'October abbreviation', 'aui'), |
|
1737 | + 'month_s_11' => _x('Nov', 'November abbreviation', 'aui'), |
|
1738 | + 'month_s_12' => _x('Dec', 'December abbreviation', 'aui'), |
|
1739 | + 'day_s1_1' => _x('S', 'Sunday initial', 'aui'), |
|
1740 | + 'day_s1_2' => _x('M', 'Monday initial', 'aui'), |
|
1741 | + 'day_s1_3' => _x('T', 'Tuesday initial', 'aui'), |
|
1742 | + 'day_s1_4' => _x('W', 'Wednesday initial', 'aui'), |
|
1743 | + 'day_s1_5' => _x('T', 'Friday initial', 'aui'), |
|
1744 | + 'day_s1_6' => _x('F', 'Thursday initial', 'aui'), |
|
1745 | + 'day_s1_7' => _x('S', 'Saturday initial', 'aui'), |
|
1746 | + 'day_s2_1' => __('Su', 'aui'), |
|
1747 | + 'day_s2_2' => __('Mo', 'aui'), |
|
1748 | + 'day_s2_3' => __('Tu', 'aui'), |
|
1749 | + 'day_s2_4' => __('We', 'aui'), |
|
1750 | + 'day_s2_5' => __('Th', 'aui'), |
|
1751 | + 'day_s2_6' => __('Fr', 'aui'), |
|
1752 | + 'day_s2_7' => __('Sa', 'aui'), |
|
1753 | + 'day_s3_1' => __('Sun', 'aui'), |
|
1754 | + 'day_s3_2' => __('Mon', 'aui'), |
|
1755 | + 'day_s3_3' => __('Tue', 'aui'), |
|
1756 | + 'day_s3_4' => __('Wed', 'aui'), |
|
1757 | + 'day_s3_5' => __('Thu', 'aui'), |
|
1758 | + 'day_s3_6' => __('Fri', 'aui'), |
|
1759 | + 'day_s3_7' => __('Sat', 'aui'), |
|
1760 | + 'day_s5_1' => __('Sunday', 'aui'), |
|
1761 | + 'day_s5_2' => __('Monday', 'aui'), |
|
1762 | + 'day_s5_3' => __('Tuesday', 'aui'), |
|
1763 | + 'day_s5_4' => __('Wednesday', 'aui'), |
|
1764 | + 'day_s5_5' => __('Thursday', 'aui'), |
|
1765 | + 'day_s5_6' => __('Friday', 'aui'), |
|
1766 | + 'day_s5_7' => __('Saturday', 'aui'), |
|
1767 | + 'am_lower' => __('am', 'aui'), |
|
1768 | + 'pm_lower' => __('pm', 'aui'), |
|
1769 | + 'am_upper' => __('AM', 'aui'), |
|
1770 | + 'pm_upper' => __('PM', 'aui'), |
|
1771 | + 'firstDayOfWeek' => (int) get_option('start_of_week'), |
|
1772 | 1772 | 'time_24hr' => false, |
1773 | - 'year' => __( 'Year', 'aui' ), |
|
1774 | - 'hour' => __( 'Hour', 'aui' ), |
|
1775 | - 'minute' => __( 'Minute', 'aui' ), |
|
1776 | - 'weekAbbreviation' => __( 'Wk', 'aui' ), |
|
1777 | - 'rangeSeparator' => __( ' to ', 'aui' ), |
|
1778 | - 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
|
1779 | - 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
|
1773 | + 'year' => __('Year', 'aui'), |
|
1774 | + 'hour' => __('Hour', 'aui'), |
|
1775 | + 'minute' => __('Minute', 'aui'), |
|
1776 | + 'weekAbbreviation' => __('Wk', 'aui'), |
|
1777 | + 'rangeSeparator' => __(' to ', 'aui'), |
|
1778 | + 'scrollTitle' => __('Scroll to increment', 'aui'), |
|
1779 | + 'toggleTitle' => __('Click to toggle', 'aui') |
|
1780 | 1780 | ); |
1781 | 1781 | |
1782 | - return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
1782 | + return apply_filters('ayecode_ui_calendar_params', $params); |
|
1783 | 1783 | } |
1784 | 1784 | |
1785 | 1785 | /** |
@@ -1792,47 +1792,47 @@ discard block |
||
1792 | 1792 | public static function flatpickr_locale() { |
1793 | 1793 | $params = self::calendar_params(); |
1794 | 1794 | |
1795 | - if ( is_string( $params ) ) { |
|
1796 | - $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
1795 | + if (is_string($params)) { |
|
1796 | + $params = html_entity_decode($params, ENT_QUOTES, 'UTF-8'); |
|
1797 | 1797 | } else { |
1798 | - foreach ( (array) $params as $key => $value ) { |
|
1799 | - if ( ! is_scalar( $value ) ) { |
|
1798 | + foreach ((array) $params as $key => $value) { |
|
1799 | + if (!is_scalar($value)) { |
|
1800 | 1800 | continue; |
1801 | 1801 | } |
1802 | 1802 | |
1803 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
1803 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
1804 | 1804 | } |
1805 | 1805 | } |
1806 | 1806 | |
1807 | 1807 | $day_s3 = array(); |
1808 | 1808 | $day_s5 = array(); |
1809 | 1809 | |
1810 | - for ( $i = 1; $i <= 7; $i ++ ) { |
|
1811 | - $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1812 | - $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1810 | + for ($i = 1; $i <= 7; $i++) { |
|
1811 | + $day_s3[] = addslashes($params['day_s3_' . $i]); |
|
1812 | + $day_s5[] = addslashes($params['day_s3_' . $i]); |
|
1813 | 1813 | } |
1814 | 1814 | |
1815 | 1815 | $month_s = array(); |
1816 | 1816 | $month_long = array(); |
1817 | 1817 | |
1818 | - for ( $i = 1; $i <= 12; $i ++ ) { |
|
1819 | - $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
1820 | - $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
1818 | + for ($i = 1; $i <= 12; $i++) { |
|
1819 | + $month_s[] = addslashes($params['month_s_' . $i]); |
|
1820 | + $month_long[] = addslashes($params['month_long_' . $i]); |
|
1821 | 1821 | } |
1822 | 1822 | |
1823 | 1823 | ob_start(); |
1824 | -if ( 0 ) { ?><script><?php } ?> |
|
1824 | +if (0) { ?><script><?php } ?> |
|
1825 | 1825 | { |
1826 | 1826 | weekdays: { |
1827 | - shorthand: ['<?php echo implode( "','", $day_s3 ); ?>'], |
|
1828 | - longhand: ['<?php echo implode( "','", $day_s5 ); ?>'], |
|
1827 | + shorthand: ['<?php echo implode("','", $day_s3); ?>'], |
|
1828 | + longhand: ['<?php echo implode("','", $day_s5); ?>'], |
|
1829 | 1829 | }, |
1830 | 1830 | months: { |
1831 | - shorthand: ['<?php echo implode( "','", $month_s ); ?>'], |
|
1832 | - longhand: ['<?php echo implode( "','", $month_long ); ?>'], |
|
1831 | + shorthand: ['<?php echo implode("','", $month_s); ?>'], |
|
1832 | + longhand: ['<?php echo implode("','", $month_long); ?>'], |
|
1833 | 1833 | }, |
1834 | 1834 | daysInMonth: [31,28,31,30,31,30,31,31,30,31,30,31], |
1835 | - firstDayOfWeek: <?php echo (int) $params[ 'firstDayOfWeek' ]; ?>, |
|
1835 | + firstDayOfWeek: <?php echo (int) $params['firstDayOfWeek']; ?>, |
|
1836 | 1836 | ordinal: function (nth) { |
1837 | 1837 | var s = nth % 100; |
1838 | 1838 | if (s > 3 && s < 21) |
@@ -1848,21 +1848,21 @@ discard block |
||
1848 | 1848 | return "th"; |
1849 | 1849 | } |
1850 | 1850 | }, |
1851 | - rangeSeparator: '<?php echo addslashes( $params[ 'rangeSeparator' ] ); ?>', |
|
1852 | - weekAbbreviation: '<?php echo addslashes( $params[ 'weekAbbreviation' ] ); ?>', |
|
1853 | - scrollTitle: '<?php echo addslashes( $params[ 'scrollTitle' ] ); ?>', |
|
1854 | - toggleTitle: '<?php echo addslashes( $params[ 'toggleTitle' ] ); ?>', |
|
1855 | - amPM: ['<?php echo addslashes( $params[ 'am_upper' ] ); ?>','<?php echo addslashes( $params[ 'pm_upper' ] ); ?>'], |
|
1856 | - yearAriaLabel: '<?php echo addslashes( $params[ 'year' ] ); ?>', |
|
1857 | - hourAriaLabel: '<?php echo addslashes( $params[ 'hour' ] ); ?>', |
|
1858 | - minuteAriaLabel: '<?php echo addslashes( $params[ 'minute' ] ); ?>', |
|
1859 | - time_24hr: <?php echo ( $params[ 'time_24hr' ] ? 'true' : 'false' ) ; ?> |
|
1851 | + rangeSeparator: '<?php echo addslashes($params['rangeSeparator']); ?>', |
|
1852 | + weekAbbreviation: '<?php echo addslashes($params['weekAbbreviation']); ?>', |
|
1853 | + scrollTitle: '<?php echo addslashes($params['scrollTitle']); ?>', |
|
1854 | + toggleTitle: '<?php echo addslashes($params['toggleTitle']); ?>', |
|
1855 | + amPM: ['<?php echo addslashes($params['am_upper']); ?>','<?php echo addslashes($params['pm_upper']); ?>'], |
|
1856 | + yearAriaLabel: '<?php echo addslashes($params['year']); ?>', |
|
1857 | + hourAriaLabel: '<?php echo addslashes($params['hour']); ?>', |
|
1858 | + minuteAriaLabel: '<?php echo addslashes($params['minute']); ?>', |
|
1859 | + time_24hr: <?php echo ($params['time_24hr'] ? 'true' : 'false'); ?> |
|
1860 | 1860 | } |
1861 | -<?php if ( 0 ) { ?></script><?php } ?> |
|
1861 | +<?php if (0) { ?></script><?php } ?> |
|
1862 | 1862 | <?php |
1863 | 1863 | $locale = ob_get_clean(); |
1864 | 1864 | |
1865 | - return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
1865 | + return apply_filters('ayecode_ui_flatpickr_locale', trim($locale)); |
|
1866 | 1866 | } |
1867 | 1867 | |
1868 | 1868 | /** |
@@ -1874,20 +1874,20 @@ discard block |
||
1874 | 1874 | */ |
1875 | 1875 | public static function select2_params() { |
1876 | 1876 | $params = array( |
1877 | - 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'aui' ), |
|
1878 | - 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'aui' ), |
|
1879 | - 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'aui' ), |
|
1880 | - 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ), |
|
1881 | - 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ), |
|
1882 | - 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'aui' ), |
|
1883 | - 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ), |
|
1884 | - 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ), |
|
1885 | - 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ), |
|
1886 | - 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'aui' ), |
|
1887 | - 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'aui' ) |
|
1877 | + 'i18n_select_state_text' => esc_attr__('Select an option…', 'aui'), |
|
1878 | + 'i18n_no_matches' => _x('No matches found', 'enhanced select', 'aui'), |
|
1879 | + 'i18n_ajax_error' => _x('Loading failed', 'enhanced select', 'aui'), |
|
1880 | + 'i18n_input_too_short_1' => _x('Please enter 1 or more characters', 'enhanced select', 'aui'), |
|
1881 | + 'i18n_input_too_short_n' => _x('Please enter %item% or more characters', 'enhanced select', 'aui'), |
|
1882 | + 'i18n_input_too_long_1' => _x('Please delete 1 character', 'enhanced select', 'aui'), |
|
1883 | + 'i18n_input_too_long_n' => _x('Please delete %item% characters', 'enhanced select', 'aui'), |
|
1884 | + 'i18n_selection_too_long_1' => _x('You can only select 1 item', 'enhanced select', 'aui'), |
|
1885 | + 'i18n_selection_too_long_n' => _x('You can only select %item% items', 'enhanced select', 'aui'), |
|
1886 | + 'i18n_load_more' => _x('Loading more results…', 'enhanced select', 'aui'), |
|
1887 | + 'i18n_searching' => _x('Searching…', 'enhanced select', 'aui') |
|
1888 | 1888 | ); |
1889 | 1889 | |
1890 | - return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
1890 | + return apply_filters('ayecode_ui_select2_params', $params); |
|
1891 | 1891 | } |
1892 | 1892 | |
1893 | 1893 | /** |
@@ -1900,17 +1900,17 @@ discard block |
||
1900 | 1900 | public static function select2_locale() { |
1901 | 1901 | $params = self::select2_params(); |
1902 | 1902 | |
1903 | - foreach ( (array) $params as $key => $value ) { |
|
1904 | - if ( ! is_scalar( $value ) ) { |
|
1903 | + foreach ((array) $params as $key => $value) { |
|
1904 | + if (!is_scalar($value)) { |
|
1905 | 1905 | continue; |
1906 | 1906 | } |
1907 | 1907 | |
1908 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
1908 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
1909 | 1909 | } |
1910 | 1910 | |
1911 | - $locale = json_encode( $params ); |
|
1911 | + $locale = json_encode($params); |
|
1912 | 1912 | |
1913 | - return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
1913 | + return apply_filters('ayecode_ui_select2_locale', trim($locale)); |
|
1914 | 1914 | } |
1915 | 1915 | } |
1916 | 1916 |