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