I have a theme which support RTL. RTL direction semi work with WPML plugin, but when I add ?rtl=1
to URL it work fully. I mean it switch direction in the correct way.
How I can switch direction without add ?rtl=1
to each URL?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI have a theme which support RTL. RTL direction semi work with WPML plugin, but when I add ?rtl=1
to URL it work fully. I mean it switch direction in the correct way.
How I can switch direction without add ?rtl=1
to each URL?
Looking at the source, there is no programmatic way to accomplish that. There is only one location where $_GET['rtl']
is referenced and its value is used directly (i.e., it is not used to set the value of another variable used in the plugin). The function you would want to modify if you want the same effect without passing the rtl
parameter is function _show_post_content()
in inc/translation-management/translation-management.class.php
. Specifically this block of code looks to be the only place affected by the parameter:
[...]
if ( @intval( $_GET[ 'rtl' ] ) ) {
$rtl = ' dir="rtl"';
} else {
$rtl = '';
}
echo '<html' . $rtl . '>';
[...]
You could just remove the if/else statement all together and change the echo to echo '<html dir="rtl">'
for a quick "hacky" fix if desired.