Skip to content

Filter calendar feeds by any event-bearing taxonomy and shadow source - #2662

Open
tsubu wants to merge 3 commits into
GatherPress:developfrom
tsubu:fix/ical-feed-any-taxonomy
Open

tsubu wants to merge 3 commits into
GatherPress:developfrom
tsubu:fix/ical-feed-any-taxonomy

Conversation

@tsubu

@tsubu tsubu commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #1642

Proposed changes:

GatherPress registers a calendar feed for every event-bearing taxonomy and every shadow-source post type, including those of companion plugins. But Calendar\External\Setup::get_ical_list() filtered only topics and venues, so the feed of any other term or source post listed all events.

  • get_ical_list() now builds its filter from the queried object, in a new get_queried_tax_query():

    • a single post of a shadow-source post type (such as a venue) gives its shadow term, through Shadow_Source::build_tax_query_clause();
    • a term of an event-bearing taxonomy (such as a topic) gives itself, by term ID.

    These are the same checks that decide which post types and taxonomies get a feed endpoint, so every endpoint now gets its own filter. Topic and venue feeds list the same events as before.

  • Event\Query::get_events_list() accepts tax_query clauses for any other taxonomy. They join the topic and venue clauses with AND, and members that are not arrays are left out. Events API: More filters, e.g. by geolocation #1263 is closed, and the method already takes an args array, so this adds one key rather than a new API.

  • docs/user/calendar-feeds.md says that companion taxonomies and shadow sources get feeds with only their events.

  • A changelog entry is in .github/changelog/ical-feed-any-taxonomy.

Other information:

  • Have you written new tests for your changes, if applicable?

New tests: a companion taxonomy feed, a companion shadow-source feed, and the tax_query argument. The two feed tests fail on develop (the event without the term is in the feed) and pass with this change.

Checked in wp-env (PHP 8.3):

  • PHPUnit: all 3137 tests pass.
  • PHPStan: no errors.
  • PHPCS: no errors or warnings in the changed files.

AI assistance

  • An AI tool wrote a significant part of this change.

Claude Code wrote the code, tests and docs. I reviewed the diff, ran the checks above, and checked the feeds over HTTP as in the testing instructions. The change only builds WP_Query tax_query clauses from the queried object (a WP_Post or WP_Term that WordPress resolved), and passes no request input to the query directly. Feeds still leave out password-protected events.

Testing instructions:

  1. Add a mu-plugin that registers a companion taxonomy and a shadow-source post type on events:

    add_action( 'init', static function () {
    	register_taxonomy( 'gp_language', 'gatherpress_event', array( 'public' => true, 'rewrite' => array( 'slug' => 'language' ) ) );
    	register_post_type( 'gp_production', array( 'public' => true, 'supports' => array( 'title', 'gatherpress-shadow-source' ), 'rewrite' => array( 'slug' => 'production' ) ) );
    }, 5 );
    add_filter( 'gatherpress_shadow_taxonomy_object_types', static function ( $types, $source ) {
    	if ( 'gp_production' === $source ) {
    		$types[] = 'gatherpress_event';
    	}
    	return $types;
    }, 10, 2 );
  2. Flush the permalinks (Settings > Permalinks > Save).

  3. Create two upcoming events, "Japanese Meetup" and "English Meetup". Publish a gp_production post with the slug hamlet.

  4. Give "Japanese Meetup" the japanese term in gp_language and the _hamlet term in _gp_production, for example with wp_set_object_terms().

  5. Open /language/japanese/feed/ical/ and /production/hamlet/feed/ical/. Each lists only "Japanese Meetup". On develop, both list every upcoming event.

  6. Open a topic feed (/topic/{slug}/feed/ical/), a venue feed (/venue/{slug}/feed/ical/) and /event/feed/ical/. They list the same events as on develop.

My results:

