From 59b2461dcf2feb0ccfca1d5b06000bd6d2301677 Mon Sep 17 00:00:00 2001 From: nacin Date: Fri, 26 Feb 2010 21:07:41 +0000 Subject: [PATCH] add_editor_style(), second pass. Accept an array of stylesheets, also allow multiple calls to the function. Support child themes. See #9015 see #11512 git-svn-id: http://svn.automattic.com/wordpress/trunk@13444 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/theme.php | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/wp-includes/theme.php b/wp-includes/theme.php index 741c66d36..0e80fcb1e 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -1447,30 +1447,43 @@ body { } /** - * Add callback for a custom TinyMCE editor stylesheet. + * Add callback for custom TinyMCE editor stylesheets. * * The parameter $stylesheet is the name of the stylesheet, relative to - * the theme root. It is optional and defaults to 'editor-style.css'. + * the theme root. It also accepts an array of stylesheets. + * It is optional and defaults to 'editor-style.css'. * * @since 3.0.0 * - * @param callback $stylesheet Name of stylesheet relative to theme root. + * @param mixed $stylesheet Optional. Stylesheet name or array thereof, relative to theme root. + * Defaults to 'editor-style.css' */ 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; + global $editor_style; + $editor_style = (array) $editor_style; + $stylesheet = (array) $stylesheet; + foreach ( $stylesheet as $file ) { + if ( file_exists( get_stylesheet_directory() . "/$file" ) + && ( $uri = get_stylesheet_directory_uri() . "/$file" ) + && ! in_array( $uri, $editor_style ) ) + $editor_style[] = $uri; + elseif ( TEMPLATEPATH !== STYLESHEETPATH + && file_exists( get_template_directory() . "/$file" ) + && ( $uri = get_template_directory_uri() . "/$file" ) + && ! in_array( $uri, $editor_style ) ) + $editor_style[] = $uri; + } add_filter( 'mce_css', '_editor_style_cb' ); } /** - * Callback for custom editor stylesheet. + * Callback for custom editor stylesheet support. * * @since 3.0.0 * @see add_editor_style() @@ -1480,7 +1493,7 @@ function _editor_style_cb( $url ) { global $editor_style; if ( ! empty( $url ) ) $url .= ','; - return $url . get_stylesheet_directory_uri() . "/$editor_style"; + return $url . implode( ',', $editor_style ); } /**