Completed
Pull Request — master (#236)
by Sudar
28:57 queued 21:51
created

el_fix_compatibility_with_wpmandrill()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 5
c 1
b 0
f 0
nc 3
nop 2
dl 0
loc 10
rs 10
1
<?php
2
/**
3
 * Fixes compatibility issues with wpmandrill plugin.
4
 *
5
 * The wpmandrill plugin is changing "message" key to "html".
6
 *
7
 * @see https://github.com/sudar/email-log/issues/20
8
 *
9
 * Ideally this should be fixed in wpmandrill, but I am including this hack here till it is fixed by them.
10
 * This will be eventually removed once it is fixed in the original plugin.
11
 * @since 2.3.2
12
 */
13
defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
14
15
/**
16
 * Fix compatiblity issue with wpmandrill plguin.
17
 * The wpmandrill plugin is changing "message" key to "html".
18
 *
19
 * @since 2.3.2
20
 *
21
 * @param array $log       Log that is going to be inserted.
22
 * @param array $mail_info Original mail info that was sent.
23
 *
24
 * @return array Modified log.
25
 */
26
function el_fix_compatibility_with_wpmandrill( $log, $mail_info ) {
27
	if ( ! empty( $log['message'] ) ) {
28
		return $log;
29
	}
30
31
	if ( isset( $mail_info['html'] ) && ! empty( $mail_info['html'] ) ) {
32
		$log['message'] = $mail_info['html'];
33
	}
34
35
	return $log;
36
}
37
add_filter( 'el_email_log_before_insert', 'el_fix_compatibility_with_wpmandrill', 10, 2 );
38