这是我的解决方案,它使用update\\u option\\u*过滤器,我相信这是正确的方法。将其添加到插件或主题函数中。php文件,然后您可以在设置->常规屏幕中安全地放置逗号分隔的管理电子邮件。
add_filter(\'pre_update_option_admin_email\',\'sanitize_multiple_emails\',10,2);
function sanitize_multiple_emails($value,$oldValue)
{
//if anything is fishy, just trust wp to keep on as it would.
if(!isset($_POST["admin_email"]))
return $value;
$result = "";
$emails = explode(",",$_POST["admin_email"]);
foreach($emails as $email)
{
$email = trim($email);
$email = sanitize_email( $email );
//again, something wrong? let wp keep at it.
if(!is_email($email))
return $value;
$result .= $email.",";
}
if(strlen($result == ""))
return $value;
$result = substr($result,0,-1);
return $result;
}