@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -141,27 +141,27 @@ discard block |
||
141 | 141 | 'v1' => 'GIVE_API_V1', |
142 | 142 | ); |
143 | 143 | |
144 | - foreach ( $this->get_versions() as $version => $class ) { |
|
145 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php'; |
|
144 | + foreach ($this->get_versions() as $version => $class) { |
|
145 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php'; |
|
146 | 146 | } |
147 | 147 | |
148 | - add_action( 'init', array( $this, 'add_endpoint' ) ); |
|
149 | - add_action( 'wp', array( $this, 'process_query' ), - 1 ); |
|
150 | - add_filter( 'query_vars', array( $this, 'query_vars' ) ); |
|
151 | - add_action( 'show_user_profile', array( $this, 'user_key_field' ) ); |
|
152 | - add_action( 'edit_user_profile', array( $this, 'user_key_field' ) ); |
|
153 | - add_action( 'personal_options_update', array( $this, 'generate_api_key' ) ); |
|
154 | - add_action( 'edit_user_profile_update', array( $this, 'generate_api_key' ) ); |
|
155 | - add_action( 'give_process_api_key', array( $this, 'process_api_key' ) ); |
|
148 | + add_action('init', array($this, 'add_endpoint')); |
|
149 | + add_action('wp', array($this, 'process_query'), - 1); |
|
150 | + add_filter('query_vars', array($this, 'query_vars')); |
|
151 | + add_action('show_user_profile', array($this, 'user_key_field')); |
|
152 | + add_action('edit_user_profile', array($this, 'user_key_field')); |
|
153 | + add_action('personal_options_update', array($this, 'generate_api_key')); |
|
154 | + add_action('edit_user_profile_update', array($this, 'generate_api_key')); |
|
155 | + add_action('give_process_api_key', array($this, 'process_api_key')); |
|
156 | 156 | |
157 | 157 | // Setup a backwards compatibility check for user API Keys |
158 | - add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 ); |
|
158 | + add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4); |
|
159 | 159 | |
160 | 160 | // Determine if JSON_PRETTY_PRINT is available |
161 | - $this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null; |
|
161 | + $this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null; |
|
162 | 162 | |
163 | 163 | // Allow API request logging to be turned off |
164 | - $this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests ); |
|
164 | + $this->log_requests = apply_filters('give_api_log_requests', $this->log_requests); |
|
165 | 165 | |
166 | 166 | // Setup Give_Payment_Stats instance |
167 | 167 | $this->stats = new Give_Payment_Stats(); |
@@ -179,17 +179,17 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return mixed |
181 | 181 | */ |
182 | - public function __call( $name, $arguments ) { |
|
182 | + public function __call($name, $arguments) { |
|
183 | 183 | $deprecated_function_arr = array( |
184 | 184 | 'get_customers', |
185 | 185 | ); |
186 | 186 | |
187 | - if ( in_array( $name, $deprecated_function_arr, true ) ) { |
|
188 | - switch ( $name ) { |
|
187 | + if (in_array($name, $deprecated_function_arr, true)) { |
|
188 | + switch ($name) { |
|
189 | 189 | case 'get_customers': |
190 | - $args = ! empty( $arguments[0] ) ? $arguments[0] : array(); |
|
190 | + $args = ! empty($arguments[0]) ? $arguments[0] : array(); |
|
191 | 191 | |
192 | - return $this->get_donors( $args ); |
|
192 | + return $this->get_donors($args); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @since 1.1 |
203 | 203 | */ |
204 | 204 | public function add_endpoint() { |
205 | - add_rewrite_endpoint( 'give-api', EP_ALL ); |
|
205 | + add_rewrite_endpoint('give-api', EP_ALL); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return string[] $vars New query vars |
217 | 217 | */ |
218 | - public function query_vars( $vars ) { |
|
218 | + public function query_vars($vars) { |
|
219 | 219 | |
220 | 220 | $vars[] = 'token'; |
221 | 221 | $vars[] = 'key'; |
@@ -266,11 +266,11 @@ discard block |
||
266 | 266 | */ |
267 | 267 | public function get_default_version() { |
268 | 268 | |
269 | - $version = get_option( 'give_default_api_version' ); |
|
269 | + $version = get_option('give_default_api_version'); |
|
270 | 270 | |
271 | - if ( defined( 'GIVE_API_VERSION' ) ) { |
|
271 | + if (defined('GIVE_API_VERSION')) { |
|
272 | 272 | $version = GIVE_API_VERSION; |
273 | - } elseif ( ! $version ) { |
|
273 | + } elseif ( ! $version) { |
|
274 | 274 | $version = 'v1'; |
275 | 275 | } |
276 | 276 | |
@@ -291,14 +291,14 @@ discard block |
||
291 | 291 | |
292 | 292 | $version = $wp_query->query_vars['give-api']; |
293 | 293 | |
294 | - if ( strpos( $version, '/' ) ) { |
|
294 | + if (strpos($version, '/')) { |
|
295 | 295 | |
296 | - $version = explode( '/', $version ); |
|
297 | - $version = strtolower( $version[0] ); |
|
296 | + $version = explode('/', $version); |
|
297 | + $version = strtolower($version[0]); |
|
298 | 298 | |
299 | - $wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] ); |
|
299 | + $wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']); |
|
300 | 300 | |
301 | - if ( array_key_exists( $version, $this->versions ) ) { |
|
301 | + if (array_key_exists($version, $this->versions)) { |
|
302 | 302 | |
303 | 303 | $this->queried_version = $version; |
304 | 304 | |
@@ -334,16 +334,16 @@ discard block |
||
334 | 334 | $this->override = false; |
335 | 335 | |
336 | 336 | // Make sure we have both user and api key |
337 | - if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] !== 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) { |
|
337 | + if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] !== 'forms' || ! empty($wp_query->query_vars['token']))) { |
|
338 | 338 | |
339 | - if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) { |
|
339 | + if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) { |
|
340 | 340 | $this->missing_auth(); |
341 | 341 | |
342 | 342 | return false; |
343 | 343 | } |
344 | 344 | |
345 | 345 | // Retrieve the user by public API key and ensure they exist |
346 | - if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) { |
|
346 | + if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) { |
|
347 | 347 | |
348 | 348 | $this->invalid_key(); |
349 | 349 | |
@@ -351,11 +351,11 @@ discard block |
||
351 | 351 | |
352 | 352 | } else { |
353 | 353 | |
354 | - $token = urldecode( $wp_query->query_vars['token'] ); |
|
355 | - $secret = $this->get_user_secret_key( $user ); |
|
356 | - $public = urldecode( $wp_query->query_vars['key'] ); |
|
354 | + $token = urldecode($wp_query->query_vars['token']); |
|
355 | + $secret = $this->get_user_secret_key($user); |
|
356 | + $public = urldecode($wp_query->query_vars['key']); |
|
357 | 357 | |
358 | - if ( hash_equals( md5( $secret . $public ), $token ) ) { |
|
358 | + if (hash_equals(md5($secret.$public), $token)) { |
|
359 | 359 | $this->is_valid_request = true; |
360 | 360 | } else { |
361 | 361 | $this->invalid_auth(); |
@@ -364,9 +364,9 @@ discard block |
||
364 | 364 | } |
365 | 365 | |
366 | 366 | } |
367 | - } elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] === 'forms' ) { |
|
367 | + } elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] === 'forms') { |
|
368 | 368 | $this->is_valid_request = true; |
369 | - $wp_query->set( 'key', 'public' ); |
|
369 | + $wp_query->set('key', 'public'); |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 | |
@@ -382,25 +382,25 @@ discard block |
||
382 | 382 | * |
383 | 383 | * @return bool if user ID is found, false otherwise |
384 | 384 | */ |
385 | - public function get_user( $key = '' ) { |
|
385 | + public function get_user($key = '') { |
|
386 | 386 | global $wpdb, $wp_query; |
387 | 387 | |
388 | - if ( empty( $key ) ) { |
|
389 | - $key = urldecode( $wp_query->query_vars['key'] ); |
|
388 | + if (empty($key)) { |
|
389 | + $key = urldecode($wp_query->query_vars['key']); |
|
390 | 390 | } |
391 | 391 | |
392 | - if ( empty( $key ) ) { |
|
392 | + if (empty($key)) { |
|
393 | 393 | return false; |
394 | 394 | } |
395 | 395 | |
396 | - $user = Give_Cache::get( md5( 'give_api_user_' . $key ), true ); |
|
396 | + $user = Give_Cache::get(md5('give_api_user_'.$key), true); |
|
397 | 397 | |
398 | - if ( false === $user ) { |
|
399 | - $user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) ); |
|
400 | - Give_Cache::set( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS, true ); |
|
398 | + if (false === $user) { |
|
399 | + $user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key)); |
|
400 | + Give_Cache::set(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS, true); |
|
401 | 401 | } |
402 | 402 | |
403 | - if ( $user != null ) { |
|
403 | + if ($user != null) { |
|
404 | 404 | $this->user_id = $user; |
405 | 405 | |
406 | 406 | return $user; |
@@ -416,19 +416,19 @@ discard block |
||
416 | 416 | * |
417 | 417 | * @return mixed|null|string |
418 | 418 | */ |
419 | - public function get_user_public_key( $user_id = 0 ) { |
|
419 | + public function get_user_public_key($user_id = 0) { |
|
420 | 420 | global $wpdb; |
421 | 421 | |
422 | - if ( empty( $user_id ) ) { |
|
422 | + if (empty($user_id)) { |
|
423 | 423 | return ''; |
424 | 424 | } |
425 | 425 | |
426 | - $cache_key = md5( 'give_api_user_public_key' . $user_id ); |
|
427 | - $user_public_key = Give_Cache::get( $cache_key, true ); |
|
426 | + $cache_key = md5('give_api_user_public_key'.$user_id); |
|
427 | + $user_public_key = Give_Cache::get($cache_key, true); |
|
428 | 428 | |
429 | - if ( empty( $user_public_key ) ) { |
|
430 | - $user_public_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id ) ); |
|
431 | - Give_Cache::set( $cache_key, $user_public_key, HOUR_IN_SECONDS, true ); |
|
429 | + if (empty($user_public_key)) { |
|
430 | + $user_public_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id)); |
|
431 | + Give_Cache::set($cache_key, $user_public_key, HOUR_IN_SECONDS, true); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | return $user_public_key; |
@@ -441,19 +441,19 @@ discard block |
||
441 | 441 | * |
442 | 442 | * @return mixed|null|string |
443 | 443 | */ |
444 | - public function get_user_secret_key( $user_id = 0 ) { |
|
444 | + public function get_user_secret_key($user_id = 0) { |
|
445 | 445 | global $wpdb; |
446 | 446 | |
447 | - if ( empty( $user_id ) ) { |
|
447 | + if (empty($user_id)) { |
|
448 | 448 | return ''; |
449 | 449 | } |
450 | 450 | |
451 | - $cache_key = md5( 'give_api_user_secret_key' . $user_id ); |
|
452 | - $user_secret_key = Give_Cache::get( $cache_key, true ); |
|
451 | + $cache_key = md5('give_api_user_secret_key'.$user_id); |
|
452 | + $user_secret_key = Give_Cache::get($cache_key, true); |
|
453 | 453 | |
454 | - if ( empty( $user_secret_key ) ) { |
|
455 | - $user_secret_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id ) ); |
|
456 | - Give_Cache::set( $cache_key, $user_secret_key, HOUR_IN_SECONDS, true ); |
|
454 | + if (empty($user_secret_key)) { |
|
455 | + $user_secret_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id)); |
|
456 | + Give_Cache::set($cache_key, $user_secret_key, HOUR_IN_SECONDS, true); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | return $user_secret_key; |
@@ -469,10 +469,10 @@ discard block |
||
469 | 469 | */ |
470 | 470 | private function missing_auth() { |
471 | 471 | $error = array(); |
472 | - $error['error'] = __( 'You must specify both a token and API key.', 'give' ); |
|
472 | + $error['error'] = __('You must specify both a token and API key.', 'give'); |
|
473 | 473 | |
474 | 474 | $this->data = $error; |
475 | - $this->output( 401 ); |
|
475 | + $this->output(401); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | /** |
@@ -486,10 +486,10 @@ discard block |
||
486 | 486 | */ |
487 | 487 | private function invalid_auth() { |
488 | 488 | $error = array(); |
489 | - $error['error'] = __( 'Your request could not be authenticated.', 'give' ); |
|
489 | + $error['error'] = __('Your request could not be authenticated.', 'give'); |
|
490 | 490 | |
491 | 491 | $this->data = $error; |
492 | - $this->output( 403 ); |
|
492 | + $this->output(403); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | /** |
@@ -503,10 +503,10 @@ discard block |
||
503 | 503 | */ |
504 | 504 | private function invalid_key() { |
505 | 505 | $error = array(); |
506 | - $error['error'] = __( 'Invalid API key.', 'give' ); |
|
506 | + $error['error'] = __('Invalid API key.', 'give'); |
|
507 | 507 | |
508 | 508 | $this->data = $error; |
509 | - $this->output( 403 ); |
|
509 | + $this->output(403); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
@@ -519,10 +519,10 @@ discard block |
||
519 | 519 | */ |
520 | 520 | private function invalid_version() { |
521 | 521 | $error = array(); |
522 | - $error['error'] = __( 'Invalid API version.', 'give' ); |
|
522 | + $error['error'] = __('Invalid API version.', 'give'); |
|
523 | 523 | |
524 | 524 | $this->data = $error; |
525 | - $this->output( 404 ); |
|
525 | + $this->output(404); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -538,10 +538,10 @@ discard block |
||
538 | 538 | global $wp_query; |
539 | 539 | |
540 | 540 | // Start logging how long the request takes for logging |
541 | - $before = microtime( true ); |
|
541 | + $before = microtime(true); |
|
542 | 542 | |
543 | 543 | // Check for give-api var. Get out if not present |
544 | - if ( empty( $wp_query->query_vars['give-api'] ) ) { |
|
544 | + if (empty($wp_query->query_vars['give-api'])) { |
|
545 | 545 | return; |
546 | 546 | } |
547 | 547 | |
@@ -555,45 +555,45 @@ discard block |
||
555 | 555 | $this->validate_request(); |
556 | 556 | |
557 | 557 | // Only proceed if no errors have been noted |
558 | - if ( ! $this->is_valid_request ) { |
|
558 | + if ( ! $this->is_valid_request) { |
|
559 | 559 | return; |
560 | 560 | } |
561 | 561 | |
562 | - if ( ! defined( 'GIVE_DOING_API' ) ) { |
|
563 | - define( 'GIVE_DOING_API', true ); |
|
562 | + if ( ! defined('GIVE_DOING_API')) { |
|
563 | + define('GIVE_DOING_API', true); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | $data = array(); |
567 | 567 | $this->routes = new $this->versions[$this->get_queried_version()]; |
568 | 568 | $this->routes->validate_request(); |
569 | 569 | |
570 | - switch ( $this->endpoint ) : |
|
570 | + switch ($this->endpoint) : |
|
571 | 571 | |
572 | 572 | case 'stats' : |
573 | 573 | |
574 | - $data = $this->routes->get_stats( array( |
|
575 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, |
|
576 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, |
|
577 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
578 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
579 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
580 | - ) ); |
|
574 | + $data = $this->routes->get_stats(array( |
|
575 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, |
|
576 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, |
|
577 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
578 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
579 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
580 | + )); |
|
581 | 581 | |
582 | 582 | break; |
583 | 583 | |
584 | 584 | case 'forms' : |
585 | 585 | |
586 | - $form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null; |
|
586 | + $form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null; |
|
587 | 587 | |
588 | - $data = $this->routes->get_forms( $form ); |
|
588 | + $data = $this->routes->get_forms($form); |
|
589 | 589 | |
590 | 590 | break; |
591 | 591 | |
592 | 592 | case 'donors' : |
593 | 593 | |
594 | - $donor = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null; |
|
594 | + $donor = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null; |
|
595 | 595 | |
596 | - $data = $this->routes->get_donors( $donor ); |
|
596 | + $data = $this->routes->get_donors($donor); |
|
597 | 597 | |
598 | 598 | break; |
599 | 599 | |
@@ -606,26 +606,26 @@ discard block |
||
606 | 606 | * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524) |
607 | 607 | * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524) |
608 | 608 | */ |
609 | - $data = $this->routes->get_recent_donations( array( |
|
610 | - 'id' => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null, |
|
611 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
612 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
613 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
614 | - ) ); |
|
609 | + $data = $this->routes->get_recent_donations(array( |
|
610 | + 'id' => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null, |
|
611 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
612 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
613 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
614 | + )); |
|
615 | 615 | |
616 | 616 | break; |
617 | 617 | |
618 | 618 | endswitch; |
619 | 619 | |
620 | 620 | // Allow extensions to setup their own return data |
621 | - $this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this ); |
|
621 | + $this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this); |
|
622 | 622 | |
623 | - $after = microtime( true ); |
|
624 | - $request_time = ( $after - $before ); |
|
623 | + $after = microtime(true); |
|
624 | + $request_time = ($after - $before); |
|
625 | 625 | $this->data['request_speed'] = $request_time; |
626 | 626 | |
627 | 627 | // Log this API request, if enabled. We log it here because we have access to errors. |
628 | - $this->log_request( $this->data ); |
|
628 | + $this->log_request($this->data); |
|
629 | 629 | |
630 | 630 | // Send out data to the output function |
631 | 631 | $this->output(); |
@@ -655,25 +655,25 @@ discard block |
||
655 | 655 | global $wp_query; |
656 | 656 | |
657 | 657 | // Whitelist our query options |
658 | - $accepted = apply_filters( 'give_api_valid_query_modes', array( |
|
658 | + $accepted = apply_filters('give_api_valid_query_modes', array( |
|
659 | 659 | 'stats', |
660 | 660 | 'forms', |
661 | 661 | 'donors', |
662 | 662 | 'donations', |
663 | - ) ); |
|
663 | + )); |
|
664 | 664 | |
665 | - $query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null; |
|
666 | - $query = str_replace( $this->queried_version . '/', '', $query ); |
|
665 | + $query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null; |
|
666 | + $query = str_replace($this->queried_version.'/', '', $query); |
|
667 | 667 | |
668 | 668 | $error = array(); |
669 | 669 | |
670 | 670 | // Make sure our query is valid |
671 | - if ( ! in_array( $query, $accepted ) ) { |
|
672 | - $error['error'] = __( 'Invalid query.', 'give' ); |
|
671 | + if ( ! in_array($query, $accepted)) { |
|
672 | + $error['error'] = __('Invalid query.', 'give'); |
|
673 | 673 | |
674 | 674 | $this->data = $error; |
675 | 675 | // 400 is Bad Request |
676 | - $this->output( 400 ); |
|
676 | + $this->output(400); |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | $this->endpoint = $query; |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | public function get_paged() { |
691 | 691 | global $wp_query; |
692 | 692 | |
693 | - return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1; |
|
693 | + return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1; |
|
694 | 694 | } |
695 | 695 | |
696 | 696 | |
@@ -705,13 +705,13 @@ discard block |
||
705 | 705 | public function per_page() { |
706 | 706 | global $wp_query; |
707 | 707 | |
708 | - $per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10; |
|
708 | + $per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10; |
|
709 | 709 | |
710 | - if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) { |
|
710 | + if ($per_page < 0 && $this->get_query_mode() == 'donors') { |
|
711 | 711 | $per_page = 99999999; |
712 | 712 | } // End if(). |
713 | 713 | |
714 | - return apply_filters( 'give_api_results_per_page', $per_page ); |
|
714 | + return apply_filters('give_api_results_per_page', $per_page); |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | /** |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | * |
725 | 725 | * @return array $dates |
726 | 726 | */ |
727 | - public function get_dates( $args = array() ) { |
|
727 | + public function get_dates($args = array()) { |
|
728 | 728 | $dates = array(); |
729 | 729 | |
730 | 730 | $defaults = array( |
@@ -735,60 +735,60 @@ discard block |
||
735 | 735 | 'enddate' => null, |
736 | 736 | ); |
737 | 737 | |
738 | - $args = wp_parse_args( $args, $defaults ); |
|
738 | + $args = wp_parse_args($args, $defaults); |
|
739 | 739 | |
740 | - $current_time = current_time( 'timestamp' ); |
|
740 | + $current_time = current_time('timestamp'); |
|
741 | 741 | |
742 | - if ( 'range' === $args['date'] ) { |
|
743 | - $startdate = strtotime( $args['startdate'] ); |
|
744 | - $enddate = strtotime( $args['enddate'] ); |
|
745 | - $dates['day_start'] = date( 'd', $startdate ); |
|
746 | - $dates['day_end'] = date( 'd', $enddate ); |
|
747 | - $dates['m_start'] = date( 'n', $startdate ); |
|
748 | - $dates['m_end'] = date( 'n', $enddate ); |
|
749 | - $dates['year'] = date( 'Y', $startdate ); |
|
750 | - $dates['year_end'] = date( 'Y', $enddate ); |
|
742 | + if ('range' === $args['date']) { |
|
743 | + $startdate = strtotime($args['startdate']); |
|
744 | + $enddate = strtotime($args['enddate']); |
|
745 | + $dates['day_start'] = date('d', $startdate); |
|
746 | + $dates['day_end'] = date('d', $enddate); |
|
747 | + $dates['m_start'] = date('n', $startdate); |
|
748 | + $dates['m_end'] = date('n', $enddate); |
|
749 | + $dates['year'] = date('Y', $startdate); |
|
750 | + $dates['year_end'] = date('Y', $enddate); |
|
751 | 751 | } else { |
752 | 752 | // Modify dates based on predefined ranges |
753 | - switch ( $args['date'] ) : |
|
753 | + switch ($args['date']) : |
|
754 | 754 | |
755 | 755 | case 'this_month' : |
756 | 756 | $dates['day'] = null; |
757 | - $dates['m_start'] = date( 'n', $current_time ); |
|
758 | - $dates['m_end'] = date( 'n', $current_time ); |
|
759 | - $dates['year'] = date( 'Y', $current_time ); |
|
757 | + $dates['m_start'] = date('n', $current_time); |
|
758 | + $dates['m_end'] = date('n', $current_time); |
|
759 | + $dates['year'] = date('Y', $current_time); |
|
760 | 760 | break; |
761 | 761 | |
762 | 762 | case 'last_month' : |
763 | 763 | $dates['day'] = null; |
764 | - $dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1; |
|
764 | + $dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1; |
|
765 | 765 | $dates['m_end'] = $dates['m_start']; |
766 | - $dates['year'] = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time ); |
|
766 | + $dates['year'] = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time); |
|
767 | 767 | break; |
768 | 768 | |
769 | 769 | case 'today' : |
770 | - $dates['day'] = date( 'd', $current_time ); |
|
771 | - $dates['m_start'] = date( 'n', $current_time ); |
|
772 | - $dates['m_end'] = date( 'n', $current_time ); |
|
773 | - $dates['year'] = date( 'Y', $current_time ); |
|
770 | + $dates['day'] = date('d', $current_time); |
|
771 | + $dates['m_start'] = date('n', $current_time); |
|
772 | + $dates['m_end'] = date('n', $current_time); |
|
773 | + $dates['year'] = date('Y', $current_time); |
|
774 | 774 | break; |
775 | 775 | |
776 | 776 | case 'yesterday' : |
777 | 777 | |
778 | - $year = date( 'Y', $current_time ); |
|
779 | - $month = date( 'n', $current_time ); |
|
780 | - $day = date( 'd', $current_time ); |
|
778 | + $year = date('Y', $current_time); |
|
779 | + $month = date('n', $current_time); |
|
780 | + $day = date('d', $current_time); |
|
781 | 781 | |
782 | - if ( $month == 1 && $day == 1 ) { |
|
782 | + if ($month == 1 && $day == 1) { |
|
783 | 783 | |
784 | - $year -= 1; |
|
784 | + $year -= 1; |
|
785 | 785 | $month = 12; |
786 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
786 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
787 | 787 | |
788 | - } elseif ( $month > 1 && $day == 1 ) { |
|
788 | + } elseif ($month > 1 && $day == 1) { |
|
789 | 789 | |
790 | 790 | $month -= 1; |
791 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
791 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
792 | 792 | |
793 | 793 | } else { |
794 | 794 | |
@@ -804,65 +804,65 @@ discard block |
||
804 | 804 | break; |
805 | 805 | |
806 | 806 | case 'this_quarter' : |
807 | - $month_now = date( 'n', $current_time ); |
|
807 | + $month_now = date('n', $current_time); |
|
808 | 808 | |
809 | 809 | $dates['day'] = null; |
810 | 810 | |
811 | - if ( $month_now <= 3 ) { |
|
811 | + if ($month_now <= 3) { |
|
812 | 812 | |
813 | 813 | $dates['m_start'] = 1; |
814 | 814 | $dates['m_end'] = 3; |
815 | - $dates['year'] = date( 'Y', $current_time ); |
|
815 | + $dates['year'] = date('Y', $current_time); |
|
816 | 816 | |
817 | - } elseif ( $month_now <= 6 ) { |
|
817 | + } elseif ($month_now <= 6) { |
|
818 | 818 | |
819 | 819 | $dates['m_start'] = 4; |
820 | 820 | $dates['m_end'] = 6; |
821 | - $dates['year'] = date( 'Y', $current_time ); |
|
821 | + $dates['year'] = date('Y', $current_time); |
|
822 | 822 | |
823 | - } elseif ( $month_now <= 9 ) { |
|
823 | + } elseif ($month_now <= 9) { |
|
824 | 824 | |
825 | 825 | $dates['m_start'] = 7; |
826 | 826 | $dates['m_end'] = 9; |
827 | - $dates['year'] = date( 'Y', $current_time ); |
|
827 | + $dates['year'] = date('Y', $current_time); |
|
828 | 828 | |
829 | 829 | } else { |
830 | 830 | |
831 | 831 | $dates['m_start'] = 10; |
832 | 832 | $dates['m_end'] = 12; |
833 | - $dates['year'] = date( 'Y', $current_time ); |
|
833 | + $dates['year'] = date('Y', $current_time); |
|
834 | 834 | |
835 | 835 | } |
836 | 836 | break; |
837 | 837 | |
838 | 838 | case 'last_quarter' : |
839 | - $month_now = date( 'n', $current_time ); |
|
839 | + $month_now = date('n', $current_time); |
|
840 | 840 | |
841 | 841 | $dates['day'] = null; |
842 | 842 | |
843 | - if ( $month_now <= 3 ) { |
|
843 | + if ($month_now <= 3) { |
|
844 | 844 | |
845 | 845 | $dates['m_start'] = 10; |
846 | 846 | $dates['m_end'] = 12; |
847 | - $dates['year'] = date( 'Y', $current_time ) - 1; // Previous year |
|
847 | + $dates['year'] = date('Y', $current_time) - 1; // Previous year |
|
848 | 848 | |
849 | - } elseif ( $month_now <= 6 ) { |
|
849 | + } elseif ($month_now <= 6) { |
|
850 | 850 | |
851 | 851 | $dates['m_start'] = 1; |
852 | 852 | $dates['m_end'] = 3; |
853 | - $dates['year'] = date( 'Y', $current_time ); |
|
853 | + $dates['year'] = date('Y', $current_time); |
|
854 | 854 | |
855 | - } elseif ( $month_now <= 9 ) { |
|
855 | + } elseif ($month_now <= 9) { |
|
856 | 856 | |
857 | 857 | $dates['m_start'] = 4; |
858 | 858 | $dates['m_end'] = 6; |
859 | - $dates['year'] = date( 'Y', $current_time ); |
|
859 | + $dates['year'] = date('Y', $current_time); |
|
860 | 860 | |
861 | 861 | } else { |
862 | 862 | |
863 | 863 | $dates['m_start'] = 7; |
864 | 864 | $dates['m_end'] = 9; |
865 | - $dates['year'] = date( 'Y', $current_time ); |
|
865 | + $dates['year'] = date('Y', $current_time); |
|
866 | 866 | |
867 | 867 | } |
868 | 868 | break; |
@@ -871,14 +871,14 @@ discard block |
||
871 | 871 | $dates['day'] = null; |
872 | 872 | $dates['m_start'] = null; |
873 | 873 | $dates['m_end'] = null; |
874 | - $dates['year'] = date( 'Y', $current_time ); |
|
874 | + $dates['year'] = date('Y', $current_time); |
|
875 | 875 | break; |
876 | 876 | |
877 | 877 | case 'last_year' : |
878 | 878 | $dates['day'] = null; |
879 | 879 | $dates['m_start'] = null; |
880 | 880 | $dates['m_end'] = null; |
881 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
881 | + $dates['year'] = date('Y', $current_time) - 1; |
|
882 | 882 | break; |
883 | 883 | |
884 | 884 | endswitch; |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | * |
892 | 892 | * @param array $dates The dates used for retrieving earnings. |
893 | 893 | */ |
894 | - return apply_filters( 'give_api_stat_dates', $dates ); |
|
894 | + return apply_filters('give_api_stat_dates', $dates); |
|
895 | 895 | } |
896 | 896 | |
897 | 897 | /** |
@@ -905,84 +905,84 @@ discard block |
||
905 | 905 | * |
906 | 906 | * @return array $donors Multidimensional array of the donors. |
907 | 907 | */ |
908 | - public function get_donors( $donor = null ) { |
|
908 | + public function get_donors($donor = null) { |
|
909 | 909 | |
910 | 910 | $donors = array(); |
911 | 911 | $error = array(); |
912 | - if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) { |
|
912 | + if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) { |
|
913 | 913 | return $donors; |
914 | 914 | } |
915 | 915 | |
916 | 916 | $paged = $this->get_paged(); |
917 | 917 | $per_page = $this->per_page(); |
918 | - $offset = $per_page * ( $paged - 1 ); |
|
918 | + $offset = $per_page * ($paged - 1); |
|
919 | 919 | |
920 | - if ( is_numeric( $donor ) ) { |
|
920 | + if (is_numeric($donor)) { |
|
921 | 921 | $field = 'id'; |
922 | 922 | } else { |
923 | 923 | $field = 'email'; |
924 | 924 | } |
925 | 925 | |
926 | - $donor_query = Give()->donors->get_donors( array( |
|
926 | + $donor_query = Give()->donors->get_donors(array( |
|
927 | 927 | 'number' => $per_page, |
928 | 928 | 'offset' => $offset, |
929 | 929 | $field => $donor, |
930 | - ) ); |
|
930 | + )); |
|
931 | 931 | $donor_count = 0; |
932 | 932 | |
933 | - if ( $donor_query ) { |
|
933 | + if ($donor_query) { |
|
934 | 934 | |
935 | - foreach ( $donor_query as $donor_obj ) { |
|
935 | + foreach ($donor_query as $donor_obj) { |
|
936 | 936 | |
937 | - $names = explode( ' ', $donor_obj->name ); |
|
938 | - $first_name = ! empty( $names[0] ) ? $names[0] : ''; |
|
937 | + $names = explode(' ', $donor_obj->name); |
|
938 | + $first_name = ! empty($names[0]) ? $names[0] : ''; |
|
939 | 939 | $last_name = ''; |
940 | - if ( ! empty( $names[1] ) ) { |
|
941 | - unset( $names[0] ); |
|
942 | - $last_name = implode( ' ', $names ); |
|
940 | + if ( ! empty($names[1])) { |
|
941 | + unset($names[0]); |
|
942 | + $last_name = implode(' ', $names); |
|
943 | 943 | } |
944 | 944 | |
945 | - $donors['donors'][ $donor_count ]['info']['user_id'] = ''; |
|
946 | - $donors['donors'][ $donor_count ]['info']['username'] = ''; |
|
947 | - $donors['donors'][ $donor_count ]['info']['display_name'] = ''; |
|
948 | - $donors['donors'][ $donor_count ]['info']['donor_id'] = $donor_obj->id; |
|
949 | - $donors['donors'][ $donor_count ]['info']['first_name'] = $first_name; |
|
950 | - $donors['donors'][ $donor_count ]['info']['last_name'] = $last_name; |
|
951 | - $donors['donors'][ $donor_count ]['info']['email'] = $donor_obj->email; |
|
945 | + $donors['donors'][$donor_count]['info']['user_id'] = ''; |
|
946 | + $donors['donors'][$donor_count]['info']['username'] = ''; |
|
947 | + $donors['donors'][$donor_count]['info']['display_name'] = ''; |
|
948 | + $donors['donors'][$donor_count]['info']['donor_id'] = $donor_obj->id; |
|
949 | + $donors['donors'][$donor_count]['info']['first_name'] = $first_name; |
|
950 | + $donors['donors'][$donor_count]['info']['last_name'] = $last_name; |
|
951 | + $donors['donors'][$donor_count]['info']['email'] = $donor_obj->email; |
|
952 | 952 | |
953 | - if ( ! empty( $donor_obj->user_id ) ) { |
|
953 | + if ( ! empty($donor_obj->user_id)) { |
|
954 | 954 | |
955 | - $user_data = get_userdata( $donor_obj->user_id ); |
|
955 | + $user_data = get_userdata($donor_obj->user_id); |
|
956 | 956 | |
957 | 957 | // Donor with registered account. |
958 | - $donors['donors'][ $donor_count ]['info']['user_id'] = $donor_obj->user_id; |
|
959 | - $donors['donors'][ $donor_count ]['info']['username'] = $user_data->user_login; |
|
960 | - $donors['donors'][ $donor_count ]['info']['display_name'] = $user_data->display_name; |
|
958 | + $donors['donors'][$donor_count]['info']['user_id'] = $donor_obj->user_id; |
|
959 | + $donors['donors'][$donor_count]['info']['username'] = $user_data->user_login; |
|
960 | + $donors['donors'][$donor_count]['info']['display_name'] = $user_data->display_name; |
|
961 | 961 | |
962 | 962 | } |
963 | 963 | |
964 | - $donors['donors'][ $donor_count ]['stats']['total_donations'] = $donor_obj->purchase_count; |
|
965 | - $donors['donors'][ $donor_count ]['stats']['total_spent'] = $donor_obj->purchase_value; |
|
964 | + $donors['donors'][$donor_count]['stats']['total_donations'] = $donor_obj->purchase_count; |
|
965 | + $donors['donors'][$donor_count]['stats']['total_spent'] = $donor_obj->purchase_value; |
|
966 | 966 | |
967 | 967 | /** @var $donor \Give_Donor */ |
968 | - $donor = new Give_Donor( $donor_obj->id ); |
|
968 | + $donor = new Give_Donor($donor_obj->id); |
|
969 | 969 | |
970 | 970 | // Get donor's addresses. |
971 | - $donors['donors'][ $donor_count ]['address'] = $donor->address; |
|
971 | + $donors['donors'][$donor_count]['address'] = $donor->address; |
|
972 | 972 | |
973 | - $donor_count ++; |
|
973 | + $donor_count++; |
|
974 | 974 | |
975 | 975 | } |
976 | - } elseif ( $donor ) { |
|
976 | + } elseif ($donor) { |
|
977 | 977 | |
978 | 978 | $error['error'] = sprintf( /* translators: %s: donor */ |
979 | - __( 'Donor %s not found.', 'give' ), $donor ); |
|
979 | + __('Donor %s not found.', 'give'), $donor ); |
|
980 | 980 | |
981 | 981 | return $error; |
982 | 982 | |
983 | 983 | } else { |
984 | 984 | |
985 | - $error['error'] = __( 'No donors found.', 'give' ); |
|
985 | + $error['error'] = __('No donors found.', 'give'); |
|
986 | 986 | |
987 | 987 | return $error; |
988 | 988 | |
@@ -1001,37 +1001,37 @@ discard block |
||
1001 | 1001 | * |
1002 | 1002 | * @return array $donors Multidimensional array of the forms. |
1003 | 1003 | */ |
1004 | - public function get_forms( $form = null ) { |
|
1004 | + public function get_forms($form = null) { |
|
1005 | 1005 | |
1006 | 1006 | $forms = array(); |
1007 | 1007 | $error = array(); |
1008 | 1008 | |
1009 | - if ( $form == null ) { |
|
1009 | + if ($form == null) { |
|
1010 | 1010 | $forms['forms'] = array(); |
1011 | 1011 | |
1012 | - $form_list = get_posts( array( |
|
1012 | + $form_list = get_posts(array( |
|
1013 | 1013 | 'post_type' => 'give_forms', |
1014 | 1014 | 'posts_per_page' => $this->per_page(), |
1015 | 1015 | 'suppress_filters' => true, |
1016 | 1016 | 'paged' => $this->get_paged(), |
1017 | - ) ); |
|
1017 | + )); |
|
1018 | 1018 | |
1019 | - if ( $form_list ) { |
|
1019 | + if ($form_list) { |
|
1020 | 1020 | $i = 0; |
1021 | - foreach ( $form_list as $form_info ) { |
|
1022 | - $forms['forms'][ $i ] = $this->get_form_data( $form_info ); |
|
1023 | - $i ++; |
|
1021 | + foreach ($form_list as $form_info) { |
|
1022 | + $forms['forms'][$i] = $this->get_form_data($form_info); |
|
1023 | + $i++; |
|
1024 | 1024 | } |
1025 | 1025 | } |
1026 | 1026 | } else { |
1027 | - if ( get_post_type( $form ) == 'give_forms' ) { |
|
1028 | - $form_info = get_post( $form ); |
|
1027 | + if (get_post_type($form) == 'give_forms') { |
|
1028 | + $form_info = get_post($form); |
|
1029 | 1029 | |
1030 | - $forms['forms'][0] = $this->get_form_data( $form_info ); |
|
1030 | + $forms['forms'][0] = $this->get_form_data($form_info); |
|
1031 | 1031 | |
1032 | 1032 | } else { |
1033 | 1033 | $error['error'] = sprintf( /* translators: %s: form */ |
1034 | - __( 'Form %s not found.', 'give' ), $form ); |
|
1034 | + __('Form %s not found.', 'give'), $form ); |
|
1035 | 1035 | |
1036 | 1036 | return $error; |
1037 | 1037 | } |
@@ -1049,7 +1049,7 @@ discard block |
||
1049 | 1049 | * |
1050 | 1050 | * @return array Array of post data to return back in the API. |
1051 | 1051 | */ |
1052 | - private function get_form_data( $form_info ) { |
|
1052 | + private function get_form_data($form_info) { |
|
1053 | 1053 | |
1054 | 1054 | $form = array(); |
1055 | 1055 | |
@@ -1059,60 +1059,60 @@ discard block |
||
1059 | 1059 | $form['info']['create_date'] = $form_info->post_date; |
1060 | 1060 | $form['info']['modified_date'] = $form_info->post_modified; |
1061 | 1061 | $form['info']['status'] = $form_info->post_status; |
1062 | - $form['info']['link'] = html_entity_decode( $form_info->guid ); |
|
1063 | - $form['info']['content'] = give_get_meta( $form_info->ID, '_give_form_content', true ); |
|
1064 | - $form['info']['thumbnail'] = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) ); |
|
1062 | + $form['info']['link'] = html_entity_decode($form_info->guid); |
|
1063 | + $form['info']['content'] = give_get_meta($form_info->ID, '_give_form_content', true); |
|
1064 | + $form['info']['thumbnail'] = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID)); |
|
1065 | 1065 | |
1066 | - if ( give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) { |
|
1067 | - $form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' ); |
|
1068 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); |
|
1066 | + if (give_is_setting_enabled(give_get_option('categories', 'disabled'))) { |
|
1067 | + $form['info']['category'] = get_the_terms($form_info, 'give_forms_category'); |
|
1068 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); |
|
1069 | 1069 | } |
1070 | - if ( give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) { |
|
1071 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); |
|
1070 | + if (give_is_setting_enabled(give_get_option('tags', 'disabled'))) { |
|
1071 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); |
|
1072 | 1072 | } |
1073 | 1073 | |
1074 | 1074 | // Check whether any goal is to be achieved for the donation form. |
1075 | - $goal_option = give_get_meta( $form_info->ID, '_give_goal_option', true ); |
|
1076 | - $goal_amount = give_get_meta( $form_info->ID, '_give_set_goal', true ); |
|
1077 | - if ( give_is_setting_enabled( $goal_option ) && $goal_amount ) { |
|
1078 | - $total_income = give_get_form_earnings_stats( $form_info->ID ); |
|
1079 | - $goal_percentage_completed = ( $total_income < $goal_amount ) ? round( ( $total_income / $goal_amount ) * 100, 2 ) : 100; |
|
1080 | - $form['goal']['amount'] = isset( $goal_amount ) ? $goal_amount : ''; |
|
1081 | - $form['goal']['percentage_completed'] = isset( $goal_percentage_completed ) ? $goal_percentage_completed : ''; |
|
1075 | + $goal_option = give_get_meta($form_info->ID, '_give_goal_option', true); |
|
1076 | + $goal_amount = give_get_meta($form_info->ID, '_give_set_goal', true); |
|
1077 | + if (give_is_setting_enabled($goal_option) && $goal_amount) { |
|
1078 | + $total_income = give_get_form_earnings_stats($form_info->ID); |
|
1079 | + $goal_percentage_completed = ($total_income < $goal_amount) ? round(($total_income / $goal_amount) * 100, 2) : 100; |
|
1080 | + $form['goal']['amount'] = isset($goal_amount) ? $goal_amount : ''; |
|
1081 | + $form['goal']['percentage_completed'] = isset($goal_percentage_completed) ? $goal_percentage_completed : ''; |
|
1082 | 1082 | } |
1083 | 1083 | |
1084 | - if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) { |
|
1085 | - $form['stats']['total']['donations'] = give_get_form_sales_stats( $form_info->ID ); |
|
1086 | - $form['stats']['total']['earnings'] = give_get_form_earnings_stats( $form_info->ID ); |
|
1087 | - $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID ); |
|
1088 | - $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings( $form_info->ID ); |
|
1084 | + if (user_can($this->user_id, 'view_give_reports') || $this->override) { |
|
1085 | + $form['stats']['total']['donations'] = give_get_form_sales_stats($form_info->ID); |
|
1086 | + $form['stats']['total']['earnings'] = give_get_form_earnings_stats($form_info->ID); |
|
1087 | + $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID); |
|
1088 | + $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings($form_info->ID); |
|
1089 | 1089 | } |
1090 | 1090 | |
1091 | 1091 | $counter = 0; |
1092 | - if ( give_has_variable_prices( $form_info->ID ) ) { |
|
1093 | - foreach ( give_get_variable_prices( $form_info->ID ) as $price ) { |
|
1094 | - $counter ++; |
|
1092 | + if (give_has_variable_prices($form_info->ID)) { |
|
1093 | + foreach (give_get_variable_prices($form_info->ID) as $price) { |
|
1094 | + $counter++; |
|
1095 | 1095 | // multi-level item |
1096 | - $level = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter; |
|
1097 | - $form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount']; |
|
1096 | + $level = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter; |
|
1097 | + $form['pricing'][sanitize_key($level)] = $price['_give_amount']; |
|
1098 | 1098 | |
1099 | 1099 | } |
1100 | 1100 | } else { |
1101 | - $form['pricing']['amount'] = give_get_form_price( $form_info->ID ); |
|
1101 | + $form['pricing']['amount'] = give_get_form_price($form_info->ID); |
|
1102 | 1102 | } |
1103 | 1103 | |
1104 | - if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) { |
|
1104 | + if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) { |
|
1105 | 1105 | |
1106 | 1106 | /** |
1107 | 1107 | * Fires when generating API sensitive data. |
1108 | 1108 | * |
1109 | 1109 | * @since 1.1 |
1110 | 1110 | */ |
1111 | - do_action( 'give_api_sensitive_data' ); |
|
1111 | + do_action('give_api_sensitive_data'); |
|
1112 | 1112 | |
1113 | 1113 | } |
1114 | 1114 | |
1115 | - return apply_filters( 'give_api_forms_form', $form ); |
|
1115 | + return apply_filters('give_api_forms_form', $form); |
|
1116 | 1116 | |
1117 | 1117 | } |
1118 | 1118 | |
@@ -1127,7 +1127,7 @@ discard block |
||
1127 | 1127 | * |
1128 | 1128 | * @return array |
1129 | 1129 | */ |
1130 | - public function get_stats( $args = array() ) { |
|
1130 | + public function get_stats($args = array()) { |
|
1131 | 1131 | $defaults = array( |
1132 | 1132 | 'type' => null, |
1133 | 1133 | 'form' => null, |
@@ -1136,9 +1136,9 @@ discard block |
||
1136 | 1136 | 'enddate' => null, |
1137 | 1137 | ); |
1138 | 1138 | |
1139 | - $args = wp_parse_args( $args, $defaults ); |
|
1139 | + $args = wp_parse_args($args, $defaults); |
|
1140 | 1140 | |
1141 | - $dates = $this->get_dates( $args ); |
|
1141 | + $dates = $this->get_dates($args); |
|
1142 | 1142 | |
1143 | 1143 | $stats = array(); |
1144 | 1144 | $earnings = array( |
@@ -1149,40 +1149,40 @@ discard block |
||
1149 | 1149 | ); |
1150 | 1150 | $error = array(); |
1151 | 1151 | |
1152 | - if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { |
|
1152 | + if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { |
|
1153 | 1153 | return $stats; |
1154 | 1154 | } |
1155 | 1155 | |
1156 | - if ( $args['type'] == 'donations' ) { |
|
1156 | + if ($args['type'] == 'donations') { |
|
1157 | 1157 | |
1158 | - if ( $args['form'] == null ) { |
|
1159 | - if ( $args['date'] == null ) { |
|
1158 | + if ($args['form'] == null) { |
|
1159 | + if ($args['date'] == null) { |
|
1160 | 1160 | $donations = $this->get_default_sales_stats(); |
1161 | - } elseif ( $args['date'] === 'range' ) { |
|
1161 | + } elseif ($args['date'] === 'range') { |
|
1162 | 1162 | // Return donations for a date range. |
1163 | 1163 | // Ensure the end date is later than the start date. |
1164 | - if ( $args['enddate'] < $args['startdate'] ) { |
|
1165 | - $error['error'] = __( 'The end date must be later than the start date.', 'give' ); |
|
1164 | + if ($args['enddate'] < $args['startdate']) { |
|
1165 | + $error['error'] = __('The end date must be later than the start date.', 'give'); |
|
1166 | 1166 | } |
1167 | 1167 | |
1168 | 1168 | // Ensure both the start and end date are specified |
1169 | - if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { |
|
1170 | - $error['error'] = __( 'Invalid or no date range specified.', 'give' ); |
|
1169 | + if (empty($args['startdate']) || empty($args['enddate'])) { |
|
1170 | + $error['error'] = __('Invalid or no date range specified.', 'give'); |
|
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | $total = 0; |
1174 | 1174 | |
1175 | 1175 | // Loop through the years |
1176 | 1176 | $y = $dates['year']; |
1177 | - while ( $y <= $dates['year_end'] ) : |
|
1177 | + while ($y <= $dates['year_end']) : |
|
1178 | 1178 | |
1179 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
1179 | + if ($dates['year'] == $dates['year_end']) { |
|
1180 | 1180 | $month_start = $dates['m_start']; |
1181 | 1181 | $month_end = $dates['m_end']; |
1182 | - } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
1182 | + } elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { |
|
1183 | 1183 | $month_start = $dates['m_start']; |
1184 | 1184 | $month_end = 12; |
1185 | - } elseif ( $y == $dates['year_end'] ) { |
|
1185 | + } elseif ($y == $dates['year_end']) { |
|
1186 | 1186 | $month_start = 1; |
1187 | 1187 | $month_end = $dates['m_end']; |
1188 | 1188 | } else { |
@@ -1191,116 +1191,116 @@ discard block |
||
1191 | 1191 | } |
1192 | 1192 | |
1193 | 1193 | $i = $month_start; |
1194 | - while ( $i <= $month_end ) : |
|
1194 | + while ($i <= $month_end) : |
|
1195 | 1195 | |
1196 | - if ( $i == $dates['m_start'] ) { |
|
1196 | + if ($i == $dates['m_start']) { |
|
1197 | 1197 | $d = $dates['day_start']; |
1198 | 1198 | } else { |
1199 | 1199 | $d = 1; |
1200 | 1200 | } |
1201 | 1201 | |
1202 | - if ( $i == $dates['m_end'] ) { |
|
1202 | + if ($i == $dates['m_end']) { |
|
1203 | 1203 | $num_of_days = $dates['day_end']; |
1204 | 1204 | } else { |
1205 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
1205 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
1206 | 1206 | } |
1207 | 1207 | |
1208 | - while ( $d <= $num_of_days ) : |
|
1209 | - $sale_count = give_get_sales_by_date( $d, $i, $y ); |
|
1210 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
1211 | - if ( ! isset( $donations['sales'][ $date_key ] ) ) { |
|
1212 | - $donations['sales'][ $date_key ] = 0; |
|
1208 | + while ($d <= $num_of_days) : |
|
1209 | + $sale_count = give_get_sales_by_date($d, $i, $y); |
|
1210 | + $date_key = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); |
|
1211 | + if ( ! isset($donations['sales'][$date_key])) { |
|
1212 | + $donations['sales'][$date_key] = 0; |
|
1213 | 1213 | } |
1214 | - $donations['sales'][ $date_key ] += $sale_count; |
|
1214 | + $donations['sales'][$date_key] += $sale_count; |
|
1215 | 1215 | $total += $sale_count; |
1216 | - $d ++; |
|
1216 | + $d++; |
|
1217 | 1217 | endwhile; |
1218 | - $i ++; |
|
1218 | + $i++; |
|
1219 | 1219 | endwhile; |
1220 | 1220 | |
1221 | - $y ++; |
|
1221 | + $y++; |
|
1222 | 1222 | endwhile; |
1223 | 1223 | |
1224 | 1224 | $donations['totals'] = $total; |
1225 | 1225 | } else { |
1226 | - if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { |
|
1226 | + if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { |
|
1227 | 1227 | $donations_count = 0; |
1228 | 1228 | |
1229 | 1229 | // Loop through the months |
1230 | 1230 | $month = $dates['m_start']; |
1231 | 1231 | |
1232 | - while ( $month <= $dates['m_end'] ) : |
|
1233 | - $donations_count += give_get_sales_by_date( null, $month, $dates['year'] ); |
|
1234 | - $month ++; |
|
1232 | + while ($month <= $dates['m_end']) : |
|
1233 | + $donations_count += give_get_sales_by_date(null, $month, $dates['year']); |
|
1234 | + $month++; |
|
1235 | 1235 | endwhile; |
1236 | 1236 | |
1237 | - $donations['donations'][ $args['date'] ] = $donations_count; |
|
1237 | + $donations['donations'][$args['date']] = $donations_count; |
|
1238 | 1238 | } else { |
1239 | - $donations['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); |
|
1239 | + $donations['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']); |
|
1240 | 1240 | } |
1241 | 1241 | }// End if(). |
1242 | - } elseif ( $args['form'] == 'all' ) { |
|
1243 | - $forms = get_posts( array( |
|
1242 | + } elseif ($args['form'] == 'all') { |
|
1243 | + $forms = get_posts(array( |
|
1244 | 1244 | 'post_type' => 'give_forms', |
1245 | 1245 | 'nopaging' => true, |
1246 | - ) ); |
|
1247 | - $i = 0; |
|
1248 | - foreach ( $forms as $form_info ) { |
|
1249 | - $donations['donations'][ $i ] = array( |
|
1250 | - $form_info->post_name => give_get_form_sales_stats( $form_info->ID ), |
|
1246 | + )); |
|
1247 | + $i = 0; |
|
1248 | + foreach ($forms as $form_info) { |
|
1249 | + $donations['donations'][$i] = array( |
|
1250 | + $form_info->post_name => give_get_form_sales_stats($form_info->ID), |
|
1251 | 1251 | ); |
1252 | - $i ++; |
|
1252 | + $i++; |
|
1253 | 1253 | } |
1254 | 1254 | } else { |
1255 | - if ( get_post_type( $args['form'] ) == 'give_forms' ) { |
|
1256 | - $form_info = get_post( $args['form'] ); |
|
1255 | + if (get_post_type($args['form']) == 'give_forms') { |
|
1256 | + $form_info = get_post($args['form']); |
|
1257 | 1257 | $donations['donations'][0] = array( |
1258 | - $form_info->post_name => give_get_form_sales_stats( $args['form'] ), |
|
1258 | + $form_info->post_name => give_get_form_sales_stats($args['form']), |
|
1259 | 1259 | ); |
1260 | 1260 | } else { |
1261 | 1261 | $error['error'] = sprintf( /* translators: %s: form */ |
1262 | - __( 'Form %s not found.', 'give' ), $args['form'] ); |
|
1262 | + __('Form %s not found.', 'give'), $args['form'] ); |
|
1263 | 1263 | } |
1264 | 1264 | }// End if(). |
1265 | 1265 | |
1266 | - if ( ! empty( $error ) ) { |
|
1266 | + if ( ! empty($error)) { |
|
1267 | 1267 | return $error; |
1268 | 1268 | } |
1269 | 1269 | |
1270 | 1270 | return $donations; |
1271 | 1271 | |
1272 | - } elseif ( $args['type'] == 'earnings' ) { |
|
1273 | - if ( $args['form'] == null ) { |
|
1274 | - if ( $args['date'] == null ) { |
|
1272 | + } elseif ($args['type'] == 'earnings') { |
|
1273 | + if ($args['form'] == null) { |
|
1274 | + if ($args['date'] == null) { |
|
1275 | 1275 | $earnings = $this->get_default_earnings_stats(); |
1276 | - } elseif ( $args['date'] === 'range' ) { |
|
1276 | + } elseif ($args['date'] === 'range') { |
|
1277 | 1277 | // Return sales for a date range |
1278 | 1278 | // Ensure the end date is later than the start date |
1279 | - if ( $args['enddate'] < $args['startdate'] ) { |
|
1280 | - $error['error'] = __( 'The end date must be later than the start date.', 'give' ); |
|
1279 | + if ($args['enddate'] < $args['startdate']) { |
|
1280 | + $error['error'] = __('The end date must be later than the start date.', 'give'); |
|
1281 | 1281 | } |
1282 | 1282 | |
1283 | 1283 | // Ensure both the start and end date are specified |
1284 | - if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { |
|
1285 | - $error['error'] = __( 'Invalid or no date range specified.', 'give' ); |
|
1284 | + if (empty($args['startdate']) || empty($args['enddate'])) { |
|
1285 | + $error['error'] = __('Invalid or no date range specified.', 'give'); |
|
1286 | 1286 | } |
1287 | 1287 | |
1288 | 1288 | $total = (float) 0.00; |
1289 | 1289 | |
1290 | 1290 | // Loop through the years |
1291 | 1291 | $y = $dates['year']; |
1292 | - if ( ! isset( $earnings['earnings'] ) ) { |
|
1292 | + if ( ! isset($earnings['earnings'])) { |
|
1293 | 1293 | $earnings['earnings'] = array(); |
1294 | 1294 | } |
1295 | - while ( $y <= $dates['year_end'] ) : |
|
1295 | + while ($y <= $dates['year_end']) : |
|
1296 | 1296 | |
1297 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
1297 | + if ($dates['year'] == $dates['year_end']) { |
|
1298 | 1298 | $month_start = $dates['m_start']; |
1299 | 1299 | $month_end = $dates['m_end']; |
1300 | - } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
1300 | + } elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { |
|
1301 | 1301 | $month_start = $dates['m_start']; |
1302 | 1302 | $month_end = 12; |
1303 | - } elseif ( $y == $dates['year_end'] ) { |
|
1303 | + } elseif ($y == $dates['year_end']) { |
|
1304 | 1304 | $month_start = 1; |
1305 | 1305 | $month_end = $dates['m_end']; |
1306 | 1306 | } else { |
@@ -1309,94 +1309,94 @@ discard block |
||
1309 | 1309 | } |
1310 | 1310 | |
1311 | 1311 | $i = $month_start; |
1312 | - while ( $i <= $month_end ) : |
|
1312 | + while ($i <= $month_end) : |
|
1313 | 1313 | |
1314 | - if ( $i == $dates['m_start'] ) { |
|
1314 | + if ($i == $dates['m_start']) { |
|
1315 | 1315 | $d = $dates['day_start']; |
1316 | 1316 | } else { |
1317 | 1317 | $d = 1; |
1318 | 1318 | } |
1319 | 1319 | |
1320 | - if ( $i == $dates['m_end'] ) { |
|
1320 | + if ($i == $dates['m_end']) { |
|
1321 | 1321 | $num_of_days = $dates['day_end']; |
1322 | 1322 | } else { |
1323 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
1323 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
1324 | 1324 | } |
1325 | 1325 | |
1326 | - while ( $d <= $num_of_days ) : |
|
1327 | - $earnings_stat = give_get_earnings_by_date( $d, $i, $y ); |
|
1328 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
1329 | - if ( ! isset( $earnings['earnings'][ $date_key ] ) ) { |
|
1330 | - $earnings['earnings'][ $date_key ] = 0; |
|
1326 | + while ($d <= $num_of_days) : |
|
1327 | + $earnings_stat = give_get_earnings_by_date($d, $i, $y); |
|
1328 | + $date_key = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); |
|
1329 | + if ( ! isset($earnings['earnings'][$date_key])) { |
|
1330 | + $earnings['earnings'][$date_key] = 0; |
|
1331 | 1331 | } |
1332 | - $earnings['earnings'][ $date_key ] += $earnings_stat; |
|
1332 | + $earnings['earnings'][$date_key] += $earnings_stat; |
|
1333 | 1333 | $total += $earnings_stat; |
1334 | - $d ++; |
|
1334 | + $d++; |
|
1335 | 1335 | endwhile; |
1336 | 1336 | |
1337 | - $i ++; |
|
1337 | + $i++; |
|
1338 | 1338 | endwhile; |
1339 | 1339 | |
1340 | - $y ++; |
|
1340 | + $y++; |
|
1341 | 1341 | endwhile; |
1342 | 1342 | |
1343 | 1343 | $earnings['totals'] = $total; |
1344 | 1344 | } else { |
1345 | - if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { |
|
1345 | + if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { |
|
1346 | 1346 | $earnings_count = (float) 0.00; |
1347 | 1347 | |
1348 | 1348 | // Loop through the months |
1349 | 1349 | $month = $dates['m_start']; |
1350 | 1350 | |
1351 | - while ( $month <= $dates['m_end'] ) : |
|
1352 | - $earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] ); |
|
1353 | - $month ++; |
|
1351 | + while ($month <= $dates['m_end']) : |
|
1352 | + $earnings_count += give_get_earnings_by_date(null, $month, $dates['year']); |
|
1353 | + $month++; |
|
1354 | 1354 | endwhile; |
1355 | 1355 | |
1356 | - $earnings['earnings'][ $args['date'] ] = $earnings_count; |
|
1356 | + $earnings['earnings'][$args['date']] = $earnings_count; |
|
1357 | 1357 | } else { |
1358 | - $earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); |
|
1358 | + $earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']); |
|
1359 | 1359 | } |
1360 | 1360 | }// End if(). |
1361 | - } elseif ( $args['form'] == 'all' ) { |
|
1362 | - $forms = get_posts( array( |
|
1361 | + } elseif ($args['form'] == 'all') { |
|
1362 | + $forms = get_posts(array( |
|
1363 | 1363 | 'post_type' => 'give_forms', |
1364 | 1364 | 'nopaging' => true, |
1365 | - ) ); |
|
1365 | + )); |
|
1366 | 1366 | |
1367 | 1367 | $i = 0; |
1368 | - foreach ( $forms as $form_info ) { |
|
1369 | - $earnings['earnings'][ $i ] = array( |
|
1370 | - $form_info->post_name => give_get_form_earnings_stats( $form_info->ID ), |
|
1368 | + foreach ($forms as $form_info) { |
|
1369 | + $earnings['earnings'][$i] = array( |
|
1370 | + $form_info->post_name => give_get_form_earnings_stats($form_info->ID), |
|
1371 | 1371 | ); |
1372 | - $i ++; |
|
1372 | + $i++; |
|
1373 | 1373 | } |
1374 | 1374 | } else { |
1375 | - if ( get_post_type( $args['form'] ) == 'give_forms' ) { |
|
1376 | - $form_info = get_post( $args['form'] ); |
|
1375 | + if (get_post_type($args['form']) == 'give_forms') { |
|
1376 | + $form_info = get_post($args['form']); |
|
1377 | 1377 | $earnings['earnings'][0] = array( |
1378 | - $form_info->post_name => give_get_form_earnings_stats( $args['form'] ), |
|
1378 | + $form_info->post_name => give_get_form_earnings_stats($args['form']), |
|
1379 | 1379 | ); |
1380 | 1380 | } else { |
1381 | 1381 | $error['error'] = sprintf( /* translators: %s: form */ |
1382 | - __( 'Form %s not found.', 'give' ), $args['form'] ); |
|
1382 | + __('Form %s not found.', 'give'), $args['form'] ); |
|
1383 | 1383 | } |
1384 | 1384 | }// End if(). |
1385 | 1385 | |
1386 | - if ( ! empty( $error ) ) { |
|
1386 | + if ( ! empty($error)) { |
|
1387 | 1387 | return $error; |
1388 | 1388 | } |
1389 | 1389 | |
1390 | 1390 | return $earnings; |
1391 | - } elseif ( $args['type'] == 'donors' ) { |
|
1391 | + } elseif ($args['type'] == 'donors') { |
|
1392 | 1392 | $donors = new Give_DB_Donors(); |
1393 | 1393 | $stats['donations']['total_donors'] = $donors->count(); |
1394 | 1394 | |
1395 | 1395 | return $stats; |
1396 | 1396 | |
1397 | - } elseif ( empty( $args['type'] ) ) { |
|
1398 | - $stats = array_merge( $stats, $this->get_default_sales_stats() ); |
|
1399 | - $stats = array_merge( $stats, $this->get_default_earnings_stats() ); |
|
1397 | + } elseif (empty($args['type'])) { |
|
1398 | + $stats = array_merge($stats, $this->get_default_sales_stats()); |
|
1399 | + $stats = array_merge($stats, $this->get_default_earnings_stats()); |
|
1400 | 1400 | |
1401 | 1401 | return array( |
1402 | 1402 | 'stats' => $stats, |
@@ -1414,7 +1414,7 @@ discard block |
||
1414 | 1414 | * |
1415 | 1415 | * @return array |
1416 | 1416 | */ |
1417 | - public function get_recent_donations( $args = array() ) { |
|
1417 | + public function get_recent_donations($args = array()) { |
|
1418 | 1418 | global $wp_query; |
1419 | 1419 | |
1420 | 1420 | $defaults = array( |
@@ -1424,33 +1424,33 @@ discard block |
||
1424 | 1424 | 'enddate' => null, |
1425 | 1425 | ); |
1426 | 1426 | |
1427 | - $args = wp_parse_args( $args, $defaults ); |
|
1427 | + $args = wp_parse_args($args, $defaults); |
|
1428 | 1428 | |
1429 | 1429 | $donations = array(); |
1430 | 1430 | |
1431 | - if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { |
|
1431 | + if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { |
|
1432 | 1432 | return $donations; |
1433 | 1433 | } |
1434 | 1434 | |
1435 | - if ( isset( $wp_query->query_vars['id'] ) ) { |
|
1435 | + if (isset($wp_query->query_vars['id'])) { |
|
1436 | 1436 | $query = array(); |
1437 | - $query[] = new Give_Payment( $wp_query->query_vars['id'] ); |
|
1438 | - } elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) { |
|
1437 | + $query[] = new Give_Payment($wp_query->query_vars['id']); |
|
1438 | + } elseif (isset($wp_query->query_vars['purchasekey'])) { |
|
1439 | 1439 | $query = array(); |
1440 | - $query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] ); |
|
1441 | - } elseif ( isset( $wp_query->query_vars['email'] ) ) { |
|
1442 | - $args = array( |
|
1440 | + $query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']); |
|
1441 | + } elseif (isset($wp_query->query_vars['email'])) { |
|
1442 | + $args = array( |
|
1443 | 1443 | 'fields' => 'ids', |
1444 | 1444 | 'meta_key' => '_give_payment_donor_email', |
1445 | 1445 | 'meta_value' => $wp_query->query_vars['email'], |
1446 | 1446 | 'number' => $this->per_page(), |
1447 | 1447 | 'page' => $this->get_paged(), |
1448 | 1448 | ); |
1449 | - $query = give_get_payments( $args ); |
|
1450 | - } elseif ( isset( $wp_query->query_vars['date'] ) ) { |
|
1449 | + $query = give_get_payments($args); |
|
1450 | + } elseif (isset($wp_query->query_vars['date'])) { |
|
1451 | 1451 | |
1452 | - $current_time = current_time( 'timestamp' ); |
|
1453 | - $dates = $this->get_dates( $args ); |
|
1452 | + $current_time = current_time('timestamp'); |
|
1453 | + $dates = $this->get_dates($args); |
|
1454 | 1454 | $start_date = ''; |
1455 | 1455 | $end_date = ''; |
1456 | 1456 | |
@@ -1463,27 +1463,27 @@ discard block |
||
1463 | 1463 | * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524) |
1464 | 1464 | * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524) |
1465 | 1465 | */ |
1466 | - switch ( $wp_query->query_vars['date'] ) { |
|
1466 | + switch ($wp_query->query_vars['date']) { |
|
1467 | 1467 | |
1468 | 1468 | case 'today': |
1469 | 1469 | |
1470 | 1470 | // Set and Format Start and End Date to be date of today. |
1471 | - $start_date = $end_date = date( 'Y/m/d', $current_time ); |
|
1471 | + $start_date = $end_date = date('Y/m/d', $current_time); |
|
1472 | 1472 | |
1473 | 1473 | break; |
1474 | 1474 | |
1475 | 1475 | case 'yesterday': |
1476 | 1476 | |
1477 | 1477 | // Set and Format Start and End Date to be date of yesterday. |
1478 | - $start_date = $end_date = date( 'Y/m', $current_time ) . '/' . ( date( 'd', $current_time ) - 1 ); |
|
1478 | + $start_date = $end_date = date('Y/m', $current_time).'/'.(date('d', $current_time) - 1); |
|
1479 | 1479 | |
1480 | 1480 | break; |
1481 | 1481 | |
1482 | 1482 | case 'range': |
1483 | 1483 | |
1484 | 1484 | // Format Start Date and End Date for filtering payment based on date range. |
1485 | - $start_date = $dates['year'] . '/' . $dates['m_start'] . '/' . $dates['day_start']; |
|
1486 | - $end_date = $dates['year_end'] . '/' . $dates['m_end'] . '/' . $dates['day_end']; |
|
1485 | + $start_date = $dates['year'].'/'.$dates['m_start'].'/'.$dates['day_start']; |
|
1486 | + $end_date = $dates['year_end'].'/'.$dates['m_end'].'/'.$dates['day_end']; |
|
1487 | 1487 | |
1488 | 1488 | break; |
1489 | 1489 | |
@@ -1497,22 +1497,22 @@ discard block |
||
1497 | 1497 | 'page' => $this->get_paged(), |
1498 | 1498 | ); |
1499 | 1499 | |
1500 | - $query = give_get_payments( $args ); |
|
1500 | + $query = give_get_payments($args); |
|
1501 | 1501 | } else { |
1502 | 1502 | $args = array( |
1503 | 1503 | 'fields' => 'ids', |
1504 | 1504 | 'number' => $this->per_page(), |
1505 | 1505 | 'page' => $this->get_paged(), |
1506 | 1506 | ); |
1507 | - $query = give_get_payments( $args ); |
|
1507 | + $query = give_get_payments($args); |
|
1508 | 1508 | }// End if(). |
1509 | 1509 | |
1510 | - if ( $query ) { |
|
1510 | + if ($query) { |
|
1511 | 1511 | $i = 0; |
1512 | - foreach ( $query as $payment ) { |
|
1512 | + foreach ($query as $payment) { |
|
1513 | 1513 | |
1514 | - if ( is_numeric( $payment ) ) { |
|
1515 | - $payment = new Give_Payment( $payment ); |
|
1514 | + if (is_numeric($payment)) { |
|
1515 | + $payment = new Give_Payment($payment); |
|
1516 | 1516 | $payment_meta = $payment->get_meta(); |
1517 | 1517 | $user_info = $payment->user_info; |
1518 | 1518 | } |
@@ -1520,43 +1520,43 @@ discard block |
||
1520 | 1520 | $payment_meta = $payment->get_meta(); |
1521 | 1521 | $user_info = $payment->user_info; |
1522 | 1522 | |
1523 | - $first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : ''; |
|
1524 | - $last_name = isset( $user_info['last_name'] ) ? $user_info['last_name'] : ''; |
|
1525 | - |
|
1526 | - $donations['donations'][ $i ]['ID'] = $payment->number; |
|
1527 | - $donations['donations'][ $i ]['transaction_id'] = $payment->transaction_id; |
|
1528 | - $donations['donations'][ $i ]['key'] = $payment->key; |
|
1529 | - $donations['donations'][ $i ]['total'] = $payment->total; |
|
1530 | - $donations['donations'][ $i ]['status'] = give_get_payment_status( $payment, true ); |
|
1531 | - $donations['donations'][ $i ]['gateway'] = $payment->gateway; |
|
1532 | - $donations['donations'][ $i ]['name'] = $first_name . ' ' . $last_name; |
|
1533 | - $donations['donations'][ $i ]['fname'] = $first_name; |
|
1534 | - $donations['donations'][ $i ]['lname'] = $last_name; |
|
1535 | - $donations['donations'][ $i ]['email'] = $payment->email; |
|
1536 | - $donations['donations'][ $i ]['date'] = $payment->date; |
|
1537 | - $donations['donations'][ $i ]['payment_meta'] = array(); |
|
1538 | - |
|
1539 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta; |
|
1540 | - $price = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false; |
|
1541 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
1542 | - |
|
1543 | - $donations['donations'][ $i ]['form']['id'] = $form_id; |
|
1544 | - $donations['donations'][ $i ]['form']['name'] = get_the_title( $payment_meta['form_id'] ); |
|
1545 | - $donations['donations'][ $i ]['form']['price'] = $price; |
|
1546 | - |
|
1547 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1548 | - if ( isset( $payment_meta['price_id'] ) ) { |
|
1549 | - $price_name = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID ); |
|
1550 | - $donations['donations'][ $i ]['form']['price_name'] = $price_name; |
|
1551 | - $donations['donations'][ $i ]['form']['price_id'] = $price_id; |
|
1552 | - $donations['donations'][ $i ]['form']['price'] = give_get_price_option_amount( $form_id, $price_id ); |
|
1523 | + $first_name = isset($user_info['first_name']) ? $user_info['first_name'] : ''; |
|
1524 | + $last_name = isset($user_info['last_name']) ? $user_info['last_name'] : ''; |
|
1525 | + |
|
1526 | + $donations['donations'][$i]['ID'] = $payment->number; |
|
1527 | + $donations['donations'][$i]['transaction_id'] = $payment->transaction_id; |
|
1528 | + $donations['donations'][$i]['key'] = $payment->key; |
|
1529 | + $donations['donations'][$i]['total'] = $payment->total; |
|
1530 | + $donations['donations'][$i]['status'] = give_get_payment_status($payment, true); |
|
1531 | + $donations['donations'][$i]['gateway'] = $payment->gateway; |
|
1532 | + $donations['donations'][$i]['name'] = $first_name.' '.$last_name; |
|
1533 | + $donations['donations'][$i]['fname'] = $first_name; |
|
1534 | + $donations['donations'][$i]['lname'] = $last_name; |
|
1535 | + $donations['donations'][$i]['email'] = $payment->email; |
|
1536 | + $donations['donations'][$i]['date'] = $payment->date; |
|
1537 | + $donations['donations'][$i]['payment_meta'] = array(); |
|
1538 | + |
|
1539 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta; |
|
1540 | + $price = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false; |
|
1541 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
1542 | + |
|
1543 | + $donations['donations'][$i]['form']['id'] = $form_id; |
|
1544 | + $donations['donations'][$i]['form']['name'] = get_the_title($payment_meta['form_id']); |
|
1545 | + $donations['donations'][$i]['form']['price'] = $price; |
|
1546 | + |
|
1547 | + if (give_has_variable_prices($form_id)) { |
|
1548 | + if (isset($payment_meta['price_id'])) { |
|
1549 | + $price_name = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID); |
|
1550 | + $donations['donations'][$i]['form']['price_name'] = $price_name; |
|
1551 | + $donations['donations'][$i]['form']['price_id'] = $price_id; |
|
1552 | + $donations['donations'][$i]['form']['price'] = give_get_price_option_amount($form_id, $price_id); |
|
1553 | 1553 | |
1554 | 1554 | } |
1555 | 1555 | } |
1556 | 1556 | |
1557 | - if( ! empty( $payment_meta ) ) { |
|
1557 | + if ( ! empty($payment_meta)) { |
|
1558 | 1558 | // Add custom meta to API |
1559 | - foreach ( $payment_meta as $meta_key => $meta_value ) { |
|
1559 | + foreach ($payment_meta as $meta_key => $meta_value) { |
|
1560 | 1560 | |
1561 | 1561 | $exceptions = array( |
1562 | 1562 | 'form_title', |
@@ -1569,20 +1569,20 @@ discard block |
||
1569 | 1569 | ); |
1570 | 1570 | |
1571 | 1571 | // Don't clutter up results with dupes |
1572 | - if ( in_array( $meta_key, $exceptions ) ) { |
|
1572 | + if (in_array($meta_key, $exceptions)) { |
|
1573 | 1573 | continue; |
1574 | 1574 | } |
1575 | 1575 | |
1576 | - $donations['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value; |
|
1576 | + $donations['donations'][$i]['payment_meta'][$meta_key] = $meta_value; |
|
1577 | 1577 | |
1578 | 1578 | } |
1579 | 1579 | } |
1580 | 1580 | |
1581 | - $i ++; |
|
1581 | + $i++; |
|
1582 | 1582 | }// End foreach(). |
1583 | 1583 | }// End if(). |
1584 | 1584 | |
1585 | - return apply_filters( 'give_api_donations_endpoint', $donations ); |
|
1585 | + return apply_filters('give_api_donations_endpoint', $donations); |
|
1586 | 1586 | } |
1587 | 1587 | |
1588 | 1588 | /** |
@@ -1598,9 +1598,9 @@ discard block |
||
1598 | 1598 | public function get_output_format() { |
1599 | 1599 | global $wp_query; |
1600 | 1600 | |
1601 | - $format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json'; |
|
1601 | + $format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json'; |
|
1602 | 1602 | |
1603 | - return apply_filters( 'give_api_output_format', $format ); |
|
1603 | + return apply_filters('give_api_output_format', $format); |
|
1604 | 1604 | } |
1605 | 1605 | |
1606 | 1606 | |
@@ -1616,8 +1616,8 @@ discard block |
||
1616 | 1616 | * |
1617 | 1617 | * @return void |
1618 | 1618 | */ |
1619 | - private function log_request( $data = array() ) { |
|
1620 | - if ( ! $this->log_requests ) { |
|
1619 | + private function log_request($data = array()) { |
|
1620 | + if ( ! $this->log_requests) { |
|
1621 | 1621 | return; |
1622 | 1622 | } |
1623 | 1623 | |
@@ -1628,37 +1628,37 @@ discard block |
||
1628 | 1628 | |
1629 | 1629 | $query = array( |
1630 | 1630 | 'give-api' => $wp_query->query_vars['give-api'], |
1631 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, |
|
1632 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, |
|
1633 | - 'query' => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null, |
|
1634 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, |
|
1635 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, |
|
1636 | - 'donor' => isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null, |
|
1637 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
1638 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
1639 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
1640 | - 'id' => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null, |
|
1641 | - 'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null, |
|
1642 | - 'email' => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null, |
|
1631 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, |
|
1632 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, |
|
1633 | + 'query' => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null, |
|
1634 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, |
|
1635 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, |
|
1636 | + 'donor' => isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null, |
|
1637 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
1638 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
1639 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
1640 | + 'id' => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null, |
|
1641 | + 'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null, |
|
1642 | + 'email' => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null, |
|
1643 | 1643 | ); |
1644 | 1644 | |
1645 | 1645 | $log_data = array( |
1646 | 1646 | 'log_type' => 'api_request', |
1647 | - 'post_excerpt' => http_build_query( $query ), |
|
1648 | - 'post_content' => ! empty( $data['error'] ) ? $data['error'] : '', |
|
1647 | + 'post_excerpt' => http_build_query($query), |
|
1648 | + 'post_content' => ! empty($data['error']) ? $data['error'] : '', |
|
1649 | 1649 | ); |
1650 | 1650 | |
1651 | 1651 | $log_meta = array( |
1652 | - 'api_query' => http_build_query( $query ), |
|
1652 | + 'api_query' => http_build_query($query), |
|
1653 | 1653 | 'request_ip' => give_get_ip(), |
1654 | 1654 | 'user' => $this->user_id, |
1655 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, |
|
1656 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, |
|
1655 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, |
|
1656 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, |
|
1657 | 1657 | 'time' => $data['request_speed'], |
1658 | 1658 | 'version' => $this->get_queried_version(), |
1659 | 1659 | ); |
1660 | 1660 | |
1661 | - Give()->logs->insert_log( $log_data, $log_meta ); |
|
1661 | + Give()->logs->insert_log($log_data, $log_meta); |
|
1662 | 1662 | } |
1663 | 1663 | |
1664 | 1664 | |
@@ -1682,11 +1682,11 @@ discard block |
||
1682 | 1682 | * |
1683 | 1683 | * @param int $status_code |
1684 | 1684 | */ |
1685 | - public function output( $status_code = 200 ) { |
|
1685 | + public function output($status_code = 200) { |
|
1686 | 1686 | |
1687 | 1687 | $format = $this->get_output_format(); |
1688 | 1688 | |
1689 | - status_header( $status_code ); |
|
1689 | + status_header($status_code); |
|
1690 | 1690 | |
1691 | 1691 | /** |
1692 | 1692 | * Fires before outputting the API. |
@@ -1697,25 +1697,25 @@ discard block |
||
1697 | 1697 | * @param Give_API $this The Give_API object. |
1698 | 1698 | * @param string $format Output format, XML or JSON. Default is JSON. |
1699 | 1699 | */ |
1700 | - do_action( 'give_api_output_before', $this->data, $this, $format ); |
|
1700 | + do_action('give_api_output_before', $this->data, $this, $format); |
|
1701 | 1701 | |
1702 | - switch ( $format ) : |
|
1702 | + switch ($format) : |
|
1703 | 1703 | |
1704 | 1704 | case 'xml' : |
1705 | 1705 | |
1706 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php'; |
|
1707 | - $xml = Array2XML::createXML( 'give', $this->data ); |
|
1706 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php'; |
|
1707 | + $xml = Array2XML::createXML('give', $this->data); |
|
1708 | 1708 | echo $xml->saveXML(); |
1709 | 1709 | |
1710 | 1710 | break; |
1711 | 1711 | |
1712 | 1712 | case 'json' : |
1713 | 1713 | |
1714 | - header( 'Content-Type: application/json' ); |
|
1715 | - if ( ! empty( $this->pretty_print ) ) { |
|
1716 | - echo json_encode( $this->data, $this->pretty_print ); |
|
1714 | + header('Content-Type: application/json'); |
|
1715 | + if ( ! empty($this->pretty_print)) { |
|
1716 | + echo json_encode($this->data, $this->pretty_print); |
|
1717 | 1717 | } else { |
1718 | - echo json_encode( $this->data ); |
|
1718 | + echo json_encode($this->data); |
|
1719 | 1719 | } |
1720 | 1720 | |
1721 | 1721 | break; |
@@ -1730,7 +1730,7 @@ discard block |
||
1730 | 1730 | * @param array $data Response data to return. |
1731 | 1731 | * @param Give_API $this The Give_API object. |
1732 | 1732 | */ |
1733 | - do_action( "give_api_output_{$format}", $this->data, $this ); |
|
1733 | + do_action("give_api_output_{$format}", $this->data, $this); |
|
1734 | 1734 | |
1735 | 1735 | break; |
1736 | 1736 | |
@@ -1745,7 +1745,7 @@ discard block |
||
1745 | 1745 | * @param Give_API $this The Give_API object. |
1746 | 1746 | * @param string $format Output format, XML or JSON. Default is JSON. |
1747 | 1747 | */ |
1748 | - do_action( 'give_api_output_after', $this->data, $this, $format ); |
|
1748 | + do_action('give_api_output_after', $this->data, $this, $format); |
|
1749 | 1749 | |
1750 | 1750 | give_die(); |
1751 | 1751 | } |
@@ -1762,41 +1762,41 @@ discard block |
||
1762 | 1762 | * |
1763 | 1763 | * @return void |
1764 | 1764 | */ |
1765 | - function user_key_field( $user ) { |
|
1765 | + function user_key_field($user) { |
|
1766 | 1766 | |
1767 | - if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) { |
|
1767 | + if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) { |
|
1768 | 1768 | |
1769 | - $user = get_userdata( $user->ID ); |
|
1769 | + $user = get_userdata($user->ID); |
|
1770 | 1770 | ?> |
1771 | 1771 | <table class="form-table"> |
1772 | 1772 | <tbody> |
1773 | 1773 | <tr> |
1774 | 1774 | <th> |
1775 | - <?php _e( 'Give API Keys', 'give' ); ?> |
|
1775 | + <?php _e('Give API Keys', 'give'); ?> |
|
1776 | 1776 | </th> |
1777 | 1777 | <td> |
1778 | 1778 | <?php |
1779 | - $public_key = $this->get_user_public_key( $user->ID ); |
|
1780 | - $secret_key = $this->get_user_secret_key( $user->ID ); |
|
1779 | + $public_key = $this->get_user_public_key($user->ID); |
|
1780 | + $secret_key = $this->get_user_secret_key($user->ID); |
|
1781 | 1781 | ?> |
1782 | - <?php if ( empty( $user->give_user_public_key ) ) { ?> |
|
1782 | + <?php if (empty($user->give_user_public_key)) { ?> |
|
1783 | 1783 | <input name="give_set_api_key" type="checkbox" id="give_set_api_key" /> |
1784 | - <span class="description"><?php _e( 'Generate API Key', 'give' ); ?></span> |
|
1784 | + <span class="description"><?php _e('Generate API Key', 'give'); ?></span> |
|
1785 | 1785 | <?php } else { ?> |
1786 | - <strong style="display:inline-block; width: 125px;"><?php _e( 'Public key:', 'give' ); ?> |
|
1786 | + <strong style="display:inline-block; width: 125px;"><?php _e('Public key:', 'give'); ?> |
|
1787 | 1787 | </strong> |
1788 | - <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>" /> |
|
1788 | + <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>" /> |
|
1789 | 1789 | <br /> |
1790 | - <strong style="display:inline-block; width: 125px;"><?php _e( 'Secret key:', 'give' ); ?> |
|
1790 | + <strong style="display:inline-block; width: 125px;"><?php _e('Secret key:', 'give'); ?> |
|
1791 | 1791 | </strong> |
1792 | - <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>" /> |
|
1792 | + <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>" /> |
|
1793 | 1793 | <br /> |
1794 | - <strong style="display:inline-block; width: 125px;"><?php _e( 'Token:', 'give' ); ?> |
|
1794 | + <strong style="display:inline-block; width: 125px;"><?php _e('Token:', 'give'); ?> |
|
1795 | 1795 | </strong> |
1796 | - <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>" /> |
|
1796 | + <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>" /> |
|
1797 | 1797 | <br /> |
1798 | 1798 | <input name="give_revoke_api_key" type="checkbox" id="give_revoke_api_key" /> |
1799 | - <span class="description"><label for="give_revoke_api_key"><?php _e( 'Revoke API Keys', 'give' ); ?></label></span> |
|
1799 | + <span class="description"><label for="give_revoke_api_key"><?php _e('Revoke API Keys', 'give'); ?></label></span> |
|
1800 | 1800 | <?php } ?> |
1801 | 1801 | </td> |
1802 | 1802 | </tr> |
@@ -1815,61 +1815,61 @@ discard block |
||
1815 | 1815 | * |
1816 | 1816 | * @return void |
1817 | 1817 | */ |
1818 | - public function process_api_key( $args ) { |
|
1818 | + public function process_api_key($args) { |
|
1819 | 1819 | |
1820 | - if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) { |
|
1821 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( |
|
1820 | + if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) { |
|
1821 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array( |
|
1822 | 1822 | 'response' => 403, |
1823 | - ) ); |
|
1823 | + )); |
|
1824 | 1824 | } |
1825 | 1825 | |
1826 | - if ( empty( $args['user_id'] ) ) { |
|
1827 | - wp_die( __( 'User ID Required.', 'give' ), __( 'Error', 'give' ), array( |
|
1826 | + if (empty($args['user_id'])) { |
|
1827 | + wp_die(__('User ID Required.', 'give'), __('Error', 'give'), array( |
|
1828 | 1828 | 'response' => 401, |
1829 | - ) ); |
|
1829 | + )); |
|
1830 | 1830 | } |
1831 | 1831 | |
1832 | - if ( is_numeric( $args['user_id'] ) ) { |
|
1833 | - $user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id(); |
|
1832 | + if (is_numeric($args['user_id'])) { |
|
1833 | + $user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id(); |
|
1834 | 1834 | } else { |
1835 | - $userdata = get_user_by( 'login', $args['user_id'] ); |
|
1835 | + $userdata = get_user_by('login', $args['user_id']); |
|
1836 | 1836 | $user_id = $userdata->ID; |
1837 | 1837 | } |
1838 | - $process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false; |
|
1838 | + $process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false; |
|
1839 | 1839 | |
1840 | - if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) { |
|
1841 | - wp_die( sprintf( /* translators: %s: process */ |
|
1842 | - __( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), __( 'Error', 'give' ), array( |
|
1840 | + if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) { |
|
1841 | + wp_die(sprintf( /* translators: %s: process */ |
|
1842 | + __('You do not have permission to %s API keys for this user.', 'give'), $process ), __('Error', 'give'), array( |
|
1843 | 1843 | 'response' => 403, |
1844 | - ) ); |
|
1845 | - } elseif ( ! current_user_can( 'manage_give_settings' ) ) { |
|
1846 | - wp_die( sprintf( /* translators: %s: process */ |
|
1847 | - __( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), __( 'Error', 'give' ), array( |
|
1844 | + )); |
|
1845 | + } elseif ( ! current_user_can('manage_give_settings')) { |
|
1846 | + wp_die(sprintf( /* translators: %s: process */ |
|
1847 | + __('You do not have permission to %s API keys for this user.', 'give'), $process ), __('Error', 'give'), array( |
|
1848 | 1848 | 'response' => 403, |
1849 | - ) ); |
|
1849 | + )); |
|
1850 | 1850 | } |
1851 | 1851 | |
1852 | - switch ( $process ) { |
|
1852 | + switch ($process) { |
|
1853 | 1853 | case 'generate': |
1854 | - if ( $this->generate_api_key( $user_id ) ) { |
|
1855 | - Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) ); |
|
1856 | - wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1854 | + if ($this->generate_api_key($user_id)) { |
|
1855 | + Give_Cache::delete(Give_Cache::get_key('give_total_api_keys')); |
|
1856 | + wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1857 | 1857 | exit(); |
1858 | 1858 | } else { |
1859 | - wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1859 | + wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1860 | 1860 | exit(); |
1861 | 1861 | } |
1862 | 1862 | break; |
1863 | 1863 | case 'regenerate': |
1864 | - $this->generate_api_key( $user_id, true ); |
|
1865 | - Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) ); |
|
1866 | - wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1864 | + $this->generate_api_key($user_id, true); |
|
1865 | + Give_Cache::delete(Give_Cache::get_key('give_total_api_keys')); |
|
1866 | + wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1867 | 1867 | exit(); |
1868 | 1868 | break; |
1869 | 1869 | case 'revoke': |
1870 | - $this->revoke_api_key( $user_id ); |
|
1871 | - Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) ); |
|
1872 | - wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1870 | + $this->revoke_api_key($user_id); |
|
1871 | + Give_Cache::delete(Give_Cache::get_key('give_total_api_keys')); |
|
1872 | + wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1873 | 1873 | exit(); |
1874 | 1874 | break; |
1875 | 1875 | default; |
@@ -1888,59 +1888,59 @@ discard block |
||
1888 | 1888 | * |
1889 | 1889 | * @return boolean True if (re)generated successfully, false otherwise. |
1890 | 1890 | */ |
1891 | - public function generate_api_key( $user_id = 0, $regenerate = false ) { |
|
1891 | + public function generate_api_key($user_id = 0, $regenerate = false) { |
|
1892 | 1892 | |
1893 | 1893 | // Bail out, if user doesn't exists. |
1894 | - if ( empty( $user_id ) ) { |
|
1894 | + if (empty($user_id)) { |
|
1895 | 1895 | return false; |
1896 | 1896 | } |
1897 | 1897 | |
1898 | - $user = get_userdata( $user_id ); |
|
1898 | + $user = get_userdata($user_id); |
|
1899 | 1899 | |
1900 | 1900 | // Bail Out, if user object doesn't exists. |
1901 | - if ( ! $user ) { |
|
1901 | + if ( ! $user) { |
|
1902 | 1902 | return false; |
1903 | 1903 | } |
1904 | 1904 | |
1905 | 1905 | $new_public_key = ''; |
1906 | 1906 | $new_secret_key = ''; |
1907 | 1907 | |
1908 | - if( ! empty( $_POST['from'] ) && 'profile' === $_POST['from'] ) { |
|
1908 | + if ( ! empty($_POST['from']) && 'profile' === $_POST['from']) { |
|
1909 | 1909 | // For User Profile Page. |
1910 | - if( ! empty( $_POST['give_set_api_key'] ) ) { |
|
1910 | + if ( ! empty($_POST['give_set_api_key'])) { |
|
1911 | 1911 | // Generate API Key from User Profile page. |
1912 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
1913 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
1914 | - } elseif ( ! empty( $_POST['give_revoke_api_key'] ) ) { |
|
1912 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
1913 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
1914 | + } elseif ( ! empty($_POST['give_revoke_api_key'])) { |
|
1915 | 1915 | // Revoke API Key from User Profile page. |
1916 | - $this->revoke_api_key( $user->ID ); |
|
1916 | + $this->revoke_api_key($user->ID); |
|
1917 | 1917 | } else { |
1918 | 1918 | return false; |
1919 | 1919 | } |
1920 | 1920 | } else { |
1921 | 1921 | // For Tools > API page. |
1922 | - $public_key = $this->get_user_public_key( $user_id ); |
|
1922 | + $public_key = $this->get_user_public_key($user_id); |
|
1923 | 1923 | |
1924 | - if ( empty( $public_key ) && ! $regenerate ) { |
|
1924 | + if (empty($public_key) && ! $regenerate) { |
|
1925 | 1925 | // Generating API for first time. |
1926 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
1927 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
1928 | - } elseif ( $public_key && $regenerate ) { |
|
1926 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
1927 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
1928 | + } elseif ($public_key && $regenerate) { |
|
1929 | 1929 | // API Key already exists and Regenerating API Key. |
1930 | - $this->revoke_api_key( $user->ID ); |
|
1931 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
1932 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
1933 | - } elseif ( ! empty( $public_key ) && ! $regenerate ) { |
|
1930 | + $this->revoke_api_key($user->ID); |
|
1931 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
1932 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
1933 | + } elseif ( ! empty($public_key) && ! $regenerate) { |
|
1934 | 1934 | // Doing nothing, when API Key exists but still try to generate again instead of regenerating. |
1935 | 1935 | return false; |
1936 | 1936 | } else { |
1937 | 1937 | // Revoke API Key. |
1938 | - $this->revoke_api_key( $user->ID ); |
|
1938 | + $this->revoke_api_key($user->ID); |
|
1939 | 1939 | } |
1940 | 1940 | } |
1941 | 1941 | |
1942 | - update_user_meta( $user_id, $new_public_key, 'give_user_public_key' ); |
|
1943 | - update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' ); |
|
1942 | + update_user_meta($user_id, $new_public_key, 'give_user_public_key'); |
|
1943 | + update_user_meta($user_id, $new_secret_key, 'give_user_secret_key'); |
|
1944 | 1944 | |
1945 | 1945 | return true; |
1946 | 1946 | } |
@@ -1955,26 +1955,26 @@ discard block |
||
1955 | 1955 | * |
1956 | 1956 | * @return bool |
1957 | 1957 | */ |
1958 | - public function revoke_api_key( $user_id = 0 ) { |
|
1958 | + public function revoke_api_key($user_id = 0) { |
|
1959 | 1959 | |
1960 | - if ( empty( $user_id ) ) { |
|
1960 | + if (empty($user_id)) { |
|
1961 | 1961 | return false; |
1962 | 1962 | } |
1963 | 1963 | |
1964 | - $user = get_userdata( $user_id ); |
|
1964 | + $user = get_userdata($user_id); |
|
1965 | 1965 | |
1966 | - if ( ! $user ) { |
|
1966 | + if ( ! $user) { |
|
1967 | 1967 | return false; |
1968 | 1968 | } |
1969 | 1969 | |
1970 | - $public_key = $this->get_user_public_key( $user_id ); |
|
1971 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
1972 | - if ( ! empty( $public_key ) ) { |
|
1973 | - Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_' . $public_key ) ) ); |
|
1974 | - Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_public_key' . $user_id ) ) ); |
|
1975 | - Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_secret_key' . $user_id ) ) ); |
|
1976 | - delete_user_meta( $user_id, $public_key ); |
|
1977 | - delete_user_meta( $user_id, $secret_key ); |
|
1970 | + $public_key = $this->get_user_public_key($user_id); |
|
1971 | + $secret_key = $this->get_user_secret_key($user_id); |
|
1972 | + if ( ! empty($public_key)) { |
|
1973 | + Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_'.$public_key))); |
|
1974 | + Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_public_key'.$user_id))); |
|
1975 | + Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_secret_key'.$user_id))); |
|
1976 | + delete_user_meta($user_id, $public_key); |
|
1977 | + delete_user_meta($user_id, $secret_key); |
|
1978 | 1978 | } else { |
1979 | 1979 | return false; |
1980 | 1980 | } |
@@ -1996,9 +1996,9 @@ discard block |
||
1996 | 1996 | * |
1997 | 1997 | * @return string |
1998 | 1998 | */ |
1999 | - private function generate_public_key( $user_email = '' ) { |
|
2000 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
2001 | - $public = hash( 'md5', $user_email . $auth_key . date( 'U' ) ); |
|
1999 | + private function generate_public_key($user_email = '') { |
|
2000 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
2001 | + $public = hash('md5', $user_email.$auth_key.date('U')); |
|
2002 | 2002 | |
2003 | 2003 | return $public; |
2004 | 2004 | } |
@@ -2013,9 +2013,9 @@ discard block |
||
2013 | 2013 | * |
2014 | 2014 | * @return string |
2015 | 2015 | */ |
2016 | - private function generate_private_key( $user_id = 0 ) { |
|
2017 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
2018 | - $secret = hash( 'md5', $user_id . $auth_key . date( 'U' ) ); |
|
2016 | + private function generate_private_key($user_id = 0) { |
|
2017 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
2018 | + $secret = hash('md5', $user_id.$auth_key.date('U')); |
|
2019 | 2019 | |
2020 | 2020 | return $secret; |
2021 | 2021 | } |
@@ -2030,8 +2030,8 @@ discard block |
||
2030 | 2030 | * |
2031 | 2031 | * @return string |
2032 | 2032 | */ |
2033 | - public function get_token( $user_id = 0 ) { |
|
2034 | - return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) ); |
|
2033 | + public function get_token($user_id = 0) { |
|
2034 | + return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id)); |
|
2035 | 2035 | } |
2036 | 2036 | |
2037 | 2037 | /** |
@@ -2045,9 +2045,9 @@ discard block |
||
2045 | 2045 | |
2046 | 2046 | // Default sales return |
2047 | 2047 | $donations = array(); |
2048 | - $donations['donations']['today'] = $this->stats->get_sales( 0, 'today' ); |
|
2049 | - $donations['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' ); |
|
2050 | - $donations['donations']['last_month'] = $this->stats->get_sales( 0, 'last_month' ); |
|
2048 | + $donations['donations']['today'] = $this->stats->get_sales(0, 'today'); |
|
2049 | + $donations['donations']['current_month'] = $this->stats->get_sales(0, 'this_month'); |
|
2050 | + $donations['donations']['last_month'] = $this->stats->get_sales(0, 'last_month'); |
|
2051 | 2051 | $donations['donations']['totals'] = give_get_total_donations(); |
2052 | 2052 | |
2053 | 2053 | return $donations; |
@@ -2064,9 +2064,9 @@ discard block |
||
2064 | 2064 | |
2065 | 2065 | // Default earnings return |
2066 | 2066 | $earnings = array(); |
2067 | - $earnings['earnings']['today'] = $this->stats->get_earnings( 0, 'today' ); |
|
2068 | - $earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' ); |
|
2069 | - $earnings['earnings']['last_month'] = $this->stats->get_earnings( 0, 'last_month' ); |
|
2067 | + $earnings['earnings']['today'] = $this->stats->get_earnings(0, 'today'); |
|
2068 | + $earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month'); |
|
2069 | + $earnings['earnings']['last_month'] = $this->stats->get_earnings(0, 'last_month'); |
|
2070 | 2070 | $earnings['earnings']['totals'] = give_get_total_earnings(); |
2071 | 2071 | |
2072 | 2072 | return $earnings; |
@@ -2086,25 +2086,25 @@ discard block |
||
2086 | 2086 | * |
2087 | 2087 | * @return string The API key/secret for the user supplied |
2088 | 2088 | */ |
2089 | - public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) { |
|
2089 | + public function api_key_backwards_compat($check, $object_id, $meta_key, $single) { |
|
2090 | 2090 | |
2091 | - if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) { |
|
2091 | + if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') { |
|
2092 | 2092 | return $check; |
2093 | 2093 | } |
2094 | 2094 | |
2095 | 2095 | $return = $check; |
2096 | 2096 | |
2097 | - switch ( $meta_key ) { |
|
2097 | + switch ($meta_key) { |
|
2098 | 2098 | case 'give_user_public_key': |
2099 | - $return = Give()->api->get_user_public_key( $object_id ); |
|
2099 | + $return = Give()->api->get_user_public_key($object_id); |
|
2100 | 2100 | break; |
2101 | 2101 | case 'give_user_secret_key': |
2102 | - $return = Give()->api->get_user_secret_key( $object_id ); |
|
2102 | + $return = Give()->api->get_user_secret_key($object_id); |
|
2103 | 2103 | break; |
2104 | 2104 | } |
2105 | 2105 | |
2106 | - if ( ! $single ) { |
|
2107 | - $return = array( $return ); |
|
2106 | + if ( ! $single) { |
|
2107 | + $return = array($return); |
|
2108 | 2108 | } |
2109 | 2109 | |
2110 | 2110 | return $return; |
@@ -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 | |
@@ -62,51 +62,51 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return bool If the gravatar exists or not |
64 | 64 | */ |
65 | - public function validate_gravatar( $id_or_email ) { |
|
65 | + public function validate_gravatar($id_or_email) { |
|
66 | 66 | //id or email code borrowed from wp-includes/pluggable.php |
67 | 67 | $email = ''; |
68 | - if ( is_numeric( $id_or_email ) ) { |
|
68 | + if (is_numeric($id_or_email)) { |
|
69 | 69 | $id = (int) $id_or_email; |
70 | - $user = get_userdata( $id ); |
|
71 | - if ( $user ) { |
|
70 | + $user = get_userdata($id); |
|
71 | + if ($user) { |
|
72 | 72 | $email = $user->user_email; |
73 | 73 | } |
74 | - } elseif ( is_object( $id_or_email ) ) { |
|
74 | + } elseif (is_object($id_or_email)) { |
|
75 | 75 | // No avatar for pingbacks or trackbacks |
76 | - $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); |
|
77 | - if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) { |
|
76 | + $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment')); |
|
77 | + if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) { |
|
78 | 78 | return false; |
79 | 79 | } |
80 | 80 | |
81 | - if ( ! empty( $id_or_email->user_id ) ) { |
|
81 | + if ( ! empty($id_or_email->user_id)) { |
|
82 | 82 | $id = (int) $id_or_email->user_id; |
83 | - $user = get_userdata( $id ); |
|
84 | - if ( $user ) { |
|
83 | + $user = get_userdata($id); |
|
84 | + if ($user) { |
|
85 | 85 | $email = $user->user_email; |
86 | 86 | } |
87 | - } elseif ( ! empty( $id_or_email->comment_author_email ) ) { |
|
87 | + } elseif ( ! empty($id_or_email->comment_author_email)) { |
|
88 | 88 | $email = $id_or_email->comment_author_email; |
89 | 89 | } |
90 | 90 | } else { |
91 | 91 | $email = $id_or_email; |
92 | 92 | } |
93 | 93 | |
94 | - $hashkey = md5( strtolower( trim( $email ) ) ); |
|
95 | - $uri = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404'; |
|
94 | + $hashkey = md5(strtolower(trim($email))); |
|
95 | + $uri = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404'; |
|
96 | 96 | |
97 | - $data = Give_Cache::get_group( $hashkey ); |
|
97 | + $data = Give_Cache::get_group($hashkey); |
|
98 | 98 | |
99 | - if ( is_null( $data ) ) { |
|
100 | - $response = wp_remote_head( $uri ); |
|
101 | - if ( is_wp_error( $response ) ) { |
|
99 | + if (is_null($data)) { |
|
100 | + $response = wp_remote_head($uri); |
|
101 | + if (is_wp_error($response)) { |
|
102 | 102 | $data = 'not200'; |
103 | 103 | } else { |
104 | 104 | $data = $response['response']['code']; |
105 | 105 | } |
106 | - Give_Cache::set_group( $hashkey, $data, $group = '', $expire = 60 * 5 ); |
|
106 | + Give_Cache::set_group($hashkey, $data, $group = '', $expire = 60 * 5); |
|
107 | 107 | |
108 | 108 | } |
109 | - if ( $data == '200' ) { |
|
109 | + if ($data == '200') { |
|
110 | 110 | return true; |
111 | 111 | } else { |
112 | 112 | return false; |
@@ -123,15 +123,15 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return array IDs if logs, false otherwise |
125 | 125 | */ |
126 | - public function get_log_ids( $form_id = '' ) { |
|
126 | + public function get_log_ids($form_id = '') { |
|
127 | 127 | // get log for this form |
128 | - $logs = Give()->logs->get_logs( $form_id ); |
|
128 | + $logs = Give()->logs->get_logs($form_id); |
|
129 | 129 | |
130 | - if ( $logs ) { |
|
130 | + if ($logs) { |
|
131 | 131 | $log_ids = array(); |
132 | 132 | |
133 | 133 | // make an array with all the donor IDs |
134 | - foreach ( $logs as $log ) { |
|
134 | + foreach ($logs as $log) { |
|
135 | 135 | $log_ids[] = $log->ID; |
136 | 136 | } |
137 | 137 | |
@@ -152,51 +152,51 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return mixed |
154 | 154 | */ |
155 | - public function get_payment_ids( $form_id = '' ) { |
|
155 | + public function get_payment_ids($form_id = '') { |
|
156 | 156 | |
157 | 157 | $give_options = give_get_settings(); |
158 | 158 | |
159 | - $log_ids = $this->get_log_ids( $form_id ); |
|
159 | + $log_ids = $this->get_log_ids($form_id); |
|
160 | 160 | |
161 | - if ( $log_ids ) { |
|
161 | + if ($log_ids) { |
|
162 | 162 | |
163 | 163 | $payment_ids = array(); |
164 | 164 | |
165 | - foreach ( $log_ids as $id ) { |
|
165 | + foreach ($log_ids as $id) { |
|
166 | 166 | // get the payment ID for each corresponding log ID |
167 | - $payment_ids[] = give_get_meta( $id, '_give_log_payment_id', true ); |
|
167 | + $payment_ids[] = give_get_meta($id, '_give_log_payment_id', true); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | // remove donors who have donated more than once so we can have unique avatars |
171 | 171 | $unique_emails = array(); |
172 | 172 | |
173 | - foreach ( $payment_ids as $key => $id ) { |
|
173 | + foreach ($payment_ids as $key => $id) { |
|
174 | 174 | |
175 | - $email = give_get_meta( $id, '_give_payment_donor_email', true ); |
|
175 | + $email = give_get_meta($id, '_give_payment_donor_email', true); |
|
176 | 176 | |
177 | - if ( isset ( $give_options['give_donors_gravatars_has_gravatar_account'] ) ) { |
|
178 | - if ( ! $this->validate_gravatar( $email ) ) { |
|
177 | + if (isset ($give_options['give_donors_gravatars_has_gravatar_account'])) { |
|
178 | + if ( ! $this->validate_gravatar($email)) { |
|
179 | 179 | continue; |
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
183 | - $unique_emails[ $id ] = give_get_meta( $id, '_give_payment_donor_email', true ); |
|
183 | + $unique_emails[$id] = give_get_meta($id, '_give_payment_donor_email', true); |
|
184 | 184 | |
185 | 185 | } |
186 | 186 | |
187 | 187 | $unique_ids = array(); |
188 | 188 | |
189 | 189 | // strip duplicate emails |
190 | - $unique_emails = array_unique( $unique_emails ); |
|
190 | + $unique_emails = array_unique($unique_emails); |
|
191 | 191 | |
192 | 192 | // convert the unique IDs back into simple array |
193 | - foreach ( $unique_emails as $id => $email ) { |
|
193 | + foreach ($unique_emails as $id => $email) { |
|
194 | 194 | $unique_ids[] = $id; |
195 | 195 | } |
196 | 196 | |
197 | 197 | // randomize the payment IDs if enabled |
198 | - if ( isset( $give_options['give_donors_gravatars_random_gravatars'] ) ) { |
|
199 | - shuffle( $unique_ids ); |
|
198 | + if (isset($give_options['give_donors_gravatars_random_gravatars'])) { |
|
199 | + shuffle($unique_ids); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | // return our unique IDs |
@@ -217,22 +217,22 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @return string |
219 | 219 | */ |
220 | - public function gravatars( $form_id = false, $title = '' ) { |
|
220 | + public function gravatars($form_id = false, $title = '') { |
|
221 | 221 | |
222 | 222 | // unique $payment_ids |
223 | - $payment_ids = $this->get_payment_ids( $form_id ); |
|
223 | + $payment_ids = $this->get_payment_ids($form_id); |
|
224 | 224 | |
225 | 225 | $give_options = give_get_settings(); |
226 | 226 | |
227 | 227 | // return if no ID |
228 | - if ( ! $form_id ) { |
|
228 | + if ( ! $form_id) { |
|
229 | 229 | return; |
230 | 230 | } |
231 | 231 | |
232 | 232 | // minimum amount of donations before showing gravatars |
233 | 233 | // if the number of items in array is not greater or equal to the number specified, then exit |
234 | - if ( isset( $give_options['give_donors_gravatars_min_purchases_required'] ) && '' != $give_options['give_donors_gravatars_min_purchases_required'] ) { |
|
235 | - if ( ! ( count( $payment_ids ) >= $give_options['give_donors_gravatars_min_purchases_required'] ) ) { |
|
234 | + if (isset($give_options['give_donors_gravatars_min_purchases_required']) && '' != $give_options['give_donors_gravatars_min_purchases_required']) { |
|
235 | + if ( ! (count($payment_ids) >= $give_options['give_donors_gravatars_min_purchases_required'])) { |
|
236 | 236 | return; |
237 | 237 | } |
238 | 238 | } |
@@ -243,28 +243,28 @@ discard block |
||
243 | 243 | echo '<div id="give-purchase-gravatars">'; |
244 | 244 | |
245 | 245 | |
246 | - if ( isset ( $title ) ) { |
|
246 | + if (isset ($title)) { |
|
247 | 247 | |
248 | - if ( $title ) { |
|
249 | - echo apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $title ) . '</h3>' ); |
|
250 | - } elseif ( isset( $give_options['give_donors_gravatars_heading'] ) ) { |
|
251 | - echo apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $give_options['give_donors_gravatars_heading'] ) . '</h2>' ); |
|
248 | + if ($title) { |
|
249 | + echo apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($title).'</h3>'); |
|
250 | + } elseif (isset($give_options['give_donors_gravatars_heading'])) { |
|
251 | + echo apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($give_options['give_donors_gravatars_heading']).'</h2>'); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | } |
255 | 255 | echo '<ul class="give-purchase-gravatars-list">'; |
256 | 256 | $i = 0; |
257 | 257 | |
258 | - if ( $payment_ids ) { |
|
259 | - foreach ( $payment_ids as $id ) { |
|
258 | + if ($payment_ids) { |
|
259 | + foreach ($payment_ids as $id) { |
|
260 | 260 | |
261 | 261 | // Give saves a blank option even when the control is turned off, hence the extra check |
262 | - if ( isset( $give_options['give_donors_gravatars_maximum_number'] ) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number'] ) { |
|
262 | + if (isset($give_options['give_donors_gravatars_maximum_number']) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number']) { |
|
263 | 263 | continue; |
264 | 264 | } |
265 | 265 | |
266 | 266 | // get the payment meta |
267 | - $payment_meta = give_get_meta( $id, '_give_payment_meta', true ); |
|
267 | + $payment_meta = give_get_meta($id, '_give_payment_meta', true); |
|
268 | 268 | |
269 | 269 | $user_info = $payment_meta['user_info']; |
270 | 270 | |
@@ -272,21 +272,21 @@ discard block |
||
272 | 272 | $name = $user_info['first_name']; |
273 | 273 | |
274 | 274 | // get donor's email |
275 | - $email = give_get_meta( $id, '_give_payment_donor_email', true ); |
|
275 | + $email = give_get_meta($id, '_give_payment_donor_email', true); |
|
276 | 276 | |
277 | 277 | // set gravatar size and provide filter |
278 | - $size = isset( $give_options['give_donors_gravatars_gravatar_size'] ) ? apply_filters( 'give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size'] ) : ''; |
|
278 | + $size = isset($give_options['give_donors_gravatars_gravatar_size']) ? apply_filters('give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size']) : ''; |
|
279 | 279 | |
280 | 280 | // default image |
281 | - $default_image = apply_filters( 'give_donors_gravatars_gravatar_default_image', false ); |
|
281 | + $default_image = apply_filters('give_donors_gravatars_gravatar_default_image', false); |
|
282 | 282 | |
283 | 283 | // assemble output |
284 | 284 | $output .= '<li>'; |
285 | 285 | |
286 | - $output .= get_avatar( $email, $size, $default_image, $name ); |
|
286 | + $output .= get_avatar($email, $size, $default_image, $name); |
|
287 | 287 | $output .= '</li>'; |
288 | 288 | |
289 | - $i ++; |
|
289 | + $i++; |
|
290 | 290 | |
291 | 291 | } // end foreach |
292 | 292 | } |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | echo '</ul>'; |
296 | 296 | echo '</div>'; |
297 | 297 | |
298 | - return apply_filters( 'give_donors_gravatars', ob_get_clean() ); |
|
298 | + return apply_filters('give_donors_gravatars', ob_get_clean()); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * @return void |
308 | 308 | */ |
309 | 309 | public function register_widget() { |
310 | - register_widget( 'Give_Donors_Gravatars_Widget' ); |
|
310 | + register_widget('Give_Donors_Gravatars_Widget'); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -321,19 +321,19 @@ discard block |
||
321 | 321 | * |
322 | 322 | * @return string |
323 | 323 | */ |
324 | - public function shortcode( $atts, $content = null ) { |
|
324 | + public function shortcode($atts, $content = null) { |
|
325 | 325 | |
326 | - $atts = shortcode_atts( array( |
|
326 | + $atts = shortcode_atts(array( |
|
327 | 327 | 'id' => '', |
328 | 328 | 'title' => '' |
329 | - ), $atts, 'give_donors_gravatars' ); |
|
329 | + ), $atts, 'give_donors_gravatars'); |
|
330 | 330 | |
331 | 331 | // if no ID is passed on single give_forms pages, get the correct ID |
332 | - if ( is_singular( 'give_forms' ) ) { |
|
332 | + if (is_singular('give_forms')) { |
|
333 | 333 | $id = get_the_ID(); |
334 | 334 | } |
335 | 335 | |
336 | - $content = $this->gravatars( $atts['id'], $atts['title'] ); |
|
336 | + $content = $this->gravatars($atts['id'], $atts['title']); |
|
337 | 337 | |
338 | 338 | return $content; |
339 | 339 | |
@@ -349,56 +349,56 @@ discard block |
||
349 | 349 | * |
350 | 350 | * @return array Gravatar settings. |
351 | 351 | */ |
352 | - public function settings( $settings ) { |
|
352 | + public function settings($settings) { |
|
353 | 353 | |
354 | 354 | $give_gravatar_settings = array( |
355 | 355 | array( |
356 | - 'name' => esc_html__( 'Donator Gravatars', 'give' ), |
|
356 | + 'name' => esc_html__('Donator Gravatars', 'give'), |
|
357 | 357 | 'desc' => '<hr>', |
358 | 358 | 'id' => 'give_title', |
359 | 359 | 'type' => 'give_title' |
360 | 360 | ), |
361 | 361 | array( |
362 | - 'name' => esc_html__( 'Heading', 'give' ), |
|
363 | - 'desc' => esc_html__( 'The heading to display above the Gravatars.', 'give' ), |
|
362 | + 'name' => esc_html__('Heading', 'give'), |
|
363 | + 'desc' => esc_html__('The heading to display above the Gravatars.', 'give'), |
|
364 | 364 | 'type' => 'text', |
365 | 365 | 'id' => 'give_donors_gravatars_heading' |
366 | 366 | ), |
367 | 367 | array( |
368 | - 'name' => esc_html__( 'Gravatar Size', 'give' ), |
|
369 | - 'desc' => esc_html__( 'The size of each Gravatar in pixels (512px maximum).', 'give' ), |
|
368 | + 'name' => esc_html__('Gravatar Size', 'give'), |
|
369 | + 'desc' => esc_html__('The size of each Gravatar in pixels (512px maximum).', 'give'), |
|
370 | 370 | 'type' => 'text_small', |
371 | 371 | 'id' => 'give_donors_gravatars_gravatar_size', |
372 | 372 | 'default' => '64' |
373 | 373 | ), |
374 | 374 | array( |
375 | - 'name' => esc_html__( 'Minimum Unique Donations Required', 'give' ), |
|
376 | - 'desc' => esc_html__( 'The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ), |
|
375 | + 'name' => esc_html__('Minimum Unique Donations Required', 'give'), |
|
376 | + 'desc' => esc_html__('The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give'), |
|
377 | 377 | 'type' => 'text_small', |
378 | 378 | 'id' => 'give_donors_gravatars_min_purchases_required', |
379 | 379 | ), |
380 | 380 | array( |
381 | - 'name' => esc_html__( 'Maximum Gravatars To Show', 'give' ), |
|
382 | - 'desc' => esc_html__( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ), |
|
381 | + 'name' => esc_html__('Maximum Gravatars To Show', 'give'), |
|
382 | + 'desc' => esc_html__('The maximum number of gravatars to show. Leave blank for no limit.', 'give'), |
|
383 | 383 | 'type' => 'text', |
384 | 384 | 'id' => 'give_donors_gravatars_maximum_number', |
385 | 385 | 'default' => '20', |
386 | 386 | ), |
387 | 387 | array( |
388 | - 'name' => esc_html__( 'Gravatar Visibility', 'give' ), |
|
389 | - 'desc' => esc_html__( 'Show only donors with a Gravatar account.', 'give' ), |
|
388 | + 'name' => esc_html__('Gravatar Visibility', 'give'), |
|
389 | + 'desc' => esc_html__('Show only donors with a Gravatar account.', 'give'), |
|
390 | 390 | 'id' => 'give_donors_gravatars_has_gravatar_account', |
391 | 391 | 'type' => 'checkbox', |
392 | 392 | ), |
393 | 393 | array( |
394 | - 'name' => esc_html__( 'Randomize Gravatars', 'give' ), |
|
395 | - 'desc' => esc_html__( 'Randomize the Gravatars.', 'give' ), |
|
394 | + 'name' => esc_html__('Randomize Gravatars', 'give'), |
|
395 | + 'desc' => esc_html__('Randomize the Gravatars.', 'give'), |
|
396 | 396 | 'id' => 'give_donors_gravatars_random_gravatars', |
397 | 397 | 'type' => 'checkbox', |
398 | 398 | ), |
399 | 399 | ); |
400 | 400 | |
401 | - return array_merge( $settings, $give_gravatar_settings ); |
|
401 | + return array_merge($settings, $give_gravatar_settings); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | } |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | // widget settings |
425 | 425 | $widget_ops = array( |
426 | 426 | 'classname' => 'give-donors-gravatars', |
427 | - 'description' => esc_html__( 'Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give' ), |
|
427 | + 'description' => esc_html__('Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give'), |
|
428 | 428 | ); |
429 | 429 | |
430 | 430 | // widget control settings |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | // create the widget |
438 | 438 | parent::__construct( |
439 | 439 | 'give_donors_gravatars_widget', |
440 | - esc_html__( 'Give Donors Gravatars', 'give' ), |
|
440 | + esc_html__('Give Donors Gravatars', 'give'), |
|
441 | 441 | $widget_ops, |
442 | 442 | $control_ops |
443 | 443 | ); |
@@ -457,29 +457,29 @@ discard block |
||
457 | 457 | * |
458 | 458 | * @return void |
459 | 459 | */ |
460 | - public function widget( $args, $instance ) { |
|
460 | + public function widget($args, $instance) { |
|
461 | 461 | |
462 | 462 | //@TODO: Don't extract it!!! |
463 | - extract( $args ); |
|
463 | + extract($args); |
|
464 | 464 | |
465 | - if ( ! is_singular( 'give_forms' ) ) { |
|
465 | + if ( ! is_singular('give_forms')) { |
|
466 | 466 | return; |
467 | 467 | } |
468 | 468 | |
469 | 469 | // Variables from widget settings |
470 | - $title = apply_filters( 'widget_title', $instance['title'] ); |
|
470 | + $title = apply_filters('widget_title', $instance['title']); |
|
471 | 471 | |
472 | 472 | // Used by themes. Opens the widget |
473 | 473 | echo $before_widget; |
474 | 474 | |
475 | 475 | // Display the widget title |
476 | - if ( $title ) { |
|
477 | - echo $before_title . $title . $after_title; |
|
476 | + if ($title) { |
|
477 | + echo $before_title.$title.$after_title; |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | $gravatars = new Give_Donors_Gravatars(); |
481 | 481 | |
482 | - echo $gravatars->gravatars( get_the_ID(), null ); // remove title |
|
482 | + echo $gravatars->gravatars(get_the_ID(), null); // remove title |
|
483 | 483 | |
484 | 484 | // Used by themes. Closes the widget |
485 | 485 | echo $after_widget; |
@@ -499,11 +499,11 @@ discard block |
||
499 | 499 | * |
500 | 500 | * @return array Updated settings to save. |
501 | 501 | */ |
502 | - public function update( $new_instance, $old_instance ) { |
|
502 | + public function update($new_instance, $old_instance) { |
|
503 | 503 | |
504 | 504 | $instance = $old_instance; |
505 | 505 | |
506 | - $instance['title'] = strip_tags( $new_instance['title'] ); |
|
506 | + $instance['title'] = strip_tags($new_instance['title']); |
|
507 | 507 | |
508 | 508 | return $instance; |
509 | 509 | |
@@ -521,19 +521,19 @@ discard block |
||
521 | 521 | * |
522 | 522 | * @return void |
523 | 523 | */ |
524 | - public function form( $instance ) { |
|
524 | + public function form($instance) { |
|
525 | 525 | |
526 | 526 | // Set up some default widget settings. |
527 | 527 | $defaults = array( |
528 | 528 | 'title' => '', |
529 | 529 | ); |
530 | 530 | |
531 | - $instance = wp_parse_args( (array) $instance, $defaults ); ?> |
|
531 | + $instance = wp_parse_args((array) $instance, $defaults); ?> |
|
532 | 532 | |
533 | 533 | <!-- Title --> |
534 | 534 | <p> |
535 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ) ?></label> |
|
536 | - <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
535 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give') ?></label> |
|
536 | + <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
537 | 537 | </p> |
538 | 538 | |
539 | 539 | <?php |
@@ -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 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @return static |
52 | 52 | */ |
53 | 53 | public static function get_instance() { |
54 | - if ( null === static::$instance ) { |
|
54 | + if (null === static::$instance) { |
|
55 | 55 | self::$instance = new static(); |
56 | 56 | self::$instance->setup(); |
57 | 57 | } |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | * @since 1.8.13 |
67 | 67 | */ |
68 | 68 | private function setup() { |
69 | - add_filter( 'cron_schedules', array( self::$instance, '__add_schedules' ) ); |
|
70 | - add_action( 'wp', array( self::$instance, '__schedule_events' ) ); |
|
69 | + add_filter('cron_schedules', array(self::$instance, '__add_schedules')); |
|
70 | + add_action('wp', array(self::$instance, '__schedule_events')); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return array An array of non-default cron schedules. |
82 | 82 | */ |
83 | - public function __add_schedules( $schedules = array() ) { |
|
83 | + public function __add_schedules($schedules = array()) { |
|
84 | 84 | // Adds once weekly to the existing schedules. |
85 | 85 | $schedules['weekly'] = array( |
86 | 86 | 'interval' => 604800, |
87 | - 'display' => __( 'Once Weekly', 'give' ), |
|
87 | + 'display' => __('Once Weekly', 'give'), |
|
88 | 88 | ); |
89 | 89 | |
90 | 90 | return $schedules; |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | * @return void |
113 | 113 | */ |
114 | 114 | private function weekly_events() { |
115 | - if ( ! wp_next_scheduled( 'give_weekly_scheduled_events' ) ) { |
|
116 | - wp_schedule_event( current_time( 'timestamp' ), 'weekly', 'give_weekly_scheduled_events' ); |
|
115 | + if ( ! wp_next_scheduled('give_weekly_scheduled_events')) { |
|
116 | + wp_schedule_event(current_time('timestamp'), 'weekly', 'give_weekly_scheduled_events'); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * @return void |
127 | 127 | */ |
128 | 128 | private function daily_events() { |
129 | - if ( ! wp_next_scheduled( 'give_daily_scheduled_events' ) ) { |
|
130 | - wp_schedule_event( current_time( 'timestamp' ), 'daily', 'give_daily_scheduled_events' ); |
|
129 | + if ( ! wp_next_scheduled('give_daily_scheduled_events')) { |
|
130 | + wp_schedule_event(current_time('timestamp'), 'daily', 'give_daily_scheduled_events'); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @return string |
143 | 143 | */ |
144 | - public static function get_cron_action( $type = 'weekly' ) { |
|
145 | - switch ( $type ) { |
|
144 | + public static function get_cron_action($type = 'weekly') { |
|
145 | + switch ($type) { |
|
146 | 146 | case 'daily': |
147 | 147 | $cron_action = 'give_daily_scheduled_events'; |
148 | 148 | break; |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | * @param $action |
165 | 165 | * @param string $type |
166 | 166 | */ |
167 | - private static function add_event( $action, $type = 'weekly' ) { |
|
168 | - $cron_event = self::get_cron_action( $type ); |
|
169 | - add_action( $cron_event, $action ); |
|
167 | + private static function add_event($action, $type = 'weekly') { |
|
168 | + $cron_event = self::get_cron_action($type); |
|
169 | + add_action($cron_event, $action); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @param $action |
179 | 179 | */ |
180 | - public static function add_weekly_event( $action ) { |
|
181 | - self::add_event( $action, 'weekly' ); |
|
180 | + public static function add_weekly_event($action) { |
|
181 | + self::add_event($action, 'weekly'); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @param $action |
191 | 191 | */ |
192 | - public static function add_daily_event( $action ) { |
|
193 | - self::add_event( $action, 'daily' ); |
|
192 | + public static function add_daily_event($action) { |
|
193 | + self::add_event($action, 'daily'); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 |
@@ -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,16 +98,16 @@ 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 | 105 | // Bailout. |
106 | - if ( empty( $row_id ) ) { |
|
106 | + if (empty($row_id)) { |
|
107 | 107 | return null; |
108 | 108 | } |
109 | 109 | |
110 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
110 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @return object |
123 | 123 | */ |
124 | - public function get_by( $column, $row_id ) { |
|
124 | + public function get_by($column, $row_id) { |
|
125 | 125 | /* @var WPDB $wpdb */ |
126 | 126 | global $wpdb; |
127 | 127 | |
128 | 128 | // Bailout. |
129 | - if ( empty( $column ) || empty( $row_id ) ) { |
|
129 | + if (empty($column) || empty($row_id)) { |
|
130 | 130 | return null; |
131 | 131 | } |
132 | 132 | |
133 | - $column = esc_sql( $column ); |
|
133 | + $column = esc_sql($column); |
|
134 | 134 | |
135 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
135 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id)); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -146,18 +146,18 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return string Column value. |
148 | 148 | */ |
149 | - public function get_column( $column, $row_id ) { |
|
149 | + public function get_column($column, $row_id) { |
|
150 | 150 | /* @var WPDB $wpdb */ |
151 | 151 | global $wpdb; |
152 | 152 | |
153 | 153 | // Bailout. |
154 | - if ( empty( $column ) || empty( $row_id ) ) { |
|
154 | + if (empty($column) || empty($row_id)) { |
|
155 | 155 | return null; |
156 | 156 | } |
157 | 157 | |
158 | - $column = esc_sql( $column ); |
|
158 | + $column = esc_sql($column); |
|
159 | 159 | |
160 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
160 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -172,19 +172,19 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return string |
174 | 174 | */ |
175 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
175 | + public function get_column_by($column, $column_where, $column_value) { |
|
176 | 176 | /* @var WPDB $wpdb */ |
177 | 177 | global $wpdb; |
178 | 178 | |
179 | 179 | // Bailout. |
180 | - if ( empty( $column ) || empty( $column_where ) || empty( $column_value ) ) { |
|
180 | + if (empty($column) || empty($column_where) || empty($column_value)) { |
|
181 | 181 | return null; |
182 | 182 | } |
183 | 183 | |
184 | - $column_where = esc_sql( $column_where ); |
|
185 | - $column = esc_sql( $column ); |
|
184 | + $column_where = esc_sql($column_where); |
|
185 | + $column = esc_sql($column); |
|
186 | 186 | |
187 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
187 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value)); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -198,12 +198,12 @@ discard block |
||
198 | 198 | * |
199 | 199 | * @return int |
200 | 200 | */ |
201 | - public function insert( $data, $type = '' ) { |
|
201 | + public function insert($data, $type = '') { |
|
202 | 202 | /* @var WPDB $wpdb */ |
203 | 203 | global $wpdb; |
204 | 204 | |
205 | 205 | // Set default values. |
206 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
206 | + $data = wp_parse_args($data, $this->get_column_defaults()); |
|
207 | 207 | |
208 | 208 | /** |
209 | 209 | * Fires before inserting data to the database. |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @param array $data |
214 | 214 | */ |
215 | - do_action( "give_pre_insert_{$type}", $data ); |
|
215 | + do_action("give_pre_insert_{$type}", $data); |
|
216 | 216 | |
217 | 217 | // Initialise column format array |
218 | 218 | $column_formats = $this->get_columns(); |
@@ -221,13 +221,13 @@ discard block |
||
221 | 221 | // $data = array_change_key_case( $data ); |
222 | 222 | |
223 | 223 | // White list columns |
224 | - $data = array_intersect_key( $data, $column_formats ); |
|
224 | + $data = array_intersect_key($data, $column_formats); |
|
225 | 225 | |
226 | 226 | // Reorder $column_formats to match the order of columns given in $data |
227 | - $data_keys = array_keys( $data ); |
|
228 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
227 | + $data_keys = array_keys($data); |
|
228 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
229 | 229 | |
230 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
230 | + $wpdb->insert($this->table_name, $data, $column_formats); |
|
231 | 231 | |
232 | 232 | /** |
233 | 233 | * Fires after inserting data to the database. |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @param int $insert_id |
238 | 238 | * @param array $data |
239 | 239 | */ |
240 | - do_action( "give_post_insert_{$type}", $wpdb->insert_id, $data ); |
|
240 | + do_action("give_post_insert_{$type}", $wpdb->insert_id, $data); |
|
241 | 241 | |
242 | 242 | return $wpdb->insert_id; |
243 | 243 | } |
@@ -254,18 +254,18 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @return bool |
256 | 256 | */ |
257 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
257 | + public function update($row_id, $data = array(), $where = '') { |
|
258 | 258 | /* @var WPDB $wpdb */ |
259 | 259 | global $wpdb; |
260 | 260 | |
261 | 261 | // Row ID must be positive integer |
262 | - $row_id = absint( $row_id ); |
|
262 | + $row_id = absint($row_id); |
|
263 | 263 | |
264 | - if ( empty( $row_id ) ) { |
|
264 | + if (empty($row_id)) { |
|
265 | 265 | return false; |
266 | 266 | } |
267 | 267 | |
268 | - if ( empty( $where ) ) { |
|
268 | + if (empty($where)) { |
|
269 | 269 | $where = $this->primary_key; |
270 | 270 | } |
271 | 271 | |
@@ -273,16 +273,16 @@ discard block |
||
273 | 273 | $column_formats = $this->get_columns(); |
274 | 274 | |
275 | 275 | // Force fields to lower case |
276 | - $data = array_change_key_case( $data ); |
|
276 | + $data = array_change_key_case($data); |
|
277 | 277 | |
278 | 278 | // White list columns |
279 | - $data = array_intersect_key( $data, $column_formats ); |
|
279 | + $data = array_intersect_key($data, $column_formats); |
|
280 | 280 | |
281 | 281 | // Reorder $column_formats to match the order of columns given in $data |
282 | - $data_keys = array_keys( $data ); |
|
283 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
282 | + $data_keys = array_keys($data); |
|
283 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
284 | 284 | |
285 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
285 | + if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) { |
|
286 | 286 | return false; |
287 | 287 | } |
288 | 288 | |
@@ -299,18 +299,18 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @return bool |
301 | 301 | */ |
302 | - public function delete( $row_id = 0 ) { |
|
302 | + public function delete($row_id = 0) { |
|
303 | 303 | /* @var WPDB $wpdb */ |
304 | 304 | global $wpdb; |
305 | 305 | |
306 | 306 | // Row ID must be positive integer |
307 | - $row_id = absint( $row_id ); |
|
307 | + $row_id = absint($row_id); |
|
308 | 308 | |
309 | - if ( empty( $row_id ) ) { |
|
309 | + if (empty($row_id)) { |
|
310 | 310 | return false; |
311 | 311 | } |
312 | 312 | |
313 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
313 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) { |
|
314 | 314 | return false; |
315 | 315 | } |
316 | 316 | |
@@ -327,13 +327,13 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @return bool If the table name exists. |
329 | 329 | */ |
330 | - public function table_exists( $table ) { |
|
330 | + public function table_exists($table) { |
|
331 | 331 | /* @var WPDB $wpdb */ |
332 | 332 | global $wpdb; |
333 | 333 | |
334 | - $table = sanitize_text_field( $table ); |
|
334 | + $table = sanitize_text_field($table); |
|
335 | 335 | |
336 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
336 | + return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table; |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
@@ -347,16 +347,16 @@ discard block |
||
347 | 347 | * |
348 | 348 | * @return bool |
349 | 349 | */ |
350 | - public function does_column_exist( $column_name ) { |
|
350 | + public function does_column_exist($column_name) { |
|
351 | 351 | |
352 | 352 | global $wpdb; |
353 | 353 | |
354 | - $column = $wpdb->get_results( $wpdb->prepare( |
|
354 | + $column = $wpdb->get_results($wpdb->prepare( |
|
355 | 355 | "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = %s AND TABLE_NAME = %s AND COLUMN_NAME = %s ", |
356 | 356 | DB_NAME, $this->table_name, $column_name |
357 | - ) ); |
|
357 | + )); |
|
358 | 358 | |
359 | - if ( ! empty( $column ) ) { |
|
359 | + if ( ! empty($column)) { |
|
360 | 360 | return true; |
361 | 361 | } |
362 | 362 | |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * @return bool Returns if the customers table was installed and upgrade routine run. |
373 | 373 | */ |
374 | 374 | public function installed() { |
375 | - return $this->table_exists( $this->table_name ); |
|
375 | + return $this->table_exists($this->table_name); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | /** |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | * @access public |
383 | 383 | */ |
384 | 384 | public function register_table() { |
385 | - $current_version = get_option( $this->table_name . '_db_version' ); |
|
386 | - if ( ! $current_version || version_compare( $current_version, $this->version, '<' ) ) { |
|
385 | + $current_version = get_option($this->table_name.'_db_version'); |
|
386 | + if ( ! $current_version || version_compare($current_version, $this->version, '<')) { |
|
387 | 387 | $this->create_table(); |
388 | 388 | } |
389 | 389 | } |
@@ -408,23 +408,23 @@ discard block |
||
408 | 408 | * |
409 | 409 | * @return int|bool The normalized log ID or false if it's found to not be valid. |
410 | 410 | */ |
411 | - public function sanitize_id( $id ) { |
|
412 | - if ( ! is_numeric( $id ) ) { |
|
411 | + public function sanitize_id($id) { |
|
412 | + if ( ! is_numeric($id)) { |
|
413 | 413 | return false; |
414 | 414 | } |
415 | 415 | |
416 | 416 | $id = (int) $id; |
417 | 417 | |
418 | 418 | // We were given a non positive number. |
419 | - if ( absint( $id ) !== $id ) { |
|
419 | + if (absint($id) !== $id) { |
|
420 | 420 | return false; |
421 | 421 | } |
422 | 422 | |
423 | - if ( empty( $id ) ) { |
|
423 | + if (empty($id)) { |
|
424 | 424 | return false; |
425 | 425 | } |
426 | 426 | |
427 | - return absint( $id ); |
|
427 | + return absint($id); |
|
428 | 428 | |
429 | 429 | } |
430 | 430 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,26 +25,26 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_load_scripts() { |
27 | 27 | |
28 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/frontend/'; |
|
29 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
30 | - $scripts_footer = ( give_is_setting_enabled( give_get_option( 'scripts_footer' ) ) ) ? true : false; |
|
28 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/frontend/'; |
|
29 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
30 | + $scripts_footer = (give_is_setting_enabled(give_get_option('scripts_footer'))) ? true : false; |
|
31 | 31 | |
32 | 32 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
33 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
33 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
34 | 34 | |
35 | 35 | // Localize / PHP to AJAX vars. |
36 | - $localize_give_vars = apply_filters( 'give_global_script_vars', array( |
|
36 | + $localize_give_vars = apply_filters('give_global_script_vars', array( |
|
37 | 37 | 'ajaxurl' => give_get_ajax_url(), |
38 | - 'checkout_nonce' => wp_create_nonce( 'give_checkout_nonce' ), // Do not use this nonce. Its deprecated. |
|
38 | + 'checkout_nonce' => wp_create_nonce('give_checkout_nonce'), // Do not use this nonce. Its deprecated. |
|
39 | 39 | 'currency' => give_get_currency(), |
40 | - 'currency_sign' => give_currency_filter( '' ), |
|
40 | + 'currency_sign' => give_currency_filter(''), |
|
41 | 41 | 'currency_pos' => give_get_currency_position(), |
42 | 42 | 'thousands_separator' => give_get_price_thousand_separator(), |
43 | 43 | 'decimal_separator' => give_get_price_decimal_separator(), |
44 | - 'no_gateway' => __( 'Please select a payment method.', 'give' ), |
|
45 | - 'bad_minimum' => __( 'The minimum custom donation amount for this form is', 'give' ), |
|
46 | - 'general_loading' => __( 'Loading...', 'give' ), |
|
47 | - 'purchase_loading' => __( 'Please Wait...', 'give' ), |
|
44 | + 'no_gateway' => __('Please select a payment method.', 'give'), |
|
45 | + 'bad_minimum' => __('The minimum custom donation amount for this form is', 'give'), |
|
46 | + 'general_loading' => __('Loading...', 'give'), |
|
47 | + 'purchase_loading' => __('Please Wait...', 'give'), |
|
48 | 48 | 'number_decimals' => give_get_price_decimals(), |
49 | 49 | 'give_version' => GIVE_VERSION, |
50 | 50 | 'magnific_options' => apply_filters( |
@@ -58,83 +58,83 @@ discard block |
||
58 | 58 | 'give_form_translation_js', |
59 | 59 | array( |
60 | 60 | // Field name Validation message. |
61 | - 'payment-mode' => __( 'Please select payment mode.', 'give' ), |
|
62 | - 'give_first' => __( 'Please enter your first name.', 'give' ), |
|
63 | - 'give_email' => __( 'Please enter a valid email address.', 'give' ), |
|
64 | - 'give_user_login' => __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ), |
|
65 | - 'give_user_pass' => __( 'Enter a password.', 'give' ), |
|
66 | - 'give_user_pass_confirm' => __( 'Enter the password confirmation.', 'give' ), |
|
67 | - 'give_agree_to_terms' => __( 'You must agree to the terms and conditions.', 'give' ), |
|
61 | + 'payment-mode' => __('Please select payment mode.', 'give'), |
|
62 | + 'give_first' => __('Please enter your first name.', 'give'), |
|
63 | + 'give_email' => __('Please enter a valid email address.', 'give'), |
|
64 | + 'give_user_login' => __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'), |
|
65 | + 'give_user_pass' => __('Enter a password.', 'give'), |
|
66 | + 'give_user_pass_confirm' => __('Enter the password confirmation.', 'give'), |
|
67 | + 'give_agree_to_terms' => __('You must agree to the terms and conditions.', 'give'), |
|
68 | 68 | ) |
69 | 69 | ), |
70 | - 'confirm_email_sent_message' => __( 'Please check your email and click on the link to access your complete donation history.', 'give' ), |
|
71 | - ) ); |
|
70 | + 'confirm_email_sent_message' => __('Please check your email and click on the link to access your complete donation history.', 'give'), |
|
71 | + )); |
|
72 | 72 | |
73 | - $localize_give_ajax = apply_filters( 'give_global_ajax_vars', array( |
|
73 | + $localize_give_ajax = apply_filters('give_global_ajax_vars', array( |
|
74 | 74 | 'ajaxurl' => give_get_ajax_url(), |
75 | - 'ajaxNonce' => wp_create_nonce( 'give_ajax_nonce' ), |
|
76 | - 'loading' => __( 'Loading', 'give' ), |
|
75 | + 'ajaxNonce' => wp_create_nonce('give_ajax_nonce'), |
|
76 | + 'loading' => __('Loading', 'give'), |
|
77 | 77 | // General loading message. |
78 | - 'select_option' => __( 'Please select an option', 'give' ), |
|
78 | + 'select_option' => __('Please select an option', 'give'), |
|
79 | 79 | // Variable pricing error with multi-donation option enabled. |
80 | - 'default_gateway' => give_get_default_gateway( null ), |
|
81 | - 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', |
|
80 | + 'default_gateway' => give_get_default_gateway(null), |
|
81 | + 'permalinks' => get_option('permalink_structure') ? '1' : '0', |
|
82 | 82 | 'number_decimals' => give_get_price_decimals(), |
83 | - ) ); |
|
83 | + )); |
|
84 | 84 | |
85 | 85 | // DEBUG is On. |
86 | - if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { |
|
86 | + if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) { |
|
87 | 87 | |
88 | - if ( give_is_cc_verify_enabled() ) { |
|
89 | - wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
90 | - wp_enqueue_script( 'give-cc-validator' ); |
|
88 | + if (give_is_cc_verify_enabled()) { |
|
89 | + wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
90 | + wp_enqueue_script('give-cc-validator'); |
|
91 | 91 | } |
92 | 92 | |
93 | - wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
94 | - wp_enqueue_script( 'give-float-labels' ); |
|
93 | + wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
94 | + wp_enqueue_script('give-float-labels'); |
|
95 | 95 | |
96 | - wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
97 | - wp_enqueue_script( 'give-blockui' ); |
|
96 | + wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
97 | + wp_enqueue_script('give-blockui'); |
|
98 | 98 | |
99 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
100 | - wp_enqueue_script( 'give-accounting' ); |
|
99 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
100 | + wp_enqueue_script('give-accounting'); |
|
101 | 101 | |
102 | - wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
103 | - wp_enqueue_script( 'give-magnific' ); |
|
102 | + wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
103 | + wp_enqueue_script('give-magnific'); |
|
104 | 104 | |
105 | - wp_register_script( 'give-checkout-global', $js_dir . 'give-donations' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
106 | - wp_enqueue_script( 'give-checkout-global' ); |
|
105 | + wp_register_script('give-checkout-global', $js_dir.'give-donations'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
106 | + wp_enqueue_script('give-checkout-global'); |
|
107 | 107 | |
108 | - wp_register_script( 'give-hint.css', $js_plugins . 'give-hint.css' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
109 | - wp_enqueue_script( 'give-hint.css' ); |
|
108 | + wp_register_script('give-hint.css', $js_plugins.'give-hint.css'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
109 | + wp_enqueue_script('give-hint.css'); |
|
110 | 110 | |
111 | 111 | // General scripts. |
112 | - wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
113 | - wp_enqueue_script( 'give-scripts' ); |
|
112 | + wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
113 | + wp_enqueue_script('give-scripts'); |
|
114 | 114 | |
115 | 115 | // Load AJAX scripts, if enabled. |
116 | - wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
117 | - wp_enqueue_script( 'give-ajax' ); |
|
116 | + wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
117 | + wp_enqueue_script('give-ajax'); |
|
118 | 118 | |
119 | 119 | // Localize / Pass AJAX vars from PHP, |
120 | - wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_vars ); |
|
121 | - wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax ); |
|
120 | + wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_vars); |
|
121 | + wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax); |
|
122 | 122 | |
123 | 123 | } else { |
124 | 124 | |
125 | 125 | // DEBUG is OFF (one JS file to rule them all!). |
126 | - wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
127 | - wp_enqueue_script( 'give' ); |
|
126 | + wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
127 | + wp_enqueue_script('give'); |
|
128 | 128 | |
129 | 129 | // Localize / Pass AJAX vars from PHP. |
130 | - wp_localize_script( 'give', 'give_global_vars', $localize_give_vars ); |
|
131 | - wp_localize_script( 'give', 'give_scripts', $localize_give_ajax ); |
|
130 | + wp_localize_script('give', 'give_global_vars', $localize_give_vars); |
|
131 | + wp_localize_script('give', 'give_scripts', $localize_give_ajax); |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
135 | 135 | } |
136 | 136 | |
137 | -add_action( 'wp_enqueue_scripts', 'give_load_scripts' ); |
|
137 | +add_action('wp_enqueue_scripts', 'give_load_scripts'); |
|
138 | 138 | |
139 | 139 | /** |
140 | 140 | * Register styles. |
@@ -147,16 +147,16 @@ discard block |
||
147 | 147 | */ |
148 | 148 | function give_register_styles() { |
149 | 149 | |
150 | - if ( ! give_is_setting_enabled( give_get_option( 'css' ) ) ) { |
|
150 | + if ( ! give_is_setting_enabled(give_get_option('css'))) { |
|
151 | 151 | return; |
152 | 152 | } |
153 | 153 | |
154 | - wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' ); |
|
155 | - wp_enqueue_style( 'give-styles' ); |
|
154 | + wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all'); |
|
155 | + wp_enqueue_style('give-styles'); |
|
156 | 156 | |
157 | 157 | } |
158 | 158 | |
159 | -add_action( 'wp_enqueue_scripts', 'give_register_styles' ); |
|
159 | +add_action('wp_enqueue_scripts', 'give_register_styles'); |
|
160 | 160 | |
161 | 161 | |
162 | 162 | /** |
@@ -169,19 +169,19 @@ discard block |
||
169 | 169 | function give_get_stylesheet_uri() { |
170 | 170 | |
171 | 171 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
172 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
172 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
173 | 173 | |
174 | 174 | // LTR or RTL files. |
175 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
175 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
176 | 176 | |
177 | - $file = 'give' . $direction . $suffix . '.css'; |
|
177 | + $file = 'give'.$direction.$suffix.'.css'; |
|
178 | 178 | $templates_dir = give_get_theme_template_dir_name(); |
179 | 179 | |
180 | - $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file; |
|
181 | - $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
182 | - $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file; |
|
183 | - $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
184 | - $give_plugin_style_sheet = trailingslashit( give_get_templates_dir() ) . $file; |
|
180 | + $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()).$templates_dir.$file; |
|
181 | + $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$direction.'.css'; |
|
182 | + $parent_theme_style_sheet = trailingslashit(get_template_directory()).$templates_dir.$file; |
|
183 | + $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$direction.'.css'; |
|
184 | + $give_plugin_style_sheet = trailingslashit(give_get_templates_dir()).$file; |
|
185 | 185 | |
186 | 186 | $uri = false; |
187 | 187 | |
@@ -191,23 +191,23 @@ discard block |
||
191 | 191 | * followed by non minified version, even if SCRIPT_DEBUG is not enabled. |
192 | 192 | * This allows users to copy just give.css to their theme. |
193 | 193 | */ |
194 | - if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) { |
|
195 | - if ( ! empty( $nonmin ) ) { |
|
196 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
194 | + if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) { |
|
195 | + if ( ! empty($nonmin)) { |
|
196 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
197 | 197 | } else { |
198 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file; |
|
198 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file; |
|
199 | 199 | } |
200 | - } elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) { |
|
201 | - if ( ! empty( $nonmin ) ) { |
|
202 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
200 | + } elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) { |
|
201 | + if ( ! empty($nonmin)) { |
|
202 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
203 | 203 | } else { |
204 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file; |
|
204 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file; |
|
205 | 205 | } |
206 | - } elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) { |
|
207 | - $uri = trailingslashit( give_get_templates_url() ) . $file; |
|
206 | + } elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) { |
|
207 | + $uri = trailingslashit(give_get_templates_url()).$file; |
|
208 | 208 | } |
209 | 209 | |
210 | - return apply_filters( 'give_get_stylesheet_uri', $uri ); |
|
210 | + return apply_filters('give_get_stylesheet_uri', $uri); |
|
211 | 211 | |
212 | 212 | } |
213 | 213 | |
@@ -224,82 +224,82 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return void |
226 | 226 | */ |
227 | -function give_load_admin_scripts( $hook ) { |
|
227 | +function give_load_admin_scripts($hook) { |
|
228 | 228 | |
229 | 229 | global $post, $post_type; |
230 | 230 | |
231 | 231 | $give_options = give_get_settings(); |
232 | 232 | |
233 | 233 | // Directories of assets. |
234 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
235 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
236 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
234 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
235 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
236 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
237 | 237 | |
238 | 238 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
239 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
239 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
240 | 240 | |
241 | 241 | // LTR or RTL files. |
242 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
242 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
243 | 243 | |
244 | 244 | // Global Admin. |
245 | - wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' ); |
|
246 | - wp_enqueue_style( 'give-admin-bar-notification' ); |
|
245 | + wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css'); |
|
246 | + wp_enqueue_style('give-admin-bar-notification'); |
|
247 | 247 | |
248 | 248 | // Give Admin Only. |
249 | - if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) { |
|
249 | + if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { |
|
250 | 250 | return; |
251 | 251 | } |
252 | 252 | |
253 | 253 | // CSS. |
254 | - wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' ); |
|
255 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
256 | - wp_register_style( 'give-admin', $css_dir . 'give-admin' . $direction . $suffix . '.css', array(), GIVE_VERSION ); |
|
257 | - wp_enqueue_style( 'give-admin' ); |
|
258 | - wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION ); |
|
259 | - wp_enqueue_style( 'jquery-chosen' ); |
|
260 | - wp_enqueue_style( 'thickbox' ); |
|
261 | - wp_enqueue_style( 'wp-color-picker' ); |
|
254 | + wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css'); |
|
255 | + wp_enqueue_style('jquery-ui-css'); |
|
256 | + wp_register_style('give-admin', $css_dir.'give-admin'.$direction.$suffix.'.css', array(), GIVE_VERSION); |
|
257 | + wp_enqueue_style('give-admin'); |
|
258 | + wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION); |
|
259 | + wp_enqueue_style('jquery-chosen'); |
|
260 | + wp_enqueue_style('thickbox'); |
|
261 | + wp_enqueue_style('wp-color-picker'); |
|
262 | 262 | |
263 | 263 | |
264 | 264 | // JS. |
265 | - wp_register_script( 'give-selector-cache', $js_plugins . 'selector-cache' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
266 | - wp_enqueue_script( 'give-selector-cache' ); |
|
265 | + wp_register_script('give-selector-cache', $js_plugins.'selector-cache'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
266 | + wp_enqueue_script('give-selector-cache'); |
|
267 | 267 | |
268 | - wp_register_script( 'give-ajaxify-fields', $js_plugins . 'give-ajaxify-fields' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
269 | - wp_enqueue_script( 'give-ajaxify-fields' ); |
|
268 | + wp_register_script('give-ajaxify-fields', $js_plugins.'give-ajaxify-fields'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
269 | + wp_enqueue_script('give-ajaxify-fields'); |
|
270 | 270 | |
271 | - wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
272 | - wp_enqueue_script( 'jquery-chosen' ); |
|
271 | + wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
272 | + wp_enqueue_script('jquery-chosen'); |
|
273 | 273 | |
274 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
275 | - wp_enqueue_script( 'give-accounting' ); |
|
274 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
275 | + wp_enqueue_script('give-accounting'); |
|
276 | 276 | |
277 | - wp_enqueue_script( 'wp-color-picker' ); |
|
278 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
279 | - wp_enqueue_script( 'thickbox' ); |
|
277 | + wp_enqueue_script('wp-color-picker'); |
|
278 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
279 | + wp_enqueue_script('thickbox'); |
|
280 | 280 | |
281 | - wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'wp-color-picker', 'jquery-query' ), GIVE_VERSION, false ); |
|
282 | - wp_enqueue_script( 'give-admin-scripts' ); |
|
281 | + wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery', 'jquery-ui-datepicker', 'wp-color-picker', 'jquery-query'), GIVE_VERSION, false); |
|
282 | + wp_enqueue_script('give-admin-scripts'); |
|
283 | 283 | |
284 | - wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' ); |
|
285 | - wp_enqueue_script( 'jquery-flot' ); |
|
284 | + wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js'); |
|
285 | + wp_enqueue_script('jquery-flot'); |
|
286 | 286 | |
287 | - wp_register_script( 'give-repeatable-fields', $js_plugins . 'repeatable-fields' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
288 | - wp_enqueue_script( 'give-repeatable-fields' ); |
|
287 | + wp_register_script('give-repeatable-fields', $js_plugins.'repeatable-fields'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
288 | + wp_enqueue_script('give-repeatable-fields'); |
|
289 | 289 | |
290 | - wp_register_script( 'give-hint.css', $js_plugins . 'give-hint.css' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
291 | - wp_enqueue_script( 'give-hint.css' ); |
|
290 | + wp_register_script('give-hint.css', $js_plugins.'give-hint.css'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
291 | + wp_enqueue_script('give-hint.css'); |
|
292 | 292 | |
293 | 293 | // Forms CPT Script. |
294 | - if ( $post_type === 'give_forms' ) { |
|
295 | - wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
296 | - wp_enqueue_script( 'give-admin-forms-scripts' ); |
|
294 | + if ($post_type === 'give_forms') { |
|
295 | + wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
296 | + wp_enqueue_script('give-admin-forms-scripts'); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | // Settings Scripts. |
300 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) { |
|
301 | - wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
302 | - wp_enqueue_script( 'give-admin-settings-scripts' ); |
|
300 | + if (isset($_GET['page']) && $_GET['page'] == 'give-settings') { |
|
301 | + wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
302 | + wp_enqueue_script('give-admin-settings-scripts'); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | // Price Separators. |
@@ -307,91 +307,91 @@ discard block |
||
307 | 307 | $decimal_separator = give_get_price_decimal_separator(); |
308 | 308 | |
309 | 309 | // Localize strings & variables for JS. |
310 | - wp_localize_script( 'give-admin-scripts', 'give_vars', array( |
|
311 | - 'post_id' => isset( $post->ID ) ? $post->ID : null, |
|
310 | + wp_localize_script('give-admin-scripts', 'give_vars', array( |
|
311 | + 'post_id' => isset($post->ID) ? $post->ID : null, |
|
312 | 312 | 'give_version' => GIVE_VERSION, |
313 | 313 | 'thousands_separator' => $thousand_separator, |
314 | 314 | 'decimal_separator' => $decimal_separator, |
315 | - 'quick_edit_warning' => __( 'Not available for variable priced forms.', 'give' ), |
|
316 | - 'delete_payment' => __( 'Are you sure you want to delete this payment?', 'give' ), |
|
317 | - 'delete_payment_note' => __( 'Are you sure you want to delete this note?', 'give' ), |
|
318 | - 'revoke_api_key' => __( 'Are you sure you want to revoke this API key?', 'give' ), |
|
319 | - 'regenerate_api_key' => __( 'Are you sure you want to regenerate this API key?', 'give' ), |
|
320 | - 'resend_receipt' => __( 'Are you sure you want to resend the donation receipt?', 'give' ), |
|
321 | - 'disconnect_user' => __( 'Are you sure you want to disconnect the user from this donor?', 'give' ), |
|
322 | - 'one_option' => __( 'Choose a form', 'give' ), |
|
323 | - 'one_or_more_option' => __( 'Choose one or more forms', 'give' ), |
|
324 | - 'currency_sign' => give_currency_filter( '' ), |
|
325 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', |
|
315 | + 'quick_edit_warning' => __('Not available for variable priced forms.', 'give'), |
|
316 | + 'delete_payment' => __('Are you sure you want to delete this payment?', 'give'), |
|
317 | + 'delete_payment_note' => __('Are you sure you want to delete this note?', 'give'), |
|
318 | + 'revoke_api_key' => __('Are you sure you want to revoke this API key?', 'give'), |
|
319 | + 'regenerate_api_key' => __('Are you sure you want to regenerate this API key?', 'give'), |
|
320 | + 'resend_receipt' => __('Are you sure you want to resend the donation receipt?', 'give'), |
|
321 | + 'disconnect_user' => __('Are you sure you want to disconnect the user from this donor?', 'give'), |
|
322 | + 'one_option' => __('Choose a form', 'give'), |
|
323 | + 'one_or_more_option' => __('Choose one or more forms', 'give'), |
|
324 | + 'currency_sign' => give_currency_filter(''), |
|
325 | + 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', |
|
326 | 326 | 'currency_decimals' => give_get_price_decimals(), |
327 | - 'batch_export_no_class' => __( 'You must choose a method.', 'give' ), |
|
328 | - 'batch_export_no_reqs' => __( 'Required fields not completed.', 'give' ), |
|
329 | - 'reset_stats_warn' => __( 'Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give' ), |
|
330 | - 'delete_test_donor' => __( 'Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give' ), |
|
331 | - 'delete_import_donor' => __( 'Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give' ), |
|
332 | - 'price_format_guide' => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ), |
|
327 | + 'batch_export_no_class' => __('You must choose a method.', 'give'), |
|
328 | + 'batch_export_no_reqs' => __('Required fields not completed.', 'give'), |
|
329 | + 'reset_stats_warn' => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'), |
|
330 | + 'delete_test_donor' => __('Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give'), |
|
331 | + 'delete_import_donor' => __('Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give'), |
|
332 | + 'price_format_guide' => sprintf(__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator), |
|
333 | 333 | /* translators : %s: Donation form options metabox */ |
334 | - 'confirm_before_remove_row_text' => __( 'Do you want to delete this item?', 'give' ), |
|
335 | - 'matched_success_failure_page' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
|
336 | - 'dismiss_notice_text' => __( 'Dismiss this notice.', 'give' ), |
|
337 | - 'search_placeholder' => __( 'Type to search all forms', 'give' ), |
|
338 | - 'search_placeholder_donor' => __( 'Type to search all donors', 'give' ), |
|
339 | - 'search_placeholder_country' => __( 'Type to search all countries', 'give' ), |
|
340 | - 'search_placeholder_state' => __( 'Type to search all states/provinces', 'give' ), |
|
341 | - 'unlock_donor_fields' => __( 'To edit first name and last name, please go to user profile of the donor.', 'give' ), |
|
342 | - 'remove_from_bulk_delete' => __( 'Remove from Bulk Delete', 'give' ), |
|
334 | + 'confirm_before_remove_row_text' => __('Do you want to delete this item?', 'give'), |
|
335 | + 'matched_success_failure_page' => __('You cannot set the success and failed pages to the same page', 'give'), |
|
336 | + 'dismiss_notice_text' => __('Dismiss this notice.', 'give'), |
|
337 | + 'search_placeholder' => __('Type to search all forms', 'give'), |
|
338 | + 'search_placeholder_donor' => __('Type to search all donors', 'give'), |
|
339 | + 'search_placeholder_country' => __('Type to search all countries', 'give'), |
|
340 | + 'search_placeholder_state' => __('Type to search all states/provinces', 'give'), |
|
341 | + 'unlock_donor_fields' => __('To edit first name and last name, please go to user profile of the donor.', 'give'), |
|
342 | + 'remove_from_bulk_delete' => __('Remove from Bulk Delete', 'give'), |
|
343 | 343 | 'donors_bulk_action' => array( |
344 | - 'no_donor_selected' => __( 'You must choose at least one or more donors to delete.', 'give' ), |
|
345 | - 'no_action_selected' => __( 'You must select a bulk action to proceed.', 'give' ), |
|
344 | + 'no_donor_selected' => __('You must choose at least one or more donors to delete.', 'give'), |
|
345 | + 'no_action_selected' => __('You must select a bulk action to proceed.', 'give'), |
|
346 | 346 | ), |
347 | 347 | 'donations_bulk_action' => array( |
348 | 348 | 'delete' => array( |
349 | - 'zero' => __( 'You must choose at least one or more donations to delete.', 'give' ), |
|
350 | - 'single' => __( 'Are you sure you want to permanently delete this donation?', 'give' ), |
|
351 | - 'multiple' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ), |
|
349 | + 'zero' => __('You must choose at least one or more donations to delete.', 'give'), |
|
350 | + 'single' => __('Are you sure you want to permanently delete this donation?', 'give'), |
|
351 | + 'multiple' => __('Are you sure you want to permanently delete the selected {payment_count} donations?', 'give'), |
|
352 | 352 | ), |
353 | 353 | 'resend-receipt' => array( |
354 | - 'zero' => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ), |
|
355 | - 'single' => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ), |
|
356 | - 'multiple' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ), |
|
354 | + 'zero' => __('You must choose at least one or more recipients to resend the email receipt.', 'give'), |
|
355 | + 'single' => __('Are you sure you want to resend the email receipt to this recipient?', 'give'), |
|
356 | + 'multiple' => __('Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give'), |
|
357 | 357 | ), |
358 | 358 | 'set-to-status' => array( |
359 | - 'zero' => __( 'You must choose at least one or more donations to set status to {status}.', 'give' ), |
|
360 | - 'single' => __( 'Are you sure you want to set status of this donation to {status}?', 'give' ), |
|
361 | - 'multiple' => __( 'Are you sure you want to set status of {payment_count} donations to {status}?', 'give' ), |
|
359 | + 'zero' => __('You must choose at least one or more donations to set status to {status}.', 'give'), |
|
360 | + 'single' => __('Are you sure you want to set status of this donation to {status}?', 'give'), |
|
361 | + 'multiple' => __('Are you sure you want to set status of {payment_count} donations to {status}?', 'give'), |
|
362 | 362 | ), |
363 | 363 | ), |
364 | 364 | 'updates' => array( |
365 | - 'ajax_error' => __( 'Please reload this page and try again', 'give' ) |
|
365 | + 'ajax_error' => __('Please reload this page and try again', 'give') |
|
366 | 366 | ), |
367 | 367 | 'metabox_fields' => array( |
368 | 368 | 'media' => array( |
369 | - 'button_title' => __( 'Choose Image', 'give' ), |
|
369 | + 'button_title' => __('Choose Image', 'give'), |
|
370 | 370 | ), |
371 | 371 | 'file' => array( |
372 | - 'button_title' => __( 'Choose File', 'give' ), |
|
372 | + 'button_title' => __('Choose File', 'give'), |
|
373 | 373 | ), |
374 | 374 | ), |
375 | 375 | 'chosen' => array( |
376 | - 'no_results_msg' => __( 'No results match {search_term}', 'give' ), |
|
377 | - 'ajax_search_msg' => __( 'Searching results for match {search_term}', 'give' ), |
|
376 | + 'no_results_msg' => __('No results match {search_term}', 'give'), |
|
377 | + 'ajax_search_msg' => __('Searching results for match {search_term}', 'give'), |
|
378 | 378 | ), |
379 | - 'db_update_confirmation_msg_button' => __( 'Run Updates', 'give' ), |
|
380 | - 'db_update_confirmation_msg' => __( 'The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give' ), |
|
381 | - 'error_message' => __( 'Something went wrong kindly try again!', 'give' ), |
|
379 | + 'db_update_confirmation_msg_button' => __('Run Updates', 'give'), |
|
380 | + 'db_update_confirmation_msg' => __('The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give'), |
|
381 | + 'error_message' => __('Something went wrong kindly try again!', 'give'), |
|
382 | 382 | 'give_donation_import' => 'give_donation_import', |
383 | 383 | 'core_settings_import' => 'give_core_settings_import', |
384 | - 'setting_not_save_message' => __( 'Changes you made may not be saved.', 'give' ), |
|
385 | - ) ); |
|
384 | + 'setting_not_save_message' => __('Changes you made may not be saved.', 'give'), |
|
385 | + )); |
|
386 | 386 | |
387 | - if ( function_exists( 'wp_enqueue_media' ) && version_compare( get_bloginfo( 'version' ), '3.5', '>=' ) ) { |
|
387 | + if (function_exists('wp_enqueue_media') && version_compare(get_bloginfo('version'), '3.5', '>=')) { |
|
388 | 388 | // call for new media manager. |
389 | 389 | wp_enqueue_media(); |
390 | 390 | } |
391 | 391 | |
392 | 392 | } |
393 | 393 | |
394 | -add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 ); |
|
394 | +add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100); |
|
395 | 395 | |
396 | 396 | /** |
397 | 397 | * Admin Give Icon |
@@ -406,13 +406,13 @@ discard block |
||
406 | 406 | ?> |
407 | 407 | <style type="text/css" media="screen"> |
408 | 408 | |
409 | - <?php if ( version_compare( get_bloginfo( 'version' ), '3.8-RC', '>=' ) || version_compare( get_bloginfo( 'version' ), '3.8', '>=' ) ) { ?> |
|
409 | + <?php if (version_compare(get_bloginfo('version'), '3.8-RC', '>=') || version_compare(get_bloginfo('version'), '3.8', '>=')) { ?> |
|
410 | 410 | @font-face { |
411 | 411 | font-family: 'give-icomoon'; |
412 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?ngjl88'; ?>'); |
|
413 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
414 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
415 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
412 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?ngjl88'; ?>'); |
|
413 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
414 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
415 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
416 | 416 | font-weight: normal; |
417 | 417 | font-style: normal; |
418 | 418 | } |
@@ -431,4 +431,4 @@ discard block |
||
431 | 431 | <?php |
432 | 432 | } |
433 | 433 | |
434 | -add_action( 'admin_head', 'give_admin_icon' ); |
|
434 | +add_action('admin_head', 'give_admin_icon'); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @param $args array The array of arguments that can be passed in and used for setting up this payment query. |
88 | 88 | */ |
89 | - public function __construct( $args = array() ) { |
|
89 | + public function __construct($args = array()) { |
|
90 | 90 | $defaults = array( |
91 | 91 | 'number' => 20, |
92 | 92 | 'offset' => 0, |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | // 'form' => array(), |
105 | 105 | ); |
106 | 106 | |
107 | - $this->args = wp_parse_args( $args, $defaults ); |
|
107 | + $this->args = wp_parse_args($args, $defaults); |
|
108 | 108 | $this->table_name = Give()->donors->table_name; |
109 | 109 | $this->meta_table_name = Give()->donor_meta->table_name; |
110 | 110 | $this->meta_type = Give()->donor_meta->meta_type; |
@@ -146,21 +146,21 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @param Give_Donors_Query $this Donors query object. |
148 | 148 | */ |
149 | - do_action( 'give_pre_get_donors', $this ); |
|
149 | + do_action('give_pre_get_donors', $this); |
|
150 | 150 | |
151 | - $cache_key = Give_Cache::get_key( 'give_donor', $this->get_sql(), false ); |
|
151 | + $cache_key = Give_Cache::get_key('give_donor', $this->get_sql(), false); |
|
152 | 152 | |
153 | 153 | // Get donors from cache. |
154 | - $this->donors = Give_Cache::get_db_query( $cache_key ); |
|
154 | + $this->donors = Give_Cache::get_db_query($cache_key); |
|
155 | 155 | |
156 | - if ( is_null( $this->donors ) ) { |
|
157 | - if ( empty( $this->args['count'] ) ) { |
|
158 | - $this->donors = $wpdb->get_results( $this->get_sql() ); |
|
156 | + if (is_null($this->donors)) { |
|
157 | + if (empty($this->args['count'])) { |
|
158 | + $this->donors = $wpdb->get_results($this->get_sql()); |
|
159 | 159 | } else { |
160 | - $this->donors = $wpdb->get_var( $this->get_sql() ); |
|
160 | + $this->donors = $wpdb->get_var($this->get_sql()); |
|
161 | 161 | } |
162 | 162 | |
163 | - Give_Cache::set_db_query( $cache_key, $this->donors ); |
|
163 | + Give_Cache::set_db_query($cache_key, $this->donors); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * |
172 | 172 | * @param Give_Donors_Query $this Donors query object. |
173 | 173 | */ |
174 | - do_action( 'give_post_get_donors', $this ); |
|
174 | + do_action('give_post_get_donors', $this); |
|
175 | 175 | |
176 | 176 | return $this->donors; |
177 | 177 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | public function get_sql() { |
189 | 189 | global $wpdb; |
190 | 190 | |
191 | - if ( $this->args['number'] < 1 ) { |
|
191 | + if ($this->args['number'] < 1) { |
|
192 | 192 | $this->args['number'] = 999999999999; |
193 | 193 | } |
194 | 194 | |
@@ -196,22 +196,22 @@ discard block |
||
196 | 196 | |
197 | 197 | |
198 | 198 | // Set offset. |
199 | - if ( empty( $this->args['offset'] ) && ( 0 < $this->args['paged'] ) ) { |
|
200 | - $this->args['offset'] = $this->args['number'] * ( $this->args['paged'] - 1 ); |
|
199 | + if (empty($this->args['offset']) && (0 < $this->args['paged'])) { |
|
200 | + $this->args['offset'] = $this->args['number'] * ($this->args['paged'] - 1); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | // Set fields. |
204 | 204 | $fields = "{$this->table_name}.*"; |
205 | - if ( ! empty( $this->args['fields'] ) && 'all' !== $this->args['fields'] ) { |
|
206 | - if ( is_string( $this->args['fields'] ) ) { |
|
205 | + if ( ! empty($this->args['fields']) && 'all' !== $this->args['fields']) { |
|
206 | + if (is_string($this->args['fields'])) { |
|
207 | 207 | $fields = "{$this->table_name}.{$this->args['fields']}"; |
208 | - } elseif ( is_array( $this->args['fields'] ) ) { |
|
209 | - $fields = "{$this->table_name}." . implode( " , {$this->table_name}.", $this->args['fields'] ); |
|
208 | + } elseif (is_array($this->args['fields'])) { |
|
209 | + $fields = "{$this->table_name}.".implode(" , {$this->table_name}.", $this->args['fields']); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | |
213 | 213 | // Set count. |
214 | - if ( ! empty( $this->args['count'] ) ) { |
|
214 | + if ( ! empty($this->args['count'])) { |
|
215 | 215 | $fields = "COUNT({$this->table_name}.id)"; |
216 | 216 | } |
217 | 217 | |
@@ -219,13 +219,13 @@ discard block |
||
219 | 219 | |
220 | 220 | $sql = $wpdb->prepare( |
221 | 221 | "SELECT {$fields} FROM {$this->table_name} LIMIT %d,%d;", |
222 | - absint( $this->args['offset'] ), |
|
223 | - absint( $this->args['number'] ) |
|
222 | + absint($this->args['offset']), |
|
223 | + absint($this->args['number']) |
|
224 | 224 | ); |
225 | 225 | |
226 | 226 | // $where, $orderby and order already prepared query they can generate notice if you re prepare them in above. |
227 | 227 | // WordPress consider LIKE condition as placeholder if start with s,f, or d. |
228 | - $sql = str_replace( 'LIMIT', "{$where} {$orderby} {$this->args['order']} LIMIT", $sql ); |
|
228 | + $sql = str_replace('LIMIT', "{$where} {$orderby} {$this->args['order']} LIMIT", $sql); |
|
229 | 229 | |
230 | 230 | return $sql; |
231 | 231 | } |
@@ -243,15 +243,15 @@ discard block |
||
243 | 243 | $where = ''; |
244 | 244 | |
245 | 245 | // Get sql query for meta. |
246 | - if ( ! empty( $this->args['meta_query'] ) ) { |
|
247 | - $meta_query_object = new WP_Meta_Query( $this->args['meta_query'] ); |
|
246 | + if ( ! empty($this->args['meta_query'])) { |
|
247 | + $meta_query_object = new WP_Meta_Query($this->args['meta_query']); |
|
248 | 248 | $meta_query = $meta_query_object->get_sql( |
249 | 249 | $this->meta_type, |
250 | 250 | $this->table_name, |
251 | 251 | 'id' |
252 | 252 | ); |
253 | 253 | |
254 | - $where = implode( '', $meta_query ); |
|
254 | + $where = implode('', $meta_query); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | $where .= 'WHERE 1=1 '; |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | $where .= $this->get_where_user(); |
262 | 262 | $where .= $this->get_where_date(); |
263 | 263 | |
264 | - return trim( $where ); |
|
264 | + return trim($where); |
|
265 | 265 | |
266 | 266 | } |
267 | 267 | |
@@ -279,17 +279,17 @@ discard block |
||
279 | 279 | |
280 | 280 | $where = ''; |
281 | 281 | |
282 | - if ( ! empty( $this->args['email'] ) ) { |
|
282 | + if ( ! empty($this->args['email'])) { |
|
283 | 283 | |
284 | - if ( is_array( $this->args['email'] ) ) { |
|
284 | + if (is_array($this->args['email'])) { |
|
285 | 285 | |
286 | - $emails_count = count( $this->args['email'] ); |
|
287 | - $emails_placeholder = array_fill( 0, $emails_count, '%s' ); |
|
288 | - $emails = implode( ', ', $emails_placeholder ); |
|
286 | + $emails_count = count($this->args['email']); |
|
287 | + $emails_placeholder = array_fill(0, $emails_count, '%s'); |
|
288 | + $emails = implode(', ', $emails_placeholder); |
|
289 | 289 | |
290 | - $where .= $wpdb->prepare( "AND {$this->table_name}.email IN( $emails )", $this->args['email'] ); |
|
290 | + $where .= $wpdb->prepare("AND {$this->table_name}.email IN( $emails )", $this->args['email']); |
|
291 | 291 | } else { |
292 | - $where .= $wpdb->prepare( "AND {$this->table_name}.email = %s", $this->args['email'] ); |
|
292 | + $where .= $wpdb->prepare("AND {$this->table_name}.email = %s", $this->args['email']); |
|
293 | 293 | } |
294 | 294 | } |
295 | 295 | |
@@ -309,11 +309,11 @@ discard block |
||
309 | 309 | $where = ''; |
310 | 310 | |
311 | 311 | // Specific donors. |
312 | - if ( ! empty( $this->args['donor'] ) ) { |
|
313 | - if ( ! is_array( $this->args['donor'] ) ) { |
|
314 | - $this->args['donor'] = explode( ',', $this->args['donor'] ); |
|
312 | + if ( ! empty($this->args['donor'])) { |
|
313 | + if ( ! is_array($this->args['donor'])) { |
|
314 | + $this->args['donor'] = explode(',', $this->args['donor']); |
|
315 | 315 | } |
316 | - $donor_ids = implode( ',', array_map( 'intval', $this->args['donor'] ) ); |
|
316 | + $donor_ids = implode(',', array_map('intval', $this->args['donor'])); |
|
317 | 317 | |
318 | 318 | $where .= "AND {$this->table_name}.id IN( {$donor_ids} )"; |
319 | 319 | } |
@@ -334,9 +334,9 @@ discard block |
||
334 | 334 | $where = ''; |
335 | 335 | |
336 | 336 | // Donors created for a specific date or in a date range |
337 | - if ( ! empty( $this->args['date_query'] ) ) { |
|
337 | + if ( ! empty($this->args['date_query'])) { |
|
338 | 338 | $date_query_object = new WP_Date_Query( |
339 | - is_array( $this->args['date_query'] ) ? $this->args['date_query'] : wp_parse_args( $this->args['date_query'] ), |
|
339 | + is_array($this->args['date_query']) ? $this->args['date_query'] : wp_parse_args($this->args['date_query']), |
|
340 | 340 | "{$this->table_name}.date_created" |
341 | 341 | ); |
342 | 342 | |
@@ -371,11 +371,11 @@ discard block |
||
371 | 371 | $where = ''; |
372 | 372 | |
373 | 373 | // Donors created for a specific date or in a date range |
374 | - if ( ! empty( $this->args['s'] ) && false !== strpos( $this->args['s'], ':' ) ) { |
|
375 | - $search_parts = explode( ':', $this->args['s'] ); |
|
374 | + if ( ! empty($this->args['s']) && false !== strpos($this->args['s'], ':')) { |
|
375 | + $search_parts = explode(':', $this->args['s']); |
|
376 | 376 | |
377 | - if ( ! empty( $search_parts[0] ) ) { |
|
378 | - switch ( $search_parts[0] ) { |
|
377 | + if ( ! empty($search_parts[0])) { |
|
378 | + switch ($search_parts[0]) { |
|
379 | 379 | case 'name': |
380 | 380 | $where = "AND {$this->table_name}.name LIKE '%{$search_parts[1]}%'"; |
381 | 381 | break; |
@@ -403,11 +403,11 @@ discard block |
||
403 | 403 | $where = ''; |
404 | 404 | |
405 | 405 | // Donors create for specific wp user. |
406 | - if ( ! empty( $this->args['user'] ) ) { |
|
407 | - if ( ! is_array( $this->args['user'] ) ) { |
|
408 | - $this->args['user'] = explode( ',', $this->args['user'] ); |
|
406 | + if ( ! empty($this->args['user'])) { |
|
407 | + if ( ! is_array($this->args['user'])) { |
|
408 | + $this->args['user'] = explode(',', $this->args['user']); |
|
409 | 409 | } |
410 | - $user_ids = implode( ',', array_map( 'intval', $this->args['user'] ) ); |
|
410 | + $user_ids = implode(',', array_map('intval', $this->args['user'])); |
|
411 | 411 | |
412 | 412 | $where .= "AND {$this->table_name}.user_id IN( {$user_ids} )"; |
413 | 413 | } |
@@ -426,14 +426,13 @@ discard block |
||
426 | 426 | private function get_order_query() { |
427 | 427 | $table_columns = Give()->donors->get_columns(); |
428 | 428 | |
429 | - $this->args['orderby'] = ! array_key_exists( $this->args['orderby'], $table_columns ) ? |
|
430 | - 'id' : |
|
431 | - $this->args['orderby']; |
|
429 | + $this->args['orderby'] = ! array_key_exists($this->args['orderby'], $table_columns) ? |
|
430 | + 'id' : $this->args['orderby']; |
|
432 | 431 | |
433 | - $this->args['orderby'] = esc_sql( $this->args['orderby'] ); |
|
434 | - $this->args['order'] = esc_sql( $this->args['order'] ); |
|
432 | + $this->args['orderby'] = esc_sql($this->args['orderby']); |
|
433 | + $this->args['order'] = esc_sql($this->args['order']); |
|
435 | 434 | |
436 | - switch ( $table_columns[ $this->args['orderby'] ] ) { |
|
435 | + switch ($table_columns[$this->args['orderby']]) { |
|
437 | 436 | case '%d': |
438 | 437 | case '%f': |
439 | 438 | $query = "ORDER BY {$this->table_name}.{$this->args['orderby']}+0"; |
@@ -11,19 +11,19 @@ |
||
11 | 11 | * |
12 | 12 | * @return string|array |
13 | 13 | */ |
14 | -function __give_v20_bc_user_address( $meta_value, $user_id, $meta_key, $single ) { |
|
14 | +function __give_v20_bc_user_address($meta_value, $user_id, $meta_key, $single) { |
|
15 | 15 | if ( |
16 | - give_has_upgrade_completed( 'v20_upgrades_user_address' ) && |
|
16 | + give_has_upgrade_completed('v20_upgrades_user_address') && |
|
17 | 17 | '_give_user_address' === $meta_key |
18 | 18 | ) { |
19 | - $meta_value = give_get_donor_address( $user_id ); |
|
19 | + $meta_value = give_get_donor_address($user_id); |
|
20 | 20 | |
21 | - if ( $single ) { |
|
22 | - $meta_value = array( $meta_value ); |
|
21 | + if ($single) { |
|
22 | + $meta_value = array($meta_value); |
|
23 | 23 | } |
24 | 24 | } |
25 | 25 | |
26 | 26 | return $meta_value; |
27 | 27 | } |
28 | 28 | |
29 | -add_filter( 'get_user_metadata', '__give_v20_bc_user_address', 10, 4 ); |
|
30 | 29 | \ No newline at end of file |
30 | +add_filter('get_user_metadata', '__give_v20_bc_user_address', 10, 4); |
|
31 | 31 | \ 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 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | /* @var WPDB $wpdb */ |
51 | 51 | global $wpdb; |
52 | 52 | |
53 | - $wpdb->formmeta = $this->table_name = $wpdb->prefix . 'give_formmeta'; |
|
53 | + $wpdb->formmeta = $this->table_name = $wpdb->prefix.'give_formmeta'; |
|
54 | 54 | $this->primary_key = 'meta_id'; |
55 | 55 | $this->version = '1.0'; |
56 | 56 | |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | KEY meta_key (meta_key) |
100 | 100 | ) {$charset_collate};"; |
101 | 101 | |
102 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
103 | - dbDelta( $sql ); |
|
102 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
103 | + dbDelta($sql); |
|
104 | 104 | |
105 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
105 | + update_option($this->table_name.'_db_version', $this->version); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -113,6 +113,6 @@ discard block |
||
113 | 113 | * @return bool |
114 | 114 | */ |
115 | 115 | protected function is_custom_meta_table_active() { |
116 | - return give_has_upgrade_completed( 'v20_move_metadata_into_new_table' ); |
|
116 | + return give_has_upgrade_completed('v20_move_metadata_into_new_table'); |
|
117 | 117 | } |
118 | 118 | } |
@@ -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 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | /* @var WPDB $wpdb */ |
54 | 54 | global $wpdb; |
55 | 55 | |
56 | - $wpdb->donormeta = $this->table_name = $wpdb->prefix . 'give_donormeta'; |
|
56 | + $wpdb->donormeta = $this->table_name = $wpdb->prefix.'give_donormeta'; |
|
57 | 57 | $this->primary_key = 'meta_id'; |
58 | 58 | $this->version = '1.0'; |
59 | 59 | |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return bool False for failure. True for success. |
92 | 92 | */ |
93 | - public function delete_all_meta( $donor_id = 0 ) { |
|
93 | + public function delete_all_meta($donor_id = 0) { |
|
94 | 94 | global $wpdb; |
95 | - $status = $wpdb->delete( $this->table_name, array( 'customer_id' => $donor_id ), array( '%d' ) ); |
|
95 | + $status = $wpdb->delete($this->table_name, array('customer_id' => $donor_id), array('%d')); |
|
96 | 96 | |
97 | - if( $status ) { |
|
98 | - Give_Cache::delete_group( $donor_id, 'give-donors' ); |
|
97 | + if ($status) { |
|
98 | + Give_Cache::delete_group($donor_id, 'give-donors'); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function create_table() { |
111 | 111 | |
112 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
112 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
113 | 113 | |
114 | 114 | $sql = "CREATE TABLE {$this->table_name} ( |
115 | 115 | meta_id bigint(20) NOT NULL AUTO_INCREMENT, |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | KEY meta_key (meta_key) |
122 | 122 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
123 | 123 | |
124 | - dbDelta( $sql ); |
|
124 | + dbDelta($sql); |
|
125 | 125 | |
126 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
126 | + update_option($this->table_name.'_db_version', $this->version); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | global $wpdb; |
139 | 139 | |
140 | 140 | if ( |
141 | - ! give_has_upgrade_completed( 'v20_rename_donor_tables' ) && |
|
142 | - $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s","{$wpdb->prefix}give_customermeta" ) ) |
|
141 | + ! give_has_upgrade_completed('v20_rename_donor_tables') && |
|
142 | + $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customermeta")) |
|
143 | 143 | ) { |
144 | 144 | $wpdb->donormeta = $this->table_name = "{$wpdb->prefix}give_customermeta"; |
145 | 145 | $this->meta_type = 'customer'; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * |
159 | 159 | * @return bool |
160 | 160 | */ |
161 | - protected function is_valid_post_type( $ID ) { |
|
161 | + protected function is_valid_post_type($ID) { |
|
162 | 162 | return $ID && true; |
163 | 163 | } |
164 | 164 |