1

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 ...

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
}
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' );
}
  • Thanks. There is no equivalent for doing this $pagenow thing with the screen object I guess? – NextGenThemes Apr 10 '14 at 5:27
  • @redanimalwar Nothing really unique. But I might be wrong. – fuxia Apr 10 '14 at 5:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.