admin-header.php 8.0 KB

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