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
@@ -4,7 +4,7 @@ namespace Chisel\WP;
4
4
 
5
5
  use Timber\Post as TimberPost;
6
6
  use Timber\Timber;
7
- use Chisel\Helper\ImageHelpers;
7
+ use Chisel\Helpers\ImageHelpers;
8
8
 
9
9
  /**
10
10
  * Extend Timber Post class with custom functionality. This is a woocommerce product class.
@@ -16,28 +16,29 @@ class ChiselProduct extends TimberPost {
16
16
  /**
17
17
  * Product thumbnail.
18
18
  *
19
- * @var html
19
+ * @var ?string
20
20
  */
21
- public $thumbnail_html = null;
21
+ public ?string $thumbnail_html = null;
22
22
 
23
23
  /**
24
24
  * Category thumbnail id.
25
25
  *
26
- * @var int
26
+ * @var ?int
27
27
  */
28
- public $thumbnail_id = null;
28
+ public ?int $thumbnail_id = null;
29
29
 
30
30
  /**
31
31
  * Get the product thumbnail. Returns the thumbnail responsive image html.
32
32
  *
33
33
  * @param string $size Thumbnail size.
34
- * @return html
34
+ *
35
+ * @return string Responsive <img> HTML, or empty string.
35
36
  */
36
- public function get_thumbnail( $size = 'woocommerce_thumbnail' ) {
37
+ public function get_thumbnail( string $size = 'woocommerce_thumbnail' ): string {
37
38
  $size = apply_filters( 'single_product_archive_thumbnail_size', $size );
38
39
 
39
40
  if ( $this->thumbnail_html === null ) {
40
- $thumbnail_id = $this->get_thumbnail_id( $size );
41
+ $thumbnail_id = $this->get_thumbnail_id();
41
42
 
42
43
  $this->thumbnail_html = $thumbnail_id ? ImageHelpers::get_responsive_image( $thumbnail_id, $size ) : '';
43
44
  }
@@ -50,7 +51,7 @@ class ChiselProduct extends TimberPost {
50
51
  *
51
52
  * @return int
52
53
  */
53
- public function get_thumbnail_id() {
54
+ public function get_thumbnail_id(): int {
54
55
  if ( $this->thumbnail_id === null ) {
55
56
  $thumbnail_id = get_post_thumbnail_id( $this->ID );
56
57
 
@@ -61,6 +62,6 @@ class ChiselProduct extends TimberPost {
61
62
  $this->thumbnail_id = $thumbnail_id;
62
63
  }
63
64
 
64
- return $this->thumbnail_id;
65
+ return (int) $this->thumbnail_id;
65
66
  }
66
67
  }
@@ -3,7 +3,7 @@
3
3
  namespace Chisel\WP;
4
4
 
5
5
  use Timber\Term as TimberTerm;
6
- use Chisel\Helper\ImageHelpers;
6
+ use Chisel\Helpers\ImageHelpers;
7
7
 
8
8
  /**
9
9
  * Extend Timber Term class with custom functionality.
@@ -15,29 +15,29 @@ class ChiselProductCategory extends TimberTerm {
15
15
  /**
16
16
  * Category thumbnail.
17
17
  *
18
- * @var html
18
+ * @var ?string
19
19
  */
20
- public $thumbnail_html = null;
20
+ public ?string $thumbnail_html = null;
21
21
 
22
22
  /**
23
23
  * Category thumbnail id.
24
24
  *
25
- * @var int
25
+ * @var ?int
26
26
  */
27
- public $thumbnail_id = null;
27
+ public ?int $thumbnail_id = null;
28
28
 
29
29
  /**
30
30
  * Get the product thumbnail. Returns the thumbnail responsive image html.
31
31
  *
32
32
  * @param string $size Thumbnail size.
33
33
  *
34
- * @return html
34
+ * @return string Responsive <img> HTML, or empty string.
35
35
  */
36
- public function get_thumbnail( $size = 'woocommerce_thumbnail' ) {
36
+ public function get_thumbnail( string $size = 'woocommerce_thumbnail' ) {
37
37
  $size = apply_filters( 'subcategory_archive_thumbnail_size', $size );
38
38
 
39
39
  if ( $this->thumbnail_html === null ) {
40
- $thumbnail_id = $this->get_thumbnail_id( $size );
40
+ $thumbnail_id = $this->get_thumbnail_id();
41
41
 
42
42
  $this->thumbnail_html = $thumbnail_id ? ImageHelpers::get_responsive_image( $thumbnail_id, $size ) : '';
43
43
  }
@@ -50,9 +50,9 @@ class ChiselProductCategory extends TimberTerm {
50
50
  *
51
51
  * @return int
52
52
  */
53
- public function get_thumbnail_id() {
53
+ public function get_thumbnail_id(): int {
54
54
  if ( $this->thumbnail_id === null ) {
55
- $thumbnail_id = $this->meta( 'thumbnail_id' );
55
+ $thumbnail_id = (int) $this->meta( 'thumbnail_id' );
56
56
 
57
57
  if ( ! $thumbnail_id ) {
58
58
  $thumbnail_id = get_option( 'woocommerce_placeholder_image', 0 );
@@ -11,7 +11,7 @@ use Chisel\Traits\Singleton;
11
11
  *
12
12
  * @package Chisel
13
13
  */
14
- class Comments implements InstanceInterface, HooksInterface {
14
+ final class Comments implements InstanceInterface, HooksInterface {
15
15
 
16
16
  use Singleton;
17
17
 
@@ -20,14 +20,14 @@ class Comments implements InstanceInterface, HooksInterface {
20
20
  *
21
21
  * @var bool
22
22
  */
23
- private $disable_comments;
23
+ private bool $disable_comments = true;
24
24
 
25
25
  /**
26
26
  * Post types for which comments are disabled.
27
27
  *
28
28
  * @var array
29
29
  */
30
- private $post_types = array(
30
+ private array $post_types = array(
31
31
  'post',
32
32
  'page',
33
33
  );
@@ -47,14 +47,14 @@ class Comments implements InstanceInterface, HooksInterface {
47
47
  /**
48
48
  * Set properties.
49
49
  */
50
- public function set_properties() {
50
+ public function set_properties(): void {
51
51
  $this->disable_comments = apply_filters( 'chisel_disable_comments', true );
52
52
  }
53
53
 
54
54
  /**
55
55
  * Register action hooks.
56
56
  */
57
- public function action_hooks() {
57
+ public function action_hooks(): void {
58
58
  add_action( 'after_setup_theme', array( $this, 'disable_comments_for_post_types' ), 99 );
59
59
  add_action( 'admin_menu', array( $this, 'remove_admin_menu' ), 999 );
60
60
 
@@ -74,7 +74,7 @@ class Comments implements InstanceInterface, HooksInterface {
74
74
  /**
75
75
  * Register filter hooks.
76
76
  */
77
- public function filter_hooks() {
77
+ public function filter_hooks(): void {
78
78
  add_filter( 'wp_headers', array( $this, 'filter_wp_headers' ) );
79
79
  add_filter( 'pre_option_default_pingback_flag', '__return_zero' );
80
80
  add_filter( 'comments_open', '__return_false', 20 );
@@ -102,7 +102,7 @@ class Comments implements InstanceInterface, HooksInterface {
102
102
  *
103
103
  * @return void
104
104
  */
105
- public function disable_comments_for_post_types() {
105
+ public function disable_comments_for_post_types(): void {
106
106
  $this->post_types = apply_filters( 'chisel_disable_comments_post_types', $this->post_types );
107
107
 
108
108
  if ( $this->post_types ) {
@@ -121,7 +121,7 @@ class Comments implements InstanceInterface, HooksInterface {
121
121
  /**
122
122
  * Remove comments related admin menus.
123
123
  */
124
- public function remove_admin_menu() {
124
+ public function remove_admin_menu(): void {
125
125
  global $pagenow;
126
126
 
127
127
  if ( in_array( $pagenow, array( 'comment.php', 'edit-comments.php', 'options-discussion.php' ), true ) ) {
@@ -135,7 +135,7 @@ class Comments implements InstanceInterface, HooksInterface {
135
135
  /**
136
136
  * Add custom CSS to dashboard.
137
137
  */
138
- public function admin_css() {
138
+ public function admin_css(): void {
139
139
  ?>
140
140
  <style>
141
141
  #dashboard_right_now .comment-count,
@@ -152,14 +152,14 @@ class Comments implements InstanceInterface, HooksInterface {
152
152
  /**
153
153
  * Remove comments from dashboard.
154
154
  */
155
- public function filter_dashboard() {
155
+ public function filter_dashboard(): void {
156
156
  remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
157
157
  }
158
158
 
159
159
  /**
160
160
  * Disable recent comments widget.
161
161
  */
162
- public function disable_rc_widget() {
162
+ public function disable_rc_widget(): void {
163
163
  unregister_widget( 'WP_Widget_Recent_Comments' );
164
164
  add_filter( 'show_recent_comments_widget_style', '__return_false' );
165
165
  }
@@ -167,7 +167,7 @@ class Comments implements InstanceInterface, HooksInterface {
167
167
  /**
168
168
  * Filter feed query
169
169
  */
170
- public function filter_query() {
170
+ public function filter_query(): void {
171
171
  if ( is_comment_feed() ) {
172
172
  wp_die( esc_html__( 'Comments are closed.' ), '', array( 'response' => 403 ) );
173
173
  }
@@ -176,7 +176,7 @@ class Comments implements InstanceInterface, HooksInterface {
176
176
  /**
177
177
  * Remove comment links from admin bar.
178
178
  */
179
- public function filter_admin_bar() {
179
+ public function filter_admin_bar(): void {
180
180
  remove_action( 'admin_bar_menu', 'wp_admin_bar_comments_menu', 60 );
181
181
 
182
182
  if ( is_multisite() ) {
@@ -187,7 +187,7 @@ class Comments implements InstanceInterface, HooksInterface {
187
187
  /**
188
188
  * Disable comments template on single posts.
189
189
  */
190
- public function check_comment_template() {
190
+ public function check_comment_template(): void {
191
191
  if ( is_singular() ) {
192
192
  // Kill the comments' template.
193
193
  add_filter( 'comments_template', '__return_empty_string', 20 );
@@ -201,14 +201,14 @@ class Comments implements InstanceInterface, HooksInterface {
201
201
  /**
202
202
  * Add hook to run custom script.
203
203
  */
204
- public function filter_gutenberg() {
204
+ public function filter_gutenberg(): void {
205
205
  add_action( 'admin_footer', array( $this, 'print_footer_scripts' ) );
206
206
  }
207
207
 
208
208
  /**
209
209
  * Unregister comments blocks and panels.
210
210
  */
211
- public function print_footer_scripts() {
211
+ public function print_footer_scripts(): void {
212
212
  ?>
213
213
  <script>
214
214
  wp.domReady( () => {
@@ -221,7 +221,7 @@ class Comments implements InstanceInterface, HooksInterface {
221
221
  wp.blocks.unregisterBlockType( blockType );
222
222
  }
223
223
 
224
- wp.data.dispatch( 'core/edit-post')?.removeEditorPanel( 'discussion-panel' ); // Discussion
224
+ wp.data.dispatch( 'core/editor')?.removeEditorPanel( 'discussion-panel' ); // Discussion
225
225
  } );
226
226
  </script>
227
227
  <?php
@@ -234,16 +234,8 @@ class Comments implements InstanceInterface, HooksInterface {
234
234
  *
235
235
  * @return array
236
236
  */
237
- public function filter_rest_endpoints( $endpoints ) {
238
- if ( isset( $endpoints['comments'] ) ) {
239
- unset( $endpoints['comments'] );
240
- }
241
- if ( isset( $endpoints['/wp/v2/comments'] ) ) {
242
- unset( $endpoints['/wp/v2/comments'] );
243
- }
244
- if ( isset( $endpoints['/wp/v2/comments/(?P<id>[\d]+)'] ) ) {
245
- unset( $endpoints['/wp/v2/comments/(?P<id>[\d]+)'] );
246
- }
237
+ public function filter_rest_endpoints( array $endpoints ): array {
238
+ unset( $endpoints['comments'], $endpoints['/wp/v2/comments'], $endpoints['/wp/v2/comments/(?P<id>[\d]+)'] );
247
239
 
248
240
  return $endpoints;
249
241
  }
@@ -255,7 +247,7 @@ class Comments implements InstanceInterface, HooksInterface {
255
247
  *
256
248
  * @return array
257
249
  */
258
- public function disable_xmlrc_comments( $methods ) {
250
+ public function disable_xmlrc_comments( array $methods ): array {
259
251
  unset( $methods['wp.newComment'] );
260
252
 
261
253
  return $methods;
@@ -264,23 +256,23 @@ class Comments implements InstanceInterface, HooksInterface {
264
256
  /**
265
257
  * Remove comments from REST API
266
258
  *
267
- * @param array $prepared_comment
268
- * @param WP_REST_Request $request
259
+ * @param array $prepared_comment
260
+ * @param \WP_REST_Request $request
269
261
  *
270
- * @return WP_Error
262
+ * @return \WP_Error
271
263
  */
272
- public function disable_rest_api_comments( $prepared_comment, $request ) {
264
+ public function disable_rest_api_comments( array $prepared_comment, \WP_REST_Request $request ): \WP_Error {
273
265
  return new \WP_Error( 'rest_comment_disabled', 'Commenting is disabled.', array( 'status' => 403 ) );
274
266
  }
275
267
 
276
268
  /**
277
269
  * Remove comment links from network admin bar.
278
270
  *
279
- * @param WP_Admin_Bar $wp_admin_bar
271
+ * @param \WP_Admin_Bar $wp_admin_bar
280
272
  *
281
273
  * @return void
282
274
  */
283
- public function remove_network_comment_links( $wp_admin_bar ) {
275
+ public function remove_network_comment_links( \WP_Admin_Bar $wp_admin_bar ): void {
284
276
  if ( is_user_logged_in() ) {
285
277
  foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
286
278
  $wp_admin_bar->remove_menu( 'blog-' . $blog->userblog_id . '-c' );
@@ -295,7 +287,7 @@ class Comments implements InstanceInterface, HooksInterface {
295
287
  *
296
288
  * @return array
297
289
  */
298
- public function filter_wp_headers( $headers ) {
290
+ public function filter_wp_headers( array $headers ): array {
299
291
  unset( $headers['X-Pingback'] );
300
292
 
301
293
  return $headers;
@@ -3,80 +3,75 @@
3
3
  namespace Chisel\WP;
4
4
 
5
5
  use Timber\Timber;
6
- use Chisel\Helper\ImageHelpers;
7
- use Chisel\Helper\AcfHelpers;
8
- use Chisel\Helper\CacheHelpers;
6
+ use Chisel\Helpers\ImageHelpers;
7
+ use Chisel\Helpers\AcfHelpers;
8
+ use Chisel\Helpers\CacheHelpers;
9
9
 
10
10
  /**
11
11
  * Use this class to get site components.
12
12
  *
13
13
  * @package Chisel
14
14
  */
15
- class Components {
15
+ final class Components {
16
16
 
17
17
  /**
18
18
  * The site nav menus.
19
19
  *
20
20
  * @var array
21
21
  */
22
- private static $menus = array();
22
+ private static array $menus = array();
23
23
 
24
24
  /**
25
25
  * The logo.
26
26
  *
27
- * @var array
27
+ * @var string
28
28
  */
29
- private static $logo = array();
29
+ private static string $logo = '';
30
30
 
31
31
  /**
32
32
  * The sidebar widgets.
33
33
  *
34
- * @var array
34
+ * @var string
35
35
  */
36
- private static $sidebar = array();
36
+ private static string $sidebar = '';
37
37
 
38
38
  /**
39
39
  * The footer sidebars.
40
40
  *
41
41
  * @var array
42
42
  */
43
- private static $footer_sidebars = array();
43
+ private static array $footer_sidebars = array();
44
44
 
45
45
  /**
46
46
  * The page / post title.
47
47
  *
48
48
  * @var array
49
49
  */
50
- private static $the_title = array();
50
+ private static array $the_title = array();
51
51
 
52
52
  /**
53
53
  * The svg icons.
54
54
  *
55
55
  * @var array
56
56
  */
57
- private static $icons = array();
57
+ private static array $icons = array();
58
58
 
59
59
  /**
60
60
  * Get the site nav menus.
61
61
  *
62
62
  * @return array
63
63
  */
64
- public static function get_menus() {
65
- if ( ! self::$menus ) {
66
- foreach ( array_keys( get_registered_nav_menus() ) as $menu ) {
67
- if ( strpos( $menu, 'chisel', 0 ) === false ) {
68
- continue;
69
- }
70
-
71
- $menu_name = str_replace( 'chisel_', '', $menu );
72
-
73
- if ( ! has_nav_menu( $menu ) ) {
74
- $menus[$menu_name] = '';
64
+ public static function get_menus(): array {
65
+ if ( empty( self::$menus ) ) {
66
+ $nav_menus = get_registered_nav_menus();
75
67
 
68
+ foreach ( array_keys( $nav_menus ) as $menu ) {
69
+ if ( strpos( $menu, 'chisel', 0 ) === false ) {
76
70
  continue;
77
71
  }
78
72
 
79
- $menus[$menu_name] = Timber::get_menu( $menu );
73
+ $menu_name = str_replace( 'chisel_', '', $menu );
74
+ $menus[$menu_name] = has_nav_menu( $menu ) ? Timber::get_menu( $menu ) : '';
80
75
  }
81
76
  }
82
77
 
@@ -88,7 +83,7 @@ class Components {
88
83
  *
89
84
  * @return string
90
85
  */
91
- public static function get_logo() {
86
+ public static function get_logo(): string {
92
87
  if ( self::$logo ) {
93
88
  return self::$logo;
94
89
  }
@@ -107,27 +102,22 @@ class Components {
107
102
  *
108
103
  * @param string $sidebar_id The sidebar id.
109
104
  *
110
- * @return array
105
+ * @return string
111
106
  */
112
- public static function get_sidebar( $sidebar_id = false ) {
113
- if ( self::$sidebar ) {
107
+ public static function get_sidebar( string $sidebar_id = '' ): string {
108
+ if ( self::$sidebar !== '' ) {
114
109
  return self::$sidebar;
115
110
  }
116
111
 
117
112
  if ( $sidebar_id ) {
118
113
  self::$sidebar = Timber::get_widgets( 'chisel-sidebar-' . $sidebar_id );
119
- return self::$sidebar;
120
- }
121
-
122
- if ( is_singular( 'post' ) ) {
114
+ } elseif ( is_singular( 'post' ) ) {
123
115
  self::$sidebar = Timber::get_widgets( 'chisel-sidebar-blog' );
124
- }
125
-
126
- if ( function_exists( 'is_shop' ) && is_shop() ) {
116
+ } elseif ( function_exists( 'is_shop' ) && is_shop() ) {
127
117
  self::$sidebar = Timber::get_widgets( 'chisel-sidebar-woocommerce' );
128
118
  }
129
119
 
130
- return self::$sidebar;
120
+ return (string) self::$sidebar;
131
121
  }
132
122
 
133
123
  /**
@@ -135,8 +125,8 @@ class Components {
135
125
  *
136
126
  * @return array
137
127
  */
138
- public static function get_footer_sidebars() {
139
- if ( self::$footer_sidebars ) {
128
+ public static function get_footer_sidebars(): array {
129
+ if ( ! empty( self::$footer_sidebars ) ) {
140
130
  return self::$footer_sidebars;
141
131
  }
142
132
 
@@ -154,20 +144,14 @@ class Components {
154
144
  }
155
145
  }
156
146
 
157
- switch ( count( self::$footer_sidebars['columns'] ) ) {
158
- case 4:
159
- $column_class = 'o-layout__item--3-large';
160
- break;
161
- case 3:
162
- $column_class = 'o-layout__item--4-large';
163
- break;
164
- case 2:
165
- $column_class = 'o-layout__item--6-large';
166
- break;
167
- default:
168
- $column_class = 'o-layout__item--12';
169
- break;
170
- }
147
+ $column_count = count( self::$footer_sidebars['columns'] );
148
+
149
+ $column_class = match ( $column_count ) {
150
+ 4 => 'o-layout__item--3-large',
151
+ 3 => 'o-layout__item--4-large',
152
+ 2 => 'o-layout__item--6-large',
153
+ default => 'o-layout__item--12',
154
+ };
171
155
 
172
156
  self::$footer_sidebars['column_class'] = $column_class;
173
157
 
@@ -175,17 +159,16 @@ class Components {
175
159
  }
176
160
 
177
161
  /**
178
- * Get the current page title.
162
+ * Get the current page title data.
179
163
  *
180
164
  * @return array
181
165
  */
182
- public static function get_the_title() {
183
- if ( self::$the_title ) {
166
+ public static function get_the_title(): array {
167
+ if ( ! empty( self::$the_title ) ) {
184
168
  return self::$the_title;
185
169
  }
186
170
 
187
171
  $classname = 'c-title';
188
- $the_title = array();
189
172
  $title_text = '';
190
173
  $title_class = '';
191
174
 
@@ -202,7 +185,7 @@ class Components {
202
185
  }
203
186
  }
204
187
  } elseif ( is_home() ) {
205
- $posts_page_id = absint( get_option( 'page_for_posts' ) );
188
+ $posts_page_id = (int) get_option( 'page_for_posts' );
206
189
 
207
190
  if ( $posts_page_id ) {
208
191
  $title_text = get_the_title( $posts_page_id );
@@ -230,7 +213,7 @@ class Components {
230
213
  $title_text = __( '404 - Page not found', 'chisel' );
231
214
  }
232
215
 
233
- if ( $title_text ) {
216
+ if ( $title_text !== '' ) {
234
217
  self::$the_title = array(
235
218
  'text' => esc_html( $title_text ),
236
219
  'class' => $title_class ? esc_attr( $title_class ) : $classname,
@@ -245,12 +228,12 @@ class Components {
245
228
  *
246
229
  * @param array $args
247
230
  *
248
- * @return html
231
+ * @return string
249
232
  */
250
- public static function get_icon( $args ) {
233
+ public static function get_icon( array $args ): string {
251
234
  $icon_slug = sanitize_title( $args['name'] );
235
+ $icon_key = '';
252
236
 
253
- $icon_key = '';
254
237
  foreach ( $args as $key => $value ) {
255
238
  if ( is_bool( $value ) ) {
256
239
  $value = $value ? 'yes' : 'no';
@@ -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\RegisterCustomPostType;
8
+ use Chisel\Factories\RegisterCustomPostType;
9
9
 
10
10
  /**
11
11
  * Custom post types and taxonomies wrapper class.
12
12
  *
13
13
  * @package Chisel
14
14
  */
15
- class CustomPostTypes implements InstanceInterface, HooksInterface {
15
+ final class CustomPostTypes implements InstanceInterface, HooksInterface {
16
16
 
17
17
  use Singleton;
18
18
 
@@ -21,21 +21,21 @@ class CustomPostTypes implements InstanceInterface, HooksInterface {
21
21
  *
22
22
  * @var array
23
23
  */
24
- private $post_types = array();
24
+ private array $post_types = array();
25
25
 
26
26
  /**
27
27
  * Default post type supports.
28
28
  *
29
29
  * @var array
30
30
  */
31
- private $default_post_type_supports = array();
31
+ private array $default_post_type_supports = array();
32
32
 
33
33
  /**
34
34
  * Default post type rewrite args.
35
35
  *
36
36
  * @var array
37
37
  */
38
- private $default_post_type_rewrite_args = array();
38
+ private array $default_post_type_rewrite_args = array();
39
39
 
40
40
  /**
41
41
  * Class constructor.
@@ -50,9 +50,9 @@ class CustomPostTypes implements InstanceInterface, HooksInterface {
50
50
  /**
51
51
  * Set properties.
52
52
  */
53
- public function set_properties() {
54
- $this->default_post_type_supports = apply_filters( 'chisel_default_post_type_supports', array( 'title', 'page-attributes', 'revisions', 'author' ) );
55
- $this->default_post_type_rewrite_args = apply_filters(
53
+ public function set_properties(): void {
54
+ $this->default_post_type_supports = (array) apply_filters( 'chisel_default_post_type_supports', array( 'title', 'page-attributes', 'revisions', 'author' ) );
55
+ $this->default_post_type_rewrite_args = (array) apply_filters(
56
56
  'chisel_default_post_type_rewrite_args',
57
57
  array(
58
58
  'slug' => '',
@@ -69,20 +69,19 @@ class CustomPostTypes implements InstanceInterface, HooksInterface {
69
69
  /**
70
70
  * Register action hooks.
71
71
  */
72
- public function action_hooks() {
72
+ public function action_hooks(): void {
73
73
  add_action( 'init', array( $this, 'register_post_types' ) );
74
74
  }
75
75
 
76
76
  /**
77
77
  * Register filter hooks.
78
78
  */
79
- public function filter_hooks() {
80
- }
79
+ public function filter_hooks(): void {}
81
80
 
82
81
  /**
83
82
  * Register custom post types.
84
83
  */
85
- public function register_post_types() {
84
+ public function register_post_types(): void {
86
85
  $this->post_types = apply_filters( 'chisel_custom_post_types', $this->post_types );
87
86
 
88
87
  if ( empty( $this->post_types ) ) {
@@ -103,7 +102,7 @@ class CustomPostTypes implements InstanceInterface, HooksInterface {
103
102
  /**
104
103
  * Set custom post types.
105
104
  */
106
- private function set_post_types() {
105
+ private function set_post_types(): void {
107
106
  $this->post_types = array(
108
107
  // phpcs:disable
109
108
  // 'chisel-cpt' => array(