Se você olhar em /wp-admin/edit-form-advanced.php
, encontrará a meta box:
add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', $post_type, 'side', 'core');
Observe o __('Publish')
- a função __()
leva a translate()
, onde você obtém o filtro 'gettext'
.
Existem duas maneiras de lidar com o seu problema: 1. Enderece a string em uma única função especializada (certifique-se de combinar o texto correto!) ou 2. use uma abordagem mais genérica.
@Rarst lançou agora a versão 1, então adicionarei a versão 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' )
)
);
Você não precisa usar o código como um plugin. Incluindo-o nas funções do seu tema.php será suficiente.
Atualizar
Para remover o botão Salvar original (não sei qual é o botão 'rascunho'), adicione o seguinte código ao seu plugin functions.php / a:
add_action( 'admin_print_footer_scripts', 'remove_save_button' );
function remove_save_button()
{
?>
<script>
jQuery(document).ready(function($){$('#save-post').remove();});
</script><?php
}
Sim, é feio.