@@ -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