generator-chisel 2.0.0-alpha.8 → 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 +57 -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 -2
- 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 +69 -55
- 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 -10
- 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/blocks-alignment.js +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/mods/core-button.js +18 -14
- 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/post-item.twig +1 -1
- 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
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Chisel\Helper;
|
|
4
|
+
|
|
5
|
+
use Timber\Timber;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Helper functions.
|
|
9
|
+
*
|
|
10
|
+
* @package Chisel
|
|
11
|
+
*/
|
|
12
|
+
class DataHelpers {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Json decode data for storing in html attribute
|
|
16
|
+
*
|
|
17
|
+
* @param array $data
|
|
18
|
+
*
|
|
19
|
+
* @return string
|
|
20
|
+
*/
|
|
21
|
+
public static function json_encode_for_data_attribute( $data ) {
|
|
22
|
+
return htmlspecialchars( wp_json_encode( $data ) );
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Convert an object to an array.
|
|
27
|
+
*
|
|
28
|
+
* @param object $object_to_convert
|
|
29
|
+
*
|
|
30
|
+
* @return array
|
|
31
|
+
*/
|
|
32
|
+
public static function object_to_array( $object_to_convert ) {
|
|
33
|
+
return json_decode( wp_json_encode( $object_to_convert ), true );
|
|
34
|
+
}
|
|
35
|
+
}
|
package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/GravityFormsHelpers.php
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Chisel\Helper;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Helper functions.
|
|
7
|
+
*
|
|
8
|
+
* @package Chisel
|
|
9
|
+
*/
|
|
10
|
+
class GravityFormsHelpers {
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Check if Gravity Forms plugin is active.
|
|
14
|
+
*
|
|
15
|
+
* @return bool
|
|
16
|
+
*/
|
|
17
|
+
public static function is_gf_active() {
|
|
18
|
+
return class_exists( '\GFForms' );
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get list of available Gravity Forms. Can be used in acf/load_field filter to populate the select field.
|
|
23
|
+
*
|
|
24
|
+
* @return array
|
|
25
|
+
*/
|
|
26
|
+
public static function get_forms_list() {
|
|
27
|
+
if ( ! class_exists( 'GFForms' ) ) {
|
|
28
|
+
return array();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
$forms = \GFAPI::get_forms();
|
|
32
|
+
|
|
33
|
+
$list = array();
|
|
34
|
+
|
|
35
|
+
if ( $forms ) {
|
|
36
|
+
foreach ( $forms as $form ) {
|
|
37
|
+
$list[$form['id']] = $form['title'];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return $list;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* This function will generate the gravity form for a given id with default parameters. Use if you need to generate ajax fomr outside of blocks.
|
|
46
|
+
*
|
|
47
|
+
* @param int $form_id
|
|
48
|
+
* @param bool $display_title
|
|
49
|
+
* @param bool $display_description
|
|
50
|
+
* @param bool $display_inactive
|
|
51
|
+
* @param array $field_values
|
|
52
|
+
* @param bool $ajax
|
|
53
|
+
* @param int $tabindex
|
|
54
|
+
* @param bool $_echo
|
|
55
|
+
*
|
|
56
|
+
* @return mixed
|
|
57
|
+
*/
|
|
58
|
+
public static function get_form( $form_id, $display_title = false, $display_description = false, $display_inactive = false, $field_values = null, $ajax = true, $tabindex = 0, $_echo = false ) {
|
|
59
|
+
if ( function_exists( 'gravity_form' ) ) {
|
|
60
|
+
return gravity_form( $form_id, $display_title, $display_description, $display_inactive, $field_values, $ajax, $tabindex, $_echo );
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Chisel\Helper;
|
|
4
|
+
|
|
5
|
+
use Timber\Timber;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Image Helper functions.
|
|
9
|
+
*
|
|
10
|
+
* @package Chisel
|
|
11
|
+
*/
|
|
12
|
+
class ImageHelpers {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Responsive image data.
|
|
16
|
+
*
|
|
17
|
+
* @var array
|
|
18
|
+
*/
|
|
19
|
+
private static $responsive_image_data = array();
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get image url of the theme images.
|
|
23
|
+
*
|
|
24
|
+
* @param string $image_name
|
|
25
|
+
* @param bool $is_icon
|
|
26
|
+
*
|
|
27
|
+
* @return string
|
|
28
|
+
*/
|
|
29
|
+
public static function get_image_url( $image_name, $is_icon = false ) {
|
|
30
|
+
$folder_name = $is_icon ? 'icons' : 'images';
|
|
31
|
+
$image_path = '/assets/' . $folder_name . '/' . $image_name;
|
|
32
|
+
$file_path = get_template_directory() . $image_path;
|
|
33
|
+
|
|
34
|
+
if ( ! file_exists( $file_path ) ) {
|
|
35
|
+
return '';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return get_template_directory_uri() . $image_path;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Get responsive image html
|
|
43
|
+
*
|
|
44
|
+
* @param int $image_id Image ID.
|
|
45
|
+
* @param string $image_size Image size.
|
|
46
|
+
* @param array $attrs Image attributes.
|
|
47
|
+
*
|
|
48
|
+
* @return string|html
|
|
49
|
+
*/
|
|
50
|
+
public static function get_responsive_image( $image_id, $image_size = 'medium', $attrs = array() ) {
|
|
51
|
+
if ( ! $image_id ) {
|
|
52
|
+
return '';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
$image = Timber::get_image( $image_id );
|
|
56
|
+
|
|
57
|
+
self::$responsive_image_data = array(
|
|
58
|
+
'image_id' => $image_id,
|
|
59
|
+
'attrs' => $attrs,
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
// Adjust image width and height to prevent layout shifts.
|
|
63
|
+
if ( isset( $attrs['width'] ) && isset( $attrs['height'] ) ) {
|
|
64
|
+
add_filter(
|
|
65
|
+
'wp_get_attachment_image_src',
|
|
66
|
+
array( self::class, 'responsive_image_dimensions' ),
|
|
67
|
+
10,
|
|
68
|
+
4
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
$responsive_image = $image ? $image->responsive( $image_size, $attrs ) : '';
|
|
73
|
+
|
|
74
|
+
remove_filter(
|
|
75
|
+
'wp_get_attachment_image_src',
|
|
76
|
+
array( self::class, 'responsive_image_dimensions' ),
|
|
77
|
+
10
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
return $responsive_image;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Adjust image width and height to prevent layout shifts
|
|
85
|
+
*
|
|
86
|
+
* @param array $src
|
|
87
|
+
* @param int $id
|
|
88
|
+
*
|
|
89
|
+
* @return array
|
|
90
|
+
*/
|
|
91
|
+
public static function responsive_image_dimensions( $src, $id ) {
|
|
92
|
+
$image_id = self::$responsive_image_data['image_id'] ?? 0;
|
|
93
|
+
$attrs = self::$responsive_image_data['attrs'] ?? array();
|
|
94
|
+
|
|
95
|
+
if ( $id === $image_id && isset( $attrs['width'] ) && isset( $attrs['height'] ) ) {
|
|
96
|
+
$src[1] = $attrs['width'];
|
|
97
|
+
$src[2] = $attrs['height'];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return $src;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
|
|
3
|
-
namespace Chisel;
|
|
3
|
+
namespace Chisel\Helper;
|
|
4
4
|
|
|
5
|
-
use
|
|
5
|
+
use Chisel\Helper\ImageHelpers;
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Helper functions.
|
|
9
9
|
*
|
|
10
10
|
* @package Chisel
|
|
11
11
|
*/
|
|
12
|
-
class
|
|
13
|
-
|
|
12
|
+
class ThemeHelpers {
|
|
14
13
|
/**
|
|
15
14
|
* Color palettes.
|
|
16
15
|
*
|
|
17
16
|
* @var array
|
|
18
17
|
*/
|
|
19
|
-
|
|
18
|
+
private static $colors_palettes = array(
|
|
20
19
|
'acf' => array(),
|
|
21
20
|
'tinymce' => '',
|
|
22
21
|
);
|
|
@@ -31,107 +30,33 @@ class Helpers {
|
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
/**
|
|
34
|
-
*
|
|
33
|
+
* Check if current environment is development and runnning in fast refresh mode. Set define( 'WP_ENVIRONMENT_TYPE', 'development' ); in wp-config-local.
|
|
35
34
|
*
|
|
36
35
|
* @return bool
|
|
37
36
|
*/
|
|
38
|
-
public static function
|
|
39
|
-
$
|
|
40
|
-
return $theme->get( 'Version' );
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Get colors palette for given type from theme.json file.
|
|
45
|
-
*
|
|
46
|
-
* @param string $type Type of palette to get.
|
|
47
|
-
*
|
|
48
|
-
* @return array
|
|
49
|
-
*/
|
|
50
|
-
public static function get_colors_palette( $type ) {
|
|
51
|
-
if ( ! isset( self::$colors_palettes[$type] ) || self::$colors_palettes[$type] ) {
|
|
52
|
-
return self::$colors_palettes[$type];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
$theme_json = get_template_directory() . '/theme.json';
|
|
56
|
-
$theme_json_data = wp_json_file_decode( $theme_json, array( 'associative' => true ) );
|
|
57
|
-
$colors_palette = $theme_json_data['settings']['color']['palette'];
|
|
58
|
-
|
|
59
|
-
if ( $colors_palette ) {
|
|
60
|
-
foreach ( $colors_palette as $color_data ) {
|
|
61
|
-
$color = sanitize_hex_color( $color_data['color'] );
|
|
62
|
-
|
|
63
|
-
if ( $type === 'acf' ) {
|
|
64
|
-
self::$colors_palettes[$type][] = $color;
|
|
65
|
-
} elseif ( $type === 'tinymce' ) {
|
|
66
|
-
self::$colors_palettes[$type] .= sprintf(
|
|
67
|
-
'"%s", "%s",',
|
|
68
|
-
str_replace( '#', '', $color ),
|
|
69
|
-
esc_attr( $color_data['name'] )
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return apply_filters( 'chisel_' . $type . '_colors_palette', self::$colors_palettes[$type] );
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Json decode data for storing in html attribute
|
|
80
|
-
*
|
|
81
|
-
* @param array $data
|
|
82
|
-
*
|
|
83
|
-
* @return string
|
|
84
|
-
*/
|
|
85
|
-
public static function json_encode_for_data_attribute( $data ) {
|
|
86
|
-
return htmlspecialchars( wp_json_encode( $data ) );
|
|
87
|
-
}
|
|
37
|
+
public static function is_fast_refresh() {
|
|
38
|
+
$runtime = get_template_directory() . '/build/runtime.js';
|
|
88
39
|
|
|
89
|
-
|
|
90
|
-
* Convert an object to an array.
|
|
91
|
-
*
|
|
92
|
-
* @param object $object_to_convert
|
|
93
|
-
*
|
|
94
|
-
* @return array
|
|
95
|
-
*/
|
|
96
|
-
public static function object_to_array( $object_to_convert ) {
|
|
97
|
-
return json_decode( wp_json_encode( $object_to_convert ), true );
|
|
40
|
+
return self::is_dev_env() && is_file( $runtime );
|
|
98
41
|
}
|
|
99
42
|
|
|
100
43
|
/**
|
|
101
|
-
* Get
|
|
102
|
-
*
|
|
103
|
-
* @param string $image_name
|
|
104
|
-
* @param bool $is_icon
|
|
44
|
+
* Get theme version.
|
|
105
45
|
*
|
|
106
|
-
* @return
|
|
46
|
+
* @return bool
|
|
107
47
|
*/
|
|
108
|
-
public static function
|
|
109
|
-
$
|
|
110
|
-
|
|
111
|
-
$file_path = get_template_directory() . $image_path;
|
|
112
|
-
|
|
113
|
-
if ( ! file_exists( $file_path ) ) {
|
|
114
|
-
return '';
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return get_template_directory_uri() . $image_path;
|
|
48
|
+
public static function get_theme_version() {
|
|
49
|
+
$theme = wp_get_theme();
|
|
50
|
+
return $theme->get( 'Version' );
|
|
118
51
|
}
|
|
119
52
|
|
|
120
53
|
/**
|
|
121
|
-
* Get
|
|
122
|
-
*
|
|
123
|
-
* @param int $image_id Image ID.
|
|
124
|
-
* @param string $image_size Image size.
|
|
125
|
-
* @param array $attrs Image attributes.
|
|
54
|
+
* Get theme name / site title.
|
|
126
55
|
*
|
|
127
|
-
* @return
|
|
56
|
+
* @return bool
|
|
128
57
|
*/
|
|
129
|
-
public static function
|
|
130
|
-
|
|
131
|
-
return '';
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return Timber::get_image( $image_id )->responsive( $image_size, $attrs );
|
|
58
|
+
public static function get_theme_name() {
|
|
59
|
+
return esc_attr( get_bloginfo( 'name' ) );
|
|
135
60
|
}
|
|
136
61
|
|
|
137
62
|
/**
|
|
@@ -182,6 +107,41 @@ class Helpers {
|
|
|
182
107
|
return implode( ' ', $classnames );
|
|
183
108
|
}
|
|
184
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Get colors palette for given type from theme.json file.
|
|
112
|
+
*
|
|
113
|
+
* @param string $type Type of palette to get.
|
|
114
|
+
*
|
|
115
|
+
* @return array
|
|
116
|
+
*/
|
|
117
|
+
public static function get_colors_palette( $type ) {
|
|
118
|
+
if ( ! isset( self::$colors_palettes[$type] ) || self::$colors_palettes[$type] ) {
|
|
119
|
+
return self::$colors_palettes[$type];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
$theme_json = get_template_directory() . '/theme.json';
|
|
123
|
+
$theme_json_data = wp_json_file_decode( $theme_json, array( 'associative' => true ) );
|
|
124
|
+
$colors_palette = $theme_json_data['settings']['color']['palette'];
|
|
125
|
+
|
|
126
|
+
if ( $colors_palette ) {
|
|
127
|
+
foreach ( $colors_palette as $color_data ) {
|
|
128
|
+
$color = sanitize_hex_color( $color_data['color'] );
|
|
129
|
+
|
|
130
|
+
if ( $type === 'acf' ) {
|
|
131
|
+
self::$colors_palettes[$type][] = $color;
|
|
132
|
+
} elseif ( $type === 'tinymce' ) {
|
|
133
|
+
self::$colors_palettes[$type] .= sprintf(
|
|
134
|
+
'"%s", "%s",',
|
|
135
|
+
str_replace( '#', '', $color ),
|
|
136
|
+
esc_attr( $color_data['name'] )
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return apply_filters( 'chisel_' . $type . '_colors_palette', self::$colors_palettes[$type] );
|
|
143
|
+
}
|
|
144
|
+
|
|
185
145
|
/**
|
|
186
146
|
* Get logo data for the wp login page.
|
|
187
147
|
*
|
|
@@ -195,7 +155,7 @@ class Helpers {
|
|
|
195
155
|
$logo_data = wp_get_attachment_image_src( $logo_id, 'medium' );
|
|
196
156
|
} else {
|
|
197
157
|
$logo_data = array(
|
|
198
|
-
|
|
158
|
+
ImageHelpers::get_image_url( 'chisel.png' ),
|
|
199
159
|
84,
|
|
200
160
|
84,
|
|
201
161
|
0,
|
package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/WoocommerceHelpers.php
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Chisel\Helper;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Helper functions.
|
|
7
|
+
*
|
|
8
|
+
* @package Chisel
|
|
9
|
+
*/
|
|
10
|
+
class WoocommerceHelpers {
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Check if WooCommerce is active.
|
|
14
|
+
*
|
|
15
|
+
* @return bool
|
|
16
|
+
*/
|
|
17
|
+
public static function is_woocommerce_active() {
|
|
18
|
+
return class_exists( '\Woocommerce' );
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Set the product object. For some reason, products in the loop don’t get the right context by default. Without this, some elements of the listed products would show the same information as the first product in the loop. This function fixes that.
|
|
23
|
+
*
|
|
24
|
+
* @param object $post The post object.
|
|
25
|
+
*/
|
|
26
|
+
public static function timber_set_product( $post ) {
|
|
27
|
+
global $product;
|
|
28
|
+
|
|
29
|
+
if ( is_woocommerce() ) {
|
|
30
|
+
$product = wc_get_product( $post->ID );
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get products grid classnames
|
|
36
|
+
*
|
|
37
|
+
* @param bool $products
|
|
38
|
+
* @param bool $has_sidebar
|
|
39
|
+
*
|
|
40
|
+
* @return string
|
|
41
|
+
*/
|
|
42
|
+
public static function get_products_grid_classnames( $products, $has_sidebar ) {
|
|
43
|
+
$loop_columns = wc_get_loop_prop( 'columns' );
|
|
44
|
+
|
|
45
|
+
// Set max columns to 4.
|
|
46
|
+
if ( $loop_columns > 4 ) {
|
|
47
|
+
$loop_columns = 4;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
$columns_data = array(
|
|
51
|
+
'medium' => $loop_columns,
|
|
52
|
+
'small' => $loop_columns > 2 ? $loop_columns - 1 : $loop_columns,
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
$grid_classnames = array(
|
|
56
|
+
'o-grid',
|
|
57
|
+
'o-grid--cols-1',
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
if ( $products ) {
|
|
61
|
+
$grid_classnames[] = 'o-grid--cols-' . $columns_data['small'] . '-small';
|
|
62
|
+
|
|
63
|
+
if ( $has_sidebar ) {
|
|
64
|
+
$grid_classnames[] = 'o-grid--cols-' . $columns_data['small'] . '-medium';
|
|
65
|
+
} else {
|
|
66
|
+
$grid_classnames[] = 'o-grid--cols-' . $columns_data['medium'] . '-medium';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return implode( ' ', $grid_classnames );
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Chisel\Helper;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Helper functions.
|
|
7
|
+
*
|
|
8
|
+
* @package Chisel
|
|
9
|
+
*/
|
|
10
|
+
class YoastHelpers {
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Check if Gravity Forms plugin is active.
|
|
14
|
+
*
|
|
15
|
+
* @return bool
|
|
16
|
+
*/
|
|
17
|
+
public static function is_yoast_active() {
|
|
18
|
+
return class_exists( '\WPSEO_Options' );
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Display breadcrumbs.
|
|
23
|
+
*
|
|
24
|
+
* @return html
|
|
25
|
+
*/
|
|
26
|
+
public static function breadcrumbs() {
|
|
27
|
+
if ( ! self::is_yoast_active() ) {
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if ( is_front_page() ) {
|
|
32
|
+
return '';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return yoast_breadcrumb( '<div class="c-breadcrumbs">', '</div>', false );
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
|
|
3
|
-
namespace Chisel;
|
|
3
|
+
namespace Chisel\Interfaces;
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Hooks Interface
|
|
7
7
|
*
|
|
8
8
|
* @package Chisel
|
|
9
9
|
*/
|
|
10
|
-
interface
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Get the instance of the class.
|
|
14
|
-
*/
|
|
15
|
-
public static function get_instance();
|
|
10
|
+
interface HooksInterface {
|
|
16
11
|
|
|
17
12
|
/**
|
|
18
13
|
* Set class properties.
|
package/lib/commands/create/creators/app/chisel-starter-theme/{classes → inc/Module}/AcfSync.php
RENAMED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
|
|
3
|
-
namespace Chisel;
|
|
3
|
+
namespace Chisel\Module;
|
|
4
|
+
|
|
5
|
+
use Chisel\Interfaces\InstanceInterface;
|
|
6
|
+
use Chisel\Interfaces\HooksInterface;
|
|
7
|
+
use Chisel\Traits\Singleton;
|
|
4
8
|
|
|
5
9
|
/**
|
|
6
10
|
* ACF related functionalities.
|
|
7
11
|
*
|
|
8
12
|
* @package Chisel
|
|
9
13
|
*/
|
|
10
|
-
class AcfSync extends \ACF_Admin_Internal_Post_Type_List implements
|
|
14
|
+
class AcfSync extends \ACF_Admin_Internal_Post_Type_List implements InstanceInterface, HooksInterface {
|
|
15
|
+
|
|
16
|
+
use Singleton;
|
|
11
17
|
|
|
12
18
|
/**
|
|
13
19
|
* The acf groups post type.
|
|
@@ -28,21 +34,21 @@ class AcfSync extends \ACF_Admin_Internal_Post_Type_List implements Instance {
|
|
|
28
34
|
*
|
|
29
35
|
* @var null|int
|
|
30
36
|
*/
|
|
31
|
-
|
|
37
|
+
private $post_id = null;
|
|
32
38
|
|
|
33
39
|
/**
|
|
34
40
|
* The key of acf field group to sync.
|
|
35
41
|
*
|
|
36
42
|
* @var null|string
|
|
37
43
|
*/
|
|
38
|
-
|
|
44
|
+
private $single_post_key = null;
|
|
39
45
|
|
|
40
46
|
/**
|
|
41
47
|
* The acf groups sync page url.
|
|
42
48
|
*
|
|
43
49
|
* @var string
|
|
44
50
|
*/
|
|
45
|
-
|
|
51
|
+
private $sync_page_url = '';
|
|
46
52
|
|
|
47
53
|
/**
|
|
48
54
|
* ACF section current page
|
|
@@ -164,7 +170,7 @@ class AcfSync extends \ACF_Admin_Internal_Post_Type_List implements Instance {
|
|
|
164
170
|
*
|
|
165
171
|
* @return void
|
|
166
172
|
*/
|
|
167
|
-
|
|
173
|
+
private function display_admin_notice() {
|
|
168
174
|
?>
|
|
169
175
|
<div class="error">
|
|
170
176
|
<p><?php esc_html_e( 'You have unsynced ACF fields.', 'chisel' ); ?> <a href="<?php echo esc_url( $this->sync_page_url ); ?>"><?php esc_html_e( ' View fields available for sync', 'chisel' ); ?></a></p>
|
|
@@ -177,7 +183,7 @@ class AcfSync extends \ACF_Admin_Internal_Post_Type_List implements Instance {
|
|
|
177
183
|
*
|
|
178
184
|
* @return void
|
|
179
185
|
*/
|
|
180
|
-
|
|
186
|
+
private function display_modal_notice() {
|
|
181
187
|
$url = $this->get_admin_url( '&acfsync=' . $this->single_post_key . '&_wpnonce=' . wp_create_nonce( 'bulk-posts' ) );
|
|
182
188
|
?>
|
|
183
189
|
<div class="xfive-acf-sync-modal js-xfive-acf-sync-modal is-open" role="dialog">
|
|
@@ -214,17 +220,4 @@ class AcfSync extends \ACF_Admin_Internal_Post_Type_List implements Instance {
|
|
|
214
220
|
public static function load_scripts() {
|
|
215
221
|
return self::get_instance()->post_id && self::get_instance()->single_post_key;
|
|
216
222
|
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Get the instance of the class.
|
|
220
|
-
*/
|
|
221
|
-
public static function get_instance() {
|
|
222
|
-
static $instance = null;
|
|
223
|
-
|
|
224
|
-
if ( null === $instance ) {
|
|
225
|
-
$instance = new self();
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
return $instance;
|
|
229
|
-
}
|
|
230
223
|
}
|