I have been looking at get_current_screen();
. I have seen there is also a global $current_screen;
that I could use.
Here are two examples:
// Using function
function wpse_post_notice() {
$screen = get_current_screen();
// Only run in post/page creation and edit screens
if ( $screen->post_type === 'post' ) {
return 'This is a post';
}
}
// Using gloabl
function wpse_post_notice() {
global $current_screen;
// Only run in post/page creation and edit screens
if ( $current_screen->post_type === 'post' ) {
return 'This is a post';
}
}
Is one method considered better than the other? If so why?