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

Closes #6367 Add theme resolver for compatibility classes

Open remyperona opened this issue 1 year ago • 5 comments

Description

Replace current instantiation of themes compatibility classes from loading them all, to only loading the one corresponding to the current theme (if it exists).

Fixes #6367

Type of change

  • Enhancement (non-breaking change which improves an existing functionality).

Checklists

Generic development checklist

  • [x] My code follows the style guidelines of this project, with adapted comments and without new warnings.
  • [x] I have added unit and integration tests that prove my fix is effective or that my feature works.
  • [x] The CI passes locally with my changes (including unit tests, integration tests, linter).

Test summary

  • [x] I triggered all changed lines of code at least once without new errors/warnings/notices.
  • [ ] I validated all Acceptance Criteria of the related issues. (If applicable, provide proof).
  • [ ] I validated all test plan the QA Review asked me to.

remyperona avatar Jan 17 '24 21:01 remyperona

@Tabrisrp Thanks for the PR. using the helper plugin and trying those steps 3 times, can see small improvement on the PR (instead of global time 54.80ms it is 52.71ms). However, can see UI regression in this scenario https://wpmediaqa.testrail.io/index.php?/tests/view/41471&group_by=cases:section_id&group_id=709&group_order=asc on trunk: trunk.webm on PR: branch.webm Update After discussion with @piotrbak and further investigation on rocketlabs site, the preview image is applied to FE. can you please check?

Mai-Saad avatar Feb 14 '24 12:02 Mai-Saad

@Tabrisrp If I understand the old code correctly, the callback maybe_disable_youtube_preview listened to the switch_theme hook to catch when Divi was becoming the new theme. And bailed out otherwise.

Now maybe, if we are in another theme and switching to Divi, the callback is not registered since the Divi compat is not loaded so nothing happens. On the other hand, when switching from the Divi theme, we don't bail out from the callback anymore as the condition has been removed. As a result, we apply the option restriction to the new theme.

If my understanding is correct, the issue is well described here: https://developer.wordpress.org/reference/hooks/switch_theme/ Have you considered using after_switch_theme instead?

MathieuLamiot avatar Feb 14 '24 21:02 MathieuLamiot

Tested with after_switch_theme, it's working, updated the code to reflect

remyperona avatar Feb 15 '24 20:02 remyperona

Nice!

MathieuLamiot avatar Feb 16 '24 07:02 MathieuLamiot

working fine now

Mai-Saad avatar Feb 16 '24 12:02 Mai-Saad