| Conditions | 32 |
| Paths | > 20000 |
| Total Lines | 660 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 300 | function give_donor_view( $donor ) { |
||
| 301 | |||
| 302 | $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
||
| 303 | |||
| 304 | /** |
||
| 305 | * Fires in donor profile screen, above the donor card. |
||
| 306 | * |
||
| 307 | * @since 1.0 |
||
| 308 | * |
||
| 309 | * @param object $donor The donor object being displayed. |
||
| 310 | */ |
||
| 311 | do_action( 'give_donor_card_top', $donor ); |
||
| 312 | |||
| 313 | // Set Read only to the fields which needs to be locked. |
||
| 314 | $read_only = ''; |
||
| 315 | if ( $donor->user_id ) { |
||
| 316 | $read_only = 'readonly="readonly"'; |
||
| 317 | } |
||
| 318 | |||
| 319 | // List of title prefixes. |
||
| 320 | $title_prefixes = give_get_name_title_prefixes(); |
||
| 321 | |||
| 322 | // Prepend title prefix to name if it is set. |
||
| 323 | $title_prefix = Give()->donor_meta->get_meta( $donor->id, '_give_donor_title_prefix', true ); |
||
| 324 | $donor_name_without_prefix = $donor->name; |
||
| 325 | $donor->name = give_get_donor_name_with_title_prefixes( $title_prefix, $donor->name ); |
||
| 326 | ?> |
||
| 327 | <div id="donor-summary" class="info-wrapper donor-section postbox"> |
||
| 328 | <form id="edit-donor-info" method="post" |
||
| 329 | action="<?php echo esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); ?>"> |
||
| 330 | <div class="donor-info"> |
||
| 331 | <div class="donor-bio-header clearfix"> |
||
| 332 | <div class="avatar-wrap left" id="donor-avatar"> |
||
| 333 | <?php |
||
| 334 | |||
| 335 | // Check whether a Gravatar exists for a donor or not. |
||
| 336 | $validate_gravatar_image = give_validate_gravatar( $donor->email ); |
||
| 337 | |||
| 338 | // Get donor's initials for non-gravatars |
||
| 339 | $donor_name_array = explode( " ", $donor_name_without_prefix ); |
||
| 340 | $donor_name_args['firstname'] = ! empty( $donor_name_array[0] ) ? $donor_name_array[0] : ''; |
||
| 341 | $donor_name_args['lastname'] = ! empty( $donor_name_array[1] ) ? $donor_name_array[1] : ''; |
||
| 342 | $donor_name_initial = give_get_name_initial( $donor_name_args ); |
||
| 343 | |||
| 344 | // Gravatars image for donor |
||
| 345 | if ( $validate_gravatar_image ) { |
||
| 346 | $donor_gravatar_image = get_avatar( $donor->email ); |
||
| 347 | } else { |
||
| 348 | $donor_gravatar_image = '<div class="give-donor-admin-avatar">' . $donor_name_initial . '</div>'; |
||
| 349 | } |
||
| 350 | |||
| 351 | echo $donor_gravatar_image; |
||
| 352 | ?> |
||
| 353 | </div> |
||
| 354 | <div id="donor-name-wrap" class="left"> |
||
| 355 | <span class="donor-name info-item edit-item"> |
||
| 356 | <select name="donor_info[title]"> |
||
| 357 | <option disabled value="0"><?php esc_html_e( 'Title', 'give' ); ?></option> |
||
| 358 | <?php |
||
| 359 | if ( is_array( $title_prefixes ) && count( $title_prefixes ) > 0 ) { |
||
| 360 | foreach ( $title_prefixes as $title ) { |
||
| 361 | echo sprintf( |
||
| 362 | '<option %1$s value="%2$s">%2$s</option>', |
||
| 363 | selected( $title_prefix, $title, false ), |
||
| 364 | esc_html( $title ) |
||
| 365 | ); |
||
| 366 | } |
||
| 367 | } |
||
| 368 | ?> |
||
| 369 | </select> |
||
| 370 | <input <?php echo $read_only; ?> size="15" data-key="first_name" |
||
| 371 | name="donor_info[first_name]" type="text" |
||
| 372 | value="<?php echo esc_html( $donor->get_first_name() ); ?>" |
||
| 373 | placeholder="<?php esc_html_e( 'First Name', 'give' ); ?>"/> |
||
| 374 | <?php if ( $donor->user_id ) : ?> |
||
| 375 | <a href="#" class="give-lock-block"> |
||
| 376 | <i class="give-icon give-icon-locked"></i> |
||
| 377 | </a> |
||
| 378 | <?php endif; ?> |
||
| 379 | <input <?php echo $read_only; ?> size="15" data-key="last_name" |
||
| 380 | name="donor_info[last_name]" type="text" |
||
| 381 | value="<?php echo esc_html( $donor->get_last_name() ); ?>" |
||
| 382 | placeholder="<?php esc_html_e( 'Last Name', 'give' ); ?>"/> |
||
| 383 | <?php if ( $donor->user_id ) : ?> |
||
| 384 | <a href="#" class="give-lock-block"> |
||
| 385 | <i class="give-icon give-icon-locked"></i> |
||
| 386 | </a> |
||
| 387 | <?php endif; ?> |
||
| 388 | </span> |
||
| 389 | <span class="donor-name info-item editable"> |
||
| 390 | <span data-key="name"><?php echo esc_html( $donor->name ); ?></span> |
||
| 391 | </span> |
||
| 392 | </div> |
||
| 393 | <p class="donor-since info-item"> |
||
| 394 | <?php esc_html_e( 'Donor since', 'give' ); ?> |
||
| 395 | <?php echo date_i18n( give_date_format(), strtotime( $donor->date_created ) ) ?> |
||
| 396 | </p> |
||
| 397 | <?php if ( current_user_can( $donor_edit_role ) ) : ?> |
||
| 398 | <a href="#" id="edit-donor" class="button info-item editable donor-edit-link"> |
||
| 399 | <?php esc_html_e( 'Edit Donor', 'give' ); ?> |
||
| 400 | </a> |
||
| 401 | <?php endif; ?> |
||
| 402 | </div> |
||
| 403 | <!-- /donor-bio-header --> |
||
| 404 | |||
| 405 | <div class="donor-main-wrapper"> |
||
| 406 | |||
| 407 | <table class="widefat striped"> |
||
| 408 | <tbody> |
||
| 409 | <tr> |
||
| 410 | <th scope="col"><label for="tablecell"><?php esc_html_e( 'Donor ID:', 'give' ); ?></label> |
||
| 411 | </th> |
||
| 412 | <td><?php echo intval( $donor->id ); ?></td> |
||
| 413 | </tr> |
||
| 414 | <tr> |
||
| 415 | <th scope="col"><label for="tablecell"><?php esc_html_e( 'User ID:', 'give' ); ?></label> |
||
| 416 | </th> |
||
| 417 | <td> |
||
| 418 | <span class="donor-user-id info-item edit-item"> |
||
| 419 | <?php |
||
| 420 | |||
| 421 | $user_id = $donor->user_id > 0 ? $donor->user_id : ''; |
||
| 422 | |||
| 423 | $data_atts = array( |
||
| 424 | 'key' => 'user_login', |
||
| 425 | 'search-type' => 'user', |
||
| 426 | ); |
||
| 427 | $user_args = array( |
||
| 428 | 'name' => 'donor_info[user_id]', |
||
| 429 | 'class' => 'give-user-dropdown', |
||
| 430 | 'data' => $data_atts, |
||
| 431 | ); |
||
| 432 | |||
| 433 | if ( ! empty( $user_id ) ) { |
||
| 434 | $userdata = get_userdata( $user_id ); |
||
| 435 | $user_args['selected'] = $user_id; |
||
| 436 | } |
||
| 437 | |||
| 438 | echo Give()->html->ajax_user_search( $user_args ); |
||
| 439 | ?> |
||
| 440 | </span> |
||
| 441 | |||
| 442 | <span class="donor-user-id info-item editable"> |
||
| 443 | <?php if ( ! empty( $userdata ) ) : ?> |
||
| 444 | <span |
||
| 445 | data-key="user_id">#<?php echo $donor->user_id . ' - ' . $userdata->display_name; ?></span> |
||
| 446 | <?php else : ?> |
||
| 447 | <span |
||
| 448 | data-key="user_id"><?php esc_html_e( 'Unregistered', 'give' ); ?></span> |
||
| 449 | <?php endif; ?> |
||
| 450 | <?php if ( current_user_can( $donor_edit_role ) && intval( $donor->user_id ) > 0 ) : |
||
| 451 | |||
| 452 | echo sprintf( |
||
| 453 | '- <span class="disconnect-user"> |
||
| 454 | <a id="disconnect-donor" href="#disconnect" aria-label="%1$s">%2$s</a> |
||
| 455 | </span> | |
||
| 456 | <span class="view-user-profile"> |
||
| 457 | <a id="view-user-profile" href="%3$s" aria-label="%4$s">%5$s</a> |
||
| 458 | </span>', |
||
| 459 | esc_html__( 'Disconnects the current user ID from this donor record.', 'give' ), |
||
| 460 | esc_html__( 'Disconnect User', 'give' ), |
||
| 461 | esc_url( 'user-edit.php?user_id=' . $donor->user_id ), |
||
| 462 | esc_html__( 'View User Profile of current user ID.', 'give' ), |
||
| 463 | esc_html__( 'View User Profile', 'give' ) |
||
| 464 | ); |
||
| 465 | |||
| 466 | endif; ?> |
||
| 467 | </span> |
||
| 468 | </td> |
||
| 469 | </tr> |
||
| 470 | |||
| 471 | <?php |
||
| 472 | $donor_company = $donor->get_meta( '_give_donor_company', true ); |
||
| 473 | ?> |
||
| 474 | <tr class="alternate"> |
||
| 475 | <th scope="col"> |
||
| 476 | <label for="tablecell"><?php esc_html_e( 'Company Name:', 'give' ); ?></label> |
||
| 477 | </th> |
||
| 478 | <td> |
||
| 479 | <span class="donor-user-id info-item edit-item"> |
||
| 480 | <input name="give_donor_company" value="<?php echo $donor_company ?>" type="text"> |
||
| 481 | </span> |
||
| 482 | |||
| 483 | <span class="donor-user-id info-item editable"> |
||
| 484 | <?php echo $donor_company; ?> |
||
| 485 | </span> |
||
| 486 | </td> |
||
| 487 | </tr> |
||
| 488 | </tbody> |
||
| 489 | </table> |
||
| 490 | </div> |
||
| 491 | |||
| 492 | </div> |
||
| 493 | |||
| 494 | <span id="donor-edit-actions" class="edit-item"> |
||
| 495 | <input type="hidden" data-key="id" name="donor_info[id]" value="<?php echo intval( $donor->id ); ?>"/> |
||
| 496 | <?php wp_nonce_field( 'edit-donor', '_wpnonce', false, true ); ?> |
||
| 497 | <input type="hidden" name="give_action" value="edit-donor"/> |
||
| 498 | <input type="submit" id="give-edit-donor-save" class="button-secondary" |
||
| 499 | value="<?php esc_html_e( 'Update Donor', 'give' ); ?>"/> |
||
| 500 | <a id="give-edit-donor-cancel" href="" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a> |
||
| 501 | </span> |
||
| 502 | |||
| 503 | </form> |
||
| 504 | |||
| 505 | </div> |
||
| 506 | |||
| 507 | <?php |
||
| 508 | /** |
||
| 509 | * Fires in donor profile screen, above the stats list. |
||
| 510 | * |
||
| 511 | * @since 1.0 |
||
| 512 | * |
||
| 513 | * @param Give_Donor $donor The donor object being displayed. |
||
| 514 | */ |
||
| 515 | do_action( 'give_donor_before_stats', $donor ); |
||
| 516 | ?> |
||
| 517 | |||
| 518 | <div id="donor-stats-wrapper" class="donor-section postbox clear"> |
||
| 519 | <ul> |
||
| 520 | <li> |
||
| 521 | <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor->id ) ); ?>"> |
||
| 522 | <span class="dashicons dashicons-heart"></span> |
||
| 523 | <?php |
||
| 524 | // Completed Donations. |
||
| 525 | $completed_donations_text = sprintf( _n( '%d Completed Donation', '%d Completed Donations', $donor->purchase_count, 'give' ), $donor->purchase_count ); |
||
| 526 | echo apply_filters( 'give_donor_completed_donations', $completed_donations_text, $donor ); |
||
| 527 | ?> |
||
| 528 | </a> |
||
| 529 | </li> |
||
| 530 | <li> |
||
| 531 | <span class="dashicons dashicons-chart-area"></span> |
||
| 532 | <?php echo give_currency_filter( give_format_amount( $donor->get_total_donation_amount(), array( 'sanitize' => false ) ) ); ?> <?php _e( 'Lifetime Donations', 'give' ); ?> |
||
| 533 | </li> |
||
| 534 | <?php |
||
| 535 | /** |
||
| 536 | * Fires in donor profile screen, in the stats list. |
||
| 537 | * |
||
| 538 | * Allows you to add more list items to the stats list. |
||
| 539 | * |
||
| 540 | * @since 1.0 |
||
| 541 | * |
||
| 542 | * @param object $donor The donor object being displayed. |
||
| 543 | */ |
||
| 544 | do_action( 'give_donor_stats_list', $donor ); |
||
| 545 | ?> |
||
| 546 | </ul> |
||
| 547 | </div> |
||
| 548 | |||
| 549 | <?php |
||
| 550 | /** |
||
| 551 | * Fires in donor profile screen, above the address list. |
||
| 552 | * |
||
| 553 | * @since 1.8.14 |
||
| 554 | * |
||
| 555 | * @param Give_Donor $donor The donor object being displayed. |
||
| 556 | */ |
||
| 557 | do_action( 'give_donor_before_address', $donor ); |
||
| 558 | ?> |
||
| 559 | |||
| 560 | <div id="donor-address-wrapper" class="donor-section clear"> |
||
| 561 | <h3><?php _e( 'Addresses', 'give' ); ?></h3> |
||
| 562 | |||
| 563 | <div class="postbox"> |
||
| 564 | <div class="give-spinner-wrapper"> |
||
| 565 | <span class="give-spinner spinner aligncenter"></span> |
||
| 566 | </div> |
||
| 567 | <div class="inside"> |
||
| 568 | <div class="all-address"> |
||
| 569 | <div class="give-grid-row"> |
||
| 570 | <?php |
||
| 571 | if ( ! empty( $donor->address ) ) : |
||
| 572 | // Default address always will be at zero array index. |
||
| 573 | $is_set_as_default = null; |
||
| 574 | |||
| 575 | foreach ( $donor->address as $address_type => $addresses ) { |
||
| 576 | |||
| 577 | switch ( true ) { |
||
| 578 | case is_array( end( $addresses ) ): |
||
| 579 | $index = 1; |
||
| 580 | foreach ( $addresses as $id => $address ) { |
||
| 581 | echo __give_get_format_address( |
||
| 582 | $address, |
||
| 583 | array( |
||
| 584 | 'type' => $address_type, |
||
| 585 | 'id' => $id, |
||
| 586 | 'index' => $index, |
||
| 587 | ) |
||
| 588 | ); |
||
| 589 | |||
| 590 | $index ++; |
||
| 591 | } |
||
| 592 | break; |
||
| 593 | |||
| 594 | case is_string( end( $addresses ) ): |
||
| 595 | echo __give_get_format_address( |
||
| 596 | $addresses, |
||
| 597 | array( |
||
| 598 | 'type' => $address_type, |
||
| 599 | ) |
||
| 600 | ); |
||
| 601 | break; |
||
| 602 | } |
||
| 603 | } |
||
| 604 | endif; |
||
| 605 | ?> |
||
| 606 | </div> |
||
| 607 | <span class="give-no-address-message<?php if ( ! empty( $donor->address ) ) { |
||
| 608 | echo ' give-hidden'; |
||
| 609 | } ?>"> |
||
| 610 | <?php _e( 'This donor does not have any addresses saved.', 'give' ); ?> |
||
| 611 | </span> |
||
| 612 | <button class="button add-new-address"> |
||
| 613 | <?php _e( 'Add Address', 'give' ); ?> |
||
| 614 | </button> |
||
| 615 | </div> |
||
| 616 | |||
| 617 | <div class="address-form add-new-address-form-hidden"> |
||
| 618 | <form action="" method="post"> |
||
| 619 | <table class="widefat striped"> |
||
| 620 | <tbody> |
||
| 621 | <tr> |
||
| 622 | <th class="col"> |
||
| 623 | <label class="country"><?php esc_html_e( 'Country:', 'give' ); ?></label> |
||
| 624 | </th> |
||
| 625 | <td> |
||
| 626 | <?php |
||
| 627 | echo Give()->html->select( array( |
||
| 628 | 'options' => give_get_country_list(), |
||
| 629 | 'name' => 'country', |
||
| 630 | 'selected' => give_get_option( 'base_country' ), |
||
| 631 | 'show_option_all' => false, |
||
| 632 | 'show_option_none' => false, |
||
| 633 | 'chosen' => true, |
||
| 634 | 'placeholder' => esc_attr__( 'Select a country', 'give' ), |
||
| 635 | 'data' => array( 'search-type' => 'no_ajax' ), |
||
| 636 | ) ); |
||
| 637 | ?> |
||
| 638 | </td> |
||
| 639 | </tr> |
||
| 640 | <tr> |
||
| 641 | <th class="col"> |
||
| 642 | <label for="line1"><?php esc_html_e( 'Address 1:', 'give' ); ?></label> |
||
| 643 | </th> |
||
| 644 | <td> |
||
| 645 | <input id="line1" name="line1" type="text" class="medium-text"/> |
||
| 646 | </td> |
||
| 647 | </tr> |
||
| 648 | <tr> |
||
| 649 | <th class="col"> |
||
| 650 | <label for="line2"><?php esc_html_e( 'Address 2:', 'give' ); ?></label> |
||
| 651 | </th> |
||
| 652 | <td> |
||
| 653 | <input id="line2" type="text" name="line2" value="" class="medium-text"/> |
||
| 654 | |||
| 655 | </td> |
||
| 656 | </tr> |
||
| 657 | <tr> |
||
| 658 | <th class="col"> |
||
| 659 | <label for="city"><?php esc_html_e( 'City:', 'give' ); ?></label> |
||
| 660 | </th> |
||
| 661 | <td> |
||
| 662 | <input id="city" type="text" name="city" value="" class="medium-text"/> |
||
| 663 | </td> |
||
| 664 | </tr> |
||
| 665 | <?php |
||
| 666 | $no_states_country = give_no_states_country_list(); |
||
| 667 | $base_country = give_get_option( 'base_country' ); |
||
| 668 | if ( ! array_key_exists( $base_country, $no_states_country ) ) { |
||
| 669 | ?> |
||
| 670 | <tr class="give-field-wrap"> |
||
| 671 | <th class="col"> |
||
| 672 | <label |
||
| 673 | for="state"><?php esc_html_e( 'State / Province / County:', 'give' ); ?></label> |
||
| 674 | </th> |
||
| 675 | <td> |
||
| 676 | <?php |
||
| 677 | $states = give_get_states( $base_country ); |
||
| 678 | $state_args = array( |
||
| 679 | 'name' => 'state', |
||
| 680 | 'class' => 'regular-text', |
||
| 681 | ); |
||
| 682 | |||
| 683 | if ( empty( $states ) ) { |
||
| 684 | |||
| 685 | // Show Text field, if empty states. |
||
| 686 | $state_args = wp_parse_args( $state_args, array( |
||
| 687 | 'value' => give_get_option( 'base_state' ), |
||
| 688 | ) ); |
||
| 689 | echo Give()->html->text( $state_args ); |
||
| 690 | } else { |
||
| 691 | |||
| 692 | // Show Chosen DropDown, if states are not empty. |
||
| 693 | $state_args = wp_parse_args( $state_args, array( |
||
| 694 | 'options' => $states, |
||
| 695 | 'selected' => give_get_option( 'base_state' ), |
||
| 696 | 'show_option_all' => false, |
||
| 697 | 'show_option_none' => false, |
||
| 698 | 'chosen' => true, |
||
| 699 | 'placeholder' => __( 'Select a state', 'give' ), |
||
| 700 | 'data' => array( 'search-type' => 'no_ajax' ), |
||
| 701 | ) ); |
||
| 702 | echo Give()->html->select( $state_args ); |
||
| 703 | } |
||
| 704 | ?> |
||
| 705 | </td> |
||
| 706 | </tr> |
||
| 707 | <?php |
||
| 708 | } |
||
| 709 | ?> |
||
| 710 | <tr> |
||
| 711 | <th class="col"> |
||
| 712 | <label for="zip"><?php esc_html_e( 'Zip / Postal Code:', 'give' ); ?></label> |
||
| 713 | </th> |
||
| 714 | <td> |
||
| 715 | <input id="zip" type="text" name="zip" value="" class="medium-text"/> |
||
| 716 | </td> |
||
| 717 | </tr> |
||
| 718 | <tr> |
||
| 719 | <td colspan="2"> |
||
| 720 | <?php wp_nonce_field( 'give-manage-donor-addresses', '_wpnonce', false ); ?> |
||
| 721 | <input type="hidden" name="address-action" value="add"> |
||
| 722 | <input type="hidden" name="address-id" value=""> |
||
| 723 | <input type="submit" class="button button-primary js-save" |
||
| 724 | value="<?php _e( 'Save', 'give' ); ?>"> <button |
||
| 725 | class="button js-cancel"><?php _e( 'Cancel', 'give' ); ?></button> |
||
| 726 | </td> |
||
| 727 | </tr> |
||
| 728 | </tbody> |
||
| 729 | </table> |
||
| 730 | </form> |
||
| 731 | </div> |
||
| 732 | </div> |
||
| 733 | </div> |
||
| 734 | </div> |
||
| 735 | |||
| 736 | <?php |
||
| 737 | /** |
||
| 738 | * Fires in donor profile screen, above the tables wrapper. |
||
| 739 | * |
||
| 740 | * @since 1.0 |
||
| 741 | * |
||
| 742 | * @param Give_Donor $donor The donor object being displayed. |
||
| 743 | */ |
||
| 744 | do_action( 'give_donor_before_tables_wrapper', $donor ); |
||
| 745 | ?> |
||
| 746 | |||
| 747 | <div id="donor-tables-wrapper" class="donor-section"> |
||
| 748 | |||
| 749 | <?php |
||
| 750 | /** |
||
| 751 | * Fires in donor profile screen, above the tables. |
||
| 752 | * |
||
| 753 | * @since 1.0 |
||
| 754 | * |
||
| 755 | * @param object $donor The donor object being displayed. |
||
| 756 | */ |
||
| 757 | do_action( 'give_donor_before_tables', $donor ); |
||
| 758 | ?> |
||
| 759 | |||
| 760 | <h3><?php _e( 'Donor Emails', 'give' ); ?></h3> |
||
| 761 | |||
| 762 | <table class="wp-list-table widefat striped emails"> |
||
| 763 | <thead> |
||
| 764 | <tr> |
||
| 765 | <th><?php _e( 'Email', 'give' ); ?></th> |
||
| 766 | <th><?php _e( 'Actions', 'give' ); ?></th> |
||
| 767 | </tr> |
||
| 768 | </thead> |
||
| 769 | |||
| 770 | <tbody> |
||
| 771 | <?php if ( ! empty( $donor->emails ) ) { ?> |
||
| 772 | |||
| 773 | <?php foreach ( $donor->emails as $key => $email ) : ?> |
||
| 774 | <tr data-key="<?php echo $key; ?>"> |
||
| 775 | <td> |
||
| 776 | <?php echo $email; ?> |
||
| 777 | <?php if ( 'primary' === $key ) : ?> |
||
| 778 | <span class="dashicons dashicons-star-filled primary-email-icon"></span> |
||
| 779 | <?php endif; ?> |
||
| 780 | </td> |
||
| 781 | <td> |
||
| 782 | <?php if ( 'primary' !== $key ) : ?> |
||
| 783 | <?php |
||
| 784 | $base_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); |
||
| 785 | $promote_url = wp_nonce_url( add_query_arg( array( |
||
| 786 | 'email' => rawurlencode( $email ), |
||
| 787 | 'give_action' => 'set_donor_primary_email', |
||
| 788 | ), $base_url ), 'give-set-donor-primary-email' ); |
||
| 789 | $remove_url = wp_nonce_url( add_query_arg( array( |
||
| 790 | 'email' => rawurlencode( $email ), |
||
| 791 | 'give_action' => 'remove_donor_email', |
||
| 792 | ), $base_url ), 'give-remove-donor-email' ); |
||
| 793 | ?> |
||
| 794 | <a href="<?php echo $promote_url; ?>"><?php _e( 'Make Primary', 'give' ); ?></a> |
||
| 795 | | |
||
| 796 | <a href="<?php echo $remove_url; ?>" class="delete"><?php _e( 'Remove', 'give' ); ?></a> |
||
| 797 | <?php endif; ?> |
||
| 798 | </td> |
||
| 799 | </tr> |
||
| 800 | <?php endforeach; ?> |
||
| 801 | |||
| 802 | <tr class="add-donor-email-row"> |
||
| 803 | <td colspan="2" class="add-donor-email-td"> |
||
| 804 | <div class="add-donor-email-wrapper"> |
||
| 805 | <input type="hidden" name="donor-id" value="<?php echo $donor->id; ?>"/> |
||
| 806 | <?php wp_nonce_field( 'give_add_donor_email', 'add_email_nonce', false, true ); ?> |
||
| 807 | <input type="email" name="additional-email" value="" |
||
| 808 | placeholder="<?php _e( 'Email Address', 'give' ); ?>"/> |
||
| 809 | <input type="checkbox" name="make-additional-primary" value="1" |
||
| 810 | id="make-additional-primary"/> <label |
||
| 811 | for="make-additional-primary"><?php _e( 'Make Primary', 'give' ); ?></label> |
||
| 812 | <button class="button-secondary give-add-donor-email" |
||
| 813 | id="add-donor-email"><?php _e( 'Add Email', 'give' ); ?></button> |
||
| 814 | <span class="spinner"></span> |
||
| 815 | </div> |
||
| 816 | <div class="notice-wrap"></div> |
||
| 817 | </td> |
||
| 818 | </tr> |
||
| 819 | <?php } else { ?> |
||
| 820 | <tr> |
||
| 821 | <td colspan="2"><?php _e( 'No Emails Found', 'give' ); ?></td> |
||
| 822 | </tr> |
||
| 823 | <?php }// End if(). |
||
| 824 | ?> |
||
| 825 | </tbody> |
||
| 826 | </table> |
||
| 827 | |||
| 828 | <h3><?php _e( 'Recent Donations', 'give' ); ?></h3> |
||
| 829 | <?php |
||
| 830 | $payment_ids = explode( ',', $donor->payment_ids ); |
||
| 831 | $payments = give_get_payments( array( |
||
| 832 | 'post__in' => $payment_ids, |
||
| 833 | ) ); |
||
| 834 | $payments = array_slice( $payments, 0, 10 ); |
||
| 835 | ?> |
||
| 836 | <table class="wp-list-table widefat striped payments"> |
||
| 837 | <thead> |
||
| 838 | <tr> |
||
| 839 | <th scope="col"><?php _e( 'ID', 'give' ); ?></th> |
||
| 840 | <th scope="col"><?php _e( 'Amount', 'give' ); ?></th> |
||
| 841 | <th scope="col"><?php _e( 'Date', 'give' ); ?></th> |
||
| 842 | <th scope="col"><?php _e( 'Status', 'give' ); ?></th> |
||
| 843 | <th scope="col"><?php _e( 'Actions', 'give' ); ?></th> |
||
| 844 | </tr> |
||
| 845 | </thead> |
||
| 846 | <tbody> |
||
| 847 | <?php if ( ! empty( $payments ) ) { ?> |
||
| 848 | <?php foreach ( $payments as $payment ) : ?> |
||
| 849 | <tr> |
||
| 850 | <td><?php echo Give()->seq_donation_number->get_serial_code( $payment->ID ); ?></td> |
||
| 851 | <td><?php echo give_donation_amount( $payment->ID, array( |
||
| 852 | 'currency' => true, |
||
| 853 | 'amount' => true, |
||
| 854 | 'type' => 'donor' |
||
| 855 | ) ); ?></td> |
||
| 856 | <td><?php echo date_i18n( give_date_format(), strtotime( $payment->post_date ) ); ?></td> |
||
| 857 | <td><?php echo give_get_payment_status( $payment, true ); ?></td> |
||
| 858 | <td> |
||
| 859 | <?php |
||
| 860 | printf( |
||
| 861 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
||
| 862 | admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment->ID ), |
||
| 863 | sprintf( |
||
| 864 | /* translators: %s: Donation ID */ |
||
| 865 | esc_attr__( 'View Donation %s.', 'give' ), |
||
| 866 | $payment->ID |
||
| 867 | ), |
||
| 868 | __( 'View Donation', 'give' ) |
||
| 869 | ); |
||
| 870 | ?> |
||
| 871 | |||
| 872 | <?php |
||
| 873 | /** |
||
| 874 | * Fires in donor profile screen, in the recent donations tables action links. |
||
| 875 | * |
||
| 876 | * Allows you to add more action links for each donation, after the 'View Donation' action link. |
||
| 877 | * |
||
| 878 | * @since 1.0 |
||
| 879 | * |
||
| 880 | * @param object $donor The donor object being displayed. |
||
| 881 | * @param object $payment The payment object being displayed. |
||
| 882 | */ |
||
| 883 | do_action( 'give_donor_recent_purchases_actions', $donor, $payment ); |
||
| 884 | ?> |
||
| 885 | </td> |
||
| 886 | </tr> |
||
| 887 | <?php endforeach; ?> |
||
| 888 | <?php } else { ?> |
||
| 889 | <tr> |
||
| 890 | <td colspan="5"><?php _e( 'No donations found.', 'give' ); ?></td> |
||
| 891 | </tr> |
||
| 892 | <?php }// End if(). |
||
| 893 | ?> |
||
| 894 | </tbody> |
||
| 895 | </table> |
||
| 896 | |||
| 897 | <h3><?php _e( 'Completed Forms', 'give' ); ?></h3> |
||
| 898 | <?php |
||
| 899 | $donations = give_get_users_completed_donations( $donor->email ); |
||
| 900 | ?> |
||
| 901 | <table class="wp-list-table widefat striped donations"> |
||
| 902 | <thead> |
||
| 903 | <tr> |
||
| 904 | <th scope="col"><?php _e( 'Form', 'give' ); ?></th> |
||
| 905 | <th scope="col" width="120px"><?php _e( 'Actions', 'give' ); ?></th> |
||
| 906 | </tr> |
||
| 907 | </thead> |
||
| 908 | <tbody> |
||
| 909 | <?php if ( ! empty( $donations ) ) { ?> |
||
| 910 | <?php foreach ( $donations as $donation ) : ?> |
||
| 911 | <tr> |
||
| 912 | <td><?php echo $donation->post_title; ?></td> |
||
| 913 | <td> |
||
| 914 | <?php |
||
| 915 | printf( |
||
| 916 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
||
| 917 | esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ), |
||
| 918 | sprintf( |
||
| 919 | /* translators: %s: form name */ |
||
| 920 | esc_attr__( 'View Form %s.', 'give' ), |
||
| 921 | $donation->post_title |
||
| 922 | ), |
||
| 923 | __( 'View Form', 'give' ) |
||
| 924 | ); |
||
| 925 | ?> |
||
| 926 | </td> |
||
| 927 | </tr> |
||
| 928 | <?php endforeach; ?> |
||
| 929 | <?php } else { ?> |
||
| 930 | <tr> |
||
| 931 | <td colspan="2"><?php _e( 'No completed donations found.', 'give' ); ?></td> |
||
| 932 | </tr> |
||
| 933 | <?php } ?> |
||
| 934 | </tbody> |
||
| 935 | </table> |
||
| 936 | <?php |
||
| 937 | /** |
||
| 938 | * Fires in donor profile screen, below the tables. |
||
| 939 | * |
||
| 940 | * @since 1.0 |
||
| 941 | * |
||
| 942 | * @param object $donor The donor object being displayed. |
||
| 943 | */ |
||
| 944 | do_action( 'give_donor_after_tables', $donor ); |
||
| 945 | ?> |
||
| 946 | |||
| 947 | </div> |
||
| 948 | |||
| 949 | <?php |
||
| 950 | /** |
||
| 951 | * Fires in donor profile screen, below the donor card. |
||
| 952 | * |
||
| 953 | * @since 1.0 |
||
| 954 | * |
||
| 955 | * @param object $donor The donor object being displayed. |
||
| 956 | */ |
||
| 957 | do_action( 'give_donor_card_bottom', $donor ); |
||
| 958 | |||
| 959 | } |
||
| 960 | |||
| 1130 |