| @@ -143,34 +143,12 @@ | ||
| 143 | 143 | * |
| 144 | 144 | * @param string $data Request data. |
| 145 | 145 | * @param int $response_code Response Code. |
| 146 | 146 | * @param string $error_info Error Info. |
| 147 | - * | |
| 147 | + * | |
| 148 | 148 | * @return void |
| 149 | 149 | */ |
| 150 | 150 | public static function suretriggers_log_request( $data, $response_code, $error_info ) { |
| 151 | - // Allow disabling logging via constant in wp-config.php. | |
| 152 | - if ( defined( 'SURETRIGGERS_DISABLE_LOGGING' ) && SURETRIGGERS_DISABLE_LOGGING ) { | |
| 153 | - return; | |
| 154 | - } | |
| 155 | - | |
| 156 | - // Allow disabling logging via the Settings UI option. | |
| 157 | - if ( get_option( 'suretriggers_disable_request_logging', false ) ) { | |
| 158 | - return; | |
| 159 | - } | |
| 160 | - | |
| 161 | - /** | |
| 162 | - * Filter to disable webhook request logging programmatically. | |
| 163 | - * Return false to stop logging. | |
| 164 | - * | |
| 165 | - * @param bool $enable Whether to log. Default true. | |
| 166 | - * @param int $response_code HTTP response code. | |
| 167 | - * @param string $error_info Error message if any. | |
| 168 | - */ | |
| 169 | - if ( ! apply_filters( 'suretriggers_enable_request_logging', true, $response_code, $error_info ) ) { | |
| 170 | - return; | |
| 171 | - } | |
| 172 | - | |
| 173 | 151 | global $wpdb; |
| 174 | 152 | // Store the data in request logs. |
| 175 | 153 | $wpdb->insert( |
| 176 | 154 | self::get_table_name(), |
| @@ -261,21 +239,11 @@ | ||
| 261 | 239 | |
| 262 | 240 | $data = json_decode( $failed_requests['request_data'], true ); |
| 263 | 241 | if ( is_array( $data ) ) { |
| 264 | 242 | $data['headers']['Authorization'] = 'Bearer ' . SaasApiToken::get(); |
| 265 | - | |
| 266 | - // Generate a new UUID so the SaaS server doesn't deduplicate this as a replay. | |
| 267 | - if ( isset( $data['body']['wordpress_webhook_uuid'] ) ) { | |
| 268 | - $new_uuid = str_replace( '-', '', wp_generate_uuid4() ); | |
| 269 | - $site_url = esc_url_raw( str_replace( '/wp-json/', '', get_site_url() ) ); | |
| 270 | - $site_url = preg_replace( '/^https?:\/\//', '', $site_url ); | |
| 271 | - $encoded_site_url = urlencode( (string) $site_url ); | |
| 272 | - $data['body']['wordpress_webhook_uuid'] = $new_uuid . '_' . $encoded_site_url; | |
| 273 | - } | |
| 274 | - | |
| 275 | - $response = wp_remote_post( $failed_requests['request_url'], $data ); | |
| 276 | - $response_code = wp_remote_retrieve_response_code( $response ); | |
| 277 | - $error_info = wp_remote_retrieve_body( $response ); | |
| 243 | + $response = wp_remote_post( $failed_requests['request_url'], $data ); | |
| 244 | + $response_code = wp_remote_retrieve_response_code( $response ); | |
| 245 | + $error_info = wp_remote_retrieve_body( $response ); | |
| 278 | 246 | if ( 405 === wp_remote_retrieve_response_code( $response ) ) { |
| 279 | 247 | $error_info = wp_remote_retrieve_response_message( $response ); |
| 280 | 248 | } |
| 281 | 249 | if ( 0 === wp_remote_retrieve_response_code( $response ) ) { |
| @@ -285,9 +253,9 @@ | ||
| 285 | 253 | $table_name, |
| 286 | 254 | [ |
| 287 | 255 | 'request_method' => $failed_requests['request_method'], |
| 288 | 256 | 'request_url' => $failed_requests['request_url'], |
| 289 | - 'request_data' => (string) wp_json_encode( $data ), | |
| 257 | + 'request_data' => $failed_requests['request_data'], | |
| 290 | 258 | 'response_code' => $response_code, |
| 291 | 259 | 'status' => ( 200 === $response_code ) ? 'success' : 'failed', |
| 292 | 260 | 'error_info' => $error_info, |
| 293 | 261 | 'retry_attempts' => $failed_requests['retry_attempts'] + 1, |