@@ 322-339 (lines=18) @@ | ||
319 | * @return WP_Error|string |
|
320 | * @since 4.4.0 |
|
321 | */ |
|
322 | public static function normalize_url_protocol_agnostic( $url ) { |
|
323 | $parsed_url = wp_parse_url( trailingslashit( esc_url_raw( $url ) ) ); |
|
324 | if ( ! $parsed_url || empty( $parsed_url['host'] ) || empty( $parsed_url['path'] ) ) { |
|
325 | return new WP_Error( |
|
326 | 'cannot_parse_url', |
|
327 | sprintf( |
|
328 | /* translators: %s: URL to parse. */ |
|
329 | esc_html__( 'Cannot parse URL %s', 'jetpack' ), |
|
330 | $url |
|
331 | ) |
|
332 | ); |
|
333 | } |
|
334 | ||
335 | // Strip www and protocols. |
|
336 | $url = preg_replace( '/^www\./i', '', $parsed_url['host'] . $parsed_url['path'] ); |
|
337 | ||
338 | return $url; |
|
339 | } |
|
340 | ||
341 | /** |
|
342 | * Gets the value that is to be saved in the jetpack_sync_error_idc option. |
@@ 6268-6277 (lines=10) @@ | ||
6265 | * @param string $url |
|
6266 | * @return WP_Error|string |
|
6267 | */ |
|
6268 | public static function normalize_url_protocol_agnostic( $url ) { |
|
6269 | $parsed_url = wp_parse_url( trailingslashit( esc_url_raw( $url ) ) ); |
|
6270 | if ( ! $parsed_url || empty( $parsed_url['host'] ) || empty( $parsed_url['path'] ) ) { |
|
6271 | return new WP_Error( 'cannot_parse_url', sprintf( esc_html__( 'Cannot parse URL %s', 'jetpack' ), $url ) ); |
|
6272 | } |
|
6273 | ||
6274 | // Strip www and protocols |
|
6275 | $url = preg_replace( '/^www\./i', '', $parsed_url['host'] . $parsed_url['path'] ); |
|
6276 | return $url; |
|
6277 | } |
|
6278 | ||
6279 | /** |
|
6280 | * Gets the value that is to be saved in the jetpack_sync_error_idc option. |