wp-rocket icon indicating copy to clipboard operation
wp-rocket copied to clipboard

Compatibility between ALR and GeneratePress footer element

Open alfonso100 opened this issue 10 months ago • 6 comments

Is your feature request related to a problem? Please describe. GeneratePress theme uses a generic class for their site footer class="site-footer" and we are having some cases where this has conflicts with ALR, such as missing images, or late loading of the footer element.

https://i.imgur.com/J0TsK0K.png

Describe the solution you'd like @DahmaniAdame suggested we could automatically detect GeneratePress and add a class to theclass="site-footer" element:

They have this hook - https://docs.generatepress.com/article/generate_footer_class/ that can add additional classes, let's say no-wpr-lazyrender that we can either add to the backend to skip adding the footer: class="site-footer no-wpr-lazyrender".

Describe alternatives you've considered

  • Add DOM conditions to the ALR backend, where we can add a DOM condition to cover cases like these.
  • ALR disabled by default, and only enable it using a UI checkbox?

Additional context Slack thread: https://group-onecom.slack.com/archives/C08EFUGUH5G/p1741790267057259 HS tickets (thanks @girlie !): https://secure.helpscout.net/search/?query=tag%3Awpr%20automatic%20lazy%20rendering%20generatepress HS ticket, specific for this case: https://secure.helpscout.net/conversation/2873474700/545516?viewId=2683093

As a temporary fix, we added class="site-footer" to the ALR exclusions, this should be revisited once we get more info on this issue

Acceptance Criteria

  • Add a compatibility file for GeneratePress to exclude the footer

alfonso100 avatar Mar 12 '25 19:03 alfonso100

As i reported that bug keeping myself updated with this comment :) thanks @alfonso100 !

masteradhoc avatar Mar 12 '25 19:03 masteradhoc

I have also encountered issues with the default TwentyTwentyFive theme and the footer not loading altogether on mobile devices unless I add an exclusion for the footer element via the rocket_lrc_exclusions filter.

ethanclevenger91 avatar Dec 03 '25 22:12 ethanclevenger91

Scope a solution

  • Add 'generatepress' to the compatibilities array in ThemeResolver.php
  • Create a new compatibility class GeneratePress.php implementing Subscriber_Interface with a method to add .site-footer to ALR exclusions via the rocket_lrc_exclusions filter
  • Register the new GeneratePress subscriber in SubscriberFactory.php with the appropriate class and arguments

Efforts S

Miraeld avatar Dec 11 '25 06:12 Miraeld

LGTM

@Miraeld What do you think about the generic approach that @alfonso100 stated in the issue suggested by @DahmaniAdame. The only change to your grooming will be to hook a callback to generatepress filter that will add no-wpr-lazyrender class.

add_filter('generate_footer_class', function($class) {
	$class[] = 'no-wpr-lazyrender';
	return $class;
});

The on our backend, we only need to add no-wpr-lazyrender to the exclusion list, This can be done for another theme/plugin.

In my opinion both are ok for me, but I'm not sure if this is a product decision.

CC @DahmaniAdame @wordpressfan

jeawhanlee avatar Dec 11 '25 11:12 jeawhanlee

Both would fix it. I would favor the class one to showcase the exclusion using the no-wpr-lazyrender class for other devs to use when they know an element needs to excluded.

Up to @wordpressfan

DahmaniAdame avatar Dec 11 '25 11:12 DahmaniAdame

We'll go with the no-wpr-lazyrender approach, see thread here

jeawhanlee avatar Dec 11 '25 12:12 jeawhanlee