YS Editor Scope Wrapper
Apply CSS scope classes to WordPress Block Editor wrapper, so wrapper-scoped CSS that only exists on the frontend also works in the editor preview. Auto-detects candidates from posts.
by YANGSHEEP DESIGN · github.com/ya19880104/ys-editor-scope-wrapper · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/ya19880104/ys-editor-scope-wrapper/archive/refs/heads/main.zip中文版本: README.zh-TW.md
Apply CSS scope classes to the WordPress Block Editor wrapper and iframe canvas, so wrapper-scoped CSS that only exists on the frontend also works inside the editor preview.
The problem
Many page-builder workflows write CSS as .scope-class .xxx { ... }:
- On the frontend — the page builder (GreenShift / GL Page Builder / etc.) injects
<div class="scope-class">aroundthe_content, so.scope-class .xxxrules match. - In the Block Editor — that wrapper does not exist.
.editor-styles-wrapperhas noscope-classon it, so every wrapper-scoped rule becomes dead. The editor shows raw text, no fonts, no colors, no layout.
This plugin closes that gap.
What it does
On every Block Editor load:
- Reads the configured class list from
ys_editor_scope_classesoption. - Adds each class to
.editor-styles-wrapper(andiframe[name="editor-canvas"]body, for the new iframe canvas mode). - Uses
MutationObserverso iframe lazy-loading and editor remounting are handled.
The added classes are pure DOM additions — they are not written into post_content.
Auto-detection
The Settings screen automatically scans your published posts and surfaces candidate classes you can tick on/off:
| Source | What it picks up |
|---|---|
| Style Manager root class | The first dynamicGClasses[].value inside each `` block. |
| Inline ` |