Make WordPress Core

Ticket #34882: 34882.diff

File 34882.diff, 2.2 KB (added by azaozz, 6 years ago)
  • src/wp-includes/class-wp-editor.php

     
    538538                                        $settings['wpeditimage_disable_captions'] = true;
    539539                                }
    540540
    541                                 $mce_css       = $settings['content_css'];
    542                                 $editor_styles = get_editor_stylesheets();
     541                                $mce_css = $settings['content_css'];
    543542
    544                                 if ( ! empty( $editor_styles ) ) {
    545                                         // Force urlencoding of commas.
    546                                         foreach ( $editor_styles as $key => $url ) {
    547                                                 if ( strpos( $url, ',' ) !== false ) {
    548                                                         $editor_styles[ $key ] = str_replace( ',', '%2C', $url );
     543                                // The `editor-style.css` added by the theme is generally intended for the editor instance on the Edit Post screen.
     544                                // Plugins that use wp_editor() on the front-end can decide whether to add the theme stylesheet
     545                                // by using `get_editor_stylesheets()` and the `mce_css` or `tiny_mce_before_init` filters, see below.
     546                                if ( is_admin() ) {
     547                                        $editor_styles = get_editor_stylesheets();
     548
     549                                        if ( ! empty( $editor_styles ) ) {
     550                                                // Force urlencoding of commas.
     551                                                foreach ( $editor_styles as $key => $url ) {
     552                                                        if ( strpos( $url, ',' ) !== false ) {
     553                                                                $editor_styles[ $key ] = str_replace( ',', '%2C', $url );
     554                                                        }
    549555                                                }
     556
     557                                                $mce_css .= ',' . implode( ',', $editor_styles );
    550558                                        }
    551 
    552                                         $mce_css .= ',' . implode( ',', $editor_styles );
    553559                                }
    554560
    555561                                /**
  • src/wp-includes/theme.php

     
    19141914 *                                 Defaults to 'editor-style.css'
    19151915 */
    19161916function add_editor_style( $stylesheet = 'editor-style.css' ) {
     1917        global $editor_styles;
     1918
    19171919        add_theme_support( 'editor-style' );
    19181920
    1919         if ( ! is_admin() ) {
    1920                 return;
    1921         }
    1922 
    1923         global $editor_styles;
    19241921        $editor_styles = (array) $editor_styles;
    19251922        $stylesheet    = (array) $stylesheet;
     1923
    19261924        if ( is_rtl() ) {
    19271925                $rtl_stylesheet = str_replace( '.css', '-rtl.css', $stylesheet[0] );
    19281926                $stylesheet[]   = $rtl_stylesheet;