generator-chisel 2.0.0-alpha.8 → 2.0.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 (174) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/bin/chisel.js +6 -0
  3. package/lib/commands/create/Creator.js +6 -0
  4. package/lib/commands/create/creators/app/chisel-starter-theme/.gitignore.chisel-tpl +3 -2
  5. package/lib/commands/create/creators/app/chisel-starter-theme/.nvmrc +1 -1
  6. package/lib/commands/create/creators/app/chisel-starter-theme/404.php +2 -2
  7. package/lib/commands/create/creators/app/chisel-starter-theme/README.md +37 -1
  8. package/lib/commands/create/creators/app/chisel-starter-theme/acf-json/group_6772609e3c28c.json +83 -0
  9. package/lib/commands/create/creators/app/chisel-starter-theme/acf-json/group_6772615562fb4.json +49 -0
  10. package/lib/commands/create/creators/app/chisel-starter-theme/archive.php +2 -4
  11. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/block.json +31 -0
  12. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/edit.js +35 -0
  13. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/editor.scss +3 -0
  14. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/index.js +45 -0
  15. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/save.js +20 -0
  16. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/script.js +7 -0
  17. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/style.scss +3 -0
  18. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/view.js +7 -0
  19. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/view.scss +3 -0
  20. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/block.json +32 -0
  21. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/edit.js +33 -0
  22. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/editor.scss +3 -0
  23. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/index.js +45 -0
  24. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/render.php +12 -0
  25. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/render.twig +5 -0
  26. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/save.js +6 -0
  27. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/script.js +7 -0
  28. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/style.scss +3 -0
  29. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/view.js +7 -0
  30. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/view.scss +3 -0
  31. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/block.json +36 -0
  32. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/critical.scss +3 -0
  33. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/editor.scss +3 -0
  34. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/example.twig +3 -0
  35. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/index.js +7 -0
  36. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/init.php +0 -0
  37. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/script.js +8 -0
  38. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/style.scss +3 -0
  39. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/view.js +7 -0
  40. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/view.scss +3 -0
  41. package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/arrow-left.svg +3 -0
  42. package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/arrow-right.svg +3 -0
  43. package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/chisel-icon.svg +1 -0
  44. package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/chisel-logo.svg +1 -0
  45. package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/close-line.svg +1 -0
  46. package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/color/chisel-icon.svg +1 -0
  47. package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/color/chisel-logo.svg +1 -0
  48. package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/color/facebook-logo.svg +10 -0
  49. package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/color/instagram-logo.svg +14 -0
  50. package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/x-logo.svg +1 -0
  51. package/lib/commands/create/creators/app/chisel-starter-theme/author.php +3 -4
  52. package/lib/commands/create/creators/app/chisel-starter-theme/composer.json +3 -0
  53. package/lib/commands/create/creators/app/chisel-starter-theme/footer.php +2 -2
  54. package/lib/commands/create/creators/app/chisel-starter-theme/functions.php +18 -24
  55. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Factory/RegisterAcfOptionsPage.php +62 -0
  56. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/Factory}/RegisterBlocks.php +53 -22
  57. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Factory/RegisterCustomPostType.php +211 -0
  58. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Factory/RegisterCustomTaxonomy.php +174 -0
  59. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/AcfHelpers.php +46 -0
  60. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/AjaxHelpers.php +33 -0
  61. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/AssetsHelpers.php +28 -0
  62. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/BlocksHelpers.php +118 -0
  63. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/CacheHelpers.php +41 -0
  64. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/CommentsHelpers.php +26 -0
  65. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/DataHelpers.php +35 -0
  66. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/GravityFormsHelpers.php +65 -0
  67. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/ImageHelpers.php +102 -0
  68. package/lib/commands/create/creators/app/chisel-starter-theme/{classes/Helpers.php → inc/Helper/ThemeHelpers.php} +53 -93
  69. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/WoocommerceHelpers.php +72 -0
  70. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/YoastHelpers.php +37 -0
  71. package/lib/commands/create/creators/app/chisel-starter-theme/{classes/interfaces/Instance.php → inc/Interfaces/HooksInterface.php} +3 -8
  72. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Interfaces/InstanceInterface.php +16 -0
  73. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/Module}/AcfSync.php +13 -20
  74. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/Module}/Ajax.php +16 -41
  75. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/Plugin}/GravityForms.php +15 -72
  76. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/Plugin}/Woocommerce.php +26 -80
  77. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Plugin/Yoast.php +46 -0
  78. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Traits/PageBlocks.php +92 -0
  79. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Traits/Singleton.php +23 -0
  80. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Acf.php +118 -0
  81. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/AcfBlocks.php +62 -61
  82. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/AjaxEnpoints.php +6 -6
  83. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Assets.php +258 -119
  84. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Blocks.php +69 -55
  85. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Cache.php +103 -0
  86. package/lib/commands/create/creators/app/chisel-starter-theme/{classes/ExtendedImage.php → inc/WP/ChiselImage.php} +2 -2
  87. package/lib/commands/create/creators/app/chisel-starter-theme/{classes/ExtendedPost.php → inc/WP/ChiselPost.php} +4 -10
  88. package/lib/commands/create/creators/app/chisel-starter-theme/{classes/ExtendedProduct.php → inc/WP/ChiselProduct.php} +4 -3
  89. package/lib/commands/create/creators/app/chisel-starter-theme/{classes/ExtendedTerm.php → inc/WP/ChiselTerm.php} +2 -2
  90. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Comments.php +10 -32
  91. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Components.php +61 -36
  92. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/CustomPostTypes.php +124 -0
  93. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/CustomTaxonomies.php +129 -0
  94. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Sidebars.php +11 -17
  95. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Site.php +15 -21
  96. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Theme.php +22 -15
  97. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Twig.php +34 -21
  98. package/lib/commands/create/creators/app/chisel-starter-theme/index.php +2 -3
  99. package/lib/commands/create/creators/app/chisel-starter-theme/package.chisel-tpl.json +5 -1
  100. package/lib/commands/create/creators/app/chisel-starter-theme/page.php +3 -3
  101. package/lib/commands/create/creators/app/chisel-starter-theme/phpcs.xml +5 -2
  102. package/lib/commands/create/creators/app/chisel-starter-theme/search.php +3 -4
  103. package/lib/commands/create/creators/app/chisel-starter-theme/single.php +3 -3
  104. package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks/accordion/accordion-item.js +2 -2
  105. package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks/accordion/style.scss +12 -5
  106. package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks-acf/slider/acf-json/group_66462c70b851f.json +107 -105
  107. package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks-acf/slider/block.json +1 -1
  108. package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks-acf/slider/slider.twig +4 -2
  109. package/lib/commands/create/creators/app/chisel-starter-theme/src/design/settings/_index.scss +2 -1
  110. package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_buttons.scss +1 -1
  111. package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_icon.scss +39 -7
  112. package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_index.scss +1 -0
  113. package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_layout.scss +11 -0
  114. package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/admin/acf.js +65 -1
  115. package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/app.js +2 -0
  116. package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/blocks.js +10 -4
  117. package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/mods/blocks-alignment.js +2 -2
  118. package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/mods/core-button.js +18 -14
  119. package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/utils.js +0 -12
  120. package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/modules/loaded.js +7 -0
  121. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/admin.scss +2 -0
  122. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core-button.scss +14 -13
  123. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_buttons.scss +14 -13
  124. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_icons-preview.scss +97 -0
  125. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_main-nav.scss +19 -9
  126. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_posts-items.scss +6 -0
  127. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/objects/_icon.scss +51 -0
  128. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/objects/_layout.scss +0 -13
  129. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/wp-admin/_acf.scss +29 -0
  130. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/wp-admin/_index.scss +4 -0
  131. package/lib/commands/create/creators/app/chisel-starter-theme/style.chisel-tpl.css +1 -1
  132. package/lib/commands/create/creators/app/chisel-starter-theme/views/base.twig +1 -1
  133. package/lib/commands/create/creators/app/chisel-starter-theme/views/components/header.twig +1 -1
  134. package/lib/commands/create/creators/app/chisel-starter-theme/views/{partials → components}/logo.twig +2 -2
  135. package/lib/commands/create/creators/app/chisel-starter-theme/views/components/main-nav-item.twig +2 -1
  136. package/lib/commands/create/creators/app/chisel-starter-theme/views/components/main-nav.twig +5 -2
  137. package/lib/commands/create/creators/app/chisel-starter-theme/views/components/pagination.twig +70 -0
  138. package/lib/commands/create/creators/app/chisel-starter-theme/views/components/post-item.twig +1 -1
  139. package/lib/commands/create/creators/app/chisel-starter-theme/views/components/slider.twig +2 -2
  140. package/lib/commands/create/creators/app/chisel-starter-theme/views/{partials → components}/the-title.twig +1 -1
  141. package/lib/commands/create/creators/app/chisel-starter-theme/views/index.twig +10 -5
  142. package/lib/commands/create/creators/app/chisel-starter-theme/views/objects/icon.twig +37 -0
  143. package/lib/commands/create/creators/app/chisel-starter-theme/views/partials/icons-preview.twig +81 -0
  144. package/lib/commands/create/creators/app/chisel-starter-theme/views/sidebar-blog.twig +1 -1
  145. package/lib/commands/create/creators/app/chisel-starter-theme/views/sidebar-woocommerce.twig +1 -1
  146. package/lib/commands/create/creators/app/chisel-starter-theme/views/single.twig +2 -2
  147. package/lib/commands/create/creators/app/chisel-starter-theme/views/woocommerce/archive-product.twig +2 -2
  148. package/lib/commands/create/creators/app/chisel-starter-theme/views/woocommerce/linked-products.twig +2 -2
  149. package/lib/commands/create/creators/app/chisel-starter-theme/views/woocommerce/single-product.twig +4 -4
  150. package/lib/commands/create/creators/app/chisel-starter-theme/woocommerce.php +6 -6
  151. package/lib/commands/create/creators/app/index.js +74 -20
  152. package/lib/commands/create/creators/app/template/.devcontainer/Dockerfile +21 -0
  153. package/lib/commands/create/creators/app/template/.devcontainer/compose.chisel-tpl +3 -0
  154. package/lib/commands/create/creators/app/template/.devcontainer/devcontainer.json.chisel-tpl +31 -0
  155. package/lib/commands/create/creators/app/template/.devcontainer/docker-compose.yml.chisel-tpl +40 -0
  156. package/lib/commands/create/creators/app/template/.devcontainer/exec +8 -0
  157. package/lib/commands/create/creators/app/template/.devcontainer/post-create-command.sh.chisel-tpl +24 -0
  158. package/lib/commands/create/creators/devcontainer.js +62 -0
  159. package/lib/commands/create/creators/utils.js +58 -0
  160. package/lib/commands/create/creators/wp/index.js +24 -3
  161. package/lib/commands/create/creators/wp-plugins/plugins.json +1 -1
  162. package/lib/commands/create/index.js +9 -2
  163. package/lib/commands/create/packages-versions.js +3 -3
  164. package/package.json +3 -3
  165. package/lib/commands/create/creators/app/chisel-starter-theme/classes/Acf.php +0 -188
  166. package/lib/commands/create/creators/app/chisel-starter-theme/classes/ChiselCache.php +0 -87
  167. package/lib/commands/create/creators/app/chisel-starter-theme/classes/CustomPostTypes.php +0 -444
  168. package/lib/commands/create/creators/app/chisel-starter-theme/classes/Yoast.php +0 -78
  169. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_icon.scss +0 -19
  170. package/lib/commands/create/creators/app/chisel-starter-theme/views/components/icon.twig +0 -1
  171. package/lib/commands/create/creators/app/chisel-starter-theme/views/partials/pagination.twig +0 -70
  172. /package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons/{loader.svg → animated/loader.svg} +0 -0
  173. /package/lib/commands/create/creators/app/chisel-starter-theme/assets/{icons → icons-source}/minus.svg +0 -0
  174. /package/lib/commands/create/creators/app/chisel-starter-theme/assets/{icons → icons-source}/plus.svg +0 -0
