generator-chisel 2.1.2 → 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 (64) hide show
  1. package/CHANGELOG.md +4 -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 +20 -15
  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 +23 -23
  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 +22 -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/scripts/editor/blocks-styles.js +3 -2
  57. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/vendor/_breadcrumbs.scss +6 -3
  58. package/lib/commands/create/creators/app/chisel-starter-theme/style.chisel-tpl.css +1 -1
  59. package/lib/commands/create/creators/app/chisel-starter-theme/woocommerce.php +3 -3
  60. package/lib/commands/create/packages-versions.js +1 -1
  61. package/package.json +2 -2
  62. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Factory/RegisterAcfOptionsPage.php +0 -62
  63. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/AjaxHelpers.php +0 -33
  64. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/CacheHelpers.php +0 -41
@@ -1,20 +1,20 @@
1
1
  <?php
2
2
 
3
- namespace Chisel\Helper;
3
+ namespace Chisel\Helpers;
4
4
 
5
5
  /**
6
6
  * Helper functions.
7
7
  *
8
8
  * @package Chisel
9
9
  */
10
- class GravityFormsHelpers {
10
+ final class GravityFormsHelpers {
11
11
 
12
12
  /**
13
13
  * Check if Gravity Forms plugin is active.
14
14
  *
15
15
  * @return bool
16
16
  */
17
- public static function is_gf_active() {
17
+ public static function is_gf_active(): bool {
18
18
  return class_exists( '\GFForms' );
19
19
  }
20
20
 
@@ -23,7 +23,7 @@ class GravityFormsHelpers {
23
23
  *
24
24
  * @return array
25
25
  */
26
- public static function get_forms_list() {
26
+ public static function get_forms_list(): array {
27
27
  if ( ! class_exists( 'GFForms' ) ) {
28
28
  return array();
29
29
  }
@@ -44,18 +44,18 @@ class GravityFormsHelpers {
44
44
  /**
45
45
  * 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.
46
46
  *
47
- * @param int $form_id
48
- * @param bool $display_title
49
- * @param bool $display_description
50
- * @param bool $display_inactive
51
- * @param array $field_values
52
- * @param bool $ajax
53
- * @param int $tabindex
54
- * @param bool $_echo
47
+ * @param int $form_id
48
+ * @param bool $display_title
49
+ * @param bool $display_description
50
+ * @param bool $display_inactive
51
+ * @param ?array $field_values
52
+ * @param bool $ajax
53
+ * @param int $tabindex
54
+ * @param bool $_echo
55
55
  *
56
56
  * @return mixed
57
57
  */
58
- public static function get_form( $form_id, $display_title = false, $display_description = false, $display_inactive = false, $field_values = null, $ajax = true, $tabindex = 0, $_echo = false ) {
58
+ public static function get_form( int $form_id, bool $display_title = false, bool $display_description = false, bool $display_inactive = false, ?array $field_values = null, bool $ajax = true, int $tabindex = 0, bool $_echo = false ): mixed {
59
59
  if ( function_exists( 'gravity_form' ) ) {
60
60
  return gravity_form( $form_id, $display_title, $display_description, $display_inactive, $field_values, $ajax, $tabindex, $_echo );
61
61
  }
@@ -1,6 +1,6 @@
1
1
  <?php
2
2
 
3
- namespace Chisel\Helper;
3
+ namespace Chisel\Helpers;
4
4
 
5
5
  use Timber\Timber;
6
6
 
@@ -9,14 +9,17 @@ use Timber\Timber;
9
9
  *
10
10
  * @package Chisel
11
11
  */
12
- class ImageHelpers {
12
+ final class ImageHelpers {
13
13
 
14
14
  /**
15
15
  * Responsive image data.
16
16
  *
17
17
  * @var array
18
18
  */
19
- private static $responsive_image_data = array();
19
+ private static $responsive_image_data = array(
20
+ 'image_id' => 0,
21
+ 'attrs' => array(),
22
+ );
20
23
 
21
24
  /**
22
25
  * Get image url of the theme images.
@@ -26,12 +29,16 @@ class ImageHelpers {
26
29
  *
27
30
  * @return string
28
31
  */
29
- public static function get_image_url( $image_name, $is_icon = false ) {
32
+ public static function get_image_url( string $image_name, bool $is_icon = false ): string {
33
+ if ( $image_name === '' ) {
34
+ return '';
35
+ }
36
+
30
37
  $folder_name = $is_icon ? 'icons' : 'images';
31
38
  $image_path = '/assets/' . $folder_name . '/' . $image_name;
32
39
  $file_path = get_template_directory() . $image_path;
33
40
 
34
- if ( ! file_exists( $file_path ) ) {
41
+ if ( ! is_file( $file_path ) ) {
35
42
  return '';
36
43
  }
37
44
 
@@ -47,19 +54,17 @@ class ImageHelpers {
47
54
  *
48
55
  * @return string|html
49
56
  */
50
- public static function get_responsive_image( $image_id, $image_size = 'medium', $attrs = array() ) {
51
- if ( ! $image_id ) {
57
+ public static function get_responsive_image( int $image_id, string $image_size = 'medium', array $attrs = array() ): string {
58
+ if ( $image_id <= 0 ) {
52
59
  return '';
53
60
  }
54
61
 
55
- $image = Timber::get_image( $image_id );
56
-
57
62
  self::$responsive_image_data = array(
58
63
  'image_id' => $image_id,
59
64
  'attrs' => $attrs,
60
65
  );
61
66
 
62
- // Adjust image width and height to prevent layout shifts.
67
+ // Adjust image width and height to preven content layout shifts (CLS).
63
68
  if ( isset( $attrs['width'] ) && isset( $attrs['height'] ) ) {
64
69
  add_filter(
65
70
  'wp_get_attachment_image_src',
@@ -69,7 +74,8 @@ class ImageHelpers {
69
74
  );
70
75
  }
71
76
 
72
- $responsive_image = $image ? $image->responsive( $image_size, $attrs ) : '';
77
+ $image = Timber::get_image( $image_id );
78
+ $html = $image ? (string) $image->responsive( $image_size, $attrs ) : '';
73
79
 
74
80
  remove_filter(
75
81
  'wp_get_attachment_image_src',
@@ -77,7 +83,7 @@ class ImageHelpers {
77
83
  10
78
84
  );
79
85
 
80
- return $responsive_image;
86
+ return $html;
81
87
  }
82
88
 
83
89
  /**
@@ -88,13 +94,22 @@ class ImageHelpers {
88
94
  *
89
95
  * @return array
90
96
  */
91
- public static function responsive_image_dimensions( $src, $id ) {
97
+ public static function responsive_image_dimensions( array $src, int $id ) {
98
+ if ( empty( $src ) ) {
99
+ return $src;
100
+ }
101
+
92
102
  $image_id = self::$responsive_image_data['image_id'] ?? 0;
93
103
  $attrs = self::$responsive_image_data['attrs'] ?? array();
94
104
 
95
105
  if ( $id === $image_id && isset( $attrs['width'] ) && isset( $attrs['height'] ) ) {
96
- $src[1] = $attrs['width'];
97
- $src[2] = $attrs['height'];
106
+ $width = (int) $attrs['width'];
107
+ $height = (int) $attrs['height'];
108
+
109
+ if ( $width > 0 && $height > 0 ) {
110
+ $src[1] = $width;
111
+ $src[2] = $height;
112
+ }
98
113
  }
99
114
 
100
115
  return $src;
@@ -1,21 +1,21 @@
1
1
  <?php
2
2
 
3
- namespace Chisel\Helper;
3
+ namespace Chisel\Helpers;
4
4
 
5
- use Chisel\Helper\ImageHelpers;
5
+ use Chisel\Helpers\ImageHelpers;
6
6
 
7
7
  /**
8
8
  * Helper functions.
9
9
  *
10
10
  * @package Chisel
11
11
  */
12
- class ThemeHelpers {
12
+ final class ThemeHelpers {
13
13
  /**
14
14
  * Color palettes.
15
15
  *
16
16
  * @var array
17
17
  */
18
- private static $colors_palettes = array(
18
+ private static array $colors_palettes = array(
19
19
  'acf' => array(),
20
20
  'tinymce' => '',
21
21
  );
@@ -25,7 +25,7 @@ class ThemeHelpers {
25
25
  *
26
26
  * @return bool
27
27
  */
28
- public static function is_dev_env() {
28
+ public static function is_dev_env(): bool {
29
29
  return wp_get_environment_type() === 'development';
30
30
  }
31
31
 
@@ -34,7 +34,7 @@ class ThemeHelpers {
34
34
  *
35
35
  * @return bool
36
36
  */
37
- public static function is_fast_refresh() {
37
+ public static function is_fast_refresh(): bool {
38
38
  $runtime = get_template_directory() . '/build/runtime.js';
39
39
 
40
40
  return self::is_dev_env() && is_file( $runtime );
@@ -43,11 +43,11 @@ class ThemeHelpers {
43
43
  /**
44
44
  * Get theme version.
45
45
  *
46
- * @return bool
46
+ * @return string
47
47
  */
48
- public static function get_theme_version() {
48
+ public static function get_theme_version(): string {
49
49
  $theme = wp_get_theme();
50
- return $theme->get( 'Version' );
50
+ return (string) $theme->get( 'Version' );
51
51
  }
52
52
 
53
53
  /**
@@ -55,8 +55,8 @@ class ThemeHelpers {
55
55
  *
56
56
  * @return bool
57
57
  */
58
- public static function get_theme_name() {
59
- return esc_attr( get_bloginfo( 'name' ) );
58
+ public static function get_theme_name(): string {
59
+ return (string) get_bloginfo( 'name' );
60
60
  }
61
61
 
62
62
  /**
@@ -67,8 +67,8 @@ class ThemeHelpers {
67
67
  *
68
68
  * @return string
69
69
  */
70
- public static function bem( $name = '', ...$modifiers ) {
71
- if ( empty( $name ) || empty( $modifiers ) ) {
70
+ public static function bem( string $name = '', mixed ...$modifiers ): string {
71
+ if ( $name === '' || empty( $modifiers ) ) {
72
72
  return '';
73
73
  }
74
74
 
@@ -112,27 +112,31 @@ class ThemeHelpers {
112
112
  *
113
113
  * @param string $type Type of palette to get.
114
114
  *
115
- * @return array
115
+ * @return string|array
116
116
  */
117
- public static function get_colors_palette( $type ) {
117
+ public static function get_colors_palette( string $type ): string|array {
118
118
  if ( ! isset( self::$colors_palettes[$type] ) || self::$colors_palettes[$type] ) {
119
- return self::$colors_palettes[$type];
119
+ return apply_filters( 'chisel_' . $type . '_colors_palette', self::$colors_palettes[$type] );
120
120
  }
121
121
 
122
122
  $theme_json = get_template_directory() . '/theme.json';
123
- $theme_json_data = wp_json_file_decode( $theme_json, array( 'associative' => true ) );
124
- $colors_palette = $theme_json_data['settings']['color']['palette'];
123
+ $theme_json_data = is_file( $theme_json ) ? wp_json_file_decode( $theme_json, array( 'associative' => true ) ) : array();
124
+ $colors_palette = isset( $theme_json_data['settings']['color']['palette'] ) ? $theme_json_data['settings']['color']['palette'] : array();
125
125
 
126
- if ( $colors_palette ) {
126
+ if ( ! empty( $colors_palette ) ) {
127
127
  foreach ( $colors_palette as $color_data ) {
128
- $color = sanitize_hex_color( $color_data['color'] );
128
+ $hex_color = isset( $color_data['color'] ) ? sanitize_hex_color( (string) $color_data['color'] ) : null;
129
+
130
+ if ( ! $hex_color ) {
131
+ continue;
132
+ }
129
133
 
130
134
  if ( $type === 'acf' ) {
131
- self::$colors_palettes[$type][] = $color;
135
+ self::$colors_palettes[$type][] = $hex_color;
132
136
  } elseif ( $type === 'tinymce' ) {
133
137
  self::$colors_palettes[$type] .= sprintf(
134
138
  '"%s", "%s",',
135
- str_replace( '#', '', $color ),
139
+ str_replace( '#', '', $hex_color ),
136
140
  esc_attr( $color_data['name'] )
137
141
  );
138
142
  }
@@ -147,11 +151,11 @@ class ThemeHelpers {
147
151
  *
148
152
  * @return array
149
153
  */
150
- public static function get_login_page_logo_data() {
151
- $logo_id = get_theme_mod( 'custom_logo', 0 );
154
+ public static function get_login_page_logo_data(): array {
155
+ $logo_id = (int) get_theme_mod( 'custom_logo', 0 );
152
156
  $logo_data = array();
153
157
 
154
- if ( $logo_id ) {
158
+ if ( $logo_id > 0 ) {
155
159
  $logo_data = wp_get_attachment_image_src( $logo_id, 'medium' );
156
160
  } else {
157
161
  $logo_data = array(
@@ -1,29 +1,35 @@
1
1
  <?php
2
2
 
3
- namespace Chisel\Helper;
3
+ namespace Chisel\Helpers;
4
4
 
5
5
  /**
6
6
  * Helper functions.
7
7
  *
8
8
  * @package Chisel
9
9
  */
10
- class WoocommerceHelpers {
10
+ final class WoocommerceHelpers {
11
11
 
12
12
  /**
13
13
  * Check if WooCommerce is active.
14
14
  *
15
15
  * @return bool
16
16
  */
17
- public static function is_woocommerce_active() {
17
+ public static function is_woocommerce_active(): bool {
18
18
  return class_exists( '\Woocommerce' );
19
19
  }
20
20
 
21
21
  /**
22
22
  * Set the product object. For some reason, products in the loop don’t get the right context by default. Without this, some elements of the listed products would show the same information as the first product in the loop. This function fixes that.
23
23
  *
24
- * @param object $post The post object.
24
+ * @param object $post
25
+ *
26
+ * @return void
25
27
  */
26
- public static function timber_set_product( $post ) {
28
+ public static function timber_set_product( object $post ): void {
29
+ if ( ! self::is_woocommerce_active() ) {
30
+ return;
31
+ }
32
+
27
33
  global $product;
28
34
 
29
35
  if ( is_woocommerce() ) {
@@ -34,13 +40,13 @@ class WoocommerceHelpers {
34
40
  /**
35
41
  * Get products grid classnames
36
42
  *
37
- * @param bool $products
38
- * @param bool $has_sidebar
43
+ * @param bool $products - Whether there are products to render.
44
+ * @param bool $has_sidebar -Whether the layout includes a sidebar.
39
45
  *
40
46
  * @return string
41
47
  */
42
- public static function get_products_grid_classnames( $products, $has_sidebar ) {
43
- $loop_columns = wc_get_loop_prop( 'columns' );
48
+ public static function get_products_grid_classnames( bool $products, bool $has_sidebar ): string {
49
+ $loop_columns = (int) wc_get_loop_prop( 'columns' );
44
50
 
45
51
  // Set max columns to 4.
46
52
  if ( $loop_columns > 4 ) {
@@ -1,29 +1,29 @@
1
1
  <?php
2
2
 
3
- namespace Chisel\Helper;
3
+ namespace Chisel\Helpers;
4
4
 
5
5
  /**
6
6
  * Helper functions.
7
7
  *
8
8
  * @package Chisel
9
9
  */
10
- class YoastHelpers {
10
+ final class YoastHelpers {
11
11
 
12
12
  /**
13
13
  * Check if Yoast plugin is active.
14
14
  *
15
15
  * @return bool
16
16
  */
17
- public static function is_yoast_active() {
17
+ public static function is_yoast_active(): bool {
18
18
  return class_exists( '\WPSEO_Options' );
19
19
  }
20
20
 
21
21
  /**
22
22
  * Display breadcrumbs.
23
23
  *
24
- * @return html
24
+ * @return string
25
25
  */
26
- public static function breadcrumbs() {
26
+ public static function breadcrumbs(): string {
27
27
  if ( ! self::is_yoast_active() ) {
28
28
  return '';
29
29
  }
@@ -32,6 +32,6 @@ class YoastHelpers {
32
32
  return '';
33
33
  }
34
34
 
35
- return yoast_breadcrumb( '<div class="c-breadcrumbs">', '</div>', false );
35
+ return (string) yoast_breadcrumb( '<div class="c-breadcrumbs o-wrapper__inner">', '</div>', false );
36
36
  }
37
37
  }
@@ -12,15 +12,15 @@ interface HooksInterface {
12
12
  /**
13
13
  * Set class properties.
14
14
  */
15
- public function set_properties();
15
+ public function set_properties(): void;
16
16
 
17
17
  /**
18
18
  * Register action hooks.
19
19
  */
20
- public function action_hooks();
20
+ public function action_hooks(): void;
21
21
 
22
22
  /**
23
23
  * Register filter hooks.
24
24
  */
25
- public function filter_hooks();
25
+ public function filter_hooks(): void;
26
26
  }
@@ -12,5 +12,5 @@ interface InstanceInterface {
12
12
  /**
13
13
  * Get the instance of the class.
14
14
  */
15
- public static function get_instance();
15
+ public static function get_instance(): static;
16
16
  }
@@ -1,18 +1,18 @@
1
1
  <?php
2
2
 
3
- namespace Chisel\Plugin;
3
+ namespace Chisel\Plugins;
4
4
 
5
5
  use Chisel\Interfaces\InstanceInterface;
6
6
  use Chisel\Interfaces\HooksInterface;
7
7
  use Chisel\Traits\Singleton;
8
- use Chisel\Helper\GravityFormsHelpers;
8
+ use Chisel\Helpers\GravityFormsHelpers;
9
9
 
10
10
  /**
11
11
  * GravityForms related functionalities.
12
12
  *
13
13
  * @package Chisel
14
14
  */
15
- class GravityForms implements InstanceInterface, HooksInterface {
15
+ final class GravityForms implements InstanceInterface, HooksInterface {
16
16
 
17
17
  use Singleton;
18
18
 
@@ -33,19 +33,19 @@ class GravityForms implements InstanceInterface, HooksInterface {
33
33
  /**
34
34
  * Set properties.
35
35
  */
36
- public function set_properties() {}
36
+ public function set_properties(): void {}
37
37
 
38
38
  /**
39
39
  * Register action hooks.
40
40
  */
41
- public function action_hooks() {
41
+ public function action_hooks(): void {
42
42
  add_action( 'wp_enqueue_scripts', array( $this, 'deregister_scripts' ), 999 );
43
43
  }
44
44
 
45
45
  /**
46
46
  * Register filter hooks.
47
47
  */
48
- public function filter_hooks() {
48
+ public function filter_hooks(): void {
49
49
  add_filter( 'chisel_frontend_footer_styles', array( $this, 'register_custom_styles' ) );
50
50
  add_filter( 'chisel_enqueue_frontend_footer_style', array( $this, 'enqueue_custom_styles' ), 10, 3 );
51
51
  add_filter( 'gform_form_theme_slug', array( $this, 'default_form_styles' ), 99, 2 );
@@ -55,7 +55,7 @@ class GravityForms implements InstanceInterface, HooksInterface {
55
55
  /**
56
56
  * This function will deregister gforms specific scripts
57
57
  */
58
- public function deregister_scripts() {
58
+ public function deregister_scripts(): void {
59
59
  wp_dequeue_style( 'gforms_reset_css' );
60
60
  }
61
61
 
@@ -66,7 +66,7 @@ class GravityForms implements InstanceInterface, HooksInterface {
66
66
  *
67
67
  * @return array
68
68
  */
69
- public function register_custom_styles( $styles ) {
69
+ public function register_custom_styles( array $styles ): array {
70
70
  $styles['gravity-forms'] = array();
71
71
 
72
72
  return $styles;
@@ -81,14 +81,14 @@ class GravityForms implements InstanceInterface, HooksInterface {
81
81
  *
82
82
  * @return bool
83
83
  */
84
- public function enqueue_custom_styles( $enqueue, $handle, $args ) {
84
+ public function enqueue_custom_styles( bool $enqueue, string $handle, array $args ): bool {
85
85
  if ( $handle !== 'gravity-forms' ) {
86
86
  return $enqueue;
87
87
  }
88
88
 
89
89
  global $post;
90
90
 
91
- if ( $post ) {
91
+ if ( $post instanceof \WP_Post ) {
92
92
  $enqueue = has_block( 'gravityforms/form', $post );
93
93
  }
94
94
 
@@ -103,7 +103,7 @@ class GravityForms implements InstanceInterface, HooksInterface {
103
103
  *
104
104
  * @return string
105
105
  */
106
- public function default_form_styles( $slug, $form ) {
106
+ public function default_form_styles( string $slug, array $form ): string {
107
107
  if ( ! is_admin() ) {
108
108
  $slug = 'gravity-theme';
109
109
  }
@@ -118,10 +118,8 @@ class GravityForms implements InstanceInterface, HooksInterface {
118
118
  *
119
119
  * @return array
120
120
  */
121
- public function plugin_settings_fields( $fields ) {
122
- if ( isset( $fields['default_theme'] ) ) {
123
- unset( $fields['default_theme'] );
124
- }
121
+ public function plugin_settings_fields( array $fields ): array {
122
+ unset( $fields['default_theme'] );
125
123
 
126
124
  return $fields;
127
125
  }
@@ -1,18 +1,18 @@
1
1
  <?php
2
2
 
3
- namespace Chisel\Plugin;
3
+ namespace Chisel\Plugins;
4
4
 
5
5
  use Chisel\Interfaces\InstanceInterface;
6
6
  use Chisel\Interfaces\HooksInterface;
7
7
  use Chisel\Traits\Singleton;
8
- use Chisel\Helper\WoocommerceHelpers;
8
+ use Chisel\Helpers\WoocommerceHelpers;
9
9
 
10
10
  /**
11
11
  * Class used to extend Timber functionality.
12
12
  *
13
13
  * @package Chisel
14
14
  */
15
- class Woocommerce implements InstanceInterface, HooksInterface {
15
+ final class Woocommerce implements InstanceInterface, HooksInterface {
16
16
 
17
17
  use Singleton;
18
18
 
@@ -40,7 +40,7 @@ class Woocommerce implements InstanceInterface, HooksInterface {
40
40
  /**
41
41
  * Set properties.
42
42
  */
43
- public function set_properties() {
43
+ public function set_properties(): void {
44
44
  $this->sidebars = array(
45
45
  'woocommerce' => array(
46
46
  'name' => __( 'Woocommerce', 'chisel' ),
@@ -52,7 +52,7 @@ class Woocommerce implements InstanceInterface, HooksInterface {
52
52
  /**
53
53
  * Register action hooks.
54
54
  */
55
- public function action_hooks() {
55
+ public function action_hooks(): void {
56
56
  $this->remove_actions();
57
57
 
58
58
  add_action( 'after_setup_theme', array( $this, 'add_woocommerce_support' ) );
@@ -66,7 +66,7 @@ class Woocommerce implements InstanceInterface, HooksInterface {
66
66
  /**
67
67
  * Register filter hooks.
68
68
  */
69
- public function filter_hooks() {
69
+ public function filter_hooks(): void {
70
70
  add_filter( 'chisel_sidebars', array( $this, 'register_sidebars' ) );
71
71
  add_filter( 'woocommerce_enqueue_styles', array( $this, 'enqueue_styles' ) );
72
72
  add_filter( 'chisel_frontend_styles', array( $this, 'register_custom_styles' ) );
@@ -102,7 +102,7 @@ class Woocommerce implements InstanceInterface, HooksInterface {
102
102
  /**
103
103
  * Add WooCommerce support.
104
104
  */
105
- public function add_woocommerce_support() {
105
+ public function add_woocommerce_support(): void {
106
106
  add_theme_support( 'woocommerce' );
107
107
  add_theme_support( 'wc-product-gallery-zoom' );
108
108
  add_theme_support( 'wc-product-gallery-lightbox' );
@@ -112,25 +112,25 @@ class Woocommerce implements InstanceInterface, HooksInterface {
112
112
  /**
113
113
  * Open container for sort bar.
114
114
  */
115
- public function before_shop_loop_div_open() {
115
+ public function before_shop_loop_div_open(): void {
116
116
  echo '<div class="c-shop__sort"> ';
117
117
  }
118
118
 
119
119
  /**
120
120
  * Close container for sort bar.
121
121
  */
122
- public function before_shop_loop_div_close() {
122
+ public function before_shop_loop_div_close(): void {
123
123
  echo ' </div> ';
124
124
  }
125
125
 
126
126
  /**
127
127
  * Modify woocommerce customizer settings.
128
128
  *
129
- * @param WP_Customize_Manager $wp_customize
129
+ * @param \WP_Customize_Manager $wp_customize
130
130
  *
131
131
  * @return void
132
132
  */
133
- public function modify_customizer( $wp_customize ) {
133
+ public function modify_customizer( \WP_Customize_Manager $wp_customize ): void {
134
134
  $shop_page_display_control = $wp_customize->get_control( 'woocommerce_shop_page_display' );
135
135
  $category_page_display_control = $wp_customize->get_control( 'woocommerce_category_archive_display' );
136
136
 
@@ -150,7 +150,7 @@ class Woocommerce implements InstanceInterface, HooksInterface {
150
150
  *
151
151
  * @return array
152
152
  */
153
- public function register_sidebars( $sidebars ) {
153
+ public function register_sidebars( array $sidebars ): array {
154
154
  $sidebars = array_merge( $sidebars, $this->sidebars );
155
155
 
156
156
  return $sidebars;
@@ -163,7 +163,7 @@ class Woocommerce implements InstanceInterface, HooksInterface {
163
163
  *
164
164
  * @return array
165
165
  */
166
- public function enqueue_styles( $enqueue_styles ) {
166
+ public function enqueue_styles( array $enqueue_styles ): array {
167
167
  unset( $enqueue_styles['woocommerce-layout'] );
168
168
 
169
169
  return $enqueue_styles;
@@ -177,7 +177,7 @@ class Woocommerce implements InstanceInterface, HooksInterface {
177
177
  *
178
178
  * @return array
179
179
  */
180
- public function register_custom_styles( $styles ) {
180
+ public function register_custom_styles( array $styles ): array {
181
181
  $styles['woocommerce'] = array();
182
182
 
183
183
  return $styles;