Skip to content

Add an occurrence API where every event is a series of one, refs #80 - #2612

Draft
mauteri wants to merge 3 commits into
feat/80-occurrence-foundationfrom
feat/80-occurrence-api
Draft

mauteri wants to merge 3 commits into
feat/80-occurrence-foundationfrom
feat/80-occurrence-api

Conversation

@mauteri

@mauteri mauteri commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Refs #80. Stacked on #2602, so review that first. This does not close the issue.

Proposed changes:

A single place for code to ask for an event's dates, where every event is a series of one. Nothing is stored and no existing caller changes yet. Repeat rules, and gatherpress-recurring-events today, can supply more dates through the filters without callers changing. This follows Dossy's design write-up.

  • Event\Occurrence is a read-only value: series post ID, key (recurrence_id), start and end in the event's timezone, whether it lasts all day, and its status (an event status slug, with is_canceled()).
  • Event\Occurrences, one instance per event, from Event::occurrences(). It works out the event's one date once and keeps it, which is also where repeat rules and their expansion cache will live:
    • in_range( $from, $to ) returns the occurrences that overlap a range, in start order. The range end is exclusive.
    • find( $recurrence_id ) returns one occurrence by key, or null.
    • on_day( $day ) returns the first occurrence that starts on a date in the event's timezone, or null.
    • primary() returns the occurrence a series shows by default: the first that hasn't ended, preferring one that isn't canceled, or the last when all have ended. For a series of one, that's its one date.
    • The static Occurrences::recurrence_id( $start, $all_day ) builds the key: the local start as Ymd\THis, or the local date as Ymd for all-day. These are the forms events.wordpress.org already uses in URLs.
  • Filters: gatherpress_event_occurrences (range), gatherpress_event_occurrence (by key) and gatherpress_event_primary_occurrence.
  • Docs: an Occurrences section in docs/developer/data-model/README.md.

Rule storage is left out on purpose until the open questions on #2602 are settled.

Requirements from events.wordpress.org

@bor0 listed what their Groups integration uses from gatherpress-recurring-events (gpre) (comment), now tracked on #80. Groups will move to core's API so gpre can be removed. Until then, gpre can still supply dates through the filters here.

Groups needs Here
One occurrence by key find()
The occurrence on a given day on_day()
A series' dates in_range()
The series' default occurrence primary()
Whether a date is canceled Occurrence::$status, is_canceled()
Current occurrence get and set Later, with RSVPs per date
RSVP to occurrence lookup Later, with the RSVP join table
Rule read and write Later, once rule storage is settled

Testing instructions:

In the terminal:

  1. Run npm run test:unit:php. All tests pass.
  2. With this branch active in wp-env, print an event's occurrences for December 2026:
    npm run wp-env run cli -- wp eval '$id = wp_insert_post( array( "post_type" => "gatherpress_event", "post_status" => "publish", "post_title" => "Occurrence test" ) ); ( new GatherPress\Core\Event( $id ) )->save_datetimes( array( "datetime_start" => "2026-12-11 20:00:00", "datetime_end" => "2026-12-11 22:00:00", "timezone" => "America/New_York" ) ); foreach ( ( new GatherPress\Core\Event( $id ) )->occurrences()->in_range( new DateTimeImmutable( "2026-12-01" ), new DateTimeImmutable( "2027-01-01" ) ) as $o ) { echo $o->recurrence_id, " ", $o->start->format( DATE_ATOM ), "\n"; }'
    
    It prints 20261211T200000 2026-12-11T20:00:00-05:00.

🤖 Generated with Claude Code

…#80

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

mauteri and others added 2 commits November 9, 2026 09:54
…nt::occurrences()

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Preview changes with Playground

Customize PR Playground

To customize the Playground preview for this specific PR, create a file at:

.github/playground/PR-2612-blueprint-override.json

The override is merged into the generated blueprint and can be used to:

  • Enable Playground features
  • Install additional plugins
  • Change site options
  • Run steps before or after the GatherPress' default steps

Example:

{
	"$schema": "https://gatherpress.org/playground-preview/pr-override-schema.json",
	"landingPage": "/wp-admin/edit.php?post_type=gatherpress_venue",
	"siteOptions": {
		"show_on_front": "page"
	},
	"features": {
		"networking": true
	},
	"prependSteps": [
		{
			"step": "installPlugin",
			"pluginData": {
				"resource": "wordpress.org/plugins",
				"slug": "simple-location"
			},
			"options": {
				"activate": true
			}
		}
	],
	"appendSteps": [
		{
			"step": "runPHP",
			"code": ""
		}
	]
}

Go to Playground PR preview customization for more details.

You can preview the recent changes for PR#2612 with the following PHP versions:

PHP Version 8.4

PHP Version 8.2

PHP Version 8.1

Download .zip with build changes

Made with 💙 from GatherPress & a little bit of WordPress Playground. Changes will not persist between sessions.

@mauteri mauteri added this to the 0.38.0 milestone Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant