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

Closes #7239: 3.19 - User interface #7303

Merged
merged 8 commits into from
Feb 14, 2025

Conversation

Miraeld
Copy link
Contributor

@Miraeld Miraeld commented Feb 12, 2025

Description

Fixes #7239
Display the newly added preload fonts to the media - fonts section of settings page.

Type of change

  • New feature (non-breaking change which adds functionality).

Detailed scenario

Refer to issue

Technical description

Documentation

This pull request introduces several changes to the font optimization settings in the WP Rocket plugin, adding a new auto preload fonts option and ensuring compatibility with legacy settings. The most important changes include adding the new option, updating the settings page, and ensuring the new option is enabled based on existing settings.

Font Optimization Settings:

  • Added a new auto_preload_fonts checkbox option to the font_optimization_section in media_section() to allow users to preload fonts automatically.
  • Updated the description for the host_fonts_locally option to include a link with more information.

Legacy Settings Compatibility:

  • Introduced the maybe_enable_auto_preload_fonts() method in Settings/Page.php to enable the new auto_preload_fonts option if the old rocket_preload_fonts option is not empty.
  • Added the maybe_enable_auto_preload_fonts() method to the wp_rocket_upgrade event in Settings/Subscriber.php to ensure it runs during upgrades. [1] [2]

Additional Changes:

  • Updated the add_option() and sanitize_option_value() methods in Fonts/Admin/Settings.php to include the new auto_preload_fonts option.

New dependencies

None

Risks

None

Mandatory Checklist

Code validation

  • I validated all the Acceptance Criteria. If possible, provide screenshots or videos.
  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I implemented built-in tests to cover the new/changed code.

Code style

  • I wrote a self-explanatory code about what it does.
  • I protected entry points against unexpected inputs.
  • I did not introduce unnecessary complexity.
  • Output messages (errors, notices, logs) are explicit enough for users to understand the issue and are actionnable.

@Miraeld Miraeld requested a review from a team February 12, 2025 02:09
@Miraeld Miraeld self-assigned this Feb 12, 2025
Copy link

codacy-production bot commented Feb 12, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-0.01% (target: -0.10%) 23.08% (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (5b018e4) 38787 17157 44.23%
Head commit (0914246) 38806 (+19) 17162 (+5) 44.23% (-0.01%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#7303) 26 6 23.08%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

@hanna-meda
Copy link
Contributor

@Miraeld, thank you for this PR.
We are missing the description. According to the Notion doc, this block, the description should be "Preload above-the-fold fonts to enhance layout stability and optimize text-based LCP elements. More info"
More info link: https://docs.wp-rocket.me/article/1317-preload-font
Also, the checkbox label should be "Preload fonts", note that the "f" in fonts should be lowercase. It's currently uppercase (@piotrbak to reconfirm this today).

@Miraeld Miraeld linked an issue Feb 12, 2025 that may be closed by this pull request
@Miraeld
Copy link
Contributor Author

Miraeld commented Feb 12, 2025

@hanna-meda Thanks for your feedback, I've just pushed a fix.

Note that Codacy will fail, that's normal, we are adding some front-end, and no tests are covering the front end.

Copy link
Contributor

@hanna-meda hanna-meda left a comment

Choose a reason for hiding this comment

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

All is looking good, @Miraeld.
testrail-report-703.pdf

@Miraeld Miraeld merged commit 3fb8689 into feature/preload-fonts Feb 14, 2025
11 of 13 checks passed
@Miraeld Miraeld deleted the enhancement/7239-user-interface branch February 14, 2025 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3.19 - Preload Fonts - User Interface part
3 participants