generator-chisel 2.0.0-alpha.5 → 2.0.0-alpha.7

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/lib/commands/create/creators/app/chisel-starter-theme/.gitignore.chisel-tpl +2 -0
  3. package/lib/commands/create/creators/app/chisel-starter-theme/archive.php +1 -12
  4. package/lib/commands/create/creators/app/chisel-starter-theme/author.php +2 -6
  5. package/lib/commands/create/creators/app/chisel-starter-theme/classes/AcfBlocks.php +1 -1
  6. package/lib/commands/create/creators/app/chisel-starter-theme/classes/Assets.php +86 -45
  7. package/lib/commands/create/creators/app/chisel-starter-theme/classes/Blocks.php +16 -0
  8. package/lib/commands/create/creators/app/chisel-starter-theme/classes/Components.php +56 -19
  9. package/lib/commands/create/creators/app/chisel-starter-theme/classes/CustomPostTypes.php +1 -1
  10. package/lib/commands/create/creators/app/chisel-starter-theme/classes/ExtendedPost.php +1 -1
  11. package/lib/commands/create/creators/app/chisel-starter-theme/classes/ExtendedProduct.php +1 -1
  12. package/lib/commands/create/creators/app/chisel-starter-theme/classes/GravityForms.php +47 -2
  13. package/lib/commands/create/creators/app/chisel-starter-theme/classes/Helpers.php +67 -0
  14. package/lib/commands/create/creators/app/chisel-starter-theme/classes/RegisterBlocks.php +2 -1
  15. package/lib/commands/create/creators/app/chisel-starter-theme/classes/Site.php +1 -18
  16. package/lib/commands/create/creators/app/chisel-starter-theme/classes/Theme.php +1 -20
  17. package/lib/commands/create/creators/app/chisel-starter-theme/classes/Twig.php +57 -3
  18. package/lib/commands/create/creators/app/chisel-starter-theme/classes/Yoast.php +17 -0
  19. package/lib/commands/create/creators/app/chisel-starter-theme/index.php +0 -1
  20. package/lib/commands/create/creators/app/chisel-starter-theme/search.php +0 -1
  21. package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks-acf/slider/acf-json/group_66462c70b851f.json +1 -1
  22. package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks-acf/slider/block.json +1 -1
  23. package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks-acf/slider/slider.twig +2 -0
  24. package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_buttons.scss +10 -0
  25. package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_icon.scss +8 -2
  26. package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_media.scss +15 -0
  27. package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/app.js +2 -0
  28. package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/blocks-mods.js +1 -0
  29. package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/mods/blocks-alignment.js +26 -0
  30. package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/mods/core-button.js +60 -5
  31. package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/modules/scrollbar-width.js +8 -0
  32. package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/modules/slider.js +6 -1
  33. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core-button.scss +31 -4
  34. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_buttons.scss +29 -2
  35. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_slider.scss +13 -7
  36. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/vendor/_breadcrumbs.scss +16 -0
  37. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/wp-editor/_swiper-sliders.scss +11 -2
  38. package/lib/commands/create/creators/app/chisel-starter-theme/views/404.twig +1 -2
  39. package/lib/commands/create/creators/app/chisel-starter-theme/views/base.twig +4 -0
  40. package/lib/commands/create/creators/app/chisel-starter-theme/views/index.twig +2 -4
  41. package/lib/commands/create/creators/app/chisel-starter-theme/views/partials/block-edit-button.twig +3 -0
  42. package/lib/commands/create/creators/app/chisel-starter-theme/views/partials/the-title.twig +3 -1
  43. package/lib/commands/create/creators/wp-plugins/plugins.json +3 -1
  44. package/lib/commands/create/packages-versions.js +2 -2
  45. package/package.json +2 -2
  46. package/lib/commands/create/creators/app/chisel-starter-theme/views/components/page-title.twig +0 -5
package/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  <!-- INSERT-NEW-ENTRIES-HERE -->
4
4
 
