sitepress = $sitepress; $this->translate_link_targets = $translate_link_targets; } /** * @param string $url * @param string $lang * * @return string|false */ public function resolve_object_url( $url, $lang ) { if ( $this->lock ) { return false; } $this->lock = true; $current_lang = $this->sitepress->get_current_language(); $this->sitepress->switch_lang( $lang ); try { $new_url = $this->translate_link_targets->convert_url( $url ); if ( trailingslashit( $new_url ) === trailingslashit( $url ) ) { $new_url = false; } } catch ( Exception $e ) { $new_url = false; } $this->sitepress->switch_lang( $current_lang ); $this->lock = false; return $new_url; } }