From 054dac262fec5fd16334c1520f4b16f5155af6c6 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Mon, 1 Nov 2021 22:31:56 +0000 Subject: [PATCH] Editor: Include post's title in editor `title` element. Include the current post title in the `title` element when editing a post. Improve accessibility by distinguishing between different edit screens in the browser tab list. Props skierpage, alexstine, audrasjb, sabernhardt. Fixes #52314. git-svn-id: https://develop.svn.wordpress.org/trunk@51969 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/admin-header.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/admin-header.php b/src/wp-admin/admin-header.php index 2f7ae3b8c5..767276b974 100644 --- a/src/wp-admin/admin-header.php +++ b/src/wp-admin/admin-header.php @@ -22,9 +22,10 @@ if ( ! defined( 'WP_ADMIN' ) ) { * @global string $update_title * @global int $total_update_count * @global string $parent_file + * @global string $typenow */ global $title, $hook_suffix, $current_screen, $wp_locale, $pagenow, - $update_title, $total_update_count, $parent_file; + $update_title, $total_update_count, $parent_file, $typenow; // Catch plugins that include admin-header.php before admin.php completes. if ( empty( $current_screen ) ) { @@ -57,6 +58,15 @@ if ( wp_is_recovery_mode() ) { $admin_title = sprintf( __( 'Recovery Mode — %s' ), $admin_title ); } +if ( 'post' === $current_screen->base && 'add' !== $current_screen->action ) { + $post_title = get_the_title(); + if ( ! empty( $post_title ) ) { + $obj = get_post_type_object( $typenow ); + /* translators: Editor admin screen title. 1: "Edit item" text for the post type, 2: Post title. */ + $admin_title = sprintf( __( '%1$s “%2$s”' ), $obj->labels->edit_item, $post_title ); + } +} + /** * Filters the title tag content for an admin page. *