From 1245c12d50cc975e3b795f43a1fd41e3a26da677 Mon Sep 17 00:00:00 2001 From: Hoang Huu Date: Thu, 28 May 2020 14:33:18 +0700 Subject: [PATCH] Fix enquire email --- changelog.txt | 3 + inc/message/class-opalestate-message.php | 2 +- inc/message/functions.php | 121 ++++++++++++++--------- opal-estate-pro.php | 6 +- readme.txt | 5 +- 5 files changed, 88 insertions(+), 49 deletions(-) diff --git a/changelog.txt b/changelog.txt index 83e0f392..01639512 100755 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ += 1.4.9.8 - 2020-05-28 = +* Fixes - Enquire email. + = 1.4.9.4 - 2020-05-27 = * Fixes - Minor bugs. diff --git a/inc/message/class-opalestate-message.php b/inc/message/class-opalestate-message.php index 9cee00d5..6e41eb70 100755 --- a/inc/message/class-opalestate-message.php +++ b/inc/message/class-opalestate-message.php @@ -266,7 +266,7 @@ class OpalEstate_User_Message { switch ( trim( $_POST['type'] ) ) { case 'send_equiry': if ( wp_verify_nonce( $_POST['message_action'], 'send-enquiry-form' ) ) { - $member = $this->get_member_email_data( (int) $_POST['post_id'] ); + $member = $this->get_member_email_data( absint( $_POST['post_id'] ) ); $content = $this->send_equiry( $_POST, $member ); } break; diff --git a/inc/message/functions.php b/inc/message/functions.php index e69d125f..3276f0b7 100755 --- a/inc/message/functions.php +++ b/inc/message/functions.php @@ -1,46 +1,79 @@ - OpalEstate_User_Message::get_instance()->get_list( $args ), - 'total' => OpalEstate_User_Message::get_instance()->get_total( $args ) - ); + OpalEstate_User_Message::get_instance()->get_list( $args ), + 'total' => OpalEstate_User_Message::get_instance()->get_total( $args ), + ]; +} + +function opalestate_get_member_email_data( $post_id ) { + $type = get_post_meta( $post_id, OPALESTATE_PROPERTY_PREFIX . 'author_type', true ); + + $receiver_id = 0; + switch ( $type ) { + case 'agent': + $agent_id = get_post_meta( $post_id, OPALESTATE_PROPERTY_PREFIX . 'agent', true ); + if ( ! $agent_id ) { + $post = get_post( $post_id ); + $user = get_user_by( 'id', $post->post_author ); + $email = $user->data->user_email; + $name = $user->data->display_name; + $receiver_id = $post->post_author; + } else { + $user_id = get_post_meta( $agent_id, OPALESTATE_AGENT_PREFIX . 'user_id', true ); + if ( $user_id ) { + $post = get_post( $post_id ); + $user = get_user_by( 'id', $user_id ); + $email = $user->data->user_email; + $name = $user->data->display_name; + $receiver_id = $post->post_author; + } else { + $post = get_post( $agent_id ); + $name = $post->post_title; + $email = get_post_meta( $agent_id, OPALESTATE_AGENT_PREFIX . 'email', true ); + } + } + + break; + + case 'agency': + $agency_id = get_post_meta( $post_id, OPALESTATE_PROPERTY_PREFIX . 'agency', true ); + + if ( ! $agency_id ) { + $post = get_post( $post_id ); + $user = get_user_by( 'id', $post->post_author ); + $email = $user->data->user_email; + $name = $user->data->display_name; + $receiver_id = $post->post_author; + } else { + $user_id = get_post_meta( $agency_id, OPALESTATE_AGENCY_PREFIX . 'user_id', true ); + if ( $user_id ) { + $post = get_post( $post_id ); + $user = get_user_by( 'id', $user_id ); + $email = $user->data->user_email; + $name = $user->data->display_name; + $receiver_id = $post->post_author; + } else { + $post = get_post( $agency_id ); + $name = $post->post_title; + $email = get_post_meta( $agency_id, OPALESTATE_AGENCY_PREFIX . 'email', true ); + } + } + + break; + default: + $post = get_post( $post_id ); + $user = get_user_by( 'id', $post->post_author ); + $email = $user->data->user_email; + $name = $user->data->display_name; + $receiver_id = $post->post_author; + + break; } - function opalestate_get_member_email_data( $post_id ){ - - $output = array(); - $type = get_post_meta( $post_id, OPALESTATE_PROPERTY_PREFIX . 'author_type', true ); - - $receiver_id = 0; - switch ( $type ) { - - case 'agent': - $related_id = get_post_meta( $post_id, OPALESTATE_PROPERTY_PREFIX . 'related_id', true ); - $post = get_post( $related_id ); - $name = $post->post_title; - $email = get_post_meta( $related_id, OPALESTATE_AGENT_PREFIX . 'email', true ); - break; - - case 'agency': - $related_id = get_post_meta( $post_id, OPALESTATE_PROPERTY_PREFIX . 'related_id', true ); - $agent = get_post( $related_id ); - $name = $agent->post_title; - $email = get_post_meta( $related_id, OPALESTATE_AGENCY_PREFIX . 'email', true ); - break; - default: - $post = get_post( $post_id ); - $user = get_user_by( 'id', $post->post_author ); - $email = $user->data->user_email; - $name = $user->data->display_name; - $receiver_id = $post->post_author; - - break; - } - - return $output = array( - 'receiver_email' => $email, - 'receiver_name' => $name, - 'receiver_id' => $receiver_id - ); - } -?> \ No newline at end of file + return [ + 'receiver_email' => $email, + 'receiver_name' => $name, + 'receiver_id' => $receiver_id, + ]; +} diff --git a/opal-estate-pro.php b/opal-estate-pro.php index ceff2158..ecafc7f9 100755 --- a/opal-estate-pro.php +++ b/opal-estate-pro.php @@ -3,7 +3,7 @@ * Plugin Name: Opal Estate Pro * Plugin URI: https://wpdocs.gitbook.io/opal-estate/ * Description: Opal Real Estate Plugin is an ideal solution and brilliant choice for you to set up a professional estate website. - * Version: 1.4.9.4 + * Version: 1.4.9.5 * Author: WPOPAL * Author URI: http://www.wpopal.com * Requires at least: 4.9 @@ -150,7 +150,7 @@ if ( ! class_exists( 'OpalEstate' ) ) { */ public function __clone() { // Cloning instances of the class is forbidden - _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'opalestate-pro' ), '1.4.9.4' ); + _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'opalestate-pro' ), '1.4.9.5' ); } /** @@ -159,7 +159,7 @@ if ( ! class_exists( 'OpalEstate' ) ) { public function setup_constants() { // Plugin version if ( ! defined( 'OPALESTATE_VERSION' ) ) { - define( 'OPALESTATE_VERSION', '1.4.9.4' ); + define( 'OPALESTATE_VERSION', '1.4.9.5' ); } // Plugin Folder Path diff --git a/readme.txt b/readme.txt index 2b820611..40043ef5 100755 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://wpdocs.gitbook.io/opal-estate/ Tags: estate, property, opalestate, house for rent, agency for lease, estate submission, agents estate property, property marketplace Requires at least: 4.9 Tested up to: 5.3.2 -Stable tag: 1.4.9.4 +Stable tag: 1.4.9.5 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -152,6 +152,9 @@ This section describes how to install the plugin and get it working. * System tickets support 24/7 available : [free support](https://themelexus.ticksy.com/ "Visit the Plugin support Page") == Changelog == += 1.4.9.5 - 2020-05-28 = +* Fixes - Enquire email. + = 1.4.9.4 - 2020-05-27 = * Fixes - Minor bugs.