4096 || ! preg_match( '/\A([A-Za-z0-9_-]+)\.([a-f0-9]{64})\z/', $ticket, $parts ) || ! hash_equals( hash_hmac( 'sha256', $parts[1], wp_salt( 'auth' ) . ':' . get_current_blog_id() ), $parts[2] ) ) { return PublicBooking::error( 'booking_ticket', 403 ); } // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode -- Signed JSON transport, never executable code. $data = json_decode( (string) base64_decode( strtr( $parts[1], '-_', '+/' ), true ), true ); return is_array( $data ) && ( $data['kind'] ?? '' ) === $kind && ( $data['expires'] ?? 0 ) > time() ? $data : PublicBooking::error( 'booking_ticket', 403 ); } private static function encode( string $data ): string { // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode -- Signed JSON transport, never executable code. return rtrim( strtr( base64_encode( $data ), '+/', '-_' ), '=' ); } }