@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * |
14 | 14 | * @return Give |
15 | 15 | */ |
16 | -function give_load_deprecated_properties( $instance ) { |
|
16 | +function give_load_deprecated_properties($instance) { |
|
17 | 17 | |
18 | 18 | // If a property is renamed then it gets placed below. |
19 | 19 | $instance->customers = new Give_DB_Customers(); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | } |
25 | 25 | |
26 | -add_action( 'give_init', 'give_load_deprecated_properties', 10, 1 ); |
|
26 | +add_action('give_init', 'give_load_deprecated_properties', 10, 1); |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Give_DB_Customers Class (deprecated) |
@@ -52,30 +52,30 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return mixed |
54 | 54 | */ |
55 | - public function __call( $name, $arguments ) { |
|
55 | + public function __call($name, $arguments) { |
|
56 | 56 | $deprecated_function_arr = array( |
57 | 57 | 'get_customer_by', |
58 | 58 | 'give_update_customer_email_on_user_update', |
59 | 59 | 'get_customers', |
60 | 60 | ); |
61 | 61 | |
62 | - if ( in_array( $name, $deprecated_function_arr ) ) { |
|
63 | - switch ( $name ) { |
|
62 | + if (in_array($name, $deprecated_function_arr)) { |
|
63 | + switch ($name) { |
|
64 | 64 | case 'get_customers': |
65 | - $args = ! empty( $arguments[0] ) ? $arguments[0] : array(); |
|
65 | + $args = ! empty($arguments[0]) ? $arguments[0] : array(); |
|
66 | 66 | |
67 | - return $this->get_donors( $args ); |
|
67 | + return $this->get_donors($args); |
|
68 | 68 | case 'get_customer_by': |
69 | - $field = ! empty( $arguments[0] ) ? $arguments[0] : 'id'; |
|
70 | - $donor_id = ! empty( $arguments[1] ) ? $arguments[1] : 0; |
|
69 | + $field = ! empty($arguments[0]) ? $arguments[0] : 'id'; |
|
70 | + $donor_id = ! empty($arguments[1]) ? $arguments[1] : 0; |
|
71 | 71 | |
72 | - return $this->get_donor_by( $field, $donor_id ); |
|
72 | + return $this->get_donor_by($field, $donor_id); |
|
73 | 73 | |
74 | 74 | case 'give_update_customer_email_on_user_update': |
75 | - $user_id = ! empty( $arguments[0] ) ? $arguments[0] : 0; |
|
76 | - $old_user_data = ! empty( $arguments[1] ) ? $arguments[1] : false; |
|
75 | + $user_id = ! empty($arguments[0]) ? $arguments[0] : 0; |
|
76 | + $old_user_data = ! empty($arguments[1]) ? $arguments[1] : false; |
|
77 | 77 | |
78 | - return $this->update_donor_email_on_user_update( $user_id, $old_user_data ); |
|
78 | + return $this->update_donor_email_on_user_update($user_id, $old_user_data); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | } |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | * @param bool $_id_or_email |
97 | 97 | * @param bool $by_user_id |
98 | 98 | */ |
99 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
100 | - parent::__construct( $_id_or_email, $by_user_id ); |
|
99 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
100 | + parent::__construct($_id_or_email, $by_user_id); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return mixed |
113 | 113 | */ |
114 | - public function __call( $name, $arguments ) { |
|
114 | + public function __call($name, $arguments) { |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | /* @var WPDB $wpdb */ |
132 | 132 | global $wpdb; |
133 | 133 | |
134 | - $this->table_name = $wpdb->prefix . 'give_customermeta'; |
|
134 | + $this->table_name = $wpdb->prefix.'give_customermeta'; |
|
135 | 135 | $this->primary_key = 'meta_id'; |
136 | 136 | $this->version = '1.0'; |
137 | 137 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return mixed |
150 | 150 | */ |
151 | - public function __call( $name, $arguments ) { |
|
151 | + public function __call($name, $arguments) { |
|
152 | 152 | |
153 | 153 | } |
154 | 154 |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | */ |
5 | 5 | $give_map_deprecated_actions = give_deprecated_actions(); |
6 | 6 | |
7 | -foreach ( $give_map_deprecated_actions as $new => $old ) { |
|
8 | - add_action( $new, 'give_deprecated_action_mapping', 10, 4 ); |
|
7 | +foreach ($give_map_deprecated_actions as $new => $old) { |
|
8 | + add_action($new, 'give_deprecated_action_mapping', 10, 4); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | /** |
@@ -105,17 +105,17 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return mixed|void |
107 | 107 | */ |
108 | -function give_deprecated_action_mapping( $data, $arg_1 = '', $arg_2 = '', $arg_3 = '' ) { |
|
108 | +function give_deprecated_action_mapping($data, $arg_1 = '', $arg_2 = '', $arg_3 = '') { |
|
109 | 109 | $give_map_deprecated_actions = give_deprecated_actions(); |
110 | 110 | $action = current_filter(); |
111 | 111 | |
112 | - if ( isset( $give_map_deprecated_actions[ $action ] ) ) { |
|
113 | - if ( has_action( $give_map_deprecated_actions[ $action ] ) ) { |
|
114 | - do_action( $give_map_deprecated_actions[ $action ], $data, $arg_1, $arg_2, $arg_3 ); |
|
112 | + if (isset($give_map_deprecated_actions[$action])) { |
|
113 | + if (has_action($give_map_deprecated_actions[$action])) { |
|
114 | + do_action($give_map_deprecated_actions[$action], $data, $arg_1, $arg_2, $arg_3); |
|
115 | 115 | |
116 | - if ( ! defined( 'DOING_AJAX' ) ) { |
|
116 | + if ( ! defined('DOING_AJAX')) { |
|
117 | 117 | // translators: %s: action name. |
118 | - _give_deprecated_function( sprintf( __( 'The %s action' ), $give_map_deprecated_actions[ $action ] ), '1.7', $action ); |
|
118 | + _give_deprecated_function(sprintf(__('The %s action'), $give_map_deprecated_actions[$action]), '1.7', $action); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | } |
@@ -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 | |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @return bool $ret True if guest checkout is enabled, false otherwise |
29 | 29 | */ |
30 | -function give_no_guest_checkout( $form_id ) { |
|
30 | +function give_no_guest_checkout($form_id) { |
|
31 | 31 | |
32 | 32 | $backtrace = debug_backtrace(); |
33 | 33 | |
34 | - _give_deprecated_function( __FUNCTION__, '1.4.1', null, $backtrace ); |
|
34 | + _give_deprecated_function(__FUNCTION__, '1.4.1', null, $backtrace); |
|
35 | 35 | |
36 | - $ret = give_get_meta( $form_id, '_give_logged_in_only', true ); |
|
36 | + $ret = give_get_meta($form_id, '_give_logged_in_only', true); |
|
37 | 37 | |
38 | - return (bool) apply_filters( 'give_no_guest_checkout', give_is_setting_enabled( $ret ) ); |
|
38 | + return (bool) apply_filters('give_no_guest_checkout', give_is_setting_enabled($ret)); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -50,15 +50,15 @@ discard block |
||
50 | 50 | |
51 | 51 | $backtrace = debug_backtrace(); |
52 | 52 | |
53 | - _give_deprecated_function( __FUNCTION__, '1.8', null, $backtrace ); |
|
53 | + _give_deprecated_function(__FUNCTION__, '1.8', null, $backtrace); |
|
54 | 54 | |
55 | 55 | $views = array( |
56 | - 'sales' => __( 'Donations', 'give' ), |
|
57 | - 'gateway_errors' => __( 'Payment Errors', 'give' ), |
|
58 | - 'api_requests' => __( 'API Requests', 'give' ), |
|
56 | + 'sales' => __('Donations', 'give'), |
|
57 | + 'gateway_errors' => __('Payment Errors', 'give'), |
|
58 | + 'api_requests' => __('API Requests', 'give'), |
|
59 | 59 | ); |
60 | 60 | |
61 | - $views = apply_filters( 'give_log_views', $views ); |
|
61 | + $views = apply_filters('give_log_views', $views); |
|
62 | 62 | |
63 | 63 | return $views; |
64 | 64 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | $backtrace = debug_backtrace(); |
75 | 75 | |
76 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_agree_to_terms', $backtrace ); |
|
76 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_agree_to_terms', $backtrace); |
|
77 | 77 | |
78 | 78 | // Call new renamed function. |
79 | 79 | give_donation_form_validate_agree_to_terms(); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | $backtrace = debug_backtrace(); |
92 | 92 | |
93 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_logged_in_user', $backtrace ); |
|
93 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_logged_in_user', $backtrace); |
|
94 | 94 | |
95 | 95 | // Call new renamed function. |
96 | 96 | give_donation_form_validate_logged_in_user(); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | $backtrace = debug_backtrace(); |
109 | 109 | |
110 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_gateway', $backtrace ); |
|
110 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_gateway', $backtrace); |
|
111 | 111 | |
112 | 112 | // Call new renamed function. |
113 | 113 | give_donation_form_validate_gateway(); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | $backtrace = debug_backtrace(); |
126 | 126 | |
127 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_fields', $backtrace ); |
|
127 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_fields', $backtrace); |
|
128 | 128 | |
129 | 129 | // Call new renamed function. |
130 | 130 | give_donation_form_validate_fields(); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | |
142 | 142 | $backtrace = debug_backtrace(); |
143 | 143 | |
144 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_cc', $backtrace ); |
|
144 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_cc', $backtrace); |
|
145 | 145 | |
146 | 146 | // Call new renamed function. |
147 | 147 | give_donation_form_validate_cc(); |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | $backtrace = debug_backtrace(); |
160 | 160 | |
161 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_get_donation_cc_info', $backtrace ); |
|
161 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_get_donation_cc_info', $backtrace); |
|
162 | 162 | |
163 | 163 | // Call new renamed function. |
164 | 164 | give_get_donation_cc_info(); |
@@ -175,14 +175,14 @@ discard block |
||
175 | 175 | * @param int $zip |
176 | 176 | * @param string $country_code |
177 | 177 | */ |
178 | -function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
178 | +function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
179 | 179 | |
180 | 180 | $backtrace = debug_backtrace(); |
181 | 181 | |
182 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_cc_zip', $backtrace ); |
|
182 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_cc_zip', $backtrace); |
|
183 | 183 | |
184 | 184 | // Call new renamed function. |
185 | - give_donation_form_validate_cc_zip( $zip, $country_code ); |
|
185 | + give_donation_form_validate_cc_zip($zip, $country_code); |
|
186 | 186 | |
187 | 187 | } |
188 | 188 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | |
197 | 197 | $backtrace = debug_backtrace(); |
198 | 198 | |
199 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_user_login', $backtrace ); |
|
199 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_user_login', $backtrace); |
|
200 | 200 | |
201 | 201 | // Call new renamed function. |
202 | 202 | give_donation_form_validate_user_login(); |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | |
214 | 214 | $backtrace = debug_backtrace(); |
215 | 215 | |
216 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_guest_user', $backtrace ); |
|
216 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_guest_user', $backtrace); |
|
217 | 217 | |
218 | 218 | // Call new renamed function. |
219 | 219 | give_donation_form_validate_guest_user(); |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | |
231 | 231 | $backtrace = debug_backtrace(); |
232 | 232 | |
233 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_new_user', $backtrace ); |
|
233 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_new_user', $backtrace); |
|
234 | 234 | |
235 | 235 | // Call new renamed function. |
236 | 236 | give_donation_form_validate_new_user(); |
@@ -246,14 +246,14 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @param array $valid_data |
248 | 248 | */ |
249 | -function give_get_purchase_form_user( $valid_data = array() ) { |
|
249 | +function give_get_purchase_form_user($valid_data = array()) { |
|
250 | 250 | |
251 | 251 | $backtrace = debug_backtrace(); |
252 | 252 | |
253 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_get_donation_form_user', $backtrace ); |
|
253 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_get_donation_form_user', $backtrace); |
|
254 | 254 | |
255 | 255 | // Call new renamed function. |
256 | - give_get_donation_form_user( $valid_data ); |
|
256 | + give_get_donation_form_user($valid_data); |
|
257 | 257 | |
258 | 258 | } |
259 | 259 | |
@@ -269,12 +269,12 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return string |
271 | 271 | */ |
272 | -function give_checkout_button_purchase( $form_id ) { |
|
272 | +function give_checkout_button_purchase($form_id) { |
|
273 | 273 | $backtrace = debug_backtrace(); |
274 | 274 | |
275 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_get_donation_form_submit_button', $backtrace ); |
|
275 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_get_donation_form_submit_button', $backtrace); |
|
276 | 276 | |
277 | - return give_get_donation_form_submit_button( $form_id ); |
|
277 | + return give_get_donation_form_submit_button($form_id); |
|
278 | 278 | |
279 | 279 | } |
280 | 280 | |
@@ -287,13 +287,13 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @return int $customer_id Customer ID. |
289 | 289 | */ |
290 | -function give_get_payment_customer_id( $payment_id ) { |
|
290 | +function give_get_payment_customer_id($payment_id) { |
|
291 | 291 | |
292 | 292 | $backtrace = debug_backtrace(); |
293 | 293 | |
294 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_get_payment_donor_id', $backtrace ); |
|
294 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_get_payment_donor_id', $backtrace); |
|
295 | 295 | |
296 | - return give_get_payment_donor_id( $payment_id ); |
|
296 | + return give_get_payment_donor_id($payment_id); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | |
309 | 309 | $backtrace = debug_backtrace(); |
310 | 310 | |
311 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_get_total_donations', $backtrace ); |
|
311 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_get_total_donations', $backtrace); |
|
312 | 312 | |
313 | 313 | return give_get_total_donations(); |
314 | 314 | } |
@@ -326,13 +326,13 @@ discard block |
||
326 | 326 | * |
327 | 327 | * @return int The total number of donations |
328 | 328 | */ |
329 | -function give_count_purchases_of_customer( $user = null ) { |
|
329 | +function give_count_purchases_of_customer($user = null) { |
|
330 | 330 | |
331 | 331 | $backtrace = debug_backtrace(); |
332 | 332 | |
333 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_count_donations_of_donor', $backtrace ); |
|
333 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_count_donations_of_donor', $backtrace); |
|
334 | 334 | |
335 | - return give_count_donations_of_donor( $user ); |
|
335 | + return give_count_donations_of_donor($user); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -348,13 +348,13 @@ discard block |
||
348 | 348 | * |
349 | 349 | * @return array |
350 | 350 | */ |
351 | -function give_get_purchase_stats_by_user( $user = '' ) { |
|
351 | +function give_get_purchase_stats_by_user($user = '') { |
|
352 | 352 | |
353 | 353 | $backtrace = debug_backtrace(); |
354 | 354 | |
355 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_get_donation_stats_by_user', $backtrace ); |
|
355 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_get_donation_stats_by_user', $backtrace); |
|
356 | 356 | |
357 | - return give_get_donation_stats_by_user( $user ); |
|
357 | + return give_get_donation_stats_by_user($user); |
|
358 | 358 | |
359 | 359 | } |
360 | 360 | |
@@ -372,13 +372,13 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @return bool|object List of all user donations |
374 | 374 | */ |
375 | -function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
375 | +function give_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
376 | 376 | |
377 | 377 | $backtrace = debug_backtrace(); |
378 | 378 | |
379 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_get_users_donations', $backtrace ); |
|
379 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_get_users_donations', $backtrace); |
|
380 | 380 | |
381 | - return give_get_users_donations( $user, $number, $pagination, $status ); |
|
381 | + return give_get_users_donations($user, $number, $pagination, $status); |
|
382 | 382 | |
383 | 383 | } |
384 | 384 | |
@@ -395,13 +395,13 @@ discard block |
||
395 | 395 | * |
396 | 396 | * @return bool True if has donated, false other wise. |
397 | 397 | */ |
398 | -function give_has_purchases( $user_id = null ) { |
|
398 | +function give_has_purchases($user_id = null) { |
|
399 | 399 | |
400 | 400 | $backtrace = debug_backtrace(); |
401 | 401 | |
402 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_has_donations', $backtrace ); |
|
402 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_has_donations', $backtrace); |
|
403 | 403 | |
404 | - return give_has_donations( $user_id ); |
|
404 | + return give_has_donations($user_id); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | function give_count_total_customers() { |
416 | 416 | $backtrace = debug_backtrace(); |
417 | 417 | |
418 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_count_total_donors', $backtrace ); |
|
418 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_count_total_donors', $backtrace); |
|
419 | 419 | |
420 | 420 | return give_count_total_donors(); |
421 | 421 | } |
@@ -430,13 +430,13 @@ discard block |
||
430 | 430 | * |
431 | 431 | * @return float The total amount the user has spent |
432 | 432 | */ |
433 | -function give_purchase_total_of_user( $user = null ) { |
|
433 | +function give_purchase_total_of_user($user = null) { |
|
434 | 434 | |
435 | 435 | $backtrace = debug_backtrace(); |
436 | 436 | |
437 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_donation_total_of_user', $backtrace ); |
|
437 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_donation_total_of_user', $backtrace); |
|
438 | 438 | |
439 | - return give_donation_total_of_user( $user ); |
|
439 | + return give_donation_total_of_user($user); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | /** |
@@ -450,13 +450,13 @@ discard block |
||
450 | 450 | * |
451 | 451 | * @return void |
452 | 452 | */ |
453 | -function give_delete_purchase( $payment_id = 0, $update_customer = true ) { |
|
453 | +function give_delete_purchase($payment_id = 0, $update_customer = true) { |
|
454 | 454 | |
455 | 455 | $backtrace = debug_backtrace(); |
456 | 456 | |
457 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_delete_donation', $backtrace ); |
|
457 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_delete_donation', $backtrace); |
|
458 | 458 | |
459 | - give_delete_donation( $payment_id, $update_customer ); |
|
459 | + give_delete_donation($payment_id, $update_customer); |
|
460 | 460 | |
461 | 461 | } |
462 | 462 | |
@@ -474,13 +474,13 @@ discard block |
||
474 | 474 | * |
475 | 475 | * @return void |
476 | 476 | */ |
477 | -function give_undo_purchase( $form_id = false, $payment_id ) { |
|
477 | +function give_undo_purchase($form_id = false, $payment_id) { |
|
478 | 478 | |
479 | 479 | $backtrace = debug_backtrace(); |
480 | 480 | |
481 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_undo_donation', $backtrace ); |
|
481 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_undo_donation', $backtrace); |
|
482 | 482 | |
483 | - give_undo_donation( $payment_id ); |
|
483 | + give_undo_donation($payment_id); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | |
@@ -493,12 +493,12 @@ discard block |
||
493 | 493 | * |
494 | 494 | * @return void |
495 | 495 | */ |
496 | -function give_trigger_purchase_delete( $data ) { |
|
496 | +function give_trigger_purchase_delete($data) { |
|
497 | 497 | $backtrace = debug_backtrace(); |
498 | 498 | |
499 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_trigger_donation_delete', $backtrace ); |
|
499 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_trigger_donation_delete', $backtrace); |
|
500 | 500 | |
501 | - give_trigger_donation_delete( $data ); |
|
501 | + give_trigger_donation_delete($data); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | |
@@ -512,12 +512,12 @@ discard block |
||
512 | 512 | * |
513 | 513 | * @return bool|int |
514 | 514 | */ |
515 | -function give_increase_purchase_count( $form_id = 0, $quantity = 1 ) { |
|
515 | +function give_increase_purchase_count($form_id = 0, $quantity = 1) { |
|
516 | 516 | $backtrace = debug_backtrace(); |
517 | 517 | |
518 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_increase_donation_count', $backtrace ); |
|
518 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_increase_donation_count', $backtrace); |
|
519 | 519 | |
520 | - give_increase_donation_count( $form_id, $quantity ); |
|
520 | + give_increase_donation_count($form_id, $quantity); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | |
@@ -536,12 +536,12 @@ discard block |
||
536 | 536 | * |
537 | 537 | * @return void |
538 | 538 | */ |
539 | -function give_record_sale_in_log( $give_form_id = 0, $payment_id, $price_id = false, $sale_date = null ) { |
|
539 | +function give_record_sale_in_log($give_form_id = 0, $payment_id, $price_id = false, $sale_date = null) { |
|
540 | 540 | $backtrace = debug_backtrace(); |
541 | 541 | |
542 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_record_donation_in_log', $backtrace ); |
|
542 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_record_donation_in_log', $backtrace); |
|
543 | 543 | |
544 | - give_record_donation_in_log( $give_form_id, $payment_id, $price_id, $sale_date ); |
|
544 | + give_record_donation_in_log($give_form_id, $payment_id, $price_id, $sale_date); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
@@ -558,12 +558,12 @@ discard block |
||
558 | 558 | * |
559 | 559 | * @return void |
560 | 560 | */ |
561 | -function give_print_errors( $form_id ) { |
|
561 | +function give_print_errors($form_id) { |
|
562 | 562 | $backtrace = debug_backtrace(); |
563 | 563 | |
564 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'Give_Notice::print_frontend_errors', $backtrace ); |
|
564 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'Give_Notice::print_frontend_errors', $backtrace); |
|
565 | 565 | |
566 | - do_action( 'give_frontend_notices', $form_id ); |
|
566 | + do_action('give_frontend_notices', $form_id); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | /** |
@@ -579,10 +579,10 @@ discard block |
||
579 | 579 | * |
580 | 580 | * @return string $error |
581 | 581 | */ |
582 | -function give_output_error( $message, $echo = true, $error_id = 'warning' ) { |
|
582 | +function give_output_error($message, $echo = true, $error_id = 'warning') { |
|
583 | 583 | $backtrace = debug_backtrace(); |
584 | 584 | |
585 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'Give_Notice::print_frontend_notice', $backtrace ); |
|
585 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'Give_Notice::print_frontend_notice', $backtrace); |
|
586 | 586 | |
587 | - Give()->notices->print_frontend_notice( $message, $echo, $error_id ); |
|
587 | + Give()->notices->print_frontend_notice($message, $echo, $error_id); |
|
588 | 588 | } |
@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | |
8 | 8 | $give_map_deprecated_filters = give_deprecated_filters(); |
9 | 9 | |
10 | -foreach ( $give_map_deprecated_filters as $new => $old ) { |
|
11 | - add_filter( $new, 'give_deprecated_filter_mapping', 10, 4 ); |
|
10 | +foreach ($give_map_deprecated_filters as $new => $old) { |
|
11 | + add_filter($new, 'give_deprecated_filter_mapping', 10, 4); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
@@ -65,17 +65,17 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return mixed |
67 | 67 | */ |
68 | -function give_deprecated_filter_mapping( $data, $arg_1 = '', $arg_2 = '', $arg_3 = '' ) { |
|
68 | +function give_deprecated_filter_mapping($data, $arg_1 = '', $arg_2 = '', $arg_3 = '') { |
|
69 | 69 | $give_map_deprecated_filters = give_deprecated_filters(); |
70 | 70 | $filter = current_filter(); |
71 | 71 | |
72 | - if ( isset( $give_map_deprecated_filters[ $filter ] ) ) { |
|
73 | - if ( has_filter( $give_map_deprecated_filters[ $filter ] ) ) { |
|
74 | - $data = apply_filters( $give_map_deprecated_filters[ $filter ], $data, $arg_1, $arg_2, $arg_3 ); |
|
72 | + if (isset($give_map_deprecated_filters[$filter])) { |
|
73 | + if (has_filter($give_map_deprecated_filters[$filter])) { |
|
74 | + $data = apply_filters($give_map_deprecated_filters[$filter], $data, $arg_1, $arg_2, $arg_3); |
|
75 | 75 | |
76 | - if ( ! defined( 'DOING_AJAX' ) ) { |
|
77 | - _give_deprecated_function( sprintf( /* translators: %s: filter name */ |
|
78 | - __( 'The %s filter' ), $give_map_deprecated_filters[ $filter ] ), '1.7', $filter ); |
|
76 | + if ( ! defined('DOING_AJAX')) { |
|
77 | + _give_deprecated_function(sprintf( /* translators: %s: filter name */ |
|
78 | + __('The %s filter'), $give_map_deprecated_filters[$filter] ), '1.7', $filter); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | } |
@@ -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,25 +25,25 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_load_scripts() { |
27 | 27 | |
28 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/frontend/'; |
|
29 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
30 | - $scripts_footer = ( give_is_setting_enabled( give_get_option( 'scripts_footer' ) ) ) ? true : false; |
|
28 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/frontend/'; |
|
29 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
30 | + $scripts_footer = (give_is_setting_enabled(give_get_option('scripts_footer'))) ? true : false; |
|
31 | 31 | |
32 | 32 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
33 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
33 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
34 | 34 | |
35 | 35 | // Localize / PHP to AJAX vars. |
36 | - $localize_give_vars = apply_filters( 'give_global_script_vars', array( |
|
36 | + $localize_give_vars = apply_filters('give_global_script_vars', array( |
|
37 | 37 | 'ajaxurl' => give_get_ajax_url(), |
38 | - 'checkout_nonce' => wp_create_nonce( 'give_checkout_nonce' ), |
|
39 | - 'currency_sign' => give_currency_filter( '' ), |
|
38 | + 'checkout_nonce' => wp_create_nonce('give_checkout_nonce'), |
|
39 | + 'currency_sign' => give_currency_filter(''), |
|
40 | 40 | 'currency_pos' => give_get_currency_position(), |
41 | 41 | 'thousands_separator' => give_get_price_thousand_separator(), |
42 | 42 | 'decimal_separator' => give_get_price_decimal_separator(), |
43 | - 'no_gateway' => __( 'Please select a payment method.', 'give' ), |
|
44 | - 'bad_minimum' => __( 'The minimum custom donation amount for this form is', 'give' ), |
|
45 | - 'general_loading' => __( 'Loading...', 'give' ), |
|
46 | - 'purchase_loading' => __( 'Please Wait...', 'give' ), |
|
43 | + 'no_gateway' => __('Please select a payment method.', 'give'), |
|
44 | + 'bad_minimum' => __('The minimum custom donation amount for this form is', 'give'), |
|
45 | + 'general_loading' => __('Loading...', 'give'), |
|
46 | + 'purchase_loading' => __('Please Wait...', 'give'), |
|
47 | 47 | 'number_decimals' => give_get_price_decimals(), |
48 | 48 | 'give_version' => GIVE_VERSION, |
49 | 49 | 'magnific_options' => apply_filters( |
@@ -57,81 +57,81 @@ discard block |
||
57 | 57 | 'give_form_translation_js', |
58 | 58 | array( |
59 | 59 | // Field name Validation message. |
60 | - 'payment-mode' => __( 'Please select payment mode.', 'give' ), |
|
61 | - 'give_first' => __( 'Please enter your first name.', 'give' ), |
|
62 | - 'give_email' => __( 'Please enter a valid email address.', 'give' ), |
|
63 | - 'give_user_login' => __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ), |
|
64 | - 'give_user_pass' => __( 'Enter a password.', 'give' ), |
|
65 | - 'give_user_pass_confirm' => __( 'Enter the password confirmation.', 'give' ), |
|
66 | - 'give_agree_to_terms' => __( 'You must agree to the terms and conditions.', 'give' ), |
|
60 | + 'payment-mode' => __('Please select payment mode.', 'give'), |
|
61 | + 'give_first' => __('Please enter your first name.', 'give'), |
|
62 | + 'give_email' => __('Please enter a valid email address.', 'give'), |
|
63 | + 'give_user_login' => __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'), |
|
64 | + 'give_user_pass' => __('Enter a password.', 'give'), |
|
65 | + 'give_user_pass_confirm' => __('Enter the password confirmation.', 'give'), |
|
66 | + 'give_agree_to_terms' => __('You must agree to the terms and conditions.', 'give'), |
|
67 | 67 | ) |
68 | 68 | ), |
69 | - ) ); |
|
69 | + )); |
|
70 | 70 | |
71 | - $localize_give_ajax = apply_filters( 'give_global_ajax_vars', array( |
|
71 | + $localize_give_ajax = apply_filters('give_global_ajax_vars', array( |
|
72 | 72 | 'ajaxurl' => give_get_ajax_url(), |
73 | - 'loading' => __( 'Loading', 'give' ), |
|
73 | + 'loading' => __('Loading', 'give'), |
|
74 | 74 | // General loading message. |
75 | - 'select_option' => __( 'Please select an option', 'give' ), |
|
75 | + 'select_option' => __('Please select an option', 'give'), |
|
76 | 76 | // Variable pricing error with multi-donation option enabled. |
77 | - 'default_gateway' => give_get_default_gateway( null ), |
|
78 | - 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', |
|
77 | + 'default_gateway' => give_get_default_gateway(null), |
|
78 | + 'permalinks' => get_option('permalink_structure') ? '1' : '0', |
|
79 | 79 | 'number_decimals' => give_get_price_decimals(), |
80 | - ) ); |
|
80 | + )); |
|
81 | 81 | |
82 | 82 | // DEBUG is On. |
83 | - if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { |
|
83 | + if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) { |
|
84 | 84 | |
85 | - if ( give_is_cc_verify_enabled() ) { |
|
86 | - wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
87 | - wp_enqueue_script( 'give-cc-validator' ); |
|
85 | + if (give_is_cc_verify_enabled()) { |
|
86 | + wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
87 | + wp_enqueue_script('give-cc-validator'); |
|
88 | 88 | } |
89 | 89 | |
90 | - wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
91 | - wp_enqueue_script( 'give-float-labels' ); |
|
90 | + wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
91 | + wp_enqueue_script('give-float-labels'); |
|
92 | 92 | |
93 | - wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
94 | - wp_enqueue_script( 'give-blockui' ); |
|
93 | + wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
94 | + wp_enqueue_script('give-blockui'); |
|
95 | 95 | |
96 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
97 | - wp_enqueue_script( 'give-qtip' ); |
|
96 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
97 | + wp_enqueue_script('give-qtip'); |
|
98 | 98 | |
99 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
100 | - wp_enqueue_script( 'give-accounting' ); |
|
99 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
100 | + wp_enqueue_script('give-accounting'); |
|
101 | 101 | |
102 | - wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
103 | - wp_enqueue_script( 'give-magnific' ); |
|
102 | + wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
103 | + wp_enqueue_script('give-magnific'); |
|
104 | 104 | |
105 | - wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
106 | - wp_enqueue_script( 'give-checkout-global' ); |
|
105 | + wp_register_script('give-checkout-global', $js_dir.'give-checkout-global'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
106 | + wp_enqueue_script('give-checkout-global'); |
|
107 | 107 | |
108 | 108 | // General scripts. |
109 | - wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
110 | - wp_enqueue_script( 'give-scripts' ); |
|
109 | + wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
110 | + wp_enqueue_script('give-scripts'); |
|
111 | 111 | |
112 | 112 | // Load AJAX scripts, if enabled. |
113 | - wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
114 | - wp_enqueue_script( 'give-ajax' ); |
|
113 | + wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
114 | + wp_enqueue_script('give-ajax'); |
|
115 | 115 | |
116 | 116 | // Localize / Pass AJAX vars from PHP, |
117 | - wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_vars ); |
|
118 | - wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax ); |
|
117 | + wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_vars); |
|
118 | + wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax); |
|
119 | 119 | |
120 | 120 | } else { |
121 | 121 | |
122 | 122 | // DEBUG is OFF (one JS file to rule them all!). |
123 | - wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
124 | - wp_enqueue_script( 'give' ); |
|
123 | + wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
124 | + wp_enqueue_script('give'); |
|
125 | 125 | |
126 | 126 | // Localize / Pass AJAX vars from PHP. |
127 | - wp_localize_script( 'give', 'give_global_vars', $localize_give_vars ); |
|
128 | - wp_localize_script( 'give', 'give_scripts', $localize_give_ajax ); |
|
127 | + wp_localize_script('give', 'give_global_vars', $localize_give_vars); |
|
128 | + wp_localize_script('give', 'give_scripts', $localize_give_ajax); |
|
129 | 129 | |
130 | 130 | } |
131 | 131 | |
132 | 132 | } |
133 | 133 | |
134 | -add_action( 'wp_enqueue_scripts', 'give_load_scripts' ); |
|
134 | +add_action('wp_enqueue_scripts', 'give_load_scripts'); |
|
135 | 135 | |
136 | 136 | /** |
137 | 137 | * Register styles. |
@@ -144,16 +144,16 @@ discard block |
||
144 | 144 | */ |
145 | 145 | function give_register_styles() { |
146 | 146 | |
147 | - if ( ! give_is_setting_enabled( give_get_option( 'css' ) ) ) { |
|
147 | + if ( ! give_is_setting_enabled(give_get_option('css'))) { |
|
148 | 148 | return; |
149 | 149 | } |
150 | 150 | |
151 | - wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' ); |
|
152 | - wp_enqueue_style( 'give-styles' ); |
|
151 | + wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all'); |
|
152 | + wp_enqueue_style('give-styles'); |
|
153 | 153 | |
154 | 154 | } |
155 | 155 | |
156 | -add_action( 'wp_enqueue_scripts', 'give_register_styles' ); |
|
156 | +add_action('wp_enqueue_scripts', 'give_register_styles'); |
|
157 | 157 | |
158 | 158 | |
159 | 159 | /** |
@@ -166,19 +166,19 @@ discard block |
||
166 | 166 | function give_get_stylesheet_uri() { |
167 | 167 | |
168 | 168 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
169 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
169 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
170 | 170 | |
171 | 171 | // LTR or RTL files. |
172 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
172 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
173 | 173 | |
174 | - $file = 'give' . $direction . $suffix . '.css'; |
|
174 | + $file = 'give'.$direction.$suffix.'.css'; |
|
175 | 175 | $templates_dir = give_get_theme_template_dir_name(); |
176 | 176 | |
177 | - $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file; |
|
178 | - $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
179 | - $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file; |
|
180 | - $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
181 | - $give_plugin_style_sheet = trailingslashit( give_get_templates_dir() ) . $file; |
|
177 | + $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()).$templates_dir.$file; |
|
178 | + $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$direction.'.css'; |
|
179 | + $parent_theme_style_sheet = trailingslashit(get_template_directory()).$templates_dir.$file; |
|
180 | + $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$direction.'.css'; |
|
181 | + $give_plugin_style_sheet = trailingslashit(give_get_templates_dir()).$file; |
|
182 | 182 | |
183 | 183 | $uri = false; |
184 | 184 | |
@@ -188,23 +188,23 @@ discard block |
||
188 | 188 | * followed by non minified version, even if SCRIPT_DEBUG is not enabled. |
189 | 189 | * This allows users to copy just give.css to their theme. |
190 | 190 | */ |
191 | - if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) { |
|
192 | - if ( ! empty( $nonmin ) ) { |
|
193 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
191 | + if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) { |
|
192 | + if ( ! empty($nonmin)) { |
|
193 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
194 | 194 | } else { |
195 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file; |
|
195 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file; |
|
196 | 196 | } |
197 | - } elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) { |
|
198 | - if ( ! empty( $nonmin ) ) { |
|
199 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
197 | + } elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) { |
|
198 | + if ( ! empty($nonmin)) { |
|
199 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
200 | 200 | } else { |
201 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file; |
|
201 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file; |
|
202 | 202 | } |
203 | - } elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) { |
|
204 | - $uri = trailingslashit( give_get_templates_url() ) . $file; |
|
203 | + } elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) { |
|
204 | + $uri = trailingslashit(give_get_templates_url()).$file; |
|
205 | 205 | } |
206 | 206 | |
207 | - return apply_filters( 'give_get_stylesheet_uri', $uri ); |
|
207 | + return apply_filters('give_get_stylesheet_uri', $uri); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
@@ -221,76 +221,76 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return void |
223 | 223 | */ |
224 | -function give_load_admin_scripts( $hook ) { |
|
224 | +function give_load_admin_scripts($hook) { |
|
225 | 225 | |
226 | 226 | global $post, $post_type; |
227 | 227 | |
228 | 228 | $give_options = give_get_settings(); |
229 | 229 | |
230 | 230 | // Directories of assets. |
231 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
232 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
233 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
231 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
232 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
233 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
234 | 234 | |
235 | 235 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
236 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
236 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
237 | 237 | |
238 | 238 | // LTR or RTL files. |
239 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
239 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
240 | 240 | |
241 | 241 | // Global Admin. |
242 | - wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' ); |
|
243 | - wp_enqueue_style( 'give-admin-bar-notification' ); |
|
242 | + wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css'); |
|
243 | + wp_enqueue_style('give-admin-bar-notification'); |
|
244 | 244 | |
245 | 245 | // Give Admin Only. |
246 | - if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) { |
|
246 | + if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { |
|
247 | 247 | return; |
248 | 248 | } |
249 | 249 | |
250 | 250 | // CSS. |
251 | - wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' ); |
|
252 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
253 | - wp_register_style( 'give-admin', $css_dir . 'give-admin' . $direction . $suffix . '.css', array(), GIVE_VERSION ); |
|
254 | - wp_enqueue_style( 'give-admin' ); |
|
255 | - wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION ); |
|
256 | - wp_enqueue_style( 'jquery-chosen' ); |
|
257 | - wp_enqueue_style( 'thickbox' ); |
|
258 | - wp_enqueue_style( 'wp-color-picker' ); |
|
251 | + wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css'); |
|
252 | + wp_enqueue_style('jquery-ui-css'); |
|
253 | + wp_register_style('give-admin', $css_dir.'give-admin'.$direction.$suffix.'.css', array(), GIVE_VERSION); |
|
254 | + wp_enqueue_style('give-admin'); |
|
255 | + wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION); |
|
256 | + wp_enqueue_style('jquery-chosen'); |
|
257 | + wp_enqueue_style('thickbox'); |
|
258 | + wp_enqueue_style('wp-color-picker'); |
|
259 | 259 | |
260 | 260 | |
261 | 261 | // JS. |
262 | - wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
263 | - wp_enqueue_script( 'jquery-chosen' ); |
|
262 | + wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
263 | + wp_enqueue_script('jquery-chosen'); |
|
264 | 264 | |
265 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
266 | - wp_enqueue_script( 'give-accounting' ); |
|
265 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
266 | + wp_enqueue_script('give-accounting'); |
|
267 | 267 | |
268 | - wp_enqueue_script( 'wp-color-picker' ); |
|
269 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
270 | - wp_enqueue_script( 'thickbox' ); |
|
268 | + wp_enqueue_script('wp-color-picker'); |
|
269 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
270 | + wp_enqueue_script('thickbox'); |
|
271 | 271 | |
272 | - wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'wp-color-picker' ), GIVE_VERSION, false ); |
|
273 | - wp_enqueue_script( 'give-admin-scripts' ); |
|
272 | + wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery', 'jquery-ui-datepicker', 'wp-color-picker'), GIVE_VERSION, false); |
|
273 | + wp_enqueue_script('give-admin-scripts'); |
|
274 | 274 | |
275 | - wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' ); |
|
276 | - wp_enqueue_script( 'jquery-flot' ); |
|
275 | + wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js'); |
|
276 | + wp_enqueue_script('jquery-flot'); |
|
277 | 277 | |
278 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
279 | - wp_enqueue_script( 'give-qtip' ); |
|
278 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
279 | + wp_enqueue_script('give-qtip'); |
|
280 | 280 | |
281 | - wp_register_script( 'give-repeatable-fields', $js_plugins . 'repeatable-fields' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
282 | - wp_enqueue_script( 'give-repeatable-fields' ); |
|
281 | + wp_register_script('give-repeatable-fields', $js_plugins.'repeatable-fields'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
282 | + wp_enqueue_script('give-repeatable-fields'); |
|
283 | 283 | |
284 | 284 | // Forms CPT Script. |
285 | - if ( $post_type === 'give_forms' ) { |
|
286 | - wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
287 | - wp_enqueue_script( 'give-admin-forms-scripts' ); |
|
285 | + if ($post_type === 'give_forms') { |
|
286 | + wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
287 | + wp_enqueue_script('give-admin-forms-scripts'); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | // Settings Scripts. |
291 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) { |
|
292 | - wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
293 | - wp_enqueue_script( 'give-admin-settings-scripts' ); |
|
291 | + if (isset($_GET['page']) && $_GET['page'] == 'give-settings') { |
|
292 | + wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
293 | + wp_enqueue_script('give-admin-settings-scripts'); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | // Price Separators. |
@@ -298,74 +298,74 @@ discard block |
||
298 | 298 | $decimal_separator = give_get_price_decimal_separator(); |
299 | 299 | |
300 | 300 | // Localize strings & variables for JS. |
301 | - wp_localize_script( 'give-admin-scripts', 'give_vars', array( |
|
302 | - 'post_id' => isset( $post->ID ) ? $post->ID : null, |
|
301 | + wp_localize_script('give-admin-scripts', 'give_vars', array( |
|
302 | + 'post_id' => isset($post->ID) ? $post->ID : null, |
|
303 | 303 | 'give_version' => GIVE_VERSION, |
304 | 304 | 'thousands_separator' => $thousand_separator, |
305 | 305 | 'decimal_separator' => $decimal_separator, |
306 | - 'quick_edit_warning' => __( 'Not available for variable priced forms.', 'give' ), |
|
307 | - 'delete_payment' => __( 'Are you sure you want to delete this payment?', 'give' ), |
|
308 | - 'delete_payment_note' => __( 'Are you sure you want to delete this note?', 'give' ), |
|
309 | - 'revoke_api_key' => __( 'Are you sure you want to revoke this API key?', 'give' ), |
|
310 | - 'regenerate_api_key' => __( 'Are you sure you want to regenerate this API key?', 'give' ), |
|
311 | - 'resend_receipt' => __( 'Are you sure you want to resend the donation receipt?', 'give' ), |
|
312 | - 'disconnect_user' => __( 'Are you sure you want to disconnect the user from this donor?', 'give' ), |
|
313 | - 'one_option' => __( 'Choose a form', 'give' ), |
|
314 | - 'one_or_more_option' => __( 'Choose one or more forms', 'give' ), |
|
315 | - 'currency_sign' => give_currency_filter( '' ), |
|
316 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', |
|
317 | - 'currency_decimals' => give_currency_decimal_filter( give_get_price_decimals() ), |
|
318 | - 'batch_export_no_class' => __( 'You must choose a method.', 'give' ), |
|
319 | - 'batch_export_no_reqs' => __( 'Required fields not completed.', 'give' ), |
|
320 | - 'reset_stats_warn' => __( 'Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give' ), |
|
321 | - 'price_format_guide' => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ), |
|
306 | + 'quick_edit_warning' => __('Not available for variable priced forms.', 'give'), |
|
307 | + 'delete_payment' => __('Are you sure you want to delete this payment?', 'give'), |
|
308 | + 'delete_payment_note' => __('Are you sure you want to delete this note?', 'give'), |
|
309 | + 'revoke_api_key' => __('Are you sure you want to revoke this API key?', 'give'), |
|
310 | + 'regenerate_api_key' => __('Are you sure you want to regenerate this API key?', 'give'), |
|
311 | + 'resend_receipt' => __('Are you sure you want to resend the donation receipt?', 'give'), |
|
312 | + 'disconnect_user' => __('Are you sure you want to disconnect the user from this donor?', 'give'), |
|
313 | + 'one_option' => __('Choose a form', 'give'), |
|
314 | + 'one_or_more_option' => __('Choose one or more forms', 'give'), |
|
315 | + 'currency_sign' => give_currency_filter(''), |
|
316 | + 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', |
|
317 | + 'currency_decimals' => give_currency_decimal_filter(give_get_price_decimals()), |
|
318 | + 'batch_export_no_class' => __('You must choose a method.', 'give'), |
|
319 | + 'batch_export_no_reqs' => __('Required fields not completed.', 'give'), |
|
320 | + 'reset_stats_warn' => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'), |
|
321 | + 'price_format_guide' => sprintf(__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator), |
|
322 | 322 | /* translators : %s: Donation form options metabox */ |
323 | - 'confirm_before_remove_row_text' => __( 'Do you want to delete this level?', 'give' ), |
|
324 | - 'matched_success_failure_page' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
|
325 | - 'dismiss_notice_text' => __( 'Dismiss this notice.', 'give' ), |
|
326 | - 'search_placeholder' => __( 'Type to search all forms', 'give' ), |
|
327 | - 'search_placeholder_donor' => __( 'Type to search all donors', 'give' ), |
|
328 | - 'search_placeholder_country' => __( 'Type to search all countries', 'give' ), |
|
329 | - 'search_placeholder_state' => __( 'Type to search all states/provinces', 'give' ), |
|
323 | + 'confirm_before_remove_row_text' => __('Do you want to delete this level?', 'give'), |
|
324 | + 'matched_success_failure_page' => __('You cannot set the success and failed pages to the same page', 'give'), |
|
325 | + 'dismiss_notice_text' => __('Dismiss this notice.', 'give'), |
|
326 | + 'search_placeholder' => __('Type to search all forms', 'give'), |
|
327 | + 'search_placeholder_donor' => __('Type to search all donors', 'give'), |
|
328 | + 'search_placeholder_country' => __('Type to search all countries', 'give'), |
|
329 | + 'search_placeholder_state' => __('Type to search all states/provinces', 'give'), |
|
330 | 330 | 'bulk_action' => array( |
331 | 331 | 'delete' => array( |
332 | - 'zero_payment_selected' => __( 'You must choose at least one or more payments to delete.', 'give' ), |
|
333 | - 'delete_payment' => __( 'Are you sure you want to permanently delete this donation?', 'give' ), |
|
334 | - 'delete_payments' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ), |
|
332 | + 'zero_payment_selected' => __('You must choose at least one or more payments to delete.', 'give'), |
|
333 | + 'delete_payment' => __('Are you sure you want to permanently delete this donation?', 'give'), |
|
334 | + 'delete_payments' => __('Are you sure you want to permanently delete the selected {payment_count} donations?', 'give'), |
|
335 | 335 | ), |
336 | 336 | 'resend_receipt' => array( |
337 | - 'zero_recipient_selected' => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ), |
|
338 | - 'resend_receipt' => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ), |
|
339 | - 'resend_receipts' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ), |
|
337 | + 'zero_recipient_selected' => __('You must choose at least one or more recipients to resend the email receipt.', 'give'), |
|
338 | + 'resend_receipt' => __('Are you sure you want to resend the email receipt to this recipient?', 'give'), |
|
339 | + 'resend_receipts' => __('Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give'), |
|
340 | 340 | ), |
341 | 341 | 'set_to_status' => array( |
342 | - 'zero' => __( 'You must choose at least one or more donations to set status to {status}.', 'give' ), |
|
343 | - 'single' => __( 'Are you sure you want to set status of this donation to {status}?', 'give' ), |
|
344 | - 'multiple' => __( 'Are you sure you want to set status of {payment_count} donations to {status}?', 'give' ), |
|
342 | + 'zero' => __('You must choose at least one or more donations to set status to {status}.', 'give'), |
|
343 | + 'single' => __('Are you sure you want to set status of this donation to {status}?', 'give'), |
|
344 | + 'multiple' => __('Are you sure you want to set status of {payment_count} donations to {status}?', 'give'), |
|
345 | 345 | ), |
346 | 346 | ), |
347 | 347 | 'metabox_fields' => array( |
348 | 348 | 'media' => array( |
349 | - 'button_title' => __( 'Choose Image', 'give' ), |
|
349 | + 'button_title' => __('Choose Image', 'give'), |
|
350 | 350 | ), |
351 | 351 | 'file' => array( |
352 | - 'button_title' => __( 'Choose File', 'give' ), |
|
352 | + 'button_title' => __('Choose File', 'give'), |
|
353 | 353 | ) |
354 | 354 | ), |
355 | 355 | 'chosen' => array( |
356 | - 'no_results_msg' => __( 'No results match {search_term}', 'give' ), |
|
357 | - 'ajax_search_msg' => __( 'Searching results for match {search_term}', 'give' ), |
|
356 | + 'no_results_msg' => __('No results match {search_term}', 'give'), |
|
357 | + 'ajax_search_msg' => __('Searching results for match {search_term}', 'give'), |
|
358 | 358 | ), |
359 | - ) ); |
|
359 | + )); |
|
360 | 360 | |
361 | - if ( function_exists( 'wp_enqueue_media' ) && version_compare( get_bloginfo( 'version' ), '3.5', '>=' ) ) { |
|
361 | + if (function_exists('wp_enqueue_media') && version_compare(get_bloginfo('version'), '3.5', '>=')) { |
|
362 | 362 | // call for new media manager. |
363 | 363 | wp_enqueue_media(); |
364 | 364 | } |
365 | 365 | |
366 | 366 | } |
367 | 367 | |
368 | -add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 ); |
|
368 | +add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100); |
|
369 | 369 | |
370 | 370 | /** |
371 | 371 | * Admin Give Icon |
@@ -380,13 +380,13 @@ discard block |
||
380 | 380 | ?> |
381 | 381 | <style type="text/css" media="screen"> |
382 | 382 | |
383 | - <?php if ( version_compare( get_bloginfo( 'version' ), '3.8-RC', '>=' ) || version_compare( get_bloginfo( 'version' ), '3.8', '>=' ) ) { ?> |
|
383 | + <?php if (version_compare(get_bloginfo('version'), '3.8-RC', '>=') || version_compare(get_bloginfo('version'), '3.8', '>=')) { ?> |
|
384 | 384 | @font-face { |
385 | 385 | font-family: 'give-icomoon'; |
386 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?ngjl88'; ?>'); |
|
387 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
388 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
389 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
386 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?ngjl88'; ?>'); |
|
387 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
388 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
389 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
390 | 390 | font-weight: normal; |
391 | 391 | font-style: normal; |
392 | 392 | } |
@@ -405,4 +405,4 @@ discard block |
||
405 | 405 | <?php |
406 | 406 | } |
407 | 407 | |
408 | -add_action( 'admin_head', 'give_admin_icon' ); |
|
408 | +add_action('admin_head', 'give_admin_icon'); |
@@ -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 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @since 1.0 |
32 | 32 | */ |
33 | - do_action( 'give_pre_process_donation' ); |
|
33 | + do_action('give_pre_process_donation'); |
|
34 | 34 | |
35 | 35 | // Validate the form $_POST data |
36 | 36 | $valid_data = give_donation_form_validate_fields(); |
@@ -45,26 +45,26 @@ discard block |
||
45 | 45 | * @param bool|array $valid_data Validate fields. |
46 | 46 | * @param array $_POST Array of variables passed via the HTTP POST. |
47 | 47 | */ |
48 | - do_action( 'give_checkout_error_checks', $valid_data, $_POST ); |
|
48 | + do_action('give_checkout_error_checks', $valid_data, $_POST); |
|
49 | 49 | |
50 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
50 | + $is_ajax = isset($_POST['give_ajax']); |
|
51 | 51 | |
52 | 52 | // Process the login form |
53 | - if ( isset( $_POST['give_login_submit'] ) ) { |
|
53 | + if (isset($_POST['give_login_submit'])) { |
|
54 | 54 | give_process_form_login(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | // Validate the user |
58 | - $user = give_get_donation_form_user( $valid_data ); |
|
58 | + $user = give_get_donation_form_user($valid_data); |
|
59 | 59 | |
60 | - if ( false === $valid_data || give_get_errors() || ! $user ) { |
|
61 | - if ( $is_ajax ) { |
|
60 | + if (false === $valid_data || give_get_errors() || ! $user) { |
|
61 | + if ($is_ajax) { |
|
62 | 62 | /** |
63 | 63 | * Fires when AJAX sends back errors from the donation form. |
64 | 64 | * |
65 | 65 | * @since 1.0 |
66 | 66 | */ |
67 | - do_action( 'give_ajax_donation_errors' ); |
|
67 | + do_action('give_ajax_donation_errors'); |
|
68 | 68 | give_die(); |
69 | 69 | } else { |
70 | 70 | return false; |
@@ -72,17 +72,17 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | // If AJAX send back success to proceed with form submission |
75 | - if ( $is_ajax ) { |
|
75 | + if ($is_ajax) { |
|
76 | 76 | echo 'success'; |
77 | 77 | give_die(); |
78 | 78 | } |
79 | 79 | |
80 | 80 | // After AJAX: Setup session if not using php_sessions |
81 | - if ( ! Give()->session->use_php_sessions() ) { |
|
81 | + if ( ! Give()->session->use_php_sessions()) { |
|
82 | 82 | // Double-check that set_cookie is publicly accessible; |
83 | 83 | // we're using a slightly modified class-wp-sessions.php |
84 | - $session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' ); |
|
85 | - if ( $session_reflection->isPublic() ) { |
|
84 | + $session_reflection = new ReflectionMethod('WP_Session', 'set_cookie'); |
|
85 | + if ($session_reflection->isPublic()) { |
|
86 | 86 | // Manually set the cookie. |
87 | 87 | Give()->session->init()->set_cookie(); |
88 | 88 | } |
@@ -97,18 +97,18 @@ discard block |
||
97 | 97 | 'address' => $user['address'], |
98 | 98 | ); |
99 | 99 | |
100 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
100 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
101 | 101 | |
102 | - $price = isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00'; |
|
103 | - $purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); |
|
102 | + $price = isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00'; |
|
103 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
104 | 104 | |
105 | 105 | // Setup donation information |
106 | 106 | $donation_data = array( |
107 | 107 | 'price' => $price, |
108 | 108 | 'purchase_key' => $purchase_key, |
109 | 109 | 'user_email' => $user['user_email'], |
110 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
111 | - 'user_info' => stripslashes_deep( $user_info ), |
|
110 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
111 | + 'user_info' => stripslashes_deep($user_info), |
|
112 | 112 | 'post_data' => $_POST, |
113 | 113 | 'gateway' => $valid_data['gateway'], |
114 | 114 | 'card_info' => $valid_data['cc_info'], |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | * @param array $user_info Array containing basic user information. |
129 | 129 | * @param bool|array $valid_data Validate fields. |
130 | 130 | */ |
131 | - do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
131 | + do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
132 | 132 | |
133 | 133 | // Sanity check for price |
134 | - if ( ! $donation_data['price'] ) { |
|
134 | + if ( ! $donation_data['price']) { |
|
135 | 135 | // Revert to manual |
136 | 136 | $donation_data['gateway'] = 'manual'; |
137 | 137 | $_POST['give-gateway'] = 'manual'; |
@@ -142,27 +142,27 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @since 1.7 |
144 | 144 | */ |
145 | - $donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data ); |
|
145 | + $donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data); |
|
146 | 146 | |
147 | 147 | // Setup the data we're storing in the donation session |
148 | 148 | $session_data = $donation_data; |
149 | 149 | |
150 | 150 | // Make sure credit card numbers are never stored in sessions |
151 | - unset( $session_data['card_info']['card_number'] ); |
|
152 | - unset( $session_data['post_data']['card_number'] ); |
|
151 | + unset($session_data['card_info']['card_number']); |
|
152 | + unset($session_data['post_data']['card_number']); |
|
153 | 153 | |
154 | 154 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. |
155 | - give_set_purchase_session( $session_data ); |
|
155 | + give_set_purchase_session($session_data); |
|
156 | 156 | |
157 | 157 | // Send info to the gateway for payment processing |
158 | - give_send_to_gateway( $donation_data['gateway'], $donation_data ); |
|
158 | + give_send_to_gateway($donation_data['gateway'], $donation_data); |
|
159 | 159 | give_die(); |
160 | 160 | |
161 | 161 | } |
162 | 162 | |
163 | -add_action( 'give_purchase', 'give_process_donation_form' ); |
|
164 | -add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' ); |
|
165 | -add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' ); |
|
163 | +add_action('give_purchase', 'give_process_donation_form'); |
|
164 | +add_action('wp_ajax_give_process_donation', 'give_process_donation_form'); |
|
165 | +add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form'); |
|
166 | 166 | |
167 | 167 | |
168 | 168 | /** |
@@ -175,29 +175,29 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return void |
177 | 177 | */ |
178 | -function give_check_logged_in_user_for_existing_email( $valid_data, $post ) { |
|
178 | +function give_check_logged_in_user_for_existing_email($valid_data, $post) { |
|
179 | 179 | |
180 | 180 | // Verify that the email address belongs to this customer. |
181 | - if ( is_user_logged_in() ) { |
|
181 | + if (is_user_logged_in()) { |
|
182 | 182 | |
183 | - $submitted_email = $valid_data['logged_in_user']['user_email']; |
|
184 | - $customer = new Give_Donor( get_current_user_id(), true ); |
|
183 | + $submitted_email = $valid_data['logged_in_user']['user_email']; |
|
184 | + $customer = new Give_Donor(get_current_user_id(), true); |
|
185 | 185 | |
186 | 186 | // If this email address is not registered with this customer, see if it belongs to any other customer |
187 | 187 | if ( |
188 | 188 | $submitted_email !== $customer->email |
189 | - && ( is_array( $customer->emails ) && ! in_array( $submitted_email, $customer->emails ) ) |
|
189 | + && (is_array($customer->emails) && ! in_array($submitted_email, $customer->emails)) |
|
190 | 190 | ) { |
191 | - $found_customer = new Give_Donor( $submitted_email ); |
|
191 | + $found_customer = new Give_Donor($submitted_email); |
|
192 | 192 | |
193 | - if ( $found_customer->id > 0 ) { |
|
194 | - give_set_error( 'give-customer-email-exists', sprintf( __( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.' ,'give' ), $customer->email, $submitted_email ) ); |
|
193 | + if ($found_customer->id > 0) { |
|
194 | + give_set_error('give-customer-email-exists', sprintf(__('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give'), $customer->email, $submitted_email)); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | -add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2 ); |
|
200 | +add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2); |
|
201 | 201 | |
202 | 202 | /** |
203 | 203 | * Process the checkout login form |
@@ -207,49 +207,49 @@ discard block |
||
207 | 207 | * @return void |
208 | 208 | */ |
209 | 209 | function give_process_form_login() { |
210 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
210 | + $is_ajax = isset($_POST['give_ajax']); |
|
211 | 211 | |
212 | 212 | $user_data = give_donation_form_validate_user_login(); |
213 | 213 | |
214 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
215 | - if ( $is_ajax ) { |
|
214 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
215 | + if ($is_ajax) { |
|
216 | 216 | /** |
217 | 217 | * Fires when AJAX sends back errors from the donation form. |
218 | 218 | * |
219 | 219 | * @since 1.0 |
220 | 220 | */ |
221 | 221 | ob_start(); |
222 | - do_action( 'give_ajax_donation_errors' ); |
|
222 | + do_action('give_ajax_donation_errors'); |
|
223 | 223 | $message = ob_get_contents(); |
224 | 224 | ob_end_clean(); |
225 | - wp_send_json_error( $message ); |
|
225 | + wp_send_json_error($message); |
|
226 | 226 | } else { |
227 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
227 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
228 | 228 | exit; |
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
232 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
233 | 233 | |
234 | - if ( $is_ajax ) { |
|
234 | + if ($is_ajax) { |
|
235 | 235 | $message = Give()->notices->print_frontend_notice( |
236 | 236 | sprintf( |
237 | 237 | /* translators: %s: user first name */ |
238 | - esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ), |
|
239 | - ( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login'] |
|
238 | + esc_html__('Welcome %s! You have successfully logged into your account.', 'give'), |
|
239 | + ( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login'] |
|
240 | 240 | ), |
241 | 241 | false, |
242 | 242 | 'success' |
243 | 243 | ); |
244 | 244 | |
245 | - wp_send_json_success( $message ); |
|
245 | + wp_send_json_success($message); |
|
246 | 246 | } else { |
247 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
247 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
251 | -add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' ); |
|
252 | -add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' ); |
|
251 | +add_action('wp_ajax_give_process_donation_login', 'give_process_form_login'); |
|
252 | +add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login'); |
|
253 | 253 | |
254 | 254 | /** |
255 | 255 | * Donation Form Validate Fields. |
@@ -261,55 +261,55 @@ discard block |
||
261 | 261 | function give_donation_form_validate_fields() { |
262 | 262 | |
263 | 263 | // Check if there is $_POST |
264 | - if ( empty( $_POST ) ) { |
|
264 | + if (empty($_POST)) { |
|
265 | 265 | return false; |
266 | 266 | } |
267 | 267 | |
268 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
268 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
269 | 269 | |
270 | 270 | // Start an array to collect valid data |
271 | 271 | $valid_data = array( |
272 | 272 | 'gateway' => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here) |
273 | - 'need_new_user' => false, // New user flag |
|
274 | - 'need_user_login' => false, // Login user flag |
|
275 | - 'logged_user_data' => array(), // Logged user collected data |
|
276 | - 'new_user_data' => array(), // New user collected data |
|
277 | - 'login_user_data' => array(), // Login user collected data |
|
278 | - 'guest_user_data' => array(), // Guest user collected data |
|
279 | - 'cc_info' => give_donation_form_validate_cc(),// Credit card info |
|
273 | + 'need_new_user' => false, // New user flag |
|
274 | + 'need_user_login' => false, // Login user flag |
|
275 | + 'logged_user_data' => array(), // Logged user collected data |
|
276 | + 'new_user_data' => array(), // New user collected data |
|
277 | + 'login_user_data' => array(), // Login user collected data |
|
278 | + 'guest_user_data' => array(), // Guest user collected data |
|
279 | + 'cc_info' => give_donation_form_validate_cc(), // Credit card info |
|
280 | 280 | ); |
281 | 281 | |
282 | 282 | // Validate Honeypot First |
283 | - if ( ! empty( $_POST['give-honeypot'] ) ) { |
|
284 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
283 | + if ( ! empty($_POST['give-honeypot'])) { |
|
284 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | // Validate agree to terms |
288 | - if ( give_is_terms_enabled( $form_id ) ) { |
|
288 | + if (give_is_terms_enabled($form_id)) { |
|
289 | 289 | give_donation_form_validate_agree_to_terms(); |
290 | 290 | } |
291 | 291 | |
292 | 292 | // Stop processing donor registration, if donor registration is optional and donor can do guest checkout. |
293 | 293 | // If registration form username field is empty that means donor do not want to registration instead want guest checkout. |
294 | 294 | if ( |
295 | - ! give_logged_in_only( $form_id ) |
|
296 | - && isset( $_POST['give-purchase-var'] ) |
|
295 | + ! give_logged_in_only($form_id) |
|
296 | + && isset($_POST['give-purchase-var']) |
|
297 | 297 | && $_POST['give-purchase-var'] == 'needs-to-register' |
298 | - && empty( $_POST['give_user_login'] ) |
|
298 | + && empty($_POST['give_user_login']) |
|
299 | 299 | ) { |
300 | - unset( $_POST['give-purchase-var'] ); |
|
300 | + unset($_POST['give-purchase-var']); |
|
301 | 301 | } |
302 | 302 | |
303 | - if ( is_user_logged_in() ) { |
|
303 | + if (is_user_logged_in()) { |
|
304 | 304 | // Collect logged in user data. |
305 | 305 | $valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user(); |
306 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
306 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
307 | 307 | // Set new user registration as required. |
308 | 308 | $valid_data['need_new_user'] = true; |
309 | 309 | // Validate new user data. |
310 | 310 | $valid_data['new_user_data'] = give_donation_form_validate_new_user(); |
311 | 311 | // Check if login validation is needed. |
312 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
312 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
313 | 313 | // Set user login as required. |
314 | 314 | $valid_data['need_user_login'] = true; |
315 | 315 | // Validate users login info. |
@@ -334,41 +334,41 @@ discard block |
||
334 | 334 | */ |
335 | 335 | function give_donation_form_validate_gateway() { |
336 | 336 | |
337 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
338 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0; |
|
339 | - $gateway = give_get_default_gateway( $form_id ); |
|
337 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
338 | + $amount = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0; |
|
339 | + $gateway = give_get_default_gateway($form_id); |
|
340 | 340 | |
341 | 341 | // Check if a gateway value is present. |
342 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
342 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
343 | 343 | |
344 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
344 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
345 | 345 | |
346 | 346 | // Is amount being donated in LIVE mode 0.00? If so, error: |
347 | - if ( $amount == 0 && ! give_is_test_mode() ) { |
|
347 | + if ($amount == 0 && ! give_is_test_mode()) { |
|
348 | 348 | |
349 | - give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) ); |
|
349 | + give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give')); |
|
350 | 350 | |
351 | 351 | } // End if(). |
352 | - elseif ( ! give_verify_minimum_price() ) { |
|
352 | + elseif ( ! give_verify_minimum_price()) { |
|
353 | 353 | // translators: %s: minimum donation amount. |
354 | 354 | give_set_error( |
355 | 355 | 'invalid_donation_minimum', |
356 | 356 | sprintf( |
357 | 357 | /* translators: %s: minimum donation amount */ |
358 | - __( 'This form has a minimum donation amount of %s.', 'give' ), |
|
359 | - give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) ) |
|
358 | + __('This form has a minimum donation amount of %s.', 'give'), |
|
359 | + give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id))) |
|
360 | 360 | ) |
361 | 361 | ); |
362 | 362 | |
363 | 363 | } //Is this test mode zero donation? Let it through but set to manual gateway. |
364 | - elseif ( $amount == 0 && give_is_test_mode() ) { |
|
364 | + elseif ($amount == 0 && give_is_test_mode()) { |
|
365 | 365 | |
366 | 366 | $gateway = 'manual'; |
367 | 367 | |
368 | 368 | } //Check if this gateway is active. |
369 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
369 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
370 | 370 | |
371 | - give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
371 | + give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give')); |
|
372 | 372 | |
373 | 373 | } |
374 | 374 | } |
@@ -386,21 +386,21 @@ discard block |
||
386 | 386 | */ |
387 | 387 | function give_verify_minimum_price() { |
388 | 388 | |
389 | - $amount = give_sanitize_amount( $_REQUEST['give-amount'] ); |
|
390 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
391 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : null; |
|
392 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
389 | + $amount = give_sanitize_amount($_REQUEST['give-amount']); |
|
390 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
391 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : null; |
|
392 | + $variable_prices = give_has_variable_prices($form_id); |
|
393 | 393 | |
394 | - if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ) ) ) { |
|
394 | + if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id))) { |
|
395 | 395 | |
396 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
396 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
397 | 397 | |
398 | - if ( $price_level_amount == $amount ) { |
|
398 | + if ($price_level_amount == $amount) { |
|
399 | 399 | return true; |
400 | 400 | } |
401 | 401 | } |
402 | 402 | |
403 | - if ( give_get_form_minimum_price( $form_id ) > $amount ) { |
|
403 | + if (give_get_form_minimum_price($form_id) > $amount) { |
|
404 | 404 | return false; |
405 | 405 | } |
406 | 406 | |
@@ -416,9 +416,9 @@ discard block |
||
416 | 416 | */ |
417 | 417 | function give_donation_form_validate_agree_to_terms() { |
418 | 418 | // Validate agree to terms. |
419 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
419 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
420 | 420 | // User did not agree. |
421 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) ); |
|
421 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give'))); |
|
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
@@ -432,43 +432,43 @@ discard block |
||
432 | 432 | * |
433 | 433 | * @return array |
434 | 434 | */ |
435 | -function give_get_required_fields( $form_id ) { |
|
435 | +function give_get_required_fields($form_id) { |
|
436 | 436 | |
437 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
437 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
438 | 438 | |
439 | 439 | $required_fields = array( |
440 | 440 | 'give_email' => array( |
441 | 441 | 'error_id' => 'invalid_email', |
442 | - 'error_message' => __( 'Please enter a valid email address.', 'give' ), |
|
442 | + 'error_message' => __('Please enter a valid email address.', 'give'), |
|
443 | 443 | ), |
444 | 444 | 'give_first' => array( |
445 | 445 | 'error_id' => 'invalid_first_name', |
446 | - 'error_message' => __( 'Please enter your first name.', 'give' ), |
|
446 | + 'error_message' => __('Please enter your first name.', 'give'), |
|
447 | 447 | ), |
448 | 448 | ); |
449 | 449 | |
450 | - $require_address = give_require_billing_address( $payment_mode ); |
|
450 | + $require_address = give_require_billing_address($payment_mode); |
|
451 | 451 | |
452 | - if ( $require_address ) { |
|
453 | - $required_fields['card_address'] = array( |
|
452 | + if ($require_address) { |
|
453 | + $required_fields['card_address'] = array( |
|
454 | 454 | 'error_id' => 'invalid_card_address', |
455 | - 'error_message' => __( 'Please enter your primary billing address.', 'give' ), |
|
455 | + 'error_message' => __('Please enter your primary billing address.', 'give'), |
|
456 | 456 | ); |
457 | - $required_fields['card_zip'] = array( |
|
457 | + $required_fields['card_zip'] = array( |
|
458 | 458 | 'error_id' => 'invalid_zip_code', |
459 | - 'error_message' => __( 'Please enter your zip / postal code.', 'give' ), |
|
459 | + 'error_message' => __('Please enter your zip / postal code.', 'give'), |
|
460 | 460 | ); |
461 | - $required_fields['card_city'] = array( |
|
461 | + $required_fields['card_city'] = array( |
|
462 | 462 | 'error_id' => 'invalid_city', |
463 | - 'error_message' => __( 'Please enter your billing city.', 'give' ), |
|
463 | + 'error_message' => __('Please enter your billing city.', 'give'), |
|
464 | 464 | ); |
465 | 465 | $required_fields['billing_country'] = array( |
466 | 466 | 'error_id' => 'invalid_country', |
467 | - 'error_message' => __( 'Please select your billing country.', 'give' ), |
|
467 | + 'error_message' => __('Please select your billing country.', 'give'), |
|
468 | 468 | ); |
469 | - $required_fields['card_state'] = array( |
|
469 | + $required_fields['card_state'] = array( |
|
470 | 470 | 'error_id' => 'invalid_state', |
471 | - 'error_message' => __( 'Please enter billing state / province.', 'give' ), |
|
471 | + 'error_message' => __('Please enter billing state / province.', 'give'), |
|
472 | 472 | ); |
473 | 473 | } |
474 | 474 | |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * |
478 | 478 | * @since 1.7 |
479 | 479 | */ |
480 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); |
|
480 | + $required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); |
|
481 | 481 | |
482 | 482 | return $required_fields; |
483 | 483 | |
@@ -492,16 +492,16 @@ discard block |
||
492 | 492 | * |
493 | 493 | * @return bool |
494 | 494 | */ |
495 | -function give_require_billing_address( $payment_mode ) { |
|
495 | +function give_require_billing_address($payment_mode) { |
|
496 | 496 | |
497 | 497 | $return = false; |
498 | 498 | |
499 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
499 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
500 | 500 | $return = true; |
501 | 501 | } |
502 | 502 | |
503 | 503 | // Let payment gateways and other extensions determine if address fields should be required. |
504 | - return apply_filters( 'give_require_billing_address', $return ); |
|
504 | + return apply_filters('give_require_billing_address', $return); |
|
505 | 505 | |
506 | 506 | } |
507 | 507 | |
@@ -515,42 +515,42 @@ discard block |
||
515 | 515 | function give_donation_form_validate_logged_in_user() { |
516 | 516 | global $user_ID; |
517 | 517 | |
518 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
518 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
519 | 519 | |
520 | 520 | // Start empty array to collect valid user data. |
521 | 521 | $valid_user_data = array( |
522 | 522 | // Assume there will be errors. |
523 | - 'user_id' => - 1, |
|
523 | + 'user_id' => -1, |
|
524 | 524 | ); |
525 | 525 | |
526 | 526 | // Verify there is a user_ID. |
527 | - if ( $user_ID > 0 ) { |
|
527 | + if ($user_ID > 0) { |
|
528 | 528 | // Get the logged in user data. |
529 | - $user_data = get_userdata( $user_ID ); |
|
529 | + $user_data = get_userdata($user_ID); |
|
530 | 530 | |
531 | 531 | // Loop through required fields and show error messages. |
532 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
533 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
534 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
532 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
533 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
534 | + give_set_error($value['error_id'], $value['error_message']); |
|
535 | 535 | } |
536 | 536 | } |
537 | 537 | |
538 | 538 | // Verify data. |
539 | - if ( $user_data ) { |
|
539 | + if ($user_data) { |
|
540 | 540 | // Collected logged in user data. |
541 | 541 | $valid_user_data = array( |
542 | 542 | 'user_id' => $user_ID, |
543 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
544 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
545 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
543 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
544 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
545 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
546 | 546 | ); |
547 | 547 | |
548 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
549 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
548 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
549 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
550 | 550 | } |
551 | 551 | } else { |
552 | 552 | // Set invalid user error. |
553 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
553 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
554 | 554 | } |
555 | 555 | } |
556 | 556 | |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | // Default user data. |
570 | 570 | $default_user_data = array( |
571 | 571 | 'give-form-id' => '', |
572 | - 'user_id' => - 1, // Assume there will be errors. |
|
572 | + 'user_id' => -1, // Assume there will be errors. |
|
573 | 573 | 'user_first' => '', |
574 | 574 | 'user_last' => '', |
575 | 575 | 'give_user_login' => false, |
@@ -579,14 +579,14 @@ discard block |
||
579 | 579 | ); |
580 | 580 | |
581 | 581 | // Get user data. |
582 | - $user_data = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data ); |
|
582 | + $user_data = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data); |
|
583 | 583 | $registering_new_user = false; |
584 | - $form_id = absint( $user_data['give-form-id'] ); |
|
584 | + $form_id = absint($user_data['give-form-id']); |
|
585 | 585 | |
586 | 586 | // Start an empty array to collect valid user data. |
587 | 587 | $valid_user_data = array( |
588 | 588 | // Assume there will be errors. |
589 | - 'user_id' => - 1, |
|
589 | + 'user_id' => -1, |
|
590 | 590 | |
591 | 591 | // Get first name. |
592 | 592 | 'user_first' => $user_data['give_first'], |
@@ -596,25 +596,25 @@ discard block |
||
596 | 596 | ); |
597 | 597 | |
598 | 598 | // Loop through required fields and show error messages. |
599 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
600 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
601 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
599 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
600 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
601 | + give_set_error($value['error_id'], $value['error_message']); |
|
602 | 602 | } |
603 | 603 | } |
604 | 604 | |
605 | 605 | // Check if we have an username to register. |
606 | - if ( give_validate_username( $user_data['give_user_login'] ) ) { |
|
606 | + if (give_validate_username($user_data['give_user_login'])) { |
|
607 | 607 | $registering_new_user = true; |
608 | 608 | $valid_user_data['user_login'] = $user_data['give_user_login']; |
609 | 609 | } |
610 | 610 | |
611 | 611 | // Check if we have an email to verify. |
612 | - if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) { |
|
612 | + if (give_validate_user_email($user_data['give_email'], $registering_new_user)) { |
|
613 | 613 | $valid_user_data['user_email'] = $user_data['give_email']; |
614 | 614 | } |
615 | 615 | |
616 | 616 | // Check password. |
617 | - if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) { |
|
617 | + if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) { |
|
618 | 618 | // All is good to go. |
619 | 619 | $valid_user_data['user_pass'] = $user_data['give_user_pass']; |
620 | 620 | } |
@@ -634,36 +634,36 @@ discard block |
||
634 | 634 | // Start an array to collect valid user data. |
635 | 635 | $valid_user_data = array( |
636 | 636 | // Assume there will be errors. |
637 | - 'user_id' => - 1, |
|
637 | + 'user_id' => -1, |
|
638 | 638 | ); |
639 | 639 | |
640 | 640 | // Username. |
641 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
642 | - give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) ); |
|
641 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
642 | + give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give')); |
|
643 | 643 | |
644 | 644 | return $valid_user_data; |
645 | 645 | } |
646 | 646 | |
647 | 647 | // Get the user by login. |
648 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
648 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
649 | 649 | |
650 | 650 | // Check if user exists. |
651 | - if ( $user_data ) { |
|
651 | + if ($user_data) { |
|
652 | 652 | // Get password. |
653 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
653 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
654 | 654 | |
655 | 655 | // Check user_pass. |
656 | - if ( $user_pass ) { |
|
656 | + if ($user_pass) { |
|
657 | 657 | // Check if password is valid. |
658 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
658 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
659 | 659 | // Incorrect password. |
660 | 660 | give_set_error( |
661 | 661 | 'password_incorrect', |
662 | 662 | sprintf( |
663 | 663 | '%1$s <a href="%2$s">%3$s</a>', |
664 | - __( 'The password you entered is incorrect.', 'give' ), |
|
665 | - wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ), |
|
666 | - __( 'Reset Password', 'give' ) |
|
664 | + __('The password you entered is incorrect.', 'give'), |
|
665 | + wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), |
|
666 | + __('Reset Password', 'give') |
|
667 | 667 | ) |
668 | 668 | ); |
669 | 669 | // All is correct. |
@@ -680,11 +680,11 @@ discard block |
||
680 | 680 | } |
681 | 681 | } else { |
682 | 682 | // Empty password. |
683 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
683 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
684 | 684 | } |
685 | 685 | } else { |
686 | 686 | // No username. |
687 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) ); |
|
687 | + give_set_error('username_incorrect', __('The username you entered does not exist.', 'give')); |
|
688 | 688 | }// End if(). |
689 | 689 | |
690 | 690 | return $valid_user_data; |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | */ |
700 | 700 | function give_donation_form_validate_guest_user() { |
701 | 701 | |
702 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
702 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
703 | 703 | |
704 | 704 | // Start an array to collect valid user data. |
705 | 705 | $valid_user_data = array( |
@@ -708,38 +708,38 @@ discard block |
||
708 | 708 | ); |
709 | 709 | |
710 | 710 | // Show error message if user must be logged in. |
711 | - if ( give_logged_in_only( $form_id ) ) { |
|
712 | - give_set_error( 'logged_in_only', __( 'You must be logged in to donate.', 'give' ) ); |
|
711 | + if (give_logged_in_only($form_id)) { |
|
712 | + give_set_error('logged_in_only', __('You must be logged in to donate.', 'give')); |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | // Get the guest email. |
716 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
716 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
717 | 717 | |
718 | 718 | // Check email. |
719 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
719 | + if ($guest_email && strlen($guest_email) > 0) { |
|
720 | 720 | // Validate email. |
721 | - if ( ! is_email( $guest_email ) ) { |
|
721 | + if ( ! is_email($guest_email)) { |
|
722 | 722 | // Invalid email. |
723 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
723 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
724 | 724 | } else { |
725 | 725 | // All is good to go. |
726 | 726 | $valid_user_data['user_email'] = $guest_email; |
727 | 727 | |
728 | 728 | // Get user_id from donor if exist. |
729 | - $donor = new Give_Donor( $guest_email ); |
|
730 | - if ( $donor->id && $donor->user_id ) { |
|
729 | + $donor = new Give_Donor($guest_email); |
|
730 | + if ($donor->id && $donor->user_id) { |
|
731 | 731 | $valid_user_data['user_id'] = $donor->user_id; |
732 | 732 | } |
733 | 733 | } |
734 | 734 | } else { |
735 | 735 | // No email. |
736 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); |
|
736 | + give_set_error('email_empty', __('Enter an email.', 'give')); |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | // Loop through required fields and show error messages. |
740 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
741 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
742 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
740 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
741 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
742 | + give_set_error($value['error_id'], $value['error_message']); |
|
743 | 743 | } |
744 | 744 | } |
745 | 745 | |
@@ -755,36 +755,36 @@ discard block |
||
755 | 755 | * @since 1.0 |
756 | 756 | * @return integer |
757 | 757 | */ |
758 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
758 | +function give_register_and_login_new_user($user_data = array()) { |
|
759 | 759 | // Verify the array. |
760 | - if ( empty( $user_data ) ) { |
|
761 | - return - 1; |
|
760 | + if (empty($user_data)) { |
|
761 | + return -1; |
|
762 | 762 | } |
763 | 763 | |
764 | - if ( give_get_errors() ) { |
|
765 | - return - 1; |
|
764 | + if (give_get_errors()) { |
|
765 | + return -1; |
|
766 | 766 | } |
767 | 767 | |
768 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
769 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
770 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
771 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
772 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
773 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
774 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
775 | - 'role' => get_option( 'default_role' ), |
|
776 | - ), $user_data ); |
|
768 | + $user_args = apply_filters('give_insert_user_args', array( |
|
769 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
770 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
771 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
772 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
773 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
774 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
775 | + 'role' => get_option('default_role'), |
|
776 | + ), $user_data); |
|
777 | 777 | |
778 | 778 | // Insert new user. |
779 | - $user_id = wp_insert_user( $user_args ); |
|
779 | + $user_id = wp_insert_user($user_args); |
|
780 | 780 | |
781 | 781 | // Validate inserted user. |
782 | - if ( is_wp_error( $user_id ) ) { |
|
783 | - return - 1; |
|
782 | + if (is_wp_error($user_id)) { |
|
783 | + return -1; |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | // Allow themes and plugins to filter the user data. |
787 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
787 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
788 | 788 | |
789 | 789 | /** |
790 | 790 | * Fires after inserting user. |
@@ -794,10 +794,10 @@ discard block |
||
794 | 794 | * @param int $user_id User id. |
795 | 795 | * @param array $user_data Array containing user data. |
796 | 796 | */ |
797 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
797 | + do_action('give_insert_user', $user_id, $user_data); |
|
798 | 798 | |
799 | 799 | // Login new user. |
800 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
800 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
801 | 801 | |
802 | 802 | // Return user id. |
803 | 803 | return $user_id; |
@@ -812,27 +812,27 @@ discard block |
||
812 | 812 | * @since 1.0 |
813 | 813 | * @return array|bool |
814 | 814 | */ |
815 | -function give_get_donation_form_user( $valid_data = array() ) { |
|
815 | +function give_get_donation_form_user($valid_data = array()) { |
|
816 | 816 | |
817 | 817 | // Initialize user. |
818 | 818 | $user = false; |
819 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
819 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
820 | 820 | |
821 | - if ( $is_ajax ) { |
|
821 | + if ($is_ajax) { |
|
822 | 822 | // Do not create or login the user during the ajax submission (check for errors only). |
823 | 823 | return true; |
824 | - } elseif ( is_user_logged_in() ) { |
|
824 | + } elseif (is_user_logged_in()) { |
|
825 | 825 | // Set the valid user as the logged in collected data. |
826 | 826 | $user = $valid_data['logged_in_user']; |
827 | - } elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
827 | + } elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
828 | 828 | // New user registration. |
829 | - if ( $valid_data['need_new_user'] === true ) { |
|
829 | + if ($valid_data['need_new_user'] === true) { |
|
830 | 830 | // Set user. |
831 | 831 | $user = $valid_data['new_user_data']; |
832 | 832 | // Register and login new user. |
833 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
833 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
834 | 834 | // User login |
835 | - } elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
835 | + } elseif ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
836 | 836 | |
837 | 837 | /** |
838 | 838 | * The login form is now processed in the give_process_donation_login() function. |
@@ -844,48 +844,48 @@ discard block |
||
844 | 844 | // Set user. |
845 | 845 | $user = $valid_data['login_user_data']; |
846 | 846 | // Login user. |
847 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
847 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
848 | 848 | } |
849 | 849 | } |
850 | 850 | |
851 | 851 | // Check guest checkout. |
852 | - if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { |
|
852 | + if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { |
|
853 | 853 | // Set user |
854 | 854 | $user = $valid_data['guest_user_data']; |
855 | 855 | } |
856 | 856 | |
857 | 857 | // Verify we have an user. |
858 | - if ( false === $user || empty( $user ) ) { |
|
858 | + if (false === $user || empty($user)) { |
|
859 | 859 | // Return false. |
860 | 860 | return false; |
861 | 861 | } |
862 | 862 | |
863 | 863 | // Get user first name. |
864 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
865 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
864 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
865 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | // Get user last name. |
869 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
870 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : ''; |
|
869 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
870 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : ''; |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | // Get the user's billing address details. |
874 | 874 | $user['address'] = array(); |
875 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false; |
|
876 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false; |
|
877 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false; |
|
878 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false; |
|
879 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false; |
|
880 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false; |
|
881 | - |
|
882 | - if ( empty( $user['address']['country'] ) ) { |
|
875 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false; |
|
876 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false; |
|
877 | + $user['address']['city'] = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false; |
|
878 | + $user['address']['state'] = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false; |
|
879 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false; |
|
880 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false; |
|
881 | + |
|
882 | + if (empty($user['address']['country'])) { |
|
883 | 883 | $user['address'] = false; |
884 | 884 | } // End if(). |
885 | 885 | |
886 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
886 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
887 | 887 | // Store the address in the user's meta so the donation form can be pre-populated with it on return donation. |
888 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
888 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | // Return valid user. |
@@ -904,16 +904,16 @@ discard block |
||
904 | 904 | $card_data = give_get_donation_cc_info(); |
905 | 905 | |
906 | 906 | // Validate the card zip. |
907 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
908 | - if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
909 | - give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
907 | + if ( ! empty($card_data['card_zip'])) { |
|
908 | + if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
909 | + give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
910 | 910 | } |
911 | 911 | } |
912 | 912 | |
913 | 913 | // Ensure no spaces. |
914 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
915 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs |
|
916 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
914 | + if ( ! empty($card_data['card_number'])) { |
|
915 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs |
|
916 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
917 | 917 | } |
918 | 918 | |
919 | 919 | // This should validate card numbers at some point too. |
@@ -930,17 +930,17 @@ discard block |
||
930 | 930 | function give_get_donation_cc_info() { |
931 | 931 | |
932 | 932 | $cc_info = array(); |
933 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
934 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
935 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
936 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
937 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
938 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
939 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
940 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
941 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
942 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
943 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
933 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
934 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
935 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
936 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
937 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
938 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
939 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
940 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
941 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
942 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
943 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
944 | 944 | |
945 | 945 | // Return cc info. |
946 | 946 | return $cc_info; |
@@ -956,14 +956,14 @@ discard block |
||
956 | 956 | * |
957 | 957 | * @return bool|mixed |
958 | 958 | */ |
959 | -function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
959 | +function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
960 | 960 | $ret = false; |
961 | 961 | |
962 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
962 | + if (empty($zip) || empty($country_code)) { |
|
963 | 963 | return $ret; |
964 | 964 | } |
965 | 965 | |
966 | - $country_code = strtoupper( $country_code ); |
|
966 | + $country_code = strtoupper($country_code); |
|
967 | 967 | |
968 | 968 | $zip_regex = array( |
969 | 969 | 'AD' => 'AD\d{3}', |
@@ -1123,11 +1123,11 @@ discard block |
||
1123 | 1123 | 'ZM' => '\d{5}', |
1124 | 1124 | ); |
1125 | 1125 | |
1126 | - if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { |
|
1126 | + if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { |
|
1127 | 1127 | $ret = true; |
1128 | 1128 | } |
1129 | 1129 | |
1130 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
1130 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
1131 | 1131 | } |
1132 | 1132 | |
1133 | 1133 | |
@@ -1141,36 +1141,36 @@ discard block |
||
1141 | 1141 | * |
1142 | 1142 | * @return bool |
1143 | 1143 | */ |
1144 | -function give_validate_multi_donation_form_level( $valid_data, $data ) { |
|
1144 | +function give_validate_multi_donation_form_level($valid_data, $data) { |
|
1145 | 1145 | /* @var Give_Donate_Form $form */ |
1146 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
1146 | + $form = new Give_Donate_Form($data['give-form-id']); |
|
1147 | 1147 | |
1148 | 1148 | $donation_level_matched = false; |
1149 | 1149 | |
1150 | - if ( $form->is_multi_type_donation_form() ) { |
|
1150 | + if ($form->is_multi_type_donation_form()) { |
|
1151 | 1151 | |
1152 | 1152 | // Bailout. |
1153 | - if ( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1153 | + if ( ! ($variable_prices = $form->get_prices())) { |
|
1154 | 1154 | return false; |
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | // Sanitize donation amount. |
1158 | - $data['give-amount'] = give_sanitize_amount( $data['give-amount'] ); |
|
1158 | + $data['give-amount'] = give_sanitize_amount($data['give-amount']); |
|
1159 | 1159 | |
1160 | 1160 | // Get number of decimals. |
1161 | 1161 | $default_decimals = give_get_price_decimals(); |
1162 | 1162 | |
1163 | - if ( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ) { |
|
1163 | + if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) { |
|
1164 | 1164 | return true; |
1165 | 1165 | } |
1166 | 1166 | |
1167 | 1167 | // Find correct donation level from all donation levels. |
1168 | - foreach ( $variable_prices as $variable_price ) { |
|
1168 | + foreach ($variable_prices as $variable_price) { |
|
1169 | 1169 | // Sanitize level amount. |
1170 | - $variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals ); |
|
1170 | + $variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals); |
|
1171 | 1171 | |
1172 | 1172 | // Set first match donation level ID. |
1173 | - if ( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1173 | + if ($data['give-amount'] === $variable_price['_give_amount']) { |
|
1174 | 1174 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
1175 | 1175 | $donation_level_matched = true; |
1176 | 1176 | break; |
@@ -1181,19 +1181,19 @@ discard block |
||
1181 | 1181 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
1182 | 1182 | if ( |
1183 | 1183 | ! $donation_level_matched |
1184 | - && ( give_is_setting_enabled( give_get_meta( $data['give-form-id'], '_give_custom_amount', true ) ) ) |
|
1184 | + && (give_is_setting_enabled(give_get_meta($data['give-form-id'], '_give_custom_amount', true))) |
|
1185 | 1185 | ) { |
1186 | 1186 | // Sanitize custom minimum amount. |
1187 | - $custom_minimum_amount = give_sanitize_amount( give_get_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals ); |
|
1187 | + $custom_minimum_amount = give_sanitize_amount(give_get_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals); |
|
1188 | 1188 | |
1189 | - if ( $data['give-amount'] >= $custom_minimum_amount ) { |
|
1189 | + if ($data['give-amount'] >= $custom_minimum_amount) { |
|
1190 | 1190 | $_POST['give-price-id'] = 'custom'; |
1191 | 1191 | $donation_level_matched = true; |
1192 | 1192 | } |
1193 | 1193 | } |
1194 | 1194 | }// End if(). |
1195 | 1195 | |
1196 | - return ( $donation_level_matched ? true : false ); |
|
1196 | + return ($donation_level_matched ? true : false); |
|
1197 | 1197 | } |
1198 | 1198 | |
1199 | -add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 ); |
|
1199 | +add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2); |
@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // Exit if accessed directly. |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
16 | 16 | // Load WP_List_Table if not loaded. |
17 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
18 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
17 | +if ( ! class_exists('WP_List_Table')) { |
|
18 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function __construct() { |
46 | 46 | // Set parent defaults. |
47 | - parent::__construct( array( |
|
48 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
49 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
47 | + parent::__construct(array( |
|
48 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
49 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
50 | 50 | 'ajax' => false // Does this table support ajax?. |
51 | - ) ); |
|
51 | + )); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -62,19 +62,19 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return string Column Name. |
64 | 64 | */ |
65 | - public function column_default( $item, $column_name ) { |
|
65 | + public function column_default($item, $column_name) { |
|
66 | 66 | |
67 | - switch ( $column_name ) { |
|
67 | + switch ($column_name) { |
|
68 | 68 | case 'ID' : |
69 | 69 | return $item['ID_label']; |
70 | 70 | case 'payment_id' : |
71 | - return empty( $item['payment_id'] ) ? esc_html__( 'n/a', 'give' ) : sprintf( "<a href=\"%s\" target=\"_blank\">{$item['payment_id']}</a>", get_edit_post_link( $item['payment_id'] ) ); |
|
71 | + return empty($item['payment_id']) ? esc_html__('n/a', 'give') : sprintf("<a href=\"%s\" target=\"_blank\">{$item['payment_id']}</a>", get_edit_post_link($item['payment_id'])); |
|
72 | 72 | case 'gateway' : |
73 | - return empty( $item['gateway'] ) ? esc_html__( 'n/a', 'give' ) : $item['gateway']; |
|
73 | + return empty($item['gateway']) ? esc_html__('n/a', 'give') : $item['gateway']; |
|
74 | 74 | case 'error' : |
75 | - return get_the_title( $item['ID'] ) ? get_the_title( $item['ID'] ) : esc_html__( 'Payment Error', 'give' ); |
|
75 | + return get_the_title($item['ID']) ? get_the_title($item['ID']) : esc_html__('Payment Error', 'give'); |
|
76 | 76 | default: |
77 | - return $item[ $column_name ]; |
|
77 | + return $item[$column_name]; |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -88,27 +88,27 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return void |
90 | 90 | */ |
91 | - public function column_message( $item ) { ?> |
|
92 | - <a href="#TB_inline?width=640&inlineId=log-message-<?php echo $item['ID']; ?>" class="thickbox give-error-log-details-link button button-small" data-tooltip="<?php esc_attr_e( 'View Log Message', 'give' ); ?>"><span class="dashicons dashicons-visibility"></span></a> |
|
91 | + public function column_message($item) { ?> |
|
92 | + <a href="#TB_inline?width=640&inlineId=log-message-<?php echo $item['ID']; ?>" class="thickbox give-error-log-details-link button button-small" data-tooltip="<?php esc_attr_e('View Log Message', 'give'); ?>"><span class="dashicons dashicons-visibility"></span></a> |
|
93 | 93 | <div id="log-message-<?php echo $item['ID']; ?>" style="display:none;"> |
94 | 94 | <?php |
95 | 95 | |
96 | - $log_message = get_post_field( 'post_content', $item['ID'] ); |
|
96 | + $log_message = get_post_field('post_content', $item['ID']); |
|
97 | 97 | |
98 | - $serialized = strpos( $log_message, '{"' ); |
|
98 | + $serialized = strpos($log_message, '{"'); |
|
99 | 99 | |
100 | 100 | // Check to see if the log message contains serialized information |
101 | - if ( $serialized !== false ) { |
|
102 | - $length = strlen( $log_message ) - $serialized; |
|
103 | - $intro = substr( $log_message, 0, - $length ); |
|
104 | - $data = substr( $log_message, $serialized, strlen( $log_message ) - 1 ); |
|
101 | + if ($serialized !== false) { |
|
102 | + $length = strlen($log_message) - $serialized; |
|
103 | + $intro = substr($log_message, 0, - $length); |
|
104 | + $data = substr($log_message, $serialized, strlen($log_message) - 1); |
|
105 | 105 | |
106 | - echo wpautop( $intro ); |
|
107 | - echo wpautop( '<strong>' . esc_html__( 'Log data:', 'give' ) . '</strong>' ); |
|
108 | - echo '<div style="word-wrap: break-word;">' . wpautop( $data ) . '</div>'; |
|
106 | + echo wpautop($intro); |
|
107 | + echo wpautop('<strong>'.esc_html__('Log data:', 'give').'</strong>'); |
|
108 | + echo '<div style="word-wrap: break-word;">'.wpautop($data).'</div>'; |
|
109 | 109 | } else { |
110 | 110 | // No serialized data found |
111 | - echo wpautop( $log_message ); |
|
111 | + echo wpautop($log_message); |
|
112 | 112 | } |
113 | 113 | ?> |
114 | 114 | </div> |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function get_columns() { |
126 | 126 | $columns = array( |
127 | - 'ID' => esc_html__( 'Log ID', 'give' ), |
|
128 | - 'error' => esc_html__( 'Error', 'give' ), |
|
129 | - 'gateway' => esc_html__( 'Gateway', 'give' ), |
|
130 | - 'payment_id' => esc_html__( 'Donation ID', 'give' ), |
|
131 | - 'date' => esc_html__( 'Date', 'give' ), |
|
132 | - 'message' => esc_html__( 'Details', 'give' ) |
|
127 | + 'ID' => esc_html__('Log ID', 'give'), |
|
128 | + 'error' => esc_html__('Error', 'give'), |
|
129 | + 'gateway' => esc_html__('Gateway', 'give'), |
|
130 | + 'payment_id' => esc_html__('Donation ID', 'give'), |
|
131 | + 'date' => esc_html__('Date', 'give'), |
|
132 | + 'message' => esc_html__('Details', 'give') |
|
133 | 133 | ); |
134 | 134 | |
135 | 135 | return $columns; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @return int Current page number |
144 | 144 | */ |
145 | 145 | public function get_paged() { |
146 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
146 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @since 1.0 |
154 | 154 | * @return void |
155 | 155 | */ |
156 | - public function bulk_actions( $which = '' ) { |
|
156 | + public function bulk_actions($which = '') { |
|
157 | 157 | give_log_views(); |
158 | 158 | } |
159 | 159 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | |
172 | 172 | // Prevent the queries from getting cached. |
173 | 173 | // Without this there are occasional memory issues for some installs. |
174 | - wp_suspend_cache_addition( true ); |
|
174 | + wp_suspend_cache_addition(true); |
|
175 | 175 | |
176 | 176 | $logs_data = array(); |
177 | 177 | $paged = $this->get_paged(); |
@@ -181,17 +181,17 @@ discard block |
||
181 | 181 | 'posts_per_page' => $this->per_page, |
182 | 182 | ); |
183 | 183 | |
184 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
184 | + $logs = $give_logs->get_connected_logs($log_query); |
|
185 | 185 | |
186 | - if ( $logs ) { |
|
187 | - foreach ( $logs as $log ) { |
|
186 | + if ($logs) { |
|
187 | + foreach ($logs as $log) { |
|
188 | 188 | |
189 | 189 | $logs_data[] = array( |
190 | 190 | 'ID' => $log->ID, |
191 | - 'ID_label' => '<span class=\'give-item-label give-item-label-gray\'>' . $log->ID . '</span>', |
|
191 | + 'ID_label' => '<span class=\'give-item-label give-item-label-gray\'>'.$log->ID.'</span>', |
|
192 | 192 | 'payment_id' => $log->post_parent, |
193 | 193 | 'error' => 'error', |
194 | - 'gateway' => give_get_payment_gateway( $log->post_parent ), |
|
194 | + 'gateway' => give_get_payment_gateway($log->post_parent), |
|
195 | 195 | 'date' => $log->post_date |
196 | 196 | ); |
197 | 197 | } |
@@ -213,19 +213,19 @@ discard block |
||
213 | 213 | * |
214 | 214 | * @param string $which |
215 | 215 | */ |
216 | - protected function display_tablenav( $which ) { |
|
217 | - if ( 'top' === $which ) { |
|
218 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
216 | + protected function display_tablenav($which) { |
|
217 | + if ('top' === $which) { |
|
218 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
219 | 219 | } |
220 | 220 | ?> |
221 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
221 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
222 | 222 | |
223 | 223 | <div class="alignleft actions bulkactions"> |
224 | - <?php $this->bulk_actions( $which ); ?> |
|
224 | + <?php $this->bulk_actions($which); ?> |
|
225 | 225 | </div> |
226 | 226 | <?php |
227 | - $this->extra_tablenav( $which ); |
|
228 | - $this->pagination( $which ); |
|
227 | + $this->extra_tablenav($which); |
|
228 | + $this->pagination($which); |
|
229 | 229 | ?> |
230 | 230 | |
231 | 231 | <br class="clear"/> |
@@ -252,14 +252,14 @@ discard block |
||
252 | 252 | $columns = $this->get_columns(); |
253 | 253 | $hidden = array(); // No hidden columns |
254 | 254 | $sortable = $this->get_sortable_columns(); |
255 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
255 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
256 | 256 | $this->items = $this->get_logs(); |
257 | - $total_items = $give_logs->get_log_count( 0, 'gateway_error' ); |
|
257 | + $total_items = $give_logs->get_log_count(0, 'gateway_error'); |
|
258 | 258 | |
259 | - $this->set_pagination_args( array( |
|
259 | + $this->set_pagination_args(array( |
|
260 | 260 | 'total_items' => $total_items, |
261 | 261 | 'per_page' => $this->per_page, |
262 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
262 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
263 | 263 | ) |
264 | 264 | ); |
265 | 265 | } |
@@ -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 | |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | * @global $wpdb |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_install( $network_wide = false ) { |
|
29 | +function give_install($network_wide = false) { |
|
30 | 30 | |
31 | 31 | global $wpdb; |
32 | 32 | |
33 | - if ( is_multisite() && $network_wide ) { |
|
33 | + if (is_multisite() && $network_wide) { |
|
34 | 34 | |
35 | - foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
|
35 | + foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { |
|
36 | 36 | |
37 | - switch_to_blog( $blog_id ); |
|
37 | + switch_to_blog($blog_id); |
|
38 | 38 | give_run_install(); |
39 | 39 | restore_current_blog(); |
40 | 40 | |
@@ -62,34 +62,34 @@ discard block |
||
62 | 62 | give_setup_post_types(); |
63 | 63 | |
64 | 64 | // Clear the permalinks. |
65 | - flush_rewrite_rules( false ); |
|
65 | + flush_rewrite_rules(false); |
|
66 | 66 | |
67 | 67 | // Add Upgraded From Option. |
68 | - $current_version = get_option( 'give_version' ); |
|
69 | - if ( $current_version ) { |
|
70 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
68 | + $current_version = get_option('give_version'); |
|
69 | + if ($current_version) { |
|
70 | + update_option('give_version_upgraded_from', $current_version); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | // Setup some default options. |
74 | 74 | $options = array(); |
75 | 75 | |
76 | 76 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency. |
77 | - if ( empty( $current_version ) ) { |
|
78 | - $options = array_merge( $options, give_get_default_settings() ); |
|
77 | + if (empty($current_version)) { |
|
78 | + $options = array_merge($options, give_get_default_settings()); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | // Populate the default values. |
82 | - update_option( 'give_settings', array_merge( $give_options, $options ) ); |
|
82 | + update_option('give_settings', array_merge($give_options, $options)); |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Run plugin upgrades. |
86 | 86 | * |
87 | 87 | * @since 1.8 |
88 | 88 | */ |
89 | - do_action( 'give_upgrades' ); |
|
89 | + do_action('give_upgrades'); |
|
90 | 90 | |
91 | - if ( GIVE_VERSION !== get_option( 'give_version' ) ) { |
|
92 | - update_option( 'give_version', GIVE_VERSION ); |
|
91 | + if (GIVE_VERSION !== get_option('give_version')) { |
|
92 | + update_option('give_version', GIVE_VERSION); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | // Create Give roles. |
@@ -98,18 +98,18 @@ discard block |
||
98 | 98 | $roles->add_caps(); |
99 | 99 | |
100 | 100 | $api = new Give_API(); |
101 | - update_option( 'give_default_api_version', 'v' . $api->get_version() ); |
|
101 | + update_option('give_default_api_version', 'v'.$api->get_version()); |
|
102 | 102 | |
103 | 103 | // Check for PHP Session support, and enable if available. |
104 | 104 | $give_sessions = new Give_Session(); |
105 | 105 | $give_sessions->use_php_sessions(); |
106 | 106 | |
107 | 107 | // Add a temporary option to note that Give pages have been created. |
108 | - Give_Cache::set( '_give_installed', $options, 30, true ); |
|
108 | + Give_Cache::set('_give_installed', $options, 30, true); |
|
109 | 109 | |
110 | - if ( ! $current_version ) { |
|
110 | + if ( ! $current_version) { |
|
111 | 111 | |
112 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
112 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
113 | 113 | |
114 | 114 | // When new upgrade routines are added, mark them as complete on fresh install. |
115 | 115 | $upgrade_routines = array( |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | 'v189_upgrades_levels_post_meta' |
122 | 122 | ); |
123 | 123 | |
124 | - foreach ( $upgrade_routines as $upgrade ) { |
|
125 | - give_set_upgrade_complete( $upgrade ); |
|
124 | + foreach ($upgrade_routines as $upgrade) { |
|
125 | + give_set_upgrade_complete($upgrade); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | 129 | // Bail if activating from network, or bulk. |
130 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
130 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
131 | 131 | return; |
132 | 132 | } |
133 | 133 | |
134 | 134 | // Add the transient to redirect. |
135 | - Give_Cache::set( '_give_activation_redirect', true, 30, true ); |
|
135 | + Give_Cache::set('_give_activation_redirect', true, 30, true); |
|
136 | 136 | |
137 | 137 | // Set 'Donation Form' meta box enabled by default. |
138 | 138 | give_nav_donation_metabox_enabled(); |
@@ -152,11 +152,11 @@ discard block |
||
152 | 152 | * @param int $site_id The Site ID. |
153 | 153 | * @param array $meta Blog Meta. |
154 | 154 | */ |
155 | -function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
155 | +function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
156 | 156 | |
157 | - if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) { |
|
157 | + if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) { |
|
158 | 158 | |
159 | - switch_to_blog( $blog_id ); |
|
159 | + switch_to_blog($blog_id); |
|
160 | 160 | give_install(); |
161 | 161 | restore_current_blog(); |
162 | 162 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | |
165 | 165 | } |
166 | 166 | |
167 | -add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 ); |
|
167 | +add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6); |
|
168 | 168 | |
169 | 169 | |
170 | 170 | /** |
@@ -177,13 +177,13 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @return array The tables to drop. |
179 | 179 | */ |
180 | -function give_wpmu_drop_tables( $tables, $blog_id ) { |
|
180 | +function give_wpmu_drop_tables($tables, $blog_id) { |
|
181 | 181 | |
182 | - switch_to_blog( $blog_id ); |
|
182 | + switch_to_blog($blog_id); |
|
183 | 183 | $donors_db = new Give_DB_Donors(); |
184 | 184 | $donor_meta_db = new Give_DB_Donor_Meta(); |
185 | 185 | |
186 | - if ( $donors_db->installed() ) { |
|
186 | + if ($donors_db->installed()) { |
|
187 | 187 | $tables[] = $donors_db->table_name; |
188 | 188 | $tables[] = $donor_meta_db->table_name; |
189 | 189 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | |
194 | 194 | } |
195 | 195 | |
196 | -add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 ); |
|
196 | +add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2); |
|
197 | 197 | |
198 | 198 | /** |
199 | 199 | * Post-installation |
@@ -205,16 +205,16 @@ discard block |
||
205 | 205 | */ |
206 | 206 | function give_after_install() { |
207 | 207 | |
208 | - if ( ! is_admin() ) { |
|
208 | + if ( ! is_admin()) { |
|
209 | 209 | return; |
210 | 210 | } |
211 | 211 | |
212 | - $give_options = Give_Cache::get( '_give_installed', true ); |
|
213 | - $give_table_check = get_option( '_give_table_check', false ); |
|
212 | + $give_options = Give_Cache::get('_give_installed', true); |
|
213 | + $give_table_check = get_option('_give_table_check', false); |
|
214 | 214 | |
215 | - if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) { |
|
215 | + if (false === $give_table_check || current_time('timestamp') > $give_table_check) { |
|
216 | 216 | |
217 | - if ( ! @Give()->donor_meta->installed() ) { |
|
217 | + if ( ! @Give()->donor_meta->installed()) { |
|
218 | 218 | |
219 | 219 | // Create the donor meta database. |
220 | 220 | // (this ensures it creates it on multisite instances where it is network activated). |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | |
223 | 223 | } |
224 | 224 | |
225 | - if ( ! @Give()->donors->installed() ) { |
|
225 | + if ( ! @Give()->donors->installed()) { |
|
226 | 226 | // Create the donor database. |
227 | 227 | // (this ensures it creates it on multisite instances where it is network activated). |
228 | 228 | @Give()->donors->create_table(); |
@@ -234,22 +234,22 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @param array $give_options Give plugin options. |
236 | 236 | */ |
237 | - do_action( 'give_after_install', $give_options ); |
|
237 | + do_action('give_after_install', $give_options); |
|
238 | 238 | } |
239 | 239 | |
240 | - update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); |
|
240 | + update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); |
|
241 | 241 | |
242 | 242 | } |
243 | 243 | |
244 | 244 | // Delete the transient |
245 | - if ( false !== $give_options ) { |
|
246 | - Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) ); |
|
245 | + if (false !== $give_options) { |
|
246 | + Give_Cache::delete(Give_Cache::get_key('_give_installed')); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | |
250 | 250 | } |
251 | 251 | |
252 | -add_action( 'admin_init', 'give_after_install' ); |
|
252 | +add_action('admin_init', 'give_after_install'); |
|
253 | 253 | |
254 | 254 | |
255 | 255 | /** |
@@ -264,11 +264,11 @@ discard block |
||
264 | 264 | |
265 | 265 | global $wp_roles; |
266 | 266 | |
267 | - if ( ! is_object( $wp_roles ) ) { |
|
267 | + if ( ! is_object($wp_roles)) { |
|
268 | 268 | return; |
269 | 269 | } |
270 | 270 | |
271 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
271 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
272 | 272 | |
273 | 273 | // Create Give plugin roles |
274 | 274 | $roles = new Give_Roles(); |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | |
280 | 280 | } |
281 | 281 | |
282 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
282 | +add_action('admin_init', 'give_install_roles_on_network'); |
|
283 | 283 | |
284 | 284 | /** |
285 | 285 | * Default core setting values. |
@@ -315,14 +315,14 @@ discard block |
||
315 | 315 | 'uninstall_on_delete' => 'disabled', |
316 | 316 | 'the_content_filter' => 'enabled', |
317 | 317 | 'scripts_footer' => 'disabled', |
318 | - 'agree_to_terms_label' => __( 'Agree to Terms?', 'give' ), |
|
318 | + 'agree_to_terms_label' => __('Agree to Terms?', 'give'), |
|
319 | 319 | 'agreement_text' => give_get_default_agreement_text(), |
320 | 320 | |
321 | 321 | // Paypal IPN verification. |
322 | 322 | 'paypal_verification' => 'enabled', |
323 | 323 | |
324 | 324 | // Default is manual gateway. |
325 | - 'gateways' => array( 'manual' => 1, 'offline' => 1 ), |
|
325 | + 'gateways' => array('manual' => 1, 'offline' => 1), |
|
326 | 326 | 'default_gateway' => 'manual', |
327 | 327 | |
328 | 328 | // Offline gateway setup. |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | */ |
348 | 348 | function give_get_default_agreement_text() { |
349 | 349 | |
350 | - $org_name = get_bloginfo( 'name' ); |
|
350 | + $org_name = get_bloginfo('name'); |
|
351 | 351 | |
352 | 352 | $agreement = sprintf( |
353 | 353 | '<p>Acceptance of any contribution, gift or grant is at the discretion of the %1$s. The %1$s will not accept any gift unless it can be used or expended consistently with the purpose and mission of the %1$s.</p> |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | $org_name |
362 | 362 | ); |
363 | 363 | |
364 | - return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name ); |
|
364 | + return apply_filters('give_get_default_agreement_text', $agreement, $org_name); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | |
@@ -370,22 +370,22 @@ discard block |
||
370 | 370 | * |
371 | 371 | * @since 1.8.11 |
372 | 372 | */ |
373 | -function give_create_pages(){ |
|
373 | +function give_create_pages() { |
|
374 | 374 | |
375 | 375 | // Bailout if pages already created. |
376 | - if( get_option( 'give_install_pages_created') ) { |
|
376 | + if (get_option('give_install_pages_created')) { |
|
377 | 377 | return false; |
378 | 378 | } |
379 | 379 | |
380 | 380 | $options = array(); |
381 | 381 | |
382 | 382 | // Checks if the Success Page option exists AND that the page exists. |
383 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
383 | + if ( ! get_post(give_get_option('success_page'))) { |
|
384 | 384 | |
385 | 385 | // Donation Confirmation (Success) Page |
386 | 386 | $success = wp_insert_post( |
387 | 387 | array( |
388 | - 'post_title' => esc_html__( 'Donation Confirmation', 'give' ), |
|
388 | + 'post_title' => esc_html__('Donation Confirmation', 'give'), |
|
389 | 389 | 'post_content' => '[give_receipt]', |
390 | 390 | 'post_status' => 'publish', |
391 | 391 | 'post_author' => 1, |
@@ -399,13 +399,13 @@ discard block |
||
399 | 399 | } |
400 | 400 | |
401 | 401 | // Checks if the Failure Page option exists AND that the page exists. |
402 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
402 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
403 | 403 | |
404 | 404 | // Failed Donation Page |
405 | 405 | $failed = wp_insert_post( |
406 | 406 | array( |
407 | - 'post_title' => esc_html__( 'Donation Failed', 'give' ), |
|
408 | - 'post_content' => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ), |
|
407 | + 'post_title' => esc_html__('Donation Failed', 'give'), |
|
408 | + 'post_content' => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'), |
|
409 | 409 | 'post_status' => 'publish', |
410 | 410 | 'post_author' => 1, |
411 | 411 | 'post_type' => 'page', |
@@ -417,11 +417,11 @@ discard block |
||
417 | 417 | } |
418 | 418 | |
419 | 419 | // Checks if the History Page option exists AND that the page exists. |
420 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
420 | + if ( ! get_post(give_get_option('history_page'))) { |
|
421 | 421 | // Donation History Page |
422 | 422 | $history = wp_insert_post( |
423 | 423 | array( |
424 | - 'post_title' => esc_html__( 'Donation History', 'give' ), |
|
424 | + 'post_title' => esc_html__('Donation History', 'give'), |
|
425 | 425 | 'post_content' => '[donation_history]', |
426 | 426 | 'post_status' => 'publish', |
427 | 427 | 'post_author' => 1, |
@@ -433,10 +433,10 @@ discard block |
||
433 | 433 | $options['history_page'] = $history; |
434 | 434 | } |
435 | 435 | |
436 | - if( ! empty( $options ) ) { |
|
437 | - update_option( 'give_settings', array_merge( give_get_settings(), $options ) ); |
|
436 | + if ( ! empty($options)) { |
|
437 | + update_option('give_settings', array_merge(give_get_settings(), $options)); |
|
438 | 438 | } |
439 | 439 | |
440 | - add_option( 'give_install_pages_created', 1, '', 'no' ); |
|
440 | + add_option('give_install_pages_created', 1, '', 'no'); |
|
441 | 441 | } |
442 | -add_action( 'admin_init', 'give_create_pages', -1 ); |
|
442 | +add_action('admin_init', 'give_create_pages', -1); |