generator-chisel 2.4.0 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  <!-- INSERT-NEW-ENTRIES-HERE -->
4
4
 
5
+ ## <small>2.4.2 (2026-02-11)</small>
6
+
7
+ - Blocks and patterns cache and render fixes ([576fbe9](https://github.com/xfiveco/generator-chisel/commit/576fbe9))
8
+
9
+ ## <small>2.4.1 (2026-02-11)</small>
10
+
11
+ - small fixes ([4c74101](https://github.com/xfiveco/generator-chisel/commit/4c74101))
12
+ - update theme version and screenshot ([324db40](https://github.com/xfiveco/generator-chisel/commit/324db40))
13
+
5
14
  ## 2.4.0 (2026-02-09)
6
15
 
7
16
  - chisel update scripts and husky precommit hooks ([31c1019](https://github.com/xfiveco/generator-chisel/commit/31c1019))
@@ -90,17 +90,27 @@ final class BlocksHelpers {
90
90
  $context['block']['class_names'] = $classes;
91
91
  $context['block']['block_id'] = $block['anchor'] ?? ( $block['id'] ?? '' );
92
92
 
93
- // allow to use filters to manipulate the output.
93
+ // Allow to use filters to manipulate the output.
94
94
  $context = apply_filters( 'chisel_timber_acf_blocks_data', $context );
95
95
  $context = apply_filters( 'chisel_timber_acf_blocks_data_' . $block_slug, $context );
96
96
  $context = apply_filters( 'chisel_timber_acf_blocks_data_' . $block['id'], $context );
97
97
 
98
- $context['wrapper_attributes'] = get_block_wrapper_attributes(
99
- array(
100
- 'id' => $context['block']['block_id'],
101
- 'class' => implode( ' ', $context['block']['class_names'] ),
102
- )
103
- );
98
+ // Check if WP_Block_Supports has a block to render to avoid warnings.
99
+ if ( class_exists( '\WP_Block_Supports' ) && \WP_Block_Supports::$block_to_render ) {
100
+ $context['wrapper_attributes'] = get_block_wrapper_attributes(
101
+ array(
102
+ 'id' => $context['block']['block_id'],
103
+ 'class' => implode( ' ', $context['block']['class_names'] ),
104
+ )
105
+ );
106
+ } else {
107
+ // Fallback: manually construct attributes if block context is missing.
108
+ $context['wrapper_attributes'] = sprintf(
109
+ 'id="%s" class="%s"',
110
+ esc_attr( $context['block']['block_id'] ),
111
+ esc_attr( implode( ' ', $context['block']['class_names'] ) )
112
+ );
113
+ }
104
114
 
105
115
  Timber::render( AcfBlocks::get_instance()->blocks_twig_base_path . $block_slug . '/' . $block_slug . '.twig', $context, CacheHelpers::expiry() );
106
116
  }
@@ -48,6 +48,13 @@ final class Blocks {
48
48
  */
49
49
  private string $blocks_category = '';
50
50
 
51
+ /**
52
+ * Block patterns.
53
+ *
54
+ * @var array
55
+ */
56
+ private array $block_patterns = array();
57
+
51
58
 
52
59
  /**
53
60
  * Blocks patterns categories.
@@ -64,6 +71,13 @@ final class Blocks {
64
71
  */
65
72
  private string $block_patterns_categories_namespace = '';
66
73
 
74
+ /**
75
+ * Block patterns path.
76
+ *
77
+ * @var string
78
+ */
79
+ private string $block_patterns_path = '';
80
+
67
81
  /**
68
82
  * Blocks twig file base path.
69
83
  *
@@ -80,19 +94,52 @@ final class Blocks {
80
94
  $this->blocks_twig_base_path = 'build/blocks/';
81
95
  $this->theme = wp_get_theme();
82
96
  $this->blocks_category = 'chisel-blocks';
97
+ $this->block_patterns_path = get_template_directory() . '/patterns/';
83
98
  $this->block_patterns_categories_namespace = 'chisel-patterns';
84
99
  $this->block_patterns_categories = array(
85
- 'cta' => array(
86
- 'label' => __( 'Call to Action', 'chisel' ),
87
- 'description' => __( 'Call to Action Sections.', 'chisel' ),
100
+ 'hero' => array(
101
+ 'label' => __( 'Hero', 'chisel' ),
102
+ 'description' => __( 'Hero Sections.', 'chisel' ),
88
103
  ),
89
- 'features' => array(
104
+ 'features' => array(
90
105
  'label' => __( 'Features', 'chisel' ),
91
106
  'description' => __( 'Features Sections.', 'chisel' ),
92
107
  ),
93
- 'hero' => array(
94
- 'label' => __( 'Hero', 'chisel' ),
95
- 'description' => __( 'Hero Sections.', 'chisel' ),
108
+ 'cta' => array(
109
+ 'label' => __( 'Call to Action', 'chisel' ),
110
+ 'description' => __( 'Call to Action Sections.', 'chisel' ),
111
+ ),
112
+ 'testimonials' => array(
113
+ 'label' => __( 'Testimonials', 'chisel' ),
114
+ 'description' => __( 'Testimonials Sections.', 'chisel' ),
115
+ ),
116
+ 'team' => array(
117
+ 'label' => __( 'Team', 'chisel' ),
118
+ 'description' => __( 'Team Sections.', 'chisel' ),
119
+ ),
120
+ 'pricing' => array(
121
+ 'label' => __( 'Pricing', 'chisel' ),
122
+ 'description' => __( 'Pricing Sections.', 'chisel' ),
123
+ ),
124
+ 'text' => array(
125
+ 'label' => __( 'Text', 'chisel' ),
126
+ 'description' => __( 'Text Sections.', 'chisel' ),
127
+ ),
128
+ 'gallery' => array(
129
+ 'label' => __( 'Gallery', 'chisel' ),
130
+ 'description' => __( 'Gallery Sections.', 'chisel' ),
131
+ ),
132
+ 'faq' => array(
133
+ 'label' => __( 'FAQ', 'chisel' ),
134
+ 'description' => __( 'FAQ Sections.', 'chisel' ),
135
+ ),
136
+ 'stats' => array(
137
+ 'label' => __( 'Stats', 'chisel' ),
138
+ 'description' => __( 'Statistics Sections.', 'chisel' ),
139
+ ),
140
+ 'logos' => array(
141
+ 'label' => __( 'Logos', 'chisel' ),
142
+ 'description' => __( 'Logo Cloud Sections.', 'chisel' ),
96
143
  ),
97
144
  );
98
145
  }
@@ -321,6 +368,35 @@ final class Blocks {
321
368
  }
322
369
  }
323
370
 
371
+ /**
372
+ * Get block patterns from the patterns directory.
373
+ *
374
+ * @return array
375
+ */
376
+ protected function get_block_patterns(): array {
377
+ if ( $this->block_patterns ) {
378
+ return $this->block_patterns;
379
+ }
380
+
381
+ $patterns_list = is_dir( $this->block_patterns_path ) ? new \DirectoryIterator( $this->block_patterns_path ) : array();
382
+
383
+ if ( $patterns_list ) {
384
+ foreach ( $patterns_list as $item ) {
385
+ if ( $item->isDot() || $item->isDir() || 'php' !== $item->getExtension() ) {
386
+ continue;
387
+ }
388
+
389
+ $block_name = $item->getFilename();
390
+
391
+ if ( ! in_array( $block_name, $this->block_patterns, true ) ) {
392
+ $this->block_patterns[] = $block_name;
393
+ }
394
+ }
395
+ }
396
+
397
+ return $this->block_patterns;
398
+ }
399
+
324
400
  /**
325
401
  * Maybe clear patterns cache. Clear patterns cache if block patterns categories are changed / added.
326
402
  *
@@ -331,21 +407,36 @@ final class Blocks {
331
407
  return;
332
408
  }
333
409
 
334
- $theme_patterns = $this->block_patterns_categories;
335
- $cached_patterns = $this->theme->get_block_patterns();
336
- $patterns_categories = array();
410
+ $theme_patterns = $this->get_block_patterns();
411
+ $theme_pattern_categories = $this->block_patterns_categories;
412
+ $cached_patterns = $this->theme->get_block_patterns();
413
+ $patterns_categories = array();
337
414
 
338
415
  foreach ( $cached_patterns as $pattern ) {
416
+ $slug = $pattern['slug'] ?? '';
417
+ $file = '';
418
+
419
+ if ( $slug ) {
420
+ $file = explode( '/', $slug );
421
+ $file = end( $file ) . '.php';
422
+ }
423
+
424
+ if ( $file && in_array( $file, $theme_patterns, true ) ) {
425
+ $key = array_search( $file, $theme_patterns, true );
426
+
427
+ unset( $theme_patterns[ $key ] );
428
+ }
429
+
339
430
  foreach ( $pattern['categories'] ?? array() as $category ) {
340
431
  $category = str_replace( $this->block_patterns_categories_namespace . '/', '', $category );
341
432
 
342
- if ( isset( $theme_patterns[ $category ] ) ) {
343
- unset( $theme_patterns[ $category ] );
433
+ if ( isset( $theme_pattern_categories[ $category ] ) ) {
434
+ unset( $theme_pattern_categories[ $category ] );
344
435
  }
345
436
  }
346
437
  }
347
438
 
348
- if ( ! empty( $theme_patterns ) ) {
439
+ if ( ! empty( $theme_pattern_categories ) || ! empty( $theme_patterns ) ) {
349
440
  $this->theme->delete_pattern_cache();
350
441
  }
351
442
  }
@@ -34,7 +34,7 @@ class Twig {
34
34
  */
35
35
  public function register_functions( \Twig\Environment $twig, \Chisel\WP\Twig $chisel_twig ): void {
36
36
  // phpcs:disable -- Example of custom function. Remove this line and the phpcs:enable when adding your own custom functions
37
- // $twig->addFunction( new \Twig\Function( 'custom_fn', array( $this, 'custom_fn_callback' ) ) );
37
+ // $chisel_twig->register_function( $twig, 'custom_fn', array( $this, 'custom_fn_callback' ) );
38
38
  // phpcs:enable
39
39
  }
40
40
 
@@ -46,7 +46,7 @@ class Twig {
46
46
  */
47
47
  public function register_filters( \Twig\Environment $twig, \Chisel\WP\Twig $chisel_twig ): void {
48
48
  // phpcs:disable -- Example of custom filter. Remove this line and the phpcs:enable when adding your own custom filters
49
- // $twig->addFilter( new \Twig\Filter( 'custom_filter', array( $this, 'custom_filter_callback' ) ) );
49
+ // $chisel_twig->register_filter( $twig, 'custom_filter', array( $this, 'custom_filter_callback' ) );
50
50
  // phpcs:enable
51
51
  }
52
52
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "<%= app.nameSlug %>",
3
- "version": "2.0.0",
3
+ "version": "2.4.1",
4
4
  "private": true,
5
5
  "license": "UNLICENSED",
6
6
  "author": "<%= app.author %>",
@@ -3,7 +3,7 @@
3
3
  * Theme URI: https://www.getchisel.co/
4
4
  * Author: <%= app.author %>
5
5
  * Description: Chisel Wordpress Starter Theme based on Timber library.
6
- * Version: 2.4.0
6
+ * Version: 2.4.2
7
7
  * License: GNU General Public License v2 or later
8
8
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
9
  * Tags: chisel, custom, starter, theme, WordPress
@@ -1,5 +1,5 @@
1
1
  module.exports = {
2
- 'chisel-scripts': '2.2.0',
2
+ 'chisel-scripts': '2.2.1',
3
3
  'chisel-shared-utils': '2.0.0-alpha.1',
4
- 'generator-chisel': '2.4.0',
4
+ 'generator-chisel': '2.4.2',
5
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generator-chisel",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "A generator for scaffolding front-end and WordPress projects",
5
5
  "bin": {
6
6
  "chisel": "bin/chisel.js"
@@ -37,5 +37,5 @@
37
37
  "tinyqueue": "^2.0.3",
38
38
  "update-notifier": "^4.1.0"
39
39
  },
40
- "gitHead": "259173a22a8cb7a7380936bfc01baf4b87f6afa3"
40
+ "gitHead": "ee5dc88ef9d1987e2bbd786e99a6c41aaed5c922"
41
41
  }