WordPress.org

Make WordPress Core

Ticket #38643: 38643.diff

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

    diff --git src/wp-includes/admin-bar.php src/wp-includes/admin-bar.php
    index 83deb96..2b11b5b 100644
    function wp_admin_bar_render() { 
    7171        if ( ! is_admin_bar_showing() || ! is_object( $wp_admin_bar ) )
    7272                return;
    7373
     74        $switched = switch_to_locale( get_user_locale() );
     75
    7476        /**
    7577         * Load all necessary admin bar items.
    7678         *
    function wp_admin_bar_render() { 
    9799         * @since 3.1.0
    98100         */
    99101        do_action( 'wp_after_admin_bar_render' );
     102
     103        if ( $switched ) {
     104                restore_previous_locale();
     105        }
    100106}
    101107
    102108/**
    function _get_admin_bar_pref( $context = 'front', $user = 0 ) { 
    10031009
    10041010        return 'true' === $pref;
    10051011}
     1012
     1013/**
     1014 * Temporarily changes the text direction when printing admin bar styles.
     1015 *
     1016 * @param string $html   The link tag for the enqueued style.
     1017 * @param string $handle The style's registered handle.
     1018 *
     1019 * @return string The link tag for the enqueued style.
     1020 */
     1021function _admin_bar_style_set_text_direction( $html, $handle ) {
     1022        static $text_direction = null;
     1023
     1024        if ( ! is_admin() && 'admin-bar' === $handle ) {
     1025                $switched = switch_to_locale( get_user_locale() );
     1026
     1027                $text_direction = wp_styles()->text_direction;
     1028
     1029                wp_styles()->text_direction = function_exists( 'is_rtl' ) && is_rtl() ? 'rtl' : 'ltr';
     1030
     1031                if ( $switched ) {
     1032                        restore_previous_locale();
     1033                }
     1034        } else if ( null !== $text_direction ) {
     1035                wp_styles()->text_direction = $text_direction;
     1036        }
     1037
     1038        return $html;
     1039}
  • src/wp-includes/default-filters.php

    diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php
    index 5a73975..fefe7df 100644
    add_filter( 'customize_controls_print_styles', 'wp_resource_hints', 1 ); 
    434434
    435435add_action( 'wp_default_styles', 'wp_default_styles' );
    436436add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );
     437add_filter( 'style_loader_tag', '_admin_bar_style_loader_tag', 10, 2 );
    437438
    438439// Taxonomy
    439440add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority