wp/wp-admin/admin-header.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
     8 
     8 
     9 @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
     9 @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
    10 if ( ! defined( 'WP_ADMIN' ) )
    10 if ( ! defined( 'WP_ADMIN' ) )
    11 	require_once( dirname( __FILE__ ) . '/admin.php' );
    11 	require_once( dirname( __FILE__ ) . '/admin.php' );
    12 
    12 
    13 // In case admin-header.php is included in a function.
    13 /**
    14 global $title, $hook_suffix, $current_screen, $wp_locale, $pagenow, $wp_version,
    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,
    15 	$update_title, $total_update_count, $parent_file;
    26 	$update_title, $total_update_count, $parent_file;
    16 
    27 
    17 // Catch plugins that include admin-header.php before admin.php completes.
    28 // Catch plugins that include admin-header.php before admin.php completes.
    18 if ( empty( $current_screen ) )
    29 if ( empty( $current_screen ) )
    19 	set_current_screen();
    30 	set_current_screen();
    20 
    31 
    21 get_admin_page_title();
    32 get_admin_page_title();
    22 $title = esc_html( strip_tags( $title ) );
    33 $title = esc_html( strip_tags( $title ) );
    23 
    34 
    24 if ( is_network_admin() )
    35 if ( is_network_admin() ) {
    25 	$admin_title = sprintf( __( 'Network Admin: %s' ), esc_html( get_current_site()->site_name ) );
    36 	/* translators: Network admin screen title. 1: Network name */
    26 elseif ( is_user_admin() )
    37 	$admin_title = sprintf( __( 'Network Admin: %s' ), esc_html( get_network()->site_name ) );
    27 	$admin_title = sprintf( __( 'Global Dashboard: %s' ), esc_html( get_current_site()->site_name ) );
    38 } elseif ( is_user_admin() ) {
    28 else
    39 	/* translators: User dashboard screen title. 1: Network name */
       
    40 	$admin_title = sprintf( __( 'User Dashboard: %s' ), esc_html( get_network()->site_name ) );
       
    41 } else {
    29 	$admin_title = get_bloginfo( 'name' );
    42 	$admin_title = get_bloginfo( 'name' );
    30 
    43 }
    31 if ( $admin_title == $title )
    44 
       
    45 if ( $admin_title == $title ) {
       
    46 	/* translators: Admin screen title. 1: Admin screen name */
    32 	$admin_title = sprintf( __( '%1$s — WordPress' ), $title );
    47 	$admin_title = sprintf( __( '%1$s — WordPress' ), $title );
    33 else
    48 } else {
       
    49 	/* translators: Admin screen title. 1: Admin screen name, 2: Network or site name */
    34 	$admin_title = sprintf( __( '%1$s ‹ %2$s — WordPress' ), $title, $admin_title );
    50 	$admin_title = sprintf( __( '%1$s ‹ %2$s — WordPress' ), $title, $admin_title );
    35 
    51 }
    36 /**
    52 
    37  * Filter the title tag content for an admin page.
    53 /**
       
    54  * Filters the title tag content for an admin page.
    38  *
    55  *
    39  * @since 3.1.0
    56  * @since 3.1.0
    40  *
    57  *
    41  * @param string $admin_title The page title, with extra context added.
    58  * @param string $admin_title The page title, with extra context added.
    42  * @param string $title       The original page title.
    59  * @param string $title       The original page title.
    82 /**
    99 /**
    83  * Fires when styles are printed for a specific admin page based on $hook_suffix.
   100  * Fires when styles are printed for a specific admin page based on $hook_suffix.
    84  *
   101  *
    85  * @since 2.6.0
   102  * @since 2.6.0
    86  */
   103  */
    87 do_action( "admin_print_styles-$hook_suffix" );
   104 do_action( "admin_print_styles-{$hook_suffix}" );
    88 
   105 
    89 /**
   106 /**
    90  * Fires when styles are printed for all admin pages.
   107  * Fires when styles are printed for all admin pages.
    91  *
   108  *
    92  * @since 2.6.0
   109  * @since 2.6.0
    96 /**
   113 /**
    97  * Fires when scripts are printed for a specific admin page based on $hook_suffix.
   114  * Fires when scripts are printed for a specific admin page based on $hook_suffix.
    98  *
   115  *
    99  * @since 2.1.0
   116  * @since 2.1.0
   100  */
   117  */
   101 do_action( "admin_print_scripts-$hook_suffix" );
   118 do_action( "admin_print_scripts-{$hook_suffix}" );
   102 
   119 
   103 /**
   120 /**
   104  * Fires when scripts are printed for all admin pages.
   121  * Fires when scripts are printed for all admin pages.
   105  *
   122  *
   106  * @since 2.1.0
   123  * @since 2.1.0
   113  * The dynamic portion of the hook, `$hook_suffix`, refers to the hook suffix
   130  * The dynamic portion of the hook, `$hook_suffix`, refers to the hook suffix
   114  * for the admin page.
   131  * for the admin page.
   115  *
   132  *
   116  * @since 2.1.0
   133  * @since 2.1.0
   117  */
   134  */
   118 do_action( "admin_head-$hook_suffix" );
   135 do_action( "admin_head-{$hook_suffix}" );
   119 
   136 
   120 /**
   137 /**
   121  * Fires in head section for all admin pages.
   138  * Fires in head section for all admin pages.
   122  *
   139  *
   123  * @since 2.1.0
   140  * @since 2.1.0
   140 	$admin_body_class .= ' post-type-' . $current_screen->post_type;
   157 	$admin_body_class .= ' post-type-' . $current_screen->post_type;
   141 
   158 
   142 if ( $current_screen->taxonomy )
   159 if ( $current_screen->taxonomy )
   143 	$admin_body_class .= ' taxonomy-' . $current_screen->taxonomy;
   160 	$admin_body_class .= ' taxonomy-' . $current_screen->taxonomy;
   144 
   161 
   145 $admin_body_class .= ' branch-' . str_replace( array( '.', ',' ), '-', floatval( $wp_version ) );
   162 $admin_body_class .= ' branch-' . str_replace( array( '.', ',' ), '-', floatval( get_bloginfo( 'version' ) ) );
   146 $admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-9]+).*/', '$1', $wp_version ) );
   163 $admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-9]+).*/', '$1', get_bloginfo( 'version' ) ) );
   147 $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
   164 $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
   148 $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
   165 $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
   149 
   166 
   150 if ( wp_is_mobile() )
   167 if ( wp_is_mobile() )
   151 	$admin_body_class .= ' mobile';
   168 	$admin_body_class .= ' mobile';
   152 
   169 
   153 if ( is_multisite() )
   170 if ( is_multisite() )
   160 
   177 
   161 ?>
   178 ?>
   162 </head>
   179 </head>
   163 <?php
   180 <?php
   164 /**
   181 /**
   165  * Filter the CSS classes for the body tag in the admin.
   182  * Filters the CSS classes for the body tag in the admin.
   166  *
   183  *
   167  * This filter differs from the {@see 'post_class'} and {@see 'body_class'} filters
   184  * This filter differs from the {@see 'post_class'} and {@see 'body_class'} filters
   168  * in two important ways:
   185  * in two important ways:
   169  *
   186  *
   170  * 1. `$classes` is a space-separated string of class names instead of an array.
   187  * 1. `$classes` is a space-separated string of class names instead of an array.
   215 
   232 
   216 $current_screen->render_screen_meta();
   233 $current_screen->render_screen_meta();
   217 
   234 
   218 if ( is_network_admin() ) {
   235 if ( is_network_admin() ) {
   219 	/**
   236 	/**
   220 	 * Print network admin screen notices.
   237 	 * Prints network admin screen notices.
   221 	 *
   238 	 *
   222 	 * @since 3.1.0
   239 	 * @since 3.1.0
   223 	 */
   240 	 */
   224 	do_action( 'network_admin_notices' );
   241 	do_action( 'network_admin_notices' );
   225 } elseif ( is_user_admin() ) {
   242 } elseif ( is_user_admin() ) {
   226 	/**
   243 	/**
   227 	 * Print user admin screen notices.
   244 	 * Prints user admin screen notices.
   228 	 *
   245 	 *
   229 	 * @since 3.1.0
   246 	 * @since 3.1.0
   230 	 */
   247 	 */
   231 	do_action( 'user_admin_notices' );
   248 	do_action( 'user_admin_notices' );
   232 } else {
   249 } else {
   233 	/**
   250 	/**
   234 	 * Print admin screen notices.
   251 	 * Prints admin screen notices.
   235 	 *
   252 	 *
   236 	 * @since 3.1.0
   253 	 * @since 3.1.0
   237 	 */
   254 	 */
   238 	do_action( 'admin_notices' );
   255 	do_action( 'admin_notices' );
   239 }
   256 }
   240 
   257 
   241 /**
   258 /**
   242  * Print generic admin screen notices.
   259  * Prints generic admin screen notices.
   243  *
   260  *
   244  * @since 3.1.0
   261  * @since 3.1.0
   245  */
   262  */
   246 do_action( 'all_admin_notices' );
   263 do_action( 'all_admin_notices' );
   247 
   264