wp/wp-admin/admin-header.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
    16  *
    16  *
    17  * @global string    $title
    17  * @global string    $title
    18  * @global string    $hook_suffix
    18  * @global string    $hook_suffix
    19  * @global WP_Screen $current_screen     WordPress current screen object.
    19  * @global WP_Screen $current_screen     WordPress current screen object.
    20  * @global WP_Locale $wp_locale          WordPress date and time locale object.
    20  * @global WP_Locale $wp_locale          WordPress date and time locale object.
    21  * @global string    $pagenow
    21  * @global string    $pagenow            The filename of the current screen.
    22  * @global string    $update_title
    22  * @global string    $update_title
    23  * @global int       $total_update_count
    23  * @global int       $total_update_count
    24  * @global string    $parent_file
    24  * @global string    $parent_file
       
    25  * @global string    $typenow            The post type of the current screen.
    25  */
    26  */
    26 global $title, $hook_suffix, $current_screen, $wp_locale, $pagenow,
    27 global $title, $hook_suffix, $current_screen, $wp_locale, $pagenow,
    27 	$update_title, $total_update_count, $parent_file;
    28 	$update_title, $total_update_count, $parent_file, $typenow;
    28 
    29 
    29 // Catch plugins that include admin-header.php before admin.php completes.
    30 // Catch plugins that include admin-header.php before admin.php completes.
    30 if ( empty( $current_screen ) ) {
    31 if ( empty( $current_screen ) ) {
    31 	set_current_screen();
    32 	set_current_screen();
    32 }
    33 }
    46 
    47 
    47 if ( $admin_title === $title ) {
    48 if ( $admin_title === $title ) {
    48 	/* translators: Admin screen title. %s: Admin screen name. */
    49 	/* translators: Admin screen title. %s: Admin screen name. */
    49 	$admin_title = sprintf( __( '%s — WordPress' ), $title );
    50 	$admin_title = sprintf( __( '%s — WordPress' ), $title );
    50 } else {
    51 } else {
       
    52 	$screen_title = $title;
       
    53 
       
    54 	if ( 'post' === $current_screen->base && 'add' !== $current_screen->action ) {
       
    55 		$post_title = get_the_title();
       
    56 		if ( ! empty( $post_title ) ) {
       
    57 			$post_type_obj = get_post_type_object( $typenow );
       
    58 			$screen_title  = sprintf(
       
    59 				/* translators: Editor admin screen title. 1: "Edit item" text for the post type, 2: Post title. */
       
    60 				__( '%1$s “%2$s”' ),
       
    61 				$post_type_obj->labels->edit_item,
       
    62 				$post_title
       
    63 			);
       
    64 		}
       
    65 	}
       
    66 
    51 	/* translators: Admin screen title. 1: Admin screen name, 2: Network or site name. */
    67 	/* translators: Admin screen title. 1: Admin screen name, 2: Network or site name. */
    52 	$admin_title = sprintf( __( '%1$s ‹ %2$s — WordPress' ), $title, $admin_title );
    68 	$admin_title = sprintf( __( '%1$s ‹ %2$s — WordPress' ), $screen_title, $admin_title );
    53 }
    69 }
    54 
    70 
    55 if ( wp_is_recovery_mode() ) {
    71 if ( wp_is_recovery_mode() ) {
    56 	/* translators: %s: Admin screen title. */
    72 	/* translators: %s: Admin screen title. */
    57 	$admin_title = sprintf( __( 'Recovery Mode — %s' ), $admin_title );
    73 	$admin_title = sprintf( __( 'Recovery Mode — %s' ), $admin_title );
    79 wp_enqueue_script( 'svg-painter' );
    95 wp_enqueue_script( 'svg-painter' );
    80 
    96 
    81 $admin_body_class = preg_replace( '/[^a-z0-9_-]+/i', '-', $hook_suffix );
    97 $admin_body_class = preg_replace( '/[^a-z0-9_-]+/i', '-', $hook_suffix );
    82 ?>
    98 ?>
    83 <script type="text/javascript">
    99 <script type="text/javascript">
    84 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();}}};
   100 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();}}};
    85 var ajaxurl = '<?php echo esc_js( admin_url( 'admin-ajax.php', 'relative' ) ); ?>',
   101 var ajaxurl = '<?php echo esc_js( admin_url( 'admin-ajax.php', 'relative' ) ); ?>',
    86 	pagenow = '<?php echo esc_js( $current_screen->id ); ?>',
   102 	pagenow = '<?php echo esc_js( $current_screen->id ); ?>',
    87 	typenow = '<?php echo esc_js( $current_screen->post_type ); ?>',
   103 	typenow = '<?php echo esc_js( $current_screen->post_type ); ?>',
    88 	adminpage = '<?php echo esc_js( $admin_body_class ); ?>',
   104 	adminpage = '<?php echo esc_js( $admin_body_class ); ?>',
    89 	thousandsSeparator = '<?php echo esc_js( $wp_locale->number_format['thousands_sep'] ); ?>',
   105 	thousandsSeparator = '<?php echo esc_js( $wp_locale->number_format['thousands_sep'] ); ?>',
   130 do_action( 'admin_print_scripts' );
   146 do_action( 'admin_print_scripts' );
   131 
   147 
   132 /**
   148 /**
   133  * Fires in head section for a specific admin page.
   149  * Fires in head section for a specific admin page.
   134  *
   150  *
   135  * The dynamic portion of the hook, `$hook_suffix`, refers to the hook suffix
   151  * The dynamic portion of the hook name, `$hook_suffix`, refers to the hook suffix
   136  * for the admin page.
   152  * for the admin page.
   137  *
   153  *
   138  * @since 2.1.0
   154  * @since 2.1.0
   139  */
   155  */
   140 do_action( "admin_head-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
   156 do_action( "admin_head-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores