Change WordPress language based on user setting

Your use of $current_user is a little wrong, you should include the global $current_user or assign it to a variable, or shorter and cleaner just get_current_user_id(): add_filter(‘locale’, ‘change_lang’); function change_lang( $locale ) { if( $lang = get_user_meta( get_current_user_id(), ‘user_lang’, true) ) { return $lang; } return $locale; }

Using esc_attr function

Remember to have the text domain along with the render functions (echo function). It means that, they should be: esc_attr_e(“Text needing to be translated”,”your_text_domain”);<br> esc_attr_x(“Text needing to be translated”,”your_text_domain”);<br> ___(“Text needing to be translated”,”your_text_domain”);

How can i localized html or php source code from wordpress [closed]

<a style=”color:#333;” class=”read-more” href=””>Read More</a> From the inline style and class I cannot find in WP core it seems to be custom developed. You would have to searches through the sources of your site to locate code responsible (likely theme, but might not be). PS FYI Chrome blocks access to your site with malware warning.

How to translate theme content using site language?

Make sure to load the translations using the load_theme_textdomain function, and supposed your translations is located in the library/translations folder, then you can add the code below in you functions.php file. // let’s get this party started add_action( ‘after_setup_theme’, ‘translations’); function translations() { // let’s get language support going, if you need it load_theme_textdomain( ‘text_domain’, … Read more

Loading custom language file for plugin

If you will use the translation only in back end, then load the translation file on the hook admin_init. If not, also on front end, then use the hook init. A example: class Fb_Example_Class { /** * Constructor, init the functions inside WP * * @return \Fb_Example_Class */ private function __construct() { // load translation … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)