256 * 1024 ) { http_response_code( 413 ); exit; } $adpresso_payload = json_decode( (string) $adpresso_raw, true ); $adpresso_events = is_array( $adpresso_payload ) ? ( $adpresso_payload['events'] ?? $adpresso_payload ) : null; if ( ! is_array( $adpresso_events ) || empty( $adpresso_events ) ) { http_response_code( 204 ); exit; } // Reject a clearly-abusive request. if ( count( $adpresso_events ) > TrackingStorage::MAX_EVENTS_PER_BATCH ) { http_response_code( 413 ); exit; } /** * Auth salt substitute - wp_salt() (pluggable.php) isn't available under SHORTINIT. * Only used to anonymize a hash, not for authentication, so this doesn't need to match wp_salt()'s own output. */ function adpresso_fast_track_ip_hash_salt(): string { $parts = []; foreach ( [ 'AUTH_SALT', 'SECURE_AUTH_SALT', 'LOGGED_IN_SALT', 'NONCE_SALT', 'AUTH_KEY', 'SECURE_AUTH_KEY', 'LOGGED_IN_KEY', 'NONCE_KEY' ] as $constant ) { if ( defined( $constant ) && '' !== constant( $constant ) ) { $parts[] = constant( $constant ); } } if ( ! empty( $parts ) ) { return hash( 'sha256', implode( '|', $parts ) ); } return hash( 'sha256', DB_NAME . DB_USER . (string) get_option( 'home', '' ) ); } // can_use_premium_code() (Freemius) isn't callable under SHORTINIT either // see class-tracking-admin.php, which keeps this option in sync on every normal frontend page load. $adpresso_is_premium = '1' === get_option( 'adpresso_track_premium', '0' ); $adpresso_success = TrackingStorage::record_batch( $adpresso_events, $adpresso_is_premium, adpresso_fast_track_ip_hash_salt() ); if ( ! $adpresso_success ) { // The primary stats upsert itself failed - report a real failure so tracking.js falls back to the REST route. http_response_code( 500 ); exit; } http_response_code( 204 );