Description
English below. Русское описание — ниже, после английского.
English
On some WordPress builds the block-editor canvas is always rendered inside
<
iframe name=”editor-canvas”>, instead of only for block themes, non-desktop
previews, or apiVersion 3+ blocks as it used to be. Advanced Custom Fields
(ACF) itself contains a check for that iframe and, whenever it finds one,
unconditionally forces every ACF block into read-only Preview mode and hides
the classic “Switch to Edit / Switch to Preview” toolbar button — regardless
of the block’s own acf_block_version.
This plugin restores that classic toggle without modifying any ACF or
WordPress core file on disk, using three independent, individually toggleable
fixes:
- Patch ACF’s iframe detection at runtime. Serves a runtime-patched copy
of ACF’s own block-editing script (generated on demand, cached in the
uploads directory, auto-regenerated whenever ACF is updated) with the
iframe-detection function neutralized. - Cap ACF’s own “Block Version 3” down to 2. Separately, ACF’s own
“Block Version 3” (“Open Expanded Editor” modal) replaces the classic
toggle with a different UI entirely; this optionally downgrades blocks
back to Version 2 so they use the (now fixed) classic component. - Cross-document companion fixes. Once the ACF field form renders inside
the canvas iframe again, several things that only worked because the
canvas and the rest of wp-admin used to be one document need bridging:
repeater/flexible-content row tooltips, select2 dropdown positioning, and
the WYSIWYG (TinyMCE/Quicktags) field, plus loading ACF’s own admin styles
into the canvas so the form isn’t left unstyled.
All three fixes are configurable under Settings Classic Block Editing for ACF,
and every fallback path is safe: if the expected code can’t be located inside
ACF’s script (for example after an ACF update changes its build), the plugin
leaves the original script untouched and shows an admin notice instead of
silently mis-patching anything.
The iframe-detection patch and companion cross-document fixes are adapted
from the open-source plugin
Block Edit Mode for ACF
by Bakhodir Sharipov (GPLv2 or later), which solves the identical problem.
Русский
На некоторых сборках WordPress канвас редактора блоков всегда рендерится
внутри <iframe name="editor-canvas"> — а не только для блочных тем,
мобильного превью или блоков с apiVersion 3+, как было раньше. В самом
Advanced Custom Fields (ACF) есть проверка на этот iframe: обнаружив его,
ACF безусловно переводит каждый ACF-блок в режим «только просмотр» (Preview)
и прячет классическую кнопку-переключатель «Switch to Edit / Switch to
Preview» на панели инструментов блока — независимо от его собственного
acf_block_version.
Плагин возвращает этот классический переключатель, не изменяя ни одного
файла ACF или ядра WordPress на диске, тремя независимыми фиксами (каждый
включается и отключается отдельно):
- Патч детектора iframe в ACF во время выполнения. Отдаёт пропатченную
копию собственного блочного скрипта ACF (создаётся по запросу, кэшируется
в папке uploads, автоматически пересобирается при каждом обновлении ACF)
с обезвреженной функцией-детектором iframe. - Понижение собственной «Block Version 3» ACF до 2. Отдельно: «Block
Version 3» в ACF (модальное окно «Open Expanded Editor») заменяет
классический переключатель совершенно другим интерфейсом; этот фикс по
желанию понижает блоки обратно до Version 2, чтобы они использовали (уже
исправленный) классический компонент. - Кросс-документные сопутствующие правки. Когда форма полей ACF снова
рендерится внутри canvas-iframe, через границу iframe перестаёт работать
ряд вещей, которые раньше работали лишь потому, что канвас и остальная
часть wp-admin были одним документом: тултипы строк
повторителя/flexible-content, позиционирование выпадающих списков select2
и поле WYSIWYG (TinyMCE/Quicktags), плюс подгрузка собственных
admin-стилей ACF в канвас, чтобы форма не осталась без оформления.
Все три фикса настраиваются в «Настройки Classic Block Editing for ACF»,
и каждый запасной путь безопасен: если ожидаемый код не удаётся найти
внутри скрипта ACF (например, после обновления ACF изменился его сборочный
результат), плагин оставляет исходный скрипт нетронутым и показывает
уведомление в консоли администратора — вместо тихого неправильного патча.
Патч детектора iframe и кросс-документные правки адаптированы из открытого
плагина
Block Edit Mode for ACF
Bakhodir Sharipov (GPLv2 или новее), который решает ту же задачу.
Installation
English
- Upload the plugin files to the
/wp-content/plugins/rozmuar-classic-block-editing-for-acf
directory, or install the plugin through the WordPress plugins screen
directly. - Activate the plugin through the ‘Plugins’ screen in WordPress.
- Optionally configure the three fixes under Settings Classic Block
Editing for ACF (all three are enabled by default).
Русский
- Загрузите файлы плагина в папку
/wp-content/plugins/rozmuar-classic-block-editing-for-acf или установите
плагин прямо через экран «Плагины» в WordPress. - Активируйте плагин на экране «Плагины».
- При необходимости настройте три фикса в «Настройки Classic Block
Editing for ACF» (все три включены по умолчанию).
FAQ
-
Why does this need to patch ACF’s script instead of using a filter?
-
The iframe-detection function lives entirely inside ACF’s own compiled,
minified JavaScript bundle with no PHP-side filter or JS hook exposed for it.
The only way to change its behavior is to modify the JavaScript itself, which
this plugin does at runtime, on a cached copy, without ever touching ACF’s
files on disk. -
Does this modify ACF’s plugin files?
-
No. It reads ACF’s currently-registered script, writes a patched copy to
wp-content/uploads/acf-classic-block-editing/, and serves that copy instead
via thescript_loader_srcfilter. ACF’s own files are never written to. -
What happens when ACF releases an update?
-
The cached patched copy is keyed by the source file’s path, modification
time and size, so it is regenerated automatically the next time the editor
loads after an ACF update. -
What if the patch can’t find the expected code?
-
The plugin leaves the original ACF script completely untouched and displays
an admin notice, rather than guessing or applying a partial/incorrect patch. -
Почему плагин патчит скрипт ACF, а не использует фильтр?
-
Функция-детектор iframe целиком находится внутри скомпилированного
минифицированного JS-бандла ACF, и для неё не предусмотрено ни PHP-фильтра,
ни JS-хука. Единственный способ изменить её поведение — менять сам
JavaScript, что плагин и делает во время выполнения, на кэшированной копии,
ни разу не трогая файлы ACF на диске. -
Изменяет ли плагин файлы ACF?
-
Нет. Он читает зарегистрированный скрипт ACF, пишет пропатченную копию в
wp-content/uploads/acf-classic-block-editing/ и отдаёт её вместо оригинала
через фильтрscript_loader_src. В файлы самого ACF запись никогда не
ведётся. -
Что происходит при обновлении ACF?
-
Ключ кэша пропатченной копии складывается из пути, времени изменения и
размера исходного файла, поэтому копия автоматически пересобирается при
первой же загрузке редактора после обновления ACF. -
Что если патч не находит ожидаемый код?
-
Плагин полностью оставляет исходный скрипт ACF нетронутым и показывает
уведомление в админке — вместо догадок или частичного/неверного патча.
Reviews
There are no reviews for this plugin.
Contributors & Developers
“Rozmuar Classic Block Editing for Advanced Custom Fields” is open source software. The following people have contributed to this plugin.
ContributorsTranslate “Rozmuar Classic Block Editing for Advanced Custom Fields” into your language.
Interested in development?
Browse the code, check out the SVN repository, or subscribe to the development log by RSS.
Changelog
4.5.0
- Renamed to “Rozmuar Classic Block Editing for Advanced Custom Fields” and
changed the slug/text domain torozmuar-classic-block-editing-for-acf,
per the WordPress.org review team’s note that a third-party integration
needs a distinctive name of its own ahead of “… for Advanced Custom
Fields” — “Classic Block Editing for Advanced Custom Fields” (4.4.0) still
led with the ACF name once “for” was dropped. This is the permalink to be
assigned for the plugin’s WordPress.org listing. No functional changes.
4.4.1
- Corrected 4.4.0: the slug/text domain is
acf-classic-block-editing,
already assigned by WordPress.org, and was never meant to change — an
in-progress edit briefly changed it toclassic-block-editing-for-acf
before this release. Reverted the Text Domain header, every
__()/esc_html_e()domain argument, the cache directory, and the
enqueued script/style handle names back toacf-classic-block-editing.
The display name introduced in 4.4.0 is unaffected.
4.4.0
- Renamed the displayed plugin name from “ACF Classic Block Editing” to
“Classic Block Editing for Advanced Custom Fields”, per the WordPress.org
review team’s trademark note on the “ACF”-first name. The slug/text domain
(acf-classic-block-editing), already assigned by WordPress.org, is
unchanged. No functional changes.
4.3.0
- FIX 1b: type-guard ACF’s block
.formvalue in the runtime JS patch. ACF
PRO ships.formas a boolean while its own bundle treats it as a string,
which crashed every ACF block (“This block has encountered an error”) and
printed a stray “true” in the block sidebar once the iframe detection was
neutralized. The mismatched value is now coerced to an empty string. - FIX 2b: force
mode = 'edit'when a block is capped to the classic UI, so
the Edit/Preview toolbar button reappears (it is hidden whenevermode
resolves to"auto"). Overridable via the
acf_classic_block_editing_forced_mode filter. - FIX 2c: also cap
api_versionfor PHP block registrations, and move that
adjustment out from behind anacf_block_version >= 3check that never
passed for JSON-registered blocks. - FIX 2d: cap
acf.blockVersion/acf.modein the rawblock.json
metadata (block_type_metadata, priority 5) before ACF reads it, so the
client-side editor and the server agree and the classic toggle component
is mounted instead of the Block Version 3 “Expanded Editor”. - The patched-script cache key now includes a patch-revision constant so
plugin logic changes force a rebuild of the cached copy. - The failed-patch admin notice now distinguishes Fix 1 from Fix 1b, and a
partially patched copy is served when at least one patch applied.
4.0.1
- Shortened the readme short description to fit the 150-character limit.
- Removed “Compat” from the plugin name so the slug matches the already-used
acf-classic-block-editing text domain (fixes a TextDomainMismatch check).
4.0.0
- Added cross-document companion fixes (repeater/flexible-content tooltips,
select2 positioning, WYSIWYG/TinyMCE field, canvas styling) adapted from
Block Edit Mode for ACF by Bakhodir Sharipov. - Hardened the iframe-detection regex to tolerate different quoting styles.
3.0.0
- Switched the primary fix to a runtime patch of ACF’s own iframe-detection
function, which is the actual mechanism hiding the Edit/Preview toggle.
2.0.0
- Added capping of ACF’s Block Version 3 down to Version 2.
1.0.0
- Initial release: block-editor canvas iframe compatibility bridge.
