Enhancement: Block themes inherit their own Learning Mode styles - #8083
Open
faisalahammad wants to merge 3 commits into
Open
Enhancement: Block themes inherit their own Learning Mode styles#8083faisalahammad wants to merge 3 commits into
faisalahammad wants to merge 3 commits into
Conversation
Block themes were forced to load learning-mode-compat.css, which overrides their fonts, type scale, and colors so Learning Mode looks the same everywhere. Skip that stylesheet for block themes so they inherit their own styles from theme.json. Classic themes (Divi, Astra, and others) keep the compatibility styles. Themes declaring sensei-learning-mode support are still skipped as before. Fixes Automattic#7449
…ck-theme-lm-styles
Use Sensei_File_System_Helper trait methods instead of mkdir, unlink and rmdir to satisfy the WordPress filesystem alternatives PHPCS rules.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Learning Mode loads
learning-mode-compat.cssto force its own fonts, type scale, and colors so it looks consistent across all themes. On block themes that overrides the active theme'stheme.json, which is not what we want. This skips that stylesheet on block themes (and on themes that already declaresensei-learning-modesupport) so they inherit their own styles. Classic themes (Divi, Astra, and others) keep the compatibility styles as before.Closes #7449
Changes
Learning Mode style loading
Before:
After:
New helper in
includes/course-theme/class-sensei-course-theme-option.php:Why:
Sensei_Utils::is_fse_theme()wrapswp_is_block_theme(). Block themes already ship their owntheme.jsonstyles, so the compatibility overrides are only needed for classic themes.Testing
Test 1: block theme inherits its own styles
Result:
learning-mode-compat.cssis not loaded. Typography and colors follow the active theme.Test 2: classic theme still gets compatibility styles
Result:
learning-mode-compat.cssis loaded and Learning Mode looks the same as before.Test 3: automated
make test-php-filter FILTER="Sensei_Course_Theme_Option_Test".Result: all tests pass, including the three new tests covering the helper (classic + no support loads, support declared skips, block theme skips).
Notes
This is a visual change for existing block-theme sites: Learning Mode will start matching the theme's design instead of Sensei's default. That is the behavior requested in the issue.
Per the issue's own consideration, this applies to all installs. If a site needs the old behavior, its theme can avoid the change by staying a classic theme.