| Conditions | 6 |
| Paths | 24 |
| Total Lines | 29 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 6.3949 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php namespace EmailLog\Core; |
||
| 25 | 2 | public function log_email( $mail_info ) { |
|
| 26 | 2 | $email_log = email_log(); |
|
| 27 | |||
| 28 | $data = array( |
||
| 29 | 2 | 'attachments' => ( count( $mail_info['attachments'] ) > 0 ) ? 'true' : 'false', |
|
| 30 | 2 | 'to_email' => is_array( $mail_info['to'] ) ? implode( ',', $mail_info['to'] ) : $mail_info['to'], |
|
| 31 | 2 | 'subject' => $mail_info['subject'], |
|
| 32 | 2 | 'headers' => is_array( $mail_info['headers'] ) ? implode( "\n", $mail_info['headers'] ) : $mail_info['headers'], |
|
| 33 | 2 | 'sent_date' => current_time( 'mysql' ), |
|
| 34 | 2 | ); |
|
| 35 | |||
| 36 | 2 | $message = ''; |
|
| 37 | |||
| 38 | 2 | if ( isset( $mail_info['message'] ) ) { |
|
| 39 | $message = $mail_info['message']; |
||
| 40 | } else { |
||
| 41 | // wpmandrill plugin is changing "message" key to "html". See https://github.com/sudar/email-log/issues/20 |
||
| 42 | // Ideally this should be fixed in wpmandrill, but I am including this hack here till it is fixed by them. |
||
| 43 | 2 | if ( isset( $mail_info['html'] ) ) { |
|
| 44 | $message = $mail_info['html']; |
||
| 45 | } |
||
| 46 | } |
||
| 47 | |||
| 48 | 2 | $data['message'] = $message; |
|
| 49 | |||
| 50 | 2 | $email_log->table_manager->insert_log( $data ); |
|
| 51 | |||
| 52 | 2 | return $mail_info; |
|
| 53 | } |
||
| 54 | } |