此文本硬编码为wp-login.php 文件(第886行):
$user = new WP_Error( \'test_cookie\', sprintf( __( \'<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href="%s">enable cookies</a> to use WordPress.\' ),
__( \'https://codex.wordpress.org/Cookies\' ) ) );
正如您所见,没有用于生成它的过滤器。。。几乎没有过滤器。为什么几乎?因为它是经过翻译的,这意味着你可以使用
gettext 筛选以修改它。
function my_change_cookies_disabled_error( $translated_text, $text, $domain ) {
$default = \'<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href="%s">enable cookies</a> to use WordPress.\';
if ( $translated_text == $default ) {
$translated_text = __( \'<strong>ERROR</strong>: My error message\', \'my_text_domain\' );
}
return $translated_text;
}
add_filter( \'gettext\', \'my_change_cookies_disabled_error\', 20, 3 );