PLIA-3972: Load front-end overlay for any user who can edit content - #63
Merged
Merged
Conversation
siteimprove_wp_head() gated script injection on a hardcoded list of role names, so users with custom/renamed roles or multisite super admins got no overlay on previews even though the capability-checked admin paths worked. This also left the Prepublish toolbar button inert, since its handler ships in the un-loaded siteimprove.js. Switch to current_user_can( 'edit_posts' ), matching siteimprove_init(), and bump the plugin to 2.1.3 with changelog entries.
mostergaard
approved these changes
Jun 9, 2026
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.
Problem
A customer reported that on preview pages the floating Siteimprove overlay never loads, the Prepublish toolbar button does nothing (just appends
#to the URL), and nositeimprove.jsis present in the DOM — while everything works fine inwp-admin.Root cause
siteimprove_wp_head()was the only permission check in the plugin gated on hardcoded role names:Every other path (
siteimprove_init(), the settings screens) usescurrent_user_can( ... ). Users whose role name isn't in that list — custom/renamed roles, or multisite super admins not explicitly assigned a role on a subsite — have editing capabilities but no matching role name, so the overlay JS was never enqueued on the front end. The admin-side paths are capability-gated, which is why they kept working.This also explains the inert Prepublish button:
add_prepublish_toolbar_item()renders it without a role check, but its click handler lives in the un-loadedsiteimprove.js, so clicking just followshref="#".Fix
Gate the front-end injection on
current_user_can( 'edit_posts' ), matching the capability check already used for the identical'siteimprove_input'enqueue insiteimprove_init(). This covers custom roles, renamed roles, and super admins while still excluding subscribers/visitors.Version bumped 2.1.2 → 2.1.3 (patch) with changelog entries in
readme.txtandREADME.md.Testing notes
Reproduce with a user who has
edit_postsbut a non-standard role (e.g. a custom role, or a multisite super admin not added to the subsite): before the fix the overlay/Prepublish button is missing on previews; after, both load. Standard roles (administrator/editor/author/contributor/shop_manager) and subscribers are unaffected.