WordPress.org

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Action Reference/admin head

admin_head is an action event and can be hooked by add_action hook. The action refers on the admin area and everything you include here will be applied only on the admin side. You can insert any HTML tag like <link> or <script> and this will be executed only there ( in wp-admin ). The below code shows two types of usages for this action - the first one is for CSS injection and the second one for the JavaScript code injection in the <head> of the wp-admin.

Usage Example:

<?php 

// Add inline CSS in the admin head with the style tag
function my_custom_admin_head() {
	echo '<style>[for="wp_welcome_panel-hide"] {display: none !important;}</style>';
}
add_action( 'admin_head', 'my_custom_admin_head' );

// Add inline JS in the admin head with the <script> tag

function my_custom_admin_head() {
	echo '<script type=""text/javascript">console.log('admin script')</script>';
}
add_action( 'admin_head', 'my_custom_admin_head' );
?>

In the first example I have added a style to admin_head so I can remove welcome message option from dashboard, you can make and customize your own function and add it the same way.

In the second example I have added console.log which will be executed only on the admin side.

This page is marked as incomplete. You can help Codex by expanding it.