/** * Checks if the current request should be redirected. * * Requires an accept header, the redirect feature being active for the current site, and the current language not * being included in the $_SESSION's noredirect element. * * @return bool */ public function is_redirectable() { if (empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { return false; } if (!get_option($this->option_name)) { return false; } if (!isset($_SESSION) && !session_id()) { session_start(); } if (isset($_SESSION['noredirect'])) { $current_site_language = \Inpsyde\MultilingualPress\get_current_site_language(); if (in_array($current_site_language, (array) $_SESSION['noredirect'], true)) { return false; } } /** * Filters if the current request should be redirected. * * @param bool $redirect Redirect the current request? */ return (bool) apply_filters('mlp_do_redirect', true); }
/** * Use the current blog's language for the html tag. * * @wp-hook language_attributes * * @param string $output Language attributes HTML. * * @return string */ public function language_attributes($output) { $site_language = \Inpsyde\MultilingualPress\get_current_site_language(); if (!$site_language) { return $output; } $language = get_bloginfo('language'); $site_language = str_replace('_', '-', $site_language); return str_replace($language, $site_language, $output); }