@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @since 1.0 |
159 | 159 | * @access public |
160 | 160 | * |
161 | - * @param bool|string|int $_id_or_email |
|
161 | + * @param integer $_id_or_email |
|
162 | 162 | * |
163 | 163 | * @return bool|int |
164 | 164 | */ |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | * @param int $user_id User ID. |
314 | 314 | * @param WP_User $old_user_data User data. |
315 | 315 | * |
316 | - * @return bool |
|
316 | + * @return false|null |
|
317 | 317 | */ |
318 | 318 | public function update_customer_email_on_user_update( $user_id = 0, $old_user_data ) { |
319 | 319 | |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | * @access public |
363 | 363 | * |
364 | 364 | * @param string $field ID or email. Default is 'id'. |
365 | - * @param mixed $value The Customer ID or email to search. Default is 0. |
|
365 | + * @param integer $value The Customer ID or email to search. Default is 0. |
|
366 | 366 | * |
367 | 367 | * @return mixed Upon success, an object of the customer. Upon failure, NULL |
368 | 368 | */ |
@@ -427,13 +427,13 @@ discard block |
||
427 | 427 | * |
428 | 428 | * @since 1.0 |
429 | 429 | * @access public |
430 | - * |
|
431 | - * @param array $args |
|
432 | - * |
|
433 | - * @return array|object|null Customers array or object. Null if not found. |
|
430 | + * |
|
431 | + * @param array $args |
|
432 | + * |
|
433 | + * @return array|object|null Customers array or object. Null if not found. |
|
434 | 434 | */ |
435 | 435 | public function get_customers( $args = array() ) { |
436 | - /* @var WPDB $wpdb */ |
|
436 | + /* @var WPDB $wpdb */ |
|
437 | 437 | global $wpdb; |
438 | 438 | |
439 | 439 | $defaults = array( |
@@ -558,13 +558,13 @@ discard block |
||
558 | 558 | * |
559 | 559 | * @since 1.0 |
560 | 560 | * @access public |
561 | - * |
|
562 | - * @param array $args |
|
563 | - * |
|
564 | - * @return int Total number of customers. |
|
561 | + * |
|
562 | + * @param array $args |
|
563 | + * |
|
564 | + * @return int Total number of customers. |
|
565 | 565 | */ |
566 | 566 | public function count( $args = array() ) { |
567 | - /* @var WPDB $wpdb */ |
|
567 | + /* @var WPDB $wpdb */ |
|
568 | 568 | global $wpdb; |
569 | 569 | |
570 | 570 | $where = ' WHERE 1=1 '; |
@@ -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 | |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | /* @var WPDB $wpdb */ |
36 | 36 | global $wpdb; |
37 | 37 | |
38 | - $this->table_name = $wpdb->prefix . 'give_customers'; |
|
38 | + $this->table_name = $wpdb->prefix.'give_customers'; |
|
39 | 39 | $this->primary_key = 'id'; |
40 | 40 | $this->version = '1.0'; |
41 | 41 | |
42 | - add_action( 'profile_update', array( $this, 'update_customer_email_on_user_update' ), 10, 2 ); |
|
42 | + add_action('profile_update', array($this, 'update_customer_email_on_user_update'), 10, 2); |
|
43 | 43 | |
44 | 44 | } |
45 | 45 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | 'purchase_value' => 0.00, |
83 | 83 | 'purchase_count' => 0, |
84 | 84 | 'notes' => '', |
85 | - 'date_created' => date( 'Y-m-d H:i:s' ), |
|
85 | + 'date_created' => date('Y-m-d H:i:s'), |
|
86 | 86 | ); |
87 | 87 | } |
88 | 88 | |
@@ -96,40 +96,40 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @return int|bool |
98 | 98 | */ |
99 | - public function add( $data = array() ) { |
|
99 | + public function add($data = array()) { |
|
100 | 100 | |
101 | 101 | $defaults = array( |
102 | 102 | 'payment_ids' => '' |
103 | 103 | ); |
104 | 104 | |
105 | - $args = wp_parse_args( $data, $defaults ); |
|
105 | + $args = wp_parse_args($data, $defaults); |
|
106 | 106 | |
107 | - if ( empty( $args['email'] ) ) { |
|
107 | + if (empty($args['email'])) { |
|
108 | 108 | return false; |
109 | 109 | } |
110 | 110 | |
111 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
112 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
111 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
112 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
113 | 113 | } |
114 | 114 | |
115 | - $customer = $this->get_customer_by( 'email', $args['email'] ); |
|
115 | + $customer = $this->get_customer_by('email', $args['email']); |
|
116 | 116 | |
117 | - if ( $customer ) { |
|
117 | + if ($customer) { |
|
118 | 118 | // update an existing customer |
119 | 119 | |
120 | 120 | // Update the payment IDs attached to the customer |
121 | - if ( ! empty( $args['payment_ids'] ) ) { |
|
121 | + if ( ! empty($args['payment_ids'])) { |
|
122 | 122 | |
123 | - if ( empty( $customer->payment_ids ) ) { |
|
123 | + if (empty($customer->payment_ids)) { |
|
124 | 124 | |
125 | 125 | $customer->payment_ids = $args['payment_ids']; |
126 | 126 | |
127 | 127 | } else { |
128 | 128 | |
129 | - $existing_ids = array_map( 'absint', explode( ',', $customer->payment_ids ) ); |
|
130 | - $payment_ids = array_map( 'absint', explode( ',', $args['payment_ids'] ) ); |
|
131 | - $payment_ids = array_merge( $payment_ids, $existing_ids ); |
|
132 | - $customer->payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
129 | + $existing_ids = array_map('absint', explode(',', $customer->payment_ids)); |
|
130 | + $payment_ids = array_map('absint', explode(',', $args['payment_ids'])); |
|
131 | + $payment_ids = array_merge($payment_ids, $existing_ids); |
|
132 | + $customer->payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
133 | 133 | |
134 | 134 | } |
135 | 135 | |
@@ -137,13 +137,13 @@ discard block |
||
137 | 137 | |
138 | 138 | } |
139 | 139 | |
140 | - $this->update( $customer->id, $args ); |
|
140 | + $this->update($customer->id, $args); |
|
141 | 141 | |
142 | 142 | return $customer->id; |
143 | 143 | |
144 | 144 | } else { |
145 | 145 | |
146 | - return $this->insert( $args, 'customer' ); |
|
146 | + return $this->insert($args, 'customer'); |
|
147 | 147 | |
148 | 148 | } |
149 | 149 | |
@@ -162,20 +162,20 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return bool|int |
164 | 164 | */ |
165 | - public function delete( $_id_or_email = false ) { |
|
165 | + public function delete($_id_or_email = false) { |
|
166 | 166 | |
167 | - if ( empty( $_id_or_email ) ) { |
|
167 | + if (empty($_id_or_email)) { |
|
168 | 168 | return false; |
169 | 169 | } |
170 | 170 | |
171 | - $column = is_email( $_id_or_email ) ? 'email' : 'id'; |
|
172 | - $customer = $this->get_customer_by( $column, $_id_or_email ); |
|
171 | + $column = is_email($_id_or_email) ? 'email' : 'id'; |
|
172 | + $customer = $this->get_customer_by($column, $_id_or_email); |
|
173 | 173 | |
174 | - if ( $customer->id > 0 ) { |
|
174 | + if ($customer->id > 0) { |
|
175 | 175 | |
176 | 176 | global $wpdb; |
177 | 177 | |
178 | - return $wpdb->delete( $this->table_name, array( 'id' => $customer->id ), array( '%d' ) ); |
|
178 | + return $wpdb->delete($this->table_name, array('id' => $customer->id), array('%d')); |
|
179 | 179 | |
180 | 180 | } else { |
181 | 181 | return false; |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | * |
195 | 195 | * @return bool True is exists, false otherwise. |
196 | 196 | */ |
197 | - public function exists( $value = '', $field = 'email' ) { |
|
197 | + public function exists($value = '', $field = 'email') { |
|
198 | 198 | |
199 | 199 | $columns = $this->get_columns(); |
200 | - if ( ! array_key_exists( $field, $columns ) ) { |
|
200 | + if ( ! array_key_exists($field, $columns)) { |
|
201 | 201 | return false; |
202 | 202 | } |
203 | 203 | |
204 | - return (bool) $this->get_column_by( 'id', $field, $value ); |
|
204 | + return (bool) $this->get_column_by('id', $field, $value); |
|
205 | 205 | |
206 | 206 | } |
207 | 207 | |
@@ -216,16 +216,16 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @return bool |
218 | 218 | */ |
219 | - public function attach_payment( $customer_id = 0, $payment_id = 0 ) { |
|
219 | + public function attach_payment($customer_id = 0, $payment_id = 0) { |
|
220 | 220 | |
221 | - $customer = new Give_Customer( $customer_id ); |
|
221 | + $customer = new Give_Customer($customer_id); |
|
222 | 222 | |
223 | - if ( empty( $customer->id ) ) { |
|
223 | + if (empty($customer->id)) { |
|
224 | 224 | return false; |
225 | 225 | } |
226 | 226 | |
227 | 227 | // Attach the payment, but don't increment stats, as this function previously did not |
228 | - return $customer->attach_payment( $payment_id, false ); |
|
228 | + return $customer->attach_payment($payment_id, false); |
|
229 | 229 | |
230 | 230 | } |
231 | 231 | |
@@ -240,16 +240,16 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return bool |
242 | 242 | */ |
243 | - public function remove_payment( $customer_id = 0, $payment_id = 0 ) { |
|
243 | + public function remove_payment($customer_id = 0, $payment_id = 0) { |
|
244 | 244 | |
245 | - $customer = new Give_Customer( $customer_id ); |
|
245 | + $customer = new Give_Customer($customer_id); |
|
246 | 246 | |
247 | - if ( ! $customer ) { |
|
247 | + if ( ! $customer) { |
|
248 | 248 | return false; |
249 | 249 | } |
250 | 250 | |
251 | 251 | // Remove the payment, but don't decrease stats, as this function previously did not |
252 | - return $customer->remove_payment( $payment_id, false ); |
|
252 | + return $customer->remove_payment($payment_id, false); |
|
253 | 253 | |
254 | 254 | } |
255 | 255 | |
@@ -263,18 +263,18 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @return bool |
265 | 265 | */ |
266 | - public function increment_stats( $customer_id = 0, $amount = 0.00 ) { |
|
266 | + public function increment_stats($customer_id = 0, $amount = 0.00) { |
|
267 | 267 | |
268 | - $customer = new Give_Customer( $customer_id ); |
|
268 | + $customer = new Give_Customer($customer_id); |
|
269 | 269 | |
270 | - if ( empty( $customer->id ) ) { |
|
270 | + if (empty($customer->id)) { |
|
271 | 271 | return false; |
272 | 272 | } |
273 | 273 | |
274 | 274 | $increased_count = $customer->increase_purchase_count(); |
275 | - $increased_value = $customer->increase_value( $amount ); |
|
275 | + $increased_value = $customer->increase_value($amount); |
|
276 | 276 | |
277 | - return ( $increased_count && $increased_value ) ? true : false; |
|
277 | + return ($increased_count && $increased_value) ? true : false; |
|
278 | 278 | |
279 | 279 | } |
280 | 280 | |
@@ -289,18 +289,18 @@ discard block |
||
289 | 289 | * |
290 | 290 | * @return bool |
291 | 291 | */ |
292 | - public function decrement_stats( $customer_id = 0, $amount = 0.00 ) { |
|
292 | + public function decrement_stats($customer_id = 0, $amount = 0.00) { |
|
293 | 293 | |
294 | - $customer = new Give_Customer( $customer_id ); |
|
294 | + $customer = new Give_Customer($customer_id); |
|
295 | 295 | |
296 | - if ( ! $customer ) { |
|
296 | + if ( ! $customer) { |
|
297 | 297 | return false; |
298 | 298 | } |
299 | 299 | |
300 | 300 | $decreased_count = $customer->decrease_purchase_count(); |
301 | - $decreased_value = $customer->decrease_value( $amount ); |
|
301 | + $decreased_value = $customer->decrease_value($amount); |
|
302 | 302 | |
303 | - return ( $decreased_count && $decreased_value ) ? true : false; |
|
303 | + return ($decreased_count && $decreased_value) ? true : false; |
|
304 | 304 | |
305 | 305 | } |
306 | 306 | |
@@ -315,31 +315,31 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @return bool |
317 | 317 | */ |
318 | - public function update_customer_email_on_user_update( $user_id = 0, $old_user_data ) { |
|
318 | + public function update_customer_email_on_user_update($user_id = 0, $old_user_data) { |
|
319 | 319 | |
320 | - $customer = new Give_Customer( $user_id, true ); |
|
320 | + $customer = new Give_Customer($user_id, true); |
|
321 | 321 | |
322 | - if( ! $customer ) { |
|
322 | + if ( ! $customer) { |
|
323 | 323 | return false; |
324 | 324 | } |
325 | 325 | |
326 | - $user = get_userdata( $user_id ); |
|
326 | + $user = get_userdata($user_id); |
|
327 | 327 | |
328 | - if( ! empty( $user ) && $user->user_email !== $customer->email ) { |
|
328 | + if ( ! empty($user) && $user->user_email !== $customer->email) { |
|
329 | 329 | |
330 | - if( ! $this->get_customer_by( 'email', $user->user_email ) ) { |
|
330 | + if ( ! $this->get_customer_by('email', $user->user_email)) { |
|
331 | 331 | |
332 | - $success = $this->update( $customer->id, array( 'email' => $user->user_email ) ); |
|
332 | + $success = $this->update($customer->id, array('email' => $user->user_email)); |
|
333 | 333 | |
334 | - if( $success ) { |
|
334 | + if ($success) { |
|
335 | 335 | // Update some payment meta if we need to |
336 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
336 | + $payments_array = explode(',', $customer->payment_ids); |
|
337 | 337 | |
338 | - if( ! empty( $payments_array ) ) { |
|
338 | + if ( ! empty($payments_array)) { |
|
339 | 339 | |
340 | - foreach ( $payments_array as $payment_id ) { |
|
340 | + foreach ($payments_array as $payment_id) { |
|
341 | 341 | |
342 | - give_update_payment_meta( $payment_id, 'email', $user->user_email ); |
|
342 | + give_update_payment_meta($payment_id, 'email', $user->user_email); |
|
343 | 343 | |
344 | 344 | } |
345 | 345 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | * @param WP_User $user WordPress User object. |
354 | 354 | * @param Give_Customer $customer Give customer object. |
355 | 355 | */ |
356 | - do_action( 'give_update_customer_email_on_user_update', $user, $customer ); |
|
356 | + do_action('give_update_customer_email_on_user_update', $user, $customer); |
|
357 | 357 | |
358 | 358 | } |
359 | 359 | |
@@ -374,46 +374,46 @@ discard block |
||
374 | 374 | * |
375 | 375 | * @return mixed Upon success, an object of the customer. Upon failure, NULL |
376 | 376 | */ |
377 | - public function get_customer_by( $field = 'id', $value = 0 ) { |
|
377 | + public function get_customer_by($field = 'id', $value = 0) { |
|
378 | 378 | /* @var WPDB $wpdb */ |
379 | 379 | global $wpdb; |
380 | 380 | |
381 | - if ( empty( $field ) || empty( $value ) ) { |
|
381 | + if (empty($field) || empty($value)) { |
|
382 | 382 | return null; |
383 | 383 | } |
384 | 384 | |
385 | - if ( 'id' == $field || 'user_id' == $field ) { |
|
385 | + if ('id' == $field || 'user_id' == $field) { |
|
386 | 386 | // Make sure the value is numeric to avoid casting objects, for example, |
387 | 387 | // to int 1. |
388 | - if ( ! is_numeric( $value ) ) { |
|
388 | + if ( ! is_numeric($value)) { |
|
389 | 389 | return false; |
390 | 390 | } |
391 | 391 | |
392 | - $value = intval( $value ); |
|
392 | + $value = intval($value); |
|
393 | 393 | |
394 | - if ( $value < 1 ) { |
|
394 | + if ($value < 1) { |
|
395 | 395 | return false; |
396 | 396 | } |
397 | 397 | |
398 | - } elseif ( 'email' === $field ) { |
|
398 | + } elseif ('email' === $field) { |
|
399 | 399 | |
400 | - if ( ! is_email( $value ) ) { |
|
400 | + if ( ! is_email($value)) { |
|
401 | 401 | return false; |
402 | 402 | } |
403 | 403 | |
404 | - $value = trim( $value ); |
|
404 | + $value = trim($value); |
|
405 | 405 | } |
406 | 406 | |
407 | - if ( ! $value ) { |
|
407 | + if ( ! $value) { |
|
408 | 408 | return false; |
409 | 409 | } |
410 | 410 | |
411 | - switch ( $field ) { |
|
411 | + switch ($field) { |
|
412 | 412 | case 'id': |
413 | 413 | $db_field = 'id'; |
414 | 414 | break; |
415 | 415 | case 'email': |
416 | - $value = sanitize_text_field( $value ); |
|
416 | + $value = sanitize_text_field($value); |
|
417 | 417 | $db_field = 'email'; |
418 | 418 | break; |
419 | 419 | case 'user_id': |
@@ -423,15 +423,15 @@ discard block |
||
423 | 423 | return false; |
424 | 424 | } |
425 | 425 | |
426 | - if ( ! $customer = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value ) ) ) { |
|
426 | + if ( ! $customer = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value))) { |
|
427 | 427 | |
428 | 428 | // Look for customer from an additional email |
429 | - if( 'email' === $field ) { |
|
429 | + if ('email' === $field) { |
|
430 | 430 | $meta_table = Give()->customer_meta->table_name; |
431 | - $customer_id = $wpdb->get_var( $wpdb->prepare( "SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $value ) ); |
|
431 | + $customer_id = $wpdb->get_var($wpdb->prepare("SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $value)); |
|
432 | 432 | |
433 | - if( ! empty( $customer_id ) ) { |
|
434 | - return $this->get( $customer_id ); |
|
433 | + if ( ! empty($customer_id)) { |
|
434 | + return $this->get($customer_id); |
|
435 | 435 | } |
436 | 436 | } |
437 | 437 | |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | * |
452 | 452 | * @return array|object|null Customers array or object. Null if not found. |
453 | 453 | */ |
454 | - public function get_customers( $args = array() ) { |
|
454 | + public function get_customers($args = array()) { |
|
455 | 455 | /* @var WPDB $wpdb */ |
456 | 456 | global $wpdb; |
457 | 457 | |
@@ -463,21 +463,21 @@ discard block |
||
463 | 463 | 'order' => 'DESC' |
464 | 464 | ); |
465 | 465 | |
466 | - $args = wp_parse_args( $args, $defaults ); |
|
466 | + $args = wp_parse_args($args, $defaults); |
|
467 | 467 | |
468 | - if ( $args['number'] < 1 ) { |
|
468 | + if ($args['number'] < 1) { |
|
469 | 469 | $args['number'] = 999999999999; |
470 | 470 | } |
471 | 471 | |
472 | 472 | $where = ' WHERE 1=1 '; |
473 | 473 | |
474 | 474 | // specific customers |
475 | - if ( ! empty( $args['id'] ) ) { |
|
475 | + if ( ! empty($args['id'])) { |
|
476 | 476 | |
477 | - if ( is_array( $args['id'] ) ) { |
|
478 | - $ids = implode( ',', array_map( 'intval', $args['id'] ) ); |
|
477 | + if (is_array($args['id'])) { |
|
478 | + $ids = implode(',', array_map('intval', $args['id'])); |
|
479 | 479 | } else { |
480 | - $ids = intval( $args['id'] ); |
|
480 | + $ids = intval($args['id']); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | $where .= " AND `id` IN( {$ids} ) "; |
@@ -485,12 +485,12 @@ discard block |
||
485 | 485 | } |
486 | 486 | |
487 | 487 | // customers for specific user accounts |
488 | - if ( ! empty( $args['user_id'] ) ) { |
|
488 | + if ( ! empty($args['user_id'])) { |
|
489 | 489 | |
490 | - if ( is_array( $args['user_id'] ) ) { |
|
491 | - $user_ids = implode( ',', array_map( 'intval', $args['user_id'] ) ); |
|
490 | + if (is_array($args['user_id'])) { |
|
491 | + $user_ids = implode(',', array_map('intval', $args['user_id'])); |
|
492 | 492 | } else { |
493 | - $user_ids = intval( $args['user_id'] ); |
|
493 | + $user_ids = intval($args['user_id']); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | $where .= " AND `user_id` IN( {$user_ids} ) "; |
@@ -498,41 +498,41 @@ discard block |
||
498 | 498 | } |
499 | 499 | |
500 | 500 | //specific customers by email |
501 | - if( ! empty( $args['email'] ) ) { |
|
501 | + if ( ! empty($args['email'])) { |
|
502 | 502 | |
503 | - if( is_array( $args['email'] ) ) { |
|
503 | + if (is_array($args['email'])) { |
|
504 | 504 | |
505 | - $emails_count = count( $args['email'] ); |
|
506 | - $emails_placeholder = array_fill( 0, $emails_count, '%s' ); |
|
507 | - $emails = implode( ', ', $emails_placeholder ); |
|
505 | + $emails_count = count($args['email']); |
|
506 | + $emails_placeholder = array_fill(0, $emails_count, '%s'); |
|
507 | + $emails = implode(', ', $emails_placeholder); |
|
508 | 508 | |
509 | - $where .= $wpdb->prepare( " AND `email` IN( $emails ) ", $args['email'] ); |
|
509 | + $where .= $wpdb->prepare(" AND `email` IN( $emails ) ", $args['email']); |
|
510 | 510 | } else { |
511 | - $where .= $wpdb->prepare( " AND `email` = %s ", $args['email'] ); |
|
511 | + $where .= $wpdb->prepare(" AND `email` = %s ", $args['email']); |
|
512 | 512 | } |
513 | 513 | } |
514 | 514 | |
515 | 515 | // specific customers by name |
516 | - if( ! empty( $args['name'] ) ) { |
|
517 | - $where .= $wpdb->prepare( " AND `name` LIKE '%%%%" . '%s' . "%%%%' ", $args['name'] ); |
|
516 | + if ( ! empty($args['name'])) { |
|
517 | + $where .= $wpdb->prepare(" AND `name` LIKE '%%%%".'%s'."%%%%' ", $args['name']); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | // Customers created for a specific date or in a date range |
521 | - if ( ! empty( $args['date'] ) ) { |
|
521 | + if ( ! empty($args['date'])) { |
|
522 | 522 | |
523 | - if ( is_array( $args['date'] ) ) { |
|
523 | + if (is_array($args['date'])) { |
|
524 | 524 | |
525 | - if ( ! empty( $args['date']['start'] ) ) { |
|
525 | + if ( ! empty($args['date']['start'])) { |
|
526 | 526 | |
527 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
527 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
528 | 528 | |
529 | 529 | $where .= " AND `date_created` >= '{$start}'"; |
530 | 530 | |
531 | 531 | } |
532 | 532 | |
533 | - if ( ! empty( $args['date']['end'] ) ) { |
|
533 | + if ( ! empty($args['date']['end'])) { |
|
534 | 534 | |
535 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
535 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
536 | 536 | |
537 | 537 | $where .= " AND `date_created` <= '{$end}'"; |
538 | 538 | |
@@ -540,31 +540,31 @@ discard block |
||
540 | 540 | |
541 | 541 | } else { |
542 | 542 | |
543 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
544 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
545 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
543 | + $year = date('Y', strtotime($args['date'])); |
|
544 | + $month = date('m', strtotime($args['date'])); |
|
545 | + $day = date('d', strtotime($args['date'])); |
|
546 | 546 | |
547 | 547 | $where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )"; |
548 | 548 | } |
549 | 549 | |
550 | 550 | } |
551 | 551 | |
552 | - $args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'id' : $args['orderby']; |
|
552 | + $args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'id' : $args['orderby']; |
|
553 | 553 | |
554 | - if ( 'purchase_value' == $args['orderby'] ) { |
|
554 | + if ('purchase_value' == $args['orderby']) { |
|
555 | 555 | $args['orderby'] = 'purchase_value+0'; |
556 | 556 | } |
557 | 557 | |
558 | - $cache_key = md5( 'give_customers_' . serialize( $args ) ); |
|
558 | + $cache_key = md5('give_customers_'.serialize($args)); |
|
559 | 559 | |
560 | - $customers = wp_cache_get( $cache_key, 'customers' ); |
|
560 | + $customers = wp_cache_get($cache_key, 'customers'); |
|
561 | 561 | |
562 | - $args['orderby'] = esc_sql( $args['orderby'] ); |
|
563 | - $args['order'] = esc_sql( $args['order'] ); |
|
562 | + $args['orderby'] = esc_sql($args['orderby']); |
|
563 | + $args['order'] = esc_sql($args['order']); |
|
564 | 564 | |
565 | - if ( $customers === false ) { |
|
566 | - $customers = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint( $args['offset'] ), absint( $args['number'] ) ) ); |
|
567 | - wp_cache_set( $cache_key, $customers, 'customers', 3600 ); |
|
565 | + if ($customers === false) { |
|
566 | + $customers = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint($args['offset']), absint($args['number']))); |
|
567 | + wp_cache_set($cache_key, $customers, 'customers', 3600); |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | return $customers; |
@@ -582,26 +582,26 @@ discard block |
||
582 | 582 | * |
583 | 583 | * @return int Total number of customers. |
584 | 584 | */ |
585 | - public function count( $args = array() ) { |
|
585 | + public function count($args = array()) { |
|
586 | 586 | /* @var WPDB $wpdb */ |
587 | 587 | global $wpdb; |
588 | 588 | |
589 | 589 | $where = ' WHERE 1=1 '; |
590 | 590 | |
591 | - if ( ! empty( $args['date'] ) ) { |
|
591 | + if ( ! empty($args['date'])) { |
|
592 | 592 | |
593 | - if ( is_array( $args['date'] ) ) { |
|
593 | + if (is_array($args['date'])) { |
|
594 | 594 | |
595 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
596 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
595 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
596 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
597 | 597 | |
598 | 598 | $where .= " AND `date_created` >= '{$start}' AND `date_created` <= '{$end}'"; |
599 | 599 | |
600 | 600 | } else { |
601 | 601 | |
602 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
603 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
604 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
602 | + $year = date('Y', strtotime($args['date'])); |
|
603 | + $month = date('m', strtotime($args['date'])); |
|
604 | + $day = date('d', strtotime($args['date'])); |
|
605 | 605 | |
606 | 606 | $where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )"; |
607 | 607 | } |
@@ -609,16 +609,16 @@ discard block |
||
609 | 609 | } |
610 | 610 | |
611 | 611 | |
612 | - $cache_key = md5( 'give_customers_count' . serialize( $args ) ); |
|
612 | + $cache_key = md5('give_customers_count'.serialize($args)); |
|
613 | 613 | |
614 | - $count = wp_cache_get( $cache_key, 'customers' ); |
|
614 | + $count = wp_cache_get($cache_key, 'customers'); |
|
615 | 615 | |
616 | - if ( $count === false ) { |
|
617 | - $count = $wpdb->get_var( "SELECT COUNT($this->primary_key) FROM " . $this->table_name . "{$where};" ); |
|
618 | - wp_cache_set( $cache_key, $count, 'customers', 3600 ); |
|
616 | + if ($count === false) { |
|
617 | + $count = $wpdb->get_var("SELECT COUNT($this->primary_key) FROM ".$this->table_name."{$where};"); |
|
618 | + wp_cache_set($cache_key, $count, 'customers', 3600); |
|
619 | 619 | } |
620 | 620 | |
621 | - return absint( $count ); |
|
621 | + return absint($count); |
|
622 | 622 | |
623 | 623 | } |
624 | 624 | |
@@ -632,9 +632,9 @@ discard block |
||
632 | 632 | */ |
633 | 633 | public function create_table() { |
634 | 634 | |
635 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
635 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
636 | 636 | |
637 | - $sql = "CREATE TABLE " . $this->table_name . " ( |
|
637 | + $sql = "CREATE TABLE ".$this->table_name." ( |
|
638 | 638 | id bigint(20) NOT NULL AUTO_INCREMENT, |
639 | 639 | user_id bigint(20) NOT NULL, |
640 | 640 | email varchar(50) NOT NULL, |
@@ -649,9 +649,9 @@ discard block |
||
649 | 649 | KEY user (user_id) |
650 | 650 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
651 | 651 | |
652 | - dbDelta( $sql ); |
|
652 | + dbDelta($sql); |
|
653 | 653 | |
654 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
654 | + update_option($this->table_name.'_db_version', $this->version); |
|
655 | 655 | } |
656 | 656 | |
657 | 657 | /** |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | * @return bool Returns if the customers table was installed and upgrade routine run. |
664 | 664 | */ |
665 | 665 | public function installed() { |
666 | - return $this->table_exists( $this->table_name ); |
|
666 | + return $this->table_exists($this->table_name); |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | } |
@@ -358,9 +358,9 @@ |
||
358 | 358 | require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php'; |
359 | 359 | require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php'; |
360 | 360 | |
361 | - if( defined( 'WP_CLI' ) && WP_CLI ) { |
|
362 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php'; |
|
363 | - } |
|
361 | + if( defined( 'WP_CLI' ) && WP_CLI ) { |
|
362 | + require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php'; |
|
363 | + } |
|
364 | 364 | |
365 | 365 | if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
366 | 366 |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | */ |
41 | 41 | |
42 | 42 | // Exit if accessed directly. |
43 | -if ( ! defined( 'ABSPATH' ) ) { |
|
43 | +if ( ! defined('ABSPATH')) { |
|
44 | 44 | exit; |
45 | 45 | } |
46 | 46 | |
47 | -if ( ! class_exists( 'Give' ) ) : |
|
47 | +if ( ! class_exists('Give')) : |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Main Give Class |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | * @return Give |
196 | 196 | */ |
197 | 197 | public static function instance() { |
198 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give ) ) { |
|
198 | + if ( ! isset(self::$instance) && ! (self::$instance instanceof Give)) { |
|
199 | 199 | self::$instance = new Give; |
200 | 200 | self::$instance->setup_constants(); |
201 | 201 | |
202 | - add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) ); |
|
202 | + add_action('plugins_loaded', array(self::$instance, 'load_textdomain')); |
|
203 | 203 | |
204 | 204 | self::$instance->includes(); |
205 | 205 | self::$instance->roles = new Give_Roles(); |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function __clone() { |
234 | 234 | // Cloning instances of the class is forbidden |
235 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
235 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0'); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | */ |
246 | 246 | public function __wakeup() { |
247 | 247 | // Unserializing instances of the class is forbidden. |
248 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
248 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0'); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -259,33 +259,33 @@ discard block |
||
259 | 259 | private function setup_constants() { |
260 | 260 | |
261 | 261 | // Plugin version |
262 | - if ( ! defined( 'GIVE_VERSION' ) ) { |
|
263 | - define( 'GIVE_VERSION', '1.8.3' ); |
|
262 | + if ( ! defined('GIVE_VERSION')) { |
|
263 | + define('GIVE_VERSION', '1.8.3'); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | // Plugin Folder Path |
267 | - if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) { |
|
268 | - define( 'GIVE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
|
267 | + if ( ! defined('GIVE_PLUGIN_DIR')) { |
|
268 | + define('GIVE_PLUGIN_DIR', plugin_dir_path(__FILE__)); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | // Plugin Folder URL |
272 | - if ( ! defined( 'GIVE_PLUGIN_URL' ) ) { |
|
273 | - define( 'GIVE_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
|
272 | + if ( ! defined('GIVE_PLUGIN_URL')) { |
|
273 | + define('GIVE_PLUGIN_URL', plugin_dir_url(__FILE__)); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | // Plugin Basename aka: "give/give.php" |
277 | - if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) { |
|
278 | - define( 'GIVE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); |
|
277 | + if ( ! defined('GIVE_PLUGIN_BASENAME')) { |
|
278 | + define('GIVE_PLUGIN_BASENAME', plugin_basename(__FILE__)); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | // Plugin Root File |
282 | - if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) { |
|
283 | - define( 'GIVE_PLUGIN_FILE', __FILE__ ); |
|
282 | + if ( ! defined('GIVE_PLUGIN_FILE')) { |
|
283 | + define('GIVE_PLUGIN_FILE', __FILE__); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | // Make sure CAL_GREGORIAN is defined |
287 | - if ( ! defined( 'CAL_GREGORIAN' ) ) { |
|
288 | - define( 'CAL_GREGORIAN', 1 ); |
|
287 | + if ( ! defined('CAL_GREGORIAN')) { |
|
288 | + define('CAL_GREGORIAN', 1); |
|
289 | 289 | } |
290 | 290 | } |
291 | 291 | |
@@ -300,122 +300,122 @@ discard block |
||
300 | 300 | private function includes() { |
301 | 301 | global $give_options; |
302 | 302 | |
303 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php'; |
|
304 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php'; |
|
303 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-settings.php'; |
|
304 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-give-settings.php'; |
|
305 | 305 | $give_options = give_get_settings(); |
306 | 306 | |
307 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/give-metabox-functions.php'; |
|
308 | - require_once GIVE_PLUGIN_DIR . 'includes/post-types.php'; |
|
309 | - require_once GIVE_PLUGIN_DIR . 'includes/scripts.php'; |
|
310 | - require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php'; |
|
311 | - require_once GIVE_PLUGIN_DIR . 'includes/actions.php'; |
|
312 | - require_once GIVE_PLUGIN_DIR . 'includes/filters.php'; |
|
313 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php'; |
|
314 | - |
|
315 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php'; |
|
316 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php'; |
|
317 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php'; |
|
318 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php'; |
|
319 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-customers.php'; |
|
320 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-customer-meta.php'; |
|
321 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-customer.php'; |
|
322 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php'; |
|
323 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php'; |
|
324 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php'; |
|
325 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php'; |
|
326 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php'; |
|
327 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php'; |
|
328 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php'; |
|
329 | - |
|
330 | - require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php'; |
|
331 | - require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php'; |
|
332 | - require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php'; |
|
333 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php'; |
|
334 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php'; |
|
335 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php'; |
|
336 | - require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php'; |
|
337 | - require_once GIVE_PLUGIN_DIR . 'includes/formatting.php'; |
|
338 | - require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php'; |
|
339 | - require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php'; |
|
340 | - require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php'; |
|
341 | - require_once GIVE_PLUGIN_DIR . 'includes/login-register.php'; |
|
342 | - require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php'; |
|
343 | - require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php'; |
|
344 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php'; |
|
345 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php'; |
|
346 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php'; |
|
347 | - |
|
348 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php'; |
|
349 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php'; |
|
350 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php'; |
|
351 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php'; |
|
352 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php'; |
|
353 | - |
|
354 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php'; |
|
355 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php'; |
|
356 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php'; |
|
357 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php'; |
|
358 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php'; |
|
359 | - |
|
360 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php'; |
|
361 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php'; |
|
362 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php'; |
|
363 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php'; |
|
364 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php'; |
|
365 | - |
|
366 | - if( defined( 'WP_CLI' ) && WP_CLI ) { |
|
367 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php'; |
|
307 | + require_once GIVE_PLUGIN_DIR.'includes/admin/give-metabox-functions.php'; |
|
308 | + require_once GIVE_PLUGIN_DIR.'includes/post-types.php'; |
|
309 | + require_once GIVE_PLUGIN_DIR.'includes/scripts.php'; |
|
310 | + require_once GIVE_PLUGIN_DIR.'includes/ajax-functions.php'; |
|
311 | + require_once GIVE_PLUGIN_DIR.'includes/actions.php'; |
|
312 | + require_once GIVE_PLUGIN_DIR.'includes/filters.php'; |
|
313 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api.php'; |
|
314 | + |
|
315 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-roles.php'; |
|
316 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-template-loader.php'; |
|
317 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-donate-form.php'; |
|
318 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db.php'; |
|
319 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-customers.php'; |
|
320 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-customer-meta.php'; |
|
321 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-customer.php'; |
|
322 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-stats.php'; |
|
323 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-session.php'; |
|
324 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-html-elements.php'; |
|
325 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-logging.php'; |
|
326 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-license-handler.php'; |
|
327 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cron.php'; |
|
328 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-email-access.php'; |
|
329 | + |
|
330 | + require_once GIVE_PLUGIN_DIR.'includes/country-functions.php'; |
|
331 | + require_once GIVE_PLUGIN_DIR.'includes/template-functions.php'; |
|
332 | + require_once GIVE_PLUGIN_DIR.'includes/misc-functions.php'; |
|
333 | + require_once GIVE_PLUGIN_DIR.'includes/forms/functions.php'; |
|
334 | + require_once GIVE_PLUGIN_DIR.'includes/forms/template.php'; |
|
335 | + require_once GIVE_PLUGIN_DIR.'includes/forms/widget.php'; |
|
336 | + require_once GIVE_PLUGIN_DIR.'includes/shortcodes.php'; |
|
337 | + require_once GIVE_PLUGIN_DIR.'includes/formatting.php'; |
|
338 | + require_once GIVE_PLUGIN_DIR.'includes/price-functions.php'; |
|
339 | + require_once GIVE_PLUGIN_DIR.'includes/error-tracking.php'; |
|
340 | + require_once GIVE_PLUGIN_DIR.'includes/process-donation.php'; |
|
341 | + require_once GIVE_PLUGIN_DIR.'includes/login-register.php'; |
|
342 | + require_once GIVE_PLUGIN_DIR.'includes/user-functions.php'; |
|
343 | + require_once GIVE_PLUGIN_DIR.'includes/plugin-compatibility.php'; |
|
344 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-functions.php'; |
|
345 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-actions.php'; |
|
346 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-filters.php'; |
|
347 | + |
|
348 | + require_once GIVE_PLUGIN_DIR.'includes/payments/functions.php'; |
|
349 | + require_once GIVE_PLUGIN_DIR.'includes/payments/actions.php'; |
|
350 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payment-stats.php'; |
|
351 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payments-query.php'; |
|
352 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-payment.php'; |
|
353 | + |
|
354 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/functions.php'; |
|
355 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/actions.php'; |
|
356 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/paypal-standard.php'; |
|
357 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/offline-donations.php'; |
|
358 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/manual.php'; |
|
359 | + |
|
360 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-emails.php'; |
|
361 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-email-tags.php'; |
|
362 | + require_once GIVE_PLUGIN_DIR.'includes/emails/functions.php'; |
|
363 | + require_once GIVE_PLUGIN_DIR.'includes/emails/template.php'; |
|
364 | + require_once GIVE_PLUGIN_DIR.'includes/emails/actions.php'; |
|
365 | + |
|
366 | + if (defined('WP_CLI') && WP_CLI) { |
|
367 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cli-commands.php'; |
|
368 | 368 | } |
369 | 369 | |
370 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
371 | - |
|
372 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php'; |
|
373 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php'; |
|
374 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php'; |
|
375 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-notices.php'; |
|
376 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php'; |
|
377 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-i18n-module.php'; |
|
378 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php'; |
|
379 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-filters.php'; |
|
380 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/system-info.php'; |
|
381 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php'; |
|
382 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php'; |
|
383 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php'; |
|
384 | - |
|
385 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php'; |
|
386 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php'; |
|
387 | - |
|
388 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customers.php'; |
|
389 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-functions.php'; |
|
390 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-actions.php'; |
|
391 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php'; |
|
392 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-metabox-form-data.php'; |
|
393 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php'; |
|
394 | - |
|
395 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/export-functions.php'; |
|
396 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/reports.php'; |
|
397 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools.php'; |
|
398 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/tools-actions.php'; |
|
399 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/pdf-reports.php'; |
|
400 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-give-graph.php'; |
|
401 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/graphing.php'; |
|
402 | - |
|
403 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
404 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php'; |
|
405 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php'; |
|
406 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
407 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php'; |
|
408 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php'; |
|
409 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
410 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
411 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
412 | - |
|
413 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
414 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrades.php'; |
|
370 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
371 | + |
|
372 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-footer.php'; |
|
373 | + require_once GIVE_PLUGIN_DIR.'includes/admin/welcome.php'; |
|
374 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-pages.php'; |
|
375 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-notices.php'; |
|
376 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php'; |
|
377 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-i18n-module.php'; |
|
378 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-actions.php'; |
|
379 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-filters.php'; |
|
380 | + require_once GIVE_PLUGIN_DIR.'includes/admin/system-info.php'; |
|
381 | + require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php'; |
|
382 | + require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php'; |
|
383 | + require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php'; |
|
384 | + |
|
385 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php'; |
|
386 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php'; |
|
387 | + |
|
388 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customers.php'; |
|
389 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-functions.php'; |
|
390 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-actions.php'; |
|
391 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php'; |
|
392 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/class-metabox-form-data.php'; |
|
393 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php'; |
|
394 | + |
|
395 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/export-functions.php'; |
|
396 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/reports.php'; |
|
397 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools.php'; |
|
398 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/tools-actions.php'; |
|
399 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/pdf-reports.php'; |
|
400 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-give-graph.php'; |
|
401 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/graphing.php'; |
|
402 | + |
|
403 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
404 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php'; |
|
405 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php'; |
|
406 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
407 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php'; |
|
408 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php'; |
|
409 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
410 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
411 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
412 | + |
|
413 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
414 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrades.php'; |
|
415 | 415 | |
416 | 416 | } |
417 | 417 | |
418 | - require_once GIVE_PLUGIN_DIR . 'includes/install.php'; |
|
418 | + require_once GIVE_PLUGIN_DIR.'includes/install.php'; |
|
419 | 419 | |
420 | 420 | } |
421 | 421 | |
@@ -429,26 +429,26 @@ discard block |
||
429 | 429 | */ |
430 | 430 | public function load_textdomain() { |
431 | 431 | // Set filter for Give's languages directory |
432 | - $give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/'; |
|
433 | - $give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir ); |
|
432 | + $give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/'; |
|
433 | + $give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir); |
|
434 | 434 | |
435 | 435 | // Traditional WordPress plugin locale filter |
436 | - $locale = apply_filters( 'plugin_locale', get_locale(), 'give' ); |
|
437 | - $mofile = sprintf( '%1$s-%2$s.mo', 'give', $locale ); |
|
436 | + $locale = apply_filters('plugin_locale', get_locale(), 'give'); |
|
437 | + $mofile = sprintf('%1$s-%2$s.mo', 'give', $locale); |
|
438 | 438 | |
439 | 439 | // Setup paths to current locale file |
440 | - $mofile_local = $give_lang_dir . $mofile; |
|
441 | - $mofile_global = WP_LANG_DIR . '/give/' . $mofile; |
|
440 | + $mofile_local = $give_lang_dir.$mofile; |
|
441 | + $mofile_global = WP_LANG_DIR.'/give/'.$mofile; |
|
442 | 442 | |
443 | - if ( file_exists( $mofile_global ) ) { |
|
443 | + if (file_exists($mofile_global)) { |
|
444 | 444 | // Look in global /wp-content/languages/give folder |
445 | - load_textdomain( 'give', $mofile_global ); |
|
446 | - } elseif ( file_exists( $mofile_local ) ) { |
|
445 | + load_textdomain('give', $mofile_global); |
|
446 | + } elseif (file_exists($mofile_local)) { |
|
447 | 447 | // Look in local location from filter `give_languages_directory` |
448 | - load_textdomain( 'give', $mofile_local ); |
|
448 | + load_textdomain('give', $mofile_local); |
|
449 | 449 | } else { |
450 | 450 | // Load the default language files packaged up w/ Give |
451 | - load_plugin_textdomain( 'give', false, $give_lang_dir ); |
|
451 | + load_plugin_textdomain('give', false, $give_lang_dir); |
|
452 | 452 | } |
453 | 453 | } |
454 | 454 |
@@ -45,22 +45,22 @@ discard block |
||
45 | 45 | * @param string $default_path Default path. Default is empty. |
46 | 46 | */ |
47 | 47 | function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
48 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
49 | - extract( $args ); |
|
50 | - } |
|
48 | + if ( ! empty( $args ) && is_array( $args ) ) { |
|
49 | + extract( $args ); |
|
50 | + } |
|
51 | 51 | |
52 | - $template_names = array( $template_name . '.php' ); |
|
52 | + $template_names = array( $template_name . '.php' ); |
|
53 | 53 | |
54 | - $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
54 | + $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
55 | 55 | |
56 | - if ( ! file_exists( $located ) ) { |
|
56 | + if ( ! file_exists( $located ) ) { |
|
57 | 57 | /* translators: %s: the template */ |
58 | - give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
59 | - return; |
|
60 | - } |
|
58 | + give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
59 | + return; |
|
60 | + } |
|
61 | 61 | |
62 | - // Allow 3rd party plugin filter template file from their plugin. |
|
63 | - $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
62 | + // Allow 3rd party plugin filter template file from their plugin. |
|
63 | + $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Fires in give template, before the file is included. |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * @param string $located Template file filter by 3rd party plugin. |
75 | 75 | * @param array $args Passed arguments. |
76 | 76 | */ |
77 | - do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
77 | + do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
78 | 78 | |
79 | - include( $located ); |
|
79 | + include( $located ); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Fires in give template, after the file is included. |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param string $located Template file filter by 3rd party plugin. |
91 | 91 | * @param array $args Passed arguments. |
92 | 92 | */ |
93 | - do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
93 | + do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -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 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @return string |
22 | 22 | */ |
23 | 23 | function give_get_templates_dir() { |
24 | - return GIVE_PLUGIN_DIR . 'templates'; |
|
24 | + return GIVE_PLUGIN_DIR.'templates'; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @return string |
32 | 32 | */ |
33 | 33 | function give_get_templates_url() { |
34 | - return GIVE_PLUGIN_URL . 'templates'; |
|
34 | + return GIVE_PLUGIN_URL.'templates'; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -44,23 +44,23 @@ discard block |
||
44 | 44 | * @param string $template_path Template file path. Default is empty. |
45 | 45 | * @param string $default_path Default path. Default is empty. |
46 | 46 | */ |
47 | -function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
48 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
49 | - extract( $args ); |
|
47 | +function give_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
48 | + if ( ! empty($args) && is_array($args)) { |
|
49 | + extract($args); |
|
50 | 50 | } |
51 | 51 | |
52 | - $template_names = array( $template_name . '.php' ); |
|
52 | + $template_names = array($template_name.'.php'); |
|
53 | 53 | |
54 | - $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
54 | + $located = give_locate_template($template_names, $template_path, $default_path); |
|
55 | 55 | |
56 | - if ( ! file_exists( $located ) ) { |
|
56 | + if ( ! file_exists($located)) { |
|
57 | 57 | /* translators: %s: the template */ |
58 | - give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
58 | + give_output_error(sprintf(__('The %s template was not found.', 'give'), $located), true); |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
62 | 62 | // Allow 3rd party plugin filter template file from their plugin. |
63 | - $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
63 | + $located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Fires in give template, before the file is included. |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * @param string $located Template file filter by 3rd party plugin. |
75 | 75 | * @param array $args Passed arguments. |
76 | 76 | */ |
77 | - do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
77 | + do_action('give_before_template_part', $template_name, $template_path, $located, $args); |
|
78 | 78 | |
79 | - include( $located ); |
|
79 | + include($located); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Fires in give template, after the file is included. |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param string $located Template file filter by 3rd party plugin. |
91 | 91 | * @param array $args Passed arguments. |
92 | 92 | */ |
93 | - do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
93 | + do_action('give_after_template_part', $template_name, $template_path, $located, $args); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @return string |
108 | 108 | */ |
109 | -function give_get_template_part( $slug, $name = null, $load = true ) { |
|
109 | +function give_get_template_part($slug, $name = null, $load = true) { |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * Fires in give template part, before the template part is retrieved. |
@@ -118,20 +118,20 @@ discard block |
||
118 | 118 | * @param string $slug Template part file slug {slug}.php. |
119 | 119 | * @param string $name Template part file name {slug}-{name}.php. |
120 | 120 | */ |
121 | - do_action( "get_template_part_{$slug}", $slug, $name ); |
|
121 | + do_action("get_template_part_{$slug}", $slug, $name); |
|
122 | 122 | |
123 | 123 | // Setup possible parts |
124 | 124 | $templates = array(); |
125 | - if ( isset( $name ) ) { |
|
126 | - $templates[] = $slug . '-' . $name . '.php'; |
|
125 | + if (isset($name)) { |
|
126 | + $templates[] = $slug.'-'.$name.'.php'; |
|
127 | 127 | } |
128 | - $templates[] = $slug . '.php'; |
|
128 | + $templates[] = $slug.'.php'; |
|
129 | 129 | |
130 | 130 | // Allow template parts to be filtered |
131 | - $templates = apply_filters( 'give_get_template_part', $templates, $slug, $name ); |
|
131 | + $templates = apply_filters('give_get_template_part', $templates, $slug, $name); |
|
132 | 132 | |
133 | 133 | // Return the part that is found |
134 | - return give_locate_template( $templates, $load, false ); |
|
134 | + return give_locate_template($templates, $load, false); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -152,37 +152,37 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return string The template filename if one is located. |
154 | 154 | */ |
155 | -function give_locate_template( $template_names, $load = false, $require_once = true ) { |
|
155 | +function give_locate_template($template_names, $load = false, $require_once = true) { |
|
156 | 156 | // No file found yet |
157 | 157 | $located = false; |
158 | 158 | |
159 | 159 | // Try to find a template file |
160 | - foreach ( (array) $template_names as $template_name ) { |
|
160 | + foreach ((array) $template_names as $template_name) { |
|
161 | 161 | |
162 | 162 | // Continue if template is empty |
163 | - if ( empty( $template_name ) ) { |
|
163 | + if (empty($template_name)) { |
|
164 | 164 | continue; |
165 | 165 | } |
166 | 166 | |
167 | 167 | // Trim off any slashes from the template name |
168 | - $template_name = ltrim( $template_name, '/' ); |
|
168 | + $template_name = ltrim($template_name, '/'); |
|
169 | 169 | |
170 | 170 | // try locating this template file by looping through the template paths |
171 | - foreach ( give_get_theme_template_paths() as $template_path ) { |
|
171 | + foreach (give_get_theme_template_paths() as $template_path) { |
|
172 | 172 | |
173 | - if ( file_exists( $template_path . $template_name ) ) { |
|
174 | - $located = $template_path . $template_name; |
|
173 | + if (file_exists($template_path.$template_name)) { |
|
174 | + $located = $template_path.$template_name; |
|
175 | 175 | break; |
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
179 | - if ( $located ) { |
|
179 | + if ($located) { |
|
180 | 180 | break; |
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
185 | - load_template( $located, $require_once ); |
|
184 | + if ((true == $load) && ! empty($located)) { |
|
185 | + load_template($located, $require_once); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | return $located; |
@@ -199,17 +199,17 @@ discard block |
||
199 | 199 | $template_dir = give_get_theme_template_dir_name(); |
200 | 200 | |
201 | 201 | $file_paths = array( |
202 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
203 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
202 | + 1 => trailingslashit(get_stylesheet_directory()).$template_dir, |
|
203 | + 10 => trailingslashit(get_template_directory()).$template_dir, |
|
204 | 204 | 100 => give_get_templates_dir() |
205 | 205 | ); |
206 | 206 | |
207 | - $file_paths = apply_filters( 'give_template_paths', $file_paths ); |
|
207 | + $file_paths = apply_filters('give_template_paths', $file_paths); |
|
208 | 208 | |
209 | 209 | // sort the file paths based on priority |
210 | - ksort( $file_paths, SORT_NUMERIC ); |
|
210 | + ksort($file_paths, SORT_NUMERIC); |
|
211 | 211 | |
212 | - return array_map( 'trailingslashit', $file_paths ); |
|
212 | + return array_map('trailingslashit', $file_paths); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @return string |
222 | 222 | */ |
223 | 223 | function give_get_theme_template_dir_name() { |
224 | - return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) ); |
|
224 | + return trailingslashit(apply_filters('give_templates_dir', 'give')); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | * @return void |
232 | 232 | */ |
233 | 233 | function give_version_in_header() { |
234 | - echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n"; |
|
234 | + echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n"; |
|
235 | 235 | } |
236 | 236 | |
237 | -add_action( 'wp_head', 'give_version_in_header' ); |
|
237 | +add_action('wp_head', 'give_version_in_header'); |
|
238 | 238 | |
239 | 239 | /** |
240 | 240 | * Determines if we're currently on the Donations History page. |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | */ |
245 | 245 | function give_is_donation_history_page() { |
246 | 246 | |
247 | - $ret = is_page( give_get_option( 'history_page' ) ); |
|
247 | + $ret = is_page(give_get_option('history_page')); |
|
248 | 248 | |
249 | - return apply_filters( 'give_is_donation_history_page', $ret ); |
|
249 | + return apply_filters('give_is_donation_history_page', $ret); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -258,25 +258,25 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return array Modified array of classes |
260 | 260 | */ |
261 | -function give_add_body_classes( $class ) { |
|
261 | +function give_add_body_classes($class) { |
|
262 | 262 | $classes = (array) $class; |
263 | 263 | |
264 | - if ( give_is_success_page() ) { |
|
264 | + if (give_is_success_page()) { |
|
265 | 265 | $classes[] = 'give-success'; |
266 | 266 | $classes[] = 'give-page'; |
267 | 267 | } |
268 | 268 | |
269 | - if ( give_is_failed_transaction_page() ) { |
|
269 | + if (give_is_failed_transaction_page()) { |
|
270 | 270 | $classes[] = 'give-failed-transaction'; |
271 | 271 | $classes[] = 'give-page'; |
272 | 272 | } |
273 | 273 | |
274 | - if ( give_is_donation_history_page() ) { |
|
274 | + if (give_is_donation_history_page()) { |
|
275 | 275 | $classes[] = 'give-donation-history'; |
276 | 276 | $classes[] = 'give-page'; |
277 | 277 | } |
278 | 278 | |
279 | - if ( give_is_test_mode() ) { |
|
279 | + if (give_is_test_mode()) { |
|
280 | 280 | $classes[] = 'give-test-mode'; |
281 | 281 | $classes[] = 'give-page'; |
282 | 282 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | //Theme-specific Classes used to prevent conflicts via CSS |
285 | 285 | $current_theme = wp_get_theme(); |
286 | 286 | |
287 | - switch ( $current_theme->template ) { |
|
287 | + switch ($current_theme->template) { |
|
288 | 288 | |
289 | 289 | case 'Divi': |
290 | 290 | $classes[] = 'give-divi'; |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | |
299 | 299 | } |
300 | 300 | |
301 | - return array_unique( $classes ); |
|
301 | + return array_unique($classes); |
|
302 | 302 | } |
303 | 303 | |
304 | -add_filter( 'body_class', 'give_add_body_classes' ); |
|
304 | +add_filter('body_class', 'give_add_body_classes'); |
|
305 | 305 | |
306 | 306 | |
307 | 307 | /** |
@@ -317,22 +317,22 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @return array |
319 | 319 | */ |
320 | -function give_add_post_class( $classes, $class = '', $post_id = '' ) { |
|
321 | - if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) { |
|
320 | +function give_add_post_class($classes, $class = '', $post_id = '') { |
|
321 | + if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) { |
|
322 | 322 | return $classes; |
323 | 323 | } |
324 | 324 | |
325 | 325 | //@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc). |
326 | 326 | |
327 | - if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) { |
|
328 | - unset( $classes[ $key ] ); |
|
327 | + if (false !== ($key = array_search('hentry', $classes))) { |
|
328 | + unset($classes[$key]); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | return $classes; |
332 | 332 | } |
333 | 333 | |
334 | 334 | |
335 | -add_filter( 'post_class', 'give_add_post_class', 20, 3 ); |
|
335 | +add_filter('post_class', 'give_add_post_class', 20, 3); |
|
336 | 336 | |
337 | 337 | /** |
338 | 338 | * Get the placeholder image URL for forms etc |
@@ -342,84 +342,84 @@ discard block |
||
342 | 342 | */ |
343 | 343 | function give_get_placeholder_img_src() { |
344 | 344 | |
345 | - $placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) ); |
|
345 | + $placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give')); |
|
346 | 346 | |
347 | - return apply_filters( 'give_placeholder_img_src', $placeholder_url ); |
|
347 | + return apply_filters('give_placeholder_img_src', $placeholder_url); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | |
351 | 351 | /** |
352 | 352 | * Global |
353 | 353 | */ |
354 | -if ( ! function_exists( 'give_output_content_wrapper' ) ) { |
|
354 | +if ( ! function_exists('give_output_content_wrapper')) { |
|
355 | 355 | |
356 | 356 | /** |
357 | 357 | * Output the start of the page wrapper. |
358 | 358 | */ |
359 | 359 | function give_output_content_wrapper() { |
360 | - give_get_template_part( 'global/wrapper-start' ); |
|
360 | + give_get_template_part('global/wrapper-start'); |
|
361 | 361 | } |
362 | 362 | } |
363 | -if ( ! function_exists( 'give_output_content_wrapper_end' ) ) { |
|
363 | +if ( ! function_exists('give_output_content_wrapper_end')) { |
|
364 | 364 | |
365 | 365 | /** |
366 | 366 | * Output the end of the page wrapper. |
367 | 367 | */ |
368 | 368 | function give_output_content_wrapper_end() { |
369 | - give_get_template_part( 'global/wrapper-end' ); |
|
369 | + give_get_template_part('global/wrapper-end'); |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
374 | 374 | * Single Give Form |
375 | 375 | */ |
376 | -if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) { |
|
376 | +if ( ! function_exists('give_left_sidebar_pre_wrap')) { |
|
377 | 377 | function give_left_sidebar_pre_wrap() { |
378 | - echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' ); |
|
378 | + echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">'); |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | |
382 | -if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) { |
|
382 | +if ( ! function_exists('give_left_sidebar_post_wrap')) { |
|
383 | 383 | function give_left_sidebar_post_wrap() { |
384 | - echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' ); |
|
384 | + echo apply_filters('give_left_sidebar_post_wrap', '</div>'); |
|
385 | 385 | } |
386 | 386 | } |
387 | 387 | |
388 | -if ( ! function_exists( 'give_get_forms_sidebar' ) ) { |
|
388 | +if ( ! function_exists('give_get_forms_sidebar')) { |
|
389 | 389 | function give_get_forms_sidebar() { |
390 | - give_get_template_part( 'single-give-form/sidebar' ); |
|
390 | + give_get_template_part('single-give-form/sidebar'); |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
394 | -if ( ! function_exists( 'give_show_form_images' ) ) { |
|
394 | +if ( ! function_exists('give_show_form_images')) { |
|
395 | 395 | |
396 | 396 | /** |
397 | 397 | * Output the donation form featured image. |
398 | 398 | */ |
399 | 399 | function give_show_form_images() { |
400 | - if ( give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
401 | - give_get_template_part( 'single-give-form/featured-image' ); |
|
400 | + if (give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
401 | + give_get_template_part('single-give-form/featured-image'); |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
406 | -if ( ! function_exists( 'give_template_single_title' ) ) { |
|
406 | +if ( ! function_exists('give_template_single_title')) { |
|
407 | 407 | |
408 | 408 | /** |
409 | 409 | * Output the form title. |
410 | 410 | */ |
411 | 411 | function give_template_single_title() { |
412 | - give_get_template_part( 'single-give-form/title' ); |
|
412 | + give_get_template_part('single-give-form/title'); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
416 | -if ( ! function_exists( 'give_show_avatars' ) ) { |
|
416 | +if ( ! function_exists('give_show_avatars')) { |
|
417 | 417 | |
418 | 418 | /** |
419 | 419 | * Output the product title. |
420 | 420 | */ |
421 | 421 | function give_show_avatars() { |
422 | - echo do_shortcode( '[give_donors_gravatars]' ); |
|
422 | + echo do_shortcode('[give_donors_gravatars]'); |
|
423 | 423 | } |
424 | 424 | } |
425 | 425 | |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | * Conditional Functions |
428 | 428 | */ |
429 | 429 | |
430 | -if ( ! function_exists( 'is_give_form' ) ) { |
|
430 | +if ( ! function_exists('is_give_form')) { |
|
431 | 431 | |
432 | 432 | /** |
433 | 433 | * is_give_form |
@@ -439,11 +439,11 @@ discard block |
||
439 | 439 | * @return bool |
440 | 440 | */ |
441 | 441 | function is_give_form() { |
442 | - return is_singular( array( 'give_form' ) ); |
|
442 | + return is_singular(array('give_form')); |
|
443 | 443 | } |
444 | 444 | } |
445 | 445 | |
446 | -if ( ! function_exists( 'is_give_category' ) ) { |
|
446 | +if ( ! function_exists('is_give_category')) { |
|
447 | 447 | |
448 | 448 | /** |
449 | 449 | * is_give_category |
@@ -458,12 +458,12 @@ discard block |
||
458 | 458 | * |
459 | 459 | * @return bool |
460 | 460 | */ |
461 | - function is_give_category( $term = '' ) { |
|
462 | - return is_tax( 'give_forms_category', $term ); |
|
461 | + function is_give_category($term = '') { |
|
462 | + return is_tax('give_forms_category', $term); |
|
463 | 463 | } |
464 | 464 | } |
465 | 465 | |
466 | -if ( ! function_exists( 'is_give_tag' ) ) { |
|
466 | +if ( ! function_exists('is_give_tag')) { |
|
467 | 467 | |
468 | 468 | /** |
469 | 469 | * is_give_tag |
@@ -478,12 +478,12 @@ discard block |
||
478 | 478 | * |
479 | 479 | * @return bool |
480 | 480 | */ |
481 | - function is_give_tag( $term = '' ) { |
|
482 | - return is_tax( 'give_forms_tag', $term ); |
|
481 | + function is_give_tag($term = '') { |
|
482 | + return is_tax('give_forms_tag', $term); |
|
483 | 483 | } |
484 | 484 | } |
485 | 485 | |
486 | -if ( ! function_exists( 'is_give_taxonomy' ) ) { |
|
486 | +if ( ! function_exists('is_give_taxonomy')) { |
|
487 | 487 | |
488 | 488 | /** |
489 | 489 | * is_give_taxonomy |
@@ -495,6 +495,6 @@ discard block |
||
495 | 495 | * @return bool |
496 | 496 | */ |
497 | 497 | function is_give_taxonomy() { |
498 | - return is_tax( get_object_taxonomies( 'give_form' ) ); |
|
498 | + return is_tax(get_object_taxonomies('give_form')); |
|
499 | 499 | } |
500 | 500 | } |
@@ -689,7 +689,7 @@ |
||
689 | 689 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
690 | 690 | esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
691 | 691 | ); |
692 | - }else{ |
|
692 | + } else{ |
|
693 | 693 | $messages[$subscription['id']] = sprintf( |
694 | 694 | __( 'You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
695 | 695 | human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ), |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @access private |
220 | 220 | * @since 1.0 |
221 | 221 | * |
222 | - * @return bool |
|
222 | + * @return false|null |
|
223 | 223 | */ |
224 | 224 | public function auto_updater() { |
225 | 225 | |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | * @access public |
476 | 476 | * @since 1.7 |
477 | 477 | * |
478 | - * @return bool|void |
|
478 | + * @return false|null |
|
479 | 479 | */ |
480 | 480 | public function weekly_license_check() { |
481 | 481 | |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | * @access public |
528 | 528 | * @since 1.7 |
529 | 529 | * |
530 | - * @return bool|void |
|
530 | + * @return false|null |
|
531 | 531 | */ |
532 | 532 | public function weekly_subscription_check() { |
533 | 533 | |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | * @access private |
608 | 608 | * @since 1.7 |
609 | 609 | * |
610 | - * @return bool|void |
|
610 | + * @return false|null |
|
611 | 611 | */ |
612 | 612 | private function __single_subscription_check() { |
613 | 613 | // Do not fire if license key is not set. |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | * @access private |
803 | 803 | * @since 1.7 |
804 | 804 | * |
805 | - * @return void|bool |
|
805 | + * @return false|null |
|
806 | 806 | */ |
807 | 807 | private function __remove_license_key_from_subscriptions(){ |
808 | 808 | $subscriptions = get_option( 'give_subscriptions', array() ); |
@@ -10,11 +10,11 @@ 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 | |
17 | -if ( ! class_exists( 'Give_License' ) ) : |
|
17 | +if ( ! class_exists('Give_License')) : |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Give_License Class |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @var string |
105 | 105 | */ |
106 | - private $api_url = 'https://givewp.com/edd-sl-api/'; |
|
106 | + private $api_url = 'https://givewp.com/edd-sl-api/'; |
|
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Account URL |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @var null|string |
115 | 115 | */ |
116 | - private $account_url = 'https://givewp.com/my-account/'; |
|
116 | + private $account_url = 'https://givewp.com/my-account/'; |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Ccheckout URL |
@@ -142,19 +142,19 @@ discard block |
||
142 | 142 | * @param string $_checkout_url |
143 | 143 | * @param string $_account_url |
144 | 144 | */ |
145 | - public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) { |
|
145 | + public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) { |
|
146 | 146 | $give_options = give_get_settings(); |
147 | 147 | |
148 | 148 | $this->file = $_file; |
149 | 149 | $this->item_name = $_item_name; |
150 | - $this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) ); |
|
150 | + $this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name))); |
|
151 | 151 | $this->version = $_version; |
152 | - $this->license = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : ''; |
|
153 | - $this->license_data = get_option( $this->item_shortname . '_license_active' ); |
|
152 | + $this->license = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : ''; |
|
153 | + $this->license_data = get_option($this->item_shortname.'_license_active'); |
|
154 | 154 | $this->author = $_author; |
155 | - $this->api_url = is_null( $_api_url ) ? $this->api_url : $_api_url; |
|
156 | - $this->checkout_url = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url; |
|
157 | - $this->account_url = is_null( $_account_url ) ? $this->account_url : $_account_url; |
|
155 | + $this->api_url = is_null($_api_url) ? $this->api_url : $_api_url; |
|
156 | + $this->checkout_url = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url; |
|
157 | + $this->account_url = is_null($_account_url) ? $this->account_url : $_account_url; |
|
158 | 158 | |
159 | 159 | // Setup hooks |
160 | 160 | $this->includes(); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @return void |
174 | 174 | */ |
175 | 175 | private function includes() { |
176 | - if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
176 | + if ( ! class_exists('EDD_SL_Plugin_Updater')) { |
|
177 | 177 | require_once 'admin/EDD_SL_Plugin_Updater.php'; |
178 | 178 | } |
179 | 179 | } |
@@ -191,26 +191,26 @@ discard block |
||
191 | 191 | private function hooks() { |
192 | 192 | |
193 | 193 | // Register settings |
194 | - add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 ); |
|
194 | + add_filter('give_settings_licenses', array($this, 'settings'), 1); |
|
195 | 195 | |
196 | 196 | // Activate license key on settings save |
197 | - add_action( 'admin_init', array( $this, 'activate_license' ) ); |
|
197 | + add_action('admin_init', array($this, 'activate_license')); |
|
198 | 198 | |
199 | 199 | // Deactivate license key |
200 | - add_action( 'admin_init', array( $this, 'deactivate_license' ) ); |
|
200 | + add_action('admin_init', array($this, 'deactivate_license')); |
|
201 | 201 | |
202 | 202 | // Updater |
203 | - add_action( 'admin_init', array( $this, 'auto_updater' ), 0 ); |
|
203 | + add_action('admin_init', array($this, 'auto_updater'), 0); |
|
204 | 204 | |
205 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
205 | + add_action('admin_notices', array($this, 'notices')); |
|
206 | 206 | |
207 | 207 | // Check license weekly. |
208 | - add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_license_check' ) ); |
|
209 | - add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_license_check' ) ); |
|
208 | + add_action('give_weekly_scheduled_events', array($this, 'weekly_license_check')); |
|
209 | + add_action('give_validate_license_when_site_migrated', array($this, 'weekly_license_check')); |
|
210 | 210 | |
211 | 211 | // Check subscription weekly. |
212 | - add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_subscription_check' ) ); |
|
213 | - add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_subscription_check' ) ); |
|
212 | + add_action('give_weekly_scheduled_events', array($this, 'weekly_subscription_check')); |
|
213 | + add_action('give_validate_license_when_site_migrated', array($this, 'weekly_subscription_check')); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function auto_updater() { |
225 | 225 | |
226 | - if ( ! $this->is_valid_license() ) { |
|
226 | + if ( ! $this->is_valid_license()) { |
|
227 | 227 | return false; |
228 | 228 | } |
229 | 229 | |
@@ -252,16 +252,16 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @return array License settings. |
254 | 254 | */ |
255 | - public function settings( $settings ) { |
|
255 | + public function settings($settings) { |
|
256 | 256 | |
257 | 257 | $give_license_settings = array( |
258 | 258 | array( |
259 | 259 | 'name' => $this->item_name, |
260 | - 'id' => $this->item_shortname . '_license_key', |
|
260 | + 'id' => $this->item_shortname.'_license_key', |
|
261 | 261 | 'desc' => '', |
262 | 262 | 'type' => 'license_key', |
263 | 263 | 'options' => array( |
264 | - 'license' => get_option( $this->item_shortname . '_license_active' ), |
|
264 | + 'license' => get_option($this->item_shortname.'_license_active'), |
|
265 | 265 | 'shortname' => $this->item_shortname, |
266 | 266 | 'item_name' => $this->item_name, |
267 | 267 | 'api_url' => $this->api_url, |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | ) |
273 | 273 | ); |
274 | 274 | |
275 | - return array_merge( $settings, $give_license_settings ); |
|
275 | + return array_merge($settings, $give_license_settings); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -287,18 +287,18 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @return array License settings content. |
289 | 289 | */ |
290 | - public function license_settings_content( $settings ) { |
|
290 | + public function license_settings_content($settings) { |
|
291 | 291 | |
292 | 292 | $give_license_settings = array( |
293 | 293 | array( |
294 | - 'name' => esc_html__( 'Add-on Licenses', 'give' ), |
|
294 | + 'name' => esc_html__('Add-on Licenses', 'give'), |
|
295 | 295 | 'desc' => '<hr>', |
296 | 296 | 'type' => 'give_title', |
297 | 297 | 'id' => 'give_title' |
298 | 298 | ), |
299 | 299 | ); |
300 | 300 | |
301 | - return array_merge( $settings, $give_license_settings ); |
|
301 | + return array_merge($settings, $give_license_settings); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -313,37 +313,37 @@ discard block |
||
313 | 313 | */ |
314 | 314 | public function activate_license() { |
315 | 315 | // Bailout: Check if license key set of not. |
316 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
316 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
317 | 317 | return; |
318 | 318 | } |
319 | 319 | |
320 | 320 | // Security check. |
321 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
321 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
322 | 322 | |
323 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
323 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
324 | 324 | |
325 | 325 | } |
326 | 326 | |
327 | 327 | // Check if user have correct permissions. |
328 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
328 | + if ( ! current_user_can('manage_give_settings')) { |
|
329 | 329 | return; |
330 | 330 | } |
331 | 331 | |
332 | 332 | // Allow third party addon developers to handle license activation. |
333 | - if( $this->__is_third_party_addon() ){ |
|
334 | - do_action( 'give_activate_license', $this ); |
|
333 | + if ($this->__is_third_party_addon()) { |
|
334 | + do_action('give_activate_license', $this); |
|
335 | 335 | return; |
336 | 336 | } |
337 | 337 | |
338 | 338 | // Delete previous license setting if a empty license key submitted. |
339 | - if ( empty( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
340 | - delete_option( $this->item_shortname . '_license_active' ); |
|
339 | + if (empty($_POST[$this->item_shortname.'_license_key'])) { |
|
340 | + delete_option($this->item_shortname.'_license_active'); |
|
341 | 341 | return; |
342 | 342 | } |
343 | 343 | |
344 | 344 | // Do not simultaneously activate any addon if user want to deactivate any addon. |
345 | - foreach ( $_POST as $key => $value ) { |
|
346 | - if ( false !== strpos( $key, 'license_key_deactivate' ) ) { |
|
345 | + foreach ($_POST as $key => $value) { |
|
346 | + if (false !== strpos($key, 'license_key_deactivate')) { |
|
347 | 347 | // Don't activate a key when deactivating a different key |
348 | 348 | return; |
349 | 349 | } |
@@ -351,15 +351,15 @@ discard block |
||
351 | 351 | |
352 | 352 | |
353 | 353 | // Check if plugin previously installed. |
354 | - if ( $this->is_valid_license() ) { |
|
354 | + if ($this->is_valid_license()) { |
|
355 | 355 | return; |
356 | 356 | } |
357 | 357 | |
358 | 358 | // Get license key. |
359 | - $license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] ); |
|
359 | + $license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']); |
|
360 | 360 | |
361 | 361 | // Bailout. |
362 | - if( empty( $license ) ) { |
|
362 | + if (empty($license)) { |
|
363 | 363 | return; |
364 | 364 | } |
365 | 365 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $api_params = array( |
371 | 371 | 'edd_action' => 'activate_license', //never change from "edd_" to "give_"! |
372 | 372 | 'license' => $license, |
373 | - 'item_name' => urlencode( $this->item_name ), |
|
373 | + 'item_name' => urlencode($this->item_name), |
|
374 | 374 | 'url' => home_url() |
375 | 375 | ); |
376 | 376 | |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | ); |
386 | 386 | |
387 | 387 | // Make sure there are no errors |
388 | - if ( is_wp_error( $response ) ) { |
|
388 | + if (is_wp_error($response)) { |
|
389 | 389 | return; |
390 | 390 | } |
391 | 391 | |
392 | 392 | // Tell WordPress to look for updates |
393 | - set_site_transient( 'update_plugins', null ); |
|
393 | + set_site_transient('update_plugins', null); |
|
394 | 394 | |
395 | 395 | // Decode license data |
396 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
397 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
396 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
397 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
398 | 398 | |
399 | 399 | // Check subscription for license key and store this to db (if any). |
400 | 400 | $this->__single_subscription_check(); |
@@ -412,34 +412,34 @@ discard block |
||
412 | 412 | */ |
413 | 413 | public function deactivate_license() { |
414 | 414 | |
415 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
415 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
416 | 416 | return; |
417 | 417 | } |
418 | 418 | |
419 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
419 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
420 | 420 | |
421 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
421 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
422 | 422 | |
423 | 423 | } |
424 | 424 | |
425 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
425 | + if ( ! current_user_can('manage_give_settings')) { |
|
426 | 426 | return; |
427 | 427 | } |
428 | 428 | |
429 | 429 | // Allow third party addon developers to handle license deactivation. |
430 | - if( $this->__is_third_party_addon() ){ |
|
431 | - do_action( 'give_deactivate_license', $this ); |
|
430 | + if ($this->__is_third_party_addon()) { |
|
431 | + do_action('give_deactivate_license', $this); |
|
432 | 432 | return; |
433 | 433 | } |
434 | 434 | |
435 | 435 | // Run on deactivate button press |
436 | - if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) { |
|
436 | + if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) { |
|
437 | 437 | |
438 | 438 | // Data to send to the API |
439 | 439 | $api_params = array( |
440 | 440 | 'edd_action' => 'deactivate_license', //never change from "edd_" to "give_"! |
441 | 441 | 'license' => $this->license, |
442 | - 'item_name' => urlencode( $this->item_name ), |
|
442 | + 'item_name' => urlencode($this->item_name), |
|
443 | 443 | 'url' => home_url() |
444 | 444 | ); |
445 | 445 | |
@@ -454,15 +454,15 @@ discard block |
||
454 | 454 | ); |
455 | 455 | |
456 | 456 | // Make sure there are no errors |
457 | - if ( is_wp_error( $response ) ) { |
|
457 | + if (is_wp_error($response)) { |
|
458 | 458 | return; |
459 | 459 | } |
460 | 460 | |
461 | 461 | // Decode the license data |
462 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
462 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
463 | 463 | |
464 | 464 | // Remove license data. |
465 | - delete_option( $this->item_shortname . '_license_active' ); |
|
465 | + delete_option($this->item_shortname.'_license_active'); |
|
466 | 466 | |
467 | 467 | // Remove license key from subscriptions if exist. |
468 | 468 | $this->__remove_license_key_from_subscriptions(); |
@@ -479,18 +479,18 @@ discard block |
||
479 | 479 | */ |
480 | 480 | public function weekly_license_check() { |
481 | 481 | |
482 | - if( ! empty( $_POST['give_settings'] ) ) { |
|
482 | + if ( ! empty($_POST['give_settings'])) { |
|
483 | 483 | // Don't fire when saving settings |
484 | 484 | return false; |
485 | 485 | } |
486 | 486 | |
487 | - if( empty( $this->license ) ) { |
|
487 | + if (empty($this->license)) { |
|
488 | 488 | return false; |
489 | 489 | } |
490 | 490 | |
491 | 491 | // Allow third party addon developers to handle their license check. |
492 | - if( $this->__is_third_party_addon() ){ |
|
493 | - do_action( 'give_weekly_license_check', $this ); |
|
492 | + if ($this->__is_third_party_addon()) { |
|
493 | + do_action('give_weekly_license_check', $this); |
|
494 | 494 | return false; |
495 | 495 | } |
496 | 496 | |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | $api_params = array( |
499 | 499 | 'edd_action'=> 'check_license', |
500 | 500 | 'license' => $this->license, |
501 | - 'item_name' => urlencode( $this->item_name ), |
|
501 | + 'item_name' => urlencode($this->item_name), |
|
502 | 502 | 'url' => home_url() |
503 | 503 | ); |
504 | 504 | |
@@ -513,12 +513,12 @@ discard block |
||
513 | 513 | ); |
514 | 514 | |
515 | 515 | // Make sure the response came back okay. |
516 | - if ( is_wp_error( $response ) ) { |
|
516 | + if (is_wp_error($response)) { |
|
517 | 517 | return false; |
518 | 518 | } |
519 | 519 | |
520 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
521 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
520 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
521 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -531,24 +531,24 @@ discard block |
||
531 | 531 | */ |
532 | 532 | public function weekly_subscription_check() { |
533 | 533 | |
534 | - if( ! empty( $_POST['give_settings'] ) ) { |
|
534 | + if ( ! empty($_POST['give_settings'])) { |
|
535 | 535 | // Don't fire when saving settings |
536 | 536 | return false; |
537 | 537 | } |
538 | 538 | |
539 | 539 | // Remove old subscription data. |
540 | - if( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp' , 1 ) ){ |
|
541 | - delete_option( 'give_subscriptions' ); |
|
542 | - update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp' , 1 ) ) ); |
|
540 | + if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) { |
|
541 | + delete_option('give_subscriptions'); |
|
542 | + update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1))); |
|
543 | 543 | } |
544 | 544 | |
545 | - if( empty( $this->license ) ) { |
|
545 | + if (empty($this->license)) { |
|
546 | 546 | return false; |
547 | 547 | } |
548 | 548 | |
549 | 549 | // Allow third party addon developers to handle there subscription check. |
550 | - if( $this->__is_third_party_addon() ){ |
|
551 | - do_action( 'give_weekly_subscription_check', $this ); |
|
550 | + if ($this->__is_third_party_addon()) { |
|
551 | + do_action('give_weekly_subscription_check', $this); |
|
552 | 552 | return false; |
553 | 553 | } |
554 | 554 | |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | // This is custom feature to check subscriptions. |
563 | 563 | 'edd_action'=> 'check_subscription', |
564 | 564 | 'license' => $this->license, |
565 | - 'item_name' => urlencode( $this->item_name ), |
|
565 | + 'item_name' => urlencode($this->item_name), |
|
566 | 566 | 'url' => home_url() |
567 | 567 | ); |
568 | 568 | |
@@ -577,27 +577,27 @@ discard block |
||
577 | 577 | ); |
578 | 578 | |
579 | 579 | // Make sure the response came back okay. |
580 | - if ( is_wp_error( $response ) ) { |
|
580 | + if (is_wp_error($response)) { |
|
581 | 581 | return false; |
582 | 582 | } |
583 | 583 | |
584 | - $subscription_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
584 | + $subscription_data = json_decode(wp_remote_retrieve_body($response), true); |
|
585 | 585 | |
586 | - if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
587 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
586 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
587 | + $subscriptions = get_option('give_subscriptions', array()); |
|
588 | 588 | |
589 | 589 | // Update subscription data only if subscription does not exist already. |
590 | - if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) { |
|
591 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
592 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
590 | + if ( ! array_key_exists($subscription_data['id'], $subscriptions)) { |
|
591 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
592 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | // Store licenses for subscription. |
596 | - if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
597 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
596 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
597 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
598 | 598 | } |
599 | 599 | |
600 | - update_option( 'give_subscriptions', $subscriptions ); |
|
600 | + update_option('give_subscriptions', $subscriptions); |
|
601 | 601 | } |
602 | 602 | } |
603 | 603 | |
@@ -611,11 +611,11 @@ discard block |
||
611 | 611 | */ |
612 | 612 | private function __single_subscription_check() { |
613 | 613 | // Do not fire if license key is not set. |
614 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
614 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
615 | 615 | return false; |
616 | 616 | } |
617 | 617 | |
618 | - if( empty( $this->license ) ) { |
|
618 | + if (empty($this->license)) { |
|
619 | 619 | return false; |
620 | 620 | } |
621 | 621 | |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | // This is custom feature to check subscriptions. |
627 | 627 | 'edd_action'=> 'check_subscription', |
628 | 628 | 'license' => $this->license, |
629 | - 'item_name' => urlencode( $this->item_name ), |
|
629 | + 'item_name' => urlencode($this->item_name), |
|
630 | 630 | 'url' => home_url() |
631 | 631 | ); |
632 | 632 | |
@@ -641,27 +641,27 @@ discard block |
||
641 | 641 | ); |
642 | 642 | |
643 | 643 | // Make sure the response came back okay. |
644 | - if ( is_wp_error( $response ) ) { |
|
644 | + if (is_wp_error($response)) { |
|
645 | 645 | return false; |
646 | 646 | } |
647 | 647 | |
648 | - $subscription_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
648 | + $subscription_data = json_decode(wp_remote_retrieve_body($response), true); |
|
649 | 649 | |
650 | - if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
651 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
650 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
651 | + $subscriptions = get_option('give_subscriptions', array()); |
|
652 | 652 | |
653 | 653 | // Update subscription data only if subscription does not exist already. |
654 | - if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) { |
|
655 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
656 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
654 | + if ( ! array_key_exists($subscription_data['id'], $subscriptions)) { |
|
655 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
656 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | // Store licenses for subscription. |
660 | - if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
661 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
660 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
661 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
662 | 662 | } |
663 | 663 | |
664 | - update_option( 'give_subscriptions', $subscriptions ); |
|
664 | + update_option('give_subscriptions', $subscriptions); |
|
665 | 665 | } |
666 | 666 | } |
667 | 667 | |
@@ -679,87 +679,87 @@ discard block |
||
679 | 679 | static $addon_license_key_in_subscriptions; |
680 | 680 | |
681 | 681 | // Set default value. |
682 | - $addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array(); |
|
682 | + $addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array(); |
|
683 | 683 | |
684 | - if( empty( $this->license ) ) { |
|
684 | + if (empty($this->license)) { |
|
685 | 685 | return; |
686 | 686 | } |
687 | 687 | |
688 | - if( ! current_user_can( 'manage_shop_settings' ) ) { |
|
688 | + if ( ! current_user_can('manage_shop_settings')) { |
|
689 | 689 | return; |
690 | 690 | } |
691 | 691 | |
692 | 692 | // Do not show licenses notices on license tab. |
693 | - if( ! empty( $_GET['tab'] ) && 'licenses' === $_GET['tab'] ) { |
|
693 | + if ( ! empty($_GET['tab']) && 'licenses' === $_GET['tab']) { |
|
694 | 694 | return; |
695 | 695 | } |
696 | 696 | |
697 | 697 | $messages = array(); |
698 | 698 | |
699 | 699 | // Get subscriptions. |
700 | - $subscriptions = get_option( 'give_subscriptions' ); |
|
700 | + $subscriptions = get_option('give_subscriptions'); |
|
701 | 701 | |
702 | 702 | // Show subscription messages. |
703 | - if( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) { |
|
703 | + if ( ! empty($subscriptions) && ! $showed_subscriptions_message) { |
|
704 | 704 | |
705 | - foreach ( $subscriptions as $subscription ) { |
|
705 | + foreach ($subscriptions as $subscription) { |
|
706 | 706 | // Subscription expires timestamp. |
707 | - $subscription_expires = strtotime( $subscription['expires'] ); |
|
707 | + $subscription_expires = strtotime($subscription['expires']); |
|
708 | 708 | |
709 | 709 | // Start showing subscriptions message before one week of renewal date. |
710 | - if( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) { |
|
710 | + if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) { |
|
711 | 711 | continue; |
712 | 712 | } |
713 | 713 | |
714 | 714 | // Check if subscription message already exist in messages. |
715 | - if( array_key_exists( $subscription['id'], $messages ) ) { |
|
715 | + if (array_key_exists($subscription['id'], $messages)) { |
|
716 | 716 | continue; |
717 | 717 | } |
718 | 718 | |
719 | - if( ( ! $this->__is_notice_dismissed( $subscription['id'] ) && 'active' !== $subscription['status'] ) ) { |
|
719 | + if (( ! $this->__is_notice_dismissed($subscription['id']) && 'active' !== $subscription['status'])) { |
|
720 | 720 | |
721 | - if( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {// Check if license already expired. |
|
721 | + if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {// Check if license already expired. |
|
722 | 722 | $messages[$subscription['id']] = sprintf( |
723 | - __( 'You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
|
724 | - urldecode( $subscription['invoice_url'] ), |
|
723 | + __('You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'), |
|
724 | + urldecode($subscription['invoice_url']), |
|
725 | 725 | $subscription['payment_id'], |
726 | 726 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
727 | - esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
|
727 | + esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'])) |
|
728 | 728 | ); |
729 | - }else{ |
|
729 | + } else { |
|
730 | 730 | $messages[$subscription['id']] = sprintf( |
731 | - __( 'You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
|
732 | - human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ), |
|
733 | - urldecode( $subscription['invoice_url'] ), |
|
731 | + __('You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'), |
|
732 | + human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])), |
|
733 | + urldecode($subscription['invoice_url']), |
|
734 | 734 | $subscription['payment_id'], |
735 | 735 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
736 | - esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
|
736 | + esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'])) |
|
737 | 737 | ); |
738 | 738 | } |
739 | 739 | } |
740 | 740 | |
741 | 741 | // Stop validation for these licencse keys. |
742 | - $addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] ); |
|
742 | + $addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']); |
|
743 | 743 | } |
744 | 744 | $showed_subscriptions_message = true; |
745 | 745 | } |
746 | 746 | |
747 | 747 | // Show non subscription addon messages. |
748 | - if( ! in_array( $this->license, $addon_license_key_in_subscriptions ) && ! $this->__is_notice_dismissed( 'general' ) && ! $this->is_valid_license() && empty( $showed_invalid_message ) ) { |
|
748 | + if ( ! in_array($this->license, $addon_license_key_in_subscriptions) && ! $this->__is_notice_dismissed('general') && ! $this->is_valid_license() && empty($showed_invalid_message)) { |
|
749 | 749 | |
750 | 750 | $messages['general'] = sprintf( |
751 | - __( 'You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ), |
|
752 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) |
|
751 | + __('You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'), |
|
752 | + admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses') |
|
753 | 753 | ); |
754 | 754 | $showed_invalid_message = true; |
755 | 755 | |
756 | 756 | } |
757 | 757 | |
758 | 758 | // Print messages. |
759 | - if( ! empty( $messages ) ) { |
|
760 | - foreach( $messages as $notice_id => $message ) { |
|
761 | - echo '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="' . esc_url( add_query_arg( '_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'] ) ) . '">'; |
|
762 | - echo '<p>' . $message . '</p>'; |
|
759 | + if ( ! empty($messages)) { |
|
760 | + foreach ($messages as $notice_id => $message) { |
|
761 | + echo '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="'.esc_url(add_query_arg('_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'])).'">'; |
|
762 | + echo '<p>'.$message.'</p>'; |
|
763 | 763 | echo '</div>'; |
764 | 764 | } |
765 | 765 | } |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | * @return bool |
775 | 775 | */ |
776 | 776 | public function is_valid_license() { |
777 | - if( apply_filters( 'give_is_valid_license' , ( is_object( $this->license_data ) && ! empty( $this->license_data ) && property_exists( $this->license_data, 'license' )&& 'valid' === $this->license_data->license ) ) ) { |
|
777 | + if (apply_filters('give_is_valid_license', (is_object($this->license_data) && ! empty($this->license_data) && property_exists($this->license_data, 'license') && 'valid' === $this->license_data->license))) { |
|
778 | 778 | return true; |
779 | 779 | } |
780 | 780 | |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | * @return bool |
791 | 791 | */ |
792 | 792 | private function __is_third_party_addon() { |
793 | - return ( false === strpos( $this->api_url, 'givewp.com/' ) ); |
|
793 | + return (false === strpos($this->api_url, 'givewp.com/')); |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | /** |
@@ -804,26 +804,26 @@ discard block |
||
804 | 804 | * |
805 | 805 | * @return void|bool |
806 | 806 | */ |
807 | - private function __remove_license_key_from_subscriptions(){ |
|
808 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
807 | + private function __remove_license_key_from_subscriptions() { |
|
808 | + $subscriptions = get_option('give_subscriptions', array()); |
|
809 | 809 | |
810 | 810 | // Bailout. |
811 | - if( empty( $this->license ) ) { |
|
811 | + if (empty($this->license)) { |
|
812 | 812 | return false; |
813 | 813 | } |
814 | 814 | |
815 | - if( ! empty( $subscriptions ) ) { |
|
816 | - foreach ( $subscriptions as $subscription_id => $subscription ) { |
|
817 | - $license_index = array_search( $this->license, $subscription['licenses'] ); |
|
818 | - if( false !== $license_index ) { |
|
815 | + if ( ! empty($subscriptions)) { |
|
816 | + foreach ($subscriptions as $subscription_id => $subscription) { |
|
817 | + $license_index = array_search($this->license, $subscription['licenses']); |
|
818 | + if (false !== $license_index) { |
|
819 | 819 | // Remove license key. |
820 | - unset( $subscriptions[ $subscription_id ]['licenses'][$license_index] ); |
|
820 | + unset($subscriptions[$subscription_id]['licenses'][$license_index]); |
|
821 | 821 | |
822 | 822 | // Rearrange license keys. |
823 | - $subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] ); |
|
823 | + $subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']); |
|
824 | 824 | |
825 | 825 | // Update subscription information. |
826 | - update_option( 'give_subscriptions', $subscriptions ); |
|
826 | + update_option('give_subscriptions', $subscriptions); |
|
827 | 827 | break; |
828 | 828 | } |
829 | 829 | } |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | * |
839 | 839 | * @return void |
840 | 840 | */ |
841 | - private function __remove_license_notices_show_blocker(){ |
|
841 | + private function __remove_license_notices_show_blocker() { |
|
842 | 842 | global $wpdb; |
843 | 843 | |
844 | 844 | // Delete permanent notice blocker. |
@@ -876,18 +876,18 @@ discard block |
||
876 | 876 | * |
877 | 877 | * @return bool |
878 | 878 | */ |
879 | - private function __is_notice_dismissed( $notice_id ){ |
|
879 | + private function __is_notice_dismissed($notice_id) { |
|
880 | 880 | $current_user = wp_get_current_user(); |
881 | 881 | $is_notice_dismissed = false; |
882 | 882 | |
883 | 883 | // Ge is notice dismissed permanently. |
884 | - $already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) ) |
|
884 | + $already_dismiss_notices = ($already_dismiss_notices = get_user_meta($current_user->ID, '_give_hide_license_notices_permanently', true)) |
|
885 | 885 | ? $already_dismiss_notices |
886 | 886 | : array(); |
887 | 887 | |
888 | 888 | |
889 | - if( in_array( $notice_id, $already_dismiss_notices ) || get_transient( "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}" ) ) { |
|
890 | - $is_notice_dismissed = true; |
|
889 | + if (in_array($notice_id, $already_dismiss_notices) || get_transient("_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}")) { |
|
890 | + $is_notice_dismissed = true; |
|
891 | 891 | } |
892 | 892 | |
893 | 893 | return $is_notice_dismissed; |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | * @access public |
891 | 891 | * |
892 | 892 | * @param string $meta_key Metadata name. Default is empty. |
893 | - * @param mixed $meta_value Metadata value. |
|
893 | + * @param string $meta_value Metadata value. |
|
894 | 894 | * @param bool $unique Optional. Whether the same key should not be added. Default is false. |
895 | 895 | * |
896 | 896 | * @return bool False for failure. True for success. |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | * @access public |
923 | 923 | * |
924 | 924 | * @param string $meta_key Metadata name. Default is empty. |
925 | - * @param mixed $meta_value Optional. Metadata value. Default is empty. |
|
925 | + * @param string $meta_value Optional. Metadata value. Default is empty. |
|
926 | 926 | * |
927 | 927 | * @return bool False for failure. True for success. |
928 | 928 | */ |
@@ -714,12 +714,12 @@ discard block |
||
714 | 714 | |
715 | 715 | /** |
716 | 716 | * Decrease/Increase a customer's lifetime value. |
717 | - * |
|
718 | - * This function will update donation stat on basis of current amount and new amount donation difference. |
|
719 | - * Difference value can positive or negative. Negative value will decrease user donation stat while positive value increase donation stat. |
|
720 | - * |
|
717 | + * |
|
718 | + * This function will update donation stat on basis of current amount and new amount donation difference. |
|
719 | + * Difference value can positive or negative. Negative value will decrease user donation stat while positive value increase donation stat. |
|
720 | + * |
|
721 | 721 | * @since 1.0 |
722 | - * @access public |
|
722 | + * @access public |
|
723 | 723 | * |
724 | 724 | * @param float $curr_amount Current Donation amount. |
725 | 725 | * @param float $new_amount New (changed) Donation amount. |
@@ -727,35 +727,35 @@ discard block |
||
727 | 727 | * @return mixed If successful, the new donation stat value, otherwise false. |
728 | 728 | */ |
729 | 729 | public function update_donation_value( $curr_amount, $new_amount ) { |
730 | - /** |
|
731 | - * Payment total difference value can be: |
|
732 | - * zero (in case amount not change) |
|
733 | - * or -ve (in case amount decrease) |
|
734 | - * or +ve (in case amount increase) |
|
735 | - */ |
|
736 | - $payment_total_diff = $new_amount - $curr_amount; |
|
737 | - |
|
738 | - // We do not need to update donation stat if donation did not change. |
|
739 | - if( ! $payment_total_diff ) { |
|
740 | - return false; |
|
741 | - } |
|
742 | - |
|
743 | - |
|
744 | - if( $payment_total_diff > 0 ) { |
|
745 | - $this->increase_value( $payment_total_diff ); |
|
746 | - } else { |
|
747 | - // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
|
748 | - $this->decrease_value( -$payment_total_diff ); |
|
749 | - } |
|
750 | - |
|
751 | - return $this->purchase_value; |
|
730 | + /** |
|
731 | + * Payment total difference value can be: |
|
732 | + * zero (in case amount not change) |
|
733 | + * or -ve (in case amount decrease) |
|
734 | + * or +ve (in case amount increase) |
|
735 | + */ |
|
736 | + $payment_total_diff = $new_amount - $curr_amount; |
|
737 | + |
|
738 | + // We do not need to update donation stat if donation did not change. |
|
739 | + if( ! $payment_total_diff ) { |
|
740 | + return false; |
|
741 | + } |
|
742 | + |
|
743 | + |
|
744 | + if( $payment_total_diff > 0 ) { |
|
745 | + $this->increase_value( $payment_total_diff ); |
|
746 | + } else { |
|
747 | + // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
|
748 | + $this->decrease_value( -$payment_total_diff ); |
|
749 | + } |
|
750 | + |
|
751 | + return $this->purchase_value; |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | /** |
755 | 755 | * Get the parsed notes for a customer as an array. |
756 | 756 | * |
757 | 757 | * @since 1.0 |
758 | - * @access public |
|
758 | + * @access public |
|
759 | 759 | * |
760 | 760 | * @param int $length The number of notes to get. |
761 | 761 | * @param int $paged What note to start at. |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | * Get the total number of notes we have after parsing. |
781 | 781 | * |
782 | 782 | * @since 1.0 |
783 | - * @access public |
|
783 | + * @access public |
|
784 | 784 | * |
785 | 785 | * @return int The number of notes for the customer. |
786 | 786 | */ |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | * Add a note for the customer. |
798 | 798 | * |
799 | 799 | * @since 1.0 |
800 | - * @access public |
|
800 | + * @access public |
|
801 | 801 | * |
802 | 802 | * @param string $note The note to add. Default is empty. |
803 | 803 | * |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | * Get the notes column for the customer |
857 | 857 | * |
858 | 858 | * @since 1.0 |
859 | - * @access private |
|
859 | + * @access private |
|
860 | 860 | * |
861 | 861 | * @return string The Notes for the customer, non-parsed. |
862 | 862 | */ |
@@ -934,7 +934,7 @@ discard block |
||
934 | 934 | * Sanitize the data for update/create |
935 | 935 | * |
936 | 936 | * @since 1.0 |
937 | - * @access private |
|
937 | + * @access private |
|
938 | 938 | * |
939 | 939 | * @param array $data The data to sanitize. |
940 | 940 | * |
@@ -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 | |
@@ -144,29 +144,29 @@ discard block |
||
144 | 144 | * @param bool $_id_or_email |
145 | 145 | * @param bool $by_user_id |
146 | 146 | */ |
147 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
147 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
148 | 148 | |
149 | 149 | $this->db = new Give_DB_Customers; |
150 | 150 | |
151 | - if ( false === $_id_or_email || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) ) { |
|
151 | + if (false === $_id_or_email || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))) { |
|
152 | 152 | return false; |
153 | 153 | } |
154 | 154 | |
155 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
155 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
156 | 156 | |
157 | - if ( is_numeric( $_id_or_email ) ) { |
|
157 | + if (is_numeric($_id_or_email)) { |
|
158 | 158 | $field = $by_user_id ? 'user_id' : 'id'; |
159 | 159 | } else { |
160 | 160 | $field = 'email'; |
161 | 161 | } |
162 | 162 | |
163 | - $customer = $this->db->get_customer_by( $field, $_id_or_email ); |
|
163 | + $customer = $this->db->get_customer_by($field, $_id_or_email); |
|
164 | 164 | |
165 | - if ( empty( $customer ) || ! is_object( $customer ) ) { |
|
165 | + if (empty($customer) || ! is_object($customer)) { |
|
166 | 166 | return false; |
167 | 167 | } |
168 | 168 | |
169 | - $this->setup_customer( $customer ); |
|
169 | + $this->setup_customer($customer); |
|
170 | 170 | |
171 | 171 | } |
172 | 172 | |
@@ -182,15 +182,15 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return bool If the setup was successful or not. |
184 | 184 | */ |
185 | - private function setup_customer( $customer ) { |
|
185 | + private function setup_customer($customer) { |
|
186 | 186 | |
187 | - if ( ! is_object( $customer ) ) { |
|
187 | + if ( ! is_object($customer)) { |
|
188 | 188 | return false; |
189 | 189 | } |
190 | 190 | |
191 | - foreach ( $customer as $key => $value ) { |
|
191 | + foreach ($customer as $key => $value) { |
|
192 | 192 | |
193 | - switch ( $key ) { |
|
193 | + switch ($key) { |
|
194 | 194 | |
195 | 195 | case 'notes': |
196 | 196 | $this->$key = $this->get_notes(); |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | } |
206 | 206 | |
207 | 207 | // Get donor's all email including primary email. |
208 | - $this->emails = (array) $this->get_meta( 'additional_email', false ); |
|
209 | - $this->emails = array( 'primary' => $this->email ) + $this->emails; |
|
208 | + $this->emails = (array) $this->get_meta('additional_email', false); |
|
209 | + $this->emails = array('primary' => $this->email) + $this->emails; |
|
210 | 210 | |
211 | 211 | // Customer ID and email are the only things that are necessary, make sure they exist. |
212 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
212 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
213 | 213 | return true; |
214 | 214 | } |
215 | 215 | |
@@ -223,16 +223,16 @@ discard block |
||
223 | 223 | * @since 1.0 |
224 | 224 | * @access public |
225 | 225 | */ |
226 | - public function __get( $key ) { |
|
226 | + public function __get($key) { |
|
227 | 227 | |
228 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
228 | + if (method_exists($this, 'get_'.$key)) { |
|
229 | 229 | |
230 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
230 | + return call_user_func(array($this, 'get_'.$key)); |
|
231 | 231 | |
232 | 232 | } else { |
233 | 233 | |
234 | 234 | /* translators: %s: property key */ |
235 | - return new WP_Error( 'give-customer-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
235 | + return new WP_Error('give-customer-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
236 | 236 | |
237 | 237 | } |
238 | 238 | |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return bool|int False if not a valid creation, customer ID if user is found or valid creation. |
250 | 250 | */ |
251 | - public function create( $data = array() ) { |
|
251 | + public function create($data = array()) { |
|
252 | 252 | |
253 | - if ( $this->id != 0 || empty( $data ) ) { |
|
253 | + if ($this->id != 0 || empty($data)) { |
|
254 | 254 | return false; |
255 | 255 | } |
256 | 256 | |
@@ -258,15 +258,15 @@ discard block |
||
258 | 258 | 'payment_ids' => '' |
259 | 259 | ); |
260 | 260 | |
261 | - $args = wp_parse_args( $data, $defaults ); |
|
262 | - $args = $this->sanitize_columns( $args ); |
|
261 | + $args = wp_parse_args($data, $defaults); |
|
262 | + $args = $this->sanitize_columns($args); |
|
263 | 263 | |
264 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
264 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
265 | 265 | return false; |
266 | 266 | } |
267 | 267 | |
268 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
269 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
268 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
269 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -276,18 +276,18 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @param array $args Customer attributes. |
278 | 278 | */ |
279 | - do_action( 'give_customer_pre_create', $args ); |
|
279 | + do_action('give_customer_pre_create', $args); |
|
280 | 280 | |
281 | 281 | $created = false; |
282 | 282 | |
283 | 283 | // The DB class 'add' implies an update if the customer being asked to be created already exists |
284 | - if ( $this->db->add( $data ) ) { |
|
284 | + if ($this->db->add($data)) { |
|
285 | 285 | |
286 | 286 | // We've successfully added/updated the customer, reset the class vars with the new data |
287 | - $customer = $this->db->get_customer_by( 'email', $args['email'] ); |
|
287 | + $customer = $this->db->get_customer_by('email', $args['email']); |
|
288 | 288 | |
289 | 289 | // Setup the customer data with the values from DB |
290 | - $this->setup_customer( $customer ); |
|
290 | + $this->setup_customer($customer); |
|
291 | 291 | |
292 | 292 | $created = $this->id; |
293 | 293 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * customer ID if user is found or valid creation. |
302 | 302 | * @param array $args Customer attributes. |
303 | 303 | */ |
304 | - do_action( 'give_customer_post_create', $created, $args ); |
|
304 | + do_action('give_customer_post_create', $created, $args); |
|
305 | 305 | |
306 | 306 | return $created; |
307 | 307 | |
@@ -317,13 +317,13 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @return bool If the update was successful or not. |
319 | 319 | */ |
320 | - public function update( $data = array() ) { |
|
320 | + public function update($data = array()) { |
|
321 | 321 | |
322 | - if ( empty( $data ) ) { |
|
322 | + if (empty($data)) { |
|
323 | 323 | return false; |
324 | 324 | } |
325 | 325 | |
326 | - $data = $this->sanitize_columns( $data ); |
|
326 | + $data = $this->sanitize_columns($data); |
|
327 | 327 | |
328 | 328 | /** |
329 | 329 | * Fires before updating customers. |
@@ -333,14 +333,14 @@ discard block |
||
333 | 333 | * @param int $customer_id Customer id. |
334 | 334 | * @param array $data Customer attributes. |
335 | 335 | */ |
336 | - do_action( 'give_customer_pre_update', $this->id, $data ); |
|
336 | + do_action('give_customer_pre_update', $this->id, $data); |
|
337 | 337 | |
338 | 338 | $updated = false; |
339 | 339 | |
340 | - if ( $this->db->update( $this->id, $data ) ) { |
|
340 | + if ($this->db->update($this->id, $data)) { |
|
341 | 341 | |
342 | - $customer = $this->db->get_customer_by( 'id', $this->id ); |
|
343 | - $this->setup_customer( $customer ); |
|
342 | + $customer = $this->db->get_customer_by('id', $this->id); |
|
343 | + $this->setup_customer($customer); |
|
344 | 344 | |
345 | 345 | $updated = true; |
346 | 346 | } |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | * @param int $customer_id Customer id. |
355 | 355 | * @param array $data Customer attributes. |
356 | 356 | */ |
357 | - do_action( 'give_customer_post_update', $updated, $this->id, $data ); |
|
357 | + do_action('give_customer_post_update', $updated, $this->id, $data); |
|
358 | 358 | |
359 | 359 | return $updated; |
360 | 360 | } |
@@ -372,27 +372,27 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @return bool If the attachment was successfuly. |
374 | 374 | */ |
375 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
375 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
376 | 376 | |
377 | - if ( empty( $payment_id ) ) { |
|
377 | + if (empty($payment_id)) { |
|
378 | 378 | return false; |
379 | 379 | } |
380 | 380 | |
381 | - if ( empty( $this->payment_ids ) ) { |
|
381 | + if (empty($this->payment_ids)) { |
|
382 | 382 | |
383 | 383 | $new_payment_ids = $payment_id; |
384 | 384 | |
385 | 385 | } else { |
386 | 386 | |
387 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
387 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
388 | 388 | |
389 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
389 | + if (in_array($payment_id, $payment_ids)) { |
|
390 | 390 | $update_stats = false; |
391 | 391 | } |
392 | 392 | |
393 | 393 | $payment_ids[] = $payment_id; |
394 | 394 | |
395 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
395 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
396 | 396 | |
397 | 397 | } |
398 | 398 | |
@@ -404,20 +404,20 @@ discard block |
||
404 | 404 | * @param int $payment_id Payment id. |
405 | 405 | * @param int $customer_id Customer id. |
406 | 406 | */ |
407 | - do_action( 'give_customer_pre_attach_payment', $payment_id, $this->id ); |
|
407 | + do_action('give_customer_pre_attach_payment', $payment_id, $this->id); |
|
408 | 408 | |
409 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
409 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
410 | 410 | |
411 | - if ( $payment_added ) { |
|
411 | + if ($payment_added) { |
|
412 | 412 | |
413 | 413 | $this->payment_ids = $new_payment_ids; |
414 | 414 | |
415 | 415 | // We added this payment successfully, increment the stats |
416 | - if ( $update_stats ) { |
|
417 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
416 | + if ($update_stats) { |
|
417 | + $payment_amount = give_get_payment_amount($payment_id); |
|
418 | 418 | |
419 | - if ( ! empty( $payment_amount ) ) { |
|
420 | - $this->increase_value( $payment_amount ); |
|
419 | + if ( ! empty($payment_amount)) { |
|
420 | + $this->increase_value($payment_amount); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | $this->increase_purchase_count(); |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | * @param int $payment_id Payment id. |
435 | 435 | * @param int $customer_id Customer id. |
436 | 436 | */ |
437 | - do_action( 'give_customer_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
437 | + do_action('give_customer_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
438 | 438 | |
439 | 439 | return $payment_added; |
440 | 440 | } |
@@ -452,33 +452,33 @@ discard block |
||
452 | 452 | * |
453 | 453 | * @return boolean If the removal was successful. |
454 | 454 | */ |
455 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
455 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
456 | 456 | |
457 | - if ( empty( $payment_id ) ) { |
|
457 | + if (empty($payment_id)) { |
|
458 | 458 | return false; |
459 | 459 | } |
460 | 460 | |
461 | - $payment = new Give_Payment( $payment_id ); |
|
461 | + $payment = new Give_Payment($payment_id); |
|
462 | 462 | |
463 | - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { |
|
463 | + if ('publish' !== $payment->status && 'revoked' !== $payment->status) { |
|
464 | 464 | $update_stats = false; |
465 | 465 | } |
466 | 466 | |
467 | 467 | $new_payment_ids = ''; |
468 | 468 | |
469 | - if ( ! empty( $this->payment_ids ) ) { |
|
469 | + if ( ! empty($this->payment_ids)) { |
|
470 | 470 | |
471 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
471 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
472 | 472 | |
473 | - $pos = array_search( $payment_id, $payment_ids ); |
|
474 | - if ( false === $pos ) { |
|
473 | + $pos = array_search($payment_id, $payment_ids); |
|
474 | + if (false === $pos) { |
|
475 | 475 | return false; |
476 | 476 | } |
477 | 477 | |
478 | - unset( $payment_ids[ $pos ] ); |
|
479 | - $payment_ids = array_filter( $payment_ids ); |
|
478 | + unset($payment_ids[$pos]); |
|
479 | + $payment_ids = array_filter($payment_ids); |
|
480 | 480 | |
481 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
481 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
482 | 482 | |
483 | 483 | } |
484 | 484 | |
@@ -490,20 +490,20 @@ discard block |
||
490 | 490 | * @param int $payment_id Payment id. |
491 | 491 | * @param int $customer_id Customer id. |
492 | 492 | */ |
493 | - do_action( 'give_customer_pre_remove_payment', $payment_id, $this->id ); |
|
493 | + do_action('give_customer_pre_remove_payment', $payment_id, $this->id); |
|
494 | 494 | |
495 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
495 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
496 | 496 | |
497 | - if ( $payment_removed ) { |
|
497 | + if ($payment_removed) { |
|
498 | 498 | |
499 | 499 | $this->payment_ids = $new_payment_ids; |
500 | 500 | |
501 | - if ( $update_stats ) { |
|
501 | + if ($update_stats) { |
|
502 | 502 | // We removed this payment successfully, decrement the stats |
503 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
503 | + $payment_amount = give_get_payment_amount($payment_id); |
|
504 | 504 | |
505 | - if ( ! empty( $payment_amount ) ) { |
|
506 | - $this->decrease_value( $payment_amount ); |
|
505 | + if ( ! empty($payment_amount)) { |
|
506 | + $this->decrease_value($payment_amount); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | $this->decrease_purchase_count(); |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | * @param int $payment_id Payment id. |
521 | 521 | * @param int $customer_id Customer id. |
522 | 522 | */ |
523 | - do_action( 'give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
523 | + do_action('give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
524 | 524 | |
525 | 525 | return $payment_removed; |
526 | 526 | |
@@ -536,10 +536,10 @@ discard block |
||
536 | 536 | * |
537 | 537 | * @return int The donation count. |
538 | 538 | */ |
539 | - public function increase_purchase_count( $count = 1 ) { |
|
539 | + public function increase_purchase_count($count = 1) { |
|
540 | 540 | |
541 | 541 | // Make sure it's numeric and not negative. |
542 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
542 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
543 | 543 | return false; |
544 | 544 | } |
545 | 545 | |
@@ -553,9 +553,9 @@ discard block |
||
553 | 553 | * @param int $count The number to increase by. |
554 | 554 | * @param int $customer_id Customer id. |
555 | 555 | */ |
556 | - do_action( 'give_customer_pre_increase_purchase_count', $count, $this->id ); |
|
556 | + do_action('give_customer_pre_increase_purchase_count', $count, $this->id); |
|
557 | 557 | |
558 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
558 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
559 | 559 | $this->purchase_count = $new_total; |
560 | 560 | } |
561 | 561 | |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | * @param int $count The number increased by. |
569 | 569 | * @param int $customer_id Customer id. |
570 | 570 | */ |
571 | - do_action( 'give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id ); |
|
571 | + do_action('give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id); |
|
572 | 572 | |
573 | 573 | return $this->purchase_count; |
574 | 574 | } |
@@ -583,16 +583,16 @@ discard block |
||
583 | 583 | * |
584 | 584 | * @return mixed If successful, the new count, otherwise false. |
585 | 585 | */ |
586 | - public function decrease_purchase_count( $count = 1 ) { |
|
586 | + public function decrease_purchase_count($count = 1) { |
|
587 | 587 | |
588 | 588 | // Make sure it's numeric and not negative |
589 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
589 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
590 | 590 | return false; |
591 | 591 | } |
592 | 592 | |
593 | 593 | $new_total = (int) $this->purchase_count - (int) $count; |
594 | 594 | |
595 | - if ( $new_total < 0 ) { |
|
595 | + if ($new_total < 0) { |
|
596 | 596 | $new_total = 0; |
597 | 597 | } |
598 | 598 | |
@@ -604,9 +604,9 @@ discard block |
||
604 | 604 | * @param int $count The number to decrease by. |
605 | 605 | * @param int $customer_id Customer id. |
606 | 606 | */ |
607 | - do_action( 'give_customer_pre_decrease_purchase_count', $count, $this->id ); |
|
607 | + do_action('give_customer_pre_decrease_purchase_count', $count, $this->id); |
|
608 | 608 | |
609 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
609 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
610 | 610 | $this->purchase_count = $new_total; |
611 | 611 | } |
612 | 612 | |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | * @param int $count The number decreased by. |
620 | 620 | * @param int $customer_id Customer id. |
621 | 621 | */ |
622 | - do_action( 'give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id ); |
|
622 | + do_action('give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id); |
|
623 | 623 | |
624 | 624 | return $this->purchase_count; |
625 | 625 | } |
@@ -634,9 +634,9 @@ discard block |
||
634 | 634 | * |
635 | 635 | * @return mixed If successful, the new value, otherwise false. |
636 | 636 | */ |
637 | - public function increase_value( $value = 0.00 ) { |
|
637 | + public function increase_value($value = 0.00) { |
|
638 | 638 | |
639 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
639 | + $new_value = floatval($this->purchase_value) + $value; |
|
640 | 640 | |
641 | 641 | /** |
642 | 642 | * Fires before increasing customer lifetime value. |
@@ -646,9 +646,9 @@ discard block |
||
646 | 646 | * @param float $value The value to increase by. |
647 | 647 | * @param int $customer_id Customer id. |
648 | 648 | */ |
649 | - do_action( 'give_customer_pre_increase_value', $value, $this->id ); |
|
649 | + do_action('give_customer_pre_increase_value', $value, $this->id); |
|
650 | 650 | |
651 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
651 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
652 | 652 | $this->purchase_value = $new_value; |
653 | 653 | } |
654 | 654 | |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | * @param float $value The value increased by. |
662 | 662 | * @param int $customer_id Customer id. |
663 | 663 | */ |
664 | - do_action( 'give_customer_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
664 | + do_action('give_customer_post_increase_value', $this->purchase_value, $value, $this->id); |
|
665 | 665 | |
666 | 666 | return $this->purchase_value; |
667 | 667 | } |
@@ -676,11 +676,11 @@ discard block |
||
676 | 676 | * |
677 | 677 | * @return mixed If successful, the new value, otherwise false. |
678 | 678 | */ |
679 | - public function decrease_value( $value = 0.00 ) { |
|
679 | + public function decrease_value($value = 0.00) { |
|
680 | 680 | |
681 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
681 | + $new_value = floatval($this->purchase_value) - $value; |
|
682 | 682 | |
683 | - if ( $new_value < 0 ) { |
|
683 | + if ($new_value < 0) { |
|
684 | 684 | $new_value = 0.00; |
685 | 685 | } |
686 | 686 | |
@@ -692,9 +692,9 @@ discard block |
||
692 | 692 | * @param float $value The value to decrease by. |
693 | 693 | * @param int $customer_id Customer id. |
694 | 694 | */ |
695 | - do_action( 'give_customer_pre_decrease_value', $value, $this->id ); |
|
695 | + do_action('give_customer_pre_decrease_value', $value, $this->id); |
|
696 | 696 | |
697 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
697 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
698 | 698 | $this->purchase_value = $new_value; |
699 | 699 | } |
700 | 700 | |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | * @param float $value The value decreased by. |
708 | 708 | * @param int $customer_id Customer id. |
709 | 709 | */ |
710 | - do_action( 'give_customer_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
710 | + do_action('give_customer_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
711 | 711 | |
712 | 712 | return $this->purchase_value; |
713 | 713 | } |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | * |
727 | 727 | * @return mixed If successful, the new donation stat value, otherwise false. |
728 | 728 | */ |
729 | - public function update_donation_value( $curr_amount, $new_amount ) { |
|
729 | + public function update_donation_value($curr_amount, $new_amount) { |
|
730 | 730 | /** |
731 | 731 | * Payment total difference value can be: |
732 | 732 | * zero (in case amount not change) |
@@ -736,13 +736,13 @@ discard block |
||
736 | 736 | $payment_total_diff = $new_amount - $curr_amount; |
737 | 737 | |
738 | 738 | // We do not need to update donation stat if donation did not change. |
739 | - if( ! $payment_total_diff ) { |
|
739 | + if ( ! $payment_total_diff) { |
|
740 | 740 | return false; |
741 | 741 | } |
742 | 742 | |
743 | 743 | |
744 | - if( $payment_total_diff > 0 ) { |
|
745 | - $this->increase_value( $payment_total_diff ); |
|
744 | + if ($payment_total_diff > 0) { |
|
745 | + $this->increase_value($payment_total_diff); |
|
746 | 746 | } else { |
747 | 747 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
748 | 748 | $this->decrease_value( -$payment_total_diff ); |
@@ -762,15 +762,15 @@ discard block |
||
762 | 762 | * |
763 | 763 | * @return array The notes requested. |
764 | 764 | */ |
765 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
765 | + public function get_notes($length = 20, $paged = 1) { |
|
766 | 766 | |
767 | - $length = is_numeric( $length ) ? $length : 20; |
|
768 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
767 | + $length = is_numeric($length) ? $length : 20; |
|
768 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
769 | 769 | |
770 | 770 | $all_notes = $this->get_raw_notes(); |
771 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
771 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
772 | 772 | |
773 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
773 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
774 | 774 | |
775 | 775 | return $desired_notes; |
776 | 776 | |
@@ -787,9 +787,9 @@ discard block |
||
787 | 787 | public function get_notes_count() { |
788 | 788 | |
789 | 789 | $all_notes = $this->get_raw_notes(); |
790 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
790 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
791 | 791 | |
792 | - return count( $notes_array ); |
|
792 | + return count($notes_array); |
|
793 | 793 | |
794 | 794 | } |
795 | 795 | |
@@ -803,22 +803,22 @@ discard block |
||
803 | 803 | * |
804 | 804 | * @return string|boolean The new note if added successfully, false otherwise. |
805 | 805 | */ |
806 | - public function add_note( $note = '' ) { |
|
806 | + public function add_note($note = '') { |
|
807 | 807 | |
808 | - $note = trim( $note ); |
|
809 | - if ( empty( $note ) ) { |
|
808 | + $note = trim($note); |
|
809 | + if (empty($note)) { |
|
810 | 810 | return false; |
811 | 811 | } |
812 | 812 | |
813 | 813 | $notes = $this->get_raw_notes(); |
814 | 814 | |
815 | - if ( empty( $notes ) ) { |
|
815 | + if (empty($notes)) { |
|
816 | 816 | $notes = ''; |
817 | 817 | } |
818 | 818 | |
819 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
820 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
821 | - $notes .= "\n\n" . $new_note; |
|
819 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
820 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
821 | + $notes .= "\n\n".$new_note; |
|
822 | 822 | |
823 | 823 | /** |
824 | 824 | * Fires before customer note added. |
@@ -828,11 +828,11 @@ discard block |
||
828 | 828 | * @param string $new_note New note to add. |
829 | 829 | * @param int $customer_id Customer id. |
830 | 830 | */ |
831 | - do_action( 'give_customer_pre_add_note', $new_note, $this->id ); |
|
831 | + do_action('give_customer_pre_add_note', $new_note, $this->id); |
|
832 | 832 | |
833 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
833 | + $updated = $this->update(array('notes' => $notes)); |
|
834 | 834 | |
835 | - if ( $updated ) { |
|
835 | + if ($updated) { |
|
836 | 836 | $this->notes = $this->get_notes(); |
837 | 837 | } |
838 | 838 | |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | * @param string $new_note New note added. |
846 | 846 | * @param int $customer_id Customer id. |
847 | 847 | */ |
848 | - do_action( 'give_customer_post_add_note', $this->notes, $new_note, $this->id ); |
|
848 | + do_action('give_customer_post_add_note', $this->notes, $new_note, $this->id); |
|
849 | 849 | |
850 | 850 | // Return the formatted note, so we can test, as well as update any displays |
851 | 851 | return $new_note; |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | */ |
863 | 863 | private function get_raw_notes() { |
864 | 864 | |
865 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
865 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
866 | 866 | |
867 | 867 | return $all_notes; |
868 | 868 | |
@@ -879,8 +879,8 @@ discard block |
||
879 | 879 | * |
880 | 880 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
881 | 881 | */ |
882 | - public function get_meta( $meta_key = '', $single = true ) { |
|
883 | - return Give()->customer_meta->get_meta( $this->id, $meta_key, $single ); |
|
882 | + public function get_meta($meta_key = '', $single = true) { |
|
883 | + return Give()->customer_meta->get_meta($this->id, $meta_key, $single); |
|
884 | 884 | } |
885 | 885 | |
886 | 886 | /** |
@@ -895,8 +895,8 @@ discard block |
||
895 | 895 | * |
896 | 896 | * @return bool False for failure. True for success. |
897 | 897 | */ |
898 | - public function add_meta( $meta_key = '', $meta_value, $unique = false ) { |
|
899 | - return Give()->customer_meta->add_meta( $this->id, $meta_key, $meta_value, $unique ); |
|
898 | + public function add_meta($meta_key = '', $meta_value, $unique = false) { |
|
899 | + return Give()->customer_meta->add_meta($this->id, $meta_key, $meta_value, $unique); |
|
900 | 900 | } |
901 | 901 | |
902 | 902 | /** |
@@ -911,8 +911,8 @@ discard block |
||
911 | 911 | * |
912 | 912 | * @return bool False on failure, true if success. |
913 | 913 | */ |
914 | - public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) { |
|
915 | - return Give()->customer_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value ); |
|
914 | + public function update_meta($meta_key = '', $meta_value, $prev_value = '') { |
|
915 | + return Give()->customer_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value); |
|
916 | 916 | } |
917 | 917 | |
918 | 918 | /** |
@@ -926,8 +926,8 @@ discard block |
||
926 | 926 | * |
927 | 927 | * @return bool False for failure. True for success. |
928 | 928 | */ |
929 | - public function delete_meta( $meta_key = '', $meta_value = '' ) { |
|
930 | - return Give()->customer_meta->delete_meta( $this->id, $meta_key, $meta_value ); |
|
929 | + public function delete_meta($meta_key = '', $meta_value = '') { |
|
930 | + return Give()->customer_meta->delete_meta($this->id, $meta_key, $meta_value); |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | /** |
@@ -940,51 +940,51 @@ discard block |
||
940 | 940 | * |
941 | 941 | * @return array The sanitized data, based off column defaults. |
942 | 942 | */ |
943 | - private function sanitize_columns( $data ) { |
|
943 | + private function sanitize_columns($data) { |
|
944 | 944 | |
945 | 945 | $columns = $this->db->get_columns(); |
946 | 946 | $default_values = $this->db->get_column_defaults(); |
947 | 947 | |
948 | - foreach ( $columns as $key => $type ) { |
|
948 | + foreach ($columns as $key => $type) { |
|
949 | 949 | |
950 | 950 | // Only sanitize data that we were provided |
951 | - if ( ! array_key_exists( $key, $data ) ) { |
|
951 | + if ( ! array_key_exists($key, $data)) { |
|
952 | 952 | continue; |
953 | 953 | } |
954 | 954 | |
955 | - switch ( $type ) { |
|
955 | + switch ($type) { |
|
956 | 956 | |
957 | 957 | case '%s': |
958 | - if ( 'email' == $key ) { |
|
959 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
960 | - } elseif ( 'notes' == $key ) { |
|
961 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
958 | + if ('email' == $key) { |
|
959 | + $data[$key] = sanitize_email($data[$key]); |
|
960 | + } elseif ('notes' == $key) { |
|
961 | + $data[$key] = strip_tags($data[$key]); |
|
962 | 962 | } else { |
963 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
963 | + $data[$key] = sanitize_text_field($data[$key]); |
|
964 | 964 | } |
965 | 965 | break; |
966 | 966 | |
967 | 967 | case '%d': |
968 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
969 | - $data[ $key ] = $default_values[ $key ]; |
|
968 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
969 | + $data[$key] = $default_values[$key]; |
|
970 | 970 | } else { |
971 | - $data[ $key ] = absint( $data[ $key ] ); |
|
971 | + $data[$key] = absint($data[$key]); |
|
972 | 972 | } |
973 | 973 | break; |
974 | 974 | |
975 | 975 | case '%f': |
976 | 976 | // Convert what was given to a float |
977 | - $value = floatval( $data[ $key ] ); |
|
977 | + $value = floatval($data[$key]); |
|
978 | 978 | |
979 | - if ( ! is_float( $value ) ) { |
|
980 | - $data[ $key ] = $default_values[ $key ]; |
|
979 | + if ( ! is_float($value)) { |
|
980 | + $data[$key] = $default_values[$key]; |
|
981 | 981 | } else { |
982 | - $data[ $key ] = $value; |
|
982 | + $data[$key] = $value; |
|
983 | 983 | } |
984 | 984 | break; |
985 | 985 | |
986 | 986 | default: |
987 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
987 | + $data[$key] = sanitize_text_field($data[$key]); |
|
988 | 988 | break; |
989 | 989 | |
990 | 990 | } |
@@ -1005,33 +1005,33 @@ discard block |
||
1005 | 1005 | * |
1006 | 1006 | * @return bool If the email was added successfully |
1007 | 1007 | */ |
1008 | - public function add_email( $email = '', $primary = false ) { |
|
1009 | - if( ! is_email( $email ) ) { |
|
1008 | + public function add_email($email = '', $primary = false) { |
|
1009 | + if ( ! is_email($email)) { |
|
1010 | 1010 | return false; |
1011 | 1011 | } |
1012 | - $existing = new Give_Customer( $email ); |
|
1012 | + $existing = new Give_Customer($email); |
|
1013 | 1013 | |
1014 | - if( $existing->id > 0 ) { |
|
1014 | + if ($existing->id > 0) { |
|
1015 | 1015 | // Email address already belongs to another customer |
1016 | 1016 | return false; |
1017 | 1017 | } |
1018 | 1018 | |
1019 | - if ( email_exists( $email ) ) { |
|
1020 | - $user = get_user_by( 'email', $email ); |
|
1021 | - if ( $user->ID != $this->user_id ) { |
|
1019 | + if (email_exists($email)) { |
|
1020 | + $user = get_user_by('email', $email); |
|
1021 | + if ($user->ID != $this->user_id) { |
|
1022 | 1022 | return false; |
1023 | 1023 | } |
1024 | 1024 | } |
1025 | 1025 | |
1026 | - do_action( 'give_donor_pre_add_email', $email, $this->id, $this ); |
|
1026 | + do_action('give_donor_pre_add_email', $email, $this->id, $this); |
|
1027 | 1027 | |
1028 | 1028 | // Add is used to ensure duplicate emails are not added |
1029 | - $ret = (bool) $this->add_meta( 'additional_email', $email ); |
|
1029 | + $ret = (bool) $this->add_meta('additional_email', $email); |
|
1030 | 1030 | |
1031 | - do_action( 'give_donor_post_add_email', $email, $this->id, $this ); |
|
1031 | + do_action('give_donor_post_add_email', $email, $this->id, $this); |
|
1032 | 1032 | |
1033 | - if ( $ret && true === $primary ) { |
|
1034 | - $this->set_primary_email( $email ); |
|
1033 | + if ($ret && true === $primary) { |
|
1034 | + $this->set_primary_email($email); |
|
1035 | 1035 | } |
1036 | 1036 | |
1037 | 1037 | return $ret; |
@@ -1047,16 +1047,16 @@ discard block |
||
1047 | 1047 | * |
1048 | 1048 | * @return bool If the email was removed successfully |
1049 | 1049 | */ |
1050 | - public function remove_email( $email = '' ) { |
|
1051 | - if( ! is_email( $email ) ) { |
|
1050 | + public function remove_email($email = '') { |
|
1051 | + if ( ! is_email($email)) { |
|
1052 | 1052 | return false; |
1053 | 1053 | } |
1054 | 1054 | |
1055 | - do_action( 'give_donor_pre_remove_email', $email, $this->id, $this ); |
|
1055 | + do_action('give_donor_pre_remove_email', $email, $this->id, $this); |
|
1056 | 1056 | |
1057 | - $ret = (bool) $this->delete_meta( 'additional_email', $email ); |
|
1057 | + $ret = (bool) $this->delete_meta('additional_email', $email); |
|
1058 | 1058 | |
1059 | - do_action( 'give_donor_post_remove_email', $email, $this->id, $this ); |
|
1059 | + do_action('give_donor_post_remove_email', $email, $this->id, $this); |
|
1060 | 1060 | |
1061 | 1061 | return $ret; |
1062 | 1062 | } |
@@ -1073,16 +1073,16 @@ discard block |
||
1073 | 1073 | * |
1074 | 1074 | * @return bool If the email was set as primary successfully |
1075 | 1075 | */ |
1076 | - public function set_primary_email( $new_primary_email = '' ) { |
|
1077 | - if( ! is_email( $new_primary_email ) ) { |
|
1076 | + public function set_primary_email($new_primary_email = '') { |
|
1077 | + if ( ! is_email($new_primary_email)) { |
|
1078 | 1078 | return false; |
1079 | 1079 | } |
1080 | 1080 | |
1081 | - do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1081 | + do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this); |
|
1082 | 1082 | |
1083 | - $existing = new Give_Customer( $new_primary_email ); |
|
1083 | + $existing = new Give_Customer($new_primary_email); |
|
1084 | 1084 | |
1085 | - if( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) { |
|
1085 | + if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) { |
|
1086 | 1086 | // This email belongs to another customer |
1087 | 1087 | return false; |
1088 | 1088 | } |
@@ -1090,21 +1090,21 @@ discard block |
||
1090 | 1090 | $old_email = $this->email; |
1091 | 1091 | |
1092 | 1092 | // Update customer record with new email |
1093 | - $update = $this->update( array( 'email' => $new_primary_email ) ); |
|
1093 | + $update = $this->update(array('email' => $new_primary_email)); |
|
1094 | 1094 | |
1095 | 1095 | // Remove new primary from list of additional emails |
1096 | - $remove = $this->remove_email( $new_primary_email ); |
|
1096 | + $remove = $this->remove_email($new_primary_email); |
|
1097 | 1097 | |
1098 | 1098 | // Add old email to additional emails list |
1099 | - $add = $this->add_email( $old_email ); |
|
1099 | + $add = $this->add_email($old_email); |
|
1100 | 1100 | |
1101 | 1101 | $ret = $update && $remove && $add; |
1102 | 1102 | |
1103 | - if( $ret ) { |
|
1103 | + if ($ret) { |
|
1104 | 1104 | $this->email = $new_primary_email; |
1105 | 1105 | } |
1106 | 1106 | |
1107 | - do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1107 | + do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this); |
|
1108 | 1108 | |
1109 | 1109 | return $ret; |
1110 | 1110 | } |
@@ -337,7 +337,7 @@ |
||
337 | 337 | * |
338 | 338 | * @since 1.0 |
339 | 339 | * @uses Give()->session->get() |
340 | - * @return mixed array | false |
|
340 | + * @return string array | false |
|
341 | 341 | */ |
342 | 342 | function give_get_purchase_session() { |
343 | 343 | return Give()->session->get( 'give_purchase' ); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | */ |
24 | 24 | function give_is_test_mode() { |
25 | 25 | |
26 | - $ret = give_is_setting_enabled( give_get_option( 'test_mode' ) ); |
|
26 | + $ret = give_is_setting_enabled(give_get_option('test_mode')); |
|
27 | 27 | |
28 | - return (bool) apply_filters( 'give_is_test_mode', $ret ); |
|
28 | + return (bool) apply_filters('give_is_test_mode', $ret); |
|
29 | 29 | |
30 | 30 | } |
31 | 31 | |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | */ |
38 | 38 | function give_get_currency() { |
39 | 39 | |
40 | - $currency = give_get_option( 'currency', 'USD' ); |
|
40 | + $currency = give_get_option('currency', 'USD'); |
|
41 | 41 | |
42 | - return apply_filters( 'give_currency', $currency ); |
|
42 | + return apply_filters('give_currency', $currency); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | */ |
52 | 52 | function give_get_currency_position() { |
53 | 53 | |
54 | - $currency_pos = give_get_option( 'currency_position', 'before' ); |
|
54 | + $currency_pos = give_get_option('currency_position', 'before'); |
|
55 | 55 | |
56 | - return apply_filters( 'give_currency_position', $currency_pos ); |
|
56 | + return apply_filters('give_currency_position', $currency_pos); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
@@ -66,39 +66,39 @@ discard block |
||
66 | 66 | |
67 | 67 | function give_get_currencies() { |
68 | 68 | $currencies = array( |
69 | - 'USD' => esc_html__( 'US Dollars ($)', 'give' ), |
|
70 | - 'EUR' => esc_html__( 'Euros (€)', 'give' ), |
|
71 | - 'GBP' => esc_html__( 'Pounds Sterling (£)', 'give' ), |
|
72 | - 'AUD' => esc_html__( 'Australian Dollars ($)', 'give' ), |
|
73 | - 'BRL' => esc_html__( 'Brazilian Real (R$)', 'give' ), |
|
74 | - 'CAD' => esc_html__( 'Canadian Dollars ($)', 'give' ), |
|
75 | - 'CZK' => esc_html__( 'Czech Koruna (Kč)', 'give' ), |
|
76 | - 'DKK' => esc_html__( 'Danish Krone (kr)', 'give' ), |
|
77 | - 'HKD' => esc_html__( 'Hong Kong Dollar ($)', 'give' ), |
|
78 | - 'HUF' => esc_html__( 'Hungarian Forint (Ft)', 'give' ), |
|
79 | - 'ILS' => esc_html__( 'Israeli Shekel (₪)', 'give' ), |
|
80 | - 'JPY' => esc_html__( 'Japanese Yen (¥)', 'give' ), |
|
81 | - 'MYR' => esc_html__( 'Malaysian Ringgits (RM)', 'give' ), |
|
82 | - 'MXN' => esc_html__( 'Mexican Peso ($)', 'give' ), |
|
83 | - 'MAD' => esc_html__( 'Moroccan Dirham (.د.م)', 'give' ), |
|
84 | - 'NZD' => esc_html__( 'New Zealand Dollar ($)', 'give' ), |
|
85 | - 'NOK' => esc_html__( 'Norwegian Krone (Kr.)', 'give' ), |
|
86 | - 'PHP' => esc_html__( 'Philippine Pesos (₱)', 'give' ), |
|
87 | - 'PLN' => esc_html__( 'Polish Zloty (zł)', 'give' ), |
|
88 | - 'SGD' => esc_html__( 'Singapore Dollar ($)', 'give' ), |
|
89 | - 'KRW' => esc_html__( 'South Korean Won (₩)', 'give' ), |
|
90 | - 'ZAR' => esc_html__( 'South African Rand (R)', 'give' ), |
|
91 | - 'SEK' => esc_html__( 'Swedish Krona (kr)', 'give' ), |
|
92 | - 'CHF' => esc_html__( 'Swiss Franc (CHF)', 'give' ), |
|
93 | - 'TWD' => esc_html__( 'Taiwan New Dollars (NT$)', 'give' ), |
|
94 | - 'THB' => esc_html__( 'Thai Baht (฿)', 'give' ), |
|
95 | - 'INR' => esc_html__( 'Indian Rupee (₹)', 'give' ), |
|
96 | - 'TRY' => esc_html__( 'Turkish Lira (₺)', 'give' ), |
|
97 | - 'RIAL' => esc_html__( 'Iranian Rial (﷼)', 'give' ), |
|
98 | - 'RUB' => esc_html__( 'Russian Rubles (руб)', 'give' ) |
|
69 | + 'USD' => esc_html__('US Dollars ($)', 'give'), |
|
70 | + 'EUR' => esc_html__('Euros (€)', 'give'), |
|
71 | + 'GBP' => esc_html__('Pounds Sterling (£)', 'give'), |
|
72 | + 'AUD' => esc_html__('Australian Dollars ($)', 'give'), |
|
73 | + 'BRL' => esc_html__('Brazilian Real (R$)', 'give'), |
|
74 | + 'CAD' => esc_html__('Canadian Dollars ($)', 'give'), |
|
75 | + 'CZK' => esc_html__('Czech Koruna (Kč)', 'give'), |
|
76 | + 'DKK' => esc_html__('Danish Krone (kr)', 'give'), |
|
77 | + 'HKD' => esc_html__('Hong Kong Dollar ($)', 'give'), |
|
78 | + 'HUF' => esc_html__('Hungarian Forint (Ft)', 'give'), |
|
79 | + 'ILS' => esc_html__('Israeli Shekel (₪)', 'give'), |
|
80 | + 'JPY' => esc_html__('Japanese Yen (¥)', 'give'), |
|
81 | + 'MYR' => esc_html__('Malaysian Ringgits (RM)', 'give'), |
|
82 | + 'MXN' => esc_html__('Mexican Peso ($)', 'give'), |
|
83 | + 'MAD' => esc_html__('Moroccan Dirham (.د.م)', 'give'), |
|
84 | + 'NZD' => esc_html__('New Zealand Dollar ($)', 'give'), |
|
85 | + 'NOK' => esc_html__('Norwegian Krone (Kr.)', 'give'), |
|
86 | + 'PHP' => esc_html__('Philippine Pesos (₱)', 'give'), |
|
87 | + 'PLN' => esc_html__('Polish Zloty (zł)', 'give'), |
|
88 | + 'SGD' => esc_html__('Singapore Dollar ($)', 'give'), |
|
89 | + 'KRW' => esc_html__('South Korean Won (₩)', 'give'), |
|
90 | + 'ZAR' => esc_html__('South African Rand (R)', 'give'), |
|
91 | + 'SEK' => esc_html__('Swedish Krona (kr)', 'give'), |
|
92 | + 'CHF' => esc_html__('Swiss Franc (CHF)', 'give'), |
|
93 | + 'TWD' => esc_html__('Taiwan New Dollars (NT$)', 'give'), |
|
94 | + 'THB' => esc_html__('Thai Baht (฿)', 'give'), |
|
95 | + 'INR' => esc_html__('Indian Rupee (₹)', 'give'), |
|
96 | + 'TRY' => esc_html__('Turkish Lira (₺)', 'give'), |
|
97 | + 'RIAL' => esc_html__('Iranian Rial (﷼)', 'give'), |
|
98 | + 'RUB' => esc_html__('Russian Rubles (руб)', 'give') |
|
99 | 99 | ); |
100 | 100 | |
101 | - return apply_filters( 'give_currencies', $currencies ); |
|
101 | + return apply_filters('give_currencies', $currencies); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return string The symbol to use for the currency |
115 | 115 | */ |
116 | -function give_currency_symbol( $currency = '' ) { |
|
116 | +function give_currency_symbol($currency = '') { |
|
117 | 117 | |
118 | - if ( empty( $currency ) ) { |
|
118 | + if (empty($currency)) { |
|
119 | 119 | $currency = give_get_currency(); |
120 | 120 | } |
121 | - switch ( $currency ) : |
|
121 | + switch ($currency) : |
|
122 | 122 | case 'GBP' : |
123 | 123 | $symbol = '£'; |
124 | 124 | break; |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | endswitch; |
198 | 198 | |
199 | 199 | |
200 | - return apply_filters( 'give_currency_symbol', $symbol, $currency ); |
|
200 | + return apply_filters('give_currency_symbol', $symbol, $currency); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | |
@@ -209,15 +209,15 @@ discard block |
||
209 | 209 | */ |
210 | 210 | function give_get_current_page_url() { |
211 | 211 | |
212 | - if ( is_front_page() ) { |
|
213 | - $current_url = home_url( '/' ); |
|
212 | + if (is_front_page()) { |
|
213 | + $current_url = home_url('/'); |
|
214 | 214 | } else { |
215 | - $http_host = sanitize_text_field( $_SERVER['HTTP_HOST'] ); |
|
216 | - $request_uri = sanitize_text_field( $_SERVER['REQUEST_URI'] ); |
|
217 | - $current_url = set_url_scheme( 'http://' . $http_host . untrailingslashit( $request_uri ) ); |
|
215 | + $http_host = sanitize_text_field($_SERVER['HTTP_HOST']); |
|
216 | + $request_uri = sanitize_text_field($_SERVER['REQUEST_URI']); |
|
217 | + $current_url = set_url_scheme('http://'.$http_host.untrailingslashit($request_uri)); |
|
218 | 218 | } |
219 | 219 | |
220 | - return apply_filters( 'give_get_current_page_url', $current_url ); |
|
220 | + return apply_filters('give_get_current_page_url', $current_url); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | |
@@ -238,15 +238,15 @@ discard block |
||
238 | 238 | */ |
239 | 239 | $gateways = give_get_enabled_payment_gateways(); |
240 | 240 | |
241 | - if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) { |
|
241 | + if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) { |
|
242 | 242 | $ret = true; |
243 | - } else if ( count( $gateways ) == 1 ) { |
|
243 | + } else if (count($gateways) == 1) { |
|
244 | 244 | $ret = false; |
245 | - } else if ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) { |
|
245 | + } else if (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) { |
|
246 | 246 | $ret = false; |
247 | 247 | } |
248 | 248 | |
249 | - return (bool) apply_filters( 'give_verify_credit_cards', $ret ); |
|
249 | + return (bool) apply_filters('give_verify_credit_cards', $ret); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -258,26 +258,26 @@ discard block |
||
258 | 258 | function give_get_timezone_id() { |
259 | 259 | |
260 | 260 | // if site timezone string exists, return it |
261 | - if ( $timezone = get_option( 'timezone_string' ) ) { |
|
261 | + if ($timezone = get_option('timezone_string')) { |
|
262 | 262 | return $timezone; |
263 | 263 | } |
264 | 264 | |
265 | 265 | // get UTC offset, if it isn't set return UTC |
266 | - if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) { |
|
266 | + if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) { |
|
267 | 267 | return 'UTC'; |
268 | 268 | } |
269 | 269 | |
270 | 270 | // attempt to guess the timezone string from the UTC offset |
271 | - $timezone = timezone_name_from_abbr( '', $utc_offset ); |
|
271 | + $timezone = timezone_name_from_abbr('', $utc_offset); |
|
272 | 272 | |
273 | 273 | // last try, guess timezone string manually |
274 | - if ( $timezone === false ) { |
|
274 | + if ($timezone === false) { |
|
275 | 275 | |
276 | - $is_dst = date( 'I' ); |
|
276 | + $is_dst = date('I'); |
|
277 | 277 | |
278 | - foreach ( timezone_abbreviations_list() as $abbr ) { |
|
279 | - foreach ( $abbr as $city ) { |
|
280 | - if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) { |
|
278 | + foreach (timezone_abbreviations_list() as $abbr) { |
|
279 | + foreach ($abbr as $city) { |
|
280 | + if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) { |
|
281 | 281 | return $city['timezone_id']; |
282 | 282 | } |
283 | 283 | } |
@@ -301,17 +301,17 @@ discard block |
||
301 | 301 | |
302 | 302 | $ip = '127.0.0.1'; |
303 | 303 | |
304 | - if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
304 | + if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
305 | 305 | //check ip from share internet |
306 | 306 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
307 | - } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
307 | + } elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
308 | 308 | //to check ip is pass from proxy |
309 | 309 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
310 | - } elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
310 | + } elseif ( ! empty($_SERVER['REMOTE_ADDR'])) { |
|
311 | 311 | $ip = $_SERVER['REMOTE_ADDR']; |
312 | 312 | } |
313 | 313 | |
314 | - return apply_filters( 'give_get_ip', $ip ); |
|
314 | + return apply_filters('give_get_ip', $ip); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | |
@@ -326,9 +326,9 @@ discard block |
||
326 | 326 | * |
327 | 327 | * @uses Give()->session->set() |
328 | 328 | */ |
329 | -function give_set_purchase_session( $purchase_data = array() ) { |
|
330 | - Give()->session->set( 'give_purchase', $purchase_data ); |
|
331 | - Give()->session->set( 'give_email', $purchase_data['user_email'] ); |
|
329 | +function give_set_purchase_session($purchase_data = array()) { |
|
330 | + Give()->session->set('give_purchase', $purchase_data); |
|
331 | + Give()->session->set('give_email', $purchase_data['user_email']); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * @return mixed array | false |
343 | 343 | */ |
344 | 344 | function give_get_purchase_session() { |
345 | - return Give()->session->get( 'give_purchase' ); |
|
345 | + return Give()->session->get('give_purchase'); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -357,14 +357,14 @@ discard block |
||
357 | 357 | * |
358 | 358 | * @return string |
359 | 359 | */ |
360 | -function give_get_purchase_summary( $purchase_data, $email = true ) { |
|
360 | +function give_get_purchase_summary($purchase_data, $email = true) { |
|
361 | 361 | $summary = ''; |
362 | 362 | |
363 | - if ( $email ) { |
|
364 | - $summary .= $purchase_data['user_email'] . ' - '; |
|
363 | + if ($email) { |
|
364 | + $summary .= $purchase_data['user_email'].' - '; |
|
365 | 365 | } |
366 | 366 | |
367 | - $summary .= get_the_title( $purchase_data['post_data']['give-form-id'] ); |
|
367 | + $summary .= get_the_title($purchase_data['post_data']['give-form-id']); |
|
368 | 368 | |
369 | 369 | return $summary; |
370 | 370 | } |
@@ -381,31 +381,31 @@ discard block |
||
381 | 381 | function give_get_host() { |
382 | 382 | $host = false; |
383 | 383 | |
384 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
384 | + if (defined('WPE_APIKEY')) { |
|
385 | 385 | $host = 'WP Engine'; |
386 | - } elseif ( defined( 'PAGELYBIN' ) ) { |
|
386 | + } elseif (defined('PAGELYBIN')) { |
|
387 | 387 | $host = 'Pagely'; |
388 | - } elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
388 | + } elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
389 | 389 | $host = 'ICDSoft'; |
390 | - } elseif ( DB_HOST == 'mysqlv5' ) { |
|
390 | + } elseif (DB_HOST == 'mysqlv5') { |
|
391 | 391 | $host = 'NetworkSolutions'; |
392 | - } elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
392 | + } elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
393 | 393 | $host = 'iPage'; |
394 | - } elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
394 | + } elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
395 | 395 | $host = 'IPower'; |
396 | - } elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
396 | + } elseif (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
397 | 397 | $host = 'MediaTemple Grid'; |
398 | - } elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
398 | + } elseif (strpos(DB_HOST, '.pair.com') !== false) { |
|
399 | 399 | $host = 'pair Networks'; |
400 | - } elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
400 | + } elseif (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
401 | 401 | $host = 'Rackspace Cloud'; |
402 | - } elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
402 | + } elseif (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
403 | 403 | $host = 'SysFix.eu Power Hosting'; |
404 | - } elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
404 | + } elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
405 | 405 | $host = 'Flywheel'; |
406 | 406 | } else { |
407 | 407 | // Adding a general fallback for data gathering |
408 | - $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME']; |
|
408 | + $host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME']; |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | return $host; |
@@ -421,67 +421,67 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @return bool true if host matches, false if not |
423 | 423 | */ |
424 | -function give_is_host( $host = false ) { |
|
424 | +function give_is_host($host = false) { |
|
425 | 425 | |
426 | 426 | $return = false; |
427 | 427 | |
428 | - if ( $host ) { |
|
429 | - $host = str_replace( ' ', '', strtolower( $host ) ); |
|
428 | + if ($host) { |
|
429 | + $host = str_replace(' ', '', strtolower($host)); |
|
430 | 430 | |
431 | - switch ( $host ) { |
|
431 | + switch ($host) { |
|
432 | 432 | case 'wpengine': |
433 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
433 | + if (defined('WPE_APIKEY')) { |
|
434 | 434 | $return = true; |
435 | 435 | } |
436 | 436 | break; |
437 | 437 | case 'pagely': |
438 | - if ( defined( 'PAGELYBIN' ) ) { |
|
438 | + if (defined('PAGELYBIN')) { |
|
439 | 439 | $return = true; |
440 | 440 | } |
441 | 441 | break; |
442 | 442 | case 'icdsoft': |
443 | - if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
443 | + if (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
444 | 444 | $return = true; |
445 | 445 | } |
446 | 446 | break; |
447 | 447 | case 'networksolutions': |
448 | - if ( DB_HOST == 'mysqlv5' ) { |
|
448 | + if (DB_HOST == 'mysqlv5') { |
|
449 | 449 | $return = true; |
450 | 450 | } |
451 | 451 | break; |
452 | 452 | case 'ipage': |
453 | - if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
453 | + if (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
454 | 454 | $return = true; |
455 | 455 | } |
456 | 456 | break; |
457 | 457 | case 'ipower': |
458 | - if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
458 | + if (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
459 | 459 | $return = true; |
460 | 460 | } |
461 | 461 | break; |
462 | 462 | case 'mediatemplegrid': |
463 | - if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
463 | + if (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
464 | 464 | $return = true; |
465 | 465 | } |
466 | 466 | break; |
467 | 467 | case 'pairnetworks': |
468 | - if ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
468 | + if (strpos(DB_HOST, '.pair.com') !== false) { |
|
469 | 469 | $return = true; |
470 | 470 | } |
471 | 471 | break; |
472 | 472 | case 'rackspacecloud': |
473 | - if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
473 | + if (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
474 | 474 | $return = true; |
475 | 475 | } |
476 | 476 | break; |
477 | 477 | case 'sysfix.eu': |
478 | 478 | case 'sysfix.eupowerhosting': |
479 | - if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
479 | + if (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
480 | 480 | $return = true; |
481 | 481 | } |
482 | 482 | break; |
483 | 483 | case 'flywheel': |
484 | - if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
484 | + if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
485 | 485 | $return = true; |
486 | 486 | } |
487 | 487 | break; |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | * @param string $replacement Optional. The function that should have been called. |
515 | 515 | * @param array $backtrace Optional. Contains stack backtrace of deprecated function. |
516 | 516 | */ |
517 | -function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) { |
|
517 | +function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) { |
|
518 | 518 | |
519 | 519 | /** |
520 | 520 | * Fires while give deprecated function call occurs. |
@@ -527,19 +527,19 @@ discard block |
||
527 | 527 | * @param string $replacement Optional. The function that should have been called. |
528 | 528 | * @param string $version The plugin version that deprecated the function. |
529 | 529 | */ |
530 | - do_action( 'give_deprecated_function_run', $function, $replacement, $version ); |
|
530 | + do_action('give_deprecated_function_run', $function, $replacement, $version); |
|
531 | 531 | |
532 | - $show_errors = current_user_can( 'manage_options' ); |
|
532 | + $show_errors = current_user_can('manage_options'); |
|
533 | 533 | |
534 | 534 | // Allow plugin to filter the output error trigger |
535 | - if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) { |
|
536 | - if ( ! is_null( $replacement ) ) { |
|
537 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) ); |
|
538 | - trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
535 | + if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) { |
|
536 | + if ( ! is_null($replacement)) { |
|
537 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement)); |
|
538 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
539 | 539 | // Alternatively we could dump this to a file. |
540 | 540 | } else { |
541 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) ); |
|
542 | - trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
541 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version)); |
|
542 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
543 | 543 | // Alternatively we could dump this to a file. |
544 | 544 | } |
545 | 545 | } |
@@ -553,8 +553,8 @@ discard block |
||
553 | 553 | * @return string $post_id |
554 | 554 | */ |
555 | 555 | function give_get_admin_post_id() { |
556 | - $post_id = isset( $_GET['post'] ) ? $_GET['post'] : null; |
|
557 | - if ( ! $post_id && isset( $_POST['post_id'] ) ) { |
|
556 | + $post_id = isset($_GET['post']) ? $_GET['post'] : null; |
|
557 | + if ( ! $post_id && isset($_POST['post_id'])) { |
|
558 | 558 | $post_id = $_POST['post_id']; |
559 | 559 | } |
560 | 560 | |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | * @return string Arg separator output |
569 | 569 | */ |
570 | 570 | function give_get_php_arg_separator_output() { |
571 | - return ini_get( 'arg_separator.output' ); |
|
571 | + return ini_get('arg_separator.output'); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | |
@@ -583,10 +583,10 @@ discard block |
||
583 | 583 | * |
584 | 584 | * @return string Short month name |
585 | 585 | */ |
586 | -function give_month_num_to_name( $n ) { |
|
587 | - $timestamp = mktime( 0, 0, 0, $n, 1, 2005 ); |
|
586 | +function give_month_num_to_name($n) { |
|
587 | + $timestamp = mktime(0, 0, 0, $n, 1, 2005); |
|
588 | 588 | |
589 | - return date_i18n( "M", $timestamp ); |
|
589 | + return date_i18n("M", $timestamp); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | |
@@ -599,10 +599,10 @@ discard block |
||
599 | 599 | * |
600 | 600 | * @return bool Whether or not function is disabled. |
601 | 601 | */ |
602 | -function give_is_func_disabled( $function ) { |
|
603 | - $disabled = explode( ',', ini_get( 'disable_functions' ) ); |
|
602 | +function give_is_func_disabled($function) { |
|
603 | + $disabled = explode(',', ini_get('disable_functions')); |
|
604 | 604 | |
605 | - return in_array( $function, $disabled ); |
|
605 | + return in_array($function, $disabled); |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | |
@@ -613,31 +613,31 @@ discard block |
||
613 | 613 | */ |
614 | 614 | function give_get_newsletter() { ?> |
615 | 615 | |
616 | - <p class="newsletter-intro"><?php esc_html_e( 'Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give' ); ?></p> |
|
616 | + <p class="newsletter-intro"><?php esc_html_e('Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give'); ?></p> |
|
617 | 617 | |
618 | 618 | <div class="give-newsletter-form-wrap"> |
619 | 619 | |
620 | 620 | <form action="//givewp.us3.list-manage.com/subscribe/post?u=3ccb75d68bda4381e2f45794c&id=12a081aa13" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate> |
621 | 621 | <div class="give-newsletter-confirmation"> |
622 | - <p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p> |
|
622 | + <p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p> |
|
623 | 623 | </div> |
624 | 624 | |
625 | 625 | <table class="form-table give-newsletter-form"> |
626 | 626 | <tr valign="middle"> |
627 | 627 | <td> |
628 | - <label for="mce-EMAIL" class="screen-reader-text"><?php esc_html_e( 'Email Address (required)', 'give' ); ?></label> |
|
629 | - <input type="email" name="EMAIL" id="mce-EMAIL" placeholder="<?php esc_attr_e( 'Email Address (required)', 'give' ); ?>" class="required email" value=""> |
|
628 | + <label for="mce-EMAIL" class="screen-reader-text"><?php esc_html_e('Email Address (required)', 'give'); ?></label> |
|
629 | + <input type="email" name="EMAIL" id="mce-EMAIL" placeholder="<?php esc_attr_e('Email Address (required)', 'give'); ?>" class="required email" value=""> |
|
630 | 630 | </td> |
631 | 631 | <td> |
632 | - <label for="mce-FNAME" class="screen-reader-text"><?php esc_html_e( 'First Name', 'give' ); ?></label> |
|
633 | - <input type="text" name="FNAME" id="mce-FNAME" placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" class="" value=""> |
|
632 | + <label for="mce-FNAME" class="screen-reader-text"><?php esc_html_e('First Name', 'give'); ?></label> |
|
633 | + <input type="text" name="FNAME" id="mce-FNAME" placeholder="<?php esc_attr_e('First Name', 'give'); ?>" class="" value=""> |
|
634 | 634 | </td> |
635 | 635 | <td> |
636 | - <label for="mce-LNAME" class="screen-reader-text"><?php esc_html_e( 'Last Name', 'give' ); ?></label> |
|
637 | - <input type="text" name="LNAME" id="mce-LNAME" placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" class="" value=""> |
|
636 | + <label for="mce-LNAME" class="screen-reader-text"><?php esc_html_e('Last Name', 'give'); ?></label> |
|
637 | + <input type="text" name="LNAME" id="mce-LNAME" placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" class="" value=""> |
|
638 | 638 | </td> |
639 | 639 | <td> |
640 | - <input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button" value="<?php esc_attr_e( 'Subscribe', 'give' ); ?>"> |
|
640 | + <input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button" value="<?php esc_attr_e('Subscribe', 'give'); ?>"> |
|
641 | 641 | </td> |
642 | 642 | </tr> |
643 | 643 | </table> |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | <a href="https://twitter.com/givewp" class="twitter-follow-button" data-show-count="false"><?php |
699 | 699 | printf( |
700 | 700 | /* translators: %s: Give twitter user @givewp */ |
701 | - esc_html_e( 'Follow %s', 'give' ), |
|
701 | + esc_html_e('Follow %s', 'give'), |
|
702 | 702 | '@givewp' |
703 | 703 | ); |
704 | 704 | ?></a> |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | * |
728 | 728 | * @return string |
729 | 729 | */ |
730 | -function give_svg_icons( $icon ) { |
|
730 | +function give_svg_icons($icon) { |
|
731 | 731 | |
732 | 732 | // Store your SVGs in an associative array |
733 | 733 | $svgs = array( |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | ); |
740 | 740 | |
741 | 741 | // Return the chosen icon's SVG string |
742 | - return $svgs[ $icon ]; |
|
742 | + return $svgs[$icon]; |
|
743 | 743 | } |
744 | 744 | |
745 | 745 | /** |
@@ -751,15 +751,15 @@ discard block |
||
751 | 751 | * |
752 | 752 | * @return mixed |
753 | 753 | */ |
754 | -function modify_nav_menu_meta_box_object( $post_type ) { |
|
755 | - if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) { |
|
756 | - $post_type->labels->name = esc_html__( 'Donation Forms', 'give' ); |
|
754 | +function modify_nav_menu_meta_box_object($post_type) { |
|
755 | + if (isset($post_type->name) && $post_type->name == 'give_forms') { |
|
756 | + $post_type->labels->name = esc_html__('Donation Forms', 'give'); |
|
757 | 757 | } |
758 | 758 | |
759 | 759 | return $post_type; |
760 | 760 | } |
761 | 761 | |
762 | -add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' ); |
|
762 | +add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object'); |
|
763 | 763 | |
764 | 764 | |
765 | 765 | /** |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | * @license https://opensource.org/licenses/MIT MIT |
774 | 774 | */ |
775 | 775 | |
776 | -if ( ! function_exists( 'array_column' ) ) { |
|
776 | +if ( ! function_exists('array_column')) { |
|
777 | 777 | /** |
778 | 778 | * Returns the values from a single column of the input array, identified by |
779 | 779 | * the $columnKey. |
@@ -792,53 +792,53 @@ discard block |
||
792 | 792 | * |
793 | 793 | * @return array |
794 | 794 | */ |
795 | - function array_column( $input = null, $columnKey = null, $indexKey = null ) { |
|
795 | + function array_column($input = null, $columnKey = null, $indexKey = null) { |
|
796 | 796 | // Using func_get_args() in order to check for proper number of |
797 | 797 | // parameters and trigger errors exactly as the built-in array_column() |
798 | 798 | // does in PHP 5.5. |
799 | 799 | $argc = func_num_args(); |
800 | 800 | $params = func_get_args(); |
801 | 801 | |
802 | - if ( $argc < 2 ) { |
|
803 | - trigger_error( sprintf( esc_html__( 'array_column() expects at least 2 parameters, %s given.', 'give' ), $argc ), E_USER_WARNING ); |
|
802 | + if ($argc < 2) { |
|
803 | + trigger_error(sprintf(esc_html__('array_column() expects at least 2 parameters, %s given.', 'give'), $argc), E_USER_WARNING); |
|
804 | 804 | |
805 | 805 | return null; |
806 | 806 | } |
807 | 807 | |
808 | - if ( ! is_array( $params[0] ) ) { |
|
809 | - trigger_error( sprintf( esc_html__( 'array_column() expects parameter 1 to be array, %s given.', 'give' ), gettype( $params[0] ) ), E_USER_WARNING ); |
|
808 | + if ( ! is_array($params[0])) { |
|
809 | + trigger_error(sprintf(esc_html__('array_column() expects parameter 1 to be array, %s given.', 'give'), gettype($params[0])), E_USER_WARNING); |
|
810 | 810 | |
811 | 811 | return null; |
812 | 812 | } |
813 | 813 | |
814 | - if ( ! is_int( $params[1] ) |
|
815 | - && ! is_float( $params[1] ) |
|
816 | - && ! is_string( $params[1] ) |
|
814 | + if ( ! is_int($params[1]) |
|
815 | + && ! is_float($params[1]) |
|
816 | + && ! is_string($params[1]) |
|
817 | 817 | && $params[1] !== null |
818 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
818 | + && ! (is_object($params[1]) && method_exists($params[1], '__toString')) |
|
819 | 819 | ) { |
820 | - trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
820 | + trigger_error(esc_html__('array_column(): The column key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
821 | 821 | |
822 | 822 | return false; |
823 | 823 | } |
824 | 824 | |
825 | - if ( isset( $params[2] ) |
|
826 | - && ! is_int( $params[2] ) |
|
827 | - && ! is_float( $params[2] ) |
|
828 | - && ! is_string( $params[2] ) |
|
829 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
825 | + if (isset($params[2]) |
|
826 | + && ! is_int($params[2]) |
|
827 | + && ! is_float($params[2]) |
|
828 | + && ! is_string($params[2]) |
|
829 | + && ! (is_object($params[2]) && method_exists($params[2], '__toString')) |
|
830 | 830 | ) { |
831 | - trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
831 | + trigger_error(esc_html__('array_column(): The index key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
832 | 832 | |
833 | 833 | return false; |
834 | 834 | } |
835 | 835 | |
836 | 836 | $paramsInput = $params[0]; |
837 | - $paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null; |
|
837 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
838 | 838 | |
839 | 839 | $paramsIndexKey = null; |
840 | - if ( isset( $params[2] ) ) { |
|
841 | - if ( is_float( $params[2] ) || is_int( $params[2] ) ) { |
|
840 | + if (isset($params[2])) { |
|
841 | + if (is_float($params[2]) || is_int($params[2])) { |
|
842 | 842 | $paramsIndexKey = (int) $params[2]; |
843 | 843 | } else { |
844 | 844 | $paramsIndexKey = (string) $params[2]; |
@@ -847,26 +847,26 @@ discard block |
||
847 | 847 | |
848 | 848 | $resultArray = array(); |
849 | 849 | |
850 | - foreach ( $paramsInput as $row ) { |
|
850 | + foreach ($paramsInput as $row) { |
|
851 | 851 | $key = $value = null; |
852 | 852 | $keySet = $valueSet = false; |
853 | 853 | |
854 | - if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) { |
|
854 | + if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
855 | 855 | $keySet = true; |
856 | - $key = (string) $row[ $paramsIndexKey ]; |
|
856 | + $key = (string) $row[$paramsIndexKey]; |
|
857 | 857 | } |
858 | 858 | |
859 | - if ( $paramsColumnKey === null ) { |
|
859 | + if ($paramsColumnKey === null) { |
|
860 | 860 | $valueSet = true; |
861 | 861 | $value = $row; |
862 | - } elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) { |
|
862 | + } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
863 | 863 | $valueSet = true; |
864 | - $value = $row[ $paramsColumnKey ]; |
|
864 | + $value = $row[$paramsColumnKey]; |
|
865 | 865 | } |
866 | 866 | |
867 | - if ( $valueSet ) { |
|
868 | - if ( $keySet ) { |
|
869 | - $resultArray[ $key ] = $value; |
|
867 | + if ($valueSet) { |
|
868 | + if ($keySet) { |
|
869 | + $resultArray[$key] = $value; |
|
870 | 870 | } else { |
871 | 871 | $resultArray[] = $value; |
872 | 872 | } |
@@ -888,40 +888,40 @@ discard block |
||
888 | 888 | * |
889 | 889 | * @return bool Whether the receipt is visible or not. |
890 | 890 | */ |
891 | -function give_can_view_receipt( $payment_key = '' ) { |
|
891 | +function give_can_view_receipt($payment_key = '') { |
|
892 | 892 | |
893 | 893 | $return = false; |
894 | 894 | |
895 | - if ( empty( $payment_key ) ) { |
|
895 | + if (empty($payment_key)) { |
|
896 | 896 | return $return; |
897 | 897 | } |
898 | 898 | |
899 | 899 | global $give_receipt_args; |
900 | 900 | |
901 | - $give_receipt_args['id'] = give_get_purchase_id_by_key( $payment_key ); |
|
901 | + $give_receipt_args['id'] = give_get_purchase_id_by_key($payment_key); |
|
902 | 902 | |
903 | - $user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] ); |
|
903 | + $user_id = (int) give_get_payment_user_id($give_receipt_args['id']); |
|
904 | 904 | |
905 | - $payment_meta = give_get_payment_meta( $give_receipt_args['id'] ); |
|
905 | + $payment_meta = give_get_payment_meta($give_receipt_args['id']); |
|
906 | 906 | |
907 | - if ( is_user_logged_in() ) { |
|
908 | - if ( $user_id === (int) get_current_user_id() ) { |
|
907 | + if (is_user_logged_in()) { |
|
908 | + if ($user_id === (int) get_current_user_id()) { |
|
909 | 909 | $return = true; |
910 | - } elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) { |
|
910 | + } elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) { |
|
911 | 911 | $return = true; |
912 | - } elseif ( current_user_can( 'view_give_sensitive_data' ) ) { |
|
912 | + } elseif (current_user_can('view_give_sensitive_data')) { |
|
913 | 913 | $return = true; |
914 | 914 | } |
915 | 915 | } |
916 | 916 | |
917 | 917 | $session = give_get_purchase_session(); |
918 | - if ( ! empty( $session ) && ! is_user_logged_in() ) { |
|
919 | - if ( $session['purchase_key'] === $payment_meta['key'] ) { |
|
918 | + if ( ! empty($session) && ! is_user_logged_in()) { |
|
919 | + if ($session['purchase_key'] === $payment_meta['key']) { |
|
920 | 920 | $return = true; |
921 | 921 | } |
922 | 922 | } |
923 | 923 | |
924 | - return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key ); |
|
924 | + return (bool) apply_filters('give_can_view_receipt', $return, $payment_key); |
|
925 | 925 | |
926 | 926 | } |
927 | 927 | |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | * |
931 | 931 | * Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar |
932 | 932 | */ |
933 | -if ( ! function_exists( 'cal_days_in_month' ) ) { |
|
933 | +if ( ! function_exists('cal_days_in_month')) { |
|
934 | 934 | /** |
935 | 935 | * cal_days_in_month |
936 | 936 | * |
@@ -940,8 +940,8 @@ discard block |
||
940 | 940 | * |
941 | 941 | * @return bool|string |
942 | 942 | */ |
943 | - function cal_days_in_month( $calendar, $month, $year ) { |
|
944 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
943 | + function cal_days_in_month($calendar, $month, $year) { |
|
944 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
945 | 945 | } |
946 | 946 | } |
947 | 947 | |
@@ -960,42 +960,42 @@ discard block |
||
960 | 960 | */ |
961 | 961 | function give_get_plugins() { |
962 | 962 | $plugins = get_plugins(); |
963 | - $active_plugin_paths = (array) get_option( 'active_plugins', array() ); |
|
963 | + $active_plugin_paths = (array) get_option('active_plugins', array()); |
|
964 | 964 | |
965 | - if ( is_multisite() ) { |
|
966 | - $network_activated_plugin_paths = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); |
|
967 | - $active_plugin_paths = array_merge( $active_plugin_paths, $network_activated_plugin_paths ); |
|
965 | + if (is_multisite()) { |
|
966 | + $network_activated_plugin_paths = array_keys(get_site_option('active_sitewide_plugins', array())); |
|
967 | + $active_plugin_paths = array_merge($active_plugin_paths, $network_activated_plugin_paths); |
|
968 | 968 | } |
969 | 969 | |
970 | - foreach ( $plugins as $plugin_path => $plugin_data ) { |
|
970 | + foreach ($plugins as $plugin_path => $plugin_data) { |
|
971 | 971 | // Is plugin active? |
972 | - if ( in_array( $plugin_path, $active_plugin_paths ) ) { |
|
973 | - $plugins[ $plugin_path ]['Status'] = 'active'; |
|
972 | + if (in_array($plugin_path, $active_plugin_paths)) { |
|
973 | + $plugins[$plugin_path]['Status'] = 'active'; |
|
974 | 974 | } else { |
975 | - $plugins[ $plugin_path ]['Status'] = 'inactive'; |
|
975 | + $plugins[$plugin_path]['Status'] = 'inactive'; |
|
976 | 976 | } |
977 | 977 | |
978 | - $dirname = strtolower( dirname( $plugin_path ) ); |
|
978 | + $dirname = strtolower(dirname($plugin_path)); |
|
979 | 979 | |
980 | 980 | // Is plugin a Give add-on by WordImpress? |
981 | - if ( strstr( $dirname, 'give-' ) && strstr( $plugin_data['AuthorURI'], 'wordimpress.com' ) ) { |
|
981 | + if (strstr($dirname, 'give-') && strstr($plugin_data['AuthorURI'], 'wordimpress.com')) { |
|
982 | 982 | // Plugin is a Give-addon. |
983 | - $plugins[ $plugin_path ]['Type'] = 'add-on'; |
|
983 | + $plugins[$plugin_path]['Type'] = 'add-on'; |
|
984 | 984 | |
985 | 985 | // Get license info from database. |
986 | - $plugin_name = str_replace( 'Give - ', '', $plugin_data['Name'] ); |
|
987 | - $db_option = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $plugin_name ) ) ) . '_license_active'; |
|
988 | - $license_active = get_option( $db_option ); |
|
986 | + $plugin_name = str_replace('Give - ', '', $plugin_data['Name']); |
|
987 | + $db_option = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($plugin_name))).'_license_active'; |
|
988 | + $license_active = get_option($db_option); |
|
989 | 989 | |
990 | 990 | // Does a valid license exist? |
991 | - if ( ! empty( $license_active ) && 'valid' === $license_active->license ) { |
|
992 | - $plugins[ $plugin_path ]['License'] = true; |
|
991 | + if ( ! empty($license_active) && 'valid' === $license_active->license) { |
|
992 | + $plugins[$plugin_path]['License'] = true; |
|
993 | 993 | } else { |
994 | - $plugins[ $plugin_path ]['License'] = false; |
|
994 | + $plugins[$plugin_path]['License'] = false; |
|
995 | 995 | } |
996 | 996 | } else { |
997 | 997 | // Plugin is not a Give add-on. |
998 | - $plugins[ $plugin_path ]['Type'] = 'other'; |
|
998 | + $plugins[$plugin_path]['Type'] = 'other'; |
|
999 | 999 | } |
1000 | 1000 | } |
1001 | 1001 | |
@@ -1012,16 +1012,16 @@ discard block |
||
1012 | 1012 | * |
1013 | 1013 | * @return bool |
1014 | 1014 | */ |
1015 | -function give_is_terms_enabled( $form_id ) { |
|
1016 | - $form_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
1015 | +function give_is_terms_enabled($form_id) { |
|
1016 | + $form_option = get_post_meta($form_id, '_give_terms_option', true); |
|
1017 | 1017 | |
1018 | 1018 | if ( |
1019 | - give_is_setting_enabled( $form_option, 'global' ) |
|
1020 | - && give_is_setting_enabled( give_get_option( 'terms' ) ) |
|
1019 | + give_is_setting_enabled($form_option, 'global') |
|
1020 | + && give_is_setting_enabled(give_get_option('terms')) |
|
1021 | 1021 | ) { |
1022 | 1022 | return true; |
1023 | 1023 | |
1024 | - } elseif ( give_is_setting_enabled( $form_option ) ) { |
|
1024 | + } elseif (give_is_setting_enabled($form_option)) { |
|
1025 | 1025 | return true; |
1026 | 1026 | |
1027 | 1027 | } else { |
@@ -812,10 +812,10 @@ discard block |
||
812 | 812 | } |
813 | 813 | |
814 | 814 | if ( ! is_int( $params[1] ) |
815 | - && ! is_float( $params[1] ) |
|
816 | - && ! is_string( $params[1] ) |
|
817 | - && $params[1] !== null |
|
818 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
815 | + && ! is_float( $params[1] ) |
|
816 | + && ! is_string( $params[1] ) |
|
817 | + && $params[1] !== null |
|
818 | + && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
819 | 819 | ) { |
820 | 820 | trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
821 | 821 | |
@@ -823,10 +823,10 @@ discard block |
||
823 | 823 | } |
824 | 824 | |
825 | 825 | if ( isset( $params[2] ) |
826 | - && ! is_int( $params[2] ) |
|
827 | - && ! is_float( $params[2] ) |
|
828 | - && ! is_string( $params[2] ) |
|
829 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
826 | + && ! is_int( $params[2] ) |
|
827 | + && ! is_float( $params[2] ) |
|
828 | + && ! is_string( $params[2] ) |
|
829 | + && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
830 | 830 | ) { |
831 | 831 | trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
832 | 832 |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * |
327 | 327 | * @since 1.0 |
328 | 328 | * |
329 | - * @param int|bool $form_id Form ID (default: false). |
|
329 | + * @param boolean $form_id Form ID (default: false). |
|
330 | 330 | * @param int $payment_id Payment ID. |
331 | 331 | * |
332 | 332 | * @return void |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | * @param int $year Year number. Default is null. |
645 | 645 | * @param int $hour Hour number. Default is null. |
646 | 646 | * |
647 | - * @return int $earnings Earnings |
|
647 | + * @return double $earnings Earnings |
|
648 | 648 | */ |
649 | 649 | function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
650 | 650 | |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | * |
960 | 960 | * @param int $payment_id Payment ID. |
961 | 961 | * |
962 | - * @return int $form_id Form ID. |
|
962 | + * @return string $form_id Form ID. |
|
963 | 963 | */ |
964 | 964 | function give_get_payment_form_id( $payment_id ) { |
965 | 965 | $payment = new Give_Payment( $payment_id ); |
@@ -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 | |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return object $payments Payments retrieved from the database |
45 | 45 | */ |
46 | -function give_get_payments( $args = array() ) { |
|
46 | +function give_get_payments($args = array()) { |
|
47 | 47 | |
48 | 48 | // Fallback to post objects to ensure backwards compatibility. |
49 | - if ( ! isset( $args['output'] ) ) { |
|
49 | + if ( ! isset($args['output'])) { |
|
50 | 50 | $args['output'] = 'posts'; |
51 | 51 | } |
52 | 52 | |
53 | - $args = apply_filters( 'give_get_payments_args', $args ); |
|
54 | - $payments = new Give_Payments_Query( $args ); |
|
53 | + $args = apply_filters('give_get_payments_args', $args); |
|
54 | + $payments = new Give_Payments_Query($args); |
|
55 | 55 | |
56 | 56 | return $payments->get_payments(); |
57 | 57 | } |
@@ -66,48 +66,48 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return mixed |
68 | 68 | */ |
69 | -function give_get_payment_by( $field = '', $value = '' ) { |
|
69 | +function give_get_payment_by($field = '', $value = '') { |
|
70 | 70 | |
71 | - if ( empty( $field ) || empty( $value ) ) { |
|
71 | + if (empty($field) || empty($value)) { |
|
72 | 72 | return false; |
73 | 73 | } |
74 | 74 | |
75 | - switch ( strtolower( $field ) ) { |
|
75 | + switch (strtolower($field)) { |
|
76 | 76 | |
77 | 77 | case 'id': |
78 | - $payment = new Give_Payment( $value ); |
|
78 | + $payment = new Give_Payment($value); |
|
79 | 79 | $id = $payment->ID; |
80 | 80 | |
81 | - if ( empty( $id ) ) { |
|
81 | + if (empty($id)) { |
|
82 | 82 | return false; |
83 | 83 | } |
84 | 84 | |
85 | 85 | break; |
86 | 86 | |
87 | 87 | case 'key': |
88 | - $payment = give_get_payments( array( |
|
88 | + $payment = give_get_payments(array( |
|
89 | 89 | 'meta_key' => '_give_payment_purchase_key', |
90 | 90 | 'meta_value' => $value, |
91 | 91 | 'posts_per_page' => 1, |
92 | 92 | 'fields' => 'ids', |
93 | - ) ); |
|
93 | + )); |
|
94 | 94 | |
95 | - if ( $payment ) { |
|
96 | - $payment = new Give_Payment( $payment[0] ); |
|
95 | + if ($payment) { |
|
96 | + $payment = new Give_Payment($payment[0]); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | break; |
100 | 100 | |
101 | 101 | case 'payment_number': |
102 | - $payment = give_get_payments( array( |
|
102 | + $payment = give_get_payments(array( |
|
103 | 103 | 'meta_key' => '_give_payment_number', |
104 | 104 | 'meta_value' => $value, |
105 | 105 | 'posts_per_page' => 1, |
106 | 106 | 'fields' => 'ids', |
107 | - ) ); |
|
107 | + )); |
|
108 | 108 | |
109 | - if ( $payment ) { |
|
110 | - $payment = new Give_Payment( $payment[0] ); |
|
109 | + if ($payment) { |
|
110 | + $payment = new Give_Payment($payment[0]); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | break; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | return false; |
117 | 117 | } |
118 | 118 | |
119 | - if ( $payment ) { |
|
119 | + if ($payment) { |
|
120 | 120 | return $payment; |
121 | 121 | } |
122 | 122 | |
@@ -132,23 +132,23 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return int|bool Payment ID if payment is inserted, false otherwise. |
134 | 134 | */ |
135 | -function give_insert_payment( $payment_data = array() ) { |
|
135 | +function give_insert_payment($payment_data = array()) { |
|
136 | 136 | |
137 | - if ( empty( $payment_data ) ) { |
|
137 | + if (empty($payment_data)) { |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | 141 | $payment = new Give_Payment(); |
142 | - $gateway = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : ''; |
|
143 | - $gateway = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway; |
|
144 | - $form_id = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0; |
|
145 | - $price_id = isset( $payment_data['give_price_id'] ) ? $payment_data['give_price_id'] : give_get_price_id( $payment_data['give_form_id'], $payment_data['price'] ); |
|
146 | - $form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id ); |
|
142 | + $gateway = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : ''; |
|
143 | + $gateway = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway; |
|
144 | + $form_id = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0; |
|
145 | + $price_id = isset($payment_data['give_price_id']) ? $payment_data['give_price_id'] : give_get_price_id($payment_data['give_form_id'], $payment_data['price']); |
|
146 | + $form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id); |
|
147 | 147 | |
148 | 148 | // Set properties. |
149 | 149 | $payment->total = $payment_data['price']; |
150 | - $payment->status = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending'; |
|
151 | - $payment->currency = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency(); |
|
150 | + $payment->status = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending'; |
|
151 | + $payment->currency = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency(); |
|
152 | 152 | $payment->user_info = $payment_data['user_info']; |
153 | 153 | $payment->gateway = $gateway; |
154 | 154 | $payment->form_title = $form_title; |
@@ -162,31 +162,31 @@ discard block |
||
162 | 162 | $payment->ip = give_get_ip(); |
163 | 163 | $payment->key = $payment_data['purchase_key']; |
164 | 164 | $payment->mode = give_is_test_mode() ? 'test' : 'live'; |
165 | - $payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : ''; |
|
165 | + $payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : ''; |
|
166 | 166 | |
167 | 167 | // Add the donation. |
168 | 168 | $args = array( |
169 | 169 | 'price' => $payment->total, |
170 | 170 | 'price_id' => $payment->price_id, |
171 | - 'fees' => isset( $payment_data['fees'] ) ? $payment_data['fees'] : array(), |
|
171 | + 'fees' => isset($payment_data['fees']) ? $payment_data['fees'] : array(), |
|
172 | 172 | ); |
173 | 173 | |
174 | - $payment->add_donation( $payment->form_id, $args ); |
|
174 | + $payment->add_donation($payment->form_id, $args); |
|
175 | 175 | |
176 | 176 | // Set date if present. |
177 | - if ( isset( $payment_data['post_date'] ) ) { |
|
177 | + if (isset($payment_data['post_date'])) { |
|
178 | 178 | $payment->date = $payment_data['post_date']; |
179 | 179 | } |
180 | 180 | |
181 | 181 | // Handle sequential payments. |
182 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
182 | + if (give_get_option('enable_sequential')) { |
|
183 | 183 | $number = give_get_next_payment_number(); |
184 | - $payment->number = give_format_payment_number( $number ); |
|
185 | - update_option( 'give_last_payment_number', $number ); |
|
184 | + $payment->number = give_format_payment_number($number); |
|
185 | + update_option('give_last_payment_number', $number); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | // Clear the user's donation cache. |
189 | - delete_transient( 'give_user_' . $payment_data['user_info']['id'] . '_purchases' ); |
|
189 | + delete_transient('give_user_'.$payment_data['user_info']['id'].'_purchases'); |
|
190 | 190 | |
191 | 191 | // Save payment. |
192 | 192 | $payment->save(); |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | * @param int $payment_id The payment ID. |
200 | 200 | * @param array $payment_data Arguments passed. |
201 | 201 | */ |
202 | - do_action( 'give_insert_payment', $payment->ID, $payment_data ); |
|
202 | + do_action('give_insert_payment', $payment->ID, $payment_data); |
|
203 | 203 | |
204 | 204 | // Return payment ID upon success. |
205 | - if ( ! empty( $payment->ID ) ) { |
|
205 | + if ( ! empty($payment->ID)) { |
|
206 | 206 | return $payment->ID; |
207 | 207 | } |
208 | 208 | |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @return bool|int |
220 | 220 | */ |
221 | -function give_create_payment( $payment_data ) { |
|
221 | +function give_create_payment($payment_data) { |
|
222 | 222 | |
223 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
224 | - $price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : ''; |
|
223 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
224 | + $price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : ''; |
|
225 | 225 | |
226 | 226 | // Collect payment data. |
227 | 227 | $insert_payment_data = array( |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @param array $insert_payment_data |
247 | 247 | */ |
248 | - $insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data ); |
|
248 | + $insert_payment_data = apply_filters('give_create_payment', $insert_payment_data); |
|
249 | 249 | |
250 | 250 | // Record the pending payment. |
251 | - return give_insert_payment( $insert_payment_data ); |
|
251 | + return give_insert_payment($insert_payment_data); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return bool |
263 | 263 | */ |
264 | -function give_update_payment_status( $payment_id, $new_status = 'publish' ) { |
|
264 | +function give_update_payment_status($payment_id, $new_status = 'publish') { |
|
265 | 265 | |
266 | - $payment = new Give_Payment( $payment_id ); |
|
266 | + $payment = new Give_Payment($payment_id); |
|
267 | 267 | $payment->status = $new_status; |
268 | 268 | $updated = $payment->save(); |
269 | 269 | |
@@ -282,37 +282,37 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @return void |
284 | 284 | */ |
285 | -function give_delete_purchase( $payment_id = 0, $update_customer = true ) { |
|
285 | +function give_delete_purchase($payment_id = 0, $update_customer = true) { |
|
286 | 286 | global $give_logs; |
287 | 287 | |
288 | - $payment = new Give_Payment( $payment_id ); |
|
289 | - $amount = give_get_payment_amount( $payment_id ); |
|
288 | + $payment = new Give_Payment($payment_id); |
|
289 | + $amount = give_get_payment_amount($payment_id); |
|
290 | 290 | $status = $payment->post_status; |
291 | - $customer_id = give_get_payment_customer_id( $payment_id ); |
|
292 | - $customer = new Give_Customer( $customer_id ); |
|
291 | + $customer_id = give_get_payment_customer_id($payment_id); |
|
292 | + $customer = new Give_Customer($customer_id); |
|
293 | 293 | |
294 | 294 | // Only undo donations that aren't these statuses. |
295 | - $dont_undo_statuses = apply_filters( 'give_undo_purchase_statuses', array( |
|
295 | + $dont_undo_statuses = apply_filters('give_undo_purchase_statuses', array( |
|
296 | 296 | 'pending', |
297 | 297 | 'cancelled', |
298 | - ) ); |
|
298 | + )); |
|
299 | 299 | |
300 | - if ( ! in_array( $status, $dont_undo_statuses ) ) { |
|
301 | - give_undo_purchase( false, $payment_id ); |
|
300 | + if ( ! in_array($status, $dont_undo_statuses)) { |
|
301 | + give_undo_purchase(false, $payment_id); |
|
302 | 302 | } |
303 | 303 | |
304 | - if ( $status == 'publish' ) { |
|
304 | + if ($status == 'publish') { |
|
305 | 305 | |
306 | 306 | // Only decrease earnings if they haven't already been decreased (or were never increased for this payment). |
307 | - give_decrease_total_earnings( $amount ); |
|
307 | + give_decrease_total_earnings($amount); |
|
308 | 308 | // Clear the This Month earnings (this_monththis_month is NOT a typo). |
309 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
309 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
310 | 310 | |
311 | - if ( $customer->id && $update_customer ) { |
|
311 | + if ($customer->id && $update_customer) { |
|
312 | 312 | |
313 | 313 | // Decrement the stats for the donor. |
314 | 314 | $customer->decrease_purchase_count(); |
315 | - $customer->decrease_value( $amount ); |
|
315 | + $customer->decrease_value($amount); |
|
316 | 316 | |
317 | 317 | } |
318 | 318 | } |
@@ -324,17 +324,17 @@ discard block |
||
324 | 324 | * |
325 | 325 | * @param int $payment_id Payment ID. |
326 | 326 | */ |
327 | - do_action( 'give_payment_delete', $payment_id ); |
|
327 | + do_action('give_payment_delete', $payment_id); |
|
328 | 328 | |
329 | - if ( $customer->id && $update_customer ) { |
|
329 | + if ($customer->id && $update_customer) { |
|
330 | 330 | |
331 | 331 | // Remove the payment ID from the donor. |
332 | - $customer->remove_payment( $payment_id ); |
|
332 | + $customer->remove_payment($payment_id); |
|
333 | 333 | |
334 | 334 | } |
335 | 335 | |
336 | 336 | // Remove the payment. |
337 | - wp_delete_post( $payment_id, true ); |
|
337 | + wp_delete_post($payment_id, true); |
|
338 | 338 | |
339 | 339 | // Remove related sale log entries. |
340 | 340 | $give_logs->delete_logs( |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @param int $payment_id Payment ID. |
357 | 357 | */ |
358 | - do_action( 'give_payment_deleted', $payment_id ); |
|
358 | + do_action('give_payment_deleted', $payment_id); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
@@ -371,25 +371,25 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @return void |
373 | 373 | */ |
374 | -function give_undo_purchase( $form_id = false, $payment_id ) { |
|
374 | +function give_undo_purchase($form_id = false, $payment_id) { |
|
375 | 375 | |
376 | - if ( ! empty( $form_id ) ) { |
|
376 | + if ( ! empty($form_id)) { |
|
377 | 377 | $form_id = false; |
378 | - _give_deprected_argument( 'form_id', 'give_undo_purchase', '1.5' ); |
|
378 | + _give_deprected_argument('form_id', 'give_undo_purchase', '1.5'); |
|
379 | 379 | } |
380 | 380 | |
381 | - $payment = new Give_Payment( $payment_id ); |
|
381 | + $payment = new Give_Payment($payment_id); |
|
382 | 382 | |
383 | - $maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id ); |
|
384 | - if ( true === $maybe_decrease_earnings ) { |
|
383 | + $maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id); |
|
384 | + if (true === $maybe_decrease_earnings) { |
|
385 | 385 | // Decrease earnings. |
386 | - give_decrease_earnings( $payment->form_id, $payment->total ); |
|
386 | + give_decrease_earnings($payment->form_id, $payment->total); |
|
387 | 387 | } |
388 | 388 | |
389 | - $maybe_decrease_sales = apply_filters( 'give_decrease_sales_on_undo', true, $payment, $payment->form_id ); |
|
390 | - if ( true === $maybe_decrease_sales ) { |
|
389 | + $maybe_decrease_sales = apply_filters('give_decrease_sales_on_undo', true, $payment, $payment->form_id); |
|
390 | + if (true === $maybe_decrease_sales) { |
|
391 | 391 | // Decrease donation count. |
392 | - give_decrease_purchase_count( $payment->form_id ); |
|
392 | + give_decrease_purchase_count($payment->form_id); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | } |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | * |
407 | 407 | * @return array $count Number of payments sorted by payment status. |
408 | 408 | */ |
409 | -function give_count_payments( $args = array() ) { |
|
409 | +function give_count_payments($args = array()) { |
|
410 | 410 | |
411 | 411 | global $wpdb; |
412 | 412 | |
@@ -418,18 +418,18 @@ discard block |
||
418 | 418 | 'form_id' => null, |
419 | 419 | ); |
420 | 420 | |
421 | - $args = wp_parse_args( $args, $defaults ); |
|
421 | + $args = wp_parse_args($args, $defaults); |
|
422 | 422 | |
423 | 423 | $select = 'SELECT p.post_status,count( * ) AS num_posts'; |
424 | 424 | $join = ''; |
425 | 425 | $where = "WHERE p.post_type = 'give_payment'"; |
426 | 426 | |
427 | 427 | // Count payments for a specific user. |
428 | - if ( ! empty( $args['user'] ) ) { |
|
428 | + if ( ! empty($args['user'])) { |
|
429 | 429 | |
430 | - if ( is_email( $args['user'] ) ) { |
|
430 | + if (is_email($args['user'])) { |
|
431 | 431 | $field = 'email'; |
432 | - } elseif ( is_numeric( $args['user'] ) ) { |
|
432 | + } elseif (is_numeric($args['user'])) { |
|
433 | 433 | $field = 'id'; |
434 | 434 | } else { |
435 | 435 | $field = ''; |
@@ -437,105 +437,105 @@ discard block |
||
437 | 437 | |
438 | 438 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
439 | 439 | |
440 | - if ( ! empty( $field ) ) { |
|
440 | + if ( ! empty($field)) { |
|
441 | 441 | $where .= " |
442 | 442 | AND m.meta_key = '_give_payment_user_{$field}' |
443 | 443 | AND m.meta_value = '{$args['user']}'"; |
444 | 444 | } |
445 | 445 | |
446 | 446 | // Count payments for a search. |
447 | - } elseif ( ! empty( $args['s'] ) ) { |
|
447 | + } elseif ( ! empty($args['s'])) { |
|
448 | 448 | |
449 | - if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) { |
|
449 | + if (is_email($args['s']) || strlen($args['s']) == 32) { |
|
450 | 450 | |
451 | - if ( is_email( $args['s'] ) ) { |
|
451 | + if (is_email($args['s'])) { |
|
452 | 452 | $field = '_give_payment_user_email'; |
453 | 453 | } else { |
454 | 454 | $field = '_give_payment_purchase_key'; |
455 | 455 | } |
456 | 456 | |
457 | 457 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
458 | - $where .= $wpdb->prepare( ' |
|
458 | + $where .= $wpdb->prepare(' |
|
459 | 459 | AND m.meta_key = %s |
460 | 460 | AND m.meta_value = %s', |
461 | 461 | $field, |
462 | 462 | $args['s'] |
463 | 463 | ); |
464 | 464 | |
465 | - } elseif ( '#' == substr( $args['s'], 0, 1 ) ) { |
|
465 | + } elseif ('#' == substr($args['s'], 0, 1)) { |
|
466 | 466 | |
467 | - $search = str_replace( '#:', '', $args['s'] ); |
|
468 | - $search = str_replace( '#', '', $search ); |
|
467 | + $search = str_replace('#:', '', $args['s']); |
|
468 | + $search = str_replace('#', '', $search); |
|
469 | 469 | |
470 | 470 | $select = 'SELECT p2.post_status,count( * ) AS num_posts '; |
471 | 471 | $join = "LEFT JOIN $wpdb->postmeta m ON m.meta_key = '_give_log_payment_id' AND m.post_id = p.ID "; |
472 | 472 | $join .= "INNER JOIN $wpdb->posts p2 ON m.meta_value = p2.ID "; |
473 | 473 | $where = "WHERE p.post_type = 'give_log' "; |
474 | - $where .= $wpdb->prepare( 'AND p.post_parent = %d} ', $search ); |
|
474 | + $where .= $wpdb->prepare('AND p.post_parent = %d} ', $search); |
|
475 | 475 | |
476 | - } elseif ( is_numeric( $args['s'] ) ) { |
|
476 | + } elseif (is_numeric($args['s'])) { |
|
477 | 477 | |
478 | 478 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
479 | - $where .= $wpdb->prepare( " |
|
479 | + $where .= $wpdb->prepare(" |
|
480 | 480 | AND m.meta_key = '_give_payment_user_id' |
481 | 481 | AND m.meta_value = %d", |
482 | 482 | $args['s'] |
483 | 483 | ); |
484 | 484 | |
485 | 485 | } else { |
486 | - $search = $wpdb->esc_like( $args['s'] ); |
|
487 | - $search = '%' . $search . '%'; |
|
486 | + $search = $wpdb->esc_like($args['s']); |
|
487 | + $search = '%'.$search.'%'; |
|
488 | 488 | |
489 | - $where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search ); |
|
489 | + $where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search); |
|
490 | 490 | } |
491 | 491 | } |
492 | 492 | |
493 | - if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) { |
|
493 | + if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) { |
|
494 | 494 | |
495 | - $where .= $wpdb->prepare( ' AND p.post_parent = %d', $args['form_id'] ); |
|
495 | + $where .= $wpdb->prepare(' AND p.post_parent = %d', $args['form_id']); |
|
496 | 496 | |
497 | 497 | } |
498 | 498 | // Limit payments count by date. |
499 | - if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) { |
|
499 | + if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) { |
|
500 | 500 | |
501 | - $date_parts = explode( '/', $args['start-date'] ); |
|
502 | - $month = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0; |
|
503 | - $day = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0; |
|
504 | - $year = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0; |
|
501 | + $date_parts = explode('/', $args['start-date']); |
|
502 | + $month = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0; |
|
503 | + $day = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0; |
|
504 | + $year = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0; |
|
505 | 505 | |
506 | - $is_date = checkdate( $month, $day, $year ); |
|
507 | - if ( false !== $is_date ) { |
|
506 | + $is_date = checkdate($month, $day, $year); |
|
507 | + if (false !== $is_date) { |
|
508 | 508 | |
509 | - $date = new DateTime( $args['start-date'] ); |
|
510 | - $where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) ); |
|
509 | + $date = new DateTime($args['start-date']); |
|
510 | + $where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d')); |
|
511 | 511 | |
512 | 512 | } |
513 | 513 | |
514 | 514 | // Fixes an issue with the payments list table counts when no end date is specified (partiy with stats class). |
515 | - if ( empty( $args['end-date'] ) ) { |
|
515 | + if (empty($args['end-date'])) { |
|
516 | 516 | $args['end-date'] = $args['start-date']; |
517 | 517 | } |
518 | 518 | } |
519 | 519 | |
520 | - if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) { |
|
520 | + if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) { |
|
521 | 521 | |
522 | - $date_parts = explode( '/', $args['end-date'] ); |
|
522 | + $date_parts = explode('/', $args['end-date']); |
|
523 | 523 | |
524 | - $month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0; |
|
525 | - $day = ! empty( $date_parts[1] ) ? $date_parts[1] : 0; |
|
526 | - $year = ! empty( $date_parts[2] ) ? $date_parts[2] : 0; |
|
524 | + $month = ! empty($date_parts[0]) ? $date_parts[0] : 0; |
|
525 | + $day = ! empty($date_parts[1]) ? $date_parts[1] : 0; |
|
526 | + $year = ! empty($date_parts[2]) ? $date_parts[2] : 0; |
|
527 | 527 | |
528 | - $is_date = checkdate( $month, $day, $year ); |
|
529 | - if ( false !== $is_date ) { |
|
528 | + $is_date = checkdate($month, $day, $year); |
|
529 | + if (false !== $is_date) { |
|
530 | 530 | |
531 | - $date = new DateTime( $args['end-date'] ); |
|
532 | - $where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) ); |
|
531 | + $date = new DateTime($args['end-date']); |
|
532 | + $where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d')); |
|
533 | 533 | |
534 | 534 | } |
535 | 535 | } |
536 | 536 | |
537 | - $where = apply_filters( 'give_count_payments_where', $where ); |
|
538 | - $join = apply_filters( 'give_count_payments_join', $join ); |
|
537 | + $where = apply_filters('give_count_payments_where', $where); |
|
538 | + $join = apply_filters('give_count_payments_join', $join); |
|
539 | 539 | |
540 | 540 | $query = "$select |
541 | 541 | FROM $wpdb->posts p |
@@ -544,36 +544,36 @@ discard block |
||
544 | 544 | GROUP BY p.post_status |
545 | 545 | "; |
546 | 546 | |
547 | - $cache_key = md5( $query ); |
|
547 | + $cache_key = md5($query); |
|
548 | 548 | |
549 | - $count = wp_cache_get( $cache_key, 'counts' ); |
|
550 | - if ( false !== $count ) { |
|
549 | + $count = wp_cache_get($cache_key, 'counts'); |
|
550 | + if (false !== $count) { |
|
551 | 551 | return $count; |
552 | 552 | } |
553 | 553 | |
554 | - $count = $wpdb->get_results( $query, ARRAY_A ); |
|
554 | + $count = $wpdb->get_results($query, ARRAY_A); |
|
555 | 555 | |
556 | 556 | $stats = array(); |
557 | 557 | $statuses = get_post_stati(); |
558 | - if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) { |
|
559 | - unset( $statuses['private'] ); |
|
558 | + if (isset($statuses['private']) && empty($args['s'])) { |
|
559 | + unset($statuses['private']); |
|
560 | 560 | } |
561 | 561 | |
562 | - foreach ( $statuses as $state ) { |
|
563 | - $stats[ $state ] = 0; |
|
562 | + foreach ($statuses as $state) { |
|
563 | + $stats[$state] = 0; |
|
564 | 564 | } |
565 | 565 | |
566 | - foreach ( (array) $count as $row ) { |
|
566 | + foreach ((array) $count as $row) { |
|
567 | 567 | |
568 | - if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) { |
|
568 | + if ('private' == $row['post_status'] && empty($args['s'])) { |
|
569 | 569 | continue; |
570 | 570 | } |
571 | 571 | |
572 | - $stats[ $row['post_status'] ] = $row['num_posts']; |
|
572 | + $stats[$row['post_status']] = $row['num_posts']; |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | $stats = (object) $stats; |
576 | - wp_cache_set( $cache_key, $stats, 'counts' ); |
|
576 | + wp_cache_set($cache_key, $stats, 'counts'); |
|
577 | 577 | |
578 | 578 | return $stats; |
579 | 579 | } |
@@ -588,11 +588,11 @@ discard block |
||
588 | 588 | * |
589 | 589 | * @return bool $exists True if payment exists, false otherwise. |
590 | 590 | */ |
591 | -function give_check_for_existing_payment( $payment_id ) { |
|
591 | +function give_check_for_existing_payment($payment_id) { |
|
592 | 592 | $exists = false; |
593 | - $payment = new Give_Payment( $payment_id ); |
|
593 | + $payment = new Give_Payment($payment_id); |
|
594 | 594 | |
595 | - if ( $payment_id === $payment->ID && 'publish' === $payment->status ) { |
|
595 | + if ($payment_id === $payment->ID && 'publish' === $payment->status) { |
|
596 | 596 | $exists = true; |
597 | 597 | } |
598 | 598 | |
@@ -610,31 +610,31 @@ discard block |
||
610 | 610 | * |
611 | 611 | * @return bool|mixed True if payment status exists, false otherwise. |
612 | 612 | */ |
613 | -function give_get_payment_status( $payment, $return_label = false ) { |
|
613 | +function give_get_payment_status($payment, $return_label = false) { |
|
614 | 614 | |
615 | - if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) { |
|
615 | + if ( ! is_object($payment) || ! isset($payment->post_status)) { |
|
616 | 616 | return false; |
617 | 617 | } |
618 | 618 | |
619 | 619 | $statuses = give_get_payment_statuses(); |
620 | 620 | |
621 | - if ( ! is_array( $statuses ) || empty( $statuses ) ) { |
|
621 | + if ( ! is_array($statuses) || empty($statuses)) { |
|
622 | 622 | return false; |
623 | 623 | } |
624 | 624 | |
625 | 625 | // Get payment object if no already given. |
626 | - $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID ); |
|
626 | + $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID); |
|
627 | 627 | |
628 | - if ( array_key_exists( $payment->status, $statuses ) ) { |
|
629 | - if ( true === $return_label ) { |
|
628 | + if (array_key_exists($payment->status, $statuses)) { |
|
629 | + if (true === $return_label) { |
|
630 | 630 | // Return translated status label. |
631 | - return $statuses[ $payment->status ]; |
|
631 | + return $statuses[$payment->status]; |
|
632 | 632 | } else { |
633 | 633 | // Account that our 'publish' status is labeled 'Complete' |
634 | 634 | $post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status; |
635 | 635 | |
636 | 636 | // Make sure we're matching cases, since they matter |
637 | - return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) ); |
|
637 | + return array_search(strtolower($post_status), array_map('strtolower', $statuses)); |
|
638 | 638 | } |
639 | 639 | } |
640 | 640 | |
@@ -650,17 +650,17 @@ discard block |
||
650 | 650 | */ |
651 | 651 | function give_get_payment_statuses() { |
652 | 652 | $payment_statuses = array( |
653 | - 'pending' => __( 'Pending', 'give' ), |
|
654 | - 'publish' => __( 'Complete', 'give' ), |
|
655 | - 'refunded' => __( 'Refunded', 'give' ), |
|
656 | - 'failed' => __( 'Failed', 'give' ), |
|
657 | - 'cancelled' => __( 'Cancelled', 'give' ), |
|
658 | - 'abandoned' => __( 'Abandoned', 'give' ), |
|
659 | - 'preapproval' => __( 'Pre-Approved', 'give' ), |
|
660 | - 'revoked' => __( 'Revoked', 'give' ), |
|
653 | + 'pending' => __('Pending', 'give'), |
|
654 | + 'publish' => __('Complete', 'give'), |
|
655 | + 'refunded' => __('Refunded', 'give'), |
|
656 | + 'failed' => __('Failed', 'give'), |
|
657 | + 'cancelled' => __('Cancelled', 'give'), |
|
658 | + 'abandoned' => __('Abandoned', 'give'), |
|
659 | + 'preapproval' => __('Pre-Approved', 'give'), |
|
660 | + 'revoked' => __('Revoked', 'give'), |
|
661 | 661 | ); |
662 | 662 | |
663 | - return apply_filters( 'give_payment_statuses', $payment_statuses ); |
|
663 | + return apply_filters('give_payment_statuses', $payment_statuses); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
@@ -673,10 +673,10 @@ discard block |
||
673 | 673 | * @return array $payment_status All the available payment statuses. |
674 | 674 | */ |
675 | 675 | function give_get_payment_status_keys() { |
676 | - $statuses = array_keys( give_get_payment_statuses() ); |
|
677 | - asort( $statuses ); |
|
676 | + $statuses = array_keys(give_get_payment_statuses()); |
|
677 | + asort($statuses); |
|
678 | 678 | |
679 | - return array_values( $statuses ); |
|
679 | + return array_values($statuses); |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | /** |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | * |
692 | 692 | * @return int $earnings Earnings |
693 | 693 | */ |
694 | -function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
|
694 | +function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) { |
|
695 | 695 | |
696 | 696 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead. |
697 | 697 | global $wpdb; |
@@ -701,41 +701,41 @@ discard block |
||
701 | 701 | 'nopaging' => true, |
702 | 702 | 'year' => $year, |
703 | 703 | 'monthnum' => $month_num, |
704 | - 'post_status' => array( 'publish' ), |
|
704 | + 'post_status' => array('publish'), |
|
705 | 705 | 'fields' => 'ids', |
706 | 706 | 'update_post_term_cache' => false, |
707 | 707 | ); |
708 | - if ( ! empty( $day ) ) { |
|
708 | + if ( ! empty($day)) { |
|
709 | 709 | $args['day'] = $day; |
710 | 710 | } |
711 | 711 | |
712 | - if ( ! empty( $hour ) ) { |
|
712 | + if ( ! empty($hour)) { |
|
713 | 713 | $args['hour'] = $hour; |
714 | 714 | } |
715 | 715 | |
716 | - $args = apply_filters( 'give_get_earnings_by_date_args', $args ); |
|
717 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
716 | + $args = apply_filters('give_get_earnings_by_date_args', $args); |
|
717 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
718 | 718 | |
719 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
719 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
720 | 720 | $earnings = false; |
721 | 721 | } else { |
722 | - $earnings = get_transient( $key ); |
|
722 | + $earnings = get_transient($key); |
|
723 | 723 | } |
724 | 724 | |
725 | - if ( false === $earnings ) { |
|
726 | - $sales = get_posts( $args ); |
|
725 | + if (false === $earnings) { |
|
726 | + $sales = get_posts($args); |
|
727 | 727 | $earnings = 0; |
728 | - if ( $sales ) { |
|
729 | - $sales = implode( ',', $sales ); |
|
728 | + if ($sales) { |
|
729 | + $sales = implode(',', $sales); |
|
730 | 730 | |
731 | - $earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})" ); |
|
731 | + $earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})"); |
|
732 | 732 | |
733 | 733 | } |
734 | 734 | // Cache the results for one hour. |
735 | - set_transient( $key, $earnings, HOUR_IN_SECONDS ); |
|
735 | + set_transient($key, $earnings, HOUR_IN_SECONDS); |
|
736 | 736 | } |
737 | 737 | |
738 | - return round( $earnings, 2 ); |
|
738 | + return round($earnings, 2); |
|
739 | 739 | } |
740 | 740 | |
741 | 741 | /** |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | * |
751 | 751 | * @return int $count Sales |
752 | 752 | */ |
753 | -function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) { |
|
753 | +function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) { |
|
754 | 754 | |
755 | 755 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead. |
756 | 756 | $args = array( |
@@ -758,14 +758,14 @@ discard block |
||
758 | 758 | 'nopaging' => true, |
759 | 759 | 'year' => $year, |
760 | 760 | 'fields' => 'ids', |
761 | - 'post_status' => array( 'publish' ), |
|
761 | + 'post_status' => array('publish'), |
|
762 | 762 | 'update_post_meta_cache' => false, |
763 | 763 | 'update_post_term_cache' => false, |
764 | 764 | ); |
765 | 765 | |
766 | - $show_free = apply_filters( 'give_sales_by_date_show_free', true, $args ); |
|
766 | + $show_free = apply_filters('give_sales_by_date_show_free', true, $args); |
|
767 | 767 | |
768 | - if ( false === $show_free ) { |
|
768 | + if (false === $show_free) { |
|
769 | 769 | $args['meta_query'] = array( |
770 | 770 | array( |
771 | 771 | 'key' => '_give_payment_total', |
@@ -776,33 +776,33 @@ discard block |
||
776 | 776 | ); |
777 | 777 | } |
778 | 778 | |
779 | - if ( ! empty( $month_num ) ) { |
|
779 | + if ( ! empty($month_num)) { |
|
780 | 780 | $args['monthnum'] = $month_num; |
781 | 781 | } |
782 | 782 | |
783 | - if ( ! empty( $day ) ) { |
|
783 | + if ( ! empty($day)) { |
|
784 | 784 | $args['day'] = $day; |
785 | 785 | } |
786 | 786 | |
787 | - if ( ! empty( $hour ) ) { |
|
787 | + if ( ! empty($hour)) { |
|
788 | 788 | $args['hour'] = $hour; |
789 | 789 | } |
790 | 790 | |
791 | - $args = apply_filters( 'give_get_sales_by_date_args', $args ); |
|
791 | + $args = apply_filters('give_get_sales_by_date_args', $args); |
|
792 | 792 | |
793 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
793 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
794 | 794 | |
795 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
795 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
796 | 796 | $count = false; |
797 | 797 | } else { |
798 | - $count = get_transient( $key ); |
|
798 | + $count = get_transient($key); |
|
799 | 799 | } |
800 | 800 | |
801 | - if ( false === $count ) { |
|
802 | - $sales = new WP_Query( $args ); |
|
801 | + if (false === $count) { |
|
802 | + $sales = new WP_Query($args); |
|
803 | 803 | $count = (int) $sales->post_count; |
804 | 804 | // Cache the results for one hour. |
805 | - set_transient( $key, $count, HOUR_IN_SECONDS ); |
|
805 | + set_transient($key, $count, HOUR_IN_SECONDS); |
|
806 | 806 | } |
807 | 807 | |
808 | 808 | return $count; |
@@ -817,19 +817,19 @@ discard block |
||
817 | 817 | * |
818 | 818 | * @return bool $ret True if complete, false otherwise. |
819 | 819 | */ |
820 | -function give_is_payment_complete( $payment_id ) { |
|
821 | - $payment = new Give_Payment( $payment_id ); |
|
820 | +function give_is_payment_complete($payment_id) { |
|
821 | + $payment = new Give_Payment($payment_id); |
|
822 | 822 | |
823 | 823 | $ret = false; |
824 | 824 | |
825 | - if ( $payment->ID > 0 ) { |
|
825 | + if ($payment->ID > 0) { |
|
826 | 826 | |
827 | - if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) { |
|
827 | + if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) { |
|
828 | 828 | $ret = true; |
829 | 829 | } |
830 | 830 | } |
831 | 831 | |
832 | - return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status ); |
|
832 | + return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status); |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | /** |
@@ -855,57 +855,57 @@ discard block |
||
855 | 855 | */ |
856 | 856 | function give_get_total_earnings() { |
857 | 857 | |
858 | - $total = get_option( 'give_earnings_total', false ); |
|
858 | + $total = get_option('give_earnings_total', false); |
|
859 | 859 | |
860 | 860 | // If no total stored in DB, use old method of calculating total earnings. |
861 | - if ( false === $total ) { |
|
861 | + if (false === $total) { |
|
862 | 862 | |
863 | 863 | global $wpdb; |
864 | 864 | |
865 | - $total = get_transient( 'give_earnings_total' ); |
|
865 | + $total = get_transient('give_earnings_total'); |
|
866 | 866 | |
867 | - if ( false === $total ) { |
|
867 | + if (false === $total) { |
|
868 | 868 | |
869 | 869 | $total = (float) 0; |
870 | 870 | |
871 | - $args = apply_filters( 'give_get_total_earnings_args', array( |
|
871 | + $args = apply_filters('give_get_total_earnings_args', array( |
|
872 | 872 | 'offset' => 0, |
873 | - 'number' => - 1, |
|
874 | - 'status' => array( 'publish' ), |
|
873 | + 'number' => -1, |
|
874 | + 'status' => array('publish'), |
|
875 | 875 | 'fields' => 'ids', |
876 | - ) ); |
|
876 | + )); |
|
877 | 877 | |
878 | - $payments = give_get_payments( $args ); |
|
879 | - if ( $payments ) { |
|
878 | + $payments = give_get_payments($args); |
|
879 | + if ($payments) { |
|
880 | 880 | |
881 | 881 | /** |
882 | 882 | * If performing a donation, we need to skip the very last payment in the database, |
883 | 883 | * since it calls give_increase_total_earnings() on completion, |
884 | 884 | * which results in duplicated earnings for the very first donation. |
885 | 885 | */ |
886 | - if ( did_action( 'give_update_payment_status' ) ) { |
|
887 | - array_pop( $payments ); |
|
886 | + if (did_action('give_update_payment_status')) { |
|
887 | + array_pop($payments); |
|
888 | 888 | } |
889 | 889 | |
890 | - if ( ! empty( $payments ) ) { |
|
891 | - $payments = implode( ',', $payments ); |
|
892 | - $total += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" ); |
|
890 | + if ( ! empty($payments)) { |
|
891 | + $payments = implode(',', $payments); |
|
892 | + $total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})"); |
|
893 | 893 | } |
894 | 894 | } |
895 | 895 | |
896 | 896 | // Cache results for 1 day. This cache is cleared automatically when a payment is made. |
897 | - set_transient( 'give_earnings_total', $total, 86400 ); |
|
897 | + set_transient('give_earnings_total', $total, 86400); |
|
898 | 898 | |
899 | 899 | // Store the total for the first time. |
900 | - update_option( 'give_earnings_total', $total ); |
|
900 | + update_option('give_earnings_total', $total); |
|
901 | 901 | } |
902 | 902 | } |
903 | 903 | |
904 | - if ( $total < 0 ) { |
|
904 | + if ($total < 0) { |
|
905 | 905 | $total = 0; // Don't ever show negative earnings. |
906 | 906 | } |
907 | 907 | |
908 | - return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) ); |
|
908 | + return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter())); |
|
909 | 909 | } |
910 | 910 | |
911 | 911 | /** |
@@ -918,10 +918,10 @@ discard block |
||
918 | 918 | * |
919 | 919 | * @return float $total Total earnings. |
920 | 920 | */ |
921 | -function give_increase_total_earnings( $amount = 0 ) { |
|
921 | +function give_increase_total_earnings($amount = 0) { |
|
922 | 922 | $total = give_get_total_earnings(); |
923 | 923 | $total += $amount; |
924 | - update_option( 'give_earnings_total', $total ); |
|
924 | + update_option('give_earnings_total', $total); |
|
925 | 925 | |
926 | 926 | return $total; |
927 | 927 | } |
@@ -935,13 +935,13 @@ discard block |
||
935 | 935 | * |
936 | 936 | * @return float $total Total earnings. |
937 | 937 | */ |
938 | -function give_decrease_total_earnings( $amount = 0 ) { |
|
938 | +function give_decrease_total_earnings($amount = 0) { |
|
939 | 939 | $total = give_get_total_earnings(); |
940 | 940 | $total -= $amount; |
941 | - if ( $total < 0 ) { |
|
941 | + if ($total < 0) { |
|
942 | 942 | $total = 0; |
943 | 943 | } |
944 | - update_option( 'give_earnings_total', $total ); |
|
944 | + update_option('give_earnings_total', $total); |
|
945 | 945 | |
946 | 946 | return $total; |
947 | 947 | } |
@@ -957,10 +957,10 @@ discard block |
||
957 | 957 | * |
958 | 958 | * @return mixed $meta Payment Meta. |
959 | 959 | */ |
960 | -function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) { |
|
961 | - $payment = new Give_Payment( $payment_id ); |
|
960 | +function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) { |
|
961 | + $payment = new Give_Payment($payment_id); |
|
962 | 962 | |
963 | - return $payment->get_meta( $meta_key, $single ); |
|
963 | + return $payment->get_meta($meta_key, $single); |
|
964 | 964 | } |
965 | 965 | |
966 | 966 | /** |
@@ -973,10 +973,10 @@ discard block |
||
973 | 973 | * |
974 | 974 | * @return mixed Meta ID if successful, false if unsuccessful. |
975 | 975 | */ |
976 | -function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
977 | - $payment = new Give_Payment( $payment_id ); |
|
976 | +function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') { |
|
977 | + $payment = new Give_Payment($payment_id); |
|
978 | 978 | |
979 | - return $payment->update_meta( $meta_key, $meta_value, $prev_value ); |
|
979 | + return $payment->update_meta($meta_key, $meta_value, $prev_value); |
|
980 | 980 | } |
981 | 981 | |
982 | 982 | /** |
@@ -988,8 +988,8 @@ discard block |
||
988 | 988 | * |
989 | 989 | * @return string $user_info User Info Meta Values. |
990 | 990 | */ |
991 | -function give_get_payment_meta_user_info( $payment_id ) { |
|
992 | - $payment = new Give_Payment( $payment_id ); |
|
991 | +function give_get_payment_meta_user_info($payment_id) { |
|
992 | + $payment = new Give_Payment($payment_id); |
|
993 | 993 | |
994 | 994 | return $payment->user_info; |
995 | 995 | } |
@@ -1005,8 +1005,8 @@ discard block |
||
1005 | 1005 | * |
1006 | 1006 | * @return int $form_id Form ID. |
1007 | 1007 | */ |
1008 | -function give_get_payment_form_id( $payment_id ) { |
|
1009 | - $payment = new Give_Payment( $payment_id ); |
|
1008 | +function give_get_payment_form_id($payment_id) { |
|
1009 | + $payment = new Give_Payment($payment_id); |
|
1010 | 1010 | |
1011 | 1011 | return $payment->form_id; |
1012 | 1012 | } |
@@ -1020,8 +1020,8 @@ discard block |
||
1020 | 1020 | * |
1021 | 1021 | * @return string $email User email. |
1022 | 1022 | */ |
1023 | -function give_get_payment_user_email( $payment_id ) { |
|
1024 | - $payment = new Give_Payment( $payment_id ); |
|
1023 | +function give_get_payment_user_email($payment_id) { |
|
1024 | + $payment = new Give_Payment($payment_id); |
|
1025 | 1025 | |
1026 | 1026 | return $payment->email; |
1027 | 1027 | } |
@@ -1035,11 +1035,11 @@ discard block |
||
1035 | 1035 | * |
1036 | 1036 | * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true) |
1037 | 1037 | */ |
1038 | -function give_is_guest_payment( $payment_id ) { |
|
1039 | - $payment_user_id = give_get_payment_user_id( $payment_id ); |
|
1040 | - $is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true; |
|
1038 | +function give_is_guest_payment($payment_id) { |
|
1039 | + $payment_user_id = give_get_payment_user_id($payment_id); |
|
1040 | + $is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true; |
|
1041 | 1041 | |
1042 | - return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id ); |
|
1042 | + return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id); |
|
1043 | 1043 | } |
1044 | 1044 | |
1045 | 1045 | /** |
@@ -1051,8 +1051,8 @@ discard block |
||
1051 | 1051 | * |
1052 | 1052 | * @return int $user_id User ID. |
1053 | 1053 | */ |
1054 | -function give_get_payment_user_id( $payment_id ) { |
|
1055 | - $payment = new Give_Payment( $payment_id ); |
|
1054 | +function give_get_payment_user_id($payment_id) { |
|
1055 | + $payment = new Give_Payment($payment_id); |
|
1056 | 1056 | |
1057 | 1057 | return $payment->user_id; |
1058 | 1058 | } |
@@ -1066,8 +1066,8 @@ discard block |
||
1066 | 1066 | * |
1067 | 1067 | * @return int $customer_id Customer ID. |
1068 | 1068 | */ |
1069 | -function give_get_payment_customer_id( $payment_id ) { |
|
1070 | - $payment = new Give_Payment( $payment_id ); |
|
1069 | +function give_get_payment_customer_id($payment_id) { |
|
1070 | + $payment = new Give_Payment($payment_id); |
|
1071 | 1071 | |
1072 | 1072 | return $payment->customer_id; |
1073 | 1073 | } |
@@ -1081,8 +1081,8 @@ discard block |
||
1081 | 1081 | * |
1082 | 1082 | * @return string $ip User IP. |
1083 | 1083 | */ |
1084 | -function give_get_payment_user_ip( $payment_id ) { |
|
1085 | - $payment = new Give_Payment( $payment_id ); |
|
1084 | +function give_get_payment_user_ip($payment_id) { |
|
1085 | + $payment = new Give_Payment($payment_id); |
|
1086 | 1086 | |
1087 | 1087 | return $payment->ip; |
1088 | 1088 | } |
@@ -1096,8 +1096,8 @@ discard block |
||
1096 | 1096 | * |
1097 | 1097 | * @return string $date The date the payment was completed. |
1098 | 1098 | */ |
1099 | -function give_get_payment_completed_date( $payment_id = 0 ) { |
|
1100 | - $payment = new Give_Payment( $payment_id ); |
|
1099 | +function give_get_payment_completed_date($payment_id = 0) { |
|
1100 | + $payment = new Give_Payment($payment_id); |
|
1101 | 1101 | |
1102 | 1102 | return $payment->completed_date; |
1103 | 1103 | } |
@@ -1111,8 +1111,8 @@ discard block |
||
1111 | 1111 | * |
1112 | 1112 | * @return string $gateway Gateway. |
1113 | 1113 | */ |
1114 | -function give_get_payment_gateway( $payment_id ) { |
|
1115 | - $payment = new Give_Payment( $payment_id ); |
|
1114 | +function give_get_payment_gateway($payment_id) { |
|
1115 | + $payment = new Give_Payment($payment_id); |
|
1116 | 1116 | |
1117 | 1117 | return $payment->gateway; |
1118 | 1118 | } |
@@ -1126,8 +1126,8 @@ discard block |
||
1126 | 1126 | * |
1127 | 1127 | * @return string $currency The currency code. |
1128 | 1128 | */ |
1129 | -function give_get_payment_currency_code( $payment_id = 0 ) { |
|
1130 | - $payment = new Give_Payment( $payment_id ); |
|
1129 | +function give_get_payment_currency_code($payment_id = 0) { |
|
1130 | + $payment = new Give_Payment($payment_id); |
|
1131 | 1131 | |
1132 | 1132 | return $payment->currency; |
1133 | 1133 | } |
@@ -1141,10 +1141,10 @@ discard block |
||
1141 | 1141 | * |
1142 | 1142 | * @return string $currency The currency name. |
1143 | 1143 | */ |
1144 | -function give_get_payment_currency( $payment_id = 0 ) { |
|
1145 | - $currency = give_get_payment_currency_code( $payment_id ); |
|
1144 | +function give_get_payment_currency($payment_id = 0) { |
|
1145 | + $currency = give_get_payment_currency_code($payment_id); |
|
1146 | 1146 | |
1147 | - return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id ); |
|
1147 | + return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id); |
|
1148 | 1148 | } |
1149 | 1149 | |
1150 | 1150 | /** |
@@ -1156,8 +1156,8 @@ discard block |
||
1156 | 1156 | * |
1157 | 1157 | * @return string $key Donation key. |
1158 | 1158 | */ |
1159 | -function give_get_payment_key( $payment_id = 0 ) { |
|
1160 | - $payment = new Give_Payment( $payment_id ); |
|
1159 | +function give_get_payment_key($payment_id = 0) { |
|
1160 | + $payment = new Give_Payment($payment_id); |
|
1161 | 1161 | |
1162 | 1162 | return $payment->key; |
1163 | 1163 | } |
@@ -1173,8 +1173,8 @@ discard block |
||
1173 | 1173 | * |
1174 | 1174 | * @return string $number Payment order number. |
1175 | 1175 | */ |
1176 | -function give_get_payment_number( $payment_id = 0 ) { |
|
1177 | - $payment = new Give_Payment( $payment_id ); |
|
1176 | +function give_get_payment_number($payment_id = 0) { |
|
1177 | + $payment = new Give_Payment($payment_id); |
|
1178 | 1178 | |
1179 | 1179 | return $payment->number; |
1180 | 1180 | } |
@@ -1188,23 +1188,23 @@ discard block |
||
1188 | 1188 | * |
1189 | 1189 | * @return string The formatted payment number. |
1190 | 1190 | */ |
1191 | -function give_format_payment_number( $number ) { |
|
1191 | +function give_format_payment_number($number) { |
|
1192 | 1192 | |
1193 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1193 | + if ( ! give_get_option('enable_sequential')) { |
|
1194 | 1194 | return $number; |
1195 | 1195 | } |
1196 | 1196 | |
1197 | - if ( ! is_numeric( $number ) ) { |
|
1197 | + if ( ! is_numeric($number)) { |
|
1198 | 1198 | return $number; |
1199 | 1199 | } |
1200 | 1200 | |
1201 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1202 | - $number = absint( $number ); |
|
1203 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1201 | + $prefix = give_get_option('sequential_prefix'); |
|
1202 | + $number = absint($number); |
|
1203 | + $postfix = give_get_option('sequential_postfix'); |
|
1204 | 1204 | |
1205 | - $formatted_number = $prefix . $number . $postfix; |
|
1205 | + $formatted_number = $prefix.$number.$postfix; |
|
1206 | 1206 | |
1207 | - return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix ); |
|
1207 | + return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix); |
|
1208 | 1208 | } |
1209 | 1209 | |
1210 | 1210 | /** |
@@ -1217,17 +1217,17 @@ discard block |
||
1217 | 1217 | */ |
1218 | 1218 | function give_get_next_payment_number() { |
1219 | 1219 | |
1220 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1220 | + if ( ! give_get_option('enable_sequential')) { |
|
1221 | 1221 | return false; |
1222 | 1222 | } |
1223 | 1223 | |
1224 | - $number = get_option( 'give_last_payment_number' ); |
|
1225 | - $start = give_get_option( 'sequential_start', 1 ); |
|
1224 | + $number = get_option('give_last_payment_number'); |
|
1225 | + $start = give_get_option('sequential_start', 1); |
|
1226 | 1226 | $increment_number = true; |
1227 | 1227 | |
1228 | - if ( false !== $number ) { |
|
1228 | + if (false !== $number) { |
|
1229 | 1229 | |
1230 | - if ( empty( $number ) ) { |
|
1230 | + if (empty($number)) { |
|
1231 | 1231 | |
1232 | 1232 | $number = $start; |
1233 | 1233 | $increment_number = false; |
@@ -1236,24 +1236,24 @@ discard block |
||
1236 | 1236 | } else { |
1237 | 1237 | |
1238 | 1238 | // This case handles the first addition of the new option, as well as if it get's deleted for any reason. |
1239 | - $payments = new Give_Payments_Query( array( |
|
1239 | + $payments = new Give_Payments_Query(array( |
|
1240 | 1240 | 'number' => 1, |
1241 | 1241 | 'order' => 'DESC', |
1242 | 1242 | 'orderby' => 'ID', |
1243 | 1243 | 'output' => 'posts', |
1244 | 1244 | 'fields' => 'ids', |
1245 | - ) ); |
|
1245 | + )); |
|
1246 | 1246 | $last_payment = $payments->get_payments(); |
1247 | 1247 | |
1248 | - if ( ! empty( $last_payment ) ) { |
|
1248 | + if ( ! empty($last_payment)) { |
|
1249 | 1249 | |
1250 | - $number = give_get_payment_number( $last_payment[0] ); |
|
1250 | + $number = give_get_payment_number($last_payment[0]); |
|
1251 | 1251 | |
1252 | 1252 | } |
1253 | 1253 | |
1254 | - if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) { |
|
1254 | + if ( ! empty($number) && $number !== (int) $last_payment[0]) { |
|
1255 | 1255 | |
1256 | - $number = give_remove_payment_prefix_postfix( $number ); |
|
1256 | + $number = give_remove_payment_prefix_postfix($number); |
|
1257 | 1257 | |
1258 | 1258 | } else { |
1259 | 1259 | |
@@ -1262,13 +1262,13 @@ discard block |
||
1262 | 1262 | } |
1263 | 1263 | } |
1264 | 1264 | |
1265 | - $increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number ); |
|
1265 | + $increment_number = apply_filters('give_increment_payment_number', $increment_number, $number); |
|
1266 | 1266 | |
1267 | - if ( $increment_number ) { |
|
1268 | - $number ++; |
|
1267 | + if ($increment_number) { |
|
1268 | + $number++; |
|
1269 | 1269 | } |
1270 | 1270 | |
1271 | - return apply_filters( 'give_get_next_payment_number', $number ); |
|
1271 | + return apply_filters('give_get_next_payment_number', $number); |
|
1272 | 1272 | } |
1273 | 1273 | |
1274 | 1274 | /** |
@@ -1280,25 +1280,25 @@ discard block |
||
1280 | 1280 | * |
1281 | 1281 | * @return string The new Payment number without prefix and postfix. |
1282 | 1282 | */ |
1283 | -function give_remove_payment_prefix_postfix( $number ) { |
|
1283 | +function give_remove_payment_prefix_postfix($number) { |
|
1284 | 1284 | |
1285 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1286 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1285 | + $prefix = give_get_option('sequential_prefix'); |
|
1286 | + $postfix = give_get_option('sequential_postfix'); |
|
1287 | 1287 | |
1288 | 1288 | // Remove prefix. |
1289 | - $number = preg_replace( '/' . $prefix . '/', '', $number, 1 ); |
|
1289 | + $number = preg_replace('/'.$prefix.'/', '', $number, 1); |
|
1290 | 1290 | |
1291 | 1291 | // Remove the postfix. |
1292 | - $length = strlen( $number ); |
|
1293 | - $postfix_pos = strrpos( $number, $postfix ); |
|
1294 | - if ( false !== $postfix_pos ) { |
|
1295 | - $number = substr_replace( $number, '', $postfix_pos, $length ); |
|
1292 | + $length = strlen($number); |
|
1293 | + $postfix_pos = strrpos($number, $postfix); |
|
1294 | + if (false !== $postfix_pos) { |
|
1295 | + $number = substr_replace($number, '', $postfix_pos, $length); |
|
1296 | 1296 | } |
1297 | 1297 | |
1298 | 1298 | // Ensure it's a whole number. |
1299 | - $number = intval( $number ); |
|
1299 | + $number = intval($number); |
|
1300 | 1300 | |
1301 | - return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix ); |
|
1301 | + return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix); |
|
1302 | 1302 | |
1303 | 1303 | } |
1304 | 1304 | |
@@ -1314,10 +1314,10 @@ discard block |
||
1314 | 1314 | * |
1315 | 1315 | * @return string $amount Fully formatted payment amount. |
1316 | 1316 | */ |
1317 | -function give_payment_amount( $payment_id = 0 ) { |
|
1318 | - $amount = give_get_payment_amount( $payment_id ); |
|
1317 | +function give_payment_amount($payment_id = 0) { |
|
1318 | + $amount = give_get_payment_amount($payment_id); |
|
1319 | 1319 | |
1320 | - return give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment_id ) ); |
|
1320 | + return give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment_id)); |
|
1321 | 1321 | } |
1322 | 1322 | |
1323 | 1323 | /** |
@@ -1330,11 +1330,11 @@ discard block |
||
1330 | 1330 | * |
1331 | 1331 | * @return mixed|void |
1332 | 1332 | */ |
1333 | -function give_get_payment_amount( $payment_id ) { |
|
1333 | +function give_get_payment_amount($payment_id) { |
|
1334 | 1334 | |
1335 | - $payment = new Give_Payment( $payment_id ); |
|
1335 | + $payment = new Give_Payment($payment_id); |
|
1336 | 1336 | |
1337 | - return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id ); |
|
1337 | + return apply_filters('give_payment_amount', floatval($payment->total), $payment_id); |
|
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | /** |
@@ -1350,10 +1350,10 @@ discard block |
||
1350 | 1350 | * |
1351 | 1351 | * @return array Fully formatted payment subtotal. |
1352 | 1352 | */ |
1353 | -function give_payment_subtotal( $payment_id = 0 ) { |
|
1354 | - $subtotal = give_get_payment_subtotal( $payment_id ); |
|
1353 | +function give_payment_subtotal($payment_id = 0) { |
|
1354 | + $subtotal = give_get_payment_subtotal($payment_id); |
|
1355 | 1355 | |
1356 | - return give_currency_filter( give_format_amount( $subtotal ), give_get_payment_currency_code( $payment_id ) ); |
|
1356 | + return give_currency_filter(give_format_amount($subtotal), give_get_payment_currency_code($payment_id)); |
|
1357 | 1357 | } |
1358 | 1358 | |
1359 | 1359 | /** |
@@ -1367,8 +1367,8 @@ discard block |
||
1367 | 1367 | * |
1368 | 1368 | * @return float $subtotal Subtotal for payment (non formatted). |
1369 | 1369 | */ |
1370 | -function give_get_payment_subtotal( $payment_id = 0 ) { |
|
1371 | - $payment = new G_Payment( $payment_id ); |
|
1370 | +function give_get_payment_subtotal($payment_id = 0) { |
|
1371 | + $payment = new G_Payment($payment_id); |
|
1372 | 1372 | |
1373 | 1373 | return $payment->subtotal; |
1374 | 1374 | } |
@@ -1383,10 +1383,10 @@ discard block |
||
1383 | 1383 | * |
1384 | 1384 | * @return mixed array if payment fees found, false otherwise. |
1385 | 1385 | */ |
1386 | -function give_get_payment_fees( $payment_id = 0, $type = 'all' ) { |
|
1387 | - $payment = new Give_Payment( $payment_id ); |
|
1386 | +function give_get_payment_fees($payment_id = 0, $type = 'all') { |
|
1387 | + $payment = new Give_Payment($payment_id); |
|
1388 | 1388 | |
1389 | - return $payment->get_fees( $type ); |
|
1389 | + return $payment->get_fees($type); |
|
1390 | 1390 | } |
1391 | 1391 | |
1392 | 1392 | /** |
@@ -1398,8 +1398,8 @@ discard block |
||
1398 | 1398 | * |
1399 | 1399 | * @return string The donation ID. |
1400 | 1400 | */ |
1401 | -function give_get_payment_transaction_id( $payment_id = 0 ) { |
|
1402 | - $payment = new Give_Payment( $payment_id ); |
|
1401 | +function give_get_payment_transaction_id($payment_id = 0) { |
|
1402 | + $payment = new Give_Payment($payment_id); |
|
1403 | 1403 | |
1404 | 1404 | return $payment->transaction_id; |
1405 | 1405 | } |
@@ -1414,15 +1414,15 @@ discard block |
||
1414 | 1414 | * |
1415 | 1415 | * @return bool|mixed |
1416 | 1416 | */ |
1417 | -function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) { |
|
1417 | +function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') { |
|
1418 | 1418 | |
1419 | - if ( empty( $payment_id ) || empty( $transaction_id ) ) { |
|
1419 | + if (empty($payment_id) || empty($transaction_id)) { |
|
1420 | 1420 | return false; |
1421 | 1421 | } |
1422 | 1422 | |
1423 | - $transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
1423 | + $transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id); |
|
1424 | 1424 | |
1425 | - return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id ); |
|
1425 | + return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id); |
|
1426 | 1426 | } |
1427 | 1427 | |
1428 | 1428 | /** |
@@ -1435,12 +1435,12 @@ discard block |
||
1435 | 1435 | * |
1436 | 1436 | * @return int $purchase Donation ID. |
1437 | 1437 | */ |
1438 | -function give_get_purchase_id_by_key( $key ) { |
|
1438 | +function give_get_purchase_id_by_key($key) { |
|
1439 | 1439 | global $wpdb; |
1440 | 1440 | |
1441 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
1441 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key)); |
|
1442 | 1442 | |
1443 | - if ( $purchase != null ) { |
|
1443 | + if ($purchase != null) { |
|
1444 | 1444 | return $purchase; |
1445 | 1445 | } |
1446 | 1446 | |
@@ -1458,12 +1458,12 @@ discard block |
||
1458 | 1458 | * |
1459 | 1459 | * @return int $purchase Donation ID. |
1460 | 1460 | */ |
1461 | -function give_get_purchase_id_by_transaction_id( $key ) { |
|
1461 | +function give_get_purchase_id_by_transaction_id($key) { |
|
1462 | 1462 | global $wpdb; |
1463 | 1463 | |
1464 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) ); |
|
1464 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key)); |
|
1465 | 1465 | |
1466 | - if ( $purchase != null ) { |
|
1466 | + if ($purchase != null) { |
|
1467 | 1467 | return $purchase; |
1468 | 1468 | } |
1469 | 1469 | |
@@ -1480,19 +1480,19 @@ discard block |
||
1480 | 1480 | * |
1481 | 1481 | * @return array $notes Donation Notes |
1482 | 1482 | */ |
1483 | -function give_get_payment_notes( $payment_id = 0, $search = '' ) { |
|
1483 | +function give_get_payment_notes($payment_id = 0, $search = '') { |
|
1484 | 1484 | |
1485 | - if ( empty( $payment_id ) && empty( $search ) ) { |
|
1485 | + if (empty($payment_id) && empty($search)) { |
|
1486 | 1486 | return false; |
1487 | 1487 | } |
1488 | 1488 | |
1489 | - remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1490 | - remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 ); |
|
1489 | + remove_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1490 | + remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10); |
|
1491 | 1491 | |
1492 | - $notes = get_comments( array( 'post_id' => $payment_id, 'order' => 'ASC', 'search' => $search ) ); |
|
1492 | + $notes = get_comments(array('post_id' => $payment_id, 'order' => 'ASC', 'search' => $search)); |
|
1493 | 1493 | |
1494 | - add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1495 | - add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1494 | + add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1495 | + add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1496 | 1496 | |
1497 | 1497 | return $notes; |
1498 | 1498 | } |
@@ -1508,8 +1508,8 @@ discard block |
||
1508 | 1508 | * |
1509 | 1509 | * @return int The new note ID |
1510 | 1510 | */ |
1511 | -function give_insert_payment_note( $payment_id = 0, $note = '' ) { |
|
1512 | - if ( empty( $payment_id ) ) { |
|
1511 | +function give_insert_payment_note($payment_id = 0, $note = '') { |
|
1512 | + if (empty($payment_id)) { |
|
1513 | 1513 | return false; |
1514 | 1514 | } |
1515 | 1515 | |
@@ -1521,14 +1521,14 @@ discard block |
||
1521 | 1521 | * @param int $payment_id Payment ID. |
1522 | 1522 | * @param string $note The note. |
1523 | 1523 | */ |
1524 | - do_action( 'give_pre_insert_payment_note', $payment_id, $note ); |
|
1524 | + do_action('give_pre_insert_payment_note', $payment_id, $note); |
|
1525 | 1525 | |
1526 | - $note_id = wp_insert_comment( wp_filter_comment( array( |
|
1526 | + $note_id = wp_insert_comment(wp_filter_comment(array( |
|
1527 | 1527 | 'comment_post_ID' => $payment_id, |
1528 | 1528 | 'comment_content' => $note, |
1529 | 1529 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
1530 | - 'comment_date' => current_time( 'mysql' ), |
|
1531 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
1530 | + 'comment_date' => current_time('mysql'), |
|
1531 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
1532 | 1532 | 'comment_approved' => 1, |
1533 | 1533 | 'comment_parent' => 0, |
1534 | 1534 | 'comment_author' => '', |
@@ -1537,7 +1537,7 @@ discard block |
||
1537 | 1537 | 'comment_author_email' => '', |
1538 | 1538 | 'comment_type' => 'give_payment_note', |
1539 | 1539 | |
1540 | - ) ) ); |
|
1540 | + ))); |
|
1541 | 1541 | |
1542 | 1542 | /** |
1543 | 1543 | * Fires after payment note inserted. |
@@ -1548,7 +1548,7 @@ discard block |
||
1548 | 1548 | * @param int $payment_id Payment ID. |
1549 | 1549 | * @param string $note The note. |
1550 | 1550 | */ |
1551 | - do_action( 'give_insert_payment_note', $note_id, $payment_id, $note ); |
|
1551 | + do_action('give_insert_payment_note', $note_id, $payment_id, $note); |
|
1552 | 1552 | |
1553 | 1553 | return $note_id; |
1554 | 1554 | } |
@@ -1563,8 +1563,8 @@ discard block |
||
1563 | 1563 | * |
1564 | 1564 | * @return bool True on success, false otherwise. |
1565 | 1565 | */ |
1566 | -function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) { |
|
1567 | - if ( empty( $comment_id ) ) { |
|
1566 | +function give_delete_payment_note($comment_id = 0, $payment_id = 0) { |
|
1567 | + if (empty($comment_id)) { |
|
1568 | 1568 | return false; |
1569 | 1569 | } |
1570 | 1570 | |
@@ -1576,9 +1576,9 @@ discard block |
||
1576 | 1576 | * @param int $comment_id Note ID. |
1577 | 1577 | * @param int $payment_id Payment ID. |
1578 | 1578 | */ |
1579 | - do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id ); |
|
1579 | + do_action('give_pre_delete_payment_note', $comment_id, $payment_id); |
|
1580 | 1580 | |
1581 | - $ret = wp_delete_comment( $comment_id, true ); |
|
1581 | + $ret = wp_delete_comment($comment_id, true); |
|
1582 | 1582 | |
1583 | 1583 | /** |
1584 | 1584 | * Fires after donation note deleted. |
@@ -1588,7 +1588,7 @@ discard block |
||
1588 | 1588 | * @param int $comment_id Note ID. |
1589 | 1589 | * @param int $payment_id Payment ID. |
1590 | 1590 | */ |
1591 | - do_action( 'give_post_delete_payment_note', $comment_id, $payment_id ); |
|
1591 | + do_action('give_post_delete_payment_note', $comment_id, $payment_id); |
|
1592 | 1592 | |
1593 | 1593 | return $ret; |
1594 | 1594 | } |
@@ -1603,34 +1603,34 @@ discard block |
||
1603 | 1603 | * |
1604 | 1604 | * @return string |
1605 | 1605 | */ |
1606 | -function give_get_payment_note_html( $note, $payment_id = 0 ) { |
|
1606 | +function give_get_payment_note_html($note, $payment_id = 0) { |
|
1607 | 1607 | |
1608 | - if ( is_numeric( $note ) ) { |
|
1609 | - $note = get_comment( $note ); |
|
1608 | + if (is_numeric($note)) { |
|
1609 | + $note = get_comment($note); |
|
1610 | 1610 | } |
1611 | 1611 | |
1612 | - if ( ! empty( $note->user_id ) ) { |
|
1613 | - $user = get_userdata( $note->user_id ); |
|
1612 | + if ( ! empty($note->user_id)) { |
|
1613 | + $user = get_userdata($note->user_id); |
|
1614 | 1614 | $user = $user->display_name; |
1615 | 1615 | } else { |
1616 | - $user = esc_html__( 'System', 'give' ); |
|
1616 | + $user = esc_html__('System', 'give'); |
|
1617 | 1617 | } |
1618 | 1618 | |
1619 | - $date_format = give_date_format() . ', ' . get_option( 'time_format' ); |
|
1619 | + $date_format = give_date_format().', '.get_option('time_format'); |
|
1620 | 1620 | |
1621 | - $delete_note_url = wp_nonce_url( add_query_arg( array( |
|
1621 | + $delete_note_url = wp_nonce_url(add_query_arg(array( |
|
1622 | 1622 | 'give-action' => 'delete_payment_note', |
1623 | 1623 | 'note_id' => $note->comment_ID, |
1624 | 1624 | 'payment_id' => $payment_id, |
1625 | - ) ), |
|
1626 | - 'give_delete_payment_note_' . $note->comment_ID |
|
1625 | + )), |
|
1626 | + 'give_delete_payment_note_'.$note->comment_ID |
|
1627 | 1627 | ); |
1628 | 1628 | |
1629 | - $note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">'; |
|
1629 | + $note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">'; |
|
1630 | 1630 | $note_html .= '<p>'; |
1631 | - $note_html .= '<strong>' . $user . '</strong> – <span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>'; |
|
1631 | + $note_html .= '<strong>'.$user.'</strong> – <span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>'; |
|
1632 | 1632 | $note_html .= $note->comment_content; |
1633 | - $note_html .= ' – <a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . esc_attr__( 'Delete this donation note.', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>'; |
|
1633 | + $note_html .= ' – <a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.esc_attr__('Delete this donation note.', 'give').'">'.esc_html__('Delete', 'give').'</a>'; |
|
1634 | 1634 | $note_html .= '</p>'; |
1635 | 1635 | $note_html .= '</div>'; |
1636 | 1636 | |
@@ -1648,18 +1648,18 @@ discard block |
||
1648 | 1648 | * |
1649 | 1649 | * @return void |
1650 | 1650 | */ |
1651 | -function give_hide_payment_notes( $query ) { |
|
1652 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) { |
|
1653 | - $types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array(); |
|
1654 | - if ( ! is_array( $types ) ) { |
|
1655 | - $types = array( $types ); |
|
1651 | +function give_hide_payment_notes($query) { |
|
1652 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) { |
|
1653 | + $types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array(); |
|
1654 | + if ( ! is_array($types)) { |
|
1655 | + $types = array($types); |
|
1656 | 1656 | } |
1657 | 1657 | $types[] = 'give_payment_note'; |
1658 | 1658 | $query->query_vars['type__not_in'] = $types; |
1659 | 1659 | } |
1660 | 1660 | } |
1661 | 1661 | |
1662 | -add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1662 | +add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1663 | 1663 | |
1664 | 1664 | /** |
1665 | 1665 | * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets |
@@ -1671,15 +1671,15 @@ discard block |
||
1671 | 1671 | * |
1672 | 1672 | * @return array $clauses Updated comment clauses. |
1673 | 1673 | */ |
1674 | -function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) { |
|
1675 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) { |
|
1674 | +function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) { |
|
1675 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) { |
|
1676 | 1676 | $clauses['where'] .= ' AND comment_type != "give_payment_note"'; |
1677 | 1677 | } |
1678 | 1678 | |
1679 | 1679 | return $clauses; |
1680 | 1680 | } |
1681 | 1681 | |
1682 | -add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1682 | +add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1683 | 1683 | |
1684 | 1684 | |
1685 | 1685 | /** |
@@ -1692,15 +1692,15 @@ discard block |
||
1692 | 1692 | * |
1693 | 1693 | * @return string $where |
1694 | 1694 | */ |
1695 | -function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) { |
|
1695 | +function give_hide_payment_notes_from_feeds($where, $wp_comment_query) { |
|
1696 | 1696 | global $wpdb; |
1697 | 1697 | |
1698 | - $where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' ); |
|
1698 | + $where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note'); |
|
1699 | 1699 | |
1700 | 1700 | return $where; |
1701 | 1701 | } |
1702 | 1702 | |
1703 | -add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 ); |
|
1703 | +add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2); |
|
1704 | 1704 | |
1705 | 1705 | |
1706 | 1706 | /** |
@@ -1714,32 +1714,32 @@ discard block |
||
1714 | 1714 | * |
1715 | 1715 | * @return array Array of comment counts. |
1716 | 1716 | */ |
1717 | -function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) { |
|
1717 | +function give_remove_payment_notes_in_comment_counts($stats, $post_id) { |
|
1718 | 1718 | global $wpdb, $pagenow; |
1719 | 1719 | |
1720 | - if ( 'index.php' != $pagenow ) { |
|
1720 | + if ('index.php' != $pagenow) { |
|
1721 | 1721 | return $stats; |
1722 | 1722 | } |
1723 | 1723 | |
1724 | 1724 | $post_id = (int) $post_id; |
1725 | 1725 | |
1726 | - if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) { |
|
1726 | + if (apply_filters('give_count_payment_notes_in_comments', false)) { |
|
1727 | 1727 | return $stats; |
1728 | 1728 | } |
1729 | 1729 | |
1730 | - $stats = wp_cache_get( "comments-{$post_id}", 'counts' ); |
|
1730 | + $stats = wp_cache_get("comments-{$post_id}", 'counts'); |
|
1731 | 1731 | |
1732 | - if ( false !== $stats ) { |
|
1732 | + if (false !== $stats) { |
|
1733 | 1733 | return $stats; |
1734 | 1734 | } |
1735 | 1735 | |
1736 | 1736 | $where = 'WHERE comment_type != "give_payment_note"'; |
1737 | 1737 | |
1738 | - if ( $post_id > 0 ) { |
|
1739 | - $where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id ); |
|
1738 | + if ($post_id > 0) { |
|
1739 | + $where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id); |
|
1740 | 1740 | } |
1741 | 1741 | |
1742 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
1742 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
1743 | 1743 | |
1744 | 1744 | $total = 0; |
1745 | 1745 | $approved = array( |
@@ -1749,30 +1749,30 @@ discard block |
||
1749 | 1749 | 'trash' => 'trash', |
1750 | 1750 | 'post-trashed' => 'post-trashed', |
1751 | 1751 | ); |
1752 | - foreach ( (array) $count as $row ) { |
|
1752 | + foreach ((array) $count as $row) { |
|
1753 | 1753 | // Don't count post-trashed toward totals. |
1754 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { |
|
1754 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) { |
|
1755 | 1755 | $total += $row['num_comments']; |
1756 | 1756 | } |
1757 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
1758 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
1757 | + if (isset($approved[$row['comment_approved']])) { |
|
1758 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
1759 | 1759 | } |
1760 | 1760 | } |
1761 | 1761 | |
1762 | 1762 | $stats['total_comments'] = $total; |
1763 | - foreach ( $approved as $key ) { |
|
1764 | - if ( empty( $stats[ $key ] ) ) { |
|
1765 | - $stats[ $key ] = 0; |
|
1763 | + foreach ($approved as $key) { |
|
1764 | + if (empty($stats[$key])) { |
|
1765 | + $stats[$key] = 0; |
|
1766 | 1766 | } |
1767 | 1767 | } |
1768 | 1768 | |
1769 | 1769 | $stats = (object) $stats; |
1770 | - wp_cache_set( "comments-{$post_id}", $stats, 'counts' ); |
|
1770 | + wp_cache_set("comments-{$post_id}", $stats, 'counts'); |
|
1771 | 1771 | |
1772 | 1772 | return $stats; |
1773 | 1773 | } |
1774 | 1774 | |
1775 | -add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 ); |
|
1775 | +add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2); |
|
1776 | 1776 | |
1777 | 1777 | |
1778 | 1778 | /** |
@@ -1785,9 +1785,9 @@ discard block |
||
1785 | 1785 | * |
1786 | 1786 | * @return string $where Modified where clause. |
1787 | 1787 | */ |
1788 | -function give_filter_where_older_than_week( $where = '' ) { |
|
1788 | +function give_filter_where_older_than_week($where = '') { |
|
1789 | 1789 | // Payments older than one week. |
1790 | - $start = date( 'Y-m-d', strtotime( '-7 days' ) ); |
|
1790 | + $start = date('Y-m-d', strtotime('-7 days')); |
|
1791 | 1791 | $where .= " AND post_date <= '{$start}'"; |
1792 | 1792 | |
1793 | 1793 | return $where; |
@@ -1807,38 +1807,38 @@ discard block |
||
1807 | 1807 | * |
1808 | 1808 | * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title. |
1809 | 1809 | */ |
1810 | -function give_get_payment_form_title( $payment_meta, $only_level = false, $separator = '' ) { |
|
1810 | +function give_get_payment_form_title($payment_meta, $only_level = false, $separator = '') { |
|
1811 | 1811 | |
1812 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
1813 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
1814 | - $form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : ''; |
|
1812 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
1813 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
1814 | + $form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : ''; |
|
1815 | 1815 | |
1816 | - if ( $only_level == true ) { |
|
1816 | + if ($only_level == true) { |
|
1817 | 1817 | $form_title = ''; |
1818 | 1818 | } |
1819 | 1819 | |
1820 | 1820 | //If multi-level, append to the form title. |
1821 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1821 | + if (give_has_variable_prices($form_id)) { |
|
1822 | 1822 | |
1823 | 1823 | //Only add separator if there is a form title. |
1824 | - if ( ! empty( $form_title ) ) { |
|
1825 | - $form_title .= ' ' . $separator . ' '; |
|
1824 | + if ( ! empty($form_title)) { |
|
1825 | + $form_title .= ' '.$separator.' '; |
|
1826 | 1826 | } |
1827 | 1827 | |
1828 | 1828 | $form_title .= '<span class="donation-level-text-wrap">'; |
1829 | 1829 | |
1830 | - if ( $price_id == 'custom' ) { |
|
1831 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
1832 | - $form_title .= ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' ); |
|
1830 | + if ($price_id == 'custom') { |
|
1831 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
1832 | + $form_title .= ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give'); |
|
1833 | 1833 | } else { |
1834 | - $form_title .= give_get_price_option_name( $form_id, $price_id ); |
|
1834 | + $form_title .= give_get_price_option_name($form_id, $price_id); |
|
1835 | 1835 | } |
1836 | 1836 | |
1837 | 1837 | $form_title .= '</span>'; |
1838 | 1838 | |
1839 | 1839 | } |
1840 | 1840 | |
1841 | - return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta ); |
|
1841 | + return apply_filters('give_get_payment_form_title', $form_title, $payment_meta); |
|
1842 | 1842 | |
1843 | 1843 | } |
1844 | 1844 | |
@@ -1852,20 +1852,20 @@ discard block |
||
1852 | 1852 | * |
1853 | 1853 | * @return string $price_id |
1854 | 1854 | */ |
1855 | -function give_get_price_id( $form_id, $price ) { |
|
1855 | +function give_get_price_id($form_id, $price) { |
|
1856 | 1856 | |
1857 | 1857 | $price_id = 0; |
1858 | 1858 | |
1859 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1859 | + if (give_has_variable_prices($form_id)) { |
|
1860 | 1860 | |
1861 | - $levels = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) ); |
|
1861 | + $levels = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true)); |
|
1862 | 1862 | |
1863 | - foreach ( $levels as $level ) { |
|
1863 | + foreach ($levels as $level) { |
|
1864 | 1864 | |
1865 | - $level_amount = (float) give_sanitize_amount( $level['_give_amount'] ); |
|
1865 | + $level_amount = (float) give_sanitize_amount($level['_give_amount']); |
|
1866 | 1866 | |
1867 | 1867 | // Check that this indeed the recurring price. |
1868 | - if ( $level_amount == $price ) { |
|
1868 | + if ($level_amount == $price) { |
|
1869 | 1869 | |
1870 | 1870 | $price_id = $level['_give_id']['level_id']; |
1871 | 1871 | |
@@ -1890,10 +1890,10 @@ discard block |
||
1890 | 1890 | * |
1891 | 1891 | * @return string|void |
1892 | 1892 | */ |
1893 | -function give_get_form_dropdown( $args = array(), $echo = false ) { |
|
1894 | - $form_dropdown_html = Give()->html->forms_dropdown( $args ); |
|
1893 | +function give_get_form_dropdown($args = array(), $echo = false) { |
|
1894 | + $form_dropdown_html = Give()->html->forms_dropdown($args); |
|
1895 | 1895 | |
1896 | - if ( ! $echo ) { |
|
1896 | + if ( ! $echo) { |
|
1897 | 1897 | return $form_dropdown_html; |
1898 | 1898 | } |
1899 | 1899 | |
@@ -1910,17 +1910,17 @@ discard block |
||
1910 | 1910 | * |
1911 | 1911 | * @return string|bool |
1912 | 1912 | */ |
1913 | -function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) { |
|
1913 | +function give_get_form_variable_price_dropdown($args = array(), $echo = false) { |
|
1914 | 1914 | |
1915 | 1915 | // Check for give form id. |
1916 | - if ( empty( $args['id'] ) ) { |
|
1916 | + if (empty($args['id'])) { |
|
1917 | 1917 | return false; |
1918 | 1918 | } |
1919 | 1919 | |
1920 | - $form = new Give_Donate_Form( $args['id'] ); |
|
1920 | + $form = new Give_Donate_Form($args['id']); |
|
1921 | 1921 | |
1922 | 1922 | // Check if form has variable prices or not. |
1923 | - if ( ! $form->ID || ! $form->has_variable_prices() ) { |
|
1923 | + if ( ! $form->ID || ! $form->has_variable_prices()) { |
|
1924 | 1924 | return false; |
1925 | 1925 | } |
1926 | 1926 | |
@@ -1928,22 +1928,22 @@ discard block |
||
1928 | 1928 | $variable_price_options = array(); |
1929 | 1929 | |
1930 | 1930 | // Check if multi donation form support custom donation or not. |
1931 | - if ( $form->is_custom_price_mode() ) { |
|
1932 | - $variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' ); |
|
1931 | + if ($form->is_custom_price_mode()) { |
|
1932 | + $variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give'); |
|
1933 | 1933 | } |
1934 | 1934 | |
1935 | 1935 | // Get variable price and ID from variable price array. |
1936 | - foreach ( $variable_prices as $variable_price ) { |
|
1937 | - $variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'] ) ); |
|
1936 | + foreach ($variable_prices as $variable_price) { |
|
1937 | + $variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount'])); |
|
1938 | 1938 | } |
1939 | 1939 | |
1940 | 1940 | // Update options. |
1941 | - $args = array_merge( $args, array( 'options' => $variable_price_options ) ); |
|
1941 | + $args = array_merge($args, array('options' => $variable_price_options)); |
|
1942 | 1942 | |
1943 | 1943 | // Generate select html. |
1944 | - $form_dropdown_html = Give()->html->select( $args ); |
|
1944 | + $form_dropdown_html = Give()->html->select($args); |
|
1945 | 1945 | |
1946 | - if ( ! $echo ) { |
|
1946 | + if ( ! $echo) { |
|
1947 | 1947 | return $form_dropdown_html; |
1948 | 1948 | } |
1949 | 1949 |
@@ -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 | |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | * @return void |
22 | 22 | */ |
23 | 23 | function give_register_dashboard_widgets() { |
24 | - if ( current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
25 | - wp_add_dashboard_widget( 'give_dashboard_sales', esc_html__( 'Give: Donation Statistics', 'give' ), 'give_dashboard_sales_widget' ); |
|
24 | + if (current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
25 | + wp_add_dashboard_widget('give_dashboard_sales', esc_html__('Give: Donation Statistics', 'give'), 'give_dashboard_sales_widget'); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | -add_action( 'wp_dashboard_setup', 'give_register_dashboard_widgets', 10 ); |
|
29 | +add_action('wp_dashboard_setup', 'give_register_dashboard_widgets', 10); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Sales Summary Dashboard Widget |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | function give_dashboard_sales_widget() { |
40 | 40 | |
41 | - if ( ! current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
41 | + if ( ! current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | $stats = new Give_Payment_Stats; ?> |
@@ -46,27 +46,27 @@ discard block |
||
46 | 46 | <div class="give-dashboard-widget"> |
47 | 47 | |
48 | 48 | <div class="give-dashboard-today give-clearfix"> |
49 | - <h3 class="give-dashboard-date-today"><?php echo date( _x( 'F j, Y', 'dashboard widget', 'give' ) ); ?></h3> |
|
49 | + <h3 class="give-dashboard-date-today"><?php echo date(_x('F j, Y', 'dashboard widget', 'give')); ?></h3> |
|
50 | 50 | |
51 | 51 | <p class="give-dashboard-happy-day"><?php |
52 | 52 | printf( |
53 | 53 | /* translators: %s: day of the week */ |
54 | - esc_html__( 'Happy %s!', 'give' ), |
|
55 | - date( 'l', current_time( 'timestamp' ) ) |
|
54 | + esc_html__('Happy %s!', 'give'), |
|
55 | + date('l', current_time('timestamp')) |
|
56 | 56 | ); |
57 | 57 | ?></p> |
58 | 58 | |
59 | 59 | <p class="give-dashboard-today-earnings"><?php |
60 | - $earnings_today = $stats->get_earnings( 0, 'today', false ); |
|
61 | - echo give_currency_filter( give_format_amount( $earnings_today ) ); |
|
60 | + $earnings_today = $stats->get_earnings(0, 'today', false); |
|
61 | + echo give_currency_filter(give_format_amount($earnings_today)); |
|
62 | 62 | ?></p> |
63 | 63 | |
64 | 64 | <p class="give-orders-today"><?php |
65 | - $donations_today = $stats->get_sales( 0, 'today', false ); |
|
65 | + $donations_today = $stats->get_sales(0, 'today', false); |
|
66 | 66 | printf( |
67 | 67 | /* translators: %s: daily donation count */ |
68 | - esc_html__( '%s donations today', 'give' ), |
|
69 | - give_format_amount( $donations_today, false ) |
|
68 | + esc_html__('%s donations today', 'give'), |
|
69 | + give_format_amount($donations_today, false) |
|
70 | 70 | ); |
71 | 71 | ?></p> |
72 | 72 | |
@@ -76,34 +76,34 @@ discard block |
||
76 | 76 | <table class="give-table-stats"> |
77 | 77 | <thead style="display: none;"> |
78 | 78 | <tr> |
79 | - <th><?php esc_html_e( 'This Week', 'give' ); ?></th> |
|
80 | - <th><?php esc_html_e( 'This Month', 'give' ); ?></th> |
|
81 | - <th><?php esc_html_e( 'Past 30 Days', 'give' ); ?></th> |
|
79 | + <th><?php esc_html_e('This Week', 'give'); ?></th> |
|
80 | + <th><?php esc_html_e('This Month', 'give'); ?></th> |
|
81 | + <th><?php esc_html_e('Past 30 Days', 'give'); ?></th> |
|
82 | 82 | </tr> |
83 | 83 | </thead> |
84 | 84 | <tbody> |
85 | 85 | <tr id="give-table-stats-tr-1"> |
86 | 86 | <td> |
87 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_week' ) ) ); ?></p> |
|
87 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_week'))); ?></p> |
|
88 | 88 | |
89 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Week', 'give' ); ?></p> |
|
89 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('This Week', 'give'); ?></p> |
|
90 | 90 | </td> |
91 | 91 | <td> |
92 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_month' ) ) ); ?></p> |
|
92 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_month'))); ?></p> |
|
93 | 93 | |
94 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Month', 'give' ); ?></p> |
|
94 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('This Month', 'give'); ?></p> |
|
95 | 95 | </td> |
96 | 96 | </tr> |
97 | 97 | <tr id="give-table-stats-tr-2"> |
98 | 98 | <td> |
99 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'last_month' ) ) ) ?></p> |
|
99 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'last_month'))) ?></p> |
|
100 | 100 | |
101 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'Last Month', 'give' ); ?></p> |
|
101 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('Last Month', 'give'); ?></p> |
|
102 | 102 | </td> |
103 | 103 | <td> |
104 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_year', false ) ) ) ?></p> |
|
104 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_year', false))) ?></p> |
|
105 | 105 | |
106 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Year', 'give' ); ?></p> |
|
106 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('This Year', 'give'); ?></p> |
|
107 | 107 | </td> |
108 | 108 | </tr> |
109 | 109 | </tbody> |
@@ -123,23 +123,23 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return array |
125 | 125 | */ |
126 | -function give_dashboard_at_a_glance_widget( $items ) { |
|
127 | - $num_posts = wp_count_posts( 'give_forms' ); |
|
126 | +function give_dashboard_at_a_glance_widget($items) { |
|
127 | + $num_posts = wp_count_posts('give_forms'); |
|
128 | 128 | |
129 | - if ( $num_posts && $num_posts->publish ) { |
|
129 | + if ($num_posts && $num_posts->publish) { |
|
130 | 130 | |
131 | 131 | $text = sprintf( |
132 | 132 | /* translators: %s: number of posts published */ |
133 | - _n( '%s Give Form', '%s Give Forms', $num_posts->publish, 'give' ), |
|
133 | + _n('%s Give Form', '%s Give Forms', $num_posts->publish, 'give'), |
|
134 | 134 | $num_posts->publish |
135 | 135 | ); |
136 | 136 | |
137 | - $text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); |
|
137 | + $text = sprintf($text, number_format_i18n($num_posts->publish)); |
|
138 | 138 | |
139 | - if ( current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
139 | + if (current_user_can('edit_give_forms', get_current_user_id())) { |
|
140 | 140 | $text = sprintf( |
141 | 141 | '<a class="give-forms-count" href="%1$s">%2$s</a>', |
142 | - admin_url( 'edit.php?post_type=give_forms' ), |
|
142 | + admin_url('edit.php?post_type=give_forms'), |
|
143 | 143 | $text |
144 | 144 | ); |
145 | 145 | } else { |
@@ -155,4 +155,4 @@ discard block |
||
155 | 155 | return $items; |
156 | 156 | } |
157 | 157 | |
158 | -add_filter( 'dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1 ); |
|
158 | +add_filter('dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1); |
@@ -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 | |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | */ |
25 | 25 | function give_customers_page() { |
26 | 26 | $default_views = give_customer_views(); |
27 | - $requested_view = isset( $_GET['view'] ) ? sanitize_text_field( $_GET['view'] ) : 'customers'; |
|
28 | - if ( array_key_exists( $requested_view, $default_views ) && function_exists( $default_views[ $requested_view ] ) ) { |
|
29 | - give_render_customer_view( $requested_view, $default_views ); |
|
27 | + $requested_view = isset($_GET['view']) ? sanitize_text_field($_GET['view']) : 'customers'; |
|
28 | + if (array_key_exists($requested_view, $default_views) && function_exists($default_views[$requested_view])) { |
|
29 | + give_render_customer_view($requested_view, $default_views); |
|
30 | 30 | } else { |
31 | 31 | give_customers_list(); |
32 | 32 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | $views = array(); |
44 | 44 | |
45 | - return apply_filters( 'give_customer_views', $views ); |
|
45 | + return apply_filters('give_customer_views', $views); |
|
46 | 46 | |
47 | 47 | } |
48 | 48 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | $tabs = array(); |
58 | 58 | |
59 | - return apply_filters( 'give_customer_tabs', $tabs ); |
|
59 | + return apply_filters('give_customer_tabs', $tabs); |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @return void |
68 | 68 | */ |
69 | 69 | function give_customers_list() { |
70 | - include( dirname( __FILE__ ) . '/class-customer-table.php' ); |
|
70 | + include(dirname(__FILE__).'/class-customer-table.php'); |
|
71 | 71 | |
72 | 72 | $customers_table = new Give_Customer_Reports_Table(); |
73 | 73 | $customers_table->prepare_items(); |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @since 1.0 |
82 | 82 | */ |
83 | - do_action( 'give_donors_table_top' ); |
|
83 | + do_action('give_donors_table_top'); |
|
84 | 84 | ?> |
85 | - <form id="give-donors-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>"> |
|
85 | + <form id="give-donors-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors'); ?>"> |
|
86 | 86 | <?php |
87 | - $customers_table->search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors' ); |
|
87 | + $customers_table->search_box(esc_html__('Search Donors', 'give'), 'give-donors'); |
|
88 | 88 | $customers_table->display(); |
89 | 89 | ?> |
90 | 90 | <input type="hidden" name="post_type" value="give_forms" /> |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @since 1.0 |
99 | 99 | */ |
100 | - do_action( 'give_donors_table_bottom' ); |
|
100 | + do_action('give_donors_table_bottom'); |
|
101 | 101 | ?> |
102 | 102 | </div> |
103 | 103 | <?php |
@@ -113,27 +113,27 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return void |
115 | 115 | */ |
116 | -function give_render_customer_view( $view, $callbacks ) { |
|
116 | +function give_render_customer_view($view, $callbacks) { |
|
117 | 117 | |
118 | 118 | $render = true; |
119 | 119 | |
120 | - $customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' ); |
|
120 | + $customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports'); |
|
121 | 121 | |
122 | - if ( ! current_user_can( $customer_view_role ) ) { |
|
123 | - give_set_error( 'give-no-access', esc_html__( 'You are not permitted to view this data.', 'give' ) ); |
|
122 | + if ( ! current_user_can($customer_view_role)) { |
|
123 | + give_set_error('give-no-access', esc_html__('You are not permitted to view this data.', 'give')); |
|
124 | 124 | $render = false; |
125 | 125 | } |
126 | 126 | |
127 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
128 | - give_set_error( 'give-invalid_customer', esc_html__( 'Invalid Donor ID.', 'give' ) ); |
|
127 | + if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
128 | + give_set_error('give-invalid_customer', esc_html__('Invalid Donor ID.', 'give')); |
|
129 | 129 | $render = false; |
130 | 130 | } |
131 | 131 | |
132 | 132 | $customer_id = (int) $_GET['id']; |
133 | - $customer = new Give_Customer( $customer_id ); |
|
133 | + $customer = new Give_Customer($customer_id); |
|
134 | 134 | |
135 | - if ( empty( $customer->id ) ) { |
|
136 | - give_set_error( 'give-invalid_customer', esc_html__( 'Invalid Donor ID.', 'give' ) ); |
|
135 | + if (empty($customer->id)) { |
|
136 | + give_set_error('give-invalid_customer', esc_html__('Invalid Donor ID.', 'give')); |
|
137 | 137 | $render = false; |
138 | 138 | } |
139 | 139 | |
@@ -142,34 +142,34 @@ discard block |
||
142 | 142 | |
143 | 143 | <div class='wrap'> |
144 | 144 | |
145 | - <?php if ( give_get_errors() ) : ?> |
|
145 | + <?php if (give_get_errors()) : ?> |
|
146 | 146 | <div class="error settings-error"> |
147 | - <?php give_print_errors( 0 ); ?> |
|
147 | + <?php give_print_errors(0); ?> |
|
148 | 148 | </div> |
149 | 149 | <?php endif; ?> |
150 | 150 | |
151 | - <h1 class="screen-reader-text"><?php esc_html_e( 'Donor', 'give' ); ?></h1> |
|
151 | + <h1 class="screen-reader-text"><?php esc_html_e('Donor', 'give'); ?></h1> |
|
152 | 152 | |
153 | - <?php if ( $customer && $render ) : ?> |
|
153 | + <?php if ($customer && $render) : ?> |
|
154 | 154 | |
155 | 155 | <h2 class="nav-tab-wrapper"> |
156 | 156 | <?php |
157 | - foreach ( $customer_tabs as $key => $tab ) : |
|
157 | + foreach ($customer_tabs as $key => $tab) : |
|
158 | 158 | $active = $key === $view ? true : false; |
159 | 159 | $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab'; |
160 | 160 | printf( |
161 | 161 | '<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>'."\n", |
162 | - esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=' . $key . '&id=' . $customer->id ) ), |
|
163 | - esc_attr( $class ), |
|
164 | - sanitize_html_class( $tab['dashicon'] ), |
|
165 | - esc_html( $tab['title'] ) |
|
162 | + esc_url(admin_url('edit.php?post_type=give_forms&page=give-donors&view='.$key.'&id='.$customer->id)), |
|
163 | + esc_attr($class), |
|
164 | + sanitize_html_class($tab['dashicon']), |
|
165 | + esc_html($tab['title']) |
|
166 | 166 | ); |
167 | 167 | endforeach; |
168 | 168 | ?> |
169 | 169 | </h2> |
170 | 170 | |
171 | 171 | <div id="give-customer-card-wrapper"> |
172 | - <?php $callbacks[ $view ]( $customer ) ?> |
|
172 | + <?php $callbacks[$view]($customer) ?> |
|
173 | 173 | </div> |
174 | 174 | |
175 | 175 | <?php endif; ?> |
@@ -189,9 +189,9 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @return void |
191 | 191 | */ |
192 | -function give_customers_view( $customer ) { |
|
192 | +function give_customers_view($customer) { |
|
193 | 193 | |
194 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
194 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
195 | 195 | |
196 | 196 | /** |
197 | 197 | * Fires in donor profile screen, above the donor card. |
@@ -200,32 +200,32 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @param object $customer The customer object being displayed. |
202 | 202 | */ |
203 | - do_action( 'give_donor_card_top', $customer ); |
|
203 | + do_action('give_donor_card_top', $customer); |
|
204 | 204 | ?> |
205 | 205 | |
206 | 206 | <div id="donor-summary" class="info-wrapper customer-section postbox"> |
207 | 207 | |
208 | - <form id="edit-customer-info" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); ?>"> |
|
208 | + <form id="edit-customer-info" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id); ?>"> |
|
209 | 209 | |
210 | 210 | <div class="customer-info"> |
211 | 211 | |
212 | 212 | <div class="donor-bio-header clearfix"> |
213 | 213 | |
214 | 214 | <div class="avatar-wrap left" id="customer-avatar"> |
215 | - <?php echo get_avatar( $customer->email ); ?> |
|
215 | + <?php echo get_avatar($customer->email); ?> |
|
216 | 216 | </div> |
217 | 217 | |
218 | 218 | <div id="customer-name-wrap" class="left"> |
219 | 219 | <span class="customer-id">#<?php echo $customer->id; ?></span> |
220 | - <span class="customer-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr( $customer->name ); ?>" placeholder="<?php esc_attr_e( 'Donor Name', 'give' ); ?>" /></span> |
|
220 | + <span class="customer-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr($customer->name); ?>" placeholder="<?php esc_attr_e('Donor Name', 'give'); ?>" /></span> |
|
221 | 221 | <span class="customer-name info-item editable"><span data-key="name"><?php echo $customer->name; ?></span></span> |
222 | 222 | </div> |
223 | 223 | <p class="customer-since info-item"> |
224 | - <?php esc_html_e( 'Donor since', 'give' ); ?> |
|
225 | - <?php echo date_i18n( give_date_format(), strtotime( $customer->date_created ) ) ?> |
|
224 | + <?php esc_html_e('Donor since', 'give'); ?> |
|
225 | + <?php echo date_i18n(give_date_format(), strtotime($customer->date_created)) ?> |
|
226 | 226 | </p> |
227 | - <?php if ( current_user_can( $customer_edit_role ) ): ?> |
|
228 | - <a href="#" id="edit-customer" class="button info-item editable customer-edit-link"><?php esc_html_e( 'Edit Donor', 'give' ); ?></a> |
|
227 | + <?php if (current_user_can($customer_edit_role)): ?> |
|
228 | + <a href="#" id="edit-customer" class="button info-item editable customer-edit-link"><?php esc_html_e('Edit Donor', 'give'); ?></a> |
|
229 | 229 | <?php endif; ?> |
230 | 230 | </div> |
231 | 231 | <!-- /donor-bio-header --> |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | <table class="widefat"> |
236 | 236 | <tbody> |
237 | 237 | <tr class="alternate"> |
238 | - <th scope="col"><label for="tablecell"><?php esc_html_e( 'User ID:', 'give' ); ?></label></th> |
|
238 | + <th scope="col"><label for="tablecell"><?php esc_html_e('User ID:', 'give'); ?></label></th> |
|
239 | 239 | <td class="row-title"> |
240 | 240 | <span class="customer-user-id info-item edit-item"> |
241 | 241 | <?php |
@@ -251,38 +251,38 @@ discard block |
||
251 | 251 | 'data' => $data_atts, |
252 | 252 | ); |
253 | 253 | |
254 | - if ( ! empty( $user_id ) ) { |
|
255 | - $userdata = get_userdata( $user_id ); |
|
254 | + if ( ! empty($user_id)) { |
|
255 | + $userdata = get_userdata($user_id); |
|
256 | 256 | $user_args['value'] = $userdata->user_login; |
257 | 257 | } |
258 | 258 | |
259 | - echo Give()->html->ajax_user_search( $user_args ); |
|
259 | + echo Give()->html->ajax_user_search($user_args); |
|
260 | 260 | ?> |
261 | 261 | <input type="hidden" name="customerinfo[user_id]" data-key="user_id" value="<?php echo $customer->user_id; ?>" /> |
262 | 262 | </span> |
263 | 263 | |
264 | 264 | <span class="customer-user-id info-item editable"> |
265 | - <?php if ( intval( $customer->user_id ) > 0 ) { ?> |
|
265 | + <?php if (intval($customer->user_id) > 0) { ?> |
|
266 | 266 | <span data-key="user_id"><?php echo $customer->user_id; ?></span> |
267 | 267 | <?php } else { ?> |
268 | - <span data-key="user_id"><?php esc_html_e( 'None', 'give' ); ?></span> |
|
268 | + <span data-key="user_id"><?php esc_html_e('None', 'give'); ?></span> |
|
269 | 269 | <?php } ?> |
270 | - <?php if ( current_user_can( $customer_edit_role ) && intval( $customer->user_id ) > 0 ) { ?> |
|
271 | - <span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" aria-label="<?php esc_attr_e( 'Disconnects the current user ID from this customer record.', 'give' ); ?>"><?php esc_html_e( 'Disconnect User', 'give' ); ?></a></span> |
|
270 | + <?php if (current_user_can($customer_edit_role) && intval($customer->user_id) > 0) { ?> |
|
271 | + <span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" aria-label="<?php esc_attr_e('Disconnects the current user ID from this customer record.', 'give'); ?>"><?php esc_html_e('Disconnect User', 'give'); ?></a></span> |
|
272 | 272 | <?php } ?> |
273 | 273 | </span> |
274 | 274 | </td> |
275 | 275 | </tr> |
276 | - <?php if ( isset( $customer->user_id ) && $customer->user_id > 0 ) : ?> |
|
276 | + <?php if (isset($customer->user_id) && $customer->user_id > 0) : ?> |
|
277 | 277 | |
278 | 278 | <tr> |
279 | - <th scope="col"><?php esc_html_e( 'Address:', 'give' ); ?></th> |
|
279 | + <th scope="col"><?php esc_html_e('Address:', 'give'); ?></th> |
|
280 | 280 | <td class="row-title"> |
281 | 281 | |
282 | 282 | <div class="customer-address-wrapper"> |
283 | 283 | |
284 | 284 | <?php |
285 | - $address = get_user_meta( $customer->user_id, '_give_user_address', true ); |
|
285 | + $address = get_user_meta($customer->user_id, '_give_user_address', true); |
|
286 | 286 | $defaults = array( |
287 | 287 | 'line1' => '', |
288 | 288 | 'line2' => '', |
@@ -292,10 +292,10 @@ discard block |
||
292 | 292 | 'zip' => '' |
293 | 293 | ); |
294 | 294 | |
295 | - $address = wp_parse_args( $address, $defaults ); |
|
295 | + $address = wp_parse_args($address, $defaults); |
|
296 | 296 | ?> |
297 | 297 | |
298 | - <?php if ( ! empty( $address ) ) { ?> |
|
298 | + <?php if ( ! empty($address)) { ?> |
|
299 | 299 | <span class="customer-address info-item editable"> |
300 | 300 | <span class="info-item" data-key="line1"><?php echo $address['line1']; ?></span> |
301 | 301 | <span class="info-item" data-key="line2"><?php echo $address['line2']; ?></span> |
@@ -306,43 +306,43 @@ discard block |
||
306 | 306 | </span> |
307 | 307 | <?php } ?> |
308 | 308 | <span class="customer-address info-item edit-item"> |
309 | - <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e( 'Address 1', 'give' ); ?>" value="<?php echo $address['line1']; ?>" /> |
|
310 | - <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e( 'Address 2', 'give' ); ?>" value="<?php echo $address['line2']; ?>" /> |
|
311 | - <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e( 'City', 'give' ); ?>" value="<?php echo $address['city']; ?>" /> |
|
309 | + <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e('Address 1', 'give'); ?>" value="<?php echo $address['line1']; ?>" /> |
|
310 | + <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e('Address 2', 'give'); ?>" value="<?php echo $address['line2']; ?>" /> |
|
311 | + <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e('City', 'give'); ?>" value="<?php echo $address['city']; ?>" /> |
|
312 | 312 | <select data-key="country" name="customerinfo[country]" id="billing_country" class="billing_country give-select edit-item"> |
313 | 313 | <?php |
314 | 314 | |
315 | 315 | $selected_country = $address['country']; |
316 | 316 | |
317 | 317 | $countries = give_get_country_list(); |
318 | - foreach ( $countries as $country_code => $country ) { |
|
319 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
318 | + foreach ($countries as $country_code => $country) { |
|
319 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
320 | 320 | } |
321 | 321 | ?> |
322 | 322 | </select> |
323 | 323 | <?php |
324 | 324 | $selected_state = give_get_state(); |
325 | - $states = give_get_states( $selected_country ); |
|
325 | + $states = give_get_states($selected_country); |
|
326 | 326 | |
327 | - $selected_state = isset( $address['state'] ) ? $address['state'] : $selected_state; |
|
327 | + $selected_state = isset($address['state']) ? $address['state'] : $selected_state; |
|
328 | 328 | |
329 | - if ( ! empty( $states ) ) { |
|
329 | + if ( ! empty($states)) { |
|
330 | 330 | ?> |
331 | 331 | <select data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-select info-item"> |
332 | 332 | <?php |
333 | - foreach ( $states as $state_code => $state ) { |
|
334 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
333 | + foreach ($states as $state_code => $state) { |
|
334 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
335 | 335 | } |
336 | 336 | ?> |
337 | 337 | </select> |
338 | 338 | <?php |
339 | 339 | } else { |
340 | 340 | ?> |
341 | - <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e( 'State / Province', 'give' ); ?>" /> |
|
341 | + <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e('State / Province', 'give'); ?>" /> |
|
342 | 342 | <?php |
343 | 343 | } |
344 | 344 | ?> |
345 | - <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e( 'Zip / Postal Code', 'give' ); ?>" value="<?php echo $address['zip']; ?>" /> |
|
345 | + <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e('Zip / Postal Code', 'give'); ?>" value="<?php echo $address['zip']; ?>" /> |
|
346 | 346 | </span> |
347 | 347 | |
348 | 348 | </div> |
@@ -358,10 +358,10 @@ discard block |
||
358 | 358 | |
359 | 359 | <span id="customer-edit-actions" class="edit-item"> |
360 | 360 | <input type="hidden" data-key="id" name="customerinfo[id]" value="<?php echo $customer->id; ?>" /> |
361 | - <?php wp_nonce_field( 'edit-customer', '_wpnonce', false, true ); ?> |
|
361 | + <?php wp_nonce_field('edit-customer', '_wpnonce', false, true); ?> |
|
362 | 362 | <input type="hidden" name="give_action" value="edit-customer" /> |
363 | - <input type="submit" id="give-edit-customer-save" class="button-secondary" value="<?php esc_attr_e( 'Update Donor', 'give' ); ?>" /> |
|
364 | - <a id="give-edit-customer-cancel" href="" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a> |
|
363 | + <input type="submit" id="give-edit-customer-save" class="button-secondary" value="<?php esc_attr_e('Update Donor', 'give'); ?>" /> |
|
364 | + <a id="give-edit-customer-cancel" href="" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a> |
|
365 | 365 | </span> |
366 | 366 | |
367 | 367 | </form> |
@@ -376,24 +376,24 @@ discard block |
||
376 | 376 | * |
377 | 377 | * @param object $customer The customer object being displayed. |
378 | 378 | */ |
379 | - do_action( 'give_donor_before_stats', $customer ); |
|
379 | + do_action('give_donor_before_stats', $customer); |
|
380 | 380 | ?> |
381 | 381 | |
382 | 382 | <div id="customer-stats-wrapper" class="customer-section postbox clear"> |
383 | 383 | <ul> |
384 | 384 | <li> |
385 | - <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $customer->email ) ); ?>"> |
|
385 | + <a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.urlencode($customer->email)); ?>"> |
|
386 | 386 | <span class="dashicons dashicons-heart"></span> |
387 | 387 | <?php |
388 | 388 | //Completed Donations |
389 | - $completed_donations_text = sprintf( _n( '%d Completed Donation', '%d Completed Donations', $customer->purchase_count, 'give' ), $customer->purchase_count ); |
|
390 | - echo apply_filters( 'give_donor_completed_donations', $completed_donations_text, $customer ); |
|
389 | + $completed_donations_text = sprintf(_n('%d Completed Donation', '%d Completed Donations', $customer->purchase_count, 'give'), $customer->purchase_count); |
|
390 | + echo apply_filters('give_donor_completed_donations', $completed_donations_text, $customer); |
|
391 | 391 | ?> |
392 | 392 | </a> |
393 | 393 | </li> |
394 | 394 | <li> |
395 | 395 | <span class="dashicons dashicons-chart-area"></span> |
396 | - <?php echo give_currency_filter( give_format_amount( $customer->purchase_value ) ); ?> <?php esc_html_e( 'Lifetime Donations', 'give' ); ?> |
|
396 | + <?php echo give_currency_filter(give_format_amount($customer->purchase_value)); ?> <?php esc_html_e('Lifetime Donations', 'give'); ?> |
|
397 | 397 | </li> |
398 | 398 | <?php |
399 | 399 | /** |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @param object $customer The customer object being displayed. |
407 | 407 | */ |
408 | - do_action( 'give_donor_stats_list', $customer ); |
|
408 | + do_action('give_donor_stats_list', $customer); |
|
409 | 409 | ?> |
410 | 410 | </ul> |
411 | 411 | </div> |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @param object $customer The customer object being displayed. |
420 | 420 | */ |
421 | - do_action( 'give_donor_before_tables_wrapper', $customer ); |
|
421 | + do_action('give_donor_before_tables_wrapper', $customer); |
|
422 | 422 | ?> |
423 | 423 | |
424 | 424 | <div id="customer-tables-wrapper" class="customer-section"> |
@@ -431,40 +431,40 @@ discard block |
||
431 | 431 | * |
432 | 432 | * @param object $customer The customer object being displayed. |
433 | 433 | */ |
434 | - do_action( 'give_donor_before_tables', $customer ); |
|
434 | + do_action('give_donor_before_tables', $customer); |
|
435 | 435 | ?> |
436 | 436 | |
437 | - <h3><?php _e( 'Donor Emails', 'give' ); ?></h3> |
|
437 | + <h3><?php _e('Donor Emails', 'give'); ?></h3> |
|
438 | 438 | |
439 | 439 | <table class="wp-list-table widefat striped emails"> |
440 | 440 | <thead> |
441 | 441 | <tr> |
442 | - <th><?php _e( 'Email', 'give' ); ?></th> |
|
443 | - <th><?php _e( 'Actions', 'give' ); ?></th> |
|
442 | + <th><?php _e('Email', 'give'); ?></th> |
|
443 | + <th><?php _e('Actions', 'give'); ?></th> |
|
444 | 444 | </tr> |
445 | 445 | </thead> |
446 | 446 | |
447 | 447 | <tbody> |
448 | - <?php if ( ! empty( $customer->emails ) ) { ?> |
|
448 | + <?php if ( ! empty($customer->emails)) { ?> |
|
449 | 449 | |
450 | - <?php foreach ( $customer->emails as $key => $email ) : ?> |
|
450 | + <?php foreach ($customer->emails as $key => $email) : ?> |
|
451 | 451 | <tr data-key="<?php echo $key; ?>"> |
452 | 452 | <td> |
453 | 453 | <?php echo $email; ?> |
454 | - <?php if ( 'primary' === $key ) : ?> |
|
454 | + <?php if ('primary' === $key) : ?> |
|
455 | 455 | <span class="dashicons dashicons-star-filled primary-email-icon"></span> |
456 | 456 | <?php endif; ?> |
457 | 457 | </td> |
458 | 458 | <td> |
459 | - <?php if ( 'primary' !== $key ) : ?> |
|
459 | + <?php if ('primary' !== $key) : ?> |
|
460 | 460 | <?php |
461 | - $base_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); |
|
462 | - $promote_url = wp_nonce_url( add_query_arg( array( 'email' => rawurlencode( $email ), 'give_action' => 'set_donor_primary_email'), $base_url ), 'give-set-donor-primary-email' ); |
|
463 | - $remove_url = wp_nonce_url( add_query_arg( array( 'email' => rawurlencode( $email ), 'give_action' => 'remove_donor_email' ), $base_url ), 'give-remove-donor-email' ); |
|
461 | + $base_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id); |
|
462 | + $promote_url = wp_nonce_url(add_query_arg(array('email' => rawurlencode($email), 'give_action' => 'set_donor_primary_email'), $base_url), 'give-set-donor-primary-email'); |
|
463 | + $remove_url = wp_nonce_url(add_query_arg(array('email' => rawurlencode($email), 'give_action' => 'remove_donor_email'), $base_url), 'give-remove-donor-email'); |
|
464 | 464 | ?> |
465 | - <a href="<?php echo $promote_url; ?>"><?php _e( 'Make Primary', 'give' ); ?></a> |
|
465 | + <a href="<?php echo $promote_url; ?>"><?php _e('Make Primary', 'give'); ?></a> |
|
466 | 466 | | |
467 | - <a href="<?php echo $remove_url; ?>" class="delete"><?php _e( 'Remove', 'give' ); ?></a> |
|
467 | + <a href="<?php echo $remove_url; ?>" class="delete"><?php _e('Remove', 'give'); ?></a> |
|
468 | 468 | <?php endif; ?> |
469 | 469 | </td> |
470 | 470 | </tr> |
@@ -474,56 +474,56 @@ discard block |
||
474 | 474 | <td colspan="2" class="add-customer-email-td"> |
475 | 475 | <div class="add-customer-email-wrapper"> |
476 | 476 | <input type="hidden" name="customer-id" value="<?php echo $customer->id; ?>" /> |
477 | - <?php wp_nonce_field( 'give_add_donor_email', 'add_email_nonce', false, true ); ?> |
|
478 | - <input type="email" name="additional-email" value="" placeholder="<?php _e( 'Email Address', 'give' ); ?>" /> |
|
479 | - <input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" /> <label for="make-additional-primary"><?php _e( 'Make Primary', 'give' ); ?></label> |
|
480 | - <button class="button-secondary give-add-customer-email" id="add-customer-email"><?php _e( 'Add Email', 'give' ); ?></button> |
|
477 | + <?php wp_nonce_field('give_add_donor_email', 'add_email_nonce', false, true); ?> |
|
478 | + <input type="email" name="additional-email" value="" placeholder="<?php _e('Email Address', 'give'); ?>" /> |
|
479 | + <input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" /> <label for="make-additional-primary"><?php _e('Make Primary', 'give'); ?></label> |
|
480 | + <button class="button-secondary give-add-customer-email" id="add-customer-email"><?php _e('Add Email', 'give'); ?></button> |
|
481 | 481 | <span class="spinner"></span> |
482 | 482 | </div> |
483 | 483 | <div class="notice-wrap"></div> |
484 | 484 | </td> |
485 | 485 | </tr> |
486 | 486 | <?php } else { ?> |
487 | - <tr><td colspan="2"><?php _e( 'No Emails Found', 'easy-digital-downloads' ); ?></td></tr> |
|
487 | + <tr><td colspan="2"><?php _e('No Emails Found', 'easy-digital-downloads'); ?></td></tr> |
|
488 | 488 | <?php } ?> |
489 | 489 | </tbody> |
490 | 490 | </table> |
491 | 491 | |
492 | - <h3><?php esc_html_e( 'Recent Donations', 'give' ); ?></h3> |
|
492 | + <h3><?php esc_html_e('Recent Donations', 'give'); ?></h3> |
|
493 | 493 | <?php |
494 | - $payment_ids = explode( ',', $customer->payment_ids ); |
|
495 | - $payments = give_get_payments( array( 'post__in' => $payment_ids ) ); |
|
496 | - $payments = array_slice( $payments, 0, 10 ); |
|
494 | + $payment_ids = explode(',', $customer->payment_ids); |
|
495 | + $payments = give_get_payments(array('post__in' => $payment_ids)); |
|
496 | + $payments = array_slice($payments, 0, 10); |
|
497 | 497 | ?> |
498 | 498 | <table class="wp-list-table widefat striped payments"> |
499 | 499 | <thead> |
500 | 500 | <tr> |
501 | - <th scope="col"><?php esc_html_e( 'ID', 'give' ); ?></th> |
|
502 | - <th scope="col"><?php esc_html_e( 'Amount', 'give' ); ?></th> |
|
503 | - <th scope="col"><?php esc_html_e( 'Date', 'give' ); ?></th> |
|
504 | - <th scope="col"><?php esc_html_e( 'Status', 'give' ); ?></th> |
|
505 | - <th scope="col"><?php esc_html_e( 'Actions', 'give' ); ?></th> |
|
501 | + <th scope="col"><?php esc_html_e('ID', 'give'); ?></th> |
|
502 | + <th scope="col"><?php esc_html_e('Amount', 'give'); ?></th> |
|
503 | + <th scope="col"><?php esc_html_e('Date', 'give'); ?></th> |
|
504 | + <th scope="col"><?php esc_html_e('Status', 'give'); ?></th> |
|
505 | + <th scope="col"><?php esc_html_e('Actions', 'give'); ?></th> |
|
506 | 506 | </tr> |
507 | 507 | </thead> |
508 | 508 | <tbody> |
509 | - <?php if ( ! empty( $payments ) ) { ?> |
|
510 | - <?php foreach ( $payments as $payment ) : ?> |
|
509 | + <?php if ( ! empty($payments)) { ?> |
|
510 | + <?php foreach ($payments as $payment) : ?> |
|
511 | 511 | <tr> |
512 | 512 | <td><?php echo $payment->ID; ?></td> |
513 | - <td><?php echo give_payment_amount( $payment->ID ); ?></td> |
|
514 | - <td><?php echo date_i18n( give_date_format(), strtotime( $payment->post_date ) ); ?></td> |
|
515 | - <td><?php echo give_get_payment_status( $payment, true ); ?></td> |
|
513 | + <td><?php echo give_payment_amount($payment->ID); ?></td> |
|
514 | + <td><?php echo date_i18n(give_date_format(), strtotime($payment->post_date)); ?></td> |
|
515 | + <td><?php echo give_get_payment_status($payment, true); ?></td> |
|
516 | 516 | <td> |
517 | 517 | <?php |
518 | 518 | printf( |
519 | 519 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
520 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment->ID ), |
|
520 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment->ID), |
|
521 | 521 | sprintf( |
522 | 522 | /* translators: %s: Donation ID */ |
523 | - esc_attr__( 'View Donation %s.', 'give' ), |
|
523 | + esc_attr__('View Donation %s.', 'give'), |
|
524 | 524 | $payment->ID |
525 | 525 | ), |
526 | - esc_html__( 'View Donation', 'give' ) |
|
526 | + esc_html__('View Donation', 'give') |
|
527 | 527 | ); |
528 | 528 | ?> |
529 | 529 | |
@@ -538,46 +538,46 @@ discard block |
||
538 | 538 | * @param object $customer The customer object being displayed. |
539 | 539 | * @param object $payment The payment object being displayed. |
540 | 540 | */ |
541 | - do_action( 'give_donor_recent_purchases_actions', $customer, $payment ); |
|
541 | + do_action('give_donor_recent_purchases_actions', $customer, $payment); |
|
542 | 542 | ?> |
543 | 543 | </td> |
544 | 544 | </tr> |
545 | 545 | <?php endforeach; ?> |
546 | 546 | <?php } else { ?> |
547 | 547 | <tr> |
548 | - <td colspan="5"><?php esc_html_e( 'No donations found.', 'give' ); ?></td> |
|
548 | + <td colspan="5"><?php esc_html_e('No donations found.', 'give'); ?></td> |
|
549 | 549 | </tr> |
550 | 550 | <?php } ?> |
551 | 551 | </tbody> |
552 | 552 | </table> |
553 | 553 | |
554 | - <h3><?php esc_html_e( 'Completed Forms', 'give' ); ?></h3> |
|
554 | + <h3><?php esc_html_e('Completed Forms', 'give'); ?></h3> |
|
555 | 555 | <?php |
556 | - $donations = give_get_users_completed_donations( $customer->email ); |
|
556 | + $donations = give_get_users_completed_donations($customer->email); |
|
557 | 557 | ?> |
558 | 558 | <table class="wp-list-table widefat striped donations"> |
559 | 559 | <thead> |
560 | 560 | <tr> |
561 | - <th scope="col"><?php esc_html_e( 'Form', 'give' ); ?></th> |
|
562 | - <th scope="col" width="120px"><?php esc_html_e( 'Actions', 'give' ); ?></th> |
|
561 | + <th scope="col"><?php esc_html_e('Form', 'give'); ?></th> |
|
562 | + <th scope="col" width="120px"><?php esc_html_e('Actions', 'give'); ?></th> |
|
563 | 563 | </tr> |
564 | 564 | </thead> |
565 | 565 | <tbody> |
566 | - <?php if ( ! empty( $donations ) ) { ?> |
|
567 | - <?php foreach ( $donations as $donation ) : ?> |
|
566 | + <?php if ( ! empty($donations)) { ?> |
|
567 | + <?php foreach ($donations as $donation) : ?> |
|
568 | 568 | <tr> |
569 | 569 | <td><?php echo $donation->post_title; ?></td> |
570 | 570 | <td> |
571 | 571 | <?php |
572 | 572 | printf( |
573 | 573 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
574 | - esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ), |
|
574 | + esc_url(admin_url('post.php?action=edit&post='.$donation->ID)), |
|
575 | 575 | sprintf( |
576 | 576 | /* translators: %s: form name */ |
577 | - esc_attr__( 'View Form %s.', 'give' ), |
|
577 | + esc_attr__('View Form %s.', 'give'), |
|
578 | 578 | $donation->post_title |
579 | 579 | ), |
580 | - esc_html__( 'View Form', 'give' ) |
|
580 | + esc_html__('View Form', 'give') |
|
581 | 581 | ); |
582 | 582 | ?> |
583 | 583 | </td> |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | <?php endforeach; ?> |
586 | 586 | <?php } else { ?> |
587 | 587 | <tr> |
588 | - <td colspan="2"><?php esc_html_e( 'No completed donations found.', 'give' ); ?></td> |
|
588 | + <td colspan="2"><?php esc_html_e('No completed donations found.', 'give'); ?></td> |
|
589 | 589 | </tr> |
590 | 590 | <?php } ?> |
591 | 591 | </tbody> |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | * |
600 | 600 | * @param object $customer The customer object being displayed. |
601 | 601 | */ |
602 | - do_action( 'give_donor_after_tables', $customer ); |
|
602 | + do_action('give_donor_after_tables', $customer); |
|
603 | 603 | ?> |
604 | 604 | |
605 | 605 | </div> |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | * |
613 | 613 | * @param object $customer The customer object being displayed. |
614 | 614 | */ |
615 | - do_action( 'give_donor_card_bottom', $customer ); |
|
615 | + do_action('give_donor_card_bottom', $customer); |
|
616 | 616 | |
617 | 617 | } |
618 | 618 | |
@@ -625,30 +625,30 @@ discard block |
||
625 | 625 | * |
626 | 626 | * @return void |
627 | 627 | */ |
628 | -function give_customer_notes_view( $customer ) { |
|
628 | +function give_customer_notes_view($customer) { |
|
629 | 629 | |
630 | - $paged = isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) ? $_GET['paged'] : 1; |
|
631 | - $paged = absint( $paged ); |
|
630 | + $paged = isset($_GET['paged']) && is_numeric($_GET['paged']) ? $_GET['paged'] : 1; |
|
631 | + $paged = absint($paged); |
|
632 | 632 | $note_count = $customer->get_notes_count(); |
633 | - $per_page = apply_filters( 'give_customer_notes_per_page', 20 ); |
|
634 | - $total_pages = ceil( $note_count / $per_page ); |
|
635 | - $customer_notes = $customer->get_notes( $per_page, $paged ); |
|
633 | + $per_page = apply_filters('give_customer_notes_per_page', 20); |
|
634 | + $total_pages = ceil($note_count / $per_page); |
|
635 | + $customer_notes = $customer->get_notes($per_page, $paged); |
|
636 | 636 | ?> |
637 | 637 | |
638 | 638 | <div id="customer-notes-wrapper"> |
639 | 639 | <div class="customer-notes-header"> |
640 | - <?php echo get_avatar( $customer->email, 30 ); ?> <span><?php echo $customer->name; ?></span> |
|
640 | + <?php echo get_avatar($customer->email, 30); ?> <span><?php echo $customer->name; ?></span> |
|
641 | 641 | </div> |
642 | - <h3><?php esc_html_e( 'Notes', 'give' ); ?></h3> |
|
642 | + <h3><?php esc_html_e('Notes', 'give'); ?></h3> |
|
643 | 643 | |
644 | - <?php if ( 1 == $paged ) : ?> |
|
644 | + <?php if (1 == $paged) : ?> |
|
645 | 645 | <div style="display: block; margin-bottom: 55px;"> |
646 | - <form id="give-add-customer-note" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $customer->id ); ?>"> |
|
646 | + <form id="give-add-customer-note" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$customer->id); ?>"> |
|
647 | 647 | <textarea id="customer-note" name="customer_note" class="customer-note-input" rows="10"></textarea> |
648 | 648 | <br /> |
649 | 649 | <input type="hidden" id="customer-id" name="customer_id" value="<?php echo $customer->id; ?>" /> |
650 | 650 | <input type="hidden" name="give_action" value="add-customer-note" /> |
651 | - <?php wp_nonce_field( 'add-customer-note', 'add_customer_note_nonce', true, true ); ?> |
|
651 | + <?php wp_nonce_field('add-customer-note', 'add_customer_note_nonce', true, true); ?> |
|
652 | 652 | <input id="add-customer-note" class="right button-primary" type="submit" value="Add Note" /> |
653 | 653 | </form> |
654 | 654 | </div> |
@@ -663,26 +663,26 @@ discard block |
||
663 | 663 | 'show_all' => true |
664 | 664 | ); |
665 | 665 | |
666 | - echo paginate_links( $pagination_args ); |
|
666 | + echo paginate_links($pagination_args); |
|
667 | 667 | ?> |
668 | 668 | |
669 | 669 | <div id="give-customer-notes" class="postbox"> |
670 | - <?php if ( count( $customer_notes ) > 0 ) { ?> |
|
671 | - <?php foreach ( $customer_notes as $key => $note ) : ?> |
|
670 | + <?php if (count($customer_notes) > 0) { ?> |
|
671 | + <?php foreach ($customer_notes as $key => $note) : ?> |
|
672 | 672 | <div class="customer-note-wrapper dashboard-comment-wrap comment-item"> |
673 | 673 | <span class="note-content-wrap"> |
674 | - <?php echo stripslashes( $note ); ?> |
|
674 | + <?php echo stripslashes($note); ?> |
|
675 | 675 | </span> |
676 | 676 | </div> |
677 | 677 | <?php endforeach; ?> |
678 | 678 | <?php } else { ?> |
679 | 679 | <div class="give-no-customer-notes"> |
680 | - <?php esc_html_e( 'No donor notes found.', 'give' ); ?> |
|
680 | + <?php esc_html_e('No donor notes found.', 'give'); ?> |
|
681 | 681 | </div> |
682 | 682 | <?php } ?> |
683 | 683 | </div> |
684 | 684 | |
685 | - <?php echo paginate_links( $pagination_args ); ?> |
|
685 | + <?php echo paginate_links($pagination_args); ?> |
|
686 | 686 | |
687 | 687 | </div> |
688 | 688 | |
@@ -698,9 +698,9 @@ discard block |
||
698 | 698 | * |
699 | 699 | * @return void |
700 | 700 | */ |
701 | -function give_customers_delete_view( $customer ) { |
|
701 | +function give_customers_delete_view($customer) { |
|
702 | 702 | |
703 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
703 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
704 | 704 | |
705 | 705 | /** |
706 | 706 | * Fires in donor delete screen, above the content. |
@@ -709,15 +709,15 @@ discard block |
||
709 | 709 | * |
710 | 710 | * @param object $customer The customer object being displayed. |
711 | 711 | */ |
712 | - do_action( 'give_customer_delete_top', $customer ); |
|
712 | + do_action('give_customer_delete_top', $customer); |
|
713 | 713 | ?> |
714 | 714 | |
715 | 715 | <div class="info-wrapper customer-section"> |
716 | 716 | |
717 | - <form id="delete-customer" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer->id ); ?>"> |
|
717 | + <form id="delete-customer" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer->id); ?>"> |
|
718 | 718 | |
719 | 719 | <div class="customer-notes-header"> |
720 | - <?php echo get_avatar( $customer->email, 30 ); ?> <span><?php echo $customer->name; ?></span> |
|
720 | + <?php echo get_avatar($customer->email, 30); ?> <span><?php echo $customer->name; ?></span> |
|
721 | 721 | </div> |
722 | 722 | |
723 | 723 | |
@@ -725,16 +725,16 @@ discard block |
||
725 | 725 | |
726 | 726 | <span class="delete-customer-options"> |
727 | 727 | <p> |
728 | - <?php echo Give()->html->checkbox( array( 'name' => 'give-customer-delete-confirm' ) ); ?> |
|
729 | - <label for="give-customer-delete-confirm"><?php esc_html_e( 'Are you sure you want to delete this donor?', 'give' ); ?></label> |
|
728 | + <?php echo Give()->html->checkbox(array('name' => 'give-customer-delete-confirm')); ?> |
|
729 | + <label for="give-customer-delete-confirm"><?php esc_html_e('Are you sure you want to delete this donor?', 'give'); ?></label> |
|
730 | 730 | </p> |
731 | 731 | |
732 | 732 | <p> |
733 | - <?php echo Give()->html->checkbox( array( |
|
733 | + <?php echo Give()->html->checkbox(array( |
|
734 | 734 | 'name' => 'give-customer-delete-records', |
735 | - 'options' => array( 'disabled' => true ) |
|
736 | - ) ); ?> |
|
737 | - <label for="give-customer-delete-records"><?php esc_html_e( 'Delete all associated donations and records?', 'give' ); ?></label> |
|
735 | + 'options' => array('disabled' => true) |
|
736 | + )); ?> |
|
737 | + <label for="give-customer-delete-records"><?php esc_html_e('Delete all associated donations and records?', 'give'); ?></label> |
|
738 | 738 | </p> |
739 | 739 | |
740 | 740 | <?php |
@@ -747,16 +747,16 @@ discard block |
||
747 | 747 | * |
748 | 748 | * @param object $customer The customer object being displayed. |
749 | 749 | */ |
750 | - do_action( 'give_customer_delete_inputs', $customer ); |
|
750 | + do_action('give_customer_delete_inputs', $customer); |
|
751 | 751 | ?> |
752 | 752 | </span> |
753 | 753 | |
754 | 754 | <span id="customer-edit-actions"> |
755 | 755 | <input type="hidden" name="customer_id" value="<?php echo $customer->id; ?>" /> |
756 | - <?php wp_nonce_field( 'delete-customer', '_wpnonce', false, true ); ?> |
|
756 | + <?php wp_nonce_field('delete-customer', '_wpnonce', false, true); ?> |
|
757 | 757 | <input type="hidden" name="give_action" value="delete-customer" /> |
758 | - <input type="submit" disabled="disabled" id="give-delete-customer" class="button-primary" value="<?php esc_attr_e( 'Delete Donor', 'give' ); ?>" /> |
|
759 | - <a id="give-delete-customer-cancel" href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); ?>" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a> |
|
758 | + <input type="submit" disabled="disabled" id="give-delete-customer" class="button-primary" value="<?php esc_attr_e('Delete Donor', 'give'); ?>" /> |
|
759 | + <a id="give-delete-customer-cancel" href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id); ?>" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a> |
|
760 | 760 | </span> |
761 | 761 | |
762 | 762 | </div> |
@@ -772,5 +772,5 @@ discard block |
||
772 | 772 | * |
773 | 773 | * @param object $customer The customer object being displayed. |
774 | 774 | */ |
775 | - do_action( 'give_customer_delete_bottom', $customer ); |
|
775 | + do_action('give_customer_delete_bottom', $customer); |
|
776 | 776 | } |