Correct check for any admin page with editor

I have read the codex, but found it a bit incomplete. I like to load stuff only on pages where the post editor is visible. This should include custom post types and everything.

I am a bit insure about the get_current_screen() Object. When to use base, parent_base

Read More

Would this be the right check? Tested it on pages and posts and seem to be working. Just asking because I am curious if I could to this better.

$screen = get_current_screen();

if ( 'post' == $screen->base || 'page' == $screen->base ) {
// Load stuff
}

Related posts

Leave a Reply

1 comment

  1. Inspect the global variable $pagenow, and use post_type_supports() to find post types with an editor:

    function has_post_editor() 
    {    
        global $pagenow;
    
        if ( empty ( $pagenow ) )
            return FALSE;
    
        if ( ! in_array( $pagenow, array ( 'post-new.php', 'post.php' ) ) )
            return FALSE;
    
        return post_type_supports( get_current_screen()->post_type, 'editor' );
    }