Skip to content

Disable contact forms on past WordCamp sites - #1656

Open
dd32 wants to merge 7 commits into
productionfrom
fix/claude/1468-disable-past-contact-forms
Open

Disable contact forms on past WordCamp sites#1656
dd32 wants to merge 7 commits into
productionfrom
fix/claude/1468-disable-past-contact-forms

Conversation

@dd32

@dd32 dd32 commented Mar 24, 2026

Copy link
Copy Markdown
Member

Summary

  • Replaces Jetpack contact form HTML with a message on past WordCamp sites to reduce spam to organizers
  • Forms are disabled when either:
    1. A newer event site exists for the same city (using existing get_latest_home_url() logic), OR
    2. The event ended more than 18 months ago (covers cities that stopped hosting events)
  • The replacement message directs visitors to the latest edition (if one exists) and always includes a link to report Code of Conduct concerns to the WordPress Incident Response Team at reports@wordpress.org
  • Uses the jetpack_contact_form_html filter as suggested by @jeherve in the issue discussion
  • Added to latest-site-hints.php as suggested by @dd32

Implementation details

  • Reuses the existing get_latest_home_url() function and get_wordcamp_post() end date logic
  • Events still in progress (within 1 day of end date) keep their forms active
  • The 18-month grace period ensures forms stay active for slightly longer than a year after the event, giving time for a new edition to be scheduled

Test plan

  • Visit a past WordCamp site that has a newer edition — verify contact form is replaced with message linking to the new site
  • Visit the most recent WordCamp site for a city — verify contact form still works
  • Verify the Code of Conduct reporting link appears in the replacement message
  • Visit a site whose event ended less than 18 months ago with no newer site — verify form still works
  • Visit a site whose event ended more than 18 months ago with no newer site — verify form is replaced

Fixes #1468

🤖 Generated with Claude Code

dd32 and others added 4 commits March 24, 2026 11:36
Replace Jetpack contact form HTML with a message when:
1. A newer event site exists for the same city, OR
2. The event ended more than 18 months ago.

This reduces spam sent to organizers of past events. The replacement
message directs visitors to the latest edition (if available) and
includes a link to report Code of Conduct concerns to the WordPress
Incident Response Team.

Uses the jetpack_contact_form_html filter as suggested in the issue
discussion.

Fixes #1468

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Optimization per review feedback: avoid the expensive database query
to find a newer site during the first 3 months after an event ends,
since a new edition is unlikely to exist that soon.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests the contact form disabling logic for past WordCamp sites:
- Past event with newer site disables form with redirect message
- Current/future event keeps form active
- Recent past event without newer site keeps form active
- Old past event (>18 months) disables form
- Disabled form includes Code of Conduct reporting link
- Event with no end date keeps form active

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
dd32 and others added 2 commits June 2, 2026 13:39
Wrap get_latest_home_url() in an hour-long per-site transient cache, since
the query now runs on most front-end requests but the answer only changes
when a new edition site is created. The uncached worker is now
query_latest_home_url().

Also improve the disabled contact form copy: friendlier wording that points
visitors to WordCamp Central when no newer edition exists, move the <strong>
wrapper out of the translatable strings, and add the missing trailing slash
to the Code of Conduct handbook link.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 2, 2026 03:43

Copilot AI 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.

Pull request overview

This PR disables Jetpack contact forms on past WordCamp sites (to reduce spam to past organizers) by replacing the rendered form HTML with an informational message, based on whether a newer edition exists for the same city and/or the event is sufficiently old. It also adds test coverage around the new behavior and introduces transient caching for the “latest site” lookup.

Changes:

  • Add a jetpack_contact_form_html filter that replaces contact form HTML with a guidance + Code of Conduct reporting message when the site is considered “past.”
  • Add transient caching around latest-site lookups by splitting the logic into get_latest_home_url() (cached) and query_latest_home_url() (query).
  • Add a new PHPUnit test file covering the contact-form disabling behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
public_html/wp-content/mu-plugins/latest-site-hints.php Adds the Jetpack form-disabling filter and introduces cached latest-site lookup via a wrapper + renamed query function.
public_html/wp-content/mu-plugins/tests/test-disable-contact-form.php Adds PHPUnit coverage for the form-disabling behavior across several site/event scenarios.
Comments suppressed due to low confidence (1)

public_html/wp-content/mu-plugins/latest-site-hints.php:272

  • get_wordcamp_post() can return false; query_latest_home_url() currently dereferences $wordcamp->meta unconditionally, which will fatally error if a site isn’t linked to a WordCamp post. Returning false is consistent with the function’s contract.
	$wordcamp = get_wordcamp_post();
	$end_date = absint( $wordcamp->meta['End Date (YYYY-mm-dd)'][0] ?? 0 );

Comment thread public_html/wp-content/mu-plugins/latest-site-hints.php
Comment thread public_html/wp-content/mu-plugins/latest-site-hints.php Outdated
- maybe_disable_contact_form() now returns the original HTML when
  get_wordcamp_post() is false (e.g. Central), so the filter no longer
  dereferences a bool on non-WordCamp sites that render Jetpack forms.
- Remove the 3-month newer-site skip. The lookup is now transient-cached, so
  the optimization is redundant and it could keep a form active even when a
  newer edition already exists.
- Add a test covering the 18-month expiry path in isolation (no newer site).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

Automatically disable Jetpack Contact forms when the site is no longer the most recent edition.

2 participants