generator-chisel 2.0.0-alpha.1 → 2.0.0-alpha.10
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.
- package/CHANGELOG.md +48 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/.gitignore.chisel-tpl +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/acf-json/group_666eb7f38d2ed.json +42 -42
- package/lib/commands/create/creators/app/chisel-starter-theme/acf-json/group_66d5a4ebb41cd.json +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/archive.php +1 -12
- package/lib/commands/create/creators/app/chisel-starter-theme/author.php +2 -6
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Acf.php +19 -22
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/AcfBlocks.php +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Ajax.php +40 -25
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/AjaxEnpoints.php +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Assets.php +267 -148
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Blocks.php +31 -16
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Comments.php +325 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Components.php +56 -19
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/CustomPostTypes.php +33 -335
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/ExtendedPost.php +1 -8
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/ExtendedProduct.php +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/GravityForms.php +185 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Helpers.php +79 -7
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/RegisterBlocks.php +7 -5
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/RegisterCustomObject.php +395 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Site.php +1 -18
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Theme.php +33 -28
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Twig.php +64 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Woocommerce.php +37 -9
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Yoast.php +78 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/functions.php +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/index.php +0 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/patterns/comments.php +51 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/patterns/cta.php +2 -3
- package/lib/commands/create/creators/app/chisel-starter-theme/phpcs.xml +4 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/search.php +0 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks-acf/slider/acf-json/group_66462c70b851f.json +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks-acf/slider/block.json +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks-acf/slider/slider.twig +6 -4
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_buttons.scss +75 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_icon.scss +8 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_media.scss +15 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/app.js +2 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/blocks-mods.js +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/blocks.js +0 -28
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/mods/blocks-alignment.js +26 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/mods/core-button.js +162 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/mods/core-spacer.js +28 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/utils.js +24 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor.js +1 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/login.js +11 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/modules/scrollbar-width.js +8 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/modules/slider.js +12 -3
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/.gitignore.chisel-tpl +1 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/admin.scss +2 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core-button.scss +74 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core-comments.scss +16 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core.scss +4 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_index.scss +16 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_buttons.scss +64 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_index.scss +19 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_main-nav.scss +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_slider.scss +18 -13
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/elements/_form.scss +5 -7
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/elements/_index.scss +10 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/generic/_index.scss +4 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/{vendor/_gravity-forms.scss → gravity-forms.scss} +5 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/login.scss +8 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/objects/_index.scss +6 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/utilities/_index.scss +4 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/vendor/_breadcrumbs.scss +16 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/vendor/_index.scss +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/widgets/_index.scss +5 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/woo/_index.scss +12 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/wp-admin/_acf.scss +21 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/wp-admin/_index.scss +4 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/wp-editor/_index.scss +11 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/wp-editor/_swiper-sliders.scss +11 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/theme.json +6 -16
- package/lib/commands/create/creators/app/chisel-starter-theme/twig_cs.php +6 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/views/404.twig +1 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/views/base.twig +8 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/icon.twig +1 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/post-item.twig +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/slider.twig +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/views/index.twig +3 -5
- package/lib/commands/create/creators/app/chisel-starter-theme/views/partials/block-edit-button.twig +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/partials/the-title.twig +3 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/views/single.twig +2 -0
- package/lib/commands/create/creators/wp-plugins/plugins.json +3 -3
- package/lib/commands/create/packages-versions.js +2 -2
- package/package.json +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/composer.lock +0 -2180
- package/lib/commands/create/creators/app/chisel-starter-theme/lint-staged.config.mjs +0 -8
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/blocks-attributes.js +0 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/page-title.twig +0 -5
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/pagination.twig +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,54 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- INSERT-NEW-ENTRIES-HERE -->
|
|
4
4
|
|
|
5
|
+
## 2.0.0-alpha.10 (2024-10-31)
|
|
6
|
+
|
|
7
|
+
- add assets index ([fed4fd3](https://github.com/xfiveco/generator-chisel/commit/fed4fd3))
|
|
8
|
+
- CPTs, assets, blocks changes and fixes ([0014d9b](https://github.com/xfiveco/generator-chisel/commit/0014d9b))
|
|
9
|
+
- ignore assets index ([b951521](https://github.com/xfiveco/generator-chisel/commit/b951521))
|
|
10
|
+
|
|
11
|
+
## 2.0.0-alpha.9 (2024-10-18)
|
|
12
|
+
|
|
13
|
+
- fixes, adjustments, optimize ([f73f855](https://github.com/xfiveco/generator-chisel/commit/f73f855))
|
|
14
|
+
|
|
15
|
+
## 2.0.0-alpha.8 (2024-10-07)
|
|
16
|
+
|
|
17
|
+
- fixes ([4cdc3e1](https://github.com/xfiveco/generator-chisel/commit/4cdc3e1))
|
|
18
|
+
- Publish ([ad109c1](https://github.com/xfiveco/generator-chisel/commit/ad109c1))
|
|
19
|
+
|
|
20
|
+
## 2.0.0-alpha.7 (2024-10-07)
|
|
21
|
+
|
|
22
|
+
- update gitignore ([164b521](https://github.com/xfiveco/generator-chisel/commit/164b521))
|
|
23
|
+
- update gitignore, plugins list and buttons css ([e136434](https://github.com/xfiveco/generator-chisel/commit/e136434))
|
|
24
|
+
|
|
25
|
+
## 2.0.0-alpha.6 (2024-10-07)
|
|
26
|
+
|
|
27
|
+
- blocks, assets, css adjustments, breadcrumbs, bem fn ([b3460ce](https://github.com/xfiveco/generator-chisel/commit/b3460ce))
|
|
28
|
+
- page title, gravity forms, responsive image, slider fixes ([619789e](https://github.com/xfiveco/generator-chisel/commit/619789e))
|
|
29
|
+
|
|
30
|
+
## 2.0.0-alpha.5 (2024-09-27)
|
|
31
|
+
|
|
32
|
+
- bugs fixes, blocks mods, adjustments ([5a2b460](https://github.com/xfiveco/generator-chisel/commit/5a2b460))
|
|
33
|
+
|
|
34
|
+
## 2.0.0-alpha.4 (2024-09-16)
|
|
35
|
+
|
|
36
|
+
- adjust plugins ([bc2343a](https://github.com/xfiveco/generator-chisel/commit/bc2343a))
|
|
37
|
+
- bug fixes, phpcs and twigcs fixes ([118297b](https://github.com/xfiveco/generator-chisel/commit/118297b))
|
|
38
|
+
- remove lint staged (it is in coding standards) ([e51b4b6](https://github.com/xfiveco/generator-chisel/commit/e51b4b6))
|
|
39
|
+
- remove unnecessary gitignore ([f48e528](https://github.com/xfiveco/generator-chisel/commit/f48e528))
|
|
40
|
+
- scripts enqueueing fixes ([5a8badf](https://github.com/xfiveco/generator-chisel/commit/5a8badf))
|
|
41
|
+
- theme gitignore update ([9ef8d60](https://github.com/xfiveco/generator-chisel/commit/9ef8d60))
|
|
42
|
+
- twig cs adjustments ([84493cd](https://github.com/xfiveco/generator-chisel/commit/84493cd))
|
|
43
|
+
|
|
44
|
+
## 2.0.0-alpha.3 (2024-09-13)
|
|
45
|
+
|
|
46
|
+
- refactor, adjustments, css spliting, comments, 3rd party integration classes ([e1fe3cd](https://github.com/xfiveco/generator-chisel/commit/e1fe3cd))
|
|
47
|
+
- update blocks path, add action hooks ([e20d184](https://github.com/xfiveco/generator-chisel/commit/e20d184))
|
|
48
|
+
|
|
49
|
+
## 2.0.0-alpha.2 (2024-09-10)
|
|
50
|
+
|
|
51
|
+
- correct gitignore ([22542dc](https://github.com/xfiveco/generator-chisel/commit/22542dc))
|
|
52
|
+
|
|
5
53
|
## 2.0.0-alpha.1 (2024-09-10)
|
|
6
54
|
|
|
7
55
|
- adjust commands ([b289bd8](https://github.com/xfiveco/generator-chisel/commit/b289bd8))
|
package/lib/commands/create/creators/app/chisel-starter-theme/acf-json/group_666eb7f38d2ed.json
CHANGED
|
@@ -2,49 +2,49 @@
|
|
|
2
2
|
"key": "group_666eb7f38d2ed",
|
|
3
3
|
"title": "Page Title",
|
|
4
4
|
"fields": [
|
|
5
|
-
{
|
|
6
|
-
"key": "field_666eb7f40c492",
|
|
7
|
-
"label": "Page Title",
|
|
8
|
-
"name": "page_title_display",
|
|
9
|
-
"aria-label": "",
|
|
10
|
-
"type": "select",
|
|
11
|
-
"instructions": "",
|
|
12
|
-
"required": 0,
|
|
13
|
-
"conditional_logic": 0,
|
|
14
|
-
"wrapper": {
|
|
15
|
-
"width": "",
|
|
16
|
-
"class": "",
|
|
17
|
-
"id": ""
|
|
18
|
-
},
|
|
19
|
-
"choices": {
|
|
20
|
-
"show": "Show",
|
|
21
|
-
"hide-visually": "Hide visually",
|
|
22
|
-
"hide": "Hide"
|
|
23
|
-
},
|
|
24
|
-
"default_value": "show",
|
|
25
|
-
"return_format": "value",
|
|
26
|
-
"multiple": 0,
|
|
27
|
-
"allow_null": 0,
|
|
28
|
-
"ui": 0,
|
|
29
|
-
"ajax": 0,
|
|
30
|
-
"placeholder": ""
|
|
31
|
-
}
|
|
32
|
-
],
|
|
33
|
-
"location": [
|
|
34
|
-
[
|
|
35
|
-
{
|
|
36
|
-
"param": "post_type",
|
|
37
|
-
"operator": "==",
|
|
38
|
-
"value": "post"
|
|
39
|
-
}
|
|
40
|
-
],
|
|
41
|
-
[
|
|
42
5
|
{
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
6
|
+
"key": "field_666eb7f40c492",
|
|
7
|
+
"label": "Page Title",
|
|
8
|
+
"name": "page_title_display",
|
|
9
|
+
"aria-label": "",
|
|
10
|
+
"type": "select",
|
|
11
|
+
"instructions": "",
|
|
12
|
+
"required": 0,
|
|
13
|
+
"conditional_logic": 0,
|
|
14
|
+
"wrapper": {
|
|
15
|
+
"width": "",
|
|
16
|
+
"class": "",
|
|
17
|
+
"id": ""
|
|
18
|
+
},
|
|
19
|
+
"choices": {
|
|
20
|
+
"show": "Show",
|
|
21
|
+
"hide-visually": "Hide visually",
|
|
22
|
+
"hide": "Hide"
|
|
23
|
+
},
|
|
24
|
+
"default_value": "show",
|
|
25
|
+
"return_format": "value",
|
|
26
|
+
"multiple": 0,
|
|
27
|
+
"allow_null": 0,
|
|
28
|
+
"ui": 0,
|
|
29
|
+
"ajax": 0,
|
|
30
|
+
"placeholder": ""
|
|
46
31
|
}
|
|
47
|
-
|
|
32
|
+
],
|
|
33
|
+
"location": [
|
|
34
|
+
[
|
|
35
|
+
{
|
|
36
|
+
"param": "post_type",
|
|
37
|
+
"operator": "==",
|
|
38
|
+
"value": "post"
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
{
|
|
43
|
+
"param": "post_type",
|
|
44
|
+
"operator": "==",
|
|
45
|
+
"value": "page"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
48
|
],
|
|
49
49
|
"menu_order": -10,
|
|
50
50
|
"position": "side",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"active": true,
|
|
56
56
|
"description": "",
|
|
57
57
|
"show_in_rest": 0,
|
|
58
|
-
"modified":
|
|
58
|
+
"modified": 1725978564
|
|
59
59
|
}
|
|
@@ -12,24 +12,13 @@ $templates = array( 'archive.twig', 'index.twig' );
|
|
|
12
12
|
|
|
13
13
|
$context = Timber::context();
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
if ( is_day() ) {
|
|
17
|
-
$context['title'] = 'Archive: ' . get_the_date( 'D M Y' );
|
|
18
|
-
} elseif ( is_month() ) {
|
|
19
|
-
$context['title'] = 'Archive: ' . get_the_date( 'M Y' );
|
|
20
|
-
} elseif ( is_year() ) {
|
|
21
|
-
$context['title'] = 'Archive: ' . get_the_date( 'Y' );
|
|
22
|
-
} elseif ( is_tag() ) {
|
|
23
|
-
$context['title'] = __( 'Tag: ', 'chisel' ) . ' ' . single_tag_title( '', false );
|
|
15
|
+
if ( is_tag() ) {
|
|
24
16
|
array_unshift( $templates, 'archive-' . get_queried_object()->slug . '.twig' );
|
|
25
17
|
} elseif ( is_category() ) {
|
|
26
|
-
$context['title'] = __( 'Category: ', 'chisel' ) . ' ' . single_cat_title( '', false );
|
|
27
18
|
array_unshift( $templates, 'archive-' . get_queried_object()->slug . '.twig' );
|
|
28
19
|
} elseif ( is_post_type_archive() ) {
|
|
29
|
-
$context['title'] = post_type_archive_title( '', false );
|
|
30
20
|
array_unshift( $templates, 'archive-' . get_post_type() . '.twig' );
|
|
31
21
|
} elseif ( is_tax() ) {
|
|
32
|
-
$context['title'] = single_term_title( '', false );
|
|
33
22
|
array_unshift( $templates, 'archive-' . get_queried_object()->taxonomy . '.twig' );
|
|
34
23
|
}
|
|
35
24
|
|
|
@@ -8,11 +8,7 @@
|
|
|
8
8
|
use Chisel\ChiselCache;
|
|
9
9
|
use Timber\Timber;
|
|
10
10
|
|
|
11
|
-
$
|
|
12
|
-
|
|
13
|
-
$context = Timber::context();
|
|
14
|
-
$context['posts'] = Timber::get_posts();
|
|
15
|
-
$context['author'] = $author;
|
|
16
|
-
$context['title'] = __( 'Author: ', 'chisel' ) . $author->name;
|
|
11
|
+
$context = Timber::context();
|
|
12
|
+
$context['posts'] = Timber::get_posts();
|
|
17
13
|
|
|
18
14
|
Timber::render( array( 'author.twig', 'archive.twig' ), $context, ChiselCache::expiry() );
|
|
@@ -61,16 +61,13 @@ class Acf implements Instance {
|
|
|
61
61
|
* Set ACF options pages.
|
|
62
62
|
*/
|
|
63
63
|
public function set_options_pages() {
|
|
64
|
-
$this->acf_options_pages =
|
|
65
|
-
|
|
66
|
-
array(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// ),
|
|
72
|
-
// phpcs:enable
|
|
73
|
-
)
|
|
64
|
+
$this->acf_options_pages = array(
|
|
65
|
+
// phpcs:disable
|
|
66
|
+
// array(
|
|
67
|
+
// 'menu_slug' => 'theme-settings',
|
|
68
|
+
// 'page_title' => __( 'Theme Settings', 'chisel' ),
|
|
69
|
+
// ),
|
|
70
|
+
// phpcs:enable
|
|
74
71
|
);
|
|
75
72
|
}
|
|
76
73
|
|
|
@@ -78,18 +75,15 @@ class Acf implements Instance {
|
|
|
78
75
|
* Set ACF options sub pages.
|
|
79
76
|
*/
|
|
80
77
|
public function set_options_sub_pages() {
|
|
81
|
-
$this->acf_options_sub_pages =
|
|
82
|
-
|
|
83
|
-
array(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
// ),
|
|
91
|
-
// phpcs:enable
|
|
92
|
-
)
|
|
78
|
+
$this->acf_options_sub_pages = array(
|
|
79
|
+
// phpcs:disable
|
|
80
|
+
// array(
|
|
81
|
+
// 'menu_slug' => 'theme-sub-settings',
|
|
82
|
+
// 'page_title' => __( 'Theme Sub settings', 'chisel' ),
|
|
83
|
+
// 'menu_title' => __( 'Theme Sub settings', 'chisel' ),
|
|
84
|
+
// 'parent_slug' => 'theme-settings',
|
|
85
|
+
// ),
|
|
86
|
+
// phpcs:enable
|
|
93
87
|
);
|
|
94
88
|
}
|
|
95
89
|
|
|
@@ -97,6 +91,9 @@ class Acf implements Instance {
|
|
|
97
91
|
* Register ACF options pages.
|
|
98
92
|
*/
|
|
99
93
|
public function options_pages() {
|
|
94
|
+
$this->acf_options_pages = apply_filters( 'chisel_acf_options_pages', $this->acf_options_pages );
|
|
95
|
+
$this->acf_options_sub_pages = apply_filters( 'chisel_acf_options_sub_pages', $this->acf_options_sub_pages );
|
|
96
|
+
|
|
100
97
|
if ( $this->acf_options_pages && function_exists( 'acf_add_options_page' ) ) {
|
|
101
98
|
foreach ( $this->acf_options_pages as $data ) {
|
|
102
99
|
$this->register_options_page( $data, 'page' );
|
|
@@ -35,7 +35,7 @@ class AcfBlocks extends RegisterBlocks implements Instance {
|
|
|
35
35
|
* Set properties.
|
|
36
36
|
*/
|
|
37
37
|
public function set_properties() {
|
|
38
|
-
$this->blocks_twig_base_path = '
|
|
38
|
+
$this->blocks_twig_base_path = 'build/blocks-acf/';
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -162,7 +162,7 @@ class AcfBlocks extends RegisterBlocks implements Instance {
|
|
|
162
162
|
|
|
163
163
|
// allow to use filters to manipulate the output.
|
|
164
164
|
$context = apply_filters( 'chisel_timber_acf_blocks_data', $context );
|
|
165
|
-
$context = apply_filters( 'chisel_timber_acf_blocks_data_' . $
|
|
165
|
+
$context = apply_filters( 'chisel_timber_acf_blocks_data_' . $block_slug, $context );
|
|
166
166
|
$context = apply_filters( 'chisel_timber_acf_blocks_data_' . $block['id'], $context );
|
|
167
167
|
|
|
168
168
|
$context['wrapper_attributes'] = get_block_wrapper_attributes(
|
|
@@ -45,11 +45,8 @@ class Ajax extends \WP_REST_Controller implements Instance {
|
|
|
45
45
|
* Set properties.
|
|
46
46
|
*/
|
|
47
47
|
public function set_properties() {
|
|
48
|
-
$this->routes =
|
|
49
|
-
'
|
|
50
|
-
array(
|
|
51
|
-
'load-more' => array(),
|
|
52
|
-
)
|
|
48
|
+
$this->routes = array(
|
|
49
|
+
'load-more' => array(),
|
|
53
50
|
);
|
|
54
51
|
}
|
|
55
52
|
|
|
@@ -71,20 +68,24 @@ class Ajax extends \WP_REST_Controller implements Instance {
|
|
|
71
68
|
* @return void
|
|
72
69
|
*/
|
|
73
70
|
public function register_endpoints() {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
71
|
+
$this->routes = apply_filters( 'chisel_ajax_routes', $this->routes );
|
|
72
|
+
|
|
73
|
+
if ( $this->routes ) {
|
|
74
|
+
foreach ( $this->routes as $route_name => $route_params ) {
|
|
75
|
+
$route = sprintf( self::ROUTE_BASE . '/%s/', $route_name );
|
|
76
|
+
$methods = isset( $route_params['methods'] ) ? $route_params['methods'] : array( 'POST' );
|
|
77
|
+
|
|
78
|
+
register_rest_route(
|
|
79
|
+
self::ROUTE_NAMESPACE,
|
|
80
|
+
$route,
|
|
81
|
+
array(
|
|
82
|
+
'methods' => $methods,
|
|
83
|
+
'callback' => array( $this, 'callback' ),
|
|
84
|
+
'permission_callback' => array( $this, 'permissions_check' ),
|
|
85
|
+
'args' => $this->get_endpoint_args_for_item_schema( true ),
|
|
86
|
+
)
|
|
87
|
+
);
|
|
88
|
+
}
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
|
|
@@ -96,11 +97,8 @@ class Ajax extends \WP_REST_Controller implements Instance {
|
|
|
96
97
|
* @return callable
|
|
97
98
|
*/
|
|
98
99
|
public function callback( $request ) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
$callback = str_replace( '-', '_', end( $route_parts ) );
|
|
102
|
-
|
|
103
|
-
$ajax_endpoints = new AjaxEnpoints();
|
|
100
|
+
$callback = self::get_callback_name( $request );
|
|
101
|
+
$ajax_endpoints = new AjaxEnpoints();
|
|
104
102
|
|
|
105
103
|
if ( method_exists( $ajax_endpoints, $callback ) ) {
|
|
106
104
|
if ( ! defined( 'DOING_AJAX' ) ) {
|
|
@@ -123,7 +121,9 @@ class Ajax extends \WP_REST_Controller implements Instance {
|
|
|
123
121
|
* @return boolean
|
|
124
122
|
*/
|
|
125
123
|
public function permissions_check( $request ) {
|
|
126
|
-
|
|
124
|
+
$permission = apply_filters( 'chisel_ajax_permissions_check', true, self::get_callback_name( $request ), $request );
|
|
125
|
+
|
|
126
|
+
return $permission;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
/**
|
|
@@ -146,6 +146,21 @@ class Ajax extends \WP_REST_Controller implements Instance {
|
|
|
146
146
|
return (array) json_decode( stripslashes( $value ) );
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
/**
|
|
150
|
+
* Get callback name from ajax request.
|
|
151
|
+
*
|
|
152
|
+
* @param \WP_REST_Request $request
|
|
153
|
+
*
|
|
154
|
+
* @return string
|
|
155
|
+
*/
|
|
156
|
+
public static function get_callback_name( $request ) {
|
|
157
|
+
$route = $request->get_route();
|
|
158
|
+
$route_parts = explode( '/', $route );
|
|
159
|
+
$callback = str_replace( '-', '_', end( $route_parts ) );
|
|
160
|
+
|
|
161
|
+
return $callback;
|
|
162
|
+
}
|
|
163
|
+
|
|
149
164
|
/**
|
|
150
165
|
* Get the instance of the class.
|
|
151
166
|
*/
|
|
@@ -40,7 +40,7 @@ class AjaxEnpoints {
|
|
|
40
40
|
)
|
|
41
41
|
);
|
|
42
42
|
|
|
43
|
-
$templates = array( 'components/
|
|
43
|
+
$templates = array( 'components/' . $post_type . '-item.twig', 'components/post-item.twig' );
|
|
44
44
|
|
|
45
45
|
if ( $post_type === 'product' ) {
|
|
46
46
|
array_unshift( $templates, 'woocommerce/content-product.twig' );
|