[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-admin/ -> admin-header.php (source)

   1  <?php
   2  /**
   3   * WordPress Administration Template Header
   4   *
   5   * @package WordPress
   6   * @subpackage Administration
   7   */
   8  
   9  // Don't load directly.
  10  if ( ! defined( 'ABSPATH' ) ) {
  11      die( '-1' );
  12  }
  13  
  14  header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
  15  if ( ! defined( 'WP_ADMIN' ) ) {
  16      require_once  __DIR__ . '/admin.php';
  17  }
  18  
  19  /**
  20   * In case admin-header.php is included in a function.
  21   *
  22   * @global string    $title              The title of the current screen.
  23   * @global string    $hook_suffix
  24   * @global WP_Screen $current_screen     WordPress current screen object.
  25   * @global WP_Locale $wp_locale          WordPress date and time locale object.
  26   * @global string    $pagenow            The filename of the current screen.
  27   * @global string    $update_title
  28   * @global int       $total_update_count
  29   * @global string    $parent_file
  30   * @global string    $typenow            The post type of the current screen.
  31   */
  32  global $title, $hook_suffix, $current_screen, $wp_locale, $pagenow,
  33      $update_title, $total_update_count, $parent_file, $typenow;
  34  
  35  // Catch plugins that include admin-header.php before admin.php completes.
  36  if ( empty( $current_screen ) ) {
  37      set_current_screen();
  38  }
  39  
  40  get_admin_page_title();
  41  $title = strip_tags( $title );
  42  
  43  if ( is_network_admin() ) {
  44      /* translators: Network admin screen title. %s: Network title. */
  45      $admin_title = sprintf( __( 'Network Admin: %s' ), get_network()->site_name );
  46  } elseif ( is_user_admin() ) {
  47      /* translators: User dashboard screen title. %s: Network title. */
  48      $admin_title = sprintf( __( 'User Dashboard: %s' ), get_network()->site_name );
  49  } else {
  50      $admin_title = get_bloginfo( 'name' );
  51  }
  52  
  53  if ( $admin_title === $title ) {
  54      /* translators: Admin screen title. %s: Admin screen name. */
  55      $admin_title = sprintf( __( '%s &#8212; WordPress' ), $title );
  56  } else {
  57      $screen_title = $title;
  58  
  59      if ( 'post' === $current_screen->base && 'add' !== $current_screen->action ) {
  60          $post_title = get_the_title();
  61          if ( ! empty( $post_title ) ) {
  62              $post_type_obj = get_post_type_object( $typenow );
  63              $screen_title  = sprintf(
  64                  /* translators: Editor admin screen title. 1: "Edit item" text for the post type, 2: Post title. */
  65                  __( '%1$s &#8220;%2$s&#8221;' ),
  66                  $post_type_obj->labels->edit_item,
  67                  $post_title
  68              );
  69          }
  70      }
  71  
  72      /* translators: Admin screen title. 1: Admin screen name, 2: Network or site name. */
  73      $admin_title = sprintf( __( '%1$s &lsaquo; %2$s &#8212; WordPress' ), $screen_title, $admin_title );
  74  }
  75  
  76  if ( wp_is_recovery_mode() ) {
  77      /* translators: %s: Admin screen title. */
  78      $admin_title = sprintf( __( 'Recovery Mode &#8212; %s' ), $admin_title );
  79  }
  80  
  81  /**
  82   * Filters the title tag content for an admin page.
  83   *
  84   * @since 3.1.0
  85   *
  86   * @param string $admin_title The page title, with extra context added.
  87   * @param string $title       The original page title.
  88   */
  89  $admin_title = apply_filters( 'admin_title', $admin_title, $title );
  90  
  91  wp_user_settings();
  92  
  93  _wp_admin_html_begin();
  94  ?>
  95  <title><?php echo esc_html( $admin_title ); ?></title>
  96  <?php
  97  
  98  wp_enqueue_style( 'colors' );
  99  wp_enqueue_script( 'utils' );
 100  wp_enqueue_script( 'svg-painter' );
 101  
 102  $admin_body_class = preg_replace( '/[^a-z0-9_-]+/i', '-', $hook_suffix );
 103  ?>
 104  <script type="text/javascript">
 105  addLoadEvent = function(func){if(typeof jQuery!=='undefined')jQuery(function(){func();});else if(typeof wpOnload!=='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
 106  var ajaxurl = '<?php echo esc_js( admin_url( 'admin-ajax.php', 'relative' ) ); ?>',
 107      pagenow = '<?php echo esc_js( $current_screen->id ); ?>',
 108      typenow = '<?php echo esc_js( $current_screen->post_type ); ?>',
 109      adminpage = '<?php echo esc_js( $admin_body_class ); ?>',
 110      thousandsSeparator = '<?php echo esc_js( $wp_locale->number_format['thousands_sep'] ); ?>',
 111      decimalPoint = '<?php echo esc_js( $wp_locale->number_format['decimal_point'] ); ?>',
 112      isRtl = <?php echo (int) is_rtl(); ?>;
 113  </script>
 114  <?php
 115  
 116  /**
 117   * Fires when enqueuing scripts for all admin pages.
 118   *
 119   * @since 2.8.0
 120   *
 121   * @param string $hook_suffix The current admin page.
 122   */
 123  do_action( 'admin_enqueue_scripts', $hook_suffix );
 124  
 125  /**
 126   * Fires when styles are printed for a specific admin page based on $hook_suffix.
 127   *
 128   * @since 2.6.0
 129   */
 130  do_action( "admin_print_styles-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
 131  
 132  /**
 133   * Fires when styles are printed for all admin pages.
 134   *
 135   * @since 2.6.0
 136   */
 137  do_action( 'admin_print_styles' );
 138  
 139  /**
 140   * Fires when scripts are printed for a specific admin page based on $hook_suffix.
 141   *
 142   * @since 2.1.0
 143   */
 144  do_action( "admin_print_scripts-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
 145  
 146  /**
 147   * Fires when scripts are printed for all admin pages.
 148   *
 149   * @since 2.1.0
 150   */
 151  do_action( 'admin_print_scripts' );
 152  
 153  /**
 154   * Fires in head section for a specific admin page.
 155   *
 156   * The dynamic portion of the hook name, `$hook_suffix`, refers to the hook suffix
 157   * for the admin page.
 158   *
 159   * @since 2.1.0
 160   */
 161  do_action( "admin_head-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
 162  
 163  /**
 164   * Fires in head section for all admin pages.
 165   *
 166   * @since 2.1.0
 167   */
 168  do_action( 'admin_head' );
 169  
 170  if ( 'f' === get_user_setting( 'mfold' ) ) {
 171      $admin_body_class .= ' folded';
 172  }
 173  
 174  if ( ! get_user_setting( 'unfold' ) ) {
 175      $admin_body_class .= ' auto-fold';
 176  }
 177  
 178  if ( is_admin_bar_showing() ) {
 179      $admin_body_class .= ' admin-bar';
 180  }
 181  
 182  if ( is_rtl() ) {
 183      $admin_body_class .= ' rtl';
 184  }
 185  
 186  if ( $current_screen->post_type ) {
 187      $admin_body_class .= ' post-type-' . $current_screen->post_type;
 188  }
 189  
 190  if ( $current_screen->taxonomy ) {
 191      $admin_body_class .= ' taxonomy-' . $current_screen->taxonomy;
 192  }
 193  
 194  $admin_body_class .= ' branch-' . str_replace( array( '.', ',' ), '-', (float) get_bloginfo( 'version' ) );
 195  $admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-9]+).*/', '$1', get_bloginfo( 'version' ) ) );
 196  $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
 197  $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
 198  
 199  if ( wp_is_mobile() ) {
 200      $admin_body_class .= ' mobile';
 201  }
 202  
 203  if ( is_multisite() ) {
 204      $admin_body_class .= ' multisite';
 205  }
 206  
 207  if ( is_network_admin() ) {
 208      $admin_body_class .= ' network-admin';
 209  }
 210  
 211  $admin_body_class .= ' no-customize-support svg';
 212  
 213  if ( $current_screen->is_block_editor() ) {
 214      $admin_body_class .= ' block-editor-page wp-embed-responsive';
 215  }
 216  
 217  $admin_body_class .= ' wp-theme-' . sanitize_html_class( get_template() );
 218  if ( is_child_theme() ) {
 219      $admin_body_class .= ' wp-child-theme-' . sanitize_html_class( get_stylesheet() );
 220  }
 221  
 222  $error_get_last = error_get_last();
 223  
 224  // Print a CSS class to make PHP errors visible.
 225  if ( $error_get_last && WP_DEBUG && WP_DEBUG_DISPLAY && ini_get( 'display_errors' )
 226      // Don't print the class for PHP notices in wp-config.php, as they happen before WP_DEBUG takes effect,
 227      // and should not be displayed with the `error_reporting` level previously set in wp-load.php.
 228      && ( E_NOTICE !== $error_get_last['type'] || 'wp-config.php' !== wp_basename( $error_get_last['file'] ) )
 229  ) {
 230      $admin_body_class .= ' php-error';
 231  }
 232  
 233  unset( $error_get_last );
 234  
 235  ?>
 236  </head>
 237  <?php
 238  /**
 239   * Filters the CSS classes for the body tag in the admin.
 240   *
 241   * This filter differs from the {@see 'post_class'} and {@see 'body_class'} filters
 242   * in two important ways:
 243   *
 244   * 1. `$classes` is a space-separated string of class names instead of an array.
 245   * 2. Not all core admin classes are filterable, notably: wp-admin, wp-core-ui,
 246   *    and no-js cannot be removed.
 247   *
 248   * @since 2.3.0
 249   *
 250   * @param string $classes Space-separated list of CSS classes.
 251   */
 252  $admin_body_classes = apply_filters( 'admin_body_class', '' );
 253  $admin_body_classes = ltrim( $admin_body_classes . ' ' . $admin_body_class );
 254  ?>
 255  <body class="wp-admin wp-core-ui no-js <?php echo esc_attr( $admin_body_classes ); ?>">
 256  <script type="text/javascript">
 257      document.body.className = document.body.className.replace('no-js','js');
 258  </script>
 259  
 260  <?php
 261  // Make sure the customize body classes are correct as early as possible.
 262  if ( current_user_can( 'customize' ) ) {
 263      wp_customize_support_script();
 264  }
 265  ?>
 266  
 267  <div id="wpwrap">
 268  <?php require  ABSPATH . 'wp-admin/menu-header.php'; ?>
 269  <div id="wpcontent">
 270  
 271  <?php
 272  /**
 273   * Fires at the beginning of the content section in an admin page.
 274   *
 275   * @since 3.0.0
 276   */
 277  do_action( 'in_admin_header' );
 278  ?>
 279  
 280  <div id="wpbody" role="main">
 281  <?php
 282  unset( $blog_name, $total_update_count, $update_title );
 283  
 284  $current_screen->set_parentage( $parent_file );
 285  
 286  ?>
 287  
 288  <div id="wpbody-content">
 289  <?php
 290  
 291  $current_screen->render_screen_meta();
 292  
 293  if ( is_network_admin() ) {
 294      /**
 295       * Prints network admin screen notices.
 296       *
 297       * @since 3.1.0
 298       */
 299      do_action( 'network_admin_notices' );
 300  } elseif ( is_user_admin() ) {
 301      /**
 302       * Prints user admin screen notices.
 303       *
 304       * @since 3.1.0
 305       */
 306      do_action( 'user_admin_notices' );
 307  } else {
 308      /**
 309       * Prints admin screen notices.
 310       *
 311       * @since 3.1.0
 312       */
 313      do_action( 'admin_notices' );
 314  }
 315  
 316  /**
 317   * Prints generic admin screen notices.
 318   *
 319   * @since 3.1.0
 320   */
 321  do_action( 'all_admin_notices' );
 322  
 323  if ( 'options-general.php' === $parent_file ) {
 324      require  ABSPATH . 'wp-admin/options-head.php';
 325  }


Generated : Sat Feb 22 08:20:01 2025 Cross-referenced by PHPXref