Make WordPress Core

Ticket #38643: 38643.WIP.diff

File 38643.WIP.diff, 2.0 KB (added by sabernhardt, 4 years ago)
  • src/wp-includes/admin-bar.php

     
    8383                return;
    8484        }
    8585
     86        $switched = switch_to_locale( get_user_locale() );
     87
    8688        /**
    8789         * Load all necessary admin bar items.
    8890         *
     
    110112         */
    111113        do_action( 'wp_after_admin_bar_render' );
    112114
     115        if ( $switched ) {
     116                restore_previous_locale();
     117        }
     118
    113119        $rendered = true;
    114120}
    115121
     
    12661272
    12671273        return 'true' === $pref;
    12681274}
     1275
     1276/**
     1277 * Temporarily change the text direction when printing admin bar styles.
     1278 *
     1279 * @since x.x.x
     1280 * @access private
     1281 *
     1282 * @param string $html   The link tag for the enqueued style.
     1283 * @param string $handle The style's registered handle.
     1284 *
     1285 * @return string The link tag for the enqueued style.
     1286 */
     1287function _admin_bar_style_set_text_direction( $html, $handle ) {
     1288        static $text_direction = null;
     1289
     1290        if ( ! is_admin() && 'admin-bar' === $handle ) {
     1291                $switched = switch_to_locale( get_user_locale() );
     1292
     1293                $text_direction = wp_styles()->text_direction;
     1294
     1295                wp_styles()->text_direction = function_exists( 'is_rtl' ) && is_rtl() ? 'rtl' : 'ltr';
     1296
     1297                if ( $switched ) {
     1298                        restore_previous_locale();
     1299                }
     1300        } else if ( null !== $text_direction ) {
     1301                wp_styles()->text_direction = $text_direction;
     1302        }
     1303
     1304        return $html;
     1305}
  • src/wp-includes/default-filters.php

     
    574574
    575575add_action( 'wp_default_styles', 'wp_default_styles' );
    576576add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );
     577add_filter( 'style_loader_src', '_admin_bar_style_set_text_direction', 10, 2 );
    577578
    578579add_action( 'wp_head', 'wp_maybe_inline_styles', 1 ); // Run for styles enqueued in <head>.
    579580add_action( 'wp_footer', 'wp_maybe_inline_styles', 1 ); // Run for late-loaded styles in the footer.