-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#105] Added ACF Blocks Toolkit README file
- Loading branch information
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; }'; | ||
} | ||
); | ||
``` |