wp/wp-admin/admin-header.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
--- a/wp/wp-admin/admin-header.php	Wed Sep 21 18:19:35 2022 +0200
+++ b/wp/wp-admin/admin-header.php	Tue Sep 27 16:37:53 2022 +0200
@@ -18,13 +18,14 @@
  * @global string    $hook_suffix
  * @global WP_Screen $current_screen     WordPress current screen object.
  * @global WP_Locale $wp_locale          WordPress date and time locale object.
- * @global string    $pagenow
+ * @global string    $pagenow            The filename of the current screen.
  * @global string    $update_title
  * @global int       $total_update_count
  * @global string    $parent_file
+ * @global string    $typenow            The post type of the current screen.
  */
 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 ) ) {
@@ -48,8 +49,23 @@
 	/* translators: Admin screen title. %s: Admin screen name. */
 	$admin_title = sprintf( __( '%s — WordPress' ), $title );
 } else {
+	$screen_title = $title;
+
+	if ( 'post' === $current_screen->base && 'add' !== $current_screen->action ) {
+		$post_title = get_the_title();
+		if ( ! empty( $post_title ) ) {
+			$post_type_obj = get_post_type_object( $typenow );
+			$screen_title  = sprintf(
+				/* translators: Editor admin screen title. 1: "Edit item" text for the post type, 2: Post title. */
+				__( '%1$s “%2$s”' ),
+				$post_type_obj->labels->edit_item,
+				$post_title
+			);
+		}
+	}
+
 	/* translators: Admin screen title. 1: Admin screen name, 2: Network or site name. */
-	$admin_title = sprintf( __( '%1$s ‹ %2$s — WordPress' ), $title, $admin_title );
+	$admin_title = sprintf( __( '%1$s ‹ %2$s — WordPress' ), $screen_title, $admin_title );
 }
 
 if ( wp_is_recovery_mode() ) {
@@ -81,7 +97,7 @@
 $admin_body_class = preg_replace( '/[^a-z0-9_-]+/i', '-', $hook_suffix );
 ?>
 <script type="text/javascript">
-addLoadEvent = function(func){if(typeof jQuery!=='undefined')jQuery(document).ready(func);else if(typeof wpOnload!=='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
+addLoadEvent = function(func){if(typeof jQuery!=='undefined')jQuery(function(){func();});else if(typeof wpOnload!=='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
 var ajaxurl = '<?php echo esc_js( admin_url( 'admin-ajax.php', 'relative' ) ); ?>',
 	pagenow = '<?php echo esc_js( $current_screen->id ); ?>',
 	typenow = '<?php echo esc_js( $current_screen->post_type ); ?>',
@@ -132,7 +148,7 @@
 /**
  * Fires in head section for a specific admin page.
  *
- * The dynamic portion of the hook, `$hook_suffix`, refers to the hook suffix
+ * The dynamic portion of the hook name, `$hook_suffix`, refers to the hook suffix
  * for the admin page.
  *
  * @since 2.1.0