| @@ -1,8 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace WPDataAccess\Utilities { |
| 4 | 4 | |
| 5 | + use WPDataAccess\WPDA; | |
| 6 | + | |
| 5 | 7 | class WPDA_Mail { |
| 6 | 8 | |
| 7 | 9 | const WPDA_MAIL_SERVER_OPTION = 'wpda_mail_server'; |
| 8 | 10 | const CIPHER = 'AES-256-CBC'; |
| @@ -15,8 +17,10 @@ | ||
| 15 | 17 | $attachments = array() |
| 16 | 18 | ) { |
| 17 | 19 | |
| 18 | 20 | ob_start(); |
| 21 | + | |
| 22 | + do_action( 'wpda_sending_mail' ); | |
| 19 | 23 | $result = wp_mail( |
| 20 | 24 | $to, |
| 21 | 25 | $subject, |
| 22 | 26 | $message, |
| @@ -24,8 +28,9 @@ | ||
| 24 | 28 | 'Content-Type: text/html; charset=UTF-8', |
| 25 | 29 | ), |
| 26 | 30 | $attachments |
| 27 | 31 | ); |
| 32 | + | |
| 28 | 33 | $output = ob_get_clean(); |
| 29 | 34 | |
| 30 | 35 | if ( $result ) { |
| 31 | 36 | return array( |
| @@ -39,8 +44,25 @@ | ||
| 39 | 44 | 'debug' => $output, |
| 40 | 45 | 'message' => 'Failed to process request', |
| 41 | 46 | ); |
| 42 | 47 | } |
| 48 | + | |
| 49 | + } | |
| 50 | + | |
| 51 | + public static function mail_activated() { | |
| 52 | + | |
| 53 | + $mail = self::get_option(); | |
| 54 | + if ( | |
| 55 | + false !== $mail && | |
| 56 | + ( | |
| 57 | + ! isset( $mail['activate'] ) || | |
| 58 | + 'on' === $mail['activate'] | |
| 59 | + ) | |
| 60 | + ) { | |
| 61 | + return true; | |
| 62 | + } | |
| 63 | + | |
| 64 | + return false; | |
| 43 | 65 | |
| 44 | 66 | } |
| 45 | 67 | |
| 46 | 68 | public static function get_option() { |