So I'm trying to figure out how to properly use the get_current_screen. For learning sake, I'm just popping an alert for a specific page. I've looked at http://www.deluxeblogtips.com/2012/01/get-admin-screen-information.html and the codex on WP_Screen and get_current_screen (hit my max links cause my rep isn't 10 yet)
I thought I was doing this right...but not getting it to work. What I'm hoping for is that when I go to /wp-admin/post-new.php?post_type=product I can do stuff (will be enqueueing a script). Did pretty much a straight copy and changed the post type...but, what am I missing here?
add_action( 'wp_enqueue_scripts', 'rw_enqueue_scripts' );
/**
* Enqueue scripts for 'post' page of 'product' post type only
*
* @return void
*/
function rw_enqueue_scripts()
{
$screen = get_current_screen();
// Check screen base and current post type
if ( 'post' === $screen->base && 'product' === $screen->post_type )
{
echo "<script type='text/javascript'>alert('worked');</script>
";
}
}
Thanx in advance,
Brian