你们都有正确的想法,但实际上需要两个过滤器,一个用来捕捉按钮文本,另一个用来捕捉本地化文本,所以这两者的结合。
这很有效。。
class MyClass {
function __construct() {
add_action(\'admin_head-post.php\', array ( $this, \'load_gettext_filters\' ), 1 );
add_action(\'admin_head-post-new.php\', array ( $this, \'load_gettext_filters\' ), 1 );
}
function load_gettext_filters() {
global $post_type, $wp_scripts;
if( \'YOURTYPENAMEHERE\' != $post_type )
return;
$wp_scripts->registered[\'post\']->extra[\'l10n\'][1][\'publish\'] = __(\'Save\');
add_filter( \'gettext\', array ( $this, \'change_publishing_text\' ), 10, 2 );
}
function change_publishing_text( $translation, $text ) {
if( \'Publish\' != $text )
return $translation;
return __( \'Save\' );
}
}
$MyClass = new MyClass;