WordPress.org

Make WordPress Core

Ticket #11512: add_editor_style.2.diff

File add_editor_style.2.diff, 1.6 KB (added by nacin, 8 years ago)

Second pass supports arrays of stylesheets, and multiple calls to add_editor_style()

  • 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        $stylesheet = (array) $stylesheet;
     1470        foreach ( $stylesheet as $k => $v ) {
     1471                $stylesheet[$k] = get_stylesheet_directory_uri() . "/$v";
     1472        }
     1473        $editor_style = array_merge( (array) $editor_style, $stylesheet );
    14691474        add_filter( 'mce_css', '_editor_style_cb' );
    14701475}
    14711476
    14721477/**
    1473  * Callback for custom editor stylesheet.
     1478 * Callback for custom editor stylesheet support.
    14741479 *
    14751480 * @since 3.0.0
    14761481 * @see add_editor_style()
     
    14801485        global $editor_style;
    14811486        if ( ! empty( $url ) )
    14821487                $url .= ',';
    1483         return $url . get_stylesheet_directory_uri() . "/$editor_style";
     1488        return $url . implode( ',', $editor_style );
    14841489}
    14851490
    14861491/**