Skip to content

Commit

Permalink
Always force <title> to 'Edit Post' (or equivalent)
Browse files Browse the repository at this point in the history
It needs to be in a more generic state. Setting the global `$title`
overrides the behavior of `get_admin_page_title()` while still letting
the value be filterable via `admin_title`.
  • Loading branch information
danielbachhuber committed Aug 10, 2018
1 parent bf770dc commit 786de1e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ function gutenberg_pre_init() {
* @return bool Whether Gutenberg was initialized.
*/
function gutenberg_init( $return, $post ) {
global $title, $post_type;

if ( true === $return && current_filter() === 'replace_editor' ) {
return $return;
}
Expand All @@ -187,6 +189,16 @@ function gutenberg_init( $return, $post ) {
add_filter( 'screen_options_show_screen', '__return_false' );
add_filter( 'admin_body_class', 'gutenberg_add_admin_body_class' );

$post_type_object = get_post_type_object( $post_type );
/**
* Always force <title> to 'Edit Post' (or equivalent)
* because it needs to be in a generic state for both
* post-new.php and post.php?post=<id>.
*/
if ( ! empty( $post_type_object ) ) {
$title = $post_type_object->labels->edit_item;
}

/**
* Remove the emoji script as it is incompatible with both React and any
* contenteditable fields.
Expand Down

0 comments on commit 786de1e

Please sign in to comment.