@@ -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 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * Used to redirect a user back to the purchase |
157 | 157 | * page if there are errors present. |
158 | 158 | * |
159 | - * @param array $args |
|
159 | + * @param string $args |
|
160 | 160 | * |
161 | 161 | * @access public |
162 | 162 | * @since 1.0 |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | * |
391 | 391 | * @param int $form_id Give Form ID |
392 | 392 | * |
393 | - * @return int $earnings Earnings for a certain form |
|
393 | + * @return double $earnings Earnings for a certain form |
|
394 | 394 | */ |
395 | 395 | function give_get_form_earnings_stats( $form_id = 0 ) { |
396 | 396 | $give_form = new Give_Donate_Form( $form_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 | |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | |
24 | 24 | global $typenow; |
25 | 25 | |
26 | - if ( $typenow != 'give_forms' ) { |
|
26 | + if ($typenow != 'give_forms') { |
|
27 | 27 | return true; |
28 | 28 | } |
29 | 29 | |
30 | 30 | return false; |
31 | 31 | } |
32 | 32 | |
33 | -add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' ); |
|
33 | +add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition'); |
|
34 | 34 | |
35 | 35 | |
36 | 36 | /** |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return int|false |
42 | 42 | */ |
43 | -function get_form_id_from_args( $args ) { |
|
43 | +function get_form_id_from_args($args) { |
|
44 | 44 | |
45 | - if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) { |
|
45 | + if (isset($args['form_id']) && $args['form_id'] != 0) { |
|
46 | 46 | |
47 | - return intval( $args['form_id'] ); |
|
47 | + return intval($args['form_id']); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | return false; |
@@ -59,23 +59,23 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return bool |
61 | 61 | */ |
62 | -function give_is_float_labels_enabled( $args ) { |
|
62 | +function give_is_float_labels_enabled($args) { |
|
63 | 63 | |
64 | 64 | $float_labels = ''; |
65 | 65 | |
66 | - if ( ! empty( $args['float_labels'] ) ) { |
|
66 | + if ( ! empty($args['float_labels'])) { |
|
67 | 67 | $float_labels = $args['float_labels']; |
68 | 68 | } |
69 | 69 | |
70 | - if ( empty( $float_labels ) ) { |
|
71 | - $float_labels = get_post_meta( $args['form_id'], '_give_form_floating_labels', true ); |
|
70 | + if (empty($float_labels)) { |
|
71 | + $float_labels = get_post_meta($args['form_id'], '_give_form_floating_labels', true); |
|
72 | 72 | } |
73 | 73 | |
74 | - if ( empty( $float_labels ) || ( 'global' === $float_labels ) ) { |
|
75 | - $float_labels = give_get_option( 'floatlabels', 'disabled' ); |
|
74 | + if (empty($float_labels) || ('global' === $float_labels)) { |
|
75 | + $float_labels = give_get_option('floatlabels', 'disabled'); |
|
76 | 76 | } |
77 | 77 | |
78 | - return give_is_setting_enabled( $float_labels ); |
|
78 | + return give_is_setting_enabled($float_labels); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $can_checkout = true; |
93 | 93 | |
94 | - return (bool) apply_filters( 'give_can_checkout', $can_checkout ); |
|
94 | + return (bool) apply_filters('give_can_checkout', $can_checkout); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | function give_get_success_page_uri() { |
106 | 106 | $give_options = give_get_settings(); |
107 | 107 | |
108 | - $success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' ); |
|
108 | + $success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url'); |
|
109 | 109 | |
110 | - return apply_filters( 'give_get_success_page_uri', $success_page ); |
|
110 | + return apply_filters('give_get_success_page_uri', $success_page); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | */ |
120 | 120 | function give_is_success_page() { |
121 | 121 | $give_options = give_get_settings(); |
122 | - $is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false; |
|
122 | + $is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false; |
|
123 | 123 | |
124 | - return apply_filters( 'give_is_success_page', $is_success_page ); |
|
124 | + return apply_filters('give_is_success_page', $is_success_page); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -135,17 +135,17 @@ discard block |
||
135 | 135 | * @since 1.0 |
136 | 136 | * @return void |
137 | 137 | */ |
138 | -function give_send_to_success_page( $query_string = null ) { |
|
138 | +function give_send_to_success_page($query_string = null) { |
|
139 | 139 | |
140 | 140 | $redirect = give_get_success_page_uri(); |
141 | 141 | |
142 | - if ( $query_string ) { |
|
142 | + if ($query_string) { |
|
143 | 143 | $redirect .= $query_string; |
144 | 144 | } |
145 | 145 | |
146 | - $gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : ''; |
|
146 | + $gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : ''; |
|
147 | 147 | |
148 | - wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) ); |
|
148 | + wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string)); |
|
149 | 149 | give_die(); |
150 | 150 | } |
151 | 151 | |
@@ -161,20 +161,20 @@ discard block |
||
161 | 161 | * @since 1.0 |
162 | 162 | * @return Void |
163 | 163 | */ |
164 | -function give_send_back_to_checkout( $args = array() ) { |
|
164 | +function give_send_back_to_checkout($args = array()) { |
|
165 | 165 | |
166 | - $url = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : ''; |
|
166 | + $url = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : ''; |
|
167 | 167 | |
168 | 168 | //Set the form_id. |
169 | - if ( isset( $_POST['give-form-id'] ) ) { |
|
170 | - $form_id = sanitize_text_field( $_POST['give-form-id'] ); |
|
169 | + if (isset($_POST['give-form-id'])) { |
|
170 | + $form_id = sanitize_text_field($_POST['give-form-id']); |
|
171 | 171 | } else { |
172 | 172 | $form_id = 0; |
173 | 173 | } |
174 | 174 | |
175 | 175 | //Need a URL to continue. If none, redirect back to single form. |
176 | - if ( empty( $url ) ) { |
|
177 | - wp_safe_redirect( get_permalink( $form_id ) ); |
|
176 | + if (empty($url)) { |
|
177 | + wp_safe_redirect(get_permalink($form_id)); |
|
178 | 178 | give_die(); |
179 | 179 | } |
180 | 180 | |
@@ -183,36 +183,36 @@ discard block |
||
183 | 183 | ); |
184 | 184 | |
185 | 185 | // Check for backward compatibility. |
186 | - if ( is_string( $args ) ) { |
|
187 | - $args = str_replace( '?', '', $args ); |
|
186 | + if (is_string($args)) { |
|
187 | + $args = str_replace('?', '', $args); |
|
188 | 188 | } |
189 | 189 | |
190 | - $args = wp_parse_args( $args, $defaults ); |
|
190 | + $args = wp_parse_args($args, $defaults); |
|
191 | 191 | |
192 | 192 | // Merge URL query with $args to maintain third-party URL parameters after redirect. |
193 | - $url_data = wp_parse_url( $url ); |
|
193 | + $url_data = wp_parse_url($url); |
|
194 | 194 | |
195 | 195 | //Check if an array to prevent notices before parsing. |
196 | - if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) { |
|
197 | - parse_str( $url_data['query'], $query ); |
|
196 | + if (isset($url_data['query']) && ! empty($url_data['query'])) { |
|
197 | + parse_str($url_data['query'], $query); |
|
198 | 198 | |
199 | 199 | //Precaution: don't allow any CC info. |
200 | - unset( $query['card_number'] ); |
|
201 | - unset( $query['card_cvc'] ); |
|
200 | + unset($query['card_number']); |
|
201 | + unset($query['card_cvc']); |
|
202 | 202 | |
203 | 203 | } else { |
204 | 204 | //No $url_data so pass empty array. |
205 | 205 | $query = array(); |
206 | 206 | } |
207 | 207 | |
208 | - $new_query = array_merge( $args, $query ); |
|
209 | - $new_query_string = http_build_query( $new_query ); |
|
208 | + $new_query = array_merge($args, $query); |
|
209 | + $new_query_string = http_build_query($new_query); |
|
210 | 210 | |
211 | 211 | // Assemble URL parts. |
212 | - $redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' ); |
|
212 | + $redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap'); |
|
213 | 213 | |
214 | 214 | //Redirect them. |
215 | - wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) ); |
|
215 | + wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args)); |
|
216 | 216 | give_die(); |
217 | 217 | |
218 | 218 | } |
@@ -228,16 +228,16 @@ discard block |
||
228 | 228 | * @since 1.0 |
229 | 229 | * @return string |
230 | 230 | */ |
231 | -function give_get_success_page_url( $query_string = null ) { |
|
231 | +function give_get_success_page_url($query_string = null) { |
|
232 | 232 | |
233 | - $success_page = give_get_option( 'success_page', 0 ); |
|
234 | - $success_page = get_permalink( $success_page ); |
|
233 | + $success_page = give_get_option('success_page', 0); |
|
234 | + $success_page = get_permalink($success_page); |
|
235 | 235 | |
236 | - if ( $query_string ) { |
|
236 | + if ($query_string) { |
|
237 | 237 | $success_page .= $query_string; |
238 | 238 | } |
239 | 239 | |
240 | - return apply_filters( 'give_success_page_url', $success_page ); |
|
240 | + return apply_filters('give_success_page_url', $success_page); |
|
241 | 241 | |
242 | 242 | } |
243 | 243 | |
@@ -250,15 +250,15 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @return mixed|void Full URL to the Failed Donation Page, if present, home page if it doesn't exist |
252 | 252 | */ |
253 | -function give_get_failed_transaction_uri( $extras = false ) { |
|
253 | +function give_get_failed_transaction_uri($extras = false) { |
|
254 | 254 | $give_options = give_get_settings(); |
255 | 255 | |
256 | - $uri = ! empty( $give_options['failure_page'] ) ? trailingslashit( get_permalink( $give_options['failure_page'] ) ) : home_url(); |
|
257 | - if ( $extras ) { |
|
256 | + $uri = ! empty($give_options['failure_page']) ? trailingslashit(get_permalink($give_options['failure_page'])) : home_url(); |
|
257 | + if ($extras) { |
|
258 | 258 | $uri .= $extras; |
259 | 259 | } |
260 | 260 | |
261 | - return apply_filters( 'give_get_failed_transaction_uri', $uri ); |
|
261 | + return apply_filters('give_get_failed_transaction_uri', $uri); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -269,9 +269,9 @@ discard block |
||
269 | 269 | */ |
270 | 270 | function give_is_failed_transaction_page() { |
271 | 271 | $give_options = give_get_settings(); |
272 | - $ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false; |
|
272 | + $ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false; |
|
273 | 273 | |
274 | - return apply_filters( 'give_is_failure_page', $ret ); |
|
274 | + return apply_filters('give_is_failure_page', $ret); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -283,18 +283,18 @@ discard block |
||
283 | 283 | */ |
284 | 284 | function give_listen_for_failed_payments() { |
285 | 285 | |
286 | - $failed_page = give_get_option( 'failure_page', 0 ); |
|
286 | + $failed_page = give_get_option('failure_page', 0); |
|
287 | 287 | |
288 | - if ( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) { |
|
288 | + if ( ! empty($failed_page) && is_page($failed_page) && ! empty($_GET['payment-id'])) { |
|
289 | 289 | |
290 | - $payment_id = absint( $_GET['payment-id'] ); |
|
291 | - give_update_payment_status( $payment_id, 'failed' ); |
|
290 | + $payment_id = absint($_GET['payment-id']); |
|
291 | + give_update_payment_status($payment_id, 'failed'); |
|
292 | 292 | |
293 | 293 | } |
294 | 294 | |
295 | 295 | } |
296 | 296 | |
297 | -add_action( 'template_redirect', 'give_listen_for_failed_payments' ); |
|
297 | +add_action('template_redirect', 'give_listen_for_failed_payments'); |
|
298 | 298 | |
299 | 299 | /** |
300 | 300 | * Retrieve the Donation History page URI |
@@ -307,9 +307,9 @@ discard block |
||
307 | 307 | function give_get_history_page_uri() { |
308 | 308 | $give_options = give_get_settings(); |
309 | 309 | |
310 | - $history_page = isset( $give_options['history_page'] ) ? get_permalink( absint( $give_options['history_page'] ) ) : get_bloginfo( 'url' ); |
|
310 | + $history_page = isset($give_options['history_page']) ? get_permalink(absint($give_options['history_page'])) : get_bloginfo('url'); |
|
311 | 311 | |
312 | - return apply_filters( 'give_get_history_page_uri', $history_page ); |
|
312 | + return apply_filters('give_get_history_page_uri', $history_page); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | /** |
@@ -322,11 +322,11 @@ discard block |
||
322 | 322 | * @since 1.0 |
323 | 323 | * @return bool |
324 | 324 | */ |
325 | -function give_field_is_required( $field = '', $form_id ) { |
|
325 | +function give_field_is_required($field = '', $form_id) { |
|
326 | 326 | |
327 | - $required_fields = give_purchase_form_required_fields( $form_id ); |
|
327 | + $required_fields = give_purchase_form_required_fields($form_id); |
|
328 | 328 | |
329 | - return array_key_exists( $field, $required_fields ); |
|
329 | + return array_key_exists($field, $required_fields); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
@@ -344,14 +344,14 @@ discard block |
||
344 | 344 | * |
345 | 345 | * @return void |
346 | 346 | */ |
347 | -function give_record_sale_in_log( $give_form_id = 0, $payment_id, $price_id = false, $sale_date = null ) { |
|
347 | +function give_record_sale_in_log($give_form_id = 0, $payment_id, $price_id = false, $sale_date = null) { |
|
348 | 348 | global $give_logs; |
349 | 349 | |
350 | 350 | $log_data = array( |
351 | 351 | 'post_parent' => $give_form_id, |
352 | 352 | 'log_type' => 'sale', |
353 | - 'post_date' => isset( $sale_date ) ? $sale_date : null, |
|
354 | - 'post_date_gmt' => isset( $sale_date ) ? $sale_date : null |
|
353 | + 'post_date' => isset($sale_date) ? $sale_date : null, |
|
354 | + 'post_date_gmt' => isset($sale_date) ? $sale_date : null |
|
355 | 355 | ); |
356 | 356 | |
357 | 357 | $log_meta = array( |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | 'price_id' => (int) $price_id |
360 | 360 | ); |
361 | 361 | |
362 | - $give_logs->insert_log( $log_data, $log_meta ); |
|
362 | + $give_logs->insert_log($log_data, $log_meta); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | |
@@ -373,11 +373,11 @@ discard block |
||
373 | 373 | * |
374 | 374 | * @return bool|int |
375 | 375 | */ |
376 | -function give_increase_purchase_count( $form_id = 0, $quantity = 1 ) { |
|
376 | +function give_increase_purchase_count($form_id = 0, $quantity = 1) { |
|
377 | 377 | $quantity = (int) $quantity; |
378 | - $form = new Give_Donate_Form( $form_id ); |
|
378 | + $form = new Give_Donate_Form($form_id); |
|
379 | 379 | |
380 | - return $form->increase_sales( $quantity ); |
|
380 | + return $form->increase_sales($quantity); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
@@ -390,11 +390,11 @@ discard block |
||
390 | 390 | * |
391 | 391 | * @return bool|int |
392 | 392 | */ |
393 | -function give_decrease_purchase_count( $form_id = 0, $quantity = 1 ) { |
|
393 | +function give_decrease_purchase_count($form_id = 0, $quantity = 1) { |
|
394 | 394 | $quantity = (int) $quantity; |
395 | - $form = new Give_Donate_Form( $form_id ); |
|
395 | + $form = new Give_Donate_Form($form_id); |
|
396 | 396 | |
397 | - return $form->decrease_sales( $quantity ); |
|
397 | + return $form->decrease_sales($quantity); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | /** |
@@ -407,10 +407,10 @@ discard block |
||
407 | 407 | * |
408 | 408 | * @return bool|int |
409 | 409 | */ |
410 | -function give_increase_earnings( $give_form_id = 0, $amount ) { |
|
411 | - $form = new Give_Donate_Form( $give_form_id ); |
|
410 | +function give_increase_earnings($give_form_id = 0, $amount) { |
|
411 | + $form = new Give_Donate_Form($give_form_id); |
|
412 | 412 | |
413 | - return $form->increase_earnings( $amount ); |
|
413 | + return $form->increase_earnings($amount); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | /** |
@@ -423,10 +423,10 @@ discard block |
||
423 | 423 | * |
424 | 424 | * @return bool|int |
425 | 425 | */ |
426 | -function give_decrease_earnings( $form_id = 0, $amount ) { |
|
427 | - $form = new Give_Donate_Form( $form_id ); |
|
426 | +function give_decrease_earnings($form_id = 0, $amount) { |
|
427 | + $form = new Give_Donate_Form($form_id); |
|
428 | 428 | |
429 | - return $form->decrease_earnings( $amount ); |
|
429 | + return $form->decrease_earnings($amount); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | * |
440 | 440 | * @return int $earnings Earnings for a certain form |
441 | 441 | */ |
442 | -function give_get_form_earnings_stats( $form_id = 0 ) { |
|
443 | - $give_form = new Give_Donate_Form( $form_id ); |
|
442 | +function give_get_form_earnings_stats($form_id = 0) { |
|
443 | + $give_form = new Give_Donate_Form($form_id); |
|
444 | 444 | |
445 | 445 | return $give_form->earnings; |
446 | 446 | } |
@@ -455,8 +455,8 @@ discard block |
||
455 | 455 | * |
456 | 456 | * @return int $sales Amount of sales for a certain form |
457 | 457 | */ |
458 | -function give_get_form_sales_stats( $give_form_id = 0 ) { |
|
459 | - $give_form = new Give_Donate_Form( $give_form_id ); |
|
458 | +function give_get_form_sales_stats($give_form_id = 0) { |
|
459 | + $give_form = new Give_Donate_Form($give_form_id); |
|
460 | 460 | |
461 | 461 | return $give_form->sales; |
462 | 462 | } |
@@ -471,16 +471,16 @@ discard block |
||
471 | 471 | * |
472 | 472 | * @return float $sales Average monthly sales |
473 | 473 | */ |
474 | -function give_get_average_monthly_form_sales( $form_id = 0 ) { |
|
475 | - $sales = give_get_form_sales_stats( $form_id ); |
|
476 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
474 | +function give_get_average_monthly_form_sales($form_id = 0) { |
|
475 | + $sales = give_get_form_sales_stats($form_id); |
|
476 | + $release_date = get_post_field('post_date', $form_id); |
|
477 | 477 | |
478 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
478 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
479 | 479 | |
480 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
480 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
481 | 481 | |
482 | - if ( $months > 0 ) { |
|
483 | - $sales = ( $sales / $months ); |
|
482 | + if ($months > 0) { |
|
483 | + $sales = ($sales / $months); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | return $sales; |
@@ -496,16 +496,16 @@ discard block |
||
496 | 496 | * |
497 | 497 | * @return float $earnings Average monthly earnings |
498 | 498 | */ |
499 | -function give_get_average_monthly_form_earnings( $form_id = 0 ) { |
|
500 | - $earnings = give_get_form_earnings_stats( $form_id ); |
|
501 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
499 | +function give_get_average_monthly_form_earnings($form_id = 0) { |
|
500 | + $earnings = give_get_form_earnings_stats($form_id); |
|
501 | + $release_date = get_post_field('post_date', $form_id); |
|
502 | 502 | |
503 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
503 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
504 | 504 | |
505 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
505 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
506 | 506 | |
507 | - if ( $months > 0 ) { |
|
508 | - $earnings = ( $earnings / $months ); |
|
507 | + if ($months > 0) { |
|
508 | + $earnings = ($earnings / $months); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | return $earnings < 0 ? 0 : $earnings; |
@@ -525,25 +525,25 @@ discard block |
||
525 | 525 | * |
526 | 526 | * @return string $price_name Name of the price option |
527 | 527 | */ |
528 | -function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0 ) { |
|
528 | +function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0) { |
|
529 | 529 | |
530 | - $prices = give_get_variable_prices( $form_id ); |
|
530 | + $prices = give_get_variable_prices($form_id); |
|
531 | 531 | $price_name = ''; |
532 | 532 | |
533 | - foreach ( $prices as $price ) { |
|
533 | + foreach ($prices as $price) { |
|
534 | 534 | |
535 | - if ( intval( $price['_give_id']['level_id'] ) == intval( $price_id ) ) { |
|
535 | + if (intval($price['_give_id']['level_id']) == intval($price_id)) { |
|
536 | 536 | |
537 | - $price_text = isset( $price['_give_text'] ) ? $price['_give_text'] : ''; |
|
538 | - $price_fallback = give_currency_filter( give_format_amount( $price['_give_amount'] ) ); |
|
539 | - $price_name = ! empty( $price_text ) ? $price_text : $price_fallback; |
|
537 | + $price_text = isset($price['_give_text']) ? $price['_give_text'] : ''; |
|
538 | + $price_fallback = give_currency_filter(give_format_amount($price['_give_amount'])); |
|
539 | + $price_name = ! empty($price_text) ? $price_text : $price_fallback; |
|
540 | 540 | |
541 | 541 | } |
542 | 542 | |
543 | 543 | } |
544 | 544 | |
545 | 545 | |
546 | - return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id ); |
|
546 | + return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id); |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | |
@@ -556,14 +556,14 @@ discard block |
||
556 | 556 | * |
557 | 557 | * @return string $range A fully formatted price range |
558 | 558 | */ |
559 | -function give_price_range( $form_id = 0 ) { |
|
560 | - $low = give_get_lowest_price_option( $form_id ); |
|
561 | - $high = give_get_highest_price_option( $form_id ); |
|
562 | - $range = '<span class="give_price_range_low">' . give_currency_filter( give_format_amount( $low ) ) . '</span>'; |
|
559 | +function give_price_range($form_id = 0) { |
|
560 | + $low = give_get_lowest_price_option($form_id); |
|
561 | + $high = give_get_highest_price_option($form_id); |
|
562 | + $range = '<span class="give_price_range_low">'.give_currency_filter(give_format_amount($low)).'</span>'; |
|
563 | 563 | $range .= '<span class="give_price_range_sep"> – </span>'; |
564 | - $range .= '<span class="give_price_range_high">' . give_currency_filter( give_format_amount( $high ) ) . '</span>'; |
|
564 | + $range .= '<span class="give_price_range_high">'.give_currency_filter(give_format_amount($high)).'</span>'; |
|
565 | 565 | |
566 | - return apply_filters( 'give_price_range', $range, $form_id, $low, $high ); |
|
566 | + return apply_filters('give_price_range', $range, $form_id, $low, $high); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | |
@@ -578,36 +578,36 @@ discard block |
||
578 | 578 | * |
579 | 579 | * @return int ID of the lowest price |
580 | 580 | */ |
581 | -function give_get_lowest_price_id( $form_id = 0 ) { |
|
581 | +function give_get_lowest_price_id($form_id = 0) { |
|
582 | 582 | |
583 | - if ( empty( $form_id ) ) { |
|
583 | + if (empty($form_id)) { |
|
584 | 584 | $form_id = get_the_ID(); |
585 | 585 | } |
586 | 586 | |
587 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
588 | - return give_get_form_price( $form_id ); |
|
587 | + if ( ! give_has_variable_prices($form_id)) { |
|
588 | + return give_get_form_price($form_id); |
|
589 | 589 | } |
590 | 590 | |
591 | - $prices = give_get_variable_prices( $form_id ); |
|
591 | + $prices = give_get_variable_prices($form_id); |
|
592 | 592 | |
593 | 593 | $low = 0.00; |
594 | 594 | $min_id = 1; |
595 | 595 | |
596 | - if ( ! empty( $prices ) ) { |
|
596 | + if ( ! empty($prices)) { |
|
597 | 597 | |
598 | - foreach ( $prices as $key => $price ) { |
|
598 | + foreach ($prices as $key => $price) { |
|
599 | 599 | |
600 | - if ( empty( $price['_give_amount'] ) ) { |
|
600 | + if (empty($price['_give_amount'])) { |
|
601 | 601 | continue; |
602 | 602 | } |
603 | 603 | |
604 | - if ( ! isset( $min ) ) { |
|
604 | + if ( ! isset($min)) { |
|
605 | 605 | $min = $price['_give_amount']; |
606 | 606 | } else { |
607 | - $min = min( $min, $price['_give_amount'] ); |
|
607 | + $min = min($min, $price['_give_amount']); |
|
608 | 608 | } |
609 | 609 | |
610 | - if ( $price['_give_amount'] == $min ) { |
|
610 | + if ($price['_give_amount'] == $min) { |
|
611 | 611 | $min_id = $price['_give_id']['level_id']; |
612 | 612 | } |
613 | 613 | } |
@@ -625,43 +625,43 @@ discard block |
||
625 | 625 | * |
626 | 626 | * @return float Amount of the lowest price |
627 | 627 | */ |
628 | -function give_get_lowest_price_option( $form_id = 0 ) { |
|
629 | - if ( empty( $form_id ) ) { |
|
628 | +function give_get_lowest_price_option($form_id = 0) { |
|
629 | + if (empty($form_id)) { |
|
630 | 630 | $form_id = get_the_ID(); |
631 | 631 | } |
632 | 632 | |
633 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
634 | - return give_get_form_price( $form_id ); |
|
633 | + if ( ! give_has_variable_prices($form_id)) { |
|
634 | + return give_get_form_price($form_id); |
|
635 | 635 | } |
636 | 636 | |
637 | - $prices = give_get_variable_prices( $form_id ); |
|
637 | + $prices = give_get_variable_prices($form_id); |
|
638 | 638 | |
639 | 639 | $low = 0.00; |
640 | 640 | |
641 | - if ( ! empty( $prices ) ) { |
|
641 | + if ( ! empty($prices)) { |
|
642 | 642 | |
643 | - foreach ( $prices as $key => $price ) { |
|
643 | + foreach ($prices as $key => $price) { |
|
644 | 644 | |
645 | - if ( empty( $price['_give_amount'] ) ) { |
|
645 | + if (empty($price['_give_amount'])) { |
|
646 | 646 | continue; |
647 | 647 | } |
648 | 648 | |
649 | - if ( ! isset( $min ) ) { |
|
649 | + if ( ! isset($min)) { |
|
650 | 650 | $min = $price['_give_amount']; |
651 | 651 | } else { |
652 | - $min = min( $min, give_sanitize_amount( $price['_give_amount'] ) ); |
|
652 | + $min = min($min, give_sanitize_amount($price['_give_amount'])); |
|
653 | 653 | } |
654 | 654 | |
655 | - if ( $price['_give_amount'] == $min ) { |
|
655 | + if ($price['_give_amount'] == $min) { |
|
656 | 656 | $min_id = $key; |
657 | 657 | } |
658 | 658 | } |
659 | 659 | |
660 | - $low = $prices[ $min_id ]['_give_amount']; |
|
660 | + $low = $prices[$min_id]['_give_amount']; |
|
661 | 661 | |
662 | 662 | } |
663 | 663 | |
664 | - return give_sanitize_amount( $low ); |
|
664 | + return give_sanitize_amount($low); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | /** |
@@ -673,41 +673,41 @@ discard block |
||
673 | 673 | * |
674 | 674 | * @return float Amount of the highest price |
675 | 675 | */ |
676 | -function give_get_highest_price_option( $form_id = 0 ) { |
|
676 | +function give_get_highest_price_option($form_id = 0) { |
|
677 | 677 | |
678 | - if ( empty( $form_id ) ) { |
|
678 | + if (empty($form_id)) { |
|
679 | 679 | $form_id = get_the_ID(); |
680 | 680 | } |
681 | 681 | |
682 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
683 | - return give_get_form_price( $form_id ); |
|
682 | + if ( ! give_has_variable_prices($form_id)) { |
|
683 | + return give_get_form_price($form_id); |
|
684 | 684 | } |
685 | 685 | |
686 | - $prices = give_get_variable_prices( $form_id ); |
|
686 | + $prices = give_get_variable_prices($form_id); |
|
687 | 687 | |
688 | 688 | $high = 0.00; |
689 | 689 | |
690 | - if ( ! empty( $prices ) ) { |
|
690 | + if ( ! empty($prices)) { |
|
691 | 691 | |
692 | 692 | $max = 0; |
693 | 693 | |
694 | - foreach ( $prices as $key => $price ) { |
|
695 | - if ( empty( $price['_give_amount'] ) ) { |
|
694 | + foreach ($prices as $key => $price) { |
|
695 | + if (empty($price['_give_amount'])) { |
|
696 | 696 | continue; |
697 | 697 | } |
698 | - $give_amount = give_sanitize_amount( $price['_give_amount'] ); |
|
698 | + $give_amount = give_sanitize_amount($price['_give_amount']); |
|
699 | 699 | |
700 | - $max = max( $max, $give_amount ); |
|
700 | + $max = max($max, $give_amount); |
|
701 | 701 | |
702 | - if ( $give_amount == $max ) { |
|
702 | + if ($give_amount == $max) { |
|
703 | 703 | $max_id = $key; |
704 | 704 | } |
705 | 705 | } |
706 | 706 | |
707 | - $high = $prices[ $max_id ]['_give_amount']; |
|
707 | + $high = $prices[$max_id]['_give_amount']; |
|
708 | 708 | } |
709 | 709 | |
710 | - return give_sanitize_amount( $high ); |
|
710 | + return give_sanitize_amount($high); |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | /** |
@@ -719,15 +719,15 @@ discard block |
||
719 | 719 | * |
720 | 720 | * @return mixed string|int Price of the form |
721 | 721 | */ |
722 | -function give_get_form_price( $form_id = 0 ) { |
|
722 | +function give_get_form_price($form_id = 0) { |
|
723 | 723 | |
724 | - if ( empty( $form_id ) ) { |
|
724 | + if (empty($form_id)) { |
|
725 | 725 | return false; |
726 | 726 | } |
727 | 727 | |
728 | - $form = new Give_Donate_Form( $form_id ); |
|
728 | + $form = new Give_Donate_Form($form_id); |
|
729 | 729 | |
730 | - return $form->__get( 'price' ); |
|
730 | + return $form->__get('price'); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 | /** |
@@ -739,15 +739,15 @@ discard block |
||
739 | 739 | * |
740 | 740 | * @return mixed string|int Minimum price of the form |
741 | 741 | */ |
742 | -function give_get_form_minimum_price( $form_id = 0 ) { |
|
742 | +function give_get_form_minimum_price($form_id = 0) { |
|
743 | 743 | |
744 | - if ( empty( $form_id ) ) { |
|
744 | + if (empty($form_id)) { |
|
745 | 745 | return false; |
746 | 746 | } |
747 | 747 | |
748 | - $form = new Give_Donate_Form( $form_id ); |
|
748 | + $form = new Give_Donate_Form($form_id); |
|
749 | 749 | |
750 | - return $form->__get( 'minimum_price' ); |
|
750 | + return $form->__get('minimum_price'); |
|
751 | 751 | |
752 | 752 | } |
753 | 753 | |
@@ -762,52 +762,52 @@ discard block |
||
762 | 762 | * |
763 | 763 | * @return int $formatted_price |
764 | 764 | */ |
765 | -function give_price( $form_id = 0, $echo = true, $price_id = false ) { |
|
765 | +function give_price($form_id = 0, $echo = true, $price_id = false) { |
|
766 | 766 | |
767 | - if ( empty( $form_id ) ) { |
|
767 | + if (empty($form_id)) { |
|
768 | 768 | $form_id = get_the_ID(); |
769 | 769 | } |
770 | 770 | |
771 | - if ( give_has_variable_prices( $form_id ) ) { |
|
771 | + if (give_has_variable_prices($form_id)) { |
|
772 | 772 | |
773 | - $prices = give_get_variable_prices( $form_id ); |
|
773 | + $prices = give_get_variable_prices($form_id); |
|
774 | 774 | |
775 | - if ( false !== $price_id ) { |
|
775 | + if (false !== $price_id) { |
|
776 | 776 | |
777 | 777 | //loop through multi-prices to see which is default |
778 | - foreach ( $prices as $price ) { |
|
778 | + foreach ($prices as $price) { |
|
779 | 779 | //this is the default price |
780 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
780 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
781 | 781 | $price = (float) $price['_give_amount']; |
782 | 782 | }; |
783 | 783 | } |
784 | 784 | |
785 | 785 | } else { |
786 | 786 | |
787 | - $price = give_get_lowest_price_option( $form_id ); |
|
787 | + $price = give_get_lowest_price_option($form_id); |
|
788 | 788 | } |
789 | 789 | |
790 | - $price = give_sanitize_amount( $price ); |
|
790 | + $price = give_sanitize_amount($price); |
|
791 | 791 | |
792 | 792 | } else { |
793 | 793 | |
794 | - $price = give_get_form_price( $form_id ); |
|
794 | + $price = give_get_form_price($form_id); |
|
795 | 795 | |
796 | 796 | } |
797 | 797 | |
798 | - $price = apply_filters( 'give_form_price', give_sanitize_amount( $price ), $form_id ); |
|
799 | - $formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>'; |
|
800 | - $formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price ); |
|
798 | + $price = apply_filters('give_form_price', give_sanitize_amount($price), $form_id); |
|
799 | + $formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>'; |
|
800 | + $formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price); |
|
801 | 801 | |
802 | - if ( $echo ) { |
|
802 | + if ($echo) { |
|
803 | 803 | echo $formatted_price; |
804 | 804 | } else { |
805 | 805 | return $formatted_price; |
806 | 806 | } |
807 | 807 | } |
808 | 808 | |
809 | -add_filter( 'give_form_price', 'give_format_amount', 10 ); |
|
810 | -add_filter( 'give_form_price', 'give_currency_filter', 20 ); |
|
809 | +add_filter('give_form_price', 'give_format_amount', 10); |
|
810 | +add_filter('give_form_price', 'give_currency_filter', 20); |
|
811 | 811 | |
812 | 812 | |
813 | 813 | /** |
@@ -820,19 +820,19 @@ discard block |
||
820 | 820 | * |
821 | 821 | * @return float $amount Amount of the price option |
822 | 822 | */ |
823 | -function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) { |
|
824 | - $prices = give_get_variable_prices( $form_id ); |
|
823 | +function give_get_price_option_amount($form_id = 0, $price_id = 0) { |
|
824 | + $prices = give_get_variable_prices($form_id); |
|
825 | 825 | |
826 | 826 | $amount = 0.00; |
827 | 827 | |
828 | - foreach ( $prices as $price ) { |
|
829 | - if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) { |
|
830 | - $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; |
|
828 | + foreach ($prices as $price) { |
|
829 | + if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) { |
|
830 | + $amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00; |
|
831 | 831 | break; |
832 | 832 | }; |
833 | 833 | } |
834 | 834 | |
835 | - return apply_filters( 'give_get_price_option_amount', give_sanitize_amount( $amount ), $form_id, $price_id ); |
|
835 | + return apply_filters('give_get_price_option_amount', give_sanitize_amount($amount), $form_id, $price_id); |
|
836 | 836 | } |
837 | 837 | |
838 | 838 | /** |
@@ -844,13 +844,13 @@ discard block |
||
844 | 844 | * |
845 | 845 | * @return mixed string|int Goal of the form |
846 | 846 | */ |
847 | -function give_get_form_goal( $form_id = 0 ) { |
|
847 | +function give_get_form_goal($form_id = 0) { |
|
848 | 848 | |
849 | - if ( empty( $form_id ) ) { |
|
849 | + if (empty($form_id)) { |
|
850 | 850 | return false; |
851 | 851 | } |
852 | 852 | |
853 | - $form = new Give_Donate_Form( $form_id ); |
|
853 | + $form = new Give_Donate_Form($form_id); |
|
854 | 854 | |
855 | 855 | return $form->goal; |
856 | 856 | |
@@ -866,27 +866,27 @@ discard block |
||
866 | 866 | * |
867 | 867 | * @return string $formatted_goal |
868 | 868 | */ |
869 | -function give_goal( $form_id = 0, $echo = true ) { |
|
869 | +function give_goal($form_id = 0, $echo = true) { |
|
870 | 870 | |
871 | - if ( empty( $form_id ) ) { |
|
871 | + if (empty($form_id)) { |
|
872 | 872 | $form_id = get_the_ID(); |
873 | 873 | } |
874 | 874 | |
875 | - $goal = give_get_form_goal( $form_id ); |
|
875 | + $goal = give_get_form_goal($form_id); |
|
876 | 876 | |
877 | - $goal = apply_filters( 'give_form_goal', give_sanitize_amount( $goal ), $form_id ); |
|
878 | - $formatted_goal = '<span class="give_price" id="give_price_' . $form_id . '">' . $goal . '</span>'; |
|
879 | - $formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal ); |
|
877 | + $goal = apply_filters('give_form_goal', give_sanitize_amount($goal), $form_id); |
|
878 | + $formatted_goal = '<span class="give_price" id="give_price_'.$form_id.'">'.$goal.'</span>'; |
|
879 | + $formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal); |
|
880 | 880 | |
881 | - if ( $echo ) { |
|
881 | + if ($echo) { |
|
882 | 882 | echo $formatted_goal; |
883 | 883 | } else { |
884 | 884 | return $formatted_goal; |
885 | 885 | } |
886 | 886 | } |
887 | 887 | |
888 | -add_filter( 'give_form_goal', 'give_format_amount', 10 ); |
|
889 | -add_filter( 'give_form_goal', 'give_currency_filter', 20 ); |
|
888 | +add_filter('give_form_goal', 'give_format_amount', 10); |
|
889 | +add_filter('give_form_goal', 'give_currency_filter', 20); |
|
890 | 890 | |
891 | 891 | |
892 | 892 | /** |
@@ -898,10 +898,10 @@ discard block |
||
898 | 898 | * |
899 | 899 | * @return bool $ret Whether or not the logged_in_only setting is set |
900 | 900 | */ |
901 | -function give_logged_in_only( $form_id ) { |
|
902 | - $ret = give_is_setting_enabled( get_post_meta( $form_id, '_give_logged_in_only', true ) ); |
|
901 | +function give_logged_in_only($form_id) { |
|
902 | + $ret = give_is_setting_enabled(get_post_meta($form_id, '_give_logged_in_only', true)); |
|
903 | 903 | |
904 | - return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id ); |
|
904 | + return (bool) apply_filters('give_logged_in_only', $ret, $form_id); |
|
905 | 905 | |
906 | 906 | } |
907 | 907 | |
@@ -915,11 +915,11 @@ discard block |
||
915 | 915 | * |
916 | 916 | * @return string |
917 | 917 | */ |
918 | -function give_show_login_register_option( $form_id ) { |
|
918 | +function give_show_login_register_option($form_id) { |
|
919 | 919 | |
920 | - $show_register_form = get_post_meta( $form_id, '_give_show_register_form', true ); |
|
920 | + $show_register_form = get_post_meta($form_id, '_give_show_register_form', true); |
|
921 | 921 | |
922 | - return apply_filters( 'give_show_register_form', $show_register_form, $form_id ); |
|
922 | + return apply_filters('give_show_register_form', $show_register_form, $form_id); |
|
923 | 923 | |
924 | 924 | } |
925 | 925 | |
@@ -933,12 +933,12 @@ discard block |
||
933 | 933 | * @param int $form_id Form ID. |
934 | 934 | * @return array |
935 | 935 | */ |
936 | -function _give_get_prefill_form_field_values( $form_id ) { |
|
936 | +function _give_get_prefill_form_field_values($form_id) { |
|
937 | 937 | $logged_in_donor_info = array(); |
938 | 938 | |
939 | - if ( is_user_logged_in() ) : |
|
940 | - $donor_data = get_userdata( get_current_user_id() ); |
|
941 | - $donor_address = get_user_meta( get_current_user_id(), '_give_user_address', true ); |
|
939 | + if (is_user_logged_in()) : |
|
940 | + $donor_data = get_userdata(get_current_user_id()); |
|
941 | + $donor_address = get_user_meta(get_current_user_id(), '_give_user_address', true); |
|
942 | 942 | |
943 | 943 | $logged_in_donor_info = array( |
944 | 944 | // First name. |
@@ -951,42 +951,42 @@ discard block |
||
951 | 951 | 'give_email' => $donor_data->user_email, |
952 | 952 | |
953 | 953 | // Street address 1. |
954 | - 'card_address' => ( ! empty( $donor_address['line1'] ) ? $donor_address['line1'] : '' ), |
|
954 | + 'card_address' => ( ! empty($donor_address['line1']) ? $donor_address['line1'] : ''), |
|
955 | 955 | |
956 | 956 | // Street address 2. |
957 | - 'card_address_2' => ( ! empty( $donor_address['line2'] ) ? $donor_address['line2'] : '' ), |
|
957 | + 'card_address_2' => ( ! empty($donor_address['line2']) ? $donor_address['line2'] : ''), |
|
958 | 958 | |
959 | 959 | // Country. |
960 | - 'billing_country' => ( ! empty( $donor_address['country'] ) ? $donor_address['country'] : '' ), |
|
960 | + 'billing_country' => ( ! empty($donor_address['country']) ? $donor_address['country'] : ''), |
|
961 | 961 | |
962 | 962 | // State. |
963 | - 'card_state' => ( ! empty( $donor_address['state'] ) ? $donor_address['state'] : '' ), |
|
963 | + 'card_state' => ( ! empty($donor_address['state']) ? $donor_address['state'] : ''), |
|
964 | 964 | |
965 | 965 | // City. |
966 | - 'card_city' => ( ! empty( $donor_address['city'] ) ? $donor_address['city'] : '' ), |
|
966 | + 'card_city' => ( ! empty($donor_address['city']) ? $donor_address['city'] : ''), |
|
967 | 967 | |
968 | 968 | // Zipcode |
969 | - 'card_zip' => ( ! empty( $donor_address['zip'] ) ? $donor_address['zip'] : '' ) |
|
969 | + 'card_zip' => ( ! empty($donor_address['zip']) ? $donor_address['zip'] : '') |
|
970 | 970 | ); |
971 | 971 | endif; |
972 | 972 | |
973 | 973 | // Bailout: Auto fill form field values only form form which donor is donating. |
974 | - if( |
|
975 | - empty( $_GET['form-id'] ) |
|
974 | + if ( |
|
975 | + empty($_GET['form-id']) |
|
976 | 976 | || ! $form_id |
977 | - || ( $form_id !== absint( $_GET['form-id'] ) ) |
|
977 | + || ($form_id !== absint($_GET['form-id'])) |
|
978 | 978 | ) { |
979 | 979 | return $logged_in_donor_info; |
980 | 980 | } |
981 | 981 | |
982 | 982 | // Get purchase data. |
983 | - $give_purchase_data = Give()->session->get( 'give_purchase' ); |
|
983 | + $give_purchase_data = Give()->session->get('give_purchase'); |
|
984 | 984 | |
985 | 985 | // Get donor info from form data. |
986 | - $give_donor_info_in_session = empty( $give_purchase_data['post_data'] ) |
|
986 | + $give_donor_info_in_session = empty($give_purchase_data['post_data']) |
|
987 | 987 | ? array() |
988 | 988 | : $give_purchase_data['post_data']; |
989 | 989 | |
990 | 990 | // Output. |
991 | - return wp_parse_args( $give_donor_info_in_session, $logged_in_donor_info ); |
|
991 | + return wp_parse_args($give_donor_info_in_session, $logged_in_donor_info); |
|
992 | 992 | } |
993 | 993 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -85,19 +85,19 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function get_predefined_dates() { |
87 | 87 | $predefined = array( |
88 | - 'today' => esc_html__( 'Today', 'give' ), |
|
89 | - 'yesterday' => esc_html__( 'Yesterday', 'give' ), |
|
90 | - 'this_week' => esc_html__( 'This Week', 'give' ), |
|
91 | - 'last_week' => esc_html__( 'Last Week', 'give' ), |
|
92 | - 'this_month' => esc_html__( 'This Month', 'give' ), |
|
93 | - 'last_month' => esc_html__( 'Last Month', 'give' ), |
|
94 | - 'this_quarter' => esc_html__( 'This Quarter', 'give' ), |
|
95 | - 'last_quarter' => esc_html__( 'Last Quarter', 'give' ), |
|
96 | - 'this_year' => esc_html__( 'This Year', 'give' ), |
|
97 | - 'last_year' => esc_html__( 'Last Year', 'give' ) |
|
88 | + 'today' => esc_html__('Today', 'give'), |
|
89 | + 'yesterday' => esc_html__('Yesterday', 'give'), |
|
90 | + 'this_week' => esc_html__('This Week', 'give'), |
|
91 | + 'last_week' => esc_html__('Last Week', 'give'), |
|
92 | + 'this_month' => esc_html__('This Month', 'give'), |
|
93 | + 'last_month' => esc_html__('Last Month', 'give'), |
|
94 | + 'this_quarter' => esc_html__('This Quarter', 'give'), |
|
95 | + 'last_quarter' => esc_html__('Last Quarter', 'give'), |
|
96 | + 'this_year' => esc_html__('This Year', 'give'), |
|
97 | + 'last_year' => esc_html__('Last Year', 'give') |
|
98 | 98 | ); |
99 | 99 | |
100 | - return apply_filters( 'give_stats_predefined_dates', $predefined ); |
|
100 | + return apply_filters('give_stats_predefined_dates', $predefined); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -113,18 +113,18 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return void |
115 | 115 | */ |
116 | - public function setup_dates( $_start_date = 'this_month', $_end_date = false ) { |
|
116 | + public function setup_dates($_start_date = 'this_month', $_end_date = false) { |
|
117 | 117 | |
118 | - if ( empty( $_start_date ) ) { |
|
118 | + if (empty($_start_date)) { |
|
119 | 119 | $_start_date = 'this_month'; |
120 | 120 | } |
121 | 121 | |
122 | - if ( empty( $_end_date ) ) { |
|
122 | + if (empty($_end_date)) { |
|
123 | 123 | $_end_date = $_start_date; |
124 | 124 | } |
125 | 125 | |
126 | - $this->start_date = $this->convert_date( $_start_date ); |
|
127 | - $this->end_date = $this->convert_date( $_end_date, true ); |
|
126 | + $this->start_date = $this->convert_date($_start_date); |
|
127 | + $this->end_date = $this->convert_date($_end_date, true); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -140,26 +140,26 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return array|WP_Error If the date is invalid, a WP_Error object will be returned. |
142 | 142 | */ |
143 | - public function convert_date( $date, $end_date = false ) { |
|
143 | + public function convert_date($date, $end_date = false) { |
|
144 | 144 | |
145 | 145 | $this->timestamp = false; |
146 | 146 | $second = $end_date ? 59 : 0; |
147 | 147 | $minute = $end_date ? 59 : 0; |
148 | 148 | $hour = $end_date ? 23 : 0; |
149 | 149 | $day = 1; |
150 | - $month = date( 'n', current_time( 'timestamp' ) ); |
|
151 | - $year = date( 'Y', current_time( 'timestamp' ) ); |
|
150 | + $month = date('n', current_time('timestamp')); |
|
151 | + $year = date('Y', current_time('timestamp')); |
|
152 | 152 | |
153 | - if ( array_key_exists( $date, $this->get_predefined_dates() ) ) { |
|
153 | + if (array_key_exists($date, $this->get_predefined_dates())) { |
|
154 | 154 | |
155 | 155 | // This is a predefined date rate, such as last_week |
156 | - switch ( $date ) { |
|
156 | + switch ($date) { |
|
157 | 157 | |
158 | 158 | case 'this_month' : |
159 | 159 | |
160 | - if ( $end_date ) { |
|
160 | + if ($end_date) { |
|
161 | 161 | |
162 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
162 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
163 | 163 | $hour = 23; |
164 | 164 | $minute = 59; |
165 | 165 | $second = 59; |
@@ -169,28 +169,28 @@ discard block |
||
169 | 169 | |
170 | 170 | case 'last_month' : |
171 | 171 | |
172 | - if ( $month == 1 ) { |
|
172 | + if ($month == 1) { |
|
173 | 173 | |
174 | 174 | $month = 12; |
175 | - $year --; |
|
175 | + $year--; |
|
176 | 176 | |
177 | 177 | } else { |
178 | 178 | |
179 | - $month --; |
|
179 | + $month--; |
|
180 | 180 | |
181 | 181 | } |
182 | 182 | |
183 | - if ( $end_date ) { |
|
184 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
183 | + if ($end_date) { |
|
184 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | break; |
188 | 188 | |
189 | 189 | case 'today' : |
190 | 190 | |
191 | - $day = date( 'd', current_time( 'timestamp' ) ); |
|
191 | + $day = date('d', current_time('timestamp')); |
|
192 | 192 | |
193 | - if ( $end_date ) { |
|
193 | + if ($end_date) { |
|
194 | 194 | $hour = 23; |
195 | 195 | $minute = 59; |
196 | 196 | $second = 59; |
@@ -200,23 +200,23 @@ discard block |
||
200 | 200 | |
201 | 201 | case 'yesterday' : |
202 | 202 | |
203 | - $day = date( 'd', current_time( 'timestamp' ) ) - 1; |
|
203 | + $day = date('d', current_time('timestamp')) - 1; |
|
204 | 204 | |
205 | 205 | // Check if Today is the first day of the month (meaning subtracting one will get us 0) |
206 | - if ( $day < 1 ) { |
|
206 | + if ($day < 1) { |
|
207 | 207 | |
208 | 208 | // If current month is 1 |
209 | - if ( 1 == $month ) { |
|
209 | + if (1 == $month) { |
|
210 | 210 | |
211 | 211 | $year -= 1; // Today is January 1, so skip back to last day of December |
212 | 212 | $month = 12; |
213 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
213 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
214 | 214 | |
215 | 215 | } else { |
216 | 216 | |
217 | 217 | // Go back one month and get the last day of the month |
218 | 218 | $month -= 1; |
219 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
219 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
220 | 220 | |
221 | 221 | } |
222 | 222 | } |
@@ -225,12 +225,12 @@ discard block |
||
225 | 225 | |
226 | 226 | case 'this_week' : |
227 | 227 | |
228 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
229 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
228 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
229 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
230 | 230 | |
231 | - if ( $today < $days_to_week_start ) { |
|
231 | + if ($today < $days_to_week_start) { |
|
232 | 232 | |
233 | - if ( $month > 1 ) { |
|
233 | + if ($month > 1) { |
|
234 | 234 | $month -= 1; |
235 | 235 | } else { |
236 | 236 | $month = 12; |
@@ -238,19 +238,19 @@ discard block |
||
238 | 238 | |
239 | 239 | } |
240 | 240 | |
241 | - if ( ! $end_date ) { |
|
241 | + if ( ! $end_date) { |
|
242 | 242 | |
243 | 243 | // Getting the start day |
244 | 244 | |
245 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
246 | - $day += get_option( 'start_of_week' ); |
|
245 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
246 | + $day += get_option('start_of_week'); |
|
247 | 247 | |
248 | 248 | } else { |
249 | 249 | |
250 | 250 | // Getting the end day |
251 | 251 | |
252 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
253 | - $day += get_option( 'start_of_week' ) + 6; |
|
252 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
253 | + $day += get_option('start_of_week') + 6; |
|
254 | 254 | |
255 | 255 | } |
256 | 256 | |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | |
259 | 259 | case 'last_week' : |
260 | 260 | |
261 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
262 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
261 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
262 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
263 | 263 | |
264 | - if ( $today < $days_to_week_start ) { |
|
264 | + if ($today < $days_to_week_start) { |
|
265 | 265 | |
266 | - if ( $month > 1 ) { |
|
266 | + if ($month > 1) { |
|
267 | 267 | $month -= 1; |
268 | 268 | } else { |
269 | 269 | $month = 12; |
@@ -271,19 +271,19 @@ discard block |
||
271 | 271 | |
272 | 272 | } |
273 | 273 | |
274 | - if ( ! $end_date ) { |
|
274 | + if ( ! $end_date) { |
|
275 | 275 | |
276 | 276 | // Getting the start day |
277 | 277 | |
278 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
279 | - $day += get_option( 'start_of_week' ); |
|
278 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
279 | + $day += get_option('start_of_week'); |
|
280 | 280 | |
281 | 281 | } else { |
282 | 282 | |
283 | 283 | // Getting the end day |
284 | 284 | |
285 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
286 | - $day += get_option( 'start_of_week' ) + 6; |
|
285 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
286 | + $day += get_option('start_of_week') + 6; |
|
287 | 287 | |
288 | 288 | } |
289 | 289 | |
@@ -291,39 +291,39 @@ discard block |
||
291 | 291 | |
292 | 292 | case 'this_quarter' : |
293 | 293 | |
294 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
294 | + $month_now = date('n', current_time('timestamp')); |
|
295 | 295 | |
296 | - if ( $month_now <= 3 ) { |
|
296 | + if ($month_now <= 3) { |
|
297 | 297 | |
298 | - if ( ! $end_date ) { |
|
298 | + if ( ! $end_date) { |
|
299 | 299 | $month = 1; |
300 | 300 | } else { |
301 | 301 | $month = 3; |
302 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
302 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
303 | 303 | $hour = 23; |
304 | 304 | $minute = 59; |
305 | 305 | $second = 59; |
306 | 306 | } |
307 | 307 | |
308 | - } else if ( $month_now <= 6 ) { |
|
308 | + } else if ($month_now <= 6) { |
|
309 | 309 | |
310 | - if ( ! $end_date ) { |
|
310 | + if ( ! $end_date) { |
|
311 | 311 | $month = 4; |
312 | 312 | } else { |
313 | 313 | $month = 6; |
314 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
314 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
315 | 315 | $hour = 23; |
316 | 316 | $minute = 59; |
317 | 317 | $second = 59; |
318 | 318 | } |
319 | 319 | |
320 | - } else if ( $month_now <= 9 ) { |
|
320 | + } else if ($month_now <= 9) { |
|
321 | 321 | |
322 | - if ( ! $end_date ) { |
|
322 | + if ( ! $end_date) { |
|
323 | 323 | $month = 7; |
324 | 324 | } else { |
325 | 325 | $month = 9; |
326 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
326 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
327 | 327 | $hour = 23; |
328 | 328 | $minute = 59; |
329 | 329 | $second = 59; |
@@ -331,11 +331,11 @@ discard block |
||
331 | 331 | |
332 | 332 | } else { |
333 | 333 | |
334 | - if ( ! $end_date ) { |
|
334 | + if ( ! $end_date) { |
|
335 | 335 | $month = 10; |
336 | 336 | } else { |
337 | 337 | $month = 12; |
338 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
338 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
339 | 339 | $hour = 23; |
340 | 340 | $minute = 59; |
341 | 341 | $second = 59; |
@@ -347,40 +347,40 @@ discard block |
||
347 | 347 | |
348 | 348 | case 'last_quarter' : |
349 | 349 | |
350 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
350 | + $month_now = date('n', current_time('timestamp')); |
|
351 | 351 | |
352 | - if ( $month_now <= 3 ) { |
|
352 | + if ($month_now <= 3) { |
|
353 | 353 | |
354 | - if ( ! $end_date ) { |
|
354 | + if ( ! $end_date) { |
|
355 | 355 | $month = 10; |
356 | 356 | } else { |
357 | 357 | $year -= 1; |
358 | 358 | $month = 12; |
359 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
359 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
360 | 360 | $hour = 23; |
361 | 361 | $minute = 59; |
362 | 362 | $second = 59; |
363 | 363 | } |
364 | 364 | |
365 | - } else if ( $month_now <= 6 ) { |
|
365 | + } else if ($month_now <= 6) { |
|
366 | 366 | |
367 | - if ( ! $end_date ) { |
|
367 | + if ( ! $end_date) { |
|
368 | 368 | $month = 1; |
369 | 369 | } else { |
370 | 370 | $month = 3; |
371 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
371 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
372 | 372 | $hour = 23; |
373 | 373 | $minute = 59; |
374 | 374 | $second = 59; |
375 | 375 | } |
376 | 376 | |
377 | - } else if ( $month_now <= 9 ) { |
|
377 | + } else if ($month_now <= 9) { |
|
378 | 378 | |
379 | - if ( ! $end_date ) { |
|
379 | + if ( ! $end_date) { |
|
380 | 380 | $month = 4; |
381 | 381 | } else { |
382 | 382 | $month = 6; |
383 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
383 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
384 | 384 | $hour = 23; |
385 | 385 | $minute = 59; |
386 | 386 | $second = 59; |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | |
389 | 389 | } else { |
390 | 390 | |
391 | - if ( ! $end_date ) { |
|
391 | + if ( ! $end_date) { |
|
392 | 392 | $month = 7; |
393 | 393 | } else { |
394 | 394 | $month = 9; |
395 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
395 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
396 | 396 | $hour = 23; |
397 | 397 | $minute = 59; |
398 | 398 | $second = 59; |
@@ -404,11 +404,11 @@ discard block |
||
404 | 404 | |
405 | 405 | case 'this_year' : |
406 | 406 | |
407 | - if ( ! $end_date ) { |
|
407 | + if ( ! $end_date) { |
|
408 | 408 | $month = 1; |
409 | 409 | } else { |
410 | 410 | $month = 12; |
411 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
411 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
412 | 412 | $hour = 23; |
413 | 413 | $minute = 59; |
414 | 414 | $second = 59; |
@@ -419,11 +419,11 @@ discard block |
||
419 | 419 | case 'last_year' : |
420 | 420 | |
421 | 421 | $year -= 1; |
422 | - if ( ! $end_date ) { |
|
422 | + if ( ! $end_date) { |
|
423 | 423 | $month = 1; |
424 | 424 | } else { |
425 | 425 | $month = 12; |
426 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
426 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
427 | 427 | $hour = 23; |
428 | 428 | $minute = 59; |
429 | 429 | $second = 59; |
@@ -434,30 +434,30 @@ discard block |
||
434 | 434 | } |
435 | 435 | |
436 | 436 | |
437 | - } else if ( is_numeric( $date ) ) { |
|
437 | + } else if (is_numeric($date)) { |
|
438 | 438 | |
439 | 439 | // return $date unchanged since it is a timestamp |
440 | 440 | $this->timestamp = true; |
441 | 441 | |
442 | - } else if ( false !== strtotime( $date ) ) { |
|
442 | + } else if (false !== strtotime($date)) { |
|
443 | 443 | |
444 | - $date = strtotime( $date, current_time( 'timestamp' ) ); |
|
445 | - $year = date( 'Y', $date ); |
|
446 | - $month = date( 'm', $date ); |
|
447 | - $day = date( 'd', $date ); |
|
444 | + $date = strtotime($date, current_time('timestamp')); |
|
445 | + $year = date('Y', $date); |
|
446 | + $month = date('m', $date); |
|
447 | + $day = date('d', $date); |
|
448 | 448 | |
449 | 449 | } else { |
450 | 450 | |
451 | - return new WP_Error( 'invalid_date', esc_html__( 'Improper date provided.', 'give' ) ); |
|
451 | + return new WP_Error('invalid_date', esc_html__('Improper date provided.', 'give')); |
|
452 | 452 | |
453 | 453 | } |
454 | 454 | |
455 | - if ( false === $this->timestamp ) { |
|
455 | + if (false === $this->timestamp) { |
|
456 | 456 | // Create an exact timestamp |
457 | - $date = mktime( $hour, $minute, $second, $month, $day, $year ); |
|
457 | + $date = mktime($hour, $minute, $second, $month, $day, $year); |
|
458 | 458 | } |
459 | 459 | |
460 | - return apply_filters( 'give_stats_date', $date, $end_date, $this ); |
|
460 | + return apply_filters('give_stats_date', $date, $end_date, $this); |
|
461 | 461 | |
462 | 462 | } |
463 | 463 | |
@@ -473,33 +473,33 @@ discard block |
||
473 | 473 | * |
474 | 474 | * @return string |
475 | 475 | */ |
476 | - public function count_where( $where = '' ) { |
|
476 | + public function count_where($where = '') { |
|
477 | 477 | // Only get payments in our date range |
478 | 478 | |
479 | 479 | $start_where = ''; |
480 | 480 | $end_where = ''; |
481 | 481 | |
482 | - if ( $this->start_date ) { |
|
482 | + if ($this->start_date) { |
|
483 | 483 | |
484 | - if ( $this->timestamp ) { |
|
484 | + if ($this->timestamp) { |
|
485 | 485 | $format = 'Y-m-d H:i:s'; |
486 | 486 | } else { |
487 | 487 | $format = 'Y-m-d 00:00:00'; |
488 | 488 | } |
489 | 489 | |
490 | - $start_date = date( $format, $this->start_date ); |
|
490 | + $start_date = date($format, $this->start_date); |
|
491 | 491 | $start_where = " AND p.post_date >= '{$start_date}'"; |
492 | 492 | } |
493 | 493 | |
494 | - if ( $this->end_date ) { |
|
494 | + if ($this->end_date) { |
|
495 | 495 | |
496 | - if ( $this->timestamp ) { |
|
496 | + if ($this->timestamp) { |
|
497 | 497 | $format = 'Y-m-d H:i:s'; |
498 | 498 | } else { |
499 | 499 | $format = 'Y-m-d 23:59:59'; |
500 | 500 | } |
501 | 501 | |
502 | - $end_date = date( $format, $this->end_date ); |
|
502 | + $end_date = date($format, $this->end_date); |
|
503 | 503 | |
504 | 504 | $end_where = " AND p.post_date <= '{$end_date}'"; |
505 | 505 | } |
@@ -521,34 +521,34 @@ discard block |
||
521 | 521 | * |
522 | 522 | * @return string |
523 | 523 | */ |
524 | - public function payments_where( $where = '' ) { |
|
524 | + public function payments_where($where = '') { |
|
525 | 525 | |
526 | 526 | global $wpdb; |
527 | 527 | |
528 | 528 | $start_where = ''; |
529 | 529 | $end_where = ''; |
530 | 530 | |
531 | - if ( ! is_wp_error( $this->start_date ) ) { |
|
531 | + if ( ! is_wp_error($this->start_date)) { |
|
532 | 532 | |
533 | - if ( $this->timestamp ) { |
|
533 | + if ($this->timestamp) { |
|
534 | 534 | $format = 'Y-m-d H:i:s'; |
535 | 535 | } else { |
536 | 536 | $format = 'Y-m-d 00:00:00'; |
537 | 537 | } |
538 | 538 | |
539 | - $start_date = date( $format, $this->start_date ); |
|
539 | + $start_date = date($format, $this->start_date); |
|
540 | 540 | $start_where = " AND $wpdb->posts.post_date >= '{$start_date}'"; |
541 | 541 | } |
542 | 542 | |
543 | - if ( ! is_wp_error( $this->end_date ) ) { |
|
543 | + if ( ! is_wp_error($this->end_date)) { |
|
544 | 544 | |
545 | - if ( $this->timestamp ) { |
|
545 | + if ($this->timestamp) { |
|
546 | 546 | $format = 'Y-m-d 00:00:00'; |
547 | 547 | } else { |
548 | 548 | $format = 'Y-m-d 23:59:59'; |
549 | 549 | } |
550 | 550 | |
551 | - $end_date = date( $format, $this->end_date ); |
|
551 | + $end_date = date($format, $this->end_date); |
|
552 | 552 | |
553 | 553 | $end_where = " AND $wpdb->posts.post_date <= '{$end_date}'"; |
554 | 554 | } |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | * @since 1.0 |
112 | 112 | * @access public |
113 | 113 | * |
114 | - * @param int $column Column ID. |
|
115 | - * @param int $row_id Row ID. |
|
116 | - * |
|
117 | - * @return object |
|
114 | + * @param int $column Column ID. |
|
115 | + * @param int $row_id Row ID. |
|
116 | + * |
|
117 | + * @return object |
|
118 | 118 | */ |
119 | 119 | public function get_by( $column, $row_id ) { |
120 | - /* @var WPDB $wpdb */ |
|
121 | - global $wpdb; |
|
120 | + /* @var WPDB $wpdb */ |
|
121 | + global $wpdb; |
|
122 | 122 | |
123 | 123 | $column = esc_sql( $column ); |
124 | 124 | return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
@@ -129,15 +129,15 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @since 1.0 |
131 | 131 | * @access public |
132 | - * |
|
133 | - * @param int $column Column ID. |
|
134 | - * @param int $row_id Row ID. |
|
135 | - * |
|
132 | + * |
|
133 | + * @param int $column Column ID. |
|
134 | + * @param int $row_id Row ID. |
|
135 | + * |
|
136 | 136 | * @return string Column value. |
137 | 137 | */ |
138 | 138 | public function get_column( $column, $row_id ) { |
139 | - /* @var WPDB $wpdb */ |
|
140 | - global $wpdb; |
|
139 | + /* @var WPDB $wpdb */ |
|
140 | + global $wpdb; |
|
141 | 141 | |
142 | 142 | $column = esc_sql( $column ); |
143 | 143 | return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
@@ -148,16 +148,16 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @since 1.0 |
150 | 150 | * @access public |
151 | - * |
|
152 | - * @param int $column Column ID. |
|
153 | - * @param string $column_where Column name. |
|
154 | - * @param string $column_value Column value. |
|
155 | - * |
|
151 | + * |
|
152 | + * @param int $column Column ID. |
|
153 | + * @param string $column_where Column name. |
|
154 | + * @param string $column_value Column value. |
|
155 | + * |
|
156 | 156 | * @return string |
157 | 157 | */ |
158 | 158 | public function get_column_by( $column, $column_where, $column_value ) { |
159 | - /* @var WPDB $wpdb */ |
|
160 | - global $wpdb; |
|
159 | + /* @var WPDB $wpdb */ |
|
160 | + global $wpdb; |
|
161 | 161 | |
162 | 162 | $column_where = esc_sql( $column_where ); |
163 | 163 | $column = esc_sql( $column ); |
@@ -169,15 +169,15 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @since 1.0 |
171 | 171 | * @access public |
172 | - * |
|
173 | - * @param array $data |
|
174 | - * @param string $type |
|
175 | - * |
|
172 | + * |
|
173 | + * @param array $data |
|
174 | + * @param string $type |
|
175 | + * |
|
176 | 176 | * @return int |
177 | 177 | */ |
178 | 178 | public function insert( $data, $type = '' ) { |
179 | - /* @var WPDB $wpdb */ |
|
180 | - global $wpdb; |
|
179 | + /* @var WPDB $wpdb */ |
|
180 | + global $wpdb; |
|
181 | 181 | |
182 | 182 | // Set default values |
183 | 183 | $data = wp_parse_args( $data, $this->get_column_defaults() ); |
@@ -209,16 +209,16 @@ discard block |
||
209 | 209 | * |
210 | 210 | * @since 1.0 |
211 | 211 | * @access public |
212 | - * |
|
213 | - * @param int $row_id Column ID |
|
214 | - * @param array $data |
|
215 | - * @param string $where Column value |
|
216 | - * |
|
212 | + * |
|
213 | + * @param int $row_id Column ID |
|
214 | + * @param array $data |
|
215 | + * @param string $where Column value |
|
216 | + * |
|
217 | 217 | * @return bool |
218 | 218 | */ |
219 | 219 | public function update( $row_id, $data = array(), $where = '' ) { |
220 | - /* @var WPDB $wpdb */ |
|
221 | - global $wpdb; |
|
220 | + /* @var WPDB $wpdb */ |
|
221 | + global $wpdb; |
|
222 | 222 | |
223 | 223 | // Row ID must be positive integer |
224 | 224 | $row_id = absint( $row_id ); |
@@ -256,14 +256,14 @@ discard block |
||
256 | 256 | * |
257 | 257 | * @since 1.0 |
258 | 258 | * @access public |
259 | - * |
|
260 | - * @param int $row_id Column ID. |
|
261 | - * |
|
259 | + * |
|
260 | + * @param int $row_id Column ID. |
|
261 | + * |
|
262 | 262 | * @return bool |
263 | 263 | */ |
264 | 264 | public function delete( $row_id = 0 ) { |
265 | - /* @var WPDB $wpdb */ |
|
266 | - global $wpdb; |
|
265 | + /* @var WPDB $wpdb */ |
|
266 | + global $wpdb; |
|
267 | 267 | |
268 | 268 | // Row ID must be positive integer |
269 | 269 | $row_id = absint( $row_id ); |
@@ -284,13 +284,13 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @since 1.3.2 |
286 | 286 | * @access public |
287 | - * |
|
287 | + * |
|
288 | 288 | * @param string $table The table name. |
289 | - * |
|
289 | + * |
|
290 | 290 | * @return bool If the table name exists. |
291 | 291 | */ |
292 | 292 | public function table_exists( $table ) { |
293 | - /* @var WPDB $wpdb */ |
|
293 | + /* @var WPDB $wpdb */ |
|
294 | 294 | global $wpdb; |
295 | 295 | |
296 | 296 | $table = sanitize_text_field( $table ); |
@@ -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 | |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return object |
100 | 100 | */ |
101 | - public function get( $row_id ) { |
|
101 | + public function get($row_id) { |
|
102 | 102 | /* @var WPDB $wpdb */ |
103 | 103 | global $wpdb; |
104 | 104 | |
105 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
105 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @return object |
118 | 118 | */ |
119 | - public function get_by( $column, $row_id ) { |
|
119 | + public function get_by($column, $row_id) { |
|
120 | 120 | /* @var WPDB $wpdb */ |
121 | 121 | global $wpdb; |
122 | 122 | |
123 | - $column = esc_sql( $column ); |
|
124 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
123 | + $column = esc_sql($column); |
|
124 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id)); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return string Column value. |
137 | 137 | */ |
138 | - public function get_column( $column, $row_id ) { |
|
138 | + public function get_column($column, $row_id) { |
|
139 | 139 | /* @var WPDB $wpdb */ |
140 | 140 | global $wpdb; |
141 | 141 | |
142 | - $column = esc_sql( $column ); |
|
143 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
142 | + $column = esc_sql($column); |
|
143 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @return string |
157 | 157 | */ |
158 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
158 | + public function get_column_by($column, $column_where, $column_value) { |
|
159 | 159 | /* @var WPDB $wpdb */ |
160 | 160 | global $wpdb; |
161 | 161 | |
162 | - $column_where = esc_sql( $column_where ); |
|
163 | - $column = esc_sql( $column ); |
|
164 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
162 | + $column_where = esc_sql($column_where); |
|
163 | + $column = esc_sql($column); |
|
164 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value)); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return int |
177 | 177 | */ |
178 | - public function insert( $data, $type = '' ) { |
|
178 | + public function insert($data, $type = '') { |
|
179 | 179 | /* @var WPDB $wpdb */ |
180 | 180 | global $wpdb; |
181 | 181 | |
182 | 182 | // Set default values. |
183 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
183 | + $data = wp_parse_args($data, $this->get_column_defaults()); |
|
184 | 184 | |
185 | 185 | /** |
186 | 186 | * Fires before inserting data to the database. |
@@ -189,22 +189,22 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @param array $data |
191 | 191 | */ |
192 | - do_action( "give_pre_insert_{$type}", $data ); |
|
192 | + do_action("give_pre_insert_{$type}", $data); |
|
193 | 193 | |
194 | 194 | // Initialise column format array |
195 | 195 | $column_formats = $this->get_columns(); |
196 | 196 | |
197 | 197 | // Force fields to lower case |
198 | - $data = array_change_key_case( $data ); |
|
198 | + $data = array_change_key_case($data); |
|
199 | 199 | |
200 | 200 | // White list columns |
201 | - $data = array_intersect_key( $data, $column_formats ); |
|
201 | + $data = array_intersect_key($data, $column_formats); |
|
202 | 202 | |
203 | 203 | // Reorder $column_formats to match the order of columns given in $data |
204 | - $data_keys = array_keys( $data ); |
|
205 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
204 | + $data_keys = array_keys($data); |
|
205 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
206 | 206 | |
207 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
207 | + $wpdb->insert($this->table_name, $data, $column_formats); |
|
208 | 208 | |
209 | 209 | /** |
210 | 210 | * Fires after inserting data to the database. |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * @param int $insert_id |
215 | 215 | * @param array $data |
216 | 216 | */ |
217 | - do_action( "give_post_insert_{$type}", $wpdb->insert_id, $data ); |
|
217 | + do_action("give_post_insert_{$type}", $wpdb->insert_id, $data); |
|
218 | 218 | |
219 | 219 | return $wpdb->insert_id; |
220 | 220 | } |
@@ -231,18 +231,18 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @return bool |
233 | 233 | */ |
234 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
234 | + public function update($row_id, $data = array(), $where = '') { |
|
235 | 235 | /* @var WPDB $wpdb */ |
236 | 236 | global $wpdb; |
237 | 237 | |
238 | 238 | // Row ID must be positive integer |
239 | - $row_id = absint( $row_id ); |
|
239 | + $row_id = absint($row_id); |
|
240 | 240 | |
241 | - if ( empty( $row_id ) ) { |
|
241 | + if (empty($row_id)) { |
|
242 | 242 | return false; |
243 | 243 | } |
244 | 244 | |
245 | - if ( empty( $where ) ) { |
|
245 | + if (empty($where)) { |
|
246 | 246 | $where = $this->primary_key; |
247 | 247 | } |
248 | 248 | |
@@ -250,16 +250,16 @@ discard block |
||
250 | 250 | $column_formats = $this->get_columns(); |
251 | 251 | |
252 | 252 | // Force fields to lower case |
253 | - $data = array_change_key_case( $data ); |
|
253 | + $data = array_change_key_case($data); |
|
254 | 254 | |
255 | 255 | // White list columns |
256 | - $data = array_intersect_key( $data, $column_formats ); |
|
256 | + $data = array_intersect_key($data, $column_formats); |
|
257 | 257 | |
258 | 258 | // Reorder $column_formats to match the order of columns given in $data |
259 | - $data_keys = array_keys( $data ); |
|
260 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
259 | + $data_keys = array_keys($data); |
|
260 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
261 | 261 | |
262 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
262 | + if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) { |
|
263 | 263 | return false; |
264 | 264 | } |
265 | 265 | |
@@ -276,18 +276,18 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return bool |
278 | 278 | */ |
279 | - public function delete( $row_id = 0 ) { |
|
279 | + public function delete($row_id = 0) { |
|
280 | 280 | /* @var WPDB $wpdb */ |
281 | 281 | global $wpdb; |
282 | 282 | |
283 | 283 | // Row ID must be positive integer |
284 | - $row_id = absint( $row_id ); |
|
284 | + $row_id = absint($row_id); |
|
285 | 285 | |
286 | - if ( empty( $row_id ) ) { |
|
286 | + if (empty($row_id)) { |
|
287 | 287 | return false; |
288 | 288 | } |
289 | 289 | |
290 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
290 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) { |
|
291 | 291 | return false; |
292 | 292 | } |
293 | 293 | |
@@ -304,13 +304,13 @@ discard block |
||
304 | 304 | * |
305 | 305 | * @return bool If the table name exists. |
306 | 306 | */ |
307 | - public function table_exists( $table ) { |
|
307 | + public function table_exists($table) { |
|
308 | 308 | /* @var WPDB $wpdb */ |
309 | 309 | global $wpdb; |
310 | 310 | |
311 | - $table = sanitize_text_field( $table ); |
|
311 | + $table = sanitize_text_field($table); |
|
312 | 312 | |
313 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
313 | + return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * @return bool Returns if the customers table was installed and upgrade routine run. |
323 | 323 | */ |
324 | 324 | public function installed() { |
325 | - return $this->table_exists( $this->table_name ); |
|
325 | + return $this->table_exists($this->table_name); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | } |
@@ -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 | |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | public function __construct() { |
37 | 37 | |
38 | 38 | // Create the log post type |
39 | - add_action( 'init', array( $this, 'register_post_type' ), 1 ); |
|
39 | + add_action('init', array($this, 'register_post_type'), 1); |
|
40 | 40 | |
41 | 41 | // Create types taxonomy and default types |
42 | - add_action( 'init', array( $this, 'register_taxonomy' ), 1 ); |
|
42 | + add_action('init', array($this, 'register_taxonomy'), 1); |
|
43 | 43 | |
44 | 44 | } |
45 | 45 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | public function register_post_type() { |
57 | 57 | /* Logs post type */ |
58 | 58 | $log_args = array( |
59 | - 'labels' => array( 'name' => esc_html__( 'Logs', 'give' ) ), |
|
59 | + 'labels' => array('name' => esc_html__('Logs', 'give')), |
|
60 | 60 | 'public' => false, |
61 | 61 | 'exclude_from_search' => true, |
62 | 62 | 'publicly_queryable' => false, |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | 'query_var' => false, |
65 | 65 | 'rewrite' => false, |
66 | 66 | 'capability_type' => 'post', |
67 | - 'supports' => array( 'title', 'editor' ), |
|
67 | + 'supports' => array('title', 'editor'), |
|
68 | 68 | 'can_export' => true |
69 | 69 | ); |
70 | 70 | |
71 | - register_post_type( 'give_log', $log_args ); |
|
71 | + register_post_type('give_log', $log_args); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @return void |
83 | 83 | */ |
84 | 84 | public function register_taxonomy() { |
85 | - register_taxonomy( 'give_log_type', 'give_log', array( 'public' => false ) ); |
|
85 | + register_taxonomy('give_log_type', 'give_log', array('public' => false)); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | 'api_request' |
103 | 103 | ); |
104 | 104 | |
105 | - return apply_filters( 'give_log_types', $terms ); |
|
105 | + return apply_filters('give_log_types', $terms); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @return bool Whether log type is valid. |
119 | 119 | */ |
120 | - public function valid_type( $type ) { |
|
121 | - return in_array( $type, $this->log_types() ); |
|
120 | + public function valid_type($type) { |
|
121 | + return in_array($type, $this->log_types()); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @return int Log ID. |
139 | 139 | */ |
140 | - public function add( $title = '', $message = '', $parent = 0, $type = null ) { |
|
140 | + public function add($title = '', $message = '', $parent = 0, $type = null) { |
|
141 | 141 | $log_data = array( |
142 | 142 | 'post_title' => $title, |
143 | 143 | 'post_content' => $message, |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | 'log_type' => $type |
146 | 146 | ); |
147 | 147 | |
148 | - return $this->insert_log( $log_data ); |
|
148 | + return $this->insert_log($log_data); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -162,12 +162,12 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return array An array of the connected logs. |
164 | 164 | */ |
165 | - public function get_logs( $object_id = 0, $type = null, $paged = null ) { |
|
166 | - return $this->get_connected_logs( array( |
|
165 | + public function get_logs($object_id = 0, $type = null, $paged = null) { |
|
166 | + return $this->get_connected_logs(array( |
|
167 | 167 | 'post_parent' => $object_id, |
168 | 168 | 'paged' => $paged, |
169 | 169 | 'log_type' => $type |
170 | - ) ); |
|
170 | + )); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @return int The ID of the newly created log item. |
183 | 183 | */ |
184 | - public function insert_log( $log_data = array(), $log_meta = array() ) { |
|
184 | + public function insert_log($log_data = array(), $log_meta = array()) { |
|
185 | 185 | $defaults = array( |
186 | 186 | 'post_type' => 'give_log', |
187 | 187 | 'post_status' => 'publish', |
@@ -190,26 +190,26 @@ discard block |
||
190 | 190 | 'log_type' => false |
191 | 191 | ); |
192 | 192 | |
193 | - $args = wp_parse_args( $log_data, $defaults ); |
|
193 | + $args = wp_parse_args($log_data, $defaults); |
|
194 | 194 | |
195 | - do_action( 'give_pre_insert_log', $log_data, $log_meta ); |
|
195 | + do_action('give_pre_insert_log', $log_data, $log_meta); |
|
196 | 196 | |
197 | 197 | // Store the log entry |
198 | - $log_id = wp_insert_post( $args ); |
|
198 | + $log_id = wp_insert_post($args); |
|
199 | 199 | |
200 | 200 | // Set the log type, if any |
201 | - if ( $log_data['log_type'] && $this->valid_type( $log_data['log_type'] ) ) { |
|
202 | - wp_set_object_terms( $log_id, $log_data['log_type'], 'give_log_type', false ); |
|
201 | + if ($log_data['log_type'] && $this->valid_type($log_data['log_type'])) { |
|
202 | + wp_set_object_terms($log_id, $log_data['log_type'], 'give_log_type', false); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | // Set log meta, if any |
206 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
207 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
208 | - update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
206 | + if ($log_id && ! empty($log_meta)) { |
|
207 | + foreach ((array) $log_meta as $key => $meta) { |
|
208 | + update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
212 | - do_action( 'give_post_insert_log', $log_id, $log_data, $log_meta ); |
|
212 | + do_action('give_post_insert_log', $log_id, $log_data, $log_meta); |
|
213 | 213 | |
214 | 214 | return $log_id; |
215 | 215 | } |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | * |
226 | 226 | * @return bool True if successful, false otherwise. |
227 | 227 | */ |
228 | - public function update_log( $log_data = array(), $log_meta = array() ) { |
|
228 | + public function update_log($log_data = array(), $log_meta = array()) { |
|
229 | 229 | |
230 | - do_action( 'give_pre_update_log', $log_data, $log_meta ); |
|
230 | + do_action('give_pre_update_log', $log_data, $log_meta); |
|
231 | 231 | |
232 | 232 | $defaults = array( |
233 | 233 | 'post_type' => 'give_log', |
@@ -235,20 +235,20 @@ discard block |
||
235 | 235 | 'post_parent' => 0 |
236 | 236 | ); |
237 | 237 | |
238 | - $args = wp_parse_args( $log_data, $defaults ); |
|
238 | + $args = wp_parse_args($log_data, $defaults); |
|
239 | 239 | |
240 | 240 | // Store the log entry |
241 | - $log_id = wp_update_post( $args ); |
|
241 | + $log_id = wp_update_post($args); |
|
242 | 242 | |
243 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
244 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
245 | - if ( ! empty( $meta ) ) { |
|
246 | - update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
243 | + if ($log_id && ! empty($log_meta)) { |
|
244 | + foreach ((array) $log_meta as $key => $meta) { |
|
245 | + if ( ! empty($meta)) { |
|
246 | + update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
251 | - do_action( 'give_post_update_log', $log_id, $log_data, $log_meta ); |
|
251 | + do_action('give_post_update_log', $log_id, $log_data, $log_meta); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -263,19 +263,19 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @return array|false Array if logs were found, false otherwise. |
265 | 265 | */ |
266 | - public function get_connected_logs( $args = array() ) { |
|
266 | + public function get_connected_logs($args = array()) { |
|
267 | 267 | |
268 | 268 | $defaults = array( |
269 | 269 | 'post_type' => 'give_log', |
270 | 270 | 'posts_per_page' => 20, |
271 | 271 | 'post_status' => 'publish', |
272 | - 'paged' => get_query_var( 'paged' ), |
|
272 | + 'paged' => get_query_var('paged'), |
|
273 | 273 | 'log_type' => false |
274 | 274 | ); |
275 | 275 | |
276 | - $query_args = wp_parse_args( $args, $defaults ); |
|
276 | + $query_args = wp_parse_args($args, $defaults); |
|
277 | 277 | |
278 | - if ( $query_args['log_type'] && $this->valid_type( $query_args['log_type'] ) ) { |
|
278 | + if ($query_args['log_type'] && $this->valid_type($query_args['log_type'])) { |
|
279 | 279 | $query_args['tax_query'] = array( |
280 | 280 | array( |
281 | 281 | 'taxonomy' => 'give_log_type', |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | ); |
286 | 286 | } |
287 | 287 | |
288 | - $logs = get_posts( $query_args ); |
|
288 | + $logs = get_posts($query_args); |
|
289 | 289 | |
290 | - if ( $logs ) { |
|
290 | + if ($logs) { |
|
291 | 291 | return $logs; |
292 | 292 | } |
293 | 293 | |
@@ -310,17 +310,17 @@ discard block |
||
310 | 310 | * |
311 | 311 | * @return int Log count. |
312 | 312 | */ |
313 | - public function get_log_count( $object_id = 0, $type = null, $meta_query = null, $date_query = null ) { |
|
313 | + public function get_log_count($object_id = 0, $type = null, $meta_query = null, $date_query = null) { |
|
314 | 314 | |
315 | 315 | $query_args = array( |
316 | 316 | 'post_parent' => $object_id, |
317 | 317 | 'post_type' => 'give_log', |
318 | - 'posts_per_page' => - 1, |
|
318 | + 'posts_per_page' => -1, |
|
319 | 319 | 'post_status' => 'publish', |
320 | 320 | 'fields' => 'ids', |
321 | 321 | ); |
322 | 322 | |
323 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
323 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
324 | 324 | $query_args['tax_query'] = array( |
325 | 325 | array( |
326 | 326 | 'taxonomy' => 'give_log_type', |
@@ -330,15 +330,15 @@ discard block |
||
330 | 330 | ); |
331 | 331 | } |
332 | 332 | |
333 | - if ( ! empty( $meta_query ) ) { |
|
333 | + if ( ! empty($meta_query)) { |
|
334 | 334 | $query_args['meta_query'] = $meta_query; |
335 | 335 | } |
336 | 336 | |
337 | - if ( ! empty( $date_query ) ) { |
|
337 | + if ( ! empty($date_query)) { |
|
338 | 338 | $query_args['date_query'] = $date_query; |
339 | 339 | } |
340 | 340 | |
341 | - $logs = new WP_Query( $query_args ); |
|
341 | + $logs = new WP_Query($query_args); |
|
342 | 342 | |
343 | 343 | return (int) $logs->post_count; |
344 | 344 | } |
@@ -357,16 +357,16 @@ discard block |
||
357 | 357 | * |
358 | 358 | * @return void |
359 | 359 | */ |
360 | - public function delete_logs( $object_id = 0, $type = null, $meta_query = null ) { |
|
360 | + public function delete_logs($object_id = 0, $type = null, $meta_query = null) { |
|
361 | 361 | $query_args = array( |
362 | 362 | 'post_parent' => $object_id, |
363 | 363 | 'post_type' => 'give_log', |
364 | - 'posts_per_page' => - 1, |
|
364 | + 'posts_per_page' => -1, |
|
365 | 365 | 'post_status' => 'publish', |
366 | 366 | 'fields' => 'ids' |
367 | 367 | ); |
368 | 368 | |
369 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
369 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
370 | 370 | $query_args['tax_query'] = array( |
371 | 371 | array( |
372 | 372 | 'taxonomy' => 'give_log_type', |
@@ -376,15 +376,15 @@ discard block |
||
376 | 376 | ); |
377 | 377 | } |
378 | 378 | |
379 | - if ( ! empty( $meta_query ) ) { |
|
379 | + if ( ! empty($meta_query)) { |
|
380 | 380 | $query_args['meta_query'] = $meta_query; |
381 | 381 | } |
382 | 382 | |
383 | - $logs = get_posts( $query_args ); |
|
383 | + $logs = get_posts($query_args); |
|
384 | 384 | |
385 | - if ( $logs ) { |
|
386 | - foreach ( $logs as $log ) { |
|
387 | - wp_delete_post( $log, true ); |
|
385 | + if ($logs) { |
|
386 | + foreach ($logs as $log) { |
|
387 | + wp_delete_post($log, true); |
|
388 | 388 | } |
389 | 389 | } |
390 | 390 | } |
@@ -408,10 +408,10 @@ discard block |
||
408 | 408 | * |
409 | 409 | * @return mixed ID of the new log entry. |
410 | 410 | */ |
411 | -function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) { |
|
411 | +function give_record_log($title = '', $message = '', $parent = 0, $type = null) { |
|
412 | 412 | /* @var Give_Logging $give_logs */ |
413 | 413 | global $give_logs; |
414 | - $log = $give_logs->add( $title, $message, $parent, $type ); |
|
414 | + $log = $give_logs->add($title, $message, $parent, $type); |
|
415 | 415 | |
416 | 416 | return $log; |
417 | 417 | } |
@@ -398,6 +398,7 @@ |
||
398 | 398 | * |
399 | 399 | * @since 1.6 |
400 | 400 | * |
401 | + * @param Give_Payment $payment |
|
401 | 402 | * @return mixed|void |
402 | 403 | */ |
403 | 404 | function get_row_actions( $payment ) { |
@@ -10,13 +10,13 @@ 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 | 17 | // Load WP_List_Table if not loaded. |
18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
18 | +if ( ! class_exists('WP_List_Table')) { |
|
19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -118,15 +118,15 @@ discard block |
||
118 | 118 | public function __construct() { |
119 | 119 | |
120 | 120 | // Set parent defaults. |
121 | - parent::__construct( array( |
|
122 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
123 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
124 | - 'ajax' => false, // Does this table support ajax? |
|
125 | - ) ); |
|
121 | + parent::__construct(array( |
|
122 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
123 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
124 | + 'ajax' => false, // Does this table support ajax? |
|
125 | + )); |
|
126 | 126 | |
127 | 127 | $this->get_payment_counts(); |
128 | 128 | $this->process_bulk_action(); |
129 | - $this->base_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); |
|
129 | + $this->base_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history'); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -135,25 +135,25 @@ discard block |
||
135 | 135 | * @return void |
136 | 136 | */ |
137 | 137 | public function advanced_filters() { |
138 | - $start_date = isset( $_GET['start-date'] ) ? sanitize_text_field( $_GET['start-date'] ) : null; |
|
139 | - $end_date = isset( $_GET['end-date'] ) ? sanitize_text_field( $_GET['end-date'] ) : null; |
|
140 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : ''; |
|
138 | + $start_date = isset($_GET['start-date']) ? sanitize_text_field($_GET['start-date']) : null; |
|
139 | + $end_date = isset($_GET['end-date']) ? sanitize_text_field($_GET['end-date']) : null; |
|
140 | + $status = isset($_GET['status']) ? $_GET['status'] : ''; |
|
141 | 141 | ?> |
142 | 142 | <div id="give-payment-filters"> |
143 | 143 | <span id="give-payment-date-filters"> |
144 | - <label for="start-date" class="give-start-date-label"><?php esc_html_e( 'Start Date:', 'give' ); ?></label> |
|
144 | + <label for="start-date" class="give-start-date-label"><?php esc_html_e('Start Date:', 'give'); ?></label> |
|
145 | 145 | <input type="text" id="start-date" name="start-date" class="give_datepicker" value="<?php echo $start_date; ?>" placeholder="mm/dd/yyyy"/> |
146 | - <label for="end-date" class="give-end-date-label"><?php esc_html_e( 'End Date:', 'give' ); ?></label> |
|
146 | + <label for="end-date" class="give-end-date-label"><?php esc_html_e('End Date:', 'give'); ?></label> |
|
147 | 147 | <input type="text" id="end-date" name="end-date" class="give_datepicker" value="<?php echo $end_date; ?>" placeholder="mm/dd/yyyy"/> |
148 | - <input type="submit" class="button-secondary" value="<?php esc_attr_e( 'Apply', 'give' ); ?>"/> |
|
148 | + <input type="submit" class="button-secondary" value="<?php esc_attr_e('Apply', 'give'); ?>"/> |
|
149 | 149 | </span> |
150 | - <?php if ( ! empty( $status ) ) : ?> |
|
151 | - <input type="hidden" name="status" value="<?php echo esc_attr( $status ); ?>"/> |
|
150 | + <?php if ( ! empty($status)) : ?> |
|
151 | + <input type="hidden" name="status" value="<?php echo esc_attr($status); ?>"/> |
|
152 | 152 | <?php endif; ?> |
153 | - <?php if ( ! empty( $start_date ) || ! empty( $end_date ) ) : ?> |
|
154 | - <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>" class="button-secondary"><?php esc_html_e( 'Clear Filter', 'give' ); ?></a> |
|
153 | + <?php if ( ! empty($start_date) || ! empty($end_date)) : ?> |
|
154 | + <a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>" class="button-secondary"><?php esc_html_e('Clear Filter', 'give'); ?></a> |
|
155 | 155 | <?php endif; ?> |
156 | - <?php $this->search_box( esc_html__( 'Search', 'give' ), 'give-payments' ); ?> |
|
156 | + <?php $this->search_box(esc_html__('Search', 'give'), 'give-payments'); ?> |
|
157 | 157 | </div> |
158 | 158 | |
159 | 159 | <?php |
@@ -170,18 +170,18 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return void |
172 | 172 | */ |
173 | - public function search_box( $text, $input_id ) { |
|
174 | - if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
|
173 | + public function search_box($text, $input_id) { |
|
174 | + if (empty($_REQUEST['s']) && ! $this->has_items()) { |
|
175 | 175 | return; |
176 | 176 | } |
177 | 177 | |
178 | - $input_id = $input_id . '-search-input'; |
|
178 | + $input_id = $input_id.'-search-input'; |
|
179 | 179 | |
180 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
181 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
180 | + if ( ! empty($_REQUEST['orderby'])) { |
|
181 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
182 | 182 | } |
183 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
184 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
183 | + if ( ! empty($_REQUEST['order'])) { |
|
184 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
185 | 185 | } |
186 | 186 | ?> |
187 | 187 | <p class="search-box" role="search"> |
@@ -193,11 +193,11 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @since 1.7 |
195 | 195 | */ |
196 | - do_action( 'give_payment_history_search' ); |
|
196 | + do_action('give_payment_history_search'); |
|
197 | 197 | ?> |
198 | 198 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
199 | 199 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/> |
200 | - <?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?><br/> |
|
200 | + <?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?><br/> |
|
201 | 201 | </p> |
202 | 202 | <?php |
203 | 203 | } |
@@ -211,52 +211,52 @@ discard block |
||
211 | 211 | */ |
212 | 212 | public function get_views() { |
213 | 213 | |
214 | - $current = isset( $_GET['status'] ) ? $_GET['status'] : ''; |
|
215 | - $total_count = ' <span class="count">(' . $this->total_count . ')</span>'; |
|
216 | - $complete_count = ' <span class="count">(' . $this->complete_count . ')</span>'; |
|
217 | - $cancelled_count = ' <span class="count">(' . $this->cancelled_count . ')</span>'; |
|
218 | - $pending_count = ' <span class="count">(' . $this->pending_count . ')</span>'; |
|
219 | - $refunded_count = ' <span class="count">(' . $this->refunded_count . ')</span>'; |
|
220 | - $failed_count = ' <span class="count">(' . $this->failed_count . ')</span>'; |
|
221 | - $abandoned_count = ' <span class="count">(' . $this->abandoned_count . ')</span>'; |
|
222 | - $revoked_count = ' <span class="count">(' . $this->revoked_count . ')</span>'; |
|
214 | + $current = isset($_GET['status']) ? $_GET['status'] : ''; |
|
215 | + $total_count = ' <span class="count">('.$this->total_count.')</span>'; |
|
216 | + $complete_count = ' <span class="count">('.$this->complete_count.')</span>'; |
|
217 | + $cancelled_count = ' <span class="count">('.$this->cancelled_count.')</span>'; |
|
218 | + $pending_count = ' <span class="count">('.$this->pending_count.')</span>'; |
|
219 | + $refunded_count = ' <span class="count">('.$this->refunded_count.')</span>'; |
|
220 | + $failed_count = ' <span class="count">('.$this->failed_count.')</span>'; |
|
221 | + $abandoned_count = ' <span class="count">('.$this->abandoned_count.')</span>'; |
|
222 | + $revoked_count = ' <span class="count">('.$this->revoked_count.')</span>'; |
|
223 | 223 | |
224 | 224 | $views = array( |
225 | - 'all' => sprintf( '<a href="%s"%s>%s</a>', remove_query_arg( array( |
|
225 | + 'all' => sprintf('<a href="%s"%s>%s</a>', remove_query_arg(array( |
|
226 | 226 | 'status', |
227 | 227 | 'paged', |
228 | - ) ), $current === 'all' || $current == '' ? ' class="current"' : '', esc_html__( 'All', 'give' ) . $total_count ), |
|
229 | - 'publish' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array( |
|
228 | + )), $current === 'all' || $current == '' ? ' class="current"' : '', esc_html__('All', 'give').$total_count), |
|
229 | + 'publish' => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array( |
|
230 | 230 | 'status' => 'publish', |
231 | 231 | 'paged' => false, |
232 | - ) ) ), $current === 'publish' ? ' class="current"' : '', esc_html__( 'Completed', 'give' ) . $complete_count ), |
|
233 | - 'pending' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array( |
|
232 | + ))), $current === 'publish' ? ' class="current"' : '', esc_html__('Completed', 'give').$complete_count), |
|
233 | + 'pending' => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array( |
|
234 | 234 | 'status' => 'pending', |
235 | 235 | 'paged' => false, |
236 | - ) ) ), $current === 'pending' ? ' class="current"' : '', esc_html__( 'Pending', 'give' ) . $pending_count ), |
|
237 | - 'refunded' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array( |
|
236 | + ))), $current === 'pending' ? ' class="current"' : '', esc_html__('Pending', 'give').$pending_count), |
|
237 | + 'refunded' => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array( |
|
238 | 238 | 'status' => 'refunded', |
239 | 239 | 'paged' => false, |
240 | - ) ) ), $current === 'refunded' ? ' class="current"' : '', esc_html__( 'Refunded', 'give' ) . $refunded_count ), |
|
241 | - 'revoked' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array( |
|
240 | + ))), $current === 'refunded' ? ' class="current"' : '', esc_html__('Refunded', 'give').$refunded_count), |
|
241 | + 'revoked' => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array( |
|
242 | 242 | 'status' => 'revoked', |
243 | 243 | 'paged' => false, |
244 | - ) ) ), $current === 'revoked' ? ' class="current"' : '', esc_html__( 'Revoked', 'give' ) . $revoked_count ), |
|
245 | - 'failed' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array( |
|
244 | + ))), $current === 'revoked' ? ' class="current"' : '', esc_html__('Revoked', 'give').$revoked_count), |
|
245 | + 'failed' => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array( |
|
246 | 246 | 'status' => 'failed', |
247 | 247 | 'paged' => false, |
248 | - ) ) ), $current === 'failed' ? ' class="current"' : '', esc_html__( 'Failed', 'give' ) . $failed_count ), |
|
249 | - 'cancelled' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array( |
|
248 | + ))), $current === 'failed' ? ' class="current"' : '', esc_html__('Failed', 'give').$failed_count), |
|
249 | + 'cancelled' => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array( |
|
250 | 250 | 'status' => 'cancelled', |
251 | 251 | 'paged' => false, |
252 | - ) ) ), $current === 'cancelled' ? ' class="current"' : '', esc_html__( 'Cancelled', 'give' ) . $cancelled_count ), |
|
253 | - 'abandoned' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array( |
|
252 | + ))), $current === 'cancelled' ? ' class="current"' : '', esc_html__('Cancelled', 'give').$cancelled_count), |
|
253 | + 'abandoned' => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array( |
|
254 | 254 | 'status' => 'abandoned', |
255 | 255 | 'paged' => false, |
256 | - ) ) ), $current === 'abandoned' ? ' class="current"' : '', esc_html__( 'Abandoned', 'give' ) . $abandoned_count ), |
|
256 | + ))), $current === 'abandoned' ? ' class="current"' : '', esc_html__('Abandoned', 'give').$abandoned_count), |
|
257 | 257 | ); |
258 | 258 | |
259 | - return apply_filters( 'give_payments_table_views', $views ); |
|
259 | + return apply_filters('give_payments_table_views', $views); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -269,15 +269,15 @@ discard block |
||
269 | 269 | public function get_columns() { |
270 | 270 | $columns = array( |
271 | 271 | 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text. |
272 | - 'donation' => esc_html__( 'Donation', 'give' ), |
|
273 | - 'donation_form' => esc_html__( 'Donation Form', 'give' ), |
|
274 | - 'status' => esc_html__( 'Status', 'give' ), |
|
275 | - 'date' => esc_html__( 'Date', 'give' ), |
|
276 | - 'amount' => esc_html__( 'Amount', 'give' ), |
|
277 | - 'details' => esc_html__( 'Details', 'give' ), |
|
272 | + 'donation' => esc_html__('Donation', 'give'), |
|
273 | + 'donation_form' => esc_html__('Donation Form', 'give'), |
|
274 | + 'status' => esc_html__('Status', 'give'), |
|
275 | + 'date' => esc_html__('Date', 'give'), |
|
276 | + 'amount' => esc_html__('Amount', 'give'), |
|
277 | + 'details' => esc_html__('Details', 'give'), |
|
278 | 278 | ); |
279 | 279 | |
280 | - return apply_filters( 'give_payments_table_columns', $columns ); |
|
280 | + return apply_filters('give_payments_table_columns', $columns); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
@@ -289,14 +289,14 @@ discard block |
||
289 | 289 | */ |
290 | 290 | public function get_sortable_columns() { |
291 | 291 | $columns = array( |
292 | - 'donation' => array( 'ID', true ), |
|
293 | - 'donation_form' => array( 'donation_form', false ), |
|
294 | - 'status' => array( 'status', false ), |
|
295 | - 'amount' => array( 'amount', false ), |
|
296 | - 'date' => array( 'date', false ), |
|
292 | + 'donation' => array('ID', true), |
|
293 | + 'donation_form' => array('donation_form', false), |
|
294 | + 'status' => array('status', false), |
|
295 | + 'amount' => array('amount', false), |
|
296 | + 'date' => array('date', false), |
|
297 | 297 | ); |
298 | 298 | |
299 | - return apply_filters( 'give_payments_table_sortable_columns', $columns ); |
|
299 | + return apply_filters('give_payments_table_sortable_columns', $columns); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -322,65 +322,65 @@ discard block |
||
322 | 322 | * |
323 | 323 | * @return string Column Name |
324 | 324 | */ |
325 | - public function column_default( $payment, $column_name ) { |
|
325 | + public function column_default($payment, $column_name) { |
|
326 | 326 | |
327 | - $single_donation_url = esc_url( add_query_arg( 'id', $payment->ID, admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details' ) ) ); |
|
328 | - $row_actions = $this->get_row_actions( $payment ); |
|
327 | + $single_donation_url = esc_url(add_query_arg('id', $payment->ID, admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details'))); |
|
328 | + $row_actions = $this->get_row_actions($payment); |
|
329 | 329 | |
330 | - switch ( $column_name ) { |
|
330 | + switch ($column_name) { |
|
331 | 331 | case 'donation' : |
332 | 332 | $value = sprintf( |
333 | 333 | '<a href="%1$s" data-tooltip="%2$s">#%3$s</a> %4$s %5$s<br>', |
334 | 334 | $single_donation_url, |
335 | - sprintf( esc_attr__( 'View Donation %s', 'give' ), $payment->ID ), |
|
335 | + sprintf(esc_attr__('View Donation %s', 'give'), $payment->ID), |
|
336 | 336 | $payment->ID, |
337 | - esc_html__( 'by', 'give' ), |
|
338 | - $this->get_donor( $payment ) |
|
337 | + esc_html__('by', 'give'), |
|
338 | + $this->get_donor($payment) |
|
339 | 339 | ); |
340 | - $value .= $this->get_donor_email( $payment ); |
|
341 | - $value .= $this->row_actions( $row_actions ); |
|
340 | + $value .= $this->get_donor_email($payment); |
|
341 | + $value .= $this->row_actions($row_actions); |
|
342 | 342 | break; |
343 | 343 | |
344 | 344 | case 'amount' : |
345 | - $amount = ! empty( $payment->total ) ? $payment->total : 0; |
|
346 | - $value = give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment->ID ) ); |
|
345 | + $amount = ! empty($payment->total) ? $payment->total : 0; |
|
346 | + $value = give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment->ID)); |
|
347 | 347 | break; |
348 | 348 | |
349 | 349 | case 'donation_form' : |
350 | 350 | |
351 | - $value = '<a href="' . admin_url( 'post.php?post=' . $payment->form_id . '&action=edit' ) . '">' . $payment->form_title . '</a>'; |
|
352 | - $level = give_get_payment_form_title( $payment->meta, true ); |
|
351 | + $value = '<a href="'.admin_url('post.php?post='.$payment->form_id.'&action=edit').'">'.$payment->form_title.'</a>'; |
|
352 | + $level = give_get_payment_form_title($payment->meta, true); |
|
353 | 353 | |
354 | - if ( ! empty( $level ) ) { |
|
354 | + if ( ! empty($level)) { |
|
355 | 355 | $value .= $level; |
356 | 356 | } |
357 | 357 | |
358 | 358 | break; |
359 | 359 | |
360 | 360 | case 'date' : |
361 | - $date = strtotime( $payment->date ); |
|
362 | - $value = date_i18n( give_date_format(), $date ); |
|
361 | + $date = strtotime($payment->date); |
|
362 | + $value = date_i18n(give_date_format(), $date); |
|
363 | 363 | break; |
364 | 364 | |
365 | 365 | case 'status' : |
366 | - $value = $this->get_payment_status( $payment ); |
|
366 | + $value = $this->get_payment_status($payment); |
|
367 | 367 | break; |
368 | 368 | |
369 | 369 | case 'details' : |
370 | 370 | $value = sprintf( |
371 | 371 | '<div class="give-payment-details-link-wrap"><a href="%1$s" class="give-payment-details-link button button-small" data-tooltip="%2$s" aria-label="%2$s"><span class="dashicons dashicons-visibility"></span></a></div>', |
372 | 372 | $single_donation_url, |
373 | - sprintf( esc_attr__( 'View Donation %s', 'give' ), $payment->ID ) |
|
373 | + sprintf(esc_attr__('View Donation %s', 'give'), $payment->ID) |
|
374 | 374 | ); |
375 | 375 | break; |
376 | 376 | |
377 | 377 | default: |
378 | - $value = isset( $payment->$column_name ) ? $payment->$column_name : ''; |
|
378 | + $value = isset($payment->$column_name) ? $payment->$column_name : ''; |
|
379 | 379 | break; |
380 | 380 | |
381 | 381 | } |
382 | 382 | |
383 | - return apply_filters( 'give_payments_table_column', $value, $payment->ID, $column_name ); |
|
383 | + return apply_filters('give_payments_table_column', $value, $payment->ID, $column_name); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
@@ -393,17 +393,17 @@ discard block |
||
393 | 393 | * |
394 | 394 | * @return string Data shown in the Email column |
395 | 395 | */ |
396 | - public function get_donor_email( $payment ) { |
|
396 | + public function get_donor_email($payment) { |
|
397 | 397 | |
398 | - $email = give_get_payment_user_email( $payment->ID ); |
|
398 | + $email = give_get_payment_user_email($payment->ID); |
|
399 | 399 | |
400 | - if ( empty( $email ) ) { |
|
401 | - $email = esc_html__( '(unknown)', 'give' ); |
|
400 | + if (empty($email)) { |
|
401 | + $email = esc_html__('(unknown)', 'give'); |
|
402 | 402 | } |
403 | 403 | |
404 | - $value = '<a href="mailto:' . $email . '" data-tooltip="' . esc_attr__( 'Email donor', 'give' ) . '">' . $email . '</a>'; |
|
404 | + $value = '<a href="mailto:'.$email.'" data-tooltip="'.esc_attr__('Email donor', 'give').'">'.$email.'</a>'; |
|
405 | 405 | |
406 | - return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'email' ); |
|
406 | + return apply_filters('give_payments_table_column', $value, $payment->ID, 'email'); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -413,18 +413,18 @@ discard block |
||
413 | 413 | * |
414 | 414 | * @return mixed|void |
415 | 415 | */ |
416 | - function get_row_actions( $payment ) { |
|
416 | + function get_row_actions($payment) { |
|
417 | 417 | |
418 | 418 | $actions = array(); |
419 | - $email = give_get_payment_user_email( $payment->ID ); |
|
419 | + $email = give_get_payment_user_email($payment->ID); |
|
420 | 420 | |
421 | 421 | // Add search term string back to base URL. |
422 | - $search_terms = ( isset( $_GET['s'] ) ? trim( $_GET['s'] ) : '' ); |
|
423 | - if ( ! empty( $search_terms ) ) { |
|
424 | - $this->base_url = add_query_arg( 's', $search_terms, $this->base_url ); |
|
422 | + $search_terms = (isset($_GET['s']) ? trim($_GET['s']) : ''); |
|
423 | + if ( ! empty($search_terms)) { |
|
424 | + $this->base_url = add_query_arg('s', $search_terms, $this->base_url); |
|
425 | 425 | } |
426 | 426 | |
427 | - if ( give_is_payment_complete( $payment->ID ) && ! empty( $email ) ) { |
|
427 | + if (give_is_payment_complete($payment->ID) && ! empty($email)) { |
|
428 | 428 | |
429 | 429 | $actions['email_links'] = sprintf( |
430 | 430 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
@@ -438,8 +438,8 @@ discard block |
||
438 | 438 | ), |
439 | 439 | 'give_payment_nonce' |
440 | 440 | ), |
441 | - sprintf( esc_attr__( 'Resend Donation %s Receipt', 'give' ), $payment->ID ), |
|
442 | - esc_html__( 'Resend Donation Receipt', 'give' ) |
|
441 | + sprintf(esc_attr__('Resend Donation %s Receipt', 'give'), $payment->ID), |
|
442 | + esc_html__('Resend Donation Receipt', 'give') |
|
443 | 443 | ); |
444 | 444 | |
445 | 445 | } |
@@ -456,11 +456,11 @@ discard block |
||
456 | 456 | ), |
457 | 457 | 'give_donation_nonce' |
458 | 458 | ), |
459 | - sprintf( esc_attr__( 'Delete Donation %s', 'give' ), $payment->ID ), |
|
460 | - esc_html__( 'Delete', 'give' ) |
|
459 | + sprintf(esc_attr__('Delete Donation %s', 'give'), $payment->ID), |
|
460 | + esc_html__('Delete', 'give') |
|
461 | 461 | ); |
462 | 462 | |
463 | - return apply_filters( 'give_payment_row_actions', $actions, $payment ); |
|
463 | + return apply_filters('give_payment_row_actions', $actions, $payment); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | |
@@ -474,10 +474,10 @@ discard block |
||
474 | 474 | * |
475 | 475 | * @return string Data shown in the Email column |
476 | 476 | */ |
477 | - function get_payment_status( $payment ) { |
|
478 | - $value = '<div class="give-donation-status status-' . sanitize_title( give_get_payment_status( $payment, true ) ) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status( $payment, true ) . '</div>'; |
|
479 | - if ( $payment->mode == 'test' ) { |
|
480 | - $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was made in test mode.', 'give' ) . '">' . esc_html__( 'Test', 'give' ) . '</span>'; |
|
477 | + function get_payment_status($payment) { |
|
478 | + $value = '<div class="give-donation-status status-'.sanitize_title(give_get_payment_status($payment, true)).'"><span class="give-donation-status-icon"></span> '.give_get_payment_status($payment, true).'</div>'; |
|
479 | + if ($payment->mode == 'test') { |
|
480 | + $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was made in test mode.', 'give').'">'.esc_html__('Test', 'give').'</span>'; |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | return $value; |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | * |
494 | 494 | * @return string Displays a checkbox. |
495 | 495 | */ |
496 | - public function column_cb( $payment ) { |
|
496 | + public function column_cb($payment) { |
|
497 | 497 | return sprintf( |
498 | 498 | '<input type="checkbox" name="%1$s[]" value="%2$s" />', |
499 | 499 | 'payment', |
@@ -511,8 +511,8 @@ discard block |
||
511 | 511 | * |
512 | 512 | * @return string Displays a checkbox. |
513 | 513 | */ |
514 | - public function get_payment_id( $payment ) { |
|
515 | - return '<span class="give-payment-id">' . give_get_payment_number( $payment->ID ) . '</span>'; |
|
514 | + public function get_payment_id($payment) { |
|
515 | + return '<span class="give-payment-id">'.give_get_payment_number($payment->ID).'</span>'; |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | /** |
@@ -525,19 +525,19 @@ discard block |
||
525 | 525 | * |
526 | 526 | * @return string Data shown in the User column |
527 | 527 | */ |
528 | - public function get_donor( $payment ) { |
|
528 | + public function get_donor($payment) { |
|
529 | 529 | |
530 | - $customer_id = give_get_payment_customer_id( $payment->ID ); |
|
530 | + $customer_id = give_get_payment_customer_id($payment->ID); |
|
531 | 531 | |
532 | - if ( ! empty( $customer_id ) ) { |
|
533 | - $customer = new Give_Customer( $customer_id ); |
|
534 | - $value = '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id=$customer_id" ) ) . '">' . $customer->name . '</a>'; |
|
532 | + if ( ! empty($customer_id)) { |
|
533 | + $customer = new Give_Customer($customer_id); |
|
534 | + $value = '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id=$customer_id")).'">'.$customer->name.'</a>'; |
|
535 | 535 | } else { |
536 | - $email = give_get_payment_user_email( $payment->ID ); |
|
537 | - $value = '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-payment-history&s=$email" ) ) . '">' . esc_html__( '(donor missing)', 'give' ) . '</a>'; |
|
536 | + $email = give_get_payment_user_email($payment->ID); |
|
537 | + $value = '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-payment-history&s=$email")).'">'.esc_html__('(donor missing)', 'give').'</a>'; |
|
538 | 538 | } |
539 | 539 | |
540 | - return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'donor' ); |
|
540 | + return apply_filters('give_payments_table_column', $value, $payment->ID, 'donor'); |
|
541 | 541 | } |
542 | 542 | |
543 | 543 | /** |
@@ -549,18 +549,18 @@ discard block |
||
549 | 549 | */ |
550 | 550 | public function get_bulk_actions() { |
551 | 551 | $actions = array( |
552 | - 'delete' => esc_html__( 'Delete', 'give' ), |
|
553 | - 'set-status-publish' => esc_html__( 'Set To Completed', 'give' ), |
|
554 | - 'set-status-pending' => esc_html__( 'Set To Pending', 'give' ), |
|
555 | - 'set-status-refunded' => esc_html__( 'Set To Refunded', 'give' ), |
|
556 | - 'set-status-revoked' => esc_html__( 'Set To Revoked', 'give' ), |
|
557 | - 'set-status-failed' => esc_html__( 'Set To Failed', 'give' ), |
|
558 | - 'set-status-cancelled' => esc_html__( 'Set To Cancelled', 'give' ), |
|
559 | - 'set-status-abandoned' => esc_html__( 'Set To Abandoned', 'give' ), |
|
560 | - 'resend-receipt' => esc_html__( 'Resend Email Receipts', 'give' ), |
|
552 | + 'delete' => esc_html__('Delete', 'give'), |
|
553 | + 'set-status-publish' => esc_html__('Set To Completed', 'give'), |
|
554 | + 'set-status-pending' => esc_html__('Set To Pending', 'give'), |
|
555 | + 'set-status-refunded' => esc_html__('Set To Refunded', 'give'), |
|
556 | + 'set-status-revoked' => esc_html__('Set To Revoked', 'give'), |
|
557 | + 'set-status-failed' => esc_html__('Set To Failed', 'give'), |
|
558 | + 'set-status-cancelled' => esc_html__('Set To Cancelled', 'give'), |
|
559 | + 'set-status-abandoned' => esc_html__('Set To Abandoned', 'give'), |
|
560 | + 'resend-receipt' => esc_html__('Resend Email Receipts', 'give'), |
|
561 | 561 | ); |
562 | 562 | |
563 | - return apply_filters( 'give_payments_table_bulk_actions', $actions ); |
|
563 | + return apply_filters('give_payments_table_bulk_actions', $actions); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
@@ -571,59 +571,59 @@ discard block |
||
571 | 571 | * @return void |
572 | 572 | */ |
573 | 573 | public function process_bulk_action() { |
574 | - $ids = isset( $_GET['payment'] ) ? $_GET['payment'] : false; |
|
574 | + $ids = isset($_GET['payment']) ? $_GET['payment'] : false; |
|
575 | 575 | $action = $this->current_action(); |
576 | 576 | |
577 | - if ( ! is_array( $ids ) ) { |
|
578 | - $ids = array( $ids ); |
|
577 | + if ( ! is_array($ids)) { |
|
578 | + $ids = array($ids); |
|
579 | 579 | } |
580 | 580 | |
581 | - if ( empty( $action ) ) { |
|
581 | + if (empty($action)) { |
|
582 | 582 | return; |
583 | 583 | } |
584 | 584 | |
585 | - foreach ( $ids as $id ) { |
|
585 | + foreach ($ids as $id) { |
|
586 | 586 | |
587 | 587 | // Detect when a bulk action is being triggered. |
588 | - switch ( $this->current_action() ) { |
|
588 | + switch ($this->current_action()) { |
|
589 | 589 | |
590 | 590 | case'delete': |
591 | - give_delete_purchase( $id ); |
|
591 | + give_delete_purchase($id); |
|
592 | 592 | break; |
593 | 593 | |
594 | 594 | case 'set-status-publish': |
595 | - give_update_payment_status( $id, 'publish' ); |
|
595 | + give_update_payment_status($id, 'publish'); |
|
596 | 596 | break; |
597 | 597 | |
598 | 598 | case 'set-status-pending': |
599 | - give_update_payment_status( $id, 'pending' ); |
|
599 | + give_update_payment_status($id, 'pending'); |
|
600 | 600 | break; |
601 | 601 | |
602 | 602 | case 'set-status-refunded': |
603 | - give_update_payment_status( $id, 'refunded' ); |
|
603 | + give_update_payment_status($id, 'refunded'); |
|
604 | 604 | break; |
605 | 605 | case 'set-status-revoked': |
606 | - give_update_payment_status( $id, 'revoked' ); |
|
606 | + give_update_payment_status($id, 'revoked'); |
|
607 | 607 | break; |
608 | 608 | |
609 | 609 | case 'set-status-failed': |
610 | - give_update_payment_status( $id, 'failed' ); |
|
610 | + give_update_payment_status($id, 'failed'); |
|
611 | 611 | break; |
612 | 612 | |
613 | 613 | case 'set-status-cancelled': |
614 | - give_update_payment_status( $id, 'cancelled' ); |
|
614 | + give_update_payment_status($id, 'cancelled'); |
|
615 | 615 | break; |
616 | 616 | |
617 | 617 | case 'set-status-abandoned': |
618 | - give_update_payment_status( $id, 'abandoned' ); |
|
618 | + give_update_payment_status($id, 'abandoned'); |
|
619 | 619 | break; |
620 | 620 | |
621 | 621 | case 'set-status-preapproval': |
622 | - give_update_payment_status( $id, 'preapproval' ); |
|
622 | + give_update_payment_status($id, 'preapproval'); |
|
623 | 623 | break; |
624 | 624 | |
625 | 625 | case 'resend-receipt': |
626 | - give_email_donation_receipt( $id, false ); |
|
626 | + give_email_donation_receipt($id, false); |
|
627 | 627 | break; |
628 | 628 | } |
629 | 629 | |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | * @param int $id The ID of the payment. |
636 | 636 | * @param string $current_action The action that is being triggered. |
637 | 637 | */ |
638 | - do_action( 'give_payments_table_do_bulk_action', $id, $this->current_action() ); |
|
638 | + do_action('give_payments_table_do_bulk_action', $id, $this->current_action()); |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | } |
@@ -651,27 +651,27 @@ discard block |
||
651 | 651 | |
652 | 652 | $args = array(); |
653 | 653 | |
654 | - if ( isset( $_GET['user'] ) ) { |
|
655 | - $args['user'] = urldecode( $_GET['user'] ); |
|
656 | - } elseif ( isset( $_GET['s'] ) ) { |
|
657 | - $is_user = strpos( $_GET['s'], strtolower( 'user:' ) ) !== false; |
|
658 | - if ( $is_user ) { |
|
659 | - $args['user'] = absint( trim( str_replace( 'user:', '', strtolower( $_GET['s'] ) ) ) ); |
|
660 | - unset( $args['s'] ); |
|
654 | + if (isset($_GET['user'])) { |
|
655 | + $args['user'] = urldecode($_GET['user']); |
|
656 | + } elseif (isset($_GET['s'])) { |
|
657 | + $is_user = strpos($_GET['s'], strtolower('user:')) !== false; |
|
658 | + if ($is_user) { |
|
659 | + $args['user'] = absint(trim(str_replace('user:', '', strtolower($_GET['s'])))); |
|
660 | + unset($args['s']); |
|
661 | 661 | } else { |
662 | - $args['s'] = sanitize_text_field( $_GET['s'] ); |
|
662 | + $args['s'] = sanitize_text_field($_GET['s']); |
|
663 | 663 | } |
664 | 664 | } |
665 | 665 | |
666 | - if ( ! empty( $_GET['start-date'] ) ) { |
|
667 | - $args['start-date'] = urldecode( $_GET['start-date'] ); |
|
666 | + if ( ! empty($_GET['start-date'])) { |
|
667 | + $args['start-date'] = urldecode($_GET['start-date']); |
|
668 | 668 | } |
669 | 669 | |
670 | - if ( ! empty( $_GET['end-date'] ) ) { |
|
671 | - $args['end-date'] = urldecode( $_GET['end-date'] ); |
|
670 | + if ( ! empty($_GET['end-date'])) { |
|
671 | + $args['end-date'] = urldecode($_GET['end-date']); |
|
672 | 672 | } |
673 | 673 | |
674 | - $payment_count = give_count_payments( $args ); |
|
674 | + $payment_count = give_count_payments($args); |
|
675 | 675 | $this->complete_count = $payment_count->publish; |
676 | 676 | $this->pending_count = $payment_count->pending; |
677 | 677 | $this->refunded_count = $payment_count->refunded; |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | $this->cancelled_count = $payment_count->cancelled; |
681 | 681 | $this->abandoned_count = $payment_count->abandoned; |
682 | 682 | |
683 | - foreach ( $payment_count as $count ) { |
|
683 | + foreach ($payment_count as $count) { |
|
684 | 684 | $this->total_count += $count; |
685 | 685 | } |
686 | 686 | } |
@@ -695,26 +695,26 @@ discard block |
||
695 | 695 | public function payments_data() { |
696 | 696 | |
697 | 697 | $per_page = $this->per_page; |
698 | - $orderby = isset( $_GET['orderby'] ) ? urldecode( $_GET['orderby'] ) : 'ID'; |
|
699 | - $order = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC'; |
|
700 | - $user = isset( $_GET['user'] ) ? $_GET['user'] : null; |
|
701 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : give_get_payment_status_keys(); |
|
702 | - $meta_key = isset( $_GET['meta_key'] ) ? $_GET['meta_key'] : null; |
|
703 | - $year = isset( $_GET['year'] ) ? $_GET['year'] : null; |
|
704 | - $month = isset( $_GET['m'] ) ? $_GET['m'] : null; |
|
705 | - $day = isset( $_GET['day'] ) ? $_GET['day'] : null; |
|
706 | - $search = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : null; |
|
707 | - $start_date = isset( $_GET['start-date'] ) ? sanitize_text_field( $_GET['start-date'] ) : null; |
|
708 | - $end_date = isset( $_GET['end-date'] ) ? sanitize_text_field( $_GET['end-date'] ) : $start_date; |
|
709 | - |
|
710 | - if ( ! empty( $search ) ) { |
|
698 | + $orderby = isset($_GET['orderby']) ? urldecode($_GET['orderby']) : 'ID'; |
|
699 | + $order = isset($_GET['order']) ? $_GET['order'] : 'DESC'; |
|
700 | + $user = isset($_GET['user']) ? $_GET['user'] : null; |
|
701 | + $status = isset($_GET['status']) ? $_GET['status'] : give_get_payment_status_keys(); |
|
702 | + $meta_key = isset($_GET['meta_key']) ? $_GET['meta_key'] : null; |
|
703 | + $year = isset($_GET['year']) ? $_GET['year'] : null; |
|
704 | + $month = isset($_GET['m']) ? $_GET['m'] : null; |
|
705 | + $day = isset($_GET['day']) ? $_GET['day'] : null; |
|
706 | + $search = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : null; |
|
707 | + $start_date = isset($_GET['start-date']) ? sanitize_text_field($_GET['start-date']) : null; |
|
708 | + $end_date = isset($_GET['end-date']) ? sanitize_text_field($_GET['end-date']) : $start_date; |
|
709 | + |
|
710 | + if ( ! empty($search)) { |
|
711 | 711 | $status = 'any'; // Force all payment statuses when searching. |
712 | 712 | } |
713 | 713 | |
714 | 714 | $args = array( |
715 | 715 | 'output' => 'payments', |
716 | 716 | 'number' => $per_page, |
717 | - 'page' => isset( $_GET['paged'] ) ? $_GET['paged'] : null, |
|
717 | + 'page' => isset($_GET['paged']) ? $_GET['paged'] : null, |
|
718 | 718 | 'orderby' => $orderby, |
719 | 719 | 'order' => $order, |
720 | 720 | 'user' => $user, |
@@ -728,14 +728,14 @@ discard block |
||
728 | 728 | 'end_date' => $end_date, |
729 | 729 | ); |
730 | 730 | |
731 | - if ( is_string( $search ) && false !== strpos( $search, 'txn:' ) ) { |
|
731 | + if (is_string($search) && false !== strpos($search, 'txn:')) { |
|
732 | 732 | |
733 | 733 | $args['search_in_notes'] = true; |
734 | - $args['s'] = trim( str_replace( 'txn:', '', $args['s'] ) ); |
|
734 | + $args['s'] = trim(str_replace('txn:', '', $args['s'])); |
|
735 | 735 | |
736 | 736 | } |
737 | 737 | |
738 | - $p_query = new Give_Payments_Query( $args ); |
|
738 | + $p_query = new Give_Payments_Query($args); |
|
739 | 739 | |
740 | 740 | return $p_query->get_payments(); |
741 | 741 | |
@@ -755,17 +755,17 @@ discard block |
||
755 | 755 | */ |
756 | 756 | public function prepare_items() { |
757 | 757 | |
758 | - wp_reset_vars( array( 'action', 'payment', 'orderby', 'order', 's' ) ); |
|
758 | + wp_reset_vars(array('action', 'payment', 'orderby', 'order', 's')); |
|
759 | 759 | |
760 | 760 | $columns = $this->get_columns(); |
761 | 761 | $hidden = array(); // No hidden columns. |
762 | 762 | $sortable = $this->get_sortable_columns(); |
763 | 763 | $data = $this->payments_data(); |
764 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : 'any'; |
|
764 | + $status = isset($_GET['status']) ? $_GET['status'] : 'any'; |
|
765 | 765 | |
766 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
766 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
767 | 767 | |
768 | - switch ( $status ) { |
|
768 | + switch ($status) { |
|
769 | 769 | case 'publish': |
770 | 770 | $total_items = $this->complete_count; |
771 | 771 | break; |
@@ -792,19 +792,19 @@ discard block |
||
792 | 792 | break; |
793 | 793 | default: |
794 | 794 | // Retrieve the count of the non-default-Give status. |
795 | - $count = wp_count_posts( 'give_payment' ); |
|
795 | + $count = wp_count_posts('give_payment'); |
|
796 | 796 | $total_items = $count->{$status}; |
797 | 797 | break; |
798 | 798 | } |
799 | 799 | |
800 | 800 | $this->items = $data; |
801 | 801 | |
802 | - $this->set_pagination_args( array( |
|
802 | + $this->set_pagination_args(array( |
|
803 | 803 | 'total_items' => $total_items, |
804 | 804 | // We have to calculate the total number of items. |
805 | 805 | 'per_page' => $this->per_page, |
806 | 806 | // We have to determine how many items to show on a page. |
807 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
807 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
808 | 808 | // We have to calculate the total number of pages. |
809 | 809 | ) |
810 | 810 | ); |
@@ -713,7 +713,7 @@ |
||
713 | 713 | * @param bool $colon Check if add colon between heading and message. |
714 | 714 | * @param string $color Heading color. |
715 | 715 | * |
716 | - * @return mixed |
|
716 | + * @return string |
|
717 | 717 | */ |
718 | 718 | private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) { |
719 | 719 | // Add colon. |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * @subcommand donors |
327 | 327 | */ |
328 | 328 | public function donors( $args, $assoc_args ) { |
329 | - global $wp_query; |
|
329 | + global $wp_query; |
|
330 | 330 | $donor_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
331 | 331 | $email = isset( $assoc_args ) && array_key_exists( 'email', $assoc_args ) ? $assoc_args['email'] : false; |
332 | 332 | $name = isset( $assoc_args ) && array_key_exists( 'name', $assoc_args ) ? $assoc_args['name'] : ''; |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | * @subcommand donations |
493 | 493 | */ |
494 | 494 | public function donations( $args, $assoc_args ) { |
495 | - global $wp_query; |
|
495 | + global $wp_query; |
|
496 | 496 | $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
497 | 497 | |
498 | 498 | // Cache previous number query var. |
@@ -716,9 +716,9 @@ discard block |
||
716 | 716 | * @return mixed |
717 | 717 | */ |
718 | 718 | private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) { |
719 | - // Add colon. |
|
720 | - if ( $colon ) { |
|
721 | - $heading = $heading . ': '; |
|
719 | + // Add colon. |
|
720 | + if ( $colon ) { |
|
721 | + $heading = $heading . ': '; |
|
722 | 722 | } |
723 | 723 | return WP_CLI::colorize( "%{$color}" . $heading . '%n' ) . $message; |
724 | 724 | } |
@@ -7,10 +7,10 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // Exit if accessed directly. |
10 | -if ( ! defined( 'ABSPATH' ) ) { exit; } |
|
10 | +if ( ! defined('ABSPATH')) { exit; } |
|
11 | 11 | |
12 | 12 | // Add give command. |
13 | -WP_CLI::add_command( 'give', 'GIVE_CLI_COMMAND' ); |
|
13 | +WP_CLI::add_command('give', 'GIVE_CLI_COMMAND'); |
|
14 | 14 | |
15 | 15 | |
16 | 16 | /** |
@@ -66,54 +66,54 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @subcommand details |
68 | 68 | */ |
69 | - public function details( $args, $assoc_args ) { |
|
69 | + public function details($args, $assoc_args) { |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Plugin Information |
73 | 73 | */ |
74 | - WP_CLI::log( $this->color_message( __( 'Give Version: ', 'give' ) ) . GIVE_VERSION ); |
|
74 | + WP_CLI::log($this->color_message(__('Give Version: ', 'give')).GIVE_VERSION); |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * General Information. |
78 | 78 | */ |
79 | - WP_CLI::log( "\n#### " . $this->color_message( __( 'General information', 'give' ) ) . ' ####' ); |
|
79 | + WP_CLI::log("\n#### ".$this->color_message(__('General information', 'give')).' ####'); |
|
80 | 80 | |
81 | - $success_page = give_get_option( 'success_page' ); |
|
82 | - $failure_page = give_get_option( 'failure_page' ); |
|
83 | - $history_page = give_get_option( 'history_page' ); |
|
81 | + $success_page = give_get_option('success_page'); |
|
82 | + $failure_page = give_get_option('failure_page'); |
|
83 | + $history_page = give_get_option('history_page'); |
|
84 | 84 | |
85 | - WP_CLI::log( $this->color_message( sprintf( __( 'Success Page: ', 'give' ) ) ) . ( $success_page ? "[{$success_page}] " . get_permalink( $success_page ) : __( 'Not Set', 'give' ) ) ); |
|
86 | - WP_CLI::log( $this->color_message( __( 'Failed Donation Page: ', 'give' ) ) . ( $failure_page ? "[{$failure_page}] " . get_permalink( $failure_page ) : __( 'Not Set', 'give' ) ) ); |
|
87 | - WP_CLI::log( $this->color_message( __( 'Donation History Page: ', 'give' ) ) . ( $history_page ? "[{$history_page}] " . get_permalink( $history_page ) : __( 'Not Set', 'give' ) ) ); |
|
88 | - WP_CLI::log( $this->color_message( __( 'Country: ', 'give' ) ) . give_get_country() ); |
|
85 | + WP_CLI::log($this->color_message(sprintf(__('Success Page: ', 'give'))).($success_page ? "[{$success_page}] ".get_permalink($success_page) : __('Not Set', 'give'))); |
|
86 | + WP_CLI::log($this->color_message(__('Failed Donation Page: ', 'give')).($failure_page ? "[{$failure_page}] ".get_permalink($failure_page) : __('Not Set', 'give'))); |
|
87 | + WP_CLI::log($this->color_message(__('Donation History Page: ', 'give')).($history_page ? "[{$history_page}] ".get_permalink($history_page) : __('Not Set', 'give'))); |
|
88 | + WP_CLI::log($this->color_message(__('Country: ', 'give')).give_get_country()); |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Currency Information. |
92 | 92 | */ |
93 | - $default_gateway = give_get_option( 'default_gateway' ); |
|
93 | + $default_gateway = give_get_option('default_gateway'); |
|
94 | 94 | |
95 | - WP_CLI::log( "\n#### " . $this->color_message( __( 'Currency Information', 'give' ) ) . ' ####' ); |
|
95 | + WP_CLI::log("\n#### ".$this->color_message(__('Currency Information', 'give')).' ####'); |
|
96 | 96 | |
97 | - WP_CLI::log( $this->color_message( __( 'Currency: ', 'give' ), give_get_currency() ) ); |
|
98 | - WP_CLI::log( $this->color_message( __( 'Currency Position: ', 'give' ), give_get_currency_position() ) ); |
|
99 | - WP_CLI::log( $this->color_message( __( 'Thousand Separator: ', 'give' ), give_get_price_thousand_separator() ) ); |
|
100 | - WP_CLI::log( $this->color_message( __( 'Decimal Separator: ', 'give' ), give_get_price_decimal_separator() ) ); |
|
101 | - WP_CLI::log( $this->color_message( __( 'Number of Decimals: ', 'give' ), give_get_price_decimals() ) ); |
|
102 | - WP_CLI::log( $this->color_message( __( 'Test Mode: ', 'give' ), ( give_get_option( 'test_mode' ) ? __( 'Yes', 'give' ) : __( 'No', 'give' ) ) ) ); |
|
103 | - WP_CLI::log( $this->color_message( __( 'Default Gateway: ', 'give' ), ( $default_gateway ? $default_gateway : __( 'Not Set', 'give' ) ) ) ); |
|
97 | + WP_CLI::log($this->color_message(__('Currency: ', 'give'), give_get_currency())); |
|
98 | + WP_CLI::log($this->color_message(__('Currency Position: ', 'give'), give_get_currency_position())); |
|
99 | + WP_CLI::log($this->color_message(__('Thousand Separator: ', 'give'), give_get_price_thousand_separator())); |
|
100 | + WP_CLI::log($this->color_message(__('Decimal Separator: ', 'give'), give_get_price_decimal_separator())); |
|
101 | + WP_CLI::log($this->color_message(__('Number of Decimals: ', 'give'), give_get_price_decimals())); |
|
102 | + WP_CLI::log($this->color_message(__('Test Mode: ', 'give'), (give_get_option('test_mode') ? __('Yes', 'give') : __('No', 'give')))); |
|
103 | + WP_CLI::log($this->color_message(__('Default Gateway: ', 'give'), ($default_gateway ? $default_gateway : __('Not Set', 'give')))); |
|
104 | 104 | |
105 | 105 | // Payment gateways Information. |
106 | - $gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() ); |
|
107 | - WP_CLI::log( $this->color_message( __( 'Enabled Gateways: ', 'give' ) ) ); |
|
106 | + $gateways = give_get_ordered_payment_gateways(give_get_payment_gateways()); |
|
107 | + WP_CLI::log($this->color_message(__('Enabled Gateways: ', 'give'))); |
|
108 | 108 | |
109 | - if ( ! empty( $gateways ) ) { |
|
109 | + if ( ! empty($gateways)) { |
|
110 | 110 | self::$counter = 1; |
111 | - foreach ( $gateways as $gateway ) { |
|
112 | - WP_CLI::log( ' ' . $this->color_message( self::$counter, $gateway['admin_label'] ) ); |
|
111 | + foreach ($gateways as $gateway) { |
|
112 | + WP_CLI::log(' '.$this->color_message(self::$counter, $gateway['admin_label'])); |
|
113 | 113 | self::$counter++; |
114 | 114 | } |
115 | 115 | } else { |
116 | - WP_CLI::log( __( 'Not any payment gateways found', 'give' ) ); |
|
116 | + WP_CLI::log(__('Not any payment gateways found', 'give')); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -145,15 +145,15 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @subcommand forms |
147 | 147 | */ |
148 | - public function forms( $args, $assoc_args ) { |
|
148 | + public function forms($args, $assoc_args) { |
|
149 | 149 | global $wp_query; |
150 | - $form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
|
151 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? absint( $assoc_args['number'] ) : 10; |
|
150 | + $form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false; |
|
151 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? absint($assoc_args['number']) : 10; |
|
152 | 152 | $start = time(); |
153 | 153 | |
154 | 154 | // Cache previous number query var. |
155 | 155 | $is_set_number = $cache_per_page = false; |
156 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
156 | + if (isset($wp_query->query_vars['number'])) { |
|
157 | 157 | $cache_per_page = $wp_query->query_vars['number']; |
158 | 158 | $is_set_number = true; |
159 | 159 | } |
@@ -162,46 +162,46 @@ discard block |
||
162 | 162 | $wp_query->query_vars['number'] = $number; |
163 | 163 | |
164 | 164 | // Get forms. |
165 | - $forms = $form_id ? $this->api->get_forms( $form_id ) : $this->api->get_forms(); |
|
165 | + $forms = $form_id ? $this->api->get_forms($form_id) : $this->api->get_forms(); |
|
166 | 166 | |
167 | 167 | // Reset number query var. |
168 | - if ( $is_set_number ) { |
|
168 | + if ($is_set_number) { |
|
169 | 169 | $wp_query->query_vars['number'] = $cache_per_page; |
170 | 170 | } |
171 | 171 | |
172 | 172 | // Bailout. |
173 | - if ( array_key_exists( 'error', $forms ) ) { |
|
173 | + if (array_key_exists('error', $forms)) { |
|
174 | 174 | |
175 | - WP_CLI::warning( $forms['error'] ); |
|
175 | + WP_CLI::warning($forms['error']); |
|
176 | 176 | return; |
177 | - } elseif ( empty( $forms['forms'] ) ) { |
|
177 | + } elseif (empty($forms['forms'])) { |
|
178 | 178 | |
179 | - WP_CLI::error( __( 'No forms found.', 'give' ) ); |
|
179 | + WP_CLI::error(__('No forms found.', 'give')); |
|
180 | 180 | return; |
181 | 181 | } |
182 | 182 | |
183 | 183 | // Param to check if form typeis already showed or not. |
184 | 184 | $is_show_form_type = false; |
185 | 185 | |
186 | - if ( 1 === count( $forms ) && $form_id ) { |
|
186 | + if (1 === count($forms) && $form_id) { |
|
187 | 187 | // Show single form. |
188 | - foreach ( $forms['forms'][0] as $key => $info ) { |
|
189 | - switch ( $key ) { |
|
188 | + foreach ($forms['forms'][0] as $key => $info) { |
|
189 | + switch ($key) { |
|
190 | 190 | case 'stats': |
191 | - $this->color_main_heading( ucfirst( $key ) ); |
|
191 | + $this->color_main_heading(ucfirst($key)); |
|
192 | 192 | |
193 | - foreach ( $info as $heading => $data ) { |
|
194 | - $this->color_sub_heading( ucfirst( $heading ) ); |
|
195 | - switch ( $heading ) { |
|
193 | + foreach ($info as $heading => $data) { |
|
194 | + $this->color_sub_heading(ucfirst($heading)); |
|
195 | + switch ($heading) { |
|
196 | 196 | default: |
197 | - foreach ( $data as $subheading => $subdata ) { |
|
197 | + foreach ($data as $subheading => $subdata) { |
|
198 | 198 | |
199 | - switch ( $subheading ) { |
|
199 | + switch ($subheading) { |
|
200 | 200 | case 'earnings': |
201 | - WP_CLI::log( $this->color_message( $subheading . ': ', give_currency_filter( $subdata ) ) ); |
|
201 | + WP_CLI::log($this->color_message($subheading.': ', give_currency_filter($subdata))); |
|
202 | 202 | break; |
203 | 203 | default: |
204 | - WP_CLI::log( $this->color_message( $subheading . ': ', $subdata ) ); |
|
204 | + WP_CLI::log($this->color_message($subheading.': ', $subdata)); |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | } |
@@ -211,26 +211,26 @@ discard block |
||
211 | 211 | case 'pricing': |
212 | 212 | case 'info': |
213 | 213 | default: |
214 | - $this->color_main_heading( ucfirst( $key ) ); |
|
214 | + $this->color_main_heading(ucfirst($key)); |
|
215 | 215 | |
216 | 216 | // Show form type. |
217 | - if ( ! $is_show_form_type ) { |
|
218 | - $form = new Give_Donate_Form( $form_id ); |
|
217 | + if ( ! $is_show_form_type) { |
|
218 | + $form = new Give_Donate_Form($form_id); |
|
219 | 219 | $is_show_form_type = true; |
220 | 220 | |
221 | - WP_CLI::log( $this->color_message( __( 'form type', 'give' ), $form->get_type() ) ); |
|
221 | + WP_CLI::log($this->color_message(__('form type', 'give'), $form->get_type())); |
|
222 | 222 | } |
223 | 223 | |
224 | - foreach ( $info as $heading => $data ) { |
|
224 | + foreach ($info as $heading => $data) { |
|
225 | 225 | |
226 | - switch ( $heading ) { |
|
226 | + switch ($heading) { |
|
227 | 227 | case 'id': |
228 | - WP_CLI::log( $this->color_message( $heading, $data ) ); |
|
228 | + WP_CLI::log($this->color_message($heading, $data)); |
|
229 | 229 | break; |
230 | 230 | |
231 | 231 | default: |
232 | - $data = empty( $data ) ? __( 'Not set', 'give' ) : $data; |
|
233 | - WP_CLI::log( $this->color_message( $heading, $data ) ); |
|
232 | + $data = empty($data) ? __('Not set', 'give') : $data; |
|
233 | + WP_CLI::log($this->color_message($heading, $data)); |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | } |
@@ -241,37 +241,37 @@ discard block |
||
241 | 241 | $is_table_first_row_set = false; |
242 | 242 | $table_column_count = 0; |
243 | 243 | |
244 | - WP_CLI::line( $this->color_message( sprintf( __( '%d donation forms found', 'give' ), count( $forms['forms'] ) ), '', false ) ); |
|
244 | + WP_CLI::line($this->color_message(sprintf(__('%d donation forms found', 'give'), count($forms['forms'])), '', false)); |
|
245 | 245 | |
246 | - foreach ( $forms['forms'] as $index => $form_data ) { |
|
246 | + foreach ($forms['forms'] as $index => $form_data) { |
|
247 | 247 | |
248 | 248 | // Default table data. |
249 | 249 | $table_first_row = array(); |
250 | 250 | $table_row = array(); |
251 | 251 | |
252 | - foreach ( $form_data['info'] as $key => $form ) { |
|
252 | + foreach ($form_data['info'] as $key => $form) { |
|
253 | 253 | |
254 | 254 | // Do not show thumbnail, content and link in table. |
255 | - if ( in_array( $key, array( 'content', 'thumbnail', 'link' ), true ) ) { |
|
255 | + if (in_array($key, array('content', 'thumbnail', 'link'), true)) { |
|
256 | 256 | continue; |
257 | 257 | } |
258 | 258 | |
259 | - if ( ! $is_table_first_row_set ) { |
|
259 | + if ( ! $is_table_first_row_set) { |
|
260 | 260 | $table_first_row[] = $key; |
261 | 261 | } |
262 | 262 | |
263 | 263 | $table_row[] = $form; |
264 | 264 | |
265 | - if ( 'status' === $key ) { |
|
265 | + if ('status' === $key) { |
|
266 | 266 | // First array item will be an form id in our case. |
267 | - $form = new Give_Donate_Form( absint( $table_row[0] ) ); |
|
267 | + $form = new Give_Donate_Form(absint($table_row[0])); |
|
268 | 268 | |
269 | 269 | $table_row[] = $form->get_type(); |
270 | 270 | } |
271 | 271 | } |
272 | 272 | |
273 | 273 | // Set table first row. |
274 | - if ( ! $is_table_first_row_set ) { |
|
274 | + if ( ! $is_table_first_row_set) { |
|
275 | 275 | |
276 | 276 | // Add extra column to table. |
277 | 277 | $table_first_row[] = 'type'; |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | $table_data[] = $table_row; |
285 | 285 | } |
286 | 286 | |
287 | - $this->display_table( $table_data ); |
|
287 | + $this->display_table($table_data); |
|
288 | 288 | } |
289 | 289 | } |
290 | 290 | |
@@ -325,29 +325,29 @@ discard block |
||
325 | 325 | * |
326 | 326 | * @subcommand donors |
327 | 327 | */ |
328 | - public function donors( $args, $assoc_args ) { |
|
328 | + public function donors($args, $assoc_args) { |
|
329 | 329 | global $wp_query; |
330 | - $donor_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
|
331 | - $email = isset( $assoc_args ) && array_key_exists( 'email', $assoc_args ) ? $assoc_args['email'] : false; |
|
332 | - $name = isset( $assoc_args ) && array_key_exists( 'name', $assoc_args ) ? $assoc_args['name'] : ''; |
|
333 | - $create = isset( $assoc_args ) && array_key_exists( 'create', $assoc_args ) ? $assoc_args['create'] : false; |
|
334 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
|
330 | + $donor_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false; |
|
331 | + $email = isset($assoc_args) && array_key_exists('email', $assoc_args) ? $assoc_args['email'] : false; |
|
332 | + $name = isset($assoc_args) && array_key_exists('name', $assoc_args) ? $assoc_args['name'] : ''; |
|
333 | + $create = isset($assoc_args) && array_key_exists('create', $assoc_args) ? $assoc_args['create'] : false; |
|
334 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10; |
|
335 | 335 | $start = time(); |
336 | 336 | |
337 | - if ( $create ) { |
|
337 | + if ($create) { |
|
338 | 338 | $number = 1; |
339 | 339 | |
340 | 340 | // Create one or more donors. |
341 | - if ( ! $email ) { |
|
341 | + if ( ! $email) { |
|
342 | 342 | // If no email is specified, look to see if we are generating arbitrary donor accounts. |
343 | - $number = is_numeric( $create ) ? absint( $create ) : 1; |
|
343 | + $number = is_numeric($create) ? absint($create) : 1; |
|
344 | 344 | } |
345 | 345 | |
346 | - for ( $i = 0; $i < $number; $i++ ) { |
|
347 | - if ( ! $email ) { |
|
346 | + for ($i = 0; $i < $number; $i++) { |
|
347 | + if ( ! $email) { |
|
348 | 348 | |
349 | 349 | // Generate fake email. |
350 | - $email = 'customer-' . uniqid() . '@test.com'; |
|
350 | + $email = 'customer-'.uniqid().'@test.com'; |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | $args = array( |
@@ -355,33 +355,33 @@ discard block |
||
355 | 355 | 'name' => $name, |
356 | 356 | ); |
357 | 357 | |
358 | - $customer_id = Give()->customers->add( $args ); |
|
358 | + $customer_id = Give()->customers->add($args); |
|
359 | 359 | |
360 | - if ( $customer_id ) { |
|
361 | - WP_CLI::line( $this->color_message( sprintf( __( 'Donor %d created successfully', 'give' ), $customer_id ) ) ); |
|
360 | + if ($customer_id) { |
|
361 | + WP_CLI::line($this->color_message(sprintf(__('Donor %d created successfully', 'give'), $customer_id))); |
|
362 | 362 | } else { |
363 | - WP_CLI::error( __( 'Failed to create donor', 'give' ) ); |
|
363 | + WP_CLI::error(__('Failed to create donor', 'give')); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | // Reset email to false so it is generated on the next loop (if creating donors). |
367 | 367 | $email = false; |
368 | 368 | } |
369 | 369 | |
370 | - WP_CLI::line( $this->color_message( sprintf( __( '%1$d donors created in %2$d seconds', 'give' ), $number, time() - $start ) ) ); |
|
370 | + WP_CLI::line($this->color_message(sprintf(__('%1$d donors created in %2$d seconds', 'give'), $number, time() - $start))); |
|
371 | 371 | |
372 | 372 | } else { |
373 | 373 | // Counter. |
374 | 374 | self::$counter = 1; |
375 | 375 | |
376 | 376 | // Search for customers. |
377 | - $search = $donor_id ? $donor_id : $email; |
|
377 | + $search = $donor_id ? $donor_id : $email; |
|
378 | 378 | |
379 | 379 | /** |
380 | 380 | * Get donors. |
381 | 381 | */ |
382 | 382 | // Cache previous number query var. |
383 | 383 | $is_set_number = $cache_per_page = false; |
384 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
384 | + if (isset($wp_query->query_vars['number'])) { |
|
385 | 385 | $cache_per_page = $wp_query->query_vars['number']; |
386 | 386 | $is_set_number = true; |
387 | 387 | } |
@@ -390,43 +390,43 @@ discard block |
||
390 | 390 | $wp_query->query_vars['number'] = $number; |
391 | 391 | |
392 | 392 | // Get donors. |
393 | - $donors = $this->api->get_customers( $search ); |
|
393 | + $donors = $this->api->get_customers($search); |
|
394 | 394 | |
395 | 395 | // Reset number query var. |
396 | - if ( $is_set_number ) { |
|
396 | + if ($is_set_number) { |
|
397 | 397 | $wp_query->query_vars['number'] = $cache_per_page; |
398 | 398 | } |
399 | 399 | |
400 | - if ( isset( $donors['error'] ) ) { |
|
401 | - WP_CLI::error( $donors['error'] ); |
|
400 | + if (isset($donors['error'])) { |
|
401 | + WP_CLI::error($donors['error']); |
|
402 | 402 | } |
403 | 403 | |
404 | - if ( empty( $donors ) ) { |
|
405 | - WP_CLI::error( __( 'No donors found.', 'give' ) ); |
|
404 | + if (empty($donors)) { |
|
405 | + WP_CLI::error(__('No donors found.', 'give')); |
|
406 | 406 | return; |
407 | 407 | } |
408 | 408 | |
409 | 409 | $table_data = array(); |
410 | 410 | $is_table_first_row_set = false; |
411 | 411 | |
412 | - foreach ( $donors['donors'] as $donor_data ) { |
|
412 | + foreach ($donors['donors'] as $donor_data) { |
|
413 | 413 | // Set default table row data. |
414 | - $table_first_row = array( __( 'S. No.', 'give' ) ); |
|
415 | - $table_row = array( self::$counter ); |
|
414 | + $table_first_row = array(__('S. No.', 'give')); |
|
415 | + $table_row = array(self::$counter); |
|
416 | 416 | |
417 | - foreach ( $donor_data as $key => $donor ) { |
|
418 | - switch ( $key ) { |
|
417 | + foreach ($donor_data as $key => $donor) { |
|
418 | + switch ($key) { |
|
419 | 419 | case 'stats': |
420 | - foreach ( $donor as $heading => $data ) { |
|
420 | + foreach ($donor as $heading => $data) { |
|
421 | 421 | |
422 | 422 | // Get first row. |
423 | - if ( ! $is_table_first_row_set ) { |
|
423 | + if ( ! $is_table_first_row_set) { |
|
424 | 424 | $table_first_row[] = $heading; |
425 | 425 | } |
426 | 426 | |
427 | - switch ( $heading ) { |
|
427 | + switch ($heading) { |
|
428 | 428 | case 'total_spent': |
429 | - $table_row[] = give_currency_filter( $data ); |
|
429 | + $table_row[] = give_currency_filter($data); |
|
430 | 430 | break; |
431 | 431 | |
432 | 432 | default: |
@@ -437,10 +437,10 @@ discard block |
||
437 | 437 | |
438 | 438 | case 'info': |
439 | 439 | default: |
440 | - foreach ( $donor as $heading => $data ) { |
|
440 | + foreach ($donor as $heading => $data) { |
|
441 | 441 | |
442 | 442 | // Get first row. |
443 | - if ( ! $is_table_first_row_set ) { |
|
443 | + if ( ! $is_table_first_row_set) { |
|
444 | 444 | $table_first_row[] = $heading; |
445 | 445 | } |
446 | 446 | |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | } |
451 | 451 | |
452 | 452 | // Add first row data to table data. |
453 | - if ( ! $is_table_first_row_set ) { |
|
453 | + if ( ! $is_table_first_row_set) { |
|
454 | 454 | $table_data[] = $table_first_row; |
455 | 455 | $is_table_first_row_set = true; |
456 | 456 | } |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | self::$counter++; |
463 | 463 | } |
464 | 464 | |
465 | - $this->display_table( $table_data ); |
|
465 | + $this->display_table($table_data); |
|
466 | 466 | } |
467 | 467 | } |
468 | 468 | |
@@ -491,13 +491,13 @@ discard block |
||
491 | 491 | * |
492 | 492 | * @subcommand donations |
493 | 493 | */ |
494 | - public function donations( $args, $assoc_args ) { |
|
494 | + public function donations($args, $assoc_args) { |
|
495 | 495 | global $wp_query; |
496 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
|
496 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10; |
|
497 | 497 | |
498 | 498 | // Cache previous number query var. |
499 | 499 | $is_set_number = $cache_per_page = false; |
500 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
500 | + if (isset($wp_query->query_vars['number'])) { |
|
501 | 501 | $cache_per_page = $wp_query->query_vars['number']; |
502 | 502 | $is_set_number = true; |
503 | 503 | } |
@@ -509,45 +509,45 @@ discard block |
||
509 | 509 | $donations = $this->api->get_recent_donations(); |
510 | 510 | |
511 | 511 | // Reset number query var. |
512 | - if ( $is_set_number ) { |
|
512 | + if ($is_set_number) { |
|
513 | 513 | $wp_query->query_vars['number'] = $cache_per_page; |
514 | 514 | } |
515 | 515 | |
516 | - if ( empty( $donations ) ) { |
|
517 | - WP_CLI::error( __( 'No donations found.', 'give' ) ); |
|
516 | + if (empty($donations)) { |
|
517 | + WP_CLI::error(__('No donations found.', 'give')); |
|
518 | 518 | return; |
519 | 519 | } |
520 | 520 | |
521 | 521 | self::$counter = 1; |
522 | 522 | |
523 | - foreach ( $donations['donations'] as $key => $donation ) { |
|
524 | - $this->color_main_heading( sprintf( __( '%1$s. Donation #%2$s', 'give' ), self::$counter, $donation['ID'] ), 'Y' ); |
|
523 | + foreach ($donations['donations'] as $key => $donation) { |
|
524 | + $this->color_main_heading(sprintf(__('%1$s. Donation #%2$s', 'give'), self::$counter, $donation['ID']), 'Y'); |
|
525 | 525 | self::$counter++; |
526 | 526 | |
527 | - foreach ( $donation as $column => $data ) { |
|
527 | + foreach ($donation as $column => $data) { |
|
528 | 528 | |
529 | - if ( is_array( $data ) ) { |
|
530 | - $this->color_sub_heading( $column ); |
|
531 | - foreach ( $data as $subcolumn => $subdata ) { |
|
529 | + if (is_array($data)) { |
|
530 | + $this->color_sub_heading($column); |
|
531 | + foreach ($data as $subcolumn => $subdata) { |
|
532 | 532 | |
533 | 533 | // Decode html codes. |
534 | - switch ( $subcolumn ) { |
|
534 | + switch ($subcolumn) { |
|
535 | 535 | case 'name': |
536 | - $subdata = html_entity_decode( $subdata ); |
|
536 | + $subdata = html_entity_decode($subdata); |
|
537 | 537 | break; |
538 | 538 | } |
539 | 539 | |
540 | 540 | // @TODO Check if multi dimension array information is importent to show or not. For example inside donation array we have array for fees data inside payment meta. |
541 | - if ( is_array( $subdata ) ) { |
|
541 | + if (is_array($subdata)) { |
|
542 | 542 | continue; |
543 | 543 | } |
544 | 544 | |
545 | - WP_CLI::log( $this->color_message( $subcolumn, $subdata ) ); |
|
545 | + WP_CLI::log($this->color_message($subcolumn, $subdata)); |
|
546 | 546 | } |
547 | 547 | continue; |
548 | 548 | } |
549 | 549 | |
550 | - WP_CLI::log( $this->color_message( $column, $data ) ); |
|
550 | + WP_CLI::log($this->color_message($column, $data)); |
|
551 | 551 | } |
552 | 552 | } |
553 | 553 | } |
@@ -586,27 +586,27 @@ discard block |
||
586 | 586 | * |
587 | 587 | * @return void |
588 | 588 | */ |
589 | - public function report( $args, $assoc_args ) { |
|
589 | + public function report($args, $assoc_args) { |
|
590 | 590 | $stats = new Give_Payment_Stats(); |
591 | - $date = isset( $assoc_args ) && array_key_exists( 'date', $assoc_args ) ? $assoc_args['date'] : false; |
|
592 | - $start_date = isset( $assoc_args ) && array_key_exists( 'start-date', $assoc_args ) ? $assoc_args['start-date'] : false; |
|
593 | - $end_date = isset( $assoc_args ) && array_key_exists( 'end-date', $assoc_args ) ? $assoc_args['end-date'] : false; |
|
594 | - $form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? $assoc_args['id'] : 0; |
|
591 | + $date = isset($assoc_args) && array_key_exists('date', $assoc_args) ? $assoc_args['date'] : false; |
|
592 | + $start_date = isset($assoc_args) && array_key_exists('start-date', $assoc_args) ? $assoc_args['start-date'] : false; |
|
593 | + $end_date = isset($assoc_args) && array_key_exists('end-date', $assoc_args) ? $assoc_args['end-date'] : false; |
|
594 | + $form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? $assoc_args['id'] : 0; |
|
595 | 595 | |
596 | - if ( ! empty( $date ) ) { |
|
596 | + if ( ! empty($date)) { |
|
597 | 597 | $start_date = $date; |
598 | 598 | $end_date = false; |
599 | - } elseif ( empty( $date ) && empty( $start_date ) ) { |
|
599 | + } elseif (empty($date) && empty($start_date)) { |
|
600 | 600 | $start_date = 'this_month'; |
601 | 601 | $end_date = false; |
602 | 602 | } |
603 | 603 | |
604 | 604 | // Get stats. |
605 | - $earnings = $stats->get_earnings( $form_id, $start_date, $end_date ); |
|
606 | - $sales = $stats->get_sales( $form_id, $start_date, $end_date ); |
|
605 | + $earnings = $stats->get_earnings($form_id, $start_date, $end_date); |
|
606 | + $sales = $stats->get_sales($form_id, $start_date, $end_date); |
|
607 | 607 | |
608 | - WP_CLI::line( $this->color_message( __( 'Earnings', 'give' ), give_currency_filter( $earnings ) ) ); |
|
609 | - WP_CLI::line( $this->color_message( __( 'Sales', 'give' ), $sales ) ); |
|
608 | + WP_CLI::line($this->color_message(__('Earnings', 'give'), give_currency_filter($earnings))); |
|
609 | + WP_CLI::line($this->color_message(__('Sales', 'give'), $sales)); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | |
@@ -633,26 +633,26 @@ discard block |
||
633 | 633 | * |
634 | 634 | * @subcommand cache |
635 | 635 | */ |
636 | - public function cache( $args, $assoc_args ) { |
|
637 | - $action = isset( $assoc_args ) && array_key_exists( 'action', $assoc_args ) ? $assoc_args['action'] : false; |
|
636 | + public function cache($args, $assoc_args) { |
|
637 | + $action = isset($assoc_args) && array_key_exists('action', $assoc_args) ? $assoc_args['action'] : false; |
|
638 | 638 | |
639 | 639 | // Bailout. |
640 | - if ( ! $action || ! in_array( $action, array( 'delete' ), true ) ) { |
|
641 | - WP_CLI::warning( __( 'Type wp give cache --action=delete to delete all stat transients', 'give' ) ); |
|
640 | + if ( ! $action || ! in_array($action, array('delete'), true)) { |
|
641 | + WP_CLI::warning(__('Type wp give cache --action=delete to delete all stat transients', 'give')); |
|
642 | 642 | return; |
643 | 643 | } |
644 | 644 | |
645 | - switch ( $action ) { |
|
645 | + switch ($action) { |
|
646 | 646 | case 'delete' : |
647 | 647 | // Reset counter. |
648 | 648 | self::$counter = 1; |
649 | 649 | |
650 | - if ( $this->delete_stats_transients() ) { |
|
650 | + if ($this->delete_stats_transients()) { |
|
651 | 651 | // Report .eading. |
652 | - WP_CLI::success( 'All form stat transient cache deleted.' ); |
|
652 | + WP_CLI::success('All form stat transient cache deleted.'); |
|
653 | 653 | } else { |
654 | 654 | // Report .eading. |
655 | - WP_CLI::warning( 'We did not find any transient to delete :)' ); |
|
655 | + WP_CLI::warning('We did not find any transient to delete :)'); |
|
656 | 656 | } |
657 | 657 | break; |
658 | 658 | } |
@@ -678,23 +678,23 @@ discard block |
||
678 | 678 | ARRAY_A |
679 | 679 | ); |
680 | 680 | |
681 | - if ( ! empty( $stat_option_names ) ) { |
|
681 | + if ( ! empty($stat_option_names)) { |
|
682 | 682 | |
683 | 683 | // Convert transient option name to transient name. |
684 | 684 | $stat_option_names = array_map( |
685 | - function( $option ) { |
|
686 | - return str_replace( '_transient_', '', $option['option_name'] ); |
|
685 | + function($option) { |
|
686 | + return str_replace('_transient_', '', $option['option_name']); |
|
687 | 687 | }, |
688 | 688 | $stat_option_names |
689 | 689 | ); |
690 | 690 | |
691 | - foreach ( $stat_option_names as $option_name ) { |
|
692 | - if ( delete_transient( $option_name ) ) { |
|
691 | + foreach ($stat_option_names as $option_name) { |
|
692 | + if (delete_transient($option_name)) { |
|
693 | 693 | |
694 | - WP_CLI::log( $this->color_message( self::$counter, $option_name ) ); |
|
694 | + WP_CLI::log($this->color_message(self::$counter, $option_name)); |
|
695 | 695 | self::$counter++; |
696 | 696 | } else { |
697 | - WP_CLI::log( $this->color_message( __( 'Error while deleting this transient', 'give' ), $option_name ) ); |
|
697 | + WP_CLI::log($this->color_message(__('Error while deleting this transient', 'give'), $option_name)); |
|
698 | 698 | } |
699 | 699 | } |
700 | 700 | |
@@ -715,12 +715,12 @@ discard block |
||
715 | 715 | * |
716 | 716 | * @return mixed |
717 | 717 | */ |
718 | - private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) { |
|
718 | + private function color_message($heading, $message = '', $colon = true, $color = 'g') { |
|
719 | 719 | // Add colon. |
720 | - if ( $colon ) { |
|
721 | - $heading = $heading . ': '; |
|
720 | + if ($colon) { |
|
721 | + $heading = $heading.': '; |
|
722 | 722 | } |
723 | - return WP_CLI::colorize( "%{$color}" . $heading . '%n' ) . $message; |
|
723 | + return WP_CLI::colorize("%{$color}".$heading.'%n').$message; |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | |
@@ -735,8 +735,8 @@ discard block |
||
735 | 735 | * |
736 | 736 | * @return void |
737 | 737 | */ |
738 | - private function color_main_heading( $heading, $color = 'g' ) { |
|
739 | - WP_CLI::log( "\n###### " . $this->color_message( $heading, '', false, $color ) . ' ######' ); |
|
738 | + private function color_main_heading($heading, $color = 'g') { |
|
739 | + WP_CLI::log("\n###### ".$this->color_message($heading, '', false, $color).' ######'); |
|
740 | 740 | } |
741 | 741 | |
742 | 742 | /** |
@@ -749,8 +749,8 @@ discard block |
||
749 | 749 | * |
750 | 750 | * @return void |
751 | 751 | */ |
752 | - private function color_sub_heading( $subheading ) { |
|
753 | - WP_CLI::log( "\n--->" . $subheading . '', '', false ); |
|
752 | + private function color_sub_heading($subheading) { |
|
753 | + WP_CLI::log("\n--->".$subheading.'', '', false); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | |
@@ -764,17 +764,17 @@ discard block |
||
764 | 764 | * |
765 | 765 | * @return void |
766 | 766 | */ |
767 | - private function display_table( $data ) { |
|
767 | + private function display_table($data) { |
|
768 | 768 | $table = new \cli\Table(); |
769 | 769 | |
770 | 770 | // Set table header. |
771 | - $table->setHeaders( $data[0] ); |
|
771 | + $table->setHeaders($data[0]); |
|
772 | 772 | |
773 | 773 | // Remove table header. |
774 | - unset( $data[0] ); |
|
774 | + unset($data[0]); |
|
775 | 775 | |
776 | 776 | // Set table data. |
777 | - $table->setRows( $data ); |
|
777 | + $table->setRows($data); |
|
778 | 778 | |
779 | 779 | // Display table. |
780 | 780 | $table->display(); |
@@ -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__, esc_html__( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
235 | + _doing_it_wrong(__FUNCTION__, esc_html__('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__, esc_html__( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
248 | + _doing_it_wrong(__FUNCTION__, esc_html__('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.7' ); |
|
262 | + if ( ! defined('GIVE_VERSION')) { |
|
263 | + define('GIVE_VERSION', '1.7'); |
|
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,121 +300,121 @@ 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-purchase.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-purchase.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/system-info.php'; |
|
380 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php'; |
|
381 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php'; |
|
382 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php'; |
|
383 | - |
|
384 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php'; |
|
385 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php'; |
|
386 | - |
|
387 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customers.php'; |
|
388 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-functions.php'; |
|
389 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-actions.php'; |
|
390 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php'; |
|
391 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-metabox-form-data.php'; |
|
392 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php'; |
|
393 | - |
|
394 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/export-functions.php'; |
|
395 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/reports.php'; |
|
396 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools.php'; |
|
397 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/tools-actions.php'; |
|
398 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/pdf-reports.php'; |
|
399 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-give-graph.php'; |
|
400 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/graphing.php'; |
|
401 | - |
|
402 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
403 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php'; |
|
404 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php'; |
|
405 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
406 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php'; |
|
407 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php'; |
|
408 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
409 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
410 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
411 | - |
|
412 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
413 | - 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/system-info.php'; |
|
380 | + require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php'; |
|
381 | + require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php'; |
|
382 | + require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php'; |
|
383 | + |
|
384 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php'; |
|
385 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php'; |
|
386 | + |
|
387 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customers.php'; |
|
388 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-functions.php'; |
|
389 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-actions.php'; |
|
390 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php'; |
|
391 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/class-metabox-form-data.php'; |
|
392 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php'; |
|
393 | + |
|
394 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/export-functions.php'; |
|
395 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/reports.php'; |
|
396 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools.php'; |
|
397 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/tools-actions.php'; |
|
398 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/pdf-reports.php'; |
|
399 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-give-graph.php'; |
|
400 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/graphing.php'; |
|
401 | + |
|
402 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
403 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php'; |
|
404 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php'; |
|
405 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
406 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php'; |
|
407 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php'; |
|
408 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
409 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
410 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
411 | + |
|
412 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
413 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrades.php'; |
|
414 | 414 | |
415 | 415 | } |
416 | 416 | |
417 | - require_once GIVE_PLUGIN_DIR . 'includes/install.php'; |
|
417 | + require_once GIVE_PLUGIN_DIR.'includes/install.php'; |
|
418 | 418 | |
419 | 419 | } |
420 | 420 | |
@@ -428,26 +428,26 @@ discard block |
||
428 | 428 | */ |
429 | 429 | public function load_textdomain() { |
430 | 430 | // Set filter for Give's languages directory |
431 | - $give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/'; |
|
432 | - $give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir ); |
|
431 | + $give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/'; |
|
432 | + $give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir); |
|
433 | 433 | |
434 | 434 | // Traditional WordPress plugin locale filter |
435 | - $locale = apply_filters( 'plugin_locale', get_locale(), 'give' ); |
|
436 | - $mofile = sprintf( '%1$s-%2$s.mo', 'give', $locale ); |
|
435 | + $locale = apply_filters('plugin_locale', get_locale(), 'give'); |
|
436 | + $mofile = sprintf('%1$s-%2$s.mo', 'give', $locale); |
|
437 | 437 | |
438 | 438 | // Setup paths to current locale file |
439 | - $mofile_local = $give_lang_dir . $mofile; |
|
440 | - $mofile_global = WP_LANG_DIR . '/give/' . $mofile; |
|
439 | + $mofile_local = $give_lang_dir.$mofile; |
|
440 | + $mofile_global = WP_LANG_DIR.'/give/'.$mofile; |
|
441 | 441 | |
442 | - if ( file_exists( $mofile_global ) ) { |
|
442 | + if (file_exists($mofile_global)) { |
|
443 | 443 | // Look in global /wp-content/languages/give folder |
444 | - load_textdomain( 'give', $mofile_global ); |
|
445 | - } elseif ( file_exists( $mofile_local ) ) { |
|
444 | + load_textdomain('give', $mofile_global); |
|
445 | + } elseif (file_exists($mofile_local)) { |
|
446 | 446 | // Look in local location from filter `give_languages_directory` |
447 | - load_textdomain( 'give', $mofile_local ); |
|
447 | + load_textdomain('give', $mofile_local); |
|
448 | 448 | } else { |
449 | 449 | // Load the default language files packaged up w/ Give |
450 | - load_plugin_textdomain( 'give', false, $give_lang_dir ); |
|
450 | + load_plugin_textdomain('give', false, $give_lang_dir); |
|
451 | 451 | } |
452 | 452 | } |
453 | 453 |
@@ -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 | } |