/wp-admin/admin-header.php

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