| @@ -37,9 +37,9 @@ | ||
| 37 | 37 | * @return string modified url |
| 38 | 38 | */ |
| 39 | 39 | public function add_language_to_link( $url, $lang ) { |
| 40 | 40 | if ( ! empty( $lang ) && ! empty( $this->hosts[ $lang->slug ] ) ) { |
| 41 | - $url = preg_replace( '#://(' . wp_parse_url( $this->home, PHP_URL_HOST ) . ')($|/.*)#', '://' . $this->hosts[ $lang->slug ] . '$2', $url ); | |
| 41 | + $url = preg_replace( '#:\/\/(' . parse_url( $this->home, PHP_URL_HOST ) . ')($|\/.*)#', '://' . $this->hosts[ $lang->slug ] . '$2', $url ); | |
| 42 | 42 | } |
| 43 | 43 | return $url; |
| 44 | 44 | } |
| 45 | 45 | |
| @@ -53,9 +53,9 @@ | ||
| 53 | 53 | * @return string modified url |
| 54 | 54 | */ |
| 55 | 55 | public function remove_language_from_link( $url ) { |
| 56 | 56 | if ( ! empty( $this->hosts ) ) { |
| 57 | - $url = preg_replace( '#://(' . implode( '|', $this->hosts ) . ')($|/.*)#', '://' . wp_parse_url( $this->home, PHP_URL_HOST ) . '$2', $url ); | |
| 57 | + $url = preg_replace( '#:\/\/(' . implode( '|', $this->hosts ) . ')($|\/.*)#', '://' . parse_url( $this->home, PHP_URL_HOST ) . '$2', $url ); | |
| 58 | 58 | } |
| 59 | 59 | return $url; |
| 60 | 60 | } |
| 61 | 61 | |
| @@ -81,12 +81,9 @@ | ||
| 81 | 81 | */ |
| 82 | 82 | public function get_hosts() { |
| 83 | 83 | $hosts = array(); |
| 84 | 84 | foreach ( $this->options['domains'] as $lang => $domain ) { |
| 85 | - $host = wp_parse_url( $domain, PHP_URL_HOST ); | |
| 86 | - // The use of the constant is mandatory in PHP 7.2 and PHP 7.3 to avoid a deprecated notice. | |
| 87 | - $hosts[ $lang ] = defined( 'INTL_IDNA_VARIANT_UTS46' ) ? idn_to_ascii( $host, 0, INTL_IDNA_VARIANT_UTS46 ) : idn_to_ascii( $host ); | |
| 85 | + $hosts[ $lang ] = parse_url( $domain, PHP_URL_HOST ); | |
| 88 | 86 | } |
| 89 | - | |
| 90 | 87 | return $hosts; |
| 91 | 88 | } |
| 92 | 89 | } |