Admin check if Tinymce
-
I’m hoping Andrew Ozz might see this… but I’ll welcome anyone’s input, respectfully π
Is there a way to check (in admin area) if there is a tinymce editor being initialized somewhere on that page?
The idea… being able to register and enqueue scripts and styles on all admin pages ONLY when a tinymce editor is used.
This may include post, page, add new post, add new page, custom post types, and any other admin page (including plugins and themes) where a tinymce editor is used.
I know this function will determine if the admin screen is a post or page:
add_action('admin_print_styles', 'add_my_tinymce_button_css'); function add_my_tinymce_button_css() { // Get current screen and determine if we are using the editor $screen = get_current_screen(); // If we are editing (adding new) post or page if ( $screen->id == 'page' || $screen->id == 'post' ) { // Register our stylesheet // Note: The stylesheet resides in our plugin directory/css/admin.css // You may change this to suit your preferences wp_register_style('my_tinymce_button_css', plugin_dir_url( __FILE__ ) . ('/css/admin.css'), array()); // Now we enqueue our stylesheet wp_enqueue_style('my_tinymce_button_css'); // Depending on when you fire things, you may/may not need to enqueue 'dashicons' wp_enqueue_style('dashicons'); } }However… it doesn’t take into account any admin pages where tinymce may be used (such as in a plugin or theme admin area). I know I can add the pages manually, but I’d have to search every plugin and theme. Impractical.
Is there something like
is_tinymce_enqueued()that can be fired from within theadmin_print_styles()filter?
The topic ‘Admin check if Tinymce’ is closed to new replies.