get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $t ) ) !== $t ) { return; } $now = current_time( 'mysql', true ); $visit = trim( (string) $order->get_meta( '_aieo_attr_sid' ) ); $visit = class_exists( 'AIEO_Signal_Envelope' ) ? AIEO_Signal_Envelope::visitor_id( $visit ) : ( 1 === preg_match( '/^[A-Za-z0-9_-]{1,64}$/D', $visit ) ? $visit : '' ); $wpdb->query( $wpdb->prepare( "INSERT INTO `{$t}` (event_id, platform, event_name, order_id, session_id, user_id, status, http_code, fbtrace_id, attempts, request_payload, response_body, error_message, value, currency, test_mode, created_at, sent_at) VALUES (%s, %s, %s, %d, %s, %d, 'dispatched', 0, '', 1, '', '', '', %f, %s, 0, %s, %s) ON DUPLICATE KEY UPDATE status = 'dispatched', attempts = attempts + 1, sent_at = VALUES(sent_at)", (string) $event_id, (string) $platform, (string) $event_name, (int) $order->get_id(), $visit, (int) $order->get_customer_id(), (float) $order->get_total(), (string) $order->get_currency(), $now, $now ) ); } endif; if ( ! function_exists( 'aieo_after_response' ) ) : function aieo_after_response( $callable, array $args = array() ) { if ( ! is_callable( $callable ) ) { return false; } if ( '' === aieo_server_event_flush_fn() ) { call_user_func_array( $callable, $args ); return true; } if ( empty( $GLOBALS['aieo_after_response_pending'] ) || ! is_array( $GLOBALS['aieo_after_response_pending'] ) ) { $GLOBALS['aieo_after_response_pending'] = array(); } $GLOBALS['aieo_after_response_pending'][] = array( $callable, $args ); if ( empty( $GLOBALS['aieo_after_response_hooked'] ) ) { $GLOBALS['aieo_after_response_hooked'] = true; register_shutdown_function( 'aieo_after_response_run' ); } return true; } function aieo_after_response_run() { if ( empty( $GLOBALS['aieo_after_response_pending'] ) || ! is_array( $GLOBALS['aieo_after_response_pending'] ) ) { return; } $pending = $GLOBALS['aieo_after_response_pending']; $GLOBALS['aieo_after_response_pending'] = array(); if ( function_exists( 'ignore_user_abort' ) ) { ignore_user_abort( true ); } $flush = aieo_server_event_flush_fn(); if ( '' !== $flush ) { $flush(); } foreach ( $pending as $p ) { try { call_user_func_array( $p[0], $p[1] ); } catch ( \Throwable $e ) { continue; } } } endif;