-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do async site scan after theme activation
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.
- Loading branch information
Showing
8 changed files
with
255 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
assets/src/admin/site-scan-notice/theme-with-amp-incompatibility.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { createInterpolateElement, useContext } from '@wordpress/element'; | ||
import { __, sprintf } from '@wordpress/i18n'; | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import PropTypes from 'prop-types'; | ||
import { AMP_COMPATIBLE_THEMES_URL } from 'amp-site-scan-notice'; // From WP inline script. | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { Themes } from '../../components/themes-context-provider'; | ||
import { isExternalUrl } from '../../common/helpers/is-external-url'; | ||
|
||
/** | ||
* Render a message saying a theme is not AMP compatible. | ||
* | ||
* @param {Object} props Component props. | ||
* @param {Object} props.themeWithAmpIncompatibility Theme with AMP incompatibilities. | ||
*/ | ||
export function ThemeWithAmpIncompatibility( { themeWithAmpIncompatibility } ) { | ||
const { fetchingThemes, themes } = useContext( Themes ); | ||
|
||
if ( fetchingThemes ) { | ||
return null; | ||
} | ||
|
||
const themeMeta = themes.find( ( theme ) => theme.stylesheet === themeWithAmpIncompatibility.slug ); | ||
const themeName = themeMeta?.name?.rendered ?? themeMeta?.name; | ||
|
||
return ( | ||
<> | ||
<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> | ||
</> | ||
); | ||
} | ||
|
||
ThemeWithAmpIncompatibility.propTypes = { | ||
themeWithAmpIncompatibility: PropTypes.shape( { | ||
slug: PropTypes.string, | ||
urls: PropTypes.arrayOf( PropTypes.string ), | ||
} ).isRequired, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.