Require capability to dismiss welcome notice - #229
Conversation
a1499b7 to
4aceba7
Compare
4aceba7 to
3d4273a
Compare
|
@dknauss is this still in process or can this come out of draft for review? |
There was a problem hiding this comment.
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_optionsfor single-site (or non-network-activated) installs when dismissing the welcome notice via AJAX. - Require
manage_network_optionswhen 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.
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).
|
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 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. |
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_optionson single-site installs andmanage_network_optionswhen the plugin is network active, matching the administrative context where the notice is managed.Benefits
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.phpcomposer run lintgit diff --checkChangelog Entry
Checklist:
AI assistance was used in drafting and reviewing this change; final authorship and verification are mine.