| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | if ( ! defined( 'ABSPATH' ) ) { |
| 14: | exit; |
| 15: | } |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | function epl_edit_contact( $args ) { |
| 27: | if ( ! is_admin() || ! epl_contact_access() ) { |
| 28: | wp_die( esc_html__( 'You do not have permission to edit this contact.', 'easy-property-listings' ) ); |
| 29: | } |
| 30: | |
| 31: | if ( empty( $args ) ) { |
| 32: | return null; |
| 33: | } |
| 34: | |
| 35: | $contact_info = $args['contactinfo']; |
| 36: | $contact_id = (int) $args['contactinfo']['id']; |
| 37: | $nonce = $args['_wpnonce']; |
| 38: | |
| 39: | if ( ! wp_verify_nonce( $nonce, 'edit-contact' ) ) { |
| 40: | wp_die( esc_html__( 'Cheatin\' eh?!', 'easy-property-listings' ) ); |
| 41: | } |
| 42: | |
| 43: | $contact = new EPL_Contact( $contact_id ); |
| 44: | if ( empty( $contact->ID ) ) { |
| 45: | return false; |
| 46: | } |
| 47: | |
| 48: | $defaults = array( |
| 49: | 'name' => '', |
| 50: | 'email' => '', |
| 51: | 'user_id' => 0, |
| 52: | ); |
| 53: | |
| 54: | $contact_info = wp_parse_args( $contact_info, $defaults ); |
| 55: | |
| 56: | if ( ! is_email( $contact_info['email'] ) ) { |
| 57: | epl_set_error( 'epl-invalid-email', esc_html__( 'Please enter a valid email address.', 'easy-property-listings' ) ); |
| 58: | } |
| 59: | |
| 60: | if ( epl_get_errors() ) { |
| 61: | return null; |
| 62: | } |
| 63: | |
| 64: | |
| 65: | $contact_data = array(); |
| 66: | $contact_data['name'] = wp_strip_all_tags( stripslashes( $contact_info['name'] ) ); |
| 67: | $contact_data['email'] = $contact_info['email']; |
| 68: | |
| 69: | $contact_data = apply_filters( 'epl_edit_contact_info', $contact_data, $contact_id ); |
| 70: | |
| 71: | $contact_data = array_map( 'sanitize_text_field', $contact_data ); |
| 72: | |
| 73: | do_action( 'epl_pre_edit_contact', $contact_id, $contact_data ); |
| 74: | |
| 75: | $output = array(); |
| 76: | |
| 77: | if ( $contact->update( $contact_data ) ) { |
| 78: | |
| 79: | $output['success'] = true; |
| 80: | $output['contact_info'] = $contact_data; |
| 81: | |
| 82: | } else { |
| 83: | |
| 84: | $output['success'] = false; |
| 85: | |
| 86: | } |
| 87: | |
| 88: | do_action( 'epl_post_edit_contact', $contact_id, $contact_data ); |
| 89: | |
| 90: | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
| 91: | header( 'Content-Type: application/json' ); |
| 92: | echo wp_json_encode( $output ); |
| 93: | wp_die(); |
| 94: | } |
| 95: | |
| 96: | return $output; |
| 97: | } |
| 98: | add_action( 'epl_edit-contact', 'epl_edit_contact', 10, 1 ); |
| 99: | |
| 100: | |
| 101: | |
| 102: | |
| 103: | |
| 104: | |
| 105: | |
| 106: | |
| 107: | |
| 108: | |
| 109: | function epl_contact_delete( $args ) { |
| 110: | |
| 111: | if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) { |
| 112: | wp_die( esc_html__( 'You do not have permission to delete this contact.', 'easy-property-listings' ) ); |
| 113: | } |
| 114: | |
| 115: | if ( empty( $args ) ) { |
| 116: | return; |
| 117: | } |
| 118: | |
| 119: | $contact_id = (int) $args['contact_id']; |
| 120: | $confirm = ! empty( $args['epl-contact-delete-confirm'] ) ? true : false; |
| 121: | $nonce = $args['_wpnonce']; |
| 122: | |
| 123: | if ( ! wp_verify_nonce( $nonce, 'delete-contact' ) ) { |
| 124: | wp_die( esc_html__( 'Cheatin\' eh?!', 'easy-property-listings' ) ); |
| 125: | } |
| 126: | |
| 127: | if ( ! $confirm ) { |
| 128: | epl_set_error( 'contact-delete-no-confirm', esc_html__( 'Please confirm you want to delete this contact', 'easy-property-listings' ) ); |
| 129: | } |
| 130: | |
| 131: | if ( epl_get_errors() ) { |
| 132: | wp_safe_redirect( admin_url( 'admin.php?page=epl-contacts&view=overview&id=' . $contact_id ) ); |
| 133: | exit; |
| 134: | } |
| 135: | |
| 136: | $contact = new EPL_Contact( $contact_id ); |
| 137: | |
| 138: | do_action( 'epl_pre_delete_contact', $contact_id, $confirm ); |
| 139: | |
| 140: | $success = false; |
| 141: | |
| 142: | if ( $contact->ID > 0 ) { |
| 143: | |
| 144: | $listings_array = $contact->listing_ids; |
| 145: | |
| 146: | |
| 147: | if ( ! empty( $listings_array ) ) { |
| 148: | foreach ( $listings_array as $listing_id ) { |
| 149: | $contact->remove_listing( $listing_id ); |
| 150: | } |
| 151: | } |
| 152: | |
| 153: | $success = $contact->delete(); |
| 154: | |
| 155: | if ( $success ) { |
| 156: | |
| 157: | $redirect = admin_url( 'admin.php?page=epl-contacts&epl-message=contact-deleted' ); |
| 158: | |
| 159: | } else { |
| 160: | |
| 161: | epl_set_error( 'epl-contact-delete-failed', esc_html__( 'Error deleting contact', 'easy-property-listings' ) ); |
| 162: | $redirect = admin_url( 'admin.php?page=epl-contacts&view=delete&id=' . $contact_id ); |
| 163: | |
| 164: | } |
| 165: | } else { |
| 166: | |
| 167: | epl_set_error( 'epl-contact-delete-invalid-id', esc_html__( 'Invalid Contact ID', 'easy-property-listings' ) ); |
| 168: | $redirect = admin_url( 'admin.php?page=epl-contacts' ); |
| 169: | |
| 170: | } |
| 171: | |
| 172: | wp_safe_redirect( $redirect ); |
| 173: | exit; |
| 174: | } |
| 175: | add_action( 'epl_delete-contact', 'epl_contact_delete', 10, 1 ); |
| 176: | |
| 177: | |
| 178: | |
| 179: | |
| 180: | |
| 181: | |
| 182: | |
| 183: | |
| 184: | |
| 185: | function epl_contact_save_note( $args ) { |
| 186: | |
| 187: | if ( ! is_admin() || ! epl_contact_access() ) { |
| 188: | wp_die( esc_html__( 'You do not have permission to save note.', 'easy-property-listings' ) ); |
| 189: | } |
| 190: | |
| 191: | if ( empty( $args ) ) { |
| 192: | return; |
| 193: | } |
| 194: | |
| 195: | $contact_note = trim( sanitize_text_field( $args['contact_note'] ) ); |
| 196: | $listing_id = trim( sanitize_text_field( $args['listing_id'] ) ); |
| 197: | $note_type = trim( sanitize_text_field( $args['note_type'] ) ); |
| 198: | |
| 199: | $contact_id = (int) $args['contact_id']; |
| 200: | $nonce = $args['add_contact_note_nonce']; |
| 201: | |
| 202: | if ( ! wp_verify_nonce( $nonce, 'add_contact_note_nonce' ) ) { |
| 203: | wp_die( esc_html__( 'Cheatin\' eh?!', 'easy-property-listings' ) ); |
| 204: | } |
| 205: | |
| 206: | if ( empty( $contact_note ) ) { |
| 207: | epl_set_error( 'empty-customer-note', esc_html__( 'A note is required', 'easy-property-listings' ) ); |
| 208: | } |
| 209: | |
| 210: | if ( epl_get_errors() ) { |
| 211: | return; |
| 212: | } |
| 213: | |
| 214: | do_action( 'epl_pre_insert_contact_note', $contact_id, $note_type, $listing_id, $note_type ); |
| 215: | |
| 216: | $contact = new EPL_Contact( $contact_id ); |
| 217: | $note_object = $contact->add_note( $contact_note, $note_type, $listing_id ); |
| 218: | |
| 219: | if ( ! empty( $note_object ) && ! empty( $contact->ID ) ) { |
| 220: | |
| 221: | ob_start(); |
| 222: | ?> |
| 223: | <tr data-activity-id="<?php echo esc_attr( $note_object->comment_ID ); ?>" id="activity-id-<?php echo esc_attr( $note_object->comment_ID ); ?>" class="epl-contact-activity-row epl-contact-activity-<?php echo esc_attr( $note_object->comment_type ); ?>" > |
| 224: | <td><?php echo esc_attr( $contact->get_activity_type( $note_object->comment_type ) ); ?></td> |
| 225: | <td> |
| 226: | <?php |
| 227: | if ( $note_object->comment_post_ID > 0 ) { |
| 228: | echo '<div class="epl-contact-inline-lis-details">'; |
| 229: | echo '<span class="epl-contact-inline-lis-img">'; |
| 230: | echo get_the_post_thumbnail( $note_object->comment_post_ID, array( 50, 50 ) ); |
| 231: | echo '</span>'; |
| 232: | echo '<span class="epl-contact-inline-lis-title">'; |
| 233: | echo '<a href="' . esc_url( get_permalink( $note_object->comment_post_ID ) ) . '">' . esc_attr( get_the_title( $note_object->comment_post_ID ) ) . '</a>'; |
| 234: | echo '</span>'; |
| 235: | echo '</div>'; |
| 236: | } |
| 237: | echo wp_kses_post( $note_object->comment_content ); |
| 238: | ?> |
| 239: | </td> |
| 240: | <td> |
| 241: | <?php |
| 242: | echo esc_html( date_i18n( get_option( 'date_format' ), strtotime( $note_object->comment_date ) ) ); |
| 243: | ?> |
| 244: | </td> |
| 245: | </tr> |
| 246: | <?php |
| 247: | $output = ob_get_contents(); |
| 248: | ob_end_clean(); |
| 249: | |
| 250: | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
| 251: | echo wp_kses_post( $output ); |
| 252: | exit; |
| 253: | } |
| 254: | |
| 255: | return $note_object; |
| 256: | |
| 257: | } |
| 258: | |
| 259: | return false; |
| 260: | } |
| 261: | add_action( 'epl_add-contact-note', 'epl_contact_save_note', 10, 1 ); |
| 262: | |
| 263: | |
| 264: | |
| 265: | |
| 266: | |
| 267: | |
| 268: | |
| 269: | |
| 270: | |
| 271: | |
| 272: | function epl_contact_save_listing( $args ) { |
| 273: | $contact_add_listing_role = apply_filters( 'epl_add_contacts_listing', 'manage_options' ); |
| 274: | |
| 275: | if ( ! is_admin() || ! current_user_can( $contact_add_listing_role ) ) { |
| 276: | wp_die( esc_html__( 'You do not have permission to add listing.', 'easy-property-listings' ) ); |
| 277: | } |
| 278: | |
| 279: | if ( empty( $args ) ) { |
| 280: | return null; |
| 281: | } |
| 282: | |
| 283: | $post_fields = array( 'post_title', 'post_type' ); |
| 284: | |
| 285: | $ignore_fields = array( 'add_contact_listing_nonce', 'epl_actiion', 'contact_id' ); |
| 286: | |
| 287: | $nonce = $args['add_contact_listing_nonce']; |
| 288: | |
| 289: | if ( ! wp_verify_nonce( $nonce, 'add_contact_listing_nonce' ) ) { |
| 290: | wp_die( esc_html__( 'Cheatin\' eh?!', 'easy-property-listings' ) ); |
| 291: | } |
| 292: | if ( epl_get_errors() ) { |
| 293: | epl_print_errors(); |
| 294: | return null; |
| 295: | } |
| 296: | |
| 297: | do_action( 'epl_pre_insert_contact_listing', $args ); |
| 298: | if ( $args['property_owner'] > 0 ) { |
| 299: | $insert_post_array = array( 'post_status' => 'publish' ); |
| 300: | $insert_meta_array = array(); |
| 301: | foreach ( $args as $arg_key => $arg_value ) { |
| 302: | if ( in_array( $arg_key, $post_fields, true ) ) { |
| 303: | $insert_post_array[ $arg_key ] = $arg_value; |
| 304: | } elseif ( ! in_array( $arg_key, $ignore_fields, true ) ) { |
| 305: | $insert_meta_array[ $arg_key ] = $arg_value; |
| 306: | } |
| 307: | } |
| 308: | $insert_id = wp_insert_post( $insert_post_array ); |
| 309: | if ( $insert_id ) { |
| 310: | foreach ( $insert_meta_array as $meta_key => $meta_value ) { |
| 311: | update_post_meta( $insert_id, $meta_key, $meta_value ); |
| 312: | } |
| 313: | } else { |
| 314: | return false; |
| 315: | } |
| 316: | } |
| 317: | $inserted_lisitng = get_post( $insert_id ); |
| 318: | if ( ! empty( $inserted_lisitng ) ) { |
| 319: | |
| 320: | ob_start(); |
| 321: | ?> |
| 322: | <tr data-activity-id="<?php echo esc_attr( $inserted_lisitng->ID ); ?>" id="activity-id-<?php echo esc_attr( $inserted_lisitng->ID ); ?>" class="epl-contact-activity-row " > |
| 323: | <td><?php echo esc_attr( $inserted_lisitng->post_type ); ?></td> |
| 324: | <td> |
| 325: | <?php |
| 326: | echo '<a href="' . esc_url( get_edit_post_link( $inserted_lisitng->ID ) ) . '">' . esc_attr( $inserted_lisitng->post_title ) . '</a>'; |
| 327: | ?> |
| 328: | </td> |
| 329: | <td> |
| 330: | <?php echo esc_attr( get_post_meta( $inserted_lisitng->ID, 'property_status', true ) ); ?> |
| 331: | </td> |
| 332: | </tr> |
| 333: | <?php |
| 334: | $output = ob_get_contents(); |
| 335: | ob_end_clean(); |
| 336: | |
| 337: | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
| 338: | echo wp_kses_post( $output ); |
| 339: | exit; |
| 340: | } |
| 341: | |
| 342: | return $inserted_lisitng; |
| 343: | |
| 344: | } |
| 345: | |
| 346: | return false; |
| 347: | } |
| 348: | add_action( 'epl_add-contact-listing', 'epl_contact_save_listing', 10, 1 ); |
| 349: | |
| 350: | |
| 351: | |
| 352: | |
| 353: | |
| 354: | |
| 355: | |
| 356: | |
| 357: | function epl_contact_assign_existing_listing( $args ) { |
| 358: | |
| 359: | if ( ! is_admin() || ! epl_contact_access() ) { |
| 360: | wp_die( esc_html__( 'You do not have permission to assign listings.', 'easy-property-listings' ) ); |
| 361: | } |
| 362: | |
| 363: | if ( empty( $args ) ) { |
| 364: | return null; |
| 365: | } |
| 366: | |
| 367: | do_action( 'epl_pre_assign_contact_listing', $args ); |
| 368: | if ( $args['contact_id'] > 0 && $args['id'] > 0 ) { |
| 369: | update_post_meta( $args['id'], 'property_owner', $args['contact_id'] ); |
| 370: | |
| 371: | } else { |
| 372: | wp_die(); |
| 373: | } |
| 374: | $inserted_lisitng = get_post( $args['id'] ); |
| 375: | if ( ! empty( $inserted_lisitng ) ) { |
| 376: | |
| 377: | ob_start(); |
| 378: | ?> |
| 379: | <tr data-activity-id="<?php echo esc_attr( $inserted_lisitng->ID ); ?>" id="activity-id-<?php echo esc_attr( $inserted_lisitng->ID ); ?>" class="epl-contact-activity-row " > |
| 380: | <td><?php echo esc_attr( $inserted_lisitng->post_type ); ?></td> |
| 381: | <td> |
| 382: | <?php |
| 383: | echo '<a href="' . esc_url( get_edit_post_link( $inserted_lisitng->ID ) ) . '">' . esc_attr( $inserted_lisitng->post_title ) . '</a>'; |
| 384: | ?> |
| 385: | </td> |
| 386: | <td> |
| 387: | <?php echo esc_attr( get_post_meta( $inserted_lisitng->ID, 'property_status', true ) ); ?> |
| 388: | </td> |
| 389: | </tr> |
| 390: | <?php |
| 391: | $output = ob_get_contents(); |
| 392: | ob_end_clean(); |
| 393: | |
| 394: | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
| 395: | echo wp_kses_post( $output ); |
| 396: | exit; |
| 397: | } |
| 398: | |
| 399: | return $inserted_lisitng; |
| 400: | |
| 401: | } |
| 402: | |
| 403: | return false; |
| 404: | } |
| 405: | add_action( 'epl_add-existing-contact-listing', 'epl_contact_assign_existing_listing', 10, 1 ); |
| 406: | |
| 407: | |
| 408: | |
| 409: | |
| 410: | |
| 411: | |
| 412: | |
| 413: | |
| 414: | function epl_meta_contact( $args ) { |
| 415: | |
| 416: | if ( ! is_admin() || ! epl_contact_access() ) { |
| 417: | wp_die( esc_html__( 'You do not have permission to update this contact.', 'easy-property-listings' ) ); |
| 418: | } |
| 419: | |
| 420: | if ( empty( $args ) ) { |
| 421: | return; |
| 422: | } |
| 423: | |
| 424: | $nonce = $args['_wpnonce']; |
| 425: | if ( ! wp_verify_nonce( $nonce, 'meta-contact' ) ) { |
| 426: | wp_die( esc_html__( 'Cheatin\' eh?!', 'easy-property-listings' ) ); |
| 427: | } |
| 428: | |
| 429: | $contact_id = (int) $args['contact_id']; |
| 430: | $contact = new EPL_Contact( $contact_id ); |
| 431: | if ( empty( $contact->ID ) ) { |
| 432: | return false; |
| 433: | } |
| 434: | |
| 435: | $not_meta_fields = array( 'epl_form_builder_form_submit', 'contact_id', '_wpnonce', 'epl_action' ); |
| 436: | |
| 437: | $post_fields = array( 'post_title', 'post_content', 'ID', 'post_author' ); |
| 438: | |
| 439: | $field_updates = array( 'ID' => $contact_id ); |
| 440: | foreach ( $args as $key => $value ) { |
| 441: | if ( ! in_array( $key, $not_meta_fields, true ) ) { |
| 442: | |
| 443: | |
| 444: | if ( in_array( $key, $post_fields, true ) ) { |
| 445: | $field_updates[ $key ] = $value; |
| 446: | } else { |
| 447: | if ( is_array( $value ) ) { |
| 448: | $value = array_map( 'sanitize_text_field', $value ); |
| 449: | } else { |
| 450: | $value = sanitize_text_field( $value ); |
| 451: | } |
| 452: | $contact->update_meta( $key, $value ); |
| 453: | } |
| 454: | } |
| 455: | } |
| 456: | wp_update_post( $field_updates ); |
| 457: | |
| 458: | $redirect = admin_url( 'admin.php?page=epl-contacts&view=meta&id=' . $contact_id ); |
| 459: | wp_safe_redirect( $redirect ); |
| 460: | exit; |
| 461: | } |
| 462: | add_action( 'epl_meta-contact', 'epl_meta_contact', 10, 1 ); |
| 463: | |
| 464: | |
| 465: | |
| 466: | |
| 467: | |
| 468: | |
| 469: | |
| 470: | |
| 471: | |
| 472: | |
| 473: | |
| 474: | function epl_new_contact( $args ) { |
| 475: | |
| 476: | $args = array_map( 'sanitize_text_field', $args ); |
| 477: | |
| 478: | if ( ! is_admin() || ! epl_contact_access() ) { |
| 479: | wp_die( esc_html__( 'You do not have permission to create contacts.', 'easy-property-listings' ) ); |
| 480: | } |
| 481: | |
| 482: | if ( empty( $args ) ) { |
| 483: | return; |
| 484: | } |
| 485: | |
| 486: | $nonce = isset( $args['_wpnonce'] ) ? sanitize_text_field( $args['_wpnonce'] ) : ''; |
| 487: | if ( ! wp_verify_nonce( $nonce, 'new-contact' ) ) { |
| 488: | wp_die( esc_html__( 'Cheatin\' uhh?!', 'easy-property-listings' ) ); |
| 489: | } |
| 490: | |
| 491: | $contact_id = isset( $args['contact_id'] ) ? (int) $args['contact_id'] : 0; |
| 492: | $contact = new EPL_Contact( $contact_id ); |
| 493: | if ( empty( $contact->ID ) ) { |
| 494: | return false; |
| 495: | } |
| 496: | |
| 497: | $email = isset( $args['email'] ) ? sanitize_email( $args['email'] ) : ''; |
| 498: | if ( empty( $email ) || ! is_email( $email ) ) { |
| 499: | wp_die( esc_html__( 'Please provide valid email address', 'easy-property-listings' ) ); |
| 500: | } |
| 501: | |
| 502: | if ( $contact->contact_exists( $email ) ) { |
| 503: | wp_die( esc_html__( 'A contact with this email already exists !', 'easy-property-listings' ) ); |
| 504: | } |
| 505: | |
| 506: | $first_name = isset( $args['first_name'] ) ? sanitize_text_field( $args['first_name'] ) : ''; |
| 507: | $last_name = isset( $args['last_name'] ) ? sanitize_text_field( $args['last_name'] ) : ''; |
| 508: | $title = isset( $args['title'] ) ? sanitize_text_field( $args['title'] ) : ''; |
| 509: | |
| 510: | if ( empty( $title ) && ( ! empty( $first_name ) || ! empty( $last_name ) ) ) { |
| 511: | $title = $first_name . ' ' . $last_name; |
| 512: | } |
| 513: | |
| 514: | if ( empty( $title ) && ( ! empty( $email ) ) ) { |
| 515: | $title = $email; |
| 516: | } |
| 517: | |
| 518: | $contact->update( |
| 519: | array( |
| 520: | 'name' => esc_html( $title ), |
| 521: | 'email' => esc_html( $email ), |
| 522: | ) |
| 523: | ); |
| 524: | $contact->update_meta( 'contact_first_name', $first_name ); |
| 525: | $contact->update_meta( 'contact_last_name', $last_name ); |
| 526: | $contact->update_meta( 'contact_phones', array( 'phone' => sanitize_text_field( $args['phone'] ) ) ); |
| 527: | $contact->update_meta( 'contact_category', 'new' ); |
| 528: | |
| 529: | $redirect = admin_url( 'admin.php?page=epl-contacts&view=meta&id=' . esc_attr( $contact_id ) ); |
| 530: | wp_safe_redirect( $redirect ); |
| 531: | exit; |
| 532: | } |
| 533: | add_action( 'epl_new-contact', 'epl_new_contact', 10, 1 ); |
| 534: | |
| 535: | |
| 536: | |
| 537: | |
| 538: | |
| 539: | |
| 540: | |
| 541: | function epl_contact_category_update() { |
| 542: | |
| 543: | check_ajax_referer( 'epl_ajax_nonce', '_epl_nonce' ); |
| 544: | |
| 545: | if ( ! epl_contact_access() ) { |
| 546: | wp_die( 'Unauthorized' ); |
| 547: | } |
| 548: | |
| 549: | if ( ! empty( $_POST['contact_id'] ) && (int) $_POST['contact_id'] > 0 && ! empty( $_POST['type'] ) ) { |
| 550: | |
| 551: | $contact = new EPL_Contact( sanitize_text_field( wp_unslash( $_POST['contact_id'] ) ) ); |
| 552: | $status = $contact->update_meta( 'contact_category', trim( sanitize_text_field( wp_unslash( $_POST['type'] ) ) ) ); |
| 553: | echo esc_attr( $status ); |
| 554: | wp_die(); |
| 555: | } |
| 556: | } |
| 557: | add_action( 'wp_ajax_epl_contact_category_update', 'epl_contact_category_update' ); |
| 558: | |
| 559: | |
| 560: | |
| 561: | |
| 562: | |
| 563: | |
| 564: | |
| 565: | function epl_contact_tag_add() { |
| 566: | |
| 567: | check_ajax_referer( 'epl_ajax_nonce', '_epl_nonce' ); |
| 568: | |
| 569: | if ( ! epl_contact_access() ) { |
| 570: | wp_die( 'Unauthorized' ); |
| 571: | } |
| 572: | |
| 573: | if ( ( ! empty( $_POST['term_id'] ) ) ) { |
| 574: | |
| 575: | $term_id = sanitize_text_field( wp_unslash( $_POST['term_id'] ) ); |
| 576: | |
| 577: | if ( is_numeric( $term_id ) ) { |
| 578: | $term_id = (int) $term_id; |
| 579: | } |
| 580: | |
| 581: | |
| 582: | if ( isset( $_POST['contact_id'] ) && (int) $_POST['contact_id'] > 0 ) { |
| 583: | $terms = wp_set_object_terms( absint( wp_unslash( $_POST['contact_id'] ) ), $term_id, 'epl_contact_tag', true ); |
| 584: | wp_die( esc_attr( current( $terms ) ) ); |
| 585: | } else { |
| 586: | |
| 587: | if ( ! empty( $_POST['bg'] ) ) { |
| 588: | epl_update_contact_tag_bgcolor( $term_id, sanitize_text_field( wp_unslash( $_POST['bg'] ) ) ); |
| 589: | } |
| 590: | |
| 591: | if ( ! empty( $_POST['label'] ) ) { |
| 592: | wp_update_term( $term_id, 'epl_contact_tag', array( 'name' => sanitize_text_field( wp_unslash( $_POST['label'] ) ) ) ); |
| 593: | } |
| 594: | |
| 595: | if ( ! empty( $_POST['delete'] ) ) { |
| 596: | wp_delete_term( $term_id, 'epl_contact_tag' ); |
| 597: | } |
| 598: | |
| 599: | wp_die( 1 ); |
| 600: | |
| 601: | } |
| 602: | } |
| 603: | } |
| 604: | add_action( 'wp_ajax_contact_tags_update', 'epl_contact_tag_add' ); |
| 605: | |
| 606: | |
| 607: | |
| 608: | |
| 609: | |
| 610: | |
| 611: | |
| 612: | function epl_contact_tag_remove() { |
| 613: | |
| 614: | check_ajax_referer( 'epl_ajax_nonce', '_epl_nonce' ); |
| 615: | |
| 616: | if ( ! epl_contact_access() ) { |
| 617: | wp_die( 'Unauthorized' ); |
| 618: | } |
| 619: | |
| 620: | if ( ! empty( $_POST['term_id'] ) && ! empty( $_POST['contact_id'] ) && (int) $_POST['contact_id'] > 0 && (int) $_POST['term_id'] > 0 ) { |
| 621: | |
| 622: | wp_remove_object_terms( absint( wp_unslash( $_POST['contact_id'] ) ), absint( wp_unslash( $_POST['term_id'] ) ), 'epl_contact_tag' ); |
| 623: | wp_die( 1 ); |
| 624: | } |
| 625: | } |
| 626: | add_action( 'wp_ajax_epl_contact_tag_remove', 'epl_contact_tag_remove' ); |
| 627: | |
| 628: | |
| 629: | |
| 630: | |
| 631: | |
| 632: | |
| 633: | |
| 634: | function epl_contact_action_menus( $contact ) { |
| 635: | ?> |
| 636: | <div class="contact-action-menu epl-clearfix"> |
| 637: | <ul class="epl_contact_quick_actions"> |
| 638: | <li> |
| 639: | <a class="contact-action-category" href="#" title="<?php esc_html_e( 'Contact Category', 'easy-property-listings' ); ?>"> |
| 640: | <span class="dashicons dashicons-flag"></span> |
| 641: | <b class="caret"></b> |
| 642: | </a> |
| 643: | <ul class="epl-contact_category_suggestions"> |
| 644: | <?php |
| 645: | |
| 646: | $cats = epl_get_contact_categories(); |
| 647: | |
| 648: | foreach ( $cats as $cat_key => $cat_label ) : |
| 649: | echo '<li> <a href="#" data-key="' . esc_attr( $cat_key ) . '" data-label="' . esc_attr( $cat_label ) . '">' . esc_attr( $cat_label ) . '</a></li>'; |
| 650: | endforeach; |
| 651: | ?> |
| 652: | </ul> |
| 653: | </li> |
| 654: | |
| 655: | <li> |
| 656: | <a class="contact-action-tag" href="#" title="<?php esc_html_e( 'Contact Tags', 'easy-property-listings' ); ?>"> |
| 657: | <span class="dashicons dashicons-tag"></span> |
| 658: | <b class="caret"></b> |
| 659: | </a> |
| 660: | <div class="epl-contact-tags-find"> |
| 661: | <input type="text" id="contact-tag-hint" value=""/> |
| 662: | <ul class="epl-contact_tags_suggestions"> |
| 663: | <?php |
| 664: | $contact_tags = get_terms( |
| 665: | array( |
| 666: | 'taxonomy' => 'epl_contact_tag', |
| 667: | 'hide_empty' => false, |
| 668: | ) |
| 669: | ); |
| 670: | if ( ! empty( $contact_tags ) ) { |
| 671: | |
| 672: | foreach ( $contact_tags as $contact_tag ) { |
| 673: | $bgcolor = epl_get_contact_tag_bgcolor( $contact_tag->term_id ); |
| 674: | |
| 675: | echo '<li data-bg="' . esc_attr( $bgcolor ) . '" style="background:' . esc_attr( $bgcolor ) . ';color:#fff" data-id="' . esc_attr( $contact_tag->term_id ) . '" >' . esc_attr( $contact_tag->name ) . '</li>'; |
| 676: | } |
| 677: | } |
| 678: | ?> |
| 679: | </ul> |
| 680: | </div> |
| 681: | </li> |
| 682: | <?php do_action( 'post_contact_custom_quick_edit_options', $contact ); ?> |
| 683: | </ul> |
| 684: | |
| 685: | <div class="epl_contact_pagination"> |
| 686: | <?php if ( epl_get_prev_contact_link( $contact->ID ) ) : ?> |
| 687: | <a class="epl_contact_pagination_prev " href="<?php echo esc_url( epl_get_prev_contact_link( $contact->ID ) ); ?>"> |
| 688: | <span class="dashicons dashicons-arrow-left"></span> |
| 689: | </a> |
| 690: | <?php endif; ?> |
| 691: | |
| 692: | <?php if ( epl_get_next_contact_link( $contact->ID ) ) : ?> |
| 693: | <a class="epl_contact_pagination_next " href="<?php echo esc_url( epl_get_next_contact_link( $contact->ID ) ); ?>"> |
| 694: | <span class="dashicons dashicons-arrow-right"> |
| 695: | </span> |
| 696: | </a> |
| 697: | <?php endif; ?> |
| 698: | </div> |
| 699: | </div> |
| 700: | <?php |
| 701: | } |
| 702: | add_action( 'epl_contact_action_menus', 'epl_contact_action_menus' ); |
| 703: | |
| 704: | |
| 705: | |
| 706: | |
| 707: | |
| 708: | |
| 709: | |
| 710: | function epl_contact_entry_header( $contact ) { |
| 711: | ?> |
| 712: | <div class="epl-contact-entry-header"> |
| 713: | <h1 class="epl-contact-title"> |
| 714: | <?php echo esc_html( $contact->heading ); ?> |
| 715: | </h1> |
| 716: | <span> |
| 717: | <?php echo esc_html( $contact->get_category_label() ); ?> |
| 718: | </span> |
| 719: | </div> |
| 720: | <?php |
| 721: | } |
| 722: | add_action( 'epl_contact_entry_header', 'epl_contact_entry_header' ); |
| 723: | |
| 724: | |
| 725: | |
| 726: | |
| 727: | |
| 728: | |
| 729: | |
| 730: | function epl_contact_entry_header_editable( $contact ) { |
| 731: | ?> |
| 732: | <div class="epl-contact-entry-header"> |
| 733: | <input class="epl-contact-title-editable" type="text" name="post_title" value="<?php echo esc_attr( $contact->heading ); ?>"/> |
| 734: | <span> |
| 735: | <?php echo esc_html( $contact->get_meta( 'contact_category' ) ); ?> |
| 736: | </span> |
| 737: | </div> |
| 738: | <?php |
| 739: | } |
| 740: | add_action( 'epl_contact_entry_header_editable', 'epl_contact_entry_header_editable' ); |
| 741: | |
| 742: | |
| 743: | |
| 744: | |
| 745: | |
| 746: | |
| 747: | |
| 748: | function epl_contact_assigned_tags( $contact ) { |
| 749: | ?> |
| 750: | <div class="epl-contact-assigned-tags-wrap"> |
| 751: | <ul class="epl-contact-assigned-tags"> |
| 752: | <?php |
| 753: | $contact_tags = wp_get_object_terms( $contact->ID, 'epl_contact_tag' ); |
| 754: | if ( ! empty( $contact_tags ) ) { |
| 755: | if ( ! is_wp_error( $contact_tags ) ) { |
| 756: | foreach ( $contact_tags as $term ) { |
| 757: | $bgcolor = epl_get_contact_tag_bgcolor( $term->term_id ); |
| 758: | echo '<li data-id="' . esc_attr( $term->term_id ) . '" id="contact-tag-' . esc_attr( $term->term_id ) . '" style="background:' . esc_attr( $bgcolor ) . '">' . esc_html( $term->name ) . '<span class="dashicons dashicons-no epl-contact-tag-del"></span></li>'; |
| 759: | } |
| 760: | } |
| 761: | } |
| 762: | ?> |
| 763: | </ul> |
| 764: | </div> |
| 765: | <?php |
| 766: | } |
| 767: | add_action( 'epl_contact_assigned_tags', 'epl_contact_assigned_tags' ); |
| 768: | |
| 769: | |
| 770: | |
| 771: | |
| 772: | |
| 773: | |
| 774: | |
| 775: | function epl_contact_background_info( $contact ) { |
| 776: | echo '<div class="epl-contact-bg-info-wrap">'; |
| 777: | echo '<h4>' . esc_html__( 'Background Info', 'easy-property-listings' ) . '</h4>'; |
| 778: | echo '<div class="epl-contact-bg-info">'; |
| 779: | echo wp_kses_post( $contact->background_info ); |
| 780: | echo '</div>'; |
| 781: | |
| 782: | echo '</div>'; |
| 783: | } |
| 784: | add_action( 'epl_contact_background_info', 'epl_contact_background_info' ); |
| 785: | |
| 786: | |
| 787: | |
| 788: | |
| 789: | |
| 790: | |
| 791: | |
| 792: | function epl_contact_avatar( $contact ) { |
| 793: | ?> |
| 794: | <div class="avatar-wrap left" id="contact-avatar"> |
| 795: | <?php echo wp_kses_post( get_avatar( $contact->email, apply_filters( 'epl_contact_gravatar_size', 160 ) ) ); ?> |
| 796: | <br /> |
| 797: | </div> |
| 798: | <?php |
| 799: | } |
| 800: | add_action( 'epl_contact_avatar', 'epl_contact_avatar' ); |
| 801: | |
| 802: | |
| 803: | |
| 804: | |
| 805: | |
| 806: | |
| 807: | |
| 808: | function epl_contact_social_icons( $contact ) { |
| 809: | |
| 810: | $fb = $contact->get_meta( 'contact_facebook' ); |
| 811: | $twitter = $contact->get_meta( 'contact_twitter' ); |
| 812: | $gplus = $contact->get_meta( 'contact_google_plus' ); |
| 813: | $linked = $contact->get_meta( 'contact_linked_in' ); |
| 814: | ?> |
| 815: | |
| 816: | <?php if ( ! empty( $fb ) ) : ?> |
| 817: | <a href="<?php echo esc_url( $fb ); ?>"> |
| 818: | <span class="epl-contact-social-icon">f</span> |
| 819: | </a> |
| 820: | <?php endif; ?> |
| 821: | <?php if ( ! empty( $twitter ) ) : ?> |
| 822: | <a href="<?php echo esc_url( $twitter ); ?>"> |
| 823: | <span class="epl-contact-social-icon">t</span> |
| 824: | </a> |
| 825: | <?php endif; ?> |
| 826: | <?php if ( ! empty( $gplus ) ) : ?> |
| 827: | <a href="<?php echo esc_url( $gplus ); ?>"> |
| 828: | <span class="epl-contact-social-icon">g+</span> |
| 829: | </a> |
| 830: | <?php endif; ?> |
| 831: | <?php if ( ! empty( $linked ) ) : ?> |
| 832: | <a href="<?php echo esc_url( $linked ); ?>"> |
| 833: | <span class="epl-contact-social-icon">in</span> |
| 834: | </a> |
| 835: | <?php endif; ?> |
| 836: | <?php |
| 837: | do_action( 'epl_contact_more_social_icons', $contact ); |
| 838: | } |
| 839: | add_action( 'epl_contact_social_icons', 'epl_contact_social_icons' ); |
| 840: | |
| 841: | |
| 842: | |
| 843: | |
| 844: | |
| 845: | |
| 846: | |
| 847: | |
| 848: | |
| 849: | function epl_contact_contact_details( $contact ) { |
| 850: | ?> |
| 851: | |
| 852: | <span class="epl-contact-name epl-info-item editable"> |
| 853: | <span data-key="name"> |
| 854: | <span class="epl-contact-value"><?php echo esc_attr( $contact->get_meta( 'contact_first_name' ) . ' ' . $contact->get_meta( 'contact_last_name' ) ); ?></span> |
| 855: | </span> |
| 856: | </span> |
| 857: | <?php |
| 858: | $contact_emails = $contact->get_emails(); |
| 859: | if ( ! is_null( $contact_emails ) ) { |
| 860: | echo wp_kses_post( $contact_emails ); |
| 861: | } |
| 862: | |
| 863: | ?> |
| 864: | |
| 865: | <?php |
| 866: | $contact_phones = $contact->get_phones(); |
| 867: | if ( ! is_null( $contact_phones ) ) { |
| 868: | echo wp_kses_post( $contact_phones ); |
| 869: | } |
| 870: | $web = $contact->get_meta( 'contact_website' ); |
| 871: | $addr = $contact->epl_contact_get_address(); |
| 872: | ?> |
| 873: | |
| 874: | <?php if ( ! empty( $web ) ) : ?> |
| 875: | <span class="contact-website epl-info-item editable" data-key="website"> |
| 876: | <span class="dashicons dashicons-admin-site-alt3 epl-contact-icons"></span> |
| 877: | <span class="epl-contact-value"><?php echo esc_attr( $web ); ?></span> |
| 878: | </span> |
| 879: | <?php endif; ?> |
| 880: | <?php ?> |
| 881: | <?php if ( ! empty( $addr ) ) : ?> |
| 882: | <span class="contact-address epl-info-item editable" data-key="address"> |
| 883: | <span class="dashicons dashicons-admin-home epl-contact-icons"></span> |
| 884: | <span class="epl-contact-value"><?php echo esc_attr( $addr ); ?></span> |
| 885: | </span> |
| 886: | <?php endif; ?> |
| 887: | <span class="contact-since epl-info-item"> |
| 888: | <span class="dashicons dashicons-clock epl-contact-icons"></span> |
| 889: | <span class="epl-contact-value"><?php esc_html_e( 'Contact since', 'easy-property-listings' ); ?> |
| 890: | <?php echo esc_attr( date_i18n( get_option( 'date_format' ), strtotime( $contact->date_created ) ) ); ?></span> |
| 891: | </span> |
| 892: | <span class="epl-contact-view-more"> |
| 893: | <span class="dashicons dashicons-arrow-right-alt epl-contact-icons"></span> |
| 894: | <span class="epl-contact-value"><?php esc_html_e( 'View More', 'easy-property-listings' ); ?></span> |
| 895: | </span> |
| 896: | <?php |
| 897: | } |
| 898: | add_action( 'epl_contact_contact_details', 'epl_contact_contact_details' ); |
| 899: | |
| 900: | |
| 901: | |
| 902: | |
| 903: | |
| 904: | |
| 905: | |
| 906: | |
| 907: | |
| 908: | |
| 909: | |
| 910: | function epl_contact_recent_interests( $contact, $number = 10, $paged = 1, $orderby = 'post_date', $order = 'DESC' ) { |
| 911: | ?> |
| 912: | <?php do_action( 'epl_contact_add_listing_form', $contact ); ?> |
| 913: | <h3 class="epl-contact-activity-title"> |
| 914: | <?php esc_html_e( 'Listings', 'easy-property-listings' ); ?> |
| 915: | </h3> |
| 916: | <span class="epl-contact-add-old-listing-form-wrap"> |
| 917: | <input id="epl_contact_listing_search" type="text" placeholder="<?php esc_html_e( 'Search Listings', 'easy-property-listings' ); ?>"/> |
| 918: | </span> |
| 919: | <span class="epl-contact-or"><?php esc_html_e( 'Or', 'easy-property-listings' ); ?></span> |
| 920: | <span class="epl-contact-add-listing"><?php esc_html_e( 'Add New', 'easy-property-listings' ); ?></span> |
| 921: | |
| 922: | <input type="hidden" id="epl-listing-table-orderby" value="<?php echo esc_attr( $orderby ); ?>"/> |
| 923: | <input type="hidden" id="epl-listing-table-order" value="<?php echo esc_attr( $order ); ?>"> |
| 924: | <?php |
| 925: | epl_contact_get_listings_html( $contact, $number, $paged, $orderby, $order ); |
| 926: | } |
| 927: | add_action( 'epl_contact_recent_interests', 'epl_contact_recent_interests' ); |
| 928: | |
| 929: | |
| 930: | |
| 931: | |
| 932: | |
| 933: | |
| 934: | |
| 935: | |
| 936: | |
| 937: | |
| 938: | |
| 939: | function epl_contact_recent_activities( $contact, $number = 10, $paged = 1, $orderby = 'comment_date', $order = 'DESC' ) { |
| 940: | ?> |
| 941: | <?php do_action( 'epl_contact_add_activity_form', $contact ); ?> |
| 942: | <h3 class="epl-contact-activity-title"><?php esc_html_e( 'Activities', 'easy-property-listings' ); ?> </h3> |
| 943: | <span class="epl-contact-add-activity"><?php esc_html_e( 'Add New', 'easy-property-listings' ); ?></span> |
| 944: | <input type="hidden" id="epl-contact-table-orderby" value="<?php echo esc_attr( $orderby ); ?>"/> |
| 945: | <input type="hidden" id="epl-contact-table-order" value="<?php echo esc_attr( $order ); ?>"> |
| 946: | <?php |
| 947: | epl_contact_get_activities_html( $contact, $number, $paged, $orderby, $order ); |
| 948: | } |
| 949: | add_action( 'epl_contact_recent_activities', 'epl_contact_recent_activities' ); |
| 950: | |
| 951: | |
| 952: | |
| 953: | |
| 954: | |
| 955: | |
| 956: | |
| 957: | |
| 958: | |
| 959: | |
| 960: | |
| 961: | |
| 962: | function epl_contact_get_activities_html( $contact, $number = 10, $paged = 1, $orderby = 'comment_date', $order = 'DESC' ) { |
| 963: | |
| 964: | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
| 965: | |
| 966: | check_ajax_referer( 'epl_ajax_nonce', '_epl_nonce' ); |
| 967: | |
| 968: | if ( ! epl_contact_access() ) { |
| 969: | wp_die( 'Unauthorized' ); |
| 970: | } |
| 971: | |
| 972: | $contact = isset( $_POST['contact'] ) ? sanitize_text_field( wp_unslash( $_POST['contact'] ) ) : ''; |
| 973: | $number = isset( $_POST['number'] ) ? sanitize_text_field( wp_unslash( $_POST['number'] ) ) : ''; |
| 974: | $paged = isset( $_POST['paged'] ) ? sanitize_text_field( wp_unslash( $_POST['paged'] ) ) : ''; |
| 975: | $orderby = isset( $_POST['orderby'] ) ? sanitize_text_field( wp_unslash( $_POST['orderby'] ) ) : ''; |
| 976: | $order = isset( $_POST['order'] ) ? sanitize_text_field( wp_unslash( $_POST['order'] ) ) : ''; |
| 977: | } |
| 978: | if ( ! is_object( $contact ) ) { |
| 979: | $contact = new EPL_Contact( $contact ); |
| 980: | } |
| 981: | |
| 982: | $activities = $contact->get_notes( $number, $paged, $orderby, $order ); |
| 983: | ?> |
| 984: | <div id="epl-contact-activity-table-wrapper"> |
| 985: | <table class="wp-list-table widefat striped epl-contact-activities"> |
| 986: | <thead> |
| 987: | <tr class="epl-contact-activities-table-heads"> |
| 988: | <th class="epl-sorted-<?php echo esc_attr( strtolower( $order ) ); ?>" data-sort="comment_type"><?php esc_html_e( 'Type', 'easy-property-listings' ); ?></th> |
| 989: | <th class="epl-sorted-<?php echo esc_attr( strtolower( $order ) ); ?>" data-sort="comment_content"><?php esc_html_e( 'Comment', 'easy-property-listings' ); ?></th> |
| 990: | <th class="epl-sorted-<?php echo esc_attr( strtolower( $order ) ); ?>" data-sort="comment_date"><?php esc_html_e( 'Date', 'easy-property-listings' ); ?></th> |
| 991: | </tr> |
| 992: | </thead> |
| 993: | <tbody> |
| 994: | <?php if ( ! empty( $activities ) ) : ?> |
| 995: | <?php foreach ( $activities as $activity ) : ?> |
| 996: | <tr data-activity-id="<?php echo esc_attr( $activity->comment_ID ); ?>" id="activity-id-<?php echo esc_attr( $activity->comment_ID ); ?>" class="epl-contact-activity-row epl-contact-activity-<?php echo esc_attr( $activity->comment_type ); ?>" > |
| 997: | <td><?php echo esc_attr( $contact->get_activity_type( $activity->comment_type ) ); ?></td> |
| 998: | <td> |
| 999: | <?php |
| 1000: | if ( $activity->comment_post_ID > 0 ) { |
| 1001: | echo '<div class="epl-contact-inline-lis-details">'; |
| 1002: | echo '<span class="epl-contact-inline-lis-img">'; |
| 1003: | echo wp_kses_post( get_the_post_thumbnail( $activity->comment_post_ID, array( 50, 50 ) ) ); |
| 1004: | echo '</span>'; |
| 1005: | echo '<span class="epl-contact-inline-lis-title">'; |
| 1006: | echo '<a href="' . esc_url( get_permalink( $activity->comment_post_ID ) ) . '">' . esc_attr( get_the_title( $activity->comment_post_ID ) ) . '</a>'; |
| 1007: | echo '</span>'; |
| 1008: | echo '</div>'; |
| 1009: | } |
| 1010: | echo wp_kses_post( $activity->comment_content ); |
| 1011: | ?> |
| 1012: | </td> |
| 1013: | <td><?php echo esc_attr( date_i18n( get_option( 'date_format' ), strtotime( $activity->comment_date ) ) ); ?></td> |
| 1014: | </tr> |
| 1015: | <?php endforeach; ?> |
| 1016: | <?php else : ?> |
| 1017: | <tr><td colspan="5"><?php esc_html_e( 'No Activities', 'easy-property-listings' ); ?></td></tr> |
| 1018: | <?php endif; ?> |
| 1019: | </tbody> |
| 1020: | </table> |
| 1021: | <?php $new_paged = $paged + 1; ?> |
| 1022: | <span data-page="<?php echo esc_attr( $new_paged ); ?>" class="epl-contact-load-activities"><?php esc_html_e( 'Load More', 'easy-property-listings' ); ?> </span> |
| 1023: | </div> |
| 1024: | <?php |
| 1025: | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
| 1026: | wp_die(); |
| 1027: | } |
| 1028: | } |
| 1029: | add_action( 'wp_ajax_epl_contact_get_activity_table', 'epl_contact_get_activities_html', 10, 5 ); |
| 1030: | |
| 1031: | |
| 1032: | |
| 1033: | |
| 1034: | |
| 1035: | |
| 1036: | |
| 1037: | |
| 1038: | |
| 1039: | |
| 1040: | |
| 1041: | |
| 1042: | function epl_contact_get_listings_html( $contact, $number = 10, $paged = 1, $orderby = 'post_date', $order = 'DESC' ) { |
| 1043: | |
| 1044: | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
| 1045: | |
| 1046: | check_ajax_referer( 'epl_ajax_nonce', '_epl_nonce' ); |
| 1047: | |
| 1048: | if ( ! epl_contact_access() ) { |
| 1049: | wp_die( 'Unauthorized' ); |
| 1050: | } |
| 1051: | |
| 1052: | $contact = isset( $_POST['contact'] ) ? sanitize_text_field( wp_unslash( $_POST['contact'] ) ) : ''; |
| 1053: | $number = isset( $_POST['number'] ) ? sanitize_text_field( wp_unslash( $_POST['number'] ) ) : ''; |
| 1054: | $paged = isset( $_POST['paged'] ) ? sanitize_text_field( wp_unslash( $_POST['paged'] ) ) : ''; |
| 1055: | $orderby = isset( $_POST['orderby'] ) ? sanitize_text_field( wp_unslash( $_POST['orderby'] ) ) : ''; |
| 1056: | $order = isset( $_POST['order'] ) ? sanitize_text_field( wp_unslash( $_POST['order'] ) ) : ''; |
| 1057: | } |
| 1058: | if ( ! is_object( $contact ) ) { |
| 1059: | $contact = new EPL_Contact( $contact ); |
| 1060: | } |
| 1061: | |
| 1062: | $activities = get_posts( |
| 1063: | array( |
| 1064: | 'post_type' => array( 'property', 'rural', 'commercial', 'commercial_land', 'business', 'rental', 'land' ), |
| 1065: | 'post_status' => 'publish', |
| 1066: | 'meta_key' => 'property_owner', |
| 1067: | 'meta_value' => $contact->ID, |
| 1068: | 'posts_per_page' => -1, |
| 1069: | ) |
| 1070: | ); |
| 1071: | ?> |
| 1072: | <div id="epl-contact-listing-table-wrapper"> |
| 1073: | <table class="wp-list-table widefat striped epl-contact-listings"> |
| 1074: | <thead> |
| 1075: | <tr class="epl-contact-listings-table-heads"> |
| 1076: | <th class="epl-sorted-<?php echo esc_attr( strtolower( $order ) ); ?>" data-sort="listing_type"><?php esc_html_e( 'Type', 'easy-property-listings' ); ?></th> |
| 1077: | <th class="epl-sorted-<?php echo esc_attr( strtolower( $order ) ); ?>" data-sort="post_content"><?php esc_html_e( 'Title', 'easy-property-listings' ); ?></th> |
| 1078: | <th class="epl-sorted-<?php echo esc_attr( strtolower( $order ) ); ?>" data-sort="listing_status"><?php esc_html_e( 'Status', 'easy-property-listings' ); ?></th> |
| 1079: | </tr> |
| 1080: | </thead> |
| 1081: | <tbody> |
| 1082: | <?php if ( ! empty( $activities ) ) : ?> |
| 1083: | <?php foreach ( $activities as $inserted_lisitng ) : ?> |
| 1084: | <tr data-activity-id="<?php echo esc_attr( $inserted_lisitng->ID ); ?>" id="activity-id-<?php echo esc_attr( $inserted_lisitng->ID ); ?>" class="epl-contact-activity-row " > |
| 1085: | <td><?php echo esc_attr( $inserted_lisitng->post_type ); ?></td> |
| 1086: | <td> |
| 1087: | <?php |
| 1088: | echo '<a href="' . esc_url( get_edit_post_link( $inserted_lisitng->ID ) ) . '">' . esc_attr( $inserted_lisitng->post_title ) . '</a>'; |
| 1089: | ?> |
| 1090: | </td> |
| 1091: | <td> |
| 1092: | <?php echo esc_attr( get_post_meta( $inserted_lisitng->ID, 'property_status', true ) ); ?> |
| 1093: | </td> |
| 1094: | </tr> |
| 1095: | <?php endforeach; ?> |
| 1096: | <?php else : ?> |
| 1097: | <tr><td colspan="5"><?php esc_html_e( 'No Listings Found', 'easy-property-listings' ); ?></td></tr> |
| 1098: | <?php endif; ?> |
| 1099: | </tbody> |
| 1100: | </table> |
| 1101: | </div> |
| 1102: | <?php |
| 1103: | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
| 1104: | wp_die(); |
| 1105: | } |
| 1106: | } |
| 1107: | add_action( 'wp_ajax_epl_contact_get_listing_table', 'epl_contact_get_listings_html', 10, 5 ); |
| 1108: | |
| 1109: | |
| 1110: | |
| 1111: | |
| 1112: | |
| 1113: | |
| 1114: | |
| 1115: | function epl_contact_add_activity_form( $contact ) { |
| 1116: | $form_builder = new EPL_FORM_BUILDER(); |
| 1117: | $listing_ids = $contact->listing_ids; |
| 1118: | $listings_opts = array( '' => esc_html__( 'No Listing', 'easy-property-listings' ) ); |
| 1119: | if ( ! empty( $listing_ids ) ) { |
| 1120: | $listings = get_posts( |
| 1121: | array( |
| 1122: | 'post__in' => $listing_ids, |
| 1123: | 'post_type' => epl_all_post_types(), |
| 1124: | ) |
| 1125: | ); |
| 1126: | if ( ! empty( $listings ) ) : |
| 1127: | foreach ( $listings as $listing ) : |
| 1128: | $listings_opts[ $listing->ID ] = $listing->post_title; |
| 1129: | endforeach; |
| 1130: | endif; |
| 1131: | } |
| 1132: | $fields = array( |
| 1133: | array( |
| 1134: | 'label' => esc_html__( 'Add Activity', 'easy-property-listings' ), |
| 1135: | 'class' => 'col-1 epl-inner-div', |
| 1136: | 'id' => 'epl-contact-add-activity-wrap', |
| 1137: | 'help' => '<hr/>', |
| 1138: | 'fields' => array( |
| 1139: | array( |
| 1140: | 'name' => 'epl_contact_activity_content', |
| 1141: | 'class' => 'epl-contact-note-input', |
| 1142: | 'type' => 'textarea', |
| 1143: | ), |
| 1144: | array( |
| 1145: | 'name' => 'epl_contact_activity_type', |
| 1146: | 'class' => 'epl-contact-note-select', |
| 1147: | 'type' => 'select', |
| 1148: | 'opts' => $contact->get_activity_types(), |
| 1149: | ), |
| 1150: | array( |
| 1151: | 'name' => 'epl_contact_activity_listing', |
| 1152: | 'class' => 'epl-contact-note-select', |
| 1153: | 'type' => 'select', |
| 1154: | 'opts' => $listings_opts, |
| 1155: | ), |
| 1156: | array( |
| 1157: | 'name' => 'epl_contact_activity_submit', |
| 1158: | 'value' => esc_html__( 'Add', 'easy-property-listings' ), |
| 1159: | 'class' => 'button button-primary', |
| 1160: | 'type' => 'submit', |
| 1161: | ), |
| 1162: | ), |
| 1163: | ), |
| 1164: | ); |
| 1165: | $form_builder->set_form_attributes( |
| 1166: | array( |
| 1167: | 'name' => 'epl_contact_add_activity_form', |
| 1168: | 'id' => 'epl_contact_add_activity_form', |
| 1169: | ) |
| 1170: | ); |
| 1171: | $form_builder->add_nonce( 'add_contact_note_nonce' ); |
| 1172: | $form_builder->add_sections( $fields ); |
| 1173: | echo '<div class="epl-contact-add-activity-form-wrap">'; |
| 1174: | $form_builder->render_form(); |
| 1175: | echo '</div>'; |
| 1176: | } |
| 1177: | add_action( 'epl_contact_add_activity_form', 'epl_contact_add_activity_form' ); |
| 1178: | |
| 1179: | |
| 1180: | |
| 1181: | |
| 1182: | |
| 1183: | |
| 1184: | |
| 1185: | |
| 1186: | function epl_contact_add_listing_form( $contact ) { |
| 1187: | global $epl_settings; |
| 1188: | $form_builder = new EPL_FORM_BUILDER(); |
| 1189: | $listing_types = epl_get_active_post_types(); |
| 1190: | $fields = array( |
| 1191: | array( |
| 1192: | 'label' => esc_html__( 'Add Listing', 'easy-property-listings' ), |
| 1193: | 'class' => 'col-1 epl-inner-div', |
| 1194: | 'id' => 'epl-contact-add-listing-wrap', |
| 1195: | 'help' => '<hr/>', |
| 1196: | 'fields' => array( |
| 1197: | |
| 1198: | array( |
| 1199: | 'name' => 'property_owner', |
| 1200: | 'label' => '', |
| 1201: | 'type' => 'hidden', |
| 1202: | 'value' => $contact->ID, |
| 1203: | ), |
| 1204: | array( |
| 1205: | 'name' => 'property_address_lot_number', |
| 1206: | 'label' => esc_html__( 'Lot', 'easy-property-listings' ), |
| 1207: | 'type' => 'text', |
| 1208: | 'maxlength' => '40', |
| 1209: | 'include' => array( 'land', 'commercial_land' ), |
| 1210: | ), |
| 1211: | |
| 1212: | array( |
| 1213: | 'name' => 'property_address_sub_number', |
| 1214: | 'label' => esc_html__( 'Unit', 'easy-property-listings' ), |
| 1215: | 'type' => 'text', |
| 1216: | 'maxlength' => '40', |
| 1217: | 'exclude' => array( 'land', 'commercial_land' ), |
| 1218: | ), |
| 1219: | |
| 1220: | array( |
| 1221: | 'name' => 'property_address_street_number', |
| 1222: | 'label' => esc_html__( 'Street Number', 'easy-property-listings' ), |
| 1223: | 'type' => 'text', |
| 1224: | 'maxlength' => '40', |
| 1225: | ), |
| 1226: | |
| 1227: | array( |
| 1228: | 'name' => 'property_address_street', |
| 1229: | 'label' => esc_html__( 'Street Name', 'easy-property-listings' ), |
| 1230: | 'type' => 'text', |
| 1231: | 'maxlength' => '80', |
| 1232: | ), |
| 1233: | |
| 1234: | array( |
| 1235: | 'name' => 'property_address_suburb', |
| 1236: | 'label' => epl_labels( 'label_suburb' ), |
| 1237: | 'type' => 'text', |
| 1238: | 'maxlength' => '80', |
| 1239: | ), |
| 1240: | |
| 1241: | array( |
| 1242: | 'name' => 'property_address_state', |
| 1243: | 'label' => epl_labels( 'label_state' ), |
| 1244: | 'type' => 'text', |
| 1245: | 'maxlength' => '80', |
| 1246: | ), |
| 1247: | |
| 1248: | array( |
| 1249: | 'name' => 'property_address_postal_code', |
| 1250: | 'label' => epl_labels( 'label_postcode' ), |
| 1251: | 'type' => 'text', |
| 1252: | 'maxlength' => '30', |
| 1253: | ), |
| 1254: | |
| 1255: | array( |
| 1256: | 'name' => 'property_address_country', |
| 1257: | 'label' => esc_html__( 'Country', 'easy-property-listings' ), |
| 1258: | 'type' => 'text', |
| 1259: | 'maxlength' => '40', |
| 1260: | ), |
| 1261: | array( |
| 1262: | 'name' => 'post_title', |
| 1263: | 'label' => esc_html__( 'Full Address', 'easy-property-listings' ), |
| 1264: | 'type' => 'text', |
| 1265: | ), |
| 1266: | array( |
| 1267: | 'name' => 'post_type', |
| 1268: | 'label' => esc_html__( 'Listing Type', 'easy-property-listings' ), |
| 1269: | 'type' => 'select', |
| 1270: | 'class' => 'epl-contact-note-select', |
| 1271: | 'opts' => $listing_types, |
| 1272: | 'maxlength' => '200', |
| 1273: | ), |
| 1274: | array( |
| 1275: | 'name' => 'property_status', |
| 1276: | 'label' => esc_html__( 'Listing Status', 'easy-property-listings' ), |
| 1277: | 'type' => 'select', |
| 1278: | 'class' => 'epl-contact-note-select', |
| 1279: | 'opts' => apply_filters( |
| 1280: | 'epl_contact_property_status', |
| 1281: | array( |
| 1282: | 'current' => epl_get_the_status_label( 'current' ), |
| 1283: | 'sold' => epl_get_the_status_label( 'sold' ), |
| 1284: | 'leased' => epl_get_the_status_label( 'leased' ), |
| 1285: | ) |
| 1286: | ), |
| 1287: | 'maxlength' => '200', |
| 1288: | ), |
| 1289: | |
| 1290: | array( |
| 1291: | 'name' => 'contact_listing_submit', |
| 1292: | 'value' => esc_html__( 'Add', 'easy-property-listings' ), |
| 1293: | 'class' => 'button button-primary', |
| 1294: | 'type' => 'submit', |
| 1295: | ), |
| 1296: | ), |
| 1297: | ), |
| 1298: | ); |
| 1299: | $form_builder->set_form_attributes( |
| 1300: | array( |
| 1301: | 'name' => 'epl_contact_add_listing_form', |
| 1302: | 'id' => 'epl_contact_add_listing_form', |
| 1303: | ) |
| 1304: | ); |
| 1305: | $form_builder->add_nonce( 'add_contact_listing_nonce' ); |
| 1306: | $form_builder->add_sections( $fields ); |
| 1307: | echo '<div class="epl-contact-add-listing-form-wrap">'; |
| 1308: | $form_builder->render_form(); |
| 1309: | echo '</div>'; |
| 1310: | } |
| 1311: | add_action( 'epl_contact_add_listing_form', 'epl_contact_add_listing_form' ); |
| 1312: | |
| 1313: | |
| 1314: | |
| 1315: | |
| 1316: | |
| 1317: | |
| 1318: | |
| 1319: | |
| 1320: | function epl_before_meta_field_property_owner( $post, $value ) { |
| 1321: | |
| 1322: | if ( 0 === intval( $value ) ) { |
| 1323: | return; |
| 1324: | } |
| 1325: | |
| 1326: | $url = admin_url( 'admin.php?page=epl-contacts&view=overview&id=' . $value ); |
| 1327: | $contact = new EPL_Contact( $value ); |
| 1328: | |
| 1329: | if ( ! $contact || $contact->ID <= 0 ) { |
| 1330: | return; |
| 1331: | } |
| 1332: | |
| 1333: | echo '<tr class="form-field"><td>'; |
| 1334: | echo ' |
| 1335: | <div class="epl-listing-owner-details"> |
| 1336: | <div class="epl-listing-owner-grav"> |
| 1337: | ' . wp_kses_post( get_avatar( $contact->email, apply_filters( 'epl_contact_gravatar_size', 160 ) ) ) . ' |
| 1338: | </div> |
| 1339: | <div class="epl-listing-owner-mail"> |
| 1340: | ' . wp_kses_post( $contact->get_emails() ) . ' |
| 1341: | </div> |
| 1342: | <div class="epl-listing-owner-heading"> |
| 1343: | ' . wp_kses_post( $contact->heading ) . ' |
| 1344: | </div> |
| 1345: | <a class="epl-listing-contact-url" href="' . esc_url( $url ) . '">' . |
| 1346: | esc_html__( 'View Contact', 'easy-property-listings' ) . ' |
| 1347: | </a> |
| 1348: | </div>'; |
| 1349: | echo '</td></tr>'; |
| 1350: | } |
| 1351: | add_action( 'epl_before_meta_field_property_owner', 'epl_before_meta_field_property_owner', 10, 2 ); |
| 1352: | |
| 1353: | |
| 1354: | |
| 1355: | |
| 1356: | |
| 1357: | |
| 1358: | |
| 1359: | function epl_search_contact() { |
| 1360: | |
| 1361: | check_ajax_referer( 'epl_ajax_nonce', '_epl_nonce' ); |
| 1362: | |
| 1363: | if ( ! epl_contact_access() ) { |
| 1364: | wp_die( 'Unauthorized' ); |
| 1365: | } |
| 1366: | |
| 1367: | $u_name = isset( $_POST['user_name'] ) ? sanitize_text_field( wp_unslash( $_POST['user_name'] ) ) : ''; |
| 1368: | $search_array = array( |
| 1369: | 'showposts' => 6, |
| 1370: | 'post_type' => 'epl_contact', |
| 1371: | 'post_password' => '', |
| 1372: | 'meta_query' => array( |
| 1373: | 'relation' => 'OR', |
| 1374: | array( |
| 1375: | 'key' => 'contact_first_name', |
| 1376: | 'value' => $u_name, |
| 1377: | 'compare' => 'LIKE', |
| 1378: | ), |
| 1379: | array( |
| 1380: | 'key' => 'contact_last_name', |
| 1381: | 'value' => $u_name, |
| 1382: | 'compare' => 'LIKE', |
| 1383: | ), |
| 1384: | ), |
| 1385: | ); |
| 1386: | |
| 1387: | $listings = new WP_Query( $search_array ); |
| 1388: | |
| 1389: | if ( ! empty( $listings->posts ) ) { |
| 1390: | echo '<ul class="epl-contact-listing-suggestion">'; |
| 1391: | foreach ( $listings->posts as $listing ) { |
| 1392: | echo '<li data-id="' . esc_attr( $listing->ID ) . '">' . esc_attr( get_post_meta( $listing->ID, 'contact_first_name', true ) ) . ' ' . esc_attr( get_post_meta( $listing->ID, 'contact_last_name', true ) ) . '</li>'; |
| 1393: | } |
| 1394: | echo '</ul>'; |
| 1395: | } |
| 1396: | wp_die(); |
| 1397: | } |
| 1398: | add_action( 'wp_ajax_epl_search_contact', 'epl_search_contact' ); |
| 1399: | |
| 1400: | |
| 1401: | |
| 1402: | |
| 1403: | |
| 1404: | |
| 1405: | |
| 1406: | function epl_search_contact_listing() { |
| 1407: | |
| 1408: | check_ajax_referer( 'epl_ajax_nonce', '_epl_nonce' ); |
| 1409: | |
| 1410: | if ( ! epl_contact_access() ) { |
| 1411: | wp_die( 'Unauthorized' ); |
| 1412: | } |
| 1413: | $search_term = isset( $_POST['s'] ) ? sanitize_text_field( wp_unslash( $_POST['s'] ) ) : ''; |
| 1414: | $search_array = array( |
| 1415: | 's' => $search_term, |
| 1416: | 'showposts' => 6, |
| 1417: | 'post_type' => epl_get_core_post_types(), |
| 1418: | 'post_status' => 'publish', |
| 1419: | ); |
| 1420: | |
| 1421: | $query = http_build_query( $search_array ); |
| 1422: | |
| 1423: | $listings = get_posts( $query ); |
| 1424: | |
| 1425: | if ( ! empty( $listings ) ) { |
| 1426: | echo '<ul class="epl-contact-owned-listing-suggestion striped">'; |
| 1427: | foreach ( $listings as $listing ) { |
| 1428: | $status = get_post_meta( $listing->ID, 'property_status', true ); |
| 1429: | echo '<li data-id="' . esc_attr( $listing->ID ) . '"><span class="epl-contact-listing-type">' . esc_attr( $listing->post_type ) . '</span>' . esc_attr( $listing->post_title ) . '<span class="epl-contact-listing-status type_' . esc_attr( $status ) . '">' . esc_attr( $status ) . '</span></li>'; |
| 1430: | } |
| 1431: | echo '</ul>'; |
| 1432: | } |
| 1433: | wp_die(); |
| 1434: | } |
| 1435: | add_action( 'wp_ajax_epl_search_contact_listing', 'epl_search_contact_listing' ); |
| 1436: | |
| 1437: | |
| 1438: | |
| 1439: | |
| 1440: | |
| 1441: | |
| 1442: | |
| 1443: | |
| 1444: | |
| 1445: | function epl_search_user() { |
| 1446: | |
| 1447: | check_ajax_referer( 'epl_ajax_nonce', '_epl_nonce' ); |
| 1448: | |
| 1449: | if ( ! current_user_can( 'edit_posts' ) ) { |
| 1450: | wp_die( 'Unauthorized' ); |
| 1451: | } |
| 1452: | |
| 1453: | $search_term = isset( $_REQUEST['user_name'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['user_name'] ) ) : ''; |
| 1454: | |
| 1455: | $args = array( |
| 1456: | 'search' => $search_term . '*', |
| 1457: | 'number' => 5, |
| 1458: | ); |
| 1459: | |
| 1460: | if ( isset( $_REQUEST['exclude_roles'] ) ) { |
| 1461: | $exclude_roles = explode( ',', sanitize_text_field( wp_unslash( $_REQUEST['exclude_roles'] ) ) ); |
| 1462: | $exclude_roles = array_map( 'sanitize_text_field', $exclude_roles ); |
| 1463: | $args['role__not_in'] = $exclude_roles; |
| 1464: | } |
| 1465: | |
| 1466: | $args = apply_filters( 'epl_search_user_args', $args ); |
| 1467: | $users = get_users( $args ); |
| 1468: | $users = apply_filters( 'epl_search_user_results', $users, $args ); |
| 1469: | |
| 1470: | if ( ! empty( $users ) && ! is_wp_error( $users ) ) { |
| 1471: | ob_start(); |
| 1472: | echo '<ul class="epl-contact-user-suggestion">'; |
| 1473: | foreach ( $users as $user ) { |
| 1474: | echo '<li data-uname="' . esc_attr( $user->data->user_login ) . '" data-id="' . esc_attr( $user->ID ) . '">' . esc_attr( $user->data->display_name ) . '</li>'; |
| 1475: | } |
| 1476: | echo '</ul>'; |
| 1477: | echo ob_get_clean(); |
| 1478: | } |
| 1479: | exit; |
| 1480: | } |
| 1481: | add_action( 'wp_ajax_epl_search_user', 'epl_search_user' ); |
| 1482: | |
| 1483: | |
| 1484: | |
| 1485: | |
| 1486: | |
| 1487: | |
| 1488: | |
| 1489: | |
| 1490: | |
| 1491: | |
| 1492: | function epl_contact_save_note_note_tab( $args ) { |
| 1493: | |
| 1494: | if ( ! is_admin() || ! epl_contact_access() ) { |
| 1495: | wp_die( esc_html__( 'You do not have permission to save note.', 'easy-property-listings' ) ); |
| 1496: | } |
| 1497: | if ( empty( $args ) ) { |
| 1498: | return; |
| 1499: | } |
| 1500: | $contact_note = trim( sanitize_text_field( $args['contact_note'] ) ); |
| 1501: | $listing_id = trim( sanitize_text_field( $args['listing_id'] ) ); |
| 1502: | $note_type = trim( sanitize_text_field( $args['activity_type'] ) ); |
| 1503: | |
| 1504: | $contact_id = (int) $args['contact_id']; |
| 1505: | $nonce = $args['add_contact_note_nonce']; |
| 1506: | if ( ! wp_verify_nonce( $nonce, 'add-contact-note' ) ) { |
| 1507: | wp_die( esc_html__( 'Cheatin\' eh?!', 'easy-property-listings' ) ); |
| 1508: | } |
| 1509: | if ( empty( $contact_note ) ) { |
| 1510: | epl_set_error( 'empty-contact-note', esc_html__( 'A note is required', 'easy-property-listings' ) ); |
| 1511: | } |
| 1512: | if ( epl_get_errors() ) { |
| 1513: | epl_set_error( 'contact-error', esc_html__( 'An error occured', 'easy-property-listings' ) ); |
| 1514: | return; |
| 1515: | } |
| 1516: | do_action( 'epl_pre_insert_contact_note', $contact_id, $contact_note, $listing_id, $note_type ); |
| 1517: | |
| 1518: | $contact = new EPL_Contact( $contact_id ); |
| 1519: | $note_object = $contact->add_note( $contact_note, $note_type, $listing_id ); |
| 1520: | |
| 1521: | if ( ! empty( $note_object ) && ! empty( $contact->ID ) ) { |
| 1522: | ob_start(); |
| 1523: | ?> |
| 1524: | <div class="epl-contact-note-wrapper dashboard-comment-wrap comment-item epl-admin-note"> |
| 1525: | <span class="epl-note-content-meta"> |
| 1526: | <span class="epl-note-for-listing"> |
| 1527: | <?php |
| 1528: | echo isset( $note_object->comment_post_ID ) ? esc_attr( get_the_title( $note_object->comment_post_ID ) ) : ''; |
| 1529: | ?> |
| 1530: | </span> |
| 1531: | <span class="epl-note-time"> |
| 1532: | <?php |
| 1533: | echo esc_attr( date_i18n( get_option( 'date_format' ), strtotime( $note_object->comment_date ) ) ); |
| 1534: | ?> |
| 1535: | </span> |
| 1536: | </span> |
| 1537: | <span class="epl-note-content-wrap"> |
| 1538: | <?php echo wp_kses_post( stripslashes( $note_object->comment_content ) ); ?> |
| 1539: | </span> |
| 1540: | </div> |
| 1541: | <?php |
| 1542: | $output = ob_get_contents(); |
| 1543: | ob_end_clean(); |
| 1544: | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
| 1545: | echo wp_kses_post( $output ); |
| 1546: | exit; |
| 1547: | } |
| 1548: | return $note_object; |
| 1549: | } |
| 1550: | return false; |
| 1551: | } |
| 1552: | add_action( 'epl_add-contact-note-note-tab', 'epl_contact_save_note_note_tab', 10, 1 ); |
| 1553: | |