ID : ( is_numeric( $post ) ? (int) $post : 0 ); if ( ! is_string( $url ) || 0 === $post_id || ! Plugin::translations()->supports( $post_id ) ) { return $url; } $language = Plugin::translations()->effective_language( $post_id ); return Plugin::urls()->is_front( $post_id ) ? Plugin::urls()->home( $language ) : Plugin::urls()->add_language( $url, $language ); } /** * Address of an archive, search or feed, in the language of the request. * * @param mixed $url Address WordPress built. * @return mixed */ public function archive_link( $url ) { if ( ! is_string( $url ) || '' === $url || ! Plugin::request()->is_public() ) { return $url; } return Plugin::urls()->add_language( $url, Plugin::request()->language() ); } /** * The home address, in the language of the request. * * @param mixed $url Address WordPress built. * @param mixed $path Path that was asked for. * @return mixed */ public function home_url( $url, $path ) { if ( $this->filtering_home || ! is_string( $url ) || ! in_array( $path, array( '', '/' ), true ) || ! Plugin::request()->is_public() ) { return $url; } $language = Plugin::request()->language(); if ( Plugin::languages()->default_slug() === $language ) { return $url; } $this->filtering_home = true; $home = Plugin::urls()->home( $language ); $this->filtering_home = false; return $home; } }