Feed develop This PR
/language/japanese/feed/ical/ all 4 events Japanese Meetup
/production/hamlet/feed/ical/ all 4 events Japanese Meetup
/topic/wordcamps/feed/ical/ Topic Meetup Topic Meetup
/venue/hall-a/feed/ical/ Hall Meetup Hall Meetup
/event/feed/ical/ all 4 events all 4 events

Credit (for release notes)

My WordPress.org username: tsubu

Changelog entry

  • Automatically create a changelog entry from the details below.

The entry is already in the branch: .github/changelog/ical-feed-any-taxonomy (Patch, Fixed).

🤖 Generated with Claude Code

tsubu and others added 2 commits November 21, 2026 14:37
GatherPress registers a calendar feed for every event-bearing taxonomy
and every shadow-source post type, including those of companion
plugins. get_ical_list() filtered only topics and venues, so the feed of
any other term or source post listed all events.

get_ical_list() now builds its filter from the queried object: the
shadow term of a shadow-source post, or the queried term of an
event-bearing taxonomy. Event\Query::get_events_list() accepts
tax_query clauses for this, which also lets companion plugins filter by
their own taxonomies.

Fixes GatherPress#1642

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

coderabbitai Bot commented Nov 21, 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

@github-actions

Copy link
Copy Markdown
Contributor

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

Core Committers: Use this line as a base for the props when committing in SVN:

Props tsubu, mauteri.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Test Coverage Report

✅ All coverage checks passed!

✅ PHP Coverage
=== PR Coverage Check ===

Configuration loaded:
  Minimum coverage: 100%
  Exclude patterns: 47 patterns
  Low coverage exceptions: 0 files

Checking coverage for files changed from origin/develop...

Found 4 changed PHP file(s):
  - includes/core/classes/calendar/external/class-setup.php
  - includes/core/classes/event/class-query.php
  - test/unit/php/includes/tests/core/classes/calendar/external/class-test-setup.php
  - test/unit/php/includes/tests/core/classes/event/class-test-query.php

Files requiring coverage check: 2
  - includes/core/classes/calendar/external/class-setup.php
  - includes/core/classes/event/class-query.php

✅ Loaded coverage.xml
✅ Loaded coverage-multisite.xml

✅ includes/core/classes/calendar/external/class-setup.php - 100% coverage (457/457 lines)
✅ includes/core/classes/event/class-query.php - 100% coverage (427/427 lines)

=== Summary ===
✅ Passed: 2 file(s)
⏭️  Excluded: 2 file(s)
❌ Failed: 0 file(s)

✅ All changed files meet the minimum coverage requirement of 100%
✅ JavaScript Coverage
=== PR JavaScript Coverage Check ===

Configuration loaded:
  Minimum coverage: 100%
  Exclude patterns: 47 patterns

Checking coverage for JavaScript files changed from origin/develop...

✅ No JavaScript files changed in this PR.

This comment is automatically updated on each push.

get_queried_object() is a term only on a term archive, and a post that
is not a shadow source gives no clause, so the is_singular() and
is_tax() checks repeated the type checks. Dropping them brings the
Setup class complexity back under the PHPMD limit (146, from 147 on
develop).

Add a test that covers get_queried_tax_query() when nothing filters
the feed: the events archive and a page.

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-2662-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#2662 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.

@wppoland wppoland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Clean fix for #1642:

  • Calendar\External\Setup::get_queried_tax_query() uses the same is_tax_like_type_for_event_supporting_types() and has_post_type_for_taxonomy() checks that register the feed endpoints, delegating shadow-source posts to Shadow_Source::build_tax_query_clause() and event-bearing taxonomy terms to a term_id clause.
  • Event\Query::get_events_list() cleanly accepts array clauses in tax_query alongside topics and venues while ignoring non-array entries.
  • Great test coverage in class-test-setup.php and class-test-query.php for companion taxonomies, companion shadow-source post types, unfiltered archive/page requests, and malformed tax_query inputs.

@mauteri mauteri added this to the 0.38.0 milestone Nov 21, 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.

Extend calendar iCal feeds to all event-bearing taxonomies and venue-shaped post types

3 participants