Title: Introducing admin_print_footer_scripts-$hook_suffix in 4.6
Author: Thorsten Frommen
Published: July 15, 2016

---

 [  ](https://profiles.wordpress.org/tfrommen/) [Thorsten Frommen](https://profiles.wordpress.org/tfrommen/)
10:16 am _on_ July 15, 2016     
Tags: [4.6 ( 140 )](https://make.wordpress.org/core/tag/4-6/),
[dev-notes ( 648 )](https://make.wordpress.org/core/tag/dev-notes/), [plugins ( 33 )](https://make.wordpress.org/core/tag/plugins/),
[Script Loader ( 7 )](https://make.wordpress.org/core/tag/script-loader/)   

# Introducing admin_print_footer_scripts-$hook_suffix in 4.6

The [`admin_print_footer_scripts`](https://developer.wordpress.org/reference/hooks/admin_print_footer_scripts/)
action hook is the last chance to localize adminadmin (and super admin) scripts;
but it is a generic one. If you ever wanted to do something for specific admin pages
only, you would either have to hook into another dynamic action, or hook into `admin_print_footer_scripts`
and check the `$hook_suffix` (which is not even passed, but that’s not an issue)
yourself. The problem with the former is that there might be happening a lot between
the chosen action and when your script gets enqueued (`admin_print_footer_scripts`);
and maybe you need to be aware of what has happened. The problem with the latter
is that you would have to register possibly a lot of functions, maybe check the 
current admin page inside several of these, and eventually bail most of the times.
That’s why WordPress 4.6 brings the dynamic footer action `admin_print_footer_scripts-
$hook_suffix`. See [[37279]](https://core.trac.wordpress.org/changeset/37279).

The following pre-4.6 code

    ```notranslate
    add_action( 'admin_print_footer_scripts', function() {
        global $hook_suffix;

        if ( 'some_admin_page' !== $hook_suffix ) {
            return;
        }

        // Whatever it is that you want to do...
    } );
    ```

can now be simplified like this:

    ```notranslate
    add_action( 'admin_print_footer_scripts-some_admin_page', function() {
        // Whatever it is that you want to do...
    } );
    ```

This change brings more consistency between [`wp-admin/admin-footer.php`](https://developer.wordpress.org/reference/files/wp-admin/admin-footer.php/)
and [`wp-admin/admin-header.php`](https://developer.wordpress.org/reference/files/wp-admin/admin-header.php/),
which already fires the generic [`admin_print_scripts`](https://developer.wordpress.org/reference/hooks/admin_print_scripts/)
and the dynamic [`admin_print_scripts-$hook_suffix`](https://developer.wordpress.org/reference/hooks/admin_print_scripts-hook_suffix/)
actions.

For more background on the change, see [#34334](https://core.trac.wordpress.org/ticket/34334).

[#4-6](https://make.wordpress.org/core/tag/4-6/), [#dev-notes](https://make.wordpress.org/core/tag/dev-notes/),
[#plugins](https://make.wordpress.org/core/tag/plugins/), [#script-loader](https://make.wordpress.org/core/tag/script-loader/)

### Share this:

 * [  Threads ](https://make.wordpress.org/core/2016/07/15/introducing-admin_print_footer_scripts-hook_suffix-in-4-6/?share=threads)
 * [  Mastodon ](https://make.wordpress.org/core/2016/07/15/introducing-admin_print_footer_scripts-hook_suffix-in-4-6/?share=mastodon)
 * [  Bluesky ](https://make.wordpress.org/core/2016/07/15/introducing-admin_print_footer_scripts-hook_suffix-in-4-6/?share=bluesky)
 * [  X ](https://make.wordpress.org/core/2016/07/15/introducing-admin_print_footer_scripts-hook_suffix-in-4-6/?share=x)
 * [  Facebook ](https://make.wordpress.org/core/2016/07/15/introducing-admin_print_footer_scripts-hook_suffix-in-4-6/?share=facebook)
 * [  LinkedIn ](https://make.wordpress.org/core/2016/07/15/introducing-admin_print_footer_scripts-hook_suffix-in-4-6/?share=linkedin)

# Post navigation

[← register_meta() Discussion Recap (July 14, 2016)](https://make.wordpress.org/core/2016/07/14/register_meta-discussion-recap-july-14-2016/)

[External library updates in 4.6 →](https://make.wordpress.org/core/2016/07/18/external-library-updates-in-4-6/)