I'm trying to get current screen within wp-admin for some conditional functions to run based on screeen name as follow :
global $this_screen;
function wporg_current_screen_example( $current_screen ) {
$this_screen = $current_screen->post_type;
echo $this_screen; // Returns current screen name
}
add_action( 'current_screen', 'wporg_current_screen_example' );
echo $this_screen; // Always returns empty
Inside function, I do get value for echo $this_screen;
But when I try to get value of echo $this_screen; outside action/function it returns empty.
So, How do I get variable value outside of action hook ?
Aucun commentaire:
Enregistrer un commentaire