[ 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      exit;
  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  // Print the global admin inline scripts through the script tag API so the
 105  // `wp_inline_script_attributes` filter (e.g. a CSP nonce) applies.
 106  wp_print_inline_script_tag(
 107      <<<'JS'
 108  	function addLoadEvent( func ) {
 109          if ( typeof jQuery !== 'undefined' ) {
 110              jQuery( function () {
 111                  func();
 112              } );
 113          } else if ( typeof wpOnload !== 'function' ) {
 114              window.wpOnload = func;
 115          } else {
 116              const oldOnload = window.wpOnload;
 117              window.wpOnload = function () {
 118                  oldOnload();
 119                  func();
 120              };
 121          }
 122      }
 123      JS
 124  );
 125  wp_print_inline_script_tag(
 126      sprintf(
 127          'Object.assign( window, %s );',
 128          wp_json_encode(
 129              array(
 130                  'ajaxurl'            => admin_url( 'admin-ajax.php', 'relative' ),
 131                  'pagenow'            => $current_screen->id,
 132                  'typenow'            => $current_screen->post_type,
 133                  'adminpage'          => $admin_body_class,
 134                  'thousandsSeparator' => $wp_locale->number_format['thousands_sep'],
 135                  'decimalPoint'       => $wp_locale->number_format['decimal_point'],
 136                  'isRtl'              => (int) is_rtl(),
 137              ),
 138              JSON_HEX_TAG | JSON_UNESCAPED_SLASHES
 139          )
 140      )
 141  );
 142  
 143  /**
 144   * Fires when enqueuing scripts for all admin pages.
 145   *
 146   * @since 2.8.0
 147   *
 148   * @param string $hook_suffix The current admin page.
 149   */
 150  do_action( 'admin_enqueue_scripts', $hook_suffix );
 151  
 152  /**
 153   * Fires when styles are printed for a specific admin page based on $hook_suffix.
 154   *
 155   * @since 2.6.0
 156   */
 157  do_action( "admin_print_styles-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
 158  
 159  /**
 160   * Fires when styles are printed for all admin pages.
 161   *
 162   * @since 2.6.0
 163   */
 164  do_action( 'admin_print_styles' );
 165  
 166  /**
 167   * Fires when scripts are printed for a specific admin page based on $hook_suffix.
 168   *
 169   * @since 2.1.0
 170   */
 171  do_action( "admin_print_scripts-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
 172  
 173  /**
 174   * Fires when scripts are printed for all admin pages.
 175   *
 176   * @since 2.1.0
 177   */
 178  do_action( 'admin_print_scripts' );
 179  
 180  /**
 181   * Fires in head section for a specific admin page.
 182   *
 183   * The dynamic portion of the hook name, `$hook_suffix`, refers to the hook suffix
 184   * for the admin page.
 185   *
 186   * @since 2.1.0
 187   */
 188  do_action( "admin_head-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
 189  
 190  /**
 191   * Fires in head section for all admin pages.
 192   *
 193   * @since 2.1.0
 194   */
 195  do_action( 'admin_head' );
 196  
 197  if ( 'f' === get_user_setting( 'mfold' ) ) {
 198      $admin_body_class .= ' folded';
 199  }
 200  
 201  if ( ! get_user_setting( 'unfold' ) ) {
 202      $admin_body_class .= ' auto-fold';
 203  }
 204  
 205  if ( is_admin_bar_showing() ) {
 206      $admin_body_class .= ' admin-bar';
 207  }
 208  
 209  if ( is_rtl() ) {
 210      $admin_body_class .= ' rtl';
 211  }
 212  
 213  if ( $current_screen->post_type ) {
 214      $admin_body_class .= ' post-type-' . $current_screen->post_type;
 215  }
 216  
 217  if ( $current_screen->taxonomy ) {
 218      $admin_body_class .= ' taxonomy-' . $current_screen->taxonomy;
 219  }
 220  
 221  $admin_body_class .= ' branch-' . str_replace( array( '.', ',' ), '-', (float) get_bloginfo( 'version' ) );
 222  $admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-9]+).*/', '$1', get_bloginfo( 'version' ) ) );
 223  $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'modern' );
 224  $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
 225  
 226  if ( wp_is_mobile() ) {
 227      $admin_body_class .= ' mobile';
 228  }
 229  
 230  if ( is_multisite() ) {
 231      $admin_body_class .= ' multisite';
 232  }
 233  
 234  if ( is_network_admin() ) {
 235      $admin_body_class .= ' network-admin';
 236  }
 237  
 238  $admin_body_class .= ' no-customize-support svg';
 239  
 240  if ( $current_screen->is_block_editor() ) {
 241      $admin_body_class .= ' block-editor-page wp-embed-responsive';
 242  }
 243  
 244  $admin_body_class .= ' wp-theme-' . sanitize_html_class( get_template() );
 245  if ( is_child_theme() ) {
 246      $admin_body_class .= ' wp-child-theme-' . sanitize_html_class( get_stylesheet() );
 247  }
 248  
 249  $error_get_last = error_get_last();
 250  
 251  // Print a CSS class to make PHP errors visible.
 252  if ( $error_get_last && WP_DEBUG && WP_DEBUG_DISPLAY && ini_get( 'display_errors' )
 253      // Don't print the class for PHP notices in wp-config.php, as they happen before WP_DEBUG takes effect,
 254      // and should not be displayed with the `error_reporting` level previously set in wp-load.php.
 255      && ( E_NOTICE !== $error_get_last['type'] || 'wp-config.php' !== wp_basename( $error_get_last['file'] ) )
 256  ) {
 257      $admin_body_class .= ' php-error';
 258  }
 259  
 260  unset( $error_get_last );
 261  
 262  ?>
 263  </head>
 264  <?php
 265  /**
 266   * Filters the CSS classes for the body tag in the admin.
 267   *
 268   * This filter differs from the {@see 'post_class'} and {@see 'body_class'} filters
 269   * in two important ways:
 270   *
 271   * 1. `$classes` is a space-separated string of class names instead of an array.
 272   * 2. Not all core admin classes are filterable, notably: wp-admin, wp-core-ui,
 273   *    and no-js cannot be removed.
 274   *
 275   * @since 2.3.0
 276   *
 277   * @param string $classes Space-separated list of CSS classes.
 278   */
 279  $admin_body_classes = apply_filters( 'admin_body_class', '' );
 280  $admin_body_classes = ltrim( $admin_body_classes . ' ' . $admin_body_class );
 281  ?>
 282  <body class="wp-admin wp-core-ui no-js <?php echo esc_attr( $admin_body_classes ); ?>">
 283  <?php
 284  wp_print_inline_script_tag(
 285      <<<'JS'
 286      document.body.className = document.body.className.replace( 'no-js', 'js' );
 287      JS
 288  );
 289  
 290  // Make sure the customize body classes are correct as early as possible.
 291  if ( current_user_can( 'customize' ) ) {
 292      wp_customize_support_script();
 293  }
 294  ?>
 295  
 296  <div id="wpwrap">
 297  <?php require  ABSPATH . 'wp-admin/menu-header.php'; ?>
 298  <div id="wpcontent">
 299  
 300  <?php
 301  /**
 302   * Fires at the beginning of the content section in an admin page.
 303   *
 304   * @since 3.0.0
 305   */
 306  do_action( 'in_admin_header' );
 307  ?>
 308  
 309  <div id="wpbody" role="main">
 310  <?php
 311  unset( $blog_name, $total_update_count, $update_title );
 312  
 313  $current_screen->set_parentage( $parent_file );
 314  
 315  ?>
 316  
 317  <div id="wpbody-content">
 318  <?php
 319  
 320  $current_screen->render_screen_meta();
 321  
 322  if ( is_network_admin() ) {
 323      /**
 324       * Prints network admin screen notices.
 325       *
 326       * @since 3.1.0
 327       */
 328      do_action( 'network_admin_notices' );
 329  } elseif ( is_user_admin() ) {
 330      /**
 331       * Prints user admin screen notices.
 332       *
 333       * @since 3.1.0
 334       */
 335      do_action( 'user_admin_notices' );
 336  } else {
 337      /**
 338       * Prints admin screen notices.
 339       *
 340       * @since 3.1.0
 341       */
 342      do_action( 'admin_notices' );
 343  }
 344  
 345  /**
 346   * Prints generic admin screen notices.
 347   *
 348   * @since 3.1.0
 349   */
 350  do_action( 'all_admin_notices' );
 351  
 352  if ( 'options-general.php' === $parent_file ) {
 353      require  ABSPATH . 'wp-admin/options-head.php';
 354  }


Generated : Mon Sep 14 08:20:31 2026 Cross-referenced by PHPXref