@@ -918,7 +918,7 @@ |
||
| 918 | 918 | * @access public |
| 919 | 919 | * |
| 920 | 920 | * @param string $meta_key Metadata name. Default is empty. |
| 921 | - * @param mixed $meta_value Optional. Metadata value. Default is empty. |
|
| 921 | + * @param string $meta_value Optional. Metadata value. Default is empty. |
|
| 922 | 922 | * |
| 923 | 923 | * @return bool False for failure. True for success. |
| 924 | 924 | */ |
@@ -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 | |
@@ -139,32 +139,32 @@ discard block |
||
| 139 | 139 | * @param bool $_id_or_email |
| 140 | 140 | * @param bool $by_user_id |
| 141 | 141 | */ |
| 142 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
| 142 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
| 143 | 143 | |
| 144 | 144 | $this->db = Give()->donors; |
| 145 | 145 | |
| 146 | 146 | if ( |
| 147 | 147 | false === $_id_or_email |
| 148 | - || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) |
|
| 148 | + || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email)) |
|
| 149 | 149 | ) { |
| 150 | 150 | return false; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
| 153 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
| 154 | 154 | |
| 155 | - if ( is_numeric( $_id_or_email ) ) { |
|
| 155 | + if (is_numeric($_id_or_email)) { |
|
| 156 | 156 | $field = $by_user_id ? 'user_id' : 'id'; |
| 157 | 157 | } else { |
| 158 | 158 | $field = 'email'; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - $donor = $this->db->get_donor_by( $field, $_id_or_email ); |
|
| 161 | + $donor = $this->db->get_donor_by($field, $_id_or_email); |
|
| 162 | 162 | |
| 163 | - if ( empty( $donor ) || ! is_object( $donor ) ) { |
|
| 163 | + if (empty($donor) || ! is_object($donor)) { |
|
| 164 | 164 | return false; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - $this->setup_donor( $donor ); |
|
| 167 | + $this->setup_donor($donor); |
|
| 168 | 168 | |
| 169 | 169 | } |
| 170 | 170 | |
@@ -180,15 +180,15 @@ discard block |
||
| 180 | 180 | * |
| 181 | 181 | * @return bool If the setup was successful or not. |
| 182 | 182 | */ |
| 183 | - private function setup_donor( $donor ) { |
|
| 183 | + private function setup_donor($donor) { |
|
| 184 | 184 | |
| 185 | - if ( ! is_object( $donor ) ) { |
|
| 185 | + if ( ! is_object($donor)) { |
|
| 186 | 186 | return false; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - foreach ( $donor as $key => $value ) { |
|
| 189 | + foreach ($donor as $key => $value) { |
|
| 190 | 190 | |
| 191 | - switch ( $key ) { |
|
| 191 | + switch ($key) { |
|
| 192 | 192 | |
| 193 | 193 | case 'notes': |
| 194 | 194 | $this->$key = $this->get_notes(); |
@@ -202,11 +202,11 @@ discard block |
||
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | // Get donor's all email including primary email. |
| 205 | - $this->emails = (array) $this->get_meta( 'additional_email', false ); |
|
| 206 | - $this->emails = array( 'primary' => $this->email ) + $this->emails; |
|
| 205 | + $this->emails = (array) $this->get_meta('additional_email', false); |
|
| 206 | + $this->emails = array('primary' => $this->email) + $this->emails; |
|
| 207 | 207 | |
| 208 | 208 | // Donor ID and email are the only things that are necessary, make sure they exist. |
| 209 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
| 209 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
| 210 | 210 | return true; |
| 211 | 211 | } |
| 212 | 212 | |
@@ -223,16 +223,16 @@ discard block |
||
| 223 | 223 | * |
| 224 | 224 | * @return mixed|\WP_Error |
| 225 | 225 | */ |
| 226 | - public function __get( $key ) { |
|
| 226 | + public function __get($key) { |
|
| 227 | 227 | |
| 228 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
| 228 | + if (method_exists($this, 'get_'.$key)) { |
|
| 229 | 229 | |
| 230 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
| 230 | + return call_user_func(array($this, 'get_'.$key)); |
|
| 231 | 231 | |
| 232 | 232 | } else { |
| 233 | 233 | |
| 234 | 234 | /* translators: %s: property key */ |
| 235 | - return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
| 235 | + return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
| 236 | 236 | |
| 237 | 237 | } |
| 238 | 238 | |
@@ -248,9 +248,9 @@ discard block |
||
| 248 | 248 | * |
| 249 | 249 | * @return bool|int False if not a valid creation, donor ID if user is found or valid creation. |
| 250 | 250 | */ |
| 251 | - public function create( $data = array() ) { |
|
| 251 | + public function create($data = array()) { |
|
| 252 | 252 | |
| 253 | - if ( $this->id != 0 || empty( $data ) ) { |
|
| 253 | + if ($this->id != 0 || empty($data)) { |
|
| 254 | 254 | return false; |
| 255 | 255 | } |
| 256 | 256 | |
@@ -258,15 +258,15 @@ discard block |
||
| 258 | 258 | 'payment_ids' => '', |
| 259 | 259 | ); |
| 260 | 260 | |
| 261 | - $args = wp_parse_args( $data, $defaults ); |
|
| 262 | - $args = $this->sanitize_columns( $args ); |
|
| 261 | + $args = wp_parse_args($data, $defaults); |
|
| 262 | + $args = $this->sanitize_columns($args); |
|
| 263 | 263 | |
| 264 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
| 264 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
| 265 | 265 | return false; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
| 269 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
| 268 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
| 269 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | /** |
@@ -276,18 +276,18 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | * @param array $args Donor attributes. |
| 278 | 278 | */ |
| 279 | - do_action( 'give_donor_pre_create', $args ); |
|
| 279 | + do_action('give_donor_pre_create', $args); |
|
| 280 | 280 | |
| 281 | 281 | $created = false; |
| 282 | 282 | |
| 283 | 283 | // The DB class 'add' implies an update if the donor being asked to be created already exists |
| 284 | - if ( $this->db->add( $data ) ) { |
|
| 284 | + if ($this->db->add($data)) { |
|
| 285 | 285 | |
| 286 | 286 | // We've successfully added/updated the donor, reset the class vars with the new data |
| 287 | - $donor = $this->db->get_donor_by( 'email', $args['email'] ); |
|
| 287 | + $donor = $this->db->get_donor_by('email', $args['email']); |
|
| 288 | 288 | |
| 289 | 289 | // Setup the donor data with the values from DB |
| 290 | - $this->setup_donor( $donor ); |
|
| 290 | + $this->setup_donor($donor); |
|
| 291 | 291 | |
| 292 | 292 | $created = $this->id; |
| 293 | 293 | } |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation. |
| 301 | 301 | * @param array $args Customer attributes. |
| 302 | 302 | */ |
| 303 | - do_action( 'give_donor_post_create', $created, $args ); |
|
| 303 | + do_action('give_donor_post_create', $created, $args); |
|
| 304 | 304 | |
| 305 | 305 | return $created; |
| 306 | 306 | |
@@ -316,13 +316,13 @@ discard block |
||
| 316 | 316 | * |
| 317 | 317 | * @return bool If the update was successful or not. |
| 318 | 318 | */ |
| 319 | - public function update( $data = array() ) { |
|
| 319 | + public function update($data = array()) { |
|
| 320 | 320 | |
| 321 | - if ( empty( $data ) ) { |
|
| 321 | + if (empty($data)) { |
|
| 322 | 322 | return false; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - $data = $this->sanitize_columns( $data ); |
|
| 325 | + $data = $this->sanitize_columns($data); |
|
| 326 | 326 | |
| 327 | 327 | /** |
| 328 | 328 | * Fires before updating donors. |
@@ -332,14 +332,14 @@ discard block |
||
| 332 | 332 | * @param int $donor_id Donor id. |
| 333 | 333 | * @param array $data Donor attributes. |
| 334 | 334 | */ |
| 335 | - do_action( 'give_donor_pre_update', $this->id, $data ); |
|
| 335 | + do_action('give_donor_pre_update', $this->id, $data); |
|
| 336 | 336 | |
| 337 | 337 | $updated = false; |
| 338 | 338 | |
| 339 | - if ( $this->db->update( $this->id, $data ) ) { |
|
| 339 | + if ($this->db->update($this->id, $data)) { |
|
| 340 | 340 | |
| 341 | - $donor = $this->db->get_donor_by( 'id', $this->id ); |
|
| 342 | - $this->setup_donor( $donor ); |
|
| 341 | + $donor = $this->db->get_donor_by('id', $this->id); |
|
| 342 | + $this->setup_donor($donor); |
|
| 343 | 343 | |
| 344 | 344 | $updated = true; |
| 345 | 345 | } |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | * @param int $donor_id Donor id. |
| 354 | 354 | * @param array $data Donor attributes. |
| 355 | 355 | */ |
| 356 | - do_action( 'give_donor_post_update', $updated, $this->id, $data ); |
|
| 356 | + do_action('give_donor_post_update', $updated, $this->id, $data); |
|
| 357 | 357 | |
| 358 | 358 | return $updated; |
| 359 | 359 | } |
@@ -371,27 +371,27 @@ discard block |
||
| 371 | 371 | * |
| 372 | 372 | * @return bool If the attachment was successfully. |
| 373 | 373 | */ |
| 374 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
| 374 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
| 375 | 375 | |
| 376 | - if ( empty( $payment_id ) ) { |
|
| 376 | + if (empty($payment_id)) { |
|
| 377 | 377 | return false; |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | - if ( empty( $this->payment_ids ) ) { |
|
| 380 | + if (empty($this->payment_ids)) { |
|
| 381 | 381 | |
| 382 | 382 | $new_payment_ids = $payment_id; |
| 383 | 383 | |
| 384 | 384 | } else { |
| 385 | 385 | |
| 386 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
| 386 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
| 387 | 387 | |
| 388 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
| 388 | + if (in_array($payment_id, $payment_ids)) { |
|
| 389 | 389 | $update_stats = false; |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | $payment_ids[] = $payment_id; |
| 393 | 393 | |
| 394 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
| 394 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
| 395 | 395 | |
| 396 | 396 | } |
| 397 | 397 | |
@@ -403,20 +403,20 @@ discard block |
||
| 403 | 403 | * @param int $payment_id Payment id. |
| 404 | 404 | * @param int $donor_id Customer id. |
| 405 | 405 | */ |
| 406 | - do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id ); |
|
| 406 | + do_action('give_donor_pre_attach_payment', $payment_id, $this->id); |
|
| 407 | 407 | |
| 408 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
| 408 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
| 409 | 409 | |
| 410 | - if ( $payment_added ) { |
|
| 410 | + if ($payment_added) { |
|
| 411 | 411 | |
| 412 | 412 | $this->payment_ids = $new_payment_ids; |
| 413 | 413 | |
| 414 | 414 | // We added this payment successfully, increment the stats |
| 415 | - if ( $update_stats ) { |
|
| 416 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 415 | + if ($update_stats) { |
|
| 416 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 417 | 417 | |
| 418 | - if ( ! empty( $payment_amount ) ) { |
|
| 419 | - $this->increase_value( $payment_amount ); |
|
| 418 | + if ( ! empty($payment_amount)) { |
|
| 419 | + $this->increase_value($payment_amount); |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | $this->increase_purchase_count(); |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | * @param int $payment_id Payment id. |
| 433 | 433 | * @param int $donor_id Donor id. |
| 434 | 434 | */ |
| 435 | - do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
| 435 | + do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
| 436 | 436 | |
| 437 | 437 | return $payment_added; |
| 438 | 438 | } |
@@ -450,33 +450,33 @@ discard block |
||
| 450 | 450 | * |
| 451 | 451 | * @return boolean If the removal was successful. |
| 452 | 452 | */ |
| 453 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
| 453 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
| 454 | 454 | |
| 455 | - if ( empty( $payment_id ) ) { |
|
| 455 | + if (empty($payment_id)) { |
|
| 456 | 456 | return false; |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | - $payment = new Give_Payment( $payment_id ); |
|
| 459 | + $payment = new Give_Payment($payment_id); |
|
| 460 | 460 | |
| 461 | - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { |
|
| 461 | + if ('publish' !== $payment->status && 'revoked' !== $payment->status) { |
|
| 462 | 462 | $update_stats = false; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | $new_payment_ids = ''; |
| 466 | 466 | |
| 467 | - if ( ! empty( $this->payment_ids ) ) { |
|
| 467 | + if ( ! empty($this->payment_ids)) { |
|
| 468 | 468 | |
| 469 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
| 469 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
| 470 | 470 | |
| 471 | - $pos = array_search( $payment_id, $payment_ids ); |
|
| 472 | - if ( false === $pos ) { |
|
| 471 | + $pos = array_search($payment_id, $payment_ids); |
|
| 472 | + if (false === $pos) { |
|
| 473 | 473 | return false; |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | - unset( $payment_ids[ $pos ] ); |
|
| 477 | - $payment_ids = array_filter( $payment_ids ); |
|
| 476 | + unset($payment_ids[$pos]); |
|
| 477 | + $payment_ids = array_filter($payment_ids); |
|
| 478 | 478 | |
| 479 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
| 479 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
| 480 | 480 | |
| 481 | 481 | } |
| 482 | 482 | |
@@ -488,20 +488,20 @@ discard block |
||
| 488 | 488 | * @param int $payment_id Payment id. |
| 489 | 489 | * @param int $donor_id Customer id. |
| 490 | 490 | */ |
| 491 | - do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id ); |
|
| 491 | + do_action('give_donor_pre_remove_payment', $payment_id, $this->id); |
|
| 492 | 492 | |
| 493 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
| 493 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
| 494 | 494 | |
| 495 | - if ( $payment_removed ) { |
|
| 495 | + if ($payment_removed) { |
|
| 496 | 496 | |
| 497 | 497 | $this->payment_ids = $new_payment_ids; |
| 498 | 498 | |
| 499 | - if ( $update_stats ) { |
|
| 499 | + if ($update_stats) { |
|
| 500 | 500 | // We removed this payment successfully, decrement the stats |
| 501 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 501 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 502 | 502 | |
| 503 | - if ( ! empty( $payment_amount ) ) { |
|
| 504 | - $this->decrease_value( $payment_amount ); |
|
| 503 | + if ( ! empty($payment_amount)) { |
|
| 504 | + $this->decrease_value($payment_amount); |
|
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | $this->decrease_donation_count(); |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | * @param int $payment_id Payment id. |
| 518 | 518 | * @param int $donor_id Donor id. |
| 519 | 519 | */ |
| 520 | - do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
| 520 | + do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
| 521 | 521 | |
| 522 | 522 | return $payment_removed; |
| 523 | 523 | |
@@ -533,10 +533,10 @@ discard block |
||
| 533 | 533 | * |
| 534 | 534 | * @return int The donation count. |
| 535 | 535 | */ |
| 536 | - public function increase_purchase_count( $count = 1 ) { |
|
| 536 | + public function increase_purchase_count($count = 1) { |
|
| 537 | 537 | |
| 538 | 538 | // Make sure it's numeric and not negative. |
| 539 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
| 539 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
| 540 | 540 | return false; |
| 541 | 541 | } |
| 542 | 542 | |
@@ -550,9 +550,9 @@ discard block |
||
| 550 | 550 | * @param int $count The number to increase by. |
| 551 | 551 | * @param int $donor_id Donor id. |
| 552 | 552 | */ |
| 553 | - do_action( 'give_donor_pre_increase_donation_count', $count, $this->id ); |
|
| 553 | + do_action('give_donor_pre_increase_donation_count', $count, $this->id); |
|
| 554 | 554 | |
| 555 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
| 555 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
| 556 | 556 | $this->purchase_count = $new_total; |
| 557 | 557 | } |
| 558 | 558 | |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | * @param int $count The number increased by. |
| 566 | 566 | * @param int $donor_id Donor id. |
| 567 | 567 | */ |
| 568 | - do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id ); |
|
| 568 | + do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id); |
|
| 569 | 569 | |
| 570 | 570 | return $this->purchase_count; |
| 571 | 571 | } |
@@ -580,16 +580,16 @@ discard block |
||
| 580 | 580 | * |
| 581 | 581 | * @return mixed If successful, the new count, otherwise false. |
| 582 | 582 | */ |
| 583 | - public function decrease_donation_count( $count = 1 ) { |
|
| 583 | + public function decrease_donation_count($count = 1) { |
|
| 584 | 584 | |
| 585 | 585 | // Make sure it's numeric and not negative |
| 586 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
| 586 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
| 587 | 587 | return false; |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | $new_total = (int) $this->purchase_count - (int) $count; |
| 591 | 591 | |
| 592 | - if ( $new_total < 0 ) { |
|
| 592 | + if ($new_total < 0) { |
|
| 593 | 593 | $new_total = 0; |
| 594 | 594 | } |
| 595 | 595 | |
@@ -601,9 +601,9 @@ discard block |
||
| 601 | 601 | * @param int $count The number to decrease by. |
| 602 | 602 | * @param int $donor_id Customer id. |
| 603 | 603 | */ |
| 604 | - do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id ); |
|
| 604 | + do_action('give_donor_pre_decrease_donation_count', $count, $this->id); |
|
| 605 | 605 | |
| 606 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
| 606 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
| 607 | 607 | $this->purchase_count = $new_total; |
| 608 | 608 | } |
| 609 | 609 | |
@@ -616,7 +616,7 @@ discard block |
||
| 616 | 616 | * @param int $count The number decreased by. |
| 617 | 617 | * @param int $donor_id Donor id. |
| 618 | 618 | */ |
| 619 | - do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id ); |
|
| 619 | + do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id); |
|
| 620 | 620 | |
| 621 | 621 | return $this->purchase_count; |
| 622 | 622 | } |
@@ -631,9 +631,9 @@ discard block |
||
| 631 | 631 | * |
| 632 | 632 | * @return mixed If successful, the new value, otherwise false. |
| 633 | 633 | */ |
| 634 | - public function increase_value( $value = 0.00 ) { |
|
| 634 | + public function increase_value($value = 0.00) { |
|
| 635 | 635 | |
| 636 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
| 636 | + $new_value = floatval($this->purchase_value) + $value; |
|
| 637 | 637 | |
| 638 | 638 | /** |
| 639 | 639 | * Fires before increasing donor lifetime value. |
@@ -643,9 +643,9 @@ discard block |
||
| 643 | 643 | * @param float $value The value to increase by. |
| 644 | 644 | * @param int $donor_id Customer id. |
| 645 | 645 | */ |
| 646 | - do_action( 'give_donor_pre_increase_value', $value, $this->id ); |
|
| 646 | + do_action('give_donor_pre_increase_value', $value, $this->id); |
|
| 647 | 647 | |
| 648 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
| 648 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
| 649 | 649 | $this->purchase_value = $new_value; |
| 650 | 650 | } |
| 651 | 651 | |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | * @param float $value The value increased by. |
| 659 | 659 | * @param int $donor_id Donor id. |
| 660 | 660 | */ |
| 661 | - do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
| 661 | + do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id); |
|
| 662 | 662 | |
| 663 | 663 | return $this->purchase_value; |
| 664 | 664 | } |
@@ -673,11 +673,11 @@ discard block |
||
| 673 | 673 | * |
| 674 | 674 | * @return mixed If successful, the new value, otherwise false. |
| 675 | 675 | */ |
| 676 | - public function decrease_value( $value = 0.00 ) { |
|
| 676 | + public function decrease_value($value = 0.00) { |
|
| 677 | 677 | |
| 678 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
| 678 | + $new_value = floatval($this->purchase_value) - $value; |
|
| 679 | 679 | |
| 680 | - if ( $new_value < 0 ) { |
|
| 680 | + if ($new_value < 0) { |
|
| 681 | 681 | $new_value = 0.00; |
| 682 | 682 | } |
| 683 | 683 | |
@@ -689,9 +689,9 @@ discard block |
||
| 689 | 689 | * @param float $value The value to decrease by. |
| 690 | 690 | * @param int $donor_id Donor id. |
| 691 | 691 | */ |
| 692 | - do_action( 'give_donor_pre_decrease_value', $value, $this->id ); |
|
| 692 | + do_action('give_donor_pre_decrease_value', $value, $this->id); |
|
| 693 | 693 | |
| 694 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
| 694 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
| 695 | 695 | $this->purchase_value = $new_value; |
| 696 | 696 | } |
| 697 | 697 | |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | * @param float $value The value decreased by. |
| 705 | 705 | * @param int $donor_id Donor id. |
| 706 | 706 | */ |
| 707 | - do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
| 707 | + do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
| 708 | 708 | |
| 709 | 709 | return $this->purchase_value; |
| 710 | 710 | } |
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | * |
| 724 | 724 | * @return mixed If successful, the new donation stat value, otherwise false. |
| 725 | 725 | */ |
| 726 | - public function update_donation_value( $curr_amount, $new_amount ) { |
|
| 726 | + public function update_donation_value($curr_amount, $new_amount) { |
|
| 727 | 727 | /** |
| 728 | 728 | * Payment total difference value can be: |
| 729 | 729 | * zero (in case amount not change) |
@@ -733,15 +733,15 @@ discard block |
||
| 733 | 733 | $payment_total_diff = $new_amount - $curr_amount; |
| 734 | 734 | |
| 735 | 735 | // We do not need to update donation stat if donation did not change. |
| 736 | - if ( ! $payment_total_diff ) { |
|
| 736 | + if ( ! $payment_total_diff) { |
|
| 737 | 737 | return false; |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | - if ( $payment_total_diff > 0 ) { |
|
| 741 | - $this->increase_value( $payment_total_diff ); |
|
| 740 | + if ($payment_total_diff > 0) { |
|
| 741 | + $this->increase_value($payment_total_diff); |
|
| 742 | 742 | } else { |
| 743 | 743 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
| 744 | - $this->decrease_value( - $payment_total_diff ); |
|
| 744 | + $this->decrease_value( -$payment_total_diff ); |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | return $this->purchase_value; |
@@ -758,15 +758,15 @@ discard block |
||
| 758 | 758 | * |
| 759 | 759 | * @return array The notes requested. |
| 760 | 760 | */ |
| 761 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
| 761 | + public function get_notes($length = 20, $paged = 1) { |
|
| 762 | 762 | |
| 763 | - $length = is_numeric( $length ) ? $length : 20; |
|
| 764 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
| 763 | + $length = is_numeric($length) ? $length : 20; |
|
| 764 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
| 765 | 765 | |
| 766 | 766 | $all_notes = $this->get_raw_notes(); |
| 767 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
| 767 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
| 768 | 768 | |
| 769 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
| 769 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
| 770 | 770 | |
| 771 | 771 | return $desired_notes; |
| 772 | 772 | |
@@ -783,9 +783,9 @@ discard block |
||
| 783 | 783 | public function get_notes_count() { |
| 784 | 784 | |
| 785 | 785 | $all_notes = $this->get_raw_notes(); |
| 786 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
| 786 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
| 787 | 787 | |
| 788 | - return count( $notes_array ); |
|
| 788 | + return count($notes_array); |
|
| 789 | 789 | |
| 790 | 790 | } |
| 791 | 791 | |
@@ -799,22 +799,22 @@ discard block |
||
| 799 | 799 | * |
| 800 | 800 | * @return string|boolean The new note if added successfully, false otherwise. |
| 801 | 801 | */ |
| 802 | - public function add_note( $note = '' ) { |
|
| 802 | + public function add_note($note = '') { |
|
| 803 | 803 | |
| 804 | - $note = trim( $note ); |
|
| 805 | - if ( empty( $note ) ) { |
|
| 804 | + $note = trim($note); |
|
| 805 | + if (empty($note)) { |
|
| 806 | 806 | return false; |
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 809 | $notes = $this->get_raw_notes(); |
| 810 | 810 | |
| 811 | - if ( empty( $notes ) ) { |
|
| 811 | + if (empty($notes)) { |
|
| 812 | 812 | $notes = ''; |
| 813 | 813 | } |
| 814 | 814 | |
| 815 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
| 816 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
| 817 | - $notes .= "\n\n" . $new_note; |
|
| 815 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
| 816 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
| 817 | + $notes .= "\n\n".$new_note; |
|
| 818 | 818 | |
| 819 | 819 | /** |
| 820 | 820 | * Fires before donor note is added. |
@@ -824,11 +824,11 @@ discard block |
||
| 824 | 824 | * @param string $new_note New note to add. |
| 825 | 825 | * @param int $donor_id Donor id. |
| 826 | 826 | */ |
| 827 | - do_action( 'give_donor_pre_add_note', $new_note, $this->id ); |
|
| 827 | + do_action('give_donor_pre_add_note', $new_note, $this->id); |
|
| 828 | 828 | |
| 829 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
| 829 | + $updated = $this->update(array('notes' => $notes)); |
|
| 830 | 830 | |
| 831 | - if ( $updated ) { |
|
| 831 | + if ($updated) { |
|
| 832 | 832 | $this->notes = $this->get_notes(); |
| 833 | 833 | } |
| 834 | 834 | |
@@ -841,7 +841,7 @@ discard block |
||
| 841 | 841 | * @param string $new_note New note added. |
| 842 | 842 | * @param int $donor_id Donor id. |
| 843 | 843 | */ |
| 844 | - do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id ); |
|
| 844 | + do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id); |
|
| 845 | 845 | |
| 846 | 846 | // Return the formatted note, so we can test, as well as update any displays |
| 847 | 847 | return $new_note; |
@@ -858,7 +858,7 @@ discard block |
||
| 858 | 858 | */ |
| 859 | 859 | private function get_raw_notes() { |
| 860 | 860 | |
| 861 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
| 861 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
| 862 | 862 | |
| 863 | 863 | return $all_notes; |
| 864 | 864 | |
@@ -875,8 +875,8 @@ discard block |
||
| 875 | 875 | * |
| 876 | 876 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
| 877 | 877 | */ |
| 878 | - public function get_meta( $meta_key = '', $single = true ) { |
|
| 879 | - return Give()->donor_meta->get_meta( $this->id, $meta_key, $single ); |
|
| 878 | + public function get_meta($meta_key = '', $single = true) { |
|
| 879 | + return Give()->donor_meta->get_meta($this->id, $meta_key, $single); |
|
| 880 | 880 | } |
| 881 | 881 | |
| 882 | 882 | /** |
@@ -891,8 +891,8 @@ discard block |
||
| 891 | 891 | * |
| 892 | 892 | * @return bool False for failure. True for success. |
| 893 | 893 | */ |
| 894 | - public function add_meta( $meta_key = '', $meta_value, $unique = false ) { |
|
| 895 | - return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique ); |
|
| 894 | + public function add_meta($meta_key = '', $meta_value, $unique = false) { |
|
| 895 | + return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique); |
|
| 896 | 896 | } |
| 897 | 897 | |
| 898 | 898 | /** |
@@ -907,8 +907,8 @@ discard block |
||
| 907 | 907 | * |
| 908 | 908 | * @return bool False on failure, true if success. |
| 909 | 909 | */ |
| 910 | - public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) { |
|
| 911 | - return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value ); |
|
| 910 | + public function update_meta($meta_key = '', $meta_value, $prev_value = '') { |
|
| 911 | + return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value); |
|
| 912 | 912 | } |
| 913 | 913 | |
| 914 | 914 | /** |
@@ -922,8 +922,8 @@ discard block |
||
| 922 | 922 | * |
| 923 | 923 | * @return bool False for failure. True for success. |
| 924 | 924 | */ |
| 925 | - public function delete_meta( $meta_key = '', $meta_value = '' ) { |
|
| 926 | - return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value ); |
|
| 925 | + public function delete_meta($meta_key = '', $meta_value = '') { |
|
| 926 | + return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value); |
|
| 927 | 927 | } |
| 928 | 928 | |
| 929 | 929 | /** |
@@ -936,51 +936,51 @@ discard block |
||
| 936 | 936 | * |
| 937 | 937 | * @return array The sanitized data, based off column defaults. |
| 938 | 938 | */ |
| 939 | - private function sanitize_columns( $data ) { |
|
| 939 | + private function sanitize_columns($data) { |
|
| 940 | 940 | |
| 941 | 941 | $columns = $this->db->get_columns(); |
| 942 | 942 | $default_values = $this->db->get_column_defaults(); |
| 943 | 943 | |
| 944 | - foreach ( $columns as $key => $type ) { |
|
| 944 | + foreach ($columns as $key => $type) { |
|
| 945 | 945 | |
| 946 | 946 | // Only sanitize data that we were provided |
| 947 | - if ( ! array_key_exists( $key, $data ) ) { |
|
| 947 | + if ( ! array_key_exists($key, $data)) { |
|
| 948 | 948 | continue; |
| 949 | 949 | } |
| 950 | 950 | |
| 951 | - switch ( $type ) { |
|
| 951 | + switch ($type) { |
|
| 952 | 952 | |
| 953 | 953 | case '%s': |
| 954 | - if ( 'email' == $key ) { |
|
| 955 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
| 956 | - } elseif ( 'notes' == $key ) { |
|
| 957 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
| 954 | + if ('email' == $key) { |
|
| 955 | + $data[$key] = sanitize_email($data[$key]); |
|
| 956 | + } elseif ('notes' == $key) { |
|
| 957 | + $data[$key] = strip_tags($data[$key]); |
|
| 958 | 958 | } else { |
| 959 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
| 959 | + $data[$key] = sanitize_text_field($data[$key]); |
|
| 960 | 960 | } |
| 961 | 961 | break; |
| 962 | 962 | |
| 963 | 963 | case '%d': |
| 964 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
| 965 | - $data[ $key ] = $default_values[ $key ]; |
|
| 964 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
| 965 | + $data[$key] = $default_values[$key]; |
|
| 966 | 966 | } else { |
| 967 | - $data[ $key ] = absint( $data[ $key ] ); |
|
| 967 | + $data[$key] = absint($data[$key]); |
|
| 968 | 968 | } |
| 969 | 969 | break; |
| 970 | 970 | |
| 971 | 971 | case '%f': |
| 972 | 972 | // Convert what was given to a float |
| 973 | - $value = floatval( $data[ $key ] ); |
|
| 973 | + $value = floatval($data[$key]); |
|
| 974 | 974 | |
| 975 | - if ( ! is_float( $value ) ) { |
|
| 976 | - $data[ $key ] = $default_values[ $key ]; |
|
| 975 | + if ( ! is_float($value)) { |
|
| 976 | + $data[$key] = $default_values[$key]; |
|
| 977 | 977 | } else { |
| 978 | - $data[ $key ] = $value; |
|
| 978 | + $data[$key] = $value; |
|
| 979 | 979 | } |
| 980 | 980 | break; |
| 981 | 981 | |
| 982 | 982 | default: |
| 983 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
| 983 | + $data[$key] = sanitize_text_field($data[$key]); |
|
| 984 | 984 | break; |
| 985 | 985 | |
| 986 | 986 | } |
@@ -1000,33 +1000,33 @@ discard block |
||
| 1000 | 1000 | * |
| 1001 | 1001 | * @return bool If the email was added successfully |
| 1002 | 1002 | */ |
| 1003 | - public function add_email( $email = '', $primary = false ) { |
|
| 1004 | - if ( ! is_email( $email ) ) { |
|
| 1003 | + public function add_email($email = '', $primary = false) { |
|
| 1004 | + if ( ! is_email($email)) { |
|
| 1005 | 1005 | return false; |
| 1006 | 1006 | } |
| 1007 | - $existing = new Give_Donor( $email ); |
|
| 1007 | + $existing = new Give_Donor($email); |
|
| 1008 | 1008 | |
| 1009 | - if ( $existing->id > 0 ) { |
|
| 1009 | + if ($existing->id > 0) { |
|
| 1010 | 1010 | // Email address already belongs to another donor |
| 1011 | 1011 | return false; |
| 1012 | 1012 | } |
| 1013 | 1013 | |
| 1014 | - if ( email_exists( $email ) ) { |
|
| 1015 | - $user = get_user_by( 'email', $email ); |
|
| 1016 | - if ( $user->ID != $this->user_id ) { |
|
| 1014 | + if (email_exists($email)) { |
|
| 1015 | + $user = get_user_by('email', $email); |
|
| 1016 | + if ($user->ID != $this->user_id) { |
|
| 1017 | 1017 | return false; |
| 1018 | 1018 | } |
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | - do_action( 'give_donor_pre_add_email', $email, $this->id, $this ); |
|
| 1021 | + do_action('give_donor_pre_add_email', $email, $this->id, $this); |
|
| 1022 | 1022 | |
| 1023 | 1023 | // Add is used to ensure duplicate emails are not added |
| 1024 | - $ret = (bool) $this->add_meta( 'additional_email', $email ); |
|
| 1024 | + $ret = (bool) $this->add_meta('additional_email', $email); |
|
| 1025 | 1025 | |
| 1026 | - do_action( 'give_donor_post_add_email', $email, $this->id, $this ); |
|
| 1026 | + do_action('give_donor_post_add_email', $email, $this->id, $this); |
|
| 1027 | 1027 | |
| 1028 | - if ( $ret && true === $primary ) { |
|
| 1029 | - $this->set_primary_email( $email ); |
|
| 1028 | + if ($ret && true === $primary) { |
|
| 1029 | + $this->set_primary_email($email); |
|
| 1030 | 1030 | } |
| 1031 | 1031 | |
| 1032 | 1032 | return $ret; |
@@ -1042,16 +1042,16 @@ discard block |
||
| 1042 | 1042 | * |
| 1043 | 1043 | * @return bool If the email was removed successfully. |
| 1044 | 1044 | */ |
| 1045 | - public function remove_email( $email = '' ) { |
|
| 1046 | - if ( ! is_email( $email ) ) { |
|
| 1045 | + public function remove_email($email = '') { |
|
| 1046 | + if ( ! is_email($email)) { |
|
| 1047 | 1047 | return false; |
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | - do_action( 'give_donor_pre_remove_email', $email, $this->id, $this ); |
|
| 1050 | + do_action('give_donor_pre_remove_email', $email, $this->id, $this); |
|
| 1051 | 1051 | |
| 1052 | - $ret = (bool) $this->delete_meta( 'additional_email', $email ); |
|
| 1052 | + $ret = (bool) $this->delete_meta('additional_email', $email); |
|
| 1053 | 1053 | |
| 1054 | - do_action( 'give_donor_post_remove_email', $email, $this->id, $this ); |
|
| 1054 | + do_action('give_donor_post_remove_email', $email, $this->id, $this); |
|
| 1055 | 1055 | |
| 1056 | 1056 | return $ret; |
| 1057 | 1057 | } |
@@ -1068,16 +1068,16 @@ discard block |
||
| 1068 | 1068 | * |
| 1069 | 1069 | * @return bool If the email was set as primary successfully. |
| 1070 | 1070 | */ |
| 1071 | - public function set_primary_email( $new_primary_email = '' ) { |
|
| 1072 | - if ( ! is_email( $new_primary_email ) ) { |
|
| 1071 | + public function set_primary_email($new_primary_email = '') { |
|
| 1072 | + if ( ! is_email($new_primary_email)) { |
|
| 1073 | 1073 | return false; |
| 1074 | 1074 | } |
| 1075 | 1075 | |
| 1076 | - do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this ); |
|
| 1076 | + do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this); |
|
| 1077 | 1077 | |
| 1078 | - $existing = new Give_Donor( $new_primary_email ); |
|
| 1078 | + $existing = new Give_Donor($new_primary_email); |
|
| 1079 | 1079 | |
| 1080 | - if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) { |
|
| 1080 | + if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) { |
|
| 1081 | 1081 | // This email belongs to another donor. |
| 1082 | 1082 | return false; |
| 1083 | 1083 | } |
@@ -1085,21 +1085,21 @@ discard block |
||
| 1085 | 1085 | $old_email = $this->email; |
| 1086 | 1086 | |
| 1087 | 1087 | // Update donor record with new email. |
| 1088 | - $update = $this->update( array( 'email' => $new_primary_email ) ); |
|
| 1088 | + $update = $this->update(array('email' => $new_primary_email)); |
|
| 1089 | 1089 | |
| 1090 | 1090 | // Remove new primary from list of additional emails. |
| 1091 | - $remove = $this->remove_email( $new_primary_email ); |
|
| 1091 | + $remove = $this->remove_email($new_primary_email); |
|
| 1092 | 1092 | |
| 1093 | 1093 | // Add old email to additional emails list. |
| 1094 | - $add = $this->add_email( $old_email ); |
|
| 1094 | + $add = $this->add_email($old_email); |
|
| 1095 | 1095 | |
| 1096 | 1096 | $ret = $update && $remove && $add; |
| 1097 | 1097 | |
| 1098 | - if ( $ret ) { |
|
| 1098 | + if ($ret) { |
|
| 1099 | 1099 | $this->email = $new_primary_email; |
| 1100 | 1100 | } |
| 1101 | 1101 | |
| 1102 | - do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this ); |
|
| 1102 | + do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this); |
|
| 1103 | 1103 | |
| 1104 | 1104 | return $ret; |
| 1105 | 1105 | } |
@@ -1481,6 +1481,7 @@ discard block |
||
| 1481 | 1481 | * Check if Import donation is duplicate |
| 1482 | 1482 | * |
| 1483 | 1483 | * @since 1.8.13 |
| 1484 | + * @param Give_Donate_Form $form |
|
| 1484 | 1485 | */ |
| 1485 | 1486 | function give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) { |
| 1486 | 1487 | $return = false; |
@@ -1566,7 +1567,6 @@ discard block |
||
| 1566 | 1567 | * Import CSV in DB |
| 1567 | 1568 | * |
| 1568 | 1569 | * @param int $file_id CSV id |
| 1569 | - * @param array $mapto Map csv to meta key. |
|
| 1570 | 1570 | * @param int $start Start from which csv line. |
| 1571 | 1571 | * @param int $end End from which csv line. |
| 1572 | 1572 | */ |
@@ -2055,7 +2055,7 @@ discard block |
||
| 2055 | 2055 | * @since 1.8.13 |
| 2056 | 2056 | * |
| 2057 | 2057 | * @param array $list List of objects or arrays |
| 2058 | - * @param int|string $field Field from the object to place instead of the entire object |
|
| 2058 | + * @param string $field Field from the object to place instead of the entire object |
|
| 2059 | 2059 | * @param int|string $index_key Optional. Field from the object to use as keys for the new array. |
| 2060 | 2060 | * Default null. |
| 2061 | 2061 | * |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | function give_is_test_mode() { |
| 25 | 25 | |
| 26 | - $ret = give_is_setting_enabled( give_get_option( 'test_mode' ) ); |
|
| 26 | + $ret = give_is_setting_enabled(give_get_option('test_mode')); |
|
| 27 | 27 | |
| 28 | - return (bool) apply_filters( 'give_is_test_mode', $ret ); |
|
| 28 | + return (bool) apply_filters('give_is_test_mode', $ret); |
|
| 29 | 29 | |
| 30 | 30 | } |
| 31 | 31 | |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | function give_get_currency() { |
| 39 | 39 | |
| 40 | - $currency = give_get_option( 'currency', 'USD' ); |
|
| 40 | + $currency = give_get_option('currency', 'USD'); |
|
| 41 | 41 | |
| 42 | - return apply_filters( 'give_currency', $currency ); |
|
| 42 | + return apply_filters('give_currency', $currency); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | function give_get_currency_position() { |
| 53 | 53 | |
| 54 | - $currency_pos = give_get_option( 'currency_position', 'before' ); |
|
| 54 | + $currency_pos = give_get_option('currency_position', 'before'); |
|
| 55 | 55 | |
| 56 | - return apply_filters( 'give_currency_position', $currency_pos ); |
|
| 56 | + return apply_filters('give_currency_position', $currency_pos); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | |
@@ -66,39 +66,39 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | function give_get_currencies() { |
| 68 | 68 | $currencies = array( |
| 69 | - 'USD' => __( 'US Dollars ($)', 'give' ), |
|
| 70 | - 'EUR' => __( 'Euros (€)', 'give' ), |
|
| 71 | - 'GBP' => __( 'Pounds Sterling (£)', 'give' ), |
|
| 72 | - 'AUD' => __( 'Australian Dollars ($)', 'give' ), |
|
| 73 | - 'BRL' => __( 'Brazilian Real (R$)', 'give' ), |
|
| 74 | - 'CAD' => __( 'Canadian Dollars ($)', 'give' ), |
|
| 75 | - 'CZK' => __( 'Czech Koruna (Kč)', 'give' ), |
|
| 76 | - 'DKK' => __( 'Danish Krone (kr.)', 'give' ), |
|
| 77 | - 'HKD' => __( 'Hong Kong Dollar ($)', 'give' ), |
|
| 78 | - 'HUF' => __( 'Hungarian Forint (Ft)', 'give' ), |
|
| 79 | - 'ILS' => __( 'Israeli Shekel (₪)', 'give' ), |
|
| 80 | - 'JPY' => __( 'Japanese Yen (¥)', 'give' ), |
|
| 81 | - 'MYR' => __( 'Malaysian Ringgits (RM)', 'give' ), |
|
| 82 | - 'MXN' => __( 'Mexican Peso ($)', 'give' ), |
|
| 83 | - 'MAD' => __( 'Moroccan Dirham (.د.م)', 'give' ), |
|
| 84 | - 'NZD' => __( 'New Zealand Dollar ($)', 'give' ), |
|
| 85 | - 'NOK' => __( 'Norwegian Krone (Kr.)', 'give' ), |
|
| 86 | - 'PHP' => __( 'Philippine Pesos (₱)', 'give' ), |
|
| 87 | - 'PLN' => __( 'Polish Zloty (zł)', 'give' ), |
|
| 88 | - 'SGD' => __( 'Singapore Dollar ($)', 'give' ), |
|
| 89 | - 'KRW' => __( 'South Korean Won (₩)', 'give' ), |
|
| 90 | - 'ZAR' => __( 'South African Rand (R)', 'give' ), |
|
| 91 | - 'SEK' => __( 'Swedish Krona (kr)', 'give' ), |
|
| 92 | - 'CHF' => __( 'Swiss Franc (CHF)', 'give' ), |
|
| 93 | - 'TWD' => __( 'Taiwan New Dollars (NT$)', 'give' ), |
|
| 94 | - 'THB' => __( 'Thai Baht (฿)', 'give' ), |
|
| 95 | - 'INR' => __( 'Indian Rupee (₹)', 'give' ), |
|
| 96 | - 'TRY' => __( 'Turkish Lira (₺)', 'give' ), |
|
| 97 | - 'RIAL' => __( 'Iranian Rial (﷼)', 'give' ), |
|
| 98 | - 'RUB' => __( 'Russian Rubles (руб)', 'give' ), |
|
| 69 | + 'USD' => __('US Dollars ($)', 'give'), |
|
| 70 | + 'EUR' => __('Euros (€)', 'give'), |
|
| 71 | + 'GBP' => __('Pounds Sterling (£)', 'give'), |
|
| 72 | + 'AUD' => __('Australian Dollars ($)', 'give'), |
|
| 73 | + 'BRL' => __('Brazilian Real (R$)', 'give'), |
|
| 74 | + 'CAD' => __('Canadian Dollars ($)', 'give'), |
|
| 75 | + 'CZK' => __('Czech Koruna (Kč)', 'give'), |
|
| 76 | + 'DKK' => __('Danish Krone (kr.)', 'give'), |
|
| 77 | + 'HKD' => __('Hong Kong Dollar ($)', 'give'), |
|
| 78 | + 'HUF' => __('Hungarian Forint (Ft)', 'give'), |
|
| 79 | + 'ILS' => __('Israeli Shekel (₪)', 'give'), |
|
| 80 | + 'JPY' => __('Japanese Yen (¥)', 'give'), |
|
| 81 | + 'MYR' => __('Malaysian Ringgits (RM)', 'give'), |
|
| 82 | + 'MXN' => __('Mexican Peso ($)', 'give'), |
|
| 83 | + 'MAD' => __('Moroccan Dirham (.د.م)', 'give'), |
|
| 84 | + 'NZD' => __('New Zealand Dollar ($)', 'give'), |
|
| 85 | + 'NOK' => __('Norwegian Krone (Kr.)', 'give'), |
|
| 86 | + 'PHP' => __('Philippine Pesos (₱)', 'give'), |
|
| 87 | + 'PLN' => __('Polish Zloty (zł)', 'give'), |
|
| 88 | + 'SGD' => __('Singapore Dollar ($)', 'give'), |
|
| 89 | + 'KRW' => __('South Korean Won (₩)', 'give'), |
|
| 90 | + 'ZAR' => __('South African Rand (R)', 'give'), |
|
| 91 | + 'SEK' => __('Swedish Krona (kr)', 'give'), |
|
| 92 | + 'CHF' => __('Swiss Franc (CHF)', 'give'), |
|
| 93 | + 'TWD' => __('Taiwan New Dollars (NT$)', 'give'), |
|
| 94 | + 'THB' => __('Thai Baht (฿)', 'give'), |
|
| 95 | + 'INR' => __('Indian Rupee (₹)', 'give'), |
|
| 96 | + 'TRY' => __('Turkish Lira (₺)', 'give'), |
|
| 97 | + 'RIAL' => __('Iranian Rial (﷼)', 'give'), |
|
| 98 | + 'RUB' => __('Russian Rubles (руб)', 'give'), |
|
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | - return apply_filters( 'give_currencies', $currencies ); |
|
| 101 | + return apply_filters('give_currencies', $currencies); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | |
@@ -115,12 +115,12 @@ discard block |
||
| 115 | 115 | * |
| 116 | 116 | * @return string The symbol to use for the currency |
| 117 | 117 | */ |
| 118 | -function give_currency_symbol( $currency = '', $decode_currency = false ) { |
|
| 118 | +function give_currency_symbol($currency = '', $decode_currency = false) { |
|
| 119 | 119 | |
| 120 | - if ( empty( $currency ) ) { |
|
| 120 | + if (empty($currency)) { |
|
| 121 | 121 | $currency = give_get_currency(); |
| 122 | 122 | } |
| 123 | - switch ( $currency ) : |
|
| 123 | + switch ($currency) : |
|
| 124 | 124 | case 'GBP' : |
| 125 | 125 | $symbol = '£'; |
| 126 | 126 | break; |
@@ -198,9 +198,9 @@ discard block |
||
| 198 | 198 | break; |
| 199 | 199 | endswitch; |
| 200 | 200 | |
| 201 | - $symbol = ( ! $decode_currency ? $symbol : html_entity_decode( $symbol ) ); |
|
| 201 | + $symbol = ( ! $decode_currency ? $symbol : html_entity_decode($symbol)); |
|
| 202 | 202 | |
| 203 | - return apply_filters( 'give_currency_symbol', $symbol, $currency ); |
|
| 203 | + return apply_filters('give_currency_symbol', $symbol, $currency); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | |
@@ -213,16 +213,16 @@ discard block |
||
| 213 | 213 | * |
| 214 | 214 | * @return string |
| 215 | 215 | */ |
| 216 | -function give_get_currency_name( $currency_code ) { |
|
| 216 | +function give_get_currency_name($currency_code) { |
|
| 217 | 217 | $currency_name = ''; |
| 218 | 218 | $currency_names = give_get_currencies(); |
| 219 | 219 | |
| 220 | - if ( $currency_code && array_key_exists( $currency_code, $currency_names ) ) { |
|
| 221 | - $currency_name = explode( '(', $currency_names[ $currency_code ] ); |
|
| 222 | - $currency_name = trim( current( $currency_name ) ); |
|
| 220 | + if ($currency_code && array_key_exists($currency_code, $currency_names)) { |
|
| 221 | + $currency_name = explode('(', $currency_names[$currency_code]); |
|
| 222 | + $currency_name = trim(current($currency_name)); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - return apply_filters( 'give_currency_name', $currency_name, $currency_code ); |
|
| 225 | + return apply_filters('give_currency_name', $currency_name, $currency_code); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | |
@@ -236,21 +236,21 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | global $wp; |
| 238 | 238 | |
| 239 | - if ( get_option( 'permalink_structure' ) ) { |
|
| 240 | - $base = trailingslashit( home_url( $wp->request ) ); |
|
| 239 | + if (get_option('permalink_structure')) { |
|
| 240 | + $base = trailingslashit(home_url($wp->request)); |
|
| 241 | 241 | } else { |
| 242 | - $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ); |
|
| 243 | - $base = remove_query_arg( array( 'post_type', 'name' ), $base ); |
|
| 242 | + $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); |
|
| 243 | + $base = remove_query_arg(array('post_type', 'name'), $base); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | $scheme = is_ssl() ? 'https' : 'http'; |
| 247 | - $current_uri = set_url_scheme( $base, $scheme ); |
|
| 247 | + $current_uri = set_url_scheme($base, $scheme); |
|
| 248 | 248 | |
| 249 | - if ( is_front_page() ) { |
|
| 250 | - $current_uri = home_url( '/' ); |
|
| 249 | + if (is_front_page()) { |
|
| 250 | + $current_uri = home_url('/'); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - return apply_filters( 'give_get_current_page_url', $current_uri ); |
|
| 253 | + return apply_filters('give_get_current_page_url', $current_uri); |
|
| 254 | 254 | |
| 255 | 255 | } |
| 256 | 256 | |
@@ -272,15 +272,15 @@ discard block |
||
| 272 | 272 | */ |
| 273 | 273 | $gateways = give_get_enabled_payment_gateways(); |
| 274 | 274 | |
| 275 | - if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) { |
|
| 275 | + if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) { |
|
| 276 | 276 | $ret = true; |
| 277 | - } elseif ( count( $gateways ) == 1 ) { |
|
| 277 | + } elseif (count($gateways) == 1) { |
|
| 278 | 278 | $ret = false; |
| 279 | - } elseif ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) { |
|
| 279 | + } elseif (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) { |
|
| 280 | 280 | $ret = false; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - return (bool) apply_filters( 'give_verify_credit_cards', $ret ); |
|
| 283 | + return (bool) apply_filters('give_verify_credit_cards', $ret); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
@@ -292,26 +292,26 @@ discard block |
||
| 292 | 292 | function give_get_timezone_id() { |
| 293 | 293 | |
| 294 | 294 | // if site timezone string exists, return it. |
| 295 | - if ( $timezone = get_option( 'timezone_string' ) ) { |
|
| 295 | + if ($timezone = get_option('timezone_string')) { |
|
| 296 | 296 | return $timezone; |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | // get UTC offset, if it isn't set return UTC. |
| 300 | - if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) { |
|
| 300 | + if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) { |
|
| 301 | 301 | return 'UTC'; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | // attempt to guess the timezone string from the UTC offset. |
| 305 | - $timezone = timezone_name_from_abbr( '', $utc_offset ); |
|
| 305 | + $timezone = timezone_name_from_abbr('', $utc_offset); |
|
| 306 | 306 | |
| 307 | 307 | // last try, guess timezone string manually. |
| 308 | - if ( $timezone === false ) { |
|
| 308 | + if ($timezone === false) { |
|
| 309 | 309 | |
| 310 | - $is_dst = date( 'I' ); |
|
| 310 | + $is_dst = date('I'); |
|
| 311 | 311 | |
| 312 | - foreach ( timezone_abbreviations_list() as $abbr ) { |
|
| 313 | - foreach ( $abbr as $city ) { |
|
| 314 | - if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) { |
|
| 312 | + foreach (timezone_abbreviations_list() as $abbr) { |
|
| 313 | + foreach ($abbr as $city) { |
|
| 314 | + if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) { |
|
| 315 | 315 | return $city['timezone_id']; |
| 316 | 316 | } |
| 317 | 317 | } |
@@ -335,17 +335,17 @@ discard block |
||
| 335 | 335 | |
| 336 | 336 | $ip = '127.0.0.1'; |
| 337 | 337 | |
| 338 | - if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
| 338 | + if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
| 339 | 339 | // check ip from share internet |
| 340 | 340 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
| 341 | - } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
| 341 | + } elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 342 | 342 | // to check ip is pass from proxy |
| 343 | 343 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
| 344 | - } elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
| 344 | + } elseif ( ! empty($_SERVER['REMOTE_ADDR'])) { |
|
| 345 | 345 | $ip = $_SERVER['REMOTE_ADDR']; |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - return apply_filters( 'give_get_ip', $ip ); |
|
| 348 | + return apply_filters('give_get_ip', $ip); |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | |
@@ -360,9 +360,9 @@ discard block |
||
| 360 | 360 | * |
| 361 | 361 | * @uses Give()->session->set() |
| 362 | 362 | */ |
| 363 | -function give_set_purchase_session( $purchase_data = array() ) { |
|
| 364 | - Give()->session->set( 'give_purchase', $purchase_data ); |
|
| 365 | - Give()->session->set( 'give_email', $purchase_data['user_email'] ); |
|
| 363 | +function give_set_purchase_session($purchase_data = array()) { |
|
| 364 | + Give()->session->set('give_purchase', $purchase_data); |
|
| 365 | + Give()->session->set('give_email', $purchase_data['user_email']); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | /** |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | * @return mixed array | false |
| 377 | 377 | */ |
| 378 | 378 | function give_get_purchase_session() { |
| 379 | - return Give()->session->get( 'give_purchase' ); |
|
| 379 | + return Give()->session->get('give_purchase'); |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | /** |
@@ -392,40 +392,40 @@ discard block |
||
| 392 | 392 | * |
| 393 | 393 | * @return string |
| 394 | 394 | */ |
| 395 | -function give_payment_gateway_donation_summary( $donation_data, $name_and_email = true, $length = 255 ) { |
|
| 395 | +function give_payment_gateway_donation_summary($donation_data, $name_and_email = true, $length = 255) { |
|
| 396 | 396 | |
| 397 | 397 | $summary = ''; |
| 398 | 398 | |
| 399 | - $form_id = isset( $donation_data['post_data']['give-form-id'] ) ? $donation_data['post_data']['give-form-id'] : ''; |
|
| 399 | + $form_id = isset($donation_data['post_data']['give-form-id']) ? $donation_data['post_data']['give-form-id'] : ''; |
|
| 400 | 400 | |
| 401 | 401 | // Form title. |
| 402 | - if ( isset( $donation_data['post_data']['give-form-title'] ) ) { |
|
| 402 | + if (isset($donation_data['post_data']['give-form-title'])) { |
|
| 403 | 403 | $summary .= $donation_data['post_data']['give-form-title']; |
| 404 | 404 | } |
| 405 | 405 | // Form multilevel if applicable. |
| 406 | - if ( isset( $donation_data['post_data']['give-price-id'] ) ) { |
|
| 407 | - $summary .= ': ' . give_get_price_option_name( $form_id, $donation_data['post_data']['give-price-id'] ); |
|
| 406 | + if (isset($donation_data['post_data']['give-price-id'])) { |
|
| 407 | + $summary .= ': '.give_get_price_option_name($form_id, $donation_data['post_data']['give-price-id']); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | // Add Donor's name + email if requested. |
| 411 | - if ( $name_and_email ) { |
|
| 411 | + if ($name_and_email) { |
|
| 412 | 412 | |
| 413 | 413 | // First name |
| 414 | - if ( isset( $donation_data['user_info']['first_name'] ) && ! empty( $donation_data['user_info']['first_name'] ) ) { |
|
| 415 | - $summary .= ' - ' . $donation_data['user_info']['first_name']; |
|
| 414 | + if (isset($donation_data['user_info']['first_name']) && ! empty($donation_data['user_info']['first_name'])) { |
|
| 415 | + $summary .= ' - '.$donation_data['user_info']['first_name']; |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | - if ( isset( $donation_data['user_info']['last_name'] ) && ! empty( $donation_data['user_info']['last_name'] ) ) { |
|
| 419 | - $summary .= ' ' . $donation_data['user_info']['last_name']; |
|
| 418 | + if (isset($donation_data['user_info']['last_name']) && ! empty($donation_data['user_info']['last_name'])) { |
|
| 419 | + $summary .= ' '.$donation_data['user_info']['last_name']; |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | - $summary .= ' (' . $donation_data['user_email'] . ')'; |
|
| 422 | + $summary .= ' ('.$donation_data['user_email'].')'; |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | // Cut the length |
| 426 | - $summary = substr( $summary, 0, $length ); |
|
| 426 | + $summary = substr($summary, 0, $length); |
|
| 427 | 427 | |
| 428 | - return apply_filters( 'give_payment_gateway_donation_summary', $summary ); |
|
| 428 | + return apply_filters('give_payment_gateway_donation_summary', $summary); |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | |
@@ -440,31 +440,31 @@ discard block |
||
| 440 | 440 | function give_get_host() { |
| 441 | 441 | $host = false; |
| 442 | 442 | |
| 443 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
| 443 | + if (defined('WPE_APIKEY')) { |
|
| 444 | 444 | $host = 'WP Engine'; |
| 445 | - } elseif ( defined( 'PAGELYBIN' ) ) { |
|
| 445 | + } elseif (defined('PAGELYBIN')) { |
|
| 446 | 446 | $host = 'Pagely'; |
| 447 | - } elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
| 447 | + } elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
| 448 | 448 | $host = 'ICDSoft'; |
| 449 | - } elseif ( DB_HOST == 'mysqlv5' ) { |
|
| 449 | + } elseif (DB_HOST == 'mysqlv5') { |
|
| 450 | 450 | $host = 'NetworkSolutions'; |
| 451 | - } elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
| 451 | + } elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
| 452 | 452 | $host = 'iPage'; |
| 453 | - } elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
| 453 | + } elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
| 454 | 454 | $host = 'IPower'; |
| 455 | - } elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
| 455 | + } elseif (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
| 456 | 456 | $host = 'MediaTemple Grid'; |
| 457 | - } elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
| 457 | + } elseif (strpos(DB_HOST, '.pair.com') !== false) { |
|
| 458 | 458 | $host = 'pair Networks'; |
| 459 | - } elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
| 459 | + } elseif (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
| 460 | 460 | $host = 'Rackspace Cloud'; |
| 461 | - } elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
| 461 | + } elseif (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
| 462 | 462 | $host = 'SysFix.eu Power Hosting'; |
| 463 | - } elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
| 463 | + } elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
| 464 | 464 | $host = 'Flywheel'; |
| 465 | 465 | } else { |
| 466 | 466 | // Adding a general fallback for data gathering |
| 467 | - $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME']; |
|
| 467 | + $host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME']; |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | return $host; |
@@ -480,67 +480,67 @@ discard block |
||
| 480 | 480 | * |
| 481 | 481 | * @return bool true if host matches, false if not |
| 482 | 482 | */ |
| 483 | -function give_is_host( $host = false ) { |
|
| 483 | +function give_is_host($host = false) { |
|
| 484 | 484 | |
| 485 | 485 | $return = false; |
| 486 | 486 | |
| 487 | - if ( $host ) { |
|
| 488 | - $host = str_replace( ' ', '', strtolower( $host ) ); |
|
| 487 | + if ($host) { |
|
| 488 | + $host = str_replace(' ', '', strtolower($host)); |
|
| 489 | 489 | |
| 490 | - switch ( $host ) { |
|
| 490 | + switch ($host) { |
|
| 491 | 491 | case 'wpengine': |
| 492 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
| 492 | + if (defined('WPE_APIKEY')) { |
|
| 493 | 493 | $return = true; |
| 494 | 494 | } |
| 495 | 495 | break; |
| 496 | 496 | case 'pagely': |
| 497 | - if ( defined( 'PAGELYBIN' ) ) { |
|
| 497 | + if (defined('PAGELYBIN')) { |
|
| 498 | 498 | $return = true; |
| 499 | 499 | } |
| 500 | 500 | break; |
| 501 | 501 | case 'icdsoft': |
| 502 | - if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
| 502 | + if (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
| 503 | 503 | $return = true; |
| 504 | 504 | } |
| 505 | 505 | break; |
| 506 | 506 | case 'networksolutions': |
| 507 | - if ( DB_HOST == 'mysqlv5' ) { |
|
| 507 | + if (DB_HOST == 'mysqlv5') { |
|
| 508 | 508 | $return = true; |
| 509 | 509 | } |
| 510 | 510 | break; |
| 511 | 511 | case 'ipage': |
| 512 | - if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
| 512 | + if (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
| 513 | 513 | $return = true; |
| 514 | 514 | } |
| 515 | 515 | break; |
| 516 | 516 | case 'ipower': |
| 517 | - if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
| 517 | + if (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
| 518 | 518 | $return = true; |
| 519 | 519 | } |
| 520 | 520 | break; |
| 521 | 521 | case 'mediatemplegrid': |
| 522 | - if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
| 522 | + if (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
| 523 | 523 | $return = true; |
| 524 | 524 | } |
| 525 | 525 | break; |
| 526 | 526 | case 'pairnetworks': |
| 527 | - if ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
| 527 | + if (strpos(DB_HOST, '.pair.com') !== false) { |
|
| 528 | 528 | $return = true; |
| 529 | 529 | } |
| 530 | 530 | break; |
| 531 | 531 | case 'rackspacecloud': |
| 532 | - if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
| 532 | + if (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
| 533 | 533 | $return = true; |
| 534 | 534 | } |
| 535 | 535 | break; |
| 536 | 536 | case 'sysfix.eu': |
| 537 | 537 | case 'sysfix.eupowerhosting': |
| 538 | - if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
| 538 | + if (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
| 539 | 539 | $return = true; |
| 540 | 540 | } |
| 541 | 541 | break; |
| 542 | 542 | case 'flywheel': |
| 543 | - if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
| 543 | + if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
| 544 | 544 | $return = true; |
| 545 | 545 | } |
| 546 | 546 | break; |
@@ -573,7 +573,7 @@ discard block |
||
| 573 | 573 | * @param string $replacement Optional. The function that should have been called. |
| 574 | 574 | * @param array $backtrace Optional. Contains stack backtrace of deprecated function. |
| 575 | 575 | */ |
| 576 | -function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) { |
|
| 576 | +function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) { |
|
| 577 | 577 | |
| 578 | 578 | /** |
| 579 | 579 | * Fires while give deprecated function call occurs. |
@@ -586,19 +586,19 @@ discard block |
||
| 586 | 586 | * @param string $replacement Optional. The function that should have been called. |
| 587 | 587 | * @param string $version The plugin version that deprecated the function. |
| 588 | 588 | */ |
| 589 | - do_action( 'give_deprecated_function_run', $function, $replacement, $version ); |
|
| 589 | + do_action('give_deprecated_function_run', $function, $replacement, $version); |
|
| 590 | 590 | |
| 591 | - $show_errors = current_user_can( 'manage_options' ); |
|
| 591 | + $show_errors = current_user_can('manage_options'); |
|
| 592 | 592 | |
| 593 | 593 | // Allow plugin to filter the output error trigger. |
| 594 | - if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) { |
|
| 595 | - if ( ! is_null( $replacement ) ) { |
|
| 596 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) ); |
|
| 597 | - trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
| 594 | + if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) { |
|
| 595 | + if ( ! is_null($replacement)) { |
|
| 596 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement)); |
|
| 597 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
| 598 | 598 | // Alternatively we could dump this to a file. |
| 599 | 599 | } else { |
| 600 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) ); |
|
| 601 | - trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
| 600 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version)); |
|
| 601 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
| 602 | 602 | // Alternatively we could dump this to a file. |
| 603 | 603 | } |
| 604 | 604 | } |
@@ -612,8 +612,8 @@ discard block |
||
| 612 | 612 | * @return string $post_id |
| 613 | 613 | */ |
| 614 | 614 | function give_get_admin_post_id() { |
| 615 | - $post_id = isset( $_GET['post'] ) ? $_GET['post'] : null; |
|
| 616 | - if ( ! $post_id && isset( $_POST['post_id'] ) ) { |
|
| 615 | + $post_id = isset($_GET['post']) ? $_GET['post'] : null; |
|
| 616 | + if ( ! $post_id && isset($_POST['post_id'])) { |
|
| 617 | 617 | $post_id = $_POST['post_id']; |
| 618 | 618 | } |
| 619 | 619 | |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | * @return string Arg separator output |
| 628 | 628 | */ |
| 629 | 629 | function give_get_php_arg_separator_output() { |
| 630 | - return ini_get( 'arg_separator.output' ); |
|
| 630 | + return ini_get('arg_separator.output'); |
|
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | |
@@ -642,10 +642,10 @@ discard block |
||
| 642 | 642 | * |
| 643 | 643 | * @return string Short month name |
| 644 | 644 | */ |
| 645 | -function give_month_num_to_name( $n ) { |
|
| 646 | - $timestamp = mktime( 0, 0, 0, $n, 1, 2005 ); |
|
| 645 | +function give_month_num_to_name($n) { |
|
| 646 | + $timestamp = mktime(0, 0, 0, $n, 1, 2005); |
|
| 647 | 647 | |
| 648 | - return date_i18n( 'M', $timestamp ); |
|
| 648 | + return date_i18n('M', $timestamp); |
|
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | |
@@ -658,10 +658,10 @@ discard block |
||
| 658 | 658 | * |
| 659 | 659 | * @return bool Whether or not function is disabled. |
| 660 | 660 | */ |
| 661 | -function give_is_func_disabled( $function ) { |
|
| 662 | - $disabled = explode( ',', ini_get( 'disable_functions' ) ); |
|
| 661 | +function give_is_func_disabled($function) { |
|
| 662 | + $disabled = explode(',', ini_get('disable_functions')); |
|
| 663 | 663 | |
| 664 | - return in_array( $function, $disabled ); |
|
| 664 | + return in_array($function, $disabled); |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | function give_get_newsletter() { |
| 674 | 674 | ?> |
| 675 | 675 | |
| 676 | - <p class="newsletter-intro"><?php esc_html_e( 'Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give' ); ?></p> |
|
| 676 | + <p class="newsletter-intro"><?php esc_html_e('Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give'); ?></p> |
|
| 677 | 677 | |
| 678 | 678 | <div class="give-newsletter-form-wrap"> |
| 679 | 679 | |
@@ -681,33 +681,33 @@ discard block |
||
| 681 | 681 | method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" |
| 682 | 682 | target="_blank" novalidate> |
| 683 | 683 | <div class="give-newsletter-confirmation"> |
| 684 | - <p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p> |
|
| 684 | + <p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p> |
|
| 685 | 685 | </div> |
| 686 | 686 | |
| 687 | 687 | <table class="form-table give-newsletter-form"> |
| 688 | 688 | <tr valign="middle"> |
| 689 | 689 | <td> |
| 690 | 690 | <label for="mce-EMAIL" |
| 691 | - class="screen-reader-text"><?php esc_html_e( 'Email Address (required)', 'give' ); ?></label> |
|
| 691 | + class="screen-reader-text"><?php esc_html_e('Email Address (required)', 'give'); ?></label> |
|
| 692 | 692 | <input type="email" name="EMAIL" id="mce-EMAIL" |
| 693 | - placeholder="<?php esc_attr_e( 'Email Address (required)', 'give' ); ?>" |
|
| 693 | + placeholder="<?php esc_attr_e('Email Address (required)', 'give'); ?>" |
|
| 694 | 694 | class="required email" value=""> |
| 695 | 695 | </td> |
| 696 | 696 | <td> |
| 697 | 697 | <label for="mce-FNAME" |
| 698 | - class="screen-reader-text"><?php esc_html_e( 'First Name', 'give' ); ?></label> |
|
| 698 | + class="screen-reader-text"><?php esc_html_e('First Name', 'give'); ?></label> |
|
| 699 | 699 | <input type="text" name="FNAME" id="mce-FNAME" |
| 700 | - placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" class="" value=""> |
|
| 700 | + placeholder="<?php esc_attr_e('First Name', 'give'); ?>" class="" value=""> |
|
| 701 | 701 | </td> |
| 702 | 702 | <td> |
| 703 | 703 | <label for="mce-LNAME" |
| 704 | - class="screen-reader-text"><?php esc_html_e( 'Last Name', 'give' ); ?></label> |
|
| 704 | + class="screen-reader-text"><?php esc_html_e('Last Name', 'give'); ?></label> |
|
| 705 | 705 | <input type="text" name="LNAME" id="mce-LNAME" |
| 706 | - placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" class="" value=""> |
|
| 706 | + placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" class="" value=""> |
|
| 707 | 707 | </td> |
| 708 | 708 | <td> |
| 709 | 709 | <input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button" |
| 710 | - value="<?php esc_attr_e( 'Subscribe', 'give' ); ?>"> |
|
| 710 | + value="<?php esc_attr_e('Subscribe', 'give'); ?>"> |
|
| 711 | 711 | </td> |
| 712 | 712 | </tr> |
| 713 | 713 | </table> |
@@ -759,7 +759,7 @@ discard block |
||
| 759 | 759 | * |
| 760 | 760 | * @return string |
| 761 | 761 | */ |
| 762 | -function give_svg_icons( $icon ) { |
|
| 762 | +function give_svg_icons($icon) { |
|
| 763 | 763 | |
| 764 | 764 | // Store your SVGs in an associative array |
| 765 | 765 | $svgs = array( |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | ); |
| 772 | 772 | |
| 773 | 773 | // Return the chosen icon's SVG string |
| 774 | - return $svgs[ $icon ]; |
|
| 774 | + return $svgs[$icon]; |
|
| 775 | 775 | } |
| 776 | 776 | |
| 777 | 777 | /** |
@@ -783,15 +783,15 @@ discard block |
||
| 783 | 783 | * |
| 784 | 784 | * @return mixed |
| 785 | 785 | */ |
| 786 | -function modify_nav_menu_meta_box_object( $post_type ) { |
|
| 787 | - if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) { |
|
| 788 | - $post_type->labels->name = esc_html__( 'Donation Forms', 'give' ); |
|
| 786 | +function modify_nav_menu_meta_box_object($post_type) { |
|
| 787 | + if (isset($post_type->name) && $post_type->name == 'give_forms') { |
|
| 788 | + $post_type->labels->name = esc_html__('Donation Forms', 'give'); |
|
| 789 | 789 | } |
| 790 | 790 | |
| 791 | 791 | return $post_type; |
| 792 | 792 | } |
| 793 | 793 | |
| 794 | -add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' ); |
|
| 794 | +add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object'); |
|
| 795 | 795 | |
| 796 | 796 | /** |
| 797 | 797 | * Enable 'Donation Form' meta enabled by default on Menu page. |
@@ -801,22 +801,22 @@ discard block |
||
| 801 | 801 | function give_nav_donation_metabox_enabled() { |
| 802 | 802 | |
| 803 | 803 | // Return false, if it fails to retrieve hidden meta box list and is not admin. |
| 804 | - if ( ( ! $hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus' ) ) || ! is_admin() ) { |
|
| 804 | + if (( ! $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus')) || ! is_admin()) { |
|
| 805 | 805 | return false; |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | // Return false, In case, we don't find 'Donation Form' in hidden meta box list. |
| 809 | - if ( ! in_array( 'add-post-type-give_forms', $hidden_meta_boxes, true ) ) { |
|
| 809 | + if ( ! in_array('add-post-type-give_forms', $hidden_meta_boxes, true)) { |
|
| 810 | 810 | return false; |
| 811 | 811 | } |
| 812 | 812 | |
| 813 | 813 | // Exclude 'Donation Form' value from hidden meta box's list. |
| 814 | - $hidden_meta_boxes = array_diff( $hidden_meta_boxes, array( 'add-post-type-give_forms' ) ); |
|
| 814 | + $hidden_meta_boxes = array_diff($hidden_meta_boxes, array('add-post-type-give_forms')); |
|
| 815 | 815 | |
| 816 | 816 | // Get current user ID. |
| 817 | 817 | $user = wp_get_current_user(); |
| 818 | 818 | |
| 819 | - update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true ); |
|
| 819 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
| 820 | 820 | } |
| 821 | 821 | |
| 822 | 822 | /** |
@@ -830,7 +830,7 @@ discard block |
||
| 830 | 830 | * @license https://opensource.org/licenses/MIT MIT |
| 831 | 831 | */ |
| 832 | 832 | |
| 833 | -if ( ! function_exists( 'array_column' ) ) { |
|
| 833 | +if ( ! function_exists('array_column')) { |
|
| 834 | 834 | /** |
| 835 | 835 | * Returns the values from a single column of the input array, identified by |
| 836 | 836 | * the $columnKey. |
@@ -849,53 +849,53 @@ discard block |
||
| 849 | 849 | * |
| 850 | 850 | * @return array |
| 851 | 851 | */ |
| 852 | - function array_column( $input = null, $columnKey = null, $indexKey = null ) { |
|
| 852 | + function array_column($input = null, $columnKey = null, $indexKey = null) { |
|
| 853 | 853 | // Using func_get_args() in order to check for proper number of |
| 854 | 854 | // parameters and trigger errors exactly as the built-in array_column() |
| 855 | 855 | // does in PHP 5.5. |
| 856 | 856 | $argc = func_num_args(); |
| 857 | 857 | $params = func_get_args(); |
| 858 | 858 | |
| 859 | - if ( $argc < 2 ) { |
|
| 860 | - trigger_error( sprintf( esc_html__( 'array_column() expects at least 2 parameters, %s given.', 'give' ), $argc ), E_USER_WARNING ); |
|
| 859 | + if ($argc < 2) { |
|
| 860 | + trigger_error(sprintf(esc_html__('array_column() expects at least 2 parameters, %s given.', 'give'), $argc), E_USER_WARNING); |
|
| 861 | 861 | |
| 862 | 862 | return null; |
| 863 | 863 | } |
| 864 | 864 | |
| 865 | - if ( ! is_array( $params[0] ) ) { |
|
| 866 | - trigger_error( sprintf( esc_html__( 'array_column() expects parameter 1 to be array, %s given.', 'give' ), gettype( $params[0] ) ), E_USER_WARNING ); |
|
| 865 | + if ( ! is_array($params[0])) { |
|
| 866 | + trigger_error(sprintf(esc_html__('array_column() expects parameter 1 to be array, %s given.', 'give'), gettype($params[0])), E_USER_WARNING); |
|
| 867 | 867 | |
| 868 | 868 | return null; |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - if ( ! is_int( $params[1] ) |
|
| 872 | - && ! is_float( $params[1] ) |
|
| 873 | - && ! is_string( $params[1] ) |
|
| 871 | + if ( ! is_int($params[1]) |
|
| 872 | + && ! is_float($params[1]) |
|
| 873 | + && ! is_string($params[1]) |
|
| 874 | 874 | && $params[1] !== null |
| 875 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
| 875 | + && ! (is_object($params[1]) && method_exists($params[1], '__toString')) |
|
| 876 | 876 | ) { |
| 877 | - trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
| 877 | + trigger_error(esc_html__('array_column(): The column key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
| 878 | 878 | |
| 879 | 879 | return false; |
| 880 | 880 | } |
| 881 | 881 | |
| 882 | - if ( isset( $params[2] ) |
|
| 883 | - && ! is_int( $params[2] ) |
|
| 884 | - && ! is_float( $params[2] ) |
|
| 885 | - && ! is_string( $params[2] ) |
|
| 886 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
| 882 | + if (isset($params[2]) |
|
| 883 | + && ! is_int($params[2]) |
|
| 884 | + && ! is_float($params[2]) |
|
| 885 | + && ! is_string($params[2]) |
|
| 886 | + && ! (is_object($params[2]) && method_exists($params[2], '__toString')) |
|
| 887 | 887 | ) { |
| 888 | - trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
| 888 | + trigger_error(esc_html__('array_column(): The index key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
| 889 | 889 | |
| 890 | 890 | return false; |
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | $paramsInput = $params[0]; |
| 894 | - $paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null; |
|
| 894 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
| 895 | 895 | |
| 896 | 896 | $paramsIndexKey = null; |
| 897 | - if ( isset( $params[2] ) ) { |
|
| 898 | - if ( is_float( $params[2] ) || is_int( $params[2] ) ) { |
|
| 897 | + if (isset($params[2])) { |
|
| 898 | + if (is_float($params[2]) || is_int($params[2])) { |
|
| 899 | 899 | $paramsIndexKey = (int) $params[2]; |
| 900 | 900 | } else { |
| 901 | 901 | $paramsIndexKey = (string) $params[2]; |
@@ -904,26 +904,26 @@ discard block |
||
| 904 | 904 | |
| 905 | 905 | $resultArray = array(); |
| 906 | 906 | |
| 907 | - foreach ( $paramsInput as $row ) { |
|
| 907 | + foreach ($paramsInput as $row) { |
|
| 908 | 908 | $key = $value = null; |
| 909 | 909 | $keySet = $valueSet = false; |
| 910 | 910 | |
| 911 | - if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) { |
|
| 911 | + if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
| 912 | 912 | $keySet = true; |
| 913 | - $key = (string) $row[ $paramsIndexKey ]; |
|
| 913 | + $key = (string) $row[$paramsIndexKey]; |
|
| 914 | 914 | } |
| 915 | 915 | |
| 916 | - if ( $paramsColumnKey === null ) { |
|
| 916 | + if ($paramsColumnKey === null) { |
|
| 917 | 917 | $valueSet = true; |
| 918 | 918 | $value = $row; |
| 919 | - } elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) { |
|
| 919 | + } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
| 920 | 920 | $valueSet = true; |
| 921 | - $value = $row[ $paramsColumnKey ]; |
|
| 921 | + $value = $row[$paramsColumnKey]; |
|
| 922 | 922 | } |
| 923 | 923 | |
| 924 | - if ( $valueSet ) { |
|
| 925 | - if ( $keySet ) { |
|
| 926 | - $resultArray[ $key ] = $value; |
|
| 924 | + if ($valueSet) { |
|
| 925 | + if ($keySet) { |
|
| 926 | + $resultArray[$key] = $value; |
|
| 927 | 927 | } else { |
| 928 | 928 | $resultArray[] = $value; |
| 929 | 929 | } |
@@ -943,40 +943,40 @@ discard block |
||
| 943 | 943 | * |
| 944 | 944 | * @return bool Whether the receipt is visible or not. |
| 945 | 945 | */ |
| 946 | -function give_can_view_receipt( $payment_key = '' ) { |
|
| 946 | +function give_can_view_receipt($payment_key = '') { |
|
| 947 | 947 | |
| 948 | 948 | $return = false; |
| 949 | 949 | |
| 950 | - if ( empty( $payment_key ) ) { |
|
| 950 | + if (empty($payment_key)) { |
|
| 951 | 951 | return $return; |
| 952 | 952 | } |
| 953 | 953 | |
| 954 | 954 | global $give_receipt_args; |
| 955 | 955 | |
| 956 | - $give_receipt_args['id'] = give_get_purchase_id_by_key( $payment_key ); |
|
| 956 | + $give_receipt_args['id'] = give_get_purchase_id_by_key($payment_key); |
|
| 957 | 957 | |
| 958 | - $user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] ); |
|
| 958 | + $user_id = (int) give_get_payment_user_id($give_receipt_args['id']); |
|
| 959 | 959 | |
| 960 | - $payment_meta = give_get_payment_meta( $give_receipt_args['id'] ); |
|
| 960 | + $payment_meta = give_get_payment_meta($give_receipt_args['id']); |
|
| 961 | 961 | |
| 962 | - if ( is_user_logged_in() ) { |
|
| 963 | - if ( $user_id === (int) get_current_user_id() ) { |
|
| 962 | + if (is_user_logged_in()) { |
|
| 963 | + if ($user_id === (int) get_current_user_id()) { |
|
| 964 | 964 | $return = true; |
| 965 | - } elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) { |
|
| 965 | + } elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) { |
|
| 966 | 966 | $return = true; |
| 967 | - } elseif ( current_user_can( 'view_give_sensitive_data' ) ) { |
|
| 967 | + } elseif (current_user_can('view_give_sensitive_data')) { |
|
| 968 | 968 | $return = true; |
| 969 | 969 | } |
| 970 | 970 | } |
| 971 | 971 | |
| 972 | 972 | $session = give_get_purchase_session(); |
| 973 | - if ( ! empty( $session ) && ! is_user_logged_in() ) { |
|
| 974 | - if ( $session['purchase_key'] === $payment_meta['key'] ) { |
|
| 973 | + if ( ! empty($session) && ! is_user_logged_in()) { |
|
| 974 | + if ($session['purchase_key'] === $payment_meta['key']) { |
|
| 975 | 975 | $return = true; |
| 976 | 976 | } |
| 977 | 977 | } |
| 978 | 978 | |
| 979 | - return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key ); |
|
| 979 | + return (bool) apply_filters('give_can_view_receipt', $return, $payment_key); |
|
| 980 | 980 | |
| 981 | 981 | } |
| 982 | 982 | |
@@ -985,7 +985,7 @@ discard block |
||
| 985 | 985 | * |
| 986 | 986 | * Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar |
| 987 | 987 | */ |
| 988 | -if ( ! function_exists( 'cal_days_in_month' ) ) { |
|
| 988 | +if ( ! function_exists('cal_days_in_month')) { |
|
| 989 | 989 | /** |
| 990 | 990 | * cal_days_in_month |
| 991 | 991 | * |
@@ -995,8 +995,8 @@ discard block |
||
| 995 | 995 | * |
| 996 | 996 | * @return bool|string |
| 997 | 997 | */ |
| 998 | - function cal_days_in_month( $calendar, $month, $year ) { |
|
| 999 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
| 998 | + function cal_days_in_month($calendar, $month, $year) { |
|
| 999 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
| 1000 | 1000 | } |
| 1001 | 1001 | } |
| 1002 | 1002 | |
@@ -1015,42 +1015,42 @@ discard block |
||
| 1015 | 1015 | */ |
| 1016 | 1016 | function give_get_plugins() { |
| 1017 | 1017 | $plugins = get_plugins(); |
| 1018 | - $active_plugin_paths = (array) get_option( 'active_plugins', array() ); |
|
| 1018 | + $active_plugin_paths = (array) get_option('active_plugins', array()); |
|
| 1019 | 1019 | |
| 1020 | - if ( is_multisite() ) { |
|
| 1021 | - $network_activated_plugin_paths = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); |
|
| 1022 | - $active_plugin_paths = array_merge( $active_plugin_paths, $network_activated_plugin_paths ); |
|
| 1020 | + if (is_multisite()) { |
|
| 1021 | + $network_activated_plugin_paths = array_keys(get_site_option('active_sitewide_plugins', array())); |
|
| 1022 | + $active_plugin_paths = array_merge($active_plugin_paths, $network_activated_plugin_paths); |
|
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | - foreach ( $plugins as $plugin_path => $plugin_data ) { |
|
| 1025 | + foreach ($plugins as $plugin_path => $plugin_data) { |
|
| 1026 | 1026 | // Is plugin active? |
| 1027 | - if ( in_array( $plugin_path, $active_plugin_paths ) ) { |
|
| 1028 | - $plugins[ $plugin_path ]['Status'] = 'active'; |
|
| 1027 | + if (in_array($plugin_path, $active_plugin_paths)) { |
|
| 1028 | + $plugins[$plugin_path]['Status'] = 'active'; |
|
| 1029 | 1029 | } else { |
| 1030 | - $plugins[ $plugin_path ]['Status'] = 'inactive'; |
|
| 1030 | + $plugins[$plugin_path]['Status'] = 'inactive'; |
|
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | - $dirname = strtolower( dirname( $plugin_path ) ); |
|
| 1033 | + $dirname = strtolower(dirname($plugin_path)); |
|
| 1034 | 1034 | |
| 1035 | 1035 | // Is plugin a Give add-on by WordImpress? |
| 1036 | - if ( strstr( $dirname, 'give-' ) && strstr( $plugin_data['AuthorURI'], 'wordimpress.com' ) ) { |
|
| 1036 | + if (strstr($dirname, 'give-') && strstr($plugin_data['AuthorURI'], 'wordimpress.com')) { |
|
| 1037 | 1037 | // Plugin is a Give-addon. |
| 1038 | - $plugins[ $plugin_path ]['Type'] = 'add-on'; |
|
| 1038 | + $plugins[$plugin_path]['Type'] = 'add-on'; |
|
| 1039 | 1039 | |
| 1040 | 1040 | // Get license info from database. |
| 1041 | - $plugin_name = str_replace( 'Give - ', '', $plugin_data['Name'] ); |
|
| 1042 | - $db_option = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $plugin_name ) ) ) . '_license_active'; |
|
| 1043 | - $license_active = get_option( $db_option ); |
|
| 1041 | + $plugin_name = str_replace('Give - ', '', $plugin_data['Name']); |
|
| 1042 | + $db_option = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($plugin_name))).'_license_active'; |
|
| 1043 | + $license_active = get_option($db_option); |
|
| 1044 | 1044 | |
| 1045 | 1045 | // Does a valid license exist? |
| 1046 | - if ( ! empty( $license_active ) && 'valid' === $license_active->license ) { |
|
| 1047 | - $plugins[ $plugin_path ]['License'] = true; |
|
| 1046 | + if ( ! empty($license_active) && 'valid' === $license_active->license) { |
|
| 1047 | + $plugins[$plugin_path]['License'] = true; |
|
| 1048 | 1048 | } else { |
| 1049 | - $plugins[ $plugin_path ]['License'] = false; |
|
| 1049 | + $plugins[$plugin_path]['License'] = false; |
|
| 1050 | 1050 | } |
| 1051 | 1051 | } else { |
| 1052 | 1052 | // Plugin is not a Give add-on. |
| 1053 | - $plugins[ $plugin_path ]['Type'] = 'other'; |
|
| 1053 | + $plugins[$plugin_path]['Type'] = 'other'; |
|
| 1054 | 1054 | } |
| 1055 | 1055 | } |
| 1056 | 1056 | |
@@ -1067,16 +1067,16 @@ discard block |
||
| 1067 | 1067 | * |
| 1068 | 1068 | * @return bool |
| 1069 | 1069 | */ |
| 1070 | -function give_is_terms_enabled( $form_id ) { |
|
| 1071 | - $form_option = give_get_meta( $form_id, '_give_terms_option', true ); |
|
| 1070 | +function give_is_terms_enabled($form_id) { |
|
| 1071 | + $form_option = give_get_meta($form_id, '_give_terms_option', true); |
|
| 1072 | 1072 | |
| 1073 | 1073 | if ( |
| 1074 | - give_is_setting_enabled( $form_option, 'global' ) |
|
| 1075 | - && give_is_setting_enabled( give_get_option( 'terms' ) ) |
|
| 1074 | + give_is_setting_enabled($form_option, 'global') |
|
| 1075 | + && give_is_setting_enabled(give_get_option('terms')) |
|
| 1076 | 1076 | ) { |
| 1077 | 1077 | return true; |
| 1078 | 1078 | |
| 1079 | - } elseif ( give_is_setting_enabled( $form_option ) ) { |
|
| 1079 | + } elseif (give_is_setting_enabled($form_option)) { |
|
| 1080 | 1080 | return true; |
| 1081 | 1081 | |
| 1082 | 1082 | } else { |
@@ -1100,9 +1100,9 @@ discard block |
||
| 1100 | 1100 | * |
| 1101 | 1101 | * @return WP_Error|bool |
| 1102 | 1102 | */ |
| 1103 | -function give_delete_donation_stats( $date_range = '', $args = array() ) { |
|
| 1103 | +function give_delete_donation_stats($date_range = '', $args = array()) { |
|
| 1104 | 1104 | // Delete all cache. |
| 1105 | - $status = Give_Cache::delete( Give_Cache::get_options_like( 'give_stats' ) ); |
|
| 1105 | + $status = Give_Cache::delete(Give_Cache::get_options_like('give_stats')); |
|
| 1106 | 1106 | |
| 1107 | 1107 | /** |
| 1108 | 1108 | * Fire the action when donation stats delete. |
@@ -1112,7 +1112,7 @@ discard block |
||
| 1112 | 1112 | * @param string|array $date_range |
| 1113 | 1113 | * @param array $args |
| 1114 | 1114 | */ |
| 1115 | - do_action( 'give_delete_donation_stats', $status, $date_range, $args ); |
|
| 1115 | + do_action('give_delete_donation_stats', $status, $date_range, $args); |
|
| 1116 | 1116 | |
| 1117 | 1117 | return $status; |
| 1118 | 1118 | } |
@@ -1130,7 +1130,7 @@ discard block |
||
| 1130 | 1130 | * |
| 1131 | 1131 | * @return mixed |
| 1132 | 1132 | */ |
| 1133 | -function give_get_meta( $id, $meta_key, $single = false, $default = false ) { |
|
| 1133 | +function give_get_meta($id, $meta_key, $single = false, $default = false) { |
|
| 1134 | 1134 | /** |
| 1135 | 1135 | * Filter the meta value |
| 1136 | 1136 | * |
@@ -1138,14 +1138,14 @@ discard block |
||
| 1138 | 1138 | */ |
| 1139 | 1139 | $meta_value = apply_filters( |
| 1140 | 1140 | 'give_get_meta', |
| 1141 | - get_post_meta( $id, $meta_key, $single ), |
|
| 1141 | + get_post_meta($id, $meta_key, $single), |
|
| 1142 | 1142 | $id, |
| 1143 | 1143 | $meta_key, |
| 1144 | 1144 | $default |
| 1145 | 1145 | ); |
| 1146 | 1146 | |
| 1147 | 1147 | if ( |
| 1148 | - ( empty( $meta_key ) || empty( $meta_value ) ) |
|
| 1148 | + (empty($meta_key) || empty($meta_value)) |
|
| 1149 | 1149 | && $default |
| 1150 | 1150 | ) { |
| 1151 | 1151 | $meta_value = $default; |
@@ -1166,15 +1166,15 @@ discard block |
||
| 1166 | 1166 | * |
| 1167 | 1167 | * @return mixed |
| 1168 | 1168 | */ |
| 1169 | -function give_update_meta( $id, $meta_key, $meta_value, $prev_value = '' ) { |
|
| 1170 | - $status = update_post_meta( $id, $meta_key, $meta_value, $prev_value ); |
|
| 1169 | +function give_update_meta($id, $meta_key, $meta_value, $prev_value = '') { |
|
| 1170 | + $status = update_post_meta($id, $meta_key, $meta_value, $prev_value); |
|
| 1171 | 1171 | |
| 1172 | 1172 | /** |
| 1173 | 1173 | * Filter the meta value update status |
| 1174 | 1174 | * |
| 1175 | 1175 | * @since 1.8.8 |
| 1176 | 1176 | */ |
| 1177 | - return apply_filters( 'give_update_meta', $status, $id, $meta_key, $meta_value ); |
|
| 1177 | + return apply_filters('give_update_meta', $status, $id, $meta_key, $meta_value); |
|
| 1178 | 1178 | } |
| 1179 | 1179 | |
| 1180 | 1180 | /** |
@@ -1188,15 +1188,15 @@ discard block |
||
| 1188 | 1188 | * |
| 1189 | 1189 | * @return mixed |
| 1190 | 1190 | */ |
| 1191 | -function give_delete_meta( $id, $meta_key, $meta_value = '' ) { |
|
| 1192 | - $status = delete_post_meta( $id, $meta_key, $meta_value ); |
|
| 1191 | +function give_delete_meta($id, $meta_key, $meta_value = '') { |
|
| 1192 | + $status = delete_post_meta($id, $meta_key, $meta_value); |
|
| 1193 | 1193 | |
| 1194 | 1194 | /** |
| 1195 | 1195 | * Filter the meta value delete status |
| 1196 | 1196 | * |
| 1197 | 1197 | * @since 1.8.8 |
| 1198 | 1198 | */ |
| 1199 | - return apply_filters( 'give_delete_meta', $status, $id, $meta_key, $meta_value ); |
|
| 1199 | + return apply_filters('give_delete_meta', $status, $id, $meta_key, $meta_value); |
|
| 1200 | 1200 | } |
| 1201 | 1201 | |
| 1202 | 1202 | /** |
@@ -1208,15 +1208,15 @@ discard block |
||
| 1208 | 1208 | * |
| 1209 | 1209 | * @return bool If the action has been added to the completed actions array |
| 1210 | 1210 | */ |
| 1211 | -function give_has_upgrade_completed( $upgrade_action = '' ) { |
|
| 1211 | +function give_has_upgrade_completed($upgrade_action = '') { |
|
| 1212 | 1212 | |
| 1213 | - if ( empty( $upgrade_action ) ) { |
|
| 1213 | + if (empty($upgrade_action)) { |
|
| 1214 | 1214 | return false; |
| 1215 | 1215 | } |
| 1216 | 1216 | |
| 1217 | 1217 | $completed_upgrades = give_get_completed_upgrades(); |
| 1218 | 1218 | |
| 1219 | - return in_array( $upgrade_action, $completed_upgrades ); |
|
| 1219 | + return in_array($upgrade_action, $completed_upgrades); |
|
| 1220 | 1220 | |
| 1221 | 1221 | } |
| 1222 | 1222 | |
@@ -1228,8 +1228,8 @@ discard block |
||
| 1228 | 1228 | * @return mixed When nothing to resume returns false, otherwise starts the upgrade where it left off |
| 1229 | 1229 | */ |
| 1230 | 1230 | function give_maybe_resume_upgrade() { |
| 1231 | - $doing_upgrade = get_option( 'give_doing_upgrade', false ); |
|
| 1232 | - if ( empty( $doing_upgrade ) ) { |
|
| 1231 | + $doing_upgrade = get_option('give_doing_upgrade', false); |
|
| 1232 | + if (empty($doing_upgrade)) { |
|
| 1233 | 1233 | return false; |
| 1234 | 1234 | } |
| 1235 | 1235 | |
@@ -1245,9 +1245,9 @@ discard block |
||
| 1245 | 1245 | * |
| 1246 | 1246 | * @return bool If the function was successfully added |
| 1247 | 1247 | */ |
| 1248 | -function give_set_upgrade_complete( $upgrade_action = '' ) { |
|
| 1248 | +function give_set_upgrade_complete($upgrade_action = '') { |
|
| 1249 | 1249 | |
| 1250 | - if ( empty( $upgrade_action ) ) { |
|
| 1250 | + if (empty($upgrade_action)) { |
|
| 1251 | 1251 | return false; |
| 1252 | 1252 | } |
| 1253 | 1253 | |
@@ -1255,16 +1255,16 @@ discard block |
||
| 1255 | 1255 | $completed_upgrades[] = $upgrade_action; |
| 1256 | 1256 | |
| 1257 | 1257 | // Remove any blanks, and only show uniques. |
| 1258 | - $completed_upgrades = array_unique( array_values( $completed_upgrades ) ); |
|
| 1258 | + $completed_upgrades = array_unique(array_values($completed_upgrades)); |
|
| 1259 | 1259 | |
| 1260 | 1260 | /** |
| 1261 | 1261 | * Fire the action when any upgrade set to complete. |
| 1262 | 1262 | * |
| 1263 | 1263 | * @since 1.8.12 |
| 1264 | 1264 | */ |
| 1265 | - do_action( 'give_set_upgrade_completed', $upgrade_action, $completed_upgrades ); |
|
| 1265 | + do_action('give_set_upgrade_completed', $upgrade_action, $completed_upgrades); |
|
| 1266 | 1266 | |
| 1267 | - return update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
| 1267 | + return update_option('give_completed_upgrades', $completed_upgrades); |
|
| 1268 | 1268 | } |
| 1269 | 1269 | |
| 1270 | 1270 | /** |
@@ -1274,7 +1274,7 @@ discard block |
||
| 1274 | 1274 | * @return array The array of completed upgrades |
| 1275 | 1275 | */ |
| 1276 | 1276 | function give_get_completed_upgrades() { |
| 1277 | - return (array) get_option( 'give_completed_upgrades' ); |
|
| 1277 | + return (array) get_option('give_completed_upgrades'); |
|
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | 1280 | |
@@ -1287,15 +1287,15 @@ discard block |
||
| 1287 | 1287 | * |
| 1288 | 1288 | * @return string URL |
| 1289 | 1289 | */ |
| 1290 | -function give_import_page_url( $parameter = array() ) { |
|
| 1290 | +function give_import_page_url($parameter = array()) { |
|
| 1291 | 1291 | $defalut_query_arg = array( |
| 1292 | 1292 | 'post_type' => 'give_forms', |
| 1293 | 1293 | 'page' => 'give-tools', |
| 1294 | 1294 | 'tab' => 'import', |
| 1295 | 1295 | ); |
| 1296 | - $import_query_arg = wp_parse_args( $parameter, $defalut_query_arg ); |
|
| 1296 | + $import_query_arg = wp_parse_args($parameter, $defalut_query_arg); |
|
| 1297 | 1297 | |
| 1298 | - return add_query_arg( $import_query_arg, admin_url( 'edit.php' ) ); |
|
| 1298 | + return add_query_arg($import_query_arg, admin_url('edit.php')); |
|
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | 1301 | /** |
@@ -1308,24 +1308,24 @@ discard block |
||
| 1308 | 1308 | * @param array $main_key First row from the CSV |
| 1309 | 1309 | * @param array $import_setting Contain the global variable. |
| 1310 | 1310 | */ |
| 1311 | -function give_save_import_donation_to_db( $raw_key, $row_data, $main_key = array(), $import_setting = array() ) { |
|
| 1312 | - $data = array_combine( $raw_key, $row_data ); |
|
| 1311 | +function give_save_import_donation_to_db($raw_key, $row_data, $main_key = array(), $import_setting = array()) { |
|
| 1312 | + $data = array_combine($raw_key, $row_data); |
|
| 1313 | 1313 | $price_id = false; |
| 1314 | 1314 | $customer_id = 0; |
| 1315 | - $import_setting['create_user'] = ( isset( $import_setting['create_user'] ) ? $import_setting['create_user'] : 1 ); |
|
| 1315 | + $import_setting['create_user'] = (isset($import_setting['create_user']) ? $import_setting['create_user'] : 1); |
|
| 1316 | 1316 | |
| 1317 | - $data = (array) apply_filters( 'give_save_import_donation_to_db', $data ); |
|
| 1317 | + $data = (array) apply_filters('give_save_import_donation_to_db', $data); |
|
| 1318 | 1318 | |
| 1319 | - if ( ! strpos( $data['amount'], '.' ) ) { |
|
| 1320 | - $data['amount'] = $data['amount'] . '.00'; |
|
| 1319 | + if ( ! strpos($data['amount'], '.')) { |
|
| 1320 | + $data['amount'] = $data['amount'].'.00'; |
|
| 1321 | 1321 | } |
| 1322 | 1322 | |
| 1323 | 1323 | // Here come the login function. |
| 1324 | - $donor_data = give_import_get_user_from_csv( $data, $import_setting ); |
|
| 1325 | - if ( ! empty( $donor_data->id ) ) { |
|
| 1326 | - if ( ! empty( $donor_data->user_id ) ) { |
|
| 1324 | + $donor_data = give_import_get_user_from_csv($data, $import_setting); |
|
| 1325 | + if ( ! empty($donor_data->id)) { |
|
| 1326 | + if ( ! empty($donor_data->user_id)) { |
|
| 1327 | 1327 | $customer_id = $donor_data->user_id; |
| 1328 | - } elseif ( ! empty( $data['user_id'] ) ) { |
|
| 1328 | + } elseif ( ! empty($data['user_id'])) { |
|
| 1329 | 1329 | $customer_id = $data['user_id']; |
| 1330 | 1330 | } |
| 1331 | 1331 | } else { |
@@ -1333,95 +1333,95 @@ discard block |
||
| 1333 | 1333 | } |
| 1334 | 1334 | |
| 1335 | 1335 | // get form data or register a form data. |
| 1336 | - $form = give_import_get_form_data_from_csv( $data, $import_setting ); |
|
| 1337 | - if ( false == $form ) { |
|
| 1336 | + $form = give_import_get_form_data_from_csv($data, $import_setting); |
|
| 1337 | + if (false == $form) { |
|
| 1338 | 1338 | return false; |
| 1339 | 1339 | } else { |
| 1340 | - $price_id = ( ! empty( $form->price_id ) ) ? $form->price_id : false; |
|
| 1340 | + $price_id = ( ! empty($form->price_id)) ? $form->price_id : false; |
|
| 1341 | 1341 | } |
| 1342 | 1342 | |
| 1343 | 1343 | |
| 1344 | 1344 | $address = array( |
| 1345 | - 'line1' => ( ! empty( $data['line1'] ) ? give_clean( $data['line1'] ) : '' ), |
|
| 1346 | - 'line2' => ( ! empty( $data['line1'] ) ? give_clean( $data['line2'] ) : '' ), |
|
| 1347 | - 'city' => ( ! empty( $data['line1'] ) ? give_clean( $data['city'] ) : '' ), |
|
| 1348 | - 'zip' => ( ! empty( $data['zip'] ) ? give_clean( $data['zip'] ) : '' ), |
|
| 1349 | - 'state' => ( ! empty( $data['state'] ) ? give_clean( $data['state'] ) : '' ), |
|
| 1350 | - 'country' => ( ! empty( $data['country'] ) ? ( ( $country_code = array_search( $data['country'], give_get_country_list() ) ) ? $country_code : $data['country'] ) : '' ), |
|
| 1345 | + 'line1' => ( ! empty($data['line1']) ? give_clean($data['line1']) : ''), |
|
| 1346 | + 'line2' => ( ! empty($data['line1']) ? give_clean($data['line2']) : ''), |
|
| 1347 | + 'city' => ( ! empty($data['line1']) ? give_clean($data['city']) : ''), |
|
| 1348 | + 'zip' => ( ! empty($data['zip']) ? give_clean($data['zip']) : ''), |
|
| 1349 | + 'state' => ( ! empty($data['state']) ? give_clean($data['state']) : ''), |
|
| 1350 | + 'country' => ( ! empty($data['country']) ? (($country_code = array_search($data['country'], give_get_country_list())) ? $country_code : $data['country']) : ''), |
|
| 1351 | 1351 | ); |
| 1352 | 1352 | |
| 1353 | 1353 | //Create payment_data array |
| 1354 | 1354 | $payment_data = array( |
| 1355 | 1355 | 'donor_id' => $donor_data->id, |
| 1356 | 1356 | 'price' => $data['amount'], |
| 1357 | - 'status' => ( ! empty( $data['post_status'] ) ? $data['post_status'] : 'publish' ), |
|
| 1357 | + 'status' => ( ! empty($data['post_status']) ? $data['post_status'] : 'publish'), |
|
| 1358 | 1358 | 'currency' => give_get_currency(), |
| 1359 | 1359 | 'user_info' => array( |
| 1360 | 1360 | 'id' => $customer_id, |
| 1361 | - 'email' => ( ! empty( $data['email'] ) ? $data['email'] : ( isset( $donor_data->email ) ? $donor_data->email : false ) ), |
|
| 1362 | - 'first_name' => ( ! empty( $data['first_name'] ) ? $data['first_name'] : ( ! empty( $customer_id ) && ( $first_name = get_user_meta( $customer_id, 'first_name', true ) ) ? $first_name : $donor_data->name ) ), |
|
| 1363 | - 'last_name' => ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ! empty( $customer_id ) && ( $last_name = get_user_meta( $customer_id, 'last_name', true ) ) ? $last_name : $donor_data->name ) ), |
|
| 1361 | + 'email' => ( ! empty($data['email']) ? $data['email'] : (isset($donor_data->email) ? $donor_data->email : false)), |
|
| 1362 | + 'first_name' => ( ! empty($data['first_name']) ? $data['first_name'] : ( ! empty($customer_id) && ($first_name = get_user_meta($customer_id, 'first_name', true)) ? $first_name : $donor_data->name)), |
|
| 1363 | + 'last_name' => ( ! empty($data['last_name']) ? $data['last_name'] : ( ! empty($customer_id) && ($last_name = get_user_meta($customer_id, 'last_name', true)) ? $last_name : $donor_data->name)), |
|
| 1364 | 1364 | 'address' => $address, |
| 1365 | 1365 | ), |
| 1366 | - 'gateway' => ( ! empty( $data['gateway'] ) && 'offline' != strtolower( $data['gateway'] ) ? strtolower( $data['gateway'] ) : 'manual' ), |
|
| 1367 | - 'give_form_title' => ( ! empty( $data['form_title'] ) ? $data['form_title'] : $form->get_name() ), |
|
| 1366 | + 'gateway' => ( ! empty($data['gateway']) && 'offline' != strtolower($data['gateway']) ? strtolower($data['gateway']) : 'manual'), |
|
| 1367 | + 'give_form_title' => ( ! empty($data['form_title']) ? $data['form_title'] : $form->get_name()), |
|
| 1368 | 1368 | 'give_form_id' => (string) $form->get_ID(), |
| 1369 | 1369 | 'give_price_id' => $price_id, |
| 1370 | - 'purchase_key' => strtolower( md5( uniqid() ) ), |
|
| 1370 | + 'purchase_key' => strtolower(md5(uniqid())), |
|
| 1371 | 1371 | 'user_email' => $data['email'], |
| 1372 | - 'post_date' => ( ! empty( $data['post_date'] ) ? mysql2date( 'Y-m-d H:i:s', $data['post_date'] ) : current_time( 'mysql' ) ), |
|
| 1373 | - 'mode' => ( ! empty( $data['mode'] ) ? ( 'true' == (string) $data['mode'] || 'TRUE' == (string) $data['mode'] ? 'test' : 'live' ) : ( isset( $import_setting['mode'] ) ? ( true == (bool) $import_setting['mode'] ? 'test' : 'live' ) : ( give_is_test_mode() ? 'test' : 'live' ) ) ), |
|
| 1372 | + 'post_date' => ( ! empty($data['post_date']) ? mysql2date('Y-m-d H:i:s', $data['post_date']) : current_time('mysql')), |
|
| 1373 | + 'mode' => ( ! empty($data['mode']) ? ('true' == (string) $data['mode'] || 'TRUE' == (string) $data['mode'] ? 'test' : 'live') : (isset($import_setting['mode']) ? (true == (bool) $import_setting['mode'] ? 'test' : 'live') : (give_is_test_mode() ? 'test' : 'live'))), |
|
| 1374 | 1374 | ); |
| 1375 | 1375 | |
| 1376 | - $payment_data = apply_filters( 'give_import_before_import_payment', $payment_data, $data, $donor_data, $form ); |
|
| 1376 | + $payment_data = apply_filters('give_import_before_import_payment', $payment_data, $data, $donor_data, $form); |
|
| 1377 | 1377 | |
| 1378 | 1378 | // Get the report |
| 1379 | 1379 | $report = give_import_donation_report(); |
| 1380 | 1380 | |
| 1381 | 1381 | // Check for duplicate code. |
| 1382 | - if ( true === give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) ) { |
|
| 1383 | - $report['duplicate_donation'] = ( ! empty( $report['duplicate_donation'] ) ? ( absint( $report['duplicate_donation'] ) + 1 ) : 1 ); |
|
| 1382 | + if (true === give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data)) { |
|
| 1383 | + $report['duplicate_donation'] = ( ! empty($report['duplicate_donation']) ? (absint($report['duplicate_donation']) + 1) : 1); |
|
| 1384 | 1384 | } else { |
| 1385 | - add_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1 ); |
|
| 1386 | - add_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2 ); |
|
| 1387 | - add_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3 ); |
|
| 1388 | - add_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11, 2 ); |
|
| 1389 | - $payment = give_insert_payment( $payment_data ); |
|
| 1390 | - remove_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1 ); |
|
| 1391 | - remove_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11 ); |
|
| 1392 | - remove_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11 ); |
|
| 1393 | - remove_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11 ); |
|
| 1385 | + add_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1); |
|
| 1386 | + add_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2); |
|
| 1387 | + add_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3); |
|
| 1388 | + add_action('give_insert_payment', 'give_import_donation_insert_payment', 11, 2); |
|
| 1389 | + $payment = give_insert_payment($payment_data); |
|
| 1390 | + remove_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1); |
|
| 1391 | + remove_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11); |
|
| 1392 | + remove_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11); |
|
| 1393 | + remove_action('give_insert_payment', 'give_import_donation_insert_payment', 11); |
|
| 1394 | 1394 | |
| 1395 | - if ( $payment ) { |
|
| 1395 | + if ($payment) { |
|
| 1396 | 1396 | |
| 1397 | - $report['create_donation'] = ( ! empty( $report['create_donation'] ) ? ( absint( $report['create_donation'] ) + 1 ) : 1 ); |
|
| 1397 | + $report['create_donation'] = ( ! empty($report['create_donation']) ? (absint($report['create_donation']) + 1) : 1); |
|
| 1398 | 1398 | |
| 1399 | - update_post_meta( $payment, '_give_payment_import', true ); |
|
| 1399 | + update_post_meta($payment, '_give_payment_import', true); |
|
| 1400 | 1400 | |
| 1401 | - if ( ! empty( $import_setting['csv'] ) ) { |
|
| 1402 | - update_post_meta( $payment, '_give_payment_import_id', $import_setting['csv'] ); |
|
| 1401 | + if ( ! empty($import_setting['csv'])) { |
|
| 1402 | + update_post_meta($payment, '_give_payment_import_id', $import_setting['csv']); |
|
| 1403 | 1403 | } |
| 1404 | 1404 | |
| 1405 | 1405 | // Insert Notes. |
| 1406 | - if ( ! empty( $data['notes'] ) ) { |
|
| 1407 | - give_insert_payment_note( $payment, $data['notes'] ); |
|
| 1406 | + if ( ! empty($data['notes'])) { |
|
| 1407 | + give_insert_payment_note($payment, $data['notes']); |
|
| 1408 | 1408 | } |
| 1409 | 1409 | |
| 1410 | - $meta_exists = array_keys( $raw_key, 'post_meta' ); |
|
| 1411 | - if ( ! empty( $main_key ) && ! empty( $meta_exists ) ) { |
|
| 1412 | - foreach ( $meta_exists as $meta_exist ) { |
|
| 1413 | - if ( ! empty( $main_key[ $meta_exist ] ) && ! empty( $row_data[ $meta_exist ] ) ) { |
|
| 1414 | - update_post_meta( $payment, $main_key[ $meta_exist ], $row_data[ $meta_exist ] ); |
|
| 1410 | + $meta_exists = array_keys($raw_key, 'post_meta'); |
|
| 1411 | + if ( ! empty($main_key) && ! empty($meta_exists)) { |
|
| 1412 | + foreach ($meta_exists as $meta_exist) { |
|
| 1413 | + if ( ! empty($main_key[$meta_exist]) && ! empty($row_data[$meta_exist])) { |
|
| 1414 | + update_post_meta($payment, $main_key[$meta_exist], $row_data[$meta_exist]); |
|
| 1415 | 1415 | } |
| 1416 | 1416 | } |
| 1417 | 1417 | } |
| 1418 | 1418 | } else { |
| 1419 | - $report['failed_donation'] = ( ! empty( $report['failed_donation'] ) ? ( absint( $report['failed_donation'] ) + 1 ) : 1 ); |
|
| 1419 | + $report['failed_donation'] = ( ! empty($report['failed_donation']) ? (absint($report['failed_donation']) + 1) : 1); |
|
| 1420 | 1420 | } |
| 1421 | 1421 | } |
| 1422 | 1422 | |
| 1423 | 1423 | // update the report |
| 1424 | - give_import_donation_report_update( $report ); |
|
| 1424 | + give_import_donation_report_update($report); |
|
| 1425 | 1425 | } |
| 1426 | 1426 | |
| 1427 | 1427 | /** |
@@ -1435,12 +1435,12 @@ discard block |
||
| 1435 | 1435 | * |
| 1436 | 1436 | * @return Give_Donor |
| 1437 | 1437 | */ |
| 1438 | -function give_donation_import_update_donor_information( $donor, $payment_id, $payment_data ) { |
|
| 1438 | +function give_donation_import_update_donor_information($donor, $payment_id, $payment_data) { |
|
| 1439 | 1439 | $old_donor = $donor; |
| 1440 | - if ( ! empty( $payment_data['donor_id'] ) ) { |
|
| 1441 | - $donor_id = absint( $payment_data['donor_id'] ); |
|
| 1442 | - $donor = new Give_Donor( $donor_id ); |
|
| 1443 | - if ( ! empty( $donor->id ) ) { |
|
| 1440 | + if ( ! empty($payment_data['donor_id'])) { |
|
| 1441 | + $donor_id = absint($payment_data['donor_id']); |
|
| 1442 | + $donor = new Give_Donor($donor_id); |
|
| 1443 | + if ( ! empty($donor->id)) { |
|
| 1444 | 1444 | return $donor; |
| 1445 | 1445 | } |
| 1446 | 1446 | } |
@@ -1453,12 +1453,12 @@ discard block |
||
| 1453 | 1453 | * |
| 1454 | 1454 | * @since 1.8.13 |
| 1455 | 1455 | */ |
| 1456 | -function give_import_donation_insert_payment( $payment_id, $payment_data ) { |
|
| 1456 | +function give_import_donation_insert_payment($payment_id, $payment_data) { |
|
| 1457 | 1457 | // Update Give Customers purchase_count |
| 1458 | - if ( ! empty( $payment_data['status'] ) && ( 'complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'] ) ) { |
|
| 1459 | - $donor_id = (int) get_post_meta( $payment_id, '_give_payment_customer_id', true ); |
|
| 1460 | - if ( ! empty( $donor_id ) ) { |
|
| 1461 | - $donor = new Give_Donor( $donor_id ); |
|
| 1458 | + if ( ! empty($payment_data['status']) && ('complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'])) { |
|
| 1459 | + $donor_id = (int) get_post_meta($payment_id, '_give_payment_customer_id', true); |
|
| 1460 | + if ( ! empty($donor_id)) { |
|
| 1461 | + $donor = new Give_Donor($donor_id); |
|
| 1462 | 1462 | $donor->increase_purchase_count(); |
| 1463 | 1463 | } |
| 1464 | 1464 | } |
@@ -1469,8 +1469,8 @@ discard block |
||
| 1469 | 1469 | * |
| 1470 | 1470 | * @since 8.1.13 |
| 1471 | 1471 | */ |
| 1472 | -function give_donation_import_give_insert_payment_args( $args, $payment_data ) { |
|
| 1473 | - if ( ! empty( $payment_data['user_info']['id'] ) ) { |
|
| 1472 | +function give_donation_import_give_insert_payment_args($args, $payment_data) { |
|
| 1473 | + if ( ! empty($payment_data['user_info']['id'])) { |
|
| 1474 | 1474 | $args['post_author'] = (int) $payment_data['user_info']['id']; |
| 1475 | 1475 | } |
| 1476 | 1476 | |
@@ -1482,11 +1482,11 @@ discard block |
||
| 1482 | 1482 | * |
| 1483 | 1483 | * @since 1.8.13 |
| 1484 | 1484 | */ |
| 1485 | -function give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) { |
|
| 1485 | +function give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data) { |
|
| 1486 | 1486 | $return = false; |
| 1487 | - if ( ! empty( $data['post_date'] ) ) { |
|
| 1488 | - $post_date = mysql2date( 'Y-m-d-H-i-s', $data['post_date'] ); |
|
| 1489 | - $post_date = explode( '-', $post_date ); |
|
| 1487 | + if ( ! empty($data['post_date'])) { |
|
| 1488 | + $post_date = mysql2date('Y-m-d-H-i-s', $data['post_date']); |
|
| 1489 | + $post_date = explode('-', $post_date); |
|
| 1490 | 1490 | $args = array( |
| 1491 | 1491 | 'post_type' => 'give_payment', |
| 1492 | 1492 | 'cache_results' => false, |
@@ -1507,7 +1507,7 @@ discard block |
||
| 1507 | 1507 | 'meta_query' => array( |
| 1508 | 1508 | array( |
| 1509 | 1509 | 'key' => '_give_payment_total', |
| 1510 | - 'value' => preg_replace( '/[\$,]/', '', $payment_data['price'] ), |
|
| 1510 | + 'value' => preg_replace('/[\$,]/', '', $payment_data['price']), |
|
| 1511 | 1511 | 'compare' => 'LIKE', |
| 1512 | 1512 | ), |
| 1513 | 1513 | array( |
@@ -1524,9 +1524,9 @@ discard block |
||
| 1524 | 1524 | ), |
| 1525 | 1525 | ); |
| 1526 | 1526 | |
| 1527 | - $payments = new Give_Payments_Query( $args ); |
|
| 1527 | + $payments = new Give_Payments_Query($args); |
|
| 1528 | 1528 | $donations = $payments->get_payments(); |
| 1529 | - if ( ! empty( $donations ) ) { |
|
| 1529 | + if ( ! empty($donations)) { |
|
| 1530 | 1530 | return true; |
| 1531 | 1531 | } |
| 1532 | 1532 | } |
@@ -1543,9 +1543,9 @@ discard block |
||
| 1543 | 1543 | * |
| 1544 | 1544 | * @return void |
| 1545 | 1545 | */ |
| 1546 | -function give_donation_import_insert_default_payment_note( $payment_id ) { |
|
| 1546 | +function give_donation_import_insert_default_payment_note($payment_id) { |
|
| 1547 | 1547 | $current_user = wp_get_current_user(); |
| 1548 | - give_insert_payment_note( $payment_id, esc_html( wp_sprintf( __( 'This donation was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
| 1548 | + give_insert_payment_note($payment_id, esc_html(wp_sprintf(__('This donation was imported by %s', 'give'), $current_user->user_email))); |
|
| 1549 | 1549 | } |
| 1550 | 1550 | |
| 1551 | 1551 | |
@@ -1558,7 +1558,7 @@ discard block |
||
| 1558 | 1558 | * |
| 1559 | 1559 | * @return bool |
| 1560 | 1560 | */ |
| 1561 | -function give_log_user_in_on_register_callback( $value ) { |
|
| 1561 | +function give_log_user_in_on_register_callback($value) { |
|
| 1562 | 1562 | return false; |
| 1563 | 1563 | } |
| 1564 | 1564 | |
@@ -1570,18 +1570,18 @@ discard block |
||
| 1570 | 1570 | * @param int $start Start from which csv line. |
| 1571 | 1571 | * @param int $end End from which csv line. |
| 1572 | 1572 | */ |
| 1573 | -function give_get_donation_data_from_csv( $file_id, $start, $end, $delimiter = ',' ) { |
|
| 1573 | +function give_get_donation_data_from_csv($file_id, $start, $end, $delimiter = ',') { |
|
| 1574 | 1574 | $raw_data = array(); |
| 1575 | - $file_dir = get_attached_file( $file_id ); |
|
| 1575 | + $file_dir = get_attached_file($file_id); |
|
| 1576 | 1576 | $count = 0; |
| 1577 | - if ( false !== ( $handle = fopen( $file_dir, 'r' ) ) ) { |
|
| 1578 | - while ( false !== ( $row = fgetcsv( $handle, 0, $delimiter ) ) ) { |
|
| 1579 | - if ( $count >= $start && $count <= $end ) { |
|
| 1577 | + if (false !== ($handle = fopen($file_dir, 'r'))) { |
|
| 1578 | + while (false !== ($row = fgetcsv($handle, 0, $delimiter))) { |
|
| 1579 | + if ($count >= $start && $count <= $end) { |
|
| 1580 | 1580 | $raw_data[] = $row; |
| 1581 | 1581 | } |
| 1582 | - $count ++; |
|
| 1582 | + $count++; |
|
| 1583 | 1583 | } |
| 1584 | - fclose( $handle ); |
|
| 1584 | + fclose($handle); |
|
| 1585 | 1585 | } |
| 1586 | 1586 | |
| 1587 | 1587 | return $raw_data; |
@@ -1601,9 +1601,9 @@ discard block |
||
| 1601 | 1601 | * |
| 1602 | 1602 | * @return array |
| 1603 | 1603 | */ |
| 1604 | - return (array) apply_filters( 'give_import_default_options', array( |
|
| 1605 | - '' => __( 'Do not import', 'give' ), |
|
| 1606 | - ) ); |
|
| 1604 | + return (array) apply_filters('give_import_default_options', array( |
|
| 1605 | + '' => __('Do not import', 'give'), |
|
| 1606 | + )); |
|
| 1607 | 1607 | } |
| 1608 | 1608 | |
| 1609 | 1609 | /** |
@@ -1619,26 +1619,26 @@ discard block |
||
| 1619 | 1619 | * |
| 1620 | 1620 | * @return array |
| 1621 | 1621 | */ |
| 1622 | - return (array) apply_filters( 'give_import_donations_options', array( |
|
| 1623 | - '' => __( 'Do not import', 'give' ), |
|
| 1624 | - 'id' => __( 'Donation ID', 'give' ), |
|
| 1625 | - 'amount' => __( 'Donation Amount', 'give' ), |
|
| 1626 | - 'post_date' => __( 'Donation Date', 'give' ), |
|
| 1627 | - 'first_name' => __( 'Donor First Name', 'give' ), |
|
| 1628 | - 'last_name' => __( 'Donor Last Name', 'give' ), |
|
| 1629 | - 'line1' => __( 'Address 1', 'give' ), |
|
| 1630 | - 'line2' => __( 'Address 2', 'give' ), |
|
| 1631 | - 'city' => __( 'City', 'give' ), |
|
| 1632 | - 'state' => __( 'State', 'give' ), |
|
| 1633 | - 'country' => __( 'Country', 'give' ), |
|
| 1634 | - 'zip' => __( 'Zip', 'give' ), |
|
| 1635 | - 'email' => __( 'Donor Email', 'give' ), |
|
| 1636 | - 'post_status' => __( 'Donation Status', 'give' ), |
|
| 1637 | - 'gateway' => __( 'Payment Method', 'give' ), |
|
| 1638 | - 'notes' => __( 'Notes', 'give' ), |
|
| 1639 | - 'mode' => __( 'Test Mode', 'give' ), |
|
| 1640 | - 'post_meta' => __( 'Import as Meta', 'give' ), |
|
| 1641 | - ) ); |
|
| 1622 | + return (array) apply_filters('give_import_donations_options', array( |
|
| 1623 | + '' => __('Do not import', 'give'), |
|
| 1624 | + 'id' => __('Donation ID', 'give'), |
|
| 1625 | + 'amount' => __('Donation Amount', 'give'), |
|
| 1626 | + 'post_date' => __('Donation Date', 'give'), |
|
| 1627 | + 'first_name' => __('Donor First Name', 'give'), |
|
| 1628 | + 'last_name' => __('Donor Last Name', 'give'), |
|
| 1629 | + 'line1' => __('Address 1', 'give'), |
|
| 1630 | + 'line2' => __('Address 2', 'give'), |
|
| 1631 | + 'city' => __('City', 'give'), |
|
| 1632 | + 'state' => __('State', 'give'), |
|
| 1633 | + 'country' => __('Country', 'give'), |
|
| 1634 | + 'zip' => __('Zip', 'give'), |
|
| 1635 | + 'email' => __('Donor Email', 'give'), |
|
| 1636 | + 'post_status' => __('Donation Status', 'give'), |
|
| 1637 | + 'gateway' => __('Payment Method', 'give'), |
|
| 1638 | + 'notes' => __('Notes', 'give'), |
|
| 1639 | + 'mode' => __('Test Mode', 'give'), |
|
| 1640 | + 'post_meta' => __('Import as Meta', 'give'), |
|
| 1641 | + )); |
|
| 1642 | 1642 | } |
| 1643 | 1643 | |
| 1644 | 1644 | /** |
@@ -1654,10 +1654,10 @@ discard block |
||
| 1654 | 1654 | * |
| 1655 | 1655 | * @return array |
| 1656 | 1656 | */ |
| 1657 | - return (array) apply_filters( 'give_import_donor_options', array( |
|
| 1658 | - 'donor_id' => __( 'Donor ID', 'give' ), |
|
| 1659 | - 'user_id' => __( 'User ID', 'give' ), |
|
| 1660 | - ) ); |
|
| 1657 | + return (array) apply_filters('give_import_donor_options', array( |
|
| 1658 | + 'donor_id' => __('Donor ID', 'give'), |
|
| 1659 | + 'user_id' => __('User ID', 'give'), |
|
| 1660 | + )); |
|
| 1661 | 1661 | } |
| 1662 | 1662 | |
| 1663 | 1663 | /** |
@@ -1673,12 +1673,12 @@ discard block |
||
| 1673 | 1673 | * |
| 1674 | 1674 | * @return array |
| 1675 | 1675 | */ |
| 1676 | - return (array) apply_filters( 'give_import_donation_form_options', array( |
|
| 1677 | - 'form_id' => __( 'Donation Form ID', 'give' ), |
|
| 1678 | - 'form_title' => __( 'Donation Form', 'give' ), |
|
| 1679 | - 'form_level' => __( 'Donation Level', 'give' ), |
|
| 1680 | - 'form_custom_amount_text' => __( 'Custom Amount Text', 'give' ), |
|
| 1681 | - ) ); |
|
| 1676 | + return (array) apply_filters('give_import_donation_form_options', array( |
|
| 1677 | + 'form_id' => __('Donation Form ID', 'give'), |
|
| 1678 | + 'form_title' => __('Donation Form', 'give'), |
|
| 1679 | + 'form_level' => __('Donation Level', 'give'), |
|
| 1680 | + 'form_custom_amount_text' => __('Custom Amount Text', 'give'), |
|
| 1681 | + )); |
|
| 1682 | 1682 | } |
| 1683 | 1683 | |
| 1684 | 1684 | /** |
@@ -1690,30 +1690,30 @@ discard block |
||
| 1690 | 1690 | * |
| 1691 | 1691 | * @return bool|false|WP_User |
| 1692 | 1692 | */ |
| 1693 | -function give_import_get_user_from_csv( $data, $import_setting = array() ) { |
|
| 1693 | +function give_import_get_user_from_csv($data, $import_setting = array()) { |
|
| 1694 | 1694 | $report = give_import_donation_report(); |
| 1695 | 1695 | $donor_data = false; |
| 1696 | 1696 | $customer_id = false; |
| 1697 | 1697 | |
| 1698 | 1698 | // check if donor id is not empty |
| 1699 | - if ( ! empty( $data['donor_id'] ) ) { |
|
| 1700 | - $donor_data = new Give_Donor( (int) $data['donor_id'] ); |
|
| 1701 | - if ( ! empty( $donor_data->id ) ) { |
|
| 1702 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
| 1699 | + if ( ! empty($data['donor_id'])) { |
|
| 1700 | + $donor_data = new Give_Donor((int) $data['donor_id']); |
|
| 1701 | + if ( ! empty($donor_data->id)) { |
|
| 1702 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
| 1703 | 1703 | } |
| 1704 | 1704 | } |
| 1705 | 1705 | |
| 1706 | - if ( empty( $donor_data->id ) && ! empty( $data['user_id'] ) ) { |
|
| 1706 | + if (empty($donor_data->id) && ! empty($data['user_id'])) { |
|
| 1707 | 1707 | $user_id = (int) $data['user_id']; |
| 1708 | - $donor_data = new Give_Donor( $user_id, true ); |
|
| 1708 | + $donor_data = new Give_Donor($user_id, true); |
|
| 1709 | 1709 | |
| 1710 | 1710 | |
| 1711 | - if ( empty( $donor_data->id ) ) { |
|
| 1712 | - $donor_data = get_user_by( 'id', $user_id ); |
|
| 1713 | - if ( ! empty( $donor_data->ID ) ) { |
|
| 1714 | - $first_name = ( ! empty( $data['first_name'] ) ? $data['first_name'] : $donor_data->user_nicename ); |
|
| 1715 | - $last_name = ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ( $lastname = get_user_meta( $donor_data->ID, 'last_name', true ) ) ? $lastname : '' ) ); |
|
| 1716 | - $name = $first_name . ' ' . $last_name; |
|
| 1711 | + if (empty($donor_data->id)) { |
|
| 1712 | + $donor_data = get_user_by('id', $user_id); |
|
| 1713 | + if ( ! empty($donor_data->ID)) { |
|
| 1714 | + $first_name = ( ! empty($data['first_name']) ? $data['first_name'] : $donor_data->user_nicename); |
|
| 1715 | + $last_name = ( ! empty($data['last_name']) ? $data['last_name'] : (($lastname = get_user_meta($donor_data->ID, 'last_name', true)) ? $lastname : '')); |
|
| 1716 | + $name = $first_name.' '.$last_name; |
|
| 1717 | 1717 | $user_email = $donor_data->user_email; |
| 1718 | 1718 | $donor_args = array( |
| 1719 | 1719 | 'name' => $name, |
@@ -1722,44 +1722,44 @@ discard block |
||
| 1722 | 1722 | ); |
| 1723 | 1723 | |
| 1724 | 1724 | $donor_data = new Give_Donor(); |
| 1725 | - $donor_data->create( $donor_args ); |
|
| 1725 | + $donor_data->create($donor_args); |
|
| 1726 | 1726 | |
| 1727 | 1727 | // Adding notes that donor is being imported from CSV. |
| 1728 | 1728 | $current_user = wp_get_current_user(); |
| 1729 | - $donor_data->add_note( esc_html( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
| 1729 | + $donor_data->add_note(esc_html(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email))); |
|
| 1730 | 1730 | |
| 1731 | 1731 | // Add is used to ensure duplicate emails are not added |
| 1732 | - if ( $user_email != $data['email'] && ! empty( $data['email'] ) ) { |
|
| 1733 | - $donor_data->add_meta( 'additional_email', $data['email'] ); |
|
| 1732 | + if ($user_email != $data['email'] && ! empty($data['email'])) { |
|
| 1733 | + $donor_data->add_meta('additional_email', $data['email']); |
|
| 1734 | 1734 | } |
| 1735 | 1735 | |
| 1736 | - $report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 ); |
|
| 1736 | + $report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1); |
|
| 1737 | 1737 | } else { |
| 1738 | 1738 | } |
| 1739 | 1739 | } else { |
| 1740 | 1740 | // Add is used to ensure duplicate emails are not added |
| 1741 | - if ( $donor_data->email != $data['email'] ) { |
|
| 1742 | - $donor_data->add_meta( 'additional_email', ( ! empty( $data['email'] ) ? $data['email'] : $donor_data->email ) ); |
|
| 1741 | + if ($donor_data->email != $data['email']) { |
|
| 1742 | + $donor_data->add_meta('additional_email', ( ! empty($data['email']) ? $data['email'] : $donor_data->email)); |
|
| 1743 | 1743 | } |
| 1744 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
| 1744 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
| 1745 | 1745 | } |
| 1746 | 1746 | } |
| 1747 | 1747 | |
| 1748 | - if ( empty( $donor_data->id ) && ! empty( $data['email'] ) ) { |
|
| 1748 | + if (empty($donor_data->id) && ! empty($data['email'])) { |
|
| 1749 | 1749 | |
| 1750 | - $donor_data = new Give_Donor( $data['email'] ); |
|
| 1751 | - if ( empty( $donor_data->id ) ) { |
|
| 1752 | - $donor_data = get_user_by( 'email', $data['email'] ); |
|
| 1750 | + $donor_data = new Give_Donor($data['email']); |
|
| 1751 | + if (empty($donor_data->id)) { |
|
| 1752 | + $donor_data = get_user_by('email', $data['email']); |
|
| 1753 | 1753 | |
| 1754 | - if ( empty( $donor_data->ID ) && ! empty( $data['first_name'] ) && ! empty( $data['last_name'] ) && isset( $import_setting['create_user'] ) && 1 === absint( $import_setting['create_user'] ) ) { |
|
| 1755 | - $give_role = (array) give_get_option( 'donor_default_user_role', get_option( 'default_role', ( ( $give_donor = wp_roles()->is_role( 'give_donor' ) ) && ! empty( $give_donor ) ? 'give_donor' : 'subscriber' ) ) ); |
|
| 1754 | + if (empty($donor_data->ID) && ! empty($data['first_name']) && ! empty($data['last_name']) && isset($import_setting['create_user']) && 1 === absint($import_setting['create_user'])) { |
|
| 1755 | + $give_role = (array) give_get_option('donor_default_user_role', get_option('default_role', (($give_donor = wp_roles()->is_role('give_donor')) && ! empty($give_donor) ? 'give_donor' : 'subscriber'))); |
|
| 1756 | 1756 | $donor_args = array( |
| 1757 | 1757 | 'user_login' => $data['email'], |
| 1758 | 1758 | 'user_email' => $data['email'], |
| 1759 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
| 1759 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
| 1760 | 1760 | 'user_first' => $data['first_name'], |
| 1761 | 1761 | 'user_last' => $data['last_name'], |
| 1762 | - 'user_pass' => wp_generate_password( 8, true ), |
|
| 1762 | + 'user_pass' => wp_generate_password(8, true), |
|
| 1763 | 1763 | 'role' => $give_role, |
| 1764 | 1764 | ); |
| 1765 | 1765 | |
@@ -1768,56 +1768,56 @@ discard block |
||
| 1768 | 1768 | * |
| 1769 | 1769 | * @since 1.8.13 |
| 1770 | 1770 | */ |
| 1771 | - $donor_args = (array) apply_filters( 'give_import_insert_user_args', $donor_args, $data, $import_setting ); |
|
| 1771 | + $donor_args = (array) apply_filters('give_import_insert_user_args', $donor_args, $data, $import_setting); |
|
| 1772 | 1772 | |
| 1773 | 1773 | // This action was added to remove the login when using the give register function. |
| 1774 | - add_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 ); |
|
| 1775 | - $customer_id = give_register_and_login_new_user( $donor_args ); |
|
| 1776 | - remove_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 ); |
|
| 1774 | + add_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11); |
|
| 1775 | + $customer_id = give_register_and_login_new_user($donor_args); |
|
| 1776 | + remove_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11); |
|
| 1777 | 1777 | |
| 1778 | - update_user_meta( $customer_id, '_give_payment_import', true ); |
|
| 1779 | - $donor_data = new Give_Donor( $customer_id, true ); |
|
| 1778 | + update_user_meta($customer_id, '_give_payment_import', true); |
|
| 1779 | + $donor_data = new Give_Donor($customer_id, true); |
|
| 1780 | 1780 | } else { |
| 1781 | - $customer_id = ( ! empty( $donor_data->ID ) ? $donor_data->ID : false ); |
|
| 1781 | + $customer_id = ( ! empty($donor_data->ID) ? $donor_data->ID : false); |
|
| 1782 | 1782 | } |
| 1783 | 1783 | |
| 1784 | - if ( ! empty( $customer_id ) || ( isset( $import_setting['create_user'] ) && 0 === absint( $import_setting['create_user'] ) ) ) { |
|
| 1785 | - $donor_data = new Give_Donor( $customer_id, true ); |
|
| 1784 | + if ( ! empty($customer_id) || (isset($import_setting['create_user']) && 0 === absint($import_setting['create_user']))) { |
|
| 1785 | + $donor_data = new Give_Donor($customer_id, true); |
|
| 1786 | 1786 | |
| 1787 | - if ( empty( $donor_data->id ) ) { |
|
| 1787 | + if (empty($donor_data->id)) { |
|
| 1788 | 1788 | |
| 1789 | - if ( ! empty( $data['form_id'] ) ) { |
|
| 1790 | - $form = new Give_Donate_Form( $data['form_id'] ); |
|
| 1789 | + if ( ! empty($data['form_id'])) { |
|
| 1790 | + $form = new Give_Donate_Form($data['form_id']); |
|
| 1791 | 1791 | } |
| 1792 | 1792 | |
| 1793 | - $payment_title = ( isset( $data['form_title'] ) ? $data['form_title'] : ( isset( $form ) ? $form->get_name() : esc_html__( 'New Form', 'give' ) ) ); |
|
| 1793 | + $payment_title = (isset($data['form_title']) ? $data['form_title'] : (isset($form) ? $form->get_name() : esc_html__('New Form', 'give'))); |
|
| 1794 | 1794 | $donor_args = array( |
| 1795 | - 'name' => ! is_email( $payment_title ) ? $data['first_name'] . ' ' . $data['last_name'] : '', |
|
| 1795 | + 'name' => ! is_email($payment_title) ? $data['first_name'].' '.$data['last_name'] : '', |
|
| 1796 | 1796 | 'email' => $data['email'], |
| 1797 | 1797 | ); |
| 1798 | 1798 | |
| 1799 | - if ( ! empty( $customer_id ) ) { |
|
| 1799 | + if ( ! empty($customer_id)) { |
|
| 1800 | 1800 | $donor_args['user_id'] = $customer_id; |
| 1801 | 1801 | } |
| 1802 | 1802 | |
| 1803 | - $donor_data->create( $donor_args ); |
|
| 1803 | + $donor_data->create($donor_args); |
|
| 1804 | 1804 | |
| 1805 | 1805 | // Adding notes that donor is being imported from CSV. |
| 1806 | 1806 | $current_user = wp_get_current_user(); |
| 1807 | - $donor_data->add_note( esc_html( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
| 1807 | + $donor_data->add_note(esc_html(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email))); |
|
| 1808 | 1808 | |
| 1809 | - $report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 ); |
|
| 1809 | + $report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1); |
|
| 1810 | 1810 | } else { |
| 1811 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
| 1811 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
| 1812 | 1812 | } |
| 1813 | 1813 | } |
| 1814 | 1814 | } else { |
| 1815 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
| 1815 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
| 1816 | 1816 | } |
| 1817 | 1817 | } |
| 1818 | 1818 | |
| 1819 | 1819 | // update the report |
| 1820 | - give_import_donation_report_update( $report ); |
|
| 1820 | + give_import_donation_report_update($report); |
|
| 1821 | 1821 | |
| 1822 | 1822 | return $donor_data; |
| 1823 | 1823 | } |
@@ -1831,7 +1831,7 @@ discard block |
||
| 1831 | 1831 | * |
| 1832 | 1832 | * @return array|bool|Give_Donate_Form|int|null|WP_Post |
| 1833 | 1833 | */ |
| 1834 | -function give_import_get_form_data_from_csv( $data, $import_setting = array() ) { |
|
| 1834 | +function give_import_get_form_data_from_csv($data, $import_setting = array()) { |
|
| 1835 | 1835 | $new_form = false; |
| 1836 | 1836 | |
| 1837 | 1837 | // Get the import report |
@@ -1840,58 +1840,58 @@ discard block |
||
| 1840 | 1840 | $form = false; |
| 1841 | 1841 | $meta = array(); |
| 1842 | 1842 | |
| 1843 | - if ( ! empty( $data['form_id'] ) ) { |
|
| 1844 | - $form = new Give_Donate_Form( $data['form_id'] ); |
|
| 1843 | + if ( ! empty($data['form_id'])) { |
|
| 1844 | + $form = new Give_Donate_Form($data['form_id']); |
|
| 1845 | 1845 | // Add support to older php version. |
| 1846 | 1846 | $form_id = $form->get_ID(); |
| 1847 | - if ( empty( $form_id ) ) { |
|
| 1848 | - $report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 ); |
|
| 1847 | + if (empty($form_id)) { |
|
| 1848 | + $report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1); |
|
| 1849 | 1849 | $form = false; |
| 1850 | 1850 | } |
| 1851 | 1851 | } |
| 1852 | 1852 | |
| 1853 | - if ( false === $form && ! empty( $data['form_title'] ) ) { |
|
| 1854 | - $form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' ); |
|
| 1853 | + if (false === $form && ! empty($data['form_title'])) { |
|
| 1854 | + $form = get_page_by_title($data['form_title'], OBJECT, 'give_forms'); |
|
| 1855 | 1855 | |
| 1856 | - if ( ! empty( $form->ID ) ) { |
|
| 1856 | + if ( ! empty($form->ID)) { |
|
| 1857 | 1857 | |
| 1858 | - $report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 ); |
|
| 1858 | + $report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1); |
|
| 1859 | 1859 | |
| 1860 | - $form = new Give_Donate_Form( $form->ID ); |
|
| 1860 | + $form = new Give_Donate_Form($form->ID); |
|
| 1861 | 1861 | } else { |
| 1862 | 1862 | $form = new Give_Donate_Form(); |
| 1863 | 1863 | $args = array( |
| 1864 | 1864 | 'post_title' => $data['form_title'], |
| 1865 | 1865 | 'post_status' => 'publish', |
| 1866 | 1866 | ); |
| 1867 | - $form = $form->create( $args ); |
|
| 1868 | - $report['create_form'] = ( ! empty( $report['create_form'] ) ? ( absint( $report['create_form'] ) + 1 ) : 1 ); |
|
| 1867 | + $form = $form->create($args); |
|
| 1868 | + $report['create_form'] = ( ! empty($report['create_form']) ? (absint($report['create_form']) + 1) : 1); |
|
| 1869 | 1869 | $new_form = true; |
| 1870 | 1870 | |
| 1871 | 1871 | } |
| 1872 | 1872 | |
| 1873 | - $form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' ); |
|
| 1874 | - $form = new Give_Donate_Form( $form->ID ); |
|
| 1873 | + $form = get_page_by_title($data['form_title'], OBJECT, 'give_forms'); |
|
| 1874 | + $form = new Give_Donate_Form($form->ID); |
|
| 1875 | 1875 | } |
| 1876 | 1876 | |
| 1877 | - if ( ! empty( $form ) && $form->get_ID() ) { |
|
| 1878 | - if ( ! empty( $data['form_level'] ) && 'custom' != (string) strtolower( $data['form_level'] ) ) { |
|
| 1877 | + if ( ! empty($form) && $form->get_ID()) { |
|
| 1878 | + if ( ! empty($data['form_level']) && 'custom' != (string) strtolower($data['form_level'])) { |
|
| 1879 | 1879 | $prices = (array) $form->get_prices(); |
| 1880 | 1880 | $price_text = array(); |
| 1881 | - foreach ( $prices as $key => $price ) { |
|
| 1882 | - if ( isset( $price['_give_id']['level_id'] ) ) { |
|
| 1883 | - $price_text[ $price['_give_id']['level_id'] ] = ( ! empty( $price['_give_text'] ) ? $price['_give_text'] : '' ); |
|
| 1881 | + foreach ($prices as $key => $price) { |
|
| 1882 | + if (isset($price['_give_id']['level_id'])) { |
|
| 1883 | + $price_text[$price['_give_id']['level_id']] = ( ! empty($price['_give_text']) ? $price['_give_text'] : ''); |
|
| 1884 | 1884 | } |
| 1885 | 1885 | } |
| 1886 | 1886 | |
| 1887 | - if ( ! in_array( $data['form_level'], $price_text ) ) { |
|
| 1887 | + if ( ! in_array($data['form_level'], $price_text)) { |
|
| 1888 | 1888 | |
| 1889 | 1889 | // For generating unquiet level id. |
| 1890 | 1890 | $count = 1; |
| 1891 | - $new_level = count( $prices ) + $count; |
|
| 1892 | - while ( array_key_exists( $new_level, $price_text ) ) { |
|
| 1893 | - $count ++; |
|
| 1894 | - $new_level = count( $prices ) + $count; |
|
| 1891 | + $new_level = count($prices) + $count; |
|
| 1892 | + while (array_key_exists($new_level, $price_text)) { |
|
| 1893 | + $count++; |
|
| 1894 | + $new_level = count($prices) + $count; |
|
| 1895 | 1895 | } |
| 1896 | 1896 | |
| 1897 | 1897 | $multi_level_donations = array( |
@@ -1899,45 +1899,45 @@ discard block |
||
| 1899 | 1899 | '_give_id' => array( |
| 1900 | 1900 | 'level_id' => $new_level, |
| 1901 | 1901 | ), |
| 1902 | - '_give_amount' => give_sanitize_amount_for_db( $data['amount'] ), |
|
| 1902 | + '_give_amount' => give_sanitize_amount_for_db($data['amount']), |
|
| 1903 | 1903 | '_give_text' => $data['form_level'], |
| 1904 | 1904 | ), |
| 1905 | 1905 | ); |
| 1906 | 1906 | |
| 1907 | - $price_text[ $new_level ] = $data['form_level']; |
|
| 1907 | + $price_text[$new_level] = $data['form_level']; |
|
| 1908 | 1908 | |
| 1909 | - if ( ! empty( $prices ) && is_array( $prices ) && ! empty( $prices[0] ) ) { |
|
| 1910 | - $prices = wp_parse_args( $multi_level_donations, $prices ); |
|
| 1909 | + if ( ! empty($prices) && is_array($prices) && ! empty($prices[0])) { |
|
| 1910 | + $prices = wp_parse_args($multi_level_donations, $prices); |
|
| 1911 | 1911 | } else { |
| 1912 | 1912 | $multi_level_donations[0]['_give_default'] = 'default'; |
| 1913 | 1913 | $prices = $multi_level_donations; |
| 1914 | 1914 | } |
| 1915 | 1915 | } |
| 1916 | - $form->price_id = array_search( $data['form_level'], $price_text ); |
|
| 1916 | + $form->price_id = array_search($data['form_level'], $price_text); |
|
| 1917 | 1917 | |
| 1918 | - $donation_levels_amounts = wp_list_pluck( $prices, '_give_amount' ); |
|
| 1919 | - $min_amount = min( $donation_levels_amounts ); |
|
| 1920 | - $max_amount = max( $donation_levels_amounts ); |
|
| 1918 | + $donation_levels_amounts = wp_list_pluck($prices, '_give_amount'); |
|
| 1919 | + $min_amount = min($donation_levels_amounts); |
|
| 1920 | + $max_amount = max($donation_levels_amounts); |
|
| 1921 | 1921 | |
| 1922 | 1922 | $meta = array( |
| 1923 | 1923 | '_give_levels_minimum_amount' => $min_amount, |
| 1924 | 1924 | '_give_levels_maximum_amount' => $max_amount, |
| 1925 | 1925 | '_give_price_option' => 'multi', |
| 1926 | - '_give_donation_levels' => array_values( $prices ), |
|
| 1926 | + '_give_donation_levels' => array_values($prices), |
|
| 1927 | 1927 | ); |
| 1928 | 1928 | } else { |
| 1929 | 1929 | $form->price_id = 'custom'; |
| 1930 | 1930 | } |
| 1931 | 1931 | |
| 1932 | 1932 | $defaults = array( |
| 1933 | - '_give_set_price' => give_sanitize_amount_for_db( $data['amount'] ), |
|
| 1933 | + '_give_set_price' => give_sanitize_amount_for_db($data['amount']), |
|
| 1934 | 1934 | '_give_price_option' => 'set', |
| 1935 | 1935 | ); |
| 1936 | 1936 | |
| 1937 | 1937 | // If new form is created. |
| 1938 | - if ( ! empty( $new_form ) ) { |
|
| 1938 | + if ( ! empty($new_form)) { |
|
| 1939 | 1939 | $new_form = array( |
| 1940 | - '_give_custom_amount_text' => ( ! empty( $data['form_custom_amount_text'] ) ? $data['form_custom_amount_text'] : 'Custom' ), |
|
| 1940 | + '_give_custom_amount_text' => ( ! empty($data['form_custom_amount_text']) ? $data['form_custom_amount_text'] : 'Custom'), |
|
| 1941 | 1941 | '_give_logged_in_only' => 'enabled', |
| 1942 | 1942 | '_give_custom_amount' => 'enabled', |
| 1943 | 1943 | '_give_payment_import' => true, |
@@ -1948,18 +1948,18 @@ discard block |
||
| 1948 | 1948 | '_give_default_gateway' => 'global', |
| 1949 | 1949 | '_give_show_register_form' => 'both', |
| 1950 | 1950 | ); |
| 1951 | - $defaults = wp_parse_args( $defaults, $new_form ); |
|
| 1951 | + $defaults = wp_parse_args($defaults, $new_form); |
|
| 1952 | 1952 | } |
| 1953 | 1953 | |
| 1954 | - $meta = wp_parse_args( $meta, $defaults ); |
|
| 1954 | + $meta = wp_parse_args($meta, $defaults); |
|
| 1955 | 1955 | |
| 1956 | - foreach ( $meta as $key => $value ) { |
|
| 1957 | - give_update_meta( $form->get_ID(), $key, $value ); |
|
| 1956 | + foreach ($meta as $key => $value) { |
|
| 1957 | + give_update_meta($form->get_ID(), $key, $value); |
|
| 1958 | 1958 | } |
| 1959 | 1959 | } |
| 1960 | 1960 | |
| 1961 | 1961 | // update the report |
| 1962 | - give_import_donation_report_update( $report ); |
|
| 1962 | + give_import_donation_report_update($report); |
|
| 1963 | 1963 | |
| 1964 | 1964 | return $form; |
| 1965 | 1965 | } |
@@ -1972,19 +1972,19 @@ discard block |
||
| 1972 | 1972 | * @param \WP_Query |
| 1973 | 1973 | * |
| 1974 | 1974 | */ |
| 1975 | -function give_remove_pages_from_search( $query ) { |
|
| 1976 | - if ( ! $query->is_admin && $query->is_search && $query->is_main_query() ) { |
|
| 1977 | - $transaction_failed = give_get_option( 'failure_page', 0 ); |
|
| 1978 | - $success_page = give_get_option( 'success_page', 0 ); |
|
| 1979 | - $args = apply_filters( 'give_remove_pages_from_search', array( |
|
| 1975 | +function give_remove_pages_from_search($query) { |
|
| 1976 | + if ( ! $query->is_admin && $query->is_search && $query->is_main_query()) { |
|
| 1977 | + $transaction_failed = give_get_option('failure_page', 0); |
|
| 1978 | + $success_page = give_get_option('success_page', 0); |
|
| 1979 | + $args = apply_filters('give_remove_pages_from_search', array( |
|
| 1980 | 1980 | $transaction_failed, |
| 1981 | 1981 | $success_page |
| 1982 | - ), $query ); |
|
| 1983 | - $query->set( 'post__not_in', $args ); |
|
| 1982 | + ), $query); |
|
| 1983 | + $query->set('post__not_in', $args); |
|
| 1984 | 1984 | } |
| 1985 | 1985 | } |
| 1986 | 1986 | |
| 1987 | -add_action( 'pre_get_posts', 'give_remove_pages_from_search', 10, 1 ); |
|
| 1987 | +add_action('pre_get_posts', 'give_remove_pages_from_search', 10, 1); |
|
| 1988 | 1988 | |
| 1989 | 1989 | /** |
| 1990 | 1990 | * Inserts a new key/value before a key in the array. |
@@ -2000,14 +2000,14 @@ discard block |
||
| 2000 | 2000 | * |
| 2001 | 2001 | * @see array_insert_before() |
| 2002 | 2002 | */ |
| 2003 | -function give_array_insert_before( $key, array &$array, $new_key, $new_value ) { |
|
| 2004 | - if ( array_key_exists( $key, $array ) ) { |
|
| 2003 | +function give_array_insert_before($key, array &$array, $new_key, $new_value) { |
|
| 2004 | + if (array_key_exists($key, $array)) { |
|
| 2005 | 2005 | $new = array(); |
| 2006 | - foreach ( $array as $k => $value ) { |
|
| 2007 | - if ( $k === $key ) { |
|
| 2008 | - $new[ $new_key ] = $new_value; |
|
| 2006 | + foreach ($array as $k => $value) { |
|
| 2007 | + if ($k === $key) { |
|
| 2008 | + $new[$new_key] = $new_value; |
|
| 2009 | 2009 | } |
| 2010 | - $new[ $k ] = $value; |
|
| 2010 | + $new[$k] = $value; |
|
| 2011 | 2011 | } |
| 2012 | 2012 | |
| 2013 | 2013 | return $new; |
@@ -2030,13 +2030,13 @@ discard block |
||
| 2030 | 2030 | * |
| 2031 | 2031 | * @see array_insert_before() |
| 2032 | 2032 | */ |
| 2033 | -function give_array_insert_after( $key, array &$array, $new_key, $new_value ) { |
|
| 2034 | - if ( array_key_exists( $key, $array ) ) { |
|
| 2033 | +function give_array_insert_after($key, array &$array, $new_key, $new_value) { |
|
| 2034 | + if (array_key_exists($key, $array)) { |
|
| 2035 | 2035 | $new = array(); |
| 2036 | - foreach ( $array as $k => $value ) { |
|
| 2037 | - $new[ $k ] = $value; |
|
| 2038 | - if ( $k === $key ) { |
|
| 2039 | - $new[ $new_key ] = $new_value; |
|
| 2036 | + foreach ($array as $k => $value) { |
|
| 2037 | + $new[$k] = $value; |
|
| 2038 | + if ($k === $key) { |
|
| 2039 | + $new[$new_key] = $new_value; |
|
| 2040 | 2040 | } |
| 2041 | 2041 | } |
| 2042 | 2042 | |
@@ -2063,21 +2063,21 @@ discard block |
||
| 2063 | 2063 | * corresponding to `$index_key`. If `$index_key` is null, array keys from the original |
| 2064 | 2064 | * `$list` will be preserved in the results. |
| 2065 | 2065 | */ |
| 2066 | -function give_list_pluck( $list, $field, $index_key = null ) { |
|
| 2066 | +function give_list_pluck($list, $field, $index_key = null) { |
|
| 2067 | 2067 | |
| 2068 | - if ( ! $index_key ) { |
|
| 2068 | + if ( ! $index_key) { |
|
| 2069 | 2069 | /* |
| 2070 | 2070 | * This is simple. Could at some point wrap array_column() |
| 2071 | 2071 | * if we knew we had an array of arrays. |
| 2072 | 2072 | */ |
| 2073 | - foreach ( $list as $key => $value ) { |
|
| 2074 | - if ( is_object( $value ) ) { |
|
| 2075 | - if ( isset( $value->$field ) ) { |
|
| 2076 | - $list[ $key ] = $value->$field; |
|
| 2073 | + foreach ($list as $key => $value) { |
|
| 2074 | + if (is_object($value)) { |
|
| 2075 | + if (isset($value->$field)) { |
|
| 2076 | + $list[$key] = $value->$field; |
|
| 2077 | 2077 | } |
| 2078 | 2078 | } else { |
| 2079 | - if ( isset( $value[ $field ] ) ) { |
|
| 2080 | - $list[ $key ] = $value[ $field ]; |
|
| 2079 | + if (isset($value[$field])) { |
|
| 2080 | + $list[$key] = $value[$field]; |
|
| 2081 | 2081 | } |
| 2082 | 2082 | } |
| 2083 | 2083 | } |
@@ -2090,18 +2090,18 @@ discard block |
||
| 2090 | 2090 | * to the end of the stack. This is how array_column() behaves. |
| 2091 | 2091 | */ |
| 2092 | 2092 | $newlist = array(); |
| 2093 | - foreach ( $list as $value ) { |
|
| 2094 | - if ( is_object( $value ) ) { |
|
| 2095 | - if ( isset( $value->$index_key ) ) { |
|
| 2096 | - $newlist[ $value->$index_key ] = $value->$field; |
|
| 2093 | + foreach ($list as $value) { |
|
| 2094 | + if (is_object($value)) { |
|
| 2095 | + if (isset($value->$index_key)) { |
|
| 2096 | + $newlist[$value->$index_key] = $value->$field; |
|
| 2097 | 2097 | } else { |
| 2098 | 2098 | $newlist[] = $value->$field; |
| 2099 | 2099 | } |
| 2100 | 2100 | } else { |
| 2101 | - if ( isset( $value[ $index_key ] ) ) { |
|
| 2102 | - $newlist[ $value[ $index_key ] ] = $value[ $field ]; |
|
| 2101 | + if (isset($value[$index_key])) { |
|
| 2102 | + $newlist[$value[$index_key]] = $value[$field]; |
|
| 2103 | 2103 | } else { |
| 2104 | - $newlist[] = $value[ $field ]; |
|
| 2104 | + $newlist[] = $value[$field]; |
|
| 2105 | 2105 | } |
| 2106 | 2106 | } |
| 2107 | 2107 | } |
@@ -2117,7 +2117,7 @@ discard block |
||
| 2117 | 2117 | * @since 1.8.13 |
| 2118 | 2118 | */ |
| 2119 | 2119 | function give_import_donation_report() { |
| 2120 | - return get_option( 'give_import_donation_report', array() ); |
|
| 2120 | + return get_option('give_import_donation_report', array()); |
|
| 2121 | 2121 | } |
| 2122 | 2122 | |
| 2123 | 2123 | |
@@ -2126,8 +2126,8 @@ discard block |
||
| 2126 | 2126 | * |
| 2127 | 2127 | * @since 1.8.13 |
| 2128 | 2128 | */ |
| 2129 | -function give_import_donation_report_update( $value = array() ) { |
|
| 2130 | - update_option( 'give_import_donation_report', $value ); |
|
| 2129 | +function give_import_donation_report_update($value = array()) { |
|
| 2130 | + update_option('give_import_donation_report', $value); |
|
| 2131 | 2131 | } |
| 2132 | 2132 | |
| 2133 | 2133 | |
@@ -2137,7 +2137,7 @@ discard block |
||
| 2137 | 2137 | * @since 1.8.13 |
| 2138 | 2138 | */ |
| 2139 | 2139 | function give_import_donation_report_reset() { |
| 2140 | - update_option( 'give_import_donation_report', array() ); |
|
| 2140 | + update_option('give_import_donation_report', array()); |
|
| 2141 | 2141 | } |
| 2142 | 2142 | |
| 2143 | 2143 | |
@@ -2154,8 +2154,8 @@ discard block |
||
| 2154 | 2154 | * |
| 2155 | 2155 | * @return int|false Meta ID on success, false on failure. |
| 2156 | 2156 | */ |
| 2157 | -function add_donor_meta( $donor_id, $meta_key, $meta_value, $unique = false ) { |
|
| 2158 | - return add_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $unique ); |
|
| 2157 | +function add_donor_meta($donor_id, $meta_key, $meta_value, $unique = false) { |
|
| 2158 | + return add_metadata('give_customer', $donor_id, $meta_key, $meta_value, $unique); |
|
| 2159 | 2159 | } |
| 2160 | 2160 | |
| 2161 | 2161 | /** |
@@ -2173,8 +2173,8 @@ discard block |
||
| 2173 | 2173 | * |
| 2174 | 2174 | * @return bool True on success, false on failure. |
| 2175 | 2175 | */ |
| 2176 | -function delete_donor_meta( $donor_id, $meta_key, $meta_value = '' ) { |
|
| 2177 | - return delete_metadata( 'give_customer', $donor_id, $meta_key, $meta_value ); |
|
| 2176 | +function delete_donor_meta($donor_id, $meta_key, $meta_value = '') { |
|
| 2177 | + return delete_metadata('give_customer', $donor_id, $meta_key, $meta_value); |
|
| 2178 | 2178 | } |
| 2179 | 2179 | |
| 2180 | 2180 | /** |
@@ -2189,8 +2189,8 @@ discard block |
||
| 2189 | 2189 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single |
| 2190 | 2190 | * is true. |
| 2191 | 2191 | */ |
| 2192 | -function get_donor_meta( $donor_id, $key = '', $single = false ) { |
|
| 2193 | - return get_metadata( 'give_customer', $donor_id, $key, $single ); |
|
| 2192 | +function get_donor_meta($donor_id, $key = '', $single = false) { |
|
| 2193 | + return get_metadata('give_customer', $donor_id, $key, $single); |
|
| 2194 | 2194 | } |
| 2195 | 2195 | |
| 2196 | 2196 | /** |
@@ -2207,8 +2207,8 @@ discard block |
||
| 2207 | 2207 | * |
| 2208 | 2208 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure. |
| 2209 | 2209 | */ |
| 2210 | -function update_donor_meta( $donor_id, $meta_key, $meta_value, $prev_value = '' ) { |
|
| 2211 | - return update_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $prev_value ); |
|
| 2210 | +function update_donor_meta($donor_id, $meta_key, $meta_value, $prev_value = '') { |
|
| 2211 | + return update_metadata('give_customer', $donor_id, $meta_key, $meta_value, $prev_value); |
|
| 2212 | 2212 | } |
| 2213 | 2213 | |
| 2214 | 2214 | /* |
@@ -2218,54 +2218,54 @@ discard block |
||
| 2218 | 2218 | * |
| 2219 | 2219 | * @param int $form_id Form id of which recalculation needs to be done. |
| 2220 | 2220 | */ |
| 2221 | -function give_recount_form_income_donation( $form_id = false ) { |
|
| 2221 | +function give_recount_form_income_donation($form_id = false) { |
|
| 2222 | 2222 | // Check if form id is not empty. |
| 2223 | - if ( ! empty( $form_id ) ) { |
|
| 2223 | + if ( ! empty($form_id)) { |
|
| 2224 | 2224 | /** |
| 2225 | 2225 | * Filter to modify payment status. |
| 2226 | 2226 | * |
| 2227 | 2227 | * @since 1.8.13 |
| 2228 | 2228 | */ |
| 2229 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 2229 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 2230 | 2230 | |
| 2231 | 2231 | /** |
| 2232 | 2232 | * Filter to modify args of payment query before recalculating the form total |
| 2233 | 2233 | * |
| 2234 | 2234 | * @since 1.8.13 |
| 2235 | 2235 | */ |
| 2236 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
| 2236 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
| 2237 | 2237 | 'give_forms' => $form_id, |
| 2238 | 2238 | 'status' => $accepted_statuses, |
| 2239 | - 'posts_per_page' => - 1, |
|
| 2239 | + 'posts_per_page' => -1, |
|
| 2240 | 2240 | 'fields' => 'ids', |
| 2241 | - ) ); |
|
| 2241 | + )); |
|
| 2242 | 2242 | |
| 2243 | 2243 | $totals = array( |
| 2244 | 2244 | 'sales' => 0, |
| 2245 | 2245 | 'earnings' => 0, |
| 2246 | 2246 | ); |
| 2247 | 2247 | |
| 2248 | - $payments = new Give_Payments_Query( $args ); |
|
| 2248 | + $payments = new Give_Payments_Query($args); |
|
| 2249 | 2249 | $payments = $payments->get_payments(); |
| 2250 | 2250 | |
| 2251 | - if ( $payments ) { |
|
| 2252 | - foreach ( $payments as $payment ) { |
|
| 2251 | + if ($payments) { |
|
| 2252 | + foreach ($payments as $payment) { |
|
| 2253 | 2253 | //Ensure acceptible status only |
| 2254 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
| 2254 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
| 2255 | 2255 | continue; |
| 2256 | 2256 | } |
| 2257 | 2257 | |
| 2258 | 2258 | //Ensure only payments for this form are counted |
| 2259 | - if ( $payment->form_id != $form_id ) { |
|
| 2259 | + if ($payment->form_id != $form_id) { |
|
| 2260 | 2260 | continue; |
| 2261 | 2261 | } |
| 2262 | 2262 | |
| 2263 | - $totals['sales'] ++; |
|
| 2263 | + $totals['sales']++; |
|
| 2264 | 2264 | $totals['earnings'] += $payment->total; |
| 2265 | 2265 | |
| 2266 | 2266 | } |
| 2267 | 2267 | } |
| 2268 | - give_update_meta( $form_id, '_give_form_sales', $totals['sales'] ); |
|
| 2269 | - give_update_meta( $form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) ); |
|
| 2268 | + give_update_meta($form_id, '_give_form_sales', $totals['sales']); |
|
| 2269 | + give_update_meta($form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings'])); |
|
| 2270 | 2270 | } |
| 2271 | 2271 | } |
| 2272 | 2272 | \ No newline at end of file |
@@ -697,7 +697,7 @@ discard block |
||
| 697 | 697 | * @param int $year Year number. Default is null. |
| 698 | 698 | * @param int $hour Hour number. Default is null. |
| 699 | 699 | * |
| 700 | - * @return int $earnings Earnings |
|
| 700 | + * @return double $earnings Earnings |
|
| 701 | 701 | */ |
| 702 | 702 | function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
| 703 | 703 | |
@@ -986,7 +986,7 @@ discard block |
||
| 986 | 986 | * |
| 987 | 987 | * @param int $payment_id Payment ID. |
| 988 | 988 | * |
| 989 | - * @return array $user_info User Info Meta Values. |
|
| 989 | + * @return string $user_info User Info Meta Values. |
|
| 990 | 990 | */ |
| 991 | 991 | function give_get_payment_meta_user_info( $payment_id ) { |
| 992 | 992 | $payment = new Give_Payment( $payment_id ); |
@@ -1003,7 +1003,7 @@ discard block |
||
| 1003 | 1003 | * |
| 1004 | 1004 | * @param int $payment_id Payment ID. |
| 1005 | 1005 | * |
| 1006 | - * @return int $form_id Form ID. |
|
| 1006 | + * @return string $form_id Form ID. |
|
| 1007 | 1007 | */ |
| 1008 | 1008 | function give_get_payment_form_id( $payment_id ) { |
| 1009 | 1009 | $payment = new Give_Payment( $payment_id ); |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -43,15 +43,15 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @return array $payments Payments retrieved from the database |
| 45 | 45 | */ |
| 46 | -function give_get_payments( $args = array() ) { |
|
| 46 | +function give_get_payments($args = array()) { |
|
| 47 | 47 | |
| 48 | 48 | // Fallback to post objects to ensure backwards compatibility. |
| 49 | - if ( ! isset( $args['output'] ) ) { |
|
| 49 | + if ( ! isset($args['output'])) { |
|
| 50 | 50 | $args['output'] = 'posts'; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - $args = apply_filters( 'give_get_payments_args', $args ); |
|
| 54 | - $payments = new Give_Payments_Query( $args ); |
|
| 53 | + $args = apply_filters('give_get_payments_args', $args); |
|
| 54 | + $payments = new Give_Payments_Query($args); |
|
| 55 | 55 | |
| 56 | 56 | return $payments->get_payments(); |
| 57 | 57 | } |
@@ -66,48 +66,48 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @return mixed |
| 68 | 68 | */ |
| 69 | -function give_get_payment_by( $field = '', $value = '' ) { |
|
| 69 | +function give_get_payment_by($field = '', $value = '') { |
|
| 70 | 70 | |
| 71 | - if ( empty( $field ) || empty( $value ) ) { |
|
| 71 | + if (empty($field) || empty($value)) { |
|
| 72 | 72 | return false; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - switch ( strtolower( $field ) ) { |
|
| 75 | + switch (strtolower($field)) { |
|
| 76 | 76 | |
| 77 | 77 | case 'id': |
| 78 | - $payment = new Give_Payment( $value ); |
|
| 78 | + $payment = new Give_Payment($value); |
|
| 79 | 79 | $id = $payment->ID; |
| 80 | 80 | |
| 81 | - if ( empty( $id ) ) { |
|
| 81 | + if (empty($id)) { |
|
| 82 | 82 | return false; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | break; |
| 86 | 86 | |
| 87 | 87 | case 'key': |
| 88 | - $payment = give_get_payments( array( |
|
| 88 | + $payment = give_get_payments(array( |
|
| 89 | 89 | 'meta_key' => '_give_payment_purchase_key', |
| 90 | 90 | 'meta_value' => $value, |
| 91 | 91 | 'posts_per_page' => 1, |
| 92 | 92 | 'fields' => 'ids', |
| 93 | - ) ); |
|
| 93 | + )); |
|
| 94 | 94 | |
| 95 | - if ( $payment ) { |
|
| 96 | - $payment = new Give_Payment( $payment[0] ); |
|
| 95 | + if ($payment) { |
|
| 96 | + $payment = new Give_Payment($payment[0]); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | break; |
| 100 | 100 | |
| 101 | 101 | case 'payment_number': |
| 102 | - $payment = give_get_payments( array( |
|
| 102 | + $payment = give_get_payments(array( |
|
| 103 | 103 | 'meta_key' => '_give_payment_number', |
| 104 | 104 | 'meta_value' => $value, |
| 105 | 105 | 'posts_per_page' => 1, |
| 106 | 106 | 'fields' => 'ids', |
| 107 | - ) ); |
|
| 107 | + )); |
|
| 108 | 108 | |
| 109 | - if ( $payment ) { |
|
| 110 | - $payment = new Give_Payment( $payment[0] ); |
|
| 109 | + if ($payment) { |
|
| 110 | + $payment = new Give_Payment($payment[0]); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | break; |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | return false; |
| 117 | 117 | }// End switch(). |
| 118 | 118 | |
| 119 | - if ( $payment ) { |
|
| 119 | + if ($payment) { |
|
| 120 | 120 | return $payment; |
| 121 | 121 | } |
| 122 | 122 | |
@@ -132,29 +132,29 @@ discard block |
||
| 132 | 132 | * |
| 133 | 133 | * @return int|bool Payment ID if payment is inserted, false otherwise. |
| 134 | 134 | */ |
| 135 | -function give_insert_payment( $payment_data = array() ) { |
|
| 135 | +function give_insert_payment($payment_data = array()) { |
|
| 136 | 136 | |
| 137 | - if ( empty( $payment_data ) ) { |
|
| 137 | + if (empty($payment_data)) { |
|
| 138 | 138 | return false; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $payment = new Give_Payment(); |
| 142 | - $gateway = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : ''; |
|
| 143 | - $gateway = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway; |
|
| 144 | - $form_id = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0; |
|
| 145 | - $price_id = give_get_payment_meta_price_id( $payment_data ); |
|
| 146 | - $form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id ); |
|
| 142 | + $gateway = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : ''; |
|
| 143 | + $gateway = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway; |
|
| 144 | + $form_id = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0; |
|
| 145 | + $price_id = give_get_payment_meta_price_id($payment_data); |
|
| 146 | + $form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id); |
|
| 147 | 147 | |
| 148 | 148 | // Set properties. |
| 149 | 149 | $payment->total = $payment_data['price']; |
| 150 | - $payment->status = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending'; |
|
| 151 | - $payment->currency = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency(); |
|
| 150 | + $payment->status = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending'; |
|
| 151 | + $payment->currency = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency(); |
|
| 152 | 152 | $payment->user_info = $payment_data['user_info']; |
| 153 | 153 | $payment->gateway = $gateway; |
| 154 | 154 | $payment->form_title = $form_title; |
| 155 | 155 | $payment->form_id = $form_id; |
| 156 | 156 | $payment->price_id = $price_id; |
| 157 | - $payment->donor_id = ( ! empty( $payment_data['donor_id'] ) ? $payment_data['donor_id'] : '' ); |
|
| 157 | + $payment->donor_id = ( ! empty($payment_data['donor_id']) ? $payment_data['donor_id'] : ''); |
|
| 158 | 158 | $payment->user_id = $payment_data['user_info']['id']; |
| 159 | 159 | $payment->email = $payment_data['user_email']; |
| 160 | 160 | $payment->first_name = $payment_data['user_info']['first_name']; |
@@ -162,8 +162,8 @@ discard block |
||
| 162 | 162 | $payment->email = $payment_data['user_info']['email']; |
| 163 | 163 | $payment->ip = give_get_ip(); |
| 164 | 164 | $payment->key = $payment_data['purchase_key']; |
| 165 | - $payment->mode = ( ! empty( $payment_data['mode'] ) ? (string) $payment_data['mode'] : ( give_is_test_mode() ? 'test' : 'live' ) ); |
|
| 166 | - $payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : ''; |
|
| 165 | + $payment->mode = ( ! empty($payment_data['mode']) ? (string) $payment_data['mode'] : (give_is_test_mode() ? 'test' : 'live')); |
|
| 166 | + $payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : ''; |
|
| 167 | 167 | |
| 168 | 168 | // Add the donation. |
| 169 | 169 | $args = array( |
@@ -171,19 +171,19 @@ discard block |
||
| 171 | 171 | 'price_id' => $payment->price_id, |
| 172 | 172 | ); |
| 173 | 173 | |
| 174 | - $payment->add_donation( $payment->form_id, $args ); |
|
| 174 | + $payment->add_donation($payment->form_id, $args); |
|
| 175 | 175 | |
| 176 | 176 | |
| 177 | 177 | // Set date if present. |
| 178 | - if ( isset( $payment_data['post_date'] ) ) { |
|
| 178 | + if (isset($payment_data['post_date'])) { |
|
| 179 | 179 | $payment->date = $payment_data['post_date']; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | // Handle sequential payments. |
| 183 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 183 | + if (give_get_option('enable_sequential')) { |
|
| 184 | 184 | $number = give_get_next_payment_number(); |
| 185 | - $payment->number = give_format_payment_number( $number ); |
|
| 186 | - update_option( 'give_last_payment_number', $number ); |
|
| 185 | + $payment->number = give_format_payment_number($number); |
|
| 186 | + update_option('give_last_payment_number', $number); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | // Save payment. |
@@ -197,10 +197,10 @@ discard block |
||
| 197 | 197 | * @param int $payment_id The payment ID. |
| 198 | 198 | * @param array $payment_data Arguments passed. |
| 199 | 199 | */ |
| 200 | - do_action( 'give_insert_payment', $payment->ID, $payment_data ); |
|
| 200 | + do_action('give_insert_payment', $payment->ID, $payment_data); |
|
| 201 | 201 | |
| 202 | 202 | // Return payment ID upon success. |
| 203 | - if ( ! empty( $payment->ID ) ) { |
|
| 203 | + if ( ! empty($payment->ID)) { |
|
| 204 | 204 | return $payment->ID; |
| 205 | 205 | } |
| 206 | 206 | |
@@ -216,10 +216,10 @@ discard block |
||
| 216 | 216 | * |
| 217 | 217 | * @return bool|int |
| 218 | 218 | */ |
| 219 | -function give_create_payment( $payment_data ) { |
|
| 219 | +function give_create_payment($payment_data) { |
|
| 220 | 220 | |
| 221 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
| 222 | - $price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : ''; |
|
| 221 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
| 222 | + $price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : ''; |
|
| 223 | 223 | |
| 224 | 224 | // Collect payment data. |
| 225 | 225 | $insert_payment_data = array( |
@@ -243,10 +243,10 @@ discard block |
||
| 243 | 243 | * |
| 244 | 244 | * @param array $insert_payment_data |
| 245 | 245 | */ |
| 246 | - $insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data ); |
|
| 246 | + $insert_payment_data = apply_filters('give_create_payment', $insert_payment_data); |
|
| 247 | 247 | |
| 248 | 248 | // Record the pending payment. |
| 249 | - return give_insert_payment( $insert_payment_data ); |
|
| 249 | + return give_insert_payment($insert_payment_data); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -259,12 +259,12 @@ discard block |
||
| 259 | 259 | * |
| 260 | 260 | * @return bool |
| 261 | 261 | */ |
| 262 | -function give_update_payment_status( $payment_id, $new_status = 'publish' ) { |
|
| 262 | +function give_update_payment_status($payment_id, $new_status = 'publish') { |
|
| 263 | 263 | |
| 264 | 264 | $updated = false; |
| 265 | - $payment = new Give_Payment( $payment_id ); |
|
| 265 | + $payment = new Give_Payment($payment_id); |
|
| 266 | 266 | |
| 267 | - if ( $payment && $payment->ID > 0 ) { |
|
| 267 | + if ($payment && $payment->ID > 0) { |
|
| 268 | 268 | |
| 269 | 269 | $payment->status = $new_status; |
| 270 | 270 | $updated = $payment->save(); |
@@ -286,38 +286,38 @@ discard block |
||
| 286 | 286 | * |
| 287 | 287 | * @return void |
| 288 | 288 | */ |
| 289 | -function give_delete_donation( $payment_id = 0, $update_donor = true ) { |
|
| 289 | +function give_delete_donation($payment_id = 0, $update_donor = true) { |
|
| 290 | 290 | global $give_logs; |
| 291 | 291 | |
| 292 | - $payment = new Give_Payment( $payment_id ); |
|
| 293 | - $amount = give_get_payment_amount( $payment_id ); |
|
| 292 | + $payment = new Give_Payment($payment_id); |
|
| 293 | + $amount = give_get_payment_amount($payment_id); |
|
| 294 | 294 | $status = $payment->post_status; |
| 295 | - $donor_id = give_get_payment_donor_id( $payment_id ); |
|
| 296 | - $donor = new Give_Donor( $donor_id ); |
|
| 295 | + $donor_id = give_get_payment_donor_id($payment_id); |
|
| 296 | + $donor = new Give_Donor($donor_id); |
|
| 297 | 297 | |
| 298 | 298 | // Only undo donations that aren't these statuses. |
| 299 | - $dont_undo_statuses = apply_filters( 'give_undo_donation_statuses', array( |
|
| 299 | + $dont_undo_statuses = apply_filters('give_undo_donation_statuses', array( |
|
| 300 | 300 | 'pending', |
| 301 | 301 | 'cancelled', |
| 302 | - ) ); |
|
| 302 | + )); |
|
| 303 | 303 | |
| 304 | - if ( ! in_array( $status, $dont_undo_statuses ) ) { |
|
| 305 | - give_undo_donation( $payment_id ); |
|
| 304 | + if ( ! in_array($status, $dont_undo_statuses)) { |
|
| 305 | + give_undo_donation($payment_id); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - if ( $status == 'publish' ) { |
|
| 308 | + if ($status == 'publish') { |
|
| 309 | 309 | |
| 310 | 310 | // Only decrease earnings if they haven't already been decreased (or were never increased for this payment). |
| 311 | - give_decrease_total_earnings( $amount ); |
|
| 311 | + give_decrease_total_earnings($amount); |
|
| 312 | 312 | |
| 313 | 313 | // @todo: Refresh only range related stat cache |
| 314 | 314 | give_delete_donation_stats(); |
| 315 | 315 | |
| 316 | - if ( $donor->id && $update_donor ) { |
|
| 316 | + if ($donor->id && $update_donor) { |
|
| 317 | 317 | |
| 318 | 318 | // Decrement the stats for the donor. |
| 319 | 319 | $donor->decrease_donation_count(); |
| 320 | - $donor->decrease_value( $amount ); |
|
| 320 | + $donor->decrease_value($amount); |
|
| 321 | 321 | |
| 322 | 322 | } |
| 323 | 323 | } |
@@ -329,25 +329,25 @@ discard block |
||
| 329 | 329 | * |
| 330 | 330 | * @param int $payment_id Payment ID. |
| 331 | 331 | */ |
| 332 | - do_action( 'give_payment_delete', $payment_id ); |
|
| 332 | + do_action('give_payment_delete', $payment_id); |
|
| 333 | 333 | |
| 334 | - if ( $donor->id && $update_donor ) { |
|
| 334 | + if ($donor->id && $update_donor) { |
|
| 335 | 335 | |
| 336 | 336 | // Remove the payment ID from the donor. |
| 337 | - $donor->remove_payment( $payment_id ); |
|
| 337 | + $donor->remove_payment($payment_id); |
|
| 338 | 338 | |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | // Remove the payment. |
| 342 | - wp_delete_post( $payment_id, true ); |
|
| 342 | + wp_delete_post($payment_id, true); |
|
| 343 | 343 | |
| 344 | 344 | // Remove related sale log entries. |
| 345 | - $give_logs->delete_logs( null, 'sale', array( |
|
| 345 | + $give_logs->delete_logs(null, 'sale', array( |
|
| 346 | 346 | array( |
| 347 | 347 | 'key' => '_give_log_payment_id', |
| 348 | 348 | 'value' => $payment_id, |
| 349 | 349 | ), |
| 350 | - ) ); |
|
| 350 | + )); |
|
| 351 | 351 | |
| 352 | 352 | /** |
| 353 | 353 | * Fires after payment deleted. |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | * |
| 357 | 357 | * @param int $payment_id Payment ID. |
| 358 | 358 | */ |
| 359 | - do_action( 'give_payment_deleted', $payment_id ); |
|
| 359 | + do_action('give_payment_deleted', $payment_id); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | /** |
@@ -371,20 +371,20 @@ discard block |
||
| 371 | 371 | * |
| 372 | 372 | * @return void |
| 373 | 373 | */ |
| 374 | -function give_undo_donation( $payment_id ) { |
|
| 374 | +function give_undo_donation($payment_id) { |
|
| 375 | 375 | |
| 376 | - $payment = new Give_Payment( $payment_id ); |
|
| 376 | + $payment = new Give_Payment($payment_id); |
|
| 377 | 377 | |
| 378 | - $maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id ); |
|
| 379 | - if ( true === $maybe_decrease_earnings ) { |
|
| 378 | + $maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id); |
|
| 379 | + if (true === $maybe_decrease_earnings) { |
|
| 380 | 380 | // Decrease earnings. |
| 381 | - give_decrease_earnings( $payment->form_id, $payment->total ); |
|
| 381 | + give_decrease_earnings($payment->form_id, $payment->total); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | - $maybe_decrease_donations = apply_filters( 'give_decrease_donations_on_undo', true, $payment, $payment->form_id ); |
|
| 385 | - if ( true === $maybe_decrease_donations ) { |
|
| 384 | + $maybe_decrease_donations = apply_filters('give_decrease_donations_on_undo', true, $payment, $payment->form_id); |
|
| 385 | + if (true === $maybe_decrease_donations) { |
|
| 386 | 386 | // Decrease donation count. |
| 387 | - give_decrease_donation_count( $payment->form_id ); |
|
| 387 | + give_decrease_donation_count($payment->form_id); |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | } |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | * |
| 402 | 402 | * @return object $stats Contains the number of payments per payment status. |
| 403 | 403 | */ |
| 404 | -function give_count_payments( $args = array() ) { |
|
| 404 | +function give_count_payments($args = array()) { |
|
| 405 | 405 | |
| 406 | 406 | global $wpdb; |
| 407 | 407 | |
@@ -413,18 +413,18 @@ discard block |
||
| 413 | 413 | 'form_id' => null, |
| 414 | 414 | ); |
| 415 | 415 | |
| 416 | - $args = wp_parse_args( $args, $defaults ); |
|
| 416 | + $args = wp_parse_args($args, $defaults); |
|
| 417 | 417 | |
| 418 | 418 | $select = 'SELECT p.post_status,count( * ) AS num_posts'; |
| 419 | 419 | $join = ''; |
| 420 | - $where = "WHERE p.post_type = 'give_payment' AND p.post_status IN ('" . implode( "','", give_get_payment_status_keys() ) . "')"; |
|
| 420 | + $where = "WHERE p.post_type = 'give_payment' AND p.post_status IN ('".implode("','", give_get_payment_status_keys())."')"; |
|
| 421 | 421 | |
| 422 | 422 | // Count payments for a specific user. |
| 423 | - if ( ! empty( $args['user'] ) ) { |
|
| 423 | + if ( ! empty($args['user'])) { |
|
| 424 | 424 | |
| 425 | - if ( is_email( $args['user'] ) ) { |
|
| 425 | + if (is_email($args['user'])) { |
|
| 426 | 426 | $field = 'email'; |
| 427 | - } elseif ( is_numeric( $args['user'] ) ) { |
|
| 427 | + } elseif (is_numeric($args['user'])) { |
|
| 428 | 428 | $field = 'id'; |
| 429 | 429 | } else { |
| 430 | 430 | $field = ''; |
@@ -432,107 +432,107 @@ discard block |
||
| 432 | 432 | |
| 433 | 433 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
| 434 | 434 | |
| 435 | - if ( ! empty( $field ) ) { |
|
| 435 | + if ( ! empty($field)) { |
|
| 436 | 436 | $where .= " |
| 437 | 437 | AND m.meta_key = '_give_payment_user_{$field}' |
| 438 | 438 | AND m.meta_value = '{$args['user']}'"; |
| 439 | 439 | } |
| 440 | - } elseif ( ! empty( $args['donor'] ) ) { |
|
| 440 | + } elseif ( ! empty($args['donor'])) { |
|
| 441 | 441 | |
| 442 | - $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
| 442 | + $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
| 443 | 443 | $where .= " |
| 444 | 444 | AND m.meta_key = '_give_payment_customer_id' |
| 445 | 445 | AND m.meta_value = '{$args['donor']}'"; |
| 446 | 446 | |
| 447 | 447 | // Count payments for a search. |
| 448 | - } elseif ( ! empty( $args['s'] ) ) { |
|
| 448 | + } elseif ( ! empty($args['s'])) { |
|
| 449 | 449 | |
| 450 | - if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) { |
|
| 450 | + if (is_email($args['s']) || strlen($args['s']) == 32) { |
|
| 451 | 451 | |
| 452 | - if ( is_email( $args['s'] ) ) { |
|
| 452 | + if (is_email($args['s'])) { |
|
| 453 | 453 | $field = '_give_payment_user_email'; |
| 454 | 454 | } else { |
| 455 | 455 | $field = '_give_payment_purchase_key'; |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | - $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
| 459 | - $where .= $wpdb->prepare( ' |
|
| 458 | + $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
| 459 | + $where .= $wpdb->prepare(' |
|
| 460 | 460 | AND m.meta_key = %s |
| 461 | - AND m.meta_value = %s', $field, $args['s'] ); |
|
| 461 | + AND m.meta_value = %s', $field, $args['s']); |
|
| 462 | 462 | |
| 463 | - } elseif ( '#' == substr( $args['s'], 0, 1 ) ) { |
|
| 463 | + } elseif ('#' == substr($args['s'], 0, 1)) { |
|
| 464 | 464 | |
| 465 | - $search = str_replace( '#:', '', $args['s'] ); |
|
| 466 | - $search = str_replace( '#', '', $search ); |
|
| 465 | + $search = str_replace('#:', '', $args['s']); |
|
| 466 | + $search = str_replace('#', '', $search); |
|
| 467 | 467 | |
| 468 | 468 | $select = 'SELECT p.post_status,count( * ) AS num_posts '; |
| 469 | 469 | $join = ''; |
| 470 | - $where = $wpdb->prepare( 'WHERE p.post_type=%s AND p.ID = %d ', 'give_payment', $search ); |
|
| 470 | + $where = $wpdb->prepare('WHERE p.post_type=%s AND p.ID = %d ', 'give_payment', $search); |
|
| 471 | 471 | |
| 472 | - } elseif ( is_numeric( $args['s'] ) ) { |
|
| 472 | + } elseif (is_numeric($args['s'])) { |
|
| 473 | 473 | |
| 474 | - $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
| 475 | - $where .= $wpdb->prepare( " |
|
| 474 | + $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
| 475 | + $where .= $wpdb->prepare(" |
|
| 476 | 476 | AND m.meta_key = '_give_payment_user_id' |
| 477 | - AND m.meta_value = %d", $args['s'] ); |
|
| 477 | + AND m.meta_value = %d", $args['s']); |
|
| 478 | 478 | |
| 479 | 479 | } else { |
| 480 | - $search = $wpdb->esc_like( $args['s'] ); |
|
| 481 | - $search = '%' . $search . '%'; |
|
| 480 | + $search = $wpdb->esc_like($args['s']); |
|
| 481 | + $search = '%'.$search.'%'; |
|
| 482 | 482 | |
| 483 | - $where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search ); |
|
| 483 | + $where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search); |
|
| 484 | 484 | }// End if(). |
| 485 | 485 | }// End if(). |
| 486 | 486 | |
| 487 | - if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) { |
|
| 487 | + if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) { |
|
| 488 | 488 | |
| 489 | - $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
| 490 | - $where .= $wpdb->prepare( ' |
|
| 489 | + $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
| 490 | + $where .= $wpdb->prepare(' |
|
| 491 | 491 | AND m.meta_key = %s |
| 492 | - AND m.meta_value = %s', '_give_payment_form_id', $args['form_id'] ); |
|
| 492 | + AND m.meta_value = %s', '_give_payment_form_id', $args['form_id']); |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | // Limit payments count by date. |
| 496 | - if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) { |
|
| 496 | + if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) { |
|
| 497 | 497 | |
| 498 | - $date_parts = explode( '/', $args['start-date'] ); |
|
| 499 | - $month = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0; |
|
| 500 | - $day = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0; |
|
| 501 | - $year = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0; |
|
| 498 | + $date_parts = explode('/', $args['start-date']); |
|
| 499 | + $month = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0; |
|
| 500 | + $day = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0; |
|
| 501 | + $year = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0; |
|
| 502 | 502 | |
| 503 | - $is_date = checkdate( $month, $day, $year ); |
|
| 504 | - if ( false !== $is_date ) { |
|
| 503 | + $is_date = checkdate($month, $day, $year); |
|
| 504 | + if (false !== $is_date) { |
|
| 505 | 505 | |
| 506 | - $date = new DateTime( $args['start-date'] ); |
|
| 507 | - $where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) ); |
|
| 506 | + $date = new DateTime($args['start-date']); |
|
| 507 | + $where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d')); |
|
| 508 | 508 | |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | 511 | // Fixes an issue with the payments list table counts when no end date is specified (with stats class). |
| 512 | - if ( empty( $args['end-date'] ) ) { |
|
| 512 | + if (empty($args['end-date'])) { |
|
| 513 | 513 | $args['end-date'] = $args['start-date']; |
| 514 | 514 | } |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | - if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) { |
|
| 517 | + if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) { |
|
| 518 | 518 | |
| 519 | - $date_parts = explode( '/', $args['end-date'] ); |
|
| 519 | + $date_parts = explode('/', $args['end-date']); |
|
| 520 | 520 | |
| 521 | - $month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0; |
|
| 522 | - $day = ! empty( $date_parts[1] ) ? $date_parts[1] : 0; |
|
| 523 | - $year = ! empty( $date_parts[2] ) ? $date_parts[2] : 0; |
|
| 521 | + $month = ! empty($date_parts[0]) ? $date_parts[0] : 0; |
|
| 522 | + $day = ! empty($date_parts[1]) ? $date_parts[1] : 0; |
|
| 523 | + $year = ! empty($date_parts[2]) ? $date_parts[2] : 0; |
|
| 524 | 524 | |
| 525 | - $is_date = checkdate( $month, $day, $year ); |
|
| 526 | - if ( false !== $is_date ) { |
|
| 525 | + $is_date = checkdate($month, $day, $year); |
|
| 526 | + if (false !== $is_date) { |
|
| 527 | 527 | |
| 528 | - $date = new DateTime( $args['end-date'] ); |
|
| 529 | - $where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) ); |
|
| 528 | + $date = new DateTime($args['end-date']); |
|
| 529 | + $where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d')); |
|
| 530 | 530 | |
| 531 | 531 | } |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | - $where = apply_filters( 'give_count_payments_where', $where ); |
|
| 535 | - $join = apply_filters( 'give_count_payments_join', $join ); |
|
| 534 | + $where = apply_filters('give_count_payments_where', $where); |
|
| 535 | + $join = apply_filters('give_count_payments_join', $join); |
|
| 536 | 536 | |
| 537 | 537 | $query = "$select |
| 538 | 538 | FROM $wpdb->posts p |
@@ -541,36 +541,36 @@ discard block |
||
| 541 | 541 | GROUP BY p.post_status |
| 542 | 542 | "; |
| 543 | 543 | |
| 544 | - $cache_key = md5( $query ); |
|
| 544 | + $cache_key = md5($query); |
|
| 545 | 545 | |
| 546 | - $count = wp_cache_get( $cache_key, 'counts' ); |
|
| 547 | - if ( false !== $count ) { |
|
| 546 | + $count = wp_cache_get($cache_key, 'counts'); |
|
| 547 | + if (false !== $count) { |
|
| 548 | 548 | return $count; |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - $count = $wpdb->get_results( $query, ARRAY_A ); |
|
| 551 | + $count = $wpdb->get_results($query, ARRAY_A); |
|
| 552 | 552 | |
| 553 | 553 | $stats = array(); |
| 554 | 554 | $statuses = get_post_stati(); |
| 555 | - if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) { |
|
| 556 | - unset( $statuses['private'] ); |
|
| 555 | + if (isset($statuses['private']) && empty($args['s'])) { |
|
| 556 | + unset($statuses['private']); |
|
| 557 | 557 | } |
| 558 | 558 | |
| 559 | - foreach ( $statuses as $state ) { |
|
| 560 | - $stats[ $state ] = 0; |
|
| 559 | + foreach ($statuses as $state) { |
|
| 560 | + $stats[$state] = 0; |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | - foreach ( (array) $count as $row ) { |
|
| 563 | + foreach ((array) $count as $row) { |
|
| 564 | 564 | |
| 565 | - if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) { |
|
| 565 | + if ('private' == $row['post_status'] && empty($args['s'])) { |
|
| 566 | 566 | continue; |
| 567 | 567 | } |
| 568 | 568 | |
| 569 | - $stats[ $row['post_status'] ] = $row['num_posts']; |
|
| 569 | + $stats[$row['post_status']] = $row['num_posts']; |
|
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | $stats = (object) $stats; |
| 573 | - wp_cache_set( $cache_key, $stats, 'counts' ); |
|
| 573 | + wp_cache_set($cache_key, $stats, 'counts'); |
|
| 574 | 574 | |
| 575 | 575 | return $stats; |
| 576 | 576 | } |
@@ -585,11 +585,11 @@ discard block |
||
| 585 | 585 | * |
| 586 | 586 | * @return bool $exists True if payment exists, false otherwise. |
| 587 | 587 | */ |
| 588 | -function give_check_for_existing_payment( $payment_id ) { |
|
| 588 | +function give_check_for_existing_payment($payment_id) { |
|
| 589 | 589 | $exists = false; |
| 590 | - $payment = new Give_Payment( $payment_id ); |
|
| 590 | + $payment = new Give_Payment($payment_id); |
|
| 591 | 591 | |
| 592 | - if ( $payment_id === $payment->ID && 'publish' === $payment->status ) { |
|
| 592 | + if ($payment_id === $payment->ID && 'publish' === $payment->status) { |
|
| 593 | 593 | $exists = true; |
| 594 | 594 | } |
| 595 | 595 | |
@@ -607,41 +607,41 @@ discard block |
||
| 607 | 607 | * |
| 608 | 608 | * @return bool|mixed True if payment status exists, false otherwise. |
| 609 | 609 | */ |
| 610 | -function give_get_payment_status( $payment, $return_label = false ) { |
|
| 610 | +function give_get_payment_status($payment, $return_label = false) { |
|
| 611 | 611 | |
| 612 | - if ( is_numeric( $payment ) ) { |
|
| 612 | + if (is_numeric($payment)) { |
|
| 613 | 613 | |
| 614 | - $payment = new Give_Payment( $payment ); |
|
| 614 | + $payment = new Give_Payment($payment); |
|
| 615 | 615 | |
| 616 | - if ( ! $payment->ID > 0 ) { |
|
| 616 | + if ( ! $payment->ID > 0) { |
|
| 617 | 617 | return false; |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | } |
| 621 | 621 | |
| 622 | - if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) { |
|
| 622 | + if ( ! is_object($payment) || ! isset($payment->post_status)) { |
|
| 623 | 623 | return false; |
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | $statuses = give_get_payment_statuses(); |
| 627 | 627 | |
| 628 | - if ( ! is_array( $statuses ) || empty( $statuses ) ) { |
|
| 628 | + if ( ! is_array($statuses) || empty($statuses)) { |
|
| 629 | 629 | return false; |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | // Get payment object if not already given. |
| 633 | - $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID ); |
|
| 633 | + $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID); |
|
| 634 | 634 | |
| 635 | - if ( array_key_exists( $payment->status, $statuses ) ) { |
|
| 636 | - if ( true === $return_label ) { |
|
| 635 | + if (array_key_exists($payment->status, $statuses)) { |
|
| 636 | + if (true === $return_label) { |
|
| 637 | 637 | // Return translated status label. |
| 638 | - return $statuses[ $payment->status ]; |
|
| 638 | + return $statuses[$payment->status]; |
|
| 639 | 639 | } else { |
| 640 | 640 | // Account that our 'publish' status is labeled 'Complete' |
| 641 | 641 | $post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status; |
| 642 | 642 | |
| 643 | 643 | // Make sure we're matching cases, since they matter |
| 644 | - return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) ); |
|
| 644 | + return array_search(strtolower($post_status), array_map('strtolower', $statuses)); |
|
| 645 | 645 | } |
| 646 | 646 | } |
| 647 | 647 | |
@@ -657,18 +657,18 @@ discard block |
||
| 657 | 657 | */ |
| 658 | 658 | function give_get_payment_statuses() { |
| 659 | 659 | $payment_statuses = array( |
| 660 | - 'pending' => __( 'Pending', 'give' ), |
|
| 661 | - 'publish' => __( 'Complete', 'give' ), |
|
| 662 | - 'refunded' => __( 'Refunded', 'give' ), |
|
| 663 | - 'failed' => __( 'Failed', 'give' ), |
|
| 664 | - 'cancelled' => __( 'Cancelled', 'give' ), |
|
| 665 | - 'abandoned' => __( 'Abandoned', 'give' ), |
|
| 666 | - 'preapproval' => __( 'Pre-Approved', 'give' ), |
|
| 667 | - 'processing' => __( 'Processing', 'give' ), |
|
| 668 | - 'revoked' => __( 'Revoked', 'give' ), |
|
| 660 | + 'pending' => __('Pending', 'give'), |
|
| 661 | + 'publish' => __('Complete', 'give'), |
|
| 662 | + 'refunded' => __('Refunded', 'give'), |
|
| 663 | + 'failed' => __('Failed', 'give'), |
|
| 664 | + 'cancelled' => __('Cancelled', 'give'), |
|
| 665 | + 'abandoned' => __('Abandoned', 'give'), |
|
| 666 | + 'preapproval' => __('Pre-Approved', 'give'), |
|
| 667 | + 'processing' => __('Processing', 'give'), |
|
| 668 | + 'revoked' => __('Revoked', 'give'), |
|
| 669 | 669 | ); |
| 670 | 670 | |
| 671 | - return apply_filters( 'give_payment_statuses', $payment_statuses ); |
|
| 671 | + return apply_filters('give_payment_statuses', $payment_statuses); |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | /** |
@@ -681,10 +681,10 @@ discard block |
||
| 681 | 681 | * @return array $payment_status All the available payment statuses. |
| 682 | 682 | */ |
| 683 | 683 | function give_get_payment_status_keys() { |
| 684 | - $statuses = array_keys( give_get_payment_statuses() ); |
|
| 685 | - asort( $statuses ); |
|
| 684 | + $statuses = array_keys(give_get_payment_statuses()); |
|
| 685 | + asort($statuses); |
|
| 686 | 686 | |
| 687 | - return array_values( $statuses ); |
|
| 687 | + return array_values($statuses); |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | /** |
@@ -699,7 +699,7 @@ discard block |
||
| 699 | 699 | * |
| 700 | 700 | * @return int $earnings Earnings |
| 701 | 701 | */ |
| 702 | -function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
|
| 702 | +function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) { |
|
| 703 | 703 | |
| 704 | 704 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead. |
| 705 | 705 | global $wpdb; |
@@ -709,41 +709,41 @@ discard block |
||
| 709 | 709 | 'nopaging' => true, |
| 710 | 710 | 'year' => $year, |
| 711 | 711 | 'monthnum' => $month_num, |
| 712 | - 'post_status' => array( 'publish' ), |
|
| 712 | + 'post_status' => array('publish'), |
|
| 713 | 713 | 'fields' => 'ids', |
| 714 | 714 | 'update_post_term_cache' => false, |
| 715 | 715 | ); |
| 716 | - if ( ! empty( $day ) ) { |
|
| 716 | + if ( ! empty($day)) { |
|
| 717 | 717 | $args['day'] = $day; |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | - if ( ! empty( $hour ) ) { |
|
| 720 | + if ( ! empty($hour)) { |
|
| 721 | 721 | $args['hour'] = $hour; |
| 722 | 722 | } |
| 723 | 723 | |
| 724 | - $args = apply_filters( 'give_get_earnings_by_date_args', $args ); |
|
| 725 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
| 724 | + $args = apply_filters('give_get_earnings_by_date_args', $args); |
|
| 725 | + $key = Give_Cache::get_key('give_stats', $args); |
|
| 726 | 726 | |
| 727 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
| 727 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
| 728 | 728 | $earnings = false; |
| 729 | 729 | } else { |
| 730 | - $earnings = Give_Cache::get( $key ); |
|
| 730 | + $earnings = Give_Cache::get($key); |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | - if ( false === $earnings ) { |
|
| 734 | - $donations = get_posts( $args ); |
|
| 733 | + if (false === $earnings) { |
|
| 734 | + $donations = get_posts($args); |
|
| 735 | 735 | $earnings = 0; |
| 736 | - if ( $donations ) { |
|
| 737 | - $donations = implode( ',', $donations ); |
|
| 736 | + if ($donations) { |
|
| 737 | + $donations = implode(',', $donations); |
|
| 738 | 738 | |
| 739 | - $earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})" ); |
|
| 739 | + $earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})"); |
|
| 740 | 740 | |
| 741 | 741 | } |
| 742 | 742 | // Cache the results for one hour. |
| 743 | - Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS ); |
|
| 743 | + Give_Cache::set($key, $earnings, HOUR_IN_SECONDS); |
|
| 744 | 744 | } |
| 745 | 745 | |
| 746 | - return round( $earnings, 2 ); |
|
| 746 | + return round($earnings, 2); |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | /** |
@@ -758,7 +758,7 @@ discard block |
||
| 758 | 758 | * |
| 759 | 759 | * @return int $count Sales |
| 760 | 760 | */ |
| 761 | -function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) { |
|
| 761 | +function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) { |
|
| 762 | 762 | |
| 763 | 763 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead. |
| 764 | 764 | $args = array( |
@@ -766,14 +766,14 @@ discard block |
||
| 766 | 766 | 'nopaging' => true, |
| 767 | 767 | 'year' => $year, |
| 768 | 768 | 'fields' => 'ids', |
| 769 | - 'post_status' => array( 'publish' ), |
|
| 769 | + 'post_status' => array('publish'), |
|
| 770 | 770 | 'update_post_meta_cache' => false, |
| 771 | 771 | 'update_post_term_cache' => false, |
| 772 | 772 | ); |
| 773 | 773 | |
| 774 | - $show_free = apply_filters( 'give_sales_by_date_show_free', true, $args ); |
|
| 774 | + $show_free = apply_filters('give_sales_by_date_show_free', true, $args); |
|
| 775 | 775 | |
| 776 | - if ( false === $show_free ) { |
|
| 776 | + if (false === $show_free) { |
|
| 777 | 777 | $args['meta_query'] = array( |
| 778 | 778 | array( |
| 779 | 779 | 'key' => '_give_payment_total', |
@@ -784,33 +784,33 @@ discard block |
||
| 784 | 784 | ); |
| 785 | 785 | } |
| 786 | 786 | |
| 787 | - if ( ! empty( $month_num ) ) { |
|
| 787 | + if ( ! empty($month_num)) { |
|
| 788 | 788 | $args['monthnum'] = $month_num; |
| 789 | 789 | } |
| 790 | 790 | |
| 791 | - if ( ! empty( $day ) ) { |
|
| 791 | + if ( ! empty($day)) { |
|
| 792 | 792 | $args['day'] = $day; |
| 793 | 793 | } |
| 794 | 794 | |
| 795 | - if ( ! empty( $hour ) ) { |
|
| 795 | + if ( ! empty($hour)) { |
|
| 796 | 796 | $args['hour'] = $hour; |
| 797 | 797 | } |
| 798 | 798 | |
| 799 | - $args = apply_filters( 'give_get_sales_by_date_args', $args ); |
|
| 799 | + $args = apply_filters('give_get_sales_by_date_args', $args); |
|
| 800 | 800 | |
| 801 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
| 801 | + $key = Give_Cache::get_key('give_stats', $args); |
|
| 802 | 802 | |
| 803 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
| 803 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
| 804 | 804 | $count = false; |
| 805 | 805 | } else { |
| 806 | - $count = Give_Cache::get( $key ); |
|
| 806 | + $count = Give_Cache::get($key); |
|
| 807 | 807 | } |
| 808 | 808 | |
| 809 | - if ( false === $count ) { |
|
| 810 | - $donations = new WP_Query( $args ); |
|
| 809 | + if (false === $count) { |
|
| 810 | + $donations = new WP_Query($args); |
|
| 811 | 811 | $count = (int) $donations->post_count; |
| 812 | 812 | // Cache the results for one hour. |
| 813 | - Give_Cache::set( $key, $count, HOUR_IN_SECONDS ); |
|
| 813 | + Give_Cache::set($key, $count, HOUR_IN_SECONDS); |
|
| 814 | 814 | } |
| 815 | 815 | |
| 816 | 816 | return $count; |
@@ -825,19 +825,19 @@ discard block |
||
| 825 | 825 | * |
| 826 | 826 | * @return bool $ret True if complete, false otherwise. |
| 827 | 827 | */ |
| 828 | -function give_is_payment_complete( $payment_id ) { |
|
| 829 | - $payment = new Give_Payment( $payment_id ); |
|
| 828 | +function give_is_payment_complete($payment_id) { |
|
| 829 | + $payment = new Give_Payment($payment_id); |
|
| 830 | 830 | |
| 831 | 831 | $ret = false; |
| 832 | 832 | |
| 833 | - if ( $payment->ID > 0 ) { |
|
| 833 | + if ($payment->ID > 0) { |
|
| 834 | 834 | |
| 835 | - if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) { |
|
| 835 | + if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) { |
|
| 836 | 836 | $ret = true; |
| 837 | 837 | } |
| 838 | 838 | } |
| 839 | 839 | |
| 840 | - return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status ); |
|
| 840 | + return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status); |
|
| 841 | 841 | } |
| 842 | 842 | |
| 843 | 843 | /** |
@@ -863,49 +863,49 @@ discard block |
||
| 863 | 863 | * |
| 864 | 864 | * @return float $total Total earnings. |
| 865 | 865 | */ |
| 866 | -function give_get_total_earnings( $recalculate = false ) { |
|
| 866 | +function give_get_total_earnings($recalculate = false) { |
|
| 867 | 867 | |
| 868 | - $total = get_option( 'give_earnings_total', 0 ); |
|
| 868 | + $total = get_option('give_earnings_total', 0); |
|
| 869 | 869 | |
| 870 | 870 | // Calculate total earnings. |
| 871 | - if ( ! $total || $recalculate ) { |
|
| 871 | + if ( ! $total || $recalculate) { |
|
| 872 | 872 | global $wpdb; |
| 873 | 873 | |
| 874 | 874 | $total = (float) 0; |
| 875 | 875 | |
| 876 | - $args = apply_filters( 'give_get_total_earnings_args', array( |
|
| 876 | + $args = apply_filters('give_get_total_earnings_args', array( |
|
| 877 | 877 | 'offset' => 0, |
| 878 | - 'number' => - 1, |
|
| 879 | - 'status' => array( 'publish' ), |
|
| 878 | + 'number' => -1, |
|
| 879 | + 'status' => array('publish'), |
|
| 880 | 880 | 'fields' => 'ids', |
| 881 | - ) ); |
|
| 881 | + )); |
|
| 882 | 882 | |
| 883 | - $payments = give_get_payments( $args ); |
|
| 884 | - if ( $payments ) { |
|
| 883 | + $payments = give_get_payments($args); |
|
| 884 | + if ($payments) { |
|
| 885 | 885 | |
| 886 | 886 | /** |
| 887 | 887 | * If performing a donation, we need to skip the very last payment in the database, |
| 888 | 888 | * since it calls give_increase_total_earnings() on completion, |
| 889 | 889 | * which results in duplicated earnings for the very first donation. |
| 890 | 890 | */ |
| 891 | - if ( did_action( 'give_update_payment_status' ) ) { |
|
| 892 | - array_pop( $payments ); |
|
| 891 | + if (did_action('give_update_payment_status')) { |
|
| 892 | + array_pop($payments); |
|
| 893 | 893 | } |
| 894 | 894 | |
| 895 | - if ( ! empty( $payments ) ) { |
|
| 896 | - $payments = implode( ',', $payments ); |
|
| 897 | - $total += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" ); |
|
| 895 | + if ( ! empty($payments)) { |
|
| 896 | + $payments = implode(',', $payments); |
|
| 897 | + $total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})"); |
|
| 898 | 898 | } |
| 899 | 899 | } |
| 900 | 900 | |
| 901 | - update_option( 'give_earnings_total', $total, 'no' ); |
|
| 901 | + update_option('give_earnings_total', $total, 'no'); |
|
| 902 | 902 | } |
| 903 | 903 | |
| 904 | - if ( $total < 0 ) { |
|
| 904 | + if ($total < 0) { |
|
| 905 | 905 | $total = 0; // Don't ever show negative earnings. |
| 906 | 906 | } |
| 907 | 907 | |
| 908 | - return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) ); |
|
| 908 | + return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter())); |
|
| 909 | 909 | } |
| 910 | 910 | |
| 911 | 911 | /** |
@@ -918,10 +918,10 @@ discard block |
||
| 918 | 918 | * |
| 919 | 919 | * @return float $total Total earnings. |
| 920 | 920 | */ |
| 921 | -function give_increase_total_earnings( $amount = 0 ) { |
|
| 921 | +function give_increase_total_earnings($amount = 0) { |
|
| 922 | 922 | $total = give_get_total_earnings(); |
| 923 | 923 | $total += $amount; |
| 924 | - update_option( 'give_earnings_total', $total ); |
|
| 924 | + update_option('give_earnings_total', $total); |
|
| 925 | 925 | |
| 926 | 926 | return $total; |
| 927 | 927 | } |
@@ -935,13 +935,13 @@ discard block |
||
| 935 | 935 | * |
| 936 | 936 | * @return float $total Total earnings. |
| 937 | 937 | */ |
| 938 | -function give_decrease_total_earnings( $amount = 0 ) { |
|
| 938 | +function give_decrease_total_earnings($amount = 0) { |
|
| 939 | 939 | $total = give_get_total_earnings(); |
| 940 | 940 | $total -= $amount; |
| 941 | - if ( $total < 0 ) { |
|
| 941 | + if ($total < 0) { |
|
| 942 | 942 | $total = 0; |
| 943 | 943 | } |
| 944 | - update_option( 'give_earnings_total', $total ); |
|
| 944 | + update_option('give_earnings_total', $total); |
|
| 945 | 945 | |
| 946 | 946 | return $total; |
| 947 | 947 | } |
@@ -957,10 +957,10 @@ discard block |
||
| 957 | 957 | * |
| 958 | 958 | * @return mixed $meta Payment Meta. |
| 959 | 959 | */ |
| 960 | -function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) { |
|
| 961 | - $payment = new Give_Payment( $payment_id ); |
|
| 960 | +function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) { |
|
| 961 | + $payment = new Give_Payment($payment_id); |
|
| 962 | 962 | |
| 963 | - return $payment->get_meta( $meta_key, $single ); |
|
| 963 | + return $payment->get_meta($meta_key, $single); |
|
| 964 | 964 | } |
| 965 | 965 | |
| 966 | 966 | /** |
@@ -973,10 +973,10 @@ discard block |
||
| 973 | 973 | * |
| 974 | 974 | * @return mixed Meta ID if successful, false if unsuccessful. |
| 975 | 975 | */ |
| 976 | -function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
| 977 | - $payment = new Give_Payment( $payment_id ); |
|
| 976 | +function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') { |
|
| 977 | + $payment = new Give_Payment($payment_id); |
|
| 978 | 978 | |
| 979 | - return $payment->update_meta( $meta_key, $meta_value, $prev_value ); |
|
| 979 | + return $payment->update_meta($meta_key, $meta_value, $prev_value); |
|
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 | /** |
@@ -988,8 +988,8 @@ discard block |
||
| 988 | 988 | * |
| 989 | 989 | * @return array $user_info User Info Meta Values. |
| 990 | 990 | */ |
| 991 | -function give_get_payment_meta_user_info( $payment_id ) { |
|
| 992 | - $payment = new Give_Payment( $payment_id ); |
|
| 991 | +function give_get_payment_meta_user_info($payment_id) { |
|
| 992 | + $payment = new Give_Payment($payment_id); |
|
| 993 | 993 | |
| 994 | 994 | return $payment->user_info; |
| 995 | 995 | } |
@@ -1005,8 +1005,8 @@ discard block |
||
| 1005 | 1005 | * |
| 1006 | 1006 | * @return int $form_id Form ID. |
| 1007 | 1007 | */ |
| 1008 | -function give_get_payment_form_id( $payment_id ) { |
|
| 1009 | - $payment = new Give_Payment( $payment_id ); |
|
| 1008 | +function give_get_payment_form_id($payment_id) { |
|
| 1009 | + $payment = new Give_Payment($payment_id); |
|
| 1010 | 1010 | |
| 1011 | 1011 | return $payment->form_id; |
| 1012 | 1012 | } |
@@ -1020,8 +1020,8 @@ discard block |
||
| 1020 | 1020 | * |
| 1021 | 1021 | * @return string $email User email. |
| 1022 | 1022 | */ |
| 1023 | -function give_get_payment_user_email( $payment_id ) { |
|
| 1024 | - $payment = new Give_Payment( $payment_id ); |
|
| 1023 | +function give_get_payment_user_email($payment_id) { |
|
| 1024 | + $payment = new Give_Payment($payment_id); |
|
| 1025 | 1025 | |
| 1026 | 1026 | return $payment->email; |
| 1027 | 1027 | } |
@@ -1035,11 +1035,11 @@ discard block |
||
| 1035 | 1035 | * |
| 1036 | 1036 | * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true) |
| 1037 | 1037 | */ |
| 1038 | -function give_is_guest_payment( $payment_id ) { |
|
| 1039 | - $payment_user_id = give_get_payment_user_id( $payment_id ); |
|
| 1040 | - $is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true; |
|
| 1038 | +function give_is_guest_payment($payment_id) { |
|
| 1039 | + $payment_user_id = give_get_payment_user_id($payment_id); |
|
| 1040 | + $is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true; |
|
| 1041 | 1041 | |
| 1042 | - return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id ); |
|
| 1042 | + return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id); |
|
| 1043 | 1043 | } |
| 1044 | 1044 | |
| 1045 | 1045 | /** |
@@ -1051,8 +1051,8 @@ discard block |
||
| 1051 | 1051 | * |
| 1052 | 1052 | * @return int $user_id User ID. |
| 1053 | 1053 | */ |
| 1054 | -function give_get_payment_user_id( $payment_id ) { |
|
| 1055 | - $payment = new Give_Payment( $payment_id ); |
|
| 1054 | +function give_get_payment_user_id($payment_id) { |
|
| 1055 | + $payment = new Give_Payment($payment_id); |
|
| 1056 | 1056 | |
| 1057 | 1057 | return $payment->user_id; |
| 1058 | 1058 | } |
@@ -1066,8 +1066,8 @@ discard block |
||
| 1066 | 1066 | * |
| 1067 | 1067 | * @return int $payment->customer_id Donor ID. |
| 1068 | 1068 | */ |
| 1069 | -function give_get_payment_donor_id( $payment_id ) { |
|
| 1070 | - $payment = new Give_Payment( $payment_id ); |
|
| 1069 | +function give_get_payment_donor_id($payment_id) { |
|
| 1070 | + $payment = new Give_Payment($payment_id); |
|
| 1071 | 1071 | |
| 1072 | 1072 | return $payment->customer_id; |
| 1073 | 1073 | } |
@@ -1081,8 +1081,8 @@ discard block |
||
| 1081 | 1081 | * |
| 1082 | 1082 | * @return string $ip User IP. |
| 1083 | 1083 | */ |
| 1084 | -function give_get_payment_user_ip( $payment_id ) { |
|
| 1085 | - $payment = new Give_Payment( $payment_id ); |
|
| 1084 | +function give_get_payment_user_ip($payment_id) { |
|
| 1085 | + $payment = new Give_Payment($payment_id); |
|
| 1086 | 1086 | |
| 1087 | 1087 | return $payment->ip; |
| 1088 | 1088 | } |
@@ -1096,8 +1096,8 @@ discard block |
||
| 1096 | 1096 | * |
| 1097 | 1097 | * @return string $date The date the payment was completed. |
| 1098 | 1098 | */ |
| 1099 | -function give_get_payment_completed_date( $payment_id = 0 ) { |
|
| 1100 | - $payment = new Give_Payment( $payment_id ); |
|
| 1099 | +function give_get_payment_completed_date($payment_id = 0) { |
|
| 1100 | + $payment = new Give_Payment($payment_id); |
|
| 1101 | 1101 | |
| 1102 | 1102 | return $payment->completed_date; |
| 1103 | 1103 | } |
@@ -1111,8 +1111,8 @@ discard block |
||
| 1111 | 1111 | * |
| 1112 | 1112 | * @return string $gateway Gateway. |
| 1113 | 1113 | */ |
| 1114 | -function give_get_payment_gateway( $payment_id ) { |
|
| 1115 | - $payment = new Give_Payment( $payment_id ); |
|
| 1114 | +function give_get_payment_gateway($payment_id) { |
|
| 1115 | + $payment = new Give_Payment($payment_id); |
|
| 1116 | 1116 | |
| 1117 | 1117 | return $payment->gateway; |
| 1118 | 1118 | } |
@@ -1126,8 +1126,8 @@ discard block |
||
| 1126 | 1126 | * |
| 1127 | 1127 | * @return string $currency The currency code. |
| 1128 | 1128 | */ |
| 1129 | -function give_get_payment_currency_code( $payment_id = 0 ) { |
|
| 1130 | - $payment = new Give_Payment( $payment_id ); |
|
| 1129 | +function give_get_payment_currency_code($payment_id = 0) { |
|
| 1130 | + $payment = new Give_Payment($payment_id); |
|
| 1131 | 1131 | |
| 1132 | 1132 | return $payment->currency; |
| 1133 | 1133 | } |
@@ -1141,10 +1141,10 @@ discard block |
||
| 1141 | 1141 | * |
| 1142 | 1142 | * @return string $currency The currency name. |
| 1143 | 1143 | */ |
| 1144 | -function give_get_payment_currency( $payment_id = 0 ) { |
|
| 1145 | - $currency = give_get_payment_currency_code( $payment_id ); |
|
| 1144 | +function give_get_payment_currency($payment_id = 0) { |
|
| 1145 | + $currency = give_get_payment_currency_code($payment_id); |
|
| 1146 | 1146 | |
| 1147 | - return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id ); |
|
| 1147 | + return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id); |
|
| 1148 | 1148 | } |
| 1149 | 1149 | |
| 1150 | 1150 | /** |
@@ -1156,8 +1156,8 @@ discard block |
||
| 1156 | 1156 | * |
| 1157 | 1157 | * @return string $key Donation key. |
| 1158 | 1158 | */ |
| 1159 | -function give_get_payment_key( $payment_id = 0 ) { |
|
| 1160 | - $payment = new Give_Payment( $payment_id ); |
|
| 1159 | +function give_get_payment_key($payment_id = 0) { |
|
| 1160 | + $payment = new Give_Payment($payment_id); |
|
| 1161 | 1161 | |
| 1162 | 1162 | return $payment->key; |
| 1163 | 1163 | } |
@@ -1173,8 +1173,8 @@ discard block |
||
| 1173 | 1173 | * |
| 1174 | 1174 | * @return string $number Payment order number. |
| 1175 | 1175 | */ |
| 1176 | -function give_get_payment_number( $payment_id = 0 ) { |
|
| 1177 | - $payment = new Give_Payment( $payment_id ); |
|
| 1176 | +function give_get_payment_number($payment_id = 0) { |
|
| 1177 | + $payment = new Give_Payment($payment_id); |
|
| 1178 | 1178 | |
| 1179 | 1179 | return $payment->number; |
| 1180 | 1180 | } |
@@ -1188,23 +1188,23 @@ discard block |
||
| 1188 | 1188 | * |
| 1189 | 1189 | * @return string The formatted payment number. |
| 1190 | 1190 | */ |
| 1191 | -function give_format_payment_number( $number ) { |
|
| 1191 | +function give_format_payment_number($number) { |
|
| 1192 | 1192 | |
| 1193 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
| 1193 | + if ( ! give_get_option('enable_sequential')) { |
|
| 1194 | 1194 | return $number; |
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | - if ( ! is_numeric( $number ) ) { |
|
| 1197 | + if ( ! is_numeric($number)) { |
|
| 1198 | 1198 | return $number; |
| 1199 | 1199 | } |
| 1200 | 1200 | |
| 1201 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
| 1202 | - $number = absint( $number ); |
|
| 1203 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
| 1201 | + $prefix = give_get_option('sequential_prefix'); |
|
| 1202 | + $number = absint($number); |
|
| 1203 | + $postfix = give_get_option('sequential_postfix'); |
|
| 1204 | 1204 | |
| 1205 | - $formatted_number = $prefix . $number . $postfix; |
|
| 1205 | + $formatted_number = $prefix.$number.$postfix; |
|
| 1206 | 1206 | |
| 1207 | - return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix ); |
|
| 1207 | + return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix); |
|
| 1208 | 1208 | } |
| 1209 | 1209 | |
| 1210 | 1210 | /** |
@@ -1217,17 +1217,17 @@ discard block |
||
| 1217 | 1217 | */ |
| 1218 | 1218 | function give_get_next_payment_number() { |
| 1219 | 1219 | |
| 1220 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
| 1220 | + if ( ! give_get_option('enable_sequential')) { |
|
| 1221 | 1221 | return false; |
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | - $number = get_option( 'give_last_payment_number' ); |
|
| 1225 | - $start = give_get_option( 'sequential_start', 1 ); |
|
| 1224 | + $number = get_option('give_last_payment_number'); |
|
| 1225 | + $start = give_get_option('sequential_start', 1); |
|
| 1226 | 1226 | $increment_number = true; |
| 1227 | 1227 | |
| 1228 | - if ( false !== $number ) { |
|
| 1228 | + if (false !== $number) { |
|
| 1229 | 1229 | |
| 1230 | - if ( empty( $number ) ) { |
|
| 1230 | + if (empty($number)) { |
|
| 1231 | 1231 | |
| 1232 | 1232 | $number = $start; |
| 1233 | 1233 | $increment_number = false; |
@@ -1236,24 +1236,24 @@ discard block |
||
| 1236 | 1236 | } else { |
| 1237 | 1237 | |
| 1238 | 1238 | // This case handles the first addition of the new option, as well as if it get's deleted for any reason. |
| 1239 | - $payments = new Give_Payments_Query( array( |
|
| 1239 | + $payments = new Give_Payments_Query(array( |
|
| 1240 | 1240 | 'number' => 1, |
| 1241 | 1241 | 'order' => 'DESC', |
| 1242 | 1242 | 'orderby' => 'ID', |
| 1243 | 1243 | 'output' => 'posts', |
| 1244 | 1244 | 'fields' => 'ids', |
| 1245 | - ) ); |
|
| 1245 | + )); |
|
| 1246 | 1246 | $last_payment = $payments->get_payments(); |
| 1247 | 1247 | |
| 1248 | - if ( ! empty( $last_payment ) ) { |
|
| 1248 | + if ( ! empty($last_payment)) { |
|
| 1249 | 1249 | |
| 1250 | - $number = give_get_payment_number( $last_payment[0] ); |
|
| 1250 | + $number = give_get_payment_number($last_payment[0]); |
|
| 1251 | 1251 | |
| 1252 | 1252 | } |
| 1253 | 1253 | |
| 1254 | - if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) { |
|
| 1254 | + if ( ! empty($number) && $number !== (int) $last_payment[0]) { |
|
| 1255 | 1255 | |
| 1256 | - $number = give_remove_payment_prefix_postfix( $number ); |
|
| 1256 | + $number = give_remove_payment_prefix_postfix($number); |
|
| 1257 | 1257 | |
| 1258 | 1258 | } else { |
| 1259 | 1259 | |
@@ -1262,13 +1262,13 @@ discard block |
||
| 1262 | 1262 | } |
| 1263 | 1263 | }// End if(). |
| 1264 | 1264 | |
| 1265 | - $increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number ); |
|
| 1265 | + $increment_number = apply_filters('give_increment_payment_number', $increment_number, $number); |
|
| 1266 | 1266 | |
| 1267 | - if ( $increment_number ) { |
|
| 1268 | - $number ++; |
|
| 1267 | + if ($increment_number) { |
|
| 1268 | + $number++; |
|
| 1269 | 1269 | } |
| 1270 | 1270 | |
| 1271 | - return apply_filters( 'give_get_next_payment_number', $number ); |
|
| 1271 | + return apply_filters('give_get_next_payment_number', $number); |
|
| 1272 | 1272 | } |
| 1273 | 1273 | |
| 1274 | 1274 | /** |
@@ -1280,25 +1280,25 @@ discard block |
||
| 1280 | 1280 | * |
| 1281 | 1281 | * @return string The new Payment number without prefix and postfix. |
| 1282 | 1282 | */ |
| 1283 | -function give_remove_payment_prefix_postfix( $number ) { |
|
| 1283 | +function give_remove_payment_prefix_postfix($number) { |
|
| 1284 | 1284 | |
| 1285 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
| 1286 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
| 1285 | + $prefix = give_get_option('sequential_prefix'); |
|
| 1286 | + $postfix = give_get_option('sequential_postfix'); |
|
| 1287 | 1287 | |
| 1288 | 1288 | // Remove prefix. |
| 1289 | - $number = preg_replace( '/' . $prefix . '/', '', $number, 1 ); |
|
| 1289 | + $number = preg_replace('/'.$prefix.'/', '', $number, 1); |
|
| 1290 | 1290 | |
| 1291 | 1291 | // Remove the postfix. |
| 1292 | - $length = strlen( $number ); |
|
| 1293 | - $postfix_pos = strrpos( $number, $postfix ); |
|
| 1294 | - if ( false !== $postfix_pos ) { |
|
| 1295 | - $number = substr_replace( $number, '', $postfix_pos, $length ); |
|
| 1292 | + $length = strlen($number); |
|
| 1293 | + $postfix_pos = strrpos($number, $postfix); |
|
| 1294 | + if (false !== $postfix_pos) { |
|
| 1295 | + $number = substr_replace($number, '', $postfix_pos, $length); |
|
| 1296 | 1296 | } |
| 1297 | 1297 | |
| 1298 | 1298 | // Ensure it's a whole number. |
| 1299 | - $number = intval( $number ); |
|
| 1299 | + $number = intval($number); |
|
| 1300 | 1300 | |
| 1301 | - return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix ); |
|
| 1301 | + return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix); |
|
| 1302 | 1302 | |
| 1303 | 1303 | } |
| 1304 | 1304 | |
@@ -1315,10 +1315,10 @@ discard block |
||
| 1315 | 1315 | * |
| 1316 | 1316 | * @return string $amount Fully formatted payment amount. |
| 1317 | 1317 | */ |
| 1318 | -function give_payment_amount( $payment_id = 0 ) { |
|
| 1319 | - $amount = give_get_payment_amount( $payment_id ); |
|
| 1318 | +function give_payment_amount($payment_id = 0) { |
|
| 1319 | + $amount = give_get_payment_amount($payment_id); |
|
| 1320 | 1320 | |
| 1321 | - return give_currency_filter( give_format_amount( $amount, array( 'sanitize' => false ) ), give_get_payment_currency_code( $payment_id ) ); |
|
| 1321 | + return give_currency_filter(give_format_amount($amount, array('sanitize' => false)), give_get_payment_currency_code($payment_id)); |
|
| 1322 | 1322 | } |
| 1323 | 1323 | |
| 1324 | 1324 | /** |
@@ -1331,11 +1331,11 @@ discard block |
||
| 1331 | 1331 | * |
| 1332 | 1332 | * @return mixed |
| 1333 | 1333 | */ |
| 1334 | -function give_get_payment_amount( $payment_id ) { |
|
| 1334 | +function give_get_payment_amount($payment_id) { |
|
| 1335 | 1335 | |
| 1336 | - $payment = new Give_Payment( $payment_id ); |
|
| 1336 | + $payment = new Give_Payment($payment_id); |
|
| 1337 | 1337 | |
| 1338 | - return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id ); |
|
| 1338 | + return apply_filters('give_payment_amount', floatval($payment->total), $payment_id); |
|
| 1339 | 1339 | } |
| 1340 | 1340 | |
| 1341 | 1341 | /** |
@@ -1352,10 +1352,10 @@ discard block |
||
| 1352 | 1352 | * |
| 1353 | 1353 | * @return array Fully formatted payment subtotal. |
| 1354 | 1354 | */ |
| 1355 | -function give_payment_subtotal( $payment_id = 0 ) { |
|
| 1356 | - $subtotal = give_get_payment_subtotal( $payment_id ); |
|
| 1355 | +function give_payment_subtotal($payment_id = 0) { |
|
| 1356 | + $subtotal = give_get_payment_subtotal($payment_id); |
|
| 1357 | 1357 | |
| 1358 | - return give_currency_filter( give_format_amount( $subtotal, array( 'sanitize' => false ) ), give_get_payment_currency_code( $payment_id ) ); |
|
| 1358 | + return give_currency_filter(give_format_amount($subtotal, array('sanitize' => false)), give_get_payment_currency_code($payment_id)); |
|
| 1359 | 1359 | } |
| 1360 | 1360 | |
| 1361 | 1361 | /** |
@@ -1369,8 +1369,8 @@ discard block |
||
| 1369 | 1369 | * |
| 1370 | 1370 | * @return float $subtotal Subtotal for payment (non formatted). |
| 1371 | 1371 | */ |
| 1372 | -function give_get_payment_subtotal( $payment_id = 0 ) { |
|
| 1373 | - $payment = new Give_Payment( $payment_id ); |
|
| 1372 | +function give_get_payment_subtotal($payment_id = 0) { |
|
| 1373 | + $payment = new Give_Payment($payment_id); |
|
| 1374 | 1374 | |
| 1375 | 1375 | return $payment->subtotal; |
| 1376 | 1376 | } |
@@ -1384,8 +1384,8 @@ discard block |
||
| 1384 | 1384 | * |
| 1385 | 1385 | * @return string The donation ID. |
| 1386 | 1386 | */ |
| 1387 | -function give_get_payment_transaction_id( $payment_id = 0 ) { |
|
| 1388 | - $payment = new Give_Payment( $payment_id ); |
|
| 1387 | +function give_get_payment_transaction_id($payment_id = 0) { |
|
| 1388 | + $payment = new Give_Payment($payment_id); |
|
| 1389 | 1389 | |
| 1390 | 1390 | return $payment->transaction_id; |
| 1391 | 1391 | } |
@@ -1400,15 +1400,15 @@ discard block |
||
| 1400 | 1400 | * |
| 1401 | 1401 | * @return bool|mixed |
| 1402 | 1402 | */ |
| 1403 | -function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) { |
|
| 1403 | +function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') { |
|
| 1404 | 1404 | |
| 1405 | - if ( empty( $payment_id ) || empty( $transaction_id ) ) { |
|
| 1405 | + if (empty($payment_id) || empty($transaction_id)) { |
|
| 1406 | 1406 | return false; |
| 1407 | 1407 | } |
| 1408 | 1408 | |
| 1409 | - $transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
| 1409 | + $transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id); |
|
| 1410 | 1410 | |
| 1411 | - return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id ); |
|
| 1411 | + return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id); |
|
| 1412 | 1412 | } |
| 1413 | 1413 | |
| 1414 | 1414 | /** |
@@ -1421,12 +1421,12 @@ discard block |
||
| 1421 | 1421 | * |
| 1422 | 1422 | * @return int $purchase Donation ID. |
| 1423 | 1423 | */ |
| 1424 | -function give_get_purchase_id_by_key( $key ) { |
|
| 1424 | +function give_get_purchase_id_by_key($key) { |
|
| 1425 | 1425 | global $wpdb; |
| 1426 | 1426 | |
| 1427 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
| 1427 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key)); |
|
| 1428 | 1428 | |
| 1429 | - if ( $purchase != null ) { |
|
| 1429 | + if ($purchase != null) { |
|
| 1430 | 1430 | return $purchase; |
| 1431 | 1431 | } |
| 1432 | 1432 | |
@@ -1444,12 +1444,12 @@ discard block |
||
| 1444 | 1444 | * |
| 1445 | 1445 | * @return int $purchase Donation ID. |
| 1446 | 1446 | */ |
| 1447 | -function give_get_purchase_id_by_transaction_id( $key ) { |
|
| 1447 | +function give_get_purchase_id_by_transaction_id($key) { |
|
| 1448 | 1448 | global $wpdb; |
| 1449 | 1449 | |
| 1450 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) ); |
|
| 1450 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key)); |
|
| 1451 | 1451 | |
| 1452 | - if ( $purchase != null ) { |
|
| 1452 | + if ($purchase != null) { |
|
| 1453 | 1453 | return $purchase; |
| 1454 | 1454 | } |
| 1455 | 1455 | |
@@ -1466,23 +1466,23 @@ discard block |
||
| 1466 | 1466 | * |
| 1467 | 1467 | * @return array $notes Donation Notes |
| 1468 | 1468 | */ |
| 1469 | -function give_get_payment_notes( $payment_id = 0, $search = '' ) { |
|
| 1469 | +function give_get_payment_notes($payment_id = 0, $search = '') { |
|
| 1470 | 1470 | |
| 1471 | - if ( empty( $payment_id ) && empty( $search ) ) { |
|
| 1471 | + if (empty($payment_id) && empty($search)) { |
|
| 1472 | 1472 | return false; |
| 1473 | 1473 | } |
| 1474 | 1474 | |
| 1475 | - remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
| 1476 | - remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 ); |
|
| 1475 | + remove_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
| 1476 | + remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10); |
|
| 1477 | 1477 | |
| 1478 | - $notes = get_comments( array( |
|
| 1478 | + $notes = get_comments(array( |
|
| 1479 | 1479 | 'post_id' => $payment_id, |
| 1480 | 1480 | 'order' => 'ASC', |
| 1481 | 1481 | 'search' => $search, |
| 1482 | - ) ); |
|
| 1482 | + )); |
|
| 1483 | 1483 | |
| 1484 | - add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
| 1485 | - add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
| 1484 | + add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
| 1485 | + add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
| 1486 | 1486 | |
| 1487 | 1487 | return $notes; |
| 1488 | 1488 | } |
@@ -1498,8 +1498,8 @@ discard block |
||
| 1498 | 1498 | * |
| 1499 | 1499 | * @return int The new note ID |
| 1500 | 1500 | */ |
| 1501 | -function give_insert_payment_note( $payment_id = 0, $note = '' ) { |
|
| 1502 | - if ( empty( $payment_id ) ) { |
|
| 1501 | +function give_insert_payment_note($payment_id = 0, $note = '') { |
|
| 1502 | + if (empty($payment_id)) { |
|
| 1503 | 1503 | return false; |
| 1504 | 1504 | } |
| 1505 | 1505 | |
@@ -1511,14 +1511,14 @@ discard block |
||
| 1511 | 1511 | * @param int $payment_id Payment ID. |
| 1512 | 1512 | * @param string $note The note. |
| 1513 | 1513 | */ |
| 1514 | - do_action( 'give_pre_insert_payment_note', $payment_id, $note ); |
|
| 1514 | + do_action('give_pre_insert_payment_note', $payment_id, $note); |
|
| 1515 | 1515 | |
| 1516 | - $note_id = wp_insert_comment( wp_filter_comment( array( |
|
| 1516 | + $note_id = wp_insert_comment(wp_filter_comment(array( |
|
| 1517 | 1517 | 'comment_post_ID' => $payment_id, |
| 1518 | 1518 | 'comment_content' => $note, |
| 1519 | 1519 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
| 1520 | - 'comment_date' => current_time( 'mysql' ), |
|
| 1521 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
| 1520 | + 'comment_date' => current_time('mysql'), |
|
| 1521 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
| 1522 | 1522 | 'comment_approved' => 1, |
| 1523 | 1523 | 'comment_parent' => 0, |
| 1524 | 1524 | 'comment_author' => '', |
@@ -1527,7 +1527,7 @@ discard block |
||
| 1527 | 1527 | 'comment_author_email' => '', |
| 1528 | 1528 | 'comment_type' => 'give_payment_note', |
| 1529 | 1529 | |
| 1530 | - ) ) ); |
|
| 1530 | + ))); |
|
| 1531 | 1531 | |
| 1532 | 1532 | /** |
| 1533 | 1533 | * Fires after payment note inserted. |
@@ -1538,7 +1538,7 @@ discard block |
||
| 1538 | 1538 | * @param int $payment_id Payment ID. |
| 1539 | 1539 | * @param string $note The note. |
| 1540 | 1540 | */ |
| 1541 | - do_action( 'give_insert_payment_note', $note_id, $payment_id, $note ); |
|
| 1541 | + do_action('give_insert_payment_note', $note_id, $payment_id, $note); |
|
| 1542 | 1542 | |
| 1543 | 1543 | return $note_id; |
| 1544 | 1544 | } |
@@ -1553,8 +1553,8 @@ discard block |
||
| 1553 | 1553 | * |
| 1554 | 1554 | * @return bool True on success, false otherwise. |
| 1555 | 1555 | */ |
| 1556 | -function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) { |
|
| 1557 | - if ( empty( $comment_id ) ) { |
|
| 1556 | +function give_delete_payment_note($comment_id = 0, $payment_id = 0) { |
|
| 1557 | + if (empty($comment_id)) { |
|
| 1558 | 1558 | return false; |
| 1559 | 1559 | } |
| 1560 | 1560 | |
@@ -1566,9 +1566,9 @@ discard block |
||
| 1566 | 1566 | * @param int $comment_id Note ID. |
| 1567 | 1567 | * @param int $payment_id Payment ID. |
| 1568 | 1568 | */ |
| 1569 | - do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id ); |
|
| 1569 | + do_action('give_pre_delete_payment_note', $comment_id, $payment_id); |
|
| 1570 | 1570 | |
| 1571 | - $ret = wp_delete_comment( $comment_id, true ); |
|
| 1571 | + $ret = wp_delete_comment($comment_id, true); |
|
| 1572 | 1572 | |
| 1573 | 1573 | /** |
| 1574 | 1574 | * Fires after donation note deleted. |
@@ -1578,7 +1578,7 @@ discard block |
||
| 1578 | 1578 | * @param int $comment_id Note ID. |
| 1579 | 1579 | * @param int $payment_id Payment ID. |
| 1580 | 1580 | */ |
| 1581 | - do_action( 'give_post_delete_payment_note', $comment_id, $payment_id ); |
|
| 1581 | + do_action('give_post_delete_payment_note', $comment_id, $payment_id); |
|
| 1582 | 1582 | |
| 1583 | 1583 | return $ret; |
| 1584 | 1584 | } |
@@ -1593,32 +1593,32 @@ discard block |
||
| 1593 | 1593 | * |
| 1594 | 1594 | * @return string |
| 1595 | 1595 | */ |
| 1596 | -function give_get_payment_note_html( $note, $payment_id = 0 ) { |
|
| 1596 | +function give_get_payment_note_html($note, $payment_id = 0) { |
|
| 1597 | 1597 | |
| 1598 | - if ( is_numeric( $note ) ) { |
|
| 1599 | - $note = get_comment( $note ); |
|
| 1598 | + if (is_numeric($note)) { |
|
| 1599 | + $note = get_comment($note); |
|
| 1600 | 1600 | } |
| 1601 | 1601 | |
| 1602 | - if ( ! empty( $note->user_id ) ) { |
|
| 1603 | - $user = get_userdata( $note->user_id ); |
|
| 1602 | + if ( ! empty($note->user_id)) { |
|
| 1603 | + $user = get_userdata($note->user_id); |
|
| 1604 | 1604 | $user = $user->display_name; |
| 1605 | 1605 | } else { |
| 1606 | - $user = esc_html__( 'System', 'give' ); |
|
| 1606 | + $user = esc_html__('System', 'give'); |
|
| 1607 | 1607 | } |
| 1608 | 1608 | |
| 1609 | - $date_format = give_date_format() . ', ' . get_option( 'time_format' ); |
|
| 1609 | + $date_format = give_date_format().', '.get_option('time_format'); |
|
| 1610 | 1610 | |
| 1611 | - $delete_note_url = wp_nonce_url( add_query_arg( array( |
|
| 1611 | + $delete_note_url = wp_nonce_url(add_query_arg(array( |
|
| 1612 | 1612 | 'give-action' => 'delete_payment_note', |
| 1613 | 1613 | 'note_id' => $note->comment_ID, |
| 1614 | 1614 | 'payment_id' => $payment_id, |
| 1615 | - ) ), 'give_delete_payment_note_' . $note->comment_ID ); |
|
| 1615 | + )), 'give_delete_payment_note_'.$note->comment_ID); |
|
| 1616 | 1616 | |
| 1617 | - $note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">'; |
|
| 1617 | + $note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">'; |
|
| 1618 | 1618 | $note_html .= '<p>'; |
| 1619 | - $note_html .= '<strong>' . $user . '</strong> – <span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>'; |
|
| 1619 | + $note_html .= '<strong>'.$user.'</strong> – <span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>'; |
|
| 1620 | 1620 | $note_html .= $note->comment_content; |
| 1621 | - $note_html .= ' – <a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . esc_attr__( 'Delete this donation note.', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>'; |
|
| 1621 | + $note_html .= ' – <a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.esc_attr__('Delete this donation note.', 'give').'">'.esc_html__('Delete', 'give').'</a>'; |
|
| 1622 | 1622 | $note_html .= '</p>'; |
| 1623 | 1623 | $note_html .= '</div>'; |
| 1624 | 1624 | |
@@ -1636,18 +1636,18 @@ discard block |
||
| 1636 | 1636 | * |
| 1637 | 1637 | * @return void |
| 1638 | 1638 | */ |
| 1639 | -function give_hide_payment_notes( $query ) { |
|
| 1640 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) { |
|
| 1641 | - $types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array(); |
|
| 1642 | - if ( ! is_array( $types ) ) { |
|
| 1643 | - $types = array( $types ); |
|
| 1639 | +function give_hide_payment_notes($query) { |
|
| 1640 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) { |
|
| 1641 | + $types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array(); |
|
| 1642 | + if ( ! is_array($types)) { |
|
| 1643 | + $types = array($types); |
|
| 1644 | 1644 | } |
| 1645 | 1645 | $types[] = 'give_payment_note'; |
| 1646 | 1646 | $query->query_vars['type__not_in'] = $types; |
| 1647 | 1647 | } |
| 1648 | 1648 | } |
| 1649 | 1649 | |
| 1650 | -add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
| 1650 | +add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
| 1651 | 1651 | |
| 1652 | 1652 | /** |
| 1653 | 1653 | * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets |
@@ -1659,15 +1659,15 @@ discard block |
||
| 1659 | 1659 | * |
| 1660 | 1660 | * @return array $clauses Updated comment clauses. |
| 1661 | 1661 | */ |
| 1662 | -function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) { |
|
| 1663 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) { |
|
| 1662 | +function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) { |
|
| 1663 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) { |
|
| 1664 | 1664 | $clauses['where'] .= ' AND comment_type != "give_payment_note"'; |
| 1665 | 1665 | } |
| 1666 | 1666 | |
| 1667 | 1667 | return $clauses; |
| 1668 | 1668 | } |
| 1669 | 1669 | |
| 1670 | -add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
| 1670 | +add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
| 1671 | 1671 | |
| 1672 | 1672 | |
| 1673 | 1673 | /** |
@@ -1680,15 +1680,15 @@ discard block |
||
| 1680 | 1680 | * |
| 1681 | 1681 | * @return string $where |
| 1682 | 1682 | */ |
| 1683 | -function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) { |
|
| 1683 | +function give_hide_payment_notes_from_feeds($where, $wp_comment_query) { |
|
| 1684 | 1684 | global $wpdb; |
| 1685 | 1685 | |
| 1686 | - $where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' ); |
|
| 1686 | + $where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note'); |
|
| 1687 | 1687 | |
| 1688 | 1688 | return $where; |
| 1689 | 1689 | } |
| 1690 | 1690 | |
| 1691 | -add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 ); |
|
| 1691 | +add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2); |
|
| 1692 | 1692 | |
| 1693 | 1693 | |
| 1694 | 1694 | /** |
@@ -1702,32 +1702,32 @@ discard block |
||
| 1702 | 1702 | * |
| 1703 | 1703 | * @return array Array of comment counts. |
| 1704 | 1704 | */ |
| 1705 | -function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) { |
|
| 1705 | +function give_remove_payment_notes_in_comment_counts($stats, $post_id) { |
|
| 1706 | 1706 | global $wpdb, $pagenow; |
| 1707 | 1707 | |
| 1708 | - if ( 'index.php' != $pagenow ) { |
|
| 1708 | + if ('index.php' != $pagenow) { |
|
| 1709 | 1709 | return $stats; |
| 1710 | 1710 | } |
| 1711 | 1711 | |
| 1712 | 1712 | $post_id = (int) $post_id; |
| 1713 | 1713 | |
| 1714 | - if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) { |
|
| 1714 | + if (apply_filters('give_count_payment_notes_in_comments', false)) { |
|
| 1715 | 1715 | return $stats; |
| 1716 | 1716 | } |
| 1717 | 1717 | |
| 1718 | - $stats = wp_cache_get( "comments-{$post_id}", 'counts' ); |
|
| 1718 | + $stats = wp_cache_get("comments-{$post_id}", 'counts'); |
|
| 1719 | 1719 | |
| 1720 | - if ( false !== $stats ) { |
|
| 1720 | + if (false !== $stats) { |
|
| 1721 | 1721 | return $stats; |
| 1722 | 1722 | } |
| 1723 | 1723 | |
| 1724 | 1724 | $where = 'WHERE comment_type != "give_payment_note"'; |
| 1725 | 1725 | |
| 1726 | - if ( $post_id > 0 ) { |
|
| 1727 | - $where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id ); |
|
| 1726 | + if ($post_id > 0) { |
|
| 1727 | + $where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id); |
|
| 1728 | 1728 | } |
| 1729 | 1729 | |
| 1730 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
| 1730 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
| 1731 | 1731 | |
| 1732 | 1732 | $total = 0; |
| 1733 | 1733 | $approved = array( |
@@ -1737,30 +1737,30 @@ discard block |
||
| 1737 | 1737 | 'trash' => 'trash', |
| 1738 | 1738 | 'post-trashed' => 'post-trashed', |
| 1739 | 1739 | ); |
| 1740 | - foreach ( (array) $count as $row ) { |
|
| 1740 | + foreach ((array) $count as $row) { |
|
| 1741 | 1741 | // Don't count post-trashed toward totals. |
| 1742 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { |
|
| 1742 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) { |
|
| 1743 | 1743 | $total += $row['num_comments']; |
| 1744 | 1744 | } |
| 1745 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
| 1746 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
| 1745 | + if (isset($approved[$row['comment_approved']])) { |
|
| 1746 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
| 1747 | 1747 | } |
| 1748 | 1748 | } |
| 1749 | 1749 | |
| 1750 | 1750 | $stats['total_comments'] = $total; |
| 1751 | - foreach ( $approved as $key ) { |
|
| 1752 | - if ( empty( $stats[ $key ] ) ) { |
|
| 1753 | - $stats[ $key ] = 0; |
|
| 1751 | + foreach ($approved as $key) { |
|
| 1752 | + if (empty($stats[$key])) { |
|
| 1753 | + $stats[$key] = 0; |
|
| 1754 | 1754 | } |
| 1755 | 1755 | } |
| 1756 | 1756 | |
| 1757 | 1757 | $stats = (object) $stats; |
| 1758 | - wp_cache_set( "comments-{$post_id}", $stats, 'counts' ); |
|
| 1758 | + wp_cache_set("comments-{$post_id}", $stats, 'counts'); |
|
| 1759 | 1759 | |
| 1760 | 1760 | return $stats; |
| 1761 | 1761 | } |
| 1762 | 1762 | |
| 1763 | -add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 ); |
|
| 1763 | +add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2); |
|
| 1764 | 1764 | |
| 1765 | 1765 | |
| 1766 | 1766 | /** |
@@ -1773,9 +1773,9 @@ discard block |
||
| 1773 | 1773 | * |
| 1774 | 1774 | * @return string $where Modified where clause. |
| 1775 | 1775 | */ |
| 1776 | -function give_filter_where_older_than_week( $where = '' ) { |
|
| 1776 | +function give_filter_where_older_than_week($where = '') { |
|
| 1777 | 1777 | // Payments older than one week. |
| 1778 | - $start = date( 'Y-m-d', strtotime( '-7 days' ) ); |
|
| 1778 | + $start = date('Y-m-d', strtotime('-7 days')); |
|
| 1779 | 1779 | $where .= " AND post_date <= '{$start}'"; |
| 1780 | 1780 | |
| 1781 | 1781 | return $where; |
@@ -1795,38 +1795,38 @@ discard block |
||
| 1795 | 1795 | * |
| 1796 | 1796 | * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title. |
| 1797 | 1797 | */ |
| 1798 | -function give_get_payment_form_title( $payment_meta, $only_level = false, $separator = '' ) { |
|
| 1798 | +function give_get_payment_form_title($payment_meta, $only_level = false, $separator = '') { |
|
| 1799 | 1799 | |
| 1800 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
| 1801 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
| 1802 | - $form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : ''; |
|
| 1800 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
| 1801 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
| 1802 | + $form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : ''; |
|
| 1803 | 1803 | |
| 1804 | - if ( $only_level == true ) { |
|
| 1804 | + if ($only_level == true) { |
|
| 1805 | 1805 | $form_title = ''; |
| 1806 | 1806 | } |
| 1807 | 1807 | |
| 1808 | 1808 | // If multi-level, append to the form title. |
| 1809 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 1809 | + if (give_has_variable_prices($form_id)) { |
|
| 1810 | 1810 | |
| 1811 | 1811 | // Only add separator if there is a form title. |
| 1812 | - if ( ! empty( $form_title ) ) { |
|
| 1813 | - $form_title .= ' ' . $separator . ' '; |
|
| 1812 | + if ( ! empty($form_title)) { |
|
| 1813 | + $form_title .= ' '.$separator.' '; |
|
| 1814 | 1814 | } |
| 1815 | 1815 | |
| 1816 | 1816 | $form_title .= '<span class="donation-level-text-wrap">'; |
| 1817 | 1817 | |
| 1818 | - if ( $price_id == 'custom' ) { |
|
| 1819 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 1820 | - $form_title .= ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' ); |
|
| 1818 | + if ($price_id == 'custom') { |
|
| 1819 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
| 1820 | + $form_title .= ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give'); |
|
| 1821 | 1821 | } else { |
| 1822 | - $form_title .= give_get_price_option_name( $form_id, $price_id ); |
|
| 1822 | + $form_title .= give_get_price_option_name($form_id, $price_id); |
|
| 1823 | 1823 | } |
| 1824 | 1824 | |
| 1825 | 1825 | $form_title .= '</span>'; |
| 1826 | 1826 | |
| 1827 | 1827 | } |
| 1828 | 1828 | |
| 1829 | - return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta ); |
|
| 1829 | + return apply_filters('give_get_payment_form_title', $form_title, $payment_meta); |
|
| 1830 | 1830 | |
| 1831 | 1831 | } |
| 1832 | 1832 | |
@@ -1840,19 +1840,19 @@ discard block |
||
| 1840 | 1840 | * |
| 1841 | 1841 | * @return string $price_id |
| 1842 | 1842 | */ |
| 1843 | -function give_get_price_id( $form_id, $price ) { |
|
| 1843 | +function give_get_price_id($form_id, $price) { |
|
| 1844 | 1844 | $price_id = null; |
| 1845 | 1845 | |
| 1846 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 1846 | + if (give_has_variable_prices($form_id)) { |
|
| 1847 | 1847 | |
| 1848 | - $levels = give_get_meta( $form_id, '_give_donation_levels', true ); |
|
| 1848 | + $levels = give_get_meta($form_id, '_give_donation_levels', true); |
|
| 1849 | 1849 | |
| 1850 | - foreach ( $levels as $level ) { |
|
| 1850 | + foreach ($levels as $level) { |
|
| 1851 | 1851 | |
| 1852 | - $level_amount = give_maybe_sanitize_amount( $level['_give_amount'] ); |
|
| 1852 | + $level_amount = give_maybe_sanitize_amount($level['_give_amount']); |
|
| 1853 | 1853 | |
| 1854 | 1854 | // Check that this indeed the recurring price. |
| 1855 | - if ( $level_amount == $price ) { |
|
| 1855 | + if ($level_amount == $price) { |
|
| 1856 | 1856 | |
| 1857 | 1857 | $price_id = $level['_give_id']['level_id']; |
| 1858 | 1858 | break; |
@@ -1860,13 +1860,13 @@ discard block |
||
| 1860 | 1860 | } |
| 1861 | 1861 | } |
| 1862 | 1862 | |
| 1863 | - if( is_null( $price_id ) && give_is_custom_price_mode( $form_id ) ) { |
|
| 1863 | + if (is_null($price_id) && give_is_custom_price_mode($form_id)) { |
|
| 1864 | 1864 | $price_id = 'custom'; |
| 1865 | 1865 | } |
| 1866 | 1866 | } |
| 1867 | 1867 | |
| 1868 | 1868 | // Price ID must be numeric or string. |
| 1869 | - $price_id = ! is_numeric( $price_id ) && ! is_string( $price_id ) ? 0 : $price_id; |
|
| 1869 | + $price_id = ! is_numeric($price_id) && ! is_string($price_id) ? 0 : $price_id; |
|
| 1870 | 1870 | |
| 1871 | 1871 | return $price_id; |
| 1872 | 1872 | } |
@@ -1884,10 +1884,10 @@ discard block |
||
| 1884 | 1884 | * |
| 1885 | 1885 | * @return string |
| 1886 | 1886 | */ |
| 1887 | -function give_get_form_dropdown( $args = array(), $echo = false ) { |
|
| 1888 | - $form_dropdown_html = Give()->html->forms_dropdown( $args ); |
|
| 1887 | +function give_get_form_dropdown($args = array(), $echo = false) { |
|
| 1888 | + $form_dropdown_html = Give()->html->forms_dropdown($args); |
|
| 1889 | 1889 | |
| 1890 | - if ( ! $echo ) { |
|
| 1890 | + if ( ! $echo) { |
|
| 1891 | 1891 | return $form_dropdown_html; |
| 1892 | 1892 | } |
| 1893 | 1893 | |
@@ -1904,17 +1904,17 @@ discard block |
||
| 1904 | 1904 | * |
| 1905 | 1905 | * @return string|bool |
| 1906 | 1906 | */ |
| 1907 | -function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) { |
|
| 1907 | +function give_get_form_variable_price_dropdown($args = array(), $echo = false) { |
|
| 1908 | 1908 | |
| 1909 | 1909 | // Check for give form id. |
| 1910 | - if ( empty( $args['id'] ) ) { |
|
| 1910 | + if (empty($args['id'])) { |
|
| 1911 | 1911 | return false; |
| 1912 | 1912 | } |
| 1913 | 1913 | |
| 1914 | - $form = new Give_Donate_Form( $args['id'] ); |
|
| 1914 | + $form = new Give_Donate_Form($args['id']); |
|
| 1915 | 1915 | |
| 1916 | 1916 | // Check if form has variable prices or not. |
| 1917 | - if ( ! $form->ID || ! $form->has_variable_prices() ) { |
|
| 1917 | + if ( ! $form->ID || ! $form->has_variable_prices()) { |
|
| 1918 | 1918 | return false; |
| 1919 | 1919 | } |
| 1920 | 1920 | |
@@ -1922,24 +1922,24 @@ discard block |
||
| 1922 | 1922 | $variable_price_options = array(); |
| 1923 | 1923 | |
| 1924 | 1924 | // Check if multi donation form support custom donation or not. |
| 1925 | - if ( $form->is_custom_price_mode() ) { |
|
| 1926 | - $variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' ); |
|
| 1925 | + if ($form->is_custom_price_mode()) { |
|
| 1926 | + $variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give'); |
|
| 1927 | 1927 | } |
| 1928 | 1928 | |
| 1929 | 1929 | // Get variable price and ID from variable price array. |
| 1930 | - foreach ( $variable_prices as $variable_price ) { |
|
| 1931 | - $variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) ) ); |
|
| 1930 | + foreach ($variable_prices as $variable_price) { |
|
| 1931 | + $variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount'], array('sanitize' => false))); |
|
| 1932 | 1932 | } |
| 1933 | 1933 | |
| 1934 | 1934 | // Update options. |
| 1935 | - $args = array_merge( $args, array( |
|
| 1935 | + $args = array_merge($args, array( |
|
| 1936 | 1936 | 'options' => $variable_price_options, |
| 1937 | - ) ); |
|
| 1937 | + )); |
|
| 1938 | 1938 | |
| 1939 | 1939 | // Generate select html. |
| 1940 | - $form_dropdown_html = Give()->html->select( $args ); |
|
| 1940 | + $form_dropdown_html = Give()->html->select($args); |
|
| 1941 | 1941 | |
| 1942 | - if ( ! $echo ) { |
|
| 1942 | + if ( ! $echo) { |
|
| 1943 | 1943 | return $form_dropdown_html; |
| 1944 | 1944 | } |
| 1945 | 1945 | |
@@ -1958,16 +1958,16 @@ discard block |
||
| 1958 | 1958 | * |
| 1959 | 1959 | * @return string |
| 1960 | 1960 | */ |
| 1961 | -function give_get_payment_meta_price_id( $payment_meta ) { |
|
| 1961 | +function give_get_payment_meta_price_id($payment_meta) { |
|
| 1962 | 1962 | |
| 1963 | - if ( isset( $payment_meta['give_price_id'] ) ) { |
|
| 1963 | + if (isset($payment_meta['give_price_id'])) { |
|
| 1964 | 1964 | $price_id = $payment_meta['give_price_id']; |
| 1965 | - } elseif ( isset( $payment_meta['price_id'] ) ) { |
|
| 1965 | + } elseif (isset($payment_meta['price_id'])) { |
|
| 1966 | 1966 | $price_id = $payment_meta['price_id']; |
| 1967 | 1967 | } else { |
| 1968 | - $price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] ); |
|
| 1968 | + $price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']); |
|
| 1969 | 1969 | } |
| 1970 | 1970 | |
| 1971 | - return apply_filters( 'give_get_payment_meta_price_id', $price_id ); |
|
| 1971 | + return apply_filters('give_get_payment_meta_price_id', $price_id); |
|
| 1972 | 1972 | |
| 1973 | 1973 | } |
@@ -671,7 +671,7 @@ |
||
| 671 | 671 | /** |
| 672 | 672 | * This function will check whether the donor email is primary or additional. |
| 673 | 673 | * |
| 674 | - * @param $email Donor Email. |
|
| 674 | + * @param string $email Donor Email. |
|
| 675 | 675 | * |
| 676 | 676 | * @since 1.8.13 |
| 677 | 677 | * |
@@ -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 | |
@@ -30,54 +30,54 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return bool|array List of all user donations. |
| 32 | 32 | */ |
| 33 | -function give_get_users_donations( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
| 33 | +function give_get_users_donations($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
| 34 | 34 | |
| 35 | - if ( empty( $user ) ) { |
|
| 35 | + if (empty($user)) { |
|
| 36 | 36 | $user = get_current_user_id(); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if ( 0 === $user && ! Give()->email_access->token_exists ) { |
|
| 39 | + if (0 === $user && ! Give()->email_access->token_exists) { |
|
| 40 | 40 | return false; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | $status = $status === 'complete' ? 'publish' : $status; |
| 44 | 44 | $paged = 1; |
| 45 | 45 | |
| 46 | - if ( $pagination ) { |
|
| 47 | - if ( get_query_var( 'paged' ) ) { |
|
| 48 | - $paged = get_query_var( 'paged' ); |
|
| 49 | - } elseif ( get_query_var( 'page' ) ) { |
|
| 50 | - $paged = get_query_var( 'page' ); |
|
| 46 | + if ($pagination) { |
|
| 47 | + if (get_query_var('paged')) { |
|
| 48 | + $paged = get_query_var('paged'); |
|
| 49 | + } elseif (get_query_var('page')) { |
|
| 50 | + $paged = get_query_var('page'); |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $args = apply_filters( 'give_get_users_donations_args', array( |
|
| 54 | + $args = apply_filters('give_get_users_donations_args', array( |
|
| 55 | 55 | 'user' => $user, |
| 56 | 56 | 'number' => $number, |
| 57 | 57 | 'status' => $status, |
| 58 | 58 | 'orderby' => 'date', |
| 59 | - ) ); |
|
| 59 | + )); |
|
| 60 | 60 | |
| 61 | - if ( $pagination ) { |
|
| 61 | + if ($pagination) { |
|
| 62 | 62 | $args['page'] = $paged; |
| 63 | 63 | } else { |
| 64 | 64 | $args['nopaging'] = true; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
| 68 | - $donor = new Give_Donor( $user, $by_user_id ); |
|
| 67 | + $by_user_id = is_numeric($user) ? true : false; |
|
| 68 | + $donor = new Give_Donor($user, $by_user_id); |
|
| 69 | 69 | |
| 70 | - if ( ! empty( $donor->payment_ids ) ) { |
|
| 70 | + if ( ! empty($donor->payment_ids)) { |
|
| 71 | 71 | |
| 72 | - unset( $args['user'] ); |
|
| 73 | - $args['post__in'] = array_map( 'absint', explode( ',', $donor->payment_ids ) ); |
|
| 72 | + unset($args['user']); |
|
| 73 | + $args['post__in'] = array_map('absint', explode(',', $donor->payment_ids)); |
|
| 74 | 74 | |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - $donations = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) ); |
|
| 77 | + $donations = give_get_payments(apply_filters('give_get_users_donations_args', $args)); |
|
| 78 | 78 | |
| 79 | 79 | // No donations |
| 80 | - if ( ! $donations ) { |
|
| 80 | + if ( ! $donations) { |
|
| 81 | 81 | return false; |
| 82 | 82 | } |
| 83 | 83 | |
@@ -96,65 +96,65 @@ discard block |
||
| 96 | 96 | * |
| 97 | 97 | * @return bool|object List of unique forms donated by user |
| 98 | 98 | */ |
| 99 | -function give_get_users_completed_donations( $user = 0, $status = 'complete' ) { |
|
| 100 | - if ( empty( $user ) ) { |
|
| 99 | +function give_get_users_completed_donations($user = 0, $status = 'complete') { |
|
| 100 | + if (empty($user)) { |
|
| 101 | 101 | $user = get_current_user_id(); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - if ( empty( $user ) ) { |
|
| 104 | + if (empty($user)) { |
|
| 105 | 105 | return false; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
| 108 | + $by_user_id = is_numeric($user) ? true : false; |
|
| 109 | 109 | |
| 110 | - $donor = new Give_Donor( $user, $by_user_id ); |
|
| 110 | + $donor = new Give_Donor($user, $by_user_id); |
|
| 111 | 111 | |
| 112 | - if ( empty( $donor->payment_ids ) ) { |
|
| 112 | + if (empty($donor->payment_ids)) { |
|
| 113 | 113 | return false; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | // Get all the items donated. |
| 117 | - $payment_ids = array_reverse( explode( ',', $donor->payment_ids ) ); |
|
| 118 | - $limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 ); |
|
| 119 | - if ( ! empty( $limit_payments ) ) { |
|
| 120 | - $payment_ids = array_slice( $payment_ids, 0, $limit_payments ); |
|
| 117 | + $payment_ids = array_reverse(explode(',', $donor->payment_ids)); |
|
| 118 | + $limit_payments = apply_filters('give_users_completed_donations_payments', 50); |
|
| 119 | + if ( ! empty($limit_payments)) { |
|
| 120 | + $payment_ids = array_slice($payment_ids, 0, $limit_payments); |
|
| 121 | 121 | } |
| 122 | 122 | $donation_data = array(); |
| 123 | - foreach ( $payment_ids as $payment_id ) { |
|
| 124 | - $donation_data[] = give_get_payment_meta( $payment_id ); |
|
| 123 | + foreach ($payment_ids as $payment_id) { |
|
| 124 | + $donation_data[] = give_get_payment_meta($payment_id); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - if ( empty( $donation_data ) ) { |
|
| 127 | + if (empty($donation_data)) { |
|
| 128 | 128 | return false; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | // Grab only the post ids "form_id" of the forms donated on this order |
| 132 | 132 | $completed_donations_ids = array(); |
| 133 | - foreach ( $donation_data as $donation_meta ) { |
|
| 134 | - $completed_donations_ids[] = isset( $donation_meta['form_id'] ) ? $donation_meta['form_id'] : ''; |
|
| 133 | + foreach ($donation_data as $donation_meta) { |
|
| 134 | + $completed_donations_ids[] = isset($donation_meta['form_id']) ? $donation_meta['form_id'] : ''; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - if ( empty( $completed_donations_ids ) ) { |
|
| 137 | + if (empty($completed_donations_ids)) { |
|
| 138 | 138 | return false; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | // Only include each donation once |
| 142 | - $form_ids = array_unique( $completed_donations_ids ); |
|
| 142 | + $form_ids = array_unique($completed_donations_ids); |
|
| 143 | 143 | |
| 144 | 144 | // Make sure we still have some products and a first item |
| 145 | - if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) { |
|
| 145 | + if (empty($form_ids) || ! isset($form_ids[0])) { |
|
| 146 | 146 | return false; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - $post_type = get_post_type( $form_ids[0] ); |
|
| 149 | + $post_type = get_post_type($form_ids[0]); |
|
| 150 | 150 | |
| 151 | - $args = apply_filters( 'give_get_users_completed_donations_args', array( |
|
| 151 | + $args = apply_filters('give_get_users_completed_donations_args', array( |
|
| 152 | 152 | 'include' => $form_ids, |
| 153 | 153 | 'post_type' => $post_type, |
| 154 | - 'posts_per_page' => - 1, |
|
| 155 | - ) ); |
|
| 154 | + 'posts_per_page' => -1, |
|
| 155 | + )); |
|
| 156 | 156 | |
| 157 | - return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) ); |
|
| 157 | + return apply_filters('give_users_completed_donations_list', get_posts($args)); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | |
@@ -170,12 +170,12 @@ discard block |
||
| 170 | 170 | * |
| 171 | 171 | * @return bool True if has donated, false other wise. |
| 172 | 172 | */ |
| 173 | -function give_has_donations( $user_id = null ) { |
|
| 174 | - if ( empty( $user_id ) ) { |
|
| 173 | +function give_has_donations($user_id = null) { |
|
| 174 | + if (empty($user_id)) { |
|
| 175 | 175 | $user_id = get_current_user_id(); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - if ( give_get_users_donations( $user_id, 1 ) ) { |
|
| 178 | + if (give_get_users_donations($user_id, 1)) { |
|
| 179 | 179 | return true; // User has at least one donation. |
| 180 | 180 | } |
| 181 | 181 | |
@@ -196,23 +196,23 @@ discard block |
||
| 196 | 196 | * |
| 197 | 197 | * @return array |
| 198 | 198 | */ |
| 199 | -function give_get_donation_stats_by_user( $user = '' ) { |
|
| 199 | +function give_get_donation_stats_by_user($user = '') { |
|
| 200 | 200 | |
| 201 | 201 | $field = ''; |
| 202 | 202 | |
| 203 | - if ( is_email( $user ) ) { |
|
| 203 | + if (is_email($user)) { |
|
| 204 | 204 | $field = 'email'; |
| 205 | - } elseif ( is_numeric( $user ) ) { |
|
| 205 | + } elseif (is_numeric($user)) { |
|
| 206 | 206 | $field = 'user_id'; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - $stats = array(); |
|
| 210 | - $donor = Give()->donors->get_donor_by( $field, $user ); |
|
| 209 | + $stats = array(); |
|
| 210 | + $donor = Give()->donors->get_donor_by($field, $user); |
|
| 211 | 211 | |
| 212 | - if ( $donor ) { |
|
| 213 | - $donor = new Give_Donor( $donor->id ); |
|
| 214 | - $stats['purchases'] = absint( $donor->purchase_count ); |
|
| 215 | - $stats['total_spent'] = give_maybe_sanitize_amount( $donor->purchase_value ); |
|
| 212 | + if ($donor) { |
|
| 213 | + $donor = new Give_Donor($donor->id); |
|
| 214 | + $stats['purchases'] = absint($donor->purchase_count); |
|
| 215 | + $stats['total_spent'] = give_maybe_sanitize_amount($donor->purchase_value); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * |
| 221 | 221 | * @since 1.7 |
| 222 | 222 | */ |
| 223 | - $stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user ); |
|
| 223 | + $stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user); |
|
| 224 | 224 | |
| 225 | 225 | return $stats; |
| 226 | 226 | } |
@@ -238,21 +238,21 @@ discard block |
||
| 238 | 238 | * |
| 239 | 239 | * @return int The total number of donations. |
| 240 | 240 | */ |
| 241 | -function give_count_donations_of_donor( $user = null ) { |
|
| 241 | +function give_count_donations_of_donor($user = null) { |
|
| 242 | 242 | |
| 243 | 243 | // Logged in? |
| 244 | - if ( empty( $user ) ) { |
|
| 244 | + if (empty($user)) { |
|
| 245 | 245 | $user = get_current_user_id(); |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | // Email access? |
| 249 | - if ( empty( $user ) && Give()->email_access->token_email ) { |
|
| 249 | + if (empty($user) && Give()->email_access->token_email) { |
|
| 250 | 250 | $user = Give()->email_access->token_email; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - $stats = ! empty( $user ) ? give_get_donation_stats_by_user( $user ) : false; |
|
| 253 | + $stats = ! empty($user) ? give_get_donation_stats_by_user($user) : false; |
|
| 254 | 254 | |
| 255 | - return isset( $stats['purchases'] ) ? $stats['purchases'] : 0; |
|
| 255 | + return isset($stats['purchases']) ? $stats['purchases'] : 0; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /** |
@@ -265,9 +265,9 @@ discard block |
||
| 265 | 265 | * |
| 266 | 266 | * @return float The total amount the user has spent |
| 267 | 267 | */ |
| 268 | -function give_donation_total_of_user( $user = null ) { |
|
| 268 | +function give_donation_total_of_user($user = null) { |
|
| 269 | 269 | |
| 270 | - $stats = give_get_donation_stats_by_user( $user ); |
|
| 270 | + $stats = give_get_donation_stats_by_user($user); |
|
| 271 | 271 | |
| 272 | 272 | return $stats['total_spent']; |
| 273 | 273 | } |
@@ -283,40 +283,40 @@ discard block |
||
| 283 | 283 | * |
| 284 | 284 | * @return bool |
| 285 | 285 | */ |
| 286 | -function give_validate_username( $username, $form_id = 0 ) { |
|
| 286 | +function give_validate_username($username, $form_id = 0) { |
|
| 287 | 287 | $valid = true; |
| 288 | 288 | |
| 289 | 289 | // Validate username. |
| 290 | - if ( ! empty( $username ) ) { |
|
| 290 | + if ( ! empty($username)) { |
|
| 291 | 291 | |
| 292 | 292 | // Sanitize username. |
| 293 | - $sanitized_user_name = sanitize_user( $username, false ); |
|
| 293 | + $sanitized_user_name = sanitize_user($username, false); |
|
| 294 | 294 | |
| 295 | 295 | // We have an user name, check if it already exists. |
| 296 | - if ( username_exists( $username ) ) { |
|
| 296 | + if (username_exists($username)) { |
|
| 297 | 297 | // Username already registered. |
| 298 | - give_set_error( 'username_unavailable', __( 'Username already taken.', 'give' ) ); |
|
| 298 | + give_set_error('username_unavailable', __('Username already taken.', 'give')); |
|
| 299 | 299 | $valid = false; |
| 300 | 300 | |
| 301 | 301 | // Check if it's valid. |
| 302 | - } elseif ( $sanitized_user_name !== $username ) { |
|
| 302 | + } elseif ($sanitized_user_name !== $username) { |
|
| 303 | 303 | // Invalid username. |
| 304 | - if ( is_multisite() ) { |
|
| 305 | - give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) ); |
|
| 304 | + if (is_multisite()) { |
|
| 305 | + give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give')); |
|
| 306 | 306 | $valid = false; |
| 307 | 307 | } else { |
| 308 | - give_set_error( 'username_invalid', __( 'Invalid username.', 'give' ) ); |
|
| 308 | + give_set_error('username_invalid', __('Invalid username.', 'give')); |
|
| 309 | 309 | $valid = false; |
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | } else { |
| 313 | 313 | // Username is empty. |
| 314 | - give_set_error( 'username_empty', __( 'Enter a username.', 'give' ) ); |
|
| 314 | + give_set_error('username_empty', __('Enter a username.', 'give')); |
|
| 315 | 315 | $valid = false; |
| 316 | 316 | |
| 317 | 317 | // Check if guest checkout is disable for form. |
| 318 | - if ( $form_id && give_logged_in_only( $form_id ) ) { |
|
| 319 | - give_set_error( 'registration_required', __( 'You must register or login to complete your donation.', 'give' ) ); |
|
| 318 | + if ($form_id && give_logged_in_only($form_id)) { |
|
| 319 | + give_set_error('registration_required', __('You must register or login to complete your donation.', 'give')); |
|
| 320 | 320 | $valid = false; |
| 321 | 321 | } |
| 322 | 322 | } |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | * @param string $username |
| 331 | 331 | * @param bool $form_id |
| 332 | 332 | */ |
| 333 | - $valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id ); |
|
| 333 | + $valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id); |
|
| 334 | 334 | |
| 335 | 335 | return $valid; |
| 336 | 336 | } |
@@ -346,25 +346,25 @@ discard block |
||
| 346 | 346 | * |
| 347 | 347 | * @return bool |
| 348 | 348 | */ |
| 349 | -function give_validate_user_email( $email, $registering_new_user = false ) { |
|
| 349 | +function give_validate_user_email($email, $registering_new_user = false) { |
|
| 350 | 350 | $valid = true; |
| 351 | 351 | |
| 352 | - if ( empty( $email ) ) { |
|
| 352 | + if (empty($email)) { |
|
| 353 | 353 | // No email. |
| 354 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); |
|
| 354 | + give_set_error('email_empty', __('Enter an email.', 'give')); |
|
| 355 | 355 | $valid = false; |
| 356 | 356 | |
| 357 | - } elseif ( ! is_email( $email ) ) { |
|
| 357 | + } elseif ( ! is_email($email)) { |
|
| 358 | 358 | // Validate email. |
| 359 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
| 359 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
| 360 | 360 | $valid = false; |
| 361 | 361 | |
| 362 | - } elseif ( $registering_new_user ) { |
|
| 362 | + } elseif ($registering_new_user) { |
|
| 363 | 363 | |
| 364 | 364 | // If donor email is not primary |
| 365 | - if ( ! email_exists( $email ) && give_donor_email_exists( $email ) && give_is_additional_email( $email ) ) { |
|
| 365 | + if ( ! email_exists($email) && give_donor_email_exists($email) && give_is_additional_email($email)) { |
|
| 366 | 366 | // Check if email exists. |
| 367 | - give_set_error( 'email_used', __( 'The email address provided is already active for another user.', 'give' ) ); |
|
| 367 | + give_set_error('email_used', __('The email address provided is already active for another user.', 'give')); |
|
| 368 | 368 | $valid = false; |
| 369 | 369 | } |
| 370 | 370 | } |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | * @param string $email |
| 379 | 379 | * @param bool $registering_new_user |
| 380 | 380 | */ |
| 381 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user ); |
|
| 381 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user); |
|
| 382 | 382 | |
| 383 | 383 | return $valid; |
| 384 | 384 | } |
@@ -394,34 +394,34 @@ discard block |
||
| 394 | 394 | * |
| 395 | 395 | * @return bool |
| 396 | 396 | */ |
| 397 | -function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) { |
|
| 397 | +function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) { |
|
| 398 | 398 | $valid = true; |
| 399 | 399 | |
| 400 | 400 | // Passwords Validation For New Donors Only |
| 401 | - if ( $registering_new_user ) { |
|
| 401 | + if ($registering_new_user) { |
|
| 402 | 402 | // Password or confirmation missing. |
| 403 | - if ( ! $password ) { |
|
| 403 | + if ( ! $password) { |
|
| 404 | 404 | // The password is invalid. |
| 405 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
| 405 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
| 406 | 406 | $valid = false; |
| 407 | - } elseif ( ! $confirm_password ) { |
|
| 407 | + } elseif ( ! $confirm_password) { |
|
| 408 | 408 | // Confirmation password is invalid. |
| 409 | - give_set_error( 'confirmation_empty', __( 'Enter the password confirmation.', 'give' ) ); |
|
| 409 | + give_set_error('confirmation_empty', __('Enter the password confirmation.', 'give')); |
|
| 410 | 410 | $valid = false; |
| 411 | 411 | } |
| 412 | 412 | } |
| 413 | 413 | // Passwords Validation For New Donors as well as Existing Donors |
| 414 | - if ( $password || $confirm_password ) { |
|
| 415 | - if ( strlen( $password ) < 6 || strlen( $confirm_password ) < 6 ) { |
|
| 414 | + if ($password || $confirm_password) { |
|
| 415 | + if (strlen($password) < 6 || strlen($confirm_password) < 6) { |
|
| 416 | 416 | // Seems Weak Password |
| 417 | - give_set_error( 'password_weak', __( 'Passwords should have at least 6 characters.', 'give' ) ); |
|
| 417 | + give_set_error('password_weak', __('Passwords should have at least 6 characters.', 'give')); |
|
| 418 | 418 | $valid = false; |
| 419 | 419 | } |
| 420 | - if ( $password && $confirm_password ) { |
|
| 420 | + if ($password && $confirm_password) { |
|
| 421 | 421 | // Verify confirmation matches. |
| 422 | - if ( $password != $confirm_password ) { |
|
| 422 | + if ($password != $confirm_password) { |
|
| 423 | 423 | // Passwords do not match |
| 424 | - give_set_error( 'password_mismatch', __( 'Passwords you entered do not match. Please try again.', 'give' ) ); |
|
| 424 | + give_set_error('password_mismatch', __('Passwords you entered do not match. Please try again.', 'give')); |
|
| 425 | 425 | $valid = false; |
| 426 | 426 | } |
| 427 | 427 | } |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | * @param string $confirm_password |
| 438 | 438 | * @param bool $registering_new_user |
| 439 | 439 | */ |
| 440 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user ); |
|
| 440 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user); |
|
| 441 | 441 | |
| 442 | 442 | return $valid; |
| 443 | 443 | } |
@@ -455,19 +455,19 @@ discard block |
||
| 455 | 455 | * |
| 456 | 456 | * @return void |
| 457 | 457 | */ |
| 458 | -function give_add_past_donations_to_new_user( $user_id ) { |
|
| 458 | +function give_add_past_donations_to_new_user($user_id) { |
|
| 459 | 459 | |
| 460 | - $email = get_the_author_meta( 'user_email', $user_id ); |
|
| 460 | + $email = get_the_author_meta('user_email', $user_id); |
|
| 461 | 461 | |
| 462 | - $payments = give_get_payments( array( |
|
| 462 | + $payments = give_get_payments(array( |
|
| 463 | 463 | 's' => $email, |
| 464 | - ) ); |
|
| 464 | + )); |
|
| 465 | 465 | |
| 466 | - if ( $payments ) { |
|
| 467 | - foreach ( $payments as $payment ) { |
|
| 466 | + if ($payments) { |
|
| 467 | + foreach ($payments as $payment) { |
|
| 468 | 468 | /* @var $payment \Give_Payment */ |
| 469 | 469 | |
| 470 | - if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) { |
|
| 470 | + if (intval(give_get_payment_user_id($payment->ID)) > 0) { |
|
| 471 | 471 | continue; |
| 472 | 472 | } |
| 473 | 473 | |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | -add_action( 'user_register', 'give_add_past_donations_to_new_user' ); |
|
| 482 | +add_action('user_register', 'give_add_past_donations_to_new_user'); |
|
| 483 | 483 | |
| 484 | 484 | |
| 485 | 485 | /** |
@@ -505,34 +505,34 @@ discard block |
||
| 505 | 505 | * |
| 506 | 506 | * @return array The donor's address, if any |
| 507 | 507 | */ |
| 508 | -function give_get_donor_address( $user_id = 0 ) { |
|
| 509 | - if ( empty( $user_id ) ) { |
|
| 508 | +function give_get_donor_address($user_id = 0) { |
|
| 509 | + if (empty($user_id)) { |
|
| 510 | 510 | $user_id = get_current_user_id(); |
| 511 | 511 | } |
| 512 | 512 | |
| 513 | - $address = get_user_meta( $user_id, '_give_user_address', true ); |
|
| 513 | + $address = get_user_meta($user_id, '_give_user_address', true); |
|
| 514 | 514 | |
| 515 | - if ( ! isset( $address['line1'] ) ) { |
|
| 515 | + if ( ! isset($address['line1'])) { |
|
| 516 | 516 | $address['line1'] = ''; |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - if ( ! isset( $address['line2'] ) ) { |
|
| 519 | + if ( ! isset($address['line2'])) { |
|
| 520 | 520 | $address['line2'] = ''; |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | - if ( ! isset( $address['city'] ) ) { |
|
| 523 | + if ( ! isset($address['city'])) { |
|
| 524 | 524 | $address['city'] = ''; |
| 525 | 525 | } |
| 526 | 526 | |
| 527 | - if ( ! isset( $address['zip'] ) ) { |
|
| 527 | + if ( ! isset($address['zip'])) { |
|
| 528 | 528 | $address['zip'] = ''; |
| 529 | 529 | } |
| 530 | 530 | |
| 531 | - if ( ! isset( $address['country'] ) ) { |
|
| 531 | + if ( ! isset($address['country'])) { |
|
| 532 | 532 | $address['country'] = ''; |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | - if ( ! isset( $address['state'] ) ) { |
|
| 535 | + if ( ! isset($address['state'])) { |
|
| 536 | 536 | $address['state'] = ''; |
| 537 | 537 | } |
| 538 | 538 | |
@@ -552,53 +552,53 @@ discard block |
||
| 552 | 552 | * |
| 553 | 553 | * @return void |
| 554 | 554 | */ |
| 555 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { |
|
| 555 | +function give_new_user_notification($user_id = 0, $user_data = array()) { |
|
| 556 | 556 | |
| 557 | - if ( empty( $user_id ) || empty( $user_data ) ) { |
|
| 557 | + if (empty($user_id) || empty($user_data)) { |
|
| 558 | 558 | return; |
| 559 | 559 | } |
| 560 | - $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
| 560 | + $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
| 561 | 561 | |
| 562 | 562 | // New User Registration: Email sends to the site admin. |
| 563 | 563 | $emails = Give()->emails; |
| 564 | - $emails->__set( 'heading', esc_html__( 'New User Registration', 'give' ) ); |
|
| 564 | + $emails->__set('heading', esc_html__('New User Registration', 'give')); |
|
| 565 | 565 | |
| 566 | 566 | /* translators: %s: site name */ |
| 567 | - $message = sprintf( esc_attr__( 'A new user has registered on %s:', 'give' ), $blogname ) . "\r\n\r\n"; |
|
| 567 | + $message = sprintf(esc_attr__('A new user has registered on %s:', 'give'), $blogname)."\r\n\r\n"; |
|
| 568 | 568 | /* translators: %s: user login */ |
| 569 | - $message .= '<strong>' . esc_attr__( 'Username:', 'give' ) . '</strong> ' . $user_data['user_login'] . "\r\n"; |
|
| 569 | + $message .= '<strong>'.esc_attr__('Username:', 'give').'</strong> '.$user_data['user_login']."\r\n"; |
|
| 570 | 570 | /* translators: %s: user email */ |
| 571 | - $message .= '<strong>' . esc_attr__( 'E-mail:', 'give' ) . '</strong> ' . $user_data['user_email'] . "\r\n\r\n"; |
|
| 571 | + $message .= '<strong>'.esc_attr__('E-mail:', 'give').'</strong> '.$user_data['user_email']."\r\n\r\n"; |
|
| 572 | 572 | |
| 573 | - $message .= '<a href="' . admin_url( 'user-edit.php?user_id=' . $user_id ) . '" target="_blank"> ' . esc_attr__( 'Click here to view »', 'give' ) . '</a>' . "\r\n"; |
|
| 573 | + $message .= '<a href="'.admin_url('user-edit.php?user_id='.$user_id).'" target="_blank"> '.esc_attr__('Click here to view »', 'give').'</a>'."\r\n"; |
|
| 574 | 574 | |
| 575 | 575 | $emails->send( |
| 576 | - get_option( 'admin_email' ), |
|
| 576 | + get_option('admin_email'), |
|
| 577 | 577 | sprintf( |
| 578 | 578 | /* translators: %s: site name */ |
| 579 | - esc_attr__( '[%s] New User Registration', 'give' ), |
|
| 579 | + esc_attr__('[%s] New User Registration', 'give'), |
|
| 580 | 580 | $blogname |
| 581 | 581 | ), |
| 582 | 582 | $message |
| 583 | 583 | ); |
| 584 | 584 | |
| 585 | 585 | // Account Information: Email sends to donor who registered. |
| 586 | - $emails->__set( 'heading', esc_html__( 'Account Information', 'give' ) ); |
|
| 586 | + $emails->__set('heading', esc_html__('Account Information', 'give')); |
|
| 587 | 587 | |
| 588 | - $message = sprintf( esc_attr__( 'The following email contains your account information for %s:', 'give' ), $blogname ) . "\r\n\r\n"; |
|
| 588 | + $message = sprintf(esc_attr__('The following email contains your account information for %s:', 'give'), $blogname)."\r\n\r\n"; |
|
| 589 | 589 | |
| 590 | 590 | /* translators: %s: user login */ |
| 591 | - $message .= '<strong>' . esc_attr__( 'Username:', 'give' ) . '</strong> ' . $user_data['user_login'] . "\r\n"; |
|
| 591 | + $message .= '<strong>'.esc_attr__('Username:', 'give').'</strong> '.$user_data['user_login']."\r\n"; |
|
| 592 | 592 | /* translators: %s: password */ |
| 593 | - $message .= '<strong>' . esc_attr__( 'Password:', 'give' ) . '</strong> ' . esc_attr__( '[Password entered during donation]', 'give' ) . "\r\n\r\n"; |
|
| 593 | + $message .= '<strong>'.esc_attr__('Password:', 'give').'</strong> '.esc_attr__('[Password entered during donation]', 'give')."\r\n\r\n"; |
|
| 594 | 594 | |
| 595 | - $message .= '<a href="' . wp_login_url() . '" target="_blank"> ' . esc_attr__( 'Click here to login »', 'give' ) . '</a>' . "\r\n"; |
|
| 595 | + $message .= '<a href="'.wp_login_url().'" target="_blank"> '.esc_attr__('Click here to login »', 'give').'</a>'."\r\n"; |
|
| 596 | 596 | |
| 597 | 597 | $emails->send( |
| 598 | 598 | $user_data['user_email'], |
| 599 | 599 | sprintf( |
| 600 | 600 | /* translators: %s: site name */ |
| 601 | - esc_attr__( '[%s] Your username and password', 'give' ), |
|
| 601 | + esc_attr__('[%s] Your username and password', 'give'), |
|
| 602 | 602 | $blogname |
| 603 | 603 | ), |
| 604 | 604 | $message |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | |
| 607 | 607 | } |
| 608 | 608 | |
| 609 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
| 609 | +add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
|
| 610 | 610 | |
| 611 | 611 | |
| 612 | 612 | /** |
@@ -622,34 +622,34 @@ discard block |
||
| 622 | 622 | * |
| 623 | 623 | * @return string |
| 624 | 624 | */ |
| 625 | -function give_get_donor_name_by( $id = 0, $from = 'donation' ) { |
|
| 625 | +function give_get_donor_name_by($id = 0, $from = 'donation') { |
|
| 626 | 626 | |
| 627 | 627 | // ID shouldn't be empty |
| 628 | - if ( empty( $id ) ) { |
|
| 628 | + if (empty($id)) { |
|
| 629 | 629 | return; |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | $name = ''; |
| 633 | 633 | |
| 634 | - switch ( $from ) { |
|
| 634 | + switch ($from) { |
|
| 635 | 635 | |
| 636 | 636 | case 'donation': |
| 637 | 637 | |
| 638 | - $user_info = give_get_payment_meta_user_info( $id ); |
|
| 639 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
| 638 | + $user_info = give_get_payment_meta_user_info($id); |
|
| 639 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
| 640 | 640 | |
| 641 | 641 | break; |
| 642 | 642 | |
| 643 | 643 | case 'donor': |
| 644 | 644 | |
| 645 | - $donor = new Give_Donor( $id ); |
|
| 645 | + $donor = new Give_Donor($id); |
|
| 646 | 646 | $name = $donor->name; |
| 647 | 647 | |
| 648 | 648 | break; |
| 649 | 649 | |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - return trim( $name ); |
|
| 652 | + return trim($name); |
|
| 653 | 653 | |
| 654 | 654 | } |
| 655 | 655 | |
@@ -661,8 +661,8 @@ discard block |
||
| 661 | 661 | * @param string $email Donor Email. |
| 662 | 662 | * @return boolean The user's ID on success, and false on failure. |
| 663 | 663 | */ |
| 664 | -function give_donor_email_exists( $email ) { |
|
| 665 | - if ( Give()->donors->get_donor_by( 'email', $email ) ) { |
|
| 664 | +function give_donor_email_exists($email) { |
|
| 665 | + if (Give()->donors->get_donor_by('email', $email)) { |
|
| 666 | 666 | return true; |
| 667 | 667 | } |
| 668 | 668 | return false; |
@@ -677,12 +677,12 @@ discard block |
||
| 677 | 677 | * |
| 678 | 678 | * @return bool |
| 679 | 679 | */ |
| 680 | -function give_is_additional_email( $email ) { |
|
| 680 | +function give_is_additional_email($email) { |
|
| 681 | 681 | global $wpdb; |
| 682 | - $meta_table = Give()->donor_meta->table_name; |
|
| 683 | - $donor_id = $wpdb->get_var( $wpdb->prepare( "SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email ) ); |
|
| 682 | + $meta_table = Give()->donor_meta->table_name; |
|
| 683 | + $donor_id = $wpdb->get_var($wpdb->prepare("SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email)); |
|
| 684 | 684 | |
| 685 | - if ( empty( $donor_id ) ) { |
|
| 685 | + if (empty($donor_id)) { |
|
| 686 | 686 | return false; |
| 687 | 687 | } |
| 688 | 688 | return true; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @since 1.0 |
| 32 | 32 | */ |
| 33 | - do_action( 'give_pre_process_donation' ); |
|
| 33 | + do_action('give_pre_process_donation'); |
|
| 34 | 34 | |
| 35 | 35 | // Validate the form $_POST data |
| 36 | 36 | $valid_data = give_donation_form_validate_fields(); |
@@ -45,26 +45,26 @@ discard block |
||
| 45 | 45 | * @param bool|array $valid_data Validate fields. |
| 46 | 46 | * @param array $_POST Array of variables passed via the HTTP POST. |
| 47 | 47 | */ |
| 48 | - do_action( 'give_checkout_error_checks', $valid_data, $_POST ); |
|
| 48 | + do_action('give_checkout_error_checks', $valid_data, $_POST); |
|
| 49 | 49 | |
| 50 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
| 50 | + $is_ajax = isset($_POST['give_ajax']); |
|
| 51 | 51 | |
| 52 | 52 | // Process the login form |
| 53 | - if ( isset( $_POST['give_login_submit'] ) ) { |
|
| 53 | + if (isset($_POST['give_login_submit'])) { |
|
| 54 | 54 | give_process_form_login(); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | // Validate the user |
| 58 | - $user = give_get_donation_form_user( $valid_data ); |
|
| 58 | + $user = give_get_donation_form_user($valid_data); |
|
| 59 | 59 | |
| 60 | - if ( false === $valid_data || give_get_errors() || ! $user ) { |
|
| 61 | - if ( $is_ajax ) { |
|
| 60 | + if (false === $valid_data || give_get_errors() || ! $user) { |
|
| 61 | + if ($is_ajax) { |
|
| 62 | 62 | /** |
| 63 | 63 | * Fires when AJAX sends back errors from the donation form. |
| 64 | 64 | * |
| 65 | 65 | * @since 1.0 |
| 66 | 66 | */ |
| 67 | - do_action( 'give_ajax_donation_errors' ); |
|
| 67 | + do_action('give_ajax_donation_errors'); |
|
| 68 | 68 | give_die(); |
| 69 | 69 | } else { |
| 70 | 70 | return false; |
@@ -72,17 +72,17 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // If AJAX send back success to proceed with form submission |
| 75 | - if ( $is_ajax ) { |
|
| 75 | + if ($is_ajax) { |
|
| 76 | 76 | echo 'success'; |
| 77 | 77 | give_die(); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // After AJAX: Setup session if not using php_sessions |
| 81 | - if ( ! Give()->session->use_php_sessions() ) { |
|
| 81 | + if ( ! Give()->session->use_php_sessions()) { |
|
| 82 | 82 | // Double-check that set_cookie is publicly accessible; |
| 83 | 83 | // we're using a slightly modified class-wp-sessions.php |
| 84 | - $session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' ); |
|
| 85 | - if ( $session_reflection->isPublic() ) { |
|
| 84 | + $session_reflection = new ReflectionMethod('WP_Session', 'set_cookie'); |
|
| 85 | + if ($session_reflection->isPublic()) { |
|
| 86 | 86 | // Manually set the cookie. |
| 87 | 87 | Give()->session->init()->set_cookie(); |
| 88 | 88 | } |
@@ -97,20 +97,19 @@ discard block |
||
| 97 | 97 | 'address' => $user['address'], |
| 98 | 98 | ); |
| 99 | 99 | |
| 100 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 100 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 101 | 101 | |
| 102 | - $price = isset( $_POST['give-amount'] ) ? |
|
| 103 | - (float) apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give-amount'] ) ) : |
|
| 104 | - '0.00'; |
|
| 105 | - $purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); |
|
| 102 | + $price = isset($_POST['give-amount']) ? |
|
| 103 | + (float) apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give-amount'])) : '0.00'; |
|
| 104 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
| 106 | 105 | |
| 107 | 106 | // Setup donation information |
| 108 | 107 | $donation_data = array( |
| 109 | 108 | 'price' => $price, |
| 110 | 109 | 'purchase_key' => $purchase_key, |
| 111 | 110 | 'user_email' => $user['user_email'], |
| 112 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
| 113 | - 'user_info' => stripslashes_deep( $user_info ), |
|
| 111 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
| 112 | + 'user_info' => stripslashes_deep($user_info), |
|
| 114 | 113 | 'post_data' => $_POST, |
| 115 | 114 | 'gateway' => $valid_data['gateway'], |
| 116 | 115 | 'card_info' => $valid_data['cc_info'], |
@@ -130,10 +129,10 @@ discard block |
||
| 130 | 129 | * @param array $user_info Array containing basic user information. |
| 131 | 130 | * @param bool|array $valid_data Validate fields. |
| 132 | 131 | */ |
| 133 | - do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
| 132 | + do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
| 134 | 133 | |
| 135 | 134 | // Sanity check for price |
| 136 | - if ( ! $donation_data['price'] ) { |
|
| 135 | + if ( ! $donation_data['price']) { |
|
| 137 | 136 | // Revert to manual |
| 138 | 137 | $donation_data['gateway'] = 'manual'; |
| 139 | 138 | $_POST['give-gateway'] = 'manual'; |
@@ -144,27 +143,27 @@ discard block |
||
| 144 | 143 | * |
| 145 | 144 | * @since 1.7 |
| 146 | 145 | */ |
| 147 | - $donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data ); |
|
| 146 | + $donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data); |
|
| 148 | 147 | |
| 149 | 148 | // Setup the data we're storing in the donation session |
| 150 | 149 | $session_data = $donation_data; |
| 151 | 150 | |
| 152 | 151 | // Make sure credit card numbers are never stored in sessions |
| 153 | - unset( $session_data['card_info']['card_number'] ); |
|
| 154 | - unset( $session_data['post_data']['card_number'] ); |
|
| 152 | + unset($session_data['card_info']['card_number']); |
|
| 153 | + unset($session_data['post_data']['card_number']); |
|
| 155 | 154 | |
| 156 | 155 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. |
| 157 | - give_set_purchase_session( $session_data ); |
|
| 156 | + give_set_purchase_session($session_data); |
|
| 158 | 157 | |
| 159 | 158 | // Send info to the gateway for payment processing |
| 160 | - give_send_to_gateway( $donation_data['gateway'], $donation_data ); |
|
| 159 | + give_send_to_gateway($donation_data['gateway'], $donation_data); |
|
| 161 | 160 | give_die(); |
| 162 | 161 | |
| 163 | 162 | } |
| 164 | 163 | |
| 165 | -add_action( 'give_purchase', 'give_process_donation_form' ); |
|
| 166 | -add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' ); |
|
| 167 | -add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' ); |
|
| 164 | +add_action('give_purchase', 'give_process_donation_form'); |
|
| 165 | +add_action('wp_ajax_give_process_donation', 'give_process_donation_form'); |
|
| 166 | +add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form'); |
|
| 168 | 167 | |
| 169 | 168 | |
| 170 | 169 | /** |
@@ -177,29 +176,29 @@ discard block |
||
| 177 | 176 | * |
| 178 | 177 | * @return void |
| 179 | 178 | */ |
| 180 | -function give_check_logged_in_user_for_existing_email( $valid_data, $post ) { |
|
| 179 | +function give_check_logged_in_user_for_existing_email($valid_data, $post) { |
|
| 181 | 180 | |
| 182 | 181 | // Verify that the email address belongs to this customer. |
| 183 | - if ( is_user_logged_in() ) { |
|
| 182 | + if (is_user_logged_in()) { |
|
| 184 | 183 | |
| 185 | 184 | $submitted_email = $valid_data['logged_in_user']['user_email']; |
| 186 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
| 185 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
| 187 | 186 | |
| 188 | 187 | // If this email address is not registered with this customer, see if it belongs to any other customer |
| 189 | 188 | if ( |
| 190 | 189 | $submitted_email !== $donor->email |
| 191 | - && ( is_array( $donor->emails ) && ! in_array( $submitted_email, $donor->emails ) ) |
|
| 190 | + && (is_array($donor->emails) && ! in_array($submitted_email, $donor->emails)) |
|
| 192 | 191 | ) { |
| 193 | - $found_donor = new Give_Donor( $submitted_email ); |
|
| 192 | + $found_donor = new Give_Donor($submitted_email); |
|
| 194 | 193 | |
| 195 | - if ( $found_donor->id > 0 ) { |
|
| 196 | - give_set_error( 'give-customer-email-exists', sprintf( __( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give' ), $donor->email, $submitted_email ) ); |
|
| 194 | + if ($found_donor->id > 0) { |
|
| 195 | + give_set_error('give-customer-email-exists', sprintf(__('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give'), $donor->email, $submitted_email)); |
|
| 197 | 196 | } |
| 198 | 197 | } |
| 199 | 198 | } |
| 200 | 199 | } |
| 201 | 200 | |
| 202 | -add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2 ); |
|
| 201 | +add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2); |
|
| 203 | 202 | |
| 204 | 203 | /** |
| 205 | 204 | * Process the checkout login form |
@@ -209,49 +208,49 @@ discard block |
||
| 209 | 208 | * @return void |
| 210 | 209 | */ |
| 211 | 210 | function give_process_form_login() { |
| 212 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
| 211 | + $is_ajax = isset($_POST['give_ajax']); |
|
| 213 | 212 | |
| 214 | 213 | $user_data = give_donation_form_validate_user_login(); |
| 215 | 214 | |
| 216 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
| 217 | - if ( $is_ajax ) { |
|
| 215 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
| 216 | + if ($is_ajax) { |
|
| 218 | 217 | /** |
| 219 | 218 | * Fires when AJAX sends back errors from the donation form. |
| 220 | 219 | * |
| 221 | 220 | * @since 1.0 |
| 222 | 221 | */ |
| 223 | 222 | ob_start(); |
| 224 | - do_action( 'give_ajax_donation_errors' ); |
|
| 223 | + do_action('give_ajax_donation_errors'); |
|
| 225 | 224 | $message = ob_get_contents(); |
| 226 | 225 | ob_end_clean(); |
| 227 | - wp_send_json_error( $message ); |
|
| 226 | + wp_send_json_error($message); |
|
| 228 | 227 | } else { |
| 229 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
| 228 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
| 230 | 229 | exit; |
| 231 | 230 | } |
| 232 | 231 | } |
| 233 | 232 | |
| 234 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
| 233 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
| 235 | 234 | |
| 236 | - if ( $is_ajax ) { |
|
| 235 | + if ($is_ajax) { |
|
| 237 | 236 | $message = Give()->notices->print_frontend_notice( |
| 238 | 237 | sprintf( |
| 239 | 238 | /* translators: %s: user first name */ |
| 240 | - esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ), |
|
| 241 | - ( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login'] |
|
| 239 | + esc_html__('Welcome %s! You have successfully logged into your account.', 'give'), |
|
| 240 | + ( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login'] |
|
| 242 | 241 | ), |
| 243 | 242 | false, |
| 244 | 243 | 'success' |
| 245 | 244 | ); |
| 246 | 245 | |
| 247 | - wp_send_json_success( $message ); |
|
| 246 | + wp_send_json_success($message); |
|
| 248 | 247 | } else { |
| 249 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
| 248 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
| 250 | 249 | } |
| 251 | 250 | } |
| 252 | 251 | |
| 253 | -add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' ); |
|
| 254 | -add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' ); |
|
| 252 | +add_action('wp_ajax_give_process_donation_login', 'give_process_form_login'); |
|
| 253 | +add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login'); |
|
| 255 | 254 | |
| 256 | 255 | /** |
| 257 | 256 | * Donation Form Validate Fields. |
@@ -263,55 +262,55 @@ discard block |
||
| 263 | 262 | function give_donation_form_validate_fields() { |
| 264 | 263 | |
| 265 | 264 | // Check if there is $_POST |
| 266 | - if ( empty( $_POST ) ) { |
|
| 265 | + if (empty($_POST)) { |
|
| 267 | 266 | return false; |
| 268 | 267 | } |
| 269 | 268 | |
| 270 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
| 269 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
| 271 | 270 | |
| 272 | 271 | // Start an array to collect valid data |
| 273 | 272 | $valid_data = array( |
| 274 | 273 | 'gateway' => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here) |
| 275 | - 'need_new_user' => false, // New user flag |
|
| 276 | - 'need_user_login' => false, // Login user flag |
|
| 277 | - 'logged_user_data' => array(), // Logged user collected data |
|
| 278 | - 'new_user_data' => array(), // New user collected data |
|
| 279 | - 'login_user_data' => array(), // Login user collected data |
|
| 280 | - 'guest_user_data' => array(), // Guest user collected data |
|
| 281 | - 'cc_info' => give_donation_form_validate_cc(),// Credit card info |
|
| 274 | + 'need_new_user' => false, // New user flag |
|
| 275 | + 'need_user_login' => false, // Login user flag |
|
| 276 | + 'logged_user_data' => array(), // Logged user collected data |
|
| 277 | + 'new_user_data' => array(), // New user collected data |
|
| 278 | + 'login_user_data' => array(), // Login user collected data |
|
| 279 | + 'guest_user_data' => array(), // Guest user collected data |
|
| 280 | + 'cc_info' => give_donation_form_validate_cc(), // Credit card info |
|
| 282 | 281 | ); |
| 283 | 282 | |
| 284 | 283 | // Validate Honeypot First |
| 285 | - if ( ! empty( $_POST['give-honeypot'] ) ) { |
|
| 286 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
| 284 | + if ( ! empty($_POST['give-honeypot'])) { |
|
| 285 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
| 287 | 286 | } |
| 288 | 287 | |
| 289 | 288 | // Validate agree to terms |
| 290 | - if ( give_is_terms_enabled( $form_id ) ) { |
|
| 289 | + if (give_is_terms_enabled($form_id)) { |
|
| 291 | 290 | give_donation_form_validate_agree_to_terms(); |
| 292 | 291 | } |
| 293 | 292 | |
| 294 | 293 | // Stop processing donor registration, if donor registration is optional and donor can do guest checkout. |
| 295 | 294 | // If registration form username field is empty that means donor do not want to registration instead want guest checkout. |
| 296 | 295 | if ( |
| 297 | - ! give_logged_in_only( $form_id ) |
|
| 298 | - && isset( $_POST['give-purchase-var'] ) |
|
| 296 | + ! give_logged_in_only($form_id) |
|
| 297 | + && isset($_POST['give-purchase-var']) |
|
| 299 | 298 | && $_POST['give-purchase-var'] == 'needs-to-register' |
| 300 | - && empty( $_POST['give_user_login'] ) |
|
| 299 | + && empty($_POST['give_user_login']) |
|
| 301 | 300 | ) { |
| 302 | - unset( $_POST['give-purchase-var'] ); |
|
| 301 | + unset($_POST['give-purchase-var']); |
|
| 303 | 302 | } |
| 304 | 303 | |
| 305 | - if ( is_user_logged_in() ) { |
|
| 304 | + if (is_user_logged_in()) { |
|
| 306 | 305 | // Collect logged in user data. |
| 307 | 306 | $valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user(); |
| 308 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
| 307 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
| 309 | 308 | // Set new user registration as required. |
| 310 | 309 | $valid_data['need_new_user'] = true; |
| 311 | 310 | // Validate new user data. |
| 312 | 311 | $valid_data['new_user_data'] = give_donation_form_validate_new_user(); |
| 313 | 312 | // Check if login validation is needed. |
| 314 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
| 313 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
| 315 | 314 | // Set user login as required. |
| 316 | 315 | $valid_data['need_user_login'] = true; |
| 317 | 316 | // Validate users login info. |
@@ -336,41 +335,41 @@ discard block |
||
| 336 | 335 | */ |
| 337 | 336 | function give_donation_form_validate_gateway() { |
| 338 | 337 | |
| 339 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
| 340 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_maybe_sanitize_amount( $_REQUEST['give-amount'] ) : 0; |
|
| 341 | - $gateway = give_get_default_gateway( $form_id ); |
|
| 338 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
| 339 | + $amount = isset($_REQUEST['give-amount']) ? give_maybe_sanitize_amount($_REQUEST['give-amount']) : 0; |
|
| 340 | + $gateway = give_get_default_gateway($form_id); |
|
| 342 | 341 | |
| 343 | 342 | // Check if a gateway value is present. |
| 344 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
| 343 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
| 345 | 344 | |
| 346 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
| 345 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
| 347 | 346 | |
| 348 | 347 | // Is amount being donated in LIVE mode 0.00? If so, error: |
| 349 | - if ( $amount == 0 && ! give_is_test_mode() ) { |
|
| 348 | + if ($amount == 0 && ! give_is_test_mode()) { |
|
| 350 | 349 | |
| 351 | - give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) ); |
|
| 350 | + give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give')); |
|
| 352 | 351 | |
| 353 | 352 | } // End if(). |
| 354 | - elseif ( ! give_verify_minimum_price() ) { |
|
| 353 | + elseif ( ! give_verify_minimum_price()) { |
|
| 355 | 354 | // translators: %s: minimum donation amount. |
| 356 | 355 | give_set_error( |
| 357 | 356 | 'invalid_donation_minimum', |
| 358 | 357 | sprintf( |
| 359 | 358 | /* translators: %s: minimum donation amount */ |
| 360 | - __( 'This form has a minimum donation amount of %s.', 'give' ), |
|
| 361 | - give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ), array( 'sanitize' => false ) ) ) |
|
| 359 | + __('This form has a minimum donation amount of %s.', 'give'), |
|
| 360 | + give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id), array('sanitize' => false))) |
|
| 362 | 361 | ) |
| 363 | 362 | ); |
| 364 | 363 | |
| 365 | 364 | } //Is this test mode zero donation? Let it through but set to manual gateway. |
| 366 | - elseif ( $amount == 0 && give_is_test_mode() ) { |
|
| 365 | + elseif ($amount == 0 && give_is_test_mode()) { |
|
| 367 | 366 | |
| 368 | 367 | $gateway = 'manual'; |
| 369 | 368 | |
| 370 | 369 | } //Check if this gateway is active. |
| 371 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
| 370 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
| 372 | 371 | |
| 373 | - give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
| 372 | + give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give')); |
|
| 374 | 373 | |
| 375 | 374 | } |
| 376 | 375 | } |
@@ -388,21 +387,21 @@ discard block |
||
| 388 | 387 | */ |
| 389 | 388 | function give_verify_minimum_price() { |
| 390 | 389 | |
| 391 | - $amount = give_maybe_sanitize_amount( $_REQUEST['give-amount'] ); |
|
| 392 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
| 393 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : null; |
|
| 394 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
| 390 | + $amount = give_maybe_sanitize_amount($_REQUEST['give-amount']); |
|
| 391 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
| 392 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : null; |
|
| 393 | + $variable_prices = give_has_variable_prices($form_id); |
|
| 395 | 394 | |
| 396 | - if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ) ) ) { |
|
| 395 | + if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id))) { |
|
| 397 | 396 | |
| 398 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
| 397 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
| 399 | 398 | |
| 400 | - if ( $price_level_amount == $amount ) { |
|
| 399 | + if ($price_level_amount == $amount) { |
|
| 401 | 400 | return true; |
| 402 | 401 | } |
| 403 | 402 | } |
| 404 | 403 | |
| 405 | - if ( give_get_form_minimum_price( $form_id ) > $amount ) { |
|
| 404 | + if (give_get_form_minimum_price($form_id) > $amount) { |
|
| 406 | 405 | return false; |
| 407 | 406 | } |
| 408 | 407 | |
@@ -418,9 +417,9 @@ discard block |
||
| 418 | 417 | */ |
| 419 | 418 | function give_donation_form_validate_agree_to_terms() { |
| 420 | 419 | // Validate agree to terms. |
| 421 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
| 420 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
| 422 | 421 | // User did not agree. |
| 423 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) ); |
|
| 422 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give'))); |
|
| 424 | 423 | } |
| 425 | 424 | } |
| 426 | 425 | |
@@ -434,59 +433,59 @@ discard block |
||
| 434 | 433 | * |
| 435 | 434 | * @return array |
| 436 | 435 | */ |
| 437 | -function give_get_required_fields( $form_id ) { |
|
| 436 | +function give_get_required_fields($form_id) { |
|
| 438 | 437 | |
| 439 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
| 438 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
| 440 | 439 | |
| 441 | 440 | $required_fields = array( |
| 442 | 441 | 'give_email' => array( |
| 443 | 442 | 'error_id' => 'invalid_email', |
| 444 | - 'error_message' => __( 'Please enter a valid email address.', 'give' ), |
|
| 443 | + 'error_message' => __('Please enter a valid email address.', 'give'), |
|
| 445 | 444 | ), |
| 446 | 445 | 'give_first' => array( |
| 447 | 446 | 'error_id' => 'invalid_first_name', |
| 448 | - 'error_message' => __( 'Please enter your first name.', 'give' ), |
|
| 447 | + 'error_message' => __('Please enter your first name.', 'give'), |
|
| 449 | 448 | ), |
| 450 | 449 | ); |
| 451 | 450 | |
| 452 | - $require_address = give_require_billing_address( $payment_mode ); |
|
| 451 | + $require_address = give_require_billing_address($payment_mode); |
|
| 453 | 452 | |
| 454 | - if ( $require_address ) { |
|
| 455 | - $required_fields['card_address'] = array( |
|
| 453 | + if ($require_address) { |
|
| 454 | + $required_fields['card_address'] = array( |
|
| 456 | 455 | 'error_id' => 'invalid_card_address', |
| 457 | - 'error_message' => __( 'Please enter your primary billing address.', 'give' ), |
|
| 456 | + 'error_message' => __('Please enter your primary billing address.', 'give'), |
|
| 458 | 457 | ); |
| 459 | - $required_fields['card_zip'] = array( |
|
| 458 | + $required_fields['card_zip'] = array( |
|
| 460 | 459 | 'error_id' => 'invalid_zip_code', |
| 461 | - 'error_message' => __( 'Please enter your zip / postal code.', 'give' ), |
|
| 460 | + 'error_message' => __('Please enter your zip / postal code.', 'give'), |
|
| 462 | 461 | ); |
| 463 | - $required_fields['card_city'] = array( |
|
| 462 | + $required_fields['card_city'] = array( |
|
| 464 | 463 | 'error_id' => 'invalid_city', |
| 465 | - 'error_message' => __( 'Please enter your billing city.', 'give' ), |
|
| 464 | + 'error_message' => __('Please enter your billing city.', 'give'), |
|
| 466 | 465 | ); |
| 467 | 466 | $required_fields['billing_country'] = array( |
| 468 | 467 | 'error_id' => 'invalid_country', |
| 469 | - 'error_message' => __( 'Please select your billing country.', 'give' ), |
|
| 468 | + 'error_message' => __('Please select your billing country.', 'give'), |
|
| 470 | 469 | ); |
| 471 | 470 | |
| 472 | 471 | |
| 473 | 472 | $required_fields['card_state'] = array( |
| 474 | 473 | 'error_id' => 'invalid_state', |
| 475 | - 'error_message' => __( 'Please enter billing state / province / County.', 'give' ), |
|
| 474 | + 'error_message' => __('Please enter billing state / province / County.', 'give'), |
|
| 476 | 475 | ); |
| 477 | 476 | |
| 478 | 477 | // Check if billing country alredy exists. |
| 479 | - if ( ! empty( $_POST['billing_country'] ) ) { |
|
| 478 | + if ( ! empty($_POST['billing_country'])) { |
|
| 480 | 479 | // Get the value from $_POST. |
| 481 | - $country = sanitize_text_field( $_POST['billing_country'] ); |
|
| 480 | + $country = sanitize_text_field($_POST['billing_country']); |
|
| 482 | 481 | |
| 483 | 482 | // Get the country list that does not required any states init. |
| 484 | 483 | $states_country = give_states_not_required_country_list(); |
| 485 | 484 | |
| 486 | 485 | // Check if states is empty or not. |
| 487 | - if ( array_key_exists( $country, $states_country ) ) { |
|
| 486 | + if (array_key_exists($country, $states_country)) { |
|
| 488 | 487 | // If states is empty remove the required feilds of state in billing cart. |
| 489 | - unset( $required_fields['card_state'] ); |
|
| 488 | + unset($required_fields['card_state']); |
|
| 490 | 489 | } |
| 491 | 490 | } |
| 492 | 491 | } |
@@ -496,7 +495,7 @@ discard block |
||
| 496 | 495 | * |
| 497 | 496 | * @since 1.7 |
| 498 | 497 | */ |
| 499 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); |
|
| 498 | + $required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); |
|
| 500 | 499 | |
| 501 | 500 | return $required_fields; |
| 502 | 501 | |
@@ -511,16 +510,16 @@ discard block |
||
| 511 | 510 | * |
| 512 | 511 | * @return bool |
| 513 | 512 | */ |
| 514 | -function give_require_billing_address( $payment_mode ) { |
|
| 513 | +function give_require_billing_address($payment_mode) { |
|
| 515 | 514 | |
| 516 | 515 | $return = false; |
| 517 | 516 | |
| 518 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
| 517 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
| 519 | 518 | $return = true; |
| 520 | 519 | } |
| 521 | 520 | |
| 522 | 521 | // Let payment gateways and other extensions determine if address fields should be required. |
| 523 | - return apply_filters( 'give_require_billing_address', $return ); |
|
| 522 | + return apply_filters('give_require_billing_address', $return); |
|
| 524 | 523 | |
| 525 | 524 | } |
| 526 | 525 | |
@@ -534,42 +533,42 @@ discard block |
||
| 534 | 533 | function give_donation_form_validate_logged_in_user() { |
| 535 | 534 | global $user_ID; |
| 536 | 535 | |
| 537 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
| 536 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
| 538 | 537 | |
| 539 | 538 | // Start empty array to collect valid user data. |
| 540 | 539 | $valid_user_data = array( |
| 541 | 540 | // Assume there will be errors. |
| 542 | - 'user_id' => - 1, |
|
| 541 | + 'user_id' => -1, |
|
| 543 | 542 | ); |
| 544 | 543 | |
| 545 | 544 | // Verify there is a user_ID. |
| 546 | - if ( $user_ID > 0 ) { |
|
| 545 | + if ($user_ID > 0) { |
|
| 547 | 546 | // Get the logged in user data. |
| 548 | - $user_data = get_userdata( $user_ID ); |
|
| 547 | + $user_data = get_userdata($user_ID); |
|
| 549 | 548 | |
| 550 | 549 | // Loop through required fields and show error messages. |
| 551 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
| 552 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
| 553 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
| 550 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
| 551 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
| 552 | + give_set_error($value['error_id'], $value['error_message']); |
|
| 554 | 553 | } |
| 555 | 554 | } |
| 556 | 555 | |
| 557 | 556 | // Verify data. |
| 558 | - if ( $user_data ) { |
|
| 557 | + if ($user_data) { |
|
| 559 | 558 | // Collected logged in user data. |
| 560 | 559 | $valid_user_data = array( |
| 561 | 560 | 'user_id' => $user_ID, |
| 562 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
| 563 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
| 564 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
| 561 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
| 562 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
| 563 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
| 565 | 564 | ); |
| 566 | 565 | |
| 567 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
| 568 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
| 566 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
| 567 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
| 569 | 568 | } |
| 570 | 569 | } else { |
| 571 | 570 | // Set invalid user error. |
| 572 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
| 571 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
| 573 | 572 | } |
| 574 | 573 | } |
| 575 | 574 | |
@@ -588,7 +587,7 @@ discard block |
||
| 588 | 587 | // Default user data. |
| 589 | 588 | $default_user_data = array( |
| 590 | 589 | 'give-form-id' => '', |
| 591 | - 'user_id' => - 1, // Assume there will be errors. |
|
| 590 | + 'user_id' => -1, // Assume there will be errors. |
|
| 592 | 591 | 'user_first' => '', |
| 593 | 592 | 'user_last' => '', |
| 594 | 593 | 'give_user_login' => false, |
@@ -598,14 +597,14 @@ discard block |
||
| 598 | 597 | ); |
| 599 | 598 | |
| 600 | 599 | // Get user data. |
| 601 | - $user_data = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data ); |
|
| 600 | + $user_data = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data); |
|
| 602 | 601 | $registering_new_user = false; |
| 603 | - $form_id = absint( $user_data['give-form-id'] ); |
|
| 602 | + $form_id = absint($user_data['give-form-id']); |
|
| 604 | 603 | |
| 605 | 604 | // Start an empty array to collect valid user data. |
| 606 | 605 | $valid_user_data = array( |
| 607 | 606 | // Assume there will be errors. |
| 608 | - 'user_id' => - 1, |
|
| 607 | + 'user_id' => -1, |
|
| 609 | 608 | |
| 610 | 609 | // Get first name. |
| 611 | 610 | 'user_first' => $user_data['give_first'], |
@@ -615,25 +614,25 @@ discard block |
||
| 615 | 614 | ); |
| 616 | 615 | |
| 617 | 616 | // Loop through required fields and show error messages. |
| 618 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
| 619 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
| 620 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
| 617 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
| 618 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
| 619 | + give_set_error($value['error_id'], $value['error_message']); |
|
| 621 | 620 | } |
| 622 | 621 | } |
| 623 | 622 | |
| 624 | 623 | // Check if we have an username to register. |
| 625 | - if ( give_validate_username( $user_data['give_user_login'] ) ) { |
|
| 624 | + if (give_validate_username($user_data['give_user_login'])) { |
|
| 626 | 625 | $registering_new_user = true; |
| 627 | 626 | $valid_user_data['user_login'] = $user_data['give_user_login']; |
| 628 | 627 | } |
| 629 | 628 | |
| 630 | 629 | // Check if we have an email to verify. |
| 631 | - if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) { |
|
| 630 | + if (give_validate_user_email($user_data['give_email'], $registering_new_user)) { |
|
| 632 | 631 | $valid_user_data['user_email'] = $user_data['give_email']; |
| 633 | 632 | } |
| 634 | 633 | |
| 635 | 634 | // Check password. |
| 636 | - if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) { |
|
| 635 | + if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) { |
|
| 637 | 636 | // All is good to go. |
| 638 | 637 | $valid_user_data['user_pass'] = $user_data['give_user_pass']; |
| 639 | 638 | } |
@@ -653,36 +652,36 @@ discard block |
||
| 653 | 652 | // Start an array to collect valid user data. |
| 654 | 653 | $valid_user_data = array( |
| 655 | 654 | // Assume there will be errors. |
| 656 | - 'user_id' => - 1, |
|
| 655 | + 'user_id' => -1, |
|
| 657 | 656 | ); |
| 658 | 657 | |
| 659 | 658 | // Username. |
| 660 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
| 661 | - give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) ); |
|
| 659 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
| 660 | + give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give')); |
|
| 662 | 661 | |
| 663 | 662 | return $valid_user_data; |
| 664 | 663 | } |
| 665 | 664 | |
| 666 | 665 | // Get the user by login. |
| 667 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
| 666 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
| 668 | 667 | |
| 669 | 668 | // Check if user exists. |
| 670 | - if ( $user_data ) { |
|
| 669 | + if ($user_data) { |
|
| 671 | 670 | // Get password. |
| 672 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
| 671 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
| 673 | 672 | |
| 674 | 673 | // Check user_pass. |
| 675 | - if ( $user_pass ) { |
|
| 674 | + if ($user_pass) { |
|
| 676 | 675 | // Check if password is valid. |
| 677 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
| 676 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
| 678 | 677 | // Incorrect password. |
| 679 | 678 | give_set_error( |
| 680 | 679 | 'password_incorrect', |
| 681 | 680 | sprintf( |
| 682 | 681 | '%1$s <a href="%2$s">%3$s</a>', |
| 683 | - __( 'The password you entered is incorrect.', 'give' ), |
|
| 684 | - wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ), |
|
| 685 | - __( 'Reset Password', 'give' ) |
|
| 682 | + __('The password you entered is incorrect.', 'give'), |
|
| 683 | + wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), |
|
| 684 | + __('Reset Password', 'give') |
|
| 686 | 685 | ) |
| 687 | 686 | ); |
| 688 | 687 | // All is correct. |
@@ -699,11 +698,11 @@ discard block |
||
| 699 | 698 | } |
| 700 | 699 | } else { |
| 701 | 700 | // Empty password. |
| 702 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
| 701 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
| 703 | 702 | } |
| 704 | 703 | } else { |
| 705 | 704 | // No username. |
| 706 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) ); |
|
| 705 | + give_set_error('username_incorrect', __('The username you entered does not exist.', 'give')); |
|
| 707 | 706 | }// End if(). |
| 708 | 707 | |
| 709 | 708 | return $valid_user_data; |
@@ -718,7 +717,7 @@ discard block |
||
| 718 | 717 | */ |
| 719 | 718 | function give_donation_form_validate_guest_user() { |
| 720 | 719 | |
| 721 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
| 720 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
| 722 | 721 | |
| 723 | 722 | // Start an array to collect valid user data. |
| 724 | 723 | $valid_user_data = array( |
@@ -727,38 +726,38 @@ discard block |
||
| 727 | 726 | ); |
| 728 | 727 | |
| 729 | 728 | // Show error message if user must be logged in. |
| 730 | - if ( give_logged_in_only( $form_id ) ) { |
|
| 731 | - give_set_error( 'logged_in_only', __( 'You must be logged in to donate.', 'give' ) ); |
|
| 729 | + if (give_logged_in_only($form_id)) { |
|
| 730 | + give_set_error('logged_in_only', __('You must be logged in to donate.', 'give')); |
|
| 732 | 731 | } |
| 733 | 732 | |
| 734 | 733 | // Get the guest email. |
| 735 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
| 734 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
| 736 | 735 | |
| 737 | 736 | // Check email. |
| 738 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
| 737 | + if ($guest_email && strlen($guest_email) > 0) { |
|
| 739 | 738 | // Validate email. |
| 740 | - if ( ! is_email( $guest_email ) ) { |
|
| 739 | + if ( ! is_email($guest_email)) { |
|
| 741 | 740 | // Invalid email. |
| 742 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
| 741 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
| 743 | 742 | } else { |
| 744 | 743 | // All is good to go. |
| 745 | 744 | $valid_user_data['user_email'] = $guest_email; |
| 746 | 745 | |
| 747 | 746 | // Get user_id from donor if exist. |
| 748 | - $donor = new Give_Donor( $guest_email ); |
|
| 749 | - if ( $donor->id && $donor->user_id ) { |
|
| 747 | + $donor = new Give_Donor($guest_email); |
|
| 748 | + if ($donor->id && $donor->user_id) { |
|
| 750 | 749 | $valid_user_data['user_id'] = $donor->user_id; |
| 751 | 750 | } |
| 752 | 751 | } |
| 753 | 752 | } else { |
| 754 | 753 | // No email. |
| 755 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); |
|
| 754 | + give_set_error('email_empty', __('Enter an email.', 'give')); |
|
| 756 | 755 | } |
| 757 | 756 | |
| 758 | 757 | // Loop through required fields and show error messages. |
| 759 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
| 760 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
| 761 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
| 758 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
| 759 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
| 760 | + give_set_error($value['error_id'], $value['error_message']); |
|
| 762 | 761 | } |
| 763 | 762 | } |
| 764 | 763 | |
@@ -774,36 +773,36 @@ discard block |
||
| 774 | 773 | * @since 1.0 |
| 775 | 774 | * @return integer |
| 776 | 775 | */ |
| 777 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
| 776 | +function give_register_and_login_new_user($user_data = array()) { |
|
| 778 | 777 | // Verify the array. |
| 779 | - if ( empty( $user_data ) ) { |
|
| 780 | - return - 1; |
|
| 778 | + if (empty($user_data)) { |
|
| 779 | + return -1; |
|
| 781 | 780 | } |
| 782 | 781 | |
| 783 | - if ( give_get_errors() ) { |
|
| 784 | - return - 1; |
|
| 782 | + if (give_get_errors()) { |
|
| 783 | + return -1; |
|
| 785 | 784 | } |
| 786 | 785 | |
| 787 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
| 788 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
| 789 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
| 790 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
| 791 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
| 792 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
| 793 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
| 794 | - 'role' => give_get_option( 'donor_default_user_role', 'give_donor' ), |
|
| 795 | - ), $user_data ); |
|
| 786 | + $user_args = apply_filters('give_insert_user_args', array( |
|
| 787 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
| 788 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
| 789 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
| 790 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
| 791 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
| 792 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
| 793 | + 'role' => give_get_option('donor_default_user_role', 'give_donor'), |
|
| 794 | + ), $user_data); |
|
| 796 | 795 | |
| 797 | 796 | // Insert new user. |
| 798 | - $user_id = wp_insert_user( $user_args ); |
|
| 797 | + $user_id = wp_insert_user($user_args); |
|
| 799 | 798 | |
| 800 | 799 | // Validate inserted user. |
| 801 | - if ( is_wp_error( $user_id ) ) { |
|
| 802 | - return - 1; |
|
| 800 | + if (is_wp_error($user_id)) { |
|
| 801 | + return -1; |
|
| 803 | 802 | } |
| 804 | 803 | |
| 805 | 804 | // Allow themes and plugins to filter the user data. |
| 806 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
| 805 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
| 807 | 806 | |
| 808 | 807 | /** |
| 809 | 808 | * Fires after inserting user. |
@@ -813,7 +812,7 @@ discard block |
||
| 813 | 812 | * @param int $user_id User id. |
| 814 | 813 | * @param array $user_data Array containing user data. |
| 815 | 814 | */ |
| 816 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
| 815 | + do_action('give_insert_user', $user_id, $user_data); |
|
| 817 | 816 | |
| 818 | 817 | /** |
| 819 | 818 | * Filter allow user to alter if user when to login or not when user is register for the first time. |
@@ -822,9 +821,9 @@ discard block |
||
| 822 | 821 | * |
| 823 | 822 | * return bool True if login with registration and False if only want to register. |
| 824 | 823 | */ |
| 825 | - if ( true === (bool) apply_filters( 'give_log_user_in_on_register', true ) ) { |
|
| 824 | + if (true === (bool) apply_filters('give_log_user_in_on_register', true)) { |
|
| 826 | 825 | // Login new user. |
| 827 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
| 826 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
| 828 | 827 | } |
| 829 | 828 | |
| 830 | 829 | // Return user id. |
@@ -840,27 +839,27 @@ discard block |
||
| 840 | 839 | * @since 1.0 |
| 841 | 840 | * @return array|bool |
| 842 | 841 | */ |
| 843 | -function give_get_donation_form_user( $valid_data = array() ) { |
|
| 842 | +function give_get_donation_form_user($valid_data = array()) { |
|
| 844 | 843 | |
| 845 | 844 | // Initialize user. |
| 846 | 845 | $user = false; |
| 847 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
| 846 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
| 848 | 847 | |
| 849 | - if ( $is_ajax ) { |
|
| 848 | + if ($is_ajax) { |
|
| 850 | 849 | // Do not create or login the user during the ajax submission (check for errors only). |
| 851 | 850 | return true; |
| 852 | - } elseif ( is_user_logged_in() ) { |
|
| 851 | + } elseif (is_user_logged_in()) { |
|
| 853 | 852 | // Set the valid user as the logged in collected data. |
| 854 | 853 | $user = $valid_data['logged_in_user']; |
| 855 | - } elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
| 854 | + } elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
| 856 | 855 | // New user registration. |
| 857 | - if ( $valid_data['need_new_user'] === true ) { |
|
| 856 | + if ($valid_data['need_new_user'] === true) { |
|
| 858 | 857 | // Set user. |
| 859 | 858 | $user = $valid_data['new_user_data']; |
| 860 | 859 | // Register and login new user. |
| 861 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
| 860 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
| 862 | 861 | // User login |
| 863 | - } elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
| 862 | + } elseif ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
| 864 | 863 | |
| 865 | 864 | /** |
| 866 | 865 | * The login form is now processed in the give_process_donation_login() function. |
@@ -872,48 +871,48 @@ discard block |
||
| 872 | 871 | // Set user. |
| 873 | 872 | $user = $valid_data['login_user_data']; |
| 874 | 873 | // Login user. |
| 875 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
| 874 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
| 876 | 875 | } |
| 877 | 876 | } |
| 878 | 877 | |
| 879 | 878 | // Check guest checkout. |
| 880 | - if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { |
|
| 879 | + if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { |
|
| 881 | 880 | // Set user |
| 882 | 881 | $user = $valid_data['guest_user_data']; |
| 883 | 882 | } |
| 884 | 883 | |
| 885 | 884 | // Verify we have an user. |
| 886 | - if ( false === $user || empty( $user ) ) { |
|
| 885 | + if (false === $user || empty($user)) { |
|
| 887 | 886 | // Return false. |
| 888 | 887 | return false; |
| 889 | 888 | } |
| 890 | 889 | |
| 891 | 890 | // Get user first name. |
| 892 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
| 893 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
| 891 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
| 892 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
| 894 | 893 | } |
| 895 | 894 | |
| 896 | 895 | // Get user last name. |
| 897 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
| 898 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : ''; |
|
| 896 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
| 897 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : ''; |
|
| 899 | 898 | } |
| 900 | 899 | |
| 901 | 900 | // Get the user's billing address details. |
| 902 | 901 | $user['address'] = array(); |
| 903 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? give_clean( $_POST['card_address'] ) : false; |
|
| 904 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? give_clean( $_POST['card_address_2'] ) : false; |
|
| 905 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? give_clean( $_POST['card_city'] ) : false; |
|
| 906 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? give_clean( $_POST['card_state'] ) : false; |
|
| 907 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? give_clean( $_POST['card_zip'] ) : false; |
|
| 908 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : false; |
|
| 909 | - |
|
| 910 | - if ( empty( $user['address']['country'] ) ) { |
|
| 902 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? give_clean($_POST['card_address']) : false; |
|
| 903 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? give_clean($_POST['card_address_2']) : false; |
|
| 904 | + $user['address']['city'] = ! empty($_POST['card_city']) ? give_clean($_POST['card_city']) : false; |
|
| 905 | + $user['address']['state'] = ! empty($_POST['card_state']) ? give_clean($_POST['card_state']) : false; |
|
| 906 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? give_clean($_POST['card_zip']) : false; |
|
| 907 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : false; |
|
| 908 | + |
|
| 909 | + if (empty($user['address']['country'])) { |
|
| 911 | 910 | $user['address'] = false; |
| 912 | 911 | } // End if(). |
| 913 | 912 | |
| 914 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
| 913 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
| 915 | 914 | // Store the address in the user's meta so the donation form can be pre-populated with it on return donation. |
| 916 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
| 915 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
| 917 | 916 | } |
| 918 | 917 | |
| 919 | 918 | // Return valid user. |
@@ -932,16 +931,16 @@ discard block |
||
| 932 | 931 | $card_data = give_get_donation_cc_info(); |
| 933 | 932 | |
| 934 | 933 | // Validate the card zip. |
| 935 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
| 936 | - if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
| 937 | - give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
| 934 | + if ( ! empty($card_data['card_zip'])) { |
|
| 935 | + if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
| 936 | + give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
| 938 | 937 | } |
| 939 | 938 | } |
| 940 | 939 | |
| 941 | 940 | // Ensure no spaces. |
| 942 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
| 943 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs |
|
| 944 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
| 941 | + if ( ! empty($card_data['card_number'])) { |
|
| 942 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs |
|
| 943 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
| 945 | 944 | } |
| 946 | 945 | |
| 947 | 946 | // This should validate card numbers at some point too. |
@@ -958,17 +957,17 @@ discard block |
||
| 958 | 957 | function give_get_donation_cc_info() { |
| 959 | 958 | |
| 960 | 959 | $cc_info = array(); |
| 961 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
| 962 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
| 963 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
| 964 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
| 965 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
| 966 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
| 967 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
| 968 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
| 969 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
| 970 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
| 971 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
| 960 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
| 961 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
| 962 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
| 963 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
| 964 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
| 965 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
| 966 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
| 967 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
| 968 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
| 969 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
| 970 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
| 972 | 971 | |
| 973 | 972 | // Return cc info. |
| 974 | 973 | return $cc_info; |
@@ -984,14 +983,14 @@ discard block |
||
| 984 | 983 | * |
| 985 | 984 | * @return bool|mixed |
| 986 | 985 | */ |
| 987 | -function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
| 986 | +function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
| 988 | 987 | $ret = false; |
| 989 | 988 | |
| 990 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
| 989 | + if (empty($zip) || empty($country_code)) { |
|
| 991 | 990 | return $ret; |
| 992 | 991 | } |
| 993 | 992 | |
| 994 | - $country_code = strtoupper( $country_code ); |
|
| 993 | + $country_code = strtoupper($country_code); |
|
| 995 | 994 | |
| 996 | 995 | $zip_regex = array( |
| 997 | 996 | 'AD' => 'AD\d{3}', |
@@ -1151,11 +1150,11 @@ discard block |
||
| 1151 | 1150 | 'ZM' => '\d{5}', |
| 1152 | 1151 | ); |
| 1153 | 1152 | |
| 1154 | - if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { |
|
| 1153 | + if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { |
|
| 1155 | 1154 | $ret = true; |
| 1156 | 1155 | } |
| 1157 | 1156 | |
| 1158 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
| 1157 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
| 1159 | 1158 | } |
| 1160 | 1159 | |
| 1161 | 1160 | |
@@ -1169,33 +1168,33 @@ discard block |
||
| 1169 | 1168 | * |
| 1170 | 1169 | * @return bool |
| 1171 | 1170 | */ |
| 1172 | -function give_validate_multi_donation_form_level( $valid_data, $data ) { |
|
| 1171 | +function give_validate_multi_donation_form_level($valid_data, $data) { |
|
| 1173 | 1172 | /* @var Give_Donate_Form $form */ |
| 1174 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
| 1173 | + $form = new Give_Donate_Form($data['give-form-id']); |
|
| 1175 | 1174 | |
| 1176 | 1175 | $donation_level_matched = false; |
| 1177 | 1176 | |
| 1178 | - if ( $form->is_multi_type_donation_form() ) { |
|
| 1177 | + if ($form->is_multi_type_donation_form()) { |
|
| 1179 | 1178 | |
| 1180 | 1179 | // Bailout. |
| 1181 | - if ( ! ( $variable_prices = $form->get_prices() ) ) { |
|
| 1180 | + if ( ! ($variable_prices = $form->get_prices())) { |
|
| 1182 | 1181 | return false; |
| 1183 | 1182 | } |
| 1184 | 1183 | |
| 1185 | 1184 | // Sanitize donation amount. |
| 1186 | - $data['give-amount'] = give_maybe_sanitize_amount( $data['give-amount'] ); |
|
| 1185 | + $data['give-amount'] = give_maybe_sanitize_amount($data['give-amount']); |
|
| 1187 | 1186 | |
| 1188 | - if ( $data['give-amount'] === give_maybe_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ) ) ) { |
|
| 1187 | + if ($data['give-amount'] === give_maybe_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']))) { |
|
| 1189 | 1188 | return true; |
| 1190 | 1189 | } |
| 1191 | 1190 | |
| 1192 | 1191 | // Find correct donation level from all donation levels. |
| 1193 | - foreach ( $variable_prices as $variable_price ) { |
|
| 1192 | + foreach ($variable_prices as $variable_price) { |
|
| 1194 | 1193 | // Sanitize level amount. |
| 1195 | - $variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] ); |
|
| 1194 | + $variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']); |
|
| 1196 | 1195 | |
| 1197 | 1196 | // Set first match donation level ID. |
| 1198 | - if ( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
| 1197 | + if ($data['give-amount'] === $variable_price['_give_amount']) { |
|
| 1199 | 1198 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
| 1200 | 1199 | $donation_level_matched = true; |
| 1201 | 1200 | break; |
@@ -1206,19 +1205,19 @@ discard block |
||
| 1206 | 1205 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
| 1207 | 1206 | if ( |
| 1208 | 1207 | ! $donation_level_matched |
| 1209 | - && ( give_is_setting_enabled( give_get_meta( $data['give-form-id'], '_give_custom_amount', true ) ) ) |
|
| 1208 | + && (give_is_setting_enabled(give_get_meta($data['give-form-id'], '_give_custom_amount', true))) |
|
| 1210 | 1209 | ) { |
| 1211 | 1210 | // Sanitize custom minimum amount. |
| 1212 | - $custom_minimum_amount = give_maybe_sanitize_amount( give_get_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ) ); |
|
| 1211 | + $custom_minimum_amount = give_maybe_sanitize_amount(give_get_meta($data['give-form-id'], '_give_custom_amount_minimum', true)); |
|
| 1213 | 1212 | |
| 1214 | - if ( $data['give-amount'] >= $custom_minimum_amount ) { |
|
| 1213 | + if ($data['give-amount'] >= $custom_minimum_amount) { |
|
| 1215 | 1214 | $_POST['give-price-id'] = 'custom'; |
| 1216 | 1215 | $donation_level_matched = true; |
| 1217 | 1216 | } |
| 1218 | 1217 | } |
| 1219 | 1218 | }// End if(). |
| 1220 | 1219 | |
| 1221 | - return ( $donation_level_matched ? true : false ); |
|
| 1220 | + return ($donation_level_matched ? true : false); |
|
| 1222 | 1221 | } |
| 1223 | 1222 | |
| 1224 | -add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 ); |
|
| 1223 | +add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2); |
|
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @return mixed array if errors are present, false if none found |
| 26 | 26 | */ |
| 27 | 27 | function give_get_errors() { |
| 28 | - return Give()->session->get( 'give_errors' ); |
|
| 28 | + return Give()->session->get('give_errors'); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -42,23 +42,23 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return void |
| 44 | 44 | */ |
| 45 | -function give_set_error( $error_id, $error_message, $notice_args = array() ) { |
|
| 45 | +function give_set_error($error_id, $error_message, $notice_args = array()) { |
|
| 46 | 46 | $errors = give_get_errors(); |
| 47 | - if ( ! $errors ) { |
|
| 47 | + if ( ! $errors) { |
|
| 48 | 48 | $errors = array(); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - if( is_array( $notice_args ) && ! empty( $notice_args ) ) { |
|
| 52 | - $errors[ $error_id ] = array( |
|
| 51 | + if (is_array($notice_args) && ! empty($notice_args)) { |
|
| 52 | + $errors[$error_id] = array( |
|
| 53 | 53 | 'message' => $error_message, |
| 54 | 54 | 'notice_args' => $notice_args, |
| 55 | 55 | ); |
| 56 | 56 | } else { |
| 57 | 57 | // Backward compatibility v<1.8.11. |
| 58 | - $errors[ $error_id ] = $error_message; |
|
| 58 | + $errors[$error_id] = $error_message; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - Give()->session->set( 'give_errors', $errors ); |
|
| 61 | + Give()->session->set('give_errors', $errors); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @return void |
| 70 | 70 | */ |
| 71 | 71 | function give_clear_errors() { |
| 72 | - Give()->session->set( 'give_errors', null ); |
|
| 72 | + Give()->session->set('give_errors', null); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -82,19 +82,19 @@ discard block |
||
| 82 | 82 | * |
| 83 | 83 | * @return void |
| 84 | 84 | */ |
| 85 | -function give_unset_error( $error_id ) { |
|
| 85 | +function give_unset_error($error_id) { |
|
| 86 | 86 | $errors = give_get_errors(); |
| 87 | - if ( $errors ) { |
|
| 87 | + if ($errors) { |
|
| 88 | 88 | /** |
| 89 | 89 | * Check If $error_id exists in the array. |
| 90 | 90 | * If exists then unset it. |
| 91 | 91 | * |
| 92 | 92 | * @since 1.8.13 |
| 93 | 93 | */ |
| 94 | - if ( isset( $errors[ $error_id ] ) ) { |
|
| 95 | - unset( $errors[ $error_id ] ); |
|
| 94 | + if (isset($errors[$error_id])) { |
|
| 95 | + unset($errors[$error_id]); |
|
| 96 | 96 | } |
| 97 | - Give()->session->set( 'give_errors', $errors ); |
|
| 97 | + Give()->session->set('give_errors', $errors); |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | 107 | function _give_die_handler() { |
| 108 | - if ( defined( 'GIVE_UNIT_TESTS' ) ) { |
|
| 108 | + if (defined('GIVE_UNIT_TESTS')) { |
|
| 109 | 109 | return '_give_die_handler'; |
| 110 | 110 | } else { |
| 111 | 111 | die(); |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | * @return void |
| 127 | 127 | */ |
| 128 | -function give_die( $message = '', $title = '', $status = 400 ) { |
|
| 129 | - add_filter( 'wp_die_ajax_handler', '_give_die_handler', 10, 3 ); |
|
| 130 | - add_filter( 'wp_die_handler', '_give_die_handler', 10, 3 ); |
|
| 131 | - wp_die( $message, $title, array( 'response' => $status ) ); |
|
| 128 | +function give_die($message = '', $title = '', $status = 400) { |
|
| 129 | + add_filter('wp_die_ajax_handler', '_give_die_handler', 10, 3); |
|
| 130 | + add_filter('wp_die_handler', '_give_die_handler', 10, 3); |
|
| 131 | + wp_die($message, $title, array('response' => $status)); |
|
| 132 | 132 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -23,50 +23,50 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return string Donation form. |
| 25 | 25 | */ |
| 26 | -function give_get_donation_form( $args = array() ) { |
|
| 26 | +function give_get_donation_form($args = array()) { |
|
| 27 | 27 | |
| 28 | 28 | global $post; |
| 29 | 29 | |
| 30 | - $form_id = is_object( $post ) ? $post->ID : 0; |
|
| 30 | + $form_id = is_object($post) ? $post->ID : 0; |
|
| 31 | 31 | |
| 32 | - if ( isset( $args['id'] ) ) { |
|
| 32 | + if (isset($args['id'])) { |
|
| 33 | 33 | $form_id = $args['id']; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - $defaults = apply_filters( 'give_form_args_defaults', array( |
|
| 36 | + $defaults = apply_filters('give_form_args_defaults', array( |
|
| 37 | 37 | 'form_id' => $form_id, |
| 38 | - ) ); |
|
| 38 | + )); |
|
| 39 | 39 | |
| 40 | - $args = wp_parse_args( $args, $defaults ); |
|
| 40 | + $args = wp_parse_args($args, $defaults); |
|
| 41 | 41 | |
| 42 | - $form = new Give_Donate_Form( $args['form_id'] ); |
|
| 42 | + $form = new Give_Donate_Form($args['form_id']); |
|
| 43 | 43 | |
| 44 | 44 | //bail if no form ID. |
| 45 | - if ( empty( $form->ID ) ) { |
|
| 45 | + if (empty($form->ID)) { |
|
| 46 | 46 | return false; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - $payment_mode = give_get_chosen_gateway( $form->ID ); |
|
| 49 | + $payment_mode = give_get_chosen_gateway($form->ID); |
|
| 50 | 50 | |
| 51 | - $form_action = add_query_arg( apply_filters( 'give_form_action_args', array( |
|
| 51 | + $form_action = add_query_arg(apply_filters('give_form_action_args', array( |
|
| 52 | 52 | 'payment-mode' => $payment_mode, |
| 53 | - ) ), |
|
| 53 | + )), |
|
| 54 | 54 | give_get_current_page_url() |
| 55 | 55 | ); |
| 56 | 56 | |
| 57 | 57 | //Sanity Check: Donation form not published or user doesn't have permission to view drafts. |
| 58 | 58 | if ( |
| 59 | - ( 'publish' !== $form->post_status && ! current_user_can( 'edit_give_forms', $form->ID ) ) |
|
| 60 | - || ( 'trash' === $form->post_status ) |
|
| 59 | + ('publish' !== $form->post_status && ! current_user_can('edit_give_forms', $form->ID)) |
|
| 60 | + || ('trash' === $form->post_status) |
|
| 61 | 61 | ) { |
| 62 | 62 | return false; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | //Get the form wrap CSS classes. |
| 66 | - $form_wrap_classes = $form->get_form_wrap_classes( $args ); |
|
| 66 | + $form_wrap_classes = $form->get_form_wrap_classes($args); |
|
| 67 | 67 | |
| 68 | 68 | //Get the <form> tag wrap CSS classes. |
| 69 | - $form_classes = $form->get_form_classes( $args ); |
|
| 69 | + $form_classes = $form->get_form_classes($args); |
|
| 70 | 70 | |
| 71 | 71 | ob_start(); |
| 72 | 72 | |
@@ -78,19 +78,19 @@ discard block |
||
| 78 | 78 | * @param int $form_id The form ID. |
| 79 | 79 | * @param array $args An array of form arguments. |
| 80 | 80 | */ |
| 81 | - do_action( 'give_pre_form_output', $form->ID, $args ); |
|
| 81 | + do_action('give_pre_form_output', $form->ID, $args); |
|
| 82 | 82 | |
| 83 | 83 | ?> |
| 84 | 84 | <div id="give-form-<?php echo $form->ID; ?>-wrap" class="<?php echo $form_wrap_classes; ?>"> |
| 85 | 85 | |
| 86 | - <?php if ( $form->is_close_donation_form() ) { |
|
| 86 | + <?php if ($form->is_close_donation_form()) { |
|
| 87 | 87 | |
| 88 | 88 | // Get Goal thank you message. |
| 89 | - $goal_achieved_message = give_get_meta( $form->ID, '_give_form_goal_achieved_message', true ); |
|
| 90 | - $goal_achieved_message = ! empty( $goal_achieved_message ) ? apply_filters( 'the_content', $goal_achieved_message ) : ''; |
|
| 89 | + $goal_achieved_message = give_get_meta($form->ID, '_give_form_goal_achieved_message', true); |
|
| 90 | + $goal_achieved_message = ! empty($goal_achieved_message) ? apply_filters('the_content', $goal_achieved_message) : ''; |
|
| 91 | 91 | |
| 92 | 92 | // Print thank you message. |
| 93 | - echo apply_filters( 'give_goal_closed_output', $goal_achieved_message, $form->ID ); |
|
| 93 | + echo apply_filters('give_goal_closed_output', $goal_achieved_message, $form->ID); |
|
| 94 | 94 | |
| 95 | 95 | } else { |
| 96 | 96 | /** |
@@ -98,10 +98,10 @@ discard block |
||
| 98 | 98 | * 1. if show_title params set to true |
| 99 | 99 | * 2. if admin set form display_style to button |
| 100 | 100 | */ |
| 101 | - $form_title = apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ); |
|
| 101 | + $form_title = apply_filters('give_form_title', '<h2 class="give-form-title">'.get_the_title($form_id).'</h2>'); |
|
| 102 | 102 | if ( |
| 103 | - ( isset( $args['show_title'] ) && $args['show_title'] == true ) |
|
| 104 | - && ! doing_action( 'give_single_form_summary' ) |
|
| 103 | + (isset($args['show_title']) && $args['show_title'] == true) |
|
| 104 | + && ! doing_action('give_single_form_summary') |
|
| 105 | 105 | ) { |
| 106 | 106 | echo $form_title; |
| 107 | 107 | } |
@@ -114,19 +114,19 @@ discard block |
||
| 114 | 114 | * @param int $form_id The form ID. |
| 115 | 115 | * @param array $args An array of form arguments. |
| 116 | 116 | */ |
| 117 | - do_action( 'give_pre_form', $form->ID, $args ); |
|
| 117 | + do_action('give_pre_form', $form->ID, $args); |
|
| 118 | 118 | ?> |
| 119 | 119 | |
| 120 | 120 | <form id="give-form-<?php echo $form_id; ?>" class="<?php echo $form_classes; ?>" |
| 121 | - action="<?php echo esc_url_raw( $form_action ); ?>" method="post"> |
|
| 121 | + action="<?php echo esc_url_raw($form_action); ?>" method="post"> |
|
| 122 | 122 | <input type="hidden" name="give-form-id" value="<?php echo $form->ID; ?>"/> |
| 123 | - <input type="hidden" name="give-form-title" value="<?php echo htmlentities( $form->post_title ); ?>"/> |
|
| 123 | + <input type="hidden" name="give-form-title" value="<?php echo htmlentities($form->post_title); ?>"/> |
|
| 124 | 124 | <input type="hidden" name="give-current-url" |
| 125 | - value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
| 125 | + value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
| 126 | 126 | <input type="hidden" name="give-form-url" |
| 127 | - value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
| 127 | + value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
| 128 | 128 | <input type="hidden" name="give-form-minimum" |
| 129 | - value="<?php echo give_format_amount( give_get_form_minimum_price( $form->ID ), array( 'sanitize' => false ) ); ?>"/> |
|
| 129 | + value="<?php echo give_format_amount(give_get_form_minimum_price($form->ID), array('sanitize' => false)); ?>"/> |
|
| 130 | 130 | |
| 131 | 131 | <!-- The following field is for robots only, invisible to humans: --> |
| 132 | 132 | <span class="give-hidden" style="display: none !important;"> |
@@ -138,13 +138,13 @@ discard block |
||
| 138 | 138 | <?php |
| 139 | 139 | |
| 140 | 140 | // Price ID hidden field for variable (multi-level) donation forms. |
| 141 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 141 | + if (give_has_variable_prices($form_id)) { |
|
| 142 | 142 | // Get default selected price ID. |
| 143 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
| 143 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
| 144 | 144 | $price_id = 0; |
| 145 | 145 | //loop through prices. |
| 146 | - foreach ( $prices as $price ) { |
|
| 147 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
| 146 | + foreach ($prices as $price) { |
|
| 147 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
| 148 | 148 | $price_id = $price['_give_id']['level_id']; |
| 149 | 149 | }; |
| 150 | 150 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | * @param int $form_id The form ID. |
| 161 | 161 | * @param array $args An array of form arguments. |
| 162 | 162 | */ |
| 163 | - do_action( 'give_donation_form_top', $form->ID, $args ); |
|
| 163 | + do_action('give_donation_form_top', $form->ID, $args); |
|
| 164 | 164 | |
| 165 | 165 | /** |
| 166 | 166 | * Fires while outputting donation form, for payment gateway fields. |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * @param int $form_id The form ID. |
| 171 | 171 | * @param array $args An array of form arguments. |
| 172 | 172 | */ |
| 173 | - do_action( 'give_payment_mode_select', $form->ID, $args ); |
|
| 173 | + do_action('give_payment_mode_select', $form->ID, $args); |
|
| 174 | 174 | |
| 175 | 175 | /** |
| 176 | 176 | * Fires while outputting donation form, after all other fields. |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * @param int $form_id The form ID. |
| 181 | 181 | * @param array $args An array of form arguments. |
| 182 | 182 | */ |
| 183 | - do_action( 'give_donation_form_bottom', $form->ID, $args ); |
|
| 183 | + do_action('give_donation_form_bottom', $form->ID, $args); |
|
| 184 | 184 | |
| 185 | 185 | ?> |
| 186 | 186 | </form> |
@@ -194,12 +194,12 @@ discard block |
||
| 194 | 194 | * @param int $form_id The form ID. |
| 195 | 195 | * @param array $args An array of form arguments. |
| 196 | 196 | */ |
| 197 | - do_action( 'give_post_form', $form->ID, $args ); |
|
| 197 | + do_action('give_post_form', $form->ID, $args); |
|
| 198 | 198 | |
| 199 | 199 | } |
| 200 | 200 | ?> |
| 201 | 201 | |
| 202 | - </div><!--end #give-form-<?php echo absint( $form->ID ); ?>--> |
|
| 202 | + </div><!--end #give-form-<?php echo absint($form->ID); ?>--> |
|
| 203 | 203 | <?php |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -210,11 +210,11 @@ discard block |
||
| 210 | 210 | * @param int $form_id The form ID. |
| 211 | 211 | * @param array $args An array of form arguments. |
| 212 | 212 | */ |
| 213 | - do_action( 'give_post_form_output', $form->ID, $args ); |
|
| 213 | + do_action('give_post_form_output', $form->ID, $args); |
|
| 214 | 214 | |
| 215 | 215 | $final_output = ob_get_clean(); |
| 216 | 216 | |
| 217 | - echo apply_filters( 'give_donate_form', $final_output, $args ); |
|
| 217 | + echo apply_filters('give_donate_form', $final_output, $args); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -231,11 +231,11 @@ discard block |
||
| 231 | 231 | * |
| 232 | 232 | * @return string |
| 233 | 233 | */ |
| 234 | -function give_show_purchase_form( $form_id ) { |
|
| 234 | +function give_show_purchase_form($form_id) { |
|
| 235 | 235 | |
| 236 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
| 236 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
| 237 | 237 | |
| 238 | - if ( ! isset( $form_id ) && isset( $_POST['give_form_id'] ) ) { |
|
| 238 | + if ( ! isset($form_id) && isset($_POST['give_form_id'])) { |
|
| 239 | 239 | $form_id = $_POST['give_form_id']; |
| 240 | 240 | } |
| 241 | 241 | |
@@ -244,33 +244,33 @@ discard block |
||
| 244 | 244 | * |
| 245 | 245 | * @since 1.7 |
| 246 | 246 | */ |
| 247 | - do_action( 'give_payment_fields_top', $form_id ); |
|
| 247 | + do_action('give_payment_fields_top', $form_id); |
|
| 248 | 248 | |
| 249 | - if ( give_can_checkout() && isset( $form_id ) ) { |
|
| 249 | + if (give_can_checkout() && isset($form_id)) { |
|
| 250 | 250 | |
| 251 | 251 | /** |
| 252 | 252 | * Fires while displaying donation form, before registration login. |
| 253 | 253 | * |
| 254 | 254 | * @since 1.7 |
| 255 | 255 | */ |
| 256 | - do_action( 'give_donation_form_before_register_login', $form_id ); |
|
| 256 | + do_action('give_donation_form_before_register_login', $form_id); |
|
| 257 | 257 | |
| 258 | 258 | /** |
| 259 | 259 | * Fire when register/login form fields render. |
| 260 | 260 | * |
| 261 | 261 | * @since 1.7 |
| 262 | 262 | */ |
| 263 | - do_action( 'give_donation_form_register_login_fields', $form_id ); |
|
| 263 | + do_action('give_donation_form_register_login_fields', $form_id); |
|
| 264 | 264 | |
| 265 | 265 | /** |
| 266 | 266 | * Fire when credit card form fields render. |
| 267 | 267 | * |
| 268 | 268 | * @since 1.7 |
| 269 | 269 | */ |
| 270 | - do_action( 'give_donation_form_before_cc_form', $form_id ); |
|
| 270 | + do_action('give_donation_form_before_cc_form', $form_id); |
|
| 271 | 271 | |
| 272 | 272 | // Load the credit card form and allow gateways to load their own if they wish. |
| 273 | - if ( has_action( 'give_' . $payment_mode . '_cc_form' ) ) { |
|
| 273 | + if (has_action('give_'.$payment_mode.'_cc_form')) { |
|
| 274 | 274 | /** |
| 275 | 275 | * Fires while displaying donation form, credit card form fields for a given gateway. |
| 276 | 276 | * |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | * |
| 279 | 279 | * @param int $form_id The form ID. |
| 280 | 280 | */ |
| 281 | - do_action( "give_{$payment_mode}_cc_form", $form_id ); |
|
| 281 | + do_action("give_{$payment_mode}_cc_form", $form_id); |
|
| 282 | 282 | } else { |
| 283 | 283 | /** |
| 284 | 284 | * Fires while displaying donation form, credit card form fields. |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | * |
| 288 | 288 | * @param int $form_id The form ID. |
| 289 | 289 | */ |
| 290 | - do_action( 'give_cc_form', $form_id ); |
|
| 290 | + do_action('give_cc_form', $form_id); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | /** |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | * |
| 296 | 296 | * @since 1.7 |
| 297 | 297 | */ |
| 298 | - do_action( 'give_donation_form_after_cc_form', $form_id ); |
|
| 298 | + do_action('give_donation_form_after_cc_form', $form_id); |
|
| 299 | 299 | |
| 300 | 300 | } else { |
| 301 | 301 | /** |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | * |
| 304 | 304 | * @since 1.7 |
| 305 | 305 | */ |
| 306 | - do_action( 'give_donation_form_no_access', $form_id ); |
|
| 306 | + do_action('give_donation_form_no_access', $form_id); |
|
| 307 | 307 | |
| 308 | 308 | } |
| 309 | 309 | |
@@ -312,10 +312,10 @@ discard block |
||
| 312 | 312 | * |
| 313 | 313 | * @since 1.7 |
| 314 | 314 | */ |
| 315 | - do_action( 'give_payment_fields_bottom', $form_id ); |
|
| 315 | + do_action('give_payment_fields_bottom', $form_id); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | -add_action( 'give_donation_form', 'give_show_purchase_form' ); |
|
| 318 | +add_action('give_donation_form', 'give_show_purchase_form'); |
|
| 319 | 319 | |
| 320 | 320 | /** |
| 321 | 321 | * Give Show Login/Register Form Fields. |
@@ -326,11 +326,11 @@ discard block |
||
| 326 | 326 | * |
| 327 | 327 | * @return void |
| 328 | 328 | */ |
| 329 | -function give_show_register_login_fields( $form_id ) { |
|
| 329 | +function give_show_register_login_fields($form_id) { |
|
| 330 | 330 | |
| 331 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
| 331 | + $show_register_form = give_show_login_register_option($form_id); |
|
| 332 | 332 | |
| 333 | - if ( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
| 333 | + if (($show_register_form === 'registration' || ($show_register_form === 'both' && ! isset($_GET['login']))) && ! is_user_logged_in()) : |
|
| 334 | 334 | ?> |
| 335 | 335 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
| 336 | 336 | <?php |
@@ -339,11 +339,11 @@ discard block |
||
| 339 | 339 | * |
| 340 | 340 | * @since 1.7 |
| 341 | 341 | */ |
| 342 | - do_action( 'give_donation_form_register_fields', $form_id ); |
|
| 342 | + do_action('give_donation_form_register_fields', $form_id); |
|
| 343 | 343 | ?> |
| 344 | 344 | </div> |
| 345 | 345 | <?php |
| 346 | - elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
| 346 | + elseif (($show_register_form === 'login' || ($show_register_form === 'both' && isset($_GET['login']))) && ! is_user_logged_in()) : |
|
| 347 | 347 | ?> |
| 348 | 348 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
| 349 | 349 | <?php |
@@ -352,23 +352,23 @@ discard block |
||
| 352 | 352 | * |
| 353 | 353 | * @since 1.7 |
| 354 | 354 | */ |
| 355 | - do_action( 'give_donation_form_login_fields', $form_id ); |
|
| 355 | + do_action('give_donation_form_login_fields', $form_id); |
|
| 356 | 356 | ?> |
| 357 | 357 | </div> |
| 358 | 358 | <?php |
| 359 | 359 | endif; |
| 360 | 360 | |
| 361 | - if ( ( ! isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form || 'login' === $show_register_form ) { |
|
| 361 | + if (( ! isset($_GET['login']) && is_user_logged_in()) || ! isset($show_register_form) || 'none' === $show_register_form || 'login' === $show_register_form) { |
|
| 362 | 362 | /** |
| 363 | 363 | * Fire when user info render. |
| 364 | 364 | * |
| 365 | 365 | * @since 1.7 |
| 366 | 366 | */ |
| 367 | - do_action( 'give_donation_form_after_user_info', $form_id ); |
|
| 367 | + do_action('give_donation_form_after_user_info', $form_id); |
|
| 368 | 368 | } |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | -add_action( 'give_donation_form_register_login_fields', 'give_show_register_login_fields' ); |
|
| 371 | +add_action('give_donation_form_register_login_fields', 'give_show_register_login_fields'); |
|
| 372 | 372 | |
| 373 | 373 | /** |
| 374 | 374 | * Donation Amount Field. |
@@ -383,16 +383,16 @@ discard block |
||
| 383 | 383 | * |
| 384 | 384 | * @return void |
| 385 | 385 | */ |
| 386 | -function give_output_donation_amount_top( $form_id = 0, $args = array() ) { |
|
| 386 | +function give_output_donation_amount_top($form_id = 0, $args = array()) { |
|
| 387 | 387 | |
| 388 | 388 | $give_options = give_get_settings(); |
| 389 | - $variable_pricing = give_has_variable_prices( $form_id ); |
|
| 390 | - $allow_custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
| 391 | - $currency_position = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before'; |
|
| 392 | - $symbol = give_currency_symbol( give_get_currency() ); |
|
| 393 | - $currency_output = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>'; |
|
| 394 | - $default_amount = give_format_amount( give_get_default_form_amount( $form_id ), array( 'sanitize' => false ) ); |
|
| 395 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 389 | + $variable_pricing = give_has_variable_prices($form_id); |
|
| 390 | + $allow_custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
| 391 | + $currency_position = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before'; |
|
| 392 | + $symbol = give_currency_symbol(give_get_currency()); |
|
| 393 | + $currency_output = '<span class="give-currency-symbol give-currency-position-'.$currency_position.'">'.$symbol.'</span>'; |
|
| 394 | + $default_amount = give_format_amount(give_get_default_form_amount($form_id), array('sanitize' => false)); |
|
| 395 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
| 396 | 396 | |
| 397 | 397 | /** |
| 398 | 398 | * Fires while displaying donation form, before donation level fields. |
@@ -402,20 +402,20 @@ discard block |
||
| 402 | 402 | * @param int $form_id The form ID. |
| 403 | 403 | * @param array $args An array of form arguments. |
| 404 | 404 | */ |
| 405 | - do_action( 'give_before_donation_levels', $form_id, $args ); |
|
| 405 | + do_action('give_before_donation_levels', $form_id, $args); |
|
| 406 | 406 | |
| 407 | 407 | //Set Price, No Custom Amount Allowed means hidden price field |
| 408 | - if ( ! give_is_setting_enabled( $allow_custom_amount ) ) { |
|
| 408 | + if ( ! give_is_setting_enabled($allow_custom_amount)) { |
|
| 409 | 409 | ?> |
| 410 | - <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
| 410 | + <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
| 411 | 411 | <input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount" |
| 412 | 412 | value="<?php echo $default_amount; ?>" required aria-required="true"/> |
| 413 | 413 | <div class="set-price give-donation-amount form-row-wide"> |
| 414 | - <?php if ( $currency_position == 'before' ) { |
|
| 414 | + <?php if ($currency_position == 'before') { |
|
| 415 | 415 | echo $currency_output; |
| 416 | 416 | } ?> |
| 417 | 417 | <span id="give-amount-text" class="give-text-input give-amount-top"><?php echo $default_amount; ?></span> |
| 418 | - <?php if ( $currency_position == 'after' ) { |
|
| 418 | + <?php if ($currency_position == 'after') { |
|
| 419 | 419 | echo $currency_output; |
| 420 | 420 | } ?> |
| 421 | 421 | </div> |
@@ -425,13 +425,13 @@ discard block |
||
| 425 | 425 | ?> |
| 426 | 426 | <div class="give-total-wrap"> |
| 427 | 427 | <div class="give-donation-amount form-row-wide"> |
| 428 | - <?php if ( $currency_position == 'before' ) { |
|
| 428 | + <?php if ($currency_position == 'before') { |
|
| 429 | 429 | echo $currency_output; |
| 430 | 430 | } ?> |
| 431 | - <label class="give-hidden" for="give-amount"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
| 431 | + <label class="give-hidden" for="give-amount"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
| 432 | 432 | <input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="tel" |
| 433 | 433 | placeholder="" value="<?php echo $default_amount; ?>" autocomplete="off"> |
| 434 | - <?php if ( $currency_position == 'after' ) { |
|
| 434 | + <?php if ($currency_position == 'after') { |
|
| 435 | 435 | echo $currency_output; |
| 436 | 436 | } ?> |
| 437 | 437 | </div> |
@@ -446,16 +446,16 @@ discard block |
||
| 446 | 446 | * @param int $form_id The form ID. |
| 447 | 447 | * @param array $args An array of form arguments. |
| 448 | 448 | */ |
| 449 | - do_action( 'give_after_donation_amount', $form_id, $args ); |
|
| 449 | + do_action('give_after_donation_amount', $form_id, $args); |
|
| 450 | 450 | |
| 451 | 451 | //Custom Amount Text |
| 452 | - if ( ! $variable_pricing && give_is_setting_enabled( $allow_custom_amount ) && ! empty( $custom_amount_text ) ) { ?> |
|
| 452 | + if ( ! $variable_pricing && give_is_setting_enabled($allow_custom_amount) && ! empty($custom_amount_text)) { ?> |
|
| 453 | 453 | <p class="give-custom-amount-text"><?php echo $custom_amount_text; ?></p> |
| 454 | 454 | <?php } |
| 455 | 455 | |
| 456 | 456 | //Output Variable Pricing Levels. |
| 457 | - if ( $variable_pricing ) { |
|
| 458 | - give_output_levels( $form_id ); |
|
| 457 | + if ($variable_pricing) { |
|
| 458 | + give_output_levels($form_id); |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | /** |
@@ -466,10 +466,10 @@ discard block |
||
| 466 | 466 | * @param int $form_id The form ID. |
| 467 | 467 | * @param array $args An array of form arguments. |
| 468 | 468 | */ |
| 469 | - do_action( 'give_after_donation_levels', $form_id, $args ); |
|
| 469 | + do_action('give_after_donation_levels', $form_id, $args); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | -add_action( 'give_donation_form_top', 'give_output_donation_amount_top', 10, 2 ); |
|
| 472 | +add_action('give_donation_form_top', 'give_output_donation_amount_top', 10, 2); |
|
| 473 | 473 | |
| 474 | 474 | /** |
| 475 | 475 | * Outputs the Donation Levels in various formats such as dropdown, radios, and buttons. |
@@ -480,30 +480,30 @@ discard block |
||
| 480 | 480 | * |
| 481 | 481 | * @return string Donation levels. |
| 482 | 482 | */ |
| 483 | -function give_output_levels( $form_id ) { |
|
| 483 | +function give_output_levels($form_id) { |
|
| 484 | 484 | |
| 485 | 485 | //Get variable pricing. |
| 486 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
| 487 | - $display_style = give_get_meta( $form_id, '_give_display_style', true ); |
|
| 488 | - $custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
| 489 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 490 | - if ( empty( $custom_amount_text ) ) { |
|
| 491 | - $custom_amount_text = esc_html__( 'Give a Custom Amount', 'give' ); |
|
| 486 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
| 487 | + $display_style = give_get_meta($form_id, '_give_display_style', true); |
|
| 488 | + $custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
| 489 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
| 490 | + if (empty($custom_amount_text)) { |
|
| 491 | + $custom_amount_text = esc_html__('Give a Custom Amount', 'give'); |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | $output = ''; |
| 495 | 495 | |
| 496 | - switch ( $display_style ) { |
|
| 496 | + switch ($display_style) { |
|
| 497 | 497 | case 'buttons': |
| 498 | 498 | |
| 499 | 499 | $output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">'; |
| 500 | 500 | |
| 501 | - foreach ( $prices as $price ) { |
|
| 502 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
| 503 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-' . $price['_give_id']['level_id'] . ' ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'give-default-level' : '' ), $form_id, $price ); |
|
| 501 | + foreach ($prices as $price) { |
|
| 502 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
| 503 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-'.$price['_give_id']['level_id'].' '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'give-default-level' : ''), $form_id, $price); |
|
| 504 | 504 | |
| 505 | 505 | $output .= '<li>'; |
| 506 | - $output .= '<button type="button" data-price-id="' . $price['_give_id']['level_id'] . '" class=" ' . $level_classes . '" value="' . give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) . '">'; |
|
| 506 | + $output .= '<button type="button" data-price-id="'.$price['_give_id']['level_id'].'" class=" '.$level_classes.'" value="'.give_format_amount($price['_give_amount'], array('sanitize' => false)).'">'; |
|
| 507 | 507 | $output .= $level_text; |
| 508 | 508 | $output .= '</button>'; |
| 509 | 509 | $output .= '</li>'; |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | //Custom Amount. |
| 514 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
| 514 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
| 515 | 515 | $output .= '<li>'; |
| 516 | 516 | $output .= '<button type="button" data-price-id="custom" class="give-donation-level-btn give-btn give-btn-level-custom" value="custom">'; |
| 517 | 517 | $output .= $custom_amount_text; |
@@ -527,22 +527,22 @@ discard block |
||
| 527 | 527 | |
| 528 | 528 | $output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">'; |
| 529 | 529 | |
| 530 | - foreach ( $prices as $price ) { |
|
| 531 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
| 532 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
| 530 | + foreach ($prices as $price) { |
|
| 531 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
| 532 | + $level_classes = apply_filters('give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-'.$price['_give_id']['level_id'].((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
| 533 | 533 | |
| 534 | 534 | $output .= '<li>'; |
| 535 | - $output .= '<input type="radio" data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" name="give-radio-donation-level" id="give-radio-level-' . $price['_give_id']['level_id'] . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'checked="checked"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) . '">'; |
|
| 536 | - $output .= '<label for="give-radio-level-' . $price['_give_id']['level_id'] . '">' . $level_text . '</label>'; |
|
| 535 | + $output .= '<input type="radio" data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" name="give-radio-donation-level" id="give-radio-level-'.$price['_give_id']['level_id'].'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'checked="checked"' : '').' value="'.give_format_amount($price['_give_amount'], array('sanitize' => false)).'">'; |
|
| 536 | + $output .= '<label for="give-radio-level-'.$price['_give_id']['level_id'].'">'.$level_text.'</label>'; |
|
| 537 | 537 | $output .= '</li>'; |
| 538 | 538 | |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | //Custom Amount. |
| 542 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
| 542 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
| 543 | 543 | $output .= '<li>'; |
| 544 | 544 | $output .= '<input type="radio" data-price-id="custom" class="give-radio-input give-radio-input-level give-radio-level-custom" name="give-radio-donation-level" id="give-radio-level-custom" value="custom">'; |
| 545 | - $output .= '<label for="give-radio-level-custom">' . $custom_amount_text . '</label>'; |
|
| 545 | + $output .= '<label for="give-radio-level-custom">'.$custom_amount_text.'</label>'; |
|
| 546 | 546 | $output .= '</li>'; |
| 547 | 547 | } |
| 548 | 548 | |
@@ -552,23 +552,23 @@ discard block |
||
| 552 | 552 | |
| 553 | 553 | case 'dropdown': |
| 554 | 554 | |
| 555 | - $output .= '<label for="give-donation-level-select-' . $form_id . '" class="give-hidden">' . esc_html__( 'Choose Your Donation Amount', 'give' ) . ':</label>'; |
|
| 556 | - $output .= '<select id="give-donation-level-select-' . $form_id . '" class="give-select give-select-level give-donation-levels-wrap">'; |
|
| 555 | + $output .= '<label for="give-donation-level-select-'.$form_id.'" class="give-hidden">'.esc_html__('Choose Your Donation Amount', 'give').':</label>'; |
|
| 556 | + $output .= '<select id="give-donation-level-select-'.$form_id.'" class="give-select give-select-level give-donation-levels-wrap">'; |
|
| 557 | 557 | |
| 558 | 558 | //first loop through prices. |
| 559 | - foreach ( $prices as $price ) { |
|
| 560 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
| 561 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
| 559 | + foreach ($prices as $price) { |
|
| 560 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
| 561 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-'.$price['_give_id']['level_id'].((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
| 562 | 562 | |
| 563 | - $output .= '<option data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'selected="selected"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) . '">'; |
|
| 563 | + $output .= '<option data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'selected="selected"' : '').' value="'.give_format_amount($price['_give_amount'], array('sanitize' => false)).'">'; |
|
| 564 | 564 | $output .= $level_text; |
| 565 | 565 | $output .= '</option>'; |
| 566 | 566 | |
| 567 | 567 | } |
| 568 | 568 | |
| 569 | 569 | //Custom Amount. |
| 570 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
| 571 | - $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">' . $custom_amount_text . '</option>'; |
|
| 570 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
| 571 | + $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">'.$custom_amount_text.'</option>'; |
|
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | $output .= '</select>'; |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | break; |
| 577 | 577 | } |
| 578 | 578 | |
| 579 | - echo apply_filters( 'give_form_level_output', $output, $form_id ); |
|
| 579 | + echo apply_filters('give_form_level_output', $output, $form_id); |
|
| 580 | 580 | } |
| 581 | 581 | |
| 582 | 582 | /** |
@@ -591,27 +591,27 @@ discard block |
||
| 591 | 591 | * |
| 592 | 592 | * @return string Checkout button. |
| 593 | 593 | */ |
| 594 | -function give_display_checkout_button( $form_id, $args ) { |
|
| 594 | +function give_display_checkout_button($form_id, $args) { |
|
| 595 | 595 | |
| 596 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
| 596 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
| 597 | 597 | ? $args['display_style'] |
| 598 | - : give_get_meta( $form_id, '_give_payment_display', true ); |
|
| 598 | + : give_get_meta($form_id, '_give_payment_display', true); |
|
| 599 | 599 | |
| 600 | - if ( 'button' === $display_option ) { |
|
| 600 | + if ('button' === $display_option) { |
|
| 601 | 601 | $display_option = 'modal'; |
| 602 | - } elseif ( $display_option === 'onpage' ) { |
|
| 602 | + } elseif ($display_option === 'onpage') { |
|
| 603 | 603 | return ''; |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | - $display_label_field = give_get_meta( $form_id, '_give_reveal_label', true ); |
|
| 607 | - $display_label = ! empty( $args['continue_button_title'] ) ? $args['continue_button_title'] : ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
| 606 | + $display_label_field = give_get_meta($form_id, '_give_reveal_label', true); |
|
| 607 | + $display_label = ! empty($args['continue_button_title']) ? $args['continue_button_title'] : ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
| 608 | 608 | |
| 609 | - $output = '<button type="button" class="give-btn give-btn-' . $display_option . '">' . $display_label . '</button>'; |
|
| 609 | + $output = '<button type="button" class="give-btn give-btn-'.$display_option.'">'.$display_label.'</button>'; |
|
| 610 | 610 | |
| 611 | - echo apply_filters( 'give_display_checkout_button', $output ); |
|
| 611 | + echo apply_filters('give_display_checkout_button', $output); |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | -add_action( 'give_after_donation_levels', 'give_display_checkout_button', 10, 2 ); |
|
| 614 | +add_action('give_after_donation_levels', 'give_display_checkout_button', 10, 2); |
|
| 615 | 615 | |
| 616 | 616 | /** |
| 617 | 617 | * Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided. |
@@ -622,57 +622,57 @@ discard block |
||
| 622 | 622 | * |
| 623 | 623 | * @return void |
| 624 | 624 | */ |
| 625 | -function give_user_info_fields( $form_id ) { |
|
| 625 | +function give_user_info_fields($form_id) { |
|
| 626 | 626 | // Get user info. |
| 627 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
| 627 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
| 628 | 628 | |
| 629 | 629 | /** |
| 630 | 630 | * Fire before user personal information fields |
| 631 | 631 | * |
| 632 | 632 | * @since 1.7 |
| 633 | 633 | */ |
| 634 | - do_action( 'give_donation_form_before_personal_info', $form_id ); |
|
| 634 | + do_action('give_donation_form_before_personal_info', $form_id); |
|
| 635 | 635 | ?> |
| 636 | 636 | <fieldset id="give_checkout_user_info"> |
| 637 | - <legend><?php echo apply_filters( 'give_checkout_personal_info_text', esc_html__( 'Personal Info', 'give' ) ); ?></legend> |
|
| 637 | + <legend><?php echo apply_filters('give_checkout_personal_info_text', esc_html__('Personal Info', 'give')); ?></legend> |
|
| 638 | 638 | <p id="give-first-name-wrap" class="form-row form-row-first form-row-responsive"> |
| 639 | 639 | <label class="give-label" for="give-first"> |
| 640 | - <?php esc_html_e( 'First Name', 'give' ); ?> |
|
| 641 | - <?php if ( give_field_is_required( 'give_first', $form_id ) ) : ?> |
|
| 640 | + <?php esc_html_e('First Name', 'give'); ?> |
|
| 641 | + <?php if (give_field_is_required('give_first', $form_id)) : ?> |
|
| 642 | 642 | <span class="give-required-indicator">*</span> |
| 643 | 643 | <?php endif ?> |
| 644 | 644 | <span class="give-tooltip give-icon give-icon-question" |
| 645 | - data-tooltip="<?php esc_attr_e( 'We will use this to personalize your account experience.', 'give' ); ?>"></span> |
|
| 645 | + data-tooltip="<?php esc_attr_e('We will use this to personalize your account experience.', 'give'); ?>"></span> |
|
| 646 | 646 | </label> |
| 647 | 647 | <input |
| 648 | 648 | class="give-input required" |
| 649 | 649 | type="text" |
| 650 | 650 | name="give_first" |
| 651 | - placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" |
|
| 651 | + placeholder="<?php esc_attr_e('First Name', 'give'); ?>" |
|
| 652 | 652 | id="give-first" |
| 653 | - value="<?php echo isset( $give_user_info['give_first'] ) ? $give_user_info['give_first'] : ''; ?>" |
|
| 654 | - <?php echo( give_field_is_required( 'give_first', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 653 | + value="<?php echo isset($give_user_info['give_first']) ? $give_user_info['give_first'] : ''; ?>" |
|
| 654 | + <?php echo(give_field_is_required('give_first', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 655 | 655 | /> |
| 656 | 656 | </p> |
| 657 | 657 | |
| 658 | 658 | <p id="give-last-name-wrap" class="form-row form-row-last form-row-responsive"> |
| 659 | 659 | <label class="give-label" for="give-last"> |
| 660 | - <?php esc_html_e( 'Last Name', 'give' ); ?> |
|
| 661 | - <?php if ( give_field_is_required( 'give_last', $form_id ) ) : ?> |
|
| 660 | + <?php esc_html_e('Last Name', 'give'); ?> |
|
| 661 | + <?php if (give_field_is_required('give_last', $form_id)) : ?> |
|
| 662 | 662 | <span class="give-required-indicator">*</span> |
| 663 | 663 | <?php endif ?> |
| 664 | 664 | <span class="give-tooltip give-icon give-icon-question" |
| 665 | - data-tooltip="<?php esc_attr_e( 'We will use this as well to personalize your account experience.', 'give' ); ?>"></span> |
|
| 665 | + data-tooltip="<?php esc_attr_e('We will use this as well to personalize your account experience.', 'give'); ?>"></span> |
|
| 666 | 666 | </label> |
| 667 | 667 | |
| 668 | 668 | <input |
| 669 | - class="give-input<?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required' : '' ); ?>" |
|
| 669 | + class="give-input<?php echo(give_field_is_required('give_last', $form_id) ? ' required' : ''); ?>" |
|
| 670 | 670 | type="text" |
| 671 | 671 | name="give_last" |
| 672 | 672 | id="give-last" |
| 673 | - placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" |
|
| 674 | - value="<?php echo isset( $give_user_info['give_last'] ) ? $give_user_info['give_last'] : ''; ?>" |
|
| 675 | - <?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 673 | + placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" |
|
| 674 | + value="<?php echo isset($give_user_info['give_last']) ? $give_user_info['give_last'] : ''; ?>" |
|
| 675 | + <?php echo(give_field_is_required('give_last', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 676 | 676 | /> |
| 677 | 677 | </p> |
| 678 | 678 | |
@@ -682,26 +682,26 @@ discard block |
||
| 682 | 682 | * |
| 683 | 683 | * @since 1.7 |
| 684 | 684 | */ |
| 685 | - do_action( 'give_donation_form_before_email', $form_id ); |
|
| 685 | + do_action('give_donation_form_before_email', $form_id); |
|
| 686 | 686 | ?> |
| 687 | 687 | <p id="give-email-wrap" class="form-row form-row-wide"> |
| 688 | 688 | <label class="give-label" for="give-email"> |
| 689 | - <?php esc_html_e( 'Email Address', 'give' ); ?> |
|
| 690 | - <?php if ( give_field_is_required( 'give_email', $form_id ) ) { ?> |
|
| 689 | + <?php esc_html_e('Email Address', 'give'); ?> |
|
| 690 | + <?php if (give_field_is_required('give_email', $form_id)) { ?> |
|
| 691 | 691 | <span class="give-required-indicator">*</span> |
| 692 | 692 | <?php } ?> |
| 693 | 693 | <span class="give-tooltip give-icon give-icon-question" |
| 694 | - data-tooltip="<?php esc_attr_e( 'We will send the donation receipt to this address.', 'give' ); ?>"></span> |
|
| 694 | + data-tooltip="<?php esc_attr_e('We will send the donation receipt to this address.', 'give'); ?>"></span> |
|
| 695 | 695 | </label> |
| 696 | 696 | |
| 697 | 697 | <input |
| 698 | 698 | class="give-input required" |
| 699 | 699 | type="email" |
| 700 | 700 | name="give_email" |
| 701 | - placeholder="<?php esc_attr_e( 'Email Address', 'give' ); ?>" |
|
| 701 | + placeholder="<?php esc_attr_e('Email Address', 'give'); ?>" |
|
| 702 | 702 | id="give-email" |
| 703 | - value="<?php echo isset( $give_user_info['give_email'] ) ? $give_user_info['give_email'] : ''; ?>" |
|
| 704 | - <?php echo( give_field_is_required( 'give_email', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 703 | + value="<?php echo isset($give_user_info['give_email']) ? $give_user_info['give_email'] : ''; ?>" |
|
| 704 | + <?php echo(give_field_is_required('give_email', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 705 | 705 | /> |
| 706 | 706 | |
| 707 | 707 | </p> |
@@ -711,14 +711,14 @@ discard block |
||
| 711 | 711 | * |
| 712 | 712 | * @since 1.7 |
| 713 | 713 | */ |
| 714 | - do_action( 'give_donation_form_after_email', $form_id ); |
|
| 714 | + do_action('give_donation_form_after_email', $form_id); |
|
| 715 | 715 | |
| 716 | 716 | /** |
| 717 | 717 | * Fire after personal email field |
| 718 | 718 | * |
| 719 | 719 | * @since 1.7 |
| 720 | 720 | */ |
| 721 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
| 721 | + do_action('give_donation_form_user_info', $form_id); |
|
| 722 | 722 | ?> |
| 723 | 723 | </fieldset> |
| 724 | 724 | <?php |
@@ -727,11 +727,11 @@ discard block |
||
| 727 | 727 | * |
| 728 | 728 | * @since 1.7 |
| 729 | 729 | */ |
| 730 | - do_action( 'give_donation_form_after_personal_info', $form_id ); |
|
| 730 | + do_action('give_donation_form_after_personal_info', $form_id); |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | -add_action( 'give_donation_form_after_user_info', 'give_user_info_fields' ); |
|
| 734 | -add_action( 'give_register_fields_before', 'give_user_info_fields' ); |
|
| 733 | +add_action('give_donation_form_after_user_info', 'give_user_info_fields'); |
|
| 734 | +add_action('give_register_fields_before', 'give_user_info_fields'); |
|
| 735 | 735 | |
| 736 | 736 | /** |
| 737 | 737 | * Renders the credit card info form. |
@@ -742,7 +742,7 @@ discard block |
||
| 742 | 742 | * |
| 743 | 743 | * @return void |
| 744 | 744 | */ |
| 745 | -function give_get_cc_form( $form_id ) { |
|
| 745 | +function give_get_cc_form($form_id) { |
|
| 746 | 746 | |
| 747 | 747 | ob_start(); |
| 748 | 748 | |
@@ -753,53 +753,53 @@ discard block |
||
| 753 | 753 | * |
| 754 | 754 | * @param int $form_id The form ID. |
| 755 | 755 | */ |
| 756 | - do_action( 'give_before_cc_fields', $form_id ); |
|
| 756 | + do_action('give_before_cc_fields', $form_id); |
|
| 757 | 757 | ?> |
| 758 | 758 | <fieldset id="give_cc_fields-<?php echo $form_id ?>" class="give-do-validate"> |
| 759 | - <legend><?php echo apply_filters( 'give_credit_card_fieldset_heading', esc_html__( 'Credit Card Info', 'give' ) ); ?></legend> |
|
| 760 | - <?php if ( is_ssl() ) : ?> |
|
| 759 | + <legend><?php echo apply_filters('give_credit_card_fieldset_heading', esc_html__('Credit Card Info', 'give')); ?></legend> |
|
| 760 | + <?php if (is_ssl()) : ?> |
|
| 761 | 761 | <div id="give_secure_site_wrapper-<?php echo $form_id ?>"> |
| 762 | 762 | <span class="give-icon padlock"></span> |
| 763 | - <span><?php esc_html_e( 'This is a secure SSL encrypted payment.', 'give' ); ?></span> |
|
| 763 | + <span><?php esc_html_e('This is a secure SSL encrypted payment.', 'give'); ?></span> |
|
| 764 | 764 | </div> |
| 765 | 765 | <?php endif; ?> |
| 766 | 766 | <p id="give-card-number-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
| 767 | 767 | <label for="card_number-<?php echo $form_id ?>" class="give-label"> |
| 768 | - <?php esc_html_e( 'Card Number', 'give' ); ?> |
|
| 768 | + <?php esc_html_e('Card Number', 'give'); ?> |
|
| 769 | 769 | <span class="give-required-indicator">*</span> |
| 770 | 770 | <span class="give-tooltip give-icon give-icon-question" |
| 771 | - data-tooltip="<?php esc_attr_e( 'The (typically) 16 digits on the front of your credit card.', 'give' ); ?>"></span> |
|
| 771 | + data-tooltip="<?php esc_attr_e('The (typically) 16 digits on the front of your credit card.', 'give'); ?>"></span> |
|
| 772 | 772 | <span class="card-type"></span> |
| 773 | 773 | </label> |
| 774 | 774 | |
| 775 | 775 | <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" |
| 776 | - class="card-number give-input required" placeholder="<?php esc_attr_e( 'Card number', 'give' ); ?>" |
|
| 776 | + class="card-number give-input required" placeholder="<?php esc_attr_e('Card number', 'give'); ?>" |
|
| 777 | 777 | required aria-required="true"/> |
| 778 | 778 | </p> |
| 779 | 779 | |
| 780 | 780 | <p id="give-card-cvc-wrap-<?php echo $form_id ?>" class="form-row form-row-one-third form-row-responsive"> |
| 781 | 781 | <label for="card_cvc-<?php echo $form_id ?>" class="give-label"> |
| 782 | - <?php esc_html_e( 'CVC', 'give' ); ?> |
|
| 782 | + <?php esc_html_e('CVC', 'give'); ?> |
|
| 783 | 783 | <span class="give-required-indicator">*</span> |
| 784 | 784 | <span class="give-tooltip give-icon give-icon-question" |
| 785 | - data-tooltip="<?php esc_attr_e( 'The 3 digit (back) or 4 digit (front) value on your card.', 'give' ); ?>"></span> |
|
| 785 | + data-tooltip="<?php esc_attr_e('The 3 digit (back) or 4 digit (front) value on your card.', 'give'); ?>"></span> |
|
| 786 | 786 | </label> |
| 787 | 787 | |
| 788 | 788 | <input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" |
| 789 | - class="card-cvc give-input required" placeholder="<?php esc_attr_e( 'Security code', 'give' ); ?>" |
|
| 789 | + class="card-cvc give-input required" placeholder="<?php esc_attr_e('Security code', 'give'); ?>" |
|
| 790 | 790 | required aria-required="true"/> |
| 791 | 791 | </p> |
| 792 | 792 | |
| 793 | 793 | <p id="give-card-name-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
| 794 | 794 | <label for="card_name-<?php echo $form_id ?>" class="give-label"> |
| 795 | - <?php esc_html_e( 'Name on the Card', 'give' ); ?> |
|
| 795 | + <?php esc_html_e('Name on the Card', 'give'); ?> |
|
| 796 | 796 | <span class="give-required-indicator">*</span> |
| 797 | 797 | <span class="give-tooltip give-icon give-icon-question" |
| 798 | - data-tooltip="<?php esc_attr_e( 'The name printed on the front of your credit card.', 'give' ); ?>"></span> |
|
| 798 | + data-tooltip="<?php esc_attr_e('The name printed on the front of your credit card.', 'give'); ?>"></span> |
|
| 799 | 799 | </label> |
| 800 | 800 | |
| 801 | 801 | <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" |
| 802 | - class="card-name give-input required" placeholder="<?php esc_attr_e( 'Card name', 'give' ); ?>" |
|
| 802 | + class="card-name give-input required" placeholder="<?php esc_attr_e('Card name', 'give'); ?>" |
|
| 803 | 803 | required aria-required="true"/> |
| 804 | 804 | </p> |
| 805 | 805 | <?php |
@@ -810,14 +810,14 @@ discard block |
||
| 810 | 810 | * |
| 811 | 811 | * @param int $form_id The form ID. |
| 812 | 812 | */ |
| 813 | - do_action( 'give_before_cc_expiration' ); |
|
| 813 | + do_action('give_before_cc_expiration'); |
|
| 814 | 814 | ?> |
| 815 | 815 | <p class="card-expiration form-row form-row-one-third form-row-responsive"> |
| 816 | 816 | <label for="card_expiry-<?php echo $form_id ?>" class="give-label"> |
| 817 | - <?php esc_html_e( 'Expiration', 'give' ); ?> |
|
| 817 | + <?php esc_html_e('Expiration', 'give'); ?> |
|
| 818 | 818 | <span class="give-required-indicator">*</span> |
| 819 | 819 | <span class="give-tooltip give-icon give-icon-question" |
| 820 | - data-tooltip="<?php esc_attr_e( 'The date your credit card expires, typically on the front of the card.', 'give' ); ?>"></span> |
|
| 820 | + data-tooltip="<?php esc_attr_e('The date your credit card expires, typically on the front of the card.', 'give'); ?>"></span> |
|
| 821 | 821 | </label> |
| 822 | 822 | |
| 823 | 823 | <input type="hidden" id="card_exp_month-<?php echo $form_id ?>" name="card_exp_month" |
@@ -826,7 +826,7 @@ discard block |
||
| 826 | 826 | class="card-expiry-year"/> |
| 827 | 827 | |
| 828 | 828 | <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" |
| 829 | - class="card-expiry give-input required" placeholder="<?php esc_attr_e( 'MM / YY', 'give' ); ?>" |
|
| 829 | + class="card-expiry give-input required" placeholder="<?php esc_attr_e('MM / YY', 'give'); ?>" |
|
| 830 | 830 | required aria-required="true"/> |
| 831 | 831 | </p> |
| 832 | 832 | <?php |
@@ -837,7 +837,7 @@ discard block |
||
| 837 | 837 | * |
| 838 | 838 | * @param int $form_id The form ID. |
| 839 | 839 | */ |
| 840 | - do_action( 'give_after_cc_expiration', $form_id ); |
|
| 840 | + do_action('give_after_cc_expiration', $form_id); |
|
| 841 | 841 | ?> |
| 842 | 842 | </fieldset> |
| 843 | 843 | <?php |
@@ -848,12 +848,12 @@ discard block |
||
| 848 | 848 | * |
| 849 | 849 | * @param int $form_id The form ID. |
| 850 | 850 | */ |
| 851 | - do_action( 'give_after_cc_fields', $form_id ); |
|
| 851 | + do_action('give_after_cc_fields', $form_id); |
|
| 852 | 852 | |
| 853 | 853 | echo ob_get_clean(); |
| 854 | 854 | } |
| 855 | 855 | |
| 856 | -add_action( 'give_cc_form', 'give_get_cc_form' ); |
|
| 856 | +add_action('give_cc_form', 'give_get_cc_form'); |
|
| 857 | 857 | |
| 858 | 858 | /** |
| 859 | 859 | * Outputs the default credit card address fields. |
@@ -864,24 +864,24 @@ discard block |
||
| 864 | 864 | * |
| 865 | 865 | * @return void |
| 866 | 866 | */ |
| 867 | -function give_default_cc_address_fields( $form_id ) { |
|
| 867 | +function give_default_cc_address_fields($form_id) { |
|
| 868 | 868 | // Get user info. |
| 869 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
| 869 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
| 870 | 870 | |
| 871 | 871 | $logged_in = is_user_logged_in(); |
| 872 | 872 | |
| 873 | - if ( $logged_in ) { |
|
| 874 | - $user_address = get_user_meta( get_current_user_id(), '_give_user_address', true ); |
|
| 873 | + if ($logged_in) { |
|
| 874 | + $user_address = get_user_meta(get_current_user_id(), '_give_user_address', true); |
|
| 875 | 875 | } |
| 876 | - $line1 = $logged_in && ! empty( $user_address['line1'] ) ? $user_address['line1'] : ''; |
|
| 877 | - $line2 = $logged_in && ! empty( $user_address['line2'] ) ? $user_address['line2'] : ''; |
|
| 878 | - $city = $logged_in && ! empty( $user_address['city'] ) ? $user_address['city'] : ''; |
|
| 879 | - $zip = $logged_in && ! empty( $user_address['zip'] ) ? $user_address['zip'] : ''; |
|
| 876 | + $line1 = $logged_in && ! empty($user_address['line1']) ? $user_address['line1'] : ''; |
|
| 877 | + $line2 = $logged_in && ! empty($user_address['line2']) ? $user_address['line2'] : ''; |
|
| 878 | + $city = $logged_in && ! empty($user_address['city']) ? $user_address['city'] : ''; |
|
| 879 | + $zip = $logged_in && ! empty($user_address['zip']) ? $user_address['zip'] : ''; |
|
| 880 | 880 | |
| 881 | 881 | ob_start(); |
| 882 | 882 | ?> |
| 883 | 883 | <fieldset id="give_cc_address" class="cc-address"> |
| 884 | - <legend><?php echo apply_filters( 'give_billing_details_fieldset_heading', esc_html__( 'Billing Details', 'give' ) ); ?></legend> |
|
| 884 | + <legend><?php echo apply_filters('give_billing_details_fieldset_heading', esc_html__('Billing Details', 'give')); ?></legend> |
|
| 885 | 885 | <?php |
| 886 | 886 | /** |
| 887 | 887 | * Fires while rendering credit card billing form, before address fields. |
@@ -890,79 +890,79 @@ discard block |
||
| 890 | 890 | * |
| 891 | 891 | * @param int $form_id The form ID. |
| 892 | 892 | */ |
| 893 | - do_action( 'give_cc_billing_top' ); |
|
| 893 | + do_action('give_cc_billing_top'); |
|
| 894 | 894 | ?> |
| 895 | 895 | <p id="give-card-address-wrap" class="form-row form-row-wide"> |
| 896 | 896 | <label for="card_address" class="give-label"> |
| 897 | - <?php esc_html_e( 'Address 1', 'give' ); ?> |
|
| 897 | + <?php esc_html_e('Address 1', 'give'); ?> |
|
| 898 | 898 | <?php |
| 899 | - if ( give_field_is_required( 'card_address', $form_id ) ) : ?> |
|
| 899 | + if (give_field_is_required('card_address', $form_id)) : ?> |
|
| 900 | 900 | <span class="give-required-indicator">*</span> |
| 901 | 901 | <?php endif; ?> |
| 902 | 902 | <span class="give-tooltip give-icon give-icon-question" |
| 903 | - data-tooltip="<?php esc_attr_e( 'The primary billing address for your credit card.', 'give' ); ?>"></span> |
|
| 903 | + data-tooltip="<?php esc_attr_e('The primary billing address for your credit card.', 'give'); ?>"></span> |
|
| 904 | 904 | </label> |
| 905 | 905 | |
| 906 | 906 | <input |
| 907 | 907 | type="text" |
| 908 | 908 | id="card_address" |
| 909 | 909 | name="card_address" |
| 910 | - class="card-address give-input<?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required' : '' ); ?>" |
|
| 911 | - placeholder="<?php esc_attr_e( 'Address line 1', 'give' ); ?>" |
|
| 912 | - value="<?php echo isset( $give_user_info['card_address'] ) ? $give_user_info['card_address'] : ''; ?>" |
|
| 913 | - <?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 910 | + class="card-address give-input<?php echo(give_field_is_required('card_address', $form_id) ? ' required' : ''); ?>" |
|
| 911 | + placeholder="<?php esc_attr_e('Address line 1', 'give'); ?>" |
|
| 912 | + value="<?php echo isset($give_user_info['card_address']) ? $give_user_info['card_address'] : ''; ?>" |
|
| 913 | + <?php echo(give_field_is_required('card_address', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 914 | 914 | /> |
| 915 | 915 | </p> |
| 916 | 916 | |
| 917 | 917 | <p id="give-card-address-2-wrap" class="form-row form-row-wide"> |
| 918 | 918 | <label for="card_address_2" class="give-label"> |
| 919 | - <?php esc_html_e( 'Address 2', 'give' ); ?> |
|
| 920 | - <?php if ( give_field_is_required( 'card_address_2', $form_id ) ) : ?> |
|
| 919 | + <?php esc_html_e('Address 2', 'give'); ?> |
|
| 920 | + <?php if (give_field_is_required('card_address_2', $form_id)) : ?> |
|
| 921 | 921 | <span class="give-required-indicator">*</span> |
| 922 | 922 | <?php endif; ?> |
| 923 | 923 | <span class="give-tooltip give-icon give-icon-question" |
| 924 | - data-tooltip="<?php esc_attr_e( '(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give' ); ?>"></span> |
|
| 924 | + data-tooltip="<?php esc_attr_e('(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give'); ?>"></span> |
|
| 925 | 925 | </label> |
| 926 | 926 | |
| 927 | 927 | <input |
| 928 | 928 | type="text" |
| 929 | 929 | id="card_address_2" |
| 930 | 930 | name="card_address_2" |
| 931 | - class="card-address-2 give-input<?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required' : '' ); ?>" |
|
| 932 | - placeholder="<?php esc_attr_e( 'Address line 2', 'give' ); ?>" |
|
| 933 | - value="<?php echo isset( $give_user_info['card_address_2'] ) ? $give_user_info['card_address_2'] : ''; ?>" |
|
| 934 | - <?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 931 | + class="card-address-2 give-input<?php echo(give_field_is_required('card_address_2', $form_id) ? ' required' : ''); ?>" |
|
| 932 | + placeholder="<?php esc_attr_e('Address line 2', 'give'); ?>" |
|
| 933 | + value="<?php echo isset($give_user_info['card_address_2']) ? $give_user_info['card_address_2'] : ''; ?>" |
|
| 934 | + <?php echo(give_field_is_required('card_address_2', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 935 | 935 | /> |
| 936 | 936 | </p> |
| 937 | 937 | |
| 938 | 938 | <p id="give-card-city-wrap" class="form-row form-row-first form-row-responsive"> |
| 939 | 939 | <label for="card_city" class="give-label"> |
| 940 | - <?php esc_html_e( 'City', 'give' ); ?> |
|
| 941 | - <?php if ( give_field_is_required( 'card_city', $form_id ) ) : ?> |
|
| 940 | + <?php esc_html_e('City', 'give'); ?> |
|
| 941 | + <?php if (give_field_is_required('card_city', $form_id)) : ?> |
|
| 942 | 942 | <span class="give-required-indicator">*</span> |
| 943 | 943 | <?php endif; ?> |
| 944 | 944 | <span class="give-tooltip give-icon give-icon-question" |
| 945 | - data-tooltip="<?php esc_attr_e( 'The city for your billing address.', 'give' ); ?>"></span> |
|
| 945 | + data-tooltip="<?php esc_attr_e('The city for your billing address.', 'give'); ?>"></span> |
|
| 946 | 946 | </label> |
| 947 | 947 | <input |
| 948 | 948 | type="text" |
| 949 | 949 | id="card_city" |
| 950 | 950 | name="card_city" |
| 951 | - class="card-city give-input<?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required' : '' ); ?>" |
|
| 952 | - placeholder="<?php esc_attr_e( 'City', 'give' ); ?>" |
|
| 953 | - value="<?php echo isset( $give_user_info['card_city'] ) ? $give_user_info['card_city'] : ''; ?>" |
|
| 954 | - <?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 951 | + class="card-city give-input<?php echo(give_field_is_required('card_city', $form_id) ? ' required' : ''); ?>" |
|
| 952 | + placeholder="<?php esc_attr_e('City', 'give'); ?>" |
|
| 953 | + value="<?php echo isset($give_user_info['card_city']) ? $give_user_info['card_city'] : ''; ?>" |
|
| 954 | + <?php echo(give_field_is_required('card_city', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 955 | 955 | /> |
| 956 | 956 | </p> |
| 957 | 957 | |
| 958 | 958 | <p id="give-card-zip-wrap" class="form-row form-row-last form-row-responsive"> |
| 959 | 959 | <label for="card_zip" class="give-label"> |
| 960 | - <?php esc_html_e( 'Zip / Postal Code', 'give' ); ?> |
|
| 961 | - <?php if ( give_field_is_required( 'card_zip', $form_id ) ) : ?> |
|
| 960 | + <?php esc_html_e('Zip / Postal Code', 'give'); ?> |
|
| 961 | + <?php if (give_field_is_required('card_zip', $form_id)) : ?> |
|
| 962 | 962 | <span class="give-required-indicator">*</span> |
| 963 | 963 | <?php endif; ?> |
| 964 | 964 | <span class="give-tooltip give-icon give-icon-question" |
| 965 | - data-tooltip="<?php esc_attr_e( 'The zip or postal code for your billing address.', 'give' ); ?>"></span> |
|
| 965 | + data-tooltip="<?php esc_attr_e('The zip or postal code for your billing address.', 'give'); ?>"></span> |
|
| 966 | 966 | </label> |
| 967 | 967 | |
| 968 | 968 | <input |
@@ -970,40 +970,40 @@ discard block |
||
| 970 | 970 | size="4" |
| 971 | 971 | id="card_zip" |
| 972 | 972 | name="card_zip" |
| 973 | - class="card-zip give-input<?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required' : '' ); ?>" |
|
| 974 | - placeholder="<?php esc_attr_e( 'Zip / Postal Code', 'give' ); ?>" |
|
| 975 | - value="<?php echo isset( $give_user_info['card_zip'] ) ? $give_user_info['card_zip'] : ''; ?>" |
|
| 976 | - <?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 973 | + class="card-zip give-input<?php echo(give_field_is_required('card_zip', $form_id) ? ' required' : ''); ?>" |
|
| 974 | + placeholder="<?php esc_attr_e('Zip / Postal Code', 'give'); ?>" |
|
| 975 | + value="<?php echo isset($give_user_info['card_zip']) ? $give_user_info['card_zip'] : ''; ?>" |
|
| 976 | + <?php echo(give_field_is_required('card_zip', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 977 | 977 | /> |
| 978 | 978 | </p> |
| 979 | 979 | |
| 980 | 980 | <p id="give-card-country-wrap" class="form-row form-row-first form-row-responsive"> |
| 981 | 981 | <label for="billing_country" class="give-label"> |
| 982 | - <?php esc_html_e( 'Country', 'give' ); ?> |
|
| 983 | - <?php if ( give_field_is_required( 'billing_country', $form_id ) ) : ?> |
|
| 982 | + <?php esc_html_e('Country', 'give'); ?> |
|
| 983 | + <?php if (give_field_is_required('billing_country', $form_id)) : ?> |
|
| 984 | 984 | <span class="give-required-indicator">*</span> |
| 985 | 985 | <?php endif; ?> |
| 986 | 986 | <span class="give-tooltip give-icon give-icon-question" |
| 987 | - data-tooltip="<?php esc_attr_e( 'The country for your billing address.', 'give' ); ?>"></span> |
|
| 987 | + data-tooltip="<?php esc_attr_e('The country for your billing address.', 'give'); ?>"></span> |
|
| 988 | 988 | </label> |
| 989 | 989 | |
| 990 | 990 | <select |
| 991 | 991 | name="billing_country" |
| 992 | 992 | id="billing_country" |
| 993 | - class="billing-country billing_country give-select<?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required' : '' ); ?>" |
|
| 994 | - <?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 993 | + class="billing-country billing_country give-select<?php echo(give_field_is_required('billing_country', $form_id) ? ' required' : ''); ?>" |
|
| 994 | + <?php echo(give_field_is_required('billing_country', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 995 | 995 | > |
| 996 | 996 | <?php |
| 997 | 997 | |
| 998 | 998 | $selected_country = give_get_country(); |
| 999 | 999 | |
| 1000 | - if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
| 1000 | + if ( ! empty($give_user_info['billing_country']) && '*' !== $give_user_info['billing_country']) { |
|
| 1001 | 1001 | $selected_country = $give_user_info['billing_country']; |
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | 1004 | $countries = give_get_country_list(); |
| 1005 | - foreach ( $countries as $country_code => $country ) { |
|
| 1006 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
| 1005 | + foreach ($countries as $country_code => $country) { |
|
| 1006 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
| 1007 | 1007 | } |
| 1008 | 1008 | ?> |
| 1009 | 1009 | </select> |
@@ -1013,19 +1013,19 @@ discard block |
||
| 1013 | 1013 | <?php |
| 1014 | 1014 | $selected_state = give_get_state(); |
| 1015 | 1015 | |
| 1016 | - $label = __( 'State', 'give' ); |
|
| 1016 | + $label = __('State', 'give'); |
|
| 1017 | 1017 | $states_label = give_get_states_label(); |
| 1018 | 1018 | // Check if $country code exists in the array key for states label. |
| 1019 | - if ( array_key_exists( $selected_country, $states_label ) ) { |
|
| 1020 | - $label = $states_label[ $selected_country ]; |
|
| 1019 | + if (array_key_exists($selected_country, $states_label)) { |
|
| 1020 | + $label = $states_label[$selected_country]; |
|
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | - $states = give_get_states( $selected_country ); |
|
| 1023 | + $states = give_get_states($selected_country); |
|
| 1024 | 1024 | |
| 1025 | 1025 | // Get the country list that do not have any states init. |
| 1026 | 1026 | $no_states_country = give_no_states_country_list(); |
| 1027 | 1027 | |
| 1028 | - if ( ! empty( $give_user_info['card_state'] ) ) { |
|
| 1028 | + if ( ! empty($give_user_info['card_state'])) { |
|
| 1029 | 1029 | $selected_state = $give_user_info['card_state']; |
| 1030 | 1030 | } |
| 1031 | 1031 | |
@@ -1033,27 +1033,27 @@ discard block |
||
| 1033 | 1033 | $states_not_required_country_list = give_states_not_required_country_list(); |
| 1034 | 1034 | ?> |
| 1035 | 1035 | <p id="give-card-state-wrap" |
| 1036 | - class="form-row form-row-last form-row-responsive <?php echo ( ! empty( $selected_country ) && array_key_exists( $selected_country, $no_states_country ) ) ? 'give-hidden' : ''; ?> "> |
|
| 1036 | + class="form-row form-row-last form-row-responsive <?php echo ( ! empty($selected_country) && array_key_exists($selected_country, $no_states_country)) ? 'give-hidden' : ''; ?> "> |
|
| 1037 | 1037 | <label for="card_state" class="give-label"> |
| 1038 | 1038 | <span class="state-label-text"><?php echo $label; ?></span> |
| 1039 | - <?php if ( give_field_is_required( 'card_state', $form_id ) ) : |
|
| 1039 | + <?php if (give_field_is_required('card_state', $form_id)) : |
|
| 1040 | 1040 | ?> |
| 1041 | - <span class="give-required-indicator <?php echo( array_key_exists( $selected_country, $states_not_required_country_list ) ? 'give-hidden' : '' ) ?> ">*</span> |
|
| 1041 | + <span class="give-required-indicator <?php echo(array_key_exists($selected_country, $states_not_required_country_list) ? 'give-hidden' : '') ?> ">*</span> |
|
| 1042 | 1042 | <?php endif; ?> |
| 1043 | 1043 | <span class="give-tooltip give-icon give-icon-question" |
| 1044 | - data-tooltip="<?php esc_attr_e( 'The state or province or county for your billing address.', 'give' ); ?>"></span> |
|
| 1044 | + data-tooltip="<?php esc_attr_e('The state or province or county for your billing address.', 'give'); ?>"></span> |
|
| 1045 | 1045 | </label> |
| 1046 | 1046 | <?php |
| 1047 | 1047 | |
| 1048 | - if ( ! empty( $states ) ) : ?> |
|
| 1048 | + if ( ! empty($states)) : ?> |
|
| 1049 | 1049 | <select |
| 1050 | 1050 | name="card_state" |
| 1051 | 1051 | id="card_state" |
| 1052 | - class="card_state give-select<?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required' : '' ); ?>" |
|
| 1053 | - <?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required aria-required="true" ' : '' ); ?>> |
|
| 1052 | + class="card_state give-select<?php echo(give_field_is_required('card_state', $form_id) ? ' required' : ''); ?>" |
|
| 1053 | + <?php echo(give_field_is_required('card_state', $form_id) ? ' required aria-required="true" ' : ''); ?>> |
|
| 1054 | 1054 | <?php |
| 1055 | - foreach ( $states as $state_code => $state ) { |
|
| 1056 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
| 1055 | + foreach ($states as $state_code => $state) { |
|
| 1056 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
| 1057 | 1057 | } |
| 1058 | 1058 | ?> |
| 1059 | 1059 | </select> |
@@ -1070,14 +1070,14 @@ discard block |
||
| 1070 | 1070 | * |
| 1071 | 1071 | * @param int $form_id The form ID. |
| 1072 | 1072 | */ |
| 1073 | - do_action( 'give_cc_billing_bottom' ); |
|
| 1073 | + do_action('give_cc_billing_bottom'); |
|
| 1074 | 1074 | ?> |
| 1075 | 1075 | </fieldset> |
| 1076 | 1076 | <?php |
| 1077 | 1077 | echo ob_get_clean(); |
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | -add_action( 'give_after_cc_fields', 'give_default_cc_address_fields' ); |
|
| 1080 | +add_action('give_after_cc_fields', 'give_default_cc_address_fields'); |
|
| 1081 | 1081 | |
| 1082 | 1082 | |
| 1083 | 1083 | /** |
@@ -1090,24 +1090,24 @@ discard block |
||
| 1090 | 1090 | * |
| 1091 | 1091 | * @return string |
| 1092 | 1092 | */ |
| 1093 | -function give_get_register_fields( $form_id ) { |
|
| 1093 | +function give_get_register_fields($form_id) { |
|
| 1094 | 1094 | |
| 1095 | 1095 | global $user_ID; |
| 1096 | 1096 | |
| 1097 | - if ( is_user_logged_in() ) { |
|
| 1098 | - $user_data = get_userdata( $user_ID ); |
|
| 1097 | + if (is_user_logged_in()) { |
|
| 1098 | + $user_data = get_userdata($user_ID); |
|
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
| 1101 | + $show_register_form = give_show_login_register_option($form_id); |
|
| 1102 | 1102 | |
| 1103 | 1103 | ob_start(); ?> |
| 1104 | 1104 | <fieldset id="give-register-fields-<?php echo $form_id; ?>"> |
| 1105 | 1105 | |
| 1106 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
| 1106 | + <?php if ($show_register_form == 'both') { ?> |
|
| 1107 | 1107 | <div class="give-login-account-wrap"> |
| 1108 | - <p class="give-login-message"><?php esc_html_e( 'Already have an account?', 'give' ); ?> |
|
| 1109 | - <a href="<?php echo esc_url( add_query_arg( 'login', 1 ) ); ?>" class="give-checkout-login" |
|
| 1110 | - data-action="give_checkout_login"><?php esc_html_e( 'Login', 'give' ); ?></a> |
|
| 1108 | + <p class="give-login-message"><?php esc_html_e('Already have an account?', 'give'); ?> |
|
| 1109 | + <a href="<?php echo esc_url(add_query_arg('login', 1)); ?>" class="give-checkout-login" |
|
| 1110 | + data-action="give_checkout_login"><?php esc_html_e('Login', 'give'); ?></a> |
|
| 1111 | 1111 | </p> |
| 1112 | 1112 | <p class="give-loading-text"> |
| 1113 | 1113 | <span class="give-loading-animation"></span> |
@@ -1123,15 +1123,15 @@ discard block |
||
| 1123 | 1123 | * |
| 1124 | 1124 | * @param int $form_id The form ID. |
| 1125 | 1125 | */ |
| 1126 | - do_action( 'give_register_fields_before', $form_id ); |
|
| 1126 | + do_action('give_register_fields_before', $form_id); |
|
| 1127 | 1127 | ?> |
| 1128 | 1128 | |
| 1129 | 1129 | <fieldset id="give-register-account-fields-<?php echo $form_id; ?>"> |
| 1130 | 1130 | <legend> |
| 1131 | 1131 | <?php |
| 1132 | - echo apply_filters( 'give_create_account_fieldset_heading', esc_html__( 'Create an account', 'give' ) ); |
|
| 1133 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
| 1134 | - echo ' <span class="sub-text">' . esc_html__( '(optional)', 'give' ) . '</span>'; |
|
| 1132 | + echo apply_filters('give_create_account_fieldset_heading', esc_html__('Create an account', 'give')); |
|
| 1133 | + if ( ! give_logged_in_only($form_id)) { |
|
| 1134 | + echo ' <span class="sub-text">'.esc_html__('(optional)', 'give').'</span>'; |
|
| 1135 | 1135 | } |
| 1136 | 1136 | ?> |
| 1137 | 1137 | </legend> |
@@ -1143,54 +1143,54 @@ discard block |
||
| 1143 | 1143 | * |
| 1144 | 1144 | * @param int $form_id The form ID. |
| 1145 | 1145 | */ |
| 1146 | - do_action( 'give_register_account_fields_before', $form_id ); |
|
| 1146 | + do_action('give_register_account_fields_before', $form_id); |
|
| 1147 | 1147 | ?> |
| 1148 | 1148 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" |
| 1149 | 1149 | class="form-row form-row-one-third form-row-first form-row-responsive"> |
| 1150 | 1150 | <label for="give-user-login-<?php echo $form_id; ?>"> |
| 1151 | - <?php esc_html_e( 'Username', 'give' ); ?> |
|
| 1152 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1151 | + <?php esc_html_e('Username', 'give'); ?> |
|
| 1152 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1153 | 1153 | <span class="give-required-indicator">*</span> |
| 1154 | 1154 | <?php } ?> |
| 1155 | 1155 | <span class="give-tooltip give-icon give-icon-question" |
| 1156 | - data-tooltip="<?php esc_attr_e( 'The username you will use to log into your account.', 'give' ); ?>"></span> |
|
| 1156 | + data-tooltip="<?php esc_attr_e('The username you will use to log into your account.', 'give'); ?>"></span> |
|
| 1157 | 1157 | </label> |
| 1158 | 1158 | |
| 1159 | 1159 | <input name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" class="give-input" |
| 1160 | 1160 | type="text" |
| 1161 | - placeholder="<?php esc_attr_e( 'Username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1161 | + placeholder="<?php esc_attr_e('Username', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1162 | 1162 | </div> |
| 1163 | 1163 | |
| 1164 | 1164 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" |
| 1165 | 1165 | class="form-row form-row-one-third form-row-responsive"> |
| 1166 | 1166 | <label for="give-user-pass-<?php echo $form_id; ?>"> |
| 1167 | - <?php esc_html_e( 'Password', 'give' ); ?> |
|
| 1168 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1167 | + <?php esc_html_e('Password', 'give'); ?> |
|
| 1168 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1169 | 1169 | <span class="give-required-indicator">*</span> |
| 1170 | 1170 | <?php } ?> |
| 1171 | 1171 | <span class="give-tooltip give-icon give-icon-question" |
| 1172 | - data-tooltip="<?php esc_attr_e( 'The password used to access your account.', 'give' ); ?>"></span> |
|
| 1172 | + data-tooltip="<?php esc_attr_e('The password used to access your account.', 'give'); ?>"></span> |
|
| 1173 | 1173 | </label> |
| 1174 | 1174 | |
| 1175 | 1175 | <input name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" class="give-input" |
| 1176 | - placeholder="<?php esc_attr_e( 'Password', 'give' ); ?>" |
|
| 1177 | - type="password"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1176 | + placeholder="<?php esc_attr_e('Password', 'give'); ?>" |
|
| 1177 | + type="password"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1178 | 1178 | </div> |
| 1179 | 1179 | |
| 1180 | 1180 | <div id="give-user-pass-confirm-wrap-<?php echo $form_id; ?>" |
| 1181 | 1181 | class="give-register-password form-row form-row-one-third form-row-responsive"> |
| 1182 | 1182 | <label for="give-user-pass-confirm-<?php echo $form_id; ?>"> |
| 1183 | - <?php esc_html_e( 'Confirm PW', 'give' ); ?> |
|
| 1184 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1183 | + <?php esc_html_e('Confirm PW', 'give'); ?> |
|
| 1184 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1185 | 1185 | <span class="give-required-indicator">*</span> |
| 1186 | 1186 | <?php } ?> |
| 1187 | 1187 | <span class="give-tooltip give-icon give-icon-question" |
| 1188 | - data-tooltip="<?php esc_attr_e( 'Please retype your password to confirm.', 'give' ); ?>"></span> |
|
| 1188 | + data-tooltip="<?php esc_attr_e('Please retype your password to confirm.', 'give'); ?>"></span> |
|
| 1189 | 1189 | </label> |
| 1190 | 1190 | |
| 1191 | 1191 | <input name="give_user_pass_confirm" id="give-user-pass-confirm-<?php echo $form_id; ?>" |
| 1192 | - class="give-input" placeholder="<?php esc_attr_e( 'Confirm password', 'give' ); ?>" |
|
| 1193 | - type="password"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1192 | + class="give-input" placeholder="<?php esc_attr_e('Confirm password', 'give'); ?>" |
|
| 1193 | + type="password"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1194 | 1194 | </div> |
| 1195 | 1195 | <?php |
| 1196 | 1196 | /** |
@@ -1200,7 +1200,7 @@ discard block |
||
| 1200 | 1200 | * |
| 1201 | 1201 | * @param int $form_id The form ID. |
| 1202 | 1202 | */ |
| 1203 | - do_action( 'give_register_account_fields_after', $form_id ); |
|
| 1203 | + do_action('give_register_account_fields_after', $form_id); |
|
| 1204 | 1204 | ?> |
| 1205 | 1205 | </fieldset> |
| 1206 | 1206 | |
@@ -1212,7 +1212,7 @@ discard block |
||
| 1212 | 1212 | * |
| 1213 | 1213 | * @param int $form_id The form ID. |
| 1214 | 1214 | */ |
| 1215 | - do_action( 'give_register_fields_after', $form_id ); |
|
| 1215 | + do_action('give_register_fields_after', $form_id); |
|
| 1216 | 1216 | ?> |
| 1217 | 1217 | |
| 1218 | 1218 | <input type="hidden" name="give-purchase-var" value="needs-to-register"/> |
@@ -1223,7 +1223,7 @@ discard block |
||
| 1223 | 1223 | * |
| 1224 | 1224 | * @since 1.7 |
| 1225 | 1225 | */ |
| 1226 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
| 1226 | + do_action('give_donation_form_user_info', $form_id); |
|
| 1227 | 1227 | ?> |
| 1228 | 1228 | |
| 1229 | 1229 | </fieldset> |
@@ -1231,7 +1231,7 @@ discard block |
||
| 1231 | 1231 | echo ob_get_clean(); |
| 1232 | 1232 | } |
| 1233 | 1233 | |
| 1234 | -add_action( 'give_donation_form_register_fields', 'give_get_register_fields' ); |
|
| 1234 | +add_action('give_donation_form_register_fields', 'give_get_register_fields'); |
|
| 1235 | 1235 | |
| 1236 | 1236 | /** |
| 1237 | 1237 | * Gets the login fields for the login form on the checkout. This function hooks |
@@ -1244,27 +1244,27 @@ discard block |
||
| 1244 | 1244 | * |
| 1245 | 1245 | * @return string |
| 1246 | 1246 | */ |
| 1247 | -function give_get_login_fields( $form_id ) { |
|
| 1247 | +function give_get_login_fields($form_id) { |
|
| 1248 | 1248 | |
| 1249 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : $form_id; |
|
| 1250 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
| 1249 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : $form_id; |
|
| 1250 | + $show_register_form = give_show_login_register_option($form_id); |
|
| 1251 | 1251 | |
| 1252 | 1252 | ob_start(); |
| 1253 | 1253 | ?> |
| 1254 | 1254 | <fieldset id="give-login-fields-<?php echo $form_id; ?>"> |
| 1255 | - <legend><?php echo apply_filters( 'give_account_login_fieldset_heading', esc_html__( 'Login to Your Account', 'give' ) ); |
|
| 1256 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
| 1257 | - echo ' <span class="sub-text">' . esc_html__( '(optional)', 'give' ) . '</span>'; |
|
| 1255 | + <legend><?php echo apply_filters('give_account_login_fieldset_heading', esc_html__('Login to Your Account', 'give')); |
|
| 1256 | + if ( ! give_logged_in_only($form_id)) { |
|
| 1257 | + echo ' <span class="sub-text">'.esc_html__('(optional)', 'give').'</span>'; |
|
| 1258 | 1258 | } ?> |
| 1259 | 1259 | </legend> |
| 1260 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
| 1260 | + <?php if ($show_register_form == 'both') { ?> |
|
| 1261 | 1261 | <p class="give-new-account-link"> |
| 1262 | - <?php esc_html_e( 'Need to create an account?', 'give' ); ?> |
|
| 1263 | - <a href="<?php echo remove_query_arg( 'login' ); ?>" class="give-checkout-register-cancel" |
|
| 1262 | + <?php esc_html_e('Need to create an account?', 'give'); ?> |
|
| 1263 | + <a href="<?php echo remove_query_arg('login'); ?>" class="give-checkout-register-cancel" |
|
| 1264 | 1264 | data-action="give_checkout_register"> |
| 1265 | - <?php esc_html_e( 'Register', 'give' ); |
|
| 1266 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
| 1267 | - echo ' ' . esc_html__( 'and donate as a guest »', 'give' ); |
|
| 1265 | + <?php esc_html_e('Register', 'give'); |
|
| 1266 | + if ( ! give_logged_in_only($form_id)) { |
|
| 1267 | + echo ' '.esc_html__('and donate as a guest »', 'give'); |
|
| 1268 | 1268 | } ?> |
| 1269 | 1269 | </a> |
| 1270 | 1270 | </p> |
@@ -1280,49 +1280,49 @@ discard block |
||
| 1280 | 1280 | * |
| 1281 | 1281 | * @param int $form_id The form ID. |
| 1282 | 1282 | */ |
| 1283 | - do_action( 'give_checkout_login_fields_before', $form_id ); |
|
| 1283 | + do_action('give_checkout_login_fields_before', $form_id); |
|
| 1284 | 1284 | ?> |
| 1285 | 1285 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-first form-row-responsive"> |
| 1286 | 1286 | <label class="give-label" for="give-user-login-<?php echo $form_id; ?>"> |
| 1287 | - <?php esc_html_e( 'Username', 'give' ); ?> |
|
| 1288 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1287 | + <?php esc_html_e('Username', 'give'); ?> |
|
| 1288 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1289 | 1289 | <span class="give-required-indicator">*</span> |
| 1290 | 1290 | <?php } ?> |
| 1291 | 1291 | </label> |
| 1292 | 1292 | |
| 1293 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" type="text" |
|
| 1293 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" type="text" |
|
| 1294 | 1294 | name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" |
| 1295 | - placeholder="<?php esc_attr_e( 'Your username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1295 | + placeholder="<?php esc_attr_e('Your username', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1296 | 1296 | </div> |
| 1297 | 1297 | |
| 1298 | 1298 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" |
| 1299 | 1299 | class="give_login_password form-row form-row-last form-row-responsive"> |
| 1300 | 1300 | <label class="give-label" for="give-user-pass-<?php echo $form_id; ?>"> |
| 1301 | - <?php esc_html_e( 'Password', 'give' ); ?> |
|
| 1302 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1301 | + <?php esc_html_e('Password', 'give'); ?> |
|
| 1302 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1303 | 1303 | <span class="give-required-indicator">*</span> |
| 1304 | 1304 | <?php } ?> |
| 1305 | 1305 | </label> |
| 1306 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" |
|
| 1306 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" |
|
| 1307 | 1307 | type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" |
| 1308 | - placeholder="<?php esc_attr_e( 'Your password', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1308 | + placeholder="<?php esc_attr_e('Your password', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1309 | 1309 | <input type="hidden" name="give-purchase-var" value="needs-to-login"/> |
| 1310 | 1310 | </div> |
| 1311 | 1311 | |
| 1312 | 1312 | <div id="give-forgot-password-wrap-<?php echo $form_id; ?>" class="give_login_forgot_password"> |
| 1313 | 1313 | <span class="give-forgot-password "> |
| 1314 | 1314 | <a href="<?php echo wp_lostpassword_url() ?>" |
| 1315 | - target="_blank"><?php esc_html_e( 'Reset Password', 'give' ) ?></a> |
|
| 1315 | + target="_blank"><?php esc_html_e('Reset Password', 'give') ?></a> |
|
| 1316 | 1316 | </span> |
| 1317 | 1317 | </div> |
| 1318 | 1318 | |
| 1319 | 1319 | <div id="give-user-login-submit-<?php echo $form_id; ?>" class="give-clearfix"> |
| 1320 | 1320 | <input type="submit" class="give-submit give-btn button" name="give_login_submit" |
| 1321 | - value="<?php esc_attr_e( 'Login', 'give' ); ?>"/> |
|
| 1322 | - <?php if ( $show_register_form !== 'login' ) { ?> |
|
| 1321 | + value="<?php esc_attr_e('Login', 'give'); ?>"/> |
|
| 1322 | + <?php if ($show_register_form !== 'login') { ?> |
|
| 1323 | 1323 | <input type="button" data-action="give_cancel_login" |
| 1324 | 1324 | class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" |
| 1325 | - value="<?php esc_attr_e( 'Cancel', 'give' ); ?>"/> |
|
| 1325 | + value="<?php esc_attr_e('Cancel', 'give'); ?>"/> |
|
| 1326 | 1326 | <?php } ?> |
| 1327 | 1327 | <span class="give-loading-animation"></span> |
| 1328 | 1328 | </div> |
@@ -1334,14 +1334,14 @@ discard block |
||
| 1334 | 1334 | * |
| 1335 | 1335 | * @param int $form_id The form ID. |
| 1336 | 1336 | */ |
| 1337 | - do_action( 'give_checkout_login_fields_after', $form_id ); |
|
| 1337 | + do_action('give_checkout_login_fields_after', $form_id); |
|
| 1338 | 1338 | ?> |
| 1339 | 1339 | </fieldset><!--end #give-login-fields--> |
| 1340 | 1340 | <?php |
| 1341 | 1341 | echo ob_get_clean(); |
| 1342 | 1342 | } |
| 1343 | 1343 | |
| 1344 | -add_action( 'give_donation_form_login_fields', 'give_get_login_fields', 10, 1 ); |
|
| 1344 | +add_action('give_donation_form_login_fields', 'give_get_login_fields', 10, 1); |
|
| 1345 | 1345 | |
| 1346 | 1346 | /** |
| 1347 | 1347 | * Payment Mode Select. |
@@ -1357,9 +1357,9 @@ discard block |
||
| 1357 | 1357 | * |
| 1358 | 1358 | * @return void |
| 1359 | 1359 | */ |
| 1360 | -function give_payment_mode_select( $form_id ) { |
|
| 1360 | +function give_payment_mode_select($form_id) { |
|
| 1361 | 1361 | |
| 1362 | - $gateways = give_get_enabled_payment_gateways( $form_id ); |
|
| 1362 | + $gateways = give_get_enabled_payment_gateways($form_id); |
|
| 1363 | 1363 | |
| 1364 | 1364 | /** |
| 1365 | 1365 | * Fires while selecting payment gateways, before the fields. |
@@ -1368,10 +1368,10 @@ discard block |
||
| 1368 | 1368 | * |
| 1369 | 1369 | * @param int $form_id The form ID. |
| 1370 | 1370 | */ |
| 1371 | - do_action( 'give_payment_mode_top', $form_id ); |
|
| 1371 | + do_action('give_payment_mode_top', $form_id); |
|
| 1372 | 1372 | ?> |
| 1373 | 1373 | |
| 1374 | - <fieldset id="give-payment-mode-select" <?php if ( count( $gateways ) <= 1 ) { |
|
| 1374 | + <fieldset id="give-payment-mode-select" <?php if (count($gateways) <= 1) { |
|
| 1375 | 1375 | echo 'style="display: none;"'; |
| 1376 | 1376 | } ?>> |
| 1377 | 1377 | <?php |
@@ -1382,10 +1382,10 @@ discard block |
||
| 1382 | 1382 | * |
| 1383 | 1383 | * @param int $form_id The form ID. |
| 1384 | 1384 | */ |
| 1385 | - do_action( 'give_payment_mode_before_gateways_wrap' ); |
|
| 1385 | + do_action('give_payment_mode_before_gateways_wrap'); |
|
| 1386 | 1386 | ?> |
| 1387 | 1387 | <legend |
| 1388 | - class="give-payment-mode-label"><?php echo apply_filters( 'give_checkout_payment_method_text', esc_html__( 'Select Payment Method', 'give' ) ); ?> |
|
| 1388 | + class="give-payment-mode-label"><?php echo apply_filters('give_checkout_payment_method_text', esc_html__('Select Payment Method', 'give')); ?> |
|
| 1389 | 1389 | <span class="give-loading-text"><span |
| 1390 | 1390 | class="give-loading-animation"></span> |
| 1391 | 1391 | </span> |
@@ -1398,26 +1398,26 @@ discard block |
||
| 1398 | 1398 | * |
| 1399 | 1399 | * @since 1.7 |
| 1400 | 1400 | */ |
| 1401 | - do_action( 'give_payment_mode_before_gateways' ) |
|
| 1401 | + do_action('give_payment_mode_before_gateways') |
|
| 1402 | 1402 | ?> |
| 1403 | 1403 | <ul id="give-gateway-radio-list"> |
| 1404 | 1404 | <?php |
| 1405 | 1405 | /** |
| 1406 | 1406 | * Loop through the active payment gateways. |
| 1407 | 1407 | */ |
| 1408 | - $selected_gateway = give_get_chosen_gateway( $form_id ); |
|
| 1408 | + $selected_gateway = give_get_chosen_gateway($form_id); |
|
| 1409 | 1409 | |
| 1410 | - foreach ( $gateways as $gateway_id => $gateway ) : |
|
| 1410 | + foreach ($gateways as $gateway_id => $gateway) : |
|
| 1411 | 1411 | //Determine the default gateway. |
| 1412 | - $checked = checked( $gateway_id, $selected_gateway, false ); |
|
| 1412 | + $checked = checked($gateway_id, $selected_gateway, false); |
|
| 1413 | 1413 | $checked_class = $checked ? ' class="give-gateway-option-selected"' : ''; ?> |
| 1414 | 1414 | <li<?php echo $checked_class ?>> |
| 1415 | 1415 | <input type="radio" name="payment-mode" class="give-gateway" |
| 1416 | - id="give-gateway-<?php echo esc_attr( $gateway_id ) . '-' . $form_id; ?>" |
|
| 1417 | - value="<?php echo esc_attr( $gateway_id ); ?>"<?php echo $checked; ?>> |
|
| 1418 | - <label for="give-gateway-<?php echo esc_attr( $gateway_id ) . '-' . $form_id; ?>" |
|
| 1416 | + id="give-gateway-<?php echo esc_attr($gateway_id).'-'.$form_id; ?>" |
|
| 1417 | + value="<?php echo esc_attr($gateway_id); ?>"<?php echo $checked; ?>> |
|
| 1418 | + <label for="give-gateway-<?php echo esc_attr($gateway_id).'-'.$form_id; ?>" |
|
| 1419 | 1419 | class="give-gateway-option" |
| 1420 | - id="give-gateway-option-<?php echo esc_attr( $gateway_id ); ?>"> <?php echo esc_html( $gateway['checkout_label'] ); ?></label> |
|
| 1420 | + id="give-gateway-option-<?php echo esc_attr($gateway_id); ?>"> <?php echo esc_html($gateway['checkout_label']); ?></label> |
|
| 1421 | 1421 | </li> |
| 1422 | 1422 | <?php |
| 1423 | 1423 | endforeach; |
@@ -1429,7 +1429,7 @@ discard block |
||
| 1429 | 1429 | * |
| 1430 | 1430 | * @since 1.7 |
| 1431 | 1431 | */ |
| 1432 | - do_action( 'give_payment_mode_after_gateways' ); |
|
| 1432 | + do_action('give_payment_mode_after_gateways'); |
|
| 1433 | 1433 | ?> |
| 1434 | 1434 | </div> |
| 1435 | 1435 | <?php |
@@ -1440,7 +1440,7 @@ discard block |
||
| 1440 | 1440 | * |
| 1441 | 1441 | * @param int $form_id The form ID. |
| 1442 | 1442 | */ |
| 1443 | - do_action( 'give_payment_mode_after_gateways_wrap' ); |
|
| 1443 | + do_action('give_payment_mode_after_gateways_wrap'); |
|
| 1444 | 1444 | ?> |
| 1445 | 1445 | </fieldset> |
| 1446 | 1446 | |
@@ -1452,7 +1452,7 @@ discard block |
||
| 1452 | 1452 | * |
| 1453 | 1453 | * @param int $form_id The form ID. |
| 1454 | 1454 | */ |
| 1455 | - do_action( 'give_payment_mode_bottom', $form_id ); |
|
| 1455 | + do_action('give_payment_mode_bottom', $form_id); |
|
| 1456 | 1456 | ?> |
| 1457 | 1457 | |
| 1458 | 1458 | <div id="give_purchase_form_wrap"> |
@@ -1463,7 +1463,7 @@ discard block |
||
| 1463 | 1463 | * |
| 1464 | 1464 | * @since 1.7 |
| 1465 | 1465 | */ |
| 1466 | - do_action( 'give_donation_form', $form_id ); |
|
| 1466 | + do_action('give_donation_form', $form_id); |
|
| 1467 | 1467 | ?> |
| 1468 | 1468 | |
| 1469 | 1469 | </div> |
@@ -1474,10 +1474,10 @@ discard block |
||
| 1474 | 1474 | * |
| 1475 | 1475 | * @since 1.7 |
| 1476 | 1476 | */ |
| 1477 | - do_action( 'give_donation_form_wrap_bottom', $form_id ); |
|
| 1477 | + do_action('give_donation_form_wrap_bottom', $form_id); |
|
| 1478 | 1478 | } |
| 1479 | 1479 | |
| 1480 | -add_action( 'give_payment_mode_select', 'give_payment_mode_select' ); |
|
| 1480 | +add_action('give_payment_mode_select', 'give_payment_mode_select'); |
|
| 1481 | 1481 | |
| 1482 | 1482 | /** |
| 1483 | 1483 | * Renders the Checkout Agree to Terms, this displays a checkbox for users to |
@@ -1490,31 +1490,31 @@ discard block |
||
| 1490 | 1490 | * |
| 1491 | 1491 | * @return bool |
| 1492 | 1492 | */ |
| 1493 | -function give_terms_agreement( $form_id ) { |
|
| 1494 | - $form_option = give_get_meta( $form_id, '_give_terms_option', true ); |
|
| 1493 | +function give_terms_agreement($form_id) { |
|
| 1494 | + $form_option = give_get_meta($form_id, '_give_terms_option', true); |
|
| 1495 | 1495 | |
| 1496 | 1496 | // Bailout if per form and global term and conditions is not setup. |
| 1497 | 1497 | if ( |
| 1498 | - give_is_setting_enabled( $form_option, 'global' ) |
|
| 1499 | - && give_is_setting_enabled( give_get_option( 'terms' ) ) |
|
| 1498 | + give_is_setting_enabled($form_option, 'global') |
|
| 1499 | + && give_is_setting_enabled(give_get_option('terms')) |
|
| 1500 | 1500 | ) { |
| 1501 | - $label = give_get_option( 'agree_to_terms_label', esc_html__( 'Agree to Terms?', 'give' ) ); |
|
| 1502 | - $terms = $terms = give_get_option( 'agreement_text', '' ); |
|
| 1503 | - $edit_term_url = admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=display§ion=term-and-conditions' ); |
|
| 1501 | + $label = give_get_option('agree_to_terms_label', esc_html__('Agree to Terms?', 'give')); |
|
| 1502 | + $terms = $terms = give_get_option('agreement_text', ''); |
|
| 1503 | + $edit_term_url = admin_url('edit.php?post_type=give_forms&page=give-settings&tab=display§ion=term-and-conditions'); |
|
| 1504 | 1504 | |
| 1505 | - } elseif ( give_is_setting_enabled( $form_option ) ) { |
|
| 1506 | - $label = ( $label = give_get_meta( $form_id, '_give_agree_label', true ) ) ? stripslashes( $label ) : esc_html__( 'Agree to Terms?', 'give' ); |
|
| 1507 | - $terms = give_get_meta( $form_id, '_give_agree_text', true ); |
|
| 1508 | - $edit_term_url = admin_url( 'post.php?post=' . $form_id . '&action=edit#form_terms_options' ); |
|
| 1505 | + } elseif (give_is_setting_enabled($form_option)) { |
|
| 1506 | + $label = ($label = give_get_meta($form_id, '_give_agree_label', true)) ? stripslashes($label) : esc_html__('Agree to Terms?', 'give'); |
|
| 1507 | + $terms = give_get_meta($form_id, '_give_agree_text', true); |
|
| 1508 | + $edit_term_url = admin_url('post.php?post='.$form_id.'&action=edit#form_terms_options'); |
|
| 1509 | 1509 | |
| 1510 | 1510 | } else { |
| 1511 | 1511 | return false; |
| 1512 | 1512 | } |
| 1513 | 1513 | |
| 1514 | 1514 | // Bailout: Check if term and conditions text is empty or not. |
| 1515 | - if ( empty( $terms ) ) { |
|
| 1516 | - if ( is_user_logged_in() && current_user_can( 'edit_give_forms' ) ) { |
|
| 1517 | - echo sprintf( __( 'Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give' ), $edit_term_url ); |
|
| 1515 | + if (empty($terms)) { |
|
| 1516 | + if (is_user_logged_in() && current_user_can('edit_give_forms')) { |
|
| 1517 | + echo sprintf(__('Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give'), $edit_term_url); |
|
| 1518 | 1518 | } |
| 1519 | 1519 | |
| 1520 | 1520 | return false; |
@@ -1522,7 +1522,7 @@ discard block |
||
| 1522 | 1522 | |
| 1523 | 1523 | ?> |
| 1524 | 1524 | <fieldset id="give_terms_agreement"> |
| 1525 | - <legend><?php echo apply_filters( 'give_terms_agreement_text', esc_html__( 'Terms', 'give' ) ); ?></legend> |
|
| 1525 | + <legend><?php echo apply_filters('give_terms_agreement_text', esc_html__('Terms', 'give')); ?></legend> |
|
| 1526 | 1526 | <div id="give_terms" class="give_terms-<?php echo $form_id; ?>" style="display:none;"> |
| 1527 | 1527 | <?php |
| 1528 | 1528 | /** |
@@ -1530,22 +1530,22 @@ discard block |
||
| 1530 | 1530 | * |
| 1531 | 1531 | * @since 1.0 |
| 1532 | 1532 | */ |
| 1533 | - do_action( 'give_before_terms' ); |
|
| 1533 | + do_action('give_before_terms'); |
|
| 1534 | 1534 | |
| 1535 | - echo wpautop( stripslashes( $terms ) ); |
|
| 1535 | + echo wpautop(stripslashes($terms)); |
|
| 1536 | 1536 | /** |
| 1537 | 1537 | * Fires while rendering terms of agreement, after the fields. |
| 1538 | 1538 | * |
| 1539 | 1539 | * @since 1.0 |
| 1540 | 1540 | */ |
| 1541 | - do_action( 'give_after_terms' ); |
|
| 1541 | + do_action('give_after_terms'); |
|
| 1542 | 1542 | ?> |
| 1543 | 1543 | </div> |
| 1544 | 1544 | <div id="give_show_terms"> |
| 1545 | 1545 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
| 1546 | - aria-controls="give_terms"><?php esc_html_e( 'Show Terms', 'give' ); ?></a> |
|
| 1546 | + aria-controls="give_terms"><?php esc_html_e('Show Terms', 'give'); ?></a> |
|
| 1547 | 1547 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
| 1548 | - aria-controls="give_terms" style="display:none;"><?php esc_html_e( 'Hide Terms', 'give' ); ?></a> |
|
| 1548 | + aria-controls="give_terms" style="display:none;"><?php esc_html_e('Hide Terms', 'give'); ?></a> |
|
| 1549 | 1549 | </div> |
| 1550 | 1550 | |
| 1551 | 1551 | <input name="give_agree_to_terms" class="required" type="checkbox" |
@@ -1556,7 +1556,7 @@ discard block |
||
| 1556 | 1556 | <?php |
| 1557 | 1557 | } |
| 1558 | 1558 | |
| 1559 | -add_action( 'give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1 ); |
|
| 1559 | +add_action('give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1); |
|
| 1560 | 1560 | |
| 1561 | 1561 | /** |
| 1562 | 1562 | * Checkout Final Total. |
@@ -1569,31 +1569,30 @@ discard block |
||
| 1569 | 1569 | * |
| 1570 | 1570 | * @return void |
| 1571 | 1571 | */ |
| 1572 | -function give_checkout_final_total( $form_id ) { |
|
| 1572 | +function give_checkout_final_total($form_id) { |
|
| 1573 | 1573 | |
| 1574 | - $total = isset( $_POST['give_total'] ) ? |
|
| 1575 | - apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give_total'] ) ) : |
|
| 1576 | - give_get_default_form_amount( $form_id ); |
|
| 1574 | + $total = isset($_POST['give_total']) ? |
|
| 1575 | + apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give_total'])) : give_get_default_form_amount($form_id); |
|
| 1577 | 1576 | |
| 1578 | 1577 | |
| 1579 | 1578 | //Only proceed if give_total available. |
| 1580 | - if ( empty( $total ) ) { |
|
| 1579 | + if (empty($total)) { |
|
| 1581 | 1580 | return; |
| 1582 | 1581 | } |
| 1583 | 1582 | ?> |
| 1584 | 1583 | <p id="give-final-total-wrap" class="form-wrap "> |
| 1585 | 1584 | <span class="give-donation-total-label"> |
| 1586 | - <?php echo apply_filters( 'give_donation_total_label', esc_html__( 'Donation Total:', 'give' ) ); ?> |
|
| 1585 | + <?php echo apply_filters('give_donation_total_label', esc_html__('Donation Total:', 'give')); ?> |
|
| 1587 | 1586 | </span> |
| 1588 | 1587 | <span class="give-final-total-amount" |
| 1589 | - data-total="<?php echo give_format_amount( $total, array( 'sanitize' => false ) ); ?>"> |
|
| 1590 | - <?php echo give_currency_filter( give_format_amount( $total, array( 'sanitize' => false ) ) ); ?> |
|
| 1588 | + data-total="<?php echo give_format_amount($total, array('sanitize' => false)); ?>"> |
|
| 1589 | + <?php echo give_currency_filter(give_format_amount($total, array('sanitize' => false))); ?> |
|
| 1591 | 1590 | </span> |
| 1592 | 1591 | </p> |
| 1593 | 1592 | <?php |
| 1594 | 1593 | } |
| 1595 | 1594 | |
| 1596 | -add_action( 'give_donation_form_before_submit', 'give_checkout_final_total', 999 ); |
|
| 1595 | +add_action('give_donation_form_before_submit', 'give_checkout_final_total', 999); |
|
| 1597 | 1596 | |
| 1598 | 1597 | /** |
| 1599 | 1598 | * Renders the Checkout Submit section. |
@@ -1604,7 +1603,7 @@ discard block |
||
| 1604 | 1603 | * |
| 1605 | 1604 | * @return void |
| 1606 | 1605 | */ |
| 1607 | -function give_checkout_submit( $form_id ) { |
|
| 1606 | +function give_checkout_submit($form_id) { |
|
| 1608 | 1607 | ?> |
| 1609 | 1608 | <fieldset id="give_purchase_submit"> |
| 1610 | 1609 | <?php |
@@ -1613,24 +1612,24 @@ discard block |
||
| 1613 | 1612 | * |
| 1614 | 1613 | * @since 1.7 |
| 1615 | 1614 | */ |
| 1616 | - do_action( 'give_donation_form_before_submit', $form_id ); |
|
| 1615 | + do_action('give_donation_form_before_submit', $form_id); |
|
| 1617 | 1616 | |
| 1618 | - give_checkout_hidden_fields( $form_id ); |
|
| 1617 | + give_checkout_hidden_fields($form_id); |
|
| 1619 | 1618 | |
| 1620 | - echo give_get_donation_form_submit_button( $form_id ); |
|
| 1619 | + echo give_get_donation_form_submit_button($form_id); |
|
| 1621 | 1620 | |
| 1622 | 1621 | /** |
| 1623 | 1622 | * Fire after donation form submit. |
| 1624 | 1623 | * |
| 1625 | 1624 | * @since 1.7 |
| 1626 | 1625 | */ |
| 1627 | - do_action( 'give_donation_form_after_submit', $form_id ); |
|
| 1626 | + do_action('give_donation_form_after_submit', $form_id); |
|
| 1628 | 1627 | ?> |
| 1629 | 1628 | </fieldset> |
| 1630 | 1629 | <?php |
| 1631 | 1630 | } |
| 1632 | 1631 | |
| 1633 | -add_action( 'give_donation_form_after_cc_form', 'give_checkout_submit', 9999 ); |
|
| 1632 | +add_action('give_donation_form_after_cc_form', 'give_checkout_submit', 9999); |
|
| 1634 | 1633 | |
| 1635 | 1634 | /** |
| 1636 | 1635 | * Give Donation form submit button. |
@@ -1641,10 +1640,10 @@ discard block |
||
| 1641 | 1640 | * |
| 1642 | 1641 | * @return string |
| 1643 | 1642 | */ |
| 1644 | -function give_get_donation_form_submit_button( $form_id ) { |
|
| 1643 | +function give_get_donation_form_submit_button($form_id) { |
|
| 1645 | 1644 | |
| 1646 | - $display_label_field = give_get_meta( $form_id, '_give_checkout_label', true ); |
|
| 1647 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
| 1645 | + $display_label_field = give_get_meta($form_id, '_give_checkout_label', true); |
|
| 1646 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
| 1648 | 1647 | ob_start(); |
| 1649 | 1648 | ?> |
| 1650 | 1649 | <div class="give-submit-button-wrap give-clearfix"> |
@@ -1653,7 +1652,7 @@ discard block |
||
| 1653 | 1652 | <span class="give-loading-animation"></span> |
| 1654 | 1653 | </div> |
| 1655 | 1654 | <?php |
| 1656 | - return apply_filters( 'give_donation_form_submit_button', ob_get_clean(), $form_id ); |
|
| 1655 | + return apply_filters('give_donation_form_submit_button', ob_get_clean(), $form_id); |
|
| 1657 | 1656 | } |
| 1658 | 1657 | |
| 1659 | 1658 | /** |
@@ -1668,17 +1667,17 @@ discard block |
||
| 1668 | 1667 | * |
| 1669 | 1668 | * @return mixed |
| 1670 | 1669 | */ |
| 1671 | -function give_show_goal_progress( $form_id, $args ) { |
|
| 1670 | +function give_show_goal_progress($form_id, $args) { |
|
| 1672 | 1671 | |
| 1673 | 1672 | ob_start(); |
| 1674 | - give_get_template( 'shortcode-goal', array( 'form_id' => $form_id, 'args' => $args ) ); |
|
| 1673 | + give_get_template('shortcode-goal', array('form_id' => $form_id, 'args' => $args)); |
|
| 1675 | 1674 | |
| 1676 | - echo apply_filters( 'give_goal_output', ob_get_clean() ); |
|
| 1675 | + echo apply_filters('give_goal_output', ob_get_clean()); |
|
| 1677 | 1676 | |
| 1678 | 1677 | return true; |
| 1679 | 1678 | } |
| 1680 | 1679 | |
| 1681 | -add_action( 'give_pre_form', 'give_show_goal_progress', 10, 2 ); |
|
| 1680 | +add_action('give_pre_form', 'give_show_goal_progress', 10, 2); |
|
| 1682 | 1681 | |
| 1683 | 1682 | |
| 1684 | 1683 | /** |
@@ -1691,10 +1690,10 @@ discard block |
||
| 1691 | 1690 | * |
| 1692 | 1691 | * @return mixed|string |
| 1693 | 1692 | */ |
| 1694 | -function give_get_form_content_placement( $form_id, $args ) { |
|
| 1693 | +function give_get_form_content_placement($form_id, $args) { |
|
| 1695 | 1694 | $show_content = ''; |
| 1696 | 1695 | |
| 1697 | - if ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) { |
|
| 1696 | + if (isset($args['show_content']) && ! empty($args['show_content'])) { |
|
| 1698 | 1697 | // Content positions. |
| 1699 | 1698 | $content_placement = array( |
| 1700 | 1699 | 'above' => 'give_pre_form', |
@@ -1702,18 +1701,18 @@ discard block |
||
| 1702 | 1701 | ); |
| 1703 | 1702 | |
| 1704 | 1703 | // Check if content position already decoded. |
| 1705 | - if ( in_array( $args['show_content'], $content_placement ) ) { |
|
| 1704 | + if (in_array($args['show_content'], $content_placement)) { |
|
| 1706 | 1705 | return $args['show_content']; |
| 1707 | 1706 | } |
| 1708 | 1707 | |
| 1709 | - $show_content = ( 'none' !== $args['show_content'] ? $content_placement[ $args['show_content'] ] : '' ); |
|
| 1708 | + $show_content = ('none' !== $args['show_content'] ? $content_placement[$args['show_content']] : ''); |
|
| 1710 | 1709 | |
| 1711 | - } elseif ( give_is_setting_enabled( give_get_meta( $form_id, '_give_display_content', true ) ) ) { |
|
| 1712 | - $show_content = give_get_meta( $form_id, '_give_content_placement', true ); |
|
| 1710 | + } elseif (give_is_setting_enabled(give_get_meta($form_id, '_give_display_content', true))) { |
|
| 1711 | + $show_content = give_get_meta($form_id, '_give_content_placement', true); |
|
| 1713 | 1712 | |
| 1714 | - } elseif ( 'none' !== give_get_meta( $form_id, '_give_content_option', true ) ) { |
|
| 1713 | + } elseif ('none' !== give_get_meta($form_id, '_give_content_option', true)) { |
|
| 1715 | 1714 | // Backward compatibility for _give_content_option for v18. |
| 1716 | - $show_content = give_get_meta( $form_id, '_give_content_option', true ); |
|
| 1715 | + $show_content = give_get_meta($form_id, '_give_content_option', true); |
|
| 1717 | 1716 | } |
| 1718 | 1717 | |
| 1719 | 1718 | return $show_content; |
@@ -1729,20 +1728,20 @@ discard block |
||
| 1729 | 1728 | * |
| 1730 | 1729 | * @return void|bool |
| 1731 | 1730 | */ |
| 1732 | -function give_form_content( $form_id, $args ) { |
|
| 1731 | +function give_form_content($form_id, $args) { |
|
| 1733 | 1732 | |
| 1734 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
| 1733 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
| 1735 | 1734 | |
| 1736 | 1735 | // Bailout. |
| 1737 | - if ( empty( $show_content ) ) { |
|
| 1736 | + if (empty($show_content)) { |
|
| 1738 | 1737 | return false; |
| 1739 | 1738 | } |
| 1740 | 1739 | |
| 1741 | 1740 | // Add action according to value. |
| 1742 | - add_action( $show_content, 'give_form_display_content', 10, 2 ); |
|
| 1741 | + add_action($show_content, 'give_form_display_content', 10, 2); |
|
| 1743 | 1742 | } |
| 1744 | 1743 | |
| 1745 | -add_action( 'give_pre_form_output', 'give_form_content', 10, 2 ); |
|
| 1744 | +add_action('give_pre_form_output', 'give_form_content', 10, 2); |
|
| 1746 | 1745 | |
| 1747 | 1746 | /** |
| 1748 | 1747 | * Renders Post Form Content. |
@@ -1756,22 +1755,22 @@ discard block |
||
| 1756 | 1755 | * |
| 1757 | 1756 | * @return void |
| 1758 | 1757 | */ |
| 1759 | -function give_form_display_content( $form_id, $args ) { |
|
| 1758 | +function give_form_display_content($form_id, $args) { |
|
| 1760 | 1759 | |
| 1761 | - $content = wpautop( give_get_meta( $form_id, '_give_form_content', true ) ); |
|
| 1762 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
| 1760 | + $content = wpautop(give_get_meta($form_id, '_give_form_content', true)); |
|
| 1761 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
| 1763 | 1762 | |
| 1764 | - if ( give_is_setting_enabled( give_get_option( 'the_content_filter' ) ) ) { |
|
| 1765 | - $content = apply_filters( 'the_content', $content ); |
|
| 1763 | + if (give_is_setting_enabled(give_get_option('the_content_filter'))) { |
|
| 1764 | + $content = apply_filters('the_content', $content); |
|
| 1766 | 1765 | } |
| 1767 | 1766 | |
| 1768 | - $output = '<div id="give-form-content-' . $form_id . '" class="give-form-content-wrap ' . $show_content . '-content">' . $content . '</div>'; |
|
| 1767 | + $output = '<div id="give-form-content-'.$form_id.'" class="give-form-content-wrap '.$show_content.'-content">'.$content.'</div>'; |
|
| 1769 | 1768 | |
| 1770 | - echo apply_filters( 'give_form_content_output', $output ); |
|
| 1769 | + echo apply_filters('give_form_content_output', $output); |
|
| 1771 | 1770 | |
| 1772 | 1771 | //remove action to prevent content output on addition forms on page. |
| 1773 | 1772 | //@see: https://github.com/WordImpress/Give/issues/634. |
| 1774 | - remove_action( $show_content, 'give_form_display_content' ); |
|
| 1773 | + remove_action($show_content, 'give_form_display_content'); |
|
| 1775 | 1774 | } |
| 1776 | 1775 | |
| 1777 | 1776 | /** |
@@ -1783,7 +1782,7 @@ discard block |
||
| 1783 | 1782 | * |
| 1784 | 1783 | * @return void |
| 1785 | 1784 | */ |
| 1786 | -function give_checkout_hidden_fields( $form_id ) { |
|
| 1785 | +function give_checkout_hidden_fields($form_id) { |
|
| 1787 | 1786 | |
| 1788 | 1787 | /** |
| 1789 | 1788 | * Fires while rendering hidden checkout fields, before the fields. |
@@ -1792,13 +1791,13 @@ discard block |
||
| 1792 | 1791 | * |
| 1793 | 1792 | * @param int $form_id The form ID. |
| 1794 | 1793 | */ |
| 1795 | - do_action( 'give_hidden_fields_before', $form_id ); |
|
| 1794 | + do_action('give_hidden_fields_before', $form_id); |
|
| 1796 | 1795 | |
| 1797 | - if ( is_user_logged_in() ) { ?> |
|
| 1796 | + if (is_user_logged_in()) { ?> |
|
| 1798 | 1797 | <input type="hidden" name="give-user-id" value="<?php echo get_current_user_id(); ?>"/> |
| 1799 | 1798 | <?php } ?> |
| 1800 | 1799 | <input type="hidden" name="give_action" value="purchase"/> |
| 1801 | - <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway( $form_id ); ?>"/> |
|
| 1800 | + <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway($form_id); ?>"/> |
|
| 1802 | 1801 | <?php |
| 1803 | 1802 | /** |
| 1804 | 1803 | * Fires while rendering hidden checkout fields, after the fields. |
@@ -1807,7 +1806,7 @@ discard block |
||
| 1807 | 1806 | * |
| 1808 | 1807 | * @param int $form_id The form ID. |
| 1809 | 1808 | */ |
| 1810 | - do_action( 'give_hidden_fields_after', $form_id ); |
|
| 1809 | + do_action('give_hidden_fields_after', $form_id); |
|
| 1811 | 1810 | |
| 1812 | 1811 | } |
| 1813 | 1812 | |
@@ -1822,20 +1821,20 @@ discard block |
||
| 1822 | 1821 | * |
| 1823 | 1822 | * @return string $content Filtered content. |
| 1824 | 1823 | */ |
| 1825 | -function give_filter_success_page_content( $content ) { |
|
| 1824 | +function give_filter_success_page_content($content) { |
|
| 1826 | 1825 | |
| 1827 | 1826 | $give_options = give_get_settings(); |
| 1828 | 1827 | |
| 1829 | - if ( isset( $give_options['success_page'] ) && isset( $_GET['payment-confirmation'] ) && is_page( $give_options['success_page'] ) ) { |
|
| 1830 | - if ( has_filter( 'give_payment_confirm_' . $_GET['payment-confirmation'] ) ) { |
|
| 1831 | - $content = apply_filters( 'give_payment_confirm_' . $_GET['payment-confirmation'], $content ); |
|
| 1828 | + if (isset($give_options['success_page']) && isset($_GET['payment-confirmation']) && is_page($give_options['success_page'])) { |
|
| 1829 | + if (has_filter('give_payment_confirm_'.$_GET['payment-confirmation'])) { |
|
| 1830 | + $content = apply_filters('give_payment_confirm_'.$_GET['payment-confirmation'], $content); |
|
| 1832 | 1831 | } |
| 1833 | 1832 | } |
| 1834 | 1833 | |
| 1835 | 1834 | return $content; |
| 1836 | 1835 | } |
| 1837 | 1836 | |
| 1838 | -add_filter( 'the_content', 'give_filter_success_page_content' ); |
|
| 1837 | +add_filter('the_content', 'give_filter_success_page_content'); |
|
| 1839 | 1838 | |
| 1840 | 1839 | /** |
| 1841 | 1840 | * Test Mode Frontend Warning. |
@@ -1846,12 +1845,12 @@ discard block |
||
| 1846 | 1845 | */ |
| 1847 | 1846 | function give_test_mode_frontend_warning() { |
| 1848 | 1847 | |
| 1849 | - if ( give_is_test_mode() ) { |
|
| 1850 | - echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>' . esc_html__( 'Notice:', 'give' ) . '</strong> ' . esc_html__( 'Test mode is enabled. While in test mode no live donations are processed.', 'give' ) . '</p></div>'; |
|
| 1848 | + if (give_is_test_mode()) { |
|
| 1849 | + echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>'.esc_html__('Notice:', 'give').'</strong> '.esc_html__('Test mode is enabled. While in test mode no live donations are processed.', 'give').'</p></div>'; |
|
| 1851 | 1850 | } |
| 1852 | 1851 | } |
| 1853 | 1852 | |
| 1854 | -add_action( 'give_pre_form', 'give_test_mode_frontend_warning', 10 ); |
|
| 1853 | +add_action('give_pre_form', 'give_test_mode_frontend_warning', 10); |
|
| 1855 | 1854 | |
| 1856 | 1855 | /** |
| 1857 | 1856 | * Members-only Form. |
@@ -1865,21 +1864,21 @@ discard block |
||
| 1865 | 1864 | * |
| 1866 | 1865 | * @return string |
| 1867 | 1866 | */ |
| 1868 | -function give_members_only_form( $final_output, $args ) { |
|
| 1867 | +function give_members_only_form($final_output, $args) { |
|
| 1869 | 1868 | |
| 1870 | - $form_id = isset( $args['form_id'] ) ? $args['form_id'] : 0; |
|
| 1869 | + $form_id = isset($args['form_id']) ? $args['form_id'] : 0; |
|
| 1871 | 1870 | |
| 1872 | 1871 | //Sanity Check: Must have form_id & not be logged in. |
| 1873 | - if ( empty( $form_id ) || is_user_logged_in() ) { |
|
| 1872 | + if (empty($form_id) || is_user_logged_in()) { |
|
| 1874 | 1873 | return $final_output; |
| 1875 | 1874 | } |
| 1876 | 1875 | |
| 1877 | 1876 | //Logged in only and Register / Login set to none. |
| 1878 | - if ( give_logged_in_only( $form_id ) && give_show_login_register_option( $form_id ) == 'none' ) { |
|
| 1877 | + if (give_logged_in_only($form_id) && give_show_login_register_option($form_id) == 'none') { |
|
| 1879 | 1878 | |
| 1880 | - $final_output = Give()->notices->print_frontend_notice( esc_html__( 'Please log in in order to complete your donation.', 'give' ), false ); |
|
| 1879 | + $final_output = Give()->notices->print_frontend_notice(esc_html__('Please log in in order to complete your donation.', 'give'), false); |
|
| 1881 | 1880 | |
| 1882 | - return apply_filters( 'give_members_only_output', $final_output, $form_id ); |
|
| 1881 | + return apply_filters('give_members_only_output', $final_output, $form_id); |
|
| 1883 | 1882 | |
| 1884 | 1883 | } |
| 1885 | 1884 | |
@@ -1887,4 +1886,4 @@ discard block |
||
| 1887 | 1886 | |
| 1888 | 1887 | } |
| 1889 | 1888 | |
| 1890 | -add_filter( 'give_donate_form', 'give_members_only_form', 10, 2 ); |
|
| 1889 | +add_filter('give_donate_form', 'give_members_only_form', 10, 2); |
|
@@ -363,8 +363,8 @@ |
||
| 363 | 363 | 'ajax_search_msg' => __( 'Searching results for match {search_term}', 'give' ), |
| 364 | 364 | ), |
| 365 | 365 | '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' ), |
| 366 | - 'error_message' => __( 'Something went wrong kindly try again!','give' ), |
|
| 367 | - 'give_donation_import' => 'give_donation_import', |
|
| 366 | + 'error_message' => __( 'Something went wrong kindly try again!','give' ), |
|
| 367 | + 'give_donation_import' => 'give_donation_import', |
|
| 368 | 368 | ) ); |
| 369 | 369 | |
| 370 | 370 | if ( function_exists( 'wp_enqueue_media' ) && version_compare( get_bloginfo( 'version' ), '3.5', '>=' ) ) { |
@@ -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' ), |
|
| 38 | + 'checkout_nonce' => wp_create_nonce('give_checkout_nonce'), |
|
| 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,81 +58,81 @@ 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 | - ) ); |
|
| 70 | + )); |
|
| 71 | 71 | |
| 72 | - $localize_give_ajax = apply_filters( 'give_global_ajax_vars', array( |
|
| 72 | + $localize_give_ajax = apply_filters('give_global_ajax_vars', array( |
|
| 73 | 73 | 'ajaxurl' => give_get_ajax_url(), |
| 74 | - 'loading' => __( 'Loading', 'give' ), |
|
| 74 | + 'loading' => __('Loading', 'give'), |
|
| 75 | 75 | // General loading message. |
| 76 | - 'select_option' => __( 'Please select an option', 'give' ), |
|
| 76 | + 'select_option' => __('Please select an option', 'give'), |
|
| 77 | 77 | // Variable pricing error with multi-donation option enabled. |
| 78 | - 'default_gateway' => give_get_default_gateway( null ), |
|
| 79 | - 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', |
|
| 78 | + 'default_gateway' => give_get_default_gateway(null), |
|
| 79 | + 'permalinks' => get_option('permalink_structure') ? '1' : '0', |
|
| 80 | 80 | 'number_decimals' => give_get_price_decimals(), |
| 81 | - ) ); |
|
| 81 | + )); |
|
| 82 | 82 | |
| 83 | 83 | // DEBUG is On. |
| 84 | - if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { |
|
| 84 | + if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) { |
|
| 85 | 85 | |
| 86 | - if ( give_is_cc_verify_enabled() ) { |
|
| 87 | - wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
| 88 | - wp_enqueue_script( 'give-cc-validator' ); |
|
| 86 | + if (give_is_cc_verify_enabled()) { |
|
| 87 | + wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
| 88 | + wp_enqueue_script('give-cc-validator'); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
| 92 | - wp_enqueue_script( 'give-float-labels' ); |
|
| 91 | + wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
| 92 | + wp_enqueue_script('give-float-labels'); |
|
| 93 | 93 | |
| 94 | - wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
| 95 | - wp_enqueue_script( 'give-blockui' ); |
|
| 94 | + wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
| 95 | + wp_enqueue_script('give-blockui'); |
|
| 96 | 96 | |
| 97 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
| 98 | - wp_enqueue_script( 'give-qtip' ); |
|
| 97 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
| 98 | + wp_enqueue_script('give-qtip'); |
|
| 99 | 99 | |
| 100 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
| 101 | - wp_enqueue_script( 'give-accounting' ); |
|
| 100 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
| 101 | + wp_enqueue_script('give-accounting'); |
|
| 102 | 102 | |
| 103 | - wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
| 104 | - wp_enqueue_script( 'give-magnific' ); |
|
| 103 | + wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
| 104 | + wp_enqueue_script('give-magnific'); |
|
| 105 | 105 | |
| 106 | - wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
| 107 | - wp_enqueue_script( 'give-checkout-global' ); |
|
| 106 | + wp_register_script('give-checkout-global', $js_dir.'give-checkout-global'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
| 107 | + wp_enqueue_script('give-checkout-global'); |
|
| 108 | 108 | |
| 109 | 109 | // General scripts. |
| 110 | - wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
| 111 | - wp_enqueue_script( 'give-scripts' ); |
|
| 110 | + wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
| 111 | + wp_enqueue_script('give-scripts'); |
|
| 112 | 112 | |
| 113 | 113 | // Load AJAX scripts, if enabled. |
| 114 | - wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
| 115 | - wp_enqueue_script( 'give-ajax' ); |
|
| 114 | + wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
| 115 | + wp_enqueue_script('give-ajax'); |
|
| 116 | 116 | |
| 117 | 117 | // Localize / Pass AJAX vars from PHP, |
| 118 | - wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_vars ); |
|
| 119 | - wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax ); |
|
| 118 | + wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_vars); |
|
| 119 | + wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax); |
|
| 120 | 120 | |
| 121 | 121 | } else { |
| 122 | 122 | |
| 123 | 123 | // DEBUG is OFF (one JS file to rule them all!). |
| 124 | - wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
| 125 | - wp_enqueue_script( 'give' ); |
|
| 124 | + wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
| 125 | + wp_enqueue_script('give'); |
|
| 126 | 126 | |
| 127 | 127 | // Localize / Pass AJAX vars from PHP. |
| 128 | - wp_localize_script( 'give', 'give_global_vars', $localize_give_vars ); |
|
| 129 | - wp_localize_script( 'give', 'give_scripts', $localize_give_ajax ); |
|
| 128 | + wp_localize_script('give', 'give_global_vars', $localize_give_vars); |
|
| 129 | + wp_localize_script('give', 'give_scripts', $localize_give_ajax); |
|
| 130 | 130 | |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | -add_action( 'wp_enqueue_scripts', 'give_load_scripts' ); |
|
| 135 | +add_action('wp_enqueue_scripts', 'give_load_scripts'); |
|
| 136 | 136 | |
| 137 | 137 | /** |
| 138 | 138 | * Register styles. |
@@ -145,16 +145,16 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | function give_register_styles() { |
| 147 | 147 | |
| 148 | - if ( ! give_is_setting_enabled( give_get_option( 'css' ) ) ) { |
|
| 148 | + if ( ! give_is_setting_enabled(give_get_option('css'))) { |
|
| 149 | 149 | return; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' ); |
|
| 153 | - wp_enqueue_style( 'give-styles' ); |
|
| 152 | + wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all'); |
|
| 153 | + wp_enqueue_style('give-styles'); |
|
| 154 | 154 | |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | -add_action( 'wp_enqueue_scripts', 'give_register_styles' ); |
|
| 157 | +add_action('wp_enqueue_scripts', 'give_register_styles'); |
|
| 158 | 158 | |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -167,19 +167,19 @@ discard block |
||
| 167 | 167 | function give_get_stylesheet_uri() { |
| 168 | 168 | |
| 169 | 169 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
| 170 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
| 170 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 171 | 171 | |
| 172 | 172 | // LTR or RTL files. |
| 173 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
| 173 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
| 174 | 174 | |
| 175 | - $file = 'give' . $direction . $suffix . '.css'; |
|
| 175 | + $file = 'give'.$direction.$suffix.'.css'; |
|
| 176 | 176 | $templates_dir = give_get_theme_template_dir_name(); |
| 177 | 177 | |
| 178 | - $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file; |
|
| 179 | - $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
| 180 | - $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file; |
|
| 181 | - $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
| 182 | - $give_plugin_style_sheet = trailingslashit( give_get_templates_dir() ) . $file; |
|
| 178 | + $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()).$templates_dir.$file; |
|
| 179 | + $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$direction.'.css'; |
|
| 180 | + $parent_theme_style_sheet = trailingslashit(get_template_directory()).$templates_dir.$file; |
|
| 181 | + $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$direction.'.css'; |
|
| 182 | + $give_plugin_style_sheet = trailingslashit(give_get_templates_dir()).$file; |
|
| 183 | 183 | |
| 184 | 184 | $uri = false; |
| 185 | 185 | |
@@ -189,23 +189,23 @@ discard block |
||
| 189 | 189 | * followed by non minified version, even if SCRIPT_DEBUG is not enabled. |
| 190 | 190 | * This allows users to copy just give.css to their theme. |
| 191 | 191 | */ |
| 192 | - if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) { |
|
| 193 | - if ( ! empty( $nonmin ) ) { |
|
| 194 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
| 192 | + if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) { |
|
| 193 | + if ( ! empty($nonmin)) { |
|
| 194 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
| 195 | 195 | } else { |
| 196 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file; |
|
| 196 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file; |
|
| 197 | 197 | } |
| 198 | - } elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) { |
|
| 199 | - if ( ! empty( $nonmin ) ) { |
|
| 200 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
| 198 | + } elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) { |
|
| 199 | + if ( ! empty($nonmin)) { |
|
| 200 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
| 201 | 201 | } else { |
| 202 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file; |
|
| 202 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file; |
|
| 203 | 203 | } |
| 204 | - } elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) { |
|
| 205 | - $uri = trailingslashit( give_get_templates_url() ) . $file; |
|
| 204 | + } elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) { |
|
| 205 | + $uri = trailingslashit(give_get_templates_url()).$file; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - return apply_filters( 'give_get_stylesheet_uri', $uri ); |
|
| 208 | + return apply_filters('give_get_stylesheet_uri', $uri); |
|
| 209 | 209 | |
| 210 | 210 | } |
| 211 | 211 | |
@@ -222,79 +222,79 @@ discard block |
||
| 222 | 222 | * |
| 223 | 223 | * @return void |
| 224 | 224 | */ |
| 225 | -function give_load_admin_scripts( $hook ) { |
|
| 225 | +function give_load_admin_scripts($hook) { |
|
| 226 | 226 | |
| 227 | 227 | global $post, $post_type; |
| 228 | 228 | |
| 229 | 229 | $give_options = give_get_settings(); |
| 230 | 230 | |
| 231 | 231 | // Directories of assets. |
| 232 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
| 233 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
| 234 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
| 232 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
| 233 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
| 234 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
| 235 | 235 | |
| 236 | 236 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
| 237 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
| 237 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 238 | 238 | |
| 239 | 239 | // LTR or RTL files. |
| 240 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
| 240 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
| 241 | 241 | |
| 242 | 242 | // Global Admin. |
| 243 | - wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' ); |
|
| 244 | - wp_enqueue_style( 'give-admin-bar-notification' ); |
|
| 243 | + wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css'); |
|
| 244 | + wp_enqueue_style('give-admin-bar-notification'); |
|
| 245 | 245 | |
| 246 | 246 | // Give Admin Only. |
| 247 | - if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) { |
|
| 247 | + if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { |
|
| 248 | 248 | return; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | // CSS. |
| 252 | - wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' ); |
|
| 253 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
| 254 | - wp_register_style( 'give-admin', $css_dir . 'give-admin' . $direction . $suffix . '.css', array(), GIVE_VERSION ); |
|
| 255 | - wp_enqueue_style( 'give-admin' ); |
|
| 256 | - wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION ); |
|
| 257 | - wp_enqueue_style( 'jquery-chosen' ); |
|
| 258 | - wp_enqueue_style( 'thickbox' ); |
|
| 259 | - wp_enqueue_style( 'wp-color-picker' ); |
|
| 252 | + wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css'); |
|
| 253 | + wp_enqueue_style('jquery-ui-css'); |
|
| 254 | + wp_register_style('give-admin', $css_dir.'give-admin'.$direction.$suffix.'.css', array(), GIVE_VERSION); |
|
| 255 | + wp_enqueue_style('give-admin'); |
|
| 256 | + wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION); |
|
| 257 | + wp_enqueue_style('jquery-chosen'); |
|
| 258 | + wp_enqueue_style('thickbox'); |
|
| 259 | + wp_enqueue_style('wp-color-picker'); |
|
| 260 | 260 | |
| 261 | 261 | |
| 262 | 262 | // JS. |
| 263 | - wp_register_script( 'give-selector-cache', $js_plugins . 'selector-cache' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
| 264 | - wp_enqueue_script( 'give-selector-cache' ); |
|
| 263 | + wp_register_script('give-selector-cache', $js_plugins.'selector-cache'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
| 264 | + wp_enqueue_script('give-selector-cache'); |
|
| 265 | 265 | |
| 266 | - wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
| 267 | - wp_enqueue_script( 'jquery-chosen' ); |
|
| 266 | + wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
| 267 | + wp_enqueue_script('jquery-chosen'); |
|
| 268 | 268 | |
| 269 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
| 270 | - wp_enqueue_script( 'give-accounting' ); |
|
| 269 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
| 270 | + wp_enqueue_script('give-accounting'); |
|
| 271 | 271 | |
| 272 | - wp_enqueue_script( 'wp-color-picker' ); |
|
| 273 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 274 | - wp_enqueue_script( 'thickbox' ); |
|
| 272 | + wp_enqueue_script('wp-color-picker'); |
|
| 273 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 274 | + wp_enqueue_script('thickbox'); |
|
| 275 | 275 | |
| 276 | - 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 ); |
|
| 277 | - wp_enqueue_script( 'give-admin-scripts' ); |
|
| 276 | + 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); |
|
| 277 | + wp_enqueue_script('give-admin-scripts'); |
|
| 278 | 278 | |
| 279 | - wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' ); |
|
| 280 | - wp_enqueue_script( 'jquery-flot' ); |
|
| 279 | + wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js'); |
|
| 280 | + wp_enqueue_script('jquery-flot'); |
|
| 281 | 281 | |
| 282 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
| 283 | - wp_enqueue_script( 'give-qtip' ); |
|
| 282 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
| 283 | + wp_enqueue_script('give-qtip'); |
|
| 284 | 284 | |
| 285 | - wp_register_script( 'give-repeatable-fields', $js_plugins . 'repeatable-fields' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
| 286 | - wp_enqueue_script( 'give-repeatable-fields' ); |
|
| 285 | + wp_register_script('give-repeatable-fields', $js_plugins.'repeatable-fields'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
| 286 | + wp_enqueue_script('give-repeatable-fields'); |
|
| 287 | 287 | |
| 288 | 288 | // Forms CPT Script. |
| 289 | - if ( $post_type === 'give_forms' ) { |
|
| 290 | - wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
| 291 | - wp_enqueue_script( 'give-admin-forms-scripts' ); |
|
| 289 | + if ($post_type === 'give_forms') { |
|
| 290 | + wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
| 291 | + wp_enqueue_script('give-admin-forms-scripts'); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | // Settings Scripts. |
| 295 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) { |
|
| 296 | - wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
| 297 | - wp_enqueue_script( 'give-admin-settings-scripts' ); |
|
| 295 | + if (isset($_GET['page']) && $_GET['page'] == 'give-settings') { |
|
| 296 | + wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
| 297 | + wp_enqueue_script('give-admin-settings-scripts'); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | // Price Separators. |
@@ -302,79 +302,79 @@ discard block |
||
| 302 | 302 | $decimal_separator = give_get_price_decimal_separator(); |
| 303 | 303 | |
| 304 | 304 | // Localize strings & variables for JS. |
| 305 | - wp_localize_script( 'give-admin-scripts', 'give_vars', array( |
|
| 306 | - 'post_id' => isset( $post->ID ) ? $post->ID : null, |
|
| 305 | + wp_localize_script('give-admin-scripts', 'give_vars', array( |
|
| 306 | + 'post_id' => isset($post->ID) ? $post->ID : null, |
|
| 307 | 307 | 'give_version' => GIVE_VERSION, |
| 308 | 308 | 'thousands_separator' => $thousand_separator, |
| 309 | 309 | 'decimal_separator' => $decimal_separator, |
| 310 | - 'quick_edit_warning' => __( 'Not available for variable priced forms.', 'give' ), |
|
| 311 | - 'delete_payment' => __( 'Are you sure you want to delete this payment?', 'give' ), |
|
| 312 | - 'delete_payment_note' => __( 'Are you sure you want to delete this note?', 'give' ), |
|
| 313 | - 'revoke_api_key' => __( 'Are you sure you want to revoke this API key?', 'give' ), |
|
| 314 | - 'regenerate_api_key' => __( 'Are you sure you want to regenerate this API key?', 'give' ), |
|
| 315 | - 'resend_receipt' => __( 'Are you sure you want to resend the donation receipt?', 'give' ), |
|
| 316 | - 'disconnect_user' => __( 'Are you sure you want to disconnect the user from this donor?', 'give' ), |
|
| 317 | - 'one_option' => __( 'Choose a form', 'give' ), |
|
| 318 | - 'one_or_more_option' => __( 'Choose one or more forms', 'give' ), |
|
| 319 | - 'currency_sign' => give_currency_filter( '' ), |
|
| 320 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', |
|
| 321 | - 'currency_decimals' => give_currency_decimal_filter( give_get_price_decimals() ), |
|
| 322 | - 'batch_export_no_class' => __( 'You must choose a method.', 'give' ), |
|
| 323 | - 'batch_export_no_reqs' => __( 'Required fields not completed.', 'give' ), |
|
| 324 | - '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' ), |
|
| 325 | - 'delete_test_donor' => __( 'Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give' ), |
|
| 326 | - 'delete_import_donor' => __( 'Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give' ), |
|
| 327 | - 'price_format_guide' => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ), |
|
| 310 | + 'quick_edit_warning' => __('Not available for variable priced forms.', 'give'), |
|
| 311 | + 'delete_payment' => __('Are you sure you want to delete this payment?', 'give'), |
|
| 312 | + 'delete_payment_note' => __('Are you sure you want to delete this note?', 'give'), |
|
| 313 | + 'revoke_api_key' => __('Are you sure you want to revoke this API key?', 'give'), |
|
| 314 | + 'regenerate_api_key' => __('Are you sure you want to regenerate this API key?', 'give'), |
|
| 315 | + 'resend_receipt' => __('Are you sure you want to resend the donation receipt?', 'give'), |
|
| 316 | + 'disconnect_user' => __('Are you sure you want to disconnect the user from this donor?', 'give'), |
|
| 317 | + 'one_option' => __('Choose a form', 'give'), |
|
| 318 | + 'one_or_more_option' => __('Choose one or more forms', 'give'), |
|
| 319 | + 'currency_sign' => give_currency_filter(''), |
|
| 320 | + 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', |
|
| 321 | + 'currency_decimals' => give_currency_decimal_filter(give_get_price_decimals()), |
|
| 322 | + 'batch_export_no_class' => __('You must choose a method.', 'give'), |
|
| 323 | + 'batch_export_no_reqs' => __('Required fields not completed.', 'give'), |
|
| 324 | + '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'), |
|
| 325 | + 'delete_test_donor' => __('Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give'), |
|
| 326 | + 'delete_import_donor' => __('Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give'), |
|
| 327 | + 'price_format_guide' => sprintf(__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator), |
|
| 328 | 328 | /* translators : %s: Donation form options metabox */ |
| 329 | - 'confirm_before_remove_row_text' => __( 'Do you want to delete this level?', 'give' ), |
|
| 330 | - 'matched_success_failure_page' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
|
| 331 | - 'dismiss_notice_text' => __( 'Dismiss this notice.', 'give' ), |
|
| 332 | - 'search_placeholder' => __( 'Type to search all forms', 'give' ), |
|
| 333 | - 'search_placeholder_donor' => __( 'Type to search all donors', 'give' ), |
|
| 334 | - 'search_placeholder_country' => __( 'Type to search all countries', 'give' ), |
|
| 335 | - 'search_placeholder_state' => __( 'Type to search all states/provinces', 'give' ), |
|
| 329 | + 'confirm_before_remove_row_text' => __('Do you want to delete this level?', 'give'), |
|
| 330 | + 'matched_success_failure_page' => __('You cannot set the success and failed pages to the same page', 'give'), |
|
| 331 | + 'dismiss_notice_text' => __('Dismiss this notice.', 'give'), |
|
| 332 | + 'search_placeholder' => __('Type to search all forms', 'give'), |
|
| 333 | + 'search_placeholder_donor' => __('Type to search all donors', 'give'), |
|
| 334 | + 'search_placeholder_country' => __('Type to search all countries', 'give'), |
|
| 335 | + 'search_placeholder_state' => __('Type to search all states/provinces', 'give'), |
|
| 336 | 336 | 'bulk_action' => array( |
| 337 | 337 | 'delete' => array( |
| 338 | - 'zero' => __( 'You must choose at least one or more payments to delete.', 'give' ), |
|
| 339 | - 'single' => __( 'Are you sure you want to permanently delete this donation?', 'give' ), |
|
| 340 | - 'multiple' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ), |
|
| 338 | + 'zero' => __('You must choose at least one or more payments to delete.', 'give'), |
|
| 339 | + 'single' => __('Are you sure you want to permanently delete this donation?', 'give'), |
|
| 340 | + 'multiple' => __('Are you sure you want to permanently delete the selected {payment_count} donations?', 'give'), |
|
| 341 | 341 | ), |
| 342 | 342 | 'resend-receipt' => array( |
| 343 | - 'zero' => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ), |
|
| 344 | - 'single' => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ), |
|
| 345 | - 'multiple' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ), |
|
| 343 | + 'zero' => __('You must choose at least one or more recipients to resend the email receipt.', 'give'), |
|
| 344 | + 'single' => __('Are you sure you want to resend the email receipt to this recipient?', 'give'), |
|
| 345 | + 'multiple' => __('Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give'), |
|
| 346 | 346 | ), |
| 347 | 347 | 'set-to-status' => array( |
| 348 | - 'zero' => __( 'You must choose at least one or more donations to set status to {status}.', 'give' ), |
|
| 349 | - 'single' => __( 'Are you sure you want to set status of this donation to {status}?', 'give' ), |
|
| 350 | - 'multiple' => __( 'Are you sure you want to set status of {payment_count} donations to {status}?', 'give' ), |
|
| 348 | + 'zero' => __('You must choose at least one or more donations to set status to {status}.', 'give'), |
|
| 349 | + 'single' => __('Are you sure you want to set status of this donation to {status}?', 'give'), |
|
| 350 | + 'multiple' => __('Are you sure you want to set status of {payment_count} donations to {status}?', 'give'), |
|
| 351 | 351 | ), |
| 352 | 352 | ), |
| 353 | 353 | 'metabox_fields' => array( |
| 354 | 354 | 'media' => array( |
| 355 | - 'button_title' => __( 'Choose Image', 'give' ), |
|
| 355 | + 'button_title' => __('Choose Image', 'give'), |
|
| 356 | 356 | ), |
| 357 | 357 | 'file' => array( |
| 358 | - 'button_title' => __( 'Choose File', 'give' ), |
|
| 358 | + 'button_title' => __('Choose File', 'give'), |
|
| 359 | 359 | ) |
| 360 | 360 | ), |
| 361 | 361 | 'chosen' => array( |
| 362 | - 'no_results_msg' => __( 'No results match {search_term}', 'give' ), |
|
| 363 | - 'ajax_search_msg' => __( 'Searching results for match {search_term}', 'give' ), |
|
| 362 | + 'no_results_msg' => __('No results match {search_term}', 'give'), |
|
| 363 | + 'ajax_search_msg' => __('Searching results for match {search_term}', 'give'), |
|
| 364 | 364 | ), |
| 365 | - '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' ), |
|
| 366 | - 'error_message' => __( 'Something went wrong kindly try again!','give' ), |
|
| 365 | + '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'), |
|
| 366 | + 'error_message' => __('Something went wrong kindly try again!', 'give'), |
|
| 367 | 367 | 'give_donation_import' => 'give_donation_import', |
| 368 | - ) ); |
|
| 368 | + )); |
|
| 369 | 369 | |
| 370 | - if ( function_exists( 'wp_enqueue_media' ) && version_compare( get_bloginfo( 'version' ), '3.5', '>=' ) ) { |
|
| 370 | + if (function_exists('wp_enqueue_media') && version_compare(get_bloginfo('version'), '3.5', '>=')) { |
|
| 371 | 371 | // call for new media manager. |
| 372 | 372 | wp_enqueue_media(); |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | -add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 ); |
|
| 377 | +add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100); |
|
| 378 | 378 | |
| 379 | 379 | /** |
| 380 | 380 | * Admin Give Icon |
@@ -389,13 +389,13 @@ discard block |
||
| 389 | 389 | ?> |
| 390 | 390 | <style type="text/css" media="screen"> |
| 391 | 391 | |
| 392 | - <?php if ( version_compare( get_bloginfo( 'version' ), '3.8-RC', '>=' ) || version_compare( get_bloginfo( 'version' ), '3.8', '>=' ) ) { ?> |
|
| 392 | + <?php if (version_compare(get_bloginfo('version'), '3.8-RC', '>=') || version_compare(get_bloginfo('version'), '3.8', '>=')) { ?> |
|
| 393 | 393 | @font-face { |
| 394 | 394 | font-family: 'give-icomoon'; |
| 395 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?ngjl88'; ?>'); |
|
| 396 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
| 397 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
| 398 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
| 395 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?ngjl88'; ?>'); |
|
| 396 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
| 397 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
| 398 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
| 399 | 399 | font-weight: normal; |
| 400 | 400 | font-style: normal; |
| 401 | 401 | } |
@@ -414,4 +414,4 @@ discard block |
||
| 414 | 414 | <?php |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | -add_action( 'admin_head', 'give_admin_icon' ); |
|
| 417 | +add_action('admin_head', 'give_admin_icon'); |
|
@@ -165,16 +165,16 @@ discard block |
||
| 165 | 165 | * |
| 166 | 166 | * @since 1.0 |
| 167 | 167 | * @access public |
| 168 | - * |
|
| 169 | - * @param int $column Column ID. |
|
| 170 | - * @param string $column_where Column name. |
|
| 171 | - * @param string $column_value Column value. |
|
| 172 | - * |
|
| 168 | + * |
|
| 169 | + * @param int $column Column ID. |
|
| 170 | + * @param string $column_where Column name. |
|
| 171 | + * @param string $column_value Column value. |
|
| 172 | + * |
|
| 173 | 173 | * @return string |
| 174 | 174 | */ |
| 175 | 175 | public function get_column_by( $column, $column_where, $column_value ) { |
| 176 | - /* @var WPDB $wpdb */ |
|
| 177 | - global $wpdb; |
|
| 176 | + /* @var WPDB $wpdb */ |
|
| 177 | + global $wpdb; |
|
| 178 | 178 | |
| 179 | 179 | // Bailout. |
| 180 | 180 | if ( empty( $column ) || empty( $column_where ) || empty( $column_value ) ) { |
@@ -191,15 +191,15 @@ discard block |
||
| 191 | 191 | * |
| 192 | 192 | * @since 1.0 |
| 193 | 193 | * @access public |
| 194 | - * |
|
| 195 | - * @param array $data |
|
| 196 | - * @param string $type |
|
| 197 | - * |
|
| 194 | + * |
|
| 195 | + * @param array $data |
|
| 196 | + * @param string $type |
|
| 197 | + * |
|
| 198 | 198 | * @return int |
| 199 | 199 | */ |
| 200 | 200 | public function insert( $data, $type = '' ) { |
| 201 | - /* @var WPDB $wpdb */ |
|
| 202 | - global $wpdb; |
|
| 201 | + /* @var WPDB $wpdb */ |
|
| 202 | + global $wpdb; |
|
| 203 | 203 | |
| 204 | 204 | // Set default values. |
| 205 | 205 | $data = wp_parse_args( $data, $this->get_column_defaults() ); |
@@ -246,16 +246,16 @@ discard block |
||
| 246 | 246 | * |
| 247 | 247 | * @since 1.0 |
| 248 | 248 | * @access public |
| 249 | - * |
|
| 250 | - * @param int $row_id Column ID |
|
| 251 | - * @param array $data |
|
| 252 | - * @param string $where Column value |
|
| 253 | - * |
|
| 249 | + * |
|
| 250 | + * @param int $row_id Column ID |
|
| 251 | + * @param array $data |
|
| 252 | + * @param string $where Column value |
|
| 253 | + * |
|
| 254 | 254 | * @return bool |
| 255 | 255 | */ |
| 256 | 256 | public function update( $row_id, $data = array(), $where = '' ) { |
| 257 | - /* @var WPDB $wpdb */ |
|
| 258 | - global $wpdb; |
|
| 257 | + /* @var WPDB $wpdb */ |
|
| 258 | + global $wpdb; |
|
| 259 | 259 | |
| 260 | 260 | // Row ID must be positive integer |
| 261 | 261 | $row_id = absint( $row_id ); |
@@ -293,14 +293,14 @@ discard block |
||
| 293 | 293 | * |
| 294 | 294 | * @since 1.0 |
| 295 | 295 | * @access public |
| 296 | - * |
|
| 297 | - * @param int $row_id Column ID. |
|
| 298 | - * |
|
| 296 | + * |
|
| 297 | + * @param int $row_id Column ID. |
|
| 298 | + * |
|
| 299 | 299 | * @return bool |
| 300 | 300 | */ |
| 301 | 301 | public function delete( $row_id = 0 ) { |
| 302 | - /* @var WPDB $wpdb */ |
|
| 303 | - global $wpdb; |
|
| 302 | + /* @var WPDB $wpdb */ |
|
| 303 | + global $wpdb; |
|
| 304 | 304 | |
| 305 | 305 | // Row ID must be positive integer |
| 306 | 306 | $row_id = absint( $row_id ); |
@@ -321,13 +321,13 @@ discard block |
||
| 321 | 321 | * |
| 322 | 322 | * @since 1.3.2 |
| 323 | 323 | * @access public |
| 324 | - * |
|
| 324 | + * |
|
| 325 | 325 | * @param string $table The table name. |
| 326 | - * |
|
| 326 | + * |
|
| 327 | 327 | * @return bool If the table name exists. |
| 328 | 328 | */ |
| 329 | 329 | public function table_exists( $table ) { |
| 330 | - /* @var WPDB $wpdb */ |
|
| 330 | + /* @var WPDB $wpdb */ |
|
| 331 | 331 | global $wpdb; |
| 332 | 332 | |
| 333 | 333 | $table = sanitize_text_field( $table ); |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -98,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,18 +172,18 @@ 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 ); |
|
| 186 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
| 184 | + $column_where = esc_sql($column_where); |
|
| 185 | + $column = esc_sql($column); |
|
| 186 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value)); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | /** |
@@ -197,12 +197,12 @@ discard block |
||
| 197 | 197 | * |
| 198 | 198 | * @return int |
| 199 | 199 | */ |
| 200 | - public function insert( $data, $type = '' ) { |
|
| 200 | + public function insert($data, $type = '') { |
|
| 201 | 201 | /* @var WPDB $wpdb */ |
| 202 | 202 | global $wpdb; |
| 203 | 203 | |
| 204 | 204 | // Set default values. |
| 205 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
| 205 | + $data = wp_parse_args($data, $this->get_column_defaults()); |
|
| 206 | 206 | |
| 207 | 207 | /** |
| 208 | 208 | * Fires before inserting data to the database. |
@@ -211,22 +211,22 @@ discard block |
||
| 211 | 211 | * |
| 212 | 212 | * @param array $data |
| 213 | 213 | */ |
| 214 | - do_action( "give_pre_insert_{$type}", $data ); |
|
| 214 | + do_action("give_pre_insert_{$type}", $data); |
|
| 215 | 215 | |
| 216 | 216 | // Initialise column format array |
| 217 | 217 | $column_formats = $this->get_columns(); |
| 218 | 218 | |
| 219 | 219 | // Force fields to lower case |
| 220 | - $data = array_change_key_case( $data ); |
|
| 220 | + $data = array_change_key_case($data); |
|
| 221 | 221 | |
| 222 | 222 | // White list columns |
| 223 | - $data = array_intersect_key( $data, $column_formats ); |
|
| 223 | + $data = array_intersect_key($data, $column_formats); |
|
| 224 | 224 | |
| 225 | 225 | // Reorder $column_formats to match the order of columns given in $data |
| 226 | - $data_keys = array_keys( $data ); |
|
| 227 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
| 226 | + $data_keys = array_keys($data); |
|
| 227 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
| 228 | 228 | |
| 229 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
| 229 | + $wpdb->insert($this->table_name, $data, $column_formats); |
|
| 230 | 230 | |
| 231 | 231 | /** |
| 232 | 232 | * Fires after inserting data to the database. |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | * @param int $insert_id |
| 237 | 237 | * @param array $data |
| 238 | 238 | */ |
| 239 | - do_action( "give_post_insert_{$type}", $wpdb->insert_id, $data ); |
|
| 239 | + do_action("give_post_insert_{$type}", $wpdb->insert_id, $data); |
|
| 240 | 240 | |
| 241 | 241 | return $wpdb->insert_id; |
| 242 | 242 | } |
@@ -253,18 +253,18 @@ discard block |
||
| 253 | 253 | * |
| 254 | 254 | * @return bool |
| 255 | 255 | */ |
| 256 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
| 256 | + public function update($row_id, $data = array(), $where = '') { |
|
| 257 | 257 | /* @var WPDB $wpdb */ |
| 258 | 258 | global $wpdb; |
| 259 | 259 | |
| 260 | 260 | // Row ID must be positive integer |
| 261 | - $row_id = absint( $row_id ); |
|
| 261 | + $row_id = absint($row_id); |
|
| 262 | 262 | |
| 263 | - if ( empty( $row_id ) ) { |
|
| 263 | + if (empty($row_id)) { |
|
| 264 | 264 | return false; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - if ( empty( $where ) ) { |
|
| 267 | + if (empty($where)) { |
|
| 268 | 268 | $where = $this->primary_key; |
| 269 | 269 | } |
| 270 | 270 | |
@@ -272,16 +272,16 @@ discard block |
||
| 272 | 272 | $column_formats = $this->get_columns(); |
| 273 | 273 | |
| 274 | 274 | // Force fields to lower case |
| 275 | - $data = array_change_key_case( $data ); |
|
| 275 | + $data = array_change_key_case($data); |
|
| 276 | 276 | |
| 277 | 277 | // White list columns |
| 278 | - $data = array_intersect_key( $data, $column_formats ); |
|
| 278 | + $data = array_intersect_key($data, $column_formats); |
|
| 279 | 279 | |
| 280 | 280 | // Reorder $column_formats to match the order of columns given in $data |
| 281 | - $data_keys = array_keys( $data ); |
|
| 282 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
| 281 | + $data_keys = array_keys($data); |
|
| 282 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
| 283 | 283 | |
| 284 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
| 284 | + if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) { |
|
| 285 | 285 | return false; |
| 286 | 286 | } |
| 287 | 287 | |
@@ -298,18 +298,18 @@ discard block |
||
| 298 | 298 | * |
| 299 | 299 | * @return bool |
| 300 | 300 | */ |
| 301 | - public function delete( $row_id = 0 ) { |
|
| 301 | + public function delete($row_id = 0) { |
|
| 302 | 302 | /* @var WPDB $wpdb */ |
| 303 | 303 | global $wpdb; |
| 304 | 304 | |
| 305 | 305 | // Row ID must be positive integer |
| 306 | - $row_id = absint( $row_id ); |
|
| 306 | + $row_id = absint($row_id); |
|
| 307 | 307 | |
| 308 | - if ( empty( $row_id ) ) { |
|
| 308 | + if (empty($row_id)) { |
|
| 309 | 309 | return false; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
| 312 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) { |
|
| 313 | 313 | return false; |
| 314 | 314 | } |
| 315 | 315 | |
@@ -326,13 +326,13 @@ discard block |
||
| 326 | 326 | * |
| 327 | 327 | * @return bool If the table name exists. |
| 328 | 328 | */ |
| 329 | - public function table_exists( $table ) { |
|
| 329 | + public function table_exists($table) { |
|
| 330 | 330 | /* @var WPDB $wpdb */ |
| 331 | 331 | global $wpdb; |
| 332 | 332 | |
| 333 | - $table = sanitize_text_field( $table ); |
|
| 333 | + $table = sanitize_text_field($table); |
|
| 334 | 334 | |
| 335 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
| 335 | + return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table; |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | /** |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | * @return bool Returns if the customers table was installed and upgrade routine run. |
| 345 | 345 | */ |
| 346 | 346 | public function installed() { |
| 347 | - return $this->table_exists( $this->table_name ); |
|
| 347 | + return $this->table_exists($this->table_name); |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | /** |
@@ -354,8 +354,8 @@ discard block |
||
| 354 | 354 | * @access public |
| 355 | 355 | */ |
| 356 | 356 | public function register_table() { |
| 357 | - $current_version = get_option( $this->table_name . '_db_version' ); |
|
| 358 | - if ( ! $current_version || version_compare( $current_version, $this->version, '<' ) ) { |
|
| 357 | + $current_version = get_option($this->table_name.'_db_version'); |
|
| 358 | + if ( ! $current_version || version_compare($current_version, $this->version, '<')) { |
|
| 359 | 359 | $this->create_table(); |
| 360 | 360 | } |
| 361 | 361 | } |
@@ -366,5 +366,5 @@ discard block |
||
| 366 | 366 | * @since 1.8.9 |
| 367 | 367 | * @access public |
| 368 | 368 | */ |
| 369 | - public function create_table(){} |
|
| 369 | + public function create_table() {} |
|
| 370 | 370 | } |