wp/wp-admin/admin-header.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
     4  *
     4  *
     5  * @package WordPress
     5  * @package WordPress
     6  * @subpackage Administration
     6  * @subpackage Administration
     7  */
     7  */
     8 
     8 
     9 @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
     9 header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
    10 if ( ! defined( 'WP_ADMIN' ) ) {
    10 if ( ! defined( 'WP_ADMIN' ) ) {
    11 	require_once( dirname( __FILE__ ) . '/admin.php' );
    11 	require_once __DIR__ . '/admin.php';
    12 }
    12 }
    13 
    13 
    14 /**
    14 /**
    15  * In case admin-header.php is included in a function.
    15  * In case admin-header.php is included in a function.
    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
    19  * @global WP_Screen $current_screen     WordPress current screen object.
    20  * @global WP_Locale $wp_locale
    20  * @global WP_Locale $wp_locale          WordPress date and time locale object.
    21  * @global string    $pagenow
    21  * @global string    $pagenow
    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  */
    25  */
    30 if ( empty( $current_screen ) ) {
    30 if ( empty( $current_screen ) ) {
    31 	set_current_screen();
    31 	set_current_screen();
    32 }
    32 }
    33 
    33 
    34 get_admin_page_title();
    34 get_admin_page_title();
    35 $title = esc_html( strip_tags( $title ) );
    35 $title = strip_tags( $title );
    36 
    36 
    37 if ( is_network_admin() ) {
    37 if ( is_network_admin() ) {
    38 	/* translators: Network admin screen title. %s: Network name */
    38 	/* translators: Network admin screen title. %s: Network title. */
    39 	$admin_title = sprintf( __( 'Network Admin: %s' ), esc_html( get_network()->site_name ) );
    39 	$admin_title = sprintf( __( 'Network Admin: %s' ), get_network()->site_name );
    40 } elseif ( is_user_admin() ) {
    40 } elseif ( is_user_admin() ) {
    41 	/* translators: User dashboard screen title. %s: Network name */
    41 	/* translators: User dashboard screen title. %s: Network title. */
    42 	$admin_title = sprintf( __( 'User Dashboard: %s' ), esc_html( get_network()->site_name ) );
    42 	$admin_title = sprintf( __( 'User Dashboard: %s' ), get_network()->site_name );
    43 } else {
    43 } else {
    44 	$admin_title = get_bloginfo( 'name' );
    44 	$admin_title = get_bloginfo( 'name' );
    45 }
    45 }
    46 
    46 
    47 if ( $admin_title == $title ) {
    47 if ( $admin_title === $title ) {
    48 	/* translators: Admin screen title. %s: Admin screen name */
    48 	/* translators: Admin screen title. %s: Admin screen name. */
    49 	$admin_title = sprintf( __( '%s — WordPress' ), $title );
    49 	$admin_title = sprintf( __( '%s — WordPress' ), $title );
    50 } else {
    50 } else {
    51 	/* translators: Admin screen title. 1: Admin screen name, 2: Network or site name */
    51 	/* 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 );
    52 	$admin_title = sprintf( __( '%1$s ‹ %2$s — WordPress' ), $title, $admin_title );
    53 }
    53 }
    54 
    54 
    55 if ( wp_is_recovery_mode() ) {
    55 if ( wp_is_recovery_mode() ) {
    56 	/* translators: %s: Admin screen title. */
    56 	/* translators: %s: Admin screen title. */
    69 
    69 
    70 wp_user_settings();
    70 wp_user_settings();
    71 
    71 
    72 _wp_admin_html_begin();
    72 _wp_admin_html_begin();
    73 ?>
    73 ?>
    74 <title><?php echo $admin_title; ?></title>
    74 <title><?php echo esc_html( $admin_title ); ?></title>
    75 <?php
    75 <?php
    76 
    76 
    77 wp_enqueue_style( 'colors' );
    77 wp_enqueue_style( 'colors' );
    78 wp_enqueue_style( 'ie' );
       
    79 wp_enqueue_script( 'utils' );
    78 wp_enqueue_script( 'utils' );
    80 wp_enqueue_script( 'svg-painter' );
    79 wp_enqueue_script( 'svg-painter' );
    81 
    80 
    82 $admin_body_class = preg_replace( '/[^a-z0-9_-]+/i', '-', $hook_suffix );
    81 $admin_body_class = preg_replace( '/[^a-z0-9_-]+/i', '-', $hook_suffix );
    83 ?>
    82 ?>
    84 <script type="text/javascript">
    83 <script type="text/javascript">
    85 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();}}};
    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();}}};
    86 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
    85 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
    87 	pagenow = '<?php echo $current_screen->id; ?>',
    86 	pagenow = '<?php echo $current_screen->id; ?>',
    88 	typenow = '<?php echo $current_screen->post_type; ?>',
    87 	typenow = '<?php echo $current_screen->post_type; ?>',
    89 	adminpage = '<?php echo $admin_body_class; ?>',
    88 	adminpage = '<?php echo $admin_body_class; ?>',
    90 	thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
    89 	thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
    91 	decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
    90 	decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
    92 	isRtl = <?php echo (int) is_rtl(); ?>;
    91 	isRtl = <?php echo (int) is_rtl(); ?>;
    93 </script>
    92 </script>
    94 <meta name="viewport" content="width=device-width,initial-scale=1.0">
       
    95 <?php
    93 <?php
    96 
    94 
    97 /**
    95 /**
    98  * Enqueue scripts for all admin pages.
    96  * Enqueue scripts for all admin pages.
    99  *
    97  *
   106 /**
   104 /**
   107  * Fires when styles are printed for a specific admin page based on $hook_suffix.
   105  * Fires when styles are printed for a specific admin page based on $hook_suffix.
   108  *
   106  *
   109  * @since 2.6.0
   107  * @since 2.6.0
   110  */
   108  */
   111 do_action( "admin_print_styles-{$hook_suffix}" );
   109 do_action( "admin_print_styles-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
   112 
   110 
   113 /**
   111 /**
   114  * Fires when styles are printed for all admin pages.
   112  * Fires when styles are printed for all admin pages.
   115  *
   113  *
   116  * @since 2.6.0
   114  * @since 2.6.0
   120 /**
   118 /**
   121  * Fires when scripts are printed for a specific admin page based on $hook_suffix.
   119  * Fires when scripts are printed for a specific admin page based on $hook_suffix.
   122  *
   120  *
   123  * @since 2.1.0
   121  * @since 2.1.0
   124  */
   122  */
   125 do_action( "admin_print_scripts-{$hook_suffix}" );
   123 do_action( "admin_print_scripts-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
   126 
   124 
   127 /**
   125 /**
   128  * Fires when scripts are printed for all admin pages.
   126  * Fires when scripts are printed for all admin pages.
   129  *
   127  *
   130  * @since 2.1.0
   128  * @since 2.1.0
   137  * The dynamic portion of the hook, `$hook_suffix`, refers to the hook suffix
   135  * The dynamic portion of the hook, `$hook_suffix`, refers to the hook suffix
   138  * for the admin page.
   136  * for the admin page.
   139  *
   137  *
   140  * @since 2.1.0
   138  * @since 2.1.0
   141  */
   139  */
   142 do_action( "admin_head-{$hook_suffix}" );
   140 do_action( "admin_head-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
   143 
   141 
   144 /**
   142 /**
   145  * Fires in head section for all admin pages.
   143  * Fires in head section for all admin pages.
   146  *
   144  *
   147  * @since 2.1.0
   145  * @since 2.1.0
   148  */
   146  */
   149 do_action( 'admin_head' );
   147 do_action( 'admin_head' );
   150 
   148 
   151 if ( get_user_setting( 'mfold' ) == 'f' ) {
   149 if ( 'f' === get_user_setting( 'mfold' ) ) {
   152 	$admin_body_class .= ' folded';
   150 	$admin_body_class .= ' folded';
   153 }
   151 }
   154 
   152 
   155 if ( ! get_user_setting( 'unfold' ) ) {
   153 if ( ! get_user_setting( 'unfold' ) ) {
   156 	$admin_body_class .= ' auto-fold';
   154 	$admin_body_class .= ' auto-fold';
   198 	if ( current_theme_supports( 'editor-styles' ) && current_theme_supports( 'dark-editor-style' ) ) {
   196 	if ( current_theme_supports( 'editor-styles' ) && current_theme_supports( 'dark-editor-style' ) ) {
   199 		$admin_body_class .= ' is-dark-theme';
   197 		$admin_body_class .= ' is-dark-theme';
   200 	}
   198 	}
   201 }
   199 }
   202 
   200 
       
   201 $error = error_get_last();
       
   202 
       
   203 // Print a CSS class to make PHP errors visible.
       
   204 if ( $error && WP_DEBUG && WP_DEBUG_DISPLAY && ini_get( 'display_errors' )
       
   205 	// Don't print the class for PHP notices in wp-config.php, as they happen before WP_DEBUG takes effect,
       
   206 	// and should not be displayed with the `error_reporting` level previously set in wp-load.php.
       
   207 	&& ( E_NOTICE !== $error['type'] || 'wp-config.php' !== wp_basename( $error['file'] ) )
       
   208 ) {
       
   209 	$admin_body_class .= ' php-error';
       
   210 }
       
   211 
       
   212 unset( $error );
       
   213 
   203 ?>
   214 ?>
   204 </head>
   215 </head>
   205 <?php
   216 <?php
   206 /**
   217 /**
   207  * Filters the CSS classes for the body tag in the admin.
   218  * Filters the CSS classes for the body tag in the admin.
   231 	wp_customize_support_script();
   242 	wp_customize_support_script();
   232 }
   243 }
   233 ?>
   244 ?>
   234 
   245 
   235 <div id="wpwrap">
   246 <div id="wpwrap">
   236 <?php require( ABSPATH . 'wp-admin/menu-header.php' ); ?>
   247 <?php require ABSPATH . 'wp-admin/menu-header.php'; ?>
   237 <div id="wpcontent">
   248 <div id="wpcontent">
   238 
   249 
   239 <?php
   250 <?php
   240 /**
   251 /**
   241  * Fires at the beginning of the content section in an admin page.
   252  * Fires at the beginning of the content section in an admin page.
   286  *
   297  *
   287  * @since 3.1.0
   298  * @since 3.1.0
   288  */
   299  */
   289 do_action( 'all_admin_notices' );
   300 do_action( 'all_admin_notices' );
   290 
   301 
   291 if ( $parent_file == 'options-general.php' ) {
   302 if ( 'options-general.php' === $parent_file ) {
   292 	require( ABSPATH . 'wp-admin/options-head.php' );
   303 	require ABSPATH . 'wp-admin/options-head.php';
   293 }
   304 }