WordPress5.5版本系列中,包含主题或插件,有新版本时提示你更新,若更新失败或成功都会用邮件提示管理员

禁用主题和插件自动更新邮件通知

如果你想要彻底禁用主题和插件自动更新的邮件通知,可以使用下面的函数来实现,添加到主题的functions.php 即可生效: // 禁用插件自动更新邮件通知add_filter( 'auto_plugin_update_send_email', '__return_false' ); // 禁用主题自动更新邮件通知add_filter( 'auto_theme_update_send_email', '__return_false' );

自定义主题和插件自动更新邮件通知的内容和收件人

WordPress 5.5 新增了一个钩子 auto_plugin_theme_update_email 允许我们进行邮件自定义。以下是一个简单的示例: function myplugin_auto_plugin_theme_update_email( $email, $type, $successful_updates, $failed_updates ) { // 修改收件人邮箱 $email['to'] = 'admin@example.com'; // 修改【更新失败】的邮件标题 if ( 'fail' === $type ) { $email['subject'] = __( 'ATTN: IT Department – SOME AUTO-UPDATES WENT WRONG!', 'my-plugin' ); } return $email;}add_filter( 'auto_plugin_theme_update_email', 'myplugin_auto_plugin_theme_update_email',