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.
- package/CHANGELOG.md +15 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/.editorconfig +16 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/.gitignore.chisel-tpl +0 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/.husky/pre-commit +92 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/.nvmrc +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/.vscode/extensions.json +10 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/.vscode/settings.json +19 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/README.md +67 -10
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/search.svg +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/composer.json +3 -3
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc/WP/AjaxEndpoints.php → core/Ajax/LoadMoreEndpoint.php} +8 -51
- package/lib/commands/create/creators/app/chisel-starter-theme/core/Controllers/AjaxController.php +225 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/AcfHelpers.php +4 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/AjaxHelpers.php +4 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/AssetsHelpers.php +4 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/BlocksHelpers.php +5 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/CacheHelpers.php +5 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/CommentsHelpers.php +4 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/DataHelpers.php +4 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/GravityFormsHelpers.php +4 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/ImageHelpers.php +4 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/ThemeHelpers.php +10 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/WoocommerceHelpers.php +4 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/YoastHelpers.php +4 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/core/Interfaces/AjaxEndpointInterface.php +15 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc/Plugins → core/Plugins/GravityForms}/GravityForms.php +12 -24
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc/Plugins → core/Plugins/Woocommerce}/Woocommerce.php +23 -14
- package/lib/commands/create/creators/app/chisel-starter-theme/core/Plugins/Yoast/Yoast.php +37 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc/WP → core/Timber}/Cache.php +5 -17
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc/WP → core/Timber}/ChiselImage.php +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc/WP → core/Timber}/ChiselPost.php +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc/WP → core/Timber}/ChiselProduct.php +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc/WP → core/Timber}/ChiselProductCategory.php +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc/WP → core/Timber}/ChiselTerm.php +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc/WP → core/Timber}/Components.php +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/core/Traits/Hooks.php +29 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/core/Traits/HooksSingleton.php +54 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/core/Traits/Rest.php +51 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Traits/Singleton.php +10 -8
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/Acf.php +22 -55
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/AcfBlocks.php +7 -20
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/Assets.php +3 -15
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/Blocks.php +7 -19
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/Comments.php +44 -49
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/CustomPostTypes.php +8 -35
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/CustomTaxonomies.php +12 -36
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/Sidebars.php +3 -15
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/Site.php +52 -18
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/Theme.php +4 -15
- package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/WP/Twig.php +12 -31
- package/lib/commands/create/creators/app/chisel-starter-theme/custom/app/Timber/ChiselPost.php +14 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/custom/app/WP/Acf.php +66 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/custom/app/WP/Ajax.php +45 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/custom/app/WP/Assets.php +37 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/custom/app/WP/CustomPostTypes.php +76 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/custom/app/WP/Site.php +42 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/custom/app/WP/Twig.php +52 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/custom/functions.php +8 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/custom/views/README.md +7 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/functions.php +31 -9
- package/lib/commands/create/creators/app/chisel-starter-theme/package.chisel-tpl.json +11 -6
- package/lib/commands/create/creators/app/chisel-starter-theme/phpcs.xml +10 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks/accordion/block.json +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/settings/_index.scss +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_breakpoints.scss +1 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/mods/core.js +11 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/modules/main-nav.js +14 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/modules/slider.js +45 -4
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_buttons.scss +11 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_search-form.scss +17 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_slider.scss +3 -3
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-base.scss +117 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-collapse.scss.disabled +66 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-elastic.scss.disabled +56 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-emphatic.scss.disabled +59 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-settings.scss +22 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-slider.scss +59 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-spin.scss.disabled +60 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-spring.scss.disabled +98 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-squeeze.scss.disabled +47 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-stand.scss.disabled +59 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-three-d.scss.disabled +139 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/main-nav-toggle/_mnt-vortex.scss.disabled +61 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/gravity-forms.scss +17 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/style.chisel-tpl.css +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/theme.json +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/twig_cs.php +4 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/views/base.twig +1 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/footer.twig +19 -11
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/header.twig +6 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/logo.twig +6 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/main-nav.twig +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/post-item.twig +38 -20
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/search-form.twig +8 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/index.twig +19 -10
- package/lib/commands/create/creators/app/chisel-starter-theme/views/search.twig +5 -6
- package/lib/commands/create/creators/app/chisel-starter-theme/views/single.twig +43 -31
- package/lib/commands/create/creators/app/chisel-starter-theme/views/woocommerce/content-product.twig +1 -1
- package/lib/commands/create/creators/app/index.js +87 -9
- package/lib/commands/create/creators/app/template/.gitignore.chisel-tpl +1 -0
- package/lib/commands/create/creators/wp/index.js +10 -2
- package/lib/commands/create/packages-versions.js +2 -2
- package/lib/commands/create/priorities.js +3 -0
- package/package.json +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Controllers/AjaxController.php +0 -156
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Interfaces/HooksInterface.php +0 -26
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Interfaces/InstanceInterface.php +0 -16
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Plugins/Yoast.php +0 -46
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_main-nav-toggle.scss +0 -804
- /package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Enums/AcfOptionsPageType.php +0 -0
- /package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Enums/BlocksType.php +0 -0
- /package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Factories/RegisterAcfOptionsPage.php +0 -0
- /package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Factories/RegisterBlocks.php +0 -0
- /package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Factories/RegisterCustomPostType.php +0 -0
- /package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Factories/RegisterCustomTaxonomy.php +0 -0
- /package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Traits/PageBlocks.php +0 -0
- /package/lib/commands/create/creators/app/chisel-starter-theme/{src/scripts/blog.js → custom/app/Ajax/.gitkeep} +0 -0
package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Helpers/ThemeHelpers.php
RENAMED
|
@@ -10,6 +10,10 @@ use Chisel\Helpers\ImageHelpers;
|
|
|
10
10
|
* @package Chisel
|
|
11
11
|
*/
|
|
12
12
|
final class ThemeHelpers {
|
|
13
|
+
/**
|
|
14
|
+
* Prevent instantiation.
|
|
15
|
+
*/
|
|
16
|
+
private function __construct() {}
|
|
13
17
|
/**
|
|
14
18
|
* Color palettes.
|
|
15
19
|
*
|
|
@@ -65,7 +69,7 @@ final class ThemeHelpers {
|
|
|
65
69
|
* @return bool
|
|
66
70
|
*/
|
|
67
71
|
public static function should_use_icons_module(): bool {
|
|
68
|
-
return defined( 'CHISEL_USE_ICONS_MODULE' ) && CHISEL_USE_ICONS_MODULE;
|
|
72
|
+
return defined( 'CHISEL_USE_ICONS_MODULE' ) && CHISEL_USE_ICONS_MODULE === true;
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
/**
|
|
@@ -77,12 +81,16 @@ final class ThemeHelpers {
|
|
|
77
81
|
* @return string
|
|
78
82
|
*/
|
|
79
83
|
public static function bem( string $name = '', mixed ...$modifiers ): string {
|
|
80
|
-
if ( $name === ''
|
|
84
|
+
if ( $name === '' ) {
|
|
81
85
|
return '';
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
$classnames = array( $name );
|
|
85
89
|
|
|
90
|
+
if ( empty( $modifiers ) ) {
|
|
91
|
+
return $name;
|
|
92
|
+
}
|
|
93
|
+
|
|
86
94
|
foreach ( $modifiers as $key => $value ) {
|
|
87
95
|
if ( is_array( $value ) ) {
|
|
88
96
|
$values = array_map(
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Chisel\Interfaces;
|
|
4
|
+
|
|
5
|
+
interface AjaxEndpointInterface {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Handle ajax request.
|
|
9
|
+
*
|
|
10
|
+
* @param \WP_REST_Request $request WP_REST_Request.
|
|
11
|
+
*
|
|
12
|
+
* @return \WP_REST_Response
|
|
13
|
+
*/
|
|
14
|
+
public function handle( \WP_REST_Request $request ): \WP_REST_Response;
|
|
15
|
+
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
|
|
3
|
-
namespace Chisel\Plugins;
|
|
3
|
+
namespace Chisel\Plugins\GravityForms;
|
|
4
4
|
|
|
5
|
-
use Chisel\
|
|
6
|
-
use Chisel\Interfaces\HooksInterface;
|
|
7
|
-
use Chisel\Traits\Singleton;
|
|
5
|
+
use Chisel\Traits\HooksSingleton;
|
|
8
6
|
use Chisel\Helpers\GravityFormsHelpers;
|
|
9
7
|
|
|
10
8
|
/**
|
|
@@ -12,29 +10,21 @@ use Chisel\Helpers\GravityFormsHelpers;
|
|
|
12
10
|
*
|
|
13
11
|
* @package Chisel
|
|
14
12
|
*/
|
|
15
|
-
final class GravityForms
|
|
13
|
+
final class GravityForms {
|
|
16
14
|
|
|
17
|
-
use
|
|
15
|
+
use HooksSingleton;
|
|
18
16
|
|
|
19
17
|
/**
|
|
20
|
-
*
|
|
18
|
+
* Initialize.
|
|
21
19
|
*/
|
|
22
|
-
|
|
20
|
+
public function init() {
|
|
23
21
|
if ( ! GravityFormsHelpers::is_gf_active() ) {
|
|
24
|
-
return;
|
|
22
|
+
return false;
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
$this->action_hooks();
|
|
30
|
-
$this->filter_hooks();
|
|
25
|
+
return true;
|
|
31
26
|
}
|
|
32
27
|
|
|
33
|
-
/**
|
|
34
|
-
* Set properties.
|
|
35
|
-
*/
|
|
36
|
-
public function set_properties(): void {}
|
|
37
|
-
|
|
38
28
|
/**
|
|
39
29
|
* Register action hooks.
|
|
40
30
|
*/
|
|
@@ -47,8 +37,8 @@ final class GravityForms implements InstanceInterface, HooksInterface {
|
|
|
47
37
|
*/
|
|
48
38
|
public function filter_hooks(): void {
|
|
49
39
|
add_filter( 'chisel_frontend_footer_styles', array( $this, 'register_custom_styles' ) );
|
|
50
|
-
add_filter( 'chisel_enqueue_frontend_footer_style', array( $this, 'enqueue_custom_styles' ), 10,
|
|
51
|
-
add_filter( 'gform_form_theme_slug', array( $this, 'default_form_styles' ), 99
|
|
40
|
+
add_filter( 'chisel_enqueue_frontend_footer_style', array( $this, 'enqueue_custom_styles' ), 10, 2 );
|
|
41
|
+
add_filter( 'gform_form_theme_slug', array( $this, 'default_form_styles' ), 99 );
|
|
52
42
|
add_filter( 'gform_plugin_settings_fields', array( $this, 'plugin_settings_fields' ), 99 );
|
|
53
43
|
}
|
|
54
44
|
|
|
@@ -77,11 +67,10 @@ final class GravityForms implements InstanceInterface, HooksInterface {
|
|
|
77
67
|
*
|
|
78
68
|
* @param bool $enqueue
|
|
79
69
|
* @param string $handle
|
|
80
|
-
* @param array $args
|
|
81
70
|
*
|
|
82
71
|
* @return bool
|
|
83
72
|
*/
|
|
84
|
-
public function enqueue_custom_styles( bool $enqueue, string $handle
|
|
73
|
+
public function enqueue_custom_styles( bool $enqueue, string $handle ): bool {
|
|
85
74
|
if ( $handle !== 'gravity-forms' ) {
|
|
86
75
|
return $enqueue;
|
|
87
76
|
}
|
|
@@ -99,11 +88,10 @@ final class GravityForms implements InstanceInterface, HooksInterface {
|
|
|
99
88
|
* Set default form styles for all forms so that our custom styles can be used.
|
|
100
89
|
*
|
|
101
90
|
* @param string $slug
|
|
102
|
-
* @param array $form
|
|
103
91
|
*
|
|
104
92
|
* @return string
|
|
105
93
|
*/
|
|
106
|
-
public function default_form_styles( string $slug
|
|
94
|
+
public function default_form_styles( string $slug ): string {
|
|
107
95
|
if ( ! is_admin() ) {
|
|
108
96
|
$slug = 'gravity-theme';
|
|
109
97
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
|
|
3
|
-
namespace Chisel\Plugins;
|
|
3
|
+
namespace Chisel\Plugins\Woocommerce;
|
|
4
|
+
|
|
5
|
+
use Chisel\Traits\HooksSingleton;
|
|
4
6
|
|
|
5
|
-
use Chisel\Interfaces\InstanceInterface;
|
|
6
|
-
use Chisel\Interfaces\HooksInterface;
|
|
7
|
-
use Chisel\Traits\Singleton;
|
|
8
7
|
use Chisel\Helpers\WoocommerceHelpers;
|
|
9
8
|
|
|
10
9
|
/**
|
|
@@ -12,9 +11,8 @@ use Chisel\Helpers\WoocommerceHelpers;
|
|
|
12
11
|
*
|
|
13
12
|
* @package Chisel
|
|
14
13
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
use Singleton;
|
|
14
|
+
class Woocommerce {
|
|
15
|
+
use HooksSingleton;
|
|
18
16
|
|
|
19
17
|
/**
|
|
20
18
|
* Woocommerce sidebars.
|
|
@@ -24,17 +22,14 @@ final class Woocommerce implements InstanceInterface, HooksInterface {
|
|
|
24
22
|
private $sidebars = array();
|
|
25
23
|
|
|
26
24
|
/**
|
|
27
|
-
*
|
|
25
|
+
* Initialize.
|
|
28
26
|
*/
|
|
29
|
-
|
|
27
|
+
public function init(): bool {
|
|
30
28
|
if ( ! WoocommerceHelpers::is_woocommerce_active() ) {
|
|
31
|
-
return;
|
|
29
|
+
return false;
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
$this->action_hooks();
|
|
37
|
-
$this->filter_hooks();
|
|
32
|
+
return true;
|
|
38
33
|
}
|
|
39
34
|
|
|
40
35
|
/**
|
|
@@ -74,6 +69,7 @@ final class Woocommerce implements InstanceInterface, HooksInterface {
|
|
|
74
69
|
add_filter( 'chisel_sidebars', array( $this, 'register_sidebars' ) );
|
|
75
70
|
add_filter( 'woocommerce_enqueue_styles', array( $this, 'enqueue_styles' ) );
|
|
76
71
|
add_filter( 'chisel_frontend_styles', array( $this, 'register_custom_styles' ) );
|
|
72
|
+
add_filter( 'woocommerce_template_loader_files', array( $this, 'woocommerce_template_loader_files' ), 99 );
|
|
77
73
|
}
|
|
78
74
|
|
|
79
75
|
/**
|
|
@@ -215,4 +211,17 @@ final class Woocommerce implements InstanceInterface, HooksInterface {
|
|
|
215
211
|
|
|
216
212
|
return $styles;
|
|
217
213
|
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Add custom woocommerce template loader files. Lets us override default templates.
|
|
217
|
+
*
|
|
218
|
+
* @param array $files
|
|
219
|
+
*
|
|
220
|
+
* @return array
|
|
221
|
+
*/
|
|
222
|
+
public function woocommerce_template_loader_files( array $files ): array {
|
|
223
|
+
$files[] = 'custom/woocommerce.php';
|
|
224
|
+
|
|
225
|
+
return $files;
|
|
226
|
+
}
|
|
218
227
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Chisel\Plugins\Yoast;
|
|
4
|
+
|
|
5
|
+
use Chisel\Traits\HooksSingleton;
|
|
6
|
+
use Chisel\Helpers\YoastHelpers;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Yoast SEO plugin related functionalities.
|
|
10
|
+
*
|
|
11
|
+
* @package Chisel
|
|
12
|
+
*/
|
|
13
|
+
final class Yoast {
|
|
14
|
+
|
|
15
|
+
use HooksSingleton;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Initialize.
|
|
19
|
+
*/
|
|
20
|
+
public function init(): bool {
|
|
21
|
+
if ( ! YoastHelpers::is_yoast_active() ) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Register action hooks.
|
|
30
|
+
*/
|
|
31
|
+
public function action_hooks(): void {}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Register filter hooks.
|
|
35
|
+
*/
|
|
36
|
+
public function filter_hooks(): void {}
|
|
37
|
+
}
|
package/lib/commands/create/creators/app/chisel-starter-theme/{inc/WP → core/Timber}/Cache.php
RENAMED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
|
|
3
|
-
namespace Chisel\
|
|
3
|
+
namespace Chisel\Timber;
|
|
4
4
|
|
|
5
5
|
use Timber\Loader;
|
|
6
6
|
|
|
7
|
-
use Chisel\
|
|
8
|
-
use Chisel\Interfaces\HooksInterface;
|
|
9
|
-
use Chisel\Traits\Singleton;
|
|
7
|
+
use Chisel\Traits\HooksSingleton;
|
|
10
8
|
use Chisel\Helpers\ThemeHelpers;
|
|
11
9
|
|
|
12
10
|
/**
|
|
@@ -14,9 +12,9 @@ use Chisel\Helpers\ThemeHelpers;
|
|
|
14
12
|
*
|
|
15
13
|
* @package Chisel
|
|
16
14
|
*/
|
|
17
|
-
final class Cache
|
|
15
|
+
final class Cache {
|
|
18
16
|
|
|
19
|
-
use
|
|
17
|
+
use HooksSingleton;
|
|
20
18
|
|
|
21
19
|
/**
|
|
22
20
|
* Cache expiry time.
|
|
@@ -39,16 +37,6 @@ final class Cache implements InstanceInterface, HooksInterface {
|
|
|
39
37
|
*/
|
|
40
38
|
private bool $environment_cache = false;
|
|
41
39
|
|
|
42
|
-
/**
|
|
43
|
-
* Class constructor.
|
|
44
|
-
*/
|
|
45
|
-
private function __construct() {
|
|
46
|
-
add_action( 'after_setup_theme', array( $this, 'set_properties' ), 7 );
|
|
47
|
-
|
|
48
|
-
$this->action_hooks();
|
|
49
|
-
$this->filter_hooks();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
40
|
/**
|
|
53
41
|
* Set properties.
|
|
54
42
|
*/
|
|
@@ -80,7 +68,7 @@ final class Cache implements InstanceInterface, HooksInterface {
|
|
|
80
68
|
*/
|
|
81
69
|
public function cache_mode( string $cache_mode ): string {
|
|
82
70
|
// Available cache modes: 'CACHE_NONE', 'CACHE_OBJECT' (WP Object Cache), 'CACHE_TRANSIENT', 'CACHE_SITE_TRANSIENT', 'CACHE_USE_DEFAULT'.
|
|
83
|
-
$cache_mode = Loader::
|
|
71
|
+
$cache_mode = Loader::CACHE_NONE;
|
|
84
72
|
|
|
85
73
|
return $cache_mode;
|
|
86
74
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Chisel\Traits;
|
|
4
|
+
|
|
5
|
+
trait Hooks {
|
|
6
|
+
/**
|
|
7
|
+
* Register action hooks.
|
|
8
|
+
*/
|
|
9
|
+
abstract public function action_hooks(): void;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Register filter hooks.
|
|
13
|
+
*/
|
|
14
|
+
abstract public function filter_hooks(): void;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Boot hooks.
|
|
18
|
+
*/
|
|
19
|
+
public function boot(): void {
|
|
20
|
+
if ( method_exists( $this, 'init' ) ) {
|
|
21
|
+
if ( $this->init() === false ) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
$this->action_hooks();
|
|
27
|
+
$this->filter_hooks();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Chisel\Traits;
|
|
4
|
+
|
|
5
|
+
use Chisel\Traits\Singleton;
|
|
6
|
+
use Chisel\Traits\Hooks;
|
|
7
|
+
|
|
8
|
+
trait HooksSingleton {
|
|
9
|
+
use Singleton;
|
|
10
|
+
use Hooks;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Properties hook.
|
|
14
|
+
*
|
|
15
|
+
* @var array
|
|
16
|
+
*/
|
|
17
|
+
protected function properties_hook(): array {
|
|
18
|
+
return array(
|
|
19
|
+
'action' => 'after_setup_theme',
|
|
20
|
+
'priority' => 7,
|
|
21
|
+
'args' => 1,
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Should call parent constructor.
|
|
27
|
+
*
|
|
28
|
+
* @return bool
|
|
29
|
+
*/
|
|
30
|
+
protected function should_call_parent_construct(): bool {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Class constructor - boot the class.
|
|
36
|
+
*/
|
|
37
|
+
protected function __construct() {
|
|
38
|
+
if ( $this->should_call_parent_construct() ) {
|
|
39
|
+
parent::__construct();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if ( method_exists( $this, 'set_properties' ) ) {
|
|
43
|
+
$properties_hook = $this->properties_hook();
|
|
44
|
+
add_action(
|
|
45
|
+
$properties_hook['action'],
|
|
46
|
+
array( $this, 'set_properties' ),
|
|
47
|
+
$properties_hook['priority'],
|
|
48
|
+
$properties_hook['args']
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
$this->boot();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Chisel\Traits;
|
|
4
|
+
|
|
5
|
+
trait Rest {
|
|
6
|
+
/**
|
|
7
|
+
* Get data from request.
|
|
8
|
+
*
|
|
9
|
+
* @param \WP_REST_Request $request WP_REST_Request.
|
|
10
|
+
*
|
|
11
|
+
* @return array
|
|
12
|
+
*/
|
|
13
|
+
private function get_data( \WP_REST_Request $request ): array {
|
|
14
|
+
return $request->get_body_params();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* This function will return a success response.
|
|
19
|
+
*
|
|
20
|
+
* @param mixed $data
|
|
21
|
+
*
|
|
22
|
+
* @return \WP_REST_Response
|
|
23
|
+
*/
|
|
24
|
+
private function success( mixed $data = array() ): \WP_REST_Response {
|
|
25
|
+
return new \WP_REST_Response(
|
|
26
|
+
array(
|
|
27
|
+
'error' => 0,
|
|
28
|
+
'message' => 'ok',
|
|
29
|
+
'data' => $data,
|
|
30
|
+
),
|
|
31
|
+
200
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* This function will return an error response.
|
|
37
|
+
*
|
|
38
|
+
* @param string $message
|
|
39
|
+
*
|
|
40
|
+
* @return \WP_REST_Response
|
|
41
|
+
*/
|
|
42
|
+
private function error( string $message ): \WP_REST_Response {
|
|
43
|
+
return new \WP_REST_Response(
|
|
44
|
+
array(
|
|
45
|
+
'error' => 1,
|
|
46
|
+
'message' => $message,
|
|
47
|
+
),
|
|
48
|
+
200
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
package/lib/commands/create/creators/app/chisel-starter-theme/{inc → core}/Traits/Singleton.php
RENAMED
|
@@ -4,29 +4,31 @@ namespace Chisel\Traits;
|
|
|
4
4
|
|
|
5
5
|
trait Singleton {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Instances of classes using this trait, keyed by class name.
|
|
8
8
|
*
|
|
9
|
-
* @var
|
|
9
|
+
* @var array<string, static>
|
|
10
10
|
*/
|
|
11
|
-
private static
|
|
11
|
+
private static array $instances = array();
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Get the instance of the class using the singleton.
|
|
15
15
|
*
|
|
16
|
-
* @return
|
|
16
|
+
* @return static
|
|
17
17
|
*/
|
|
18
18
|
public static function get_instance(): static {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
$class = static::class;
|
|
20
|
+
|
|
21
|
+
if ( ! isset( self::$instances[ $class ] ) ) {
|
|
22
|
+
self::$instances[ $class ] = new static();
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
return
|
|
25
|
+
return self::$instances[ $class ];
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
/**
|
|
27
29
|
* Prevent direct construction; let get_instance() control instantiation.
|
|
28
30
|
*/
|
|
29
|
-
|
|
31
|
+
protected function __construct() {}
|
|
30
32
|
|
|
31
33
|
/**
|
|
32
34
|
* Prevent cloning.
|