This is default wordpress add_editor_style function:
function add_editor_style( $stylesheet = 'editor-style.css' ) {
add_theme_support( 'editor-style' );
if ( ! is_admin() )
return;
global $editor_styles;
$editor_styles = (array) $editor_styles;
$stylesheet = (array) $stylesheet;
if ( is_rtl() ) {
$rtl_stylesheet = str_replace('.css', '-rtl.css', $stylesheet[0]);
$stylesheet[] = $rtl_stylesheet;
}
$editor_styles = array_merge( $editor_styles, $stylesheet );
}
As you see if ( ! is_admin() ) return;
is there and basically we cant add custom styles to frontend wp_editor.. What is proper solution for it?
Here is my solution:
Live Example: http://unsalkorkmaz.com/firmasite-social-buddypress-bbpress-theme-based-on-bootstrap/
Check comments wp_editor.. its loading bootstrap.css and google fonts etc..
This code is extra:
Its removing version from styles and scripts. So browser wont load same style double times.
add_editor_style
is not meant to load a stylesheet on the front end. It is meant to make the visual editor display on the backend of the site look more like the final version of the post on the front end. There is no filter (you found the function source) that lets you change that behavior.If you have an editor on the front end, style it just like you style anything else- on the front end– by editing
style.css
or by conditionally loading another stylesheet withwp_register_style
,wp_enqueue_style
, andwp_enqueue_scripts
I don’t know how your editor works but I included a condition that should only load the editor on a template named
editor.php
. I am sure that is wrong but should be illustrative.Caveat: I don’t know what your front end editor is or how it works. I am assuming it is the core editor that you’ve loaded on the front. I know that directly editing an admin stylesheet (appropriate or not) will alter the appearance of the backend editor. The same thing should be true on the front.
http://codex.wordpress.org/Function_Reference/get_stylesheet_directory
http://codex.wordpress.org/Function_Reference/is_page_template