Skip to content

Commit beeadbf

Browse files
committed
Merge branch 'release/1.0.5'
2 parents 0ea22ce + 033465c commit beeadbf

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## 1.0.5
5+
6+
* [Fixed] Invalid `micropackage/acf-block-creator/config` hookname
7+
* [Added] Filters for block tamplate and style file paths
8+
49
## 1.0.4
510

611
* [Fixed] block setup fields behavior

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "micropackage/acf-block-creator",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"description": "ACF Block Creator - automatic block creation add-on for ACF",
55
"license": "GPL-3.0-or-later",
66
"authors": [

src/ACFBlockCreator.php

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static function init( $config = [] ) {
6262
*/
6363
protected function __construct( $config ) {
6464
$this->config = apply_filters(
65-
'micropackage/acf-block-loader/config',
65+
'micropackage/acf-block-creator/config',
6666
wp_parse_args( $config, [
6767
'blocks_dir' => 'blocks',
6868
'scss_dir' => false,
@@ -276,14 +276,45 @@ public function update_field_group( $field_group ) {
276276
$template
277277
);
278278

279-
$this->root_fs->put_contents( "{$this->config['blocks_dir']}/{$slug}.php", preg_replace( '/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/', "\n\n", $template ) );
279+
$template_dir = apply_filters(
280+
'micropackage/acf-block-creator/block-template-dir',
281+
$this->config['blocks_dir'],
282+
$slug
283+
);
284+
285+
$template_file = apply_filters(
286+
'micropackage/acf-block-creator/block-template-file',
287+
"{$slug}.php",
288+
$slug
289+
);
290+
291+
if ( ! $this->maybe_mkdir( $template_dir ) ) {
292+
return;
293+
}
294+
295+
$this->root_fs->put_contents(
296+
"{$template_dir}/{$template_file}",
297+
preg_replace( '/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/', "\n\n", $template )
298+
);
299+
300+
$scss_dir = apply_filters(
301+
'micropackage/acf-block-creator/block-style-dir',
302+
$this->config['scss_dir'],
303+
$slug
304+
);
280305

281306
// Create block scss partial.
282-
if ( is_string( $this->config['scss_dir'] ) ) {
307+
if ( is_string( $scss_dir ) ) {
308+
$scss_file = apply_filters(
309+
'micropackage/acf-block-creator/block-style-file',
310+
"_{$slug}.scss",
311+
$slug
312+
);
313+
283314
$scss = ".block.$slug {\n/* stylelint-disable */\n}";
284315

285-
if ( $this->maybe_mkdir( $this->config['scss_dir'] ) ) {
286-
$this->root_fs->put_contents( "{$this->config['scss_dir']}/_{$slug}.scss", $scss );
316+
if ( $this->maybe_mkdir( $scss_dir ) ) {
317+
$this->root_fs->put_contents( "{$scss_dir}/{$scss_file}", $scss );
287318
}
288319
}
289320

0 commit comments

Comments
 (0)