Make WordPress Core

Ticket #52294: method-2-example.diff

File method-2-example.diff, 3.0 KB (added by yoavf, 3 years ago)

adding a new param to add_editor_style to allow replacing the css file with RTL version

  • src/wp-content/themes/twentytwentyone/functions.php

    diff --git a/src/wp-content/themes/twentytwentyone/functions.php b/src/wp-content/themes/twentytwentyone/functions.php
    index 1139c3b659..78edfde4b6 100644
    a b if ( ! function_exists( 'twenty_twenty_one_setup' ) ) { 
    140140                }
    141141
    142142                // Enqueue editor styles.
    143                 add_editor_style( $editor_stylesheet_path );
     143                add_editor_style( $editor_stylesheet_path, 'replace' );
    144144
    145145                // Add custom editor font sizes.
    146146                add_theme_support(
  • src/wp-content/themes/twentytwentyone/package.json

    diff --git a/src/wp-content/themes/twentytwentyone/package.json b/src/wp-content/themes/twentytwentyone/package.json
    index 6c43119fcb..bfa1cc75e5 100644
    a b  
    5555                "build:style-dark-mode": "sass assets/sass/style-dark-mode.scss:assets/css/style-dark-mode.css --style=expanded --source-map",
    5656                "build:rtl": "rtlcss style.css style-rtl.css style-dark-mode.css style-dark-mode-rtl.css",
    5757                "build:dark-rtl": "rtlcss assets/css/style-dark-mode.css assets/css/style-dark-mode-rtl.css",
     58                "build:style-editor-rtl": "rtlcss assets/css/style-editor.css assets/css/style-editor-rtl.css",
    5859                "build:print": "sass assets/sass/07-utilities/print.scss:assets/css/print.css --style=expanded --source-map",
    5960                "build:ie": "postcss style.css -o assets/css/ie.css",
    6061                "build:ie-editor": "postcss assets/css/style-editor.css -o assets/css/ie-editor.css",
  • src/wp-includes/theme.php

    diff --git a/src/wp-includes/theme.php b/src/wp-includes/theme.php
    index 916c836f43..ed63c1989c 100644
    a b function wp_update_custom_css_post( $css, $args = array() ) { 
    20352035 * Since version 3.4 the TinyMCE body has .rtl CSS class.
    20362036 * It is a better option to use that class and add any RTL styles to the main stylesheet.
    20372037 *
     2038 * @param array|string $stylesheet Optional. Stylesheet name or array thereof, relative to theme root.
     2039 *                                 Defaults to 'editor-style.css'
     2040 * @param string $rtl_mode Optional. Should the rtl stylesheet be loaded instead or in addition to the main stylesheet.
     2041 *                                 Defaults to 'add'
     2042 *
    20382043 * @since 3.0.0
    20392044 *
    20402045 * @global array $editor_styles
    20412046 *
    2042  * @param array|string $stylesheet Optional. Stylesheet name or array thereof, relative to theme root.
    2043  *                                 Defaults to 'editor-style.css'
    20442047 */
    2045 function add_editor_style( $stylesheet = 'editor-style.css' ) {
     2048function add_editor_style( $stylesheet = 'editor-style.css', $rtl_mode = 'add' ) {
    20462049        global $editor_styles;
    20472050
    20482051        add_theme_support( 'editor-style' );
    function add_editor_style( $stylesheet = 'editor-style.css' ) { 
    20532056        if ( is_rtl() ) {
    20542057                $rtl_stylesheet = str_replace( '.css', '-rtl.css', $stylesheet[0] );
    20552058                $stylesheet[]   = $rtl_stylesheet;
     2059
     2060                if ( $rtl_mode === 'replace' ) {
     2061                        unset( $stylesheet[0] );
     2062                }
    20562063        }
    20572064
    20582065        $editor_styles = array_merge( $editor_styles, $stylesheet );