| @@ 327-344 (lines=18) @@ | ||
| 324 | * @return WP_Error|string |
|
| 325 | * @since 4.4.0 |
|
| 326 | */ |
|
| 327 | public static function normalize_url_protocol_agnostic( $url ) { |
|
| 328 | $parsed_url = wp_parse_url( trailingslashit( esc_url_raw( $url ) ) ); |
|
| 329 | if ( ! $parsed_url || empty( $parsed_url['host'] ) || empty( $parsed_url['path'] ) ) { |
|
| 330 | return new WP_Error( |
|
| 331 | 'cannot_parse_url', |
|
| 332 | sprintf( |
|
| 333 | /* translators: %s: URL to parse. */ |
|
| 334 | esc_html__( 'Cannot parse URL %s', 'jetpack' ), |
|
| 335 | $url |
|
| 336 | ) |
|
| 337 | ); |
|
| 338 | } |
|
| 339 | ||
| 340 | // Strip www and protocols. |
|
| 341 | $url = preg_replace( '/^www\./i', '', $parsed_url['host'] . $parsed_url['path'] ); |
|
| 342 | ||
| 343 | return $url; |
|
| 344 | } |
|
| 345 | ||
| 346 | /** |
|
| 347 | * Gets the value that is to be saved in the jetpack_sync_error_idc option. |
|
| @@ 6259-6268 (lines=10) @@ | ||
| 6256 | * @param string $url |
|
| 6257 | * @return WP_Error|string |
|
| 6258 | */ |
|
| 6259 | public static function normalize_url_protocol_agnostic( $url ) { |
|
| 6260 | $parsed_url = wp_parse_url( trailingslashit( esc_url_raw( $url ) ) ); |
|
| 6261 | if ( ! $parsed_url || empty( $parsed_url['host'] ) || empty( $parsed_url['path'] ) ) { |
|
| 6262 | return new WP_Error( 'cannot_parse_url', sprintf( esc_html__( 'Cannot parse URL %s', 'jetpack' ), $url ) ); |
|
| 6263 | } |
|
| 6264 | ||
| 6265 | // Strip www and protocols |
|
| 6266 | $url = preg_replace( '/^www\./i', '', $parsed_url['host'] . $parsed_url['path'] ); |
|
| 6267 | return $url; |
|
| 6268 | } |
|
| 6269 | ||
| 6270 | /** |
|
| 6271 | * Gets the value that is to be saved in the jetpack_sync_error_idc option. |
|