No Description

admin-header.php 8.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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 __DIR__ . '/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 = strip_tags( $title );
  32. if ( is_network_admin() ) {
  33. /* translators: Network admin screen title. %s: Network title. */
  34. $admin_title = sprintf( __( 'Network Admin: %s' ), 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' ), 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 esc_html( $admin_title ); ?></title>
  65. <?php
  66. wp_enqueue_style( 'colors' );
  67. wp_enqueue_script( 'utils' );
  68. wp_enqueue_script( 'svg-painter' );
  69. $admin_body_class = preg_replace( '/[^a-z0-9_-]+/i', '-', $hook_suffix );
  70. ?>
  71. <script type="text/javascript">
  72. 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();}}};
  73. var ajaxurl = '<?php echo esc_js( admin_url( 'admin-ajax.php', 'relative' ) ); ?>',
  74. pagenow = '<?php echo esc_js( $current_screen->id ); ?>',
  75. typenow = '<?php echo esc_js( $current_screen->post_type ); ?>',
  76. adminpage = '<?php echo esc_js( $admin_body_class ); ?>',
  77. thousandsSeparator = '<?php echo esc_js( $wp_locale->number_format['thousands_sep'] ); ?>',
  78. decimalPoint = '<?php echo esc_js( $wp_locale->number_format['decimal_point'] ); ?>',
  79. isRtl = <?php echo (int) is_rtl(); ?>;
  80. </script>
  81. <?php
  82. /**
  83. * Enqueue scripts for all admin pages.
  84. *
  85. * @since 2.8.0
  86. *
  87. * @param string $hook_suffix The current admin page.
  88. */
  89. do_action( 'admin_enqueue_scripts', $hook_suffix );
  90. /**
  91. * Fires when styles are printed for a specific admin page based on $hook_suffix.
  92. *
  93. * @since 2.6.0
  94. */
  95. do_action( "admin_print_styles-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
  96. /**
  97. * Fires when styles are printed for all admin pages.
  98. *
  99. * @since 2.6.0
  100. */
  101. do_action( 'admin_print_styles' );
  102. /**
  103. * Fires when scripts are printed for a specific admin page based on $hook_suffix.
  104. *
  105. * @since 2.1.0
  106. */
  107. do_action( "admin_print_scripts-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
  108. /**
  109. * Fires when scripts are printed for all admin pages.
  110. *
  111. * @since 2.1.0
  112. */
  113. do_action( 'admin_print_scripts' );
  114. /**
  115. * Fires in head section for a specific admin page.
  116. *
  117. * The dynamic portion of the hook, `$hook_suffix`, refers to the hook suffix
  118. * for the admin page.
  119. *
  120. * @since 2.1.0
  121. */
  122. do_action( "admin_head-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
  123. /**
  124. * Fires in head section for all admin pages.
  125. *
  126. * @since 2.1.0
  127. */
  128. do_action( 'admin_head' );
  129. if ( 'f' === get_user_setting( 'mfold' ) ) {
  130. $admin_body_class .= ' folded';
  131. }
  132. if ( ! get_user_setting( 'unfold' ) ) {
  133. $admin_body_class .= ' auto-fold';
  134. }
  135. if ( is_admin_bar_showing() ) {
  136. $admin_body_class .= ' admin-bar';
  137. }
  138. if ( is_rtl() ) {
  139. $admin_body_class .= ' rtl';
  140. }
  141. if ( $current_screen->post_type ) {
  142. $admin_body_class .= ' post-type-' . $current_screen->post_type;
  143. }
  144. if ( $current_screen->taxonomy ) {
  145. $admin_body_class .= ' taxonomy-' . $current_screen->taxonomy;
  146. }
  147. $admin_body_class .= ' branch-' . str_replace( array( '.', ',' ), '-', (float) get_bloginfo( 'version' ) );
  148. $admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-9]+).*/', '$1', get_bloginfo( 'version' ) ) );
  149. $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
  150. $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
  151. if ( wp_is_mobile() ) {
  152. $admin_body_class .= ' mobile';
  153. }
  154. if ( is_multisite() ) {
  155. $admin_body_class .= ' multisite';
  156. }
  157. if ( is_network_admin() ) {
  158. $admin_body_class .= ' network-admin';
  159. }
  160. $admin_body_class .= ' no-customize-support no-svg';
  161. if ( $current_screen->is_block_editor() ) {
  162. $admin_body_class .= ' block-editor-page wp-embed-responsive';
  163. }
  164. $error_get_last = error_get_last();
  165. // Print a CSS class to make PHP errors visible.
  166. if ( $error_get_last && WP_DEBUG && WP_DEBUG_DISPLAY && ini_get( 'display_errors' )
  167. // Don't print the class for PHP notices in wp-config.php, as they happen before WP_DEBUG takes effect,
  168. // and should not be displayed with the `error_reporting` level previously set in wp-load.php.
  169. && ( E_NOTICE !== $error_get_last['type'] || 'wp-config.php' !== wp_basename( $error_get_last['file'] ) )
  170. ) {
  171. $admin_body_class .= ' php-error';
  172. }
  173. unset( $error_get_last );
  174. ?>
  175. </head>
  176. <?php
  177. /**
  178. * Filters the CSS classes for the body tag in the admin.
  179. *
  180. * This filter differs from the {@see 'post_class'} and {@see 'body_class'} filters
  181. * in two important ways:
  182. *
  183. * 1. `$classes` is a space-separated string of class names instead of an array.
  184. * 2. Not all core admin classes are filterable, notably: wp-admin, wp-core-ui,
  185. * and no-js cannot be removed.
  186. *
  187. * @since 2.3.0
  188. *
  189. * @param string $classes Space-separated list of CSS classes.
  190. */
  191. $admin_body_classes = apply_filters( 'admin_body_class', '' );
  192. $admin_body_classes = ltrim( $admin_body_classes . ' ' . $admin_body_class );
  193. ?>
  194. <body class="wp-admin wp-core-ui no-js <?php echo $admin_body_classes; ?>">
  195. <script type="text/javascript">
  196. document.body.className = document.body.className.replace('no-js','js');
  197. </script>
  198. <?php
  199. // Make sure the customize body classes are correct as early as possible.
  200. if ( current_user_can( 'customize' ) ) {
  201. wp_customize_support_script();
  202. }
  203. ?>
  204. <div id="wpwrap">
  205. <?php require ABSPATH . 'wp-admin/menu-header.php'; ?>
  206. <div id="wpcontent">
  207. <?php
  208. /**
  209. * Fires at the beginning of the content section in an admin page.
  210. *
  211. * @since 3.0.0
  212. */
  213. do_action( 'in_admin_header' );
  214. ?>
  215. <div id="wpbody" role="main">
  216. <?php
  217. unset( $blog_name, $total_update_count, $update_title );
  218. $current_screen->set_parentage( $parent_file );
  219. ?>
  220. <div id="wpbody-content">
  221. <?php
  222. $current_screen->render_screen_meta();
  223. if ( is_network_admin() ) {
  224. /**
  225. * Prints network admin screen notices.
  226. *
  227. * @since 3.1.0
  228. */
  229. do_action( 'network_admin_notices' );
  230. } elseif ( is_user_admin() ) {
  231. /**
  232. * Prints user admin screen notices.
  233. *
  234. * @since 3.1.0
  235. */
  236. do_action( 'user_admin_notices' );
  237. } else {
  238. /**
  239. * Prints admin screen notices.
  240. *
  241. * @since 3.1.0
  242. */
  243. do_action( 'admin_notices' );
  244. }
  245. /**
  246. * Prints generic admin screen notices.
  247. *
  248. * @since 3.1.0
  249. */
  250. do_action( 'all_admin_notices' );
  251. if ( 'options-general.php' === $parent_file ) {
  252. require ABSPATH . 'wp-admin/options-head.php';
  253. }