Compatibility between ALR and GeneratePress footer element
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
As i reported that bug keeping myself updated with this comment :) thanks @alfonso100 !
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.
Scope a solution
- Add
'generatepress'to the compatibilities array in ThemeResolver.php - Create a new compatibility class GeneratePress.php implementing
Subscriber_Interfacewith a method to add.site-footerto ALR exclusions via therocket_lrc_exclusionsfilter - Register the new GeneratePress subscriber in SubscriberFactory.php with the appropriate class and arguments
Efforts S
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
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
We'll go with the no-wpr-lazyrender approach, see thread here