Turn off Developer Tools when user preference is disabled#4955
Merged
westonruter merged 17 commits intodevelopfrom Jul 1, 2020
Merged
Turn off Developer Tools when user preference is disabled#4955westonruter merged 17 commits intodevelopfrom
westonruter merged 17 commits intodevelopfrom
Conversation
…cess * Add dev tools checkbox on the user edit screen. * Map amp_validate to manage_options by default. * Use amp_validate capability for editing amp_validated_url posts and amp_validation_error terms. * Allow access to dev tools if user has the capability but hide the UI if not enabled. * Hide validation info from At a Glance on the Dashboard if dev tools not enabled. * Prevent showing Validate link, validation info, and paired browsing in AMP admin bar menu if dev tools not enabled. * Let users who can manage_options have dev tools enabled by default.
* Remove obsolete notice taking user to hidden developer tools when Reader mode is selected. * Prevent validating after plugin activation if dev tools is not enabled.
Contributor
|
Plugin builds for 642f85e are ready 🛎️!
|
westonruter
commented
Jun 30, 2020
amedina
reviewed
Jun 30, 2020
Member
amedina
left a comment
There was a problem hiding this comment.
This is super good. I went over the various scenarios, via the setup wizard, from the user profile editing screen, and the flow is intuitive. This feature represents a huge improvement in the UX, especially for non tech-savvy folks.
pierlon
suggested changes
Jul 1, 2020
includes/class-amp-theme-support.php
Outdated
| * | ||
| * @return DevToolsUserAccess | ||
| */ | ||
| private static function get_dev_tools_user_access() { |
Contributor
There was a problem hiding this comment.
Seems this method is not being used anywhere.
tests/php/validation/test-class-amp-validated-url-post-type.php
Outdated
Show resolved
Hide resolved
Co-authored-by: Pierre Gordon <16200219+pierlon@users.noreply.github.com>
Co-authored-by: Pierre Gordon <16200219+pierlon@users.noreply.github.com>
pierlon
approved these changes
Jul 1, 2020
Contributor
pierlon
left a comment
There was a problem hiding this comment.
Really great job done here 👍
3 tasks
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.
Summary
Fixes #2673.
Fixes #4480.
See #2069.
To accompany the “technical user” question in the onboarding wizard, there is now a Developer Tools preference on the user edit screen:
This checkbox is only presented to users who can
manage_options. Actually, the checkbox is presented to users who canamp_validate, a new meta capability that is mapped to themanage_optionsprimitive capability by default. This allows a site to customize which users can access developer tools, but by default it is limited to administrators (whereas currently it is anyone who canedit_posts).As opposed to the DevTools toggle being
nullby default, it is nowtrueby default. Admins can turn it off if they don't want it. The first time the wizard is entered, it does not consider the current user's preferences so it will ask whether they are technical without auto-selecting one option.When an administrator has DevTools turned off, then the admin menu items for Validated URLs and Validation Errors do not appear:
They are also hidden in the At a Glance widget on the Dashboard:
And the admin bar simply shows a link back to the non-AMP version, with no Validate link, CSS usage info, or paired browsing (aside: the link text is not entirely intuitive here):
Nevertheless, even though an administrator has turned off DevTools, they can still access them manually by going to
/wp-admin/edit.php?post_type=amp_validated_url. All the screens then show up in the admin menu. This will be critical for allowing administrators to access the validation screens in response to the Site Health test proposed in #1756 (comment).Naturally, when Developer Tools are turned off, no validation warning messages will appear in the editor. Additionally, no synchronous validation is performed during saving. (Scheduling a job to validate an edit to a published post needs to be done as part of #1756.) This will address the slowness of synchronous loopback requests (#2069) for non-administrators and admins with DevTools turned off.
Additionally, loopback requests to perform validation are also no longer performed when activating a new plugin if the user has DevTools turned off.
Lastly, when DevTools are enabled they will also now apply in Reader mode for the first time.
As part of this, the admin bar is now also shown in the Reader mode template. Please note that in order to support scripts that are added for the admin bar, this PR introduces
wp_print_head_scripts()atamp_post_template_headandwp_print_footer_scripts()atamp_post_template_footer. Nevertheless,wp_enqueue_scripts()is not called so it's up to plugins that want to extend the sidebar in legacy Reader mode to enqueue the scripts at theadmin_bar_initaction.While Developer Tools are restricted to administrator users who can
amp_validatewhich is mapped tomanage_optionsby default, this can be overridden for example to let editors access dev tools via code like this:That then moves the DevTools to the top-level menu item:
Todo
Checklist