-
Notifications
You must be signed in to change notification settings - Fork 384
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
Do async site scan after theme activation #6859
Conversation
Plugin builds for f7f2121 are ready 🛎️!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes looks good to me.
This utilizes the async site scan notice that is shown after plugin activation. Right now, both on `plugins.php` and on `themes.php` screens, the scan results will include plugin and theme issues.
8696ef2
to
9566a93
Compare
Codecov Report
@@ Coverage Diff @@
## develop #6859 +/- ##
=============================================
+ Coverage 77.80% 77.81% +0.01%
- Complexity 6767 6771 +4
=============================================
Files 267 267
Lines 21548 21560 +12
=============================================
+ Hits 16765 16777 +12
Misses 4783 4783
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay in reviewing.
/** | ||
* HTML ID for the app root sibling element. | ||
* | ||
* Since there is no action for adding notice on `themes.php` screen, we need to inject React root element with JS. | ||
* It is an ID of a success notice saying "New theme activated. Visit site" on the `themes.php` screen. | ||
* | ||
* @var string | ||
*/ | ||
const APP_ROOT_SIBLING_ID = 'message2'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Classic 😄
|
||
root = document.createElement( 'div' ); | ||
root.setAttribute( 'id', APP_ROOT_ID ); | ||
rootSibling.after( root ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. The after
method is available for every browser except IE11. I need to start using it!
<p> | ||
{ createInterpolateElement( | ||
sprintf( | ||
// translators: %s stands for a theme name. | ||
__( 'AMP compatibility issues discovered with the <b>%s</b> theme.', 'amp' ), | ||
themeName, | ||
), | ||
{ | ||
b: <strong />, | ||
}, | ||
) } | ||
</p> | ||
<div className="amp-site-scan-notice__cta"> | ||
<a | ||
href={ AMP_COMPATIBLE_THEMES_URL } | ||
className="button" | ||
{ ...isExternalUrl( AMP_COMPATIBLE_THEMES_URL ) ? { target: '_blank', rel: 'noopener noreferrer' } : {} } | ||
> | ||
{ __( 'View AMP-Compatible Themes', 'amp' ) } | ||
</a> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this add the list of URLs in the same way as PluginsWithAmpIncompatibility
does?
<p> | ||
{ createInterpolateElement( | ||
sprintf( | ||
// translators: %s stands for a theme name. | ||
__( 'AMP compatibility issues discovered with the <b>%s</b> theme.', 'amp' ), | ||
themeName, | ||
), | ||
{ | ||
b: <strong />, | ||
}, | ||
) } | ||
</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may actually be two themes that have compatibility issues, the parent theme and the child theme. Therefore I suggest that the structure here follow closely what you did in PluginsWithAmpIncompatibility
and have the list of themes along with the URLs that they have issues detected on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely. Check out #6859 (comment) below.
return null; | ||
} | ||
|
||
const themeMeta = themes.find( ( theme ) => theme.stylesheet === themeWithAmpIncompatibility.slug ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted below, this should also account for there being a child theme active.
@@ -197,6 +235,11 @@ protected function add_preload_rest_paths() { | |||
[ 'author', 'name', 'plugin', 'status', 'version' ], | |||
'/wp/v2/plugins' | |||
), | |||
add_query_arg( | |||
'_fields', | |||
[ 'author', 'name', 'status', 'stylesheet', 'version' ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per above, this will also need to include template
for the sake of child themes:
[ 'author', 'name', 'status', 'stylesheet', 'version' ], | |
[ 'author', 'name', 'status', 'stylesheet', 'template', 'version' ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just committed that but I'm now wondering if we actually need to know the parent theme (i.e. the template
)? We don't show an information like this anywhere in the UI so I guess we could just skip that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you'd need it here potentially:
const themeMeta = themes.find( ( theme ) => theme.stylesheet === themeWithAmpIncompatibility.slug );
const themeName = themeMeta?.name?.rendered ?? themeMeta?.name;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are now using template
, too. As noted in #6859 (comment), the parent/child themes were not handled well in the Site Scan results. This should be fixed with 11da989.
Co-authored-by: Weston Ruter <westonruter@google.com>
Co-authored-by: Weston Ruter <westonruter@google.com>
@westonruter While reviewing your feedback I realized that the Site Scan is not handling correctly cases when child and parent themes cause AMP incompatibilities. The parent theme is greyed-out as if it was inactive (because its I've issued a new ticket #6958 mainly for tracking/QA reasons because this issue should be fixed with 11da989: It also takes care of the post-activation notice: |
…theme-activation-site-scan * 'develop' of github.com:ampproject/amp-wp: (158 commits) Include SCSS files in the lint-staged config for stylelint Fix stylelint issue Rename 'allowed' to 'associated' Use named functions Add label for why the validation data is being shown Remove wrapping of site-scan-results__source-detail Bump lint-staged from 12.3.4 to 12.3.5 Update perimssions for gutenberg-packages-update workflow Add approve step for auto-merge workflow Add notice step Move conditional from matrix job to its steps Only run PHP feature tests when php files have changed Only run phpunit tests if a PHP file has changed Update auto-merge workflow based on latest GH docs Bump node-fetch from 2.6.5 to 2.6.7 Bump postcss from 8.4.7 to 8.4.8 Bump eslint-plugin-jsdoc from 37.9.6 to 37.9.7 Improve test coverage Prevent site scan progress bar overflow bug in Safari Hide default details summary marker on Safari ...
Looks like tests are failing after I merged #6933. This error is also happening in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work
]; | ||
|
||
// Display the theme information at the top when on the `themes.php` screen. | ||
if ( document.location.href.includes( 'themes.php' ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works, although it may be a bit more elegant to pass this information via the amp-site-scan-notice
external dependency.
Co-authored-by: Piotr Delawski <piotr.delawski@gmail.com>
Summary
Fixes #6814
Fixes #6958
This PR reuses the async site scan notice logic introduced in #6685 so that a site scan is done after theme activation, too.
Right now on both
plugins.php
andthemes.php
screens the scan results will include plugin and theme issues.This PR also updates the Site Scan results for themes. Previously, a parent theme causing AMP incompatibilities was greyed-out while it should not (#6958):
Checklist