WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] load stylesheet for editor (3 posts)

  1. shazdeh
    Member
    Posted 2 years ago #

    We have add_editor_style function, but the path to the stylesheet is relative to theme root. I was wondering how to load a stylesheet for editor from an external source?

  2. shazdeh
    Member
    Posted 2 years ago #

    Here's the solution I came up with, if interested:

    if( typeof jQuery != "undefined" ) {
    	jQuery(window).load(function() {
    		if( jQuery('#content_ifr').length > 0 ) {
    			jQuery('<link rel="stylesheet" href="STYLESHEET_URL" />').appendTo( jQuery('#content_ifr')[0].contentWindow.document.head );
    		}
    	});
    }

    I'm printing this on 'admin_print_footer_scripts' hook.

  3. shazdeh
    Member
    Posted 2 years ago #

    I just found the solution:

    function plugin_mce_css($mce_css) {
      if (! empty($mce_css)) $mce_css .= ',';
      $mce_css .= plugins_url('css/styles.css', __FILE__);
      return $mce_css;
    }
    add_filter( 'mce_css', 'plugin_mce_css' );

Topic Closed

This topic has been closed to new replies.

About this Topic