Make WordPress Core

Changeset 13444


Ignore:
Timestamp:
02/26/2010 09:07:41 PM (15 years ago)
Author:
nacin
Message:

add_editor_style(), second pass. Accept an array of stylesheets, also allow multiple calls to the function. Support child themes. See #9015 see #11512

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/theme.php

    r13441 r13444  
    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' );
     
    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 $file ) {
     1472        if ( file_exists( get_stylesheet_directory() . "/$file" )
     1473            && ( $uri = get_stylesheet_directory_uri() . "/$file" )
     1474            && ! in_array( $uri, $editor_style ) )
     1475            $editor_style[] = $uri;
     1476        elseif ( TEMPLATEPATH !== STYLESHEETPATH
     1477            && file_exists( get_template_directory() . "/$file" )
     1478            && ( $uri = get_template_directory_uri() . "/$file" )
     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
     
    14811494    if ( ! empty( $url ) )
    14821495        $url .= ',';
    1483     return $url . get_stylesheet_directory_uri() . "/$editor_style";
     1496    return $url . implode( ',', $editor_style );
    14841497}
    14851498
Note: See TracChangeset for help on using the changeset viewer.