Skip to content

Commit

Permalink
[#105] Added ACF Blocks Toolkit README file
Browse files Browse the repository at this point in the history
  • Loading branch information
bd-viget committed Jun 14, 2024
1 parent f145753 commit 58b5342
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions wp-content/plugins/acf-blocks-toolkit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# ACF Blocks Toolkit

This is a toolkit for creating custom blocks with ACF Pro. It provides a simple way to create blocks with ACF Pro.

This toolkit also includes a feature that adds icons to buttons.

## Creating ACF Blocks in your Theme

To create a block in your theme, simply create a `blocks` folder in the root of your theme directory. Each block should have its own folder and a `block.json` file. The `block.json` file should contain the block configuration. You can then use a `render.php` file or `render.twig` file to render the block.

## Hooks

### `acfbt_block_locations` (Filter)

Filter the block locations. This allows you to add or change where custom blocks can be found.

```php
<?php
add_filter(
'acfbt_block_locations',
function ( array $locations ): array {
$locations[] = get_template_directory() . '/other-blocks';
return $locations;
}
);
```

### `acfbt_button_icons` (Filter)

Filter the button icons.

```php
<?php
add_filter(
'acfbt_button_icons',
function ( array $icons ): array {
$icons['my-custom-icon'] = [ // The key is the unique icon slug.
'label' => __( 'My Custom Icon', 'my-text-domain' ),
'icon' => '<svg ... ></svg>',
'defaultLeft' => false, // Optional, defaults icon to align left.
];

return $icons;
}
);
```

### `acfbt_button_icons_editor_css` (Filter)

Filter the editor CSS for the button icons. This is useful when some icons do not use outline fill the fill property causes issues. Or can also be used to specify icon dimensions using `max-height`.

```php
add_filter(
'acfbt_button_icons_editor_css',
function ( string $css ): string {
return $css . '.components-button.button-icon-picker__icon-my-custom-icon svg { fill:none; }';
}
);
```

0 comments on commit 58b5342

Please sign in to comment.