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

Đang mở Phù hợp với người mới
#120 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
css, php, wordpress
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu trong inc/Core.php tại phương thức add_editor_styles() khoảng dòng 107, phương thức này đưa assets/css/build/editor.css vào hàng đợi trên enqueue_block_editor_assets; cũng hãy đọc setup() nơi hỗ trợ editor-styles được khai báo. Chọn giữa việc đăng ký stylesheet bằng add_editor_style() và chuyển việc đưa vào hàng đợi sang enqueue_block_assets kèm kiểm tra admin, lưu ý đến tệp RTL. Hoàn tất nghĩa là cảnh báo console đã biến mất khi bật SCRIPT_DEBUG và canvas của trình soạn thảo vẫn khớp với front end đối với tiêu đề, nút, trích dẫn, tìm kiếm và bài viết mới nhất.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
PHP
Star
0
Fork
0
Merge trung bình
1 giờ 2 phút
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Codeinwp/fork

Tất cả issue của Codeinwp/fork

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.