=== OnceBlock – Build Once, Insert Anywhere ===
Contributors: davet86, alkesh7
Tags: gutenberg, blocks, presets, reusable, native
Requires at least: 5.9
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.7
Text Domain: onceblock
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A powerful native WordPress plugin for creating and managing reusable Gutenberg block presets. No dependencies required!

== Description ==

OnceBlock is a comprehensive solution for managing reusable block content in WordPress. This plugin allows you to create, organize, and deploy block presets across your website with ease.

= Key Features =

* **Native WordPress**: Works with pure WordPress - no external dependencies required
* **Custom Post Type**: Dedicated "Block Presets" post type for managing reusable content
* **Gutenberg Ready**: Full integration with the native WordPress block editor
* **Usage Tracking**: Monitor which presets are used where and how often
* **REST API**: Full REST API support for headless implementations
* **Shortcode Support**: Easy insertion via shortcodes `[bpmgr_block id="123"]`
* **Statistics Dashboard**: Comprehensive usage analytics and reporting
* **Taxonomies**: Organize presets with categories and tags
* **ACF Integration (Optional)**: Automatic registration of ACF blocks from theme folders if ACF Pro is installed
* **Developer Friendly**: Extensive hooks and filters for customization

= Perfect For =

* Agencies managing multiple client sites
* Developers building custom themes with reusable components
* Content managers who need consistent design elements
* Sites with complex layouts that need to be replicated
* Teams collaborating on content creation

= Usage Examples =

In PHP templates: `bpmgr_render_block_preset(123);`

In content: `[bpmgr_block id="123"]`

REST API: `GET /wp-json/bpmgr/v1/block-presets`, `GET /wp-json/bpmgr/v1/block-presets/123`, `GET /wp-json/bpmgr/v1/block-presets/123/render`

= ACF Integration =

The plugin automatically scans specified theme folders for ACF blocks and registers them in the Gutenberg editor. Default folders include:

* `general/acf-blocks/`
* `public/acf-blocks/`
* `login-register/acf-blocks/`
* `members/acf-blocks/`

