generator-chisel 2.1.1 → 2.2.0

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 (68) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/lib/commands/create/creators/app/chisel-starter-theme/404.php +1 -1
  3. package/lib/commands/create/creators/app/chisel-starter-theme/archive.php +1 -1
  4. package/lib/commands/create/creators/app/chisel-starter-theme/author.php +1 -1
  5. package/lib/commands/create/creators/app/chisel-starter-theme/composer.json +7 -6
  6. package/lib/commands/create/creators/app/chisel-starter-theme/footer.php +1 -1
  7. package/lib/commands/create/creators/app/chisel-starter-theme/functions.php +3 -3
  8. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Controllers/AjaxController.php +22 -17
  9. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Enums/AcfOptionsPageType.php +8 -0
  10. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Enums/BlocksType.php +17 -0
  11. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Factories/RegisterAcfOptionsPage.php +78 -0
  12. package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Factory → Factories}/RegisterBlocks.php +41 -30
  13. package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Factory → Factories}/RegisterCustomPostType.php +44 -32
  14. package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Factory → Factories}/RegisterCustomTaxonomy.php +39 -27
  15. package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Helper → Helpers}/AcfHelpers.php +12 -12
  16. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helpers/AjaxHelpers.php +36 -0
  17. package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Helper → Helpers}/AssetsHelpers.php +3 -3
  18. package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Helper → Helpers}/BlocksHelpers.php +22 -18
  19. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helpers/CacheHelpers.php +43 -0
  20. package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Helper → Helpers}/CommentsHelpers.php +8 -6
  21. package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Helper → Helpers}/DataHelpers.php +5 -5
  22. package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Helper → Helpers}/GravityFormsHelpers.php +13 -13
  23. package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Helper → Helpers}/ImageHelpers.php +30 -15
  24. package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Helper → Helpers}/ThemeHelpers.php +29 -25
  25. package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Helper → Helpers}/WoocommerceHelpers.php +15 -9
  26. package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Helper → Helpers}/YoastHelpers.php +6 -6
  27. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Interfaces/HooksInterface.php +3 -3
  28. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Interfaces/InstanceInterface.php +1 -1
  29. package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Plugin → Plugins}/GravityForms.php +13 -15
  30. package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Plugin → Plugins}/Woocommerce.php +14 -14
  31. package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Plugin → Plugins}/Yoast.php +6 -6
  32. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Traits/PageBlocks.php +14 -14
  33. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Traits/Singleton.php +28 -7
  34. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Acf.php +16 -15
  35. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/AcfBlocks.php +19 -19
  36. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/{AjaxEnpoints.php → AjaxEndpoints.php} +13 -13
  37. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Assets.php +42 -68
  38. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Blocks.php +38 -27
  39. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Cache.php +10 -11
  40. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/ChiselImage.php +3 -2
  41. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/ChiselPost.php +13 -7
  42. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/ChiselProduct.php +11 -10
  43. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/ChiselProductCategory.php +10 -10
  44. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Comments.php +27 -35
  45. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Components.php +44 -61
  46. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/CustomPostTypes.php +12 -13
  47. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/CustomTaxonomies.php +12 -13
  48. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Sidebars.php +6 -6
  49. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Site.php +7 -8
  50. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Theme.php +25 -22
  51. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Twig.php +53 -48
  52. package/lib/commands/create/creators/app/chisel-starter-theme/index.php +1 -1
  53. package/lib/commands/create/creators/app/chisel-starter-theme/page.php +1 -1
  54. package/lib/commands/create/creators/app/chisel-starter-theme/search.php +1 -1
  55. package/lib/commands/create/creators/app/chisel-starter-theme/single.php +1 -1
  56. package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks-acf/slider/slider.twig +1 -1
  57. package/lib/commands/create/creators/app/chisel-starter-theme/src/design/settings/_index.scss +1 -0
  58. package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/blocks-styles.js +3 -2
  59. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_content.scss +0 -1
  60. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/elements/_html.scss +2 -0
  61. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/vendor/_breadcrumbs.scss +6 -3
  62. package/lib/commands/create/creators/app/chisel-starter-theme/style.chisel-tpl.css +1 -1
  63. package/lib/commands/create/creators/app/chisel-starter-theme/woocommerce.php +3 -3
  64. package/lib/commands/create/packages-versions.js +1 -1
  65. package/package.json +2 -2
  66. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Factory/RegisterAcfOptionsPage.php +0 -62
  67. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/AjaxHelpers.php +0 -33
  68. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/CacheHelpers.php +0 -41
