Skip to content
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

Add Site Icon tests for Site Health and warnings in Customizer control #702

Merged
merged 69 commits into from
Apr 1, 2022
Merged
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
d18eeed
Add js for maskable icon customizer preview settings
thelovekesh Feb 11, 2022
7d9e93e
Add icon purpose as `any maskable` if user have not checked site icon…
thelovekesh Feb 11, 2022
cd67ec2
Update to show icon as maskable when user uplaods site-icon
thelovekesh Feb 11, 2022
df60ff3
Update theme_mod type in settings with option
thelovekesh Feb 11, 2022
e147659
Move code from manifest to admin
Feb 11, 2022
c0005c8
Optimize JS for icon handling
Feb 11, 2022
c9e7bca
Fix: Add mask when image updated
Feb 11, 2022
5172a07
Update function names
Feb 11, 2022
2a50729
Fix: Icon toggling
Feb 11, 2022
e07955f
Use default maskable set from option
Feb 11, 2022
9657a3c
Fix eslint warnings
thelovekesh Feb 12, 2022
9e96825
Fix site icon purpose addition in manifest
thelovekesh Feb 13, 2022
7e73f78
Remove maskbale icon setting registration
thelovekesh Feb 13, 2022
8850990
Add file for regestring maskable icon setting
thelovekesh Feb 13, 2022
940ce83
Add customizer manager class for init
thelovekesh Feb 13, 2022
6cf206e
Fix showing and hiding of maskable icon setting based on site icon
thelovekesh Feb 13, 2022
5e93c75
Move customizer script to wp-admin folder
thelovekesh Feb 13, 2022
3a6a0ea
Fix: Initial checkbox state
Feb 11, 2022
da51dfe
Update: Set maskable icon setting visibility from js
thelovekesh Feb 13, 2022
a4f6e46
Remove active_callback as already implemented in js
thelovekesh Feb 13, 2022
9c1e043
Fix phpcs errors
thelovekesh Feb 13, 2022
5a43714
Add inline doc and fix adding of icon purpose
thelovekesh Feb 13, 2022
d25f371
Add test cases for maskable icon customizer settings
thelovekesh Feb 14, 2022
99a09e5
Add test cases for adding icon purpose in manifest
thelovekesh Feb 14, 2022
15b8bbe
Remove empty file for adding tests related to admin.php
thelovekesh Feb 14, 2022
bb106bc
Enqueue site icon default value
Feb 14, 2022
8bd06ea
Remove redundant code
Feb 14, 2022
6d18007
Fix: Linting
Feb 14, 2022
540b96d
Remove section binind on expend event
thelovekesh Feb 14, 2022
261f9fc
Add active_callback and remove inline js for sending site_icon value
thelovekesh Feb 14, 2022
053abf0
Remove customizer js from wp-includes
thelovekesh Feb 14, 2022
9796921
Fix: Checkbox toggle and state management
Feb 14, 2022
9db329f
Rename pwa_maskable_icon option to site_icon_maskable
westonruter Feb 15, 2022
aa53d84
Use priority on site_icon to set priority of site_icon_maskable
westonruter Feb 15, 2022
cd6f5ff
Improve method, dependency, and file naming
westonruter Feb 15, 2022
aef39e2
Simplify logic for managing site_icon_maskable active state
westonruter Feb 15, 2022
6e6a187
Refactor logic to better utilize Customizer JS API
westonruter Feb 15, 2022
9c18eda
Fix logic inversion for maskable icon
westonruter Feb 15, 2022
f1c834d
Add missing covers tags
westonruter Feb 15, 2022
1fd98ec
Merge branch 'feature/304-makable-icon-setting' into feature/integration
Feb 16, 2022
7621c6e
Add site health tests for the site icon
thelovekesh Feb 14, 2022
34b02e5
Fix: DocBlock
thelovekesh Feb 14, 2022
c37d7e9
Update wp_getimagesize function with wp_get_attachment_metadata
thelovekesh Feb 15, 2022
88b1986
Add image for testing the site icon
thelovekesh Feb 15, 2022
dccd1b2
Add tests for validating site icons
thelovekesh Feb 15, 2022
5595f72
Fix: return type
Feb 16, 2022
b58c78b
JS: Validation for icon
Feb 16, 2022
8033350
Fix: Linting
Feb 16, 2022
eb120de
Merge branch 'develop' of github.com:GoogleChromeLabs/pwa-wp into fea…
westonruter Mar 30, 2022
89b9d58
Skip test_pwa_validate_site_icon_not_png on PHP 7.1
westonruter Mar 31, 2022
ca01f7b
Reuse existing variable and improve variable name
westonruter Mar 31, 2022
eac70d9
Use warning notification type
westonruter Mar 31, 2022
85f590a
Add notifications to control instead of section
westonruter Mar 31, 2022
e7d0c61
Improve function name
westonruter Mar 31, 2022
44f13f5
Use attachment data for notifications and update notifications when s…
westonruter Mar 31, 2022
d6c815a
Show missing icon notification when attachment is no longer present
westonruter Mar 31, 2022
5bbe720
Remove extraneous variable
westonruter Mar 31, 2022
b27018d
Reuse l10n object in Customizer
westonruter Mar 31, 2022
dc25901
Add warning notifications for non-PNG and non-square icons
westonruter Mar 31, 2022
92da073
Improve strings and presentation of site health test
westonruter Mar 31, 2022
4d545fd
Improve method naming and return value
westonruter Mar 31, 2022
e6a716d
Fix boolean condition for whether icon is too small
westonruter Mar 31, 2022
bb4cac4
Remove extraneous comments
westonruter Mar 31, 2022
d06a61d
Reset notifications when site icon has been removed
westonruter Mar 31, 2022
bca28f1
Improve name of JS file
westonruter Mar 31, 2022
79b9c57
Add paragraph wrapper and harden translation escaping
westonruter Mar 31, 2022
12586a1
Add customize cap check before adding button to Customizer
westonruter Mar 31, 2022
b1d7399
Further generalize naming for site icon code after bca28f1af
westonruter Apr 1, 2022
adda38a
Improve test phpdoc descriptions
westonruter Apr 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve strings and presentation of site health test
  • Loading branch information
