Theme/plugin responsible for prematurely calling is_amp_endpoint() should be identified #4602
Labels
Changelogged
Whether the issue/PR has been added to release notes.
Enhancement
New feature or improvement of an existing one
P1
Medium priority
WS:Core
Work stream for Plugin core
Milestone
Feature description
A very common issue for themes and plugins integrating with the AMP plugin is calling
is_amp_endpoint()
before thewp
action, for example:Often users think that the AMP plugin is at fault because they only see the issue being emitted from the AMP plugin. In reality the issue is with another theme/plugin, but the other theme/plugin is not being identified. In #4574 (comment) I proposed:
This would be really helpful for users trying to find out who to contact about the problem. We can make use of the same logic used to identify a theme/plugin for the validation error source stacks here. At the moment, this logic is contained in
\AMP_Validation_Manager::get_source( $callback )
. If we can grab all the functions from the callstack viadebug_backtrace()
and then obtain thefunction
from each and obtain the source, we can then list the theme/plugin in the message that is emitted by_doing_it_wrong
.Note that this should probably only be done when
WP_DEBUG
is enabled.If the admin bar is being displayed (and
WP_DEBUG
is not enabled) perhaps the issue should be called out as a warning under the AMP admin menu item. And if there, should the issue also be called out on the Validated URL screen? This gets into some new territory for the Validation screens, namely in the beginning they were limited to showing AMP validation errors. However, then they added Stylesheet information. I've also proposed that fatal errors occurring during validation should be exposed (#4580). What about incorrect usage issues or other problems with AMP content? The AMP validator itself has two classes of issues: errors and warnings. Invalid JSON is actually a warning and not an error (see #4430). Should those there be a section on the validated URL screen for warnings, including things like invalid JSON, callingis_amp_endpoint
incorrectly, and fatal errors?Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
is_amp_endpoint()
(and friends) too early, any notice that is displayed should identify that theme or plugin as the culprit.Implementation brief
debug_backgrace()
to obtain the first call stack entry outside the AMP plugin to identify who called the function.QA testing instructions
Demo
Changelog entry
The text was updated successfully, but these errors were encountered: