generator-chisel 2.0.0-alpha.9 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/bin/chisel.js +6 -0
- package/lib/commands/create/Creator.js +6 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/.gitignore.chisel-tpl +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/.nvmrc +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/404.php +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/README.md +37 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/acf-json/group_6772609e3c28c.json +83 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/acf-json/group_6772615562fb4.json +49 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/archive.php +2 -4
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/block.json +31 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/edit.js +35 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/editor.scss +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/index.js +45 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/save.js +20 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/script.js +7 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/style.scss +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/view.js +7 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example/view.scss +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/block.json +32 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/edit.js +33 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/editor.scss +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/index.js +45 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/render.php +12 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/render.twig +5 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/save.js +6 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/script.js +7 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/style.scss +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/view.js +7 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks/example-server-side/view.scss +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/block.json +36 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/critical.scss +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/editor.scss +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/example.twig +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/index.js +7 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/init.php +0 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/script.js +8 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/style.scss +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/view.js +7 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/example-blocks/blocks-acf/example/view.scss +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/arrow-left.svg +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/arrow-right.svg +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/chisel-icon.svg +1 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/chisel-logo.svg +1 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/close-line.svg +1 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/color/chisel-icon.svg +1 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/color/chisel-logo.svg +1 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/color/facebook-logo.svg +10 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/color/instagram-logo.svg +14 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons-source/x-logo.svg +1 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/author.php +3 -4
- package/lib/commands/create/creators/app/chisel-starter-theme/composer.json +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/footer.php +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/functions.php +18 -24
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Factory/RegisterAcfOptionsPage.php +62 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/Factory}/RegisterBlocks.php +53 -22
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Factory/RegisterCustomPostType.php +211 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Factory/RegisterCustomTaxonomy.php +174 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/AcfHelpers.php +46 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/AjaxHelpers.php +33 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/AssetsHelpers.php +28 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/BlocksHelpers.php +118 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/CacheHelpers.php +41 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/CommentsHelpers.php +26 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/DataHelpers.php +35 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/GravityFormsHelpers.php +65 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/ImageHelpers.php +102 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/{classes/Helpers.php → inc/Helper/ThemeHelpers.php} +53 -93
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/WoocommerceHelpers.php +72 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/YoastHelpers.php +37 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/{classes/interfaces/Instance.php → inc/Interfaces/HooksInterface.php} +3 -8
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Interfaces/InstanceInterface.php +16 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/Module}/AcfSync.php +13 -20
- package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/Module}/Ajax.php +16 -41
- package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/Plugin}/GravityForms.php +15 -72
- package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/Plugin}/Woocommerce.php +26 -80
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Plugin/Yoast.php +46 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Traits/PageBlocks.php +92 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Traits/Singleton.php +23 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Acf.php +118 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/AcfBlocks.php +62 -61
- package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/AjaxEnpoints.php +6 -6
- package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Assets.php +258 -119
- package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Blocks.php +63 -51
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Cache.php +103 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/{classes/ExtendedImage.php → inc/WP/ChiselImage.php} +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/{classes/ExtendedPost.php → inc/WP/ChiselPost.php} +4 -3
- package/lib/commands/create/creators/app/chisel-starter-theme/{classes/ExtendedProduct.php → inc/WP/ChiselProduct.php} +4 -3
- package/lib/commands/create/creators/app/chisel-starter-theme/{classes/ExtendedTerm.php → inc/WP/ChiselTerm.php} +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Comments.php +10 -32
- package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Components.php +61 -36
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/CustomPostTypes.php +124 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/CustomTaxonomies.php +129 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Sidebars.php +11 -17
- package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Site.php +15 -21
- package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Theme.php +22 -15
- package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Twig.php +34 -21
- package/lib/commands/create/creators/app/chisel-starter-theme/index.php +2 -3
- package/lib/commands/create/creators/app/chisel-starter-theme/package.chisel-tpl.json +5 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/page.php +3 -3
- package/lib/commands/create/creators/app/chisel-starter-theme/phpcs.xml +5 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/search.php +3 -4
- package/lib/commands/create/creators/app/chisel-starter-theme/single.php +3 -3
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks/accordion/accordion-item.js +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks/accordion/style.scss +12 -5
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks-acf/slider/acf-json/group_66462c70b851f.json +107 -105
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks-acf/slider/block.json +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks-acf/slider/slider.twig +4 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/settings/_index.scss +2 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_buttons.scss +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_icon.scss +39 -7
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_index.scss +1 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_layout.scss +11 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/admin/acf.js +65 -1
- 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.js +10 -4
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/mods/core-button.js +13 -9
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/utils.js +0 -12
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/modules/loaded.js +7 -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 +14 -13
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_buttons.scss +14 -13
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_icons-preview.scss +97 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_main-nav.scss +19 -9
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_posts-items.scss +6 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/objects/_icon.scss +51 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/objects/_layout.scss +0 -13
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/wp-admin/_acf.scss +29 -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/style.chisel-tpl.css +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/views/base.twig +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/header.twig +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/views/{partials → components}/logo.twig +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/main-nav-item.twig +2 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/main-nav.twig +5 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/pagination.twig +70 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/slider.twig +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/views/{partials → components}/the-title.twig +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/views/index.twig +10 -5
- package/lib/commands/create/creators/app/chisel-starter-theme/views/objects/icon.twig +37 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/partials/icons-preview.twig +81 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/sidebar-blog.twig +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/views/sidebar-woocommerce.twig +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/views/single.twig +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/views/woocommerce/archive-product.twig +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/views/woocommerce/linked-products.twig +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/views/woocommerce/single-product.twig +4 -4
- package/lib/commands/create/creators/app/chisel-starter-theme/woocommerce.php +6 -6
- package/lib/commands/create/creators/app/index.js +74 -20
- package/lib/commands/create/creators/app/template/.devcontainer/Dockerfile +21 -0
- package/lib/commands/create/creators/app/template/.devcontainer/compose.chisel-tpl +3 -0
- package/lib/commands/create/creators/app/template/.devcontainer/devcontainer.json.chisel-tpl +31 -0
- package/lib/commands/create/creators/app/template/.devcontainer/docker-compose.yml.chisel-tpl +40 -0
- package/lib/commands/create/creators/app/template/.devcontainer/exec +8 -0
- package/lib/commands/create/creators/app/template/.devcontainer/post-create-command.sh.chisel-tpl +24 -0
- package/lib/commands/create/creators/devcontainer.js +62 -0
- package/lib/commands/create/creators/utils.js +58 -0
- package/lib/commands/create/creators/wp/index.js +24 -3
- package/lib/commands/create/creators/wp-plugins/plugins.json +1 -1
- package/lib/commands/create/index.js +9 -2
- package/lib/commands/create/packages-versions.js +3 -3
- package/package.json +3 -3
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Acf.php +0 -188
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/ChiselCache.php +0 -87
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/CustomPostTypes.php +0 -444
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Yoast.php +0 -78
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_icon.scss +0 -19
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/icon.twig +0 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/views/partials/pagination.twig +0 -70
- /package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons/{loader.svg → animated/loader.svg} +0 -0
- /package/lib/commands/create/creators/app/chisel-starter-theme/assets/{icons → icons-source}/minus.svg +0 -0
- /package/lib/commands/create/creators/app/chisel-starter-theme/assets/{icons → icons-source}/plus.svg +0 -0
|
@@ -1,22 +1,47 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
|
|
3
|
-
namespace Chisel;
|
|
3
|
+
namespace Chisel\WP;
|
|
4
4
|
|
|
5
5
|
use Timber\Timber;
|
|
6
6
|
|
|
7
|
+
use Chisel\Interfaces\InstanceInterface;
|
|
8
|
+
use Chisel\Interfaces\HooksInterface;
|
|
9
|
+
use Chisel\Traits\Singleton;
|
|
10
|
+
use Chisel\Factory\RegisterBlocks;
|
|
11
|
+
use Chisel\Helper\BlocksHelpers;
|
|
12
|
+
use Chisel\Helper\ThemeHelpers;
|
|
13
|
+
use Chisel\Traits\PageBlocks;
|
|
14
|
+
|
|
7
15
|
/**
|
|
8
16
|
* Blocks related functionalities.
|
|
9
17
|
*
|
|
10
18
|
* @package Chisel
|
|
11
19
|
*/
|
|
12
|
-
class Blocks
|
|
20
|
+
class Blocks implements InstanceInterface, HooksInterface {
|
|
21
|
+
|
|
22
|
+
use Singleton;
|
|
23
|
+
use PageBlocks;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Register blocks factory.
|
|
27
|
+
*
|
|
28
|
+
* @var RegisterBlocks
|
|
29
|
+
*/
|
|
30
|
+
private $register_blocks_factory;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Blocks.
|
|
34
|
+
*
|
|
35
|
+
* @var array
|
|
36
|
+
*/
|
|
37
|
+
private $blocks = array();
|
|
13
38
|
|
|
14
39
|
/**
|
|
15
40
|
* Chisel blocks category.
|
|
16
41
|
*
|
|
17
42
|
* @var string
|
|
18
43
|
*/
|
|
19
|
-
|
|
44
|
+
private $blocks_category;
|
|
20
45
|
|
|
21
46
|
|
|
22
47
|
/**
|
|
@@ -24,22 +49,23 @@ class Blocks extends RegisterBlocks implements Instance {
|
|
|
24
49
|
*
|
|
25
50
|
* @var array
|
|
26
51
|
*/
|
|
27
|
-
|
|
52
|
+
private $block_patterns_categories = array();
|
|
28
53
|
|
|
29
54
|
/**
|
|
30
55
|
* Blocks twig file base path.
|
|
31
56
|
*
|
|
32
57
|
* @var string
|
|
33
58
|
*/
|
|
34
|
-
|
|
59
|
+
private $blocks_twig_base_path = 'build/blocks/';
|
|
35
60
|
|
|
36
61
|
/**
|
|
37
62
|
* Class constructor.
|
|
38
63
|
*/
|
|
39
64
|
private function __construct() {
|
|
40
|
-
$this->
|
|
65
|
+
$this->register_blocks_factory = new RegisterBlocks( 'wp' );
|
|
66
|
+
$this->blocks = $this->register_blocks_factory->get_blocks();
|
|
41
67
|
|
|
42
|
-
|
|
68
|
+
add_action( 'after_setup_theme', array( $this, 'set_properties' ), 7 );
|
|
43
69
|
|
|
44
70
|
$this->action_hooks();
|
|
45
71
|
$this->filter_hooks();
|
|
@@ -65,6 +91,7 @@ class Blocks extends RegisterBlocks implements Instance {
|
|
|
65
91
|
add_action( 'init', array( $this, 'register_blocks' ) );
|
|
66
92
|
add_action( 'after_setup_theme', array( $this, 'blocks_theme_supports' ) );
|
|
67
93
|
add_action( 'init', array( $this, 'register_block_patterns_categories' ) );
|
|
94
|
+
add_action( 'wp_print_styles', array( $this, 'dequeue_blocks_styles' ), 999 );
|
|
68
95
|
}
|
|
69
96
|
|
|
70
97
|
/**
|
|
@@ -84,7 +111,7 @@ class Blocks extends RegisterBlocks implements Instance {
|
|
|
84
111
|
* Register blocks and their assets.
|
|
85
112
|
*/
|
|
86
113
|
public function register_blocks() {
|
|
87
|
-
$this->register_custom_blocks();
|
|
114
|
+
$this->register_blocks_factory->register_custom_blocks();
|
|
88
115
|
}
|
|
89
116
|
|
|
90
117
|
/**
|
|
@@ -119,7 +146,7 @@ class Blocks extends RegisterBlocks implements Instance {
|
|
|
119
146
|
$categories,
|
|
120
147
|
array(
|
|
121
148
|
'slug' => $this->blocks_category,
|
|
122
|
-
'title' =>
|
|
149
|
+
'title' => sprintf( '%s %s', ThemeHelpers::get_theme_name(), esc_html__( 'Blocks', 'chisel' ) ),
|
|
123
150
|
'icon' => '<svg width="44" height="44" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44.16 44.16"><path d="M22.08,0a22,22,0,0,0-12,3.55.83.83,0,0,0-.25,1.16A.84.84,0,0,0,11,5,20.41,20.41,0,1,1,8.37,7,.84.84,0,1,0,7.23,5.74,22.08,22.08,0,1,0,22.08,0Zm15,12.07a.84.84,0,1,0-1.4.93,16.3,16.3,0,1,1-2.16-2.61.84.84,0,0,0,1.19,0,.85.85,0,0,0,0-1.19,18.14,18.14,0,1,0,2.38,2.88Zm-15-2.86a12.83,12.83,0,0,0-7.65,2.52.85.85,0,0,0-.17,1.18.84.84,0,0,0,1.18.18A11.18,11.18,0,1,1,24.8,32.93.84.84,0,0,0,25,34.59l.2,0A12.87,12.87,0,0,0,22.08,9.21ZM15,30.74A11.19,11.19,0,0,1,13,15.62a.84.84,0,1,0-1.37-1,12.86,12.86,0,0,0,2.36,17.4.84.84,0,0,0,.53.19.86.86,0,0,0,.66-.31A.85.85,0,0,0,15,30.74Z" fill="#2a1468"></path><path d="M28.49,25.69a.85.85,0,0,0-1.18.19,6.46,6.46,0,1,1-1.43-9,.84.84,0,1,0,1-1.36,8.15,8.15,0,1,0,1.8,11.38A.85.85,0,0,0,28.49,25.69Zm-6.41-7a3.43,3.43,0,1,0,3.43,3.43A3.44,3.44,0,0,0,22.08,18.65Zm0,5.17a1.74,1.74,0,1,1,1.74-1.74A1.74,1.74,0,0,1,22.08,23.82Z" fill="#ff6d54"></path></svg>',
|
|
124
151
|
)
|
|
125
152
|
);
|
|
@@ -139,7 +166,7 @@ class Blocks extends RegisterBlocks implements Instance {
|
|
|
139
166
|
}
|
|
140
167
|
|
|
141
168
|
foreach ( $this->block_patterns_categories as $slug => $category ) {
|
|
142
|
-
$category['label'] = '[
|
|
169
|
+
$category['label'] = sprintf( '[%s] %s', ThemeHelpers::get_theme_name(), esc_attr( $category['label'] ) );
|
|
143
170
|
register_block_pattern_category( 'chisel-patterns/' . $slug, $category );
|
|
144
171
|
}
|
|
145
172
|
}
|
|
@@ -156,7 +183,7 @@ class Blocks extends RegisterBlocks implements Instance {
|
|
|
156
183
|
}
|
|
157
184
|
|
|
158
185
|
foreach ( $this->blocks as $block ) {
|
|
159
|
-
$locations[] = array( $this->
|
|
186
|
+
$locations[] = array( $this->register_blocks_factory->get_blocks_path_src() . '/' . $block . '/' );
|
|
160
187
|
}
|
|
161
188
|
|
|
162
189
|
return $locations;
|
|
@@ -176,14 +203,14 @@ class Blocks extends RegisterBlocks implements Instance {
|
|
|
176
203
|
return $block_content;
|
|
177
204
|
}
|
|
178
205
|
|
|
179
|
-
$custom_classnames =
|
|
206
|
+
$custom_classnames = BlocksHelpers::get_block_object_classnames( $block['blockName'] );
|
|
180
207
|
|
|
181
208
|
if ( empty( $custom_classnames ) ) {
|
|
182
209
|
return $block_content;
|
|
183
210
|
}
|
|
184
211
|
|
|
185
212
|
$block_content = preg_replace( '/<([^>]+) class="([^"]+)">/', '<$1 class="$2 ' . $custom_classnames . '">', $block_content, 1 );
|
|
186
|
-
$block_content = preg_replace( '/class="([^"]*) is-layout-flow ([^"]*)"/', 'class="$1 $
|
|
213
|
+
$block_content = preg_replace( '/class="([^"]*) (is-layout-flow|is-layout-constrained) ([^"]*)"/', 'class="$1 $3"', $block_content ); // It overwrites margin styles. Let's get rid of it.
|
|
187
214
|
|
|
188
215
|
if ( $block['blockName'] === 'core/table' ) {
|
|
189
216
|
$block_content = preg_replace( '/<([^>]+) class="([^"]+)">/', '<$1 class="$2 u-table-responsive">', $block_content, 1 );
|
|
@@ -234,52 +261,37 @@ class Blocks extends RegisterBlocks implements Instance {
|
|
|
234
261
|
}
|
|
235
262
|
|
|
236
263
|
/**
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
* @param string $block_name
|
|
264
|
+
* Dequeue blocks styles that are not used on current page and add inline critical css for blocks.
|
|
240
265
|
*
|
|
241
|
-
* @return
|
|
266
|
+
* @return void
|
|
242
267
|
*/
|
|
243
|
-
public
|
|
244
|
-
if (
|
|
245
|
-
return
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
$block_name_parts = explode( '/', $block_name );
|
|
249
|
-
|
|
250
|
-
if ( empty( $block_name_parts ) || ! isset( $block_name_parts[1] ) ) {
|
|
251
|
-
return '';
|
|
268
|
+
public function dequeue_blocks_styles() {
|
|
269
|
+
if ( is_admin() ) {
|
|
270
|
+
return;
|
|
252
271
|
}
|
|
253
272
|
|
|
254
|
-
|
|
255
|
-
|
|
273
|
+
$blocks_used_on_page = $this->get_content_blocks_names();
|
|
274
|
+
$blocks = $this->blocks;
|
|
256
275
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
* @param string $block_name
|
|
261
|
-
* @param array $context
|
|
262
|
-
*
|
|
263
|
-
* @return void
|
|
264
|
-
*/
|
|
265
|
-
public static function render_twig_file( $block_name, $context ) {
|
|
266
|
-
$block_name = explode( '/', $block_name );
|
|
267
|
-
$block_name = end( $block_name );
|
|
276
|
+
if ( $blocks ) {
|
|
277
|
+
$blocks_path = $this->register_blocks_factory->get_blocks_path();
|
|
278
|
+
$blocks_url = $this->register_blocks_factory->get_blocks_url();
|
|
268
279
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
280
|
+
foreach ( $blocks as $block_name ) {
|
|
281
|
+
if ( ! in_array( $block_name, $blocks_used_on_page, true ) ) {
|
|
282
|
+
wp_dequeue_style( 'block-wp-' . $block_name . '-style' );
|
|
283
|
+
} else {
|
|
284
|
+
$block_critical_css = $blocks_path . '/' . $block_name . '/script.css';
|
|
272
285
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
*/
|
|
276
|
-
public static function get_instance() {
|
|
277
|
-
static $instance = null;
|
|
286
|
+
if ( is_file( $block_critical_css ) ) {
|
|
287
|
+
$css = BlocksHelpers::get_block_inline_css( $blocks_url, $block_name );
|
|
278
288
|
|
|
279
|
-
|
|
280
|
-
|
|
289
|
+
if ( $css ) {
|
|
290
|
+
$add = wp_add_inline_style( AssetsHelpers::get_final_handle( 'main' ), $css );
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
281
295
|
}
|
|
282
|
-
|
|
283
|
-
return $instance;
|
|
284
296
|
}
|
|
285
297
|
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Chisel\WP;
|
|
4
|
+
|
|
5
|
+
use Timber\Loader;
|
|
6
|
+
|
|
7
|
+
use Chisel\Interfaces\InstanceInterface;
|
|
8
|
+
use Chisel\Interfaces\HooksInterface;
|
|
9
|
+
use Chisel\Traits\Singleton;
|
|
10
|
+
use Chisel\Helper\ThemeHelpers;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Cache related functionalities.
|
|
14
|
+
*
|
|
15
|
+
* @package Chisel
|
|
16
|
+
*/
|
|
17
|
+
class Cache implements InstanceInterface, HooksInterface {
|
|
18
|
+
|
|
19
|
+
use Singleton;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Cache expiry time.
|
|
23
|
+
*
|
|
24
|
+
* @var int
|
|
25
|
+
*/
|
|
26
|
+
public $cache_expiry = HOUR_IN_SECONDS;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Cache everything mode. The whole template you render and its data will be cached.
|
|
30
|
+
*
|
|
31
|
+
* @var int
|
|
32
|
+
*/
|
|
33
|
+
public $cache_everything = false;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Environment cache.
|
|
37
|
+
*
|
|
38
|
+
* @var int
|
|
39
|
+
*/
|
|
40
|
+
private $environment_cache = true;
|
|
41
|
+
|
|
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
|
+
/**
|
|
53
|
+
* Set properties.
|
|
54
|
+
*/
|
|
55
|
+
public function set_properties() {
|
|
56
|
+
$this->cache_expiry = apply_filters( 'chisel_cache_expiry', $this->cache_expiry );
|
|
57
|
+
$this->cache_everything = apply_filters( 'chisel_cache_everything', $this->cache_everything );
|
|
58
|
+
$this->environment_cache = apply_filters( 'chisel_environment_cache', $this->environment_cache );
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Register action hooks.
|
|
63
|
+
*/
|
|
64
|
+
public function action_hooks() {
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Register filter hooks.
|
|
69
|
+
*/
|
|
70
|
+
public function filter_hooks() {
|
|
71
|
+
add_filter( 'timber/cache/mode', array( $this, 'cache_mode' ) );
|
|
72
|
+
add_filter( 'timber/twig/environment/options', array( $this, 'environment_cache' ) );
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Set Timber cache mode for cache everything mode.
|
|
77
|
+
*
|
|
78
|
+
* @param string $cache_mode The cache mode.
|
|
79
|
+
*
|
|
80
|
+
* @return string
|
|
81
|
+
*/
|
|
82
|
+
public function cache_mode( $cache_mode ) {
|
|
83
|
+
// Available cache modes: 'CACHE_NONE', 'CACHE_OBJECT' (WP Object Cache), 'CACHE_TRANSIENT', 'CACHE_SITE_TRANSIENT', 'CACHE_USE_DEFAULT'.
|
|
84
|
+
$cache_mode = Loader::CACHE_USE_DEFAULT;
|
|
85
|
+
|
|
86
|
+
return $cache_mode;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Set Timber environment cache. Uses twig cache. Caches the twig file, but not the data. In order for the cache to work WP_DEBUG must be set to false.
|
|
91
|
+
*
|
|
92
|
+
* @param array $options
|
|
93
|
+
*
|
|
94
|
+
* @return array
|
|
95
|
+
*/
|
|
96
|
+
public function environment_cache( $options ) {
|
|
97
|
+
$options['cache'] = $this->environment_cache;
|
|
98
|
+
$options['auto_reload'] = ThemeHelpers::is_dev_env();
|
|
99
|
+
$options['debug'] = ThemeHelpers::is_dev_env();
|
|
100
|
+
|
|
101
|
+
return $options;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
|
|
3
|
-
namespace Chisel;
|
|
3
|
+
namespace Chisel\WP;
|
|
4
4
|
|
|
5
5
|
use Timber\Image as TimberImage;
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ use Timber\Image as TimberImage;
|
|
|
9
9
|
*
|
|
10
10
|
* @package Chisel
|
|
11
11
|
*/
|
|
12
|
-
class
|
|
12
|
+
class ChiselImage extends TimberImage {
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Get responsive image html
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
|
|
3
|
-
namespace Chisel;
|
|
3
|
+
namespace Chisel\WP;
|
|
4
4
|
|
|
5
5
|
use Timber\Post as TimberPost;
|
|
6
6
|
use Timber\Timber;
|
|
7
|
+
use Chisel\Helper\ImageHelpers;
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Extend Timber Post class with custom functionality.
|
|
10
11
|
*
|
|
11
12
|
* @package Chisel
|
|
12
13
|
*/
|
|
13
|
-
class
|
|
14
|
+
class ChiselPost extends TimberPost {
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Post thumbnail.
|
|
@@ -27,7 +28,7 @@ class ExtendedPost extends TimberPost {
|
|
|
27
28
|
*/
|
|
28
29
|
public function get_thumbnail( $size = 'medium' ) {
|
|
29
30
|
if ( ! $this->thumbnail_html ) {
|
|
30
|
-
$this->thumbnail_html = has_post_thumbnail( $this->ID ) ?
|
|
31
|
+
$this->thumbnail_html = has_post_thumbnail( $this->ID ) ? ImageHelpers::get_responsive_image( get_post_thumbnail_id( $this->ID ), $size ) : '';
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
return $this->thumbnail_html;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
|
|
3
|
-
namespace Chisel;
|
|
3
|
+
namespace Chisel\WP;
|
|
4
4
|
|
|
5
5
|
use Timber\Post as TimberPost;
|
|
6
6
|
use Timber\Timber;
|
|
7
|
+
use Chisel\Helper\ImageHelpers;
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Extend Timber Post class with custom functionality. This is a woocommerce product class.
|
|
10
11
|
*
|
|
11
12
|
* @package Chisel
|
|
12
13
|
*/
|
|
13
|
-
class
|
|
14
|
+
class ChiselProduct extends TimberPost {
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Product thumbnail.
|
|
@@ -27,7 +28,7 @@ class ExtendedProduct extends TimberPost {
|
|
|
27
28
|
*/
|
|
28
29
|
public function get_thumbnail( $size = 'woocommerce_thumbnail' ) {
|
|
29
30
|
if ( ! $this->thumbnail_html ) {
|
|
30
|
-
$thumbnail_html = has_post_thumbnail( $this->ID ) ?
|
|
31
|
+
$thumbnail_html = has_post_thumbnail( $this->ID ) ? ImageHelpers::get_responsive_image( get_post_thumbnail_id( $this->ID ), $size ) : '';
|
|
31
32
|
|
|
32
33
|
if ( ! $thumbnail_html ) {
|
|
33
34
|
$thumbnail_html = wc_placeholder_img( $size );
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
|
|
3
|
-
namespace Chisel;
|
|
3
|
+
namespace Chisel\WP;
|
|
4
4
|
|
|
5
5
|
use Timber\Term as TimberTerm;
|
|
6
6
|
|
|
@@ -9,5 +9,5 @@ use Timber\Term as TimberTerm;
|
|
|
9
9
|
*
|
|
10
10
|
* @package Chisel
|
|
11
11
|
*/
|
|
12
|
-
class
|
|
12
|
+
class ChiselTerm extends TimberTerm {
|
|
13
13
|
}
|
package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Comments.php
RENAMED
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
|
|
3
|
-
namespace Chisel;
|
|
3
|
+
namespace Chisel\WP;
|
|
4
|
+
|
|
5
|
+
use Chisel\Interfaces\InstanceInterface;
|
|
6
|
+
use Chisel\Interfaces\HooksInterface;
|
|
7
|
+
use Chisel\Traits\Singleton;
|
|
4
8
|
|
|
5
9
|
/**
|
|
6
10
|
* Comments related functionalities.
|
|
7
11
|
*
|
|
8
12
|
* @package Chisel
|
|
9
13
|
*/
|
|
10
|
-
class Comments implements
|
|
14
|
+
class Comments implements InstanceInterface, HooksInterface {
|
|
15
|
+
|
|
16
|
+
use Singleton;
|
|
11
17
|
|
|
12
18
|
/**
|
|
13
19
|
* Disable comments
|
|
14
20
|
*
|
|
15
21
|
* @var bool
|
|
16
22
|
*/
|
|
17
|
-
|
|
23
|
+
private $disable_comments;
|
|
18
24
|
|
|
19
25
|
/**
|
|
20
26
|
* Post types for which comments are disabled.
|
|
21
27
|
*
|
|
22
28
|
* @var array
|
|
23
29
|
*/
|
|
24
|
-
|
|
30
|
+
private $post_types = array(
|
|
25
31
|
'post',
|
|
26
32
|
'page',
|
|
27
33
|
);
|
|
@@ -294,32 +300,4 @@ class Comments implements Instance {
|
|
|
294
300
|
|
|
295
301
|
return $headers;
|
|
296
302
|
}
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Display comments template - the comments and the form.
|
|
300
|
-
*
|
|
301
|
-
* @return void
|
|
302
|
-
*/
|
|
303
|
-
public static function comments_template() {
|
|
304
|
-
if ( ! post_type_supports( get_post_type(), 'comments' ) ) {
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
if ( comments_open() ) {
|
|
309
|
-
return apply_filters( 'the_content', '<!-- wp:pattern {"slug":"chisel/comments"} /-->' );
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* Get the instance of the class.
|
|
315
|
-
*/
|
|
316
|
-
public static function get_instance() {
|
|
317
|
-
static $instance = null;
|
|
318
|
-
|
|
319
|
-
if ( null === $instance ) {
|
|
320
|
-
$instance = new self();
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
return $instance;
|
|
324
|
-
}
|
|
325
303
|
}
|
package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/WP}/Components.php
RENAMED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
|
|
3
|
-
namespace Chisel;
|
|
3
|
+
namespace Chisel\WP;
|
|
4
4
|
|
|
5
5
|
use Timber\Timber;
|
|
6
|
-
use Chisel\
|
|
6
|
+
use Chisel\Helper\ImageHelpers;
|
|
7
|
+
use Chisel\Helper\AcfHelpers;
|
|
8
|
+
use Chisel\Helper\CacheHelpers;
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Use this class to get site components.
|
|
@@ -17,35 +19,42 @@ class Components {
|
|
|
17
19
|
*
|
|
18
20
|
* @var array
|
|
19
21
|
*/
|
|
20
|
-
|
|
22
|
+
private static $menus = array();
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
|
-
* The logo
|
|
25
|
+
* The logo.
|
|
24
26
|
*
|
|
25
|
-
* @var
|
|
27
|
+
* @var array
|
|
26
28
|
*/
|
|
27
|
-
|
|
29
|
+
private static $logo = array();
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
32
|
* The sidebar widgets.
|
|
31
33
|
*
|
|
32
34
|
* @var array
|
|
33
35
|
*/
|
|
34
|
-
|
|
36
|
+
private static $sidebar = array();
|
|
35
37
|
|
|
36
38
|
/**
|
|
37
39
|
* The footer sidebars.
|
|
38
40
|
*
|
|
39
41
|
* @var array
|
|
40
42
|
*/
|
|
41
|
-
|
|
43
|
+
private static $footer_sidebars = array();
|
|
42
44
|
|
|
43
45
|
/**
|
|
44
46
|
* The page / post title.
|
|
45
47
|
*
|
|
46
|
-
* @var
|
|
48
|
+
* @var array
|
|
49
|
+
*/
|
|
50
|
+
private static $the_title = array();
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The svg icons.
|
|
54
|
+
*
|
|
55
|
+
* @var array
|
|
47
56
|
*/
|
|
48
|
-
|
|
57
|
+
private static $icons = array();
|
|
49
58
|
|
|
50
59
|
/**
|
|
51
60
|
* Get the site nav menus.
|
|
@@ -80,23 +89,17 @@ class Components {
|
|
|
80
89
|
* @return string
|
|
81
90
|
*/
|
|
82
91
|
public static function get_logo() {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
$logo_id = get_theme_mod( 'custom_logo', 0 );
|
|
92
|
+
if ( self::$logo ) {
|
|
93
|
+
return self::$logo;
|
|
94
|
+
}
|
|
87
95
|
|
|
88
|
-
|
|
89
|
-
self::$logo_image = Helpers::get_responsive_image( $logo_id );
|
|
90
|
-
}
|
|
96
|
+
$logo_id = get_theme_mod( 'custom_logo', 0 );
|
|
91
97
|
|
|
92
|
-
|
|
98
|
+
if ( $logo_id ) {
|
|
99
|
+
self::$logo = ImageHelpers::get_responsive_image( $logo_id );
|
|
93
100
|
}
|
|
94
101
|
|
|
95
|
-
return
|
|
96
|
-
'partials/logo.twig',
|
|
97
|
-
$context,
|
|
98
|
-
ChiselCache::expiry( DAY_IN_SECONDS )
|
|
99
|
-
);
|
|
102
|
+
return self::$logo;
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
/**
|
|
@@ -174,23 +177,23 @@ class Components {
|
|
|
174
177
|
/**
|
|
175
178
|
* Get the current page title.
|
|
176
179
|
*
|
|
177
|
-
* @return
|
|
180
|
+
* @return array
|
|
178
181
|
*/
|
|
179
182
|
public static function get_the_title() {
|
|
183
|
+
if ( self::$the_title ) {
|
|
184
|
+
return self::$the_title;
|
|
185
|
+
}
|
|
186
|
+
|
|
180
187
|
$classname = 'c-title';
|
|
181
188
|
$the_title = array();
|
|
182
189
|
$title_text = '';
|
|
183
190
|
$title_class = '';
|
|
184
191
|
|
|
185
|
-
if ( self::$the_title !== null ) {
|
|
186
|
-
return self::$the_title;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
192
|
if ( is_singular() ) {
|
|
190
193
|
global $post;
|
|
191
194
|
|
|
192
195
|
if ( isset( $post->ID ) ) {
|
|
193
|
-
$display_title =
|
|
196
|
+
$display_title = AcfHelpers::get_field( 'page_title_display', $post->ID ) ?: 'show';
|
|
194
197
|
|
|
195
198
|
if ( $display_title !== 'hide' ) {
|
|
196
199
|
$title_text = get_the_title( $post->ID );
|
|
@@ -228,18 +231,40 @@ class Components {
|
|
|
228
231
|
}
|
|
229
232
|
|
|
230
233
|
if ( $title_text ) {
|
|
231
|
-
|
|
234
|
+
self::$the_title = array(
|
|
232
235
|
'text' => esc_html( $title_text ),
|
|
233
236
|
'class' => $title_class ? esc_attr( $title_class ) : $classname,
|
|
234
237
|
);
|
|
235
238
|
}
|
|
236
239
|
|
|
237
|
-
self::$the_title
|
|
240
|
+
return self::$the_title;
|
|
241
|
+
}
|
|
238
242
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
243
|
+
/**
|
|
244
|
+
* Get svg icon. The arguments are described in objects/icon.twig file
|
|
245
|
+
*
|
|
246
|
+
* @param array $args
|
|
247
|
+
*
|
|
248
|
+
* @return html
|
|
249
|
+
*/
|
|
250
|
+
public static function get_icon( $args ) {
|
|
251
|
+
$icon_slug = sanitize_title( $args['name'] );
|
|
252
|
+
|
|
253
|
+
$icon_key = '';
|
|
254
|
+
foreach ( $args as $key => $value ) {
|
|
255
|
+
if ( is_bool( $value ) ) {
|
|
256
|
+
$value = $value ? 'yes' : 'no';
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
$icon_key .= sanitize_title( $key . $value );
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if ( isset( self::$icons[$icon_key] ) ) {
|
|
263
|
+
return self::$icons[$icon_key];
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
self::$icons[$icon_key] = Timber::compile( 'objects/icon.twig', $args, CacheHelpers::expiry() );
|
|
267
|
+
|
|
268
|
+
return self::$icons[$icon_key];
|
|
244
269
|
}
|
|
245
270
|
}
|