@@ -1,15 +1,20 @@
1
1
  <?php
2
2
 
3
- namespace Chisel;
3
+ namespace Chisel\Module;
4
4
 
5
- use Chisel\AjaxEnpoints;
5
+ use Chisel\WP\AjaxEnpoints;
6
+ use Chisel\Interfaces\InstanceInterface;
7
+ use Chisel\Interfaces\HooksInterface;
8
+ use Chisel\Traits\Singleton;
6
9
 
7
10
  /**
8
11
  * Custom Ajax class based on REST API.
9
12
  *
10
13
  * @package Chisel
11
14
  */
12
- class Ajax extends \WP_REST_Controller implements Instance {
15
+ class Ajax extends \WP_REST_Controller implements InstanceInterface, HooksInterface {
16
+
17
+ use Singleton;
13
18
 
14
19
  /**
15
20
  * Ajax custom route namespace.
@@ -30,13 +35,14 @@ class Ajax extends \WP_REST_Controller implements Instance {
30
35
  *
31
36
  * @var array
32
37
  */
33
- protected $routes = array();
38
+ private $routes = array();
34
39
 
35
40
  /**
36
41
  * Class constructor.
37
42
  */
38
43
  private function __construct() {
39
- $this->set_properties();
44
+ add_action( 'after_setup_theme', array( $this, 'set_properties' ), 7 );
45
+
40
46
  $this->action_hooks();
41
47
  $this->filter_hooks();
42
48
  }
@@ -97,7 +103,7 @@ class Ajax extends \WP_REST_Controller implements Instance {
97
103
  * @return callable
98
104
  */
99
105
  public function callback( $request ) {
100
- $callback = self::get_callback_name( $request );
106
+ $callback = $this->get_callback_name( $request );
101
107
  $ajax_endpoints = new AjaxEnpoints();
102
108
 
103
109
  if ( method_exists( $ajax_endpoints, $callback ) ) {
@@ -121,29 +127,11 @@ class Ajax extends \WP_REST_Controller implements Instance {
121
127
  * @return boolean
122
128
  */
123
129
  public function permissions_check( $request ) {
124
- $permission = apply_filters( 'chisel_ajax_permissions_check', true, self::get_callback_name( $request ), $request );
130
+ $verify_nonce = wp_verify_nonce( $request->get_header( 'x_wp_nonce' ), 'wp_rest' );
125
131
 
126
- return $permission;
127
- }
132
+ $permission = apply_filters( 'chisel_ajax_permissions_check', (bool) $verify_nonce, $this->get_callback_name( $request ), $request );
128
133
 
129
- /**
130
- * Get custom ajax endpint
131
- *
132
- * @return string
133
- */
134
- public static function get_ajax_endpoint_url() {
135
- return sprintf( '%s/wp-json/%s/%s', esc_url( get_bloginfo( 'url' ) ), self::ROUTE_NAMESPACE, self::ROUTE_BASE );
136
- }
137
-
138
- /**
139
- * Decode json string from ajax request
140
- *
141
- * @param string $value
142
- *
143
- * @return array
144
- */
145
- public static function ajax_json_decode( $value ) {
146
- return (array) json_decode( stripslashes( $value ) );
134
+ return $permission;
147
135
  }
148
136
 
149
137
  /**
@@ -153,24 +141,11 @@ class Ajax extends \WP_REST_Controller implements Instance {
153
141
  *
154
142
  * @return string
155
143
  */
156
- public static function get_callback_name( $request ) {
144
+ private function get_callback_name( $request ) {
157
145
  $route = $request->get_route();
158
146
  $route_parts = explode( '/', $route );
159
147
  $callback = str_replace( '-', '_', end( $route_parts ) );
160
148
 
161
149
  return $callback;
162
150
  }
163
-
164
- /**
165
- * Get the instance of the class.
166
- */
167
- public static function get_instance() {
168
- static $instance = null;
169
-
170
- if ( null === $instance ) {
171
- $instance = new self();
172
- }
173
-
174
- return $instance;
175
- }
176
151
  }
@@ -1,23 +1,31 @@
1
1
  <?php
2
2
 
3
- namespace Chisel;
3
+ namespace Chisel\Plugin;
4
+
5
+ use Chisel\Interfaces\InstanceInterface;
6
+ use Chisel\Interfaces\HooksInterface;
7
+ use Chisel\Traits\Singleton;
8
+ use Chisel\Helper\GravityFormsHelpers;
4
9
 
5
10
  /**
6
11
  * GravityForms related functionalities.
7
12
  *
8
13
  * @package Chisel
9
14
  */
10
- class GravityForms implements Instance {
15
+ class GravityForms implements InstanceInterface, HooksInterface {
16
+
17
+ use Singleton;
11
18
 
12
19
  /**
13
20
  * Class constructor.
14
21
  */
15
22
  private function __construct() {
16
- if ( ! self::is_gf_active() ) {
23
+ if ( ! GravityFormsHelpers::is_gf_active() ) {
17
24
  return;
18
25
  }
19
26
 
20
- $this->set_properties();
27
+ add_action( 'after_setup_theme', array( $this, 'set_properties' ), 7 );
28
+
21
29
  $this->action_hooks();
22
30
  $this->filter_hooks();
23
31
  }
@@ -96,7 +104,9 @@ class GravityForms implements Instance {
96
104
  * @return string
97
105
  */
98
106
  public function default_form_styles( $slug, $form ) {
99
- $slug = 'gravity-theme';
107
+ if ( ! is_admin() ) {
108
+ $slug = 'gravity-theme';
109
+ }
100
110
 
101
111
  return $slug;
102
112
  }
@@ -115,71 +125,4 @@ class GravityForms implements Instance {
115
125
 
116
126
  return $fields;
117
127
  }
118
-
119
- /**
120
- * Get list of available Gravity Forms. Can be used in acf/load_field filter to populate the select field.
121
- *
122
- * @return array
123
- */
124
- public static function forms_list() {
125
- if ( ! class_exists( 'GFForms' ) ) {
126
- return array();
127
- }
128
-
129
- $forms = \GFAPI::get_forms();
130
-
131
- $list = array();
132
-
133
- if ( $forms ) {
134
- foreach ( $forms as $form ) {
135
- $list[$form['id']] = $form['title'];
136
- }
137
- }
138
-
139
- return $list;
140
- }
141
-
142
- /**
143
- * This function will generate the gravity form for a given id with default parameters. Use if you need to generate ajax fomr outside of blocks.
144
- *
145
- * @param int $form_id
146
- * @param bool $display_title
147
- * @param bool $display_description
148
- * @param bool $display_inactive
149
- * @param array $field_values
150
- * @param bool $ajax
151
- * @param int $tabindex
152
- * @param bool $_echo
153
- *
154
- * @return mixed
155
- */
156
- public static function get_contact_form( $form_id, $display_title = false, $display_description = false, $display_inactive = false, $field_values = null, $ajax = true, $tabindex = 0, $_echo = false ) {
157
- if ( function_exists( 'gravity_form' ) ) {
158
- return gravity_form( $form_id, $display_title, $display_description, $display_inactive, $field_values, $ajax, $tabindex, $_echo );
159
- }
160
-
161
- return null;
162
- }
163
-
164
- /**
165
- * Check if Gravity Forms plugin is active.
166
- *
167
- * @return bool
168
- */
169
- public static function is_gf_active() {
170
- return class_exists( '\GFForms' );
171
- }
172
-
173
- /**
174
- * Get the instance of the class.
175
- */
176
- public static function get_instance() {
177
- static $instance = null;
178
-
179
- if ( null === $instance ) {
180
- $instance = new self();
181
- }
182
-
183
- return $instance;
184
- }
185
128
  }
@@ -1,25 +1,38 @@
1
1
  <?php
2
- //phpcs:disable
3
- namespace Chisel;
2
+
3
+ namespace Chisel\Plugin;
4
+
5
+ use Chisel\Interfaces\InstanceInterface;
6
+ use Chisel\Interfaces\HooksInterface;
7
+ use Chisel\Traits\Singleton;
8
+ use Chisel\Helper\WoocommerceHelpers;
4
9
 
5
10
  /**
6
11
  * Class used to extend Timber functionality.
7
12
  *
8
13
  * @package Chisel
9
14
  */
10
- class Woocommerce implements Instance {
15
+ class Woocommerce implements InstanceInterface, HooksInterface {
16
+
17
+ use Singleton;
11
18
 
12
- protected $sidebars = array();
19
+ /**
20
+ * Woocommerce sidebars.
21
+ *
22
+ * @var string
23
+ */
24
+ private $sidebars = array();
13
25
 
14
26
  /**
15
27
  * Class constructor.
16
28
  */
17
29
  private function __construct() {
18
- if ( ! self::is_woocommerce_active() ) {
30
+ if ( ! WoocommerceHelpers::is_woocommerce_active() ) {
19
31
  return;
20
32
  }
21
33
 
22
- $this->set_properties();
34
+ add_action( 'after_setup_theme', array( $this, 'set_properties' ), 7 );
35
+
23
36
  $this->action_hooks();
24
37
  $this->filter_hooks();
25
38
  }
@@ -30,9 +43,9 @@ class Woocommerce implements Instance {
30
43
  public function set_properties() {
31
44
  $this->sidebars = array(
32
45
  'woocommerce' => array(
33
- 'name' => __( 'Woocommerce', 'chisel' ),
34
- 'description' => __( 'Sidebar for shop pages', 'chisel' ),
35
- ),
46
+ 'name' => __( 'Woocommerce', 'chisel' ),
47
+ 'description' => __( 'Sidebar for shop pages', 'chisel' ),
48
+ ),
36
49
  );
37
50
  }
38
51
 
@@ -76,7 +89,6 @@ class Woocommerce implements Instance {
76
89
 
77
90
  remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
78
91
  remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
79
-
80
92
  }
81
93
 
82
94
  /**
@@ -91,14 +103,14 @@ class Woocommerce implements Instance {
91
103
 
92
104
  /**
93
105
  * Open container for sort bar.
94
- */
106
+ */
95
107
  public function before_shop_loop_div_open() {
96
108
  echo '<div class="c-shop__sort"> ';
97
109
  }
98
110
 
99
111
  /**
100
112
  * Close container for sort bar.
101
- */
113
+ */
102
114
  public function before_shop_loop_div_close() {
103
115
  echo ' </div> ';
104
116
  }
@@ -109,7 +121,7 @@ class Woocommerce implements Instance {
109
121
  * @param array $sidebars
110
122
  *
111
123
  * @return array
112
- */
124
+ */
113
125
  public function register_sidebars( $sidebars ) {
114
126
  $sidebars = array_merge( $sidebars, $this->sidebars );
115
127
 
@@ -122,7 +134,7 @@ class Woocommerce implements Instance {
122
134
  * @param array $enqueue_styles
123
135
  *
124
136
  * @return array
125
- */
137
+ */
126
138
  public function enqueue_styles( $enqueue_styles ) {
127
139
  unset( $enqueue_styles['woocommerce-layout'] );
128
140
 
@@ -142,70 +154,4 @@ class Woocommerce implements Instance {
142
154
 
143
155
  return $styles;
144
156
  }
145
-
146
- /**
147
- * 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.
148
- *
149
- * @param object $post The post object.
150
- */
151
- public static function timber_set_product( $post ) {
152
- global $product;
153
-
154
- if ( is_woocommerce() ) {
155
- $product = wc_get_product( $post->ID );
156
- }
157
- }
158
-
159
- public static function get_products_grid_classnames( $products, $has_sidebar ) {
160
- $loop_columns = wc_get_loop_prop( 'columns' );
161
-
162
- // Set max columns to 4.
163
- if ( $loop_columns > 4 ) {
164
- $loop_columns = 4;
165
- }
166
-
167
- $columns_data = array(
168
- 'medium' => $loop_columns,
169
- 'small' => $loop_columns > 2 ? $loop_columns - 1 : $loop_columns,
170
- );
171
-
172
- $grid_classnames = array(
173
- 'o-grid',
174
- 'o-grid--cols-1',
175
- );
176
-
177
- if ( $products ) {
178
- $grid_classnames[] = 'o-grid--cols-' . $columns_data['small'] . '-small';
179
-
180
- if ( $has_sidebar ) {
181
- $grid_classnames[] = 'o-grid--cols-' . $columns_data['small'] . '-medium';
182
- } else {
183
- $grid_classnames[] = 'o-grid--cols-' . $columns_data['medium'] . '-medium';
184
- }
185
- }
186
-
187
- return implode( ' ', $grid_classnames );
188
- }
189
-
190
- /**
191
- * Check if WooCommerce is active.
192
- *
193
- * @return bool
194
- */
195
- public static function is_woocommerce_active() {
196
- return class_exists( '\Woocommerce' );
197
- }
198
-
199
- /**
200
- * Get the instance of the class.
201
- */
202
- public static function get_instance() {
203
- static $instance = null;
204
-
205
- if ( null === $instance ) {
206
- $instance = new self();
207
- }
208
-
209
- return $instance;
210
- }
211
157
  }
@@ -0,0 +1,46 @@
1
+ <?php
2
+
3
+ namespace Chisel\Plugin;
4
+
5
+ use Chisel\Interfaces\InstanceInterface;
6
+ use Chisel\Interfaces\HooksInterface;
7
+ use Chisel\Traits\Singleton;
8
+ use Chisel\Helper\YoastHelpers;
9
+
10
+ /**
11
+ * Yoast SEO plugin related functionalities.
12
+ *
13
+ * @package Chisel
14
+ */
15
+ class Yoast implements InstanceInterface, HooksInterface {
16
+
17
+ use Singleton;
18
+
19
+ /**
20
+ * Class constructor.
21
+ */
22
+ private function __construct() {
23
+ if ( ! YoastHelpers::is_yoast_active() ) {
24
+ return;
25
+ }
26
+
27
+ $this->set_properties();
28
+ $this->action_hooks();
29
+ $this->filter_hooks();
30
+ }
31
+
32
+ /**
33
+ * Set properties.
34
+ */
35
+ public function set_properties() {}
36
+
37
+ /**
38
+ * Register action hooks.
39
+ */
40
+ public function action_hooks() {}
41
+
42
+ /**
43
+ * Register filter hooks.
44
+ */
45
+ public function filter_hooks() {}
46
+ }
@@ -0,0 +1,92 @@
1
+ <?php
2
+
3
+ namespace Chisel\Traits;
4
+
5
+ trait PageBlocks {
6
+ /**
7
+ * Content blocks from current page
8
+ *
9
+ * @var array|null
10
+ */
11
+ private static $content_blocks_names = null;
12
+
13
+ /**
14
+ * Get the instance of the class.
15
+ *
16
+ * @param string $prefix
17
+ *
18
+ * @return array
19
+ */
20
+ public function get_content_blocks_names( $prefix = 'chisel' ) {
21
+ if ( self::$content_blocks_names ) {
22
+ return self::$content_blocks_names;
23
+ }
24
+
25
+ global $post;
26
+
27
+ $content_blocks_names = array();
28
+
29
+ if ( is_a( $post, 'WP_Post' ) && $post->post_content && has_blocks( $post->post_content ) ) {
30
+ $blocks = parse_blocks( $post->post_content );
31
+
32
+ if ( $blocks ) {
33
+ $blocks_names = $this->get_blocks_names( $blocks );
34
+
35
+ if ( $blocks_names ) {
36
+ $blocks_names = array_filter(
37
+ $blocks_names,
38
+ function ( $block_name ) use ( $prefix ) {
39
+ return strpos( $block_name, $prefix ) !== false;
40
+ }
41
+ );
42
+
43
+ if ( $blocks_names ) {
44
+ $blocks_names = array_values( array_unique( $blocks_names ) );
45
+ $blocks_names = array_map(
46
+ function ( $block_name ) use ( $prefix ) {
47
+ return str_replace( $prefix . '/', '', $block_name );
48
+ },
49
+ $blocks_names
50
+ );
51
+ $content_blocks_names = array_merge( $content_blocks_names, $blocks_names );
52
+ }
53
+ }
54
+ }
55
+ }
56
+
57
+ self::$content_blocks_names = $content_blocks_names;
58
+
59
+ return self::$content_blocks_names;
60
+ }
61
+
62
+ /**
63
+ * Get blocks_names recursively.
64
+ *
65
+ * @param array $inner_blocks
66
+ *
67
+ * @return array
68
+ */
69
+ private function get_blocks_names( $inner_blocks ) {
70
+ $blocks_names = array();
71
+
72
+ foreach ( $inner_blocks as $block ) {
73
+ $block_name = sanitize_text_field( $block['blockName'] );
74
+
75
+ if ( ! $block_name ) {
76
+ continue;
77
+ }
78
+
79
+ $blocks_names[] = $block_name;
80
+
81
+ if ( isset( $block['innerBlocks'] ) && $block['innerBlocks'] ) {
82
+ $inner_blocks_names = $this->get_blocks_names( $block['innerBlocks'] );
83
+
84
+ if ( $inner_blocks_names ) {
85
+ $blocks_names = array_merge( $blocks_names, $inner_blocks_names );
86
+ }
87
+ }
88
+ }
89
+
90
+ return $blocks_names;
91
+ }
92
+ }
@@ -0,0 +1,23 @@
1
+ <?php
2
+
3
+ namespace Chisel\Traits;
4
+
5
+ trait Singleton {
6
+ /**
7
+ * Instance of the class.
8
+ *
9
+ * @var self
10
+ */
11
+ private static $instance;
12
+
13
+ /**
14
+ * Get the instance of the class.
15
+ */
16
+ public static function get_instance() {
17
+ if ( ! ( self::$instance instanceof self ) ) {
18
+ self::$instance = new self();
19
+ }
20
+
21
+ return self::$instance;
22
+ }
23
+ }
@@ -0,0 +1,118 @@
1
+ <?php
2
+
3
+ namespace Chisel\WP;
4
+
5
+ use Chisel\Interfaces\InstanceInterface;
6
+ use Chisel\Interfaces\HooksInterface;
7
+ use Chisel\Traits\Singleton;
8
+ use Chisel\Module\AcfSync;
9
+ use Chisel\Factory\RegisterAcfOptionsPage;
10
+
11
+ /**
12
+ * ACF related functionalities.
13
+ *
14
+ * @package Chisel
15
+ */
16
+ class Acf implements InstanceInterface, HooksInterface {
17
+
18
+ use Singleton;
19
+
20
+ /**
21
+ * ACF options pages.
22
+ *
23
+ * @var array
24
+ */
25
+ private $acf_options_pages = array();
26
+
27
+ /**
28
+ * ACF options sub pages.
29
+ *
30
+ * @var array
31
+ */
32
+ private $acf_options_sub_pages = array();
33
+
34
+ /**
35
+ * Class constructor.
36
+ */
37
+ private function __construct() {
38
+ add_action( 'after_setup_theme', array( $this, 'set_properties' ), 7 );
39
+
40
+ $this->action_hooks();
41
+ $this->filter_hooks();
42
+
43
+ if ( class_exists( '\ACF_Admin_Internal_Post_Type_List' ) ) {
44
+ AcfSync::get_instance();
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Set properties.
50
+ */
51
+ public function set_properties() {
52
+ $this->set_options_pages();
53
+ $this->set_options_sub_pages();
54
+ }
55
+
56
+ /**
57
+ * Register action hooks.
58
+ */
59
+ public function action_hooks() {
60
+ add_action( 'acf/init', array( $this, 'options_pages' ) );
61
+ }
62
+
63
+ /**
64
+ * Register filter hooks.
65
+ */
66
+ public function filter_hooks() {
67
+ }
68
+
69
+ /**
70
+ * Set ACF options pages.
71
+ */
72
+ private function set_options_pages() {
73
+ $this->acf_options_pages = array(
74
+ // phpcs:disable
75
+ // array(
76
+ // 'menu_slug' => 'theme-settings',
77
+ // 'page_title' => __( 'Theme Settings', 'chisel' ),
78
+ // ),
79
+ // phpcs:enable
80
+ );
81
+ }
82
+
83
+ /**
84
+ * Set ACF options sub pages.
85
+ */
86
+ private function set_options_sub_pages() {
87
+ $this->acf_options_sub_pages = array(
88
+ // phpcs:disable
89
+ // array(
90
+ // 'menu_slug' => 'theme-sub-settings',
91
+ // 'page_title' => __( 'Theme Sub settings', 'chisel' ),
92
+ // 'menu_title' => __( 'Theme Sub settings', 'chisel' ),
93
+ // 'parent_slug' => 'theme-settings',
94
+ // ),
95
+ // phpcs:enable
96
+ );
97
+ }
98
+
99
+ /**
100
+ * Register ACF options pages.
101
+ */
102
+ public function options_pages() {
103
+ $this->acf_options_pages = apply_filters( 'chisel_acf_options_pages', $this->acf_options_pages );
104
+ $this->acf_options_sub_pages = apply_filters( 'chisel_acf_options_sub_pages', $this->acf_options_sub_pages );
105
+
106
+ if ( $this->acf_options_pages && function_exists( 'acf_add_options_page' ) ) {
107
+ foreach ( $this->acf_options_pages as $data ) {
108
+ $this->register_options_page( $data, 'page' );
109
+ }
110
+ }
111
+
112
+ if ( $this->acf_options_sub_pages && function_exists( 'acf_add_options_sub_page' ) ) {
113
+ foreach ( $this->acf_options_sub_pages as $data ) {
114
+ $this->register_options_page( $data, 'subpage' );
115
+ }
116
+ }
117
+ }
118
+ }