Skip to content

Require capability to dismiss welcome notice - #229

Open
dknauss wants to merge 2 commits into
10up:developfrom
dknauss:pr/welcome-dismiss-capability
Open

Require capability to dismiss welcome notice#229
dknauss wants to merge 2 commits into
10up:developfrom
dknauss:pr/welcome-dismiss-capability

Conversation

@dknauss

@dknauss dknauss commented Jul 5, 2026

Copy link
Copy Markdown

Description of the Change

Adds a capability check to the AJAX handler that dismisses the welcome notice.

The handler already verifies the nonce. This change also requires manage_options on single-site installs and manage_network_options when the plugin is network active, matching the administrative context where the notice is managed.

Benefits

  • Adds a defense-in-depth capability check for a state-changing AJAX request.
  • Keeps behavior unchanged for administrators who can manage the relevant settings.

Possible Drawbacks

None expected. Users without the relevant admin capability should not be able to persist this admin notice dismissal state.

Verification Process

  • php -l includes/classes/Notifications/Welcome.php
  • composer run lint
  • git diff --check

Changelog Entry

Fixed - Require the relevant admin capability when dismissing the welcome notice.

Checklist:

  • My code follows the code style of this project.
  • All new and existing tests pass. (No automated test suite exists in this repo; CI runs lint only.)

AI assistance was used in drafting and reviewing this change; final authorship and verification are mine.

@dknauss
dknauss force-pushed the pr/welcome-dismiss-capability branch from a1499b7 to 4aceba7 Compare July 5, 2026 02:44
@dknauss
dknauss force-pushed the pr/welcome-dismiss-capability branch from 4aceba7 to 3d4273a Compare July 5, 2026 02:59
@jeffpaul

Copy link
Copy Markdown
Member

@dknauss is this still in process or can this come out of draft for review?

Copilot AI left a comment

Copy link
Copy Markdown

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 hardens the welcome-notice dismissal flow by adding an authorization check to the wp_ajax_tenup_dismiss_welcome handler, aligning permissions with whether the plugin is network-activated or not.

Changes:

  • Require manage_options for single-site (or non-network-activated) installs when dismissing the welcome notice via AJAX.
  • Require manage_network_options when the plugin is network activated, before persisting the dismissal state.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread includes/classes/Notifications/Welcome.php
Comment thread includes/classes/Notifications/Welcome.php
The capability check added to ajax_dismiss() means a user below
manage_options can no longer persist a dismissal — but notice() and
enqueue_scripts() were still unconditional, so such a user saw the
dismissible notice, clicked X, and had it reappear on every page load.
Gate the render and the enqueue on the same capability so only users who
can dismiss it ever see it (and skip both once dismissed).
@dknauss
dknauss marked this pull request as ready for review August 12, 2026 23:03
@dknauss

dknauss commented Aug 12, 2026

Copy link
Copy Markdown
Author

Thanks for the reminder @jeffpaul; I had forgotten this.

I just brought it out of draft and pushed a follow-up (ec90bd6) that closes the gap the Copilot review flagged above: the capability check was only on the AJAX dismiss handler. A user below manage_options would still see the dismissible notice but their dismissal wouldn't persist, so it would reappear every page load. The notice render and the script enqueue are now gated on the same capability, so only users who are able to dismiss it ever see it. I've left the redundant exit; after wp_send_json_error() as-is, since that call already ends the request via wp_die().

I also pushed ef98d7b to #228 addressing Copilot's note that an explicit empty-array deny-all was being expanded to all blocks.

#230 and #233 have minor Copilot comments (a float→int timeout truncation and array pass1 input) now, but I'll address those next if you want.

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.

3 participants