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
package/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  <!-- INSERT-NEW-ENTRIES-HERE -->
4
4
 
5
+ ## 2.4.0 (2026-02-09)
6
+
7
+ - chisel update scripts and husky precommit hooks ([31c1019](https://github.com/xfiveco/generator-chisel/commit/31c1019))
8
+ - php refactor and optimize, chise install set default wp options, minor fixes ([f742903](https://github.com/xfiveco/generator-chisel/commit/f742903))
9
+ - separate core php from custom, add base for custom, improve code structure ([d3ea3f4](https://github.com/xfiveco/generator-chisel/commit/d3ea3f4))
10
+ - theme improvements, fixes, adjustments ([d2f7420](https://github.com/xfiveco/generator-chisel/commit/d2f7420))
11
+ - update chisel version ([55bfaaf](https://github.com/xfiveco/generator-chisel/commit/55bfaaf))
12
+ - Webpack config chnages: client ovarlay, nvmrc update, composer packages version update ([a07c16c](https://github.com/xfiveco/generator-chisel/commit/a07c16c))
13
+
14
+ ## <small>2.3.3 (2026-01-02)</small>
15
+
16
+ - Publish ([0e98159](https://github.com/xfiveco/generator-chisel/commit/0e98159))
17
+ - Publish ([2864ed6](https://github.com/xfiveco/generator-chisel/commit/2864ed6))
18
+ - wp-config-updates, wp/scripts lt, icons module define in functions.php ([3c97c63](https://github.com/xfiveco/generator-chisel/commit/3c97c63))
19
+
5
20
  ## <small>2.3.2 (2025-12-16)</small>
6
21
 
7
22
  - make icons module optional ([94e4c6c](https://github.com/xfiveco/generator-chisel/commit/94e4c6c))
@@ -0,0 +1,16 @@
1
+ root = true
2
+
3
+ [*]
4
+ end_of_line = lf
5
+ indent_style = space
6
+ indent_size = 2
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+ max_line_length = 100
11
+
12
+ [*.md]
13
+ trim_trailing_whitespace = false
14
+
15
+ [*.php]
16
+ indent_style = tab
@@ -1,5 +1,4 @@
1
1
  /build
2
2
  /vendor
3
3
  /node_modules
4
- /assets/hashes.php
5
4
  /.use-devcontainer
@@ -0,0 +1,92 @@
1
+ #!/bin/sh
2
+ # Chisel Core Files Protection Hook
3
+ # This hook warns when committing MODIFICATIONS to core/ folder files
4
+ # which will be overwritten by chisel-update
5
+
6
+ # ============================================================================
7
+ # CORE FILES CHECK
8
+ # ============================================================================
9
+
10
+ check_core_files() {
11
+ # Allow skipping with CHISEL_SKIP_CORE_CHECK=1 or --no-verify
12
+ if [ "$CHISEL_SKIP_CORE_CHECK" = "1" ]; then
13
+ return 0
14
+ fi
15
+
16
+ # Check if this is the initial commit (no HEAD exists)
17
+ if ! git rev-parse --verify HEAD >/dev/null 2>&1; then
18
+ # Initial commit - allow all files including core/
19
+ return 0
20
+ fi
21
+
22
+ # Only check for MODIFIED files in core/ (not newly Added files)
23
+ # M = Modified, R = Renamed (which counts as a modification)
24
+ CORE_FILES=$(git diff --cached --name-only --diff-filter=MR | grep "/core/" || true)
25
+ CORE_FILES_ALT=$(git diff --cached --name-only --diff-filter=MR | grep "^core/" || true)
26
+
27
+ # Combine results
28
+ if [ -n "$CORE_FILES_ALT" ]; then
29
+ if [ -n "$CORE_FILES" ]; then
30
+ CORE_FILES="$CORE_FILES
31
+ $CORE_FILES_ALT"
32
+ else
33
+ CORE_FILES="$CORE_FILES_ALT"
34
+ fi
35
+ fi
36
+
37
+ # Exit if no core files are staged
38
+ if [ -z "$CORE_FILES" ]; then
39
+ return 0
40
+ fi
41
+
42
+ # Warn about core file modifications
43
+ echo ""
44
+ echo " ⚠️ CHISEL CORE FILES MODIFIED ⚠️ "
45
+ echo "╠══════════════════════════════════════════════════════════════════════════════╣"
46
+ echo "║ ║"
47
+ echo "║ You are about to commit changes to files in the 'core/' folder. ║"
48
+ echo "║ These files are managed by Chisel and will be OVERWRITTEN when you run: ║"
49
+ echo "║ ║"
50
+ echo "║ npm run update-chisel ║"
51
+ echo "║ ║"
52
+ echo "╠══════════════════════════════════════════════════════════════════════════════╣"
53
+ echo "║ RECOMMENDATION: ║"
54
+ echo "║ ║"
55
+ echo "║ Instead of modifying core files, create or modify files in the 'custom/' ║"
56
+ echo "║ folder. Custom files extend and override core functionality safely. ║"
57
+ echo "║ ║"
58
+ echo "║ Examples: ║"
59
+ echo "║ - core/WP/Site.php → custom/app/WP/Site.php ║"
60
+ echo "║ - core/Helpers/ImageHelpers.php → custom/app/Helpers/ImageHelpers.php ║"
61
+ echo "║ ║"
62
+ echo "╠══════════════════════════════════════════════════════════════════════════════╣"
63
+ echo "║ Modified core files: ║"
64
+ echo "╟──────────────────────────────────────────────────────────────────────────────╢"
65
+
66
+ echo "$CORE_FILES" | while read -r file; do
67
+ printf "║ • %-70s ║\n" "$file"
68
+ done
69
+
70
+ echo "╠══════════════════════════════════════════════════════════════════════════════╣"
71
+ echo "║ OPTIONS: ║"
72
+ echo "║ ║"
73
+ echo "║ 1. Move your changes to the 'custom/' folder (recommended) ║"
74
+ echo "║ 2. Skip this check if you know what you're doing: ║"
75
+ echo "║ ║"
76
+ echo "║ git commit --no-verify ║"
77
+ echo "║ # or ║"
78
+ echo "║ CHISEL_SKIP_CORE_CHECK=1 git commit ║"
79
+ echo "║ ║"
80
+ echo "╚══════════════════════════════════════════════════════════════════════════════╝"
81
+ echo ""
82
+
83
+ return 1
84
+ }
85
+
86
+ # Run core files check
87
+ check_core_files || exit 1
88
+
89
+ # ============================================================================
90
+ # ADDITIONAL HOOKS
91
+ # ============================================================================
92
+
@@ -1 +1 @@
1
- >=20.12.2
1
+ 24.11.1
@@ -0,0 +1,10 @@
1
+ {
2
+ "recommendations": [
3
+ "esbenp.prettier-vscode",
4
+ "dbaeumer.vscode-eslint",
5
+ "streetsidesoftware.code-spell-checker",
6
+ "editorconfig.editorconfig",
7
+ "stylelint.vscode-stylelint",
8
+ "mrmlnc.vscode-scss"
9
+ ]
10
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "git.openRepositoryInParentFolders": "always",
3
+
4
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
5
+ "editor.formatOnSave": true,
6
+
7
+ "editor.codeActionsOnSave": {
8
+ "source.fixAll": "explicit",
9
+ "source.fixAll.eslint": "explicit"
10
+ },
11
+
12
+ "[javascript][javascriptreact][typescript][typescriptreact][vue][css][scss]": {
13
+ "editor.formatOnSave": false
14
+ },
15
+
16
+ "stylelint.validate": ["css", "scss", "vue"],
17
+ "css.validate": false,
18
+ "scss.validate": false
19
+ }
@@ -1,21 +1,22 @@
1
- # Chisel Wordpress Theme
1
+ # Chisel WordPress Theme
2
2
 
3
- ## Wordpress Starter Theme based on Timber library
3
+ ## WordPress Starter Theme based on Timber library
4
4
 
5
- Chisel is a Wordpress Starter Theme powered by Timber library that helps to seprate the logic from view by using Twig engine to render html content. It also simplifies the code, makes it more readable and speeds up development.
5
+ Chisel is a custom WordPress development framework we built to make developers’ lives easier. It streamlines theme development with a modern stack Webpack, Timber, and ITCSS ensuring faster coding, cleaner structure, and more maintainable projects.
6
6
 
7
7
  ## Installation
8
8
 
9
- Use node version `20.12.2`
9
+ Use Node.js version `24.11.1` (Minimum `20.12.2`)
10
10
 
11
- Chisel is installed as a npm package using npx command: `npx generator-chisel`, which installs the whole projet for you including composer and node dependencies, however when you join the project and clone the repository, follow these steps to start the local developent:
11
+ Chisel is installed as a npm package using npx command: `npx generator-chisel`, which scaffolds the entire project for you including composer and node dependencies, however when you join the project and clone the repository, follow these steps to start the local development:
12
12
 
13
13
  1. Go to the theme folder
14
14
  2. Run `composer install`
15
15
  3. Run `npm install`
16
- 4. Run `npm run wp-config`
16
+ 4. Copy `wp-config-custom.php` and rename it to `wp-config.php` in the project root directory (if you haven't done so already).
17
+ 5. Run `npm run wp-config`
17
18
 
18
- After creating the wp-config-local.php file make sure you have these lines in the file:
19
+ After creating the `wp-config-local.php` file make sure you have these lines in the file:
19
20
 
20
21
  ```php
21
22
  define( 'WP_DEBUG', true );
@@ -27,11 +28,67 @@ Chisel is installed as a npm package using npx command: `npx generator-chisel`,
27
28
  define( 'WP_ENVIRONMENT_TYPE', 'development' );
28
29
  ```
29
30
 
30
- 5. Run `npm run build`
31
+ 6. Run `npm run build`
31
32
 
32
- The local url for the new project should be `project-name.test`
33
+ The local URL for the new project should be `project-name.test`
33
34
 
34
- 6. Run `npm run dev` to start local development. The url for local development is the same with "fast refresh" mode enabled for CSS and JavaScript.
35
+ 7. Run `npm run dev` to start local development. The URL for local development is the same with "Fast Refresh" mode enabled for CSS and JavaScript.
36
+
37
+ ## Updating Chisel
38
+
39
+ To check if a new version of Chisel is available:
40
+
41
+ ```bash
42
+ npm run check-update
43
+ ```
44
+
45
+ To update the core files to the latest version:
46
+
47
+ ```bash
48
+ npm run update-chisel
49
+ ```
50
+
51
+ Or run both at once:
52
+
53
+ ```bash
54
+ npm run update
55
+ ```
56
+
57
+ **Note:** The update command will overwrite all files in the `core/` folder.
58
+
59
+ ## Core Folder Protection
60
+
61
+ The `core/` folder contains base Chisel files that are updated automatically when you run `npm run update-chisel`. A pre-commit hook will warn you if you try to commit changes to these files.
62
+
63
+ ### Setting Up Git Hooks
64
+
65
+ Git hooks are set up automatically by the Chisel generator if git is already initialized. If you cloned the project or ran `git init` after installation, run:
66
+
67
+ ```bash
68
+ npm run prepare
69
+ ```
70
+
71
+ ### Recommended Approach
72
+
73
+ Instead of modifying core files directly, create corresponding files in the `custom/` folder:
74
+
75
+ | Instead of modifying... | Create/modify... |
76
+ |----------------------------------|----------------------------------------|
77
+ | `core/WP/Site.php` | `custom/app/WP/Site.php` |
78
+ | `core/Helpers/ImageHelpers.php` | `custom/app/Helpers/ImageHelpers.php` |
79
+ | `core/Timber/ChiselPost.php` | `custom/app/Timber/ChiselPost.php` |
80
+
81
+ ### Bypassing the Hook
82
+
83
+ If you understand the implications and need to commit core changes anyway:
84
+
85
+ ```bash
86
+ # Option 1: Skip verification
87
+ git commit --no-verify
88
+
89
+ # Option 2: Use environment variable
90
+ CHISEL_SKIP_CORE_CHECK=1 git commit
91
+ ```
35
92
 
36
93
  ## Known issues
37
94
 
@@ -0,0 +1,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M21 21L16.65 16.65M11 19C15.4183 19 19 15.4183 19 11C19 6.58172 15.4183 3 11 3C6.58172 3 3 6.58172 3 11C3 15.4183 6.58172 19 11 19Z" stroke="#293229" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
3
+ </svg>
@@ -11,9 +11,9 @@
11
11
  },
12
12
  "require-dev": {
13
13
  "squizlabs/php_codesniffer": "^3.13",
14
- "wp-coding-standards/wpcs": "^3.2",
15
- "friendsoftwig/twigcs": "^6.5",
16
- "vincentlanglet/twig-cs-fixer": "^3.10"
14
+ "wp-coding-standards/wpcs": "^3.3",
15
+ "friendsoftwig/twigcs": "^6.6",
16
+ "vincentlanglet/twig-cs-fixer": "^3.11"
17
17
  },
18
18
  "require": {
19
19
  "php": "^8.2",
@@ -1,25 +1,28 @@
1
1
  <?php
2
2
 
3
- namespace Chisel\WP;
3
+ namespace Chisel\Ajax;
4
4
 
5
+ use Chisel\Interfaces\AjaxEndpointInterface;
6
+ use Chisel\Traits\Rest;
5
7
  use Timber\Timber;
6
8
  use Chisel\Helpers\CacheHelpers;
7
9
 
8
10
  /**
9
- * Custom Ajax enpoints callbacks
11
+ * Load more endpoint.
10
12
  *
11
13
  * @package Chisel
12
14
  */
13
- final class AjaxEndpoints {
15
+ final class LoadMoreEndpoint implements AjaxEndpointInterface {
16
+ use Rest;
14
17
 
15
18
  /**
16
- * Ajax call for load more feature.
19
+ * Ajax call for load more posts feature.
17
20
  *
18
21
  * @param \WP_REST_Request $request WP_REST_Request.
19
22
  *
20
23
  * @return \WP_REST_Response
21
24
  */
22
- public function load_more( \WP_REST_Request $request ): \WP_REST_Response {
25
+ public function handle( \WP_REST_Request $request ): \WP_REST_Response {
23
26
  if ( ! $request ) {
24
27
  return $this->error( 'No request data' );
25
28
  }
@@ -60,50 +63,4 @@ final class AjaxEndpoints {
60
63
 
61
64
  return $this->success( $response );
62
65
  }
63
-
64
- /**
65
- * Get data from request.
66
- *
67
- * @param \WP_REST_Request $request WP_REST_Request.
68
- *
69
- * @return array
70
- */
71
- private function get_data( \WP_REST_Request $request ): array {
72
- return $request->get_body_params();
73
- }
74
-
75
- /**
76
- * This function will return a success response.
77
- *
78
- * @param mixed $data
79
- *
80
- * @return \WP_REST_Response
81
- */
82
- private function success( mixed $data = array() ): \WP_REST_Response {
83
- return new \WP_REST_Response(
84
- array(
85
- 'error' => 0,
86
- 'message' => 'ok',
87
- 'data' => $data,
88
- ),
89
- 200
90
- );
91
- }
92
-
93
- /**
94
- * This function will return an error response.
95
- *
96
- * @param string $message
97
- *
98
- * @return \WP_REST_Response
99
- */
100
- private function error( string $message ): \WP_REST_Response {
101
- return new \WP_REST_Response(
102
- array(
103
- 'error' => 1,
104
- 'message' => $message,
105
- ),
106
- 200
107
- );
108
- }
109
66
  }
@@ -0,0 +1,225 @@
1
+ <?php
2
+
3
+ namespace Chisel\Controllers;
4
+
5
+ use Chisel\Traits\HooksSingleton;
6
+ use Chisel\Traits\Rest;
7
+
8
+ /**
9
+ * Custom Ajax class based on REST API.
10
+ *
11
+ * @package Chisel
12
+ */
13
+ final class AjaxController extends \WP_REST_Controller {
14
+
15
+ use HooksSingleton;
16
+ use Rest;
17
+
18
+ /**
19
+ * Ajax custom route namespace.
20
+ *
21
+ * @var string
22
+ */
23
+ public const ROUTE_NAMESPACE = 'chisel/v2';
24
+
25
+ /**
26
+ * Ajax custom route base.
27
+ *
28
+ * @var string
29
+ */
30
+ public const ROUTE_BASE = 'ajax';
31
+
32
+ /**
33
+ * Ajax custom routes.
34
+ *
35
+ * @var array
36
+ */
37
+ private array $routes = array();
38
+
39
+ /**
40
+ * Set properties.
41
+ */
42
+ public function set_properties(): void {
43
+ $this->routes = array(
44
+ 'load-more' => array(),
45
+ );
46
+ }
47
+
48
+ /**
49
+ * Register action hooks.
50
+ */
51
+ public function action_hooks(): void {
52
+ add_action( 'rest_api_init', array( $this, 'register_endpoints' ) );
53
+ }
54
+
55
+ /**
56
+ * Register filter hooks.
57
+ */
58
+ public function filter_hooks(): void {}
59
+
60
+ /**
61
+ * Register endpoints
62
+ *
63
+ * @return void
64
+ */
65
+ public function register_endpoints(): void {
66
+ $this->routes = apply_filters( 'chisel_ajax_routes', $this->routes );
67
+
68
+ if ( $this->routes ) {
69
+ foreach ( $this->routes as $route_name => $route_params ) {
70
+ $route = sprintf( '%s/%s/', self::ROUTE_BASE, $route_name );
71
+ $methods = isset( $route_params['methods'] ) ? $route_params['methods'] : array( 'POST' );
72
+ $handler = isset( $route_params['handler'] ) ? $route_params['handler'] : null;
73
+
74
+ register_rest_route(
75
+ self::ROUTE_NAMESPACE,
76
+ $route,
77
+ array(
78
+ 'methods' => $methods,
79
+ 'callback' => array( $this, 'callback' ),
80
+ 'permission_callback' => array( $this, 'permissions_check' ),
81
+ 'args' => $this->get_endpoint_args_for_item_schema( true ),
82
+ 'handler' => $handler,
83
+ )
84
+ );
85
+ }
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Create dynamic route callback
91
+ *
92
+ * @param \WP_REST_Request $request WP_REST_Request.
93
+ *
94
+ * @return \WP_REST_Response|\WP_Error|array
95
+ */
96
+ public function callback( \WP_REST_Request $request ): \WP_REST_Response|\WP_Error|array {
97
+ $endpoint_class = $this->get_endpoint_class( $request );
98
+
99
+ if ( is_wp_error( $endpoint_class ) ) {
100
+ return $this->error( $endpoint_class->get_error_message() );
101
+ }
102
+
103
+ $callback = 'handle';
104
+
105
+ if ( method_exists( $endpoint_class, $callback ) ) {
106
+ if ( ! defined( 'DOING_AJAX' ) ) {
107
+ define( 'DOING_AJAX', true );
108
+ }
109
+
110
+ if ( ! defined( 'DOING_CHISEL_AJAX' ) ) {
111
+ define( 'DOING_CHISEL_AJAX', true );
112
+ }
113
+
114
+ $endpoint = new $endpoint_class();
115
+ return $endpoint->handle( $request );
116
+ }
117
+
118
+ return $this->error( sprintf( 'Callback `%s()` not found in %s class', $callback, $endpoint_class ) );
119
+ }
120
+
121
+ /**
122
+ * Check ajax request permissions.
123
+ *
124
+ * @param \WP_REST_Request $request WP_REST_Request.
125
+ *
126
+ * @return boolean|\WP_REST_Response|\WP_Error
127
+ */
128
+ public function permissions_check( \WP_REST_Request $request ): bool|\WP_REST_Response|\WP_Error {
129
+ $verify_nonce = wp_verify_nonce( $request->get_header( 'x_wp_nonce' ), 'wp_rest' );
130
+ $allowed = (bool) $verify_nonce;
131
+
132
+ $endpoint_class = $this->get_endpoint_class( $request );
133
+
134
+ if ( is_wp_error( $endpoint_class ) ) {
135
+ return $this->error( $endpoint_class->get_error_message() );
136
+ }
137
+
138
+ $endpoint_class = sanitize_key( str_replace( '\\', '-', $endpoint_class ) );
139
+
140
+ $permission = apply_filters( 'chisel_ajax_permissions_check', $allowed, $endpoint_class, $request );
141
+
142
+ return $permission;
143
+ }
144
+
145
+ /**
146
+ * Get callback class from ajax request.
147
+ *
148
+ * @param \WP_REST_Request $request
149
+ *
150
+ * @return string|\WP_Error
151
+ */
152
+ private function get_endpoint_class( \WP_REST_Request $request ): string|\WP_Error {
153
+ $custom_class_name = $this->get_endpoint_custom_class( $request );
154
+
155
+ if ( is_wp_error( $custom_class_name ) ) {
156
+ return $custom_class_name;
157
+ }
158
+
159
+ if ( $custom_class_name ) {
160
+ return $custom_class_name;
161
+ }
162
+
163
+ $route = $request->get_route();
164
+ $route_parts = explode( '/', $route );
165
+ $endpoint = end( $route_parts );
166
+ $endpoint_parts = explode( '-', $endpoint );
167
+ $endpoint_parts = array_map( 'ucfirst', $endpoint_parts );
168
+ $endpoint_class = implode( '', $endpoint_parts ) . 'Endpoint';
169
+
170
+ $custom_class_name = CHISEL_NAMESPACE . 'Ajax\\Custom\\' . $endpoint_class;
171
+ $default_class_name = CHISEL_NAMESPACE . 'Ajax\\' . $endpoint_class;
172
+
173
+ if ( class_exists( $custom_class_name ) ) {
174
+ $class_name = $custom_class_name;
175
+ } elseif ( class_exists( $default_class_name ) ) {
176
+ $class_name = $default_class_name;
177
+ } else {
178
+ $class_name = null;
179
+ }
180
+
181
+ if ( ! $class_name ) {
182
+ return new \WP_Error( 'chisel_ajax_endpoint_class_missing', sprintf( 'Ajax Endpoint class: %s not found in inc or custom/inc directory', $endpoint_class ), array( 'status' => 404 ) );
183
+ }
184
+
185
+ return $class_name;
186
+ }
187
+
188
+ /**
189
+ * Get custom class from ajax request.
190
+ *
191
+ * @param \WP_REST_Request $request
192
+ *
193
+ * @return string|bool|\WP_Error
194
+ */
195
+ private function get_endpoint_custom_class( \WP_REST_Request $request ): string|bool|\WP_Error {
196
+ $attributes = $request->get_attributes();
197
+
198
+ $custom_class = $attributes['handler'] ?? null;
199
+
200
+ if ( ! $custom_class ) {
201
+ return false;
202
+ }
203
+
204
+ if ( ! class_exists( $custom_class ) ) {
205
+ return new \WP_Error( 'chisel_ajax_handler_class_missing', sprintf( 'Ajax custom Endpoint class: %s not found in custom/inc directory', $custom_class ), array( 'status' => 404 ) );
206
+ }
207
+
208
+ return $custom_class;
209
+ }
210
+
211
+ /**
212
+ * Get endpoint name from ajax request.
213
+ *
214
+ * @param \WP_REST_Request $request
215
+ *
216
+ * @return string
217
+ */
218
+ private function get_endpoint_name( \WP_REST_Request $request ): string {
219
+ $route = $request->get_route();
220
+ $route_parts = explode( '/', $route );
221
+ $endpoint = str_replace( '-', '_', end( $route_parts ) );
222
+
223
+ return $endpoint;
224
+ }
225
+ }
@@ -8,6 +8,10 @@ namespace Chisel\Helpers;
8
8
  * @package Chisel
9
9
  */
10
10
  final class AcfHelpers {
11
+ /**
12
+ * Prevent instantiation.
13
+ */
14
+ private function __construct() {}
11
15
 
12
16
  /**
13
17
  * Get the acf field value. Acf get_field() wrapper. If ACF plugin is not active, returns false.
@@ -10,6 +10,10 @@ use Chisel\Controllers\AjaxController;
10
10
  * @package Chisel
11
11
  */
12
12
  final class AjaxHelpers {
13
+ /**
14
+ * Prevent instantiation.
15
+ */
16
+ private function __construct() {}
13
17
 
14
18
  /**
15
19
  * Get custom ajax endpint
@@ -8,6 +8,10 @@ namespace Chisel\Helpers;
8
8
  * @package Chisel
9
9
  */
10
10
  final class AssetsHelpers {
11
+ /**
12
+ * Prevent instantiation.
13
+ */
14
+ private function __construct() {}
11
15
 
12
16
  /**
13
17
  * Get the final handle for the asset.
@@ -4,6 +4,7 @@ namespace Chisel\Helpers;
4
4
 
5
5
  use Timber\Timber;
6
6
  use Chisel\WP\AcfBlocks;
7
+ use Chisel\WP\Blocks;
7
8
  use Chisel\Helpers\CacheHelpers;
8
9
 
9
10
  /**
@@ -12,6 +13,10 @@ use Chisel\Helpers\CacheHelpers;
12
13
  * @package Chisel
13
14
  */
14
15
  final class BlocksHelpers {
16
+ /**
17
+ * Prevent instantiation.
18
+ */
19
+ private function __construct() {}
15
20
 
16
21
  /**
17
22
  * Get block object classnames
@@ -5,7 +5,7 @@ namespace Chisel\Helpers;
5
5
  use Timber\Timber;
6
6
  use Timber\Loader;
7
7
 
8
- use Chisel\WP\Cache;
8
+ use Chisel\Timber\Cache;
9
9
 
10
10
  /**
11
11
  * Image Helper functions.
@@ -13,6 +13,10 @@ use Chisel\WP\Cache;
13
13
  * @package Chisel
14
14
  */
15
15
  final class CacheHelpers {
16
+ /**
17
+ * Prevent instantiation.
18
+ */
19
+ private function __construct() {}
16
20
 
17
21
  /**
18
22
  * Get the cache expiry time.