Disable contact forms on past WordCamp sites - #1656
Open
dd32 wants to merge 7 commits into
Open
Conversation
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>
5 tasks
…68-disable-past-contact-forms
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>
Contributor
There was a problem hiding this comment.
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_htmlfilter 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) andquery_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 returnfalse;query_latest_home_url()currently dereferences$wordcamp->metaunconditionally, which will fatally error if a site isn’t linked to a WordCamp post. Returningfalseis consistent with the function’s contract.
$wordcamp = get_wordcamp_post();
$end_date = absint( $wordcamp->meta['End Date (YYYY-mm-dd)'][0] ?? 0 );
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
get_latest_home_url()logic), ORjetpack_contact_form_htmlfilter as suggested by @jeherve in the issue discussionlatest-site-hints.phpas suggested by @dd32Implementation details
get_latest_home_url()function andget_wordcamp_post()end date logicTest plan
Fixes #1468
🤖 Generated with Claude Code