=== FieldCanvas Layout Builder - Visual ACF Flexible Content Builder ===
Contributors: chintan95
Tags: acf, flexible content, layout builder, advanced custom fields, drag and drop
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 8.0
Stable tag: 1.0.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Build ACF Flexible Content layouts visually with drag-and-drop, then insert complete field groups in one click. No PHP required.

== Description ==

**FieldCanvas Layout Builder** is a visual layout generator for **Advanced Custom Fields (ACF) Flexible Content**. Instead of manually adding fields one at a time in the ACF field group editor, drag fields onto a canvas, arrange them, and insert a fully-built Flexible Content layout - or a whole field group - into WordPress in one click.

If you build websites with ACF and are tired of the repetitive click-through of creating the same Hero, Testimonial, FAQ, or Pricing layouts by hand, FieldCanvas turns that into a five-minute visual task with a reusable library you can draw from on every project.

= Why FieldCanvas Layout Builder? =

* **Visual, drag-and-drop layout builder** - assemble Flexible Content layouts from 40+ ACF field types (Text, Image, Gallery, Relationship, Repeater, Group, nested Flexible Content, and more) without touching PHP
* **One-click insert** - push a finished layout straight into a new or existing ACF field group and Flexible Content field
* **19 built-in starter layouts** - Hero Banner, Services, FAQ, Testimonials, Team, Pricing, and more, ready to insert or customize
* **Layout Library** - save, search, favourite, and reuse layouts across every field group and every project
* **Version history** - review and restore earlier versions of any layout
* **Import / Export** - move layouts between sites as JSON, or export in native ACF JSON format for use with ACF Tools
* **Usage tracking** - see exactly where a layout or field group is currently used before you delete it
* **Duplicate detection** - built-in field-name collision checks prevent ACF conflicts when inserting or duplicating

= Who is this for? =

Freelancers, agencies, and in-house WordPress teams who build custom sites on top of Advanced Custom Fields and want to stop rebuilding the same Flexible Content layouts from scratch on every client project.

= Requirements =

* Advanced Custom Fields (free or Pro) must be installed and active for generated field groups and layouts to be usable.

== Installation ==

1. Upload the `fieldcanvas-layout-builder` folder to the `/wp-content/plugins/` directory, or install the plugin zip through **Plugins → Add New → Upload Plugin** in wp-admin.
2. Activate the plugin through the **Plugins** menu in WordPress.
3. Make sure Advanced Custom Fields is installed and active.
4. Go to **FieldCanvas Layout Builder** in the admin menu to start building layouts.

== Frequently Asked Questions ==

= Does this replace Advanced Custom Fields? =

No. This plugin generates ACF Flexible Content layouts and field groups; ACF itself must be installed and active for the generated fields to work.

= Where are my saved layouts stored? =

Layouts are stored in custom database tables created by the plugin. Uninstalling the plugin (via the WordPress uninstall process, not simple deactivation) removes these tables and the plugin's options.

= Can I move layouts between sites? =

Yes. Use the Import/Export screen to download a layout (or your full layout library) as JSON, then import that JSON file on another site running the same plugin.

= What happens to my field groups if I delete a layout? =

Deleting a layout removes it from the library but does not remove it from any existing field groups. The layout data remains in your ACF field groups. The delete function will warn you if the layout is currently in use.

= Can I edit built-in/default layouts? =

Yes. Built-in layouts (marked with "Default" badge) can be duplicated and then edited as custom layouts. The original default layout remains in the library.

= Does this plugin work with ACF Free? =

Yes, the plugin works with both ACF Free and ACF Pro. ACF Pro is recommended for the full Flexible Content experience with advanced field options.

= How do I create a new layout? =

Go to **FieldCanvas Layout Builder → Custom Builder**, drag fields from the left sidebar into the builder area, configure each field's settings, and click "Save Layout".

= How do I insert a layout into a field group? =

In the Layout Library, click the "Insert" button on any layout card. Choose whether to insert as direct fields or as a Flexible Content layout, select a field group (or create a new one), and confirm.

= Can I export layouts in ACF format? =

Yes. In Import/Export, select your layouts and choose "ACF JSON Format" as the export format. This creates a standard ACF field group file compatible with ACF Tools import.

= Does this plugin support nested repeaters? =

Yes. Repeater and Group fields can be nested to any depth. Drag fields into the sub-fields area of a repeater or group to nest them.

== Screenshots ==

1. Custom Builder - assemble a layout from the field palette.
2. Layout Library - search, favourite, and reuse saved layouts.
3. Dashboard - usage stats and recent layouts at a glance.

== Changelog ==

= 1.0.0 =
**Core Features**
* Drag-and-drop visual builder for creating ACF Flexible Content layouts without PHP coding
* Support for 40+ field types including Text, Textarea, Image, Gallery, Repeater, Group, Flexible Content, etc.
* One-click insertion of layouts into new or existing ACF field groups
* Layout Library with search, filtering, and pagination
* Favorites system for quick access to frequently-used layouts
* Template seeding with 19 built-in default layouts (Hero Banner, Services, FAQ, Testimonials, Team, Pricing, etc.)
* Each Flexible Content layout has its own Layout Name field and Layout (Display) select - Table / Block / Row - matching real ACF, with Layout Name auto-filling from the Layout Label
* Insert Layout modal supports creating a brand-new Flexible Content field on the fly, with its own Field Label / Field Name pair, or targeting an existing one
* Inserting a layout that already exists (by name) in the target Flexible Content field offers an "Insert as a new duplicate layout" option, so you can update in place or add a separate copy without collisions

**Functionality**
* Layout search includes field definitions for better discoverability
* Smooth drag-and-drop sorting and nested field management for complex layouts, with native auto-scroll
* Duplicate layout and duplicate field functionality for quick iterations, applied recursively to nested Repeater/Group sub-fields and Flexible Content layouts
* Multi-level undo via browser back/forward navigation
* Auto-generated field names with Unicode/diacritic normalization, kept in sync with the Field Label as you type
* Duplicate field-name validation to prevent ACF conflicts, both in the builder and when inserting into an existing field group
* Conditional logic support with target field validation

**Data Management**
* Import/Export layouts in JSON (native) and ACF JSON formats
* Export location rules customizable via filter hook (fcalb_export_location_rules)
* Layout and usage tracking with database indexes for performance
* Automatic tracking of layout usage across field groups and post types
* Settings page with full database reset option

**User Experience**
* Unsaved changes warning before page navigation
* Contextual help tabs for all admin pages (Dashboard, Library, Builder, Import/Export, Settings)
* Toast notifications for user feedback
* Dashboard with statistics: total layouts, field groups, favorites, usage by post type
* Most Used, Recent Layouts, and Favorites tables on dashboard
* Responsive admin UI with clean, modern design

**Developer Features**
* Trait-based code reuse for shared template fields and utilities
* Filter hooks for extensibility (fcalb_export_location_rules)
* Proper nonce handling and capabilities checking for security
* WordPress database best practices with prepared statements
* Database indexes for optimized query performance

**Technical Improvements**
* PHP 8.0+ namespaced code with strict type handling
* jQuery 3.x compatible drag-and-drop with jQuery UI Sortable
* ACF compatibility with versions 5.0 and later
* Transient cleanup and cache flushing on settings reset
* NULL value filtering in dashboard usage queries

== Upgrade Notice ==

= 1.0.0 =
Initial release of FieldCanvas Layout Builder.