2019-09-10 06:27:33 +02:00
|
|
|
<?php
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
|
|
exit; // Exit if accessed directly
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @class OpalEstate_Send_Email_Notification
|
|
|
|
*/
|
|
|
|
class OpalEstate_Send_Email_Notification extends OpalEstate_Abstract_Email_Template {
|
|
|
|
|
|
|
|
public $type = '';
|
2019-10-21 08:24:14 +02:00
|
|
|
|
2020-02-21 05:13:46 +01:00
|
|
|
public function set_type( $content ) {
|
|
|
|
$type = '';
|
|
|
|
if ( isset( $content['type'] ) && 'send_enquiry' === $content['type'] ) {
|
|
|
|
$type = 'enquiry';
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->type = $type;
|
|
|
|
}
|
|
|
|
|
2019-09-10 06:27:33 +02:00
|
|
|
/**
|
|
|
|
* Send Email
|
|
|
|
*/
|
2019-10-21 08:24:14 +02:00
|
|
|
public function get_subject() {
|
2019-09-10 06:27:33 +02:00
|
|
|
switch ( $this->type ) {
|
|
|
|
case 'enquiry':
|
2019-09-30 11:28:04 +02:00
|
|
|
|
2019-10-21 08:24:14 +02:00
|
|
|
$subject = html_entity_decode( esc_html__( 'You got a message enquiry', 'opalestate-pro' ) );
|
2019-09-30 11:28:04 +02:00
|
|
|
$subject = opalestate_options( 'enquiry_email_subject', $subject );
|
2019-10-21 08:24:14 +02:00
|
|
|
|
2019-09-10 06:27:33 +02:00
|
|
|
break;
|
2019-10-21 08:24:14 +02:00
|
|
|
|
2019-09-10 06:27:33 +02:00
|
|
|
default:
|
2019-09-30 11:28:04 +02:00
|
|
|
|
2019-10-21 08:24:14 +02:00
|
|
|
$subject = html_entity_decode( esc_html__( 'You got a message contact', 'opalestate-pro' ) );
|
2019-09-30 11:28:04 +02:00
|
|
|
$subject = opalestate_options( 'contact_email_subject', $subject );
|
|
|
|
|
2019-09-10 06:27:33 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-02-21 05:13:46 +01:00
|
|
|
return $this->replace_tags( $subject );
|
2019-09-10 06:27:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-21 08:24:14 +02:00
|
|
|
* Send Email.
|
2019-09-10 06:27:33 +02:00
|
|
|
*/
|
|
|
|
public function get_content_template() {
|
|
|
|
switch ( $this->type ) {
|
|
|
|
case 'enquiry':
|
2019-09-30 11:28:04 +02:00
|
|
|
return opalestate_options( 'enquiry_email_body', self::get_default_template( 'enquiry' ) );
|
2019-09-10 06:27:33 +02:00
|
|
|
break;
|
|
|
|
default:
|
2019-10-21 08:24:14 +02:00
|
|
|
return opalestate_options( 'contact_email_body', self::get_default_template() );
|
2019-09-10 06:27:33 +02:00
|
|
|
break;
|
|
|
|
}
|
2019-10-21 08:24:14 +02:00
|
|
|
}
|
2019-09-10 06:27:33 +02:00
|
|
|
|
2019-10-21 08:24:14 +02:00
|
|
|
public function to_email() {
|
2019-09-10 06:27:33 +02:00
|
|
|
return $this->args ['receiver_email'];
|
|
|
|
}
|
|
|
|
|
2019-10-21 08:24:14 +02:00
|
|
|
public function cc_email() {
|
2019-09-10 06:27:33 +02:00
|
|
|
return $this->args ['sender_email'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function get_body() {
|
2019-10-21 08:24:14 +02:00
|
|
|
$this->args['email'] = $this->args['sender_email'];
|
|
|
|
|
2019-09-10 06:27:33 +02:00
|
|
|
return parent::get_body();
|
|
|
|
}
|
2019-09-30 11:28:04 +02:00
|
|
|
|
2019-10-21 08:24:14 +02:00
|
|
|
/**
|
|
|
|
* Get default template.
|
|
|
|
*
|
|
|
|
* @param string $type
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public static function get_default_template( $type = 'contact' ) {
|
|
|
|
if ( $type == 'enquiry' ) {
|
2019-09-30 11:28:04 +02:00
|
|
|
return opalestate_load_template_path( 'emails/enquiry' );
|
|
|
|
}
|
|
|
|
|
2019-10-21 08:24:14 +02:00
|
|
|
return opalestate_load_template_path( 'emails/contact' );
|
2019-09-30 11:28:04 +02:00
|
|
|
}
|
2019-09-10 06:27:33 +02:00
|
|
|
}
|