2019-09-10 06:27:33 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* $Desc$
|
|
|
|
*
|
|
|
|
* @version $Id$
|
|
|
|
* @package $package$
|
|
|
|
* @author Opal Team <info@wpopal.com >
|
2019-09-30 11:28:04 +02:00
|
|
|
* @copyright Copyright (C) 2019 wpopal.com. All Rights Reserved.
|
2019-09-10 06:27:33 +02:00
|
|
|
* @license GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*
|
|
|
|
* @website http://www.wpopal.com
|
|
|
|
* @support http://www.wpopal.com/support/forum.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Exit if accessed directly
|
2019-09-20 12:36:01 +02:00
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
|
|
exit;
|
|
|
|
}
|
2019-09-10 06:27:33 +02:00
|
|
|
|
|
|
|
/**
|
2019-09-20 12:36:01 +02:00
|
|
|
* @class OpalMembership_Checkout
|
2019-09-10 06:27:33 +02:00
|
|
|
*
|
|
|
|
* @version 1.0
|
|
|
|
*/
|
|
|
|
class Opalestate_Emails {
|
|
|
|
/**
|
|
|
|
* init action to automatic send email when user edit or submit a new submission and init setting form in plugin setting of admin
|
|
|
|
*/
|
|
|
|
public static function init() {
|
|
|
|
self::load();
|
|
|
|
|
2019-09-20 12:36:01 +02:00
|
|
|
if ( is_admin() ) {
|
|
|
|
add_filter( 'opalestate_settings_tabs', [ __CLASS__, 'setting_email_tab' ], 1 );
|
|
|
|
add_filter( 'opalestate_registered_emails_settings', [ __CLASS__, 'setting_email_fields' ], 10, 1 );
|
|
|
|
}
|
|
|
|
|
2019-12-04 09:13:37 +01:00
|
|
|
if ( 'on' === opalestate_get_option( 'enable_customer_new_submission', 'on' ) ) {
|
|
|
|
add_action( 'opalestate_processed_new_submission', [ __CLASS__, 'new_submission_email' ], 10, 2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( 'on' === opalestate_get_option( 'enable_admin_new_submission', 'on' ) ) {
|
|
|
|
add_action( 'opalestate_processed_new_submission', [ __CLASS__, 'admin_new_submission_email' ], 15, 2 );
|
|
|
|
}
|
2019-09-20 12:36:01 +02:00
|
|
|
|
2019-12-04 09:13:37 +01:00
|
|
|
if ( 'on' === opalestate_get_option( 'enable_approve_property_email', 'on' ) ) {
|
2019-09-20 12:36:01 +02:00
|
|
|
add_action( 'transition_post_status', [ __CLASS__, 'send_email_when_publish_property' ], 10, 3 );
|
|
|
|
add_action( 'opalestate_processed_approve_publish_property', [ __CLASS__, 'approve_publish_property_email' ], 10, 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send email when User contact via Enquiry Form and Contact Form
|
|
|
|
*/
|
|
|
|
add_action( 'opalestate_send_email_notifycation', [ __CLASS__, 'send_notifycation' ] );
|
|
|
|
add_action( 'opalestate_send_email_submitted', [ __CLASS__, 'new_submission_email' ] );
|
2019-10-21 08:24:14 +02:00
|
|
|
add_action( 'opalestate_send_email_submitted', [ __CLASS__, 'admin_new_submission_email' ] );
|
2019-09-20 12:36:01 +02:00
|
|
|
add_action( 'opalestate_send_email_request_reviewing', [ __CLASS__, 'send_email_request_reviewing' ] );
|
2019-09-10 06:27:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-21 08:24:14 +02:00
|
|
|
* Load.
|
2019-09-10 06:27:33 +02:00
|
|
|
*/
|
|
|
|
public static function load() {
|
|
|
|
require_once OPALESTATE_PLUGIN_DIR . 'inc/email/class-opalestate-abs-email-template.php';
|
|
|
|
require_once OPALESTATE_PLUGIN_DIR . 'inc/email/class-opalestate-email-notifycation.php';
|
|
|
|
require_once OPALESTATE_PLUGIN_DIR . 'inc/email/class-opalestate-request-viewing.php';
|
|
|
|
require_once OPALESTATE_PLUGIN_DIR . 'inc/email/class-opalestate-new-submitted.php';
|
2019-10-21 08:24:14 +02:00
|
|
|
require_once OPALESTATE_PLUGIN_DIR . 'inc/email/class-opalestate-admin-new-submitted.php';
|
2019-10-02 03:33:42 +02:00
|
|
|
require_once OPALESTATE_PLUGIN_DIR . 'inc/email/class-opalestate-approve.php';
|
2019-09-10 06:27:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send Email Notifycation with two types: Enquiry or Contact
|
|
|
|
*/
|
2019-09-20 12:36:01 +02:00
|
|
|
public static function send_notifycation( $content ) {
|
|
|
|
$mail = new OpalEstate_Send_Email_Notification();
|
2020-02-21 05:13:46 +01:00
|
|
|
$mail->set_type( $content );
|
2019-09-20 12:36:01 +02:00
|
|
|
$mail->set_args( $content );
|
|
|
|
|
|
|
|
$return = self::send_mail_now( $mail );
|
|
|
|
|
|
|
|
if ( isset( $content['data'] ) ) {
|
2019-09-10 06:27:33 +02:00
|
|
|
$return['data'] = $content['data'];
|
|
|
|
}
|
|
|
|
|
2019-09-20 12:36:01 +02:00
|
|
|
echo json_encode( $return );
|
|
|
|
die();
|
|
|
|
}
|
2019-09-10 06:27:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* send email if agent submit a new property
|
|
|
|
*/
|
2019-09-20 12:36:01 +02:00
|
|
|
public static function new_submission_email( $user_id, $post_id ) {
|
|
|
|
$mail = new OpalEstate_Send_Email_New_Submitted();
|
2019-09-10 06:27:33 +02:00
|
|
|
$mail->set_pros( $post_id, $user_id );
|
2019-09-20 12:36:01 +02:00
|
|
|
$return = self::send_mail_now( $mail );
|
2019-10-21 08:24:14 +02:00
|
|
|
}
|
2019-09-10 06:27:33 +02:00
|
|
|
|
2019-10-21 08:24:14 +02:00
|
|
|
/**
|
|
|
|
* send email if agent submit a new property
|
|
|
|
*/
|
|
|
|
public static function admin_new_submission_email( $user_id, $post_id ) {
|
|
|
|
$mail = new OpalEstate_Send_Email_Admin_New_Submitted();
|
|
|
|
$mail->set_pros( $post_id, $user_id );
|
|
|
|
$return = self::send_mail_now( $mail );
|
2019-09-10 06:27:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send email to requet viewing a property
|
|
|
|
*/
|
2019-09-20 12:36:01 +02:00
|
|
|
public static function send_email_request_reviewing( $content ) {
|
2019-09-10 06:27:33 +02:00
|
|
|
$mail = new OpalEstate_Send_Email_Request_Reviewing();
|
|
|
|
$mail->set_args( $content );
|
|
|
|
|
2019-09-20 12:36:01 +02:00
|
|
|
$return = self::send_mail_now( $mail );
|
2019-09-10 06:27:33 +02:00
|
|
|
|
2019-09-20 12:36:01 +02:00
|
|
|
echo json_encode( $return );
|
|
|
|
die();
|
2019-09-10 06:27:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2019-09-20 12:36:01 +02:00
|
|
|
public static function send_mail_now( $mail ) {
|
|
|
|
$from_name = $mail->from_name();
|
|
|
|
$from_email = $mail->from_email();
|
|
|
|
$headers = sprintf( "From: %s <%s>\r\n Content-type: text/html", $from_name, $from_email );
|
2019-09-10 06:27:33 +02:00
|
|
|
|
2019-09-20 12:36:01 +02:00
|
|
|
$subject = $mail->get_subject();
|
|
|
|
$message = $mail->get_body();
|
2019-09-10 06:27:33 +02:00
|
|
|
|
2019-09-20 12:36:01 +02:00
|
|
|
if ( $mail->to_email() ) {
|
2019-09-10 06:27:33 +02:00
|
|
|
|
2019-09-20 12:36:01 +02:00
|
|
|
if ( $mail->get_cc() ) {
|
2019-09-10 06:27:33 +02:00
|
|
|
$status = @wp_mail( $mail->get_cc(), $subject, $message, $headers );
|
2019-09-20 12:36:01 +02:00
|
|
|
}
|
2019-09-10 06:27:33 +02:00
|
|
|
|
2019-09-20 12:36:01 +02:00
|
|
|
$status = @wp_mail( $mail->to_email(), $subject, $message, $headers );
|
2019-09-10 06:27:33 +02:00
|
|
|
|
2019-09-20 12:36:01 +02:00
|
|
|
if ( $status ) {
|
|
|
|
return [ 'status' => true, 'msg' => esc_html__( 'Message has been successfully sent.', 'opalestate-pro' ) ];
|
|
|
|
} else {
|
|
|
|
return [ 'status' => true, 'msg' => esc_html__( 'Unable to send a message.', 'opalestate-pro' ) ];
|
|
|
|
}
|
2019-09-10 06:27:33 +02:00
|
|
|
}
|
|
|
|
|
2019-09-20 12:36:01 +02:00
|
|
|
return [ 'status' => true, 'msg' => esc_html__( 'Missing some information!', 'opalestate-pro' ) ];
|
2019-09-10 06:27:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2019-09-20 12:36:01 +02:00
|
|
|
public static function send_email_when_publish_property( $new_status, $old_status, $post ) {
|
|
|
|
if ( is_object( $post ) ) {
|
|
|
|
if ( $post->post_type == 'opalestate_property' ) {
|
|
|
|
if ( $new_status != $old_status ) {
|
|
|
|
if ( $new_status == 'publish' ) {
|
|
|
|
if ( $old_status == 'draft' || $old_status == 'pending' ) {
|
|
|
|
// Send email
|
2019-12-11 09:28:54 +01:00
|
|
|
$post_id = $post->ID;
|
|
|
|
$author_id = $post->post_author;
|
|
|
|
$author = get_userdata( $author_id );
|
|
|
|
|
|
|
|
if ( ! in_array( 'administrator', $author->roles ) && ! in_array( 'opalestate_manager', $author->roles ) && ! in_array( 'opalmembership_manager', $author->roles ) ) {
|
|
|
|
do_action( 'opalestate_processed_approve_publish_property', $post_id );
|
|
|
|
}
|
2019-09-20 12:36:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-10 06:27:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* add new tab Email in opalestate -> setting
|
|
|
|
*/
|
2019-09-20 12:36:01 +02:00
|
|
|
public static function setting_email_tab( $tabs ) {
|
2019-09-10 06:27:33 +02:00
|
|
|
$tabs['emails'] = esc_html__( 'Email', 'opalestate-pro' );
|
2019-09-20 12:36:01 +02:00
|
|
|
|
2019-09-10 06:27:33 +02:00
|
|
|
return $tabs;
|
2019-09-20 12:36:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function newproperty_email_body() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function approve_email_body() {
|
2019-09-10 06:27:33 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* render setting email fields with default values
|
|
|
|
*/
|
2019-09-20 12:36:01 +02:00
|
|
|
public static function setting_email_fields( $fields ) {
|
2020-02-21 05:13:46 +01:00
|
|
|
$enquire_list_tags = '<div>
|
2019-09-10 06:27:33 +02:00
|
|
|
<p class="tags-description">Use the following tags to automatically add property information to the emails. Tags labeled with an asterisk (*) can be used in the email subject as well.</p>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{receive_name}</strong> Name of the agent who made the property
|
|
|
|
</div>
|
2020-02-21 05:13:46 +01:00
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{property_name}</strong> Name of the property
|
|
|
|
</div>
|
|
|
|
|
2019-09-10 06:27:33 +02:00
|
|
|
<div class="opalestate-template-tags-box">
|
2019-10-21 08:24:14 +02:00
|
|
|
<strong>{property_link}</strong> Link of the property
|
2019-09-10 06:27:33 +02:00
|
|
|
</div>
|
2020-02-21 05:13:46 +01:00
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{property_edit_link}</strong> Link for editing of the property (admin)
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{name}</strong> Name of the user who contact via email form
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{email}</strong> Email of the user who contact via email form
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{phone}</strong> Phone number of who sent via form
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{message}</strong> Message content of who sent via form
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{site_link}</strong> A link to this website
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{current_time}</strong> Current date and time
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div> ';
|
|
|
|
$enquire_list_tags = apply_filters( 'opalestate_email_enquire_tags', $enquire_list_tags );
|
|
|
|
|
|
|
|
$contact_list_tags = '<div>
|
|
|
|
<p class="tags-description">Use the following tags to automatically add property information to the emails. Tags labeled with an asterisk (*) can be used in the email subject as well.</p>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{receive_name}</strong> Name of the agent who made the property
|
|
|
|
</div>
|
2019-09-10 06:27:33 +02:00
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{name}</strong> Name of the user who contact via email form
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{email}</strong> Email of the user who contact via email form
|
|
|
|
</div>
|
2020-02-21 05:13:46 +01:00
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{phone}</strong> Phone number of who sent via form
|
|
|
|
</div>
|
2019-10-21 08:24:14 +02:00
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{message}</strong> * Message content of who sent via form
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{site_link}</strong> A link to this website
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{current_time}</strong> Current date and time
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div> ';
|
2020-02-21 05:13:46 +01:00
|
|
|
$contact_list_tags = apply_filters( 'opalestate_email_contact_tags', $contact_list_tags );
|
2019-10-21 08:24:14 +02:00
|
|
|
|
|
|
|
$review_list_tags = '<div>
|
|
|
|
<p class="tags-description">Use the following tags to automatically add property information to the emails. Tags labeled with an asterisk (*) can be used in the email subject as well.</p>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{receive_name}</strong> Name of the agent who made the property
|
|
|
|
</div>
|
2020-02-21 05:13:46 +01:00
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{property_name}</strong> Name of the property
|
|
|
|
</div>
|
2019-10-21 08:24:14 +02:00
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{property_link}</strong> Link of the property
|
|
|
|
</div>
|
2020-02-21 05:13:46 +01:00
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{property_edit_link}</strong> Link for editing of the property (admin)
|
|
|
|
</div>
|
2019-10-21 08:24:14 +02:00
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{name}</strong> Name of the user who contact via email form
|
|
|
|
</div>
|
2019-09-10 06:27:33 +02:00
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
2019-10-21 08:24:14 +02:00
|
|
|
<strong>{email}</strong> Email of the user who contact via email form
|
|
|
|
</div>
|
|
|
|
|
2020-02-21 05:13:46 +01:00
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{schedule_date}</strong> Schedule date
|
|
|
|
</div>
|
|
|
|
|
2019-10-21 08:24:14 +02:00
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{schedule_time}</strong> Schedule time
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
2020-02-21 05:13:46 +01:00
|
|
|
<strong>{phone}</strong> Phone number of who sent via form
|
2019-09-10 06:27:33 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{message}</strong> * Message content of who sent via form
|
|
|
|
</div>
|
2019-10-21 08:24:14 +02:00
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{site_link}</strong> A link to this website
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{current_time}</strong> Current date and time
|
|
|
|
</div>
|
2019-09-10 06:27:33 +02:00
|
|
|
|
|
|
|
</div> ';
|
2020-02-21 05:13:46 +01:00
|
|
|
$review_list_tags = apply_filters( 'opalestate_email_review_tags', $review_list_tags );
|
2019-09-10 06:27:33 +02:00
|
|
|
|
|
|
|
$list_tags = '<div>
|
|
|
|
<p class="tags-description">Use the following tags to automatically add property information to the emails. Tags labeled with an asterisk (*) can be used in the email subject as well.</p>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
2020-02-21 05:13:46 +01:00
|
|
|
<strong>{property_name}</strong> Name of the property
|
2019-09-10 06:27:33 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
2019-10-21 08:24:14 +02:00
|
|
|
<strong>{property_link}</strong> Link of the property
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{property_edit_link}</strong> Link for editing of the property (admin)
|
2019-09-10 06:27:33 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{user_email}</strong> Email of the user who made the property
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
2020-02-21 05:13:46 +01:00
|
|
|
<strong>{submitted_date}</strong> Submitted date
|
2019-09-10 06:27:33 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
2020-02-21 05:13:46 +01:00
|
|
|
<strong>{user_name}</strong> Name of the user who made the property
|
2019-09-10 06:27:33 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{site_name}</strong> The name of this website
|
|
|
|
</div>
|
|
|
|
<div class="opalestate-template-tags-box">
|
|
|
|
<strong>{site_link}</strong> A link to this website
|
|
|
|
</div>
|
|
|
|
<div class="opalestate-template-tags-box">
|
2020-02-21 05:13:46 +01:00
|
|
|
<strong>{current_time}</strong> Current date and time when email sent
|
2019-09-10 06:27:33 +02:00
|
|
|
</div></div>';
|
|
|
|
|
|
|
|
$list_tags = apply_filters( 'opalestate_email_tags', $list_tags );
|
|
|
|
|
2019-09-20 12:36:01 +02:00
|
|
|
|
|
|
|
$fields = [
|
|
|
|
'id' => 'options_page',
|
|
|
|
'title' => esc_html__( 'Email Settings', 'opalestate-pro' ),
|
|
|
|
'show_on' => [ 'key' => 'options-page', 'value' => [ 'opalestate_settings' ], ],
|
|
|
|
'fields' => apply_filters( 'opalestate_settings_emails', [
|
|
|
|
[
|
2019-09-10 06:27:33 +02:00
|
|
|
'name' => esc_html__( 'Email Settings', 'opalestate-pro' ),
|
|
|
|
'desc' => '<hr>',
|
2020-02-21 05:13:46 +01:00
|
|
|
'id' => 'opalestate_title_email_settings',
|
2019-09-20 12:36:01 +02:00
|
|
|
'type' => 'title',
|
|
|
|
],
|
|
|
|
[
|
2019-09-10 06:27:33 +02:00
|
|
|
'id' => 'from_name',
|
|
|
|
'name' => esc_html__( 'From Name', 'opalestate-pro' ),
|
|
|
|
'desc' => esc_html__( 'The name donation receipts are said to come from. This should probably be your site or shop name.', 'opalestate-pro' ),
|
|
|
|
'default' => get_bloginfo( 'name' ),
|
2019-09-20 12:36:01 +02:00
|
|
|
'type' => 'text',
|
|
|
|
],
|
|
|
|
[
|
2019-09-10 06:27:33 +02:00
|
|
|
'id' => 'from_email',
|
|
|
|
'name' => esc_html__( 'From Email', 'opalestate-pro' ),
|
|
|
|
'desc' => esc_html__( 'Email to send donation receipts from. This will act as the "from" and "reply-to" address.', 'opalestate-pro' ),
|
|
|
|
'default' => get_bloginfo( 'admin_email' ),
|
2019-09-20 12:36:01 +02:00
|
|
|
'type' => 'text',
|
|
|
|
],
|
2019-09-10 06:27:33 +02:00
|
|
|
|
|
|
|
|
2019-09-20 12:36:01 +02:00
|
|
|
[
|
2019-09-10 06:27:33 +02:00
|
|
|
'name' => esc_html__( 'Email Submission Templates (Template Tags)', 'opalestate-pro' ),
|
2019-09-20 12:36:01 +02:00
|
|
|
'desc' => $list_tags . '<br><hr>',
|
2020-02-21 05:13:46 +01:00
|
|
|
'id' => 'opalestate_title_email_submission_template',
|
2019-09-20 12:36:01 +02:00
|
|
|
'type' => 'title',
|
|
|
|
],
|
2019-09-10 06:27:33 +02:00
|
|
|
|
|
|
|
|
2019-09-30 11:28:04 +02:00
|
|
|
//------------------------------------------
|
2019-09-20 12:36:01 +02:00
|
|
|
[
|
2019-12-04 09:13:37 +01:00
|
|
|
'name' => esc_html__( 'New Property Submission (Customer)', 'opalestate-pro' ),
|
2019-09-10 06:27:33 +02:00
|
|
|
'desc' => '<hr>',
|
2020-02-21 05:13:46 +01:00
|
|
|
'id' => 'opalestate_title_email_new_property_customer',
|
2019-09-20 12:36:01 +02:00
|
|
|
'type' => 'title',
|
|
|
|
],
|
2019-12-04 09:13:37 +01:00
|
|
|
[
|
|
|
|
'name' => esc_html__( 'Enable', 'opalestate-pro' ),
|
|
|
|
'desc' => esc_html__( 'Enable email for customers when they have a submission.', 'opalestate-pro' ),
|
|
|
|
'id' => 'enable_customer_new_submission',
|
|
|
|
'type' => 'switch',
|
|
|
|
'options' => [
|
|
|
|
'on' => esc_html__( 'Enable', 'opalestate-pro' ),
|
|
|
|
'off' => esc_html__( 'Disable', 'opalestate-pro' ),
|
|
|
|
],
|
|
|
|
'default' => 'on',
|
|
|
|
],
|
2019-09-20 12:36:01 +02:00
|
|
|
[
|
|
|
|
'id' => 'newproperty_email_subject',
|
|
|
|
'name' => esc_html__( 'Email Subject', 'opalestate-pro' ),
|
|
|
|
'type' => 'text',
|
|
|
|
'desc' => esc_html__( 'The email subject for admin notifications.', 'opalestate-pro' ),
|
|
|
|
'attributes' => [
|
2019-10-21 08:24:14 +02:00
|
|
|
'rows' => 3,
|
2019-09-20 12:36:01 +02:00
|
|
|
],
|
|
|
|
'default' => esc_html__( 'New Property Listing Submitted: {property_name}', 'opalestate-pro' ),
|
|
|
|
|
|
|
|
],
|
|
|
|
[
|
2019-09-10 06:27:33 +02:00
|
|
|
'id' => 'newproperty_email_body',
|
|
|
|
'name' => esc_html__( 'Email Body', 'opalestate-pro' ),
|
|
|
|
'type' => 'wysiwyg',
|
2019-09-20 12:36:01 +02:00
|
|
|
'desc' => esc_html__( 'Enter the email an admin should receive when an initial payment request is made.', 'opalestate-pro' ),
|
2019-09-10 06:27:33 +02:00
|
|
|
'default' => OpalEstate_Send_Email_New_Submitted::get_default_template(),
|
2019-09-20 12:36:01 +02:00
|
|
|
],
|
2019-09-10 06:27:33 +02:00
|
|
|
//------------------------------------------
|
2019-10-21 08:24:14 +02:00
|
|
|
|
|
|
|
[
|
2019-12-04 09:13:37 +01:00
|
|
|
'name' => esc_html__( 'New Property Submission (Admin)', 'opalestate-pro' ),
|
|
|
|
'desc' => '<hr>',
|
2020-02-21 05:13:46 +01:00
|
|
|
'id' => 'opalestate_title_email_new_property_admin',
|
2019-12-04 09:13:37 +01:00
|
|
|
'type' => 'title',
|
|
|
|
'before_row' => '<hr>',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'name' => esc_html__( 'Enable', 'opalestate-pro' ),
|
|
|
|
'desc' => esc_html__( 'Enable email for admin when a property is submitted.', 'opalestate-pro' ),
|
|
|
|
'id' => 'enable_admin_new_submission',
|
|
|
|
'type' => 'switch',
|
|
|
|
'options' => [
|
|
|
|
'on' => esc_html__( 'Enable', 'opalestate-pro' ),
|
|
|
|
'off' => esc_html__( 'Disable', 'opalestate-pro' ),
|
|
|
|
],
|
|
|
|
'default' => 'on',
|
2019-10-21 08:24:14 +02:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'id' => 'admin_newproperty_email_subject',
|
|
|
|
'name' => esc_html__( 'Email Subject', 'opalestate-pro' ),
|
|
|
|
'type' => 'text',
|
|
|
|
'desc' => esc_html__( 'The email subject for admin notifications.', 'opalestate-pro' ),
|
|
|
|
'default' => esc_html__( 'You received a new submission: {property_name} from {user_mail}', 'opalestate-pro' ),
|
|
|
|
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'id' => 'admin_newproperty_email_body',
|
|
|
|
'name' => esc_html__( 'Email Body', 'opalestate-pro' ),
|
|
|
|
'type' => 'wysiwyg',
|
|
|
|
'desc' => esc_html__( 'Enter the email an admin should receive when an initial payment request is made.', 'opalestate-pro' ),
|
|
|
|
'default' => OpalEstate_Send_Email_Admin_New_Submitted::get_default_template(),
|
|
|
|
],
|
|
|
|
//------------------------------------------
|
|
|
|
|
2019-09-20 12:36:01 +02:00
|
|
|
[
|
2019-12-04 09:13:37 +01:00
|
|
|
'name' => esc_html__( 'Approved property for publish (Customer)', 'opalestate-pro' ),
|
|
|
|
'desc' => '<hr>',
|
2020-02-21 05:13:46 +01:00
|
|
|
'id' => 'opalestate_title_email_approved_property',
|
2019-12-04 09:13:37 +01:00
|
|
|
'type' => 'title',
|
|
|
|
'before_row' => '<hr>',
|
2019-09-20 12:36:01 +02:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'name' => esc_html__( 'Enable approve property email', 'opalestate-pro' ),
|
|
|
|
'desc' => esc_html__( 'Enable approve property email.', 'opalestate-pro' ),
|
|
|
|
'id' => 'enable_approve_property_email',
|
|
|
|
'type' => 'switch',
|
|
|
|
'options' => [
|
|
|
|
'on' => esc_html__( 'Enable', 'opalestate-pro' ),
|
|
|
|
'off' => esc_html__( 'Disable', 'opalestate-pro' ),
|
|
|
|
],
|
2019-12-04 09:13:37 +01:00
|
|
|
'default' => 'on',
|
2019-09-20 12:36:01 +02:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'id' => 'approve_email_subject',
|
|
|
|
'name' => esc_html__( 'Email Subject', 'opalestate-pro' ),
|
|
|
|
'type' => 'text',
|
|
|
|
'desc' => esc_html__( 'The email subject a user should receive when they make an initial property request.', 'opalestate-pro' ),
|
2020-02-21 05:13:46 +01:00
|
|
|
'default' => esc_html__( 'New Property Listing Approved: {property_name}', 'opalestate-pro' ),
|
2019-09-20 12:36:01 +02:00
|
|
|
],
|
|
|
|
|
|
|
|
[
|
|
|
|
'id' => 'approve_email_body',
|
|
|
|
'name' => esc_html__( 'Email Body', 'opalestate-pro' ),
|
|
|
|
'type' => 'wysiwyg',
|
|
|
|
'desc' => esc_html__( 'Enter the email a user should receive when they make an initial payment request.', 'opalestate-pro' ),
|
|
|
|
'default' => OpalEstate_Send_Email_Approve::get_default_template(),
|
|
|
|
],
|
2019-09-30 11:28:04 +02:00
|
|
|
/// enquire contact template ////
|
|
|
|
[
|
2020-02-21 05:13:46 +01:00
|
|
|
'name' => esc_html__( 'Email Enquire Contact Form (in the single property page)', 'opalestate-pro' ),
|
|
|
|
'desc' => $enquire_list_tags . '<br><hr>',
|
|
|
|
'id' => 'opalestate_title_email_enquire_contact',
|
2019-12-04 09:13:37 +01:00
|
|
|
'type' => 'title',
|
|
|
|
'before_row' => '<hr>',
|
2019-09-30 11:28:04 +02:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'id' => 'enquiry_email_subject',
|
|
|
|
'name' => esc_html__( 'Email Subject', 'opalestate-pro' ),
|
|
|
|
'type' => 'text',
|
|
|
|
'desc' => esc_html__( 'The email subject a user should receive when they make an initial property request.', 'opalestate-pro' ),
|
|
|
|
'default' => esc_html__( 'You got a message', 'opalestate-pro' ),
|
|
|
|
],
|
2019-09-10 06:27:33 +02:00
|
|
|
|
2019-09-30 11:28:04 +02:00
|
|
|
[
|
2019-10-21 08:24:14 +02:00
|
|
|
'id' => 'enquiry_email_body',
|
|
|
|
'name' => esc_html__( 'Email Body', 'opalestate-pro' ),
|
|
|
|
'type' => 'wysiwyg',
|
|
|
|
'default' => OpalEstate_Send_Email_Notification::get_default_template( 'enquiry' ),
|
2019-09-30 11:28:04 +02:00
|
|
|
],
|
2020-02-21 05:13:46 +01:00
|
|
|
/// Email Request Review ///
|
2019-09-20 12:36:01 +02:00
|
|
|
[
|
2020-02-21 05:13:46 +01:00
|
|
|
'name' => esc_html__( 'Email Request Review Form (in the single property page)', 'opalestate-pro' ),
|
|
|
|
'desc' => $review_list_tags . '<br><hr>',
|
|
|
|
'id' => 'opalestate_title_email_request_review',
|
2019-12-04 09:13:37 +01:00
|
|
|
'type' => 'title',
|
|
|
|
'before_row' => '<hr>',
|
2019-09-20 12:36:01 +02:00
|
|
|
],
|
|
|
|
[
|
2020-02-21 05:13:46 +01:00
|
|
|
'id' => 'request_review_email_subject',
|
2019-09-20 12:36:01 +02:00
|
|
|
'name' => esc_html__( 'Email Subject', 'opalestate-pro' ),
|
|
|
|
'type' => 'text',
|
|
|
|
'desc' => esc_html__( 'The email subject a user should receive when they make an initial property request.', 'opalestate-pro' ),
|
2020-02-21 05:13:46 +01:00
|
|
|
'default' => esc_html__( 'You have a message request reviewing', 'opalestate-pro' ),
|
2019-09-20 12:36:01 +02:00
|
|
|
],
|
|
|
|
|
|
|
|
[
|
2020-02-21 05:13:46 +01:00
|
|
|
'id' => 'request_review_email_body',
|
2019-10-21 08:24:14 +02:00
|
|
|
'name' => esc_html__( 'Email Body', 'opalestate-pro' ),
|
|
|
|
'type' => 'wysiwyg',
|
2020-02-21 05:13:46 +01:00
|
|
|
'default' => OpalEstate_Send_Email_Request_Reviewing::get_default_template(),
|
2019-09-30 11:28:04 +02:00
|
|
|
],
|
2020-02-21 05:13:46 +01:00
|
|
|
/// email contact template ////
|
2019-09-30 11:28:04 +02:00
|
|
|
[
|
2020-02-21 05:13:46 +01:00
|
|
|
'name' => esc_html__( 'Email Contact Host Form (in the Agent/Agency page)', 'opalestate-pro' ),
|
|
|
|
'desc' => $contact_list_tags . '<br><hr>',
|
|
|
|
'id' => 'opalestate_title_email_contact_author_form',
|
2019-12-04 09:13:37 +01:00
|
|
|
'type' => 'title',
|
|
|
|
'before_row' => '<hr>',
|
2019-09-30 11:28:04 +02:00
|
|
|
],
|
|
|
|
[
|
2020-02-21 05:13:46 +01:00
|
|
|
'id' => 'contact_email_subject',
|
2019-09-30 11:28:04 +02:00
|
|
|
'name' => esc_html__( 'Email Subject', 'opalestate-pro' ),
|
|
|
|
'type' => 'text',
|
|
|
|
'desc' => esc_html__( 'The email subject a user should receive when they make an initial property request.', 'opalestate-pro' ),
|
2020-02-21 05:13:46 +01:00
|
|
|
'default' => esc_html__( 'You got a message', 'opalestate-pro' ),
|
2019-09-30 11:28:04 +02:00
|
|
|
],
|
|
|
|
|
|
|
|
[
|
2020-02-21 05:13:46 +01:00
|
|
|
'id' => 'contact_email_body',
|
2019-10-21 08:24:14 +02:00
|
|
|
'name' => esc_html__( 'Email Body', 'opalestate-pro' ),
|
|
|
|
'type' => 'wysiwyg',
|
2020-02-21 05:13:46 +01:00
|
|
|
'default' => OpalEstate_Send_Email_Notification::get_default_template(),
|
2019-09-20 12:36:01 +02:00
|
|
|
],
|
|
|
|
]
|
|
|
|
),
|
|
|
|
];
|
2019-09-10 06:27:33 +02:00
|
|
|
|
|
|
|
return $fields;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get data of newrequest email
|
|
|
|
*
|
2019-09-20 12:36:01 +02:00
|
|
|
* @var $args array: property_id , $body
|
2019-09-10 06:27:33 +02:00
|
|
|
*/
|
|
|
|
public static function replace_shortcode( $args, $body ) {
|
|
|
|
|
2019-09-20 12:36:01 +02:00
|
|
|
$tags = [
|
|
|
|
'user_name' => "",
|
|
|
|
'user_mail' => "",
|
2019-09-10 06:27:33 +02:00
|
|
|
'submitted_date' => "",
|
2019-09-20 12:36:01 +02:00
|
|
|
'property_name' => "",
|
|
|
|
'site_name' => '',
|
|
|
|
'site_link' => '',
|
|
|
|
'property_link' => '',
|
|
|
|
];
|
2019-09-10 06:27:33 +02:00
|
|
|
$tags = array_merge( $tags, $args );
|
|
|
|
|
|
|
|
extract( $tags );
|
|
|
|
|
2019-09-20 12:36:01 +02:00
|
|
|
$tags = [
|
|
|
|
"{user_mail}",
|
|
|
|
"{user_name}",
|
|
|
|
"{submitted_date}",
|
|
|
|
"{site_name}",
|
|
|
|
"{site_link}",
|
|
|
|
"{current_time}",
|
|
|
|
'{property_name}',
|
|
|
|
'{property_link}',
|
|
|
|
];
|
|
|
|
|
|
|
|
$values = [
|
|
|
|
$user_mail,
|
|
|
|
$user_name,
|
|
|
|
$submitted_date,
|
|
|
|
get_bloginfo( 'name' ),
|
|
|
|
get_home_url(),
|
2020-02-21 05:13:46 +01:00
|
|
|
date_i18n( opalestate_email_date_format() ),
|
2019-09-20 12:36:01 +02:00
|
|
|
$property_name,
|
|
|
|
$property_link,
|
|
|
|
];
|
|
|
|
|
|
|
|
$message = str_replace( $tags, $values, $body );
|
2019-09-10 06:27:33 +02:00
|
|
|
|
|
|
|
return $message;
|
|
|
|
}
|
2019-09-20 12:36:01 +02:00
|
|
|
|
2019-09-10 06:27:33 +02:00
|
|
|
public static function approve_publish_property_email( $post_id ) {
|
2019-09-20 12:36:01 +02:00
|
|
|
$mail = new OpalEstate_Send_Email_Approve();
|
2019-09-10 06:27:33 +02:00
|
|
|
$mail->set_pros( $post_id );
|
|
|
|
|
2019-12-11 09:28:54 +01:00
|
|
|
self::send_mail_now( $mail );
|
2019-09-20 12:36:01 +02:00
|
|
|
}
|
2019-09-10 06:27:33 +02:00
|
|
|
}
|
|
|
|
|
2019-09-20 12:36:01 +02:00
|
|
|
Opalestate_Emails::init();
|