I have a theme of Savoy bought from ThemeForest. I am making this theme to RTL with the help of WordPress.
According to WordPress documentation.https://codex.wordpress.org/Right-to-Left_Language_Support.
I convert the savoy theme style.css file with the RTLCSS tool. I put the file name style-rtl.css in the root directory as style.css is. There is 3 CSS file in the asset/CSS directory element.css, shop.css. grid.css. I also convert them into RTL CSS files as elements_rtl.css, shop_rtl.css, grid_rtl.css.
Then put this function to the function.php file:
This function I get from a tutorial who says that just enter this function to enqueue :
wp_register_style('ju_style_rtl' , $uri . '/style-rtl.css');
wp_register_style('ju_style_editor_rtl' , $uri . '/assets/css/rtl_css/style_editor_rtl.css');
wp_register_style('ju_elements_rtl' , $uri . '/assets/css/rtl_css/elements_rtl.css');
wp_register_style('ju_grid_rtl' , $uri . '/assets/css/rtl_css/grid_rtl.css');
wp_register_style('ju_shop_rtl' , $uri . '/assets/css/rtl_css/shop_rtl.css');
if(is_rtl() ){
wp_enqueue_style('ju_style_rtl' );
wp_enqueue_style('ju_elements_rtl' );
wp_enqueue_style('ju_grid_rtl' );
wp_enqueue_style('ju_shop_rtl' );
}
This function I get from an online Article and it is also according to wordpress.
//WP_RTL
function enqueue_theme_files() {
wp_enqueue_style( ‘themeslug-style’, get_stylesheet_uri() );
wp_style_add_data( ‘themeslug-style’, ‘rtl’, ‘replace’ );
}
add_action( ‘wp_enqueue_scripts’, ‘enqueue_theme_files’ );
So the main problem comes now when I upload this theme to WordPress it works perfectly when I test it by RTL tester as I keep login but when I log out from the wordpress or open the website from another browser it keep same as LTR.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…