Claude introduced PHP string escaping bug in CSS snippet, silently dropping entire dark theme on live site

Resolved 💬 3 comments Opened Apr 20, 2026 by marcelmarnix Closed Apr 23, 2026

Preflight Checklist

  • [x] I have searched existing issues for similar behavior reports
  • [x] This report does NOT contain sensitive information (API keys, passwords, etc.)

Type of Behavior Issue

Other unexpected behavior

What You Asked Claude to Do

I asked Claude to add a CSS rule to hide a Rank Math PRO upsell banner on my live WordPress site. The rule needed to target elements using attribute selectors: [id*="rank-math"][class*="cta"]. Claude added this rule to an existing PHP snippet (snippet 14) that echoes a large CSS block using PHP's echo "..."; double-quoted string syntax.

What Claude Actually Did

  1. Claude added the CSS selector [id*="rank-math"][class*="cta"] inside a PHP echo "..." double-quoted string
  2. The double quotes inside the attribute selectors ("rank-math" and "cta") prematurely terminated the PHP string
  3. This caused a PHP fatal error when the snippet executed
  4. The Code Snippets plugin auto-detects fatal errors and silently deactivates the offending snippet
  5. Snippet 14 — which contained the entire site dark theme — was deactivated with no visible error to the user
  6. The entire site reverted to a white/default theme on the live production site, visible to all visitors
  7. The failure was silent — no error page, no notification, just the theme disappearing

Expected Behavior

Claude should have recognized that the CSS snippet uses PHP echo "..." double-quoted string syntax, and that double quotes inside attribute selectors like [id*="rank-math"] will break the PHP string. The fix is trivial and known: use single quotes inside the CSS selectors — [id*='rank-math'][class*='cta']. Claude should either have applied this automatically or at minimum tested the PHP syntax before deploying to the live site.

Files Affected

WordPress Code Snippets plugin — Snippet 14 (global dark theme CSS, ~50 lines of PHP/CSS)
Live production site: marcelmarnix.com

Permission Mode

Accept Edits was ON (auto-accepting changes)

Can You Reproduce This?

Yes, every time with the same prompt

Steps to Reproduce

  1. Have a PHP snippet that outputs CSS using echo "..." double-quoted string syntax
  2. Ask Claude to add a CSS rule with attribute selectors containing double quotes, e.g. [id*="something"]
  3. Claude inserts the rule verbatim without escaping the inner double quotes
  4. PHP fatal error fires on the next request
  5. Code Snippets plugin silently deactivates the snippet
  6. All CSS from that snippet disappears from the site with no visible error

Claude Model

Sonnet

Relevant Conversation

Claude added: `[id*="rank-math"][class*="cta"]{display:none !important;}` inside `echo "<style>...";`

Result: PHP fatal error. Code Snippets auto-deactivated snippet 14. Entire dark theme dropped silently on live site.

Fix applied: Changed to single quotes: `[id*='rank-math'][class*='cta']` and reactivated snippet.

Impact

Critical - Data loss or corrupted project

Claude Code Version

claude-sonnet-4-6 (VSCode extension, session date 2026-04-19)

Platform

Anthropic API

Additional Context

  • The failure was completely silent from the user's perspective — no error shown, site appeared to "reset" visually
  • Claude had read the full snippet content before editing and could have seen the echo "..." pattern
  • This is a well-known PHP gotcha: double quotes inside double-quoted strings must be escaped or the string terminated
  • The correct approach is always to use single quotes inside CSS attribute selectors when the PHP string uses double quotes
  • This is one of 5 issues filed from the same session (2026-04-19) documenting Claude's mistakes on a live production WordPress site
  • Impact: entire dark theme dropped on live site, visible to all visitors, until manually diagnosed and fixed

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