Last active
May 2, 2023 16:52
-
-
Save afragen/e2f40ed2e71e590a127e8adc1db05948 to your computer and use it in GitHub Desktop.
Stop success update email for plugin/theme auto updates.
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 | |
/** | |
* Stop success email from auto-updates. | |
* | |
* @package StopAutoUpdateSuccessEmail | |
* | |
* Plugin Name: Stop Auto-update Success Email | |
* Plugin URI: https://gist.github.com/afragen/e2f40ed2e71e590a127e8adc1db05948 | |
* Description: Stop success email from auto-updates. | |
* Version: 0.2.0 | |
* Author: WordPress Core Contributors | |
* License: MIT | |
* Requires at least: 5.2 | |
* Requires PHP: 5.6 | |
* Gist Plugin URI: https://gist.github.com/afragen/e2f40ed2e71e590a127e8adc1db05948 | |
*/ | |
add_filter( 'auto_plugin_update_send_email', 'send_email_on_failure', 10, 2 ); | |
add_filter( 'auto_theme_update_send_email', 'send_email_on_failure', 10, 2 ); | |
/** | |
* Sends update emails only when at least one plugin/theme update has failed. | |
* | |
* @param bool $enabled Whether the update email is enabled. | |
* @param array $update_results An array of update results. | |
* @return bool | |
*/ | |
function send_email_on_failure( $enabled, $update_results ) { | |
foreach ( $update_results as $update_result ) { | |
if ( true !== $update_result->result ) { | |
return true; | |
} | |
} | |
return false; | |
} |
Should now disable success email for both plugins and themes.
Thanks Andy!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lets turn it around:
Tutorial added here: https://easywebdesigntutorials.com/how-to-disable-update-emails-on-success/