AnsPress_Email()
Description #
Email handler class.
Source #
File: addons/free/email.php
*/
class AnsPress_Email_Hooks {
/**
* All emails to send notification.
*
* @var array
*/
public static $emails = array();
/**
* Subject of email to send.
*
* @var string
*/
public static $subject;
/**
* Email body.
*
* @var string
*/
public static $message;
/**
* Initialize the class.
*/
public static function init() {
SELF::ap_default_options();
anspress()->add_filter( 'comment_notification_recipients', __CLASS__, 'default_recipients', 10, 2 );
anspress()->add_action( 'ap_after_new_question', __CLASS__, 'question_subscription', 10, 2 );
anspress()->add_action( 'ap_after_new_answer', __CLASS__, 'answer_subscription', 10, 2 );
anspress()->add_action( 'ap_publish_comment', __CLASS__, 'comment_subscription' );
anspress()->add_action( 'before_delete_post', __CLASS__, 'delete_subscriptions' );
anspress()->add_action( 'deleted_comment', __CLASS__, 'delete_comment_subscriptions' );
anspress()->add_action( 'ap_option_groups', __CLASS__, 'register_option', 100 );
anspress()->add_action( 'ap_after_new_question', __CLASS__, 'ap_after_new_question' );
anspress()->add_action( 'ap_after_new_answer', __CLASS__, 'ap_after_new_answer' );
anspress()->add_action( 'ap_select_answer', __CLASS__, 'select_answer' );
anspress()->add_action( 'ap_publish_comment', __CLASS__, 'new_comment' );
anspress()->add_action( 'ap_after_update_question', __CLASS__, 'ap_after_update_question', 10, 2 );
anspress()->add_action( 'ap_after_update_answer', __CLASS__, 'ap_after_update_answer', 10, 2 );
anspress()->add_action( 'ap_trash_question', __CLASS__, 'ap_trash_question', 10, 2 );
anspress()->add_action( 'ap_trash_answer', __CLASS__, 'ap_trash_answer', 10, 2 );
}
/**
* Return empty reccipients for default comment notifications.
*
* @param array $recipients Array of recipients.
* @param intgere $comment_id Comment ID.
* @return array
*/
public static function default_recipients( $recipients, $comment_id ) {
$_comment = get_comment( $comment_id );
if ( 'anspress' === $_comment->comment_type ) {
return [];
}
return $recipients;
}
/**
* Apppend default options
*
* @since 4.0.0
*/
public static function ap_default_options() {
$defaults = [];
$defaults['notify_admin_email'] = get_option( 'admin_email' );
$defaults['plain_email'] = false;
$defaults['notify_admin_new_question'] = true;
Expand full source code Collapse full source code View on GitHub: addons/free/email.php:27
Add your comment