PageRenderTime 23ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 1ms

/wp-admin/admin-header.php

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