How to prevent text modified using gettext filter being stomped (presumably) by updateText() js function within a CPT’s edit screen

First, you have nasty typo in __contsruct. 🙂

Second, your hook timing is wrong. Related WP JavaScript is localized via postL10n object (you can see it echoed in page’s source), that gets put together on init hook – way earlier then admin_head and your filter is not in place yet.

From quick test this should do it:

add_action( 'init', array ( &$this, 'load_gettext_filters' ), 9 );

Update

Ok, scratch that. Won’t work if we need context. Let’s try this:

add_action('admin_footer', array ( &$this, 'localize_post_script' ) );

    function localize_post_script() {

        global $wp_scripts;

        $wp_scripts->registered['post']->extra['l10n'][1]['publish'] = __('Publish');
    }

Leave a Comment