/** * Redirects if needed. * * @return bool */ public function redirect() { if (!empty($_GET['noredirect'])) { $this->save_session($_GET['noredirect']); return false; } $redirect_match = $this->negotiation->get_redirect_match(); $current_site_id = get_current_blog_id(); if ($redirect_match['site_id'] === $current_site_id) { return false; } /** * Filters the redirect URL. * * @param string $url Redirect URL. * @param array $redirect_match Redirect match. { * 'priority' => int * 'url' => string * 'language' => string * 'site_id' => int * } * @param int $current_site_id Current site ID. * * @return string */ $url = (string) apply_filters('mlp_redirect_url', $redirect_match['url'], $redirect_match, $current_site_id); if (!$url) { return false; } $this->save_session($redirect_match['language']); wp_redirect($url); $this->call_exit(); return true; }
/** * Redirect if needed. * * @return void */ public function redirect() { if (!empty($_GET['noredirect'])) { $this->save_session($_GET['noredirect']); return; } $match = $this->negotiation->get_redirect_match(); if ($match['site_id'] === get_current_blog_id()) { return; } $url = $match['url']; $current_blog_id = get_current_blog_id(); /** * Filter the redirect URL. * * You might add support for other types than singular posts and home here. * If you return an empty string, the redirect will not happen. The result will be validated with esc_url(). * * @param string $url Redirect URL. * @param array $match Redirect match. { * 'priority' => int * 'url' => string * 'language' => string * 'site_id' => int * } * @param int $current_blog_id Current blog ID. * * @return string */ $url = apply_filters('mlp_redirect_url', $url, $match, $current_blog_id); if (empty($url)) { return; } $this->save_session($match['language']); wp_redirect($url); exit; }