Changeset 56682 for trunk/src/wp-includes/admin-bar.php
- Timestamp:
- 09/25/2023 05:04:41 PM (2 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/admin-bar.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/admin-bar.php
r56548 r56682 1226 1226 1227 1227 /** 1228 * Prints style and scripts for the admin bar. 1229 * 1230 * @since 3.1.0 1231 */ 1232 function wp_admin_bar_header() { 1233 $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; 1234 ?> 1235 <style<?php echo $type_attr; ?> media="print">#wpadminbar { display:none; }</style> 1236 <?php 1237 } 1238 1239 /** 1240 * Prints default admin bar callback. 1241 * 1242 * @since 3.1.0 1243 */ 1244 function _admin_bar_bump_cb() { 1245 $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; 1246 ?> 1247 <style<?php echo $type_attr; ?> media="screen"> 1248 html { margin-top: 32px !important; } 1249 @media screen and ( max-width: 782px ) { 1250 html { margin-top: 46px !important; } 1251 } 1252 </style> 1253 <?php 1228 * Enqueues inline style to hide the admin bar when printing. 1229 * 1230 * @since 6.4.0 1231 */ 1232 function wp_enqueue_admin_bar_header_styles() { 1233 // Back-compat for plugins that disable functionality by unhooking this action. 1234 $action = is_admin() ? 'admin_head' : 'wp_head'; 1235 if ( ! has_action( $action, 'wp_admin_bar_header' ) ) { 1236 return; 1237 } 1238 remove_action( $action, 'wp_admin_bar_header' ); 1239 1240 wp_add_inline_style( 'admin-bar', '@media print { #wpadminbar { display:none; } }' ); 1241 } 1242 1243 /** 1244 * Enqueues inline bump styles to make room for the admin bar. 1245 * 1246 * @since 6.4.0 1247 */ 1248 function wp_enqueue_admin_bar_bump_styles() { 1249 if ( current_theme_supports( 'admin-bar' ) ) { 1250 $admin_bar_args = get_theme_support( 'admin-bar' ); 1251 $header_callback = $admin_bar_args[0]['callback']; 1252 } 1253 1254 if ( empty( $header_callback ) ) { 1255 $header_callback = '_admin_bar_bump_cb'; 1256 } 1257 1258 if ( '_admin_bar_bump_cb' !== $header_callback ) { 1259 return; 1260 } 1261 1262 // Back-compat for plugins that disable functionality by unhooking this action. 1263 if ( ! has_action( 'wp_head', $header_callback ) ) { 1264 return; 1265 } 1266 remove_action( 'wp_head', $header_callback ); 1267 1268 $css = ' 1269 @media screen { html { margin-top: 32px !important; } } 1270 @media screen and ( max-width: 782px ) { html { margin-top: 46px !important; } } 1271 '; 1272 wp_add_inline_style( 'admin-bar', $css ); 1254 1273 } 1255 1274
Note: See TracChangeset
for help on using the changeset viewer.