First a teeny bit of background... I have a custom post type where I'd like to use custom post statuses. Since custom post statuses (stati/status/whatever), have not been fully implemented within the core, I've decided to use the gettetext filters to change the names of certain things. For example, I've changed the text "Publish" on the publish button to say "Save". I went with something like Rarst's approach here. A summary of my code is below. I'm really not going for anything drastic here as far as changing what each status does/is.
Anyway, the translation works just fine as far as PHP is concerned. However, while testing, I realized that if I click the Edit link within the misc publishing actions div, then click the cancel link that subsequently appears, my translated "Save" button will revert to a "Publish" button.
This seems to happen as a result of the javascript function updateText()
found in /wp-admin/js/post.dev.js
. I'm looking for a way to keep the JS from stomping my translation. I'd prefer not to just mess with it using DOM manipulation, but if that's my only option, I'll go for it. I'm running 3.1, btw.
<?php
class MyClass {
function __contsruct() {
add_action( 'admin_head', array ( &$this, 'load_gettext_filters' ) );
}
function load_gettext_filters() {
add_filter( 'gettext', array ( &$this, 'change_publishing_text' ), 10, 2 );
}
function change_publishing_text( $translation, $text ) {
global $post;
if ( ! isset ( $post->post_type ) ) {
return $translation;
}
if ( 'mypost' === $post->post_type ) {
if ( ( 'Publish' === $text ) ) {
return 'Save';
}
}
return $translation;
}
}