auto_plugin_update_send_email
云策文档标注
概述
此文档介绍 WordPress 的 auto_plugin_update_send_email 过滤器,用于控制是否在自动后台插件更新后发送电子邮件通知。开发者可以通过此 Hook 自定义通知行为。
关键要点
- 过滤器名称:auto_plugin_update_send_email
- 参数:$enabled(布尔值,表示通知是否启用)和 $update_results(数组,包含插件更新结果)
- 用途:允许开发者启用或禁用自动插件更新后的电子邮件通知
- 相关函数:WP_Automatic_Updater::after_plugin_theme_update()
- 版本历史:WordPress 5.5.0 引入,5.5.1 添加 $update_results 参数
代码示例
add_filter( 'auto_plugin_update_send_email', '__return_false' );注意事项
使用此过滤器时,需确保理解自动更新机制,以避免意外禁用重要通知。建议在测试环境中验证效果。
原文内容
Filters whether to send an email following an automatic background plugin update.
Parameters
$enabledbool-
True if plugin update notifications are enabled, false otherwise.
$update_resultsarray-
The results of plugins update tasks.
Source
$notifications_enabled = apply_filters( 'auto_plugin_update_send_email', true, $update_results['plugin'] );
Skip to note 2 content
iSaumya
Disable the automated notification email that is sent via WordPress after you have enabled automatic plugin update just by using one line of code:
add_filter( 'auto_plugin_update_send_email', '__return_false' );