diff --git a/uls-functions.php b/uls-functions.php index 6b998b0..b677788 100644 --- a/uls-functions.php +++ b/uls-functions.php @@ -646,20 +646,6 @@ function uls_tab_background_color_picker() { object_id, 'uls_translation_'.strtolower(uls_get_user_language()), true); - if ( !empty($post_id) ) { - $key->title = get_post($post_id)->post_title; - $key->url = uls_get_url_translated($key->url); - var_dump('yeah!'); - } - } - return $object; -} -//add_filter( 'wp_nav_menu_objects', 'uls_traduction_automatic_menu');*/ // this functin action is for register sidebar if the checkbox in backend is enable function uls_register_sidebar_laguages() { diff --git a/user-language-switch.php b/user-language-switch.php index b6d95dc..9c4abf0 100644 --- a/user-language-switch.php +++ b/user-language-switch.php @@ -1337,6 +1337,23 @@ function update_db_after_update() { register_activation_hook( __FILE__, 'update_db_after_update' ); +// this function search the front page and show its traduction if it has +// the filter is the option_ this Used to temporarily alter a WordPress option before you display a specific view +// alter the page_on_front action + +add_filter('option_page_on_front', 'uls_search_front_page_translation'); +function uls_search_front_page_translation($page_on_front) { + + if (!empty($page_on_front) ) { + $lang_code = uls_get_site_language(); // get site language + $get_page_translation = get_post_meta($page_on_front,'uls_translation_'.strtolower($lang_code), true); // get language translations + + if ( !empty($get_page_translation) ) { + return $get_page_translation; + } + } + return $page_on_front; +} /* Moving configuration options to user profile page */