fix(uppercase): enqueue frontend styles for uppercase rich-text format - #2665
Open
faisalahammad wants to merge 1 commit into
Open
fix(uppercase): enqueue frontend styles for uppercase rich-text format#2665faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
When the uppercase RichText format is applied to a core/paragraph block,
the saved HTML contains <span class="uppercase"> but the CSS rule
(.uppercase { text-transform: uppercase }) in style-coblocks-1.css was
not loaded on the frontend. Two changes:
- Widens has_coblocks_block() to pass the block_assets gate when
post_content contains the uppercase format marker. This ensures
coblocks-frontend is registered for the affected page.
- Adds a render_block filter check that enqueues coblocks-frontend
when a rendered block's content contains class="uppercase".
Fixes godaddy-wordpress#2654
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.
Description
When a user applies the uppercase rich-text format on a core block (e.g. core/paragraph), the editor wraps the selected text in a
<span class="uppercase">. The CSS rule that makes it visually uppercase (.uppercase { text-transform: uppercase }) lives in thestyle-coblocks-1.css(registered as handlecoblocks-frontend), but the handle was never enqueued on pages that don't include a CoBlocks block. Result: the markup is saved, the CSS rule doesn't load, the live site renders lowercase.Two changes in
includes/class-coblocks-block-assets.php:has_coblocks_block()— widened to also match whenpost_contentcontains the literalclass="uppercase"substring, so the early-return gate inblock_assets()lets the page reach the registration step.coblocks_enqueue_scripts_for_core_blocks()(render_block filter) — when a block's content containsclass="uppercase"thecoblocks-frontendhandle is enqueued for the page. Idempotent across multiple matches.Both insertions follow patterns already used in the same file (strpos for the coblocks marker; render_block enqueue mirrors the lightbox and gist cases).
Closes #2654
Screenshots
Not applicable — no UI design changes; the live site now displays text in uppercase.
Types of changes
How has this been tested?
Automated:
Manual (step-by-step for the user to verify per repo's testing flow):
core/paragraphblock. Type some lowercase text.<span class="uppercase">.<span class="uppercase">element is present, and the page<head>includes a<link rel="stylesheet">forstyle-coblocks-1.css(the coblocks-frontend handle). Without this PR, that stylesheet is missing.Regression checks:
Acceptance criteria
A core/paragraph (or any core RichText-bearing block) with the uppercase rich-text format applied now renders uppercase on the live site. No regression to existing CoBlocks block enqueue behavior. No new stylesheets added to non-affected pages.
Checklist: