Make WordPress Core

Ticket #11512: add_editor_style.3.diff

File add_editor_style.3.diff, 2.0 KB (added by nacin, 15 years ago)

Some child theme logic

  • theme.php

     
    14471447}
    14481448
    14491449/**
    1450  * Add callback for a custom TinyMCE editor stylesheet.
     1450 * Add callback for custom TinyMCE editor stylesheets.
    14511451 *
    14521452 * The parameter $stylesheet is the name of the stylesheet, relative to
    1453  * the theme root. It is optional and defaults to 'editor-style.css'.
     1453 * the theme root. It also accepts an array of stylesheets.
     1454 * It is optional and defaults to 'editor-style.css'.
    14541455 *
    14551456 * @since 3.0.0
    14561457 *
    1457  * @param callback $stylesheet Name of stylesheet relative to theme root.
     1458 * @param mixed $stylesheet Optional. Stylesheet name or array thereof, relative to theme root.
     1459 *      Defaults to 'editor-style.css'
    14581460 */
    14591461function add_editor_style( $stylesheet = 'editor-style.css' ) {
    1460         if ( isset( $GLOBALS['editor_style'] ) )
    1461                 return;
    14621462
    14631463        add_theme_support( 'editor-style' );
    14641464
    14651465        if ( ! is_admin() )
    14661466                return;
    14671467
    1468         $GLOBALS['editor_style'] = $stylesheet;
     1468        global $editor_style;
     1469        $editor_style = (array) $editor_style;
     1470        $stylesheet   = (array) $stylesheet;
     1471        foreach ( $stylesheet as $k => $v ) {
     1472                if ( file_exists( get_stylesheet_directory() . "/$v" )
     1473                        && ( $uri = get_stylesheet_directory_uri() . "/$v" )
     1474                        && ! in_array( $uri, $editor_style ) )
     1475                        $editor_style[] = $uri;
     1476                elseif ( TEMPLATEPATH !== STYLESHEETPATH
     1477                        && file_exists( get_template_directory() . "/$v" )
     1478                        && ( $uri = get_template_directory_uri() . "/$v" )
     1479                        && ! in_array( $uri, $editor_style ) )
     1480                        $editor_style[] = $uri;
     1481        }
    14691482        add_filter( 'mce_css', '_editor_style_cb' );
    14701483}
    14711484
    14721485/**
    1473  * Callback for custom editor stylesheet.
     1486 * Callback for custom editor stylesheet support.
    14741487 *
    14751488 * @since 3.0.0
    14761489 * @see add_editor_style()
     
    14801493        global $editor_style;
    14811494        if ( ! empty( $url ) )
    14821495                $url .= ',';
    1483         return $url . get_stylesheet_directory_uri() . "/$editor_style";
     1496        return $url . implode( ',', $editor_style );
    14841497}
    14851498
    14861499/**