Make WordPress Core

Ticket #11512: add_editor_style.diff

File add_editor_style.diff, 2.3 KB (added by nacin, 15 years ago)
  • wp-content/themes/twentyten/functions.php

     
    2828
    2929        add_custom_background();
    3030
     31        // This theme styles the visual editor with editor-style.css to match the theme style.
     32        add_editor_style();
     33
    3134        // This theme needs post thumbnails
    3235        add_theme_support( 'post-thumbnails' );
    3336
     
    134137}
    135138endif;
    136139
    137 // Make the Visual Editor styles match the theme's styles
    138 if ( ! function_exists( 'twentyten_editor_style' ) ) :
    139 function twentyten_editor_style( $url ) {
    140         if ( ! empty( $url ) )
    141                 $url .= ',';
    142 
    143         // Change the path here if using sub-directory
    144         $url .= trailingslashit( get_stylesheet_directory_uri() ) . 'editor-style.css';
    145 
    146         return $url;
    147 }
    148 endif;
    149 add_filter( 'mce_css', 'twentyten_editor_style' );
    150 
    151140// Remove inline styles on gallery shortcode
    152141if ( ! function_exists( 'twentyten_remove_gallery_css' ) ) :
    153142function twentyten_remove_gallery_css() {
  • wp-includes/theme.php

     
    14471447}
    14481448
    14491449/**
     1450 * Add callback for a custom TinyMCE editor stylesheet.
     1451 *
     1452 * The parameter $stylesheet is the name of the stylesheet, relative to
     1453 * the theme root. It is optional and defaults to 'editor-style.css'.
     1454 *
     1455 * @since 3.0.0
     1456 *
     1457 * @param callback $stylesheet Name of stylesheet relative to theme root.
     1458 */
     1459function add_editor_style( $stylesheet = 'editor-style.css' ) {
     1460        if ( isset( $GLOBALS['editor_style'] ) )
     1461                return;
     1462
     1463        add_theme_support( 'editor-style' );
     1464
     1465        if ( ! is_admin() )
     1466                return;
     1467
     1468        $GLOBALS['editor_style'] = $stylesheet;
     1469        add_filter( 'mce_css', '_editor_style_cb' );
     1470}
     1471
     1472/**
     1473 * Callback for custom editor stylesheet.
     1474 *
     1475 * @since 3.0.0
     1476 * @see add_editor_style()
     1477 * @access protected
     1478 */
     1479function _editor_style_cb( $url ) {
     1480        global $editor_style;
     1481        if ( ! empty( $url ) )
     1482                $url .= ',';
     1483        return $url . get_stylesheet_directory_uri() . "/$editor_style";
     1484}
     1485
     1486/**
    14501487 * Allows a theme to register its support of a certain feature
    14511488 *
    14521489 * Must be called in the themes functions.php file to work.