PHP Класс WPAS_Email_Notification

This class handles all e-mail notifications. One instance of this class relates to one and one only post, but can handle multiple notifications for the same post. The available notifications can be extended with the use of a few filters available throughout the class and the dispatch of e-mails is handled by the pluggable function wp_mail(). It is recommended to use a proper SMTP server for e-mail routing in order to ensure a safe delivery.
Автор: ThemeAvenue ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( integer $post_id ) Class constructor.
__destruct ( )
fetch ( string $contents ) : string Convert tags within a string.
get_cases ( ) : array Get available notification cases.
get_reply ( ) : boolean | object Ge the post object for the reply.
get_sender ( ) : array Get sender data.
get_tags ( ) : array Get the available template tags.
get_tags_values ( ) : array Get tags and their value in the current context.
get_ticket ( ) : boolean | object Ge the post object for the ticket.
is_active ( string $case ) : boolean Check if the requested notification is active.
notification_exists ( string $case ) : boolean Check if the requested notification exists.
notify ( string $case ) : boolean | object Send out the e-mail notification.
set_html_mime_type ( ) : string Set the e-mail content type to HTML.
set_text_mime_type ( ) : string Set the e-mail content type to plain text.

Приватные методы

Метод Описание
cases_active_option ( ) : array Get notification cases active option name.
get_body ( $case ) : string Get e-mail body.
get_content ( string $part, string $case ) : string Get e-mail content.
get_formatted_email ( string $content = '' ) : string Retrieve the e-mail template to use and input the content
get_subject ( $case ) : string Get e-mail subject.

Описание методов

__construct() публичный Метод

Class constructor.
public __construct ( integer $post_id )
$post_id integer ID of the post to notify about

__destruct() публичный Метод

public __destruct ( )

fetch() публичный Метод

Takes a string (subject or body) and replace the tags with their current value if any.
С версии: 3.0.0
public fetch ( string $contents ) : string
$contents string String to convert tags from
Результат string String with tags converted into their corresponding value

get_cases() публичный Метод

Get available notification cases.
С версии: 3.0.2
public get_cases ( ) : array
Результат array Array of the available cases

get_reply() публичный Метод

Ge the post object for the reply.
С версии: 3.0.2
public get_reply ( ) : boolean | object
Результат boolean | object The reply object if there is a reply, false otherwise

get_sender() публичный Метод

Get sender data.
С версии: 3.0.2
public get_sender ( ) : array
Результат array Array containing the sender name and e-mail as well as the reply address

get_tags() публичный статический Метод

This is just a list of available tags, no value is attached to those tags. This list is used both for value attribution and in the contextual help in the plugin settings page.
С версии: 3.0.2
public static get_tags ( ) : array
Результат array Array of tags with their description

get_tags_values() публичный Метод

Get tags and their value in the current context.
С версии: 3.0.0
public get_tags_values ( ) : array
Результат array Array of tag / value pairs

get_ticket() публичный Метод

Ge the post object for the ticket.
С версии: 3.0.2
public get_ticket ( ) : boolean | object
Результат boolean | object The ticket object if there is a reply, false otherwise

is_active() публичный Метод

E-mail notifications can be enabled or disabled on a per-case basis by the user in the plugin settings. We need to check that the requested notification hasn't been disabled by the user before sending it out.
С версии: 3.0.2
public is_active ( string $case ) : boolean
$case string The notification case requested
Результат boolean True if the notification is enabled for this case, false otherwise

notification_exists() публичный Метод

Check if the requested notification exists.
public notification_exists ( string $case ) : boolean
$case string The notification case requested
Результат boolean True if such a case exists, false otherwise

notify() публичный Метод

Send out the e-mail notification.
С версии: 3.0.2
public notify ( string $case ) : boolean | object
$case string The notification case
Результат boolean | object True if the notification was sent, WP_Error otherwise

set_html_mime_type() публичный Метод

Set the e-mail content type to HTML.
С версии: 3.1.1
public set_html_mime_type ( ) : string
Результат string HTML content type

set_text_mime_type() публичный Метод

Set the e-mail content type to plain text.
С версии: 3.1.1
public set_text_mime_type ( ) : string
Результат string Text content type