PHP Class 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.
Author: ThemeAvenue ([email protected])
Show file Open project: awesome-support/awesome-support Class Usage Examples

Public Methods

Method Description
__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.

Private Methods

Method Description
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.

Method Details

__construct() public method

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

__destruct() public method

public __destruct ( )

fetch() public method

Takes a string (subject or body) and replace the tags with their current value if any.
Since: 3.0.0
public fetch ( string $contents ) : string
$contents string String to convert tags from
return string String with tags converted into their corresponding value

get_cases() public method

Get available notification cases.
Since: 3.0.2
public get_cases ( ) : array
return array Array of the available cases

get_reply() public method

Ge the post object for the reply.
Since: 3.0.2
public get_reply ( ) : boolean | object
return boolean | object The reply object if there is a reply, false otherwise

get_sender() public method

Get sender data.
Since: 3.0.2
public get_sender ( ) : array
return array Array containing the sender name and e-mail as well as the reply address

get_tags() public static method

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.
Since: 3.0.2
public static get_tags ( ) : array
return array Array of tags with their description

get_tags_values() public method

Get tags and their value in the current context.
Since: 3.0.0
public get_tags_values ( ) : array
return array Array of tag / value pairs

get_ticket() public method

Ge the post object for the ticket.
Since: 3.0.2
public get_ticket ( ) : boolean | object
return boolean | object The ticket object if there is a reply, false otherwise

is_active() public method

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.
Since: 3.0.2
public is_active ( string $case ) : boolean
$case string The notification case requested
return boolean True if the notification is enabled for this case, false otherwise

notification_exists() public method

Check if the requested notification exists.
public notification_exists ( string $case ) : boolean
$case string The notification case requested
return boolean True if such a case exists, false otherwise

notify() public method

Send out the e-mail notification.
Since: 3.0.2
public notify ( string $case ) : boolean | object
$case string The notification case
return boolean | object True if the notification was sent, WP_Error otherwise

set_html_mime_type() public method

Set the e-mail content type to HTML.
Since: 3.1.1
public set_html_mime_type ( ) : string
return string HTML content type

set_text_mime_type() public method

Set the e-mail content type to plain text.
Since: 3.1.1
public set_text_mime_type ( ) : string
return string Text content type