Opal-Estate-Pro/inc/email/class-opalestate-abs-email-template.php

117 lines
2.2 KiB
PHP
Raw Normal View History

2019-09-10 06:27:33 +02:00
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
2020-02-21 05:13:46 +01:00
* @class OpalEstate_Abstract_Email_Template
2019-09-10 06:27:33 +02:00
*
* @version 1.0
*/
class OpalEstate_Abstract_Email_Template {
2019-09-20 12:36:01 +02:00
public $args = [];
2019-09-10 06:27:33 +02:00
/**
* Get the unique email notification key.
*
* @return string
*/
public function get_key() {
return 'opalestate-notification';
}
2019-09-20 12:36:01 +02:00
/**
2019-09-10 06:27:33 +02:00
* Get the friendly name for this email notification.
*
* @return string
*/
public function get_title() {
return esc_html__( 'Admin Notice of Expiring Job Listings', 'opalestate-pro' );
}
/**
* Get the description for this email notification.
*
* @return string
*/
public function get_description() {
return esc_html__( 'Send notices to the site administrator before a job listing expires.', 'opalestate-pro' );
}
2019-09-20 12:36:01 +02:00
public function to_email() {
2019-09-10 06:27:33 +02:00
}
2020-02-21 05:13:46 +01:00
/**
* Get the content for this email notification.
*
* @return string
*/
2019-09-10 06:27:33 +02:00
public function get_content_template() {
}
2019-09-20 12:36:01 +02:00
public function set_args( $args ) {
2019-09-10 06:27:33 +02:00
return $this->args = $args;
}
2019-09-20 12:36:01 +02:00
public function replace_tags( $template ) {
$args = $this->args;
$default = [
2019-10-21 08:24:14 +02:00
'receiver_name' => '',
'name' => '',
'receiver_email' => '',
2020-02-21 05:13:46 +01:00
'property_name' => '',
2019-10-21 08:24:14 +02:00
'property_link' => '',
'property_edit_link' => '',
'message' => '',
'site_name' => get_bloginfo(),
'site_link' => get_home_url(),
2020-02-21 05:13:46 +01:00
'current_time' => date_i18n( opalestate_email_date_format() ),
2019-10-21 08:24:14 +02:00
'phone' => '',
2019-09-20 12:36:01 +02:00
];
$args = array_merge( $default, $args );
$tags = [];
$values = [];
2019-09-10 06:27:33 +02:00
foreach ( $args as $key => $value ) {
2019-09-20 12:36:01 +02:00
$tags[] = "{" . $key . "}";
2019-09-10 06:27:33 +02:00
$values[] = $value;
2019-09-20 12:36:01 +02:00
}
2019-09-10 06:27:33 +02:00
$message = str_replace( $tags, $values, $template );
2019-09-20 12:36:01 +02:00
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
2019-09-20 12:36:01 +02:00
public function get_subject() {
2019-09-10 06:27:33 +02:00
2019-09-20 12:36:01 +02:00
}
2019-09-10 06:27:33 +02:00
2019-09-20 12:36:01 +02:00
public function from_email() {
return opalestate_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
}
2019-09-10 06:27:33 +02:00
2019-09-20 12:36:01 +02:00
public function from_name() {
return opalestate_get_option( 'from_name', get_bloginfo( 'name' ) );
}
2019-09-10 06:27:33 +02:00
2019-09-20 12:36:01 +02:00
public function get_cc() {
2019-09-10 06:27:33 +02:00
2019-09-20 12:36:01 +02:00
}
2019-09-10 06:27:33 +02:00
2019-09-20 12:36:01 +02:00
public function get_body() {
$template = $this->get_content_template();
2019-09-10 06:27:33 +02:00
2019-09-20 12:36:01 +02:00
return $this->replace_tags( $template );
2019-09-10 06:27:33 +02:00
}
2019-09-20 12:36:01 +02:00
public function get_plain_text_body() {
2019-09-10 06:27:33 +02:00
}
}