-
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
Improve post Site Scan action items #6698
Conversation
@westonruter The only item left to do is adding links to the AMP Compatible tabs for themes and plugins. I was wondering about the filesystem check you mentioned in the original issue. I think we need to not only check the filesystem but also user capabilities. Do you think we could reuse some of the logic from |
Codecov Report
@@ Coverage Diff @@
## develop #6698 +/- ##
=============================================
- Coverage 76.67% 76.61% -0.07%
- Complexity 6543 6545 +2
=============================================
Files 263 265 +2
Lines 20956 20989 +33
=============================================
+ Hits 16069 16080 +11
- Misses 4887 4909 +22
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Plugin builds for 7114e14 are ready 🛎️!
|
@delawski That's right. If the filesystem is not writable, the $theme_link = current_user_can( 'install_themes' ) ? admin_url( '/theme-install.php?browse=amp-compatible' ) : 'https://amp-wp.org/ecosystem/themes/';
$plugin_link = current_user_can( 'install_plugins' ) ? admin_url( '/plugin-install.php?tab=amp-compatible' ) : 'https://amp-wp.org/ecosystem/plugins/'; |
And when the capability checks return false, we should have the external link icon to go with the links. |
d9759f3
to
074f845
Compare
This prevents the progress bar starting at 100% in the Onboarding Wizard site scan.
@westonruter Thank you for the suggestions. I've used the proposed logic in fd06053: Also, I found a bug in the Site Scan in the Wizard. The progress bar has been shown too early, when the state was not stable yet causing the progress bar to start at 100%. This has been fixed in 3621298. Lastly, I've included a Site Scan reducer one-line fix (253e5fd) to the issue you've revealed in #6705 (comment). |
I've just noticed a new action item on the original issue:
I'll take care of that next. |
This has been addressed in 87e609c: Screen.Recording.2021-11-17.at.02.20.16.PM.mp4 |
It's this change in WordPress core: WordPress/wordpress-develop@5d5c9bf Easy to fix. See #6727. |
…te-scan-results-panel * 'develop' of github.com:ampproject/amp-wp: Fix test_amp_remove_paired_endpoint in WP 5.9 by removing empty query string
I just realized there is another factor for the recommendation matrix. Namely, if the user has a plugin suppressed then we should never recommend Standard mode, which we are doing now: If a plugin is being suppressed, then this normally means that you're in a paired AMP mode and you don't want the plugin running on the AMP version but you do want it running on the non-AMP version. If you are in Standard mode, then essentially the user should rather just have deactivated the plugin entirely as that is how it would be behaving. So this would look something like this: diff --git a/assets/src/components/use-template-mode-recommendation/index.js b/assets/src/components/use-template-mode-recommendation/index.js
index d6b9dee9d..dfea95155 100644
--- a/assets/src/components/use-template-mode-recommendation/index.js
+++ b/assets/src/components/use-template-mode-recommendation/index.js
@@ -60,12 +60,14 @@ export function useTemplateModeRecommendation() {
* @param {boolean} args.hasFreshSiteScanResults Whether fresh site scan results are available.
* @param {boolean} args.hasThemeIssues Whether the site scan found themes with AMP incompatibility.
* @param {boolean} args.userIsTechnical Whether the user answered yes to the technical question.
+ * @param {boolean} args.hasSuppressedPlugins
*/
export function getTemplateModeRecommendation( {
hasPluginIssues,
hasFreshSiteScanResults,
hasThemeIssues,
userIsTechnical,
+ hasSuppressedPlugins,
} ) {
/* eslint-disable @wordpress/no-unused-vars-before-return */
const mobileRedirectionNote = __( 'If automatic mobile redirection is enabled, the AMP version of the content will be served on mobile devices. If AMP-to-AMP linking is enabled, once users are on an AMP page, they will continue navigating your AMP content.', 'amp' );
@@ -298,17 +300,18 @@ export function getTemplateModeRecommendation( {
],
},
[ TRANSITIONAL ]: {
- recommendationLevel: NOT_RECOMMENDED,
+ recommendationLevel: hasSuppressedPlugins ? RECOMMENDED : NOT_RECOMMENDED,
details: [
transitionalModeDescription,
notRecommendedDueToCompleteCompatibility,
],
},
[ STANDARD ]: {
- recommendationLevel: RECOMMENDED,
+ recommendationLevel: hasSuppressedPlugins ? NOT_RECOMMENDED : RECOMMENDED,
details: [
standardModeDescription,
__( 'Recommended as you have an AMP-compatible theme and no issues were detected with any of the plugins on your site.', 'amp' ),
+ hasSuppressedPlugins ? __( 'Not recommended because you have suppressed plugins.', 'amp' ) : null,
],
},
};
@@ -326,7 +329,7 @@ export function getTemplateModeRecommendation( {
],
},
[ TRANSITIONAL ]: {
- recommendationLevel: NEUTRAL,
+ recommendationLevel: hasSuppressedPlugins ? RECOMMENDED : NEUTRAL,
details: [
transitionalModeDescription,
__( 'Recommended if you can’t commit to choosing plugins that are AMP compatible when extending your site. This mode will make it easy to keep AMP content even if non-AMP-compatible plugins are used later on.', 'amp' ),
@@ -337,6 +340,7 @@ export function getTemplateModeRecommendation( {
details: [
standardModeDescription,
__( 'Recommended if you can commit to always choosing plugins that are AMP compatible when extending your site.', 'amp' ),
+ hasSuppressedPlugins ? __( 'Not recommended because you have suppressed plugins.', 'amp' ) : null,
],
},
}; |
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { useMemo } from '@wordpress/element'; | ||
import { createInterpolateElement, useMemo } from '@wordpress/element'; |
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.
Fancy.
{ showHelpText && ( | ||
<p> | ||
{ createInterpolateElement( | ||
__( 'Because of plugin issues we’ve uncovered, you may want to <a>review and suppress plugins</a>.', 'amp' ), |
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.
Aside: With createInterpolateElement
, what happens when you have more than one <a>
in your string?
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.
You can use whatever tag name you wish, e.g. you could do something like this:
createInterpolateElement( 'Visit <ArchiveLink>archive</ArchiveLink> or return to <HomeLink>homepage</HomeLink>', {
ArchiveLink: <a href="/archive" />,
HomeLink: <a href="/" />,
} );
Thanks for providing that diff. I've added it along with a logic for determining the |
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.
🥇
// Plugins are considered suppressed only if they are active (included in the `suppressible_plugins` object). | ||
const hasSuppressedPlugins = Object.entries( currentOptions?.suppressed_plugins || {} ) | ||
.some( ( [ slug, suppressed ] ) => suppressed && Boolean( currentOptions.suppressible_plugins?.[ 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.
Nicely done
const fetchedPluginSuppression = await apiFetch( { | ||
path: addQueryArgs( optionsRestPath, { | ||
_fields: [ 'suppressed_plugins', 'suppressible_plugins' ], | ||
} ), | ||
} ); |
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.
❤️
setOriginalOptions( { | ||
...originalOptions, | ||
...fetchedPluginSuppression, | ||
} ); |
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 is great. I was thinking that this could have the effect of overriding a user's unsaved changes to plugin suppression, but this won't be the case the original options are updated, not the modified otpions.
Summary
Fixes #6689
This PR improves the action items for when there are theme and/or plugin incompatibilities.
Here are the todo items from the original issue:
ExternalLink
s going to the theme/plugin ecosystem pages on amp-wp.org.suppressed_plugins
option should be re-fetched so that the suppressed table is updated with which plugins have validation errors.Here's the updated Site Scan panel on the AMP Settings screen where the plugin/theme action items are located inside the respective sub-panels:
Checklist