1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
function epl_contacts_page() {
$default_views = epl_contact_views();
$requested_view = isset( $_GET['view'] ) ? sanitize_text_field( wp_unslash( $_GET['view'] ) ) : 'contacts';
if ( array_key_exists( $requested_view, $default_views ) && function_exists( $default_views[ $requested_view ] ) ) {
epl_render_contact_view( $requested_view, $default_views );
} else {
epl_contacts_list();
}
}
function epl_contact_views() {
$views = array();
return apply_filters( 'epl_contact_views', $views );
}
function epl_contact_tabs() {
$tabs = array();
return apply_filters( 'epl_contact_tabs', $tabs );
}
function epl_contacts_list() {
global $epl_contacts_table;
$epl_contacts_table->prepare_items();
?>
<div class="wrap">
<h2><?php esc_html_e( 'Contacts', 'easy-property-listings' ); ?>
<a class="add-new-h2" href="<?php echo esc_url( admin_url( 'admin.php?page=epl-contacts&view=new-contact' ) ); ?>"><?php esc_html_e( 'Add New', 'easy-property-listings' ); ?></a>
<a class="add-new-h2 epl-contact-tags-page" href="<?php echo esc_url( admin_url( 'admin.php?page=epl-contacts&view=all_tags' ) ); ?>"><?php esc_html_e( 'Tags', 'easy-property-listings' ); ?></a>
</h2>
<?php do_action( 'epl_contacts_table_top' ); ?>
<form id="epl-contacts-filter" method="get" action="<?php echo esc_url( admin_url( 'admin.php?page=epl-contacts' ) ); ?>">
<?php
$epl_contacts_table->search_box( esc_html__( 'Search Contacts', 'easy-property-listings' ), 'epl-contacts' );
$epl_contacts_table->display();
?>
<input type="hidden" name="page" value="epl-contacts" />
<input type="hidden" name="view" value="contacts" />
</form>
<?php do_action( 'epl_contacts_table_bottom' ); ?>
</div>
<?php
}
function epl_render_contact_view( $view, $callbacks ) {
$render = true;
if ( ! is_admin() || ! epl_contact_access() ) {
epl_set_error( 'epl-no-access', esc_html__( 'You are not permitted to view this data.', 'easy-property-listings' ) );
$render = false;
}
if ( 'new-contact' === $view || 'all_tags' === $view ) {
$callbacks[ $view ]();
return;
}
if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
epl_set_error( 'epl-invalid_contact', esc_html__( 'Invalid Contact ID Provided.', 'easy-property-listings' ) );
$render = false;
}
$contact_id = (int) $_GET['id'];
$contact = new EPL_Contact( $contact_id );
if ( empty( $contact->ID ) ) {
epl_set_error( 'epl-invalid_contact', esc_html__( 'Invalid Contact ID Provided.', 'easy-property-listings' ) );
$render = false;
}
$contact_tabs = epl_contact_tabs();
?>
<div class='wrap'>
<h2><?php esc_html_e( 'Contact Details', 'easy-property-listings' ); ?></h2>
<?php if ( epl_get_errors() ) : ?>
<div class="error settings-error">
<?php epl_print_errors(); ?>
</div>
<?php endif; ?>
<?php if ( $contact && $render ) : ?>
<div id="epl-item-tab-wrapper" class="contact-tab-wrapper">
<ul id="epl-item-tab-wrapper-list" class="ustomer-tab-wrapper-list">
<?php foreach ( $contact_tabs as $key => $tab ) : ?>
<?php $active = $key === $view ? true : false; ?>
<?php $class = $active ? 'active' : 'inactive'; ?>
<?php if ( ! $active ) : ?>
<a title="<?php echo esc_attr( $tab['title'] ); ?>" aria-label="<?php echo esc_attr( $tab['title'] ); ?>" href="<?php echo esc_url( admin_url( 'admin.php?page=epl-contacts&view=' . $key . '&id=' . $contact->ID ) ); ?>">
<?php endif; ?>
<li class="<?php echo sanitize_html_class( $class ); ?>"><span class="dashicons <?php echo sanitize_html_class( $tab['dashicon'] ); ?>"></span></li>
<?php if ( ! $active ) : ?>
</a>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
<div id="epl-item-card-wrapper" class="epl-contact-card-wrapper" style="float: left">
<?php $callbacks[ $view ]( $contact ); ?>
</div>
<?php endif; ?>
</div>
<?php
}
function epl_all_tags_view() {
include_once 'contact-tags-ui.php';
}
function epl_new_contact_view() {
?>
<?php
if ( isset( $_GET['id'] ) ) {
$redirect = admin_url( 'admin.php?page=epl-contacts&view=meta&id=' . intval( wp_unslash( $_GET['id'] ) ) );
wp_safe_redirect( $redirect );
exit();
}
?>
<div class='wrap'>
<h2><?php esc_html_e( 'Add Contact', 'easy-property-listings' ); ?></h2>
<?php if ( epl_get_errors() ) : ?>
<div class="error settings-error">
<?php epl_print_errors(); ?>
</div>
<?php endif; ?>
<div id="epl-item-tab-wrapper" class="contact-tab-wrapper">
</div>
<div id="epl-item-card-wrapper" class="epl-contact-card-wrapper" style="float: left">
<div class="epl-info-wrapper epl-contact-section">
<?php
$args = array(
'post_type' => 'epl_contact',
'post_status' => 'auto-draft',
'post_title' => esc_html__( 'Contact Name', 'easy-property-listings' ),
);
$contact_id = wp_insert_post( $args );
if ( $contact_id ) :
?>
<form id="epl-meta-contact-form" method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=epl-contacts&view=new-contact&id=' . $contact_id ) ); ?>">
<div class="epl-contact-info epl-meta-contact epl-admin-new-contact">
<?php do_action( 'epl_new_contact_fields' ); ?>
<?php
$contact = new EPL_Contact( $contact_id );
$contact_meta_fields = new EPL_FORM_BUILDER();
$contact_fields = apply_filters(
'epl_contact_new_fields',
array(
array(
'name' => 'title',
'label' => esc_html__( 'Summary', 'easy-property-listings' ),
'type' => 'text',
'maxlength' => '60',
'value' => $contact->name,
),
array(
'name' => 'first_name',
'label' => esc_html__( 'First Name', 'easy-property-listings' ),
'type' => 'text',
'maxlength' => '60',
'value' => $contact->get_meta( 'contact_first_name' ),
),
array(
'name' => 'last_name',
'label' => esc_html__( 'Last Name', 'easy-property-listings' ),
'type' => 'text',
'maxlength' => '60',
'value' => $contact->get_meta( 'contact_last_name' ),
),
array(
'name' => 'email',
'label' => esc_html__( 'Email *', 'easy-property-listings' ),
'type' => 'email',
'maxlength' => '60',
'value' => $contact->get_primary_email( $contact->ID ),
),
array(
'name' => 'phone',
'label' => esc_html__( 'Phone', 'easy-property-listings' ),
'type' => 'text',
'maxlength' => '60',
'value' => '',
),
)
);
$contact_meta_fields->add_fields( $contact_fields );
$contact_meta_fields->render_form();
?>
<span style="color:#f00; text-align:right;">
<?php esc_html_e( '* Required Fields', 'easy-property-listings' ); ?>
</span>
<span id="epl-contact-edit-actions">
<input type="hidden" name="contact_id" value="<?php echo esc_attr( $contact->ID ); ?>" />
<input type="hidden" name="ID" value="<?php echo esc_attr( $contact->ID ); ?>" />
<?php wp_nonce_field( 'new-contact', '_wpnonce', false, true ); ?>
<input type="hidden" name="epl_action" value="new-contact" />
<input type="submit" id="epl-new-contact" class="button-primary" value="<?php esc_html_e( 'Create', 'easy-property-listings' ); ?>" />
</span>
</div>
</form>
<?php endif; ?>
</div>
</div>
</div>
<?php
}
function epl_contacts_view( $contact ) {
$contact_edit_role = apply_filters( 'epl_edit_contacts_role', 'manage_options' );
?>
<?php do_action( 'epl_contact_card_top', $contact ); ?>
<?php do_action( 'epl_pre_contact_quick_edit_options', $contact ); ?>
<?php do_action( 'epl_contact_action_menus', $contact ); ?>
<?php do_action( 'epl_contact_entry_header', $contact ); ?>
<?php do_action( 'epl_contact_assigned_tags', $contact ); ?>
<?php do_action( 'epl_post_contact_quick_edit_options', $contact ); ?>
<div class="epl-info-wrapper epl-contact-section epl-contact-single-display">
<input type="hidden" id="epl_contact_id" value="<?php echo esc_attr( $contact->ID ); ?>"/>
<div class="epl-item-info epl-contact-info">
<?php do_action( 'epl_contact_avatar', $contact ); ?>
<div class="epl-contact-id right">
<?php do_action( 'epl_contact_social_icons', $contact ); ?>
</div>
<div class="epl-contact-main-wrapper left">
<?php do_action( 'epl_contact_contact_details', $contact ); ?>
</div>
</div>
</div>
<?php do_action( 'epl_contact_before_tables_wrapper', $contact ); ?>
<?php do_action( 'epl_contact_background_info', $contact ); ?>
<div id="epl-item-tables-wrapper" class="contact-tables-wrapper epl-contact-section">
<?php do_action( 'epl_contact_before_tables', $contact ); ?>
<?php do_action( 'epl_contact_recent_activities', $contact ); ?>
<?php do_action( 'epl_contact_after_tables', $contact ); ?>
</div>
<?php do_action( 'epl_contact_card_bottom', $contact ); ?>
<?php
}
function epl_contact_meta_view( $contact ) {
$this_user = wp_get_current_user();
if ( ! is_admin() || ! epl_contact_access() ) {
wp_die( esc_html__( 'You do not have permission to see this page.', 'easy-property-listings' ) );
}
?>
<?php do_action( 'epl_contact_edit_top', $contact ); ?>
<?php do_action( 'epl_pre_contact_quick_edit_options', $contact ); ?>
<?php do_action( 'epl_contact_action_menus', $contact ); ?>
<form id="epl-meta-contact-form" method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=epl-contacts&view=meta&id=' . $contact->ID ) ); ?>">
<?php do_action( 'epl_contact_entry_header_editable', $contact ); ?>
<?php do_action( 'epl_contact_assigned_tags', $contact ); ?>
<?php do_action( 'epl_post_contact_quick_edit_options', $contact ); ?>
<div class="epl-info-wrapper epl-contact-section">
<div class="epl-item-info epl-contact-info">
<?php do_action( 'epl_contact_avatar', $contact ); ?>
<div class="epl-contact-edit-main-wrapper left">
<input type="hidden" id="epl_contact_id" value="<?php echo esc_attr( $contact->ID ); ?>"/>
<div class="epl-contact-info epl-meta-contact">
<?php do_action( 'epl_contact_meta_fields', $contact ); ?>
<?php
$contact_meta_fields = new EPL_FORM_BUILDER();
$contact_phones = $contact->get_meta( 'contact_phones' );
$contact_phones = array_filter( $contact_phones );
$contact_phone = isset( $contact_phones['phone'] ) ? $contact_phones['phone'] : '';
$contact_emails = (array) $contact->get_meta( 'contact_emails' );
$contact_emails = array_filter( $contact_emails );
$contact_email = isset( $contact_emails['email'] ) ? $contact_emails['email'] : '';
$fields = array(
array(
'class' => 'col-1 epl-inner-div',
'id' => 'epl-contact-basic-details',
'fields' => apply_filters(
'epl_contact_basic_fields',
array(
array(
'name' => 'contact_first_name',
'type' => 'text',
'maxlength' => '60',
'value' => $contact->get_meta( 'contact_first_name' ),
),
array(
'name' => 'contact_last_name',
'type' => 'text',
'maxlength' => '60',
'value' => $contact->get_meta( 'contact_last_name' ),
),
)
),
),
array(
'label' => '',
'class' => 'col-1 epl-inner-div',
'id' => 'epl-contact-professional-details',
'help' => esc_html__( 'Professional Details', 'easy-property-listings' ) . '<hr/>',
'fields' => apply_filters(
'epl_contact_professional_fields',
array(
array(
'name' => 'contact_title',
'label' => esc_html__( 'Title', 'easy-property-listings' ),
'type' => 'text',
'value' => $contact->get_meta( 'contact_title' ),
),
array(
'name' => 'contact_company',
'label' => esc_html__( 'Company', 'easy-property-listings' ),
'type' => 'text',
'value' => $contact->get_meta( 'contact_company' ),
),
)
),
),
array(
'label' => '',
'class' => 'col-1 epl-inner-div',
'id' => 'epl-contact-contact-details',
'help' => esc_html__( 'Contact Details', 'easy-property-listings' ) . '<hr/>',
'fields' => apply_filters(
'epl_contact_contact_fields',
array(
array(
'name' => 'contact_phones[phone]',
'label' => esc_html__( 'Phone', 'easy-property-listings' ),
'type' => 'text',
'class' => 'epl-contact-addable',
'maxlength' => '60',
'value' => $contact_phone,
),
array(
'name' => 'contact_emails[email]',
'label' => esc_html__( 'Email', 'easy-property-listings' ),
'type' => 'email',
'class' => 'epl-contact-addable-email',
'maxlength' => '60',
'value' => $contact_email,
),
array(
'name' => 'contact_website',
'label' => esc_html__( 'Website', 'easy-property-listings' ),
'type' => 'text',
'maxlength' => '60',
'value' => $contact->get_meta( 'contact_website' ),
),
),
$contact
),
),
array(
'label' => '',
'class' => 'col-1 epl-inner-div',
'id' => 'epl-contact-custom-details',
'help' => esc_html__( 'Custom Fields', 'easy-property-listings' ) . '<hr/>',
'fields' => apply_filters(
'epl_contact_custom_fields',
array(
array(
'name' => 'contact_referred_by',
'label' => esc_html__( 'Referred By', 'easy-property-listings' ),
'type' => 'text',
'maxlength' => '60',
'value' => $contact->get_meta( 'contact_referred_by' ),
),
array(
'name' => 'contact_custom_1',
'label' => esc_html__( 'Custom Field 1', 'easy-property-listings' ),
'type' => 'text',
'maxlength' => '60',
'value' => $contact->get_meta( 'contact_custom_1' ),
),
array(
'name' => 'contact_custom_2',
'label' => esc_html__( 'Custom Field 2', 'easy-property-listings' ),
'type' => 'text',
'maxlength' => '60',
'value' => $contact->get_meta( 'contact_custom_2' ),
),
)
),
),
array(
'label' => '',
'class' => 'col-1 epl-inner-div',
'id' => 'epl-contact-social-details',
'help' => esc_html__( 'Social Networks', 'easy-property-listings' ) . '<hr/>',
'fields' => apply_filters(
'epl_contact_social_fields',
array(
array(
'name' => 'contact_facebook',
'label' => esc_html__( 'Facebook', 'easy-property-listings' ),
'type' => 'text',
'maxlength' => '60',
'value' => $contact->get_meta( 'contact_facebook' ),
),
array(
'name' => 'contact_twitter',
'label' => esc_html__( 'Twitter', 'easy-property-listings' ),
'type' => 'text',
'maxlength' => '60',
'value' => $contact->get_meta( 'contact_twitter' ),
),
array(
'name' => 'contact_google_plus',
'label' => esc_html__( 'Google Plus', 'easy-property-listings' ),
'type' => 'text',
'maxlength' => '60',
'value' => $contact->get_meta( 'contact_google_plus' ),
),
array(
'name' => 'contact_linked_in',
'label' => esc_html__( 'Linked In', 'easy-property-listings' ),
'type' => 'text',
'maxlength' => '60',
'value' => $contact->get_meta( 'contact_linked_in' ),
),
)
),
),
array(
'label' => '',
'class' => 'col-1 epl-inner-div',
'id' => 'epl-contact-address-details',
'help' => esc_html__( 'Address', 'easy-property-listings' ) . '<hr/>',
'fields' => array(
array(
'name' => 'contact_street_number',
'label' => esc_html__( 'Street Number', 'easy-property-listings' ),
'type' => 'text',
'maxlength' => '200',
'value' => $contact->get_meta( 'contact_street_number' ),
),
array(
'name' => 'contact_street_name',
'label' => esc_html__( 'Street Name', 'easy-property-listings' ),
'type' => 'text',
'maxlength' => '200',
'value' => $contact->get_meta( 'contact_street_name' ),
),
array(
'name' => 'contact_suburb',
'label' => esc_html__( 'Suburb', 'easy-property-listings' ),
'type' => 'text',
'maxlength' => '200',
'value' => $contact->get_meta( 'contact_suburb' ),
),
array(
'name' => 'contact_state',
'label' => esc_html__( 'State', 'easy-property-listings' ),
'type' => 'text',
'maxlength' => '200',
'value' => $contact->get_meta( 'contact_state' ),
),
array(
'name' => 'contact_postcode',
'label' => esc_html__( 'Postcode', 'easy-property-listings' ),
'type' => 'text',
'maxlength' => '200',
'value' => $contact->get_meta( 'contact_postcode' ),
),
array(
'name' => 'contact_country',
'label' => esc_html__( 'Country', 'easy-property-listings' ),
'type' => 'text',
'maxlength' => '200',
'value' => $contact->get_meta( 'contact_country' ),
),
),
),
array(
'label' => '',
'class' => 'col-1 epl-inner-div',
'id' => 'epl-contact-wpuser-details',
'help' => esc_html__( 'Author', 'easy-property-listings' ) . '<hr/>',
'fields' => apply_filters(
'epl_contact_wpuser_info_fields',
array(
array(
'name' => 'contact_wp_user',
'id' => 'epl_contact_wp_user',
'type' => 'text',
'autocomplete' => 'off',
'value' => $contact->get_meta( 'contact_wp_user' ),
),
array(
'name' => 'contact_wp_user_id',
'id' => 'epl_contact_wp_user_id',
'type' => 'hidden',
'value' => $contact->get_meta( 'contact_wp_user_id' ),
),
)
),
),
array(
'label' => '',
'class' => 'col-1 epl-inner-div',
'id' => 'epl-contact-bginfo-details',
'help' => esc_html__( 'Background Info', 'easy-property-listings' ) . '<hr/>',
'fields' => apply_filters(
'epl_contact_background_info_fields',
array(
array(
'name' => 'post_content',
'type' => 'textarea',
'value' => $contact->background_info,
),
)
),
),
);
$contact_meta_fields->add_sections( $fields );
$contact_meta_fields->render_form();
?>
<span id="epl-contact-edit-actions">
<input type="hidden" name="contact_id" value="<?php echo esc_attr( $contact->ID ); ?>" />
<?php wp_nonce_field( 'meta-contact', '_wpnonce', false, true ); ?>
<input type="hidden" name="epl_action" value="meta-contact" />
<input type="submit" id="epl-meta-contact" class="button-primary" value="<?php esc_html_e( 'Update', 'easy-property-listings' ); ?>" />
</span>
</div>
</div>
</div>
</div>
</form>
<?php
}
function epl_contact_notes_view( $contact ) {
$paged = isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) ? absint( wp_unslash( $_GET['paged'] ) ) : 1;
$paged = absint( $paged );
$note_count = $contact->get_notes_count();
$per_page = apply_filters( 'epl_contact_notes_per_page', 20 );
$total_pages = ceil( $note_count / $per_page );
$contact_notes = $contact->get_notes( $per_page, $paged );
?>
<div id="epl-item-notes-wrapper">
<div class="epl-item-notes-header">
<?php echo wp_kses_post( get_avatar( $contact->email, 30 ) ); ?> <span><?php echo esc_attr( $contact->name ); ?></span>
</div>
<h3><?php esc_html_e( 'Notes', 'easy-property-listings' ); ?></h3>
<?php if ( 1 === $paged ) : ?>
<div style="display: block; margin-bottom: 35px;">
<form id="epl-add-contact-note" method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=epl-contacts&view=notes&id=' . $contact->ID ) ); ?>">
<textarea id="contact-note" name="contact_note" class="epl-contact-note-input" rows="10"></textarea>
<br />
<input type="hidden" id="epl-contact-id" name="contact_id" value="<?php echo esc_attr( $contact->ID ); ?>" />
<input type="hidden" name="epl_action" value="add-contact-note" />
<br />
<label class ="epl-contact-select-label" >
<select aria-label="<?php esc_attr_e( 'Select listing for note', 'easy-property-listings' ); ?>" class="epl-contact-note-select" id="contact-note-listing">
<option value=''><?php esc_html_e( 'Note for Listing', 'easy-property-listings' ); ?></option>
<?php
if ( ! empty( $contact->listing_ids ) ) {
foreach ( $contact->listing_ids as $listing_id ) {
echo '<option value="' . esc_attr( $listing_id ) . '">' . esc_html( get_the_title( $listing_id ) ) . '</option>';
}
}
?>
</select>
</label>
<label class ="epl-contact-select-label" >
<select aria-label="<?php esc_attr_e( 'Select label for note', 'easy-property-listings' ); ?>" class="epl-contact-note-select" id="contact-activity-type">
<?php
foreach ( $contact->get_activity_types() as $act_key => $act_name ) {
echo '<option value="' . esc_attr( $act_key ) . '">' . esc_html( $act_name ) . '</option>';
}
?>
</select>
</label>
<br />
<?php wp_nonce_field( 'add-contact-note', 'add_contact_note_nonce', true, true ); ?>
<input id="add-contact-note" class="right button-primary" type="submit" value="Add Note" />
</form>
</div>
<?php endif; ?>
<?php
$pagination_args = array(
'base' => '%_%',
'format' => '?paged=%#%',
'total' => $total_pages,
'current' => $paged,
'show_all' => true,
);
?>
<div id="epl-contact-notes">
<?php if ( count( $contact_notes ) > 0 ) : ?>
<?php foreach ( $contact_notes as $key => $note ) : ?>
<div class="epl-contact-note-wrapper dashboard-comment-wrap comment-item <?php echo esc_attr( $note->comment_type ); ?>" >
<span class="epl-note-content-meta">
<span class="epl-note-for-listing">
<?php
echo isset( $note->post_title ) ? esc_attr( $note->post_title ) : '';
?>
</span>
<span class="epl-note-time">
<?php
echo esc_attr( date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ) );
?>
</span>
</span>
<span class="epl-note-content-wrap">
<?php echo wp_kses_post( stripslashes( $note->comment_content ) ); ?>
</span>
</div>
<?php endforeach; ?>
<?php else : ?>
<div class="epl-no-contact-notes">
<?php esc_html_e( 'No Contact Notes', 'easy-property-listings' ); ?>
</div>
<?php endif; ?>
</div>
<div class="epl-note-pagination">
<?php
$paginated_links = paginate_links( $pagination_args );
if ( ! is_null( $paginated_links ) ) {
echo wp_kses_post( $paginated_links );
}
?>
</div>
</div>
<?php
}
function epl_contacts_delete_view( $contact ) {
$contact_edit_role = apply_filters( 'epl_edit_contacts_role', 'manage_options' );
?>
<?php do_action( 'epl_contact_delete_top', $contact ); ?>
<div class="epl-info-wrapper epl-contact-section">
<form id="epl-delete-contact-form" method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=epl-contacts&view=delete&id=' . $contact->ID ) ); ?>">
<div class="epl-item-notes-header">
<?php echo wp_kses_post( get_avatar( $contact->email, 30 ) ); ?> <span><?php echo esc_attr( $contact->name ); ?></span>
</div>
<div class="epl-contact-info epl-wrapper-delete-contact">
<span class="epl-delete-contact-options">
<p>
<input type="checkbox" class="epl-checkbox epl-contact-delete-confirm" id="epl-contact-delete-confirm" name="epl-contact-delete-confirm">
<label for="epl-contact-delete-confirm"><?php esc_html_e( 'Are you sure you want to delete this contact?', 'easy-property-listings' ); ?></label>
</p>
<?php do_action( 'epl_contact_delete_inputs', $contact ); ?>
</span>
<span id="epl-contact-edit-actions">
<input type="hidden" name="contact_id" value="<?php echo esc_attr( $contact->ID ); ?>" />
<?php wp_nonce_field( 'delete-contact', '_wpnonce', false, true ); ?>
<input type="hidden" name="epl_action" value="delete-contact" />
<input type="submit" disabled="disabled" id="epl-delete-contact" class="button-primary" value="<?php esc_html_e( 'Delete Contact', 'easy-property-listings' ); ?>" />
<a id="epl-delete-contact-cancel" href="<?php echo esc_attr( admin_url( 'admin.php?page=epl-contacts&view=overview&id=' . $contact->ID ) ); ?>" class="delete"><?php esc_html_e( 'Cancel', 'easy-property-listings' ); ?></a>
</span>
</div>
</form>
</div>
<?php
do_action( 'epl_contact_delete_bottom', $contact );
}
function epl_contacts_listing_view( $contact ) {
?>
<?php do_action( 'epl_contact_card_top', $contact ); ?>
<?php do_action( 'epl_pre_contact_quick_edit_options', $contact ); ?>
<?php do_action( 'epl_contact_action_menus', $contact ); ?>
<?php do_action( 'epl_contact_entry_header', $contact ); ?>
<?php do_action( 'epl_contact_assigned_tags', $contact ); ?>
<?php do_action( 'epl_post_contact_quick_edit_options', $contact ); ?>
<div class="epl-info-wrapper epl-contact-section epl-contact-single-display">
<input type="hidden" id="epl_contact_id" value="<?php echo esc_attr( $contact->ID ); ?>"/>
<div class="epl-item-info epl-contact-info">
<?php do_action( 'epl_contact_avatar', $contact ); ?>
<div class="epl-contact-id right">
<?php do_action( 'epl_contact_social_icons', $contact ); ?>
</div>
<div class="epl-contact-main-wrapper left">
<?php do_action( 'epl_contact_contact_details', $contact ); ?>
</div>
</div>
</div>
<?php do_action( 'epl_contact_before_tables_wrapper', $contact ); ?>
<div id="epl-item-tables-wrapper" class="contact-tables-wrapper epl-contact-section">
<?php do_action( 'epl_contact_before_tables', $contact ); ?>
<?php do_action( 'epl_contact_recent_interests', $contact ); ?>
<?php do_action( 'epl_contact_after_tables', $contact ); ?>
</div>
<?php do_action( 'epl_contact_card_bottom', $contact ); ?>
<?php
}
function epl_add_contact_screen_options() {
global $epl_contacts_table;
$option = 'per_page';
$args = array(
'label' => esc_html__( 'Contacts', 'easy-property-listings' ),
'default' => 10,
'option' => 'contacts_per_page',
);
add_screen_option( $option, $args );
include_once dirname( __FILE__ ) . '/class-epl-contact-reports-table.php';
$epl_contacts_table = new EPL_Contact_Reports_Table();
}
function epl_contact_table_set_option( $status, $option, $value ) {
return $value;
}
function epl_add_contact_screen_opts() {
global $epl_contact_page_hook;
add_action( "load-$epl_contact_page_hook", 'epl_add_contact_screen_options' );
add_filter( 'set-screen-option', 'epl_contact_table_set_option', 10, 3 );
}
add_action( 'admin_menu', 'epl_add_contact_screen_opts', 99 );