| @@ -5,8 +5,10 @@ | ||
| 5 | 5 | * @package Timetics |
| 6 | 6 | */ |
| 7 | 7 | namespace Timetics\Core\Integrations\Google; |
| 8 | 8 | |
| 9 | +defined( 'ABSPATH' ) || exit; | |
| 10 | + | |
| 9 | 11 | use Exception; |
| 10 | 12 | use InvalidArgumentException; |
| 11 | 13 | |
| 12 | 14 | /** |
| @@ -165,9 +167,9 @@ | ||
| 165 | 167 | |
| 166 | 168 | $response = wp_remote_post( self::TIMETICS_TOKEN_URI, array( 'body' => $args ) ); |
| 167 | 169 | |
| 168 | 170 | if ( is_wp_error( $response ) ) { |
| 169 | - throw new Exception( $response->get_error_message() ); | |
| 171 | + throw new Exception( esc_html( $response->get_error_message() ) ); | |
| 170 | 172 | } |
| 171 | 173 | |
| 172 | 174 | $status_code = (int) wp_remote_retrieve_response_code( $response ); |
| 173 | 175 | $body = wp_remote_retrieve_body( $response ); |
| @@ -174,9 +176,9 @@ | ||
| 174 | 176 | $data = json_decode( $body, true ); |
| 175 | 177 | |
| 176 | 178 | if ( 200 !== $status_code || empty( $data['access_token'] ) ) { |
| 177 | 179 | $message = ! empty( $data['error_description'] ) ? $data['error_description'] : __( 'Failed to obtain Google access token.', 'timetics' ); |
| 178 | - throw new Exception( $message ); | |
| 180 | + throw new Exception( esc_html( $message ) ); | |
| 179 | 181 | } |
| 180 | 182 | |
| 181 | 183 | return $data; |
| 182 | 184 | } |