Using WordPress ‘admin_print_footer_scripts-{$hook_suffix}’ PHP action

The admin_print_footer_scripts-{$hook_suffix} WordPress PHP action is used to print scripts and data queued for the footer of a WordPress admin page.

Usage

add_action('admin_print_footer_scripts-{$hook_suffix}', 'your_custom_function');
function your_custom_function() {
    // your custom code here
}

Parameters

  • None

More information

See WordPress Developer Resources: admin_print_footer_scripts-{$hook_suffix}

Examples

Add a custom JavaScript script to the footer of the ‘edit-post’ page

This code adds a custom JavaScript script to the footer of the ‘edit-post’ page in the WordPress admin area.

add_action('admin_print_footer_scripts-edit.php', 'enqueue_custom_script');
function enqueue_custom_script() {
    echo '<script type="text/javascript">
            // Your custom JavaScript code
          </script>';
}

This code adds a custom CSS style to the footer of the ‘themes’ page in the WordPress admin area.

add_action('admin_print_footer_scripts-themes.php', 'enqueue_custom_css');
function enqueue_custom_css() {
    echo '<style>
            /* Your custom CSS styles */
          </style>';
}

This code prints a JavaScript alert on the ‘plugins’ page in the WordPress admin area.

add_action('admin_print_footer_scripts-plugins.php', 'show_alert_on_plugins_page');
function show_alert_on_plugins_page() {
    echo '<script type="text/javascript">
            alert("Welcome to the Plugins Page!");
          </script>';
}

This code adds a custom JavaScript function to the footer of the ‘widgets’ page in the WordPress admin area.

add_action('admin_print_footer_scripts-widgets.php', 'enqueue_custom_js_function');
function enqueue_custom_js_function() {
    echo '<script type="text/javascript">
            function myCustomFunction() {
                // Your custom JavaScript function
            }
          </script>';
}

Add a custom CSS class to the body of the ‘profile’ page

This code adds a custom CSS class to the body of the ‘profile’ page in the WordPress admin area.

add_action('admin_print_footer_scripts-profile.php', 'add_custom_css_class');
function add_custom_css_class() {
    echo '<script type="text/javascript">
            document.body.classList.add("my-custom-class");
          </script>';
}