You can customize these folders in the plugin settings.

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/onceblock/`
2. Activate the plugin through the 'Plugins' screen in WordPress
3. Navigate to Settings > Blocks Presets to configure the plugin
4. Start creating block presets under the new "Block Presets" menu

== Frequently Asked Questions ==

= Does this plugin require ACF? =

No! This plugin works with pure WordPress and has no external dependencies. ACF integration is completely optional and can be enabled in settings if you have Advanced Custom Fields Pro installed.

= Is this compatible with my theme? =

The plugin is designed to work with any WordPress theme. It doesn't modify your theme files but provides hooks and filters for integration.

= Can I use this with page builders? =

Yes, block presets work within the Gutenberg editor and are compatible with most page builders that support WordPress blocks.

= How do I customize the block folders? =

Go to Settings > Blocks Presets and modify the "ACF Block Folders" setting to specify which theme folders should be scanned for ACF blocks.

== Screenshots ==

1. Manage your block presets: categories, tags, shortcodes and usage count in one list.
2. Insert a preset in the block editor: search and filter your library, then pick a preset from the sidebar.
3. Usage statistics show your most used and unused presets.
4. Simple settings, with optional ACF block registration from theme folders.

== Changelog ==

= 1.0.7 =
* Changed: the Plugin URI now points to the renamed GitHub repository (neodavet/onceblock)
* Added: automatic deployment from GitHub to WordPress.org

= 1.0.6 =
* Changed: the plugin is now named OnceBlock – Build Once, Insert Anywhere (slug `onceblock`)
* Removed: the unprefixed legacy `block` post type, the `[block_preset]` shortcode, `do_cpt_block()`, the "Enable Legacy Post Type" setting and the migration tool
* Fix: the REST API routes and PHP helpers only ever return published block presets
* Fix: the Statistics chart script is now enqueued instead of printed inline
* Security: rendered preset content is passed through `wp_kses_post()` in the block render callback

= 1.0.5 =
* Removed "Tested up to" from the plugin header; it is now declared only in readme.txt, as WordPress.org requires

= 1.0.4 =
* Changed: the plugin author is now listed as David Tavares Cuevas
* Changed: the Plugin URI now points to the GitHub repository

= 1.0.3 =
* Changed: block preset pages now use the URL base `/block-preset/` (previously `/bpmgr_block_preset/`); the old URL redirects to the new one
* Fix: single preset pages returned a 404 after activation because rewrite rules were flushed before the post types were registered
* Fix: the admin script failed to initialize (`$ is not defined`), which broke the new Duplicate action and other admin script features

= 1.0.2 =
* Renamed the plugin to Block Presets Manager (slug `block-presets-manager`) and changed the internal code prefix to `bpmgr`
* Fix: resolved a fatal error on the Tools page caused by a duplicated function and form handler
* Removed the manual `load_plugin_textdomain()` call (translations are loaded automatically by WordPress.org)
* Updated "Tested up to" to WordPress 7.1
* New: "Duplicate" row action in the Block Presets list (creates a draft copy including categories, tags and custom fields)
* New: secure AJAX handlers for duplicating and previewing presets (nonce and capability checks)
* Code quality: cleared all remaining Plugin Check warnings (documented direct queries on the plugin's own table, unused callback parameters, JSON output encoding)

= 1.0.1 =
* Security: REST API endpoint for a single block preset no longer exposes draft/private/trashed presets to unauthenticated requests
* Security: removed a duplicate, conflicting registration of the plugin settings that had silently dropped path-safety validation on the ACF block folders setting
* Fix: resolved a fatal error that occurred whenever `bpmgr_render_block_preset()`, `do_cpt_block()`, or related helper functions were called from a theme
* Fix: resolved a fatal error on `plugins_loaded` caused by a missing text domain loader
* Fix: resolved a fatal error on activation caused by `register_activation_hook()`/`register_deactivation_hook()` being registered too late; plugin settings and the usage-tracking table are now correctly created on activation
* Fix: the `[bpmgr_block]` and `[block_preset]` shortcodes now actually register and render (they previously never worked)
* Fix: the Tools page "Export Block Presets" action now produces a valid downloadable JSON file instead of a broken response
* i18n: the block editor script's translatable strings are now loaded via `wp_set_script_translations()`, so they can actually be translated
* i18n: added missing localized strings for the admin JS, and switched a count-based message to use proper singular/plural forms
* Hardened nonce verification, redirects, and JSON output across the admin screens
* Updated "Tested up to" to WordPress 7.0
* Full WordPress Coding Standards (WPCS) compliance pass
* Removed unused legacy admin code superseded by the current settings screen

= 1.0.0 =
* Initial release
* Custom post type for block presets
* ACF blocks auto-registration
* Usage tracking and statistics
* REST API endpoints
* Migration tools
* Shortcode support
* Legacy function compatibility
* Admin interface with tools and statistics
* Comprehensive uninstall cleanup

== Upgrade Notice ==

= 1.0.7 =
Updates the Plugin URI to the renamed GitHub repository. No functional changes.

= 1.0.6 =
The plugin is renamed to OnceBlock. The legacy `block` post type, `[block_preset]` shortcode and `do_cpt_block()` function are removed; use `bpmgr_block_preset`, `[bpmgr_block]` and `bpmgr_render_block_preset()`.

= 1.0.5 =
Removes the "Tested up to" line from the plugin header. No functional changes.

= 1.0.4 =
Updates the plugin author name and Plugin URI. No functional changes.

= 1.0.3 =
Preset URLs change to /block-preset/ and several admin and activation fixes. Rewrite rules are flushed automatically on activation.

= 1.0.2 =
Fixes a fatal error on the Tools page and renames the plugin to Block Presets Manager.

= 1.0.1 =
Security and stability update: fixes two fatal-error bugs and closes a settings-validation gap. Upgrade is recommended for all users.

= 1.0.0 =
Initial release.

== Developer Information ==

= Hooks and Filters =

The plugin provides numerous hooks for customization:

Filters:
- `bpmgr_block_preset_content` - Filter block preset output

= REST API Endpoints =

- `GET /wp-json/bpmgr/v1/block-presets` - List all presets
- `GET /wp-json/bpmgr/v1/block-presets/{id}` - Get specific preset
- `GET /wp-json/bpmgr/v1/block-presets/{id}/render` - Get rendered preset

= File Structure =

    onceblock/
    ├── onceblock.php
    ├── uninstall.php
    ├── readme.txt
    ├── LICENSE
    ├── languages/
    │   └── index.php
    ├── assets/
    │   └── js/
    │       └── block-preset.js
    ├── includes/
    │   ├── class-bpmgr-post-types.php
    │   ├── class-bpmgr-acf-blocks.php
    │   ├── class-bpmgr-gutenberg-blocks.php
    │   ├── class-bpmgr-helper-functions.php
    │   └── class-bpmgr-admin.php
    └── admin/
        ├── settings-page.php
        ├── tools-page.php
        ├── statistics-page.php
        ├── css/
        │   └── admin.css
        └── js/
            ├── admin.js
            └── statistics-chart.js

For more information and documentation, visit: https://neodavet.github.io/davetportfolio/
