Skip to content

Instantly share code, notes, and snippets.

@r-a-y
Last active August 29, 2015 13:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r-a-y/9079226 to your computer and use it in GitHub Desktop.
Save r-a-y/9079226 to your computer and use it in GitHub Desktop.
Disables email from sending on a WPMU Sitewide Tags blog.
<?php
/*
Plugin Name: WPMU Sitewide Tags - Disable Email
Description: Disables email from sending on a WPMU Sitewide Tags blog.
Author: r-a-y
Version: 0.1
*/
/**
* Disables emails from firing on the WPMU Sitewide Tags blog.
*
* @param int $new_blog The new blog ID that is being switched to.
* @param int $prev_blog_id The current blog ID before switching.
*/
function ray_disable_email_on_sitewide_tags_blog( $new_blog, $prev_blog_id ) {
if ( ! function_exists( 'get_sitewide_tags_option' ) ) {
return;
}
$sitewide_tags_blog_id = get_sitewide_tags_option( 'tags_blog_id' );
if ( $new_blog == $sitewide_tags_blog_id ) {
add_action( 'phpmailer_init', 'ray_disable_email_content', 999 );
} else {
remove_action( 'phpmailer_init', 'ray_disable_email_content', 999 );
}
}
add_action( 'switch_blog', 'ray_disable_email_on_sitewide_tags_blog', 10, 2 );
/**
* Wipes out the email content when sending an email.
*
* This will disable email sendouts since the email body will be empty.
*
* @param object $phpmailer The current $phpmailer object.
*/
function ray_disable_email_content( $phpmailer ) {
$phpmailer->IsHTML( false );
$phpmailer->AltBody = '';
$phpmailer->Body = '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment