-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display error when a plugin is activated which tries to do something incompatible with AMP #842
Comments
Question About Approach Hi @westonruter,
Thanks, Weston 😄 |
@kienstra I think that this will not give us complete results. A plugin may not do anything upon activation. It may require a user to actually do something, like add a widget or shortcode. I think the best we can probably do here is:
|
Both of these checks would only be done when explicitly requested, especially the latter one because I imagine it would be expensive. |
It should also be possible to use the similar approach for shortcodes. We could wrap each registered shortcode handler with a function that puts those milestone comments before and after. The sanitizer would then be able to know which shortcode was responsible for the illegal output. The specific theme or plugin could be identified via the Reflection API to fond the filename that contains the function or class. |
If a <script> or stylesheet gets removed, store it in $removed_assets. There isn't yet a way to report inline scripts. Like <script type="text/javascript">myFunc();</script>. This uses the 'src' attribute to find the plugin or theme.
Iterate through all of the registered callbacks. If a callback is from a plugin and outputs markup, wrap the markup in comments. Later, the sanitizer can identify which plugin any illegal markup is from. Thanks to @westonruter for this strategy.
Also, address a Travis error. Instead of testing for the presence of 'amp-wp,' simply make it 'amp.' This plugin seems to be in the directory 'amp-wp' in the Travis tests.
The plugin is in 'amp-wp' in some Travis tests. So instead of expecting the plugin to be 'amp,' Simply expect it to contain 'amp.'
Add an extra parameter to track_removed(). If $source is passed, store that. Then, if a node is removed, look for the presence of $source.
If the query var of 'validate' is present, Output the previous validation response, like on the post.php page. But also add a 'plugins_with_invalid_output' value. This includes all of the plugins that output markup which had removed elements or attributes.
This might have caused issues, as the order of assignment is different in PHP 7.0. So insted, access the array values.
Substitute all uses of 'remove_invalid_callback' With AMP_Validation_Utils::CALLBACK_KEY.
Props @westonruter. This also needs to account for themes and mu-plugins.
On Weston's suggestion, as this can track nested plugins in themes. Also, update PHPUnit tests for this.
At Weston's suggestion, as this needs to apply to themes.
As Weston suggested, started with add_post_meta(). If that is false, get the post meta, And append the new URL to the array.
At Weston's suggestion. For example, <!--before:plugin:amp-->
The means of doing this might need improvement. But this uses regexes, based on the paths to the theme, plugin, and mu-plugin dirs.
In Travis, this plugin is cloned as 'amp-wp'. But developers usually clone it as 'amp'. So remove the '-wp', to avoid errors in Travis.
Mostly resolve in favor of develop. But apply some changes from branch add/842-plugin-validation. Like the constant AMP_Validation_Utils::CALLBACK_KEY, instead of 'remove_invalid_callback'.
Display a notice on /wp-admin/plugins.php, when a plugin has invalide markup on the home page. @todos include improving validate_home(). There's now an error locally, with a self-signed SSL certificate.
Discussion Is On PR Most of the discussion and solution design for this issue is now taking place on this pull request. |
Per Weston's suggestion, this outputs all of the URLs with plugin or theme errors. @todos include the 're-check' And removing the 'Add New' link on the post table.
Correct an issue in improper vertical alignment. And use constants in place of string literals.
Only remove some items from post actions. Keep the rest of the actions in place. Like 'Restore' when in the trash. Also, prevent displaying multiple plugins on plugins.php.
This displays on the 'AMP Validation Errors' page. @todo: implement this bulk action on the back-end.
On the edit.php page, there's a column for 'Incompatible Source'. The way the sources are stored enables duplicated. So use array_unique to prevent displaying more than one.
Steps To Test Hi @csossi, plugins.php
Validation Status Page
Single Error post.php Page
Troubleshooting |
verified in QA |
Acceptance Criteria
AC1: On activating a plugin on wp-admin/plugins.php, if the plugin does something that’s not compatible with AMP, display an error at the top of the page
AC2: The error message will display the following text:. “ is not compatible with AMP, and could result in content displaying improperly on your site.”
Tasks
The text was updated successfully, but these errors were encountered: