do_action( “admin_head-{$hook_suffix}” )

Fires in head section for a specific admin page.

Description

The dynamic portion of the hook name, $hook_suffix, refers to the hook suffix for the admin page.

More Information

This hook provides no parameters. You use this hook by having your function echo output to the browser, or by having it perform background tasks. Your functions shouldn’t return, and shouldn’t take any parameters.

Source

do_action( "admin_head-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores

Changelog

VersionDescription
2.1.0Introduced.

User Contributed Notes

  1. Skip to note 3 content

    (From Codex)
    Tools pages

    To add <head></head> content to a management page, the suffix for this hook should be in the following form:

    add_action('admin_head-tools_page_myplugin/myplugin', 'myplugin_adminhead');
    function myplugin_adminhead() {
        // Output <head> content here, e.g.:
        echo '<style type="text/css">'
             .'/* ... */'
             .'</style>';
    }
  2. Skip to note 4 content

    (From Codex)
    Options pages

    This hook is an action which means that it primarily acts as an event trigger, instead of a content filter. This is a semantic difference, but it will help you to remember what this hook does if you use it like this:

    add_action( 'admin_menu', 'myplugin_setup_options' );
    
    function myplugin_setup_options(){
      $plugin_page=add_options_page( 'My Plugin', 'myplugin', 8, basename(__FILE__), 'myplugin_main' );
      add_action( 'admin_head-'. $plugin_page, 'myplugin_admin_header' );
    }
    
    function myplugin_admin_header(){
      echo '<p>Only executes when the myplugin options page is displayed.</p>';
    }

You must log in before being able to contribute a note or feedback.