generator-chisel 2.0.0-alpha.13 → 2.0.0-alpha.14

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 (112) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/lib/commands/create/creators/app/chisel-starter-theme/.gitignore.chisel-tpl +1 -0
  3. package/lib/commands/create/creators/app/chisel-starter-theme/404.php +2 -2
  4. package/lib/commands/create/creators/app/chisel-starter-theme/archive.php +2 -4
  5. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/block.json +31 -0
  6. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/edit.js +35 -0
  7. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/editor.scss +3 -0
  8. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/index.js +45 -0
  9. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/save.js +20 -0
  10. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/script.js +7 -0
  11. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/style.scss +3 -0
  12. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/view.js +7 -0
  13. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/view.scss +3 -0
  14. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/block.json +32 -0
  15. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/edit.js +33 -0
  16. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/editor.scss +3 -0
  17. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/index.js +45 -0
  18. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/render.php +12 -0
  19. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/render.twig +5 -0
  20. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/save.js +6 -0
  21. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/script.js +7 -0
  22. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/style.scss +3 -0
  23. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/view.js +7 -0
  24. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/view.scss +3 -0
  25. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/block.json +36 -0
  26. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/editor.scss +3 -0
  27. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/example.twig +3 -0
  28. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/index.js +7 -0
  29. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/init.php +0 -0
  30. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/script.js +7 -0
  31. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/style.scss +3 -0
  32. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/view.js +7 -0
  33. package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/view.scss +3 -0
  34. package/lib/commands/create/creators/app/chisel-starter-theme/author.php +3 -4
  35. package/lib/commands/create/creators/app/chisel-starter-theme/footer.php +2 -2
  36. package/lib/commands/create/creators/app/chisel-starter-theme/functions.php +18 -24
  37. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Factory/RegisterAcfOptionsPage.php +62 -0
  38. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/Factory}/RegisterBlocks.php +35 -22
  39. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Factory/RegisterCustomPostType.php +211 -0
  40. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Factory/RegisterCustomTaxonomy.php +174 -0
  41. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/AcfHelpers.php +46 -0
  42. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/AjaxHelpers.php +33 -0
  43. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/BlocksHelpers.php +98 -0
  44. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/CacheHelpers.php +41 -0
  45. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/CommentsHelpers.php +26 -0
  46. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/DataHelpers.php +35 -0
  47. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/GravityFormsHelpers.php +65 -0
  48. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/ImageHelpers.php +52 -0
  49. package/lib/commands/create/creators/app/chisel-starter-theme/{classes/Helpers.php → inc/Helper/ThemeHelpers.php} +49 -98
  50. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/WoocommerceHelpers.php +72 -0
  51. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/YoastHelpers.php +37 -0
  52. package/lib/commands/create/creators/app/chisel-starter-theme/{classes/interfaces/Instance.php → inc/Interface/HooksInterface.php} +3 -8
  53. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Interface/InstanceInterface.php +16 -0
  54. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/Module}/AcfSync.php +13 -20
  55. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/Module}/Ajax.php +14 -41
  56. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/Plugin}/GravityForms.php +12 -71
  57. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/Plugin}/Woocommerce.php +26 -80
  58. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Plugin/Yoast.php +46 -0
  59. package/lib/commands/create/creators/app/chisel-starter-theme/inc/Trait/Singleton.php +23 -0
  60. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Acf.php +118 -0
  61. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/AcfBlocks.php +29 -68
  62. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/AjaxEnpoints.php +6 -6
  63. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Assets.php +41 -56
  64. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Blocks.php +33 -60
  65. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Cache.php +103 -0
  66. package/lib/commands/create/creators/app/chisel-starter-theme/{classes/ExtendedImage.php → inc/WP/ChiselImage.php} +2 -2
  67. package/lib/commands/create/creators/app/chisel-starter-theme/{classes/ExtendedPost.php → inc/WP/ChiselPost.php} +4 -3
  68. package/lib/commands/create/creators/app/chisel-starter-theme/{classes/ExtendedProduct.php → inc/WP/ChiselProduct.php} +4 -3
  69. package/lib/commands/create/creators/app/chisel-starter-theme/{classes/ExtendedTerm.php → inc/WP/ChiselTerm.php} +2 -2
  70. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Comments.php +10 -32
  71. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Components.php +26 -37
  72. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/CustomPostTypes.php +42 -58
  73. package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/CustomTaxonomies.php +129 -0
  74. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Sidebars.php +11 -17
  75. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Site.php +15 -21
  76. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Theme.php +14 -19
  77. package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Twig.php +25 -25
  78. package/lib/commands/create/creators/app/chisel-starter-theme/index.php +2 -3
  79. package/lib/commands/create/creators/app/chisel-starter-theme/page.php +3 -3
  80. package/lib/commands/create/creators/app/chisel-starter-theme/search.php +3 -4
  81. package/lib/commands/create/creators/app/chisel-starter-theme/single.php +3 -3
  82. package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks-acf/slider/block.json +1 -1
  83. package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/blocks.js +10 -4
  84. package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/mods/core-button.js +2 -2
  85. package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_posts-items.scss +6 -0
  86. package/lib/commands/create/creators/app/chisel-starter-theme/views/base.twig +1 -1
  87. package/lib/commands/create/creators/app/chisel-starter-theme/views/components/header.twig +1 -1
  88. package/lib/commands/create/creators/app/chisel-starter-theme/views/components/icon.twig +1 -1
  89. package/lib/commands/create/creators/app/chisel-starter-theme/views/{partials → components}/logo.twig +2 -2
  90. package/lib/commands/create/creators/app/chisel-starter-theme/views/components/main-nav.twig +2 -1
  91. package/lib/commands/create/creators/app/chisel-starter-theme/views/{partials → components}/pagination.twig +11 -11
  92. package/lib/commands/create/creators/app/chisel-starter-theme/views/components/slider.twig +2 -2
  93. package/lib/commands/create/creators/app/chisel-starter-theme/views/{partials → components}/the-title.twig +1 -1
  94. package/lib/commands/create/creators/app/chisel-starter-theme/views/index.twig +9 -4
  95. package/lib/commands/create/creators/app/chisel-starter-theme/views/sidebar-blog.twig +1 -1
  96. package/lib/commands/create/creators/app/chisel-starter-theme/views/sidebar-woocommerce.twig +1 -1
  97. package/lib/commands/create/creators/app/chisel-starter-theme/views/single.twig +2 -2
  98. package/lib/commands/create/creators/app/chisel-starter-theme/views/woocommerce/archive-product.twig +2 -2
  99. package/lib/commands/create/creators/app/chisel-starter-theme/views/woocommerce/linked-products.twig +2 -2
  100. package/lib/commands/create/creators/app/chisel-starter-theme/views/woocommerce/single-product.twig +4 -4
  101. package/lib/commands/create/creators/app/chisel-starter-theme/woocommerce.php +6 -6
  102. package/lib/commands/create/creators/app/index.js +23 -2
  103. package/lib/commands/create/creators/app/template/.devcontainer/docker-compose.yml.chisel-tpl +1 -3
  104. package/lib/commands/create/creators/app/template/.devcontainer/post-create-command.sh.chisel-tpl +1 -0
  105. package/lib/commands/create/creators/devcontainer.js +2 -2
  106. package/lib/commands/create/creators/utils.js +39 -9
  107. package/lib/commands/create/packages-versions.js +1 -1
  108. package/package.json +2 -2
  109. package/lib/commands/create/creators/app/chisel-starter-theme/classes/Acf.php +0 -188
  110. package/lib/commands/create/creators/app/chisel-starter-theme/classes/ChiselCache.php +0 -87
  111. package/lib/commands/create/creators/app/chisel-starter-theme/classes/RegisterCustomObject.php +0 -395
  112. package/lib/commands/create/creators/app/chisel-starter-theme/classes/Yoast.php +0 -78
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  <!-- INSERT-NEW-ENTRIES-HERE -->
4
4
 
