Support » Plugins and Hacks » Hacks » load stylesheet for editor

  • Resolved shazdeh

    (@shazdeh)


    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?

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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.

    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' );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘load stylesheet for editor’ is closed to new replies.