The admin_print_footer_scripts WordPress PHP action is used to print any scripts and data queued for the footer in the admin area.
Usage
add_action('admin_print_footer_scripts', 'your_custom_function'); function your_custom_function() { // your custom code here }
Parameters
There are no parameters for this action.
More information
See WordPress Developer Resources: admin_print_footer_scripts
Examples
Add a custom script to the admin footer
This example adds a custom JavaScript script to the admin footer.
add_action('admin_print_footer_scripts', 'add_my_custom_script'); function add_my_custom_script() { echo '<script>alert("Hello from the admin footer!");</script>'; }
Enqueue a script file in the admin footer
This example enqueues a script file called ‘my-admin-script.js’ located in the theme’s ‘js’ folder.
add_action('admin_print_footer_scripts', 'enqueue_my_admin_script'); function enqueue_my_admin_script() { wp_enqueue_script('my-admin-script', get_template_directory_uri() . '/js/my-admin-script.js', array(), '1.0', true); }
Add custom inline script with jQuery
This example adds an inline script using jQuery to toggle a custom meta box.
add_action('admin_print_footer_scripts', 'add_toggle_meta_box_script'); function add_toggle_meta_box_script() { echo "<script> jQuery(document).ready(function($) { $('.toggle-meta-box').on('click', function() { $('.custom-meta-box').toggle(); }); }); </script>"; }
Print custom CSS in the admin footer
This example prints custom CSS in the admin footer to change the background color of the admin area.
add_action('admin_print_footer_scripts', 'add_custom_admin_css'); function add_custom_admin_css() { echo '<style>body { background-color: #f5f5f5; }</style>'; }
Add a custom JavaScript function in the admin footer
This example adds a custom JavaScript function in the admin footer that can be called by other scripts.
add_action('admin_print_footer_scripts', 'add_custom_js_function'); function add_custom_js_function() { echo "<script> function showAlert(message) { alert(message); } </script>"; }