wp/wp-admin/admin-header.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
     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( dirname( __FILE__ ) . '/admin.php' );
       
    12 }
    12 
    13 
    13 /**
    14 /**
    14  * In case admin-header.php is included in a function.
    15  * In case admin-header.php is included in a function.
    15  *
    16  *
    16  * @global string    $title
    17  * @global string    $title
    24  */
    25  */
    25 global $title, $hook_suffix, $current_screen, $wp_locale, $pagenow,
    26 global $title, $hook_suffix, $current_screen, $wp_locale, $pagenow,
    26 	$update_title, $total_update_count, $parent_file;
    27 	$update_title, $total_update_count, $parent_file;
    27 
    28 
    28 // Catch plugins that include admin-header.php before admin.php completes.
    29 // Catch plugins that include admin-header.php before admin.php completes.
    29 if ( empty( $current_screen ) )
    30 if ( empty( $current_screen ) ) {
    30 	set_current_screen();
    31 	set_current_screen();
       
    32 }
    31 
    33 
    32 get_admin_page_title();
    34 get_admin_page_title();
    33 $title = esc_html( strip_tags( $title ) );
    35 $title = esc_html( strip_tags( $title ) );
    34 
    36 
    35 if ( is_network_admin() ) {
    37 if ( is_network_admin() ) {
    36 	/* translators: Network admin screen title. 1: Network name */
    38 	/* translators: Network admin screen title. %s: Network name */
    37 	$admin_title = sprintf( __( 'Network Admin: %s' ), esc_html( get_network()->site_name ) );
    39 	$admin_title = sprintf( __( 'Network Admin: %s' ), esc_html( get_network()->site_name ) );
    38 } elseif ( is_user_admin() ) {
    40 } elseif ( is_user_admin() ) {
    39 	/* translators: User dashboard screen title. 1: Network name */
    41 	/* translators: User dashboard screen title. %s: Network name */
    40 	$admin_title = sprintf( __( 'User Dashboard: %s' ), esc_html( get_network()->site_name ) );
    42 	$admin_title = sprintf( __( 'User Dashboard: %s' ), esc_html( get_network()->site_name ) );
    41 } else {
    43 } else {
    42 	$admin_title = get_bloginfo( 'name' );
    44 	$admin_title = get_bloginfo( 'name' );
    43 }
    45 }
    44 
    46 
    45 if ( $admin_title == $title ) {
    47 if ( $admin_title == $title ) {
    46 	/* translators: Admin screen title. 1: Admin screen name */
    48 	/* translators: Admin screen title. %s: Admin screen name */
    47 	$admin_title = sprintf( __( '%1$s — WordPress' ), $title );
    49 	$admin_title = sprintf( __( '%s — WordPress' ), $title );
    48 } else {
    50 } else {
    49 	/* 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 */
    50 	$admin_title = sprintf( __( '%1$s ‹ %2$s — WordPress' ), $title, $admin_title );
    52 	$admin_title = sprintf( __( '%1$s ‹ %2$s — WordPress' ), $title, $admin_title );
    51 }
    53 }
    52 
    54 
       
    55 if ( wp_is_recovery_mode() ) {
       
    56 	/* translators: %s: Admin screen title. */
       
    57 	$admin_title = sprintf( __( 'Recovery Mode — %s' ), $admin_title );
       
    58 }
       
    59 
    53 /**
    60 /**
    54  * Filters the title tag content for an admin page.
    61  * Filters the title tag content for an admin page.
    55  *
    62  *
    56  * @since 3.1.0
    63  * @since 3.1.0
    57  *
    64  *
    67 <title><?php echo $admin_title; ?></title>
    74 <title><?php echo $admin_title; ?></title>
    68 <?php
    75 <?php
    69 
    76 
    70 wp_enqueue_style( 'colors' );
    77 wp_enqueue_style( 'colors' );
    71 wp_enqueue_style( 'ie' );
    78 wp_enqueue_style( 'ie' );
    72 wp_enqueue_script('utils');
    79 wp_enqueue_script( 'utils' );
    73 wp_enqueue_script( 'svg-painter' );
    80 wp_enqueue_script( 'svg-painter' );
    74 
    81 
    75 $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
    82 $admin_body_class = preg_replace( '/[^a-z0-9_-]+/i', '-', $hook_suffix );
    76 ?>
    83 ?>
    77 <script type="text/javascript">
    84 <script type="text/javascript">
    78 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();}}};
    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();}}};
    79 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
    86 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
    80 	pagenow = '<?php echo $current_screen->id; ?>',
    87 	pagenow = '<?php echo $current_screen->id; ?>',
   139  *
   146  *
   140  * @since 2.1.0
   147  * @since 2.1.0
   141  */
   148  */
   142 do_action( 'admin_head' );
   149 do_action( 'admin_head' );
   143 
   150 
   144 if ( get_user_setting('mfold') == 'f' )
   151 if ( get_user_setting( 'mfold' ) == 'f' ) {
   145 	$admin_body_class .= ' folded';
   152 	$admin_body_class .= ' folded';
   146 
   153 }
   147 if ( !get_user_setting('unfold') )
   154 
       
   155 if ( ! get_user_setting( 'unfold' ) ) {
   148 	$admin_body_class .= ' auto-fold';
   156 	$admin_body_class .= ' auto-fold';
   149 
   157 }
   150 if ( is_admin_bar_showing() )
   158 
       
   159 if ( is_admin_bar_showing() ) {
   151 	$admin_body_class .= ' admin-bar';
   160 	$admin_body_class .= ' admin-bar';
   152 
   161 }
   153 if ( is_rtl() )
   162 
       
   163 if ( is_rtl() ) {
   154 	$admin_body_class .= ' rtl';
   164 	$admin_body_class .= ' rtl';
   155 
   165 }
   156 if ( $current_screen->post_type )
   166 
       
   167 if ( $current_screen->post_type ) {
   157 	$admin_body_class .= ' post-type-' . $current_screen->post_type;
   168 	$admin_body_class .= ' post-type-' . $current_screen->post_type;
   158 
   169 }
   159 if ( $current_screen->taxonomy )
   170 
       
   171 if ( $current_screen->taxonomy ) {
   160 	$admin_body_class .= ' taxonomy-' . $current_screen->taxonomy;
   172 	$admin_body_class .= ' taxonomy-' . $current_screen->taxonomy;
       
   173 }
   161 
   174 
   162 $admin_body_class .= ' branch-' . str_replace( array( '.', ',' ), '-', floatval( get_bloginfo( 'version' ) ) );
   175 $admin_body_class .= ' branch-' . str_replace( array( '.', ',' ), '-', floatval( get_bloginfo( 'version' ) ) );
   163 $admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-9]+).*/', '$1', get_bloginfo( 'version' ) ) );
   176 $admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-9]+).*/', '$1', get_bloginfo( 'version' ) ) );
   164 $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
   177 $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
   165 $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
   178 $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
   166 
   179 
   167 if ( wp_is_mobile() )
   180 if ( wp_is_mobile() ) {
   168 	$admin_body_class .= ' mobile';
   181 	$admin_body_class .= ' mobile';
   169 
   182 }
   170 if ( is_multisite() )
   183 
       
   184 if ( is_multisite() ) {
   171 	$admin_body_class .= ' multisite';
   185 	$admin_body_class .= ' multisite';
   172 
   186 }
   173 if ( is_network_admin() )
   187 
       
   188 if ( is_network_admin() ) {
   174 	$admin_body_class .= ' network-admin';
   189 	$admin_body_class .= ' network-admin';
       
   190 }
   175 
   191 
   176 $admin_body_class .= ' no-customize-support no-svg';
   192 $admin_body_class .= ' no-customize-support no-svg';
       
   193 
       
   194 if ( $current_screen->is_block_editor() ) {
       
   195 	// Default to is-fullscreen-mode to avoid jumps in the UI.
       
   196 	$admin_body_class .= ' block-editor-page is-fullscreen-mode wp-embed-responsive';
       
   197 
       
   198 	if ( current_theme_supports( 'editor-styles' ) && current_theme_supports( 'dark-editor-style' ) ) {
       
   199 		$admin_body_class .= ' is-dark-theme';
       
   200 	}
       
   201 }
   177 
   202 
   178 ?>
   203 ?>
   179 </head>
   204 </head>
   180 <?php
   205 <?php
   181 /**
   206 /**
   191  * @since 2.3.0
   216  * @since 2.3.0
   192  *
   217  *
   193  * @param string $classes Space-separated list of CSS classes.
   218  * @param string $classes Space-separated list of CSS classes.
   194  */
   219  */
   195 $admin_body_classes = apply_filters( 'admin_body_class', '' );
   220 $admin_body_classes = apply_filters( 'admin_body_class', '' );
   196 ?>
   221 $admin_body_classes = ltrim( $admin_body_classes . ' ' . $admin_body_class );
   197 <body class="wp-admin wp-core-ui no-js <?php echo $admin_body_classes . ' ' . $admin_body_class; ?>">
   222 ?>
       
   223 <body class="wp-admin wp-core-ui no-js <?php echo $admin_body_classes; ?>">
   198 <script type="text/javascript">
   224 <script type="text/javascript">
   199 	document.body.className = document.body.className.replace('no-js','js');
   225 	document.body.className = document.body.className.replace('no-js','js');
   200 </script>
   226 </script>
   201 
   227 
   202 <?php
   228 <?php
   205 	wp_customize_support_script();
   231 	wp_customize_support_script();
   206 }
   232 }
   207 ?>
   233 ?>
   208 
   234 
   209 <div id="wpwrap">
   235 <div id="wpwrap">
   210 <?php require(ABSPATH . 'wp-admin/menu-header.php'); ?>
   236 <?php require( ABSPATH . 'wp-admin/menu-header.php' ); ?>
   211 <div id="wpcontent">
   237 <div id="wpcontent">
   212 
   238 
   213 <?php
   239 <?php
   214 /**
   240 /**
   215  * Fires at the beginning of the content section in an admin page.
   241  * Fires at the beginning of the content section in an admin page.
   219 do_action( 'in_admin_header' );
   245 do_action( 'in_admin_header' );
   220 ?>
   246 ?>
   221 
   247 
   222 <div id="wpbody" role="main">
   248 <div id="wpbody" role="main">
   223 <?php
   249 <?php
   224 unset($title_class, $blog_name, $total_update_count, $update_title);
   250 unset( $blog_name, $total_update_count, $update_title );
   225 
   251 
   226 $current_screen->set_parentage( $parent_file );
   252 $current_screen->set_parentage( $parent_file );
   227 
   253 
   228 ?>
   254 ?>
   229 
   255 
   230 <div id="wpbody-content" aria-label="<?php esc_attr_e('Main content'); ?>" tabindex="0">
   256 <div id="wpbody-content">
   231 <?php
   257 <?php
   232 
   258 
   233 $current_screen->render_screen_meta();
   259 $current_screen->render_screen_meta();
   234 
   260 
   235 if ( is_network_admin() ) {
   261 if ( is_network_admin() ) {
   260  *
   286  *
   261  * @since 3.1.0
   287  * @since 3.1.0
   262  */
   288  */
   263 do_action( 'all_admin_notices' );
   289 do_action( 'all_admin_notices' );
   264 
   290 
   265 if ( $parent_file == 'options-general.php' )
   291 if ( $parent_file == 'options-general.php' ) {
   266 	require(ABSPATH . 'wp-admin/options-head.php');
   292 	require( ABSPATH . 'wp-admin/options-head.php' );
       
   293 }