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


Generated : Wed Nov 4 08:20:38 2026 Cross-referenced by PHPXref