do_action( ‘admin_print_footer_scripts’ )

Prints any scripts and data queued for the footer.


do_action( 'admin_print_footer_scripts' );



User Contributed Notes

  1. Skip to note 2 content

    You can use this hook to insert footer javascript to alter dashboard pages,

    function admin_footer_js(){
    	//you should check to make sure this is the page your want to alter first, check if this your custom post edtit page
    	// for example .wp-admin/edit.php?post_type=my-cpt would be your custom post table list page.
    	if(!isset($_GET['post_type']) || false === strpos($_GET['post_type'],'my-cpt') ){
      		return false;
    	//get_current_screen() can result in fatal error on some admin pages, hence I use it after a basic check above
            $screen = get_current_screen();  
            if ( 'edit' != $screen->base && '' != $screen->action ){
          	//now we can sure this is our page.
    	echo "<script type='text/javascript'>\n";
    	echo 'var pluginUrl = ' . wp_json_encode( WP_PLUGIN_URL . '/my_plugin/' ) . ';';
    	echo "\n</script>";
    add_action( 'admin_print_footer_scripts', 'admin_footer_js' );

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