generator-chisel 2.3.2 → 2.4.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 (117) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/lib/commands/create/creators/app/chisel-starter-theme/.editorconfig +16 -0
  3. package/lib/commands/create/creators/app/chisel-starter-theme/.gitignore.chisel-tpl +0 -1
  4. package/lib/commands/create/creators/app/chisel-starter-theme/.husky/pre-commit +92 -0
  5. package/lib/commands/create/creators/app/chisel-starter-theme/.nvmrc +1 -1
  6. package/lib/commands/create/creators/app/chisel-starter-theme/.vscode/extensions.json +10 -0
  7. package/lib/commands/create/creators/app/chisel-starter-theme/.vscode/settings.json +19 -0
  8. package/lib/commands/create/creators/app/chisel-starter-theme/README.md +67 -10
  9. package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/search.svg +3 -0
  10. package/lib/commands/create/creators/app/chisel-starter-theme/composer.json +3 -3
  11. package/lib/commands/create/creators/app/chisel-starter-theme/{inc/WP/AjaxEndpoints.php → core/Ajax/LoadMoreEndpoint.php} +8 -51
  12. package/lib/commands/create/creators/app/chisel-starter-theme/core/Controllers/AjaxController.php +225 -0
  13. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/AcfHelpers.php +4 -0
  14. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/AjaxHelpers.php +4 -0
  15. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/AssetsHelpers.php +4 -0
  16. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/BlocksHelpers.php +5 -0
  17. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/CacheHelpers.php +5 -1
  18. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/CommentsHelpers.php +4 -0
  19. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/DataHelpers.php +4 -0
  20. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/GravityFormsHelpers.php +4 -0
  21. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/ImageHelpers.php +4 -0
  22. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/ThemeHelpers.php +10 -2
  23. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/WoocommerceHelpers.php +4 -0
  24. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/YoastHelpers.php +4 -0
  25. package/lib/commands/create/creators/app/chisel-starter-theme/core/Interfaces/AjaxEndpointInterface.php +15 -0
  26. package/lib/commands/create/creators/app/chisel-starter-theme/{inc/Plugins → core/Plugins/GravityForms}/GravityForms.php +12 -24
  27. package/lib/commands/create/creators/app/chisel-starter-theme/{inc/Plugins → core/Plugins/Woocommerce}/Woocommerce.php +23 -14
  28. package/lib/commands/create/creators/app/chisel-starter-theme/core/Plugins/Yoast/Yoast.php +37 -0
  29. package/lib/commands/create/creators/app/chisel-starter-theme/{inc/WP → core/Timber}/Cache.php +5 -17
  30. package/lib/commands/create/creators/app/chisel-starter-theme/{inc/WP → core/Timber}/ChiselImage.php +1 -1
  31. package/lib/commands/create/creators/app/chisel-starter-theme/{inc/WP → core/Timber}/ChiselPost.php +1 -1
  32. package/lib/commands/create/creators/app/chisel-starter-theme/{inc/WP → core/Timber}/ChiselProduct.php +1 -1
  33. package/lib/commands/create/creators/app/chisel-starter-theme/{inc/WP → core/Timber}/ChiselProductCategory.php +1 -1
  34. package/lib/commands/create/creators/app/chisel-starter-theme/{inc/WP → core/Timber}/ChiselTerm.php +1 -1
  35. package/lib/commands/create/creators/app/chisel-starter-theme/{inc/WP → core/Timber}/Components.php +1 -1
  36. package/lib/commands/create/creators/app/chisel-starter-theme/core/Traits/Hooks.php +29 -0
  37. package/lib/commands/create/creators/app/chisel-starter-theme/core/Traits/HooksSingleton.php +54 -0
  38. package/lib/commands/create/creators/app/chisel-starter-theme/core/Traits/Rest.php +51 -0
  39. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Traits/Singleton.php +10 -8
  40. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/Acf.php +22 -55
  41. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/AcfBlocks.php +7 -20
  42. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/Assets.php +3 -15
  43. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/Blocks.php +7 -19
  44. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/Comments.php +44 -49
  45. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/CustomPostTypes.php +8 -35
  46. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/CustomTaxonomies.php +12 -36
  47. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/Sidebars.php +3 -15
  48. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/Site.php +52 -18
  49. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/Theme.php +4 -15
  50. package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/Twig.php +12 -31
  51. package/lib/commands/create/creators/app/chisel-starter-theme/custom/app/Timber/ChiselPost.php +14 -0
  52. package/lib/commands/create/creators/app/chisel-starter-theme/custom/app/WP/Acf.php +66 -0
  53. package/lib/commands/create/creators/app/chisel-starter-theme/custom/app/WP/Ajax.php +45 -0
  54. package/lib/commands/create/creators/app/chisel-starter-theme/custom/app/WP/Assets.php +37 -0
  55. package/lib/commands/create/creators/app/chisel-starter-theme/custom/app/WP/CustomPostTypes.php +76 -0
  56. package/lib/commands/create/creators/app/chisel-starter-theme/custom/app/WP/Site.php +42 -0
  57. package/lib/commands/create/creators/app/chisel-starter-theme/custom/app/WP/Twig.php +52 -0
  58. package/lib/commands/create/creators/app/chisel-starter-theme/custom/functions.php +8 -0
  59. package/lib/commands/create/creators/app/chisel-starter-theme/custom/views/README.md +7 -0
  60. package/lib/commands/create/creators/app/chisel-starter-theme/functions.php +31 -9
  61. package/lib/commands/create/creators/app/chisel-starter-theme/package.chisel-tpl.json +11 -6
  62. package/lib/commands/create/creators/app/chisel-starter-theme/phpcs.xml +10 -0
  63. package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks/accordion/block.json +1 -1
  64. package/lib/commands/create/creators/app/chisel-starter-theme/src/design/settings/_index.scss +2 -2
  65. package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_breakpoints.scss +1 -0
  66. package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/mods/core.js +11 -2
  67. package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/modules/main-nav.js +14 -2
  68. package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/modules/slider.js +45 -4
  69. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_buttons.scss +11 -2
  70. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_search-form.scss +17 -0
  71. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_slider.scss +3 -3
  72. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-base.scss +117 -0
  73. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-collapse.scss.disabled +66 -0
  74. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-elastic.scss.disabled +56 -0
  75. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-emphatic.scss.disabled +59 -0
  76. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-settings.scss +22 -0
  77. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-slider.scss +59 -0
  78. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-spin.scss.disabled +60 -0
  79. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-spring.scss.disabled +98 -0
  80. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-squeeze.scss.disabled +47 -0
  81. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-stand.scss.disabled +59 -0
  82. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-three-d.scss.disabled +139 -0
  83. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-vortex.scss.disabled +61 -0
  84. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/gravity-forms.scss +17 -1
  85. package/lib/commands/create/creators/app/chisel-starter-theme/style.chisel-tpl.css +1 -1
  86. package/lib/commands/create/creators/app/chisel-starter-theme/theme.json +1 -1
  87. package/lib/commands/create/creators/app/chisel-starter-theme/twig_cs.php +4 -2
  88. package/lib/commands/create/creators/app/chisel-starter-theme/views/base.twig +1 -2
  89. package/lib/commands/create/creators/app/chisel-starter-theme/views/components/footer.twig +19 -11
  90. package/lib/commands/create/creators/app/chisel-starter-theme/views/components/header.twig +6 -2
  91. package/lib/commands/create/creators/app/chisel-starter-theme/views/components/logo.twig +6 -2
  92. package/lib/commands/create/creators/app/chisel-starter-theme/views/components/main-nav.twig +1 -1
  93. package/lib/commands/create/creators/app/chisel-starter-theme/views/components/post-item.twig +38 -20
  94. package/lib/commands/create/creators/app/chisel-starter-theme/views/components/search-form.twig +8 -0
  95. package/lib/commands/create/creators/app/chisel-starter-theme/views/index.twig +19 -10
  96. package/lib/commands/create/creators/app/chisel-starter-theme/views/search.twig +5 -6
  97. package/lib/commands/create/creators/app/chisel-starter-theme/views/single.twig +43 -31
  98. package/lib/commands/create/creators/app/chisel-starter-theme/views/woocommerce/content-product.twig +1 -1
  99. package/lib/commands/create/creators/app/index.js +87 -9
  100. package/lib/commands/create/creators/app/template/.gitignore.chisel-tpl +1 -0
  101. package/lib/commands/create/creators/wp/index.js +10 -2
  102. package/lib/commands/create/packages-versions.js +2 -2
  103. package/lib/commands/create/priorities.js +3 -0
  104. package/package.json +2 -2
  105. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Controllers/AjaxController.php +0 -156
  106. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Interfaces/HooksInterface.php +0 -26
  107. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Interfaces/InstanceInterface.php +0 -16
  108. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Plugins/Yoast.php +0 -46
  109. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_main-nav-toggle.scss +0 -804
  110. /package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Enums/AcfOptionsPageType.php +0 -0
  111. /package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Enums/BlocksType.php +0 -0
  112. /package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Factories/RegisterAcfOptionsPage.php +0 -0
  113. /package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Factories/RegisterBlocks.php +0 -0
  114. /package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Factories/RegisterCustomPostType.php +0 -0
  115. /package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Factories/RegisterCustomTaxonomy.php +0 -0
  116. /package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Traits/PageBlocks.php +0 -0
  117. /package/lib/commands/create/creators/app/chisel-starter-theme/{src/scripts/blog.js → custom/app/Ajax/.gitkeep} +0 -0