westonruter committed Mar 31, 2022
commit 92da073a330b90635b002c887cac32e42b6f5726
24 changes: 13 additions & 11 deletions wp-includes/class-wp-web-app-manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,27 +359,27 @@ public function pwa_validate_site_icon() {
$site_icon_id = get_option( 'site_icon' );

if ( ! $site_icon_id ) {
$icon_errors->add( 'site_icon_not_set', __( 'The site icon is not set. Please set a site icon to make your site a Progressive Web App.', 'pwa' ) );
$icon_errors->add( 'site_icon_not_set', __( 'a site icon has not been selected.', 'pwa' ) );
return $icon_errors;
}

$site_icon_metadata = wp_get_attachment_metadata( $site_icon_id );

if ( ! $site_icon_metadata ) {
$icon_errors->add( 'site_icon_metadata_not_found', __( 'The site icon metadata could not be found. Please set a site icon to make your site a Progressive Web App.', 'pwa' ) );
$icon_errors->add( 'site_icon_metadata_not_found', __( 'The site icon metadata could not be found. Please re-select a site icon.', 'pwa' ) );
return $icon_errors;
}

if ( $site_icon_metadata['width'] < 512 && $site_icon_metadata['height'] < 512 ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ( $site_icon_metadata['width'] < 512 && $site_icon_metadata['height'] < 512 ) {
if ( $site_icon_metadata['width'] < 512 || $site_icon_metadata['height'] < 512 ) {

$icon_errors->add( 'site_icon_too_small', __( 'The site icon is too small. Please use a square image with a minimum size of 512x512px.', 'pwa' ) );
$icon_errors->add( 'site_icon_too_small', __( 'The site icon is too small. Please use a square image with a minimum size of 512 &times; 512 pixels.', 'pwa' ) );
}

if ( $site_icon_metadata['height'] !== $site_icon_metadata['width'] ) {
$icon_errors->add( 'site_icon_not_square', __( 'The site icon is not square. Please use a image with 1:1 ratio resolution.', 'pwa' ) );
$icon_errors->add( 'site_icon_not_square', __( 'The site icon is not square. Please select an image with a 1:1 aspect ratio. You may be able to crop your existing site icon.', 'pwa' ) );
}

if ( 'image/png' !== get_post_mime_type( $site_icon_id ) ) {
$icon_errors->add( 'site_icon_not_png', __( 'The site icon is not a PNG image. Please use a PNG image.', 'pwa' ) );
$icon_errors->add( 'site_icon_not_png', __( 'The site icon is not a PNG image. Please select an image in PNG format.', 'pwa' ) );
}

return $icon_errors;
Expand All @@ -398,13 +398,13 @@ public function test_site_icon() {
$error_messages = $site_icon_errors->get_error_messages();

$results = array(
'label' => __( 'Site Icon is valid', 'pwa' ),
'label' => __( 'Site icon is valid', 'pwa' ),
'status' => 'good',
'badge' => array(
'label' => __( 'Progressive Web App', 'pwa' ),
'color' => 'green',
),
'description' => __( 'The site icon is used as a browser and app icon. It is recommended to use a square image with a minimum size of 512x512px.', 'pwa' ),
'description' => __( 'The site icon is used as a browser and app icon. It is recommended to use a square image with a minimum size of 512 &times; 512 pixels.', 'pwa' ),
'actions' => '',
'test' => 'pwa_site_icon_validation',
);
Expand All @@ -419,17 +419,19 @@ public function test_site_icon() {
$results['badge']['color'] = 'orange';
$results['actions'] = wp_kses_post(
sprintf(
'<a class="button button-primary" href="%s">%s</a>',
'<a class="button button-secondary" href="%s">%s</a>',
admin_url( 'customize.php?autofocus[control]=site_icon' ),
__( 'Set site icon', 'pwa' )
__( 'Select site icon', 'pwa' )
)
);

// Empty description before adding errors.
$results['description'] = '';
$results['description'] = '<p>' . esc_html__( 'Resolve the following issue(s) to ensure your site is available as a Progressive Web App:', 'pwa' ) . '</p>';
$results['description'] .= '<ul>';
foreach ( $error_messages as $message ) {
$results['description'] .= wp_kses_post( sprintf( '<p>%s</p>', $message ) );
$results['description'] .= wp_kses_post( sprintf( '<li>%s</li>', $message ) );
}
$results['description'] .= '</ul>';

return $results;
}
Expand Down