无法直接设置此文本。但是,“清空垃圾”文本在显示之前通过翻译API运行。您可以劫持此翻译,用自己的字符串替换文本。
get_current_screen()
用于检查当前管理屏幕的post\\u类型,因此您可以确保只影响“任务”类型的屏幕。
add_filter( \'gettext\', \'override_empty_trash\', 50, 3 );
/**
* Override the "Empty Trash" string on admin pages for a custom post type
*
* @param string $translated_text translation of $text from previous filter calls
* @param string $text original text string
* @param string $domain translation domain
*
* @return string|void
*/
function override_empty_trash( $translated_text, $text, $domain ) {
// Skip all of these checks if not on an admin screen
if ( is_admin() ) {
if ( \'Empty Trash\' === $text ) {
// get_current_screen returns info on the admin screen, including post_type
$current_screen = get_current_screen();
if ( \'my-post-type-slug\' === $current_screen->post_type ) {
// Override the translation, but run the replacement through the translation API
$translated_text = __( \'Empty Archives\', \'my-plugin-translation-domain\' );
}
}
}
return $translated_text;
}