admin-header.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <?php
  2. /**
  3. * WordPress Administration Template Header
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. */
  8. @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
  9. if ( ! defined( 'WP_ADMIN' ) )
  10. require_once( dirname( __FILE__ ) . '/admin.php' );
  11. /**
  12. * In case admin-header.php is included in a function.
  13. *
  14. * @global string $title
  15. * @global string $hook_suffix
  16. * @global WP_Screen $current_screen
  17. * @global WP_Locale $wp_locale
  18. * @global string $pagenow
  19. * @global string $update_title
  20. * @global int $total_update_count
  21. * @global string $parent_file
  22. */
  23. global $title, $hook_suffix, $current_screen, $wp_locale, $pagenow,
  24. $update_title, $total_update_count, $parent_file;
  25. // Catch plugins that include admin-header.php before admin.php completes.
  26. if ( empty( $current_screen ) )
  27. set_current_screen();
  28. get_admin_page_title();
  29. $title = esc_html( strip_tags( $title ) );
  30. if ( is_network_admin() ) {
  31. /* translators: Network admin screen title. 1: Network name */
  32. $admin_title = sprintf( __( 'Network Admin: %s' ), esc_html( get_network()->site_name ) );
  33. } elseif ( is_user_admin() ) {
  34. /* translators: User dashboard screen title. 1: Network name */
  35. $admin_title = sprintf( __( 'User Dashboard: %s' ), esc_html( get_network()->site_name ) );
  36. } else {
  37. $admin_title = get_bloginfo( 'name' );
  38. }
  39. if ( $admin_title == $title ) {
  40. /* translators: Admin screen title. 1: Admin screen name */
  41. $admin_title = sprintf( __( '%1$s &#8212; WordPress' ), $title );
  42. } else {
  43. /* translators: Admin screen title. 1: Admin screen name, 2: Network or site name */
  44. $admin_title = sprintf( __( '%1$s &lsaquo; %2$s &#8212; WordPress' ), $title, $admin_title );
  45. }
  46. /**
  47. * Filters the title tag content for an admin page.
  48. *
  49. * @since 3.1.0
  50. *
  51. * @param string $admin_title The page title, with extra context added.
  52. * @param string $title The original page title.
  53. */
  54. $admin_title = apply_filters( 'admin_title', $admin_title, $title );
  55. wp_user_settings();
  56. _wp_admin_html_begin();
  57. ?>
  58. <title><?php echo $admin_title; ?></title>
  59. <?php
  60. wp_enqueue_style( 'colors' );
  61. wp_enqueue_style( 'ie' );
  62. wp_enqueue_script('utils');
  63. wp_enqueue_script( 'svg-painter' );
  64. $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
  65. ?>
  66. <script type="text/javascript">
  67. 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();}}};
  68. var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
  69. pagenow = '<?php echo $current_screen->id; ?>',
  70. typenow = '<?php echo $current_screen->post_type; ?>',
  71. adminpage = '<?php echo $admin_body_class; ?>',
  72. thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
  73. decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
  74. isRtl = <?php echo (int) is_rtl(); ?>;
  75. </script>
  76. <meta name="viewport" content="width=device-width,initial-scale=1.0">
  77. <?php
  78. /**
  79. * Enqueue scripts for all admin pages.
  80. *
  81. * @since 2.8.0
  82. *
  83. * @param string $hook_suffix The current admin page.
  84. */
  85. do_action( 'admin_enqueue_scripts', $hook_suffix );
  86. /**
  87. * Fires when styles are printed for a specific admin page based on $hook_suffix.
  88. *
  89. * @since 2.6.0
  90. */
  91. do_action( "admin_print_styles-{$hook_suffix}" );
  92. /**
  93. * Fires when styles are printed for all admin pages.
  94. *
  95. * @since 2.6.0
  96. */
  97. do_action( 'admin_print_styles' );
  98. /**
  99. * Fires when scripts are printed for a specific admin page based on $hook_suffix.
  100. *
  101. * @since 2.1.0
  102. */
  103. do_action( "admin_print_scripts-{$hook_suffix}" );
  104. /**
  105. * Fires when scripts are printed for all admin pages.
  106. *
  107. * @since 2.1.0
  108. */
  109. do_action( 'admin_print_scripts' );
  110. /**
  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.
  115. *
  116. * @since 2.1.0
  117. */
  118. do_action( "admin_head-{$hook_suffix}" );
  119. /**
  120. * Fires in head section for all admin pages.
  121. *
  122. * @since 2.1.0
  123. */
  124. do_action( 'admin_head' );
  125. if ( get_user_setting('mfold') == 'f' )
  126. $admin_body_class .= ' folded';
  127. if ( !get_user_setting('unfold') )
  128. $admin_body_class .= ' auto-fold';
  129. if ( is_admin_bar_showing() )
  130. $admin_body_class .= ' admin-bar';
  131. if ( is_rtl() )
  132. $admin_body_class .= ' rtl';
  133. if ( $current_screen->post_type )
  134. $admin_body_class .= ' post-type-' . $current_screen->post_type;
  135. if ( $current_screen->taxonomy )
  136. $admin_body_class .= ' taxonomy-' . $current_screen->taxonomy;
  137. $admin_body_class .= ' branch-' . str_replace( array( '.', ',' ), '-', floatval( get_bloginfo( 'version' ) ) );
  138. $admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-9]+).*/', '$1', get_bloginfo( 'version' ) ) );
  139. $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
  140. $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
  141. if ( wp_is_mobile() )
  142. $admin_body_class .= ' mobile';
  143. if ( is_multisite() )
  144. $admin_body_class .= ' multisite';
  145. if ( is_network_admin() )
  146. $admin_body_class .= ' network-admin';
  147. $admin_body_class .= ' no-customize-support no-svg';
  148. ?>
  149. </head>
  150. <?php
  151. /**
  152. * Filters the CSS classes for the body tag in the admin.
  153. *
  154. * This filter differs from the {@see 'post_class'} and {@see 'body_class'} filters
  155. * in two important ways:
  156. *
  157. * 1. `$classes` is a space-separated string of class names instead of an array.
  158. * 2. Not all core admin classes are filterable, notably: wp-admin, wp-core-ui,
  159. * and no-js cannot be removed.
  160. *
  161. * @since 2.3.0
  162. *
  163. * @param string $classes Space-separated list of CSS classes.
  164. */
  165. $admin_body_classes = apply_filters( 'admin_body_class', '' );
  166. ?>
  167. <body class="wp-admin wp-core-ui no-js <?php echo $admin_body_classes . ' ' . $admin_body_class; ?>">
  168. <script type="text/javascript">
  169. document.body.className = document.body.className.replace('no-js','js');
  170. </script>
  171. <?php
  172. // Make sure the customize body classes are correct as early as possible.
  173. if ( current_user_can( 'customize' ) ) {
  174. wp_customize_support_script();
  175. }
  176. ?>
  177. <div id="wpwrap">
  178. <?php require(ABSPATH . 'wp-admin/menu-header.php'); ?>
  179. <div id="wpcontent">
  180. <?php
  181. /**
  182. * Fires at the beginning of the content section in an admin page.
  183. *
  184. * @since 3.0.0
  185. */
  186. do_action( 'in_admin_header' );
  187. ?>
  188. <div id="wpbody" role="main">
  189. <?php
  190. unset($title_class, $blog_name, $total_update_count, $update_title);
  191. $current_screen->set_parentage( $parent_file );
  192. ?>
  193. <div id="wpbody-content" aria-label="<?php esc_attr_e('Main content'); ?>" tabindex="0">
  194. <?php
  195. $current_screen->render_screen_meta();
  196. if ( is_network_admin() ) {
  197. /**
  198. * Prints network admin screen notices.
  199. *
  200. * @since 3.1.0
  201. */
  202. do_action( 'network_admin_notices' );
  203. } elseif ( is_user_admin() ) {
  204. /**
  205. * Prints user admin screen notices.
  206. *
  207. * @since 3.1.0
  208. */
  209. do_action( 'user_admin_notices' );
  210. } else {
  211. /**
  212. * Prints admin screen notices.
  213. *
  214. * @since 3.1.0
  215. */
  216. do_action( 'admin_notices' );
  217. }
  218. /**
  219. * Prints generic admin screen notices.
  220. *
  221. * @since 3.1.0
  222. */
  223. do_action( 'all_admin_notices' );
  224. if ( $parent_file == 'options-general.php' )
  225. require(ABSPATH . 'wp-admin/options-head.php');