5
+ ## 2.0.0-alpha.14 (2024-12-04)
6
+
7
+ - adjust base version logic, remove compose version ([69f340e](https://github.com/xfiveco/generator-chisel/commit/69f340e))
8
+ - run git hooks in devcontainer if .use-devcontainer is present ([d4fc782](https://github.com/xfiveco/generator-chisel/commit/d4fc782))
9
+ - theme refactor, example blocks, bugs fixes ([96bf7ce](https://github.com/xfiveco/generator-chisel/commit/96bf7ce))
10
+
5
11
  ## 2.0.0-alpha.13 (2024-11-12)
6
12
 
7
13
  - Adjust command ([c1b4471](https://github.com/xfiveco/generator-chisel/commit/c1b4471))
@@ -1,3 +1,4 @@
1
1
  /build
2
2
  /vendor
3
3
  /assets/hashes.php
4
+ /.use-devcontainer
@@ -5,7 +5,7 @@
5
5
  * @package Chisel
6
6
  */
7
7
 
8
- use Chisel\ChiselCache;
8
+ use Chisel\Helper\CacheHelpers;
9
9
  use Timber\Timber;
10
10
 
11
11
  $context = Timber::context();
@@ -13,4 +13,4 @@ $context = Timber::context();
13
13
  $context['post']['ID'] = 'error-404';
14
14
  $context['post']['class'] = 'is-404';
15
15
 
16
- Timber::render( '404.twig', $context, ChiselCache::expiry() );
16
+ Timber::render( '404.twig', $context, CacheHelpers::expiry() );
@@ -5,7 +5,7 @@
5
5
  * @package Chisel
6
6
  */
7
7
 
8
- use Chisel\ChiselCache;
8
+ use Chisel\Helper\CacheHelpers;
9
9
  use Timber\Timber;
10
10
 
11
11
  $templates = array( 'archive.twig', 'index.twig' );
@@ -22,6 +22,4 @@ if ( is_tag() ) {
22
22
  array_unshift( $templates, 'archive-' . get_queried_object()->taxonomy . '.twig' );
23
23
  }
24
24
 
25
- $context['posts'] = Timber::get_posts();
26
-
27
- Timber::render( $templates, $context, ChiselCache::expiry() );
25
+ Timber::render( $templates, $context, CacheHelpers::expiry() );
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "chisel/example-block",
3
+ "title": "example-block",
4
+ "description": "Example Block - This file contains the block settings. There is one custom setting, called ignoreScript, which should be used in cases when you use the script only to import scss - adding the script key to the ignoreScripts array will prevent the script from being loaded. The style array contains two values, because if the style.scss is imprted into both script.js and index.js two files will be built. All scripts and styles values may be arrays or strings.",
5
+ "category": "chisel-blocks",
6
+ "icon": "carrot",
7
+ "apiVersion": 3,
8
+ "keywords": ["example", "block"],
9
+ "textdomain": "chisel",
10
+ "styles": [
11
+ { "name": "default", "label": "Default", "isDefault": true },
12
+ { "name": "other", "label": "Other" }
13
+ ],
14
+ "supports": {
15
+ "anchor": true,
16
+ "align": false,
17
+ "alignWide": false,
18
+ "alignContent": false,
19
+ "className": true,
20
+ "customClassName": true,
21
+ "multiple": true,
22
+ "reusable": true
23
+ },
24
+ "ignoreScripts": ["script"],
25
+ "editorScript": "file:./index.js",
26
+ "editorStyle": "file:./index.css",
27
+ "style": ["file:./style-index.css", "file:./style-script.css"],
28
+ "script": "file:./script.js",
29
+ "viewScript": "file:./view.js",
30
+ "viewStyle": "file:./view.css"
31
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Retrieves the translation of text.
3
+ *
4
+ * @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-i18n/
5
+ */
6
+ import { __ } from '@wordpress/i18n';
7
+
8
+ /**
9
+ * React hook that is used to mark the block wrapper element.
10
+ * It provides all the necessary props like the class name.
11
+ *
12
+ * @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-block-editor/#useblockprops
13
+ */
14
+ import { useBlockProps } from '@wordpress/block-editor';
15
+
16
+ /**
17
+ * Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.
18
+ * Those files can contain any CSS code that gets applied to the editor.
19
+ *
20
+ * @see https://www.npmjs.com/package/@wordpress/scripts#using-css
21
+ */
22
+ import './editor.scss';
23
+
24
+ /**
25
+ * The edit function describes the structure of your block in the context of the
26
+ * editor. This represents what the editor will render when the block is used.
27
+ *
28
+ * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#edit
29
+ *
30
+ * @return {Element} Element to render.
31
+ */
32
+ // eslint-disable-next-line no-unused-vars
33
+ export default function Edit(props) {
34
+ return <div {...useBlockProps()}>{__('This is an example block.', 'chisel')}</div>;
35
+ }
@@ -0,0 +1,3 @@
1
+ .wp-chisel-example-block {
2
+ border: 1px solid green;
3
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * This file is loaded in the editor only.
3
+ *
4
+ * You must import the scss file in order for css file to be built in the build folder.
5
+ */
6
+
7
+ /**
8
+ * Registers a new block provided a unique name and an object defining its behavior.
9
+ *
10
+ * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/
11
+ */
12
+ import { registerBlockType } from '@wordpress/blocks';
13
+
14
+ /**
15
+ * Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.
16
+ * All files containing `style` keyword are bundled together. The code used
17
+ * gets applied both to the front of your site and to the editor.
18
+ *
19
+ * @see https://www.npmjs.com/package/@wordpress/scripts#using-css
20
+ */
21
+ import './style.scss';
22
+
23
+ /**
24
+ * Internal dependencies
25
+ */
26
+ import Edit from './edit';
27
+ import save from './save';
28
+ import metadata from './block.json';
29
+
30
+ /**
31
+ * Every block starts by registering a new block type definition.
32
+ *
33
+ * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/
34
+ */
35
+ registerBlockType(metadata.name, {
36
+ /**
37
+ * @see ./edit.js
38
+ */
39
+ edit: Edit,
40
+
41
+ /**
42
+ * @see ./save.js
43
+ */
44
+ save,
45
+ });
@@ -0,0 +1,20 @@
1
+ /**
2
+ * React hook that is used to mark the block wrapper element.
3
+ * It provides all the necessary props like the class name.
4
+ *
5
+ * @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-block-editor/#useblockprops
6
+ */
7
+ import { useBlockProps } from '@wordpress/block-editor';
8
+
9
+ /**
10
+ * The save function defines the way in which the different attributes should
11
+ * be combined into the final markup, which is then serialized by the block
12
+ * editor into `post_content`.
13
+ *
14
+ * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#save
15
+ *
16
+ * @return {Element} Element to render.
17
+ */
18
+ export default function save() {
19
+ return <p {...useBlockProps.save()}>{'Example Block – hello from the saved content!'}</p>;
20
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file is loaded in the editor and frontend.
3
+ *
4
+ * You must import the scss file in order for css file to be built in the build folder.
5
+ */
6
+
7
+ import './style.scss';
@@ -0,0 +1,3 @@
1
+ .wp-chisel-example-block {
2
+ border: 1px solid blue;
3
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file is loaded in frontend only.
3
+ *
4
+ * You must import the scss file in order for css file to be built in the build folder.
5
+ */
6
+
7
+ import './view.scss';
@@ -0,0 +1,3 @@
1
+ .wp-chisel-example-block {
2
+ border: 1px solid green;
3
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "chisel/example-server-side-block",
3
+ "title": "example-server-side-block",
4
+ "description": "Example Block - This file contains the block settings. There is one custom setting, called ignoreScript, which should be used in cases when you use the script only to import scss - adding the script key to the ignoreScripts array will prevent the script from being loaded. The style array contains two values, because if the style.scss is imprted into both script.js and index.js two files will be built. All scripts and styles values may be arrays or strings. In order to render the block on the server side add render setting with the render.php file name and use ServerSideRender component in edit.js file.",
5
+ "category": "chisel-blocks",
6
+ "icon": "carrot",
7
+ "apiVersion": 3,
8
+ "keywords": ["example", "block"],
9
+ "textdomain": "chisel",
10
+ "styles": [
11
+ { "name": "default", "label": "Default", "isDefault": true },
12
+ { "name": "other", "label": "Other" }
13
+ ],
14
+ "supports": {
15
+ "anchor": true,
16
+ "align": false,
17
+ "alignWide": false,
18
+ "alignContent": false,
19
+ "className": true,
20
+ "customClassName": true,
21
+ "multiple": true,
22
+ "reusable": true
23
+ },
24
+ "ignoreScripts": ["script"],
25
+ "editorScript": "file:./index.js",
26
+ "editorStyle": "file:./index.css",
27
+ "style": ["file:./style-index.css", "file:./style-script.css"],
28
+ "script": "file:./script.js",
29
+ "viewScript": "file:./view.js",
30
+ "viewStyle": "file:./view.css",
31
+ "render": "file:./render.php"
32
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * React hook that is used to mark the block wrapper element.
3
+ * It provides all the necessary props like the class name.
4
+ *
5
+ * @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-block-editor/#useblockprops
6
+ */
7
+ import { useBlockProps } from '@wordpress/block-editor';
8
+ import ServerSideRender from '@wordpress/server-side-render';
9
+
10
+ /**
11
+ * Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.
12
+ * Those files can contain any CSS code that gets applied to the editor.
13
+ *
14
+ * @see https://www.npmjs.com/package/@wordpress/scripts#using-css
15
+ */
16
+ import './editor.scss';
17
+
18
+ /**
19
+ * The edit function describes the structure of your block in the context of the
20
+ * editor. This represents what the editor will render when the block is used.
21
+ *
22
+ * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#edit
23
+ *
24
+ * @return {Element} Element to render.
25
+ */
26
+ // eslint-disable-next-line no-unused-vars
27
+ export default function Edit(props) {
28
+ return (
29
+ <div {...useBlockProps()}>
30
+ <ServerSideRender block="chisel/example-server-side-block" />
31
+ </div>
32
+ );
33
+ }
@@ -0,0 +1,3 @@
1
+ .wp-chisel-example-block {
2
+ border: 1px solid green;
3
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * This file is loaded in the editor only.
3
+ *
4
+ * You must import the scss file in order for css file to be built in the build folder.
5
+ */
6
+
7
+ /**
8
+ * Registers a new block provided a unique name and an object defining its behavior.
9
+ *
10
+ * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/
11
+ */
12
+ import { registerBlockType } from '@wordpress/blocks';
13
+
14
+ /**
15
+ * Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.
16
+ * All files containing `style` keyword are bundled together. The code used
17
+ * gets applied both to the front of your site and to the editor.
18
+ *
19
+ * @see https://www.npmjs.com/package/@wordpress/scripts#using-css
20
+ */
21
+ import './style.scss';
22
+
23
+ /**
24
+ * Internal dependencies
25
+ */
26
+ import Edit from './edit';
27
+ import save from './save';
28
+ import metadata from './block.json';
29
+
30
+ /**
31
+ * Every block starts by registering a new block type definition.
32
+ *
33
+ * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/
34
+ */
35
+ registerBlockType(metadata.name, {
36
+ /**
37
+ * @see ./edit.js
38
+ */
39
+ edit: Edit,
40
+
41
+ /**
42
+ * @see ./save.js
43
+ */
44
+ save,
45
+ });
@@ -0,0 +1,12 @@
1
+ <?php
2
+
3
+ use Chisel\Blocks;
4
+
5
+ $context = array(
6
+ 'wrapper_attributes' => get_block_wrapper_attributes(),
7
+ 'attributes' => $attributes,
8
+ 'content' => $content,
9
+ 'block' => $block,
10
+ );
11
+
12
+ Blocks::render_twig_file( $block->name, $context );
@@ -0,0 +1,6 @@
1
+ /**
2
+ * For server side rendering we do not need to save anything, so we return null.
3
+ */
4
+ export default function save() {
5
+ return null;
6
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file is loaded in the editor and frontend.
3
+ *
4
+ * You must import the scss file in order for css file to be built in the build folder.
5
+ */
6
+
7
+ import './style.scss';
@@ -0,0 +1,3 @@
1
+ .wp-chisel-example-block {
2
+ border: 1px solid blue;
3
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file is loaded in frontend only.
3
+ *
4
+ * You must import the scss file in order for css file to be built in the build folder.
5
+ */
6
+
7
+ import './view.scss';
@@ -0,0 +1,3 @@
1
+ .wp-chisel-example-block {
2
+ border: 1px solid green;
3
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "chisel/acf-example-block",
3
+ "title": "Acf-example-block",
4
+ "description": "Example ACF Block - This file contains some specific acf settings in acf section. The renderCallback value must be the same for all acf blocks. There one custom setting, called ignoreScript, which should be used in cases when you use the script only to import scss - adding the script key to the ignoreScripts array will prevent the script from being loaded. The style array contains two values, because if the style.scss is imprted into both script.js and index.js two files will be built. All scripts and styles values may be arrays or strings.",
5
+ "category": "chisel-blocks",
6
+ "icon": "carrot",
7
+ "apiVersion": 3,
8
+ "keywords": ["example", "block"],
9
+ "textdomain": "chisel",
10
+ "acf": {
11
+ "mode": "preview",
12
+ "usePostMeta": false,
13
+ "renderCallback": "\\Chisel\\AcfBlocks::acf_block_render"
14
+ },
15
+ "styles": [
16
+ { "name": "default", "label": "Default", "isDefault": true },
17
+ { "name": "other", "label": "Other" }
18
+ ],
19
+ "supports": {
20
+ "anchor": true,
21
+ "align": false,
22
+ "alignWide": false,
23
+ "alignContent": false,
24
+ "className": true,
25
+ "customClassName": true,
26
+ "multiple": true,
27
+ "reusable": true
28
+ },
29
+ "ignoreScripts": ["script"],
30
+ "editorScript": "file:./index.js",
31
+ "editorStyle": "file:./index.css",
32
+ "style": ["file:./style-index.css", "file:./style-script.css"],
33
+ "script": "file:./script.js",
34
+ "viewScript": "file:./view.js",
35
+ "viewStyle": "file:./view.css"
36
+ }
@@ -0,0 +1,3 @@
1
+ {#
2
+ This file name must be the same as the block folder name.
3
+ #}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file is loaded in the editor only.
3
+ *
4
+ * You must import the scss file in order for css file to be built in the build folder.
5
+ */
6
+
7
+ import './editor.scss';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file is loaded in the editor and frontend.
3
+ *
4
+ * You must import the scss file in order for css file to be built in the build folder.
5
+ */
6
+
7
+ import './style.scss';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file is loaded in frontend only.
3
+ *
4
+ * You must import the scss file in order for css file to be built in the build folder.
5
+ */
6
+
7
+ import './view.scss';
@@ -5,10 +5,9 @@
5
5
  * @package Chisel
6
6
  */
7
7
 
8
- use Chisel\ChiselCache;
8
+ use Chisel\Helper\CacheHelpers;
9
9
  use Timber\Timber;
10
10
 
11
- $context = Timber::context();
12
- $context['posts'] = Timber::get_posts();
11
+ $context = Timber::context();
13
12
 
14
- Timber::render( array( 'author.twig', 'archive.twig' ), $context, ChiselCache::expiry() );
13
+ Timber::render( array( 'author.twig', 'archive.twig' ), $context, CacheHelpers::expiry() );
@@ -9,7 +9,7 @@
9
9
  * @package Chisel
10
10
  */
11
11
 
12
- use Chisel\ChiselCache;
12
+ use Chisel\Helper\CacheHelpers;
13
13
 
14
14
  $context = $GLOBALS['timberContext'];
15
15
 
@@ -21,4 +21,4 @@ $context['content'] = ob_get_contents();
21
21
  ob_end_clean();
22
22
  $templates = array( 'page-plugin.twig' );
23
23
 
24
- \Timber\Timber::render( $templates, $context, ChiselCache::expiry() );
24
+ \Timber\Timber::render( $templates, $context, CacheHelpers::expiry() );
@@ -4,11 +4,9 @@ define( 'CHISEL_NAMESPACE', 'Chisel\\' );
4
4
 
5
5
  require_once get_template_directory() . '/vendor/autoload.php';
6
6
 
7
- $interfaces = glob( get_template_directory() . '/classes/interfaces/*.php' );
8
-
9
7
  spl_autoload_register(
10
- function ( $class_name ) use ( $interfaces ) {
11
- $base_directory = get_template_directory() . '/classes/';
8
+ function ( $class_name ) {
9
+ $base_directory = get_template_directory() . '/inc/';
12
10
 
13
11
  $namespace_prefix_length = strlen( CHISEL_NAMESPACE );
14
12
 
@@ -16,11 +14,6 @@ spl_autoload_register(
16
14
  return;
17
15
  }
18
16
 
19
- // Load interfaces.
20
- foreach ( $interfaces as $interface ) {
21
- require_once $interface;
22
- }
23
-
24
17
  $relative_class_name = substr( $class_name, $namespace_prefix_length );
25
18
 
26
19
  $class_filename = $base_directory . str_replace( '\\', '/', $relative_class_name ) . '.php';
@@ -33,18 +26,19 @@ spl_autoload_register(
33
26
 
34
27
  Timber\Timber::init();
35
28
 
36
- \Chisel\Blocks::get_instance();
37
- \Chisel\Acf::get_instance();
38
- \Chisel\AcfBlocks::get_instance();
39
- \Chisel\Ajax::get_instance();
40
- \Chisel\Assets::get_instance();
41
- \Chisel\ChiselCache::get_instance();
42
- \Chisel\Comments::get_instance();
43
- \Chisel\GravityForms::get_instance();
44
- \Chisel\Site::get_instance();
45
- \Chisel\Sidebars::get_instance();
46
- \Chisel\Theme::get_instance();
47
- \Chisel\CustomPostTypes::get_instance();
48
- \Chisel\Twig::get_instance();
49
- \Chisel\Woocommerce::get_instance();
50
- \Chisel\Yoast::get_instance();
29
+ \Chisel\Module\Ajax::get_instance();
30
+ \Chisel\WP\Blocks::get_instance();
31
+ \Chisel\WP\Acf::get_instance();
32
+ \Chisel\WP\AcfBlocks::get_instance();
33
+ \Chisel\WP\Assets::get_instance();
34
+ \Chisel\WP\Cache::get_instance();
35
+ \Chisel\WP\Comments::get_instance();
36
+ \Chisel\WP\Site::get_instance();
37
+ \Chisel\WP\Sidebars::get_instance();
38
+ \Chisel\WP\Theme::get_instance();
39
+ \Chisel\WP\CustomPostTypes::get_instance();
40
+ \Chisel\WP\CustomTaxonomies::get_instance();
41
+ \Chisel\WP\Twig::get_instance();
42
+ \Chisel\Plugin\GravityForms::get_instance();
43
+ \Chisel\Plugin\Woocommerce::get_instance();
44
+ \Chisel\Plugin\Yoast::get_instance();
@@ -0,0 +1,62 @@
1
+ <?php
2
+
3
+ namespace Chisel\Factory;
4
+
5
+ /**
6
+ * Custom post types wrapper class.
7
+ *
8
+ * @package Chisel
9
+ */
10
+ class RegisterAcfOptionsPage {
11
+
12
+ /**
13
+ * Page arguments.
14
+ *
15
+ * @var array
16
+ */
17
+ private $args;
18
+
19
+ /**
20
+ * Page type - page or subpage.
21
+ *
22
+ * @var array
23
+ */
24
+ private $type;
25
+
26
+ /**
27
+ * Class constructor.
28
+ *
29
+ * @param array $args page arguments.
30
+ * @param string $type page or subpage.
31
+ */
32
+ public function __construct( $args, $type = 'page' ) {
33
+ $this->args = $args;
34
+ $this->type = $type;
35
+ }
36
+
37
+ /**
38
+ * Register ACF options page.
39
+ */
40
+ private function register_options_page() {
41
+ $options_page_args = array(
42
+ 'page_title' => $this->args['page_title'],
43
+ 'menu_title' => isset( $this->args['menu_title'] ) ? $this->args['menu_title'] : $this->args['page_title'],
44
+ 'menu_slug' => $this->args['menu_slug'],
45
+ 'capability' => isset( $this->args['capability'] ) ? $this->args['capability'] : 'edit_posts',
46
+ 'position' => isset( $this->args['position'] ) ? $this->args['position'] : 45,
47
+ 'redirect' => isset( $this->args['redirect'] ) ? $this->args['redirect'] : true,
48
+ 'icon_url' => isset( $this->args['icon_url'] ) ? $this->args['icon_url'] : 'dashicons-screenoptions',
49
+ 'post_id' => isset( $this->args['post_id'] ) ? $this->args['post_id'] : 'options',
50
+ 'autoload' => isset( $this->args['autoload'] ) ? $this->args['autoload'] : false,
51
+ 'update_button' => isset( $this->args['update_button'] ) ? $this->args['update_button'] : __( 'Update', 'chisel' ),
52
+ 'updated_message' => isset( $this->args['updated_message'] ) ? $this->args['updated_message'] : __( 'Options Updated', 'chisel' ),
53
+ 'parent_slug' => isset( $this->args['parent_slug'] ) ? $this->args['parent_slug'] : '',
54
+ );
55
+
56
+ if ( $this->type === 'subpage' ) {
57
+ acf_add_options_sub_page( $options_page_args );
58
+ } else {
59
+ acf_add_options_page( $options_page_args );
60
+ }
61
+ }
62
+ }