@@ 2205-2208 (lines=4) @@ | ||
2202 | return $suppress_errors ? false : new \WP_Error( 'no_token_for_user', sprintf( __( 'No token for user %d', 'jetpack' ), $user_id ) ); |
|
2203 | } |
|
2204 | $user_token_chunks = explode( '.', $user_tokens[ $user_id ] ); |
|
2205 | if ( empty( $user_token_chunks[1] ) || empty( $user_token_chunks[2] ) ) { |
|
2206 | // translators: %s is the user ID. |
|
2207 | return $suppress_errors ? false : new \WP_Error( 'token_malformed', sprintf( __( 'Token for user %d is malformed', 'jetpack' ), $user_id ) ); |
|
2208 | } |
|
2209 | if ( $user_token_chunks[2] !== (string) $user_id ) { |
|
2210 | // translators: %1$d is the ID of the requested user. %2$d is the user ID found in the token. |
|
2211 | return $suppress_errors ? false : new \WP_Error( 'user_id_mismatch', sprintf( __( 'Requesting user_id %1$d does not match token user_id %2$d', 'jetpack' ), $user_id, $user_token_chunks[2] ) ); |
@@ 6210-6212 (lines=3) @@ | ||
6207 | */ |
|
6208 | public static function normalize_url_protocol_agnostic( $url ) { |
|
6209 | $parsed_url = wp_parse_url( trailingslashit( esc_url_raw( $url ) ) ); |
|
6210 | if ( ! $parsed_url || empty( $parsed_url['host'] ) || empty( $parsed_url['path'] ) ) { |
|
6211 | return new WP_Error( 'cannot_parse_url', sprintf( esc_html__( 'Cannot parse URL %s', 'jetpack' ), $url ) ); |
|
6212 | } |
|
6213 | ||
6214 | // Strip www and protocols |
|
6215 | $url = preg_replace( '/^www\./i', '', $parsed_url['host'] . $parsed_url['path'] ); |