=== Frontpen – Front-End Editor ===
Contributors: gopalbogati
Tags: front-end editing, inline editing, content team, editor, block editor
Requires at least: 6.4
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.3.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Edit copy directly on the live page. Click, type, save — block markup is preserved and every change is a native revision.

== Description ==

Frontpen lets logged-in editors update paragraphs, headings and list items **on the front end of the site**, without opening the block editor. Click a piece of text, type your change, and it saves — the surrounding block markup, attributes and layout are left untouched.

It is built for **content teams and copywriters** who just need to correct wording, not rebuild pages.

= How it works =

* Editable blocks are marked up as they render, using a post-order index that the server reproduces exactly. This means editing works even for blocks nested inside Group, Columns or Cover blocks.
* Classic (non-block) posts work too: each rendered paragraph, heading, list item, table cell or caption is matched back to the identical element in the stored content, and only that element's text is replaced on save. Text nested inside wrappers (such as a paragraph inside a list item, common in exported or AI-generated HTML) is found as well. Elements the server cannot verifiably match — theme or shortcode output, anything containing an image — are left alone rather than risk changing the design.
* Saves go through a dedicated REST endpoint that re-parses and re-serialises the post's blocks server-side, so nothing about the block structure is lost.
* Every save is a standard WordPress revision, so you get a full history and can roll back at any time.

= Features =

* **Inline editing** of paragraphs, headings and list items on the live page.
* **Classic content support** — posts written as plain HTML (classic editor, imported or programmatic content) are just as editable as block posts.
* **Block markup preserved** — attributes, classes and layout survive every save.
* **Native revisions** — each edit is a WordPress revision, plus a one-click "Undo last save".
* **Autosave** a moment after typing stops (configurable, or turn it off).
* **Unsaved-changes guard** warns before you navigate away with pending edits.
* **Edit-mode toolbar** — a small floating bar toggles editing on and off, so normal browsing is never disrupted.
* **Reliable front-page control** — authorized editors get an edit option on normal posts/pages; pages without supported blocks link to the standard WordPress editor instead of failing silently.
* **Safe rapid editing** — saves are queued to prevent simultaneous block updates from overwriting one another.
* **Role and per-user controls** — choose which roles may edit, always-allow specific users regardless of role, or block specific users entirely.
* **Locking** — lock a whole post from the editor screen, or exclude a single block by adding the `frontpen-no-edit` CSS class.
* **Security first** — every capability, lock and block type is re-checked on the server; the browser is never trusted.
* **No build step, no page builder** — plain PHP, CSS and JavaScript.

= Who can edit =

A user must (1) be logged in, (2) pass the access rules in the settings, and (3) already have permission to edit that specific post. The access rules combine roles with per-user lists: a blocked user can never edit, an always-allowed user may edit even if their role is not ticked, and everyone else follows the role list. Administrators can never be blocked. Visitors never see the editor or its markup.

== Installation ==

1. Upload the `frontpen` folder to `/wp-content/plugins/`, or install it from the Plugins screen.
2. Activate the plugin.
3. Go to **Settings → Front-End Editor** to choose editable block types and allowed roles.
4. Visit any post or page you can edit and click **Edit page** in the floating toolbar.

== Frequently Asked Questions ==

= Which blocks can be edited? =

Text blocks: paragraphs, headings and list items — both as Gutenberg blocks and as plain HTML elements in classic (non-block) content. In classic content, table cells, figure captions and definition lists are editable too. Layout and media blocks are intentionally left alone so the page structure stays intact.

= Can I format text while editing? =

Yes — the standard shortcuts work inside an editable region: Ctrl/Cmd+B for bold, Ctrl/Cmd+I for italic, Shift+Enter for a line break. Anything outside the safe inline tag set is stripped on save.

= Can visitors see the editor? =

No. The editing UI and its markup are only added for logged-in users who are allowed to edit the post.

= Why does the button say "Open editor" instead of "Edit page"? =

Inline editing works on Gutenberg text blocks and on plain HTML elements in classic content. If a page's visible text comes from somewhere else — a page builder, shortcodes, theme templates or custom fields — Frontpen cannot verify that editing it is safe, so it keeps the edit option visible and links to the standard WordPress editor instead.

= Why is there no Frontpen button on a WooCommerce product? =

WooCommerce product screens commonly render titles, prices and summaries from product fields and templates rather than Gutenberg post content. Frontpen stays hidden when it cannot safely edit those fields. A product description built with supported Gutenberg blocks can still use inline editing.

= How do I stop a specific block from being edited? =

Add the CSS class `frontpen-no-edit` to the block in the block editor (Advanced → Additional CSS class(es)). To lock an entire post, tick "Lock this content from front-end editing" in the Front-End Editing box on the edit screen.

= Does it work with custom post types? =

Yes, for any public post type whose content is built from supported blocks.

= What happens if two people edit at once? =

Before writing, the server checks that the block still contains the text the editor started from. If it changed, the save is refused and you are asked to reload, so no one's work is silently overwritten.

== Screenshots ==

1. The floating edit-mode toolbar on a live page.
2. Edit mode: paragraphs, headings and list items are click-to-edit, and the toolbar counts the editable regions.
3. The settings screen: editable blocks, roles and per-user access.

== Changelog ==

= 1.3.0 =
* Text nested inside wrapper elements is now editable — e.g. a paragraph inside a list item, the structure produced by many HTML exporters and AI tools.
* Classic content now also supports table cells, figure captions and definition lists.
* Per-user access control: always-allow specific users regardless of role, or block specific users entirely (administrators can never be blocked).
* The toolbar reports how many text regions are editable when entering edit mode.

= 1.2.0 =
* Inline editing now works on classic (non-block) content: plain-HTML paragraphs, headings and list items are matched back to the stored content and edited in place.
* Elements that cannot be verifiably matched — page-builder or shortcode output, nested lists, elements containing images or media — are never made editable, so the design cannot be broken.
* Classic saves reuse the same conflict detection, sanitisation, revisions and undo as block saves.

= 1.1.1 =
* Hide the no-block fallback on unsupported WooCommerce products and other custom post types.
* Keep inline editing available when a custom post type actually contains supported Gutenberg blocks.
* Avoid loading editor assets on unsupported custom post types with no editable content.

= 1.1.0 =
* Keep an edit control visible to authorized users when a page has no supported inline-editable blocks.
* Improve front-page detection by removing an unnecessary main-query restriction.
* Queue rapid saves and preserve edits typed while an earlier save is running.
* Use the WordPress HTML API for safer block annotation.
* Defer the front-end script, cache block settings per request, and add a Plugins-screen settings shortcut.
* Strengthen conflict detection and prevent nested blocks from being flattened by inline editing.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.3.0 =
Makes nested text (list bullets, table cells, captions) editable and adds per-user access control.

= 1.2.0 =
Adds inline editing for classic (non-block) posts — plain HTML content is now editable on the live page.

= 1.1.1 =
Removes the confusing Frontpen fallback notice from unsupported WooCommerce product pages.

= 1.1.0 =
Fixes missing front-page edit controls and makes rapid inline saving safer and faster.

= 1.0.0 =
Initial release.
