Skip to content

feat(updates): [SITE-5883] Add dismiss option to WordPress update notice - #121

Merged
mehta-asim merged 4 commits into
mainfrom
SITE-5883-dismissible-update-notice
Jul 14, 2026
Merged

feat(updates): [SITE-5883] Add dismiss option to WordPress update notice#121
mehta-asim merged 4 commits into
mainfrom
SITE-5883-dismissible-update-notice

Conversation

@mehta-asim

@mehta-asim mehta-asim commented Jul 13, 2026

Copy link
Copy Markdown
Member

Summary

  • Make the "A new WordPress update is available!" notice dismissible. The notice already carried the is-dismissible class, but WordPress's native dismiss is client-side only, so the notice returned on the next page load (the GitHub Add option to dismiss WordPress update notice in the admin dash #116 complaint).
  • Persist dismissal per user, keyed to the available WordPress version via a single user-meta key (pantheon_dismissed_update_notice). A newer available version no longer matches the stored value, so the notice returns automatically. No stale-meta cleanup needed (one key, overwritten).
  • Add a wp_ajax_pantheon_dismiss_update_notice handler (nonce + update_user_meta; the target version is resolved server-side, not trusted from the client) and a small script that fires on the native dismiss click.
  • Add a render gate to _pantheon_upstream_update_notice() that skips the notice when the user's dismissed version equals the current available version.

Context

SITE-5883

Community feedback (GitHub #116): the update notice is persistent and reappears on every admin page load. Maintainer guidance on that issue confirmed the fix must use user meta keyed to the version (client-side is-dismissible alone does not persist).

Builds on SITE-5884 (#119, merged): reuses the _pantheon_render_notice() dismissible support and the playwright-bdd e2e harness. _pantheon_render_notice() and the other dismissible callsites (multisite-finalize, page-cache) are intentionally left untouched — persistence is wired only at the update-notice callsite.

Changes

File Change
inc/pantheon-updates.php Render gate + dismissible => true on the update-available notice; wp_ajax_pantheon_dismiss_update_notice handler; enqueue + localize; two shared consts
inc/assets/js/pantheon-update-notice-dismiss.js Persists the native dismiss click via an AJAX POST (fire-and-forget)
tests/phpunit/test-pantheon-updates.php Gate tests: is-dismissible present, hidden when dismissed for current version, returns when newer version available
tests/phpunit/test-pantheon-update-notice-dismiss.php Handler tests: stores available version on valid nonce, rejects bad nonce
tests/e2e/ 3 BDD scenarios (renders dismissible / persists across reload / reappears on newer version); installer now also deploys the dismiss JS

Testing

Local wp-env (browser, Playwright-driven):

  • Notice renders with the native dismiss X
  • Click X → AJAX POST → 200 → dismissal stored in user meta
  • Reload → notice stays hidden (the core AC)
  • Bump available version → notice returns

Automated: phpunit (gate + handler) and BDD (dismiss / persist-across-reload / reappear) run in CI.

Test plan

  • CI: all PHP legs green (phpunit)
  • CI: BDD e2e green against a provisioned multidev
  • Reviewer sanity-check on multisite / network admin

Open items

References

Make the upstream update notice dismissible per user, keyed to the
available WordPress version so it stays dismissed until a newer version
is released. Adds an AJAX handler (nonce + user-meta), a small dismiss
script that persists the native is-dismissible click, and a render gate.
Covered by phpunit (gate + handler) and BDD scenarios (dismiss, persist
across reload, reappear on new version) on the existing e2e harness.
@mehta-asim
mehta-asim requested review from a team as code owners July 13, 2026 22:02
@mehta-asim
mehta-asim marked this pull request as draft July 13, 2026 22:02
@codacy-production

codacy-production Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 8 complexity · 0 duplication

Metric Results
Complexity 8
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Adding is-dismissible to the notice moved the pantheon-update-notice
class token, breaking the adjacency assertion in the pre-existing
targeting-hooks test; assert the class token order-independently instead.
Declare the wp_localize_script global pantheonUpdateNotice for the
linter (Codacy no-undef).
The After-hook cleanup interpolated process.env.WP_USER into the wp
command, an unsanitized env-var to shell flow (CodeQL: indirect
uncontrolled command line). Route it through a throwing allowlist guard,
matching how SITE/SOURCE_ENV are already validated.
@mehta-asim
mehta-asim marked this pull request as ready for review July 13, 2026 22:23
jazzsequence
jazzsequence previously approved these changes Jul 14, 2026
pwtyler
pwtyler previously approved these changes Jul 14, 2026
Comment thread tests/e2e/features/hide-update-notice.feature
Comment thread tests/e2e/features/hide-update-notice.feature Outdated
Per Ander: hide selectors behind a semantic step (the update notice
should offer a dismiss option), and set the dismissed state directly via
user meta in the reappear scenario instead of re-driving the dismiss UI
(already covered by the persist scenario).
@mehta-asim
mehta-asim dismissed stale reviews from pwtyler and jazzsequence via 3dbb4df July 14, 2026 18:02
@mehta-asim
mehta-asim merged commit 6f19699 into main Jul 14, 2026
18 of 21 checks passed
@mehta-asim
mehta-asim deleted the SITE-5883-dismissible-update-notice branch July 14, 2026 20:27
@mehta-asim mehta-asim mentioned this pull request Jul 15, 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.

4 participants