Toggling Dev Tools

The AMP plugin has become more user friendly by providing the flexibility of hiding developers tools. Developer Tools are now limited to being available to administrators by default. When a user with another role (e.g. author) edits a post, they will no longer be presented with AMP validation error notices. Additionally, there will not be additional latency to wait for a loopback request to be performed to obtain the validation results.

Developer Tools can now be turned off for users who don’t want to (or can’t) deal with any validation issues, but for users who do, the validation workflow is improved. Developer Tools are only accessible to administrators, and even they also have the option to turn them off. Furthermore, as the user follows the onboarding flow, if they declare themselves as non-technical, Developer Tools will be disabled by default.

The AMP Plugin determines the level of exposure to validation tool details in one of two ways. First, it uses your answer to technical expertise question in the onboarding flow:

If you answered you are non-technically savvy or you want a simpler setup, the plugin automatically switches to a simplified mode. And, at any time, you can change the setting to either turn dev tools on or off by switching the corresponding check box on your user profile (provided you have the permissions and the proper role):

Dev Tools in Reader Mode #

As of v2.0, developer Tools are also available in Reader mode. Most users do not wish to see the validation error notices because they may not have the desire or ability to fix the associated issues. Administrators, in contrast, are able to deactivate plugins which are causing validation errors, or upload new plugins which fix the AMP incompatibilities. And administrators who do not wish to see validation errors can also turn off Developer Tools in their user profile. Notice that when Developer Tools are turned off, the plugin will soon still perform validation in the background and alert administrators even who have Developer Tools turned off via Site Health.

Toggling Dev Tools #

Users with Developer Tools disabled will no longer see the “Validated URLs” or “Error Index” admin menu items, and they will no longer be told of the AMP validation status in the admin bar when viewing an AMP.

Admin bar with Dev Tools off

Admin bar with Dev Tools on

Enabling Dev Tools for non-admin users #

If a site needs to grant access to users with the editor role, for example, this can be done with a map_meta_cap filter:

add_filter( 'map_meta_cap', function ( $caps, $cap, $user_id ) { if ( 'amp_validate' === $cap && user_can( $user_id, 'edit_others_posts' ) ) { $position = array_search( $cap, $caps, true ); if ( false !== $position ) { $caps[ $position ] = 'edit_others_posts'; } } return $caps; }, 10, 3 );