I wanted to change the Publish button’s text in the Block Editor and came across this question. With the answers given it wasn’t changing the text. With the Gutenberg update, I realized it would have to be done with JavaScript. I found this response: Changing text within the Block Editor
Which I applied in my plugin code (you can insert this into your Themes functions.php file, too).
function change_publish_button_text() {
// Make sure the `wp-i18n` has been "done".
if ( wp_script_is( 'wp-i18n' ) ) :
?>
<script>
wp.i18n.setLocaleData({'Publish': ['Custom Publish Text']});
</script>
<script>
wp.i18n.setLocaleData({'Publish…': ['Custom Publish Text']});
</script>
<?php
endif;
}
add_action( 'admin_print_footer_scripts', 'change_publish_button_text', 11 );
Which to your specific request to target only on a post ID you can do this:
function change_publish_button_text() {
global $post;
if (get_the_ID() == '123') {
// Make sure the `wp-i18n` has been "done".
if ( wp_script_is( 'wp-i18n' ) ) :
?>
<script>
wp.i18n.setLocaleData({'Publish': ['Custom Publish Text']});
</script>
<script>
wp.i18n.setLocaleData({'Publish…': ['Custom Publish Text']});
</script>
<?php
endif;
}
}
add_action( 'admin_print_footer_scripts', 'change_publish_button_text', 11 );