@@ -5,14 +5,14 @@ namespace Chisel\WP;
5
5
  use Chisel\Interfaces\InstanceInterface;
6
6
  use Chisel\Interfaces\HooksInterface;
7
7
  use Chisel\Traits\Singleton;
8
- use Chisel\Factory\RegisterCustomTaxonomy;
8
+ use Chisel\Factories\RegisterCustomTaxonomy;
9
9
 
10
10
  /**
11
11
  * Custom post types and taxonomies wrapper class.
12
12
  *
13
13
  * @package Chisel
14
14
  */
15
- class CustomTaxonomies implements InstanceInterface, HooksInterface {
15
+ final class CustomTaxonomies implements InstanceInterface, HooksInterface {
16
16
 
17
17
  use Singleton;
18
18
 
@@ -21,21 +21,21 @@ class CustomTaxonomies implements InstanceInterface, HooksInterface {
21
21
  *
22
22
  * @var array
23
23
  */
24
- private $taxonomies = array();
24
+ private array $taxonomies = array();
25
25
 
26
26
  /**
27
27
  * Default taxonomy rewrite args.
28
28
  *
29
29
  * @var array
30
30
  */
31
- private $default_taxonomy_rewrite_args = array();
31
+ private array $default_taxonomy_rewrite_args = array();
32
32
 
33
33
  /**
34
34
  * Default taxonomy capabilities.
35
35
  *
36
36
  * @var array
37
37
  */
38
- private $default_taxonomy_capabilities = array();
38
+ private array $default_taxonomy_capabilities = array();
39
39
 
40
40
  /**
41
41
  * Class constructor.
@@ -50,8 +50,8 @@ class CustomTaxonomies implements InstanceInterface, HooksInterface {
50
50
  /**
51
51
  * Set properties.
52
52
  */
53
- public function set_properties() {
54
- $this->default_taxonomy_capabilities = apply_filters(
53
+ public function set_properties(): void {
54
+ $this->default_taxonomy_capabilities = (array) apply_filters(
55
55
  'chisel_default_taxonomy_capabilities',
56
56
  array(
57
57
  'manage_terms' => 'manage_categories',
@@ -60,7 +60,7 @@ class CustomTaxonomies implements InstanceInterface, HooksInterface {
60
60
  'assign_terms' => 'edit_posts',
61
61
  )
62
62
  );
63
- $this->default_taxonomy_rewrite_args = apply_filters(
63
+ $this->default_taxonomy_rewrite_args = (array) apply_filters(
64
64
  'chisel_default_taxonomy_rewrite_args',
65
65
  array(
66
66
  'slug' => '',
@@ -76,20 +76,19 @@ class CustomTaxonomies implements InstanceInterface, HooksInterface {
76
76
  /**
77
77
  * Register action hooks.
78
78
  */
79
- public function action_hooks() {
79
+ public function action_hooks(): void {
80
80
  add_action( 'init', array( $this, 'register_taxonomies' ) );
81
81
  }
82
82
 
83
83
  /**
84
84
  * Register filter hooks.
85
85
  */
86
- public function filter_hooks() {
87
- }
86
+ public function filter_hooks(): void {}
88
87
 
89
88
  /**
90
89
  * Register custom taxonomies.
91
90
  */
92
- public function register_taxonomies() {
91
+ public function register_taxonomies(): void {
93
92
  $this->taxonomies = apply_filters( 'chisel_custom_taxonomies', $this->taxonomies );
94
93
 
95
94
  if ( empty( $this->taxonomies ) ) {
@@ -111,7 +110,7 @@ class CustomTaxonomies implements InstanceInterface, HooksInterface {
111
110
  /**
112
111
  * Set custom taxonomies.
113
112
  */
114
- private function set_taxonomies() {
113
+ private function set_taxonomies(): void {
115
114
  $this->taxonomies = array(
116
115
  // phpcs:disable
117
116
  // 'chisel-term' => array(
@@ -20,7 +20,7 @@ class Sidebars implements InstanceInterface, HooksInterface {
20
20
  *
21
21
  * @var array
22
22
  */
23
- private $sidebars = array();
23
+ private array $sidebars = array();
24
24
 
25
25
  /**
26
26
  * Class constructor.
@@ -35,7 +35,7 @@ class Sidebars implements InstanceInterface, HooksInterface {
35
35
  /**
36
36
  * Set properties.
37
37
  */
38
- public function set_properties() {
38
+ public function set_properties(): void {
39
39
  $this->sidebars = array(
40
40
  'blog' => array(
41
41
  'name' => __( 'Blog', 'chisel' ),
@@ -67,23 +67,23 @@ class Sidebars implements InstanceInterface, HooksInterface {
67
67
  /**
68
68
  * Register action hooks.
69
69
  */
70
- public function action_hooks() {
70
+ public function action_hooks(): void {
71
71
  add_action( 'widgets_init', array( $this, 'register_sidebars' ) );
72
72
  }
73
73
 
74
74
  /**
75
75
  * Register filter hooks.
76
76
  */
77
- public function filter_hooks() {
77
+ public function filter_hooks(): void {
78
78
  }
79
79
 
80
80
  /**
81
81
  * Register sidebars.
82
82
  */
83
- public function register_sidebars() {
83
+ public function register_sidebars(): void {
84
84
  $this->sidebars = apply_filters( 'chisel_sidebars', $this->sidebars );
85
85
 
86
- if ( ! $this->sidebars ) {
86
+ if ( empty( $this->sidebars ) ) {
87
87
  return;
88
88
  }
89
89
 
@@ -15,7 +15,7 @@ use Chisel\Traits\Singleton;
15
15
  *
16
16
  * @package Chisel
17
17
  */
18
- class Site extends TimberSite implements InstanceInterface, HooksInterface {
18
+ final class Site extends TimberSite implements InstanceInterface, HooksInterface {
19
19
 
20
20
  use Singleton;
21
21
 
@@ -34,18 +34,17 @@ class Site extends TimberSite implements InstanceInterface, HooksInterface {
34
34
  /**
35
35
  * Set properties.
36
36
  */
37
- public function set_properties() {}
37
+ public function set_properties(): void {}
38
38
 
39
39
  /**
40
40
  * Register action hooks.
41
41
  */
42
- public function action_hooks() {
43
- }
42
+ public function action_hooks(): void {}
44
43
 
45
44
  /**
46
45
  * Register filter hooks.
47
46
  */
48
- public function filter_hooks() {
47
+ public function filter_hooks(): void {
49
48
  add_filter( 'timber/context', array( $this, 'add_to_context' ) );
50
49
  add_filter( 'timber/post/classmap', array( $this, 'post_classmap' ) );
51
50
  add_filter( 'timber/term/classmap', array( $this, 'term_classmap' ) );
@@ -57,7 +56,7 @@ class Site extends TimberSite implements InstanceInterface, HooksInterface {
57
56
  * @param array $context The context.
58
57
  * @return array
59
58
  */
60
- public function add_to_context( $context ) {
59
+ public function add_to_context( array $context ): array {
61
60
  $context['logo'] = Components::get_logo();
62
61
  $context['menus'] = Components::get_menus();
63
62
  $context['sidebar'] = Components::get_sidebar();
@@ -73,7 +72,7 @@ class Site extends TimberSite implements InstanceInterface, HooksInterface {
73
72
  * @param array $classmap The class map.
74
73
  * @return array
75
74
  */
76
- public function post_classmap( $classmap ) {
75
+ public function post_classmap( array $classmap ): array {
77
76
  $custom_classmap = array(
78
77
  'post' => ChiselPost::class,
79
78
  'page' => ChiselPost::class,
@@ -90,7 +89,7 @@ class Site extends TimberSite implements InstanceInterface, HooksInterface {
90
89
  * @param array $classmap The class map.
91
90
  * @return array
92
91
  */
93
- public function term_classmap( $classmap ) {
92
+ public function term_classmap( array $classmap ): array {
94
93
  $custom_classmap = array(
95
94
  'category' => ChiselTerm::class,
96
95
  'product_cat' => ChiselProductCategory::class,
@@ -5,14 +5,14 @@ namespace Chisel\WP;
5
5
  use Chisel\Interfaces\InstanceInterface;
6
6
  use Chisel\Interfaces\HooksInterface;
7
7
  use Chisel\Traits\Singleton;
8
- use Chisel\Helper\ThemeHelpers;
8
+ use Chisel\Helpers\ThemeHelpers;
9
9
 
10
10
  /**
11
11
  * WordPress Theme setup related functionality.
12
12
  *
13
13
  * @package Chisel
14
14
  */
15
- class Theme implements InstanceInterface, HooksInterface {
15
+ final class Theme implements InstanceInterface, HooksInterface {
16
16
 
17
17
  use Singleton;
18
18
 
@@ -21,14 +21,14 @@ class Theme implements InstanceInterface, HooksInterface {
21
21
  *
22
22
  * @var array
23
23
  */
24
- private $post_thumbnails_post_types = array( 'post' );
24
+ private array $post_thumbnails_post_types = array( 'post' );
25
25
 
26
26
  /**
27
27
  * Navigation menus.
28
28
  *
29
29
  * @var array
30
30
  */
31
- private $nav_menus = array();
31
+ private array $nav_menus = array();
32
32
 
33
33
  /**
34
34
  * Class constructor.
@@ -43,7 +43,7 @@ class Theme implements InstanceInterface, HooksInterface {
43
43
  /**
44
44
  * Set properties.
45
45
  */
46
- public function set_properties() {
46
+ public function set_properties(): void {
47
47
  // Set nav menus to register.
48
48
  $this->nav_menus = array(
49
49
  'chisel_main_nav' => __( 'Main Navigation', 'chisel' ),
@@ -54,7 +54,7 @@ class Theme implements InstanceInterface, HooksInterface {
54
54
  /**
55
55
  * Register action hooks.
56
56
  */
57
- public function action_hooks() {
57
+ public function action_hooks(): void {
58
58
  add_action( 'init', array( $this, 'theme_supports' ), 11 );
59
59
  add_action( 'after_setup_theme', array( $this, 'remove_post_supports' ), 99 );
60
60
  add_action( 'init', array( $this, 'register_nav_menus' ) );
@@ -64,7 +64,7 @@ class Theme implements InstanceInterface, HooksInterface {
64
64
  /**
65
65
  * Register filter hooks.
66
66
  */
67
- public function filter_hooks() {
67
+ public function filter_hooks(): void {
68
68
  add_filter( 'body_class', array( $this, 'body_classes' ) );
69
69
  add_filter( 'tiny_mce_before_init', array( $this, 'mce_custom_colors' ) );
70
70
  add_filter( 'login_headertext', array( $this, 'login_headertext' ) );
@@ -72,13 +72,16 @@ class Theme implements InstanceInterface, HooksInterface {
72
72
  add_filter( 'wp_revisions_to_keep', array( $this, 'wp_revisions_to_keep' ), 99, 2 );
73
73
  add_filter( 'heartbeat_settings', array( $this, 'heartbeat_settings' ) );
74
74
  add_filter( 'jpeg_quality', array( $this, 'jpeg_quality' ) );
75
+
76
+ // Disable legacy support for XML-RPC.
77
+ add_filter( 'xmlrpc_enabled', '__return_false' );
75
78
  }
76
79
 
77
80
  /**
78
81
  * Add theme supports.
79
82
  */
80
- public function theme_supports() {
81
- $this->post_thumbnails_post_types = apply_filters( 'chisel_post_thumbnails_post_types', $this->post_thumbnails_post_types );
83
+ public function theme_supports(): void {
84
+ $this->post_thumbnails_post_types = (array) apply_filters( 'chisel_post_thumbnails_post_types', $this->post_thumbnails_post_types );
82
85
 
83
86
  add_theme_support( 'post-formats', array() );
84
87
  add_theme_support( 'post-thumbnails', $this->post_thumbnails_post_types );
@@ -114,7 +117,7 @@ class Theme implements InstanceInterface, HooksInterface {
114
117
  /**
115
118
  * Remove post supports.
116
119
  */
117
- public function remove_post_supports() {
120
+ public function remove_post_supports(): void {
118
121
  remove_post_type_support( 'page', 'excerpt' );
119
122
  remove_post_type_support( 'attachment', 'comments' );
120
123
  }
@@ -122,8 +125,8 @@ class Theme implements InstanceInterface, HooksInterface {
122
125
  /**
123
126
  * Register navigation menus.
124
127
  */
125
- public function register_nav_menus() {
126
- $this->nav_menus = apply_filters( 'chisel_nav_menus', $this->nav_menus );
128
+ public function register_nav_menus(): void {
129
+ $this->nav_menus = (array) apply_filters( 'chisel_nav_menus', $this->nav_menus );
127
130
 
128
131
  register_nav_menus( $this->nav_menus );
129
132
  }
@@ -131,7 +134,7 @@ class Theme implements InstanceInterface, HooksInterface {
131
134
  /**
132
135
  * Load theme internationalization files.
133
136
  */
134
- public function i18n() {
137
+ public function i18n(): void {
135
138
  // Load user's custom translations from wp-content/languages/ folder.
136
139
  load_textdomain(
137
140
  'chisel',
@@ -160,7 +163,7 @@ class Theme implements InstanceInterface, HooksInterface {
160
163
  *
161
164
  * @return array
162
165
  */
163
- public function body_classes( $classes ) {
166
+ public function body_classes( array $classes ): array {
164
167
  $classes[] = 'chisel-theme';
165
168
 
166
169
  return $classes;
@@ -173,7 +176,7 @@ class Theme implements InstanceInterface, HooksInterface {
173
176
  *
174
177
  * @return array
175
178
  */
176
- public function mce_custom_colors( $settings ) {
179
+ public function mce_custom_colors( array $settings ): array {
177
180
  $default_colors = '
178
181
  "000000", "Black",
179
182
  "993300", "Burnt orange",
@@ -232,7 +235,7 @@ class Theme implements InstanceInterface, HooksInterface {
232
235
  *
233
236
  * @return string
234
237
  */
235
- public function login_headertext( $text ) {
238
+ public function login_headertext( string $text ): string {
236
239
  $text = esc_attr( get_bloginfo( 'name' ) );
237
240
 
238
241
  return $text;
@@ -245,7 +248,7 @@ class Theme implements InstanceInterface, HooksInterface {
245
248
  *
246
249
  * @return string
247
250
  */
248
- public function login_headerurl( $url ) {
251
+ public function login_headerurl( string $url ): string {
249
252
  $url = esc_url( get_bloginfo( 'url' ) );
250
253
 
251
254
  return $url;
@@ -254,12 +257,12 @@ class Theme implements InstanceInterface, HooksInterface {
254
257
  /**
255
258
  * Set the limit of revisions to keep.
256
259
  *
257
- * @param int $num
258
- * @param object $post
260
+ * @param int $num
261
+ * @param \WP_Post $post
259
262
  *
260
263
  * @return int
261
264
  */
262
- public function wp_revisions_to_keep( $num, $post ) {
265
+ public function wp_revisions_to_keep( int $num, \WP_Post $post ): int {
263
266
  return 10;
264
267
  }
265
268
 
@@ -270,7 +273,7 @@ class Theme implements InstanceInterface, HooksInterface {
270
273
  *
271
274
  * @return array
272
275
  */
273
- public function heartbeat_settings( $settings ) {
276
+ public function heartbeat_settings( array $settings ): array {
274
277
  $settings['interval'] = 30;
275
278
 
276
279
  return $settings;
@@ -283,7 +286,7 @@ class Theme implements InstanceInterface, HooksInterface {
283
286
  *
284
287
  * @return int
285
288
  */
286
- public function jpeg_quality( $quality ) {
289
+ public function jpeg_quality( int $quality ): int {
287
290
  return 90;
288
291
  }
289
292
  }
@@ -7,12 +7,12 @@ use Timber\Timber;
7
7
  use Chisel\Interfaces\InstanceInterface;
8
8
  use Chisel\Interfaces\HooksInterface;
9
9
  use Chisel\Traits\Singleton;
10
- use Chisel\Helper\CommentsHelpers;
11
- use Chisel\Helper\DataHelpers;
12
- use Chisel\Helper\ImageHelpers;
13
- use Chisel\Helper\ThemeHelpers;
14
- use Chisel\Helper\WoocommerceHelpers;
15
- use Chisel\Helper\YoastHelpers;
10
+ use Chisel\Helpers\CommentsHelpers;
11
+ use Chisel\Helpers\DataHelpers;
12
+ use Chisel\Helpers\ImageHelpers;
13
+ use Chisel\Helpers\ThemeHelpers;
14
+ use Chisel\Helpers\WoocommerceHelpers;
15
+ use Chisel\Helpers\YoastHelpers;
16
16
  use Chisel\WP\Components;
17
17
 
18
18
  /**
@@ -20,7 +20,7 @@ use Chisel\WP\Components;
20
20
  *
21
21
  * @package Chisel
22
22
  */
23
- class Twig implements InstanceInterface, HooksInterface {
23
+ final class Twig implements InstanceInterface, HooksInterface {
24
24
 
25
25
  use Singleton;
26
26
 
@@ -37,28 +37,27 @@ class Twig implements InstanceInterface, HooksInterface {
37
37
  /**
38
38
  * Set properties.
39
39
  */
40
- public function set_properties() {}
40
+ public function set_properties(): void {}
41
41
 
42
42
  /**
43
43
  * Register action hooks.
44
44
  */
45
- public function action_hooks() {
46
- }
45
+ public function action_hooks(): void {}
47
46
 
48
47
  /**
49
48
  * Register filter hooks.
50
49
  */
51
- public function filter_hooks() {
50
+ public function filter_hooks(): void {
52
51
  add_filter( 'timber/twig', array( $this, 'extend_twig' ) );
53
52
  }
54
53
 
55
54
  /**
56
55
  * Extend Twig functionality.
57
56
  *
58
- * @param \Twig_Environment $twig The Twig environment.
59
- * @return \Twig_Environment
57
+ * @param \Twig\Environment $twig The Twig environment.
58
+ * @return \Twig\Environment
60
59
  */
61
- public function extend_twig( $twig ) {
60
+ public function extend_twig( \Twig\Environment $twig ): \Twig\Environment {
62
61
  $twig = $this->register_functions( $twig );
63
62
  $twig = $this->register_filters( $twig );
64
63
  $twig = $this->register_tests( $twig );
@@ -69,10 +68,10 @@ class Twig implements InstanceInterface, HooksInterface {
69
68
  /**
70
69
  * Register custom Twig functions.
71
70
  *
72
- * @param \Twig_Environment $twig The Twig environment.
73
- * @return \Twig_Environment
71
+ * @param \Twig\Environment $twig The Twig environment.
72
+ * @return \Twig\Environment
74
73
  */
75
- public function register_functions( $twig ) {
74
+ public function register_functions( \Twig\Environment $twig ): \Twig\Environment {
76
75
  $this->register_function( $twig, 'get_nav_menu', array( $this, 'get_nav_menu' ) );
77
76
  $this->register_function( $twig, 'timber_set_product', array( $this, 'timber_set_product' ) );
78
77
  $this->register_function( $twig, 'post_classes', array( $this, 'post_classes' ) );
@@ -89,10 +88,10 @@ class Twig implements InstanceInterface, HooksInterface {
89
88
  /**
90
89
  * Register custom Twig filters.
91
90
  *
92
- * @param \Twig_Environment $twig The Twig environment.
93
- * @return \Twig_Environment
91
+ * @param \Twig\Environment $twig The Twig environment.
92
+ * @return \Twig\Environment
94
93
  */
95
- public function register_filters( $twig ) {
94
+ public function register_filters( \Twig\Environment $twig ): \Twig\Environment {
96
95
 
97
96
  return $twig;
98
97
  }
@@ -100,10 +99,10 @@ class Twig implements InstanceInterface, HooksInterface {
100
99
  /**
101
100
  * Register custom Twig tests.
102
101
  *
103
- * @param \Twig_Environment $twig The Twig environment.
104
- * @return \Twig_Environment
102
+ * @param \Twig\Environment $twig The Twig environment.
103
+ * @return \Twig\Environment
105
104
  */
106
- public function register_tests( $twig ) {
105
+ public function register_tests( \Twig\Environment $twig ): \Twig\Environment {
107
106
 
108
107
  return $twig;
109
108
  }
@@ -111,13 +110,13 @@ class Twig implements InstanceInterface, HooksInterface {
111
110
  /**
112
111
  * Register a Twig function.
113
112
  *
114
- * @param \Twig_Environment $twig The Twig environment.
113
+ * @param \Twig\Environment $twig The Twig environment.
115
114
  * @param string $name The name of the function.
116
115
  * @param callable $callback The callback function.
117
116
  *
118
- * @return \Twig_Environment
117
+ * @return \Twig\Environment
119
118
  */
120
- private function register_function( $twig, $name, $callback ) {
119
+ private function register_function( $twig, $name, $callback ): \Twig\Environment {
121
120
  $twig->addFunction( new \Twig\TwigFunction( $name, $callback ) );
122
121
 
123
122
  return $twig;
@@ -126,13 +125,13 @@ class Twig implements InstanceInterface, HooksInterface {
126
125
  /**
127
126
  * Register a Twig filter.
128
127
  *
129
- * @param \Twig_Environment $twig The Twig environment.
128
+ * @param \Twig\Environment $twig The Twig environment.
130
129
  * @param string $name The name of the function.
131
130
  * @param callable $callback The callback function.
132
131
  *
133
- * @return \Twig_Environment
132
+ * @return \Twig\Environment
134
133
  */
135
- private function register_filter( $twig, $name, $callback ) {
134
+ private function register_filter( \Twig\Environment $twig, string $name, callable $callback ): \Twig\Environment {
136
135
  $twig->addFilter( new \Twig\TwigFilter( $name, $callback ) );
137
136
 
138
137
  return $twig;
@@ -141,13 +140,13 @@ class Twig implements InstanceInterface, HooksInterface {
141
140
  /**
142
141
  * Register a Twig test.
143
142
  *
144
- * @param \Twig_Environment $twig The Twig environment.
143
+ * @param \Twig\Environment $twig The Twig environment.
145
144
  * @param string $name The name of the function.
146
145
  * @param callable $callback The callback function.
147
146
  *
148
- * @return \Twig_Environment
147
+ * @return \Twig\Environment
149
148
  */
150
- private function register_test( $twig, $name, $callback ) {
149
+ private function register_test( \Twig\Environment $twig, string $name, callable $callback ): \Twig\Environment {
151
150
  $twig->addTest( new \Twig\TwigTest( $name, $callback ) );
152
151
 
153
152
  return $twig;
@@ -159,10 +158,10 @@ class Twig implements InstanceInterface, HooksInterface {
159
158
  * @param string $menu_name The menu name.
160
159
  * @return string
161
160
  */
162
- public function get_nav_menu( $menu_name ) {
161
+ public function get_nav_menu( string $menu_name ): string {
163
162
  $context = Timber::context();
164
163
 
165
- return $context['menus'][$menu_name];
164
+ return $context['menus'][$menu_name] ?? '';
166
165
  }
167
166
 
168
167
  /**
@@ -170,19 +169,23 @@ class Twig implements InstanceInterface, HooksInterface {
170
169
  *
171
170
  * @param object $post The post object.
172
171
  */
173
- public function timber_set_product( $post ) {
174
- return WoocommerceHelpers::timber_set_product( $post );
172
+ public function timber_set_product( object $post ): void {
173
+ WoocommerceHelpers::timber_set_product( $post );
175
174
  }
176
175
 
177
176
  /**
178
177
  * Prepare post classnames to follow ITCSS structure.
179
178
  *
180
- * @param string $classes The post classes.
181
- * @param string $prefix The prefix e.g. c-post--.
179
+ * @param ?string $classes The post classes.
180
+ * @param string $prefix The prefix e.g. c-post--.
182
181
  *
183
182
  * @return string
184
183
  */
185
- public function post_classes( $classes, $prefix = 'c-post--' ) {
184
+ public function post_classes( ?string $classes, string $prefix = 'c-post--' ): string {
185
+ if ( empty( $classes ) ) {
186
+ return '';
187
+ }
188
+
186
189
  $classnames = explode( ' ', $classes );
187
190
  $classnames = array_map(
188
191
  function ( $classname ) use ( $prefix ) {
@@ -201,7 +204,7 @@ class Twig implements InstanceInterface, HooksInterface {
201
204
  *
202
205
  * @return array
203
206
  */
204
- public function slider_prepare_params( $params ) {
207
+ public function slider_prepare_params( array $params ): array {
205
208
  $defaults = array(
206
209
  'type' => 'default',
207
210
  );
@@ -269,16 +272,18 @@ class Twig implements InstanceInterface, HooksInterface {
269
272
  * @param string $image_size Image size.
270
273
  * @param array $attrs Image attributes.
271
274
  *
272
- * @return string|html
275
+ * @return string
273
276
  */
274
- public function get_responsive_image( $image_id, $image_size = 'medium', $attrs = array() ) {
277
+ public function get_responsive_image( int $image_id, string $image_size = 'medium', array $attrs = array() ): string {
275
278
  return ImageHelpers::get_responsive_image( $image_id, $image_size, $attrs );
276
279
  }
277
280
 
278
281
  /**
279
282
  * Display comments template - the comments and the form.
283
+ *
284
+ * @return string
280
285
  */
281
- public function comments_template() {
286
+ public function comments_template(): string {
282
287
  return CommentsHelpers::comments_template();
283
288
  }
284
289
 
@@ -290,16 +295,16 @@ class Twig implements InstanceInterface, HooksInterface {
290
295
  *
291
296
  * @return string
292
297
  */
293
- public function bem( $name = '', ...$modifiers ) {
298
+ public function bem( string $name = '', mixed ...$modifiers ): string {
294
299
  return ThemeHelpers::bem( $name, ...$modifiers );
295
300
  }
296
301
 
297
302
  /**
298
303
  * Display breadcrumbs. Requires Yoast plugin.
299
304
  *
300
- * @return html
305
+ * @return string
301
306
  */
302
- public function breadcrumbs() {
307
+ public function breadcrumbs(): string {
303
308
  return YoastHelpers::breadcrumbs();
304
309
  }
305
310
 
@@ -308,9 +313,9 @@ class Twig implements InstanceInterface, HooksInterface {
308
313
  *
309
314
  * @param array $args
310
315
  *
311
- * @return html
316
+ * @return string
312
317
  */
313
- public function get_icon( $args ) {
318
+ public function get_icon( array $args ): string {
314
319
  return Components::get_icon( $args );
315
320
  }
316
321
  }
@@ -9,7 +9,7 @@
9
9
  * @package Chisel
10
10
  */
11
11
 
12
- use Chisel\Helper\CacheHelpers;
12
+ use Chisel\Helpers\CacheHelpers;
13
13
  use Timber\Timber;
14
14
 
15
15
  $context = Timber::context();
@@ -5,7 +5,7 @@
5
5
  * @package Chisel
6
6
  */
7
7
 
8
- use Chisel\Helper\CacheHelpers;
8
+ use Chisel\Helpers\CacheHelpers;
9
9
  use Timber\Timber;
10
10
 
11
11
  $context = Timber::context();
@@ -5,7 +5,7 @@
5
5
  * @package Chisel
6
6
  */
7
7
 
8
- use Chisel\Helper\CacheHelpers;
8
+ use Chisel\Helpers\CacheHelpers;
9
9
  use Timber\Timber;
10
10
 
11
11
  $context = Timber::context();
@@ -5,7 +5,7 @@
5
5
  * @package Chisel
6
6
  */
7
7
 
8
- use Chisel\Helper\CacheHelpers;
8
+ use Chisel\Helpers\CacheHelpers;
9
9
  use Timber\Timber;
10
10
 
11
11
  $context = Timber::context();
@@ -10,7 +10,7 @@
10
10
  {{ slides_html }}
11
11
 
12
12
  <div class="b-slider__slide swiper-slide" {% if has_thumbnails_nav %}data-thumbnail-url="{{ get_image(slide.acf_bs_image).src('medium') }}"{% endif %}>
13
- {{ get_responsive_image(slide.acf_bs_image, 'large', {fetchpriority: loop.first ? 'high' : 'auto'}) }}
13
+ {{ get_responsive_image(slide.acf_bs_image, (block.align == 'full' ? 'full' : 'large'), {fetchpriority: loop.first ? 'high' : 'auto'}) }}
14
14
  </div>
15
15
  {% endset %}
16
16
  {% endif %}
@@ -1,5 +1,6 @@
1
1
  @use '../tools/theme' as *;
2
2
 
3
+ $scrollbar-width: 15px;
3
4
  $root-font-size: 16px;
4
5
  $breakpoints: (
5
6
  small: 480px,