=== CalDAV Calendar Importer ===
Contributors: vanMeerdervoort
Tags: caldav, nextcloud, calendar, events, importer
Requires at least: 5.0
Tested up to: 6.5
Requires PHP: 7.4
Stable tag: 8.2.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Imports and displays events from CalDAV calendars using a REPORT query. Designed for seamless use with Nextcloud and similar servers.

== Description ==

CalDAV Calendar Importer allows you to connect your WordPress site with one or more external CalDAV calendars (like Nextcloud), and display upcoming events using a simple shortcode.

The plugin performs a REPORT query to retrieve events and stores them in a local database. A cronjob or manual sync keeps events up-to-date. The plugin includes a visual admin interface to manage calendars and view sync logs.

**Features:**

- Connect to any CalDAV-compatible calendar via REPORT
- Manual or scheduled syncing of events
- Display events using the `[sci_events]` shortcode
- Automatically parses `DESCRIPTION` for Tickets, Info, Description links and SOLDOUT status
- SOLDOUT badge automatically shows when event is sold out
- Admin interface for managing calendars, colors, credentials
- Custom update checker for private plugin repository support
- Enhanced description parsing with automatic cleanup of technical CalDAV fields

== Installation ==

1. Upload the plugin to `/wp-content/plugins/` and activate it.
2. Go to **Admin > CalDAV Importer** to add your calendars.
3. Use the shortcode `[sci_events]` to display upcoming events on any page or post.
4. Set up a cronjob to call `wp-cron.php` or `sci_sync_events()` every hour (or use the provided automatic scheduling).

== Usage ==

=== Shortcode ===

Use the following shortcode to render events:

[sci_events]


No parameters are required. It displays all upcoming events from all configured calendars.

=== DESCRIPTION field links ===

You can add links and special tags to the event `DESCRIPTION` field in the following format:

- `Tickets: https://example.com/tickets` - Extracts ticket URL and shows a "Tickets" button
- `Info: https://example.com/info` - Extracts info URL and shows an "Info" button (optional, controlled by admin setting)
- `Description: Your event description text` - Extracts description text to display below the event
- `SOLDOUT` - Shows a "Uitverkocht" (Sold Out) badge instead of the Tickets button

You can use these tags in any order in your CalDAV event description. The plugin will automatically parse and extract them. URLs with spaces are automatically cleaned up.

== Frequently Asked Questions ==

= Can I display only a specific calendar? =
Not yet. All calendars are merged in the default shortcode. Filtering options are planned for future versions.

= Are events saved in the database? =
Yes. Each calendar has its own events table entry. Sync replaces/upserts current data.

= Is it safe to store CalDAV credentials? =
Credentials are stored in plain text in the database. Limit admin access accordingly. Support for OAuth2 or token-based auth is a future goal.

= How often are events updated? =
Hourly, unless triggered manually via the admin interface or through an external cronjob.

== Changelog ==
= 8.2.1 =

* Improved URL parsing for Tickets and Info links (now handles URLs with spaces correctly)
* SOLDOUT badge styling improvements (smaller size, new color, positioned in button area)

= 8.2.0 =

* Added SOLDOUT tag support - displays "Uitverkocht" badge when SOLDOUT is found in description
* SOLDOUT badge replaces Tickets button when event is sold out
* Added Description tag support for structured description text

= 8.1.8 =

* Improved CalDAV description parsing - removed DTSTART/DTEND technical fields from display
* Enhanced newline cleanup - removes all forms of \n, \\n, \r\n from descriptions
* Better field parsing with robust regex for Tickets:, Info:, Description: tags
* Fixed issue where URLs were truncated at spaces
* Code cleanup and formatting improvements

= 8.0.0 =

* Bugfixes

= 7.0.9 =

* Bugfixes

= 7.0.8 =

* Bugfixes

= 7.0.7 =

* Bugfixes

= 7.0.6 =

* Readded add calendar button

= 7.0.5 =

* Working manial sync
* Color palette added
* Random color option added
* verbose and non verbose logging
* View of log file in textfield

= 5.8 =
* Admin interface improvements
* Custom plugin update support
* Support for extracting Info/Ticket links from DESCRIPTION
* CSS improvements and better shortcode layout

== Upgrade Notice ==

= 8.2.1 =
Recommended update: improved URL parsing fixes issues with URLs containing spaces. SOLDOUT badge styling improvements.

= 8.2.0 =
Recommended update: adds SOLDOUT tag support for sold-out events and Description tag for structured description text.

= 8.1.8 =
Recommended update: improved description parsing with better cleanup of technical CalDAV fields and enhanced newline handling.

= 5.8 =
Recommended update: adds private repository updates, DESCRIPTION link parsing, and UI improvements.

== License ==

This plugin is licensed under the GPLv2 or later.
