conditions
3 years ago
events
3 years ago
methods
3 years ago
types
3 years ago
action-handler.php
3 years ago
action-localize.php
3 years ago
actions-tools.php
3 years ago
events-list.php
3 years ago
events-manager.php
3 years ago
manager.php
3 years ago
send-email-hooks.php
3 years ago
send-email-hooks.php
74 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Actions; |
| 5 | |
| 6 | |
| 7 | use Jet_Form_Builder\Actions\Types\Send_Email; |
| 8 | use Jet_Form_Builder\Classes\Http\Http_Tools; |
| 9 | |
| 10 | class Send_Email_Hooks { |
| 11 | |
| 12 | public static function register() { |
| 13 | add_action( |
| 14 | 'jet-form-builder/send-email/send-before', |
| 15 | array( self::class, 'basic_formatting' ) |
| 16 | ); |
| 17 | add_action( |
| 18 | 'jet-form-builder/send-email/send-before', |
| 19 | array( self::class, 'basic_content_formatting' ) |
| 20 | ); |
| 21 | add_action( |
| 22 | 'jet-form-builder/send-email/send-before', |
| 23 | array( self::class, 'content_unslash' ) |
| 24 | ); |
| 25 | } |
| 26 | |
| 27 | public static function basic_formatting( Send_Email $email ) { |
| 28 | $email->set_content( |
| 29 | jet_fb_parse_macro( $email->get_content() ) |
| 30 | ); |
| 31 | $email->set_content( |
| 32 | do_shortcode( $email->get_content() ) |
| 33 | ); |
| 34 | $email->set_subject( |
| 35 | jet_fb_parse_macro( $email->get_subject() ) |
| 36 | ); |
| 37 | $email->set_from_name( |
| 38 | jet_fb_parse_macro( $email->get_from_name() ) |
| 39 | ); |
| 40 | $email->set_from_address( |
| 41 | jet_fb_parse_macro( $email->get_from_address() ) |
| 42 | ); |
| 43 | $email->set_reply_to( |
| 44 | jet_fb_parse_macro( $email->get_reply_to() ) |
| 45 | ); |
| 46 | |
| 47 | if ( ! is_email( $email->get_reply_to() ) ) { |
| 48 | $email->set_reply_to( 'noreply@' . Http_Tools::get_site_host() ); |
| 49 | } |
| 50 | |
| 51 | if ( ! is_email( $email->get_from_address() ) ) { |
| 52 | $email->set_from_address( get_option( 'admin_email' ) ); |
| 53 | } |
| 54 | |
| 55 | $email->update_headers(); |
| 56 | } |
| 57 | |
| 58 | public static function basic_content_formatting( Send_Email $email ) { |
| 59 | $message = $email->get_content(); |
| 60 | |
| 61 | if ( $email->is_html() && empty( $email->settings['disable_format'] ) ) { |
| 62 | $message = make_clickable( wpautop( $message ) ); |
| 63 | } |
| 64 | |
| 65 | $email->set_content( |
| 66 | str_replace( '&', '&', $message ) |
| 67 | ); |
| 68 | } |
| 69 | |
| 70 | public static function content_unslash( Send_Email $email ) { |
| 71 | $email->set_content( wp_unslash( $email->get_content() ) ); |
| 72 | } |
| 73 | |
| 74 | } |