@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | |
24 | 24 | global $typenow; |
25 | 25 | |
26 | - if ( $typenow != 'give_forms' ) { |
|
26 | + if ($typenow != 'give_forms') { |
|
27 | 27 | return true; |
28 | 28 | } |
29 | 29 | |
30 | 30 | return false; |
31 | 31 | } |
32 | 32 | |
33 | -add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' ); |
|
33 | +add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition'); |
|
34 | 34 | |
35 | 35 | |
36 | 36 | /** |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return int|false |
42 | 42 | */ |
43 | -function get_form_id_from_args( $args ) { |
|
43 | +function get_form_id_from_args($args) { |
|
44 | 44 | |
45 | - if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) { |
|
45 | + if (isset($args['form_id']) && $args['form_id'] != 0) { |
|
46 | 46 | |
47 | - return intval( $args['form_id'] ); |
|
47 | + return intval($args['form_id']); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | return false; |
@@ -59,23 +59,23 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return bool |
61 | 61 | */ |
62 | -function give_is_float_labels_enabled( $args ) { |
|
62 | +function give_is_float_labels_enabled($args) { |
|
63 | 63 | |
64 | 64 | $float_labels = ''; |
65 | 65 | |
66 | - if ( ! empty( $args['float_labels'] ) ) { |
|
66 | + if ( ! empty($args['float_labels'])) { |
|
67 | 67 | $float_labels = $args['float_labels']; |
68 | 68 | } |
69 | 69 | |
70 | - if ( empty( $float_labels ) ) { |
|
71 | - $float_labels = give_get_meta( $args['form_id'], '_give_form_floating_labels', true ); |
|
70 | + if (empty($float_labels)) { |
|
71 | + $float_labels = give_get_meta($args['form_id'], '_give_form_floating_labels', true); |
|
72 | 72 | } |
73 | 73 | |
74 | - if ( empty( $float_labels ) || ( 'global' === $float_labels ) ) { |
|
75 | - $float_labels = give_get_option( 'floatlabels', 'disabled' ); |
|
74 | + if (empty($float_labels) || ('global' === $float_labels)) { |
|
75 | + $float_labels = give_get_option('floatlabels', 'disabled'); |
|
76 | 76 | } |
77 | 77 | |
78 | - return give_is_setting_enabled( $float_labels ); |
|
78 | + return give_is_setting_enabled($float_labels); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $can_checkout = true; |
93 | 93 | |
94 | - return (bool) apply_filters( 'give_can_checkout', $can_checkout ); |
|
94 | + return (bool) apply_filters('give_can_checkout', $can_checkout); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | function give_get_success_page_uri() { |
106 | 106 | $give_options = give_get_settings(); |
107 | 107 | |
108 | - $success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' ); |
|
108 | + $success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url'); |
|
109 | 109 | |
110 | - return apply_filters( 'give_get_success_page_uri', $success_page ); |
|
110 | + return apply_filters('give_get_success_page_uri', $success_page); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | */ |
120 | 120 | function give_is_success_page() { |
121 | 121 | $give_options = give_get_settings(); |
122 | - $is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false; |
|
122 | + $is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false; |
|
123 | 123 | |
124 | - return apply_filters( 'give_is_success_page', $is_success_page ); |
|
124 | + return apply_filters('give_is_success_page', $is_success_page); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -135,17 +135,17 @@ discard block |
||
135 | 135 | * @since 1.0 |
136 | 136 | * @return void |
137 | 137 | */ |
138 | -function give_send_to_success_page( $query_string = null ) { |
|
138 | +function give_send_to_success_page($query_string = null) { |
|
139 | 139 | |
140 | 140 | $redirect = give_get_success_page_uri(); |
141 | 141 | |
142 | - if ( $query_string ) { |
|
142 | + if ($query_string) { |
|
143 | 143 | $redirect .= $query_string; |
144 | 144 | } |
145 | 145 | |
146 | - $gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : ''; |
|
146 | + $gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : ''; |
|
147 | 147 | |
148 | - wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) ); |
|
148 | + wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string)); |
|
149 | 149 | give_die(); |
150 | 150 | } |
151 | 151 | |
@@ -161,19 +161,19 @@ discard block |
||
161 | 161 | * @since 1.0 |
162 | 162 | * @return Void |
163 | 163 | */ |
164 | -function give_send_back_to_checkout( $args = array() ) { |
|
164 | +function give_send_back_to_checkout($args = array()) { |
|
165 | 165 | |
166 | - $url = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : ''; |
|
166 | + $url = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : ''; |
|
167 | 167 | $form_id = 0; |
168 | 168 | |
169 | 169 | // Set the form_id. |
170 | - if ( isset( $_POST['give-form-id'] ) ) { |
|
171 | - $form_id = sanitize_text_field( $_POST['give-form-id'] ); |
|
170 | + if (isset($_POST['give-form-id'])) { |
|
171 | + $form_id = sanitize_text_field($_POST['give-form-id']); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // Need a URL to continue. If none, redirect back to single form. |
175 | - if ( empty( $url ) ) { |
|
176 | - wp_safe_redirect( get_permalink( $form_id ) ); |
|
175 | + if (empty($url)) { |
|
176 | + wp_safe_redirect(get_permalink($form_id)); |
|
177 | 177 | give_die(); |
178 | 178 | } |
179 | 179 | |
@@ -182,41 +182,41 @@ discard block |
||
182 | 182 | ); |
183 | 183 | |
184 | 184 | // Set the $level_id. |
185 | - if ( isset( $_POST['give-price-id'] ) ) { |
|
186 | - $defaults['level-id'] = sanitize_text_field( $_POST['give-price-id'] ); |
|
185 | + if (isset($_POST['give-price-id'])) { |
|
186 | + $defaults['level-id'] = sanitize_text_field($_POST['give-price-id']); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | // Check for backward compatibility. |
190 | - if ( is_string( $args ) ) { |
|
191 | - $args = str_replace( '?', '', $args ); |
|
190 | + if (is_string($args)) { |
|
191 | + $args = str_replace('?', '', $args); |
|
192 | 192 | } |
193 | 193 | |
194 | - $args = wp_parse_args( $args, $defaults ); |
|
194 | + $args = wp_parse_args($args, $defaults); |
|
195 | 195 | |
196 | 196 | // Merge URL query with $args to maintain third-party URL parameters after redirect. |
197 | - $url_data = wp_parse_url( $url ); |
|
197 | + $url_data = wp_parse_url($url); |
|
198 | 198 | |
199 | 199 | // Check if an array to prevent notices before parsing. |
200 | - if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) { |
|
201 | - parse_str( $url_data['query'], $query ); |
|
200 | + if (isset($url_data['query']) && ! empty($url_data['query'])) { |
|
201 | + parse_str($url_data['query'], $query); |
|
202 | 202 | |
203 | 203 | // Precaution: don't allow any CC info. |
204 | - unset( $query['card_number'] ); |
|
205 | - unset( $query['card_cvc'] ); |
|
204 | + unset($query['card_number']); |
|
205 | + unset($query['card_cvc']); |
|
206 | 206 | |
207 | 207 | } else { |
208 | 208 | // No $url_data so pass empty array. |
209 | 209 | $query = array(); |
210 | 210 | } |
211 | 211 | |
212 | - $new_query = array_merge( $args, $query ); |
|
213 | - $new_query_string = http_build_query( $new_query ); |
|
212 | + $new_query = array_merge($args, $query); |
|
213 | + $new_query_string = http_build_query($new_query); |
|
214 | 214 | |
215 | 215 | // Assemble URL parts. |
216 | - $redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' ); |
|
216 | + $redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap'); |
|
217 | 217 | |
218 | 218 | // Redirect them. |
219 | - wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) ); |
|
219 | + wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args)); |
|
220 | 220 | give_die(); |
221 | 221 | |
222 | 222 | } |
@@ -232,16 +232,16 @@ discard block |
||
232 | 232 | * @since 1.0 |
233 | 233 | * @return string |
234 | 234 | */ |
235 | -function give_get_success_page_url( $query_string = null ) { |
|
235 | +function give_get_success_page_url($query_string = null) { |
|
236 | 236 | |
237 | - $success_page = give_get_option( 'success_page', 0 ); |
|
238 | - $success_page = get_permalink( $success_page ); |
|
237 | + $success_page = give_get_option('success_page', 0); |
|
238 | + $success_page = get_permalink($success_page); |
|
239 | 239 | |
240 | - if ( $query_string ) { |
|
240 | + if ($query_string) { |
|
241 | 241 | $success_page .= $query_string; |
242 | 242 | } |
243 | 243 | |
244 | - return apply_filters( 'give_success_page_url', $success_page ); |
|
244 | + return apply_filters('give_success_page_url', $success_page); |
|
245 | 245 | |
246 | 246 | } |
247 | 247 | |
@@ -254,15 +254,15 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @return mixed|void Full URL to the Failed Donation Page, if present, home page if it doesn't exist |
256 | 256 | */ |
257 | -function give_get_failed_transaction_uri( $extras = false ) { |
|
257 | +function give_get_failed_transaction_uri($extras = false) { |
|
258 | 258 | $give_options = give_get_settings(); |
259 | 259 | |
260 | - $uri = ! empty( $give_options['failure_page'] ) ? trailingslashit( get_permalink( $give_options['failure_page'] ) ) : home_url(); |
|
261 | - if ( $extras ) { |
|
260 | + $uri = ! empty($give_options['failure_page']) ? trailingslashit(get_permalink($give_options['failure_page'])) : home_url(); |
|
261 | + if ($extras) { |
|
262 | 262 | $uri .= $extras; |
263 | 263 | } |
264 | 264 | |
265 | - return apply_filters( 'give_get_failed_transaction_uri', $uri ); |
|
265 | + return apply_filters('give_get_failed_transaction_uri', $uri); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -273,9 +273,9 @@ discard block |
||
273 | 273 | */ |
274 | 274 | function give_is_failed_transaction_page() { |
275 | 275 | $give_options = give_get_settings(); |
276 | - $ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false; |
|
276 | + $ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false; |
|
277 | 277 | |
278 | - return apply_filters( 'give_is_failure_page', $ret ); |
|
278 | + return apply_filters('give_is_failure_page', $ret); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -287,18 +287,18 @@ discard block |
||
287 | 287 | */ |
288 | 288 | function give_listen_for_failed_payments() { |
289 | 289 | |
290 | - $failed_page = give_get_option( 'failure_page', 0 ); |
|
290 | + $failed_page = give_get_option('failure_page', 0); |
|
291 | 291 | |
292 | - if ( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) { |
|
292 | + if ( ! empty($failed_page) && is_page($failed_page) && ! empty($_GET['payment-id'])) { |
|
293 | 293 | |
294 | - $payment_id = absint( $_GET['payment-id'] ); |
|
295 | - give_update_payment_status( $payment_id, 'failed' ); |
|
294 | + $payment_id = absint($_GET['payment-id']); |
|
295 | + give_update_payment_status($payment_id, 'failed'); |
|
296 | 296 | |
297 | 297 | } |
298 | 298 | |
299 | 299 | } |
300 | 300 | |
301 | -add_action( 'template_redirect', 'give_listen_for_failed_payments' ); |
|
301 | +add_action('template_redirect', 'give_listen_for_failed_payments'); |
|
302 | 302 | |
303 | 303 | /** |
304 | 304 | * Retrieve the Donation History page URI |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | function give_get_history_page_uri() { |
312 | 312 | $give_options = give_get_settings(); |
313 | 313 | |
314 | - $history_page = isset( $give_options['history_page'] ) ? get_permalink( absint( $give_options['history_page'] ) ) : get_bloginfo( 'url' ); |
|
314 | + $history_page = isset($give_options['history_page']) ? get_permalink(absint($give_options['history_page'])) : get_bloginfo('url'); |
|
315 | 315 | |
316 | - return apply_filters( 'give_get_history_page_uri', $history_page ); |
|
316 | + return apply_filters('give_get_history_page_uri', $history_page); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -326,11 +326,11 @@ discard block |
||
326 | 326 | * @since 1.0 |
327 | 327 | * @return bool |
328 | 328 | */ |
329 | -function give_field_is_required( $field = '', $form_id ) { |
|
329 | +function give_field_is_required($field = '', $form_id) { |
|
330 | 330 | |
331 | - $required_fields = give_get_required_fields( $form_id ); |
|
331 | + $required_fields = give_get_required_fields($form_id); |
|
332 | 332 | |
333 | - return array_key_exists( $field, $required_fields ); |
|
333 | + return array_key_exists($field, $required_fields); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | /** |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | * |
349 | 349 | * @return void |
350 | 350 | */ |
351 | -function give_record_sale_in_log( $give_form_id = 0, $payment_id, $price_id = false, $sale_date = null ) { |
|
351 | +function give_record_sale_in_log($give_form_id = 0, $payment_id, $price_id = false, $sale_date = null) { |
|
352 | 352 | global $give_logs; |
353 | 353 | |
354 | 354 | $log_data = array( |
355 | 355 | 'post_parent' => $give_form_id, |
356 | 356 | 'log_type' => 'sale', |
357 | - 'post_date' => isset( $sale_date ) ? $sale_date : null, |
|
358 | - 'post_date_gmt' => isset( $sale_date ) ? $sale_date : null, |
|
357 | + 'post_date' => isset($sale_date) ? $sale_date : null, |
|
358 | + 'post_date_gmt' => isset($sale_date) ? $sale_date : null, |
|
359 | 359 | ); |
360 | 360 | |
361 | 361 | $log_meta = array( |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | 'price_id' => (int) $price_id, |
364 | 364 | ); |
365 | 365 | |
366 | - $give_logs->insert_log( $log_data, $log_meta ); |
|
366 | + $give_logs->insert_log($log_data, $log_meta); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | |
@@ -377,11 +377,11 @@ discard block |
||
377 | 377 | * |
378 | 378 | * @return bool|int |
379 | 379 | */ |
380 | -function give_increase_purchase_count( $form_id = 0, $quantity = 1 ) { |
|
380 | +function give_increase_purchase_count($form_id = 0, $quantity = 1) { |
|
381 | 381 | $quantity = (int) $quantity; |
382 | - $form = new Give_Donate_Form( $form_id ); |
|
382 | + $form = new Give_Donate_Form($form_id); |
|
383 | 383 | |
384 | - return $form->increase_sales( $quantity ); |
|
384 | + return $form->increase_sales($quantity); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
@@ -394,11 +394,11 @@ discard block |
||
394 | 394 | * |
395 | 395 | * @return bool|int |
396 | 396 | */ |
397 | -function give_decrease_purchase_count( $form_id = 0, $quantity = 1 ) { |
|
397 | +function give_decrease_purchase_count($form_id = 0, $quantity = 1) { |
|
398 | 398 | $quantity = (int) $quantity; |
399 | - $form = new Give_Donate_Form( $form_id ); |
|
399 | + $form = new Give_Donate_Form($form_id); |
|
400 | 400 | |
401 | - return $form->decrease_sales( $quantity ); |
|
401 | + return $form->decrease_sales($quantity); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | /** |
@@ -411,10 +411,10 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @return bool|int |
413 | 413 | */ |
414 | -function give_increase_earnings( $give_form_id = 0, $amount ) { |
|
415 | - $form = new Give_Donate_Form( $give_form_id ); |
|
414 | +function give_increase_earnings($give_form_id = 0, $amount) { |
|
415 | + $form = new Give_Donate_Form($give_form_id); |
|
416 | 416 | |
417 | - return $form->increase_earnings( $amount ); |
|
417 | + return $form->increase_earnings($amount); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -427,10 +427,10 @@ discard block |
||
427 | 427 | * |
428 | 428 | * @return bool|int |
429 | 429 | */ |
430 | -function give_decrease_earnings( $form_id = 0, $amount ) { |
|
431 | - $form = new Give_Donate_Form( $form_id ); |
|
430 | +function give_decrease_earnings($form_id = 0, $amount) { |
|
431 | + $form = new Give_Donate_Form($form_id); |
|
432 | 432 | |
433 | - return $form->decrease_earnings( $amount ); |
|
433 | + return $form->decrease_earnings($amount); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @return int $earnings Earnings for a certain form |
445 | 445 | */ |
446 | -function give_get_form_earnings_stats( $form_id = 0 ) { |
|
447 | - $give_form = new Give_Donate_Form( $form_id ); |
|
446 | +function give_get_form_earnings_stats($form_id = 0) { |
|
447 | + $give_form = new Give_Donate_Form($form_id); |
|
448 | 448 | |
449 | 449 | return $give_form->earnings; |
450 | 450 | } |
@@ -459,8 +459,8 @@ discard block |
||
459 | 459 | * |
460 | 460 | * @return int $sales Amount of sales for a certain form |
461 | 461 | */ |
462 | -function give_get_form_sales_stats( $give_form_id = 0 ) { |
|
463 | - $give_form = new Give_Donate_Form( $give_form_id ); |
|
462 | +function give_get_form_sales_stats($give_form_id = 0) { |
|
463 | + $give_form = new Give_Donate_Form($give_form_id); |
|
464 | 464 | |
465 | 465 | return $give_form->sales; |
466 | 466 | } |
@@ -475,16 +475,16 @@ discard block |
||
475 | 475 | * |
476 | 476 | * @return float $sales Average monthly sales |
477 | 477 | */ |
478 | -function give_get_average_monthly_form_sales( $form_id = 0 ) { |
|
479 | - $sales = give_get_form_sales_stats( $form_id ); |
|
480 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
478 | +function give_get_average_monthly_form_sales($form_id = 0) { |
|
479 | + $sales = give_get_form_sales_stats($form_id); |
|
480 | + $release_date = get_post_field('post_date', $form_id); |
|
481 | 481 | |
482 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
482 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
483 | 483 | |
484 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
484 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
485 | 485 | |
486 | - if ( $months > 0 ) { |
|
487 | - $sales = ( $sales / $months ); |
|
486 | + if ($months > 0) { |
|
487 | + $sales = ($sales / $months); |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | return $sales; |
@@ -500,16 +500,16 @@ discard block |
||
500 | 500 | * |
501 | 501 | * @return float $earnings Average monthly earnings |
502 | 502 | */ |
503 | -function give_get_average_monthly_form_earnings( $form_id = 0 ) { |
|
504 | - $earnings = give_get_form_earnings_stats( $form_id ); |
|
505 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
503 | +function give_get_average_monthly_form_earnings($form_id = 0) { |
|
504 | + $earnings = give_get_form_earnings_stats($form_id); |
|
505 | + $release_date = get_post_field('post_date', $form_id); |
|
506 | 506 | |
507 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
507 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
508 | 508 | |
509 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
509 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
510 | 510 | |
511 | - if ( $months > 0 ) { |
|
512 | - $earnings = ( $earnings / $months ); |
|
511 | + if ($months > 0) { |
|
512 | + $earnings = ($earnings / $months); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | return $earnings < 0 ? 0 : $earnings; |
@@ -529,23 +529,23 @@ discard block |
||
529 | 529 | * |
530 | 530 | * @return string $price_name Name of the price option |
531 | 531 | */ |
532 | -function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0 ) { |
|
532 | +function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0) { |
|
533 | 533 | |
534 | - $prices = give_get_variable_prices( $form_id ); |
|
534 | + $prices = give_get_variable_prices($form_id); |
|
535 | 535 | $price_name = ''; |
536 | 536 | |
537 | - foreach ( $prices as $price ) { |
|
537 | + foreach ($prices as $price) { |
|
538 | 538 | |
539 | - if ( intval( $price['_give_id']['level_id'] ) == intval( $price_id ) ) { |
|
539 | + if (intval($price['_give_id']['level_id']) == intval($price_id)) { |
|
540 | 540 | |
541 | - $price_text = isset( $price['_give_text'] ) ? $price['_give_text'] : ''; |
|
542 | - $price_fallback = give_currency_filter( give_format_amount( $price['_give_amount'] ) ); |
|
543 | - $price_name = ! empty( $price_text ) ? $price_text : $price_fallback; |
|
541 | + $price_text = isset($price['_give_text']) ? $price['_give_text'] : ''; |
|
542 | + $price_fallback = give_currency_filter(give_format_amount($price['_give_amount'])); |
|
543 | + $price_name = ! empty($price_text) ? $price_text : $price_fallback; |
|
544 | 544 | |
545 | 545 | } |
546 | 546 | } |
547 | 547 | |
548 | - return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id ); |
|
548 | + return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | |
@@ -558,14 +558,14 @@ discard block |
||
558 | 558 | * |
559 | 559 | * @return string $range A fully formatted price range |
560 | 560 | */ |
561 | -function give_price_range( $form_id = 0 ) { |
|
562 | - $low = give_get_lowest_price_option( $form_id ); |
|
563 | - $high = give_get_highest_price_option( $form_id ); |
|
564 | - $range = '<span class="give_price_range_low">' . give_currency_filter( give_format_amount( $low ) ) . '</span>'; |
|
561 | +function give_price_range($form_id = 0) { |
|
562 | + $low = give_get_lowest_price_option($form_id); |
|
563 | + $high = give_get_highest_price_option($form_id); |
|
564 | + $range = '<span class="give_price_range_low">'.give_currency_filter(give_format_amount($low)).'</span>'; |
|
565 | 565 | $range .= '<span class="give_price_range_sep"> – </span>'; |
566 | - $range .= '<span class="give_price_range_high">' . give_currency_filter( give_format_amount( $high ) ) . '</span>'; |
|
566 | + $range .= '<span class="give_price_range_high">'.give_currency_filter(give_format_amount($high)).'</span>'; |
|
567 | 567 | |
568 | - return apply_filters( 'give_price_range', $range, $form_id, $low, $high ); |
|
568 | + return apply_filters('give_price_range', $range, $form_id, $low, $high); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | |
@@ -580,35 +580,35 @@ discard block |
||
580 | 580 | * |
581 | 581 | * @return int ID of the lowest price |
582 | 582 | */ |
583 | -function give_get_lowest_price_id( $form_id = 0 ) { |
|
583 | +function give_get_lowest_price_id($form_id = 0) { |
|
584 | 584 | |
585 | - if ( empty( $form_id ) ) { |
|
585 | + if (empty($form_id)) { |
|
586 | 586 | $form_id = get_the_ID(); |
587 | 587 | } |
588 | 588 | |
589 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
590 | - return give_get_form_price( $form_id ); |
|
589 | + if ( ! give_has_variable_prices($form_id)) { |
|
590 | + return give_get_form_price($form_id); |
|
591 | 591 | } |
592 | 592 | |
593 | - $prices = give_get_variable_prices( $form_id ); |
|
593 | + $prices = give_get_variable_prices($form_id); |
|
594 | 594 | |
595 | 595 | $min = $min_id = 0; |
596 | 596 | |
597 | - if ( ! empty( $prices ) ) { |
|
597 | + if ( ! empty($prices)) { |
|
598 | 598 | |
599 | - foreach ( $prices as $key => $price ) { |
|
599 | + foreach ($prices as $key => $price) { |
|
600 | 600 | |
601 | - if ( empty( $price['_give_amount'] ) ) { |
|
601 | + if (empty($price['_give_amount'])) { |
|
602 | 602 | continue; |
603 | 603 | } |
604 | 604 | |
605 | - if ( ! isset( $min ) ) { |
|
605 | + if ( ! isset($min)) { |
|
606 | 606 | $min = $price['_give_amount']; |
607 | 607 | } else { |
608 | - $min = min( $min, $price['_give_amount'] ); |
|
608 | + $min = min($min, $price['_give_amount']); |
|
609 | 609 | } |
610 | 610 | |
611 | - if ( $price['_give_amount'] == $min ) { |
|
611 | + if ($price['_give_amount'] == $min) { |
|
612 | 612 | $min_id = $price['_give_id']['level_id']; |
613 | 613 | } |
614 | 614 | } |
@@ -626,45 +626,45 @@ discard block |
||
626 | 626 | * |
627 | 627 | * @return float Amount of the lowest price |
628 | 628 | */ |
629 | -function give_get_lowest_price_option( $form_id = 0 ) { |
|
630 | - if ( empty( $form_id ) ) { |
|
629 | +function give_get_lowest_price_option($form_id = 0) { |
|
630 | + if (empty($form_id)) { |
|
631 | 631 | $form_id = get_the_ID(); |
632 | 632 | } |
633 | 633 | |
634 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
635 | - return give_get_form_price( $form_id ); |
|
634 | + if ( ! give_has_variable_prices($form_id)) { |
|
635 | + return give_get_form_price($form_id); |
|
636 | 636 | } |
637 | 637 | |
638 | - $prices = give_get_variable_prices( $form_id ); |
|
638 | + $prices = give_get_variable_prices($form_id); |
|
639 | 639 | |
640 | 640 | $low = 0; |
641 | 641 | |
642 | - if ( ! empty( $prices ) ) { |
|
642 | + if ( ! empty($prices)) { |
|
643 | 643 | |
644 | 644 | $min = $min_id = 0; |
645 | 645 | |
646 | - foreach ( $prices as $key => $price ) { |
|
646 | + foreach ($prices as $key => $price) { |
|
647 | 647 | |
648 | - if ( empty( $price['_give_amount'] ) ) { |
|
648 | + if (empty($price['_give_amount'])) { |
|
649 | 649 | continue; |
650 | 650 | } |
651 | 651 | |
652 | - if ( ! isset( $min ) ) { |
|
652 | + if ( ! isset($min)) { |
|
653 | 653 | $min = $price['_give_amount']; |
654 | 654 | } else { |
655 | - $min = min( $min, give_sanitize_amount( $price['_give_amount'] ) ); |
|
655 | + $min = min($min, give_sanitize_amount($price['_give_amount'])); |
|
656 | 656 | } |
657 | 657 | |
658 | - if ( $price['_give_amount'] == $min ) { |
|
658 | + if ($price['_give_amount'] == $min) { |
|
659 | 659 | $min_id = $key; |
660 | 660 | } |
661 | 661 | } |
662 | 662 | |
663 | - $low = $prices[ $min_id ]['_give_amount']; |
|
663 | + $low = $prices[$min_id]['_give_amount']; |
|
664 | 664 | |
665 | 665 | } |
666 | 666 | |
667 | - return give_sanitize_amount( $low ); |
|
667 | + return give_sanitize_amount($low); |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | /** |
@@ -676,41 +676,41 @@ discard block |
||
676 | 676 | * |
677 | 677 | * @return float Amount of the highest price |
678 | 678 | */ |
679 | -function give_get_highest_price_option( $form_id = 0 ) { |
|
679 | +function give_get_highest_price_option($form_id = 0) { |
|
680 | 680 | |
681 | - if ( empty( $form_id ) ) { |
|
681 | + if (empty($form_id)) { |
|
682 | 682 | $form_id = get_the_ID(); |
683 | 683 | } |
684 | 684 | |
685 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
686 | - return give_get_form_price( $form_id ); |
|
685 | + if ( ! give_has_variable_prices($form_id)) { |
|
686 | + return give_get_form_price($form_id); |
|
687 | 687 | } |
688 | 688 | |
689 | - $prices = give_get_variable_prices( $form_id ); |
|
689 | + $prices = give_get_variable_prices($form_id); |
|
690 | 690 | |
691 | 691 | $high = 0.00; |
692 | 692 | |
693 | - if ( ! empty( $prices ) ) { |
|
693 | + if ( ! empty($prices)) { |
|
694 | 694 | |
695 | 695 | $max_id = $max = 0; |
696 | 696 | |
697 | - foreach ( $prices as $key => $price ) { |
|
698 | - if ( empty( $price['_give_amount'] ) ) { |
|
697 | + foreach ($prices as $key => $price) { |
|
698 | + if (empty($price['_give_amount'])) { |
|
699 | 699 | continue; |
700 | 700 | } |
701 | - $give_amount = give_sanitize_amount( $price['_give_amount'] ); |
|
701 | + $give_amount = give_sanitize_amount($price['_give_amount']); |
|
702 | 702 | |
703 | - $max = max( $max, $give_amount ); |
|
703 | + $max = max($max, $give_amount); |
|
704 | 704 | |
705 | - if ( $give_amount == $max ) { |
|
705 | + if ($give_amount == $max) { |
|
706 | 706 | $max_id = $key; |
707 | 707 | } |
708 | 708 | } |
709 | 709 | |
710 | - $high = $prices[ $max_id ]['_give_amount']; |
|
710 | + $high = $prices[$max_id]['_give_amount']; |
|
711 | 711 | } |
712 | 712 | |
713 | - return give_sanitize_amount( $high ); |
|
713 | + return give_sanitize_amount($high); |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | /** |
@@ -722,15 +722,15 @@ discard block |
||
722 | 722 | * |
723 | 723 | * @return mixed string|int Price of the form |
724 | 724 | */ |
725 | -function give_get_form_price( $form_id = 0 ) { |
|
725 | +function give_get_form_price($form_id = 0) { |
|
726 | 726 | |
727 | - if ( empty( $form_id ) ) { |
|
727 | + if (empty($form_id)) { |
|
728 | 728 | return false; |
729 | 729 | } |
730 | 730 | |
731 | - $form = new Give_Donate_Form( $form_id ); |
|
731 | + $form = new Give_Donate_Form($form_id); |
|
732 | 732 | |
733 | - return $form->__get( 'price' ); |
|
733 | + return $form->__get('price'); |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | /** |
@@ -742,15 +742,15 @@ discard block |
||
742 | 742 | * |
743 | 743 | * @return mixed string|int Minimum price of the form |
744 | 744 | */ |
745 | -function give_get_form_minimum_price( $form_id = 0 ) { |
|
745 | +function give_get_form_minimum_price($form_id = 0) { |
|
746 | 746 | |
747 | - if ( empty( $form_id ) ) { |
|
747 | + if (empty($form_id)) { |
|
748 | 748 | return false; |
749 | 749 | } |
750 | 750 | |
751 | - $form = new Give_Donate_Form( $form_id ); |
|
751 | + $form = new Give_Donate_Form($form_id); |
|
752 | 752 | |
753 | - return $form->__get( 'minimum_price' ); |
|
753 | + return $form->__get('minimum_price'); |
|
754 | 754 | |
755 | 755 | } |
756 | 756 | |
@@ -765,51 +765,51 @@ discard block |
||
765 | 765 | * |
766 | 766 | * @return int $formatted_price |
767 | 767 | */ |
768 | -function give_price( $form_id = 0, $echo = true, $price_id = false ) { |
|
768 | +function give_price($form_id = 0, $echo = true, $price_id = false) { |
|
769 | 769 | |
770 | - if ( empty( $form_id ) ) { |
|
770 | + if (empty($form_id)) { |
|
771 | 771 | $form_id = get_the_ID(); |
772 | 772 | } |
773 | 773 | |
774 | - if ( give_has_variable_prices( $form_id ) ) { |
|
774 | + if (give_has_variable_prices($form_id)) { |
|
775 | 775 | |
776 | - $prices = give_get_variable_prices( $form_id ); |
|
776 | + $prices = give_get_variable_prices($form_id); |
|
777 | 777 | |
778 | - if ( false !== $price_id ) { |
|
778 | + if (false !== $price_id) { |
|
779 | 779 | |
780 | 780 | // loop through multi-prices to see which is default |
781 | - foreach ( $prices as $price ) { |
|
781 | + foreach ($prices as $price) { |
|
782 | 782 | // this is the default price |
783 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
783 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
784 | 784 | $price = (float) $price['_give_amount']; |
785 | 785 | }; |
786 | 786 | } |
787 | 787 | } else { |
788 | 788 | |
789 | - $price = give_get_lowest_price_option( $form_id ); |
|
789 | + $price = give_get_lowest_price_option($form_id); |
|
790 | 790 | } |
791 | 791 | |
792 | - $price = give_sanitize_amount( $price ); |
|
792 | + $price = give_sanitize_amount($price); |
|
793 | 793 | |
794 | 794 | } else { |
795 | 795 | |
796 | - $price = give_get_form_price( $form_id ); |
|
796 | + $price = give_get_form_price($form_id); |
|
797 | 797 | |
798 | 798 | } |
799 | 799 | |
800 | - $price = apply_filters( 'give_form_price', give_sanitize_amount( $price ), $form_id ); |
|
801 | - $formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>'; |
|
802 | - $formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price ); |
|
800 | + $price = apply_filters('give_form_price', give_sanitize_amount($price), $form_id); |
|
801 | + $formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>'; |
|
802 | + $formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price); |
|
803 | 803 | |
804 | - if ( $echo ) { |
|
804 | + if ($echo) { |
|
805 | 805 | echo $formatted_price; |
806 | 806 | } else { |
807 | 807 | return $formatted_price; |
808 | 808 | } |
809 | 809 | } |
810 | 810 | |
811 | -add_filter( 'give_form_price', 'give_format_amount', 10 ); |
|
812 | -add_filter( 'give_form_price', 'give_currency_filter', 20 ); |
|
811 | +add_filter('give_form_price', 'give_format_amount', 10); |
|
812 | +add_filter('give_form_price', 'give_currency_filter', 20); |
|
813 | 813 | |
814 | 814 | |
815 | 815 | /** |
@@ -822,19 +822,19 @@ discard block |
||
822 | 822 | * |
823 | 823 | * @return float $amount Amount of the price option |
824 | 824 | */ |
825 | -function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) { |
|
826 | - $prices = give_get_variable_prices( $form_id ); |
|
825 | +function give_get_price_option_amount($form_id = 0, $price_id = 0) { |
|
826 | + $prices = give_get_variable_prices($form_id); |
|
827 | 827 | |
828 | 828 | $amount = 0.00; |
829 | 829 | |
830 | - foreach ( $prices as $price ) { |
|
831 | - if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) { |
|
832 | - $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; |
|
830 | + foreach ($prices as $price) { |
|
831 | + if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) { |
|
832 | + $amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00; |
|
833 | 833 | break; |
834 | 834 | }; |
835 | 835 | } |
836 | 836 | |
837 | - return apply_filters( 'give_get_price_option_amount', give_sanitize_amount( $amount ), $form_id, $price_id ); |
|
837 | + return apply_filters('give_get_price_option_amount', give_sanitize_amount($amount), $form_id, $price_id); |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | /** |
@@ -846,13 +846,13 @@ discard block |
||
846 | 846 | * |
847 | 847 | * @return mixed string|int Goal of the form |
848 | 848 | */ |
849 | -function give_get_form_goal( $form_id = 0 ) { |
|
849 | +function give_get_form_goal($form_id = 0) { |
|
850 | 850 | |
851 | - if ( empty( $form_id ) ) { |
|
851 | + if (empty($form_id)) { |
|
852 | 852 | return false; |
853 | 853 | } |
854 | 854 | |
855 | - $form = new Give_Donate_Form( $form_id ); |
|
855 | + $form = new Give_Donate_Form($form_id); |
|
856 | 856 | |
857 | 857 | return $form->goal; |
858 | 858 | |
@@ -868,27 +868,27 @@ discard block |
||
868 | 868 | * |
869 | 869 | * @return string $formatted_goal |
870 | 870 | */ |
871 | -function give_goal( $form_id = 0, $echo = true ) { |
|
871 | +function give_goal($form_id = 0, $echo = true) { |
|
872 | 872 | |
873 | - if ( empty( $form_id ) ) { |
|
873 | + if (empty($form_id)) { |
|
874 | 874 | $form_id = get_the_ID(); |
875 | 875 | } |
876 | 876 | |
877 | - $goal = give_get_form_goal( $form_id ); |
|
877 | + $goal = give_get_form_goal($form_id); |
|
878 | 878 | |
879 | - $goal = apply_filters( 'give_form_goal', give_sanitize_amount( $goal ), $form_id ); |
|
880 | - $formatted_goal = '<span class="give_price" id="give_price_' . $form_id . '">' . $goal . '</span>'; |
|
881 | - $formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal ); |
|
879 | + $goal = apply_filters('give_form_goal', give_sanitize_amount($goal), $form_id); |
|
880 | + $formatted_goal = '<span class="give_price" id="give_price_'.$form_id.'">'.$goal.'</span>'; |
|
881 | + $formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal); |
|
882 | 882 | |
883 | - if ( $echo ) { |
|
883 | + if ($echo) { |
|
884 | 884 | echo $formatted_goal; |
885 | 885 | } else { |
886 | 886 | return $formatted_goal; |
887 | 887 | } |
888 | 888 | } |
889 | 889 | |
890 | -add_filter( 'give_form_goal', 'give_format_amount', 10 ); |
|
891 | -add_filter( 'give_form_goal', 'give_currency_filter', 20 ); |
|
890 | +add_filter('give_form_goal', 'give_format_amount', 10); |
|
891 | +add_filter('give_form_goal', 'give_currency_filter', 20); |
|
892 | 892 | |
893 | 893 | |
894 | 894 | /** |
@@ -900,15 +900,15 @@ discard block |
||
900 | 900 | * |
901 | 901 | * @return bool $ret Whether or not the logged_in_only setting is set |
902 | 902 | */ |
903 | -function give_logged_in_only( $form_id ) { |
|
903 | +function give_logged_in_only($form_id) { |
|
904 | 904 | // If _give_logged_in_only is set to enable then guest can donate from that specific form. |
905 | 905 | // Otherwise it is member only donation form. |
906 | - $val = give_get_meta( $form_id, '_give_logged_in_only', true ); |
|
907 | - $val = ! empty( $val ) ? $val : 'enabled'; |
|
906 | + $val = give_get_meta($form_id, '_give_logged_in_only', true); |
|
907 | + $val = ! empty($val) ? $val : 'enabled'; |
|
908 | 908 | |
909 | - $ret = ! give_is_setting_enabled( $val ); |
|
909 | + $ret = ! give_is_setting_enabled($val); |
|
910 | 910 | |
911 | - return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id ); |
|
911 | + return (bool) apply_filters('give_logged_in_only', $ret, $form_id); |
|
912 | 912 | } |
913 | 913 | |
914 | 914 | |
@@ -921,11 +921,11 @@ discard block |
||
921 | 921 | * |
922 | 922 | * @return string |
923 | 923 | */ |
924 | -function give_show_login_register_option( $form_id ) { |
|
924 | +function give_show_login_register_option($form_id) { |
|
925 | 925 | |
926 | - $show_register_form = give_get_meta( $form_id, '_give_show_register_form', true ); |
|
926 | + $show_register_form = give_get_meta($form_id, '_give_show_register_form', true); |
|
927 | 927 | |
928 | - return apply_filters( 'give_show_register_form', $show_register_form, $form_id ); |
|
928 | + return apply_filters('give_show_register_form', $show_register_form, $form_id); |
|
929 | 929 | |
930 | 930 | } |
931 | 931 | |
@@ -941,12 +941,12 @@ discard block |
||
941 | 941 | * |
942 | 942 | * @return array |
943 | 943 | */ |
944 | -function _give_get_prefill_form_field_values( $form_id ) { |
|
944 | +function _give_get_prefill_form_field_values($form_id) { |
|
945 | 945 | $logged_in_donor_info = array(); |
946 | 946 | |
947 | - if ( is_user_logged_in() ) : |
|
948 | - $donor_data = get_userdata( get_current_user_id() ); |
|
949 | - $donor_address = get_user_meta( get_current_user_id(), '_give_user_address', true ); |
|
947 | + if (is_user_logged_in()) : |
|
948 | + $donor_data = get_userdata(get_current_user_id()); |
|
949 | + $donor_address = get_user_meta(get_current_user_id(), '_give_user_address', true); |
|
950 | 950 | |
951 | 951 | $logged_in_donor_info = array( |
952 | 952 | // First name. |
@@ -959,42 +959,42 @@ discard block |
||
959 | 959 | 'give_email' => $donor_data->user_email, |
960 | 960 | |
961 | 961 | // Street address 1. |
962 | - 'card_address' => ( ! empty( $donor_address['line1'] ) ? $donor_address['line1'] : '' ), |
|
962 | + 'card_address' => ( ! empty($donor_address['line1']) ? $donor_address['line1'] : ''), |
|
963 | 963 | |
964 | 964 | // Street address 2. |
965 | - 'card_address_2' => ( ! empty( $donor_address['line2'] ) ? $donor_address['line2'] : '' ), |
|
965 | + 'card_address_2' => ( ! empty($donor_address['line2']) ? $donor_address['line2'] : ''), |
|
966 | 966 | |
967 | 967 | // Country. |
968 | - 'billing_country' => ( ! empty( $donor_address['country'] ) ? $donor_address['country'] : '' ), |
|
968 | + 'billing_country' => ( ! empty($donor_address['country']) ? $donor_address['country'] : ''), |
|
969 | 969 | |
970 | 970 | // State. |
971 | - 'card_state' => ( ! empty( $donor_address['state'] ) ? $donor_address['state'] : '' ), |
|
971 | + 'card_state' => ( ! empty($donor_address['state']) ? $donor_address['state'] : ''), |
|
972 | 972 | |
973 | 973 | // City. |
974 | - 'card_city' => ( ! empty( $donor_address['city'] ) ? $donor_address['city'] : '' ), |
|
974 | + 'card_city' => ( ! empty($donor_address['city']) ? $donor_address['city'] : ''), |
|
975 | 975 | |
976 | 976 | // Zipcode |
977 | - 'card_zip' => ( ! empty( $donor_address['zip'] ) ? $donor_address['zip'] : '' ), |
|
977 | + 'card_zip' => ( ! empty($donor_address['zip']) ? $donor_address['zip'] : ''), |
|
978 | 978 | ); |
979 | 979 | endif; |
980 | 980 | |
981 | 981 | // Bailout: Auto fill form field values only form form which donor is donating. |
982 | 982 | if ( |
983 | - empty( $_GET['form-id'] ) |
|
983 | + empty($_GET['form-id']) |
|
984 | 984 | || ! $form_id |
985 | - || ( $form_id !== absint( $_GET['form-id'] ) ) |
|
985 | + || ($form_id !== absint($_GET['form-id'])) |
|
986 | 986 | ) { |
987 | 987 | return $logged_in_donor_info; |
988 | 988 | } |
989 | 989 | |
990 | 990 | // Get purchase data. |
991 | - $give_purchase_data = Give()->session->get( 'give_purchase' ); |
|
991 | + $give_purchase_data = Give()->session->get('give_purchase'); |
|
992 | 992 | |
993 | 993 | // Get donor info from form data. |
994 | - $give_donor_info_in_session = empty( $give_purchase_data['post_data'] ) |
|
994 | + $give_donor_info_in_session = empty($give_purchase_data['post_data']) |
|
995 | 995 | ? array() |
996 | 996 | : $give_purchase_data['post_data']; |
997 | 997 | |
998 | 998 | // Output. |
999 | - return wp_parse_args( $give_donor_info_in_session, $logged_in_donor_info ); |
|
999 | + return wp_parse_args($give_donor_info_in_session, $logged_in_donor_info); |
|
1000 | 1000 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | |
18 | 18 | // Exit if accessed directly. |
19 | -if ( ! defined( 'ABSPATH' ) ) { |
|
19 | +if ( ! defined('ABSPATH')) { |
|
20 | 20 | exit; |
21 | 21 | } |
22 | 22 | |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | * @return void |
30 | 30 | */ |
31 | 31 | function give_reports_page() { |
32 | - $current_page = admin_url( 'edit.php?post_type=give_forms&page=give-reports' ); |
|
33 | - $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings'; |
|
32 | + $current_page = admin_url('edit.php?post_type=give_forms&page=give-reports'); |
|
33 | + $active_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings'; |
|
34 | 34 | $views = give_reports_default_views(); |
35 | 35 | ?> |
36 | 36 | <div class="wrap give-settings-page"> |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | <h1 class="screen-reader-text"><?php echo get_admin_page_title(); ?></h1> |
39 | 39 | |
40 | 40 | <h2 class="nav-tab-wrapper"> |
41 | - <?php foreach ( $views as $tab => $label ) { ?> |
|
42 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
41 | + <?php foreach ($views as $tab => $label) { ?> |
|
42 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
43 | 43 | 'tab' => $tab, |
44 | 44 | 'settings-updated' => false, |
45 | - ), $current_page ) ); ?>" class="nav-tab <?php echo $tab === $active_tab ? esc_attr( 'nav-tab-active' ) : ''; ?>"><?php echo esc_html( $label ); ?></a> |
|
45 | + ), $current_page)); ?>" class="nav-tab <?php echo $tab === $active_tab ? esc_attr('nav-tab-active') : ''; ?>"><?php echo esc_html($label); ?></a> |
|
46 | 46 | <?php } ?> |
47 | - <?php if ( current_user_can( 'export_give_reports' ) ) { ?> |
|
48 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
47 | + <?php if (current_user_can('export_give_reports')) { ?> |
|
48 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
49 | 49 | 'tab' => 'export', |
50 | 50 | 'settings-updated' => false, |
51 | - ), $current_page ) ); ?>" class="nav-tab <?php echo 'export' === $active_tab ? esc_attr( 'nav-tab-active' ) : ''; ?>"><?php esc_html_e( 'Export', 'give' ); ?></a> |
|
51 | + ), $current_page)); ?>" class="nav-tab <?php echo 'export' === $active_tab ? esc_attr('nav-tab-active') : ''; ?>"><?php esc_html_e('Export', 'give'); ?></a> |
|
52 | 52 | <?php } |
53 | 53 | /** |
54 | 54 | * Fires in the report tabs. |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @since 1.0 |
59 | 59 | */ |
60 | - do_action( 'give_reports_tabs' ); |
|
60 | + do_action('give_reports_tabs'); |
|
61 | 61 | ?> |
62 | 62 | </h2> |
63 | 63 | |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @since 1.0 |
69 | 69 | */ |
70 | - do_action( 'give_reports_page_top' ); |
|
70 | + do_action('give_reports_page_top'); |
|
71 | 71 | |
72 | 72 | // Set $active_tab prior to hook firing. |
73 | - if ( in_array( $active_tab, array_keys( $views ) ) ) { |
|
73 | + if (in_array($active_tab, array_keys($views))) { |
|
74 | 74 | $active_tab = 'reports'; |
75 | 75 | } |
76 | 76 | |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @since 1.0 |
81 | 81 | */ |
82 | - do_action( "give_reports_tab_{$active_tab}" ); |
|
82 | + do_action("give_reports_tab_{$active_tab}"); |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Fires after the report page. |
86 | 86 | * |
87 | 87 | * @since 1.0 |
88 | 88 | */ |
89 | - do_action( 'give_reports_page_bottom' ); |
|
89 | + do_action('give_reports_page_bottom'); |
|
90 | 90 | ?> |
91 | 91 | </div><!-- .wrap --> |
92 | 92 | <?php |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | */ |
101 | 101 | function give_reports_default_views() { |
102 | 102 | $views = array( |
103 | - 'earnings' => esc_html__( 'Income', 'give' ), |
|
104 | - 'forms' => esc_html__( 'Forms', 'give' ), |
|
105 | - 'donors' => esc_html__( 'Donors', 'give' ), |
|
106 | - 'gateways' => esc_html__( 'Donation Methods', 'give' ), |
|
103 | + 'earnings' => esc_html__('Income', 'give'), |
|
104 | + 'forms' => esc_html__('Forms', 'give'), |
|
105 | + 'donors' => esc_html__('Donors', 'give'), |
|
106 | + 'gateways' => esc_html__('Donation Methods', 'give'), |
|
107 | 107 | ); |
108 | 108 | |
109 | - $views = apply_filters( 'give_report_views', $views ); |
|
109 | + $views = apply_filters('give_report_views', $views); |
|
110 | 110 | |
111 | 111 | return $views; |
112 | 112 | } |
@@ -121,15 +121,15 @@ discard block |
||
121 | 121 | * @since 1.0 |
122 | 122 | * @return string $view Report View |
123 | 123 | */ |
124 | -function give_get_reporting_view( $default = 'earnings' ) { |
|
124 | +function give_get_reporting_view($default = 'earnings') { |
|
125 | 125 | |
126 | - if ( ! isset( $_GET['view'] ) || ! in_array( $_GET['view'], array_keys( give_reports_default_views() ) ) ) { |
|
126 | + if ( ! isset($_GET['view']) || ! in_array($_GET['view'], array_keys(give_reports_default_views()))) { |
|
127 | 127 | $view = $default; |
128 | 128 | } else { |
129 | 129 | $view = $_GET['view']; |
130 | 130 | } |
131 | 131 | |
132 | - return apply_filters( 'give_get_reporting_view', $view ); |
|
132 | + return apply_filters('give_get_reporting_view', $view); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $current_view = 'earnings'; |
143 | 143 | $views = give_reports_default_views(); |
144 | 144 | |
145 | - if ( isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $views ) ) { |
|
145 | + if (isset($_GET['tab']) && array_key_exists($_GET['tab'], $views)) { |
|
146 | 146 | $current_view = $_GET['tab']; |
147 | 147 | } |
148 | 148 | |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @since 1.0 |
153 | 153 | */ |
154 | - do_action( "give_reports_view_{$current_view}" ); |
|
154 | + do_action("give_reports_view_{$current_view}"); |
|
155 | 155 | } |
156 | 156 | |
157 | -add_action( 'give_reports_tab_reports', 'give_reports_tab_reports' ); |
|
157 | +add_action('give_reports_tab_reports', 'give_reports_tab_reports'); |
|
158 | 158 | |
159 | 159 | /** |
160 | 160 | * Renders the Reports Page Views Drop Downs |
@@ -164,19 +164,19 @@ discard block |
||
164 | 164 | */ |
165 | 165 | function give_report_views() { |
166 | 166 | $views = give_reports_default_views(); |
167 | - $current_view = isset( $_GET['view'] ) ? $_GET['view'] : 'earnings'; |
|
167 | + $current_view = isset($_GET['view']) ? $_GET['view'] : 'earnings'; |
|
168 | 168 | /** |
169 | 169 | * Fires before the report page actions form. |
170 | 170 | * |
171 | 171 | * @since 1.0 |
172 | 172 | */ |
173 | - do_action( 'give_report_view_actions_before' ); |
|
173 | + do_action('give_report_view_actions_before'); |
|
174 | 174 | ?> |
175 | 175 | <form id="give-reports-filter" method="get"> |
176 | 176 | <select id="give-reports-view" name="view"> |
177 | - <option value="-1"><?php esc_html_e( 'Report Type', 'give' ); ?></option> |
|
178 | - <?php foreach ( $views as $view_id => $label ) : ?> |
|
179 | - <option value="<?php echo esc_attr( $view_id ); ?>" <?php selected( $view_id, $current_view ); ?>><?php echo $label; ?></option> |
|
177 | + <option value="-1"><?php esc_html_e('Report Type', 'give'); ?></option> |
|
178 | + <?php foreach ($views as $view_id => $label) : ?> |
|
179 | + <option value="<?php echo esc_attr($view_id); ?>" <?php selected($view_id, $current_view); ?>><?php echo $label; ?></option> |
|
180 | 180 | <?php endforeach; ?> |
181 | 181 | </select> |
182 | 182 | |
@@ -188,12 +188,12 @@ discard block |
||
188 | 188 | * |
189 | 189 | * @since 1.0 |
190 | 190 | */ |
191 | - do_action( 'give_report_view_actions' ); |
|
191 | + do_action('give_report_view_actions'); |
|
192 | 192 | ?> |
193 | 193 | |
194 | 194 | <input type="hidden" name="post_type" value="give_forms"/> |
195 | 195 | <input type="hidden" name="page" value="give-reports"/> |
196 | - <?php submit_button( esc_html__( 'Show', 'give' ), 'secondary', 'submit', false ); ?> |
|
196 | + <?php submit_button(esc_html__('Show', 'give'), 'secondary', 'submit', false); ?> |
|
197 | 197 | </form> |
198 | 198 | <?php |
199 | 199 | /** |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @since 1.0 |
203 | 203 | */ |
204 | - do_action( 'give_report_view_actions_after' ); |
|
204 | + do_action('give_report_view_actions_after'); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -214,18 +214,18 @@ discard block |
||
214 | 214 | */ |
215 | 215 | function give_reports_forms_table() { |
216 | 216 | |
217 | - if ( isset( $_GET['form-id'] ) ) { |
|
217 | + if (isset($_GET['form-id'])) { |
|
218 | 218 | return; |
219 | 219 | } |
220 | 220 | |
221 | - include( dirname( __FILE__ ) . '/class-form-reports-table.php' ); |
|
221 | + include(dirname(__FILE__).'/class-form-reports-table.php'); |
|
222 | 222 | |
223 | 223 | $give_table = new Give_Form_Reports_Table(); |
224 | 224 | $give_table->prepare_items(); |
225 | 225 | $give_table->display(); |
226 | 226 | } |
227 | 227 | |
228 | -add_action( 'give_reports_view_forms', 'give_reports_forms_table' ); |
|
228 | +add_action('give_reports_view_forms', 'give_reports_forms_table'); |
|
229 | 229 | |
230 | 230 | /** |
231 | 231 | * Renders the detailed report for a specific give form |
@@ -234,20 +234,20 @@ discard block |
||
234 | 234 | * @return void |
235 | 235 | */ |
236 | 236 | function give_reports_form_details() { |
237 | - if ( ! isset( $_GET['form-id'] ) ) { |
|
237 | + if ( ! isset($_GET['form-id'])) { |
|
238 | 238 | return; |
239 | 239 | } |
240 | 240 | ?> |
241 | 241 | <div class="tablenav top reports-forms-details-wrap"> |
242 | 242 | <div class="actions bulkactions"> |
243 | - <button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e( 'Go Back', 'give' ); ?></button> |
|
243 | + <button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e('Go Back', 'give'); ?></button> |
|
244 | 244 | </div> |
245 | 245 | </div> |
246 | 246 | <?php |
247 | - give_reports_graph_of_form( absint( $_GET['form-id'] ) ); |
|
247 | + give_reports_graph_of_form(absint($_GET['form-id'])); |
|
248 | 248 | } |
249 | 249 | |
250 | -add_action( 'give_reports_view_forms', 'give_reports_form_details' ); |
|
250 | +add_action('give_reports_view_forms', 'give_reports_form_details'); |
|
251 | 251 | |
252 | 252 | /** |
253 | 253 | * Renders the Reports Donors Table |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @return void |
259 | 259 | */ |
260 | 260 | function give_reports_donors_table() { |
261 | - include( dirname( __FILE__ ) . '/class-donor-reports-table.php' ); |
|
261 | + include(dirname(__FILE__).'/class-donor-reports-table.php'); |
|
262 | 262 | |
263 | 263 | $give_table = new Give_Donor_Reports_Table(); |
264 | 264 | $give_table->prepare_items(); |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | * |
271 | 271 | * @since 1.0 |
272 | 272 | */ |
273 | - do_action( 'give_logs_donors_table_top' ); |
|
273 | + do_action('give_logs_donors_table_top'); |
|
274 | 274 | ?> |
275 | 275 | <form id="give-donors-filter" method="get"> |
276 | 276 | <?php |
277 | - $give_table->search_box( esc_html__( 'Search', 'give' ), 'give-donors' ); |
|
277 | + $give_table->search_box(esc_html__('Search', 'give'), 'give-donors'); |
|
278 | 278 | $give_table->display(); |
279 | 279 | ?> |
280 | 280 | <input type="hidden" name="post_type" value="give_forms"/> |
@@ -287,13 +287,13 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @since 1.0 |
289 | 289 | */ |
290 | - do_action( 'give_logs_donors_table_bottom' ); |
|
290 | + do_action('give_logs_donors_table_bottom'); |
|
291 | 291 | ?> |
292 | 292 | </div> |
293 | 293 | <?php |
294 | 294 | } |
295 | 295 | |
296 | -add_action( 'give_reports_view_donors', 'give_reports_donors_table' ); |
|
296 | +add_action('give_reports_view_donors', 'give_reports_donors_table'); |
|
297 | 297 | |
298 | 298 | |
299 | 299 | /** |
@@ -305,14 +305,14 @@ discard block |
||
305 | 305 | * @return void |
306 | 306 | */ |
307 | 307 | function give_reports_gateways_table() { |
308 | - include( dirname( __FILE__ ) . '/class-gateways-reports-table.php' ); |
|
308 | + include(dirname(__FILE__).'/class-gateways-reports-table.php'); |
|
309 | 309 | |
310 | 310 | $give_table = new Give_Gateway_Reports_Table(); |
311 | 311 | $give_table->prepare_items(); |
312 | 312 | $give_table->display(); |
313 | 313 | } |
314 | 314 | |
315 | -add_action( 'give_reports_view_gateways', 'give_reports_gateways_table' ); |
|
315 | +add_action('give_reports_view_gateways', 'give_reports_gateways_table'); |
|
316 | 316 | |
317 | 317 | |
318 | 318 | /** |
@@ -324,13 +324,13 @@ discard block |
||
324 | 324 | function give_reports_earnings() { |
325 | 325 | ?> |
326 | 326 | <div class="tablenav top reports-table-nav"> |
327 | - <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e( 'Income Report', 'give' ); ?></span></h3> |
|
327 | + <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e('Income Report', 'give'); ?></span></h3> |
|
328 | 328 | </div> |
329 | 329 | <?php |
330 | 330 | give_reports_graph(); |
331 | 331 | } |
332 | 332 | |
333 | -add_action( 'give_reports_view_earnings', 'give_reports_earnings' ); |
|
333 | +add_action('give_reports_view_earnings', 'give_reports_earnings'); |
|
334 | 334 | |
335 | 335 | |
336 | 336 | /** |
@@ -341,9 +341,9 @@ discard block |
||
341 | 341 | */ |
342 | 342 | function give_estimated_monthly_stats() { |
343 | 343 | |
344 | - $estimated = Give_Cache::get( 'give_estimated_monthly_stats', true ); |
|
344 | + $estimated = Give_Cache::get('give_estimated_monthly_stats', true); |
|
345 | 345 | |
346 | - if ( false === $estimated ) { |
|
346 | + if (false === $estimated) { |
|
347 | 347 | |
348 | 348 | $estimated = array( |
349 | 349 | 'earnings' => 0, |
@@ -352,22 +352,22 @@ discard block |
||
352 | 352 | |
353 | 353 | $stats = new Give_Payment_Stats; |
354 | 354 | |
355 | - $to_date_earnings = $stats->get_earnings( 0, 'this_month' ); |
|
356 | - $to_date_sales = $stats->get_sales( 0, 'this_month' ); |
|
355 | + $to_date_earnings = $stats->get_earnings(0, 'this_month'); |
|
356 | + $to_date_sales = $stats->get_sales(0, 'this_month'); |
|
357 | 357 | |
358 | - $current_day = date( 'd', current_time( 'timestamp' ) ); |
|
359 | - $current_month = date( 'n', current_time( 'timestamp' ) ); |
|
360 | - $current_year = date( 'Y', current_time( 'timestamp' ) ); |
|
361 | - $days_in_month = cal_days_in_month( CAL_GREGORIAN, $current_month, $current_year ); |
|
358 | + $current_day = date('d', current_time('timestamp')); |
|
359 | + $current_month = date('n', current_time('timestamp')); |
|
360 | + $current_year = date('Y', current_time('timestamp')); |
|
361 | + $days_in_month = cal_days_in_month(CAL_GREGORIAN, $current_month, $current_year); |
|
362 | 362 | |
363 | - $estimated['earnings'] = ( $to_date_earnings / $current_day ) * $days_in_month; |
|
364 | - $estimated['sales'] = ( $to_date_sales / $current_day ) * $days_in_month; |
|
363 | + $estimated['earnings'] = ($to_date_earnings / $current_day) * $days_in_month; |
|
364 | + $estimated['sales'] = ($to_date_sales / $current_day) * $days_in_month; |
|
365 | 365 | |
366 | 366 | // Cache for one day |
367 | - Give_Cache::set( 'give_estimated_monthly_stats', $estimated, DAY_IN_SECONDS, true ); |
|
367 | + Give_Cache::set('give_estimated_monthly_stats', $estimated, DAY_IN_SECONDS, true); |
|
368 | 368 | } |
369 | 369 | |
370 | - return maybe_unserialize( $estimated ); |
|
370 | + return maybe_unserialize($estimated); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | // @TODO: After release 1.8 Donations -> Reports generates with new setting api, so we can remove some old code from this file. |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $dates = give_get_report_dates(); |
26 | 26 | |
27 | 27 | // Determine graph options |
28 | - switch ( $dates['range'] ) : |
|
28 | + switch ($dates['range']) : |
|
29 | 29 | case 'today' : |
30 | 30 | case 'yesterday' : |
31 | 31 | $day_by_day = true; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $day_by_day = false; |
38 | 38 | break; |
39 | 39 | case 'other' : |
40 | - if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ( $dates['m_start'] != '12' && $dates['m_end'] != '1' ) ) { |
|
40 | + if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ($dates['m_start'] != '12' && $dates['m_end'] != '1')) { |
|
41 | 41 | $day_by_day = false; |
42 | 42 | } else { |
43 | 43 | $day_by_day = true; |
@@ -49,61 +49,61 @@ discard block |
||
49 | 49 | endswitch; |
50 | 50 | |
51 | 51 | $earnings_totals = 0.00; // Total earnings for time period shown |
52 | - $sales_totals = 0; // Total sales for time period shown |
|
52 | + $sales_totals = 0; // Total sales for time period shown |
|
53 | 53 | |
54 | 54 | $earnings_data = array(); |
55 | 55 | $sales_data = array(); |
56 | 56 | |
57 | - if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) { |
|
57 | + if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') { |
|
58 | 58 | // Hour by hour |
59 | 59 | $hour = 1; |
60 | - $month = date( 'n', current_time( 'timestamp' ) ); |
|
61 | - while ( $hour <= 23 ) : |
|
60 | + $month = date('n', current_time('timestamp')); |
|
61 | + while ($hour <= 23) : |
|
62 | 62 | |
63 | - $sales = give_get_sales_by_date( $dates['day'], $month, $dates['year'], $hour ); |
|
64 | - $earnings = give_get_earnings_by_date( $dates['day'], $month, $dates['year'], $hour ); |
|
63 | + $sales = give_get_sales_by_date($dates['day'], $month, $dates['year'], $hour); |
|
64 | + $earnings = give_get_earnings_by_date($dates['day'], $month, $dates['year'], $hour); |
|
65 | 65 | |
66 | 66 | $sales_totals += $sales; |
67 | 67 | $earnings_totals += $earnings; |
68 | 68 | |
69 | - $date = mktime( $hour, 0, 0, $month, $dates['day'], $dates['year'] ) * 1000; |
|
70 | - $sales_data[] = array( $date, $sales ); |
|
71 | - $earnings_data[] = array( $date, $earnings ); |
|
69 | + $date = mktime($hour, 0, 0, $month, $dates['day'], $dates['year']) * 1000; |
|
70 | + $sales_data[] = array($date, $sales); |
|
71 | + $earnings_data[] = array($date, $earnings); |
|
72 | 72 | |
73 | - $hour ++; |
|
73 | + $hour++; |
|
74 | 74 | endwhile; |
75 | 75 | |
76 | - } elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) { |
|
76 | + } elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') { |
|
77 | 77 | |
78 | 78 | // Day by day |
79 | 79 | $day = $dates['day']; |
80 | 80 | $day_end = $dates['day_end']; |
81 | 81 | $month = $dates['m_start']; |
82 | - while ( $day <= $day_end ) : |
|
83 | - $sales = give_get_sales_by_date( $day, $month, $dates['year'] ); |
|
82 | + while ($day <= $day_end) : |
|
83 | + $sales = give_get_sales_by_date($day, $month, $dates['year']); |
|
84 | 84 | $sales_totals += $sales; |
85 | 85 | |
86 | - $earnings = give_get_earnings_by_date( $day, $month, $dates['year'] ); |
|
86 | + $earnings = give_get_earnings_by_date($day, $month, $dates['year']); |
|
87 | 87 | $earnings_totals += $earnings; |
88 | 88 | |
89 | - $date = mktime( 0, 0, 0, $month, $day, $dates['year'] ) * 1000; |
|
90 | - $sales_data[] = array( $date, $sales ); |
|
91 | - $earnings_data[] = array( $date, $earnings ); |
|
92 | - $day ++; |
|
89 | + $date = mktime(0, 0, 0, $month, $day, $dates['year']) * 1000; |
|
90 | + $sales_data[] = array($date, $sales); |
|
91 | + $earnings_data[] = array($date, $earnings); |
|
92 | + $day++; |
|
93 | 93 | endwhile; |
94 | 94 | |
95 | 95 | } else { |
96 | 96 | |
97 | 97 | $y = $dates['year']; |
98 | - while ( $y <= $dates['year_end'] ) : |
|
98 | + while ($y <= $dates['year_end']) : |
|
99 | 99 | |
100 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
100 | + if ($dates['year'] == $dates['year_end']) { |
|
101 | 101 | $month_start = $dates['m_start']; |
102 | 102 | $month_end = $dates['m_end']; |
103 | - } elseif ( $y == $dates['year'] ) { |
|
103 | + } elseif ($y == $dates['year']) { |
|
104 | 104 | $month_start = $dates['m_start']; |
105 | 105 | $month_end = 12; |
106 | - } elseif ( $y == $dates['year_end'] ) { |
|
106 | + } elseif ($y == $dates['year_end']) { |
|
107 | 107 | $month_start = 1; |
108 | 108 | $month_end = $dates['m_end']; |
109 | 109 | } else { |
@@ -112,48 +112,48 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | $i = $month_start; |
115 | - while ( $i <= $month_end ) : |
|
115 | + while ($i <= $month_end) : |
|
116 | 116 | |
117 | - if ( $day_by_day ) { |
|
117 | + if ($day_by_day) { |
|
118 | 118 | |
119 | - if ( $i == $month_end ) { |
|
119 | + if ($i == $month_end) { |
|
120 | 120 | |
121 | 121 | $num_of_days = $dates['day_end']; |
122 | 122 | |
123 | 123 | } else { |
124 | 124 | |
125 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
125 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
126 | 126 | |
127 | 127 | } |
128 | 128 | |
129 | 129 | $d = $dates['day']; |
130 | 130 | |
131 | - while ( $d <= $num_of_days ) : |
|
131 | + while ($d <= $num_of_days) : |
|
132 | 132 | |
133 | - $sales = give_get_sales_by_date( $d, $i, $y ); |
|
133 | + $sales = give_get_sales_by_date($d, $i, $y); |
|
134 | 134 | $sales_totals += $sales; |
135 | 135 | |
136 | - $earnings = give_get_earnings_by_date( $d, $i, $y ); |
|
136 | + $earnings = give_get_earnings_by_date($d, $i, $y); |
|
137 | 137 | $earnings_totals += $earnings; |
138 | 138 | |
139 | - $date = mktime( 0, 0, 0, $i, $d, $y ) * 1000; |
|
140 | - $sales_data[] = array( $date, $sales ); |
|
141 | - $earnings_data[] = array( $date, $earnings ); |
|
142 | - $d ++; |
|
139 | + $date = mktime(0, 0, 0, $i, $d, $y) * 1000; |
|
140 | + $sales_data[] = array($date, $sales); |
|
141 | + $earnings_data[] = array($date, $earnings); |
|
142 | + $d++; |
|
143 | 143 | |
144 | 144 | endwhile; |
145 | 145 | |
146 | 146 | } else { |
147 | 147 | |
148 | - $sales = give_get_sales_by_date( null, $i, $y ); |
|
148 | + $sales = give_get_sales_by_date(null, $i, $y); |
|
149 | 149 | $sales_totals += $sales; |
150 | 150 | |
151 | - $earnings = give_get_earnings_by_date( null, $i, $y ); |
|
151 | + $earnings = give_get_earnings_by_date(null, $i, $y); |
|
152 | 152 | $earnings_totals += $earnings; |
153 | 153 | |
154 | - if ( $i == $month_end ) { |
|
154 | + if ($i == $month_end) { |
|
155 | 155 | |
156 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
156 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
157 | 157 | |
158 | 158 | } else { |
159 | 159 | |
@@ -161,24 +161,24 @@ discard block |
||
161 | 161 | |
162 | 162 | } |
163 | 163 | |
164 | - $date = mktime( 0, 0, 0, $i, $num_of_days, $y ) * 1000; |
|
165 | - $sales_data[] = array( $date, $sales ); |
|
166 | - $earnings_data[] = array( $date, $earnings ); |
|
164 | + $date = mktime(0, 0, 0, $i, $num_of_days, $y) * 1000; |
|
165 | + $sales_data[] = array($date, $sales); |
|
166 | + $earnings_data[] = array($date, $earnings); |
|
167 | 167 | |
168 | 168 | } |
169 | 169 | |
170 | - $i ++; |
|
170 | + $i++; |
|
171 | 171 | |
172 | 172 | endwhile; |
173 | 173 | |
174 | - $y ++; |
|
174 | + $y++; |
|
175 | 175 | endwhile; |
176 | 176 | |
177 | 177 | } |
178 | 178 | |
179 | 179 | $data = array( |
180 | - esc_html__( 'Income', 'give' ) => $earnings_data, |
|
181 | - esc_html__( 'Donations', 'give' ) => $sales_data |
|
180 | + esc_html__('Income', 'give') => $earnings_data, |
|
181 | + esc_html__('Donations', 'give') => $sales_data |
|
182 | 182 | ); |
183 | 183 | |
184 | 184 | // start our own output buffer |
@@ -191,12 +191,12 @@ discard block |
||
191 | 191 | <div class="inside"> |
192 | 192 | <?php give_reports_graph_controls(); ?> |
193 | 193 | <?php |
194 | - $graph = new Give_Graph( $data, array( 'dataType' => array( 'amount', 'count' ) ) ); |
|
195 | - $graph->set( 'x_mode', 'time' ); |
|
196 | - $graph->set( 'multiple_y_axes', true ); |
|
194 | + $graph = new Give_Graph($data, array('dataType' => array('amount', 'count'))); |
|
195 | + $graph->set('x_mode', 'time'); |
|
196 | + $graph->set('multiple_y_axes', true); |
|
197 | 197 | $graph->display(); |
198 | 198 | |
199 | - if ( 'this_month' == $dates['range'] ) { |
|
199 | + if ('this_month' == $dates['range']) { |
|
200 | 200 | $estimated = give_estimated_monthly_stats(); |
201 | 201 | } |
202 | 202 | ?> |
@@ -205,21 +205,21 @@ discard block |
||
205 | 205 | <table class="widefat reports-table alignleft" style="max-width:450px"> |
206 | 206 | <tbody> |
207 | 207 | <tr> |
208 | - <th scope="row"><strong><?php esc_html_e( 'Total income for period:', 'give' ); ?></strong></th> |
|
209 | - <td><?php echo give_currency_filter( give_format_amount( $earnings_totals ) ); ?></td> |
|
208 | + <th scope="row"><strong><?php esc_html_e('Total income for period:', 'give'); ?></strong></th> |
|
209 | + <td><?php echo give_currency_filter(give_format_amount($earnings_totals)); ?></td> |
|
210 | 210 | </tr> |
211 | 211 | <tr class="alternate"> |
212 | - <th scope="row"><strong><?php esc_html_e( 'Total donations for period:', 'give' ); ?><strong></th> |
|
212 | + <th scope="row"><strong><?php esc_html_e('Total donations for period:', 'give'); ?><strong></th> |
|
213 | 213 | <td><?php echo $sales_totals; ?></td> |
214 | 214 | </tr> |
215 | - <?php if ( 'this_month' == $dates['range'] ) : ?> |
|
215 | + <?php if ('this_month' == $dates['range']) : ?> |
|
216 | 216 | <tr> |
217 | - <th scope="row"><strong><?php esc_html_e( 'Estimated monthly income:', 'give' ); ?></strong></th> |
|
218 | - <td><?php echo give_currency_filter( give_format_amount( $estimated['earnings'] ) ); ?></td> |
|
217 | + <th scope="row"><strong><?php esc_html_e('Estimated monthly income:', 'give'); ?></strong></th> |
|
218 | + <td><?php echo give_currency_filter(give_format_amount($estimated['earnings'])); ?></td> |
|
219 | 219 | </tr> |
220 | 220 | <tr class="alternate"> |
221 | - <th scope="row"><strong><?php esc_html_e( 'Estimated monthly donations:', 'give' ); ?></strong></th> |
|
222 | - <td><?php echo floor( $estimated['sales'] ); ?></td> |
|
221 | + <th scope="row"><strong><?php esc_html_e('Estimated monthly donations:', 'give'); ?></strong></th> |
|
222 | + <td><?php echo floor($estimated['sales']); ?></td> |
|
223 | 223 | </tr> |
224 | 224 | <?php endif; ?> |
225 | 225 | </table> |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @since 1.0 |
234 | 234 | */ |
235 | - do_action( 'give_reports_graph_additional_stats' ); |
|
235 | + do_action('give_reports_graph_additional_stats'); |
|
236 | 236 | ?> |
237 | 237 | |
238 | 238 | </div> |
@@ -251,12 +251,12 @@ discard block |
||
251 | 251 | * @since 1.0 |
252 | 252 | * @return void |
253 | 253 | */ |
254 | -function give_reports_graph_of_form( $form_id = 0 ) { |
|
254 | +function give_reports_graph_of_form($form_id = 0) { |
|
255 | 255 | // Retrieve the queried dates |
256 | 256 | $dates = give_get_report_dates(); |
257 | 257 | |
258 | 258 | // Determine graph options |
259 | - switch ( $dates['range'] ) : |
|
259 | + switch ($dates['range']) : |
|
260 | 260 | case 'today' : |
261 | 261 | case 'yesterday' : |
262 | 262 | $day_by_day = true; |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | $day_by_day = false; |
275 | 275 | break; |
276 | 276 | case 'other' : |
277 | - if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] ) { |
|
277 | + if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year']) { |
|
278 | 278 | $day_by_day = false; |
279 | 279 | } else { |
280 | 280 | $day_by_day = true; |
@@ -286,75 +286,75 @@ discard block |
||
286 | 286 | endswitch; |
287 | 287 | |
288 | 288 | $earnings_totals = (float) 0.00; // Total earnings for time period shown |
289 | - $sales_totals = 0; // Total sales for time period shown |
|
289 | + $sales_totals = 0; // Total sales for time period shown |
|
290 | 290 | |
291 | 291 | $earnings_data = array(); |
292 | 292 | $sales_data = array(); |
293 | 293 | $stats = new Give_Payment_Stats; |
294 | 294 | |
295 | - if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) { |
|
295 | + if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') { |
|
296 | 296 | |
297 | 297 | // Hour by hour |
298 | 298 | $month = $dates['m_start']; |
299 | 299 | $hour = 1; |
300 | 300 | $minute = 0; |
301 | 301 | $second = 0; |
302 | - while ( $hour <= 23 ) : |
|
302 | + while ($hour <= 23) : |
|
303 | 303 | |
304 | - if ( $hour == 23 ) { |
|
304 | + if ($hour == 23) { |
|
305 | 305 | $minute = $second = 59; |
306 | 306 | } |
307 | 307 | |
308 | - $date = mktime( $hour, $minute, $second, $month, $dates['day'], $dates['year'] ); |
|
309 | - $date_end = mktime( $hour + 1, $minute, $second, $month, $dates['day'], $dates['year'] ); |
|
308 | + $date = mktime($hour, $minute, $second, $month, $dates['day'], $dates['year']); |
|
309 | + $date_end = mktime($hour + 1, $minute, $second, $month, $dates['day'], $dates['year']); |
|
310 | 310 | |
311 | - $sales = $stats->get_sales( $form_id, $date, $date_end ); |
|
311 | + $sales = $stats->get_sales($form_id, $date, $date_end); |
|
312 | 312 | $sales_totals += $sales; |
313 | 313 | |
314 | - $earnings = $stats->get_earnings( $form_id, $date, $date_end ); |
|
314 | + $earnings = $stats->get_earnings($form_id, $date, $date_end); |
|
315 | 315 | $earnings_totals += $earnings; |
316 | 316 | |
317 | - $sales_data[] = array( $date * 1000, $sales ); |
|
318 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
317 | + $sales_data[] = array($date * 1000, $sales); |
|
318 | + $earnings_data[] = array($date * 1000, $earnings); |
|
319 | 319 | |
320 | - $hour ++; |
|
320 | + $hour++; |
|
321 | 321 | endwhile; |
322 | 322 | |
323 | - } elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) { |
|
323 | + } elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') { |
|
324 | 324 | |
325 | 325 | //Day by day |
326 | 326 | $day = $dates['day']; |
327 | 327 | $day_end = $dates['day_end']; |
328 | 328 | $month = $dates['m_start']; |
329 | - while ( $day <= $day_end ) : |
|
329 | + while ($day <= $day_end) : |
|
330 | 330 | |
331 | - $date = mktime( 0, 0, 0, $month, $day, $dates['year'] ); |
|
332 | - $date_end = mktime( 0, 0, 0, $month, $day + 1, $dates['year'] ); |
|
333 | - $sales = $stats->get_sales( $form_id, $date, $date_end ); |
|
331 | + $date = mktime(0, 0, 0, $month, $day, $dates['year']); |
|
332 | + $date_end = mktime(0, 0, 0, $month, $day + 1, $dates['year']); |
|
333 | + $sales = $stats->get_sales($form_id, $date, $date_end); |
|
334 | 334 | $sales_totals += $sales; |
335 | 335 | |
336 | - $earnings = $stats->get_earnings( $form_id, $date, $date_end ); |
|
336 | + $earnings = $stats->get_earnings($form_id, $date, $date_end); |
|
337 | 337 | $earnings_totals += $earnings; |
338 | 338 | |
339 | - $sales_data[] = array( $date * 1000, $sales ); |
|
340 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
339 | + $sales_data[] = array($date * 1000, $sales); |
|
340 | + $earnings_data[] = array($date * 1000, $earnings); |
|
341 | 341 | |
342 | - $day ++; |
|
342 | + $day++; |
|
343 | 343 | endwhile; |
344 | 344 | |
345 | 345 | } else { |
346 | 346 | |
347 | 347 | $y = $dates['year']; |
348 | 348 | |
349 | - while ( $y <= $dates['year_end'] ) : |
|
349 | + while ($y <= $dates['year_end']) : |
|
350 | 350 | |
351 | 351 | $last_year = false; |
352 | 352 | |
353 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
353 | + if ($dates['year'] == $dates['year_end']) { |
|
354 | 354 | $month_start = $dates['m_start']; |
355 | 355 | $month_end = $dates['m_end']; |
356 | 356 | $last_year = true; |
357 | - } elseif ( $y == $dates['year'] ) { |
|
357 | + } elseif ($y == $dates['year']) { |
|
358 | 358 | $month_start = $dates['m_start']; |
359 | 359 | $month_end = 12; |
360 | 360 | } else { |
@@ -363,76 +363,76 @@ discard block |
||
363 | 363 | } |
364 | 364 | |
365 | 365 | $i = $month_start; |
366 | - while ( $i <= $month_end ) : |
|
366 | + while ($i <= $month_end) : |
|
367 | 367 | |
368 | - if ( $day_by_day ) { |
|
368 | + if ($day_by_day) { |
|
369 | 369 | |
370 | - if ( $i == $month_end && $last_year ) { |
|
370 | + if ($i == $month_end && $last_year) { |
|
371 | 371 | |
372 | 372 | $num_of_days = $dates['day_end']; |
373 | 373 | |
374 | 374 | } else { |
375 | 375 | |
376 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
376 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
377 | 377 | |
378 | 378 | } |
379 | 379 | |
380 | 380 | $d = $dates['day']; |
381 | - while ( $d <= $num_of_days ) : |
|
381 | + while ($d <= $num_of_days) : |
|
382 | 382 | |
383 | - $date = mktime( 0, 0, 0, $i, $d, $y ); |
|
384 | - $end_date = mktime( 23, 59, 59, $i, $d, $y ); |
|
383 | + $date = mktime(0, 0, 0, $i, $d, $y); |
|
384 | + $end_date = mktime(23, 59, 59, $i, $d, $y); |
|
385 | 385 | |
386 | - $sales = $stats->get_sales( $form_id, $date, $end_date ); |
|
386 | + $sales = $stats->get_sales($form_id, $date, $end_date); |
|
387 | 387 | $sales_totals += $sales; |
388 | 388 | |
389 | - $earnings = $stats->get_earnings( $form_id, $date, $end_date ); |
|
389 | + $earnings = $stats->get_earnings($form_id, $date, $end_date); |
|
390 | 390 | $earnings_totals += $earnings; |
391 | 391 | |
392 | - $sales_data[] = array( $date * 1000, $sales ); |
|
393 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
394 | - $d ++; |
|
392 | + $sales_data[] = array($date * 1000, $sales); |
|
393 | + $earnings_data[] = array($date * 1000, $earnings); |
|
394 | + $d++; |
|
395 | 395 | |
396 | 396 | endwhile; |
397 | 397 | |
398 | 398 | } else { |
399 | 399 | |
400 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
400 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
401 | 401 | |
402 | - $date = mktime( 0, 0, 0, $i, 1, $y ); |
|
403 | - $end_date = mktime( 23, 59, 59, $i, $num_of_days, $y ); |
|
402 | + $date = mktime(0, 0, 0, $i, 1, $y); |
|
403 | + $end_date = mktime(23, 59, 59, $i, $num_of_days, $y); |
|
404 | 404 | |
405 | - $sales = $stats->get_sales( $form_id, $date, $end_date ); |
|
405 | + $sales = $stats->get_sales($form_id, $date, $end_date); |
|
406 | 406 | $sales_totals += $sales; |
407 | 407 | |
408 | - $earnings = $stats->get_earnings( $form_id, $date, $end_date ); |
|
408 | + $earnings = $stats->get_earnings($form_id, $date, $end_date); |
|
409 | 409 | $earnings_totals += $earnings; |
410 | 410 | |
411 | - $sales_data[] = array( $date * 1000, $sales ); |
|
412 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
411 | + $sales_data[] = array($date * 1000, $sales); |
|
412 | + $earnings_data[] = array($date * 1000, $earnings); |
|
413 | 413 | |
414 | 414 | } |
415 | 415 | |
416 | - $i ++; |
|
416 | + $i++; |
|
417 | 417 | |
418 | 418 | endwhile; |
419 | 419 | |
420 | - $y ++; |
|
420 | + $y++; |
|
421 | 421 | endwhile; |
422 | 422 | |
423 | 423 | } |
424 | 424 | |
425 | 425 | $data = array( |
426 | - esc_html__( 'Income', 'give' ) => $earnings_data, |
|
427 | - esc_html__( 'Donations', 'give' ) => $sales_data |
|
426 | + esc_html__('Income', 'give') => $earnings_data, |
|
427 | + esc_html__('Donations', 'give') => $sales_data |
|
428 | 428 | ); |
429 | 429 | |
430 | 430 | ?> |
431 | 431 | <h3><span><?php |
432 | 432 | printf( |
433 | 433 | /* translators: %s: form title */ |
434 | - esc_html__( 'Income Report for %s', 'give' ), |
|
435 | - get_the_title( $form_id ) |
|
434 | + esc_html__('Income Report for %s', 'give'), |
|
435 | + get_the_title($form_id) |
|
436 | 436 | ); |
437 | 437 | ?></span></h3> |
438 | 438 | <div id="give-dashboard-widgets-wrap"> |
@@ -441,9 +441,9 @@ discard block |
||
441 | 441 | <div class="inside"> |
442 | 442 | <?php give_reports_graph_controls(); ?> |
443 | 443 | <?php |
444 | - $graph = new Give_Graph( $data, array( 'dataType' => array( 'amount', 'count' ) ) ); |
|
445 | - $graph->set( 'x_mode', 'time' ); |
|
446 | - $graph->set( 'multiple_y_axes', true ); |
|
444 | + $graph = new Give_Graph($data, array('dataType' => array('amount', 'count'))); |
|
445 | + $graph->set('x_mode', 'time'); |
|
446 | + $graph->set('multiple_y_axes', true); |
|
447 | 447 | $graph->display(); |
448 | 448 | ?> |
449 | 449 | </div> |
@@ -452,20 +452,20 @@ discard block |
||
452 | 452 | <table class="widefat reports-table alignleft" style="max-width:450px"> |
453 | 453 | <tbody> |
454 | 454 | <tr> |
455 | - <th scope="row"><strong><?php esc_html_e( 'Total income for period:', 'give' ); ?></strong></th> |
|
456 | - <td><?php echo give_currency_filter( give_format_amount( $earnings_totals ) ); ?></td> |
|
455 | + <th scope="row"><strong><?php esc_html_e('Total income for period:', 'give'); ?></strong></th> |
|
456 | + <td><?php echo give_currency_filter(give_format_amount($earnings_totals)); ?></td> |
|
457 | 457 | </tr> |
458 | 458 | <tr class="alternate"> |
459 | - <th scope="row"><strong><?php esc_html_e( 'Total donations for period:', 'give' ); ?></strong></th> |
|
459 | + <th scope="row"><strong><?php esc_html_e('Total donations for period:', 'give'); ?></strong></th> |
|
460 | 460 | <td><?php echo $sales_totals; ?></td> |
461 | 461 | </tr> |
462 | 462 | <tr> |
463 | - <th scope="row"><strong><?php esc_html_e( 'Average monthly income:', 'give' ); ?></strong></th> |
|
464 | - <td><?php echo give_currency_filter( give_format_amount( give_get_average_monthly_form_earnings( $form_id ) ) ); ?></td> |
|
463 | + <th scope="row"><strong><?php esc_html_e('Average monthly income:', 'give'); ?></strong></th> |
|
464 | + <td><?php echo give_currency_filter(give_format_amount(give_get_average_monthly_form_earnings($form_id))); ?></td> |
|
465 | 465 | </tr> |
466 | 466 | <tr class="alternate"> |
467 | - <th scope="row"><strong><?php esc_html_e( 'Average monthly donations:', 'give' ); ?></strong></th> |
|
468 | - <td><?php echo number_format( give_get_average_monthly_form_sales( $form_id ), 0 ); ?></td> |
|
467 | + <th scope="row"><strong><?php esc_html_e('Average monthly donations:', 'give'); ?></strong></th> |
|
468 | + <td><?php echo number_format(give_get_average_monthly_form_sales($form_id), 0); ?></td> |
|
469 | 469 | </tr> |
470 | 470 | </tbody> |
471 | 471 | </table> |
@@ -484,26 +484,26 @@ discard block |
||
484 | 484 | * @return void |
485 | 485 | */ |
486 | 486 | function give_reports_graph_controls() { |
487 | - $date_options = apply_filters( 'give_report_date_options', array( |
|
488 | - 'today' => esc_html__( 'Today', 'give' ), |
|
489 | - 'yesterday' => esc_html__( 'Yesterday', 'give' ), |
|
490 | - 'this_week' => esc_html__( 'This Week', 'give' ), |
|
491 | - 'last_week' => esc_html__( 'Last Week', 'give' ), |
|
492 | - 'this_month' => esc_html__( 'This Month', 'give' ), |
|
493 | - 'last_month' => esc_html__( 'Last Month', 'give' ), |
|
494 | - 'this_quarter' => esc_html__( 'This Quarter', 'give' ), |
|
495 | - 'last_quarter' => esc_html__( 'Last Quarter', 'give' ), |
|
496 | - 'this_year' => esc_html__( 'This Year', 'give' ), |
|
497 | - 'last_year' => esc_html__( 'Last Year', 'give' ), |
|
498 | - 'other' => esc_html__( 'Custom', 'give' ) |
|
499 | - ) ); |
|
487 | + $date_options = apply_filters('give_report_date_options', array( |
|
488 | + 'today' => esc_html__('Today', 'give'), |
|
489 | + 'yesterday' => esc_html__('Yesterday', 'give'), |
|
490 | + 'this_week' => esc_html__('This Week', 'give'), |
|
491 | + 'last_week' => esc_html__('Last Week', 'give'), |
|
492 | + 'this_month' => esc_html__('This Month', 'give'), |
|
493 | + 'last_month' => esc_html__('Last Month', 'give'), |
|
494 | + 'this_quarter' => esc_html__('This Quarter', 'give'), |
|
495 | + 'last_quarter' => esc_html__('Last Quarter', 'give'), |
|
496 | + 'this_year' => esc_html__('This Year', 'give'), |
|
497 | + 'last_year' => esc_html__('Last Year', 'give'), |
|
498 | + 'other' => esc_html__('Custom', 'give') |
|
499 | + )); |
|
500 | 500 | |
501 | 501 | $dates = give_get_report_dates(); |
502 | 502 | $display = $dates['range'] == 'other' ? '' : 'display: none;'; |
503 | - $tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings'; |
|
503 | + $tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings'; |
|
504 | 504 | |
505 | - if ( empty( $dates['day_end'] ) ) { |
|
506 | - $dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, date( 'n' ), date( 'Y' ) ); |
|
505 | + if (empty($dates['day_end'])) { |
|
506 | + $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, date('n'), date('Y')); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | /** |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | * |
512 | 512 | * @since 1.0 |
513 | 513 | */ |
514 | - do_action( 'give_report_graph_controls_before' ); |
|
514 | + do_action('give_report_graph_controls_before'); |
|
515 | 515 | ?> |
516 | 516 | <form id="give-graphs-filter" method="get"> |
517 | 517 | <div class="tablenav top"> |
@@ -519,56 +519,56 @@ discard block |
||
519 | 519 | |
520 | 520 | <input type="hidden" name="post_type" value="give_forms" /> |
521 | 521 | <input type="hidden" name="page" value="give-reports" /> |
522 | - <input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" /> |
|
522 | + <input type="hidden" name="tab" value="<?php echo esc_attr($tab); ?>" /> |
|
523 | 523 | |
524 | - <?php if ( isset( $_GET['form-id'] ) ) : ?> |
|
525 | - <input type="hidden" name="form-id" value="<?php echo absint( $_GET['form-id'] ); ?>" /> |
|
524 | + <?php if (isset($_GET['form-id'])) : ?> |
|
525 | + <input type="hidden" name="form-id" value="<?php echo absint($_GET['form-id']); ?>" /> |
|
526 | 526 | <?php endif; ?> |
527 | 527 | |
528 | 528 | <div id="give-graphs-date-options-wrap"> |
529 | 529 | <select id="give-graphs-date-options" name="range"> |
530 | - <?php foreach ( $date_options as $key => $option ) : ?> |
|
531 | - <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $dates['range'] ); ?>><?php echo esc_html( $option ); ?></option> |
|
530 | + <?php foreach ($date_options as $key => $option) : ?> |
|
531 | + <option value="<?php echo esc_attr($key); ?>"<?php selected($key, $dates['range']); ?>><?php echo esc_html($option); ?></option> |
|
532 | 532 | <?php endforeach; ?> |
533 | 533 | </select> |
534 | 534 | |
535 | - <div id="give-date-range-options" style="<?php echo esc_attr( $display ); ?>"> |
|
536 | - <span class="screen-reader-text"><?php esc_html_e( 'From', 'give' ); ?> </span> |
|
535 | + <div id="give-date-range-options" style="<?php echo esc_attr($display); ?>"> |
|
536 | + <span class="screen-reader-text"><?php esc_html_e('From', 'give'); ?> </span> |
|
537 | 537 | <select id="give-graphs-month-start" name="m_start" aria-label="Start Month"> |
538 | - <?php for ( $i = 1; $i <= 12; $i ++ ) : ?> |
|
539 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['m_start'] ) ); ?>><?php echo esc_html( give_month_num_to_name( $i ) ); ?></option> |
|
538 | + <?php for ($i = 1; $i <= 12; $i++) : ?> |
|
539 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['m_start'])); ?>><?php echo esc_html(give_month_num_to_name($i)); ?></option> |
|
540 | 540 | <?php endfor; ?> |
541 | 541 | </select> |
542 | 542 | <select id="give-graphs-day-start" name="day" aria-label="Start Day"> |
543 | - <?php for ( $i = 1; $i <= 31; $i ++ ) : ?> |
|
544 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['day'] ) ); ?>><?php echo esc_html( $i ); ?></option> |
|
543 | + <?php for ($i = 1; $i <= 31; $i++) : ?> |
|
544 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['day'])); ?>><?php echo esc_html($i); ?></option> |
|
545 | 545 | <?php endfor; ?> |
546 | 546 | </select> |
547 | 547 | <select id="give-graphs-year-start" name="year" aria-label="Start Year"> |
548 | - <?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?> |
|
549 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['year'] ) ); ?>><?php echo esc_html( $i ); ?></option> |
|
548 | + <?php for ($i = 2007; $i <= date('Y'); $i++) : ?> |
|
549 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['year'])); ?>><?php echo esc_html($i); ?></option> |
|
550 | 550 | <?php endfor; ?> |
551 | 551 | </select> |
552 | - <span class="screen-reader-text"><?php esc_html_e( 'To', 'give' ); ?> </span> |
|
552 | + <span class="screen-reader-text"><?php esc_html_e('To', 'give'); ?> </span> |
|
553 | 553 | <span>–</span> |
554 | 554 | <select id="give-graphs-month-end" name="m_end" aria-label="End Month"> |
555 | - <?php for ( $i = 1; $i <= 12; $i ++ ) : ?> |
|
556 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['m_end'] ) ); ?>><?php echo esc_html( give_month_num_to_name( $i ) ); ?></option> |
|
555 | + <?php for ($i = 1; $i <= 12; $i++) : ?> |
|
556 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['m_end'])); ?>><?php echo esc_html(give_month_num_to_name($i)); ?></option> |
|
557 | 557 | <?php endfor; ?> |
558 | 558 | </select> |
559 | 559 | <select id="give-graphs-day-end" name="day_end" aria-label="End Day"> |
560 | - <?php for ( $i = 1; $i <= 31; $i ++ ) : ?> |
|
561 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['day_end'] ) ); ?>><?php echo esc_html( $i ); ?></option> |
|
560 | + <?php for ($i = 1; $i <= 31; $i++) : ?> |
|
561 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['day_end'])); ?>><?php echo esc_html($i); ?></option> |
|
562 | 562 | <?php endfor; ?> |
563 | 563 | </select> |
564 | 564 | <select id="give-graphs-year-end" name="year_end" aria-label="End Year"> |
565 | - <?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?> |
|
566 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['year_end'] ) ); ?>><?php echo esc_html( $i ); ?></option> |
|
565 | + <?php for ($i = 2007; $i <= date('Y'); $i++) : ?> |
|
566 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['year_end'])); ?>><?php echo esc_html($i); ?></option> |
|
567 | 567 | <?php endfor; ?> |
568 | 568 | </select> |
569 | 569 | </div> |
570 | 570 | |
571 | - <input type="submit" class="button-secondary" value="<?php esc_attr_e( 'Filter', 'give' ); ?>" /> |
|
571 | + <input type="submit" class="button-secondary" value="<?php esc_attr_e('Filter', 'give'); ?>" /> |
|
572 | 572 | </div> |
573 | 573 | |
574 | 574 | <input type="hidden" name="give_action" value="filter_reports" /> |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | * |
582 | 582 | * @since 1.0 |
583 | 583 | */ |
584 | - do_action( 'give_report_graph_controls_after' ); |
|
584 | + do_action('give_report_graph_controls_after'); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | /** |
@@ -596,65 +596,65 @@ discard block |
||
596 | 596 | function give_get_report_dates() { |
597 | 597 | $dates = array(); |
598 | 598 | |
599 | - $current_time = current_time( 'timestamp' ); |
|
599 | + $current_time = current_time('timestamp'); |
|
600 | 600 | |
601 | - $dates['range'] = isset( $_GET['range'] ) ? $_GET['range'] : 'this_month'; |
|
602 | - $dates['year'] = isset( $_GET['year'] ) ? $_GET['year'] : date( 'Y' ); |
|
603 | - $dates['year_end'] = isset( $_GET['year_end'] ) ? $_GET['year_end'] : date( 'Y' ); |
|
604 | - $dates['m_start'] = isset( $_GET['m_start'] ) ? $_GET['m_start'] : 1; |
|
605 | - $dates['m_end'] = isset( $_GET['m_end'] ) ? $_GET['m_end'] : 12; |
|
606 | - $dates['day'] = isset( $_GET['day'] ) ? $_GET['day'] : 1; |
|
607 | - $dates['day_end'] = isset( $_GET['day_end'] ) ? $_GET['day_end'] : cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] ); |
|
601 | + $dates['range'] = isset($_GET['range']) ? $_GET['range'] : 'this_month'; |
|
602 | + $dates['year'] = isset($_GET['year']) ? $_GET['year'] : date('Y'); |
|
603 | + $dates['year_end'] = isset($_GET['year_end']) ? $_GET['year_end'] : date('Y'); |
|
604 | + $dates['m_start'] = isset($_GET['m_start']) ? $_GET['m_start'] : 1; |
|
605 | + $dates['m_end'] = isset($_GET['m_end']) ? $_GET['m_end'] : 12; |
|
606 | + $dates['day'] = isset($_GET['day']) ? $_GET['day'] : 1; |
|
607 | + $dates['day_end'] = isset($_GET['day_end']) ? $_GET['day_end'] : cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']); |
|
608 | 608 | |
609 | 609 | // Modify dates based on predefined ranges |
610 | - switch ( $dates['range'] ) : |
|
610 | + switch ($dates['range']) : |
|
611 | 611 | |
612 | 612 | case 'this_month' : |
613 | - $dates['m_start'] = date( 'n', $current_time ); |
|
614 | - $dates['m_end'] = date( 'n', $current_time ); |
|
613 | + $dates['m_start'] = date('n', $current_time); |
|
614 | + $dates['m_end'] = date('n', $current_time); |
|
615 | 615 | $dates['day'] = 1; |
616 | - $dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] ); |
|
617 | - $dates['year'] = date( 'Y' ); |
|
618 | - $dates['year_end'] = date( 'Y' ); |
|
616 | + $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']); |
|
617 | + $dates['year'] = date('Y'); |
|
618 | + $dates['year_end'] = date('Y'); |
|
619 | 619 | break; |
620 | 620 | |
621 | 621 | case 'last_month' : |
622 | - if ( date( 'n' ) == 1 ) { |
|
622 | + if (date('n') == 1) { |
|
623 | 623 | $dates['m_start'] = 12; |
624 | 624 | $dates['m_end'] = 12; |
625 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
626 | - $dates['year_end'] = date( 'Y', $current_time ) - 1; |
|
625 | + $dates['year'] = date('Y', $current_time) - 1; |
|
626 | + $dates['year_end'] = date('Y', $current_time) - 1; |
|
627 | 627 | } else { |
628 | - $dates['m_start'] = date( 'n' ) - 1; |
|
629 | - $dates['m_end'] = date( 'n' ) - 1; |
|
628 | + $dates['m_start'] = date('n') - 1; |
|
629 | + $dates['m_end'] = date('n') - 1; |
|
630 | 630 | $dates['year_end'] = $dates['year']; |
631 | 631 | } |
632 | - $dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] ); |
|
632 | + $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']); |
|
633 | 633 | break; |
634 | 634 | |
635 | 635 | case 'today' : |
636 | - $dates['day'] = date( 'd', $current_time ); |
|
637 | - $dates['m_start'] = date( 'n', $current_time ); |
|
638 | - $dates['m_end'] = date( 'n', $current_time ); |
|
639 | - $dates['year'] = date( 'Y', $current_time ); |
|
636 | + $dates['day'] = date('d', $current_time); |
|
637 | + $dates['m_start'] = date('n', $current_time); |
|
638 | + $dates['m_end'] = date('n', $current_time); |
|
639 | + $dates['year'] = date('Y', $current_time); |
|
640 | 640 | break; |
641 | 641 | |
642 | 642 | case 'yesterday' : |
643 | 643 | |
644 | - $year = date( 'Y', $current_time ); |
|
645 | - $month = date( 'n', $current_time ); |
|
646 | - $day = date( 'd', $current_time ); |
|
644 | + $year = date('Y', $current_time); |
|
645 | + $month = date('n', $current_time); |
|
646 | + $day = date('d', $current_time); |
|
647 | 647 | |
648 | - if ( $month == 1 && $day == 1 ) { |
|
648 | + if ($month == 1 && $day == 1) { |
|
649 | 649 | |
650 | 650 | $year -= 1; |
651 | 651 | $month = 12; |
652 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
652 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
653 | 653 | |
654 | - } elseif ( $month > 1 && $day == 1 ) { |
|
654 | + } elseif ($month > 1 && $day == 1) { |
|
655 | 655 | |
656 | 656 | $month -= 1; |
657 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
657 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
658 | 658 | |
659 | 659 | } else { |
660 | 660 | |
@@ -670,91 +670,91 @@ discard block |
||
670 | 670 | break; |
671 | 671 | |
672 | 672 | case 'this_week' : |
673 | - $dates['day'] = date( 'd', $current_time - ( date( 'w', $current_time ) - 1 ) * 60 * 60 * 24 ) - 1; |
|
674 | - $dates['day'] += get_option( 'start_of_week' ); |
|
673 | + $dates['day'] = date('d', $current_time - (date('w', $current_time) - 1) * 60 * 60 * 24) - 1; |
|
674 | + $dates['day'] += get_option('start_of_week'); |
|
675 | 675 | $dates['day_end'] = $dates['day'] + 6; |
676 | - $dates['m_start'] = date( 'n', $current_time ); |
|
677 | - $dates['m_end'] = date( 'n', $current_time ); |
|
678 | - $dates['year'] = date( 'Y', $current_time ); |
|
676 | + $dates['m_start'] = date('n', $current_time); |
|
677 | + $dates['m_end'] = date('n', $current_time); |
|
678 | + $dates['year'] = date('Y', $current_time); |
|
679 | 679 | break; |
680 | 680 | |
681 | 681 | case 'last_week' : |
682 | - $dates['day'] = date( 'd', $current_time - ( date( 'w' ) - 1 ) * 60 * 60 * 24 ) - 8; |
|
683 | - $dates['day'] += get_option( 'start_of_week' ); |
|
682 | + $dates['day'] = date('d', $current_time - (date('w') - 1) * 60 * 60 * 24) - 8; |
|
683 | + $dates['day'] += get_option('start_of_week'); |
|
684 | 684 | $dates['day_end'] = $dates['day'] + 6; |
685 | - $dates['year'] = date( 'Y' ); |
|
686 | - |
|
687 | - if ( date( 'j', $current_time ) <= 7 ) { |
|
688 | - $dates['m_start'] = date( 'n', $current_time ) - 1; |
|
689 | - $dates['m_end'] = date( 'n', $current_time ) - 1; |
|
690 | - if ( $dates['m_start'] <= 1 ) { |
|
691 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
692 | - $dates['year_end'] = date( 'Y', $current_time ) - 1; |
|
685 | + $dates['year'] = date('Y'); |
|
686 | + |
|
687 | + if (date('j', $current_time) <= 7) { |
|
688 | + $dates['m_start'] = date('n', $current_time) - 1; |
|
689 | + $dates['m_end'] = date('n', $current_time) - 1; |
|
690 | + if ($dates['m_start'] <= 1) { |
|
691 | + $dates['year'] = date('Y', $current_time) - 1; |
|
692 | + $dates['year_end'] = date('Y', $current_time) - 1; |
|
693 | 693 | } |
694 | 694 | } else { |
695 | - $dates['m_start'] = date( 'n', $current_time ); |
|
696 | - $dates['m_end'] = date( 'n', $current_time ); |
|
695 | + $dates['m_start'] = date('n', $current_time); |
|
696 | + $dates['m_end'] = date('n', $current_time); |
|
697 | 697 | } |
698 | 698 | break; |
699 | 699 | |
700 | 700 | case 'this_quarter' : |
701 | - $month_now = date( 'n', $current_time ); |
|
701 | + $month_now = date('n', $current_time); |
|
702 | 702 | |
703 | - if ( $month_now <= 3 ) { |
|
703 | + if ($month_now <= 3) { |
|
704 | 704 | |
705 | 705 | $dates['m_start'] = 1; |
706 | 706 | $dates['m_end'] = 4; |
707 | - $dates['year'] = date( 'Y', $current_time ); |
|
707 | + $dates['year'] = date('Y', $current_time); |
|
708 | 708 | |
709 | - } else if ( $month_now <= 6 ) { |
|
709 | + } else if ($month_now <= 6) { |
|
710 | 710 | |
711 | 711 | $dates['m_start'] = 4; |
712 | 712 | $dates['m_end'] = 7; |
713 | - $dates['year'] = date( 'Y', $current_time ); |
|
713 | + $dates['year'] = date('Y', $current_time); |
|
714 | 714 | |
715 | - } else if ( $month_now <= 9 ) { |
|
715 | + } else if ($month_now <= 9) { |
|
716 | 716 | |
717 | 717 | $dates['m_start'] = 7; |
718 | 718 | $dates['m_end'] = 10; |
719 | - $dates['year'] = date( 'Y', $current_time ); |
|
719 | + $dates['year'] = date('Y', $current_time); |
|
720 | 720 | |
721 | 721 | } else { |
722 | 722 | |
723 | 723 | $dates['m_start'] = 10; |
724 | 724 | $dates['m_end'] = 1; |
725 | - $dates['year'] = date( 'Y', $current_time ); |
|
726 | - $dates['year_end'] = date( 'Y', $current_time ) + 1; |
|
725 | + $dates['year'] = date('Y', $current_time); |
|
726 | + $dates['year_end'] = date('Y', $current_time) + 1; |
|
727 | 727 | |
728 | 728 | } |
729 | 729 | break; |
730 | 730 | |
731 | 731 | case 'last_quarter' : |
732 | - $month_now = date( 'n' ); |
|
732 | + $month_now = date('n'); |
|
733 | 733 | |
734 | - if ( $month_now <= 3 ) { |
|
734 | + if ($month_now <= 3) { |
|
735 | 735 | |
736 | 736 | $dates['m_start'] = 10; |
737 | 737 | $dates['m_end'] = 12; |
738 | - $dates['year'] = date( 'Y', $current_time ) - 1; // Previous year |
|
739 | - $dates['year_end'] = date( 'Y', $current_time ) - 1; // Previous year |
|
738 | + $dates['year'] = date('Y', $current_time) - 1; // Previous year |
|
739 | + $dates['year_end'] = date('Y', $current_time) - 1; // Previous year |
|
740 | 740 | |
741 | - } else if ( $month_now <= 6 ) { |
|
741 | + } else if ($month_now <= 6) { |
|
742 | 742 | |
743 | 743 | $dates['m_start'] = 1; |
744 | 744 | $dates['m_end'] = 3; |
745 | - $dates['year'] = date( 'Y', $current_time ); |
|
745 | + $dates['year'] = date('Y', $current_time); |
|
746 | 746 | |
747 | - } else if ( $month_now <= 9 ) { |
|
747 | + } else if ($month_now <= 9) { |
|
748 | 748 | |
749 | 749 | $dates['m_start'] = 4; |
750 | 750 | $dates['m_end'] = 6; |
751 | - $dates['year'] = date( 'Y', $current_time ); |
|
751 | + $dates['year'] = date('Y', $current_time); |
|
752 | 752 | |
753 | 753 | } else { |
754 | 754 | |
755 | 755 | $dates['m_start'] = 7; |
756 | 756 | $dates['m_end'] = 9; |
757 | - $dates['year'] = date( 'Y', $current_time ); |
|
757 | + $dates['year'] = date('Y', $current_time); |
|
758 | 758 | |
759 | 759 | } |
760 | 760 | break; |
@@ -762,19 +762,19 @@ discard block |
||
762 | 762 | case 'this_year' : |
763 | 763 | $dates['m_start'] = 1; |
764 | 764 | $dates['m_end'] = 12; |
765 | - $dates['year'] = date( 'Y', $current_time ); |
|
765 | + $dates['year'] = date('Y', $current_time); |
|
766 | 766 | break; |
767 | 767 | |
768 | 768 | case 'last_year' : |
769 | 769 | $dates['m_start'] = 1; |
770 | 770 | $dates['m_end'] = 12; |
771 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
772 | - $dates['year_end'] = date( 'Y', $current_time ) - 1; |
|
771 | + $dates['year'] = date('Y', $current_time) - 1; |
|
772 | + $dates['year_end'] = date('Y', $current_time) - 1; |
|
773 | 773 | break; |
774 | 774 | |
775 | 775 | endswitch; |
776 | 776 | |
777 | - return apply_filters( 'give_report_dates', $dates ); |
|
777 | + return apply_filters('give_report_dates', $dates); |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | /** |
@@ -785,18 +785,18 @@ discard block |
||
785 | 785 | * |
786 | 786 | * @param $data |
787 | 787 | */ |
788 | -function give_parse_report_dates( $data ) { |
|
788 | +function give_parse_report_dates($data) { |
|
789 | 789 | $dates = give_get_report_dates(); |
790 | 790 | |
791 | 791 | $view = give_get_reporting_view(); |
792 | - $tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings'; |
|
793 | - $id = isset( $_GET['form-id'] ) ? $_GET['form-id'] : null; |
|
792 | + $tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings'; |
|
793 | + $id = isset($_GET['form-id']) ? $_GET['form-id'] : null; |
|
794 | 794 | |
795 | - wp_redirect( add_query_arg( $dates, admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=' . esc_attr( $tab ) . '&view=' . esc_attr( $view ) . '&form-id=' . absint( $id ) ) ) ); |
|
795 | + wp_redirect(add_query_arg($dates, admin_url('edit.php?post_type=give_forms&page=give-reports&tab='.esc_attr($tab).'&view='.esc_attr($view).'&form-id='.absint($id)))); |
|
796 | 796 | give_die(); |
797 | 797 | } |
798 | 798 | |
799 | -add_action( 'give_filter_reports', 'give_parse_report_dates' ); |
|
799 | +add_action('give_filter_reports', 'give_parse_report_dates'); |
|
800 | 800 | |
801 | 801 | |
802 | 802 | /** |
@@ -808,22 +808,22 @@ discard block |
||
808 | 808 | */ |
809 | 809 | function give_reports_refresh_button() { |
810 | 810 | |
811 | - $url = wp_nonce_url( add_query_arg( array( |
|
811 | + $url = wp_nonce_url(add_query_arg(array( |
|
812 | 812 | 'give_action' => 'refresh_reports_transients', |
813 | 813 | 'give-message' => 'refreshed-reports' |
814 | - ) ), 'give-refresh-reports' ); |
|
814 | + )), 'give-refresh-reports'); |
|
815 | 815 | |
816 | 816 | echo '<a href="' |
817 | - . esc_url_raw( $url ) |
|
818 | - . '" data-tooltip="'. esc_attr__( 'Clicking this will clear the reports cache.', 'give' ) |
|
817 | + . esc_url_raw($url) |
|
818 | + . '" data-tooltip="'.esc_attr__('Clicking this will clear the reports cache.', 'give') |
|
819 | 819 | . '" data-tooltip-my-position="right center" data-tooltip-target-position="left center" class="button alignright give-admin-button give-tooltip">' |
820 | 820 | . '<span class="give-admin-button-icon give-admin-button-icon-update"></span>' |
821 | - . esc_html__( 'Refresh Report Data', 'give' ) |
|
821 | + . esc_html__('Refresh Report Data', 'give') |
|
822 | 822 | . '</a>'; |
823 | 823 | |
824 | 824 | } |
825 | 825 | |
826 | -add_action( 'give_reports_graph_additional_stats', 'give_reports_refresh_button' ); |
|
826 | +add_action('give_reports_graph_additional_stats', 'give_reports_refresh_button'); |
|
827 | 827 | |
828 | 828 | /** |
829 | 829 | * Trigger the refresh of reports transients |
@@ -834,20 +834,20 @@ discard block |
||
834 | 834 | * |
835 | 835 | * @return void |
836 | 836 | */ |
837 | -function give_run_refresh_reports_transients( $data ) { |
|
837 | +function give_run_refresh_reports_transients($data) { |
|
838 | 838 | |
839 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give-refresh-reports' ) ) { |
|
839 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give-refresh-reports')) { |
|
840 | 840 | return; |
841 | 841 | } |
842 | 842 | |
843 | 843 | // Monthly stats. |
844 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
844 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
845 | 845 | |
846 | 846 | // Total earning. |
847 | - delete_option( 'give_earnings_total' ); |
|
847 | + delete_option('give_earnings_total'); |
|
848 | 848 | |
849 | 849 | // @todo: Refresh only range related stat cache |
850 | 850 | give_delete_donation_stats(); |
851 | 851 | } |
852 | 852 | |
853 | -add_action( 'give_refresh_reports_transients', 'give_run_refresh_reports_transients' ); |
|
854 | 853 | \ No newline at end of file |
854 | +add_action('give_refresh_reports_transients', 'give_run_refresh_reports_transients'); |
|
855 | 855 | \ No newline at end of file |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -81,15 +81,15 @@ discard block |
||
81 | 81 | * @param array $_data |
82 | 82 | * @param array $options |
83 | 83 | */ |
84 | - public function __construct( $_data, $options = array() ) { |
|
84 | + public function __construct($_data, $options = array()) { |
|
85 | 85 | |
86 | - $this->data = $_data; |
|
86 | + $this->data = $_data; |
|
87 | 87 | |
88 | 88 | // Generate unique ID |
89 | - $this->id = md5( rand() ); |
|
89 | + $this->id = md5(rand()); |
|
90 | 90 | |
91 | 91 | // Setup default options; |
92 | - $this->options = apply_filters( 'give_graph_args', array( |
|
92 | + $this->options = apply_filters('give_graph_args', array( |
|
93 | 93 | 'y_mode' => null, |
94 | 94 | 'x_mode' => null, |
95 | 95 | 'y_decimals' => 0, |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | 'lines' => false, |
108 | 108 | 'points' => true, |
109 | 109 | 'dataType' => array() |
110 | - ) ); |
|
110 | + )); |
|
111 | 111 | |
112 | - $this->options = wp_parse_args( $options, $this->options ); |
|
112 | + $this->options = wp_parse_args($options, $this->options); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @since 1.0 |
122 | 122 | */ |
123 | - public function set( $key, $value ) { |
|
124 | - $this->options[ $key ] = $value; |
|
123 | + public function set($key, $value) { |
|
124 | + $this->options[$key] = $value; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @since 1.0 |
133 | 133 | */ |
134 | - public function get( $key ) { |
|
135 | - return isset( $this->options[ $key ] ) ? $this->options[ $key ] : false; |
|
134 | + public function get($key) { |
|
135 | + return isset($this->options[$key]) ? $this->options[$key] : false; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @since 1.0 |
142 | 142 | */ |
143 | 143 | public function get_data() { |
144 | - return apply_filters( 'give_get_graph_data', $this->data, $this ); |
|
144 | + return apply_filters('give_get_graph_data', $this->data, $this); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -151,19 +151,19 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function load_scripts() { |
153 | 153 | // Use minified libraries if SCRIPT_DEBUG is turned off |
154 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
154 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
155 | 155 | |
156 | - wp_register_script( 'jquery-flot-orderbars', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.orderBars' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION ); |
|
157 | - wp_enqueue_script( 'jquery-flot-orderbars' ); |
|
156 | + wp_register_script('jquery-flot-orderbars', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.orderBars'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION); |
|
157 | + wp_enqueue_script('jquery-flot-orderbars'); |
|
158 | 158 | |
159 | - wp_register_script( 'jquery-flot-time', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.time' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION ); |
|
160 | - wp_enqueue_script( 'jquery-flot-time' ); |
|
159 | + wp_register_script('jquery-flot-time', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.time'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION); |
|
160 | + wp_enqueue_script('jquery-flot-time'); |
|
161 | 161 | |
162 | - wp_register_script( 'jquery-flot-resize', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.resize' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION ); |
|
163 | - wp_enqueue_script( 'jquery-flot-resize' ); |
|
162 | + wp_register_script('jquery-flot-resize', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.resize'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION); |
|
163 | + wp_enqueue_script('jquery-flot-resize'); |
|
164 | 164 | |
165 | - wp_register_script( 'jquery-flot', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot' . $suffix . '.js', false, GIVE_VERSION ); |
|
166 | - wp_enqueue_script( 'jquery-flot' ); |
|
165 | + wp_register_script('jquery-flot', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot'.$suffix.'.js', false, GIVE_VERSION); |
|
166 | + wp_enqueue_script('jquery-flot'); |
|
167 | 167 | |
168 | 168 | } |
169 | 169 | |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | [ |
191 | 191 | <?php |
192 | 192 | $order = 0; |
193 | - foreach( $this->get_data() as $label => $data ) : |
|
193 | + foreach ($this->get_data() as $label => $data) : |
|
194 | 194 | ?> |
195 | 195 | { |
196 | - label : "<?php echo esc_attr( $label ); ?>", |
|
197 | - id : "<?php echo sanitize_key( $label ); ?>", |
|
198 | - dataType : '<?php echo ( ! empty( $this->options['dataType'][$order] ) ? $this->options['dataType'][$order] : 'count' ); ?>', |
|
196 | + label : "<?php echo esc_attr($label); ?>", |
|
197 | + id : "<?php echo sanitize_key($label); ?>", |
|
198 | + dataType : '<?php echo ( ! empty($this->options['dataType'][$order]) ? $this->options['dataType'][$order] : 'count'); ?>', |
|
199 | 199 | // data format is: [ point on x, value on y ] |
200 | - data : [<?php foreach( $data as $point ) { echo '[' . implode( ',', $point ) . '],'; } ?>], |
|
200 | + data : [<?php foreach ($data as $point) { echo '['.implode(',', $point).'],'; } ?>], |
|
201 | 201 | points: { |
202 | 202 | show: <?php echo $this->options['points'] ? 'true' : 'false'; ?>, |
203 | 203 | }, |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | fill : true, |
213 | 213 | fillColor: {colors: [{opacity: 0.4}, {opacity: 0.1}]} |
214 | 214 | }, |
215 | - <?php if( $this->options[ 'multiple_y_axes' ] ) : ?> |
|
215 | + <?php if ($this->options['multiple_y_axes']) : ?> |
|
216 | 216 | yaxis : <?php echo $yaxis_count; ?> |
217 | 217 | <?php endif; ?> |
218 | 218 | |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | grid: { |
227 | 227 | show : true, |
228 | 228 | aboveData : false, |
229 | - color : "<?php echo $this->options[ 'color' ]; ?>", |
|
230 | - backgroundColor: "<?php echo $this->options[ 'bgcolor' ]; ?>", |
|
231 | - borderColor : "<?php echo $this->options[ 'bordercolor' ]; ?>", |
|
232 | - borderWidth : <?php echo absint( $this->options[ 'borderwidth' ] ); ?>, |
|
229 | + color : "<?php echo $this->options['color']; ?>", |
|
230 | + backgroundColor: "<?php echo $this->options['bgcolor']; ?>", |
|
231 | + borderColor : "<?php echo $this->options['bordercolor']; ?>", |
|
232 | + borderWidth : <?php echo absint($this->options['borderwidth']); ?>, |
|
233 | 233 | clickable : false, |
234 | 234 | hoverable : true |
235 | 235 | }, |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | mode : "<?php echo $this->options['x_mode']; ?>", |
241 | 241 | timeFormat : "<?php echo $this->options['x_mode'] == 'time' ? $this->options['time_format'] : ''; ?>", |
242 | 242 | tickSize : "<?php echo $this->options['x_mode'] == 'time' ? '' : 1; ?>", |
243 | - <?php if( $this->options['x_mode'] != 'time' ) : ?> |
|
243 | + <?php if ($this->options['x_mode'] != 'time') : ?> |
|
244 | 244 | tickDecimals: <?php echo $this->options['x_decimals']; ?> |
245 | 245 | <?php endif; ?> |
246 | 246 | }, |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | min : 0, |
250 | 250 | mode : "<?php echo $this->options['y_mode']; ?>", |
251 | 251 | timeFormat : "<?php echo $this->options['y_mode'] == 'time' ? $this->options['time_format'] : ''; ?>", |
252 | - <?php if( $this->options['y_mode'] != 'time' ) : ?> |
|
252 | + <?php if ($this->options['y_mode'] != 'time') : ?> |
|
253 | 253 | tickDecimals: <?php echo $this->options['y_decimals']; ?> |
254 | 254 | <?php endif; ?> |
255 | 255 | } |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * |
321 | 321 | * @param Give_Graph $this Graph object. |
322 | 322 | */ |
323 | - do_action( 'give_before_graph', $this ); |
|
323 | + do_action('give_before_graph', $this); |
|
324 | 324 | |
325 | 325 | // Build the graph. |
326 | 326 | echo $this->build_graph(); |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @param Give_Graph $this Graph object. |
334 | 334 | */ |
335 | - do_action( 'give_after_graph', $this ); |
|
335 | + do_action('give_after_graph', $this); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | } |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Admin_Settings' ) ) : |
|
16 | +if ( ! class_exists('Give_Admin_Settings')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Admin_Settings Class. |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param array $settings Array of settings class object. |
74 | 74 | */ |
75 | - self::$settings = apply_filters( self::$setting_filter_prefix . '_get_settings_pages', array() ); |
|
75 | + self::$settings = apply_filters(self::$setting_filter_prefix.'_get_settings_pages', array()); |
|
76 | 76 | |
77 | 77 | return self::$settings; |
78 | 78 | } |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | public static function save() { |
87 | 87 | $current_tab = give_get_current_setting_tab(); |
88 | 88 | |
89 | - if ( empty( $_REQUEST['_give-save-settings'] ) || ! wp_verify_nonce( $_REQUEST['_give-save-settings'], 'give-save-settings' ) ) { |
|
90 | - echo '<div class="notice error"><p>' . __( 'Action failed. Please refresh the page and retry.', 'give' ) . '</p></div>'; |
|
89 | + if (empty($_REQUEST['_give-save-settings']) || ! wp_verify_nonce($_REQUEST['_give-save-settings'], 'give-save-settings')) { |
|
90 | + echo '<div class="notice error"><p>'.__('Action failed. Please refresh the page and retry.', 'give').'</p></div>'; |
|
91 | 91 | die(); |
92 | 92 | } |
93 | 93 | |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @since 1.8 |
102 | 102 | */ |
103 | - do_action( self::$setting_filter_prefix . '_save_' . $current_tab ); |
|
103 | + do_action(self::$setting_filter_prefix.'_save_'.$current_tab); |
|
104 | 104 | |
105 | - self::add_message( 'give-setting-updated', __( 'Your settings have been saved.', 'give' ) ); |
|
105 | + self::add_message('give-setting-updated', __('Your settings have been saved.', 'give')); |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Trigger Action. |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @since 1.8 |
115 | 115 | */ |
116 | - do_action( self::$setting_filter_prefix . '_saved' ); |
|
116 | + do_action(self::$setting_filter_prefix.'_saved'); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return void |
128 | 128 | */ |
129 | - public static function add_message( $code, $message ) { |
|
130 | - self::$messages[ $code ] = $message; |
|
129 | + public static function add_message($code, $message) { |
|
130 | + self::$messages[$code] = $message; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return void |
142 | 142 | */ |
143 | - public static function add_error( $code, $message ) { |
|
144 | - self::$errors[ $code ] = $message; |
|
143 | + public static function add_error($code, $message) { |
|
144 | + self::$errors[$code] = $message; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -154,18 +154,18 @@ discard block |
||
154 | 154 | $notice_html = ''; |
155 | 155 | $classes = 'give-notice settings-error notice is-dismissible'; |
156 | 156 | |
157 | - self::$errors = apply_filters( self::$setting_filter_prefix . '_error_notices', self::$errors ); |
|
158 | - self::$messages = apply_filters( self::$setting_filter_prefix . '_update_notices', self::$messages ); |
|
157 | + self::$errors = apply_filters(self::$setting_filter_prefix.'_error_notices', self::$errors); |
|
158 | + self::$messages = apply_filters(self::$setting_filter_prefix.'_update_notices', self::$messages); |
|
159 | 159 | |
160 | - if ( 0 < count( self::$errors ) ) { |
|
161 | - foreach ( self::$errors as $code => $message ) { |
|
162 | - $notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' error"><p><strong>' . $message . '</strong></p></div>'; |
|
160 | + if (0 < count(self::$errors)) { |
|
161 | + foreach (self::$errors as $code => $message) { |
|
162 | + $notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' error"><p><strong>'.$message.'</strong></p></div>'; |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
166 | - if ( 0 < count( self::$messages ) ) { |
|
167 | - foreach ( self::$messages as $code => $message ) { |
|
168 | - $notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' updated"><p><strong>' . $message . '</strong></p></div>'; |
|
166 | + if (0 < count(self::$messages)) { |
|
167 | + foreach (self::$messages as $code => $message) { |
|
168 | + $notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' updated"><p><strong>'.$message.'</strong></p></div>'; |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | self::$setting_filter_prefix = give_get_current_setting_page(); |
186 | 186 | |
187 | 187 | // Bailout: Exit if setting page is not defined. |
188 | - if ( empty( self::$setting_filter_prefix ) ) { |
|
188 | + if (empty(self::$setting_filter_prefix)) { |
|
189 | 189 | return false; |
190 | 190 | } |
191 | 191 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * |
199 | 199 | * @since 1.8 |
200 | 200 | */ |
201 | - do_action( self::$setting_filter_prefix . '_start' ); |
|
201 | + do_action(self::$setting_filter_prefix.'_start'); |
|
202 | 202 | |
203 | 203 | $current_tab = give_get_current_setting_tab(); |
204 | 204 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | self::get_settings_pages(); |
207 | 207 | |
208 | 208 | // Save settings if data has been posted. |
209 | - if ( ! empty( $_POST ) ) { |
|
209 | + if ( ! empty($_POST)) { |
|
210 | 210 | self::save(); |
211 | 211 | } |
212 | 212 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * |
220 | 220 | * @since 1.8 |
221 | 221 | */ |
222 | - $tabs = apply_filters( self::$setting_filter_prefix . '_tabs_array', array() ); |
|
222 | + $tabs = apply_filters(self::$setting_filter_prefix.'_tabs_array', array()); |
|
223 | 223 | |
224 | 224 | include 'views/html-admin-settings.php'; |
225 | 225 | |
@@ -237,25 +237,25 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return string|bool |
239 | 239 | */ |
240 | - public static function get_option( $option_name = '', $field_id = '', $default = false ) { |
|
240 | + public static function get_option($option_name = '', $field_id = '', $default = false) { |
|
241 | 241 | // Bailout. |
242 | - if ( empty( $option_name ) && empty( $field_id ) ) { |
|
242 | + if (empty($option_name) && empty($field_id)) { |
|
243 | 243 | return false; |
244 | 244 | } |
245 | 245 | |
246 | - if ( ! empty( $field_id ) && ! empty( $option_name ) ) { |
|
246 | + if ( ! empty($field_id) && ! empty($option_name)) { |
|
247 | 247 | // Get field value if any. |
248 | - $option_value = get_option( $option_name ); |
|
248 | + $option_value = get_option($option_name); |
|
249 | 249 | |
250 | - $option_value = ( is_array( $option_value ) && array_key_exists( $field_id, $option_value ) ) |
|
251 | - ? $option_value[ $field_id ] |
|
250 | + $option_value = (is_array($option_value) && array_key_exists($field_id, $option_value)) |
|
251 | + ? $option_value[$field_id] |
|
252 | 252 | : $default; |
253 | 253 | } else { |
254 | 254 | // If option name is empty but not field name then this means, setting is direct store to option table under there field name. |
255 | 255 | $option_name = ! $option_name ? $field_id : $option_name; |
256 | 256 | |
257 | 257 | // Get option value if any. |
258 | - $option_value = get_option( $option_name, $default ); |
|
258 | + $option_value = get_option($option_name, $default); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | return $option_value; |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @return void |
275 | 275 | */ |
276 | - public static function output_fields( $options, $option_name = '' ) { |
|
276 | + public static function output_fields($options, $option_name = '') { |
|
277 | 277 | $current_tab = give_get_current_setting_tab(); |
278 | 278 | |
279 | 279 | // Field Default values. |
@@ -286,52 +286,52 @@ discard block |
||
286 | 286 | 'table_html' => true, |
287 | 287 | ); |
288 | 288 | |
289 | - foreach ( $options as $value ) { |
|
290 | - if ( ! isset( $value['type'] ) ) { |
|
289 | + foreach ($options as $value) { |
|
290 | + if ( ! isset($value['type'])) { |
|
291 | 291 | continue; |
292 | 292 | } |
293 | 293 | |
294 | 294 | // Set title. |
295 | - $defaults['title'] = isset( $value['name'] ) ? $value['name'] : ''; |
|
295 | + $defaults['title'] = isset($value['name']) ? $value['name'] : ''; |
|
296 | 296 | |
297 | 297 | // Set default setting. |
298 | - $value = wp_parse_args( $value, $defaults ); |
|
298 | + $value = wp_parse_args($value, $defaults); |
|
299 | 299 | |
300 | 300 | // Colorpicker field. |
301 | - $value['class'] = ( 'colorpicker' === $value['type'] ? trim( $value['class'] ) . ' give-colorpicker' : $value['class'] ); |
|
302 | - $value['type'] = ( 'colorpicker' === $value['type'] ? 'text' : $value['type'] ); |
|
301 | + $value['class'] = ('colorpicker' === $value['type'] ? trim($value['class']).' give-colorpicker' : $value['class']); |
|
302 | + $value['type'] = ('colorpicker' === $value['type'] ? 'text' : $value['type']); |
|
303 | 303 | |
304 | 304 | |
305 | 305 | // Custom attribute handling. |
306 | 306 | $custom_attributes = array(); |
307 | 307 | |
308 | - if ( ! empty( $value['attributes'] ) && is_array( $value['attributes'] ) ) { |
|
309 | - foreach ( $value['attributes'] as $attribute => $attribute_value ) { |
|
310 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; |
|
308 | + if ( ! empty($value['attributes']) && is_array($value['attributes'])) { |
|
309 | + foreach ($value['attributes'] as $attribute => $attribute_value) { |
|
310 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($attribute_value).'"'; |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | 314 | // Description handling. |
315 | - $description = self::get_field_description( $value ); |
|
315 | + $description = self::get_field_description($value); |
|
316 | 316 | |
317 | 317 | // Switch based on type. |
318 | - switch ( $value['type'] ) { |
|
318 | + switch ($value['type']) { |
|
319 | 319 | |
320 | 320 | // Section Titles |
321 | 321 | case 'title': |
322 | - if ( ! empty( $value['title'] ) ) { |
|
323 | - echo '<div class="give-setting-tab-header give-setting-tab-header-' . $current_tab . '"><h2>' . self::get_field_title( $value ) . '</h2><hr></div>'; |
|
322 | + if ( ! empty($value['title'])) { |
|
323 | + echo '<div class="give-setting-tab-header give-setting-tab-header-'.$current_tab.'"><h2>'.self::get_field_title($value).'</h2><hr></div>'; |
|
324 | 324 | } |
325 | 325 | |
326 | - if ( ! empty( $value['desc'] ) ) { |
|
327 | - echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) ); |
|
326 | + if ( ! empty($value['desc'])) { |
|
327 | + echo wpautop(wptexturize(wp_kses_post($value['desc']))); |
|
328 | 328 | } |
329 | 329 | |
330 | - if ( $value['table_html'] ) { |
|
331 | - echo '<table class="form-table give-setting-tab-body give-setting-tab-body-' . $current_tab . '">' . "\n\n"; |
|
330 | + if ($value['table_html']) { |
|
331 | + echo '<table class="form-table give-setting-tab-body give-setting-tab-body-'.$current_tab.'">'."\n\n"; |
|
332 | 332 | } |
333 | 333 | |
334 | - if ( ! empty( $value['id'] ) ) { |
|
334 | + if ( ! empty($value['id'])) { |
|
335 | 335 | |
336 | 336 | /** |
337 | 337 | * Trigger Action. |
@@ -340,14 +340,14 @@ discard block |
||
340 | 340 | * |
341 | 341 | * @since 1.8 |
342 | 342 | */ |
343 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) ); |
|
343 | + do_action('give_settings_'.sanitize_title($value['id'])); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | break; |
347 | 347 | |
348 | 348 | // Section Ends. |
349 | 349 | case 'sectionend': |
350 | - if ( ! empty( $value['id'] ) ) { |
|
350 | + if ( ! empty($value['id'])) { |
|
351 | 351 | |
352 | 352 | /** |
353 | 353 | * Trigger Action. |
@@ -356,14 +356,14 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @since 1.8 |
358 | 358 | */ |
359 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_end' ); |
|
359 | + do_action('give_settings_'.sanitize_title($value['id']).'_end'); |
|
360 | 360 | } |
361 | 361 | |
362 | - if ( $value['table_html'] ) { |
|
362 | + if ($value['table_html']) { |
|
363 | 363 | echo '</table>'; |
364 | 364 | } |
365 | 365 | |
366 | - if ( ! empty( $value['id'] ) ) { |
|
366 | + if ( ! empty($value['id'])) { |
|
367 | 367 | |
368 | 368 | /** |
369 | 369 | * Trigger Action. |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @since 1.8 |
374 | 374 | */ |
375 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_after' ); |
|
375 | + do_action('give_settings_'.sanitize_title($value['id']).'_after'); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | break; |
@@ -385,22 +385,22 @@ discard block |
||
385 | 385 | case 'password' : |
386 | 386 | |
387 | 387 | $type = $value['type']; |
388 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
388 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
389 | 389 | |
390 | 390 | ?> |
391 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
391 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
392 | 392 | <th scope="row" class="titledesc"> |
393 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
393 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
394 | 394 | </th> |
395 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
395 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
396 | 396 | <input |
397 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
398 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
399 | - type="<?php echo esc_attr( $type ); ?>" |
|
400 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
401 | - value="<?php echo esc_attr( $option_value ); ?>" |
|
402 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
403 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
397 | + name="<?php echo esc_attr($value['id']); ?>" |
|
398 | + id="<?php echo esc_attr($value['id']); ?>" |
|
399 | + type="<?php echo esc_attr($type); ?>" |
|
400 | + style="<?php echo esc_attr($value['css']); ?>" |
|
401 | + value="<?php echo esc_attr($option_value); ?>" |
|
402 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
403 | + <?php echo implode(' ', $custom_attributes); ?> |
|
404 | 404 | /> <?php echo $description; ?> |
405 | 405 | </td> |
406 | 406 | </tr><?php |
@@ -409,23 +409,23 @@ discard block |
||
409 | 409 | // Textarea. |
410 | 410 | case 'textarea': |
411 | 411 | |
412 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
412 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
413 | 413 | |
414 | 414 | ?> |
415 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
415 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
416 | 416 | <th scope="row" class="titledesc"> |
417 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
417 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
418 | 418 | </th> |
419 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
419 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
420 | 420 | <textarea |
421 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
422 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
423 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
424 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
421 | + name="<?php echo esc_attr($value['id']); ?>" |
|
422 | + id="<?php echo esc_attr($value['id']); ?>" |
|
423 | + style="<?php echo esc_attr($value['css']); ?>" |
|
424 | + class="<?php echo esc_attr($value['class']); ?>" |
|
425 | 425 | rows="10" |
426 | 426 | cols="60" |
427 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
428 | - ><?php echo esc_textarea( $option_value ); ?></textarea> |
|
427 | + <?php echo implode(' ', $custom_attributes); ?> |
|
428 | + ><?php echo esc_textarea($option_value); ?></textarea> |
|
429 | 429 | <?php echo $description; ?> |
430 | 430 | </td> |
431 | 431 | </tr><?php |
@@ -435,35 +435,35 @@ discard block |
||
435 | 435 | case 'select' : |
436 | 436 | case 'multiselect' : |
437 | 437 | |
438 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
438 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
439 | 439 | |
440 | 440 | ?> |
441 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
441 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
442 | 442 | <th scope="row" class="titledesc"> |
443 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
443 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
444 | 444 | </th> |
445 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
445 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
446 | 446 | <select |
447 | - name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) { |
|
447 | + name="<?php echo esc_attr($value['id']); ?><?php if ($value['type'] == 'multiselect') { |
|
448 | 448 | echo '[]'; |
449 | 449 | } ?>" |
450 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
451 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
452 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
453 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
454 | - <?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?> |
|
450 | + id="<?php echo esc_attr($value['id']); ?>" |
|
451 | + style="<?php echo esc_attr($value['css']); ?>" |
|
452 | + class="<?php echo esc_attr($value['class']); ?>" |
|
453 | + <?php echo implode(' ', $custom_attributes); ?> |
|
454 | + <?php echo ('multiselect' == $value['type']) ? 'multiple="multiple"' : ''; ?> |
|
455 | 455 | > |
456 | 456 | |
457 | 457 | <?php |
458 | - if ( ! empty( $value['options'] ) ) { |
|
459 | - foreach ( $value['options'] as $key => $val ) { |
|
458 | + if ( ! empty($value['options'])) { |
|
459 | + foreach ($value['options'] as $key => $val) { |
|
460 | 460 | ?> |
461 | - <option value="<?php echo esc_attr( $key ); ?>" <?php |
|
461 | + <option value="<?php echo esc_attr($key); ?>" <?php |
|
462 | 462 | |
463 | - if ( is_array( $option_value ) ) { |
|
464 | - selected( in_array( $key, $option_value ), true ); |
|
463 | + if (is_array($option_value)) { |
|
464 | + selected(in_array($key, $option_value), true); |
|
465 | 465 | } else { |
466 | - selected( $option_value, $key ); |
|
466 | + selected($option_value, $key); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | ?>><?php echo $val ?></option> |
@@ -479,28 +479,28 @@ discard block |
||
479 | 479 | |
480 | 480 | // Radio inputs. |
481 | 481 | case 'radio_inline' : |
482 | - $value['class'] = empty( $value['class'] ) ? 'give-radio-inline' : $value['class'] . ' give-radio-inline'; |
|
482 | + $value['class'] = empty($value['class']) ? 'give-radio-inline' : $value['class'].' give-radio-inline'; |
|
483 | 483 | case 'radio' : |
484 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
484 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
485 | 485 | ?> |
486 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
486 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
487 | 487 | <th scope="row" class="titledesc"> |
488 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
488 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
489 | 489 | </th> |
490 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
490 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
491 | 491 | <fieldset> |
492 | 492 | <ul> |
493 | 493 | <?php |
494 | - foreach ( $value['options'] as $key => $val ) { |
|
494 | + foreach ($value['options'] as $key => $val) { |
|
495 | 495 | ?> |
496 | 496 | <li> |
497 | 497 | <label><input |
498 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
498 | + name="<?php echo esc_attr($value['id']); ?>" |
|
499 | 499 | value="<?php echo $key; ?>" |
500 | 500 | type="radio" |
501 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
502 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
503 | - <?php checked( $key, $option_value ); ?> |
|
501 | + style="<?php echo esc_attr($value['css']); ?>" |
|
502 | + <?php echo implode(' ', $custom_attributes); ?> |
|
503 | + <?php checked($key, $option_value); ?> |
|
504 | 504 | /> <?php echo $val ?></label> |
505 | 505 | </li> |
506 | 506 | <?php |
@@ -514,21 +514,21 @@ discard block |
||
514 | 514 | |
515 | 515 | // Checkbox input. |
516 | 516 | case 'checkbox' : |
517 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
517 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
518 | 518 | ?> |
519 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
519 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
520 | 520 | <th scope="row" class="titledesc"> |
521 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
521 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
522 | 522 | </th> |
523 | 523 | <td class="give-forminp"> |
524 | 524 | <input |
525 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
526 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
525 | + name="<?php echo esc_attr($value['id']); ?>" |
|
526 | + id="<?php echo esc_attr($value['id']); ?>" |
|
527 | 527 | type="checkbox" |
528 | - class="<?php echo esc_attr( isset( $value['class'] ) ? $value['class'] : '' ); ?>" |
|
528 | + class="<?php echo esc_attr(isset($value['class']) ? $value['class'] : ''); ?>" |
|
529 | 529 | value="1" |
530 | - <?php checked( $option_value, 'on' ); ?> |
|
531 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
530 | + <?php checked($option_value, 'on'); ?> |
|
531 | + <?php echo implode(' ', $custom_attributes); ?> |
|
532 | 532 | /> |
533 | 533 | <?php echo $description; ?> |
534 | 534 | </td> |
@@ -538,28 +538,28 @@ discard block |
||
538 | 538 | |
539 | 539 | // Multi Checkbox input. |
540 | 540 | case 'multicheck' : |
541 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
542 | - $option_value = is_array( $option_value ) ? $option_value : array(); |
|
541 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
542 | + $option_value = is_array($option_value) ? $option_value : array(); |
|
543 | 543 | ?> |
544 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
544 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
545 | 545 | <th scope="row" class="titledesc"> |
546 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
546 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
547 | 547 | </th> |
548 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
548 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
549 | 549 | <fieldset> |
550 | 550 | <ul> |
551 | 551 | <?php |
552 | - foreach ( $value['options'] as $key => $val ) { |
|
552 | + foreach ($value['options'] as $key => $val) { |
|
553 | 553 | ?> |
554 | 554 | <li> |
555 | 555 | <label> |
556 | 556 | <input |
557 | - name="<?php echo esc_attr( $value['id'] ); ?>[]" |
|
557 | + name="<?php echo esc_attr($value['id']); ?>[]" |
|
558 | 558 | value="<?php echo $key; ?>" |
559 | 559 | type="checkbox" |
560 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
561 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
562 | - <?php if ( in_array( $key, $option_value ) ) { |
|
560 | + style="<?php echo esc_attr($value['css']); ?>" |
|
561 | + <?php echo implode(' ', $custom_attributes); ?> |
|
562 | + <?php if (in_array($key, $option_value)) { |
|
563 | 563 | echo 'checked="checked"'; |
564 | 564 | } ?> |
565 | 565 | /> <?php echo $val ?> |
@@ -577,25 +577,25 @@ discard block |
||
577 | 577 | |
578 | 578 | // File input field. |
579 | 579 | case 'file' : |
580 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
580 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
581 | 581 | ?> |
582 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
582 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
583 | 583 | <th scope="row" class="titledesc"> |
584 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
584 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
585 | 585 | </th> |
586 | 586 | <td class="give-forminp"> |
587 | 587 | <div class="give-field-wrap"> |
588 | 588 | <label for="<?php echo $value['id'] ?>"> |
589 | 589 | <input |
590 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
591 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
590 | + name="<?php echo esc_attr($value['id']); ?>" |
|
591 | + id="<?php echo esc_attr($value['id']); ?>" |
|
592 | 592 | type="text" |
593 | - class="give-input-field<?php echo esc_attr( isset( $value['class'] ) ? ' ' . $value['class'] : '' ); ?>" |
|
593 | + class="give-input-field<?php echo esc_attr(isset($value['class']) ? ' '.$value['class'] : ''); ?>" |
|
594 | 594 | value="<?php echo $option_value; ?>" |
595 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
596 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
595 | + style="<?php echo esc_attr($value['css']); ?>" |
|
596 | + <?php echo implode(' ', $custom_attributes); ?> |
|
597 | 597 | /> <input class="give-upload-button button" type="button" |
598 | - value="<?php echo esc_html__( 'Add or Upload File', 'give' ); ?>"> |
|
598 | + value="<?php echo esc_html__('Add or Upload File', 'give'); ?>"> |
|
599 | 599 | <?php echo $description ?> |
600 | 600 | <div class="give-image-thumb<?php echo ! $option_value ? ' give-hidden' : ''; ?>"> |
601 | 601 | <span class="give-delete-image-thumb dashicons dashicons-no-alt"></span> |
@@ -610,17 +610,17 @@ discard block |
||
610 | 610 | // WordPress Editor. |
611 | 611 | case 'wysiwyg' : |
612 | 612 | // Get option value. |
613 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
613 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
614 | 614 | |
615 | 615 | // Get editor settings. |
616 | - $editor_settings = ! empty( $value['options'] ) ? $value['options'] : array(); |
|
616 | + $editor_settings = ! empty($value['options']) ? $value['options'] : array(); |
|
617 | 617 | ?> |
618 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
618 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
619 | 619 | <th scope="row" class="titledesc"> |
620 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
620 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
621 | 621 | </th> |
622 | 622 | <td class="give-forminp"> |
623 | - <?php wp_editor( $option_value, $value['id'], $editor_settings ); ?> |
|
623 | + <?php wp_editor($option_value, $value['id'], $editor_settings); ?> |
|
624 | 624 | <?php echo $description; ?> |
625 | 625 | </td> |
626 | 626 | </tr><?php |
@@ -629,9 +629,9 @@ discard block |
||
629 | 629 | // Custom: System setting field. |
630 | 630 | case 'system_info' : |
631 | 631 | ?> |
632 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
632 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
633 | 633 | <th scope="row" class="titledesc"> |
634 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
634 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
635 | 635 | </th> |
636 | 636 | <td class="give-forminp"> |
637 | 637 | <?php give_system_info_callback(); ?> |
@@ -642,14 +642,14 @@ discard block |
||
642 | 642 | |
643 | 643 | // Custom: Default gateways setting field. |
644 | 644 | case 'default_gateway' : |
645 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
645 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
646 | 646 | ?> |
647 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
647 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
648 | 648 | <th scope="row" class="titledesc"> |
649 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
649 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
650 | 650 | </th> |
651 | 651 | <td class="give-forminp"> |
652 | - <?php give_default_gateway_callback( $value, $option_value ); ?> |
|
652 | + <?php give_default_gateway_callback($value, $option_value); ?> |
|
653 | 653 | <?php echo $description; ?> |
654 | 654 | </td> |
655 | 655 | </tr><?php |
@@ -657,14 +657,14 @@ discard block |
||
657 | 657 | |
658 | 658 | // Custom: Enable gateways setting field. |
659 | 659 | case 'enabled_gateways' : |
660 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
660 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
661 | 661 | ?> |
662 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
662 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
663 | 663 | <th scope="row" class="titledesc"> |
664 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
664 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
665 | 665 | </th> |
666 | 666 | <td class="give-forminp"> |
667 | - <?php give_enabled_gateways_callback( $value, $option_value ); ?> |
|
667 | + <?php give_enabled_gateways_callback($value, $option_value); ?> |
|
668 | 668 | <?php echo $description; ?> |
669 | 669 | </td> |
670 | 670 | </tr><?php |
@@ -673,9 +673,9 @@ discard block |
||
673 | 673 | // Custom: Email preview buttons field. |
674 | 674 | case 'email_preview_buttons' : |
675 | 675 | ?> |
676 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
676 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
677 | 677 | <th scope="row" class="titledesc"> |
678 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
678 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
679 | 679 | </th> |
680 | 680 | <td class="give-forminp"> |
681 | 681 | <?php give_email_preview_buttons_callback(); ?> |
@@ -692,22 +692,22 @@ discard block |
||
692 | 692 | |
693 | 693 | // Custom: Gateway API key. |
694 | 694 | case 'api_key' : |
695 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
696 | - $type = ! empty( $option_value ) ? 'password' : 'text'; |
|
695 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
696 | + $type = ! empty($option_value) ? 'password' : 'text'; |
|
697 | 697 | ?> |
698 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
698 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
699 | 699 | <th scope="row" class="titledesc"> |
700 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
700 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
701 | 701 | </th> |
702 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
702 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
703 | 703 | <input |
704 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
705 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
706 | - type="<?php echo esc_attr( $type ); ?>" |
|
707 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
708 | - value="<?php echo esc_attr( trim( $option_value ) ); ?>" |
|
709 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
710 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
704 | + name="<?php echo esc_attr($value['id']); ?>" |
|
705 | + id="<?php echo esc_attr($value['id']); ?>" |
|
706 | + type="<?php echo esc_attr($type); ?>" |
|
707 | + style="<?php echo esc_attr($value['css']); ?>" |
|
708 | + value="<?php echo esc_attr(trim($option_value)); ?>" |
|
709 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
710 | + <?php echo implode(' ', $custom_attributes); ?> |
|
711 | 711 | /> <?php echo $description; ?> |
712 | 712 | </td> |
713 | 713 | </tr><?php |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | // Custom: Log field. |
717 | 717 | case 'logs' : |
718 | 718 | |
719 | - include GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/logs.php'; |
|
719 | + include GIVE_PLUGIN_DIR.'includes/admin/tools/logs/logs.php'; |
|
720 | 720 | |
721 | 721 | // Get current section. |
722 | 722 | $current_section = $_GET['section'] = give_get_current_setting_section(); |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | * |
727 | 727 | * @since 1.0 |
728 | 728 | */ |
729 | - do_action( "give_logs_view_{$current_section}" ); |
|
729 | + do_action("give_logs_view_{$current_section}"); |
|
730 | 730 | |
731 | 731 | echo $description; |
732 | 732 | break; |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | // Custom: Data field. |
735 | 735 | case 'data' : |
736 | 736 | |
737 | - include GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-data.php'; |
|
737 | + include GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-data.php'; |
|
738 | 738 | |
739 | 739 | echo $description; |
740 | 740 | break; |
@@ -742,12 +742,12 @@ discard block |
||
742 | 742 | // Custom: Give Docs Link field type. |
743 | 743 | case 'give_docs_link' : |
744 | 744 | ?> |
745 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
745 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
746 | 746 | <td class="give-docs-link" colspan="2"> |
747 | 747 | <?php |
748 | - echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] ) |
|
748 | + echo '<p class="give-docs-link"><a href="'.esc_url($value['url']) |
|
749 | 749 | . '" target="_blank">' |
750 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
750 | + . sprintf(esc_html__('Need Help? See docs on "%s"', 'give'), $value['title']) |
|
751 | 751 | . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
752 | 752 | ?> |
753 | 753 | </td> |
@@ -758,8 +758,8 @@ discard block |
||
758 | 758 | // You can add or handle your custom field action. |
759 | 759 | default: |
760 | 760 | // Get option value. |
761 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
762 | - do_action( 'give_admin_field_' . $value['type'], $value, $option_value ); |
|
761 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
762 | + do_action('give_admin_field_'.$value['type'], $value, $option_value); |
|
763 | 763 | break; |
764 | 764 | } |
765 | 765 | } |
@@ -775,15 +775,15 @@ discard block |
||
775 | 775 | * |
776 | 776 | * @return string The HTML description of the field. |
777 | 777 | */ |
778 | - public static function get_field_description( $value ) { |
|
778 | + public static function get_field_description($value) { |
|
779 | 779 | $description = ''; |
780 | 780 | |
781 | 781 | // Support for both 'description' and 'desc' args. |
782 | - $description_key = isset( $value['description'] ) ? 'description' : 'desc'; |
|
783 | - $value = ( isset( $value[ $description_key ] ) && ! empty( $value[ $description_key ] ) ) ? $value[ $description_key ] : ''; |
|
782 | + $description_key = isset($value['description']) ? 'description' : 'desc'; |
|
783 | + $value = (isset($value[$description_key]) && ! empty($value[$description_key])) ? $value[$description_key] : ''; |
|
784 | 784 | |
785 | - if ( ! empty( $value ) ) { |
|
786 | - $description = '<p class="give-field-description">' . wp_kses_post( $value ) . '</p>'; |
|
785 | + if ( ! empty($value)) { |
|
786 | + $description = '<p class="give-field-description">'.wp_kses_post($value).'</p>'; |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | return $description; |
@@ -800,11 +800,11 @@ discard block |
||
800 | 800 | * |
801 | 801 | * @return array The description and tip as a 2 element array |
802 | 802 | */ |
803 | - public static function get_field_title( $value ) { |
|
804 | - $title = esc_html( $value['title'] ); |
|
803 | + public static function get_field_title($value) { |
|
804 | + $title = esc_html($value['title']); |
|
805 | 805 | |
806 | 806 | // If html tag detected then allow them to print. |
807 | - if ( strip_tags( $title ) ) { |
|
807 | + if (strip_tags($title)) { |
|
808 | 808 | $title = $value['title']; |
809 | 809 | } |
810 | 810 | |
@@ -823,8 +823,8 @@ discard block |
||
823 | 823 | * |
824 | 824 | * @return bool |
825 | 825 | */ |
826 | - public static function save_fields( $options, $option_name = '' ) { |
|
827 | - if ( empty( $_POST ) ) { |
|
826 | + public static function save_fields($options, $option_name = '') { |
|
827 | + if (empty($_POST)) { |
|
828 | 828 | return false; |
829 | 829 | } |
830 | 830 | |
@@ -832,37 +832,37 @@ discard block |
||
832 | 832 | $update_options = array(); |
833 | 833 | |
834 | 834 | // Loop options and get values to save. |
835 | - foreach ( $options as $option ) { |
|
836 | - if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) { |
|
835 | + foreach ($options as $option) { |
|
836 | + if ( ! isset($option['id']) || ! isset($option['type'])) { |
|
837 | 837 | continue; |
838 | 838 | } |
839 | 839 | |
840 | 840 | // Get posted value. |
841 | - if ( strstr( $option['id'], '[' ) ) { |
|
842 | - parse_str( $option['id'], $option_name_array ); |
|
843 | - $field_option_name = current( array_keys( $option_name_array ) ); |
|
844 | - $setting_name = key( $option_name_array[ $field_option_name ] ); |
|
845 | - $raw_value = isset( $_POST[ $field_option_name ][ $setting_name ] ) ? wp_unslash( $_POST[ $field_option_name ][ $setting_name ] ) : null; |
|
841 | + if (strstr($option['id'], '[')) { |
|
842 | + parse_str($option['id'], $option_name_array); |
|
843 | + $field_option_name = current(array_keys($option_name_array)); |
|
844 | + $setting_name = key($option_name_array[$field_option_name]); |
|
845 | + $raw_value = isset($_POST[$field_option_name][$setting_name]) ? wp_unslash($_POST[$field_option_name][$setting_name]) : null; |
|
846 | 846 | } else { |
847 | 847 | $field_option_name = $option['id']; |
848 | 848 | $setting_name = ''; |
849 | - $raw_value = isset( $_POST[ $option['id'] ] ) ? wp_unslash( $_POST[ $option['id'] ] ) : null; |
|
849 | + $raw_value = isset($_POST[$option['id']]) ? wp_unslash($_POST[$option['id']]) : null; |
|
850 | 850 | } |
851 | 851 | |
852 | 852 | // Format the value based on option type. |
853 | - switch ( $option['type'] ) { |
|
853 | + switch ($option['type']) { |
|
854 | 854 | case 'checkbox' : |
855 | - $value = is_null( $raw_value ) ? '' : 'on'; |
|
855 | + $value = is_null($raw_value) ? '' : 'on'; |
|
856 | 856 | break; |
857 | 857 | case 'wysiwyg' : |
858 | 858 | case 'textarea' : |
859 | - $value = wp_kses_post( trim( $raw_value ) ); |
|
859 | + $value = wp_kses_post(trim($raw_value)); |
|
860 | 860 | break; |
861 | 861 | case 'multiselect' : |
862 | - $value = array_filter( array_map( 'give_clean', (array) $raw_value ) ); |
|
862 | + $value = array_filter(array_map('give_clean', (array) $raw_value)); |
|
863 | 863 | break; |
864 | 864 | default : |
865 | - $value = give_clean( $raw_value ); |
|
865 | + $value = give_clean($raw_value); |
|
866 | 866 | break; |
867 | 867 | } |
868 | 868 | |
@@ -871,37 +871,37 @@ discard block |
||
871 | 871 | * |
872 | 872 | * @since 1.8 |
873 | 873 | */ |
874 | - $value = apply_filters( 'give_admin_settings_sanitize_option', $value, $option, $raw_value ); |
|
874 | + $value = apply_filters('give_admin_settings_sanitize_option', $value, $option, $raw_value); |
|
875 | 875 | |
876 | 876 | /** |
877 | 877 | * Sanitize the value of an option by option name. |
878 | 878 | * |
879 | 879 | * @since 1.8 |
880 | 880 | */ |
881 | - $value = apply_filters( "give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value ); |
|
881 | + $value = apply_filters("give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value); |
|
882 | 882 | |
883 | - if ( is_null( $value ) ) { |
|
883 | + if (is_null($value)) { |
|
884 | 884 | continue; |
885 | 885 | } |
886 | 886 | |
887 | 887 | // Check if option is an array and handle that differently to single values. |
888 | - if ( $field_option_name && $setting_name ) { |
|
889 | - if ( ! isset( $update_options[ $field_option_name ] ) ) { |
|
890 | - $update_options[ $field_option_name ] = get_option( $field_option_name, array() ); |
|
888 | + if ($field_option_name && $setting_name) { |
|
889 | + if ( ! isset($update_options[$field_option_name])) { |
|
890 | + $update_options[$field_option_name] = get_option($field_option_name, array()); |
|
891 | 891 | } |
892 | - if ( ! is_array( $update_options[ $field_option_name ] ) ) { |
|
893 | - $update_options[ $field_option_name ] = array(); |
|
892 | + if ( ! is_array($update_options[$field_option_name])) { |
|
893 | + $update_options[$field_option_name] = array(); |
|
894 | 894 | } |
895 | - $update_options[ $field_option_name ][ $setting_name ] = $value; |
|
895 | + $update_options[$field_option_name][$setting_name] = $value; |
|
896 | 896 | } else { |
897 | - $update_options[ $field_option_name ] = $value; |
|
897 | + $update_options[$field_option_name] = $value; |
|
898 | 898 | } |
899 | 899 | } |
900 | 900 | |
901 | 901 | // Save all options in our array or there own option name i.e. option id. |
902 | - if ( empty( $option_name ) ) { |
|
903 | - foreach ( $update_options as $name => $value ) { |
|
904 | - update_option( $name, $value ); |
|
902 | + if (empty($option_name)) { |
|
903 | + foreach ($update_options as $name => $value) { |
|
904 | + update_option($name, $value); |
|
905 | 905 | |
906 | 906 | /** |
907 | 907 | * Trigger action. |
@@ -910,13 +910,13 @@ discard block |
||
910 | 910 | * |
911 | 911 | * @since 1.8 |
912 | 912 | */ |
913 | - do_action( "give_save_option_{$name}", $value, $name ); |
|
913 | + do_action("give_save_option_{$name}", $value, $name); |
|
914 | 914 | } |
915 | 915 | } else { |
916 | - $old_options = ( $old_options = get_option( $option_name ) ) ? $old_options : array(); |
|
917 | - $update_options = array_merge( $old_options, $update_options ); |
|
916 | + $old_options = ($old_options = get_option($option_name)) ? $old_options : array(); |
|
917 | + $update_options = array_merge($old_options, $update_options); |
|
918 | 918 | |
919 | - update_option( $option_name, $update_options ); |
|
919 | + update_option($option_name, $update_options); |
|
920 | 920 | |
921 | 921 | /** |
922 | 922 | * Trigger action. |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | * |
926 | 926 | * @since 1.8 |
927 | 927 | */ |
928 | - do_action( "give_save_settings_{$option_name}", $update_options, $option_name ); |
|
928 | + do_action("give_save_settings_{$option_name}", $update_options, $option_name); |
|
929 | 929 | } |
930 | 930 | |
931 | 931 | return true; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | // Exit if accessed directly. |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | * 'testing' => false, // (required) Never leave as "true" in production!!! |
33 | 33 | * } |
34 | 34 | */ |
35 | - function __construct( $_banner_details ) { |
|
35 | + function __construct($_banner_details) { |
|
36 | 36 | $current_user = wp_get_current_user(); |
37 | 37 | |
38 | 38 | $this->plugin_activate_by = 0; |
39 | 39 | $this->banner_details = $_banner_details; |
40 | - $this->test_mode = ( $this->banner_details['testing'] == 'true' ) ? true : false; |
|
41 | - $this->nag_meta_key = 'give_addon_activation_ignore_' . sanitize_title( $this->banner_details['name'] ); |
|
42 | - $this->activate_by_meta_key = 'give_addon_' . sanitize_title( $this->banner_details['name'] ) . '_active_by_user'; |
|
40 | + $this->test_mode = ($this->banner_details['testing'] == 'true') ? true : false; |
|
41 | + $this->nag_meta_key = 'give_addon_activation_ignore_'.sanitize_title($this->banner_details['name']); |
|
42 | + $this->activate_by_meta_key = 'give_addon_'.sanitize_title($this->banner_details['name']).'_active_by_user'; |
|
43 | 43 | |
44 | 44 | //Get current user |
45 | 45 | $this->user_id = $current_user->ID; |
@@ -62,19 +62,19 @@ discard block |
||
62 | 62 | public function init() { |
63 | 63 | |
64 | 64 | //Testing? |
65 | - if ( $this->test_mode ) { |
|
66 | - delete_user_meta( $this->user_id, $this->nag_meta_key ); |
|
65 | + if ($this->test_mode) { |
|
66 | + delete_user_meta($this->user_id, $this->nag_meta_key); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | //Get the current page to add the notice to |
70 | - add_action( 'current_screen', array( $this, 'give_addon_notice_ignore' ) ); |
|
71 | - add_action( 'admin_notices', array( $this, 'give_addon_activation_admin_notice' ) ); |
|
70 | + add_action('current_screen', array($this, 'give_addon_notice_ignore')); |
|
71 | + add_action('admin_notices', array($this, 'give_addon_activation_admin_notice')); |
|
72 | 72 | |
73 | 73 | // File path of addon must be included in banner detail other addon activate meta will not delete. |
74 | 74 | $file_name = $this->get_plugin_file_name(); |
75 | 75 | |
76 | - if ( ! empty( $file_name ) ) { |
|
77 | - add_action( 'deactivate_' . $file_name, array( $this, 'remove_addon_activate_meta' ) ); |
|
76 | + if ( ! empty($file_name)) { |
|
77 | + add_action('deactivate_'.$file_name, array($this, 'remove_addon_activate_meta')); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | private function is_plugin_page() { |
90 | 90 | $screen = get_current_screen(); |
91 | 91 | |
92 | - return ( $screen->parent_file === 'plugins.php' ); |
|
92 | + return ($screen->parent_file === 'plugins.php'); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | public function give_addon_activation_admin_notice() { |
103 | 103 | |
104 | 104 | // Bailout. |
105 | - if ( ! $this->is_plugin_page() || $this->user_id !== $this->plugin_activate_by ) { |
|
105 | + if ( ! $this->is_plugin_page() || $this->user_id !== $this->plugin_activate_by) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
109 | 109 | // If the user hasn't already dismissed the alert, output activation banner. |
110 | - if ( ! get_user_meta( $this->user_id, $this->nag_meta_key ) ) { |
|
110 | + if ( ! get_user_meta($this->user_id, $this->nag_meta_key)) { |
|
111 | 111 | |
112 | 112 | // Output inline styles here because there's no reason |
113 | 113 | // to enqueued them after the alert is dismissed. |
@@ -189,44 +189,44 @@ discard block |
||
189 | 189 | <h3><?php |
190 | 190 | printf( |
191 | 191 | /* translators: %s: Add-on name */ |
192 | - esc_html__( "Thank you for installing Give's %s Add-on!", 'give' ), |
|
193 | - '<span>' . $this->banner_details['name'] . '</span>' |
|
192 | + esc_html__("Thank you for installing Give's %s Add-on!", 'give'), |
|
193 | + '<span>'.$this->banner_details['name'].'</span>' |
|
194 | 194 | ); |
195 | 195 | ?></h3> |
196 | 196 | |
197 | 197 | <a href="<?php |
198 | 198 | //The Dismiss Button. |
199 | - $nag_admin_dismiss_url = 'plugins.php?' . $this->nag_meta_key . '=0'; |
|
200 | - echo admin_url( $nag_admin_dismiss_url ); ?>" class="dismiss"><span |
|
199 | + $nag_admin_dismiss_url = 'plugins.php?'.$this->nag_meta_key.'=0'; |
|
200 | + echo admin_url($nag_admin_dismiss_url); ?>" class="dismiss"><span |
|
201 | 201 | class="dashicons dashicons-dismiss"></span></a> |
202 | 202 | |
203 | 203 | <div class="alert-actions"> |
204 | 204 | |
205 | 205 | <?php //Point them to your settings page. |
206 | - if ( isset( $this->banner_details['settings_url'] ) ) { ?> |
|
206 | + if (isset($this->banner_details['settings_url'])) { ?> |
|
207 | 207 | <a href="<?php echo $this->banner_details['settings_url']; ?>"> |
208 | - <span class="dashicons dashicons-admin-settings"></span><?php esc_html_e( 'Go to Settings', 'give' ); ?> |
|
208 | + <span class="dashicons dashicons-admin-settings"></span><?php esc_html_e('Go to Settings', 'give'); ?> |
|
209 | 209 | </a> |
210 | 210 | <?php } ?> |
211 | 211 | |
212 | 212 | <?php |
213 | 213 | // Show them how to configure the Addon. |
214 | - if ( isset( $this->banner_details['documentation_url'] ) ) { ?> |
|
214 | + if (isset($this->banner_details['documentation_url'])) { ?> |
|
215 | 215 | <a href="<?php echo $this->banner_details['documentation_url'] ?>" target="_blank"> |
216 | 216 | <span class="dashicons dashicons-media-text"></span><?php |
217 | 217 | printf( |
218 | 218 | /* translators: %s: Add-on name */ |
219 | - esc_html__( 'Documentation: %s Add-on', 'give' ), |
|
219 | + esc_html__('Documentation: %s Add-on', 'give'), |
|
220 | 220 | $this->banner_details['name'] |
221 | 221 | ); |
222 | 222 | ?></a> |
223 | 223 | <?php } ?> |
224 | 224 | <?php |
225 | 225 | //Let them signup for plugin updates |
226 | - if ( isset( $this->banner_details['support_url'] ) ) { ?> |
|
226 | + if (isset($this->banner_details['support_url'])) { ?> |
|
227 | 227 | |
228 | 228 | <a href="<?php echo $this->banner_details['support_url'] ?>" target="_blank"> |
229 | - <span class="dashicons dashicons-sos"></span><?php esc_html_e( 'Get Support', 'give' ); ?> |
|
229 | + <span class="dashicons dashicons-sos"></span><?php esc_html_e('Get Support', 'give'); ?> |
|
230 | 230 | </a> |
231 | 231 | |
232 | 232 | <?php } ?> |
@@ -253,13 +253,13 @@ discard block |
||
253 | 253 | * If user clicks to ignore the notice, add that to their user meta the banner then checks whether this tag exists already or not. |
254 | 254 | * See here: http://codex.wordpress.org/Function_Reference/add_user_meta |
255 | 255 | */ |
256 | - if ( isset( $_GET[ $this->nag_meta_key ] ) && '0' == $_GET[ $this->nag_meta_key ] ) { |
|
256 | + if (isset($_GET[$this->nag_meta_key]) && '0' == $_GET[$this->nag_meta_key]) { |
|
257 | 257 | |
258 | 258 | //Get the global user |
259 | 259 | $current_user = wp_get_current_user(); |
260 | 260 | $user_id = $current_user->ID; |
261 | 261 | |
262 | - add_user_meta( $user_id, $this->nag_meta_key, 'true', true ); |
|
262 | + add_user_meta($user_id, $this->nag_meta_key, 'true', true); |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | * @access private |
271 | 271 | */ |
272 | 272 | private function add_addon_activate_meta() { |
273 | - $user_id = get_option( $this->activate_by_meta_key ); |
|
273 | + $user_id = get_option($this->activate_by_meta_key); |
|
274 | 274 | $this->plugin_activate_by = (int) $user_id; |
275 | 275 | |
276 | - if ( ! $user_id ) { |
|
277 | - add_option( $this->activate_by_meta_key, $this->user_id, '', 'no' ); |
|
276 | + if ( ! $user_id) { |
|
277 | + add_option($this->activate_by_meta_key, $this->user_id, '', 'no'); |
|
278 | 278 | $this->plugin_activate_by = (int) $this->user_id; |
279 | 279 | } |
280 | 280 | } |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | * @access public |
288 | 288 | */ |
289 | 289 | public function remove_addon_activate_meta() { |
290 | - $user_id = get_option( $this->activate_by_meta_key ); |
|
290 | + $user_id = get_option($this->activate_by_meta_key); |
|
291 | 291 | |
292 | - if ( $user_id ) { |
|
293 | - delete_option( $this->activate_by_meta_key ); |
|
292 | + if ($user_id) { |
|
293 | + delete_option($this->activate_by_meta_key); |
|
294 | 294 | } |
295 | 295 | } |
296 | 296 | |
@@ -303,39 +303,39 @@ discard block |
||
303 | 303 | * @return mixed |
304 | 304 | */ |
305 | 305 | private function get_plugin_file_name() { |
306 | - $active_plugins = get_option( 'active_plugins' ); |
|
306 | + $active_plugins = get_option('active_plugins'); |
|
307 | 307 | $file_name = ''; |
308 | 308 | |
309 | 309 | try { |
310 | 310 | |
311 | 311 | // Check addon file path. |
312 | - if ( ! empty( $this->banner_details['file'] ) ) { |
|
312 | + if ( ! empty($this->banner_details['file'])) { |
|
313 | 313 | $file_name = ''; |
314 | - if ( $file_path = explode( '/plugins/', $this->banner_details['file'] ) ) { |
|
315 | - $file_path = array_pop( $file_path ); |
|
316 | - $file_name = current( explode( '/', $file_path ) ); |
|
314 | + if ($file_path = explode('/plugins/', $this->banner_details['file'])) { |
|
315 | + $file_path = array_pop($file_path); |
|
316 | + $file_name = current(explode('/', $file_path)); |
|
317 | 317 | } |
318 | 318 | |
319 | - if ( empty( $file_name ) ) { |
|
319 | + if (empty($file_name)) { |
|
320 | 320 | return false; |
321 | 321 | } |
322 | 322 | |
323 | - foreach ( $active_plugins as $plugin ) { |
|
324 | - if ( false !== strpos( $plugin, $file_name ) ) { |
|
323 | + foreach ($active_plugins as $plugin) { |
|
324 | + if (false !== strpos($plugin, $file_name)) { |
|
325 | 325 | $file_name = $plugin; |
326 | 326 | break; |
327 | 327 | } |
328 | 328 | } |
329 | - } elseif ( WP_DEBUG ) { |
|
330 | - throw new Exception( __( "File path must be added within the {$this->banner_details['name']} add-on in the banner details.", 'give' ) ); |
|
329 | + } elseif (WP_DEBUG) { |
|
330 | + throw new Exception(__("File path must be added within the {$this->banner_details['name']} add-on in the banner details.", 'give')); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | // Check plugin path calculated by addon file path. |
334 | - if ( empty( $file_name ) && WP_DEBUG ) { |
|
335 | - throw new Exception( __( "Empty add-on plugin path for {$this->banner_details['name']} add-on.", 'give' ) ); |
|
334 | + if (empty($file_name) && WP_DEBUG) { |
|
335 | + throw new Exception(__("Empty add-on plugin path for {$this->banner_details['name']} add-on.", 'give')); |
|
336 | 336 | } |
337 | 337 | |
338 | - } catch ( Exception $e ) { |
|
338 | + } catch (Exception $e) { |
|
339 | 339 | echo $e->getMessage(); |
340 | 340 | } |
341 | 341 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | give_v187_upgrades(); |
51 | 51 | $did_upgrade = true; |
52 | 52 | |
53 | - case version_compare( $give_version, '1.8.8', '<' ) : |
|
53 | + case version_compare( $give_version, '1.8.8', '<' ) : |
|
54 | 54 | give_v188_upgrades(); |
55 | 55 | $did_upgrade = true; |
56 | 56 | |
@@ -909,19 +909,19 @@ discard block |
||
909 | 909 | |
910 | 910 | global $wp_roles; |
911 | 911 | |
912 | - // Get the role object. |
|
913 | - $give_worker = get_role( 'give_worker' ); |
|
912 | + // Get the role object. |
|
913 | + $give_worker = get_role( 'give_worker' ); |
|
914 | 914 | |
915 | 915 | // A list of capabilities to add for give workers. |
916 | - $caps_to_add = array( |
|
917 | - 'edit_posts', |
|
918 | - 'edit_pages' |
|
919 | - ); |
|
920 | - |
|
921 | - foreach ( $caps_to_add as $cap ) { |
|
922 | - // Add the capability. |
|
923 | - $give_worker->add_cap( $cap ); |
|
924 | - } |
|
916 | + $caps_to_add = array( |
|
917 | + 'edit_posts', |
|
918 | + 'edit_pages' |
|
919 | + ); |
|
920 | + |
|
921 | + foreach ( $caps_to_add as $cap ) { |
|
922 | + // Add the capability. |
|
923 | + $give_worker->add_cap( $cap ); |
|
924 | + } |
|
925 | 925 | |
926 | 926 | } |
927 | 927 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -25,44 +25,44 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_do_automatic_upgrades() { |
27 | 27 | $did_upgrade = false; |
28 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
28 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
29 | 29 | |
30 | - if ( ! $give_version ) { |
|
30 | + if ( ! $give_version) { |
|
31 | 31 | // 1.0 is the first version to use this option so we must add it. |
32 | 32 | $give_version = '1.0'; |
33 | 33 | } |
34 | 34 | |
35 | - switch ( true ) { |
|
35 | + switch (true) { |
|
36 | 36 | |
37 | - case version_compare( $give_version, '1.6', '<' ) : |
|
37 | + case version_compare($give_version, '1.6', '<') : |
|
38 | 38 | give_v16_upgrades(); |
39 | 39 | $did_upgrade = true; |
40 | 40 | |
41 | - case version_compare( $give_version, '1.7', '<' ) : |
|
41 | + case version_compare($give_version, '1.7', '<') : |
|
42 | 42 | give_v17_upgrades(); |
43 | 43 | $did_upgrade = true; |
44 | 44 | |
45 | - case version_compare( $give_version, '1.8', '<' ) : |
|
45 | + case version_compare($give_version, '1.8', '<') : |
|
46 | 46 | give_v18_upgrades(); |
47 | 47 | $did_upgrade = true; |
48 | 48 | |
49 | - case version_compare( $give_version, '1.8.7', '<' ) : |
|
49 | + case version_compare($give_version, '1.8.7', '<') : |
|
50 | 50 | give_v187_upgrades(); |
51 | 51 | $did_upgrade = true; |
52 | 52 | |
53 | - case version_compare( $give_version, '1.8.8', '<' ) : |
|
53 | + case version_compare($give_version, '1.8.8', '<') : |
|
54 | 54 | give_v188_upgrades(); |
55 | 55 | $did_upgrade = true; |
56 | 56 | |
57 | 57 | } |
58 | 58 | |
59 | - if ( $did_upgrade ) { |
|
60 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
59 | + if ($did_upgrade) { |
|
60 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
65 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
64 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
65 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Display Upgrade Notices |
@@ -72,18 +72,18 @@ discard block |
||
72 | 72 | */ |
73 | 73 | function give_show_upgrade_notices() { |
74 | 74 | // Don't show notices on the upgrades page. |
75 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-upgrades' ) { |
|
75 | + if (isset($_GET['page']) && $_GET['page'] == 'give-upgrades') { |
|
76 | 76 | return; |
77 | 77 | } |
78 | 78 | |
79 | - $give_version = get_option( 'give_version' ); |
|
79 | + $give_version = get_option('give_version'); |
|
80 | 80 | |
81 | - if ( ! $give_version ) { |
|
81 | + if ( ! $give_version) { |
|
82 | 82 | // 1.0 is the first version to use this option so we must add it. |
83 | 83 | $give_version = '1.0'; |
84 | 84 | } |
85 | 85 | |
86 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
86 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
87 | 87 | |
88 | 88 | /* |
89 | 89 | * NOTICE: |
@@ -94,31 +94,31 @@ discard block |
||
94 | 94 | */ |
95 | 95 | |
96 | 96 | // v1.3.2 Upgrades |
97 | - if ( version_compare( $give_version, '1.3.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) { |
|
97 | + if (version_compare($give_version, '1.3.2', '<') || ! give_has_upgrade_completed('upgrade_give_payment_customer_id')) { |
|
98 | 98 | printf( |
99 | 99 | /* translators: %s: upgrade URL */ |
100 | - '<div class="updated"><p>' . __( 'Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>', |
|
101 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id' ) ) |
|
100 | + '<div class="updated"><p>'.__('Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>', |
|
101 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id')) |
|
102 | 102 | ); |
103 | 103 | } |
104 | 104 | |
105 | 105 | // v1.3.4 Upgrades //ensure the user has gone through 1.3.4. |
106 | - if ( version_compare( $give_version, '1.3.4', '<' ) || ( ! give_has_upgrade_completed( 'upgrade_give_offline_status' ) && give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) ) { |
|
106 | + if (version_compare($give_version, '1.3.4', '<') || ( ! give_has_upgrade_completed('upgrade_give_offline_status') && give_has_upgrade_completed('upgrade_give_payment_customer_id'))) { |
|
107 | 107 | printf( |
108 | 108 | /* translators: %s: upgrade URL */ |
109 | - '<div class="updated"><p>' . __( 'Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>', |
|
110 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status' ) ) |
|
109 | + '<div class="updated"><p>'.__('Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>', |
|
110 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status')) |
|
111 | 111 | ); |
112 | 112 | } |
113 | 113 | |
114 | 114 | // Check if we have a stalled upgrade. |
115 | 115 | $resume_upgrade = give_maybe_resume_upgrade(); |
116 | - if ( ! empty( $resume_upgrade ) ) { |
|
117 | - $resume_url = add_query_arg( $resume_upgrade, admin_url( 'index.php' ) ); |
|
116 | + if ( ! empty($resume_upgrade)) { |
|
117 | + $resume_url = add_query_arg($resume_upgrade, admin_url('index.php')); |
|
118 | 118 | echo Give_Notices::notice_html( |
119 | 119 | sprintf( |
120 | - __( 'Give needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'give' ), |
|
121 | - esc_url( $resume_url ) |
|
120 | + __('Give needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'give'), |
|
121 | + esc_url($resume_url) |
|
122 | 122 | ) |
123 | 123 | ); |
124 | 124 | |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | // v1.8 form metadata upgrades. |
129 | - if ( version_compare( $give_version, '1.8', '<' ) || ! give_has_upgrade_completed( 'v18_upgrades_form_metadata' ) ) { |
|
129 | + if (version_compare($give_version, '1.8', '<') || ! give_has_upgrade_completed('v18_upgrades_form_metadata')) { |
|
130 | 130 | echo Give_Notices::notice_html( |
131 | 131 | sprintf( |
132 | - esc_html__( 'Give needs to upgrade the form database, click %1$shere%2$s to start the upgrade.', 'give' ), |
|
133 | - '<a class="give-upgrade-link" href="' . esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=give_v18_upgrades_form_metadata' ) ) . '">', |
|
132 | + esc_html__('Give needs to upgrade the form database, click %1$shere%2$s to start the upgrade.', 'give'), |
|
133 | + '<a class="give-upgrade-link" href="'.esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=give_v18_upgrades_form_metadata')).'">', |
|
134 | 134 | '</a>' |
135 | 135 | ) |
136 | 136 | ); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $upgrade_links.on( 'click', function(e){ |
146 | 146 | e.preventDefault(); |
147 | 147 | |
148 | - if( ! window.confirm( '<?php _e( 'Please make sure to create a database backup before initiating the upgrade.', 'give' ); ?>' ) ) { |
|
148 | + if( ! window.confirm( '<?php _e('Please make sure to create a database backup before initiating the upgrade.', 'give'); ?>' ) ) { |
|
149 | 149 | return; |
150 | 150 | } |
151 | 151 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | <?php |
159 | 159 | } |
160 | 160 | |
161 | -add_action( 'admin_notices', 'give_show_upgrade_notices' ); |
|
161 | +add_action('admin_notices', 'give_show_upgrade_notices'); |
|
162 | 162 | |
163 | 163 | /** |
164 | 164 | * Triggers all upgrade functions |
@@ -170,29 +170,29 @@ discard block |
||
170 | 170 | */ |
171 | 171 | function give_trigger_upgrades() { |
172 | 172 | |
173 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
174 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
173 | + if ( ! current_user_can('manage_give_settings')) { |
|
174 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
175 | 175 | 'response' => 403, |
176 | - ) ); |
|
176 | + )); |
|
177 | 177 | } |
178 | 178 | |
179 | - $give_version = get_option( 'give_version' ); |
|
179 | + $give_version = get_option('give_version'); |
|
180 | 180 | |
181 | - if ( ! $give_version ) { |
|
181 | + if ( ! $give_version) { |
|
182 | 182 | // 1.0 is the first version to use this option so we must add it. |
183 | 183 | $give_version = '1.0'; |
184 | - add_option( 'give_version', $give_version ); |
|
184 | + add_option('give_version', $give_version); |
|
185 | 185 | } |
186 | 186 | |
187 | - update_option( 'give_version', GIVE_VERSION ); |
|
188 | - delete_option( 'give_doing_upgrade' ); |
|
187 | + update_option('give_version', GIVE_VERSION); |
|
188 | + delete_option('give_doing_upgrade'); |
|
189 | 189 | |
190 | - if ( DOING_AJAX ) { |
|
191 | - die( 'complete' ); |
|
190 | + if (DOING_AJAX) { |
|
191 | + die('complete'); |
|
192 | 192 | } // End if(). |
193 | 193 | } |
194 | 194 | |
195 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
195 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
196 | 196 | |
197 | 197 | /** |
198 | 198 | * Check if the upgrade routine has been run for a specific action |
@@ -203,15 +203,15 @@ discard block |
||
203 | 203 | * |
204 | 204 | * @return bool If the action has been added to the completed actions array |
205 | 205 | */ |
206 | -function give_has_upgrade_completed( $upgrade_action = '' ) { |
|
206 | +function give_has_upgrade_completed($upgrade_action = '') { |
|
207 | 207 | |
208 | - if ( empty( $upgrade_action ) ) { |
|
208 | + if (empty($upgrade_action)) { |
|
209 | 209 | return false; |
210 | 210 | } |
211 | 211 | |
212 | 212 | $completed_upgrades = give_get_completed_upgrades(); |
213 | 213 | |
214 | - return in_array( $upgrade_action, $completed_upgrades ); |
|
214 | + return in_array($upgrade_action, $completed_upgrades); |
|
215 | 215 | |
216 | 216 | } |
217 | 217 | |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | * @return mixed When nothing to resume returns false, otherwise starts the upgrade where it left off |
224 | 224 | */ |
225 | 225 | function give_maybe_resume_upgrade() { |
226 | - $doing_upgrade = get_option( 'give_doing_upgrade', false ); |
|
227 | - if ( empty( $doing_upgrade ) ) { |
|
226 | + $doing_upgrade = get_option('give_doing_upgrade', false); |
|
227 | + if (empty($doing_upgrade)) { |
|
228 | 228 | return false; |
229 | 229 | } |
230 | 230 | |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return bool If the function was successfully added |
242 | 242 | */ |
243 | -function give_set_upgrade_complete( $upgrade_action = '' ) { |
|
243 | +function give_set_upgrade_complete($upgrade_action = '') { |
|
244 | 244 | |
245 | - if ( empty( $upgrade_action ) ) { |
|
245 | + if (empty($upgrade_action)) { |
|
246 | 246 | return false; |
247 | 247 | } |
248 | 248 | |
@@ -250,9 +250,9 @@ discard block |
||
250 | 250 | $completed_upgrades[] = $upgrade_action; |
251 | 251 | |
252 | 252 | // Remove any blanks, and only show uniques. |
253 | - $completed_upgrades = array_unique( array_values( $completed_upgrades ) ); |
|
253 | + $completed_upgrades = array_unique(array_values($completed_upgrades)); |
|
254 | 254 | |
255 | - return update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
255 | + return update_option('give_completed_upgrades', $completed_upgrades); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -263,9 +263,9 @@ discard block |
||
263 | 263 | */ |
264 | 264 | function give_get_completed_upgrades() { |
265 | 265 | |
266 | - $completed_upgrades = get_option( 'give_completed_upgrades' ); |
|
266 | + $completed_upgrades = get_option('give_completed_upgrades'); |
|
267 | 267 | |
268 | - if ( false === $completed_upgrades ) { |
|
268 | + if (false === $completed_upgrades) { |
|
269 | 269 | $completed_upgrades = array(); |
270 | 270 | } |
271 | 271 | |
@@ -282,31 +282,31 @@ discard block |
||
282 | 282 | */ |
283 | 283 | function give_v132_upgrade_give_payment_customer_id() { |
284 | 284 | global $wpdb; |
285 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
286 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
285 | + if ( ! current_user_can('manage_give_settings')) { |
|
286 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
287 | 287 | 'response' => 403, |
288 | - ) ); |
|
288 | + )); |
|
289 | 289 | } |
290 | 290 | |
291 | - ignore_user_abort( true ); |
|
291 | + ignore_user_abort(true); |
|
292 | 292 | |
293 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
294 | - @set_time_limit( 0 ); |
|
293 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
294 | + @set_time_limit(0); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | // UPDATE DB METAKEYS. |
298 | 298 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
299 | - $query = $wpdb->query( $sql ); |
|
299 | + $query = $wpdb->query($sql); |
|
300 | 300 | |
301 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
302 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
303 | - delete_option( 'give_doing_upgrade' ); |
|
304 | - wp_redirect( admin_url() ); |
|
301 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
302 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
303 | + delete_option('give_doing_upgrade'); |
|
304 | + wp_redirect(admin_url()); |
|
305 | 305 | exit; |
306 | 306 | |
307 | 307 | } |
308 | 308 | |
309 | -add_action( 'give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id' ); |
|
309 | +add_action('give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id'); |
|
310 | 310 | |
311 | 311 | /** |
312 | 312 | * Upgrades the Offline Status |
@@ -319,16 +319,16 @@ discard block |
||
319 | 319 | |
320 | 320 | global $wpdb; |
321 | 321 | |
322 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
323 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
322 | + if ( ! current_user_can('manage_give_settings')) { |
|
323 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
324 | 324 | 'response' => 403, |
325 | - ) ); |
|
325 | + )); |
|
326 | 326 | } |
327 | 327 | |
328 | - ignore_user_abort( true ); |
|
328 | + ignore_user_abort(true); |
|
329 | 329 | |
330 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
331 | - @set_time_limit( 0 ); |
|
330 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
331 | + @set_time_limit(0); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | // Get abandoned offline payments. |
@@ -338,31 +338,31 @@ discard block |
||
338 | 338 | $where .= "AND ( p.post_status = 'abandoned' )"; |
339 | 339 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
340 | 340 | |
341 | - $sql = $select . $join . $where; |
|
342 | - $found_payments = $wpdb->get_col( $sql ); |
|
341 | + $sql = $select.$join.$where; |
|
342 | + $found_payments = $wpdb->get_col($sql); |
|
343 | 343 | |
344 | - foreach ( $found_payments as $payment ) { |
|
344 | + foreach ($found_payments as $payment) { |
|
345 | 345 | |
346 | 346 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
347 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
347 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
348 | 348 | |
349 | 349 | // 1450124863 = 12/10/2015 20:42:25. |
350 | - if ( $modified_time >= 1450124863 ) { |
|
350 | + if ($modified_time >= 1450124863) { |
|
351 | 351 | |
352 | - give_update_payment_status( $payment, 'pending' ); |
|
352 | + give_update_payment_status($payment, 'pending'); |
|
353 | 353 | |
354 | 354 | } |
355 | 355 | } |
356 | 356 | |
357 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
358 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
359 | - delete_option( 'give_doing_upgrade' ); |
|
360 | - wp_redirect( admin_url() ); |
|
357 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
358 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
359 | + delete_option('give_doing_upgrade'); |
|
360 | + wp_redirect(admin_url()); |
|
361 | 361 | exit; |
362 | 362 | |
363 | 363 | } |
364 | 364 | |
365 | -add_action( 'give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status' ); |
|
365 | +add_action('give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status'); |
|
366 | 366 | |
367 | 367 | /** |
368 | 368 | * Cleanup User Roles |
@@ -373,17 +373,17 @@ discard block |
||
373 | 373 | */ |
374 | 374 | function give_v152_cleanup_users() { |
375 | 375 | |
376 | - $give_version = get_option( 'give_version' ); |
|
376 | + $give_version = get_option('give_version'); |
|
377 | 377 | |
378 | - if ( ! $give_version ) { |
|
378 | + if ( ! $give_version) { |
|
379 | 379 | // 1.0 is the first version to use this option so we must add it. |
380 | 380 | $give_version = '1.0'; |
381 | 381 | } |
382 | 382 | |
383 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
383 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
384 | 384 | |
385 | 385 | // v1.5.2 Upgrades |
386 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
386 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
387 | 387 | |
388 | 388 | // Delete all caps with "ss". |
389 | 389 | // Also delete all unused "campaign" roles. |
@@ -430,9 +430,9 @@ discard block |
||
430 | 430 | ); |
431 | 431 | |
432 | 432 | global $wp_roles; |
433 | - foreach ( $delete_caps as $cap ) { |
|
434 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
435 | - $wp_roles->remove_cap( $role, $cap ); |
|
433 | + foreach ($delete_caps as $cap) { |
|
434 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
435 | + $wp_roles->remove_cap($role, $cap); |
|
436 | 436 | } |
437 | 437 | } |
438 | 438 | |
@@ -442,15 +442,15 @@ discard block |
||
442 | 442 | $roles->add_caps(); |
443 | 443 | |
444 | 444 | // The Update Ran. |
445 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
446 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
447 | - delete_option( 'give_doing_upgrade' ); |
|
445 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
446 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
447 | + delete_option('give_doing_upgrade'); |
|
448 | 448 | |
449 | 449 | }// End if(). |
450 | 450 | |
451 | 451 | } |
452 | 452 | |
453 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
453 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
454 | 454 | |
455 | 455 | /** |
456 | 456 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -490,53 +490,53 @@ discard block |
||
490 | 490 | |
491 | 491 | // Get addons license key. |
492 | 492 | $addons = array(); |
493 | - foreach ( $give_options as $key => $value ) { |
|
494 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
495 | - $addons[ $key ] = $value; |
|
493 | + foreach ($give_options as $key => $value) { |
|
494 | + if (false !== strpos($key, '_license_key')) { |
|
495 | + $addons[$key] = $value; |
|
496 | 496 | } |
497 | 497 | } |
498 | 498 | |
499 | 499 | // Bailout: We do not have any addon license data to upgrade. |
500 | - if ( empty( $addons ) ) { |
|
500 | + if (empty($addons)) { |
|
501 | 501 | return false; |
502 | 502 | } |
503 | 503 | |
504 | - foreach ( $addons as $key => $addon_license ) { |
|
504 | + foreach ($addons as $key => $addon_license) { |
|
505 | 505 | |
506 | 506 | // Get addon shortname. |
507 | - $shortname = str_replace( '_license_key', '', $key ); |
|
507 | + $shortname = str_replace('_license_key', '', $key); |
|
508 | 508 | |
509 | 509 | // Addon license option name. |
510 | - $addon_license_option_name = $shortname . '_license_active'; |
|
510 | + $addon_license_option_name = $shortname.'_license_active'; |
|
511 | 511 | |
512 | 512 | // bailout if license is empty. |
513 | - if ( empty( $addon_license ) ) { |
|
514 | - delete_option( $addon_license_option_name ); |
|
513 | + if (empty($addon_license)) { |
|
514 | + delete_option($addon_license_option_name); |
|
515 | 515 | continue; |
516 | 516 | } |
517 | 517 | |
518 | 518 | // Get addon name. |
519 | 519 | $addon_name = array(); |
520 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
521 | - foreach ( $addon_name_parts as $name_part ) { |
|
520 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
521 | + foreach ($addon_name_parts as $name_part) { |
|
522 | 522 | |
523 | 523 | // Fix addon name |
524 | - switch ( $name_part ) { |
|
524 | + switch ($name_part) { |
|
525 | 525 | case 'authorizenet' : |
526 | 526 | $name_part = 'authorize.net'; |
527 | 527 | break; |
528 | 528 | } |
529 | 529 | |
530 | - $addon_name[] = ucfirst( $name_part ); |
|
530 | + $addon_name[] = ucfirst($name_part); |
|
531 | 531 | } |
532 | 532 | |
533 | - $addon_name = implode( ' ', $addon_name ); |
|
533 | + $addon_name = implode(' ', $addon_name); |
|
534 | 534 | |
535 | 535 | // Data to send to the API |
536 | 536 | $api_params = array( |
537 | 537 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
538 | 538 | 'license' => $addon_license, |
539 | - 'item_name' => urlencode( $addon_name ), |
|
539 | + 'item_name' => urlencode($addon_name), |
|
540 | 540 | 'url' => home_url(), |
541 | 541 | ); |
542 | 542 | |
@@ -551,17 +551,17 @@ discard block |
||
551 | 551 | ); |
552 | 552 | |
553 | 553 | // Make sure there are no errors. |
554 | - if ( is_wp_error( $response ) ) { |
|
555 | - delete_option( $addon_license_option_name ); |
|
554 | + if (is_wp_error($response)) { |
|
555 | + delete_option($addon_license_option_name); |
|
556 | 556 | continue; |
557 | 557 | } |
558 | 558 | |
559 | 559 | // Tell WordPress to look for updates. |
560 | - set_site_transient( 'update_plugins', null ); |
|
560 | + set_site_transient('update_plugins', null); |
|
561 | 561 | |
562 | 562 | // Decode license data. |
563 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
564 | - update_option( $addon_license_option_name, $license_data ); |
|
563 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
564 | + update_option($addon_license_option_name, $license_data); |
|
565 | 565 | }// End foreach(). |
566 | 566 | } |
567 | 567 | |
@@ -591,9 +591,9 @@ discard block |
||
591 | 591 | ); |
592 | 592 | |
593 | 593 | global $wp_roles; |
594 | - foreach ( $delete_caps as $cap ) { |
|
595 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
596 | - $wp_roles->remove_cap( $role, $cap ); |
|
594 | + foreach ($delete_caps as $cap) { |
|
595 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
596 | + $wp_roles->remove_cap($role, $cap); |
|
597 | 597 | } |
598 | 598 | } |
599 | 599 | |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | function give_v18_upgrades_core_setting() { |
628 | 628 | // Core settings which changes from checkbox to radio. |
629 | 629 | $core_setting_names = array_merge( |
630 | - array_keys( give_v18_renamed_core_settings() ), |
|
630 | + array_keys(give_v18_renamed_core_settings()), |
|
631 | 631 | array( |
632 | 632 | 'uninstall_on_delete', |
633 | 633 | 'scripts_footer', |
@@ -639,48 +639,48 @@ discard block |
||
639 | 639 | ); |
640 | 640 | |
641 | 641 | // Bailout: If not any setting define. |
642 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
642 | + if ($give_settings = get_option('give_settings')) { |
|
643 | 643 | |
644 | 644 | $setting_changed = false; |
645 | 645 | |
646 | 646 | // Loop: check each setting field. |
647 | - foreach ( $core_setting_names as $setting_name ) { |
|
647 | + foreach ($core_setting_names as $setting_name) { |
|
648 | 648 | // New setting name. |
649 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
649 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
650 | 650 | |
651 | 651 | // Continue: If setting already set. |
652 | 652 | if ( |
653 | - array_key_exists( $new_setting_name, $give_settings ) |
|
654 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
653 | + array_key_exists($new_setting_name, $give_settings) |
|
654 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
655 | 655 | ) { |
656 | 656 | continue; |
657 | 657 | } |
658 | 658 | |
659 | 659 | // Set checkbox value to radio value. |
660 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
660 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
661 | 661 | |
662 | 662 | // @see https://github.com/WordImpress/Give/issues/1063 |
663 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
663 | + if (false !== strpos($setting_name, 'disable_')) { |
|
664 | 664 | |
665 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
666 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
665 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
666 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
667 | 667 | |
668 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
668 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | // Tell bot to update core setting to db. |
672 | - if ( ! $setting_changed ) { |
|
672 | + if ( ! $setting_changed) { |
|
673 | 673 | $setting_changed = true; |
674 | 674 | } |
675 | 675 | } |
676 | 676 | |
677 | 677 | // Update setting only if they changed. |
678 | - if ( $setting_changed ) { |
|
679 | - update_option( 'give_settings', $give_settings ); |
|
678 | + if ($setting_changed) { |
|
679 | + update_option('give_settings', $give_settings); |
|
680 | 680 | } |
681 | 681 | }// End if(). |
682 | 682 | |
683 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
683 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | /** |
@@ -690,22 +690,22 @@ discard block |
||
690 | 690 | * @return void |
691 | 691 | */ |
692 | 692 | function give_v18_upgrades_form_metadata() { |
693 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
694 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
693 | + if ( ! current_user_can('manage_give_settings')) { |
|
694 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
695 | 695 | 'response' => 403, |
696 | - ) ); |
|
696 | + )); |
|
697 | 697 | } |
698 | 698 | |
699 | - ignore_user_abort( true ); |
|
699 | + ignore_user_abort(true); |
|
700 | 700 | |
701 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
702 | - @set_time_limit( 0 ); |
|
701 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
702 | + @set_time_limit(0); |
|
703 | 703 | } |
704 | 704 | |
705 | - $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; |
|
705 | + $step = isset($_GET['step']) ? absint($_GET['step']) : 1; |
|
706 | 706 | |
707 | 707 | // form query |
708 | - $forms = new WP_Query( array( |
|
708 | + $forms = new WP_Query(array( |
|
709 | 709 | 'paged' => $step, |
710 | 710 | 'status' => 'any', |
711 | 711 | 'order' => 'ASC', |
@@ -714,39 +714,39 @@ discard block |
||
714 | 714 | ) |
715 | 715 | ); |
716 | 716 | |
717 | - if ( $forms->have_posts() ) { |
|
718 | - while ( $forms->have_posts() ) { |
|
717 | + if ($forms->have_posts()) { |
|
718 | + while ($forms->have_posts()) { |
|
719 | 719 | $forms->the_post(); |
720 | 720 | |
721 | 721 | // Form content. |
722 | 722 | // Note in version 1.8 display content setting split into display content and content placement setting. |
723 | 723 | // You can delete _give_content_option in future |
724 | - $show_content = give_get_meta( get_the_ID(), '_give_content_option', true ); |
|
725 | - if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
726 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
727 | - give_update_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
724 | + $show_content = give_get_meta(get_the_ID(), '_give_content_option', true); |
|
725 | + if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) { |
|
726 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
727 | + give_update_meta(get_the_ID(), '_give_display_content', $field_value); |
|
728 | 728 | |
729 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
730 | - give_update_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
729 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
730 | + give_update_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 | // "Disable" Guest Donation. Checkbox |
734 | 734 | // See: https://github.com/WordImpress/Give/issues/1470 |
735 | - $guest_donation = give_get_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
736 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
737 | - give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
735 | + $guest_donation = give_get_meta(get_the_ID(), '_give_logged_in_only', true); |
|
736 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
737 | + give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
738 | 738 | |
739 | 739 | // Offline Donations |
740 | 740 | // See: https://github.com/WordImpress/Give/issues/1579 |
741 | - $offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
742 | - if ( 'no' === $offline_donation ) { |
|
741 | + $offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
742 | + if ('no' === $offline_donation) { |
|
743 | 743 | $offline_donation_newval = 'global'; |
744 | - } elseif ( 'yes' === $offline_donation ) { |
|
744 | + } elseif ('yes' === $offline_donation) { |
|
745 | 745 | $offline_donation_newval = 'enabled'; |
746 | 746 | } else { |
747 | 747 | $offline_donation_newval = 'disabled'; |
748 | 748 | } |
749 | - give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval ); |
|
749 | + give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval); |
|
750 | 750 | |
751 | 751 | // Convert yes/no setting field to enabled/disabled. |
752 | 752 | $form_radio_settings = array( |
@@ -766,15 +766,15 @@ discard block |
||
766 | 766 | '_give_offline_donation_enable_billing_fields_single', |
767 | 767 | ); |
768 | 768 | |
769 | - foreach ( $form_radio_settings as $meta_key ) { |
|
769 | + foreach ($form_radio_settings as $meta_key) { |
|
770 | 770 | // Get value. |
771 | - $field_value = give_get_meta( get_the_ID(), $meta_key, true ); |
|
771 | + $field_value = give_get_meta(get_the_ID(), $meta_key, true); |
|
772 | 772 | |
773 | 773 | // Convert meta value only if it is in yes/no/none. |
774 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
774 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
775 | 775 | |
776 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
777 | - give_update_meta( get_the_ID(), $meta_key, $field_value ); |
|
776 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
777 | + give_update_meta(get_the_ID(), $meta_key, $field_value); |
|
778 | 778 | } |
779 | 779 | } |
780 | 780 | }// End while(). |
@@ -782,27 +782,27 @@ discard block |
||
782 | 782 | wp_reset_postdata(); |
783 | 783 | |
784 | 784 | // Forms found so upgrade them |
785 | - $step ++; |
|
786 | - $redirect = add_query_arg( array( |
|
785 | + $step++; |
|
786 | + $redirect = add_query_arg(array( |
|
787 | 787 | 'page' => 'give-upgrades', |
788 | 788 | 'give-upgrade' => 'give_v18_upgrades_form_metadata', |
789 | 789 | 'step' => $step, |
790 | - ), admin_url( 'index.php' ) ); |
|
791 | - wp_redirect( $redirect ); |
|
790 | + ), admin_url('index.php')); |
|
791 | + wp_redirect($redirect); |
|
792 | 792 | exit(); |
793 | 793 | |
794 | 794 | } else { |
795 | 795 | // No more forms found, finish up. |
796 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
797 | - delete_option( 'give_doing_upgrade' ); |
|
798 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
796 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
797 | + delete_option('give_doing_upgrade'); |
|
798 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
799 | 799 | |
800 | - wp_redirect( admin_url() ); |
|
800 | + wp_redirect(admin_url()); |
|
801 | 801 | exit; |
802 | 802 | } |
803 | 803 | } |
804 | 804 | |
805 | -add_action( 'give_give_v18_upgrades_form_metadata', 'give_v18_upgrades_form_metadata' ); |
|
805 | +add_action('give_give_v18_upgrades_form_metadata', 'give_v18_upgrades_form_metadata'); |
|
806 | 806 | |
807 | 807 | /** |
808 | 808 | * Get list of core setting renamed in version 1.8. |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | * @since 1.8.7 |
836 | 836 | * @return void |
837 | 837 | */ |
838 | -function give_v187_upgrades(){ |
|
838 | +function give_v187_upgrades() { |
|
839 | 839 | global $wpdb; |
840 | 840 | |
841 | 841 | /** |
@@ -875,24 +875,24 @@ discard block |
||
875 | 875 | ARRAY_A |
876 | 876 | ); |
877 | 877 | |
878 | - if( ! empty( $user_apikey_options ) ) { |
|
879 | - foreach ( $user_apikey_options as $user ) { |
|
880 | - $cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] ); |
|
881 | - $cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] ); |
|
882 | - $cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] ); |
|
878 | + if ( ! empty($user_apikey_options)) { |
|
879 | + foreach ($user_apikey_options as $user) { |
|
880 | + $cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']); |
|
881 | + $cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']); |
|
882 | + $cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']); |
|
883 | 883 | } |
884 | 884 | } |
885 | 885 | |
886 | - if ( ! empty( $cached_options ) ) { |
|
887 | - foreach ( $cached_options as $option ) { |
|
888 | - switch ( true ) { |
|
889 | - case ( false !== strpos( $option, 'transient' ) ): |
|
890 | - $option = str_replace( '_transient_', '', $option ); |
|
891 | - delete_transient( $option ); |
|
886 | + if ( ! empty($cached_options)) { |
|
887 | + foreach ($cached_options as $option) { |
|
888 | + switch (true) { |
|
889 | + case (false !== strpos($option, 'transient')): |
|
890 | + $option = str_replace('_transient_', '', $option); |
|
891 | + delete_transient($option); |
|
892 | 892 | break; |
893 | 893 | |
894 | 894 | default: |
895 | - delete_option( $option ); |
|
895 | + delete_option($option); |
|
896 | 896 | } |
897 | 897 | } |
898 | 898 | } |
@@ -910,7 +910,7 @@ discard block |
||
910 | 910 | global $wp_roles; |
911 | 911 | |
912 | 912 | // Get the role object. |
913 | - $give_worker = get_role( 'give_worker' ); |
|
913 | + $give_worker = get_role('give_worker'); |
|
914 | 914 | |
915 | 915 | // A list of capabilities to add for give workers. |
916 | 916 | $caps_to_add = array( |
@@ -918,9 +918,9 @@ discard block |
||
918 | 918 | 'edit_pages' |
919 | 919 | ); |
920 | 920 | |
921 | - foreach ( $caps_to_add as $cap ) { |
|
921 | + foreach ($caps_to_add as $cap) { |
|
922 | 922 | // Add the capability. |
923 | - $give_worker->add_cap( $cap ); |
|
923 | + $give_worker->add_cap($cap); |
|
924 | 924 | } |
925 | 925 | |
926 | 926 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -27,34 +27,34 @@ discard block |
||
27 | 27 | * @return array $form_columns Updated array of forms columns |
28 | 28 | * Post Type List Table |
29 | 29 | */ |
30 | -function give_form_columns( $give_form_columns ) { |
|
30 | +function give_form_columns($give_form_columns) { |
|
31 | 31 | |
32 | 32 | // Standard columns |
33 | 33 | $give_form_columns = array( |
34 | 34 | 'cb' => '<input type="checkbox"/>', |
35 | - 'title' => esc_html__( 'Name', 'give' ), |
|
36 | - 'form_category' => esc_html__( 'Categories', 'give' ), |
|
37 | - 'form_tag' => esc_html__( 'Tags', 'give' ), |
|
38 | - 'price' => esc_html__( 'Amount', 'give' ), |
|
39 | - 'goal' => esc_html__( 'Goal', 'give' ), |
|
40 | - 'donations' => esc_html__( 'Donations', 'give' ), |
|
41 | - 'earnings' => esc_html__( 'Income', 'give' ), |
|
42 | - 'shortcode' => esc_html__( 'Shortcode', 'give' ), |
|
43 | - 'date' => esc_html__( 'Date', 'give' ), |
|
35 | + 'title' => esc_html__('Name', 'give'), |
|
36 | + 'form_category' => esc_html__('Categories', 'give'), |
|
37 | + 'form_tag' => esc_html__('Tags', 'give'), |
|
38 | + 'price' => esc_html__('Amount', 'give'), |
|
39 | + 'goal' => esc_html__('Goal', 'give'), |
|
40 | + 'donations' => esc_html__('Donations', 'give'), |
|
41 | + 'earnings' => esc_html__('Income', 'give'), |
|
42 | + 'shortcode' => esc_html__('Shortcode', 'give'), |
|
43 | + 'date' => esc_html__('Date', 'give'), |
|
44 | 44 | ); |
45 | 45 | |
46 | 46 | // Does the user want categories / tags? |
47 | - if ( ! give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) { |
|
48 | - unset( $give_form_columns['form_category'] ); |
|
47 | + if ( ! give_is_setting_enabled(give_get_option('categories', 'disabled'))) { |
|
48 | + unset($give_form_columns['form_category']); |
|
49 | 49 | } |
50 | - if ( ! give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) { |
|
51 | - unset( $give_form_columns['form_tag'] ); |
|
50 | + if ( ! give_is_setting_enabled(give_get_option('tags', 'disabled'))) { |
|
51 | + unset($give_form_columns['form_tag']); |
|
52 | 52 | } |
53 | 53 | |
54 | - return apply_filters( 'give_forms_columns', $give_form_columns ); |
|
54 | + return apply_filters('give_forms_columns', $give_form_columns); |
|
55 | 55 | } |
56 | 56 | |
57 | -add_filter( 'manage_edit-give_forms_columns', 'give_form_columns' ); |
|
57 | +add_filter('manage_edit-give_forms_columns', 'give_form_columns'); |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Render Give Form Columns |
@@ -66,59 +66,59 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return void |
68 | 68 | */ |
69 | -function give_render_form_columns( $column_name, $post_id ) { |
|
70 | - if ( get_post_type( $post_id ) == 'give_forms' ) { |
|
69 | +function give_render_form_columns($column_name, $post_id) { |
|
70 | + if (get_post_type($post_id) == 'give_forms') { |
|
71 | 71 | |
72 | - switch ( $column_name ) { |
|
72 | + switch ($column_name) { |
|
73 | 73 | case 'form_category': |
74 | - echo get_the_term_list( $post_id, 'give_forms_category', '', ', ', '' ); |
|
74 | + echo get_the_term_list($post_id, 'give_forms_category', '', ', ', ''); |
|
75 | 75 | break; |
76 | 76 | case 'form_tag': |
77 | - echo get_the_term_list( $post_id, 'give_forms_tag', '', ', ', '' ); |
|
77 | + echo get_the_term_list($post_id, 'give_forms_tag', '', ', ', ''); |
|
78 | 78 | break; |
79 | 79 | case 'price': |
80 | - if ( give_has_variable_prices( $post_id ) ) { |
|
81 | - echo give_price_range( $post_id ); |
|
80 | + if (give_has_variable_prices($post_id)) { |
|
81 | + echo give_price_range($post_id); |
|
82 | 82 | } else { |
83 | - echo give_price( $post_id, false ); |
|
84 | - echo '<input type="hidden" class="formprice-' . $post_id . '" value="' . give_get_form_price( $post_id ) . '" />'; |
|
83 | + echo give_price($post_id, false); |
|
84 | + echo '<input type="hidden" class="formprice-'.$post_id.'" value="'.give_get_form_price($post_id).'" />'; |
|
85 | 85 | } |
86 | 86 | break; |
87 | 87 | case 'goal': |
88 | - if ( give_is_setting_enabled( give_get_meta( $post_id, '_give_goal_option', true ) ) ) { |
|
89 | - echo give_goal( $post_id, false ); |
|
88 | + if (give_is_setting_enabled(give_get_meta($post_id, '_give_goal_option', true))) { |
|
89 | + echo give_goal($post_id, false); |
|
90 | 90 | } else { |
91 | - esc_html_e( 'No Goal Set', 'give' ); |
|
91 | + esc_html_e('No Goal Set', 'give'); |
|
92 | 92 | } |
93 | 93 | |
94 | - echo '<input type="hidden" class="formgoal-' . $post_id . '" value="' . give_get_form_goal( $post_id ) . '" />'; |
|
94 | + echo '<input type="hidden" class="formgoal-'.$post_id.'" value="'.give_get_form_goal($post_id).'" />'; |
|
95 | 95 | break; |
96 | 96 | case 'donations': |
97 | - if ( current_user_can( 'view_give_form_stats', $post_id ) ) { |
|
98 | - echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-tools&tab=logs&form=' . $post_id ) ) . '">'; |
|
99 | - echo give_get_form_sales_stats( $post_id ); |
|
97 | + if (current_user_can('view_give_form_stats', $post_id)) { |
|
98 | + echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-tools&tab=logs&form='.$post_id)).'">'; |
|
99 | + echo give_get_form_sales_stats($post_id); |
|
100 | 100 | echo '</a>'; |
101 | 101 | } else { |
102 | 102 | echo '-'; |
103 | 103 | } |
104 | 104 | break; |
105 | 105 | case 'earnings': |
106 | - if ( current_user_can( 'view_give_form_stats', $post_id ) ) { |
|
107 | - echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=forms&form-id=' . $post_id ) ) . '">'; |
|
108 | - echo give_currency_filter( give_format_amount( give_get_form_earnings_stats( $post_id ) ) ); |
|
106 | + if (current_user_can('view_give_form_stats', $post_id)) { |
|
107 | + echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&view=forms&form-id='.$post_id)).'">'; |
|
108 | + echo give_currency_filter(give_format_amount(give_get_form_earnings_stats($post_id))); |
|
109 | 109 | echo '</a>'; |
110 | 110 | } else { |
111 | 111 | echo '-'; |
112 | 112 | } |
113 | 113 | break; |
114 | 114 | case 'shortcode': |
115 | - echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id="' . absint( $post_id ) . '"]">'; |
|
115 | + echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id="'.absint($post_id).'"]">'; |
|
116 | 116 | break; |
117 | 117 | } |
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
121 | -add_action( 'manage_posts_custom_column', 'give_render_form_columns', 10, 2 ); |
|
121 | +add_action('manage_posts_custom_column', 'give_render_form_columns', 10, 2); |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * Registers the sortable columns in the list table |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return array $columns Array of sortable columns |
131 | 131 | */ |
132 | -function give_sortable_form_columns( $columns ) { |
|
132 | +function give_sortable_form_columns($columns) { |
|
133 | 133 | $columns['price'] = 'amount'; |
134 | 134 | $columns['sales'] = 'sales'; |
135 | 135 | $columns['earnings'] = 'earnings'; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | return $columns; |
140 | 140 | } |
141 | 141 | |
142 | -add_filter( 'manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns' ); |
|
142 | +add_filter('manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns'); |
|
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Sorts Columns in the Forms List Table |
@@ -150,13 +150,13 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return array $vars Array of all the sort variables |
152 | 152 | */ |
153 | -function give_sort_forms( $vars ) { |
|
153 | +function give_sort_forms($vars) { |
|
154 | 154 | // Check if we're viewing the "give_forms" post type |
155 | - if ( ! isset( $vars['post_type'] ) || ! isset( $vars['orderby'] ) || 'give_forms' !== $vars['post_type'] ) { |
|
155 | + if ( ! isset($vars['post_type']) || ! isset($vars['orderby']) || 'give_forms' !== $vars['post_type']) { |
|
156 | 156 | return $vars; |
157 | 157 | } |
158 | 158 | |
159 | - switch ( $vars['orderby'] ) { |
|
159 | + switch ($vars['orderby']) { |
|
160 | 160 | // Check if 'orderby' is set to "sales" |
161 | 161 | case 'sales': |
162 | 162 | $vars = array_merge( |
@@ -225,16 +225,16 @@ discard block |
||
225 | 225 | * |
226 | 226 | * @return array Array of all sort variables |
227 | 227 | */ |
228 | -function give_filter_forms( $vars ) { |
|
229 | - if ( isset( $vars['post_type'] ) && 'give_forms' == $vars['post_type'] ) { |
|
228 | +function give_filter_forms($vars) { |
|
229 | + if (isset($vars['post_type']) && 'give_forms' == $vars['post_type']) { |
|
230 | 230 | |
231 | 231 | // If an author ID was passed, use it |
232 | - if ( isset( $_REQUEST['author'] ) && ! current_user_can( 'view_give_reports' ) ) { |
|
232 | + if (isset($_REQUEST['author']) && ! current_user_can('view_give_reports')) { |
|
233 | 233 | |
234 | 234 | $author_id = $_REQUEST['author']; |
235 | - if ( (int) $author_id !== get_current_user_id() ) { |
|
235 | + if ((int) $author_id !== get_current_user_id()) { |
|
236 | 236 | // Tried to view the products of another person, sorry |
237 | - wp_die( esc_html__( 'You do not have permission to view this data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
237 | + wp_die(esc_html__('You do not have permission to view this data.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
238 | 238 | } |
239 | 239 | $vars = array_merge( |
240 | 240 | $vars, |
@@ -258,11 +258,11 @@ discard block |
||
258 | 258 | * @return void |
259 | 259 | */ |
260 | 260 | function give_forms_load() { |
261 | - add_filter( 'request', 'give_sort_forms' ); |
|
262 | - add_filter( 'request', 'give_filter_forms' ); |
|
261 | + add_filter('request', 'give_sort_forms'); |
|
262 | + add_filter('request', 'give_filter_forms'); |
|
263 | 263 | } |
264 | 264 | |
265 | -add_action( 'load-edit.php', 'give_forms_load', 9999 ); |
|
265 | +add_action('load-edit.php', 'give_forms_load', 9999); |
|
266 | 266 | |
267 | 267 | /** |
268 | 268 | * Remove Forms Month Filter |
@@ -276,17 +276,17 @@ discard block |
||
276 | 276 | * @global $typenow The post type we are viewing |
277 | 277 | * @return array Empty array disables the dropdown |
278 | 278 | */ |
279 | -function give_remove_month_filter( $dates ) { |
|
279 | +function give_remove_month_filter($dates) { |
|
280 | 280 | global $typenow; |
281 | 281 | |
282 | - if ( $typenow == 'give_forms' ) { |
|
282 | + if ($typenow == 'give_forms') { |
|
283 | 283 | $dates = array(); |
284 | 284 | } |
285 | 285 | |
286 | 286 | return $dates; |
287 | 287 | } |
288 | 288 | |
289 | -add_filter( 'months_dropdown_results', 'give_remove_month_filter', 99 ); |
|
289 | +add_filter('months_dropdown_results', 'give_remove_month_filter', 99); |
|
290 | 290 | |
291 | 291 | /** |
292 | 292 | * Updates price when saving post |
@@ -297,23 +297,23 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @return int|null |
299 | 299 | */ |
300 | -function give_price_save_quick_edit( $post_id ) { |
|
301 | - if ( ! isset( $_POST['post_type'] ) || 'give_forms' !== $_POST['post_type'] ) { |
|
300 | +function give_price_save_quick_edit($post_id) { |
|
301 | + if ( ! isset($_POST['post_type']) || 'give_forms' !== $_POST['post_type']) { |
|
302 | 302 | return; |
303 | 303 | } |
304 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
304 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
305 | 305 | return $post_id; |
306 | 306 | } |
307 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
307 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
308 | 308 | return $post_id; |
309 | 309 | } |
310 | 310 | |
311 | - if ( isset( $_REQUEST['_give_regprice'] ) ) { |
|
312 | - give_update_meta( $post_id, '_give_set_price', strip_tags( stripslashes( $_REQUEST['_give_regprice'] ) ) ); |
|
311 | + if (isset($_REQUEST['_give_regprice'])) { |
|
312 | + give_update_meta($post_id, '_give_set_price', strip_tags(stripslashes($_REQUEST['_give_regprice']))); |
|
313 | 313 | } |
314 | 314 | } |
315 | 315 | |
316 | -add_action( 'save_post', 'give_price_save_quick_edit' ); |
|
316 | +add_action('save_post', 'give_price_save_quick_edit'); |
|
317 | 317 | |
318 | 318 | /** |
319 | 319 | * Process bulk edit actions via AJAX |
@@ -323,18 +323,18 @@ discard block |
||
323 | 323 | */ |
324 | 324 | function give_save_bulk_edit() { |
325 | 325 | |
326 | - $post_ids = ( isset( $_POST['post_ids'] ) && ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array(); |
|
326 | + $post_ids = (isset($_POST['post_ids']) && ! empty($_POST['post_ids'])) ? $_POST['post_ids'] : array(); |
|
327 | 327 | |
328 | - if ( ! empty( $post_ids ) && is_array( $post_ids ) ) { |
|
329 | - $price = isset( $_POST['price'] ) ? strip_tags( stripslashes( $_POST['price'] ) ) : 0; |
|
330 | - foreach ( $post_ids as $post_id ) { |
|
328 | + if ( ! empty($post_ids) && is_array($post_ids)) { |
|
329 | + $price = isset($_POST['price']) ? strip_tags(stripslashes($_POST['price'])) : 0; |
|
330 | + foreach ($post_ids as $post_id) { |
|
331 | 331 | |
332 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
332 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
333 | 333 | continue; |
334 | 334 | } |
335 | 335 | |
336 | - if ( ! empty( $price ) ) { |
|
337 | - give_update_meta( $post_id, '_give_set_price', give_sanitize_amount( $price ) ); |
|
336 | + if ( ! empty($price)) { |
|
337 | + give_update_meta($post_id, '_give_set_price', give_sanitize_amount($price)); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | } |
@@ -342,4 +342,4 @@ discard block |
||
342 | 342 | die(); |
343 | 343 | } |
344 | 344 | |
345 | -add_action( 'wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit' ); |
|
345 | +add_action('wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit'); |
@@ -46,21 +46,21 @@ discard block |
||
46 | 46 | */ |
47 | 47 | function __construct() { |
48 | 48 | $this->metabox_id = 'give-metabox-form-data'; |
49 | - $this->metabox_label = __( 'Donation Form Options', 'give' ); |
|
49 | + $this->metabox_label = __('Donation Form Options', 'give'); |
|
50 | 50 | |
51 | 51 | // Setup. |
52 | - add_action( 'admin_init', array( $this, 'setup' ) ); |
|
52 | + add_action('admin_init', array($this, 'setup')); |
|
53 | 53 | |
54 | 54 | // Add metabox. |
55 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ), 10 ); |
|
55 | + add_action('add_meta_boxes', array($this, 'add_meta_box'), 10); |
|
56 | 56 | |
57 | 57 | // Save form meta. |
58 | - add_action( 'save_post_give_forms', array( $this, 'save' ), 10, 2 ); |
|
58 | + add_action('save_post_give_forms', array($this, 'save'), 10, 2); |
|
59 | 59 | |
60 | 60 | // cmb2 old setting loaders. |
61 | 61 | // add_filter( 'give_metabox_form_data_settings', array( $this, 'cmb2_metabox_settings' ) ); |
62 | 62 | // Add offline donations options. |
63 | - add_filter( 'give_metabox_form_data_settings', array( $this, 'add_offline_donations_setting_tab' ), 0, 1 ); |
|
63 | + add_filter('give_metabox_form_data_settings', array($this, 'add_offline_donations_setting_tab'), 0, 1); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
@@ -83,18 +83,18 @@ discard block |
||
83 | 83 | */ |
84 | 84 | function get_settings() { |
85 | 85 | $post_id = give_get_admin_post_id(); |
86 | - $price = give_get_form_price( $post_id ); |
|
87 | - $custom_amount_minimum = give_get_form_minimum_price( $post_id ); |
|
88 | - $goal = give_get_form_goal( $post_id ); |
|
86 | + $price = give_get_form_price($post_id); |
|
87 | + $custom_amount_minimum = give_get_form_minimum_price($post_id); |
|
88 | + $goal = give_get_form_goal($post_id); |
|
89 | 89 | |
90 | 90 | // No empty prices - min. 1.00 for new forms |
91 | - if ( empty( $price ) && is_null( $post_id ) ) { |
|
92 | - $price = esc_attr( give_format_decimal( '1.00' ) ); |
|
91 | + if (empty($price) && is_null($post_id)) { |
|
92 | + $price = esc_attr(give_format_decimal('1.00')); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | // Min. $1.00 for new forms |
96 | - if ( empty( $custom_amount_minimum ) ) { |
|
97 | - $custom_amount_minimum = esc_attr( give_format_decimal( '1.00' ) ); |
|
96 | + if (empty($custom_amount_minimum)) { |
|
97 | + $custom_amount_minimum = esc_attr(give_format_decimal('1.00')); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | // Start with an underscore to hide fields from custom fields list |
@@ -104,215 +104,215 @@ discard block |
||
104 | 104 | /** |
105 | 105 | * Repeatable Field Groups |
106 | 106 | */ |
107 | - 'form_field_options' => apply_filters( 'give_forms_field_options', array( |
|
107 | + 'form_field_options' => apply_filters('give_forms_field_options', array( |
|
108 | 108 | 'id' => 'form_field_options', |
109 | - 'title' => __( 'Donation Options', 'give' ), |
|
109 | + 'title' => __('Donation Options', 'give'), |
|
110 | 110 | 'icon-html' => '<span class="give-icon give-icon-heart"></span>', |
111 | - 'fields' => apply_filters( 'give_forms_donation_form_metabox_fields', array( |
|
111 | + 'fields' => apply_filters('give_forms_donation_form_metabox_fields', array( |
|
112 | 112 | // Donation Option |
113 | 113 | array( |
114 | - 'name' => __( 'Donation Option', 'give' ), |
|
115 | - 'description' => __( 'Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give' ), |
|
116 | - 'id' => $prefix . 'price_option', |
|
114 | + 'name' => __('Donation Option', 'give'), |
|
115 | + 'description' => __('Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give'), |
|
116 | + 'id' => $prefix.'price_option', |
|
117 | 117 | 'type' => 'radio_inline', |
118 | 118 | 'default' => 'set', |
119 | - 'options' => apply_filters( 'give_forms_price_options', array( |
|
120 | - 'set' => __( 'Set Donation', 'give' ), |
|
121 | - 'multi' => __( 'Multi-level Donation', 'give' ), |
|
122 | - ) ), |
|
119 | + 'options' => apply_filters('give_forms_price_options', array( |
|
120 | + 'set' => __('Set Donation', 'give'), |
|
121 | + 'multi' => __('Multi-level Donation', 'give'), |
|
122 | + )), |
|
123 | 123 | ), |
124 | 124 | array( |
125 | - 'name' => __( 'Set Donation', 'give' ), |
|
126 | - 'description' => __( 'This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give' ), |
|
127 | - 'id' => $prefix . 'set_price', |
|
125 | + 'name' => __('Set Donation', 'give'), |
|
126 | + 'description' => __('This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give'), |
|
127 | + 'id' => $prefix.'set_price', |
|
128 | 128 | 'type' => 'text_small', |
129 | 129 | 'data_type' => 'price', |
130 | 130 | 'attributes' => array( |
131 | - 'placeholder' => give_format_decimal( '1.00' ), |
|
132 | - 'value' => give_format_decimal( $price ), |
|
131 | + 'placeholder' => give_format_decimal('1.00'), |
|
132 | + 'value' => give_format_decimal($price), |
|
133 | 133 | 'class' => 'give-money-field', |
134 | 134 | ), |
135 | 135 | ), |
136 | 136 | // Display Style |
137 | 137 | array( |
138 | - 'name' => __( 'Display Style', 'give' ), |
|
139 | - 'description' => __( 'Set how the donations levels will display on the form.', 'give' ), |
|
140 | - 'id' => $prefix . 'display_style', |
|
138 | + 'name' => __('Display Style', 'give'), |
|
139 | + 'description' => __('Set how the donations levels will display on the form.', 'give'), |
|
140 | + 'id' => $prefix.'display_style', |
|
141 | 141 | 'type' => 'radio_inline', |
142 | 142 | 'default' => 'buttons', |
143 | 143 | 'options' => array( |
144 | - 'buttons' => __( 'Buttons', 'give' ), |
|
145 | - 'radios' => __( 'Radios', 'give' ), |
|
146 | - 'dropdown' => __( 'Dropdown', 'give' ), |
|
144 | + 'buttons' => __('Buttons', 'give'), |
|
145 | + 'radios' => __('Radios', 'give'), |
|
146 | + 'dropdown' => __('Dropdown', 'give'), |
|
147 | 147 | ), |
148 | 148 | ), |
149 | 149 | // Custom Amount |
150 | 150 | array( |
151 | - 'name' => __( 'Custom Amount', 'give' ), |
|
152 | - 'description' => __( 'Do you want the user to be able to input their own donation amount?', 'give' ), |
|
153 | - 'id' => $prefix . 'custom_amount', |
|
151 | + 'name' => __('Custom Amount', 'give'), |
|
152 | + 'description' => __('Do you want the user to be able to input their own donation amount?', 'give'), |
|
153 | + 'id' => $prefix.'custom_amount', |
|
154 | 154 | 'type' => 'radio_inline', |
155 | 155 | 'default' => 'disabled', |
156 | 156 | 'options' => array( |
157 | - 'enabled' => __( 'Enabled', 'give' ), |
|
158 | - 'disabled' => __( 'Disabled', 'give' ), |
|
157 | + 'enabled' => __('Enabled', 'give'), |
|
158 | + 'disabled' => __('Disabled', 'give'), |
|
159 | 159 | ), |
160 | 160 | ), |
161 | 161 | array( |
162 | - 'name' => __( 'Minimum Amount', 'give' ), |
|
163 | - 'description' => __( 'Enter the minimum custom donation amount.', 'give' ), |
|
164 | - 'id' => $prefix . 'custom_amount_minimum', |
|
162 | + 'name' => __('Minimum Amount', 'give'), |
|
163 | + 'description' => __('Enter the minimum custom donation amount.', 'give'), |
|
164 | + 'id' => $prefix.'custom_amount_minimum', |
|
165 | 165 | 'type' => 'text_small', |
166 | 166 | 'data_type' => 'price', |
167 | 167 | 'attributes' => array( |
168 | - 'placeholder' => give_format_decimal( '1.00' ), |
|
169 | - 'value' => give_format_decimal( $custom_amount_minimum ), |
|
168 | + 'placeholder' => give_format_decimal('1.00'), |
|
169 | + 'value' => give_format_decimal($custom_amount_minimum), |
|
170 | 170 | 'class' => 'give-money-field', |
171 | 171 | ), |
172 | 172 | ), |
173 | 173 | array( |
174 | - 'name' => __( 'Custom Amount Text', 'give' ), |
|
175 | - 'description' => __( 'This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give' ), |
|
176 | - 'id' => $prefix . 'custom_amount_text', |
|
174 | + 'name' => __('Custom Amount Text', 'give'), |
|
175 | + 'description' => __('This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give'), |
|
176 | + 'id' => $prefix.'custom_amount_text', |
|
177 | 177 | 'type' => 'text_medium', |
178 | 178 | 'attributes' => array( |
179 | 179 | 'rows' => 3, |
180 | - 'placeholder' => esc_attr__( 'Give a Custom Amount', 'give' ), |
|
180 | + 'placeholder' => esc_attr__('Give a Custom Amount', 'give'), |
|
181 | 181 | ), |
182 | 182 | ), |
183 | 183 | // Donation Levels: Repeatable CMB2 Group |
184 | 184 | array( |
185 | - 'id' => $prefix . 'donation_levels', |
|
185 | + 'id' => $prefix.'donation_levels', |
|
186 | 186 | 'type' => 'group', |
187 | 187 | 'options' => array( |
188 | - 'add_button' => __( 'Add Level', 'give' ), |
|
189 | - 'header_title' => __( 'Donation Level', 'give' ), |
|
188 | + 'add_button' => __('Add Level', 'give'), |
|
189 | + 'header_title' => __('Donation Level', 'give'), |
|
190 | 190 | 'remove_button' => '<span class="dashicons dashicons-no"></span>', |
191 | 191 | ), |
192 | 192 | // Fields array works the same, except id's only need to be unique for this group. |
193 | 193 | // Prefix is not needed. |
194 | - 'fields' => apply_filters( 'give_donation_levels_table_row', array( |
|
194 | + 'fields' => apply_filters('give_donation_levels_table_row', array( |
|
195 | 195 | array( |
196 | - 'name' => __( 'ID', 'give' ), |
|
197 | - 'id' => $prefix . 'id', |
|
196 | + 'name' => __('ID', 'give'), |
|
197 | + 'id' => $prefix.'id', |
|
198 | 198 | 'type' => 'levels_id', |
199 | 199 | ), |
200 | 200 | array( |
201 | - 'name' => __( 'Amount', 'give' ), |
|
202 | - 'id' => $prefix . 'amount', |
|
201 | + 'name' => __('Amount', 'give'), |
|
202 | + 'id' => $prefix.'amount', |
|
203 | 203 | 'type' => 'text_small', |
204 | 204 | 'data_type' => 'price', |
205 | 205 | 'attributes' => array( |
206 | - 'placeholder' => give_format_decimal( '1.00' ), |
|
206 | + 'placeholder' => give_format_decimal('1.00'), |
|
207 | 207 | 'class' => 'give-money-field', |
208 | 208 | ), |
209 | 209 | ), |
210 | 210 | array( |
211 | - 'name' => __( 'Text', 'give' ), |
|
212 | - 'id' => $prefix . 'text', |
|
211 | + 'name' => __('Text', 'give'), |
|
212 | + 'id' => $prefix.'text', |
|
213 | 213 | 'type' => 'text', |
214 | 214 | 'attributes' => array( |
215 | - 'placeholder' => __( 'Donation Level', 'give' ), |
|
215 | + 'placeholder' => __('Donation Level', 'give'), |
|
216 | 216 | 'class' => 'give-multilevel-text-field', |
217 | 217 | ), |
218 | 218 | ), |
219 | 219 | array( |
220 | - 'name' => __( 'Default', 'give' ), |
|
221 | - 'id' => $prefix . 'default', |
|
220 | + 'name' => __('Default', 'give'), |
|
221 | + 'id' => $prefix.'default', |
|
222 | 222 | 'type' => 'give_default_radio_inline', |
223 | 223 | ), |
224 | - ) ), |
|
224 | + )), |
|
225 | 225 | ), |
226 | 226 | array( |
227 | 227 | 'name' => 'donation_options_docs', |
228 | 228 | 'type' => 'docs_link', |
229 | 229 | 'url' => 'http://docs.givewp.com/form-donation-options', |
230 | - 'title' => __( 'Donation Options', 'give' ), |
|
230 | + 'title' => __('Donation Options', 'give'), |
|
231 | 231 | ), |
232 | 232 | ), |
233 | 233 | $post_id |
234 | 234 | ), |
235 | - ) ), |
|
235 | + )), |
|
236 | 236 | |
237 | 237 | /** |
238 | 238 | * Display Options |
239 | 239 | */ |
240 | - 'form_display_options' => apply_filters( 'give_form_display_options', array( |
|
240 | + 'form_display_options' => apply_filters('give_form_display_options', array( |
|
241 | 241 | 'id' => 'form_display_options', |
242 | - 'title' => __( 'Form Display', 'give' ), |
|
242 | + 'title' => __('Form Display', 'give'), |
|
243 | 243 | 'icon-html' => '<span class="give-icon give-icon-display"></span>', |
244 | - 'fields' => apply_filters( 'give_forms_display_options_metabox_fields', array( |
|
244 | + 'fields' => apply_filters('give_forms_display_options_metabox_fields', array( |
|
245 | 245 | array( |
246 | - 'name' => __( 'Display Options', 'give' ), |
|
247 | - 'desc' => sprintf( __( 'How would you like to display donation information for this form?', 'give' ), '#' ), |
|
248 | - 'id' => $prefix . 'payment_display', |
|
246 | + 'name' => __('Display Options', 'give'), |
|
247 | + 'desc' => sprintf(__('How would you like to display donation information for this form?', 'give'), '#'), |
|
248 | + 'id' => $prefix.'payment_display', |
|
249 | 249 | 'type' => 'radio_inline', |
250 | 250 | 'options' => array( |
251 | - 'onpage' => __( 'All Fields', 'give' ), |
|
252 | - 'modal' => __( 'Modal', 'give' ), |
|
253 | - 'reveal' => __( 'Reveal', 'give' ), |
|
254 | - 'button' => __( 'Button', 'give' ), |
|
251 | + 'onpage' => __('All Fields', 'give'), |
|
252 | + 'modal' => __('Modal', 'give'), |
|
253 | + 'reveal' => __('Reveal', 'give'), |
|
254 | + 'button' => __('Button', 'give'), |
|
255 | 255 | ), |
256 | 256 | 'default' => 'onpage', |
257 | 257 | ), |
258 | 258 | array( |
259 | - 'id' => $prefix . 'reveal_label', |
|
260 | - 'name' => __( 'Continue Button', 'give' ), |
|
261 | - 'desc' => __( 'The button label for displaying the additional payment fields.', 'give' ), |
|
259 | + 'id' => $prefix.'reveal_label', |
|
260 | + 'name' => __('Continue Button', 'give'), |
|
261 | + 'desc' => __('The button label for displaying the additional payment fields.', 'give'), |
|
262 | 262 | 'type' => 'text_small', |
263 | 263 | 'attributes' => array( |
264 | - 'placeholder' => esc_attr__( 'Donate Now', 'give' ), |
|
264 | + 'placeholder' => esc_attr__('Donate Now', 'give'), |
|
265 | 265 | ), |
266 | 266 | ), |
267 | 267 | array( |
268 | - 'id' => $prefix . 'checkout_label', |
|
269 | - 'name' => __( 'Submit Button', 'give' ), |
|
270 | - 'desc' => __( 'The button label for completing a donation.', 'give' ), |
|
268 | + 'id' => $prefix.'checkout_label', |
|
269 | + 'name' => __('Submit Button', 'give'), |
|
270 | + 'desc' => __('The button label for completing a donation.', 'give'), |
|
271 | 271 | 'type' => 'text_small', |
272 | 272 | 'attributes' => array( |
273 | - 'placeholder' => __( 'Donate Now', 'give' ), |
|
273 | + 'placeholder' => __('Donate Now', 'give'), |
|
274 | 274 | ), |
275 | 275 | ), |
276 | 276 | array( |
277 | - 'name' => __( 'Default Gateway', 'give' ), |
|
278 | - 'desc' => __( 'By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give' ), |
|
279 | - 'id' => $prefix . 'default_gateway', |
|
277 | + 'name' => __('Default Gateway', 'give'), |
|
278 | + 'desc' => __('By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give'), |
|
279 | + 'id' => $prefix.'default_gateway', |
|
280 | 280 | 'type' => 'default_gateway', |
281 | 281 | ), |
282 | 282 | array( |
283 | - 'name' => __( 'Guest Donations', 'give' ), |
|
284 | - 'desc' => __( 'Do you want to allow non-logged-in users to make donations?', 'give' ), |
|
285 | - 'id' => $prefix . 'logged_in_only', |
|
283 | + 'name' => __('Guest Donations', 'give'), |
|
284 | + 'desc' => __('Do you want to allow non-logged-in users to make donations?', 'give'), |
|
285 | + 'id' => $prefix.'logged_in_only', |
|
286 | 286 | 'type' => 'radio_inline', |
287 | 287 | 'default' => 'enabled', |
288 | 288 | 'options' => array( |
289 | - 'enabled' => __( 'Enabled', 'give' ), |
|
290 | - 'disabled' => __( 'Disabled', 'give' ), |
|
289 | + 'enabled' => __('Enabled', 'give'), |
|
290 | + 'disabled' => __('Disabled', 'give'), |
|
291 | 291 | ), |
292 | 292 | ), |
293 | 293 | array( |
294 | - 'name' => __( 'Registration', 'give' ), |
|
295 | - 'desc' => __( 'Display the registration and login forms in the payment section for non-logged-in users.', 'give' ), |
|
296 | - 'id' => $prefix . 'show_register_form', |
|
294 | + 'name' => __('Registration', 'give'), |
|
295 | + 'desc' => __('Display the registration and login forms in the payment section for non-logged-in users.', 'give'), |
|
296 | + 'id' => $prefix.'show_register_form', |
|
297 | 297 | 'type' => 'radio', |
298 | 298 | 'options' => array( |
299 | - 'none' => __( 'None', 'give' ), |
|
300 | - 'registration' => __( 'Registration', 'give' ), |
|
301 | - 'login' => __( 'Login', 'give' ), |
|
302 | - 'both' => __( 'Registration + Login', 'give' ), |
|
299 | + 'none' => __('None', 'give'), |
|
300 | + 'registration' => __('Registration', 'give'), |
|
301 | + 'login' => __('Login', 'give'), |
|
302 | + 'both' => __('Registration + Login', 'give'), |
|
303 | 303 | ), |
304 | 304 | 'default' => 'none', |
305 | 305 | ), |
306 | 306 | array( |
307 | - 'name' => __( 'Floating Labels', 'give' ), |
|
307 | + 'name' => __('Floating Labels', 'give'), |
|
308 | 308 | /* translators: %s: forms http://docs.givewp.com/form-floating-labels */ |
309 | - 'desc' => sprintf( __( 'Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give' ), esc_url( 'http://docs.givewp.com/form-floating-labels' ) ), |
|
310 | - 'id' => $prefix . 'form_floating_labels', |
|
309 | + 'desc' => sprintf(__('Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), esc_url('http://docs.givewp.com/form-floating-labels')), |
|
310 | + 'id' => $prefix.'form_floating_labels', |
|
311 | 311 | 'type' => 'radio_inline', |
312 | 312 | 'options' => array( |
313 | - 'global' => __( 'Global Option', 'give' ), |
|
314 | - 'enabled' => __( 'Enabled', 'give' ), |
|
315 | - 'disabled' => __( 'Disabled', 'give' ), |
|
313 | + 'global' => __('Global Option', 'give'), |
|
314 | + 'enabled' => __('Enabled', 'give'), |
|
315 | + 'disabled' => __('Disabled', 'give'), |
|
316 | 316 | ), |
317 | 317 | 'default' => 'global', |
318 | 318 | ), |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | 'name' => 'form_display_docs', |
321 | 321 | 'type' => 'docs_link', |
322 | 322 | 'url' => 'http://docs.givewp.com/form-display-options', |
323 | - 'title' => __( 'Form Display', 'give' ), |
|
323 | + 'title' => __('Form Display', 'give'), |
|
324 | 324 | ), |
325 | 325 | ), |
326 | 326 | $post_id |
@@ -331,172 +331,172 @@ discard block |
||
331 | 331 | /** |
332 | 332 | * Donation Goals |
333 | 333 | */ |
334 | - 'donation_goal_options' => apply_filters( 'give_donation_goal_options', array( |
|
334 | + 'donation_goal_options' => apply_filters('give_donation_goal_options', array( |
|
335 | 335 | 'id' => 'donation_goal_options', |
336 | - 'title' => __( 'Donation Goal', 'give' ), |
|
336 | + 'title' => __('Donation Goal', 'give'), |
|
337 | 337 | 'icon-html' => '<span class="give-icon give-icon-target"></span>', |
338 | - 'fields' => apply_filters( 'give_forms_donation_goal_metabox_fields', array( |
|
338 | + 'fields' => apply_filters('give_forms_donation_goal_metabox_fields', array( |
|
339 | 339 | // Goals |
340 | 340 | array( |
341 | - 'name' => __( 'Donation Goal', 'give' ), |
|
342 | - 'description' => __( 'Do you want to set a donation goal for this form?', 'give' ), |
|
343 | - 'id' => $prefix . 'goal_option', |
|
341 | + 'name' => __('Donation Goal', 'give'), |
|
342 | + 'description' => __('Do you want to set a donation goal for this form?', 'give'), |
|
343 | + 'id' => $prefix.'goal_option', |
|
344 | 344 | 'type' => 'radio_inline', |
345 | 345 | 'default' => 'disabled', |
346 | 346 | 'options' => array( |
347 | - 'enabled' => __( 'Enabled', 'give' ), |
|
348 | - 'disabled' => __( 'Disabled', 'give' ), |
|
347 | + 'enabled' => __('Enabled', 'give'), |
|
348 | + 'disabled' => __('Disabled', 'give'), |
|
349 | 349 | ), |
350 | 350 | ), |
351 | 351 | array( |
352 | - 'name' => __( 'Goal Amount', 'give' ), |
|
353 | - 'description' => __( 'This is the monetary goal amount you want to reach for this form.', 'give' ), |
|
354 | - 'id' => $prefix . 'set_goal', |
|
352 | + 'name' => __('Goal Amount', 'give'), |
|
353 | + 'description' => __('This is the monetary goal amount you want to reach for this form.', 'give'), |
|
354 | + 'id' => $prefix.'set_goal', |
|
355 | 355 | 'type' => 'text_small', |
356 | 356 | 'data_type' => 'price', |
357 | 357 | 'attributes' => array( |
358 | - 'placeholder' => give_format_decimal( '0.00' ), |
|
359 | - 'value' => give_format_decimal( $goal ), |
|
358 | + 'placeholder' => give_format_decimal('0.00'), |
|
359 | + 'value' => give_format_decimal($goal), |
|
360 | 360 | 'class' => 'give-money-field', |
361 | 361 | ), |
362 | 362 | ), |
363 | 363 | |
364 | 364 | array( |
365 | - 'name' => __( 'Goal Format', 'give' ), |
|
366 | - 'description' => __( 'Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give' ), |
|
367 | - 'id' => $prefix . 'goal_format', |
|
365 | + 'name' => __('Goal Format', 'give'), |
|
366 | + 'description' => __('Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give'), |
|
367 | + 'id' => $prefix.'goal_format', |
|
368 | 368 | 'type' => 'radio_inline', |
369 | 369 | 'default' => 'amount', |
370 | 370 | 'options' => array( |
371 | - 'amount' => __( 'Amount', 'give' ), |
|
372 | - 'percentage' => __( 'Percentage', 'give' ), |
|
371 | + 'amount' => __('Amount', 'give'), |
|
372 | + 'percentage' => __('Percentage', 'give'), |
|
373 | 373 | ), |
374 | 374 | ), |
375 | 375 | array( |
376 | - 'name' => __( 'Progress Bar Color', 'give' ), |
|
377 | - 'desc' => __( 'Customize the color of the goal progress bar.', 'give' ), |
|
378 | - 'id' => $prefix . 'goal_color', |
|
376 | + 'name' => __('Progress Bar Color', 'give'), |
|
377 | + 'desc' => __('Customize the color of the goal progress bar.', 'give'), |
|
378 | + 'id' => $prefix.'goal_color', |
|
379 | 379 | 'type' => 'colorpicker', |
380 | 380 | 'default' => '#2bc253', |
381 | 381 | ), |
382 | 382 | |
383 | 383 | array( |
384 | - 'name' => __( 'Close Form', 'give' ), |
|
385 | - 'desc' => __( 'Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give' ), |
|
386 | - 'id' => $prefix . 'close_form_when_goal_achieved', |
|
384 | + 'name' => __('Close Form', 'give'), |
|
385 | + 'desc' => __('Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give'), |
|
386 | + 'id' => $prefix.'close_form_when_goal_achieved', |
|
387 | 387 | 'type' => 'radio_inline', |
388 | 388 | 'default' => 'disabled', |
389 | 389 | 'options' => array( |
390 | - 'enabled' => __( 'Enabled', 'give' ), |
|
391 | - 'disabled' => __( 'Disabled', 'give' ), |
|
390 | + 'enabled' => __('Enabled', 'give'), |
|
391 | + 'disabled' => __('Disabled', 'give'), |
|
392 | 392 | ), |
393 | 393 | ), |
394 | 394 | array( |
395 | - 'name' => __( 'Goal Achieved Message', 'give' ), |
|
396 | - 'desc' => __( 'Do you want to display a custom message when the goal is closed?', 'give' ), |
|
397 | - 'id' => $prefix . 'form_goal_achieved_message', |
|
395 | + 'name' => __('Goal Achieved Message', 'give'), |
|
396 | + 'desc' => __('Do you want to display a custom message when the goal is closed?', 'give'), |
|
397 | + 'id' => $prefix.'form_goal_achieved_message', |
|
398 | 398 | 'type' => 'wysiwyg', |
399 | - 'default' => __( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ), |
|
399 | + 'default' => __('Thank you to all our donors, we have met our fundraising goal.', 'give'), |
|
400 | 400 | ), |
401 | 401 | array( |
402 | 402 | 'name' => 'donation_goal_docs', |
403 | 403 | 'type' => 'docs_link', |
404 | 404 | 'url' => 'http://docs.givewp.com/form-donation-goal', |
405 | - 'title' => __( 'Donation Goal', 'give' ), |
|
405 | + 'title' => __('Donation Goal', 'give'), |
|
406 | 406 | ), |
407 | 407 | ), |
408 | 408 | $post_id |
409 | 409 | ), |
410 | - ) ), |
|
410 | + )), |
|
411 | 411 | |
412 | 412 | /** |
413 | 413 | * Content Field |
414 | 414 | */ |
415 | - 'form_content_options' => apply_filters( 'give_forms_content_options', array( |
|
415 | + 'form_content_options' => apply_filters('give_forms_content_options', array( |
|
416 | 416 | 'id' => 'form_content_options', |
417 | - 'title' => __( 'Form Content', 'give' ), |
|
417 | + 'title' => __('Form Content', 'give'), |
|
418 | 418 | 'icon-html' => '<span class="give-icon give-icon-edit"></span>', |
419 | - 'fields' => apply_filters( 'give_forms_content_options_metabox_fields', array( |
|
419 | + 'fields' => apply_filters('give_forms_content_options_metabox_fields', array( |
|
420 | 420 | |
421 | 421 | // Donation content. |
422 | 422 | array( |
423 | - 'name' => __( 'Display Content', 'give' ), |
|
424 | - 'description' => __( 'Do you want to add custom content to this form?', 'give' ), |
|
425 | - 'id' => $prefix . 'display_content', |
|
423 | + 'name' => __('Display Content', 'give'), |
|
424 | + 'description' => __('Do you want to add custom content to this form?', 'give'), |
|
425 | + 'id' => $prefix.'display_content', |
|
426 | 426 | 'type' => 'radio_inline', |
427 | 427 | 'options' => array( |
428 | - 'enabled' => __( 'Enabled', 'give' ), |
|
429 | - 'disabled' => __( 'Disabled', 'give' ), |
|
428 | + 'enabled' => __('Enabled', 'give'), |
|
429 | + 'disabled' => __('Disabled', 'give'), |
|
430 | 430 | ), |
431 | 431 | 'default' => 'disabled', |
432 | 432 | ), |
433 | 433 | |
434 | 434 | // Content placement. |
435 | 435 | array( |
436 | - 'name' => __( 'Content Placement', 'give' ), |
|
437 | - 'description' => __( 'This option controls where the content appears within the donation form.', 'give' ), |
|
438 | - 'id' => $prefix . 'content_placement', |
|
436 | + 'name' => __('Content Placement', 'give'), |
|
437 | + 'description' => __('This option controls where the content appears within the donation form.', 'give'), |
|
438 | + 'id' => $prefix.'content_placement', |
|
439 | 439 | 'type' => 'radio_inline', |
440 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
441 | - 'give_pre_form' => __( 'Above fields', 'give' ), |
|
442 | - 'give_post_form' => __( 'Below fields', 'give' ), |
|
440 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
441 | + 'give_pre_form' => __('Above fields', 'give'), |
|
442 | + 'give_post_form' => __('Below fields', 'give'), |
|
443 | 443 | ) |
444 | 444 | ), |
445 | 445 | 'default' => 'give_pre_form', |
446 | 446 | ), |
447 | 447 | array( |
448 | - 'name' => __( 'Content', 'give' ), |
|
449 | - 'description' => __( 'This content will display on the single give form page.', 'give' ), |
|
450 | - 'id' => $prefix . 'form_content', |
|
448 | + 'name' => __('Content', 'give'), |
|
449 | + 'description' => __('This content will display on the single give form page.', 'give'), |
|
450 | + 'id' => $prefix.'form_content', |
|
451 | 451 | 'type' => 'wysiwyg', |
452 | 452 | ), |
453 | 453 | array( |
454 | 454 | 'name' => 'form_content_docs', |
455 | 455 | 'type' => 'docs_link', |
456 | 456 | 'url' => 'http://docs.givewp.com/form-content', |
457 | - 'title' => __( 'Form Content', 'give' ), |
|
457 | + 'title' => __('Form Content', 'give'), |
|
458 | 458 | ), |
459 | 459 | ), |
460 | 460 | $post_id |
461 | 461 | ), |
462 | - ) ), |
|
462 | + )), |
|
463 | 463 | |
464 | 464 | /** |
465 | 465 | * Terms & Conditions |
466 | 466 | */ |
467 | - 'form_terms_options' => apply_filters( 'give_forms_terms_options', array( |
|
467 | + 'form_terms_options' => apply_filters('give_forms_terms_options', array( |
|
468 | 468 | 'id' => 'form_terms_options', |
469 | - 'title' => __( 'Terms & Conditions', 'give' ), |
|
469 | + 'title' => __('Terms & Conditions', 'give'), |
|
470 | 470 | 'icon-html' => '<span class="give-icon give-icon-checklist"></span>', |
471 | - 'fields' => apply_filters( 'give_forms_terms_options_metabox_fields', array( |
|
471 | + 'fields' => apply_filters('give_forms_terms_options_metabox_fields', array( |
|
472 | 472 | // Donation Option |
473 | 473 | array( |
474 | - 'name' => __( 'Terms and Conditions', 'give' ), |
|
475 | - 'description' => __( 'Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give' ), |
|
476 | - 'id' => $prefix . 'terms_option', |
|
474 | + 'name' => __('Terms and Conditions', 'give'), |
|
475 | + 'description' => __('Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give'), |
|
476 | + 'id' => $prefix.'terms_option', |
|
477 | 477 | 'type' => 'radio_inline', |
478 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
479 | - 'global' => __( 'Global Option', 'give' ), |
|
480 | - 'enabled' => __( 'Customize', 'give' ), |
|
481 | - 'disabled' => __( 'Disable', 'give' ), |
|
478 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
479 | + 'global' => __('Global Option', 'give'), |
|
480 | + 'enabled' => __('Customize', 'give'), |
|
481 | + 'disabled' => __('Disable', 'give'), |
|
482 | 482 | ) |
483 | 483 | ), |
484 | 484 | 'default' => 'global', |
485 | 485 | ), |
486 | 486 | array( |
487 | - 'id' => $prefix . 'agree_label', |
|
488 | - 'name' => __( 'Agreement Label', 'give' ), |
|
489 | - 'desc' => __( 'The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give' ), |
|
487 | + 'id' => $prefix.'agree_label', |
|
488 | + 'name' => __('Agreement Label', 'give'), |
|
489 | + 'desc' => __('The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give'), |
|
490 | 490 | 'type' => 'text', |
491 | 491 | 'size' => 'regular', |
492 | 492 | 'attributes' => array( |
493 | - 'placeholder' => esc_attr__( 'Agree to Terms?', 'give' ), |
|
493 | + 'placeholder' => esc_attr__('Agree to Terms?', 'give'), |
|
494 | 494 | ), |
495 | 495 | ), |
496 | 496 | array( |
497 | - 'id' => $prefix . 'agree_text', |
|
498 | - 'name' => __( 'Agreement Text', 'give' ), |
|
499 | - 'desc' => __( 'This is the actual text which the user will have to agree to in order to make a donation.', 'give' ), |
|
497 | + 'id' => $prefix.'agree_text', |
|
498 | + 'name' => __('Agreement Text', 'give'), |
|
499 | + 'desc' => __('This is the actual text which the user will have to agree to in order to make a donation.', 'give'), |
|
500 | 500 | 'default' => give_get_option('agreement_text'), |
501 | 501 | 'type' => 'wysiwyg', |
502 | 502 | ), |
@@ -504,19 +504,19 @@ discard block |
||
504 | 504 | 'name' => 'terms_docs', |
505 | 505 | 'type' => 'docs_link', |
506 | 506 | 'url' => 'http://docs.givewp.com/form-terms', |
507 | - 'title' => __( 'Terms and Conditions', 'give' ), |
|
507 | + 'title' => __('Terms and Conditions', 'give'), |
|
508 | 508 | ), |
509 | 509 | ), |
510 | 510 | $post_id |
511 | 511 | ), |
512 | - ) ), |
|
512 | + )), |
|
513 | 513 | ); |
514 | 514 | |
515 | 515 | |
516 | 516 | /** |
517 | 517 | * Filter the metabox tabbed panel settings. |
518 | 518 | */ |
519 | - $settings = apply_filters( 'give_metabox_form_data_settings', $settings, $post_id ); |
|
519 | + $settings = apply_filters('give_metabox_form_data_settings', $settings, $post_id); |
|
520 | 520 | |
521 | 521 | // Output. |
522 | 522 | return $settings; |
@@ -532,8 +532,8 @@ discard block |
||
532 | 532 | add_meta_box( |
533 | 533 | $this->get_metabox_ID(), |
534 | 534 | $this->get_metabox_label(), |
535 | - array( $this, 'output' ), |
|
536 | - array( 'give_forms' ), |
|
535 | + array($this, 'output'), |
|
536 | + array('give_forms'), |
|
537 | 537 | 'normal', |
538 | 538 | 'high' |
539 | 539 | ); |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | function enqueue_script() { |
550 | 550 | global $post; |
551 | 551 | |
552 | - if ( is_object( $post ) && 'give_forms' === $post->post_type ) { |
|
552 | + if (is_object($post) && 'give_forms' === $post->post_type) { |
|
553 | 553 | |
554 | 554 | } |
555 | 555 | } |
@@ -584,32 +584,32 @@ discard block |
||
584 | 584 | public function get_tabs() { |
585 | 585 | $tabs = array(); |
586 | 586 | |
587 | - if ( ! empty( $this->settings ) ) { |
|
588 | - foreach ( $this->settings as $setting ) { |
|
589 | - if ( ! isset( $setting['id'] ) || ! isset( $setting['title'] ) ) { |
|
587 | + if ( ! empty($this->settings)) { |
|
588 | + foreach ($this->settings as $setting) { |
|
589 | + if ( ! isset($setting['id']) || ! isset($setting['title'])) { |
|
590 | 590 | continue; |
591 | 591 | } |
592 | 592 | $tab = array( |
593 | 593 | 'id' => $setting['id'], |
594 | 594 | 'label' => $setting['title'], |
595 | - 'icon-html' => ( ! empty( $setting['icon-html'] ) ? $setting['icon-html'] : '' ), |
|
595 | + 'icon-html' => ( ! empty($setting['icon-html']) ? $setting['icon-html'] : ''), |
|
596 | 596 | ); |
597 | 597 | |
598 | - if ( $this->has_sub_tab( $setting ) ) { |
|
599 | - if ( empty( $setting['sub-fields'] ) ) { |
|
598 | + if ($this->has_sub_tab($setting)) { |
|
599 | + if (empty($setting['sub-fields'])) { |
|
600 | 600 | $tab = array(); |
601 | 601 | } else { |
602 | - foreach ( $setting['sub-fields'] as $sub_fields ) { |
|
602 | + foreach ($setting['sub-fields'] as $sub_fields) { |
|
603 | 603 | $tab['sub-fields'][] = array( |
604 | 604 | 'id' => $sub_fields['id'], |
605 | 605 | 'label' => $sub_fields['title'], |
606 | - 'icon-html' => ( ! empty( $sub_fields['icon-html'] ) ? $sub_fields['icon-html'] : '' ), |
|
606 | + 'icon-html' => ( ! empty($sub_fields['icon-html']) ? $sub_fields['icon-html'] : ''), |
|
607 | 607 | ); |
608 | 608 | } |
609 | 609 | } |
610 | 610 | } |
611 | 611 | |
612 | - if ( ! empty( $tab ) ) { |
|
612 | + if ( ! empty($tab)) { |
|
613 | 613 | $tabs[] = $tab; |
614 | 614 | } |
615 | 615 | } |
@@ -626,27 +626,27 @@ discard block |
||
626 | 626 | */ |
627 | 627 | public function output() { |
628 | 628 | // Bailout. |
629 | - if ( $form_data_tabs = $this->get_tabs() ) { |
|
630 | - wp_nonce_field( 'give_save_form_meta', 'give_form_meta_nonce' ); |
|
629 | + if ($form_data_tabs = $this->get_tabs()) { |
|
630 | + wp_nonce_field('give_save_form_meta', 'give_form_meta_nonce'); |
|
631 | 631 | ?> |
632 | 632 | <div class="give-metabox-panel-wrap"> |
633 | 633 | <ul class="give-form-data-tabs give-metabox-tabs"> |
634 | - <?php foreach ( $form_data_tabs as $index => $form_data_tab ) : ?> |
|
635 | - <li class="<?php echo "{$form_data_tab['id']}_tab" . ( ! $index ? ' active' : '' ) . ( $this->has_sub_tab( $form_data_tab ) ? ' has-sub-fields' : '' ); ?>"> |
|
634 | + <?php foreach ($form_data_tabs as $index => $form_data_tab) : ?> |
|
635 | + <li class="<?php echo "{$form_data_tab['id']}_tab".( ! $index ? ' active' : '').($this->has_sub_tab($form_data_tab) ? ' has-sub-fields' : ''); ?>"> |
|
636 | 636 | <a href="#<?php echo $form_data_tab['id']; ?>"> |
637 | - <?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?> |
|
637 | + <?php if ( ! empty($form_data_tab['icon-html'])) : ?> |
|
638 | 638 | <?php echo $form_data_tab['icon-html']; ?> |
639 | 639 | <?php else : ?> |
640 | 640 | <span class="give-icon give-icon-default"></span> |
641 | 641 | <?php endif; ?> |
642 | 642 | <span class="give-label"><?php echo $form_data_tab['label']; ?></span> |
643 | 643 | </a> |
644 | - <?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?> |
|
644 | + <?php if ($this->has_sub_tab($form_data_tab)) : ?> |
|
645 | 645 | <ul class="give-metabox-sub-tabs give-hidden"> |
646 | - <?php foreach ( $form_data_tab['sub-fields'] as $sub_tab ) : ?> |
|
646 | + <?php foreach ($form_data_tab['sub-fields'] as $sub_tab) : ?> |
|
647 | 647 | <li class="<?php echo "{$sub_tab['id']}_tab"; ?>"> |
648 | 648 | <a href="#<?php echo $sub_tab['id']; ?>"> |
649 | - <?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?> |
|
649 | + <?php if ( ! empty($sub_tab['icon-html'])) : ?> |
|
650 | 650 | <?php echo $sub_tab['icon-html']; ?> |
651 | 651 | <?php else : ?> |
652 | 652 | <span class="give-icon give-icon-default"></span> |
@@ -662,30 +662,30 @@ discard block |
||
662 | 662 | </ul> |
663 | 663 | |
664 | 664 | <?php $show_first_tab_content = true; ?> |
665 | - <?php foreach ( $this->settings as $setting ) : ?> |
|
666 | - <?php if ( ! $this->has_sub_tab( $setting ) ) : ?> |
|
667 | - <?php do_action( "give_before_{$setting['id']}_settings" ); ?> |
|
665 | + <?php foreach ($this->settings as $setting) : ?> |
|
666 | + <?php if ( ! $this->has_sub_tab($setting)) : ?> |
|
667 | + <?php do_action("give_before_{$setting['id']}_settings"); ?> |
|
668 | 668 | |
669 | 669 | <div id="<?php echo $setting['id']; ?>" |
670 | - class="panel give_options_panel<?php echo( $show_first_tab_content ? '' : ' give-hidden' ); |
|
670 | + class="panel give_options_panel<?php echo($show_first_tab_content ? '' : ' give-hidden'); |
|
671 | 671 | $show_first_tab_content = false; ?>"> |
672 | - <?php if ( ! empty( $setting['fields'] ) ) : ?> |
|
673 | - <?php foreach ( $setting['fields'] as $field ) : ?> |
|
674 | - <?php give_render_field( $field ); ?> |
|
672 | + <?php if ( ! empty($setting['fields'])) : ?> |
|
673 | + <?php foreach ($setting['fields'] as $field) : ?> |
|
674 | + <?php give_render_field($field); ?> |
|
675 | 675 | <?php endforeach; ?> |
676 | 676 | <?php endif; ?> |
677 | 677 | </div> |
678 | 678 | |
679 | - <?php do_action( "give_after_{$setting['id']}_settings" ); ?> |
|
679 | + <?php do_action("give_after_{$setting['id']}_settings"); ?> |
|
680 | 680 | <?php else: ?> |
681 | - <?php if ( $this->has_sub_tab( $setting ) ) : ?> |
|
682 | - <?php if ( ! empty( $setting['sub-fields'] ) ) : ?> |
|
683 | - <?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?> |
|
681 | + <?php if ($this->has_sub_tab($setting)) : ?> |
|
682 | + <?php if ( ! empty($setting['sub-fields'])) : ?> |
|
683 | + <?php foreach ($setting['sub-fields'] as $index => $sub_fields) : ?> |
|
684 | 684 | <div id="<?php echo $sub_fields['id']; ?>" |
685 | 685 | class="panel give_options_panel give-hidden"> |
686 | - <?php if ( ! empty( $sub_fields['fields'] ) ) : ?> |
|
687 | - <?php foreach ( $sub_fields['fields'] as $sub_field ) : ?> |
|
688 | - <?php give_render_field( $sub_field ); ?> |
|
686 | + <?php if ( ! empty($sub_fields['fields'])) : ?> |
|
687 | + <?php foreach ($sub_fields['fields'] as $sub_field) : ?> |
|
688 | + <?php give_render_field($sub_field); ?> |
|
689 | 689 | <?php endforeach; ?> |
690 | 690 | <?php endif; ?> |
691 | 691 | </div> |
@@ -709,9 +709,9 @@ discard block |
||
709 | 709 | * |
710 | 710 | * @return bool |
711 | 711 | */ |
712 | - private function has_sub_tab( $field_setting ) { |
|
712 | + private function has_sub_tab($field_setting) { |
|
713 | 713 | $has_sub_tab = false; |
714 | - if ( array_key_exists( 'sub-fields', $field_setting ) ) { |
|
714 | + if (array_key_exists('sub-fields', $field_setting)) { |
|
715 | 715 | $has_sub_tab = true; |
716 | 716 | } |
717 | 717 | |
@@ -725,13 +725,13 @@ discard block |
||
725 | 725 | * @return array |
726 | 726 | */ |
727 | 727 | function cmb2_metabox_settings() { |
728 | - $all_cmb2_settings = apply_filters( 'cmb2_meta_boxes', array() ); |
|
728 | + $all_cmb2_settings = apply_filters('cmb2_meta_boxes', array()); |
|
729 | 729 | $give_forms_settings = $all_cmb2_settings; |
730 | 730 | |
731 | 731 | // Filter settings: Use only give forms related settings. |
732 | - foreach ( $all_cmb2_settings as $index => $setting ) { |
|
733 | - if ( ! in_array( 'give_forms', $setting['object_types'] ) ) { |
|
734 | - unset( $give_forms_settings[ $index ] ); |
|
732 | + foreach ($all_cmb2_settings as $index => $setting) { |
|
733 | + if ( ! in_array('give_forms', $setting['object_types'])) { |
|
734 | + unset($give_forms_settings[$index]); |
|
735 | 735 | } |
736 | 736 | } |
737 | 737 | |
@@ -749,114 +749,114 @@ discard block |
||
749 | 749 | * |
750 | 750 | * @return void |
751 | 751 | */ |
752 | - public function save( $post_id, $post ) { |
|
752 | + public function save($post_id, $post) { |
|
753 | 753 | |
754 | 754 | // $post_id and $post are required. |
755 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
755 | + if (empty($post_id) || empty($post)) { |
|
756 | 756 | return; |
757 | 757 | } |
758 | 758 | |
759 | 759 | // Don't save meta boxes for revisions or autosaves. |
760 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
760 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
761 | 761 | return; |
762 | 762 | } |
763 | 763 | |
764 | 764 | // Check the nonce. |
765 | - if ( empty( $_POST['give_form_meta_nonce'] ) || ! wp_verify_nonce( $_POST['give_form_meta_nonce'], 'give_save_form_meta' ) ) { |
|
765 | + if (empty($_POST['give_form_meta_nonce']) || ! wp_verify_nonce($_POST['give_form_meta_nonce'], 'give_save_form_meta')) { |
|
766 | 766 | return; |
767 | 767 | } |
768 | 768 | |
769 | 769 | // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
770 | - if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) { |
|
770 | + if (empty($_POST['post_ID']) || $_POST['post_ID'] != $post_id) { |
|
771 | 771 | return; |
772 | 772 | } |
773 | 773 | |
774 | 774 | // Check user has permission to edit. |
775 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
775 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
776 | 776 | return; |
777 | 777 | } |
778 | 778 | |
779 | 779 | // Fire action before saving form meta. |
780 | - do_action( 'give_pre_process_give_forms_meta', $post_id, $post ); |
|
780 | + do_action('give_pre_process_give_forms_meta', $post_id, $post); |
|
781 | 781 | |
782 | 782 | /** |
783 | 783 | * Filter the meta key to save. |
784 | 784 | * Third party addon developer can remove there meta keys from this array to handle saving data on there own. |
785 | 785 | */ |
786 | - $form_meta_keys = apply_filters( 'give_process_form_meta_keys', $this->get_meta_keys_from_settings() ); |
|
786 | + $form_meta_keys = apply_filters('give_process_form_meta_keys', $this->get_meta_keys_from_settings()); |
|
787 | 787 | |
788 | 788 | // Save form meta data. |
789 | - if ( ! empty( $form_meta_keys ) ) { |
|
790 | - foreach ( $form_meta_keys as $form_meta_key ) { |
|
789 | + if ( ! empty($form_meta_keys)) { |
|
790 | + foreach ($form_meta_keys as $form_meta_key) { |
|
791 | 791 | |
792 | 792 | // Set default value for checkbox fields. |
793 | 793 | if ( |
794 | - ! isset( $_POST[ $form_meta_key ] ) |
|
795 | - && ( 'checkbox' === $this->get_field_type( $form_meta_key ) ) |
|
794 | + ! isset($_POST[$form_meta_key]) |
|
795 | + && ('checkbox' === $this->get_field_type($form_meta_key)) |
|
796 | 796 | ) { |
797 | - $_POST[ $form_meta_key ] = ''; |
|
797 | + $_POST[$form_meta_key] = ''; |
|
798 | 798 | } |
799 | 799 | |
800 | - if ( isset( $_POST[ $form_meta_key ] ) ) { |
|
801 | - if ( $field_type = $this->get_field_type( $form_meta_key ) ) { |
|
802 | - switch ( $field_type ) { |
|
800 | + if (isset($_POST[$form_meta_key])) { |
|
801 | + if ($field_type = $this->get_field_type($form_meta_key)) { |
|
802 | + switch ($field_type) { |
|
803 | 803 | case 'textarea': |
804 | 804 | case 'wysiwyg': |
805 | - $form_meta_value = wp_kses_post( $_POST[ $form_meta_key ] ); |
|
806 | - give_update_meta( $post_id, $form_meta_key, $form_meta_value ); |
|
805 | + $form_meta_value = wp_kses_post($_POST[$form_meta_key]); |
|
806 | + give_update_meta($post_id, $form_meta_key, $form_meta_value); |
|
807 | 807 | break; |
808 | 808 | |
809 | 809 | case 'group': |
810 | 810 | $form_meta_value = array(); |
811 | 811 | |
812 | - foreach ( $_POST[ $form_meta_key ] as $index => $group ) { |
|
812 | + foreach ($_POST[$form_meta_key] as $index => $group) { |
|
813 | 813 | |
814 | 814 | // Do not save template input field values. |
815 | - if ( '{{row-count-placeholder}}' === $index ) { |
|
815 | + if ('{{row-count-placeholder}}' === $index) { |
|
816 | 816 | continue; |
817 | 817 | } |
818 | 818 | |
819 | 819 | $group_meta_value = array(); |
820 | - foreach ( $group as $field_id => $field_value ) { |
|
821 | - switch ( $this->get_field_type( $field_id, $form_meta_key ) ) { |
|
820 | + foreach ($group as $field_id => $field_value) { |
|
821 | + switch ($this->get_field_type($field_id, $form_meta_key)) { |
|
822 | 822 | case 'wysiwyg': |
823 | - $group_meta_value[ $field_id ] = wp_kses_post( $field_value ); |
|
823 | + $group_meta_value[$field_id] = wp_kses_post($field_value); |
|
824 | 824 | break; |
825 | 825 | |
826 | 826 | default: |
827 | - $group_meta_value[ $field_id ] = give_clean( $field_value ); |
|
827 | + $group_meta_value[$field_id] = give_clean($field_value); |
|
828 | 828 | } |
829 | 829 | } |
830 | 830 | |
831 | - if ( ! empty( $group_meta_value ) ) { |
|
832 | - $form_meta_value[ $index ] = $group_meta_value; |
|
831 | + if ( ! empty($group_meta_value)) { |
|
832 | + $form_meta_value[$index] = $group_meta_value; |
|
833 | 833 | } |
834 | 834 | } |
835 | 835 | |
836 | 836 | |
837 | 837 | // Arrange repeater field keys in order. |
838 | - $form_meta_value = array_values( $form_meta_value ); |
|
838 | + $form_meta_value = array_values($form_meta_value); |
|
839 | 839 | |
840 | 840 | // Save data. |
841 | - give_update_meta( $post_id, $form_meta_key, $form_meta_value ); |
|
841 | + give_update_meta($post_id, $form_meta_key, $form_meta_value); |
|
842 | 842 | break; |
843 | 843 | |
844 | 844 | default: |
845 | - $form_meta_value = give_clean( $_POST[ $form_meta_key ] ); |
|
845 | + $form_meta_value = give_clean($_POST[$form_meta_key]); |
|
846 | 846 | |
847 | 847 | // Save data. |
848 | - give_update_meta( $post_id, $form_meta_key, $form_meta_value ); |
|
848 | + give_update_meta($post_id, $form_meta_key, $form_meta_value); |
|
849 | 849 | } |
850 | 850 | |
851 | 851 | // Fire after saving form meta key. |
852 | - do_action( "give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post ); |
|
852 | + do_action("give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post); |
|
853 | 853 | } |
854 | 854 | } |
855 | 855 | } |
856 | 856 | } |
857 | 857 | |
858 | 858 | // Fire action after saving form meta. |
859 | - do_action( 'give_post_process_give_forms_meta', $post_id, $post ); |
|
859 | + do_action('give_post_process_give_forms_meta', $post_id, $post); |
|
860 | 860 | } |
861 | 861 | |
862 | 862 | |
@@ -869,10 +869,10 @@ discard block |
||
869 | 869 | * |
870 | 870 | * @return string |
871 | 871 | */ |
872 | - private function get_field_id( $field ) { |
|
872 | + private function get_field_id($field) { |
|
873 | 873 | $field_id = ''; |
874 | 874 | |
875 | - if ( array_key_exists( 'id', $field ) ) { |
|
875 | + if (array_key_exists('id', $field)) { |
|
876 | 876 | $field_id = $field['id']; |
877 | 877 | |
878 | 878 | } |
@@ -889,12 +889,12 @@ discard block |
||
889 | 889 | * |
890 | 890 | * @return array |
891 | 891 | */ |
892 | - private function get_fields_id( $setting ) { |
|
892 | + private function get_fields_id($setting) { |
|
893 | 893 | $meta_keys = array(); |
894 | 894 | |
895 | - if ( ! empty( $setting ) ) { |
|
896 | - foreach ( $setting['fields'] as $field ) { |
|
897 | - if ( $field_id = $this->get_field_id( $field ) ) { |
|
895 | + if ( ! empty($setting)) { |
|
896 | + foreach ($setting['fields'] as $field) { |
|
897 | + if ($field_id = $this->get_field_id($field)) { |
|
898 | 898 | $meta_keys[] = $field_id; |
899 | 899 | } |
900 | 900 | } |
@@ -912,14 +912,14 @@ discard block |
||
912 | 912 | * |
913 | 913 | * @return array |
914 | 914 | */ |
915 | - private function get_sub_fields_id( $setting ) { |
|
915 | + private function get_sub_fields_id($setting) { |
|
916 | 916 | $meta_keys = array(); |
917 | 917 | |
918 | - if ( $this->has_sub_tab( $setting ) && ! empty( $setting['sub-fields'] ) ) { |
|
919 | - foreach ( $setting['sub-fields'] as $fields ) { |
|
920 | - if ( ! empty( $fields['fields'] ) ) { |
|
921 | - foreach ( $fields['fields'] as $field ) { |
|
922 | - if ( $field_id = $this->get_field_id( $field ) ) { |
|
918 | + if ($this->has_sub_tab($setting) && ! empty($setting['sub-fields'])) { |
|
919 | + foreach ($setting['sub-fields'] as $fields) { |
|
920 | + if ( ! empty($fields['fields'])) { |
|
921 | + foreach ($fields['fields'] as $field) { |
|
922 | + if ($field_id = $this->get_field_id($field)) { |
|
923 | 923 | $meta_keys[] = $field_id; |
924 | 924 | } |
925 | 925 | } |
@@ -940,14 +940,14 @@ discard block |
||
940 | 940 | private function get_meta_keys_from_settings() { |
941 | 941 | $meta_keys = array(); |
942 | 942 | |
943 | - foreach ( $this->settings as $setting ) { |
|
944 | - if ( $this->has_sub_tab( $setting ) ) { |
|
945 | - $meta_key = $this->get_sub_fields_id( $setting ); |
|
943 | + foreach ($this->settings as $setting) { |
|
944 | + if ($this->has_sub_tab($setting)) { |
|
945 | + $meta_key = $this->get_sub_fields_id($setting); |
|
946 | 946 | } else { |
947 | - $meta_key = $this->get_fields_id( $setting ); |
|
947 | + $meta_key = $this->get_fields_id($setting); |
|
948 | 948 | } |
949 | 949 | |
950 | - $meta_keys = array_merge( $meta_keys, $meta_key ); |
|
950 | + $meta_keys = array_merge($meta_keys, $meta_key); |
|
951 | 951 | } |
952 | 952 | |
953 | 953 | return $meta_keys; |
@@ -964,10 +964,10 @@ discard block |
||
964 | 964 | * |
965 | 965 | * @return string |
966 | 966 | */ |
967 | - function get_field_type( $field_id, $group_id = '' ) { |
|
968 | - $field = $this->get_setting_field( $field_id, $group_id ); |
|
967 | + function get_field_type($field_id, $group_id = '') { |
|
968 | + $field = $this->get_setting_field($field_id, $group_id); |
|
969 | 969 | |
970 | - $type = array_key_exists( 'type', $field ) |
|
970 | + $type = array_key_exists('type', $field) |
|
971 | 971 | ? $field['type'] |
972 | 972 | : ''; |
973 | 973 | |
@@ -985,12 +985,12 @@ discard block |
||
985 | 985 | * |
986 | 986 | * @return array |
987 | 987 | */ |
988 | - private function get_field( $setting, $field_id ) { |
|
988 | + private function get_field($setting, $field_id) { |
|
989 | 989 | $setting_field = array(); |
990 | 990 | |
991 | - if ( ! empty( $setting['fields'] ) ) { |
|
992 | - foreach ( $setting['fields'] as $field ) { |
|
993 | - if ( array_key_exists( 'id', $field ) && $field['id'] === $field_id ) { |
|
991 | + if ( ! empty($setting['fields'])) { |
|
992 | + foreach ($setting['fields'] as $field) { |
|
993 | + if (array_key_exists('id', $field) && $field['id'] === $field_id) { |
|
994 | 994 | $setting_field = $field; |
995 | 995 | break; |
996 | 996 | } |
@@ -1010,12 +1010,12 @@ discard block |
||
1010 | 1010 | * |
1011 | 1011 | * @return array |
1012 | 1012 | */ |
1013 | - private function get_sub_field( $setting, $field_id ) { |
|
1013 | + private function get_sub_field($setting, $field_id) { |
|
1014 | 1014 | $setting_field = array(); |
1015 | 1015 | |
1016 | - if ( ! empty( $setting['sub-fields'] ) ) { |
|
1017 | - foreach ( $setting['sub-fields'] as $fields ) { |
|
1018 | - if ( $field = $this->get_field( $fields, $field_id ) ) { |
|
1016 | + if ( ! empty($setting['sub-fields'])) { |
|
1017 | + foreach ($setting['sub-fields'] as $fields) { |
|
1018 | + if ($field = $this->get_field($fields, $field_id)) { |
|
1019 | 1019 | $setting_field = $field; |
1020 | 1020 | break; |
1021 | 1021 | } |
@@ -1035,17 +1035,17 @@ discard block |
||
1035 | 1035 | * |
1036 | 1036 | * @return array |
1037 | 1037 | */ |
1038 | - function get_setting_field( $field_id, $group_id = '' ) { |
|
1038 | + function get_setting_field($field_id, $group_id = '') { |
|
1039 | 1039 | $setting_field = array(); |
1040 | 1040 | |
1041 | 1041 | $_field_id = $field_id; |
1042 | - $field_id = empty( $group_id ) ? $field_id : $group_id; |
|
1042 | + $field_id = empty($group_id) ? $field_id : $group_id; |
|
1043 | 1043 | |
1044 | - if ( ! empty( $this->settings ) ) { |
|
1045 | - foreach ( $this->settings as $setting ) { |
|
1044 | + if ( ! empty($this->settings)) { |
|
1045 | + foreach ($this->settings as $setting) { |
|
1046 | 1046 | if ( |
1047 | - ( $this->has_sub_tab( $setting ) && ( $setting_field = $this->get_sub_field( $setting, $field_id ) ) ) |
|
1048 | - || ( $setting_field = $this->get_field( $setting, $field_id ) ) |
|
1047 | + ($this->has_sub_tab($setting) && ($setting_field = $this->get_sub_field($setting, $field_id))) |
|
1048 | + || ($setting_field = $this->get_field($setting, $field_id)) |
|
1049 | 1049 | ) { |
1050 | 1050 | break; |
1051 | 1051 | } |
@@ -1054,9 +1054,9 @@ discard block |
||
1054 | 1054 | |
1055 | 1055 | |
1056 | 1056 | // Get field from group. |
1057 | - if ( ! empty( $group_id ) ) { |
|
1058 | - foreach ( $setting_field['fields'] as $field ) { |
|
1059 | - if ( array_key_exists( 'id', $field ) && $field['id'] === $_field_id ) { |
|
1057 | + if ( ! empty($group_id)) { |
|
1058 | + foreach ($setting_field['fields'] as $field) { |
|
1059 | + if (array_key_exists('id', $field) && $field['id'] === $_field_id) { |
|
1060 | 1060 | $setting_field = $field; |
1061 | 1061 | } |
1062 | 1062 | } |
@@ -1075,14 +1075,14 @@ discard block |
||
1075 | 1075 | * |
1076 | 1076 | * @return mixed |
1077 | 1077 | */ |
1078 | - function add_offline_donations_setting_tab( $settings ) { |
|
1079 | - if ( give_is_gateway_active( 'offline' ) ) { |
|
1080 | - $settings['offline_donations_options'] = apply_filters( 'give_forms_offline_donations_options', array( |
|
1078 | + function add_offline_donations_setting_tab($settings) { |
|
1079 | + if (give_is_gateway_active('offline')) { |
|
1080 | + $settings['offline_donations_options'] = apply_filters('give_forms_offline_donations_options', array( |
|
1081 | 1081 | 'id' => 'offline_donations_options', |
1082 | - 'title' => __( 'Offline Donations', 'give' ), |
|
1082 | + 'title' => __('Offline Donations', 'give'), |
|
1083 | 1083 | 'icon-html' => '<span class="give-icon give-icon-purse"></span>', |
1084 | - 'fields' => apply_filters( 'give_forms_offline_donations_metabox_fields', array() ), |
|
1085 | - ) ); |
|
1084 | + 'fields' => apply_filters('give_forms_offline_donations_metabox_fields', array()), |
|
1085 | + )); |
|
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | return $settings; |