wp/wp-admin/admin-header.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
    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 // In case admin-header.php is included in a function.
    13 // In case admin-header.php is included in a function.
    14 global $title, $hook_suffix, $current_screen, $wp_locale, $pagenow, $wp_version,
    14 global $title, $hook_suffix, $current_screen, $wp_locale, $pagenow, $wp_version,
    15 	$current_site, $update_title, $total_update_count, $parent_file;
    15 	$update_title, $total_update_count, $parent_file;
    16 
    16 
    17 // Catch plugins that include admin-header.php before admin.php completes.
    17 // Catch plugins that include admin-header.php before admin.php completes.
    18 if ( empty( $current_screen ) )
    18 if ( empty( $current_screen ) )
    19 	set_current_screen();
    19 	set_current_screen();
    20 
    20 
    21 get_admin_page_title();
    21 get_admin_page_title();
    22 $title = esc_html( strip_tags( $title ) );
    22 $title = esc_html( strip_tags( $title ) );
    23 
    23 
    24 if ( is_network_admin() )
    24 if ( is_network_admin() )
    25 	$admin_title = sprintf( __('Network Admin: %s'), esc_html( $current_site->site_name ) );
    25 	$admin_title = sprintf( __( 'Network Admin: %s' ), esc_html( get_current_site()->site_name ) );
    26 elseif ( is_user_admin() )
    26 elseif ( is_user_admin() )
    27 	$admin_title = sprintf( __('Global Dashboard: %s'), esc_html( $current_site->site_name ) );
    27 	$admin_title = sprintf( __( 'Global Dashboard: %s' ), esc_html( get_current_site()->site_name ) );
    28 else
    28 else
    29 	$admin_title = get_bloginfo( 'name' );
    29 	$admin_title = get_bloginfo( 'name' );
    30 
    30 
    31 if ( $admin_title == $title )
    31 if ( $admin_title == $title )
    32 	$admin_title = sprintf( __( '%1$s — WordPress' ), $title );
    32 	$admin_title = sprintf( __( '%1$s — WordPress' ), $title );
    33 else
    33 else
    34 	$admin_title = sprintf( __( '%1$s ‹ %2$s — WordPress' ), $title, $admin_title );
    34 	$admin_title = sprintf( __( '%1$s ‹ %2$s — WordPress' ), $title, $admin_title );
    35 
    35 
    36 /**
    36 /**
    37  * Filter the <title> content for an admin page.
    37  * Filter the title tag content for an admin page.
    38  *
    38  *
    39  * @since 3.1.0
    39  * @since 3.1.0
    40  *
    40  *
    41  * @param string $admin_title The page title, with extra context added.
    41  * @param string $admin_title The page title, with extra context added.
    42  * @param string $title       The original page title.
    42  * @param string $title       The original page title.
    51 <?php
    51 <?php
    52 
    52 
    53 wp_enqueue_style( 'colors' );
    53 wp_enqueue_style( 'colors' );
    54 wp_enqueue_style( 'ie' );
    54 wp_enqueue_style( 'ie' );
    55 wp_enqueue_script('utils');
    55 wp_enqueue_script('utils');
       
    56 wp_enqueue_script( 'svg-painter' );
    56 
    57 
    57 $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
    58 $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
    58 ?>
    59 ?>
    59 <script type="text/javascript">
    60 <script type="text/javascript">
    60 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();}}};
    61 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();}}};
    64 	adminpage = '<?php echo $admin_body_class; ?>',
    65 	adminpage = '<?php echo $admin_body_class; ?>',
    65 	thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
    66 	thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
    66 	decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
    67 	decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
    67 	isRtl = <?php echo (int) is_rtl(); ?>;
    68 	isRtl = <?php echo (int) is_rtl(); ?>;
    68 </script>
    69 </script>
       
    70 <meta name="viewport" content="width=device-width,initial-scale=1.0">
    69 <?php
    71 <?php
    70 
    72 
    71 /**
    73 /**
    72  * Enqueue scripts for all admin pages.
    74  * Enqueue scripts for all admin pages.
    73  *
    75  *
    76  * @param string $hook_suffix The current admin page.
    78  * @param string $hook_suffix The current admin page.
    77  */
    79  */
    78 do_action( 'admin_enqueue_scripts', $hook_suffix );
    80 do_action( 'admin_enqueue_scripts', $hook_suffix );
    79 
    81 
    80 /**
    82 /**
    81  * Print styles for a specific admin page based on $hook_suffix.
    83  * Fires when styles are printed for a specific admin page based on $hook_suffix.
    82  *
    84  *
    83  * @since 2.6.0
    85  * @since 2.6.0
    84  */
    86  */
    85 do_action( "admin_print_styles-$hook_suffix" );
    87 do_action( "admin_print_styles-$hook_suffix" );
    86 
    88 
    87 /**
    89 /**
    88  * Print styles for all admin pages.
    90  * Fires when styles are printed for all admin pages.
    89  *
    91  *
    90  * @since 2.6.0
    92  * @since 2.6.0
    91  */
    93  */
    92 do_action( 'admin_print_styles' );
    94 do_action( 'admin_print_styles' );
    93 
    95 
    94 /**
    96 /**
    95  * Print scripts for a specific admin page based on $hook_suffix.
    97  * Fires when scripts are printed for a specific admin page based on $hook_suffix.
    96  *
    98  *
    97  * @since 2.1.0
    99  * @since 2.1.0
    98  */
   100  */
    99 do_action( "admin_print_scripts-$hook_suffix" );
   101 do_action( "admin_print_scripts-$hook_suffix" );
   100 
   102 
   101 /**
   103 /**
   102  * Print scripts for all admin pages.
   104  * Fires when scripts are printed for all admin pages.
   103  *
   105  *
   104  * @since 2.1.0
   106  * @since 2.1.0
   105  */
   107  */
   106 do_action( 'admin_print_scripts' );
   108 do_action( 'admin_print_scripts' );
   107 
   109 
   108 /**
   110 /**
   109  * Fires in <head> for a specific admin page based on $hook_suffix.
   111  * Fires in head section for a specific admin page.
       
   112  *
       
   113  * The dynamic portion of the hook, `$hook_suffix`, refers to the hook suffix
       
   114  * for the admin page.
   110  *
   115  *
   111  * @since 2.1.0
   116  * @since 2.1.0
   112  */
   117  */
   113 do_action( "admin_head-$hook_suffix" );
   118 do_action( "admin_head-$hook_suffix" );
   114 
   119 
   115 /**
   120 /**
   116  * Fires in <head> for all admin pages.
   121  * Fires in head section for all admin pages.
   117  *
   122  *
   118  * @since 2.1.0
   123  * @since 2.1.0
   119  */
   124  */
   120 do_action( 'admin_head' );
   125 do_action( 'admin_head' );
   121 
   126 
   143 $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
   148 $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
   144 
   149 
   145 if ( wp_is_mobile() )
   150 if ( wp_is_mobile() )
   146 	$admin_body_class .= ' mobile';
   151 	$admin_body_class .= ' mobile';
   147 
   152 
   148 $admin_body_class .= ' no-customize-support';
   153 if ( is_multisite() )
       
   154 	$admin_body_class .= ' multisite';
       
   155 
       
   156 if ( is_network_admin() )
       
   157 	$admin_body_class .= ' network-admin';
       
   158 
       
   159 $admin_body_class .= ' no-customize-support no-svg';
   149 
   160 
   150 ?>
   161 ?>
   151 </head>
   162 </head>
   152 <?php
   163 <?php
   153 /**
   164 /**
   154  * Filter the admin <body> CSS classes.
   165  * Filter the CSS classes for the body tag in the admin.
   155  *
   166  *
   156  * This filter differs from the post_class or body_class filters in two important ways:
   167  * This filter differs from the {@see 'post_class'} and {@see 'body_class'} filters
   157  * 1. $classes is a space-separated string of class names instead of an array.
   168  * in two important ways:
   158  * 2. Not all core admin classes are filterable, notably: wp-admin, wp-core-ui, and no-js cannot be removed.
   169  *
       
   170  * 1. `$classes` is a space-separated string of class names instead of an array.
       
   171  * 2. Not all core admin classes are filterable, notably: wp-admin, wp-core-ui,
       
   172  *    and no-js cannot be removed.
   159  *
   173  *
   160  * @since 2.3.0
   174  * @since 2.3.0
   161  *
   175  *
   162  * @param string $classes Space-separated string of CSS classes.
   176  * @param string $classes Space-separated list of CSS classes.
   163  */
   177  */
   164 ?>
   178 $admin_body_classes = apply_filters( 'admin_body_class', '' );
   165 <body class="wp-admin wp-core-ui no-js <?php echo apply_filters( 'admin_body_class', '' ) . " $admin_body_class"; ?>">
   179 ?>
       
   180 <body class="wp-admin wp-core-ui no-js <?php echo $admin_body_classes . ' ' . $admin_body_class; ?>">
   166 <script type="text/javascript">
   181 <script type="text/javascript">
   167 	document.body.className = document.body.className.replace('no-js','js');
   182 	document.body.className = document.body.className.replace('no-js','js');
   168 </script>
   183 </script>
   169 
   184 
   170 <?php
   185 <?php
   171 // Make sure the customize body classes are correct as early as possible.
   186 // Make sure the customize body classes are correct as early as possible.
   172 if ( current_user_can( 'edit_theme_options' ) )
   187 if ( current_user_can( 'customize' ) ) {
   173 	wp_customize_support_script();
   188 	wp_customize_support_script();
       
   189 }
   174 ?>
   190 ?>
   175 
   191 
   176 <div id="wpwrap">
   192 <div id="wpwrap">
   177 <a tabindex="1" href="#wpbody-content" class="screen-reader-shortcut"><?php _e('Skip to main content'); ?></a>
       
   178 <?php require(ABSPATH . 'wp-admin/menu-header.php'); ?>
   193 <?php require(ABSPATH . 'wp-admin/menu-header.php'); ?>
   179 <div id="wpcontent">
   194 <div id="wpcontent">
   180 
   195 
   181 <?php
   196 <?php
   182 /**
   197 /**
   185  * @since 3.0.0
   200  * @since 3.0.0
   186  */
   201  */
   187 do_action( 'in_admin_header' );
   202 do_action( 'in_admin_header' );
   188 ?>
   203 ?>
   189 
   204 
   190 <div id="wpbody">
   205 <div id="wpbody" role="main">
   191 <?php
   206 <?php
   192 unset($title_class, $blog_name, $total_update_count, $update_title);
   207 unset($title_class, $blog_name, $total_update_count, $update_title);
   193 
   208 
   194 $current_screen->set_parentage( $parent_file );
   209 $current_screen->set_parentage( $parent_file );
   195 
   210