← All changes
|
includes/admin/payments/view-payment-details.php
+119
-69
2.3.2
→
4.17.0
View file →
| @@ -8,16 +8,22 @@ | ||
| 8 | 8 | * @license https://opensource.org/licenses/gpl-license GNU Public License |
| 9 | 9 | * @since 1.0 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | +use Give\Donations\Models\Donation; | |
| 13 | +use Give\Donations\ValueObjects\DonationMetaKeys; | |
| 14 | +use Give\Donors\Models\Donor; | |
| 15 | + | |
| 12 | 16 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 17 | +if (!defined('ABSPATH')) { | |
| 14 | 18 | exit; |
| 15 | 19 | } |
| 16 | 20 | |
| 17 | -if ( ! current_user_can( 'view_give_payments' ) ) { | |
| 21 | +if (!current_user_can('view_give_payments')) { | |
| 18 | 22 | wp_die( |
| 19 | - __( 'Sorry, you are not allowed to access this page.', 'give' ), __( 'Error', 'give' ), array( | |
| 23 | + __('Sorry, you are not allowed to access this page.', 'give'), | |
| 24 | + __('Error', 'give'), | |
| 25 | + array( | |
| 20 | 26 | 'response' => 403, |
| 21 | 27 | ) |
| 22 | 28 | ); |
| 23 | 29 | } |
| @@ -24,8 +30,9 @@ | ||
| 24 | 30 | |
| 25 | 31 | /** |
| 26 | 32 | * View donation details page |
| 27 | 33 | * |
| 34 | + * @since 3.9.0 Add donor phone number to the view | |
| 28 | 35 | * @since 1.0 |
| 29 | 36 | * @return void |
| 30 | 37 | */ |
| 31 | 38 | if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
| @@ -44,9 +51,9 @@ | ||
| 44 | 51 | |
| 45 | 52 | $number = $payment->number; |
| 46 | 53 | $payment_meta = $payment->get_meta(); |
| 47 | 54 | |
| 48 | -$company_name = ! empty( $payment_meta['_give_donation_company'] ) ? esc_attr( $payment_meta['_give_donation_company'] ) : ''; | |
| 55 | +$company_name = ! empty( $payment_meta['_give_donation_company'] ) ? esc_html( $payment_meta['_give_donation_company'] ) : ''; | |
| 49 | 56 | $transaction_id = esc_attr( $payment->transaction_id ); |
| 50 | 57 | $user_id = $payment->user_id; |
| 51 | 58 | $donor_id = $payment->customer_id; |
| 52 | 59 | $payment_date = strtotime( $payment->date ); |
| @@ -56,8 +63,12 @@ | ||
| 56 | 63 | $gateway = $payment->gateway; |
| 57 | 64 | $currency_code = $payment->currency; |
| 58 | 65 | $payment_mode = $payment->mode; |
| 59 | 66 | $base_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); |
| 67 | +$donation_model = Donation::find( $payment_id ); | |
| 68 | +$donor_model = Donor::find( $donor_id ); | |
| 69 | +$donation_phone_number = $donation_model ? $donation_model->phone : ''; | |
| 70 | +$donor_phone_number = $donor_model ? $donor_model->phone : ''; | |
| 60 | 71 | |
| 61 | 72 | ?> |
| 62 | 73 | <div class="wrap give-wrap"> |
| 63 | 74 | |
| @@ -63,22 +74,24 @@ | ||
| 63 | 74 | |
| 64 | 75 | <h1 id="transaction-details-heading" class="wp-heading-inline"> |
| 65 | 76 | <?php |
| 66 | 77 | printf( |
| 67 | - /* translators: %s: donation number */ | |
| 78 | + /* translators: %s: donation number */ | |
| 68 | 79 | esc_html__( 'Donation %s', 'give' ), |
| 69 | 80 | $number |
| 70 | 81 | ); |
| 71 | 82 | if ( $payment_mode == 'test' ) { |
| 72 | - echo Give()->tooltips->render_span(array( | |
| 73 | - 'label' => __( 'This donation was made in test mode.', 'give' ), | |
| 74 | - 'tag_content' => __( 'Test Donation', 'give' ), | |
| 75 | - 'position'=> 'right', | |
| 76 | - 'attributes' => array( | |
| 77 | - 'id' => 'test-payment-label', | |
| 78 | - 'class' => 'give-item-label give-item-label-orange' | |
| 83 | + echo Give()->tooltips->render_span( | |
| 84 | + array( | |
| 85 | + 'label' => __( 'This donation was made in test mode.', 'give' ), | |
| 86 | + 'tag_content' => __( 'Test Donation', 'give' ), | |
| 87 | + 'position' => 'right', | |
| 88 | + 'attributes' => array( | |
| 89 | + 'id' => 'test-payment-label', | |
| 90 | + 'class' => 'give-item-label give-item-label-orange', | |
| 91 | + ), | |
| 79 | 92 | ) |
| 80 | - )); | |
| 93 | + ); | |
| 81 | 94 | } |
| 82 | 95 | ?> |
| 83 | 96 | </h1> |
| 84 | 97 | |
| @@ -105,9 +118,9 @@ | ||
| 105 | 118 | * @param int $payment_id Payment id. |
| 106 | 119 | */ |
| 107 | 120 | do_action( 'give_view_donation_details_form_top', $payment_id ); |
| 108 | 121 | ?> |
| 109 | - <div id="poststuff"> | |
| 122 | + <div id="poststuff" class="give-clearfix"> | |
| 110 | 123 | <div id="give-dashboard-widgets-wrap"> |
| 111 | 124 | <div id="post-body" class="metabox-holder columns-2"> |
| 112 | 125 | <div id="postbox-container-1" class="postbox-container"> |
| 113 | 126 | <div id="side-sortables" class="meta-box-sortables ui-sortable"> |
| @@ -132,16 +145,20 @@ | ||
| 132 | 145 | if ( current_user_can( 'view_give_payments' ) ) { |
| 133 | 146 | echo sprintf( |
| 134 | 147 | '<span class="delete-donation" id="delete-donation-%d"><a class="delete-single-donation delete-donation-button dashicons dashicons-trash" href="%s" aria-label="%s"></a></span>', |
| 135 | 148 | $payment_id, |
| 136 | - wp_nonce_url( | |
| 137 | - add_query_arg( | |
| 138 | - array( | |
| 139 | - 'give-action' => 'delete_payment', | |
| 140 | - 'purchase_id' => $payment_id, | |
| 141 | - ), $base_url | |
| 142 | - ), 'give_donation_nonce' | |
| 143 | - ), | |
| 149 | + esc_url( | |
| 150 | + wp_nonce_url( | |
| 151 | + add_query_arg( | |
| 152 | + array( | |
| 153 | + 'give-action' => 'delete_payment', | |
| 154 | + 'purchase_id' => $payment_id, | |
| 155 | + ), | |
| 156 | + $base_url | |
| 157 | + ), | |
| 158 | + 'give_donation_nonce' | |
| 159 | + ) | |
| 160 | + ), | |
| 144 | 161 | sprintf( __( 'Delete Donation %s', 'give' ), $payment_id ) |
| 145 | 162 | ); |
| 146 | 163 | } |
| 147 | 164 | ?> |
| @@ -176,9 +193,9 @@ | ||
| 176 | 193 | <div class="give-admin-box-inside"> |
| 177 | 194 | <?php $date_format = give_date_format(); ?> |
| 178 | 195 | <p> |
| 179 | 196 | <label for="give-payment-date" class="strong"><?php _e( 'Date:', 'give' ); ?></label> |
| 180 | - <input type="text" id="give-payment-date" name="give-payment-date" value="<?php echo esc_attr( date( $date_format, $payment_date ) ); ?>" autocomplete="off" class="medium-text give_datepicker" placeholder="<?php _e( 'Date', 'give' ); ?>"/> | |
| 197 | + <input type="text" id="give-payment-date" name="give-payment-date" data-standard-date="<?php echo esc_attr( date( 'Y-m-d', $payment_date ) ); ?>" value="<?php echo esc_attr( date_i18n( $date_format, $payment_date ) ); ?>" autocomplete="off" class="medium-text give_datepicker" placeholder="<?php _e( 'Date', 'give' ); ?>"/> | |
| 181 | 198 | </p> |
| 182 | 199 | </div> |
| 183 | 200 | |
| 184 | 201 | <div class="give-admin-box-inside"> |
| @@ -324,23 +341,18 @@ | ||
| 324 | 341 | <?php |
| 325 | 342 | // Display the transaction ID present. |
| 326 | 343 | // The transaction ID is the charge ID from the gateway. |
| 327 | 344 | // For instance, stripe "ch_BzvwYCchqOy5Nt". |
| 328 | - if ( $transaction_id != $payment_id ) : ?> | |
| 345 | + if ( $transaction_id != $payment_id ) : | |
| 346 | + ?> | |
| 329 | 347 | <div class="give-order-tx-id give-admin-box-inside"> |
| 330 | 348 | <p> |
| 331 | - <strong><?php _e( 'Transaction ID:', 'give' ); ?> <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php echo sprintf( esc_attr__( 'The transaction ID within %s.', 'give' ), $gateway); ?>"></span></strong> | |
| 349 | + <strong><?php _e( 'Transaction ID:', 'give' ); ?> <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php echo sprintf( esc_attr__( 'The transaction ID within %s.', 'give' ), $gateway ); ?>"></span></strong> | |
| 332 | 350 | <?php echo apply_filters( "give_payment_details_transaction_id-{$gateway}", $transaction_id, $payment_id ); ?> |
| 333 | 351 | </p> |
| 334 | 352 | </div> |
| 335 | 353 | <?php endif; ?> |
| 336 | 354 | |
| 337 | - <div class="give-admin-box-inside"> | |
| 338 | - <p><?php $purchase_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( give_get_payment_donor_id( $payment_id ) ) ); ?> | |
| 339 | - <a href="<?php echo $purchase_url; ?>"><?php _e( 'View all donations for this donor »', 'give' ); ?></a> | |
| 340 | - </p> | |
| 341 | - </div> | |
| 342 | - | |
| 343 | 355 | <?php |
| 344 | 356 | /** |
| 345 | 357 | * Fires in donation details page, after the donation-meta metabox. |
| 346 | 358 | * |
| @@ -350,8 +362,14 @@ | ||
| 350 | 362 | */ |
| 351 | 363 | do_action( 'give_view_donation_details_payment_meta_after', $payment_id ); |
| 352 | 364 | ?> |
| 353 | 365 | |
| 366 | + <div class="give-admin-box-inside"> | |
| 367 | + <p><?php $purchase_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( give_get_payment_donor_id( $payment_id ) ) ); ?> | |
| 368 | + <a href="<?php echo $purchase_url; ?>"><?php _e( 'View all donations for this donor »', 'give' ); ?></a> | |
| 369 | + </p> | |
| 370 | + </div> | |
| 371 | + | |
| 354 | 372 | </div> |
| 355 | 373 | <!-- /.column-container --> |
| 356 | 374 | |
| 357 | 375 | </div> |
| @@ -424,9 +442,25 @@ | ||
| 424 | 442 | ) |
| 425 | 443 | ); |
| 426 | 444 | ?> |
| 427 | 445 | </p> |
| 428 | - </div> | |
| 446 | + <p> | |
| 447 | + <strong><?php | |
| 448 | + esc_html_e('Campaign:', 'give'); ?></strong><br> | |
| 449 | + <?php | |
| 450 | + $donation = Donation::find($payment->ID); | |
| 451 | + echo Give()->html->campaigns_dropdown( | |
| 452 | + [ | |
| 453 | + 'selected' => $donation->campaignId, | |
| 454 | + 'name' => 'give-payment-campaign-select', | |
| 455 | + 'id' => 'give-payment-campaign-select', | |
| 456 | + 'chosen' => true, | |
| 457 | + 'placeholder' => __('Select Campaign', 'give'), | |
| 458 | + ] | |
| 459 | + ); | |
| 460 | + ?> | |
| 461 | + </p> | |
| 462 | + </div> | |
| 429 | 463 | <div class="column"> |
| 430 | 464 | <p> |
| 431 | 465 | <strong><?php _e( 'Donation Date:', 'give' ); ?></strong><br> |
| 432 | 466 | <?php echo date_i18n( give_date_format(), $payment_date ); ?> |
| @@ -466,10 +500,8 @@ | ||
| 466 | 500 | <p> |
| 467 | 501 | <strong><?php esc_html_e( 'Total Donation:', 'give' ); ?></strong><br> |
| 468 | 502 | <?php echo give_donation_amount( $payment, true ); ?> |
| 469 | 503 | </p> |
| 470 | - | |
| 471 | - <?php if ( give_is_anonymous_donation_field_enabled( $payment->form_id ) ): ?> | |
| 472 | 504 | <div> |
| 473 | 505 | <strong><?php esc_html_e( 'Anonymous Donation:', 'give' ); ?></strong> |
| 474 | 506 | <ul class="give-radio-inline"> |
| 475 | 507 | <li> |
| @@ -477,9 +509,9 @@ | ||
| 477 | 509 | <input |
| 478 | 510 | name="give_anonymous_donation" |
| 479 | 511 | value="1" |
| 480 | 512 | type="radio" |
| 481 | - <?php checked( 1, absint( give_get_meta( $payment_id, '_give_anonymous_donation', true ) ) ) ?> | |
| 513 | + <?php checked( 1, absint( give_get_meta( $payment_id, '_give_anonymous_donation', true ) ) ); ?> | |
| 482 | 514 | ><?php _e( 'Yes', 'give' ); ?> |
| 483 | 515 | </label> |
| 484 | 516 | </li> |
| 485 | 517 | <li> |
| @@ -487,15 +519,14 @@ | ||
| 487 | 519 | <input |
| 488 | 520 | name="give_anonymous_donation" |
| 489 | 521 | value="0" |
| 490 | 522 | type="radio" |
| 491 | - <?php checked( 0, absint( give_get_meta( $payment_id, '_give_anonymous_donation', true ) ) ) ?> | |
| 523 | + <?php checked( 0, absint( give_get_meta( $payment_id, '_give_anonymous_donation', true ) ) ); ?> | |
| 492 | 524 | ><?php _e( 'No', 'give' ); ?> |
| 493 | 525 | </label> |
| 494 | 526 | </li> |
| 495 | 527 | </ul> |
| 496 | 528 | </div> |
| 497 | - <?php endif; ?> | |
| 498 | 529 | <p> |
| 499 | 530 | <?php |
| 500 | 531 | /** |
| 501 | 532 | * Fires in donation details page, in the donation-information metabox, before the head elements. |
| @@ -586,9 +617,9 @@ | ||
| 586 | 617 | <span>(<a href="#new" class="give-payment-new-donor"><?php esc_html_e( 'Create New Donor', 'give' ); ?></a>)</span> |
| 587 | 618 | </p> |
| 588 | 619 | <p> |
| 589 | 620 | <strong><?php esc_html_e( 'Donor Since:', 'give' ); ?></strong><br> |
| 590 | - <?php echo date_i18n( give_date_format(), strtotime( $donor->date_created ) ) ?> | |
| 621 | + <?php echo date_i18n( give_date_format(), strtotime( $donor->date_created ) ); ?> | |
| 591 | 622 | </p> |
| 592 | 623 | </div> |
| 593 | 624 | <div class="column"> |
| 594 | 625 | <p> |
| @@ -598,14 +629,19 @@ | ||
| 598 | 629 | $donor_name = give_get_donor_name_by( $donor_id, 'donor' ); |
| 599 | 630 | |
| 600 | 631 | // Check whether the donor name and WP_User name is same or not. |
| 601 | 632 | if ( $donor_billing_name !== $donor_name ) { |
| 602 | - echo sprintf( | |
| 603 | - '%1$s (<a href="%2$s" target="_blank">%3$s</a>)', | |
| 604 | - esc_html( $donor_billing_name ), | |
| 605 | - esc_url( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id={$donor_id}" ) ), | |
| 606 | - esc_html( $donor_name ) | |
| 607 | - ); | |
| 633 | + // Donors can be deleted by the user, but we can show the donor billing name from donation details. | |
| 634 | + if ( empty( $donor_name ) ) { | |
| 635 | + echo esc_html( $donor_billing_name ); | |
| 636 | + } else { | |
| 637 | + echo sprintf( | |
| 638 | + '%1$s (<a href="%2$s" target="_blank">%3$s</a>)', | |
| 639 | + esc_html( $donor_billing_name ), | |
| 640 | + esc_url( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id={$donor_id}" ) ), | |
| 641 | + esc_html( $donor_name ) | |
| 642 | + ); | |
| 643 | + } | |
| 608 | 644 | } else { |
| 609 | 645 | echo esc_html( $donor_name ); |
| 610 | 646 | } |
| 611 | 647 | ?> |
| @@ -612,19 +648,39 @@ | ||
| 612 | 648 | </p> |
| 613 | 649 | <p> |
| 614 | 650 | <strong><?php esc_html_e( 'Donor Email:', 'give' ); ?></strong><br> |
| 615 | 651 | <?php |
| 616 | - // Show Donor donation email first and Primary email on parenthesis if not match both email. | |
| 617 | - echo hash_equals( $donor->email, $payment->email ) | |
| 618 | - ? $payment->email | |
| 619 | - : sprintf( | |
| 620 | - '%1$s (<a href="%2$s" target="_blank">%3$s</a>)', | |
| 621 | - $payment->email, | |
| 622 | - esc_url( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id={$donor_id}" ) ), | |
| 623 | - $donor->email | |
| 624 | - ); | |
| 652 | + // Show Donor donation email first and Primary email on parenthesis if not match both email. | |
| 653 | + echo ( empty( $donor->email ) || hash_equals( $donor->email, $payment->email ) ) | |
| 654 | + ? esc_html( $payment->email ) | |
| 655 | + : sprintf( | |
| 656 | + '%1$s (<a href="%2$s" target="_blank">%3$s</a>)', | |
| 657 | + esc_html( $payment->email ), | |
| 658 | + esc_url( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id={$donor_id}" ) ), | |
| 659 | + esc_html( $donor->email ) | |
| 660 | + ); | |
| 625 | 661 | ?> |
| 626 | 662 | </p> |
| 663 | + <p> | |
| 664 | + <?php | |
| 665 | + if ( ! empty($donation_phone_number)) { | |
| 666 | + ?> | |
| 667 | + <strong><?php | |
| 668 | + esc_html_e('Donor Phone:', 'give'); ?></strong><br> | |
| 669 | + <?php | |
| 670 | + // Show Donor donation phone first and Primary phone on parenthesis if not match both phone. | |
| 671 | + echo (empty($donor_phone_number) || | |
| 672 | + hash_equals($donor_phone_number, $donation_phone_number)) | |
| 673 | + ? esc_html($donation_phone_number) : | |
| 674 | + sprintf( | |
| 675 | + '%1$s (<a href="%2$s" target="_blank">%3$s</a>)', | |
| 676 | + esc_html($donation_phone_number), | |
| 677 | + esc_url(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id={$donor_id}")), | |
| 678 | + esc_html($donor_phone_number) | |
| 679 | + ); | |
| 680 | + } | |
| 681 | + ?> | |
| 682 | + </p> | |
| 627 | 683 | </div> |
| 628 | 684 | <div class="column"> |
| 629 | 685 | <p> |
| 630 | 686 | <strong><?php esc_html_e( 'Change Donor:', 'give' ); ?></strong><br> |
| @@ -637,14 +693,16 @@ | ||
| 637 | 693 | ); |
| 638 | 694 | ?> |
| 639 | 695 | </p> |
| 640 | 696 | <p> |
| 641 | - <?php if ( ! empty( $company_name ) ) { | |
| 697 | + <?php | |
| 698 | + if ( ! empty( $company_name ) ) { | |
| 642 | 699 | ?> |
| 643 | 700 | <strong><?php esc_html_e( 'Company Name:', 'give' ); ?></strong><br> |
| 644 | 701 | <?php |
| 645 | 702 | echo $company_name; |
| 646 | - } ?> | |
| 703 | + } | |
| 704 | + ?> | |
| 647 | 705 | </p> |
| 648 | 706 | </div> |
| 649 | 707 | </div> |
| 650 | 708 | |
| @@ -748,8 +806,9 @@ | ||
| 748 | 806 | 'show_option_none' => false, |
| 749 | 807 | 'chosen' => true, |
| 750 | 808 | 'placeholder' => esc_attr__( 'Select a country', 'give' ), |
| 751 | 809 | 'data' => array( 'search-type' => 'no_ajax' ), |
| 810 | + 'autocomplete' => 'country', | |
| 752 | 811 | ) |
| 753 | 812 | ); |
| 754 | 813 | ?> |
| 755 | 814 | </div> |
| @@ -795,13 +854,14 @@ | ||
| 795 | 854 | 'show_option_none' => false, |
| 796 | 855 | 'chosen' => true, |
| 797 | 856 | 'placeholder' => esc_attr__( 'Select a state', 'give' ), |
| 798 | 857 | 'data' => array( 'search-type' => 'no_ajax' ), |
| 858 | + 'autocomplete' => 'address-level1', | |
| 799 | 859 | ) |
| 800 | 860 | ); |
| 801 | 861 | } else { |
| 802 | 862 | ?> |
| 803 | - <input id="give-payment-address-state" type="text" name="give-payment-address[0][state]" value="<?php echo esc_attr( $address['state'] ); ?>" class="medium-text"/> | |
| 863 | + <input id="give-payment-address-state" type="text" name="give-payment-address[0][state]" autocomplete="address-line1" value="<?php echo esc_attr( $address['state'] ); ?>" class="medium-text"/> | |
| 804 | 864 | <?php |
| 805 | 865 | } |
| 806 | 866 | ?> |
| 807 | 867 | </div> |
| @@ -890,11 +950,12 @@ | ||
| 890 | 950 | <?php |
| 891 | 951 | /** |
| 892 | 952 | * Fires on the donation details page, after the main area. |
| 893 | 953 | * |
| 954 | + * @since 2.27.0 Change to read comment from donations meta table | |
| 894 | 955 | * @since 1.0 |
| 895 | 956 | * |
| 896 | - * @param int $payment_id Payment id. | |
| 957 | + * @param int $payment_id Payment id. | |
| 897 | 958 | */ |
| 898 | 959 | do_action( 'give_view_donation_details_main_after', $payment_id ); |
| 899 | 960 | ?> |
| 900 | 961 | |
| @@ -905,23 +966,12 @@ | ||
| 905 | 966 | <div class="inside"> |
| 906 | 967 | <div id="give-payment-donor-comment-inner"> |
| 907 | 968 | <p> |
| 908 | 969 | <?php |
| 909 | - $donor_comment = give_get_donor_donation_comment( $payment_id, $payment->donor_id ); | |
| 910 | - | |
| 911 | 970 | echo sprintf( |
| 912 | - '<input type="hidden" name="give_comment_id" value="%s">', | |
| 913 | - $donor_comment instanceof WP_Comment // Backward compatibility. | |
| 914 | - || $donor_comment instanceof stdClass | |
| 915 | - ? $donor_comment->comment_ID : 0 | |
| 916 | - ); | |
| 917 | - | |
| 918 | - echo sprintf( | |
| 919 | 971 | '<textarea name="give_comment" id="give_comment" placeholder="%s" class="large-text">%s</textarea>', |
| 920 | 972 | __( 'Add a comment', 'give' ), |
| 921 | - $donor_comment instanceof WP_Comment // Backward compatibility. | |
| 922 | - || $donor_comment instanceof stdClass | |
| 923 | - ? $donor_comment->comment_content : '' | |
| 973 | + $payment->get_meta(DonationMetaKeys::COMMENT) ?? '' | |
| 924 | 974 | ); |
| 925 | 975 | ?> |
| 926 | 976 | </p> |
| 927 | 977 | </div> |