> For the complete documentation index, see [llms.txt](https://whoisandywhite.gitbook.io/porterwp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://whoisandywhite.gitbook.io/porterwp/documentation/blocks.md).

# Blocks

PorterWP registers **ACF blocks** defined under `porter/blocks/*/`\
and glues them into the editor via the `blocks.json` config.

```
blocks
└── components
    └── testimonial
        ├── acf-json/           # Field group exported by ACF Sync
        ├── block.json          # WP core block metadata
        ├── init.php            # Optional render_callback
        ├── template.php        # Twig‑like partial used by render callback
        ├── icon.svg            # Editor icon (created by make.sh)
        ├── scss/style.scss     # Block SCSS (compiled → css/style.css)
        └── readme.md
```

## Scaffolding with `make.sh`

> **Note:** The `_block-base/` stub and `make.sh` script live in the **public PorterWP scaffold repository**, not inside the premium plugin ZIP. Clone the repo when you need to scaffold a new block.

Run from `porter/blocks/`:

```bash
sh make.sh testimonial components
```

The script:

1. Copies `_block-base/` stub into `components/testimonial`.
2. Replaces placeholders (`dummy-name`, `Dummy_Title`, etc.).
3. Creates the **icon.svg** from a template so your block has a unique glyph.

### Life‑cycle

| Phase                         | Hook                                                       |
| ----------------------------- | ---------------------------------------------------------- |
| `init`                        | `Porter_Blocks::register_blocks()` registers every folder. |
| `enqueue_block_editor_assets` | Injects block‐specific JS/CSS if present.                  |
| `render_callback`             | Calls `template.php` and passes `$block` + ACF data.       |

***

## Dynamic Blocks

Add a block name to the `dynamic_blocks` array in\
`Porter_Config_Block_Styles` (defaults to `core/query`) if its style.css should be rendered server‑side.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://whoisandywhite.gitbook.io/porterwp/documentation/blocks.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
