Fix enquire email

This commit is contained in:
Hoang Huu 2020-05-28 14:33:18 +07:00
parent 9dfb0af9e9
commit 1245c12d50
5 changed files with 88 additions and 49 deletions

View File

@ -1,3 +1,6 @@
= 1.4.9.8 - 2020-05-28 =
* Fixes - Enquire email.
= 1.4.9.4 - 2020-05-27 =
* Fixes - Minor bugs.

View File

@ -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;

View File

@ -1,46 +1,79 @@
<?php
function opalestate_get_message_by_user( $args=array() ){
return array(
'items' => OpalEstate_User_Message::get_instance()->get_list( $args ),
'total' => OpalEstate_User_Message::get_instance()->get_total( $args )
);
<?php
function opalestate_get_message_by_user( $args = [] ) {
return [
'items' => 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
);
}
?>
return [
'receiver_email' => $email,
'receiver_name' => $name,
'receiver_id' => $receiver_id,
];
}

View File

@ -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&#8217; huh?', 'opalestate-pro' ), '1.4.9.4' );
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; 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

View File

@ -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.