*/ class Simple_Job_Board_Notifications { /** * Admin Notification * * @since 1.0.0 * * @param $post_id Post ID * @return void */ public static function admin_notification($post_id) { // Applied job title $job_title = get_the_title($post_id); $applicant_post_keys = get_post_custom_keys($post_id); // Applicant Email $applicant_email = self::applicant_details('email', $post_id); // Applicant Name $applicant_name = self::applicant_details('name', $post_id); // Admin Email Address $admin_email = ( FALSE !== get_option( 'settings_admin_email' ) ) ? get_option( 'settings_admin_email' ) : get_option( 'admin_email' ); $to = apply_filters('sjb_admin_notification_to', esc_attr( $admin_email ) , $post_id); $subject = apply_filters('sjb_admin_notification_sbj', sprintf(esc_html__('Applicant Resume Received %s ', 'simple-job-board'), html_entity_decode( $job_title )), $job_title, $post_id); // Email Header: Reply-to & From Parameters $headers[] = 'From: ' . get_bloginfo('name') . ' <' . esc_attr( $admin_email ) . '>'; if (!empty($applicant_name) && !empty($applicant_email)) { $headers[] = 'Reply-To: ' . $applicant_name . ' <' . $applicant_email . '>'; } $headers[] = 'Content-Type: text/html; charset=UTF-8'; $message = self::job_notification_templates($post_id, 'Admin'); $attachment = apply_filters('sjb_admin_notification_attachment', '', $post_id); wp_mail($to, $subject, $message, $headers, $attachment); } /** * HR Notification * * @since 1.0.0 * * @param $post_id Post ID * @return void */ public static function hr_notification( $post_id ) { // Applied job title $job_title = get_the_title($post_id); // Applicant Email $applicant_email = self::applicant_details('mail', $post_id); // Applicant Name $applicant_name = self::applicant_details('name', $post_id); $to = apply_filters('sjb_hr_notification_to', get_option('settings_hr_email'), $post_id); $subject = apply_filters('sjb_hr_notification_sbj', sprintf(esc_html__('Applicant Resume Received %s ', 'simple-job-board'), html_entity_decode( $job_title )), $job_title, $post_id); $message = self::job_notification_templates($post_id, 'HR'); // Admin Email $admin_email = ( FALSE !== get_option( 'settings_admin_email' ) ) ? get_option( 'settings_admin_email' ) : get_option( 'admin_email' ); // Email Header: Reply-to & From Parameters $headers[] = 'From: ' . get_bloginfo('name') . ' <' . esc_attr($admin_email) . '>'; if (!empty($applicant_name) && !empty($applicant_email)) { $headers[] = 'Reply-To: ' . $applicant_name . ' <' . $applicant_email . '>'; } $headers[] = 'Content-Type: text/html; charset=UTF-8'; $attachment = apply_filters('sjb_hr_notification_attachment', '', $post_id); if ('' != $to) wp_mail($to, $subject, $message, $headers, $attachment); } /** * Applicant Notification * * @since 1.0.0 * * @param $post_id Post ID * @return void */ public static function applicant_notification($post_id) { // Applied job title $job_title = get_the_title($post_id); // Applicant Email $applicant_email = self::applicant_details('email', $post_id); $subject = apply_filters('sjb_applicant_notification_sbj', sprintf(esc_html__('Your Resume Received for Job %s ', 'simple-job-board'), html_entity_decode( $job_title )), $job_title, $post_id); $message = self::job_notification_templates($post_id, 'applicant'); // Admin Email $admin_email = ( FALSE !== get_option( 'settings_admin_email' ) ) ? get_option( 'settings_admin_email' ) : get_option( 'admin_email' ); // Get the site domain and get rid of www. $sitename = strtolower($_SERVER['SERVER_NAME']); if (substr($sitename, 0, 4) == 'www.') { $sitename = substr($sitename, 4); } // Email Header: Reply-to & From Parameters $from_email = 'noreply@' . $sitename; $headers[] = 'From: ' . get_bloginfo('name') . ' <' . esc_attr( $admin_email ) . '>'; $headers[] = 'Reply-To: ' . get_bloginfo('name') . '<' . $from_email . '>'; $headers[] = 'Content-Type: text/html; charset=UTF-8'; // Validate Applicant Email if ( isset( $applicant_email ) && is_email( $applicant_email ) ) wp_mail( $applicant_email, $subject, $message, $headers ); } /** * Email Template * * @since 1.0.0 * * @param int $post_id Post ID * @param string $notification_receiver Notification Receiver (Admin or HR or || Applicant) * @return string $message Email Template */ public static function job_notification_templates($post_id, $notification_receiver) { $message = self::email_start_template($notification_receiver, $post_id); if ('HR' === $notification_receiver) { $message .= self::hr_email_template($post_id, $notification_receiver ); } elseif ('Admin' === $notification_receiver) { $message .= self::admin_email_template( $post_id, $notification_receiver ); } else { $message .= self::applicant_email_template( $post_id, $notification_receiver ); } $message .= self::email_end_template( $post_id, $notification_receiver ); /** * Hook -> Notification Message. * * @since 2.2.0 * @since 2.2.3 Added $post_id and $notification_receiver parameters in filter. * * @param string $message Email Template * @param int $post_id Post Id * @param string $notification_receiver Notification Receiver */ return apply_filters('sjb_notification_template', $message, $post_id, $notification_receiver); } /** * Email Start Template * * @since 2.4.5 * * @param int $post_id Post ID * @param string $notification_receiver Notification Receiver (Admin or HR or || Applicant) * @return string $message Email Start Template */ public static function email_start_template( $post_id, $notification_receiver ) { $header_title = ( 'applicant' != $notification_receiver ) ? esc_html__('Job Application', 'simple-job-board') : esc_html__('Job Application Acknowledgement', 'simple-job-board'); $message = '
' . date("Y/m/d") . '
' . ''; /** * Modify Email Start Template * * @since 2.4.5 * * @param string $message Email Start Template * @param int $post_id Post ID * @param string $notification_receiver Notification Receiver (Admin or HR or || Applicant) * */ return apply_filters('sjb_email_start_template', $message, $notification_receiver, $post_id); } /** * Email End Template * * @since 2.4.5 */ public static function email_end_template( $post_id, $notification_receiver ) { $message = '
' . esc_html__('I am applying for the job post', 'simple-job-board') . ' ' . esc_attr($job_title) . ' ' . esc_html__('with interest. I have attached my resume with the job application. I have also filled out the required details.', 'simple-job-board') . '
'; /** * Hook -> Applicant details. * * Add applicant's details in notification template. * * @since 2.2.3 * * @param int $post_id Post Id * @param string $notification_receiver Notification Receiver * @return string $message Message Template */ $message = apply_filters('sjb_applicant_details_notification', $message, $post_id, $notification_receiver); $message .= '' . esc_html__('I look forward to hearing from you.', 'simple-job-board') . '
' . esc_html__('Warm Regards,', 'simple-job-board') . ''; if (NULL != $applicant_name): $message.= '' . $applicant_name . ' '; else: $message.= esc_html__('Applicant', 'simple-job-board') . ' '; endif; $message .= esc_html__('has applied against your job opening', 'simple-job-board') . ' ' . esc_attr($job_title) . ' ' . esc_html__('at', 'simple-job-board') . ' ' . get_bloginfo('name') . ' ' . esc_html__("Please login to your account to download the CV or check from the applicant's list from the dashboard.", "simple-job-board") . '
'; /** * Hook -> Applicant details. * * Add applicant's details in notification template. * * @since 2.2.3 * * @param int $post_id Post Id * @param string $notification_receiver Notification Receiver * @return string $message Message Template */ $message = apply_filters('sjb_applicant_details_notification', $message, $post_id, $notification_receiver); $message .= '' . esc_html__('Your application for the position of', 'simple-job-board') . ' ' . esc_attr($job_title) . ' ' . esc_html__('at', 'simple-job-board') . ' ' . get_bloginfo('name') . ' ' . esc_html__('has been successfully submitted. You will hear back from', 'simple-job-board') . ' ' . get_bloginfo('name') . ' ' . esc_html__('based on their evaluation of your CV.', 'simple-job-board') . '
' . '' . esc_html__('Good Luck!', 'simple-job-board') . '
' . esc_html__('Best Regards,', 'simple-job-board') . '