Opal-Estate-Pro/inc/email/class-opalestate-approve.php

116 lines
2.6 KiB
PHP
Raw Normal View History

2019-09-10 06:27:33 +02:00
<?php
/**
* $Desc$
*
* @version $Id$
* @package opalestate
* @author Opal Team <info@wpopal.com >
* @copyright Copyright (C) 2019 wpopal.com. All Rights Reserved.
* @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
*/
2019-10-21 08:24:14 +02:00
2019-09-10 06:27:33 +02:00
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* @class OpalEstate_Send_Email_Notification
*
* @version 1.0
*/
class OpalEstate_Send_Email_Approve extends OpalEstate_Abstract_Email_Template {
2019-10-21 08:24:14 +02:00
2019-09-10 06:27:33 +02:00
/**
2019-10-21 08:24:14 +02:00
* Get subject.
2019-09-10 06:27:33 +02:00
*/
2019-10-21 08:24:14 +02:00
public function get_subject() {
$subject = esc_html__( 'The Property Listing Approved: {property_name}', 'opalestate-pro' );
$subject = opalestate_options( 'approve_email_body', $subject );
2019-09-30 11:28:04 +02:00
2019-10-21 08:24:14 +02:00
return $this->replace_tags( $subject );
2019-09-10 06:27:33 +02:00
}
/**
2019-10-21 08:24:14 +02:00
* Get collection of key and value base on tags which using to replace custom tags
2019-09-10 06:27:33 +02:00
*/
2019-10-21 08:24:14 +02:00
public function set_pros( $property_id ) {
$property = get_post( $property_id );
$user = get_userdata( $property->post_author );
$email = get_user_meta( $property->post_author, OPALESTATE_USER_PROFILE_PREFIX . 'email', true );
$email = $email ? $email : $user->data->user_email;
$this->args = [
'receiver_email' => $email,
'user_mail' => $email,
'user_name' => $user->display_name,
'submitted_date' => $property->post_date,
'property_name' => $property->post_title,
'property_link' => get_permalink( $property_id ),
'current_time' => date( "F j, Y, g:i a" ),
];
return $this->args;
2019-09-10 06:27:33 +02:00
}
/**
2019-10-21 08:24:14 +02:00
*
2019-09-10 06:27:33 +02:00
*/
public function get_content_template() {
2019-09-30 11:28:04 +02:00
2019-10-21 08:24:14 +02:00
$content = opalestate_options( 'approve_email_body', self::get_default_template() );
return $content;
}
2019-09-10 06:27:33 +02:00
/**
*
*/
public static function get_default_template() {
2019-10-21 08:24:14 +02:00
return trim( preg_replace( '/\t+/', '', "Hi {user_name},<br>
2019-09-10 06:27:33 +02:00
<br>
Thank you so much for submitting to {site_name}.
<br>
We have completed the auditing process for your property '{property_name}' and are pleased to inform you that your submission has been accepted.
<br>
<br>
Thanks again for your contribution
<br>
&nbsp;<br>
<br>
2019-10-21 08:24:14 +02:00
<em>This message was sent by {site_link} on {current_time}.</em>" ) );
2019-09-10 06:27:33 +02:00
}
/**
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
*
2019-09-10 06:27:33 +02:00
*/
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'];
}
/**
2019-10-21 08:24:14 +02:00
*
2019-09-10 06:27:33 +02:00
*/
public function get_body() {
2019-10-21 08:24:14 +02:00
$post = get_post( $this->args['post_id'] );
$this->args['email'] = $this->args['receiver_email'];
$this->args['property_link'] = $post->post_title;
2019-09-10 06:27:33 +02:00
return parent::get_body();
}
}
2019-10-21 08:24:14 +02:00
?>