5
+ ## 2.0.0-alpha.7 (2024-10-07)
6
+
7
+ - update gitignore ([164b521](https://github.com/xfiveco/generator-chisel/commit/164b521))
8
+ - update gitignore, plugins list and buttons css ([e136434](https://github.com/xfiveco/generator-chisel/commit/e136434))
9
+
10
+ ## 2.0.0-alpha.6 (2024-10-07)
11
+
12
+ - blocks, assets, css adjustments, breadcrumbs, bem fn ([b3460ce](https://github.com/xfiveco/generator-chisel/commit/b3460ce))
13
+ - page title, gravity forms, responsive image, slider fixes ([619789e](https://github.com/xfiveco/generator-chisel/commit/619789e))
14
+
5
15
  ## 2.0.0-alpha.5 (2024-09-27)
6
16
 
7
17
  - bugs fixes, blocks mods, adjustments ([5a2b460](https://github.com/xfiveco/generator-chisel/commit/5a2b460))
@@ -1,2 +1,4 @@
1
1
  /build
2
2
  /vendor
3
+ package-lock.json
4
+ composer.lock
@@ -12,24 +12,13 @@ $templates = array( 'archive.twig', 'index.twig' );
12
12
 
13
13
  $context = Timber::context();
14
14
 
15
- $context['title'] = 'Archive';
16
- if ( is_day() ) {
17
- $context['title'] = 'Archive: ' . get_the_date( 'D M Y' );
18
- } elseif ( is_month() ) {
19
- $context['title'] = 'Archive: ' . get_the_date( 'M Y' );
20
- } elseif ( is_year() ) {
21
- $context['title'] = 'Archive: ' . get_the_date( 'Y' );
22
- } elseif ( is_tag() ) {
23
- $context['title'] = __( 'Tag: ', 'chisel' ) . ' ' . single_tag_title( '', false );
15
+ if ( is_tag() ) {
24
16
  array_unshift( $templates, 'archive-' . get_queried_object()->slug . '.twig' );
25
17
  } elseif ( is_category() ) {
26
- $context['title'] = __( 'Category: ', 'chisel' ) . ' ' . single_cat_title( '', false );
27
18
  array_unshift( $templates, 'archive-' . get_queried_object()->slug . '.twig' );
28
19
  } elseif ( is_post_type_archive() ) {
29
- $context['title'] = post_type_archive_title( '', false );
30
20
  array_unshift( $templates, 'archive-' . get_post_type() . '.twig' );
31
21
  } elseif ( is_tax() ) {
32
- $context['title'] = single_term_title( '', false );
33
22
  array_unshift( $templates, 'archive-' . get_queried_object()->taxonomy . '.twig' );
34
23
  }
35
24
 
@@ -8,11 +8,7 @@
8
8
  use Chisel\ChiselCache;
9
9
  use Timber\Timber;
10
10
 
11
- $author = Timber::get_user( get_queried_object_id() );
12
-
13
- $context = Timber::context();
14
- $context['posts'] = Timber::get_posts();
15
- $context['author'] = $author;
16
- $context['title'] = __( 'Author: ', 'chisel' ) . $author->name;
11
+ $context = Timber::context();
12
+ $context['posts'] = Timber::get_posts();
17
13
 
18
14
  Timber::render( array( 'author.twig', 'archive.twig' ), $context, ChiselCache::expiry() );
@@ -162,7 +162,7 @@ class AcfBlocks extends RegisterBlocks implements Instance {
162
162
 
163
163
  // allow to use filters to manipulate the output.
164
164
  $context = apply_filters( 'chisel_timber_acf_blocks_data', $context );
165
- $context = apply_filters( 'chisel_timber_acf_blocks_data_' . $slug, $context );
165
+ $context = apply_filters( 'chisel_timber_acf_blocks_data_' . $block_slug, $context );
166
166
  $context = apply_filters( 'chisel_timber_acf_blocks_data_' . $block['id'], $context );
167
167
 
168
168
  $context['wrapper_attributes'] = get_block_wrapper_attributes(
@@ -16,6 +16,13 @@ class Assets implements Instance {
16
16
  */
17
17
  protected $frontend_styles = array();
18
18
 
19
+ /**
20
+ * Front-end styles to be registered and enqueued in footer.
21
+ *
22
+ * @var array
23
+ */
24
+ protected $frontend_footer_styles = array();
25
+
19
26
  /**
20
27
  * Front-end scripts to be registered and enqueued.
21
28
  *
@@ -177,6 +184,7 @@ class Assets implements Instance {
177
184
  add_action( 'init', array( $this, 'register_assets' ) );
178
185
 
179
186
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_frontend_assets' ), 99 ); // Higher priority, overwrite plugins if needed.
187
+ add_action( 'wp_footer', array( $this, 'enqueue_frontend_assets_in_footer' ), 11 ); // Higher priority, overwrite plugins if needed.
180
188
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ), 11 );
181
189
  add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_editor_scripts' ) );
182
190
  add_action( 'login_enqueue_scripts', array( $this, 'enqueue_login_page_assets' ), 99 );
@@ -195,66 +203,78 @@ class Assets implements Instance {
195
203
  * Register assets.
196
204
  */
197
205
  public function register_assets() {
198
- $this->frontend_styles = apply_filters( 'chisel_frontend_styles', $this->frontend_styles );
199
- $this->frontend_scripts = apply_filters( 'chisel_frontend_scripts', $this->frontend_scripts );
200
- $this->login_styles = apply_filters( 'chisel_login_styles', $this->login_styles );
201
- $this->login_scripts = apply_filters( 'chisel_login_scripts', $this->login_scripts );
202
- $this->admin_styles = apply_filters( 'chisel_admin_styles', $this->admin_styles );
203
- $this->admin_scripts = apply_filters( 'chisel_admin_scripts', $this->admin_scripts );
204
- $this->editor_styles = apply_filters( 'chisel_editor_styles', $this->editor_styles );
205
- $this->editor_scripts = apply_filters( 'chisel_editor_scripts', $this->editor_scripts );
206
+ if ( ! is_admin() ) {
207
+ $this->frontend_styles = apply_filters( 'chisel_frontend_styles', $this->frontend_styles );
208
+ $this->frontend_footer_styles = apply_filters( 'chisel_frontend_footer_styles', $this->frontend_footer_styles );
209
+ $this->frontend_scripts = apply_filters( 'chisel_frontend_scripts', $this->frontend_scripts );
210
+ $this->login_styles = apply_filters( 'chisel_login_styles', $this->login_styles );
211
+ $this->login_scripts = apply_filters( 'chisel_login_scripts', $this->login_scripts );
212
+
213
+ if ( $this->frontend_styles ) {
214
+ foreach ( $this->frontend_styles as $file_name => $args ) {
215
+ $this->register_style( self::get_final_handle( $file_name ), $file_name, $args );
216
+ }
217
+ }
206
218
 
207
- if ( $this->frontend_styles ) {
208
- foreach ( $this->frontend_styles as $file_name => $args ) {
209
- $this->register_style( self::get_final_handle( $file_name ), $file_name, $args );
219
+ if ( $this->frontend_footer_styles ) {
220
+ foreach ( $this->frontend_footer_styles as $file_name => $args ) {
221
+ $this->register_style( self::get_final_handle( $file_name ), $file_name, $args );
222
+ }
210
223
  }
211
- }
212
224
 
213
- if ( $this->frontend_scripts ) {
214
- foreach ( $this->frontend_scripts as $file_name => $args ) {
215
- $this->register_script( self::get_final_handle( $file_name ), $file_name, $args );
225
+ if ( $this->frontend_scripts ) {
226
+ foreach ( $this->frontend_scripts as $file_name => $args ) {
227
+ $this->register_script( self::get_final_handle( $file_name ), $file_name, $args );
228
+ }
216
229
  }
217
- }
218
230
 
219
- if ( $this->login_styles ) {
220
- $login_styles_data = array();
231
+ if ( is_login() ) {
232
+ if ( $this->login_styles ) {
233
+ $login_styles_data = array();
221
234
 
222
- foreach ( $this->login_styles as $file_name => $args ) {
223
- $login_styles_data = $this->register_style( self::get_final_handle( $file_name ), $file_name, $args );
224
- }
235
+ foreach ( $this->login_styles as $file_name => $args ) {
236
+ $login_styles_data = $this->register_style( self::get_final_handle( $file_name ), $file_name, $args );
237
+ }
225
238
 
226
- if ( isset( $login_styles_data['ver'] ) ) {
227
- wp_register_style( 'global-styles', false, array(), $login_styles_data['ver'] );
228
- }
229
- }
239
+ if ( isset( $login_styles_data['ver'] ) ) {
240
+ wp_register_style( 'global-styles', false, array(), $login_styles_data['ver'] );
241
+ }
242
+ }
230
243
 
231
- if ( $this->login_scripts ) {
232
- foreach ( $this->login_scripts as $file_name => $args ) {
233
- $this->register_script( self::get_final_handle( $file_name ), $file_name, $args );
244
+ if ( $this->login_scripts ) {
245
+ foreach ( $this->login_scripts as $file_name => $args ) {
246
+ $this->register_script( self::get_final_handle( $file_name ), $file_name, $args );
247
+ }
248
+ }
234
249
  }
235
- }
236
-
237
- if ( $this->admin_styles ) {
238
- foreach ( $this->admin_styles as $file_name => $args ) {
239
- $this->register_style( self::get_final_handle( $file_name ), $file_name, $args );
250
+ } else {
251
+ $this->admin_styles = apply_filters( 'chisel_admin_styles', $this->admin_styles );
252
+ $this->admin_scripts = apply_filters( 'chisel_admin_scripts', $this->admin_scripts );
253
+ $this->editor_styles = apply_filters( 'chisel_editor_styles', $this->editor_styles );
254
+ $this->editor_scripts = apply_filters( 'chisel_editor_scripts', $this->editor_scripts );
255
+
256
+ if ( $this->admin_styles ) {
257
+ foreach ( $this->admin_styles as $file_name => $args ) {
258
+ $this->register_style( self::get_final_handle( $file_name ), $file_name, $args );
259
+ }
240
260
  }
241
- }
242
261
 
243
- if ( $this->admin_scripts ) {
244
- foreach ( $this->admin_scripts as $file_name => $args ) {
245
- $this->register_script( self::get_final_handle( $file_name ), $file_name, $args );
262
+ if ( $this->admin_scripts ) {
263
+ foreach ( $this->admin_scripts as $file_name => $args ) {
264
+ $this->register_script( self::get_final_handle( $file_name ), $file_name, $args );
265
+ }
246
266
  }
247
- }
248
267
 
249
- if ( $this->editor_styles ) {
250
- foreach ( $this->editor_styles as $file_name => $args ) {
251
- $this->register_style( self::get_final_handle( $file_name ), $file_name, $args );
268
+ if ( $this->editor_styles ) {
269
+ foreach ( $this->editor_styles as $file_name => $args ) {
270
+ $this->register_style( self::get_final_handle( $file_name ), $file_name, $args );
271
+ }
252
272
  }
253
- }
254
273
 
255
- if ( $this->editor_scripts ) {
256
- foreach ( $this->editor_scripts as $file_name => $args ) {
257
- $this->register_script( self::get_final_handle( $file_name ), $file_name, $args );
274
+ if ( $this->editor_scripts ) {
275
+ foreach ( $this->editor_scripts as $file_name => $args ) {
276
+ $this->register_script( self::get_final_handle( $file_name ), $file_name, $args );
277
+ }
258
278
  }
259
279
  }
260
280
  }
@@ -293,6 +313,27 @@ class Assets implements Instance {
293
313
  }
294
314
  }
295
315
 
316
+ /**
317
+ * Enqueue front-end styles in footer, ie. Gravity Forms custom styles.
318
+ */
319
+ public function enqueue_frontend_assets_in_footer() {
320
+ $this->frontend_footer_styles = apply_filters( 'chisel_pre_enqueue_frontend_footer_styles', $this->frontend_footer_styles );
321
+
322
+ if ( $this->frontend_footer_styles ) {
323
+ foreach ( $this->frontend_footer_styles as $handle => $args ) {
324
+ $enqueue_style = apply_filters( 'chisel_enqueue_frontend_footer_style', true, $handle, $args );
325
+ $style_handle = self::get_final_handle( $handle );
326
+
327
+ if ( $enqueue_style && wp_style_is( $style_handle, 'registered' ) ) {
328
+ wp_enqueue_style( $style_handle );
329
+
330
+ // Enqueue js file for fast refresh of the css file.
331
+ $this->enqueue_style_js_for_dev( $handle );
332
+ }
333
+ }
334
+ }
335
+ }
336
+
296
337
  /**
297
338
  * Enqueue admin assets.
298
339
  */
@@ -77,6 +77,7 @@ class Blocks extends RegisterBlocks implements Instance {
77
77
 
78
78
  add_filter( 'should_load_separate_core_block_assets', array( $this, 'should_load_separate_core_block_assets' ) );
79
79
  add_filter( 'styles_inline_size_limit', array( $this, 'styles_inline_size_limit' ) );
80
+ add_filter( 'chisel_editor_scripts', array( $this, 'blocks_alignment_data' ) );
80
81
  }
81
82
 
82
83
  /**
@@ -215,6 +216,21 @@ class Blocks extends RegisterBlocks implements Instance {
215
216
  return $load;
216
217
  }
217
218
 
219
+ /**
220
+ * Set default alignment for blocks.
221
+ *
222
+ * @param array $editor_scripts_data
223
+ *
224
+ * @return array
225
+ */
226
+ public function blocks_alignment_data( $editor_scripts_data ) {
227
+ $editor_scripts_data['editor']['localize']['data']['blocksDefaultAlignment'] = array(
228
+ 'chisel/slider' => 'full',
229
+ );
230
+
231
+ return $editor_scripts_data;
232
+ }
233
+
218
234
  /**
219
235
  * Get block object classnames
220
236
  *
@@ -86,7 +86,7 @@ class Components {
86
86
  $logo_id = get_theme_mod( 'custom_logo', 0 );
87
87
 
88
88
  if ( $logo_id ) {
89
- self::$logo_image = Timber::get_image( $logo_id )->responsive();
89
+ self::$logo_image = Helpers::get_responsive_image( $logo_id );
90
90
  }
91
91
 
92
92
  $context['logo_image'] = self::$logo_image;
@@ -172,36 +172,73 @@ class Components {
172
172
  }
173
173
 
174
174
  /**
175
- * Get the page or post title html based on the acf field value.
176
- *
177
- * @param int $post_id
175
+ * Get the current page title.
178
176
  *
179
177
  * @return string|html
180
178
  */
181
- public static function get_the_title( $post_id ) {
182
- $context = Timber::context();
179
+ public static function get_the_title() {
180
+ $classname = 'c-title';
181
+ $the_title = array();
182
+ $title_text = '';
183
+ $title_class = '';
184
+
185
+ if ( self::$the_title !== null ) {
186
+ return self::$the_title;
187
+ }
183
188
 
184
- if ( self::$the_title === null ) {
185
- $display = Acf::get_field( 'page_title_display', $post_id ) ?: 'show';
189
+ if ( is_singular() ) {
190
+ global $post;
186
191
 
187
- if ( $display === 'hide' ) {
188
- self::$the_title = array();
189
- } else {
190
- $title = get_the_title( $post_id );
191
- $sr_only = $display === 'hide-visually' ? 'u-sr-only' : '';
192
+ if ( isset( $post->ID ) ) {
193
+ $display_title = Acf::get_field( 'page_title_display', $post->ID ) ?: 'show';
192
194
 
193
- self::$the_title = array(
194
- 'class' => sprintf( 'c-title %s', $sr_only ),
195
- 'text' => esc_html( $title ),
196
- );
195
+ if ( $display_title !== 'hide' ) {
196
+ $title_text = get_the_title( $post->ID );
197
+ $sr_only = $display_title === 'hide-visually' ? 'u-sr-only' : '';
198
+ $title_class = sprintf( '%s %s', $classname, $sr_only );
199
+ }
197
200
  }
201
+ } elseif ( is_home() ) {
202
+ $posts_page_id = absint( get_option( 'page_for_posts' ) );
203
+
204
+ if ( $posts_page_id ) {
205
+ $title_text = get_the_title( $posts_page_id );
206
+ }
207
+ } elseif ( is_author() ) {
208
+ $author = Timber::get_user( get_queried_object_id() );
209
+ $title_text = __( 'Author: ', 'chisel' ) . $author->name;
210
+ } elseif ( is_day() ) {
211
+ $title_text = __( 'Date archive: ', 'chisel' ) . ' ' . get_the_date( 'D M Y' );
212
+ } elseif ( is_month() ) {
213
+ $title_text = __( 'Date archive: ', 'chisel' ) . ' ' . get_the_date( 'M Y' );
214
+ } elseif ( is_year() ) {
215
+ $title_text = __( 'Date archive: ', 'chisel' ) . ' ' . get_the_date( 'Y' );
216
+ } elseif ( is_tag() ) {
217
+ $title_text = __( 'Tag: ', 'chisel' ) . ' ' . single_tag_title( '', false );
218
+ } elseif ( is_category() ) {
219
+ $title_text = __( 'Category: ', 'chisel' ) . ' ' . single_cat_title( '', false );
220
+ } elseif ( is_post_type_archive() ) {
221
+ $title_text = post_type_archive_title( '', false );
222
+ } elseif ( is_tax() ) {
223
+ $title_text = single_term_title( '', false );
224
+ } elseif ( is_search() ) {
225
+ $title_text = __( 'Search results for: ', 'chisel' ) . ' ' . get_search_query();
226
+ } elseif ( is_404() ) {
227
+ $title_text = __( '404 - Page not found', 'chisel' );
228
+ }
229
+
230
+ if ( $title_text ) {
231
+ $the_title = array(
232
+ 'text' => esc_html( $title_text ),
233
+ 'class' => $title_class ? esc_attr( $title_class ) : $classname,
234
+ );
198
235
  }
199
236
 
200
- $context['the_title'] = apply_filters( 'chisel_the_title', self::$the_title, $post_id );
237
+ self::$the_title = apply_filters( 'chisel_the_title', $the_title );
201
238
 
202
239
  return Timber::compile(
203
240
  'partials/the-title.twig',
204
- $context,
241
+ array( 'the_title' => self::$the_title ),
205
242
  ChiselCache::expiry()
206
243
  );
207
244
  }
@@ -398,7 +398,7 @@ class CustomPostTypes implements Instance {
398
398
  // 'singular' => __( 'Chisel CPT', 'chisel' ),
399
399
  // 'plural' => __( 'Chisel CPTs', 'chisel' ),
400
400
  // 'supports' => array( 'editor', 'thumbnail', 'excerpt' ),
401
- // 'icon' => 'location-alt',
401
+ // 'menu_icon' => 'location-alt',
402
402
  // 'hierarchical' => true,
403
403
  // 'public' => true,
404
404
  // 'menu_position' => 20,
@@ -34,7 +34,7 @@ class ExtendedPost extends TimberPost {
34
34
  */
35
35
  public function get_thumbnail( $size = 'medium' ) {
36
36
  if ( ! $this->thumbnail_html ) {
37
- $this->thumbnail_html = has_post_thumbnail( $this->ID ) ? Timber::get_image( get_post_thumbnail_id( $this->ID ) )->responsive( $size ) : '';
37
+ $this->thumbnail_html = has_post_thumbnail( $this->ID ) ? Helpers::get_responsive_image( get_post_thumbnail_id( $this->ID ), $size ) : '';
38
38
  }
39
39
 
40
40
  return $this->thumbnail_html;
@@ -27,7 +27,7 @@ class ExtendedProduct extends TimberPost {
27
27
  */
28
28
  public function get_thumbnail( $size = 'woocommerce_thumbnail' ) {
29
29
  if ( ! $this->thumbnail_html ) {
30
- $thumbnail_html = has_post_thumbnail( $this->ID ) ? Timber::get_image( get_post_thumbnail_id( $this->ID ) )->responsive( $size ) : '';
30
+ $thumbnail_html = has_post_thumbnail( $this->ID ) ? Helpers::get_responsive_image( get_post_thumbnail_id( $this->ID ), $size ) : '';
31
31
 
32
32
  if ( ! $thumbnail_html ) {
33
33
  $thumbnail_html = wc_placeholder_img( $size );
@@ -38,8 +38,8 @@ class GravityForms implements Instance {
38
38
  * Register filter hooks.
39
39
  */
40
40
  public function filter_hooks() {
41
- add_filter( 'chisel_frontend_styles', array( $this, 'register_custom_styles' ) );
42
- add_filter( 'chisel_enqueue_frontend_style', array( $this, 'enqueue_custom_styles' ), 10, 3 );
41
+ add_filter( 'chisel_frontend_footer_styles', array( $this, 'register_custom_styles' ) );
42
+ add_filter( 'chisel_enqueue_frontend_footer_style', array( $this, 'enqueue_custom_styles' ), 10, 3 );
43
43
  add_filter( 'gform_form_theme_slug', array( $this, 'default_form_styles' ), 99, 2 );
44
44
  add_filter( 'gform_plugin_settings_fields', array( $this, 'plugin_settings_fields' ), 99 );
45
45
  }
@@ -116,6 +116,51 @@ class GravityForms implements Instance {
116
116
  return $fields;
117
117
  }
118
118
 
119
+ /**
120
+ * Get list of available Gravity Forms. Can be used in acf/load_field filter to populate the select field.
121
+ *
122
+ * @return array
123
+ */
124
+ public static function forms_list() {
125
+ if ( ! class_exists( 'GFForms' ) ) {
126
+ return array();
127
+ }
128
+
129
+ $forms = \GFAPI::get_forms();
130
+
131
+ $list = array();
132
+
133
+ if ( $forms ) {
134
+ foreach ( $forms as $form ) {
135
+ $list[$form['id']] = $form['title'];
136
+ }
137
+ }
138
+
139
+ return $list;
140
+ }
141
+
142
+ /**
143
+ * This function will generate the gravity form for a given id with default parameters. Use if you need to generate ajax fomr outside of blocks.
144
+ *
145
+ * @param int $form_id
146
+ * @param bool $display_title
147
+ * @param bool $display_description
148
+ * @param bool $display_inactive
149
+ * @param array $field_values
150
+ * @param bool $ajax
151
+ * @param int $tabindex
152
+ * @param bool $_echo
153
+ *
154
+ * @return mixed
155
+ */
156
+ public static function get_contact_form( $form_id, $display_title = false, $display_description = false, $display_inactive = false, $field_values = null, $ajax = true, $tabindex = 0, $_echo = false ) {
157
+ if ( function_exists( 'gravity_form' ) ) {
158
+ return gravity_form( $form_id, $display_title, $display_description, $display_inactive, $field_values, $ajax, $tabindex, $_echo );
159
+ }
160
+
161
+ return null;
162
+ }
163
+
119
164
  /**
120
165
  * Check if Gravity Forms plugin is active.
121
166
  *
@@ -2,6 +2,8 @@
2
2
 
3
3
  namespace Chisel;
4
4
 
5
+ use Timber\Timber;
6
+
5
7
  /**
6
8
  * Helper functions.
7
9
  *
@@ -115,6 +117,71 @@ class Helpers {
115
117
  return get_template_directory_uri() . $image_path;
116
118
  }
117
119
 
120
+ /**
121
+ * Get responsive image html
122
+ *
123
+ * @param int $image_id Image ID.
124
+ * @param string $image_size Image size.
125
+ * @param array $attrs Image attributes.
126
+ *
127
+ * @return string|html
128
+ */
129
+ public static function get_responsive_image( $image_id, $image_size = 'medium', $attrs = array() ) {
130
+ if ( ! $image_id ) {
131
+ return '';
132
+ }
133
+
134
+ return Timber::get_image( $image_id )->responsive( $image_size, $attrs );
135
+ }
136
+
137
+ /**
138
+ * Generate BEM class names with modifiers
139
+ *
140
+ * @param string $name
141
+ * @param mixed ...$modifiers
142
+ *
143
+ * @return string
144
+ */
145
+ public static function bem( $name = '', ...$modifiers ) {
146
+ if ( empty( $name ) || empty( $modifiers ) ) {
147
+ return '';
148
+ }
149
+
150
+ $classnames = array( $name );
151
+
152
+ foreach ( $modifiers as $key => $value ) {
153
+ if ( is_array( $value ) ) {
154
+ $values = array_map(
155
+ function ( $val ) use ( $name, $value ) {
156
+ return $name . '--' . _wp_to_kebab_case( $val . '-' . $value[ $val ] );
157
+ },
158
+ array_keys( $value )
159
+ );
160
+
161
+ $classnames = array_merge( $classnames, $values );
162
+ continue;
163
+ }
164
+
165
+ if ( $value === false || $value === null || $value === '' ) {
166
+ continue;
167
+ }
168
+
169
+ if ( is_string( $key ) ) {
170
+ $classname = $name . '--' . _wp_to_kebab_case( $key );
171
+
172
+ if ( ! is_bool( $value ) ) {
173
+ $classname .= '-' . _wp_to_kebab_case( $value );
174
+ }
175
+ } else {
176
+ $classname = $name . '--' . _wp_to_kebab_case( $value );
177
+ }
178
+
179
+ $classnames[] = $classname;
180
+ }
181
+
182
+ return implode( ' ', $classnames );
183
+ }
184
+
118
185
  /**
119
186
  * Get logo data for the wp login page.
120
187
  *
@@ -189,7 +189,8 @@ abstract class RegisterBlocks {
189
189
  $block
190
190
  );
191
191
 
192
- if ( ! in_array( $script, $ignore_scripts, true ) ) {
192
+ // Register ignored scripts in dev mode in order to watch changes.
193
+ if ( Assets::is_fast_refresh() || ( ! Assets::is_fast_refresh() && ! in_array( $script, $ignore_scripts, true ) ) ) {
193
194
  wp_register_script(
194
195
  $block_handle,
195
196
  $file_url,
@@ -40,7 +40,6 @@ class Site extends TimberSite implements Instance {
40
40
  */
41
41
  public function filter_hooks() {
42
42
  add_filter( 'timber/context', array( $this, 'add_to_context' ) );
43
- add_filter( 'timber/context', array( $this, 'set_page_title' ) );
44
43
  add_filter( 'timber/post/classmap', array( $this, 'post_classmap' ) );
45
44
  add_filter( 'timber/term/classmap', array( $this, 'term_classmap' ) );
46
45
  }
@@ -56,23 +55,7 @@ class Site extends TimberSite implements Instance {
56
55
  $context['menus'] = Components::get_menus();
57
56
  $context['sidebar'] = Components::get_sidebar();
58
57
  $context['footer_sidebars'] = Components::get_footer_sidebars();
59
-
60
- return $context;
61
- }
62
-
63
- /**
64
- * Set the page / post title
65
- *
66
- * @param array $context The context.
67
- *
68
- * @return array
69
- */
70
- public function set_page_title( $context ) {
71
- global $post;
72
-
73
- if ( isset( $post->post_type ) ) {
74
- $context['the_title'] = Components::get_the_title( $post->ID );
75
- }
58
+ $context['the_title'] = Components::get_the_title();
76
59
 
77
60
  return $context;
78
61
  }
@@ -47,11 +47,10 @@ class Theme implements Instance {
47
47
  * Register action hooks.
48
48
  */
49
49
  public function action_hooks() {
50
- add_action( 'after_setup_theme', array( $this, 'theme_supports' ) );
50
+ add_action( 'init', array( $this, 'theme_supports' ), 11 );
51
51
  add_action( 'after_setup_theme', array( $this, 'remove_post_supports' ), 99 );
52
52
  add_action( 'init', array( $this, 'register_nav_menus' ) );
53
53
  add_action( 'after_setup_theme', array( $this, 'i18n' ) );
54
- add_action( 'wp_head', array( $this, 'set_scrollbar_width_for_css' ) );
55
54
  }
56
55
 
57
56
  /**
@@ -145,24 +144,6 @@ class Theme implements Instance {
145
144
  );
146
145
  }
147
146
 
148
- /**
149
- * Calculate scrollbar width and set it as a CSS variable.
150
- */
151
- public function set_scrollbar_width_for_css() {
152
- ?>
153
- <script>
154
- function getScrollbarWidth() {
155
- return window.innerWidth - document.documentElement.clientWidth;
156
- }
157
-
158
- setTimeout(() => {
159
- const scrollbarWidth = getScrollbarWidth();
160
- document.documentElement.style.setProperty('--scrollbar-width', `${scrollbarWidth}px`);
161
- }, 10);
162
- </script>
163
- <?php
164
- }
165
-
166
147
  /**
167
148
  * Add custom classes to the body tag.
168
149
  *