=== TwoTen Inline Canvas for ACF Blocks ===
Contributors: carmex
Tags: acf, blocks, block editor, iframe, editor
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.4.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Restores the non-iframed block editor canvas on WordPress 7.1+ so ACF PRO blocks render their field forms inline in the canvas (edit mode).

== Description ==

WordPress 7.1 renders the post editor canvas inside an iframe on every
post, unconditionally. ACF PRO cannot initialise its field forms inside
that iframe, so from 7.1 every ACF block is forced into preview mode with
its fields squeezed into the right-hand sidebar — the familiar inline
"edit mode" disappears.

WordPress 7.1 still ships the old non-iframed canvas rendering path; core
just stopped using it. This plugin serves a copy of the `wp-editor` script
bundle with the single flag that controls this flipped
(`shouldIframe: true` becomes `false`), which restores the pre-7.1
editing experience: ACF block fields render inline in the main canvas,
full width, with working WYSIWYG, media pickers and repeaters.

**Safety properties**

* No core files are modified on disk. The patched copy lives in
  `wp-content/uploads/twoten-inline-canvas/` and core stays pristine
  (`wp core verify-checksums` passes).
* Scoped: only `post.php` / `post-new.php` receive the patched bundle.
  The site editor — which requires the iframe — and all other admin
  screens get stock WordPress.
* Self-healing: the patched copy is keyed to the WordPress version and
  bundle mtime, so it regenerates automatically after every core update.
* Fail-safe: the patch is only applied when the flag appears exactly once
  in the bundle. If a future WordPress changes that code, the plugin
  serves the stock bundle and the editor simply returns to the iframed
  canvas — nothing breaks.
* Does nothing at all on WordPress below 7.1 (safe to install ahead of an
  upgrade) and when `SCRIPT_DEBUG` is enabled.

**Block requirements**

Inline edit mode is an ACF Blocks v2 behaviour. ACF PRO 6.8+ defaults
`block.json` blocks to v3 on WordPress 7.1+, which removes edit mode by
design (iframe or not) — every block becomes a preview with an
"Edit Block" modal. This plugin therefore pins the default back to v2
via ACF's `acf/blocks/default_block_version` filter. Your blocks should:

* not set `"blockVersion": 3` explicitly in `block.json` (an explicit
  value is respected and keeps that block in v3);
* set `"acf": { "mode": "edit" }` (and ideally `"supports": { "mode": false }`)
  so blocks open as forms rather than previews.

Blocks saved while stuck in preview mode carry `"mode":"preview"` in their
saved markup, which overrides the block default. For blocks whose mode
toggle is hidden (`"supports": { "mode": false }`) the plugin resets that
to the block's configured mode when the post is parsed in the editor, and
the content self-heals on the next save. Blocks that allow toggling keep
the saved choice. To clean everything in one go instead:

`wp search-replace '"mode":"preview"' '"mode":"edit"' wp_posts --include-columns=post_content`

**Updates**

Updates are delivered through the WordPress.org plugin directory like any
other plugin. Updates do not apply when the file is run as a must-use
plugin.

**When to remove this plugin**

This is a compatibility shim, not a permanent architecture. Remove it once
ACF PRO supports field editing inside the iframed canvas — check the ACF
changelog before major WordPress upgrades. After any WordPress core
update, open a post in the editor and confirm blocks still show inline
forms; if the fail-safe has kicked in they will show previews again, and
the plugin needs a new patch pattern for that WordPress version.

**Disabling programmatically**

`add_filter( 'tts_inline_canvas_enabled', '__return_false' );`

== Installation ==

1. Upload the `twoten-inline-canvas-for-acf-blocks` folder to `/wp-content/plugins/`,
   or upload the ZIP via Plugins → Add New → Upload Plugin.
2. Activate it. There are no settings.

To run it as a must-use plugin instead (always on, cannot be deactivated
from the dashboard), copy `twoten-inline-canvas-for-acf-blocks.php` into
`wp-content/mu-plugins/`. The file is fully standalone. Do not run both
the normal and mu-plugin variants on the same site.

== Frequently Asked Questions ==

= Does this modify WordPress core? =

No. Core files are untouched; the plugin serves an alternative copy of one
JavaScript bundle from the uploads directory, only on post edit screens.

= What happens when WordPress updates? =

The patched bundle regenerates automatically for the new version. If the
new version has changed the relevant code, the plugin falls back to stock
behaviour (iframed canvas, ACF preview mode) rather than breaking the
editor — so glance at the block editor after each core update.

= Why do my blocks still show previews in the sidebar style? =

Check that the blocks are ACF Blocks v2 with `"mode": "edit"` (see Block
requirements). If a block allows toggling mode, a saved `"mode":"preview"`
attribute is respected; hide the toggle with `"supports": { "mode": false }`
to have the plugin reset it, or run the search-replace above.

= My blocks show a card with an "Edit Block" button instead of fields =

That is ACF's block v3 rendering. Since ACF PRO 6.8, blocks registered via
`block.json` default to v3 on WordPress 7.1+. Version 1.2.0 of this plugin
pins the default back to v2; if you still see it, check the block's
`block.json` for an explicit `"blockVersion": 3`, or for another plugin
or theme hooking `acf/blocks/default_block_version` at a later priority.

= Does this work with the free version of ACF? =

Yes, wherever free ACF renders blocks with inline edit forms the same fix
applies — but the plugin was built for and tested against ACF PRO blocks.

= How do I uninstall cleanly? =

Deactivate and delete the plugin from the Plugins screen. Uninstalling
removes the generated bundle copies from
`wp-content/uploads/twoten-inline-canvas/`. The plugin stores no options
and no database data.

== Screenshots ==

1. ACF block fields rendering inline in the editor canvas (edit mode)
   instead of being forced into the sidebar.

== Changelog ==

= 1.4.0 =
* Now distributed via the WordPress.org plugin directory. The GitHub
  release updater and `Update URI` header are removed; updates arrive
  from WordPress.org from this version onward. No functional changes to
  the editor canvas, block-version pin, or mode reset.

= 1.3.1 =
* Fix the plugin header version. The v1.3.0 release was tagged before the
  header was bumped, so it reported 1.2.0 and would have re-offered itself
  as an update forever.

= 1.3.0 =
* Reset stale `"mode":"preview"` attributes on blocks whose mode toggle
  is hidden, via the `blocks.getBlockAttributes` parser filter on post edit
  screens. Content self-heals on the next save; no database edit needed.
* Update from GitHub releases via the core `Update URI` mechanism, with a
  "Check for updates" link on the plugin row. Releases ship a clean ZIP
  built by GitHub Actions.

= 1.2.0 =
* Pin ACF block version to 2 for `block.json` blocks. ACF PRO 6.8+
  defaults them to v3 on WordPress 7.1+, which always renders a preview
  with an "Edit Block" modal — so the inline canvas alone no longer
  restored inline fields. Explicit `"blockVersion"` values and
  PHP-registered blocks are left untouched; the `tts_inline_canvas_enabled`
  kill switch also disables this.
* Correct the plugin header version (1.1.0 still reported 1.0.0).

= 1.1.0 =
* Rename to "TwoTen Inline Canvas for ACF Blocks" and prepare for the
  WordPress.org plugin directory. No functional changes.

= 1.0.0 =
* Initial release: one-token `shouldIframe` patch, scoped to post edit
  screens, keyed to core version with exactly-once fail-safe.
