generator-chisel 2.4.1 → 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 +4 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/core/Helpers/BlocksHelpers.php +17 -7
- package/lib/commands/create/creators/app/chisel-starter-theme/core/WP/Blocks.php +104 -13
- package/lib/commands/create/creators/app/chisel-starter-theme/style.chisel-tpl.css +1 -1
- package/lib/commands/create/packages-versions.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
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
|
+
|
|
5
9
|
## <small>2.4.1 (2026-02-11)</small>
|
|
6
10
|
|
|
7
11
|
- small fixes ([4c74101](https://github.com/xfiveco/generator-chisel/commit/4c74101))
|
package/lib/commands/create/creators/app/chisel-starter-theme/core/Helpers/BlocksHelpers.php
CHANGED
|
@@ -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
|
-
//
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
'
|
|
86
|
-
'label' => __( '
|
|
87
|
-
'description' => __( '
|
|
100
|
+
'hero' => array(
|
|
101
|
+
'label' => __( 'Hero', 'chisel' ),
|
|
102
|
+
'description' => __( 'Hero Sections.', 'chisel' ),
|
|
88
103
|
),
|
|
89
|
-
'features'
|
|
104
|
+
'features' => array(
|
|
90
105
|
'label' => __( 'Features', 'chisel' ),
|
|
91
106
|
'description' => __( 'Features Sections.', 'chisel' ),
|
|
92
107
|
),
|
|
93
|
-
'
|
|
94
|
-
'label' => __( '
|
|
95
|
-
'description' => __( '
|
|
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
|
|
335
|
-
$
|
|
336
|
-
$
|
|
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( $
|
|
343
|
-
unset( $
|
|
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
|
}
|
|
@@ -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.
|
|
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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "generator-chisel",
|
|
3
|
-
"version": "2.4.
|
|
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": "
|
|
40
|
+
"gitHead": "ee5dc88ef9d1987e2bbd786e99a6c41aaed5c922"
|
|
41
41
|
}
|