Skip to content

Conversation

@jeawhanlee
Copy link
Contributor

Description

Fixes #7357
Fix footer layout issue for Generate Press theme by adding a generic exclusion class to exclude from ALR

Type of change

  • Bug fix (non-breaking change which fixes an issue).

Detailed scenario

What was tested

  • Install & Activate Generate Press
  • Inspect element and look for site-footer
  • See that no-wpr-lazyrender is also added to the class

NB: We need to add no-wpr-lazyrender to the lists of exclusions for ALR in the backend to see the exclusion take effect.

How to test

Same as what was tested.

Technical description

Documentation

Add a 3rd party compatibility class to cater for adding generic class to exclude element from ALR.

New dependencies

N/A

Risks

N/A

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.

Unticked items justification

Not applicable to the changes in this PR.

Additional Checks

  • In the case of complex code, I wrote comments to explain it.
  • When possible, I prepared ways to observe the implemented system (logs, data, etc.).
  • I added error handling logic when using functions that could throw errors (HTTP/API request, filesystem, etc.)

@jeawhanlee jeawhanlee self-assigned this Dec 12, 2025
@codacy-production
Copy link

codacy-production bot commented Dec 12, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 9e90f2b1 0.00% (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (9e90f2b) Report Missing Report Missing Report Missing
Head commit (a17b774) 41889 18886 45.09%

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 (#7954) 11 0 0.00%

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

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@jeawhanlee jeawhanlee marked this pull request as ready for review December 12, 2025 20:55
@jeawhanlee jeawhanlee requested a review from a team December 12, 2025 20:55
@Miraeld Miraeld requested a review from Copilot December 15, 2025 02:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds GeneratePress theme compatibility to fix a footer layout issue with WP Rocket's Above the Fold Lazy Render (ALR) optimization. The fix adds the no-wpr-lazyrender exclusion class to GeneratePress footer elements, preventing them from being lazy-rendered and resolving layout problems.

Key changes:

  • New GeneratePress subscriber that hooks into generate_footer_class filter to inject exclusion class
  • Theme registration in ThemeResolver and SubscriberFactory to enable automatic subscriber instantiation
  • Integration tests with theme-loading infrastructure for test isolation

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
inc/ThirdParty/Themes/GeneratePress.php New subscriber implementing the exclusion class injection via the generate_footer_class filter
inc/ThirdParty/Themes/ThemeResolver.php Adds 'generatepress' to compatibilities array and fixes 'minimalistblogger' naming consistency
inc/ThirdParty/Themes/SubscriberFactory.php Registers GeneratePress subscriber in factory pattern and fixes 'minimalistblogger' case consistency
tests/Integration/inc/ThirdParty/Themes/GeneratePress/injectExclusionsClass.php Integration test validating the filter adds exclusion class to footer classes
tests/Fixtures/inc/ThirdParty/Themes/GeneratePress/injectExclusionsClass.php Test fixture data defining expected behavior
tests/Fixtures/inc/ThirdParty/Themes/themes.php New fixture mapping test groups to theme slugs for automated theme switching
tests/Integration/bootstrap.php Adds theme-loading logic based on test groups and removes unrelated blank line
composer.json Adds GeneratePress to excluded test groups and creates dedicated test command

- Add declare(strict_types=1) to GeneratePress.php as required by WP Rocket coding standards for new PHP files
- Rename test class from Test_injectExclusionsClass to Test_InjectExclusionsClass to follow PEAR naming conventions
- Add comprehensive PHPDoc with parameter documentation to test method
- Add phpcs:ignore comment for third-party hook name from GeneratePress theme

Addresses Copilot review feedback from PR #7954
@Miraeld
Copy link
Contributor

Miraeld commented Dec 16, 2025

Review Feedback Addressed

All Copilot review comments have been addressed in commit a17b774:

1. Missing declare(strict_types=1) - FIXED

Review: #7954 (comment)

  • Added declare(strict_types=1); to GeneratePress.php
  • Follows WP Rocket coding standards for new PHP files
  • Consistent with other modern theme compatibility classes (Flatsome, Uncode, Xstore)

2. Test Documentation - IMPROVED

Review: #7954 (comment)

  • Renamed class from Test_injectExclusionsClass to Test_InjectExclusionsClass (PEAR naming conventions)
  • Added comprehensive PHPDoc with method description and parameter tags
  • Added phpcs:ignore comment for third-party hook name from GeneratePress theme
  • Test properly validates the filter integration (theme is auto-loaded via bootstrap.php with @group GeneratePress)

Verification

  • All tests pass: composer run test-integration-generatepress
  • PHPCS compliant: No coding standard violations
  • PHPStan compliant: No static analysis issues

@hanna-meda
Copy link
Contributor

Hi @jeawhanlee,

Thanks for the PR. I tested it and noticed this:

GeneratePress now adds no-wpr-lazyrender to site-footer, but the element still gets hashed and ends up with data-wpr-lazyrender="1" even though class="site-footer" is in our exclusions list.
Screenshot 2025-12-16 at 20 23 43
Screenshot 2025-12-16 at 20 23 09

Adding class="no-wpr-lazyrender" to the exclusions didn’t stop the hashing. It only worked when I added class="no-wpr-lazyrender site-footer" explicitly.
Result with the current PR:

<div data-wpr-lazyrender="1" class="no-wpr-lazyrender site-footer">

Should the generic exclusion class="no-wpr-lazyrender" be enough, or do we need to require the combined selector class="no-wpr-lazyrender site-footer" for this to work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compatibility between ALR and GeneratePress footer element

4 participants