@@ -10,7 +10,9 @@ function wplf_send_email_copy( $return, $submission_id = null ) {
1010 $ form_id = intval ( ( isset ( $ submission_id ) ) ?
1111 get_post_meta ( $ submission_id , '_form_id ' , true ) : $ _POST ['_form_id ' ] );
1212
13- $ form_title = esc_html ( get_the_title ( $ form_id ) );
13+ $ form = get_post ( intval ( $ form_id ) );
14+
15+ $ form_title = esc_html ( get_the_title ( $ form ) );
1416 $ form_meta = get_post_meta ( $ form_id );
1517
1618 $ referrer = esc_url_raw ( ( isset ( $ submission_id ) ) ?
@@ -56,12 +58,31 @@ function wplf_send_email_copy( $return, $submission_id = null ) {
5658 // @codingStandardsIgnoreEnd
5759 }
5860
59- wp_mail (
60- apply_filters ( 'wplf_email_copy_to ' , $ to ),
61- apply_filters ( 'wplf_email_copy_subject ' , $ subject ),
62- apply_filters ( 'wplf_email_copy_content ' , $ content ),
63- apply_filters ( 'wplf_email_copy_headers ' , '' ),
64- apply_filters ( 'wplf_email_copy_attachments ' , array () )
65- );
61+ // default pre-filtered values for email headers and attachments
62+ $ headers = '' ;
63+ $ attachments = array ();
64+
65+ // allow filtering email fields
66+ $ to = apply_filters ( 'wplf_email_copy_to ' , $ to );
67+ $ subject = apply_filters ( 'wplf_email_copy_subject ' , $ subject );
68+ $ content = apply_filters ( 'wplf_email_copy_content ' , $ content );
69+ $ headers = apply_filters ( 'wplf_email_copy_headers ' , $ headers );
70+ $ attachments = apply_filters ( 'wplf_email_copy_attachments ' , $ attachments );
71+
72+ // form slug specific filters
73+ $ to = apply_filters ( "wplf_ {$ form ->post_name }_email_copy_to " , $ to );
74+ $ subject = apply_filters ( "wplf_ {$ form ->post_name }_email_copy_subject " , $ subject );
75+ $ content = apply_filters ( "wplf_ {$ form ->post_name }_email_copy_content " , $ content );
76+ $ headers = apply_filters ( "wplf_ {$ form ->post_name }_email_copy_headers " , $ headers );
77+ $ attachments = apply_filters ( "wplf_ {$ form ->post_name }_email_copy_attachments " , $ attachment );
78+
79+ // form ID specific filters
80+ $ to = apply_filters ( "wplf_ {$ form ->ID }_email_copy_to " , $ to );
81+ $ subject = apply_filters ( "wplf_ {$ form ->ID }_email_copy_subject " , $ subject );
82+ $ content = apply_filters ( "wplf_ {$ form ->ID }_email_copy_content " , $ content );
83+ $ headers = apply_filters ( "wplf_ {$ form ->ID }_email_copy_headers " , $ headers );
84+ $ attachments = apply_filters ( "wplf_ {$ form ->ID }_email_copy_attachments " , $ attachment );
85+
86+ wp_mail ( $ to , $ subject , $ content , $ headers , $ attachments );
6687 }
6788}
0 commit comments