fix(admin): add custom capability option for settings pages - #7578
fix(admin): add custom capability option for settings pages#7578faisalahammad wants to merge 2 commits into
Conversation
Settings pods let site owners gate the admin menu on any capability.
Defaults keep pods/pods_content/pods_edit_{name} so existing admins
do not lose access. New option is opt-in per pod, no migration.
Fixes pods-framework#7245
PR Summary
|
|
AI disclosure: this PR was written with Claude Opus 5 assistance, reviewed and tested by me. |
Review: the capability is only enforced on menu registrationNo privilege escalation on the default path — the custom cap is only appended when Two gaps before this delivers what the issue asks for. 1. The real access check is untouchedThe custom cap is only consulted when registering the menu. The actual capability resolution for settings objects lives in $capabilities['read'] = 'manage_options';
$capabilities['edit'] = 'pods_edit_' . $info['object_name'];
Worth mirroring the custom cap into that 2. Unsanitized option
MinorThe PR checklist ticks "includes automated tests", but neither changed file is a test. A wpunit test asserting that a user with only the custom cap can reach the settings page (and that one without it cannot) would cover both points above. Disclosure: this review was produced with AI assistance and verified against the branch code before posting. |
Description
Settings pods now expose a per-pod capability option. The admin menu stays gated on
pods,pods_content, orpods_edit_{name}by default. Picking "Custom" adds an editable cap name (e.g.manage_options) that grants access in the same OR-list, so existing admins keep their access andpods_is_adminfilter still works.Related GitHub issue(s)
Fixes #7245
Testing instructions
site_settingsfor the test below).manage_options(or any cap your test user has).manage_optionsbut none of the Pods caps: the settings page menu item shows.manage_optionsor any Pods cap: the menu item stays hidden.Screenshots / screencast
n/a
Changelog text for these changes
PR checklist
Screenshot