Add script to footer – on post editor

Hook into 'admin_footer-post-new.php' and 'admin_footer-post.php', check the global variable $post_type:

add_action( 'admin_footer-post-new.php', 'wpse_73692_script' );
add_action( 'admin_footer-post.php', 'wpse_73692_script' );

function wpse_73692_script()
{
    if ( 'post' !== $GLOBALS['post_type'] )
        return;

    ?>
<script>alert( '<?php echo $GLOBALS['post_type'];?>' );</script>
    <?php
}

Leave a Comment