Introduce add_editor_style() to easily register a stylesheet for the visual editor. see #11512 see #9015

git-svn-id: https://develop.svn.wordpress.org/trunk@13441 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin
2010-02-26 20:12:06 +00:00
parent 280e43154d
commit 33798863d4
2 changed files with 40 additions and 14 deletions

View File

@@ -1446,6 +1446,43 @@ body {
<?php
}
/**
* Add callback for a custom TinyMCE editor stylesheet.
*
* The parameter $stylesheet is the name of the stylesheet, relative to
* the theme root. It is optional and defaults to 'editor-style.css'.
*
* @since 3.0.0
*
* @param callback $stylesheet Name of stylesheet relative to theme root.
*/
function add_editor_style( $stylesheet = 'editor-style.css' ) {
if ( isset( $GLOBALS['editor_style'] ) )
return;
add_theme_support( 'editor-style' );
if ( ! is_admin() )
return;
$GLOBALS['editor_style'] = $stylesheet;
add_filter( 'mce_css', '_editor_style_cb' );
}
/**
* Callback for custom editor stylesheet.
*
* @since 3.0.0
* @see add_editor_style()
* @access protected
*/
function _editor_style_cb( $url ) {
global $editor_style;
if ( ! empty( $url ) )
$url .= ',';
return $url . get_stylesheet_directory_uri() . "/$editor_style";
}
/**
* Allows a theme to register its support of a certain feature
*