@@ -668,72 +668,75 @@ public static function get_timezone_string( $selected_zone ) {
668
668
}
669
669
670
670
public function send_email_digest () {
671
- $ to = get_option ( 'awsm_hr_email_address ' );
672
- if ( ! class_exists ( 'AWSM_Job_Openings_Settings ' ) ) {
673
- require_once AWSM_JOBS_PLUGIN_DIR . '/admin/class-awsm-job-openings-settings.php ' ;
674
- }
675
- $ default_from_email = AWSM_Job_Openings_Settings::awsm_from_email ();
676
- if ( ! empty ( $ to ) ) {
677
- $ applications = self ::get_recent_applications ( 3 );
678
- if ( ! empty ( $ applications ) ) {
679
- $ company_name = get_option ( 'awsm_job_company_name ' , '' );
680
- $ from = ( ! empty ( $ company_name ) ) ? $ company_name : get_option ( 'blogname ' );
681
- $ admin_email = get_option ( 'admin_email ' );
682
- $ from_email = get_option ( 'awsm_jobs_admin_from_email_notification ' , $ default_from_email );
683
-
684
- ob_start ();
685
- include self ::get_template_path ( 'email-digest.php ' , 'mail ' );
686
- $ mail_content = ob_get_clean ();
687
-
688
- /**
689
- * Filters the daily email digest template content.
690
- *
691
- * @since 2.0.0
692
- *
693
- * @param string $mail_content Mail template content.
694
- */
695
- $ mail_content = apply_filters ( 'awsm_jobs_email_digest_template_content ' , $ mail_content );
696
-
697
- if ( ! empty ( $ mail_content ) ) {
698
- $ tags = self ::get_mail_generic_template_tags (
699
- array (
700
- 'admin_email ' => $ admin_email ,
701
- 'hr_email ' => $ to ,
702
- 'company_name ' => $ company_name ,
703
- 'default_from_email ' => $ default_from_email ,
704
- )
705
- );
706
- $ tag_names = array_keys ( $ tags );
707
- $ tag_values = array_values ( $ tags );
708
- $ from_email = str_replace ( $ tag_names , $ tag_values , $ from_email );
709
- $ mail_content = str_replace ( $ tag_names , $ tag_values , $ mail_content );
710
- /**
711
- * Filters the daily email digest headers.
712
- *
713
- * @since 2.0.0
714
- *
715
- * @param array $headers Additional headers
716
- */
717
- $ headers = apply_filters (
718
- 'awsm_jobs_email_digest_mail_headers ' ,
719
- array (
720
- 'content_type ' => 'Content-Type: text/html; charset=UTF-8 ' ,
721
- 'from ' => sprintf ( 'From: %1$s <%2$s> ' , $ from , $ from_email ),
722
- )
723
- );
671
+ $ to = get_option ( 'awsm_hr_email_address ' );
672
+ $ enable_digest = get_option ( 'awsm_jobs_email_digest ' );
673
+ if ( $ enable_digest === 'enable ' ) {
674
+ if ( ! class_exists ( 'AWSM_Job_Openings_Settings ' ) ) {
675
+ require_once AWSM_JOBS_PLUGIN_DIR . '/admin/class-awsm-job-openings-settings.php ' ;
676
+ }
677
+ $ default_from_email = AWSM_Job_Openings_Settings::awsm_from_email ();
678
+ if ( ! empty ( $ to ) ) {
679
+ $ applications = self ::get_recent_applications ( 3 );
680
+ if ( ! empty ( $ applications ) ) {
681
+ $ company_name = get_option ( 'awsm_job_company_name ' , '' );
682
+ $ from = ( ! empty ( $ company_name ) ) ? $ company_name : get_option ( 'blogname ' );
683
+ $ admin_email = get_option ( 'admin_email ' );
684
+ $ from_email = get_option ( 'awsm_jobs_admin_from_email_notification ' , $ default_from_email );
685
+
686
+ ob_start ();
687
+ include self ::get_template_path ( 'email-digest.php ' , 'mail ' );
688
+ $ mail_content = ob_get_clean ();
724
689
725
690
/**
726
- * Filters the daily email digest subject .
691
+ * Filters the daily email digest template content .
727
692
*
728
693
* @since 2.0.0
729
694
*
730
- * @param string $subject Email subject .
695
+ * @param string $mail_content Mail template content .
731
696
*/
732
- $ subject = apply_filters ( 'awsm_jobs_email_digest_subject ' , esc_html__ ( ' Email Digest - WP Job Openings ' , ' wp-job-openings ' ) );
697
+ $ mail_content = apply_filters ( 'awsm_jobs_email_digest_template_content ' , $ mail_content );
733
698
734
- add_filter ( 'wp_mail_content_type ' , 'awsm_jobs_mail_content_type ' );
735
- wp_mail ( $ to , $ subject , $ mail_content , array_values ( $ headers ) );
736
- remove_filter ( 'wp_mail_content_type ' , 'awsm_jobs_mail_content_type ' );
699
+ if ( ! empty ( $ mail_content ) ) {
700
+ $ tags = self ::get_mail_generic_template_tags (
701
+ array (
702
+ 'admin_email ' => $ admin_email ,
703
+ 'hr_email ' => $ to ,
704
+ 'company_name ' => $ company_name ,
705
+ 'default_from_email ' => $ default_from_email ,
706
+ )
707
+ );
708
+ $ tag_names = array_keys ( $ tags );
709
+ $ tag_values = array_values ( $ tags );
710
+ $ from_email = str_replace ( $ tag_names , $ tag_values , $ from_email );
711
+ $ mail_content = str_replace ( $ tag_names , $ tag_values , $ mail_content );
712
+ /**
713
+ * Filters the daily email digest headers.
714
+ *
715
+ * @since 2.0.0
716
+ *
717
+ * @param array $headers Additional headers
718
+ */
719
+ $ headers = apply_filters (
720
+ 'awsm_jobs_email_digest_mail_headers ' ,
721
+ array (
722
+ 'content_type ' => 'Content-Type: text/html; charset=UTF-8 ' ,
723
+ 'from ' => sprintf ( 'From: %1$s <%2$s> ' , $ from , $ from_email ),
724
+ )
725
+ );
726
+
727
+ /**
728
+ * Filters the daily email digest subject.
729
+ *
730
+ * @since 2.0.0
731
+ *
732
+ * @param string $subject Email subject.
733
+ */
734
+ $ subject = apply_filters ( 'awsm_jobs_email_digest_subject ' , esc_html__ ( 'Email Digest - WP Job Openings ' , 'wp-job-openings ' ) );
735
+
736
+ add_filter ( 'wp_mail_content_type ' , 'awsm_jobs_mail_content_type ' );
737
+ wp_mail ( $ to , $ subject , $ mail_content , array_values ( $ headers ) );
738
+ remove_filter ( 'wp_mail_content_type ' , 'awsm_jobs_mail_content_type ' );
739
+ }
737
740
}
738
741
}
739
742
}
0 commit comments