Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
function lynt_is_en() {
$path_parts = explode('/', $_SERVER['REQUEST_URI']);
if (isset($path_parts[1]) && $path_parts[1] === 'en') {
return true;
}
return false;
}
function lynt_set_locale($locale) {
if (lynt_is_en()) {
$locale = 'en_US';
}
return $locale;
}
function lynt_register_en_sidebars() {
register_sidebar(array(
'name' => __('Footer 1 EN', 'lynt_theme'),
'id' => 'footer-1-en'
));
}
function lynt_switch_sidebars($widgets) {
$original = 'footer-1';
$new = 'footer-1-en';
if (lynt_is_en() && isset($widgets[$original]) && isset($widgets[$new])){
$widgets[$original] = $widgets[$new];
}
return $widgets;
}
function lynt_switch_menus($args) {
$new_id = 4;
if (lynt_is_en() && $args['theme_location'] === 'primary') {
$args['menu'] = $new_id;
}
return $args;
}
add_action('locale', 'lynt_set_locale');
add_action('widgets_init', 'lynt_register_en_sidebars');
add_filter('sidebars_widgets', 'lynt_switch_sidebars');
add_filter('wp_nav_menu_args', 'lynt_switch_menus');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment