2196 posts
  • Located in Europe
  • Made it to the Authors' Hall of Fame
  • Had an item featured on Envato Market
  • Participated in a focus group or interview to improve the user experience on Envato Market
+10 more
revaxarts says

I would like to enqueue scripts only if the editor is supported

This is what I have
function init(){
    global $post;
    if(!post_type_supports( $post->post_type, 'editor' )) return false;
    //enqueue scripts
}
add_action('admin_init', 'init');

Unfortunately $post is not defined yet. So I guess ‘admin_init’ is “to early” in the hook queue

147 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 10+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+2 more
FlexiPress says

this is my code


add_action( 'admin_menu', 'prima_editor_init' );
function prima_editor_init() {
    $post_types = get_post_types( array( 'show_ui' => true ), 'objects' );
    foreach ( $post_types as $type ) {
        if ( post_type_supports( $type->name, "editor" ) ) {
            add_action( "load-post.php", 'prima_editor_enqueue_script' );
            add_action( "load-post-new.php", 'prima_editor_enqueue_script' );
        }
    }
}

function prima_editor_enqueue_script() {
    // my wp_enqueue_script script
}
2196 posts
  • Located in Europe
  • Made it to the Authors' Hall of Fame
  • Had an item featured on Envato Market
  • Participated in a focus group or interview to improve the user experience on Envato Market
+10 more
revaxarts says

Thanks, I’ll give it a try

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by