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