Rozmuar Classic Block Editing for Advanced Custom Fields
Rozmuar Classic Block Editing for Advanced Custom Fields
Description
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.
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.
Installation
- 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).
Faq
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 the script_loader_src filter. ACF’s own files are never written to.
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.
The plugin leaves the original ACF script completely untouched and displays
an admin notice, rather than guessing or applying a partial/incorrect patch.
Reviews
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.