Editor stylesheet triggers "added to the iframe incorrectly" warnings in the editors

未关闭 适合新手
#31 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
css, php, wordpress
领域
frontend

调研方向

从 inc/Core.php 第 56 行开始,assets/css/build/editor.css 及其内联 Neve 变量在 enqueue_block_editor_assets 上被 enqueue。然后检查已经声明支持 editor-styles 的主题设置 hook,因为修复会通过 add_editor_style() 把注册移到那里(或移到由 is_admin() 保护的 enqueue_block_assets 上),并将内联 CSS 保持在同一个 handle 上。完成的标准是:在开启 SCRIPT_DEBUG 的情况下加载区块编辑器和站点编辑器,并且在编辑器样式仍然生效的同时不显示 "added to the iframe incorrectly" 警告。

由索引模型根据 Issue 内容生成。

描述

bug
Description

The theme's editor stylesheet is added the outdated way, so every time the block editor or the Site Editor opens, the browser console shows:

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

inc/Core.php line 56 enqueues assets/css/build/editor.css (and the Neve-inherited inline CSS attached to it) on enqueue_block_editor_assets. That hook loads assets for the editor's outer page, not the iframed canvas. WordPress copies the styles into the canvas for now, and warns that this fallback is going away. Once it does, the editor would lose the theme's editor styles.

Step-by-step reproduction instructions
  1. With Eduacademy 1.0.1 active and SCRIPT_DEBUG on (the warning prints with development scripts), open any page in the block editor, or Appearance → Editor.
  2. Open the browser console.

Expected: no warning about Eduacademy's styles.
Actual: the two "added to the iframe incorrectly" warnings above, on every editor load.

Screenshots, screen recording, code snippet or Help Scout ticket

Fix suggestion: register the editor stylesheet for the canvas with add_editor_style() on after_setup_theme (the theme already declares editor-styles support). Alternatively, enqueue it on enqueue_block_assets guarded by is_admin(), and attach the inline Neve variables to that handle.

Found while adding Eduacademy to the WordPress compatibility checks (Codeinwp/qa-compatibility#168). The warning shows on WordPress 7.0.9, 7.1-RC1 and 7.1.5 alike.

Environment info

Eduacademy 1.0.1 (built from the v1.0.1 tag), WordPress 7.0.9 / 7.1-RC1 / 7.1.5, PHP 8.3, SCRIPT_DEBUG on, Chromium.

Is the issue you are reporting a regression

No

主要语言
PHP
星标
0
派生
0
平均合并
22 小时 12 分钟
30 天内合并 PR
6

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Codeinwp/eduacademy 的其他 Issue

查看 Codeinwp/eduacademy 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。