settings->get_setting( 'admin-question-notification' ) ) { return; }
$admin_emails = $ewd_ufaq_controller->settings->get_setting( 'admin-notification-email' ) ? explode( ',', $ewd_ufaq_controller->settings->get_setting( 'admin-notification-email' ) ) : (array) get_option( 'admin_email' );
$faq_link = site_url() . '/wp-admin/post.php?post=' . $faq->ID . '&action=edit';
$subject_line = __( 'New Question Received', 'ultimate-faqs' );
$message_body = __( 'Hello Admin,', 'ultimate-faqs' ) . '
';
$message_body .= __( 'You\'ve received a new question titled ', 'ultimate-faqs' ) . $faq->question . '.
';
if ( ! empty( $faq->answer ) ) {
$message_body .= __( 'The answer reads:
', 'ultimate-faqs' );
$message_body .= esc_html( $faq->answer ) . '
';
}
$message_body .= __( 'You can view the question in the admin area by going to the following link:
', 'ultimate-faqs' );
$message_body .= '' . __( 'See the FAQ', 'ultimate-faqs' ) . '
';
$message_body .= __( 'Have a great day,', 'ultimate-faqs' ) . '
';
$message_body .= __( 'Ultimate FAQs Team', 'ultimate-faqs' );
$headers = array( 'Content-Type: text/html; charset=UTF-8' );
foreach ( $admin_emails as $admin_email ) {
$success = wp_mail( $admin_email, $subject_line, $message_body, $headers );
}
return $success;
}
/**
* Send an email to the FAQ author using UWPM when an FAQ is submitted, if selected
*
* @since 2.0.0
*/
public function user_submission_email( $faq ) {
global $ewd_ufaq_controller;
if ( ! $ewd_ufaq_controller->settings->get_setting( 'submit-faq-email' ) ) { return; }
$params = array(
'email_id' => $ewd_ufaq_controller->settings->get_setting( 'submit-faq-email' ),
'email_address' => $faq->faq_author_email,
'post_id' => $faq->ID
);
if ( function_exists( 'ewd_uwpm_send_email' ) ) {
ewd_uwpm_send_email( $params );
}
else {
$author_emails = $faq->faq_author_email ? explode( ',', $faq->faq_author_email ) : array();
$subject_line = apply_filters( 'ewd_ufaq_user_question_submitted_subject_line', __( 'New Question', 'ultimate-faqs' ) );
$message_body = __( 'Hello,', 'ultimate-faqs' ) . '
';
$message_body .= sprintf( __( 'Thank you for submitting your FAQ, %s. ', 'ultimate-faqs' ), $faq->question ) . '
';
$message_body .= get_bloginfo( 'name' );
$message_body = apply_filters( 'ewd_ufaq_user_question_submitted_message_body', $message_body );
$headers = array( 'Content-Type: text/html; charset=UTF-8' );
foreach ( $author_emails as $author_email ) {
if ( ! filter_var( $author_email, FILTER_VALIDATE_EMAIL ) ) { continue;}
$success = wp_mail( $author_email, $subject_line, $message_body, $headers );
}
return $success;
}
}
/**
* Send an email to the FAQ author once their question has been answered
*
* @since 2.4.0
*/
public function user_question_updated( $faq ) {
$author_emails = $faq->faq_author_email ? explode( ',', $faq->faq_author_email ) : array();
$subject_line = apply_filters( 'ewd_ufaq_user_question_answered_subject_line', __( 'New Question Answer', 'ultimate-faqs' ) );
$message_body = __( 'Hello,', 'ultimate-faqs' ) . '
';
$message_body .= sprintf( __( 'Your FAQ, %s, has received a new question answer: ', 'ultimate-faqs' ), $faq->question ) . '
' . $faq->answer . '
';
$message_body .= __( 'Thank You,', 'ultimate-faqs' ) . '
';
$message_body = apply_filters( 'ewd_ufaq_user_question_answered_message_body', $message_body );
$headers = array( 'Content-Type: text/html; charset=UTF-8' );
foreach ( $author_emails as $author_email ) {
if ( ! filter_var( $author_email, FILTER_VALIDATE_EMAIL ) ) { continue;}
$success = wp_mail( $author_email, $subject_line, $message_body, $headers );
}
return $success;
}
}
} // endif;