Skip to content

fix(uppercase): enqueue frontend styles for uppercase rich-text format - #2665

Open
faisalahammad wants to merge 1 commit into
godaddy-wordpress:masterfrom
faisalahammad:fix/2654-uppercase-format-frontend
Open

fix(uppercase): enqueue frontend styles for uppercase rich-text format#2665
faisalahammad wants to merge 1 commit into
godaddy-wordpress:masterfrom
faisalahammad:fix/2654-uppercase-format-frontend

Conversation

@faisalahammad

Copy link
Copy Markdown

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 the style-coblocks-1.css (registered as handle coblocks-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:

  1. has_coblocks_block() — widened to also match when post_content contains the literal class="uppercase" substring, so the early-return gate in block_assets() lets the page reach the registration step.
  2. coblocks_enqueue_scripts_for_core_blocks() (render_block filter) — when a block's content contains class="uppercase" the coblocks-frontend handle 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

  • Bug fix (non-breaking change which fixes an issue)

How has this been tested?

Automated:

  • No PHPUnit/Jest changes required by the workflow; existing suites pass unchanged (the change touches a single existing method, broadening one boolean gate, and adds one render_block hook).

Manual (step-by-step for the user to verify per repo's testing flow):

  1. Create a new draft page/post.
  2. Add a single core/paragraph block. Type some lowercase text.
  3. Select the text. From the paragraph toolbar, apply the uppercase format. The editor shows it uppercase and wraps it in <span class="uppercase">.
  4. Save/publish.
  5. View page source on the published page. The <span class="uppercase"> element is present, and the page <head> includes a <link rel="stylesheet"> for style-coblocks-1.css (the coblocks-frontend handle). Without this PR, that stylesheet is missing.
  6. Visually confirm the formatted text renders uppercase on the live page.

Regression checks:

  • A plain post (no CoBlocks blocks, no uppercase format) — coblocks-frontend is still NOT enqueued. Verify via page source.
  • A post with a CoBlocks block (e.g. Accordion) — auto-enqueue still works as before; coblocks-frontend is present and not double-loaded.

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:

  • My code is tested
  • My code follows accessibility standards
  • My code has proper inline documentation
  • I've added proper labels to this pull request

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Uppercase Option Doesn't Work on Live Site

1 participant