Change the text on the Publish button

If you look into /wp-admin/edit-form-advanced.php, you will find the meta box:

add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', $post_type, 'side', 'core');

Note the __('Publish') – the function __() leads to translate() where you get the filter 'gettext'.

There are two ways to handle your problem: 1. Address the string in a single specialized function (be sure to match the correct textdomain!) or 2. use a more generic approach.

@Rarst has just now posted version 1, so I’ll add version 2. 🙂

<?php
/*
Plugin Name: Retranslate
Description: Adds translations.
Version:     0.1
Author:      Thomas Scholz
Author URI:  http://toscho.de
License:     GPL v2
*/

class Toscho_Retrans {
    // store the options
    protected $params;

    /**
     * Set up basic information
     * 
     * @param  array $options
     * @return void
     */
    public function __construct( array $options )
    {
        $defaults = array (
            'domain'       => 'default'
        ,   'context'      => 'backend'
        ,   'replacements' => array ()
        ,   'post_type'    => array ( 'post' )
        );

        $this->params = array_merge( $defaults, $options );

        // When to add the filter
        $hook = 'backend' == $this->params['context'] 
            ? 'admin_head' : 'template_redirect';

        add_action( $hook, array ( $this, 'register_filter' ) );
    }

    /**
     * Conatiner for add_filter()
     * @return void
     */
    public function register_filter()
    {
        add_filter( 'gettext', array ( $this, 'translate' ), 10, 3 );
    }

    /**
     * The real working code.
     * 
     * @param  string $translated
     * @param  string $original
     * @param  string $domain
     * @return string
     */
    public function translate( $translated, $original, $domain )
    {
        // exit early
        if ( 'backend' == $this->params['context'] )
        {
            global $post_type;

            if ( ! empty ( $post_type ) 
                && ! in_array( $post_type, $this->params['post_type'] ) )
            {
                return $translated;
            }
        }

        if ( $this->params['domain'] !== $domain )
        {
            return $translated;
        }

        // Finally replace
        return strtr( $original, $this->params['replacements'] );
    }
}

// Sample code
// Replace 'Publish' with 'Save' and 'Preview' with 'Lurk' on pages and posts
$Toscho_Retrans = new Toscho_Retrans(
    array (
        'replacements' => array ( 
            'Publish' => 'Save'
        ,   'Preview' => 'Lurk' 
        )
    ,   'post_type'    => array ( 'page', 'post' )
    )
);

You don’t need to use the code as a plugin. Including it in your theme’s functions.php will be enough.

Update

To remove the original Save button (not sure what the ‘draft’ button is), add the following code to your functions.php/a plugin:

add_action( 'admin_print_footer_scripts', 'remove_save_button' );
function remove_save_button()
{   
?>
<script>
jQuery(document).ready(function($){$('#save-post').remove();});
</script><?php
}

Yes, it’s ugly.

tech