Editor stylesheet is loaded on `enqueue_block_editor_assets`; WordPress warns "fork-editor-css was added to the iframe incorrectly"

Offen Anfängerfreundlich
#120 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
82/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
css, php, wordpress
Bereich
frontend

Rechercherichtung

Beginne in inc/Core.php bei der Methode add_editor_styles() um Zeile 107, die assets/css/build/editor.css bei enqueue_block_editor_assets einbindet; lies auch setup(), wo die Unterstützung für editor-styles deklariert wird. Wähle zwischen dem Registrieren des Stylesheets mit add_editor_style() und dem Verschieben des Enqueue-Vorgangs nach enqueue_block_assets mit einer Admin-Prüfung, und behalte dabei die RTL-Datei im Blick. Fertig bedeutet, dass die Konsolenwarnung bei aktiviertem SCRIPT_DEBUG verschwunden ist und die Editor-Canvas für Überschriften, Buttons, Zitate, Suche und neueste Beiträge weiterhin mit dem Frontend übereinstimmt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

What's wrong

Every time the post editor or the Site Editor opens, with SCRIPT_DEBUG on, the browser console shows:

fork-editor-css was added to the iframe incorrectly. Please use block.json or enqueue_block_assets to add styles to the iframe.

Today WordPress still copies the stylesheet into the editor iframe, so Fork's editor styling works. The warning means that copying is a compatibility fallback. If WordPress removes it, the editor canvas loses Fork's editor styles (fonts, buttons, latest posts and the rest of assets/css/build/editor.css).

Cause

inc/Core.php enqueues the editor stylesheet with wp_enqueue_style() on enqueue_block_editor_assets (add_editor_styles(), line 107). That hook is meant for the editor's own UI, outside the iframe.

Steps to reproduce
  1. On a site with SCRIPT_DEBUG on and Fork active, open any page in the editor, or open Appearance → Editor.
  2. Open the browser console.

Expected: no warning about fork-editor-css.
Actual: the warning above, once per editor load. Seen on WordPress 6.7.12, 6.8, 7.1.5 and 7.2-RC2.

Suggested fix

Either:

  • register it as an editor style: add_editor_style( 'assets/css/build/editor.css' ) in setup() (Fork already declares add_theme_support( 'editor-styles' )), keeping the RTL file in mind; or
  • enqueue it on enqueue_block_assets with an is_admin() check, so it goes into the iframe the supported way.

Afterwards, check that the editor canvas still matches the front end (headings, list items, table cells, quotes, buttons, search and latest posts).

Vorherrschende Sprache
PHP
Sterne
0
Forks
0
Ø Merge
1 Std. 2 Min.
Gemergte PRs (30 T.)
5

Entwicklungsumgebung

  • Kein Dockerfile und keine Docker-Compose-Datei
  • Hat eine Pull-Request-Vorlage
  • Kein Beitragsleitfaden

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus Codeinwp/fork

Alle Issues in Codeinwp/fork

Ähnliche Issues

Weitere Issues zu PHP

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.