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

オープン 初心者向け
#120 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
css, php, wordpress
領域
frontend

調査の方向性

inc/Core.php の 107 行目あたりにある add_editor_styles() メソッドから始めてください。このメソッドは enqueue_block_editor_assets で assets/css/build/editor.css をエンキューします。また、editor-styles のサポートが宣言されている setup() も読んでください。スタイルシートを add_editor_style() で登録する方法と、エンキューを管理画面チェック付きで enqueue_block_assets に移動する方法のどちらかを選び、RTL ファイルを念頭に置いてください。完了とは、SCRIPT_DEBUG を有効にした状態でコンソール警告が消え、見出し、ボタン、引用、検索、最新投稿についてエディターのキャンバスが引き続きフロントエンドと一致していることです。

索引モデルが issue の本文から書いたものです。

説明

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).

主要言語
PHP
スター
0
フォーク
0
平均マージ
1時間 2分
マージ済み PR(30日)
5

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Codeinwp/fork のほかの issue

Codeinwp/fork の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。