Last active
August 29, 2015 14:14
-
-
Save lloc/68023f7660db58523423 to your computer and use it in GitHub Desktop.
WordPress Mail Hools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Filter the wp_mail() arguments. | |
* | |
* @since 2.2.0 | |
* | |
* @param array $args A compacted array of wp_mail() arguments, including the "to" email, | |
* subject, message, headers, and attachments values. | |
*/ | |
$atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ); | |
/** | |
* Filter the email address to send from. | |
* | |
* @since 2.2.0 | |
* | |
* @param string $from_email Email address to send from. | |
*/ | |
$phpmailer->From = apply_filters( 'wp_mail_from', $from_email ); | |
/** | |
* Filter the name to associate with the "from" email address. | |
* | |
* @since 2.3.0 | |
* | |
* @param string $from_name Name associated with the "from" email address. | |
*/ | |
$phpmailer->FromName = apply_filters( 'wp_mail_from_name', $from_name ); | |
/** | |
* Filter the wp_mail() content type. | |
* | |
* @since 2.3.0 | |
* | |
* @param string $content_type Default wp_mail() content type. | |
*/ | |
$content_type = apply_filters( 'wp_mail_content_type', $content_type ); | |
/** | |
* Filter the default wp_mail() charset. | |
* | |
* @since 2.3.0 | |
* | |
* @param string $charset Default email charset. | |
*/ | |
$phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset ); | |
/** | |
* Fires after PHPMailer is initialized. | |
* | |
* @since 2.2.0 | |
* | |
* @param PHPMailer &$phpmailer The PHPMailer instance, passed by reference. | |
*/ | |
do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( defined( 'WP_DEBUG') && true == WP_DEBUG ) { | |
class MailHooksDebugger { | |
public static function create() { | |
$obj = new self(); | |
add_filter( 'wp_mail', array( $obj, 'wp_mail_arguments' ) ); | |
add_filter( 'wp_mail_from', array( $obj, 'wp_mail_from' ) ); | |
add_filter( 'wp_mail_from_name', array( $obj, 'wp_mail_from_name' ) ); | |
add_filter( 'wp_mail_content_type', array( $obj, 'wp_mail_content_type' ) ); | |
add_filter( 'wp_mail_charset', array( $obj, 'wp_mail_charset' ) ); | |
add_action( 'phpmailer_init', array( $obj, 'phpmailer_init' ) ); | |
} | |
protected function error_log( $method, $arg ) { | |
$msg = sprintf( "Filter '%s': %s", $method, print_r( $arg, true ) ); | |
error_log( $msg ); | |
return $arg; | |
} | |
function __call( $method, $arg ) { | |
return $this->error_log( $method, $arg ); | |
} | |
function phpmailer_init( &$args ) { | |
$this->error_log( __METHOD__, $args[0] ); | |
} | |
} | |
MailHooksDebugger::create(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment