Ticket #38643: 38643.WIP.diff
File 38643.WIP.diff, 2.0 KB (added by , 4 years ago) |
---|
-
src/wp-includes/admin-bar.php
83 83 return; 84 84 } 85 85 86 $switched = switch_to_locale( get_user_locale() ); 87 86 88 /** 87 89 * Load all necessary admin bar items. 88 90 * … … 110 112 */ 111 113 do_action( 'wp_after_admin_bar_render' ); 112 114 115 if ( $switched ) { 116 restore_previous_locale(); 117 } 118 113 119 $rendered = true; 114 120 } 115 121 … … 1266 1272 1267 1273 return 'true' === $pref; 1268 1274 } 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 */ 1287 function _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
574 574 575 575 add_action( 'wp_default_styles', 'wp_default_styles' ); 576 576 add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 ); 577 add_filter( 'style_loader_src', '_admin_bar_style_set_text_direction', 10, 2 ); 577 578 578 579 add_action( 'wp_head', 'wp_maybe_inline_styles', 1 ); // Run for styles enqueued in <head>. 579 580 add_action( 'wp_footer', 'wp_maybe_inline_styles', 1 ); // Run for late-loaded styles in the footer.