wp_enqueue_admin_bar_header_styles()WP 6.4.0

Enqueues inline style to hide the admin bar when printing.

No Hooks.

Returns

null. Nothing (null).

Usage

wp_enqueue_admin_bar_header_styles();

Changelog

Since 6.4.0 Introduced.

wp_enqueue_admin_bar_header_styles() code WP 6.8.1

function wp_enqueue_admin_bar_header_styles() {
	// Back-compat for plugins that disable functionality by unhooking this action.
	$action = is_admin() ? 'admin_head' : 'wp_head';
	if ( ! has_action( $action, 'wp_admin_bar_header' ) ) {
		return;
	}
	remove_action( $action, 'wp_admin_bar_header' );

	wp_add_inline_style( 'admin-bar', '@media print { #wpadminbar { display:none; } }' );
}