@@ -5,36 +5,32 @@ namespace Chisel\WP;
5
5
  use Timber\Timber;
6
6
  use Timber\Site as TimberSite;
7
7
 
8
- use Chisel\Interfaces\InstanceInterface;
9
- use Chisel\Interfaces\HooksInterface;
10
- use Chisel\Traits\Singleton;
8
+ use Chisel\Traits\HooksSingleton;
9
+ use Chisel\Timber\ChiselImage;
10
+ use Chisel\Timber\ChiselPost;
11
+ use Chisel\Timber\ChiselProduct;
12
+ use Chisel\Timber\ChiselProductCategory;
13
+ use Chisel\Timber\ChiselTerm;
14
+ use Chisel\Timber\Components;
11
15
 
12
16
  /**
13
17
  * Site related functionality related to timber.
14
18
  *
15
19
  * @package Chisel
16
20
  */
17
- final class Site extends TimberSite implements InstanceInterface, HooksInterface {
21
+ final class Site extends TimberSite {
18
22
 
19
- use Singleton;
23
+ use HooksSingleton;
20
24
 
21
25
  /**
22
- * Class constructor.
26
+ * Call parent constructor.
27
+ *
28
+ * @return bool
23
29
  */
24
- private function __construct() {
25
- add_action( 'after_setup_theme', array( $this, 'set_properties' ), 7 );
26
-
27
- $this->action_hooks();
28
- $this->filter_hooks();
29
-
30
- parent::__construct();
30
+ protected function should_call_parent_construct(): bool {
31
+ return true;
31
32
  }
32
33
 
33
- /**
34
- * Set properties.
35
- */
36
- public function set_properties(): void {}
37
-
38
34
  /**
39
35
  * Register action hooks.
40
36
  */
@@ -44,11 +40,33 @@ final class Site extends TimberSite implements InstanceInterface, HooksInterface
44
40
  * Register filter hooks.
45
41
  */
46
42
  public function filter_hooks(): void {
43
+ add_filter( 'timber/locations', array( $this, 'tiwg_files_locations' ) );
47
44
  add_filter( 'timber/context', array( $this, 'add_to_context' ) );
48
45
  add_filter( 'timber/post/classmap', array( $this, 'post_classmap' ) );
49
46
  add_filter( 'timber/term/classmap', array( $this, 'term_classmap' ) );
50
47
  }
51
48
 
49
+ /**
50
+ * Add custom Timber files locations. Let views in custom directory override default views.
51
+ *
52
+ * @param array $locations The locations.
53
+ *
54
+ * @return array
55
+ */
56
+ public function tiwg_files_locations( array $locations ): array {
57
+ $custom_templates = get_template_directory() . '/custom/views/';
58
+
59
+ if ( is_dir( $custom_templates ) ) {
60
+ if ( isset( $locations['__main__'] ) ) {
61
+ array_unshift( $locations['__main__'], $custom_templates );
62
+ } else {
63
+ array_unshift( $locations, $custom_templates );
64
+ }
65
+ }
66
+
67
+ return $locations;
68
+ }
69
+
52
70
  /**
53
71
  * Add data to the context.
54
72
  *
@@ -80,6 +98,14 @@ final class Site extends TimberSite implements InstanceInterface, HooksInterface
80
98
  'attachment' => ChiselImage::class,
81
99
  );
82
100
 
101
+ $custom_post_types = CustomPostTypes::get_post_types();
102
+
103
+ foreach ( $custom_post_types as $cpt => $data ) {
104
+ if ( ! isset( $custom_classmap[$cpt] ) ) {
105
+ $custom_classmap[$cpt] = ChiselPost::class;
106
+ }
107
+ }
108
+
83
109
  return array_merge( $classmap, $custom_classmap );
84
110
  }
85
111
 
@@ -95,6 +121,14 @@ final class Site extends TimberSite implements InstanceInterface, HooksInterface
95
121
  'product_cat' => ChiselProductCategory::class,
96
122
  );
97
123
 
124
+ $custom_taxonomies = CustomTaxonomies::get_taxonomies();
125
+
126
+ foreach ( $custom_taxonomies as $taxonomy => $data ) {
127
+ if ( ! isset( $custom_classmap[$taxonomy] ) ) {
128
+ $custom_classmap[$taxonomy] = ChiselTerm::class;
129
+ }
130
+ }
131
+
98
132
  return array_merge( $classmap, $custom_classmap );
99
133
  }
100
134
  }
@@ -2,9 +2,7 @@
2
2
 
3
3
  namespace Chisel\WP;
4
4
 
5
- use Chisel\Interfaces\InstanceInterface;
6
- use Chisel\Interfaces\HooksInterface;
7
- use Chisel\Traits\Singleton;
5
+ use Chisel\Traits\HooksSingleton;
8
6
  use Chisel\Helpers\ThemeHelpers;
9
7
 
10
8
  /**
@@ -12,9 +10,9 @@ use Chisel\Helpers\ThemeHelpers;
12
10
  *
13
11
  * @package Chisel
14
12
  */
15
- final class Theme implements InstanceInterface, HooksInterface {
13
+ final class Theme {
16
14
 
17
- use Singleton;
15
+ use HooksSingleton;
18
16
 
19
17
  /**
20
18
  * Post types that support post thumbnails.
@@ -30,16 +28,6 @@ final class Theme implements InstanceInterface, HooksInterface {
30
28
  */
31
29
  private array $nav_menus = array();
32
30
 
33
- /**
34
- * Class constructor.
35
- */
36
- private function __construct() {
37
- add_action( 'after_setup_theme', array( $this, 'set_properties' ), 7 );
38
-
39
- $this->action_hooks();
40
- $this->filter_hooks();
41
- }
42
-
43
31
  /**
44
32
  * Set properties.
45
33
  */
@@ -83,6 +71,7 @@ final class Theme implements InstanceInterface, HooksInterface {
83
71
  public function theme_supports(): void {
84
72
  $this->post_thumbnails_post_types = (array) apply_filters( 'chisel_post_thumbnails_post_types', $this->post_thumbnails_post_types );
85
73
 
74
+ add_theme_support( 'title-tag' );
86
75
  add_theme_support( 'post-formats', array() );
87
76
  add_theme_support( 'post-thumbnails', $this->post_thumbnails_post_types );
88
77
  add_theme_support( 'menus' );
@@ -4,9 +4,7 @@ namespace Chisel\WP;
4
4
 
5
5
  use Timber\Timber;
6
6
 
7
- use Chisel\Interfaces\InstanceInterface;
8
- use Chisel\Interfaces\HooksInterface;
9
- use Chisel\Traits\Singleton;
7
+ use Chisel\Traits\HooksSingleton;
10
8
  use Chisel\Helpers\CommentsHelpers;
11
9
  use Chisel\Helpers\DataHelpers;
12
10
  use Chisel\Helpers\ImageHelpers;
@@ -20,24 +18,9 @@ use Chisel\WP\Components;
20
18
  *
21
19
  * @package Chisel
22
20
  */
23
- final class Twig implements InstanceInterface, HooksInterface {
21
+ final class Twig {
24
22
 
25
- use Singleton;
26
-
27
- /**
28
- * Class constructor.
29
- */
30
- private function __construct() {
31
- add_action( 'after_setup_theme', array( $this, 'set_properties' ), 7 );
32
-
33
- $this->action_hooks();
34
- $this->filter_hooks();
35
- }
36
-
37
- /**
38
- * Set properties.
39
- */
40
- public function set_properties(): void {}
23
+ use HooksSingleton;
41
24
 
42
25
  /**
43
26
  * Register action hooks.
@@ -83,6 +66,8 @@ final class Twig implements InstanceInterface, HooksInterface {
83
66
  $this->register_function( $twig, 'get_icon', array( $this, 'get_icon' ) );
84
67
  $this->register_function( $twig, 'should_use_icons_module', array( $this, 'should_use_icons_module' ) );
85
68
 
69
+ do_action( 'chisel_twig_register_functions', $twig, $this );
70
+
86
71
  return $twig;
87
72
  }
88
73
 
@@ -93,6 +78,7 @@ final class Twig implements InstanceInterface, HooksInterface {
93
78
  * @return \Twig\Environment
94
79
  */
95
80
  public function register_filters( \Twig\Environment $twig ): \Twig\Environment {
81
+ do_action( 'chisel_twig_register_filters', $twig, $this );
96
82
 
97
83
  return $twig;
98
84
  }
@@ -104,6 +90,7 @@ final class Twig implements InstanceInterface, HooksInterface {
104
90
  * @return \Twig\Environment
105
91
  */
106
92
  public function register_tests( \Twig\Environment $twig ): \Twig\Environment {
93
+ do_action( 'chisel_twig_register_tests', $twig, $this );
107
94
 
108
95
  return $twig;
109
96
  }
@@ -117,7 +104,7 @@ final class Twig implements InstanceInterface, HooksInterface {
117
104
  *
118
105
  * @return \Twig\Environment
119
106
  */
120
- private function register_function( $twig, $name, $callback ): \Twig\Environment {
107
+ public function register_function( \Twig\Environment $twig, string $name, callable $callback ): \Twig\Environment {
121
108
  $twig->addFunction( new \Twig\TwigFunction( $name, $callback ) );
122
109
 
123
110
  return $twig;
@@ -132,7 +119,7 @@ final class Twig implements InstanceInterface, HooksInterface {
132
119
  *
133
120
  * @return \Twig\Environment
134
121
  */
135
- private function register_filter( \Twig\Environment $twig, string $name, callable $callback ): \Twig\Environment {
122
+ public function register_filter( \Twig\Environment $twig, string $name, callable $callback ): \Twig\Environment {
136
123
  $twig->addFilter( new \Twig\TwigFilter( $name, $callback ) );
137
124
 
138
125
  return $twig;
@@ -147,7 +134,7 @@ final class Twig implements InstanceInterface, HooksInterface {
147
134
  *
148
135
  * @return \Twig\Environment
149
136
  */
150
- private function register_test( \Twig\Environment $twig, string $name, callable $callback ): \Twig\Environment {
137
+ public function register_test( \Twig\Environment $twig, string $name, callable $callback ): \Twig\Environment {
151
138
  $twig->addTest( new \Twig\TwigTest( $name, $callback ) );
152
139
 
153
140
  return $twig;
@@ -182,20 +169,14 @@ final class Twig implements InstanceInterface, HooksInterface {
182
169
  *
183
170
  * @return string
184
171
  */
185
- public function post_classes( ?string $classes, string $prefix = 'c-post--' ): string {
172
+ public function post_classes( ?string $classes, string $prefix = 'c-post' ): string {
186
173
  if ( empty( $classes ) ) {
187
174
  return '';
188
175
  }
189
176
 
190
177
  $classnames = explode( ' ', $classes );
191
- $classnames = array_map(
192
- function ( $classname ) use ( $prefix ) {
193
- return $prefix . $classname;
194
- },
195
- $classnames
196
- );
197
178
 
198
- return implode( ' ', $classnames );
179
+ return ThemeHelpers::bem( $prefix, ...$classnames );
199
180
  }
200
181
 
201
182
  /**
@@ -0,0 +1,14 @@
1
+ <?php
2
+
3
+ namespace Chisel\Timber\Custom;
4
+
5
+ use Chisel\Timber\ChiselPost as CoreChiselPost;
6
+ use Timber\Timber;
7
+
8
+ /**
9
+ * Extend Timber Post class with custom functionality.
10
+ *
11
+ * @package Chisel
12
+ */
13
+ class ChiselPost extends CoreChiselPost {
14
+ }
@@ -0,0 +1,66 @@
1
+ <?php
2
+
3
+ namespace Chisel\WP\Custom;
4
+
5
+ use Chisel\Traits\HooksSingleton;
6
+
7
+ /**
8
+ * ACF related functionality.
9
+ *
10
+ * @package Chisel
11
+ */
12
+ class Acf {
13
+
14
+ use HooksSingleton;
15
+
16
+ /**
17
+ * Register action hooks.
18
+ */
19
+ public function action_hooks(): void {}
20
+
21
+ /**
22
+ * Register filter hooks.
23
+ */
24
+ public function filter_hooks(): void {
25
+ add_filter( 'chisel_acf_options_pages', array( $this, 'register_acf_options_pages' ) );
26
+ add_filter( 'chisel_acf_options_sub_pages', array( $this, 'register_acf_options_sub_pages' ) );
27
+ }
28
+
29
+ /**
30
+ * Register custom ACF options pages.
31
+ *
32
+ * @param array $options_pages The options pages.
33
+ *
34
+ * @return array
35
+ */
36
+ public function register_acf_options_pages( $options_pages ) {
37
+ // phpcs:disable -- Example of custom ACF options page
38
+ // $options_pages[] = array(
39
+ // 'menu_slug' => 'theme-settings',
40
+ // 'page_title' => __( 'Theme Settings', 'chisel' ),
41
+ // );
42
+ // phpcs:enable
43
+
44
+ return $options_pages;
45
+ }
46
+
47
+ /**
48
+ * Register custom ACF options sub pages.
49
+ *
50
+ * @param array $options_sub_pages The options sub pages.
51
+ *
52
+ * @return array
53
+ */
54
+ public function register_acf_options_sub_pages( $options_sub_pages ) {
55
+ // phpcs:disable -- Example of custom ACF options sub page
56
+ // $options_sub_pages[] = array(
57
+ // 'menu_slug' => 'theme-sub-settings',
58
+ // 'page_title' => __( 'Theme Sub settings', 'chisel' ),
59
+ // 'menu_title' => __( 'Theme Sub settings', 'chisel' ),
60
+ // 'parent_slug' => 'theme-settings',
61
+ // );
62
+ // phpcs:enable
63
+
64
+ return $options_sub_pages;
65
+ }
66
+ }
@@ -0,0 +1,45 @@
1
+ <?php
2
+
3
+ namespace Chisel\WP\Custom;
4
+
5
+ use Chisel\Traits\HooksSingleton;
6
+
7
+ /**
8
+ * Ajax related functionality.
9
+ *
10
+ * @package Chisel
11
+ */
12
+ class Ajax {
13
+
14
+ use HooksSingleton;
15
+
16
+ /**
17
+ * Register action hooks.
18
+ */
19
+ public function action_hooks(): void {}
20
+
21
+ /**
22
+ * Register filter hooks.
23
+ */
24
+ public function filter_hooks(): void {
25
+ add_filter( 'chisel_ajax_routes', array( $this, 'register_ajax_routes' ) );
26
+ }
27
+
28
+ /**
29
+ * Register custom ajax routes.
30
+ *
31
+ * @param array $routes The ajax routes.
32
+ *
33
+ * @return array
34
+ */
35
+ public function register_ajax_routes( array $routes ): array {
36
+ // phpcs:disable -- Example of custom ajax route
37
+ // $routes['custom_route'] = array(
38
+ // 'methods' => 'POST', // default is POST
39
+ // 'handler' => 'Chisel\WP\Custom\Ajax\CustomRouteHandler', // custom handler class, leave empty for default handler: CustomRouteEndpoint
40
+ // );
41
+ // phpcs:enable
42
+
43
+ return $routes;
44
+ }
45
+ }
@@ -0,0 +1,37 @@
1
+ <?php
2
+
3
+ namespace Chisel\WP\Custom;
4
+
5
+ use Chisel\Traits\HooksSingleton;
6
+
7
+ /**
8
+ * Class for enqueuing scripts and styles.
9
+ *
10
+ * @package Chisel
11
+ */
12
+ class Assets {
13
+ use HooksSingleton;
14
+
15
+ /**
16
+ * Add action hooks.
17
+ */
18
+ public function action_hooks(): void {}
19
+
20
+ /**
21
+ * Add filter hooks.
22
+ */
23
+ public function filter_hooks(): void {
24
+ add_filter( 'chisel_frontend_styles', array( $this, 'frontend_styles' ) );
25
+ }
26
+
27
+ /**
28
+ * Modify frontend styles.
29
+ *
30
+ * @param array $styles Frontend styles.
31
+ *
32
+ * @return array Frontend styles.
33
+ */
34
+ public function frontend_styles( array $styles ): array {
35
+ return $styles;
36
+ }
37
+ }
@@ -0,0 +1,76 @@
1
+ <?php
2
+
3
+ namespace Chisel\WP\Custom;
4
+
5
+ use Chisel\Traits\HooksSingleton;
6
+
7
+ /**
8
+ * Custom Post Types related functionality.
9
+ *
10
+ * @package Chisel
11
+ */
12
+ class CustomPostTypes {
13
+ use HooksSingleton;
14
+
15
+ /**
16
+ * Register action hooks.
17
+ */
18
+ public function action_hooks(): void {}
19
+
20
+ /**
21
+ * Register filter hooks.
22
+ */
23
+ public function filter_hooks(): void {
24
+ add_filter( 'chisel_custom_post_types', array( $this, 'register_custom_post_types' ) );
25
+ add_filter( 'chisel_custom_taxonomies', array( $this, 'register_custom_taxonomies' ) );
26
+ }
27
+
28
+ /**
29
+ * Register custom post types.
30
+ *
31
+ * @param array $post_types The post types.
32
+ *
33
+ * @return array
34
+ */
35
+ public function register_custom_post_types( $post_types ) {
36
+ // phpcs:disable -- Example of custom post type. Remove this line and the phpcs:enable when adding your own custom post types
37
+ // $post_types['chisel-cpt'] = array(
38
+ // 'singular' => __( 'Chisel CPT', 'chisel' ),
39
+ // 'plural' => __( 'Chisel CPTs', 'chisel' ),
40
+ // 'supports' => array( 'editor', 'thumbnail', 'excerpt' ),
41
+ // 'menu_icon' => 'dashicons-location-alt',
42
+ // 'hierarchical' => true,
43
+ // 'public' => true,
44
+ // 'menu_position' => 20,
45
+ // 'rewrite' => array(
46
+ // 'slug' => 'chisel-post',
47
+ // ),
48
+ // );
49
+ // phpcs:enable
50
+
51
+ return $post_types;
52
+ }
53
+
54
+ /**
55
+ * Register custom taxonomies.
56
+ *
57
+ * @param array $taxonomies The taxonomies.
58
+ *
59
+ * @return array
60
+ */
61
+ public function register_custom_taxonomies( $taxonomies ) {
62
+ // phpcs:disable -- Example of custom taxonomy. Remove this line and the phpcs:enable when adding your own custom taxonomies
63
+ // $taxonomies['chisel-term'] = array(
64
+ // 'singular' => __( 'Chisel Term', 'chisel' ),
65
+ // 'plural' => __( 'Chisel Terms', 'chisel' ),
66
+ // 'post_types' => array( 'chisel-cpt' ),
67
+ // 'public' => true,
68
+ // 'rewrite' => array(
69
+ // 'slug' => 'chisel-term',
70
+ // ),
71
+ // );
72
+ // phpcs:enable
73
+
74
+ return $taxonomies;
75
+ }
76
+ }
@@ -0,0 +1,42 @@
1
+ <?php
2
+
3
+ namespace Chisel\WP\Custom;
4
+
5
+ use Chisel\Traits\HooksSingleton;
6
+
7
+ /**
8
+ * Site related functionality related to timber.
9
+ *
10
+ * @package Chisel
11
+ */
12
+ class Site {
13
+
14
+ use HooksSingleton;
15
+
16
+ /**
17
+ * Register action hooks.
18
+ */
19
+ public function action_hooks(): void {}
20
+
21
+ /**
22
+ * Register filter hooks.
23
+ */
24
+ public function filter_hooks(): void {
25
+ add_filter( 'timber/post/classmap', array( $this, 'post_classmap' ), 11 );
26
+ }
27
+
28
+ /**
29
+ * Add custom post class map.
30
+ *
31
+ * @param array $classmap The class map.
32
+ *
33
+ * @return array
34
+ */
35
+ public function post_classmap( array $classmap ): array {
36
+ $custom_classmap = array(
37
+ 'post' => \Chisel\Timber\Custom\ChiselPost::class,
38
+ );
39
+
40
+ return array_merge( $classmap, $custom_classmap );
41
+ }
42
+ }
@@ -0,0 +1,52 @@
1
+ <?php
2
+
3
+ namespace Chisel\WP\Custom;
4
+
5
+ use Chisel\Traits\HooksSingleton;
6
+
7
+ /**
8
+ * Custom Twig functionality.
9
+ *
10
+ * @package Chisel
11
+ */
12
+ class Twig {
13
+
14
+ use HooksSingleton;
15
+
16
+ /**
17
+ * Register action hooks.
18
+ */
19
+ public function action_hooks(): void {
20
+ add_action( 'chisel_twig_register_functions', array( $this, 'register_functions' ), 10, 2 );
21
+ add_action( 'chisel_twig_register_filters', array( $this, 'register_filters' ), 10, 2 );
22
+ }
23
+
24
+ /**
25
+ * Register filter hooks.
26
+ */
27
+ public function filter_hooks(): void {}
28
+
29
+ /**
30
+ * Register custom twig functions.
31
+ *
32
+ * @param \Twig\Environment $twig The Twig environment.
33
+ * @param \Chisel\WP\Twig $chisel_twig The Chisel Twig instance.
34
+ */
35
+ public function register_functions( \Twig\Environment $twig, \Chisel\WP\Twig $chisel_twig ): void {
36
+ // phpcs:disable -- Example of custom function. Remove this line and the phpcs:enable when adding your own custom functions
37
+ // $twig->addFunction( new \Twig\Function( 'custom_fn', array( $this, 'custom_fn_callback' ) ) );
38
+ // phpcs:enable
39
+ }
40
+
41
+ /**
42
+ * Register custom twig filters.
43
+ *
44
+ * @param \Twig\Environment $twig The Twig environment.
45
+ * @param \Chisel\WP\Twig $chisel_twig The Chisel Twig instance.
46
+ */
47
+ public function register_filters( \Twig\Environment $twig, \Chisel\WP\Twig $chisel_twig ): void {
48
+ // phpcs:disable -- Example of custom filter. Remove this line and the phpcs:enable when adding your own custom filters
49
+ // $twig->addFilter( new \Twig\Filter( 'custom_filter', array( $this, 'custom_filter_callback' ) ) );
50
+ // phpcs:enable
51
+ }
52
+ }
@@ -0,0 +1,8 @@
1
+ <?php
2
+
3
+ \Chisel\WP\Custom\Acf::get_instance();
4
+ \Chisel\WP\Custom\Ajax::get_instance();
5
+ \Chisel\WP\Custom\Assets::get_instance();
6
+ \Chisel\WP\Custom\CustomPostTypes::get_instance();
7
+ \Chisel\WP\Custom\Site::get_instance();
8
+ \Chisel\WP\Custom\Twig::get_instance();
@@ -0,0 +1,7 @@
1
+ # Custom views
2
+
3
+ Recommended approach is to use the main views folder, but if want more control and clear separation between the main theme and customizations, use the custom views folder.
4
+
5
+ ## Usage
6
+
7
+ To overwrite views existing in the main folder create a file with the same name and the same folder structure.