@total_onion/onion-library 2.0.181 → 2.0.183
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/components/block-group-container-v3/group_6865578ada499.json +3722 -3775
- package/components/block-post-info-v3/group_6866429531436.json +3036 -3013
- package/components/block-scrolling-banner-v3/group_68e67fca1ec80.json +502 -210
- package/components/block-scrolling-banner-v3/scrolling-banner-v3.js +4 -4
- package/components/block-scrolling-banner-v3/scrolling-banner-v3.twig +2 -4
- package/components/core-block-editor-assets-v3/block-editor-assets-v3.php +6 -7
- package/components/core-core-block-render-function-v3/core-block-render-function-v3.php +39 -0
- package/components/{fields-core-design-settings-v3 → core-core-design-settings-v3}/core-design-settings-v3.php +6 -2
- package/components/core-core-post-overrides-v3/core-post-overrides-v3.php +21 -0
- package/components/core-core-themes/core-themes-v3.php +68 -0
- package/components/core-globals/globals.php +39 -0
- package/datalayer-tools.mjs +2 -0
- package/onion-utils.mjs +2 -3
- package/package.json +1 -1
- package/components/fields-core-block-render-function-v3/core-block-render-function-v3.php +0 -50
|
@@ -83,12 +83,12 @@ function scrollingbannerJs(block) {
|
|
|
83
83
|
wrapper.appendChild(newTickerContainer);
|
|
84
84
|
|
|
85
85
|
const animation1 = [
|
|
86
|
-
{
|
|
87
|
-
{
|
|
86
|
+
{transform: 'translateX(0%)'},
|
|
87
|
+
{transform: 'translateX(-100%)'}
|
|
88
88
|
];
|
|
89
89
|
const animation2 = [
|
|
90
|
-
{
|
|
91
|
-
{
|
|
90
|
+
{transform: 'translateX(100%)'},
|
|
91
|
+
{transform: 'translateX(0%)'}
|
|
92
92
|
];
|
|
93
93
|
|
|
94
94
|
const time = 100000 / speed;
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
</style>
|
|
15
15
|
<section {{block.anchor ? "id=" ~ block.anchor : ''}} class="{{blockClassName}} {{classNameEntryPoint}} {{block.id}} lazy-fade" {{dataAttributeEntryPoint}} data-blockid="{{block.id}}" data-assetkey="{{blockClassName}}">
|
|
16
16
|
|
|
17
|
-
{% set bannerText1 = fields.
|
|
18
|
-
{% set bannerText2 = fields.
|
|
17
|
+
{% set bannerText1 = fields.scrolling_banner_text_1 %}
|
|
18
|
+
{% set bannerText2 = fields.scrolling_banner_text_2 %}
|
|
19
19
|
{% set enableScrolling = fields.enable_scrolling_banner %}
|
|
20
20
|
{% set bannerSpeed = fields.scrolling_banner_speed %}
|
|
21
21
|
{% set imageSeperator = fields.seperator_as_image %}
|
|
@@ -47,7 +47,5 @@
|
|
|
47
47
|
</div>
|
|
48
48
|
</div>
|
|
49
49
|
{% endif %}
|
|
50
|
-
|
|
51
|
-
|
|
52
50
|
{# {{htmlEntryPoint}} #}
|
|
53
51
|
</section>
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
<?php
|
|
2
|
-
add_action('enqueue_block_assets', 'add_block_editor_assets_v3', 10, true);
|
|
3
2
|
function add_block_editor_assets_v3(): void
|
|
4
3
|
{
|
|
5
4
|
if (is_admin()) {
|
|
6
5
|
wp_enqueue_script('editorstyles', gtp_get_asset_uri('editor.js'), array(), null, true);
|
|
7
|
-
wp_localize_script('editorstyles', 'previewvars', core_design_settings_v3());
|
|
8
|
-
wp_localize_script('editorstyles', '
|
|
9
|
-
wp_localize_script('editorstyles', 'coretypography', core_typography_v3());
|
|
6
|
+
wp_localize_script('editorstyles', 'previewvars', core_design_settings_v3(OPTIONS));
|
|
7
|
+
wp_localize_script('editorstyles', 'corePostOverrides', core_post_overrides_v3(OPTIONS));
|
|
8
|
+
wp_localize_script('editorstyles', 'coretypography', core_typography_v3(OPTIONS));
|
|
10
9
|
wp_localize_script('editorstyles', 'corefontmodifiers', core_font_modifiers_v3());
|
|
11
|
-
wp_localize_script('editorstyles', 'corethemes', core_themes_v3());
|
|
12
|
-
wp_localize_script('editorstyles', 'currenttheme', core_current_theme_v3());
|
|
13
|
-
wp_localize_script('editorstyles', 'colourconfig', create_colour_data());
|
|
10
|
+
wp_localize_script('editorstyles', 'corethemes', core_themes_v3(OPTIONS));
|
|
11
|
+
wp_localize_script('editorstyles', 'currenttheme', core_current_theme_v3(OPTIONS));
|
|
12
|
+
wp_localize_script('editorstyles', 'colourconfig', create_colour_data(OPTIONS));
|
|
14
13
|
}
|
|
15
14
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
use Timber\Timber;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Rendering of core blocks with Post entity
|
|
7
|
+
*
|
|
8
|
+
* @param array<string, mixed> $block block.
|
|
9
|
+
* @param string $content content.
|
|
10
|
+
* @param bool $is_preview If it's a preview.
|
|
11
|
+
*/
|
|
12
|
+
function core_block_render_post_object_v3(array $block, string $content = '', bool $is_preview = false, $post_id = 0, $wp_block = false, $context = false, array $extra_context = array()): void
|
|
13
|
+
{
|
|
14
|
+
$context = \Timber\Timber::context();
|
|
15
|
+
$slug = substr($block['name'], 4); // Removes 'acf/' from the name.
|
|
16
|
+
$fields = get_fields();
|
|
17
|
+
$context['block'] = $block;
|
|
18
|
+
$context['fields'] = $fields;
|
|
19
|
+
$context['is_preview'] = $is_preview;
|
|
20
|
+
$context['environment'] = $_ENV['PANTHEON_ENVIRONMENT'] ?? 'local';
|
|
21
|
+
|
|
22
|
+
if (defined('OPTIONS') && is_array(OPTIONS)) {
|
|
23
|
+
$context['options'] = OPTIONS;
|
|
24
|
+
$context['nav_menus'] = Defined('NAV_MENUS') ? NAV_MENUS : [];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if ($extra_context) {
|
|
28
|
+
foreach ($extra_context as $key => $value) {
|
|
29
|
+
$context[$key] = $value;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
if (file_exists(__DIR__ . '/../../../views/blocks/' . $slug . '.twig')) {
|
|
35
|
+
\Timber\Timber::render("blocks/{$slug}.twig", $context);
|
|
36
|
+
} else {
|
|
37
|
+
echo 'could not find Twig template for ' . $slug . '. This block may no longer be in use.';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
// @codingStandardsIgnoreStart
|
|
3
|
-
function core_design_settings_v3()
|
|
3
|
+
function core_design_settings_v3($options)
|
|
4
4
|
{
|
|
5
|
-
|
|
5
|
+
if (!is_array($options)) {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
$json_data = file_get_contents(get_template_directory() . '/inc/theme-data/' . $options['current_theme_name'] . '/design-settings-vars.json');
|
|
6
9
|
$design_settings_data = json_decode($json_data, true);
|
|
7
10
|
$output = '';
|
|
8
11
|
if ($design_settings_data) {
|
|
@@ -31,6 +34,7 @@ function core_design_settings_v3()
|
|
|
31
34
|
--landscape-design-reference:' . ($settings['landscape_design_reference'] ?? 1024) . ';
|
|
32
35
|
--portrait-design-reference:' . ($settings['portrait_design_reference'] ?? 1024) . ';
|
|
33
36
|
--mobile-design-reference:' . ($settings['mobile_design_reference'] ?? 1024) . ';
|
|
37
|
+
--global-content-max-width-setting:' . ($settings['global_max_width'] ?? 1024) . ';
|
|
34
38
|
}</style>';
|
|
35
39
|
}
|
|
36
40
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
// @codingStandardsIgnoreStart
|
|
3
|
+
function core_post_overrides_v3($options)
|
|
4
|
+
{
|
|
5
|
+
$output = '';
|
|
6
|
+
$current_post = [];
|
|
7
|
+
if (isset($GLOBALS['post'])) {
|
|
8
|
+
$current_post = Timber::get_post($GLOBALS['post']->ID);
|
|
9
|
+
}
|
|
10
|
+
if (is_array($options)) {
|
|
11
|
+
|
|
12
|
+
$output = '
|
|
13
|
+
<style id="core-site-global-v3">
|
|
14
|
+
body {
|
|
15
|
+
--post-colour:' . ($current_post && (property_exists($current_post, 'meta') && isset($current_post->meta['post_colour'])) ? $current_post->meta['post_colour'] : '') . ';
|
|
16
|
+
--post-text-colour-style:' . ($current_post && (property_exists($current_post, 'meta') && isset($current_post->meta['post_text_colour_style'])) ? remove_underscore($current_post->meta['post_text_colour_style']) : '') . ';
|
|
17
|
+
}</style>';
|
|
18
|
+
}
|
|
19
|
+
return [$output];
|
|
20
|
+
} // END function core_design_vars
|
|
21
|
+
// @codingStandardsIgnoreEnd
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
// @codingStandardsIgnoreStart
|
|
3
|
+
function core_themes_v3($options)
|
|
4
|
+
{
|
|
5
|
+
if (!is_array($options)) {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
$json_data = file_get_contents(get_template_directory() . '/inc/theme-data/' . $options['current_theme_name'] . '/theme-vars.json');
|
|
9
|
+
$themes_data = json_decode($json_data, true);
|
|
10
|
+
if ($themes_data) {
|
|
11
|
+
|
|
12
|
+
$output = '';
|
|
13
|
+
$output = '<style id="core-themes-vars">
|
|
14
|
+
:root {
|
|
15
|
+
';
|
|
16
|
+
|
|
17
|
+
foreach ($themes_data as $theme => $value) {
|
|
18
|
+
if (isset($value['theme_primary_background_type'])) {
|
|
19
|
+
$background_value = remove_underscore($value['theme_primary_background_type']) == 'solid-colour' ? $value['theme_primary_background_colour'] : (remove_underscore($value['theme_primary_background_type']) == 'gradient' ? $value['theme_primary_background_gradient'] : null);
|
|
20
|
+
} else {
|
|
21
|
+
$background_value = $value['theme_primary_background_colour'];
|
|
22
|
+
}
|
|
23
|
+
$output .=
|
|
24
|
+
'&[data-currentcolourpalette="theme-' . $theme + 1 . '"] {
|
|
25
|
+
';
|
|
26
|
+
foreach ($value['theme_colours'] as $index => $content) {
|
|
27
|
+
if (is_array($content) && array_key_exists('theme_colour', $content)) {
|
|
28
|
+
$output .= '--palette-default-' . ($index + 1) . ': ' . $content['theme_colour'] . ';
|
|
29
|
+
';
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
foreach ($value['text_colours'] as $index => $content) {
|
|
33
|
+
if (is_array($content) && array_key_exists('colour', $content)) {
|
|
34
|
+
$output .= '--text-colour-default-' . ($index + 1) . ': ' . $content['colour'] . ';
|
|
35
|
+
';
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
$output .= '--theme-primary-text-colour: ' . ($value['theme_primary_text_colour'] ?? '#ffffff') . ';
|
|
39
|
+
--theme-secondary-text-colour: ' . ($value['theme_secondary_text_colour'] ?? '#ffffff') . ';
|
|
40
|
+
--theme-tertiary-text-colour: ' . ($value['theme_tertiary_text_colour'] ?? '#ffffff') . ';
|
|
41
|
+
--theme-primary-background-colour:' . $background_value . ';
|
|
42
|
+
--theme-secondary-background-colour: ' . ($value['theme_secondary_background_colour'] ?? '#ffffff') . ';
|
|
43
|
+
--theme-tertiary-background-colour: ' . ($value['theme_tertiary_background_colour'] ?? '#ffffff') . ';
|
|
44
|
+
--theme-primary-accent-colour:' . ($value['theme_primary_accent_colour'] ?? '#ffffff') . ';
|
|
45
|
+
--theme-secondary-accent-colour: ' . ($value['theme_secondary_accent_colour'] ?? '#ffffff') . ';
|
|
46
|
+
--theme-tertiary-accent-colour: ' . ($value['theme_tertiary_accent_colour'] ?? '#ffffff') . ';
|
|
47
|
+
--link-colour: ' . ($value['links']['link_colour'] ?? '#ffffff') . ';
|
|
48
|
+
--link-colour-hover: ' . ($value['links']['link_colour_hover'] ?? '#ffffff') . ';
|
|
49
|
+
--link-decoration-colour: ' . ($value['links']['link_decoration_colour'] ?? '#ffffff') . ';
|
|
50
|
+
--link-decoration-colour-hover: ' . ($value['links']['link_decoration_colour_hover'] ?? '#ffffff') . ';
|
|
51
|
+
--link-decoration-style: ' . (remove_underscore($value['links']['link_decoration_style']) ?? '#ffffff') . ';
|
|
52
|
+
--link-decoration-style-hover: ' . (remove_underscore($value['links']['link_decoration_style_hover']) ?? '#ffffff') . ';
|
|
53
|
+
--primary-font-family:' . (remove_underscore($value['theme_primary_font']['font'] ?? 'arial')) . ';
|
|
54
|
+
--secondary-font-family:' . (remove_underscore($value['theme_secondary_font']['font'] ?? 'arial')) . ';
|
|
55
|
+
--tertiary-font-family:' . (remove_underscore($value['theme_tertiary_font']['font'] ?? 'arial')) . ';
|
|
56
|
+
--quaternary-font-family:' . (remove_underscore($value['theme_quaternary_font']['font'] ?? 'arial')) . ';
|
|
57
|
+
}
|
|
58
|
+
';
|
|
59
|
+
}
|
|
60
|
+
$output .= '}
|
|
61
|
+
</style>';
|
|
62
|
+
|
|
63
|
+
return [$output];
|
|
64
|
+
} else {
|
|
65
|
+
return array();
|
|
66
|
+
}
|
|
67
|
+
} // END function core_design_vars
|
|
68
|
+
// @codingStandardsIgnoreEnd
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Sets globals in the context
|
|
5
|
+
*
|
|
6
|
+
* @package Global Theme
|
|
7
|
+
*s
|
|
8
|
+
* @return array<string,mixed>
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
function create_context(): array
|
|
12
|
+
{
|
|
13
|
+
$context = \Timber\Timber::context();
|
|
14
|
+
$context['environment'] = $_ENV['PANTHEON_ENVIRONMENT'] ?? 'local';
|
|
15
|
+
Define('NAV_MENUS', assemble_menus());
|
|
16
|
+
|
|
17
|
+
if (file_exists(__DIR__ . '/inc/markets.php')) {
|
|
18
|
+
require_once get_template_directory() . '/inc/markets.php';
|
|
19
|
+
}
|
|
20
|
+
if (defined('ICL_LANGUAGE_CODE')) {
|
|
21
|
+
$context['market_slug'] = ICL_LANGUAGE_CODE; // @phpstan-ignore-line
|
|
22
|
+
$languages = apply_filters('wpml_active_languages', null);
|
|
23
|
+
$context['languages'] = $languages;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (defined('OPTIONS') && is_array(OPTIONS)) {
|
|
27
|
+
if (array_key_exists('header_pattern', OPTIONS)) {
|
|
28
|
+
$context['header_post'] = Timber::get_post(OPTIONS['header_pattern']);
|
|
29
|
+
}
|
|
30
|
+
if (array_key_exists('footer_pattern', OPTIONS)) {
|
|
31
|
+
$context['footer_post'] = Timber::get_post(OPTIONS['footer_pattern']);
|
|
32
|
+
}
|
|
33
|
+
$context['options'] = OPTIONS;
|
|
34
|
+
$context['options']['nav_menus'] = NAV_MENUS;
|
|
35
|
+
$context['archive_links'] = OPTIONS['archive_links'];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return $context;
|
|
39
|
+
}
|
package/onion-utils.mjs
CHANGED
|
@@ -13,14 +13,13 @@ export function ttfb() {
|
|
|
13
13
|
const [pageNav] = entryList.getEntriesByType("navigation");
|
|
14
14
|
const time = pageNav.responseStart;
|
|
15
15
|
console.log(`TTFB: ${time} new`);
|
|
16
|
-
|
|
16
|
+
pushTTFBData(time);
|
|
17
17
|
}).observe({ type: "navigation", buffered: true });
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
function
|
|
20
|
+
function pushTTFBData(time) {
|
|
21
21
|
window.dataLayer = window.dataLayer || [];
|
|
22
22
|
window.dataLayer.push({ ttfb: time });
|
|
23
|
-
console.log("ttfb sent");
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
/**
|
package/package.json
CHANGED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
use Timber\Timber;
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Rendering of core blocks with Post entity
|
|
7
|
-
*
|
|
8
|
-
* @param array<string, mixed> $block block.
|
|
9
|
-
* @param string $content content.
|
|
10
|
-
* @param bool $is_preview If it's a preview.
|
|
11
|
-
*/
|
|
12
|
-
function core_block_render_post_object_v3(array $block, string $content = '', bool $is_preview = false, $post_id = 0, $wp_block = false, $context = false, array $extraContext = null): void
|
|
13
|
-
{
|
|
14
|
-
$context = \Timber\Timber::context();
|
|
15
|
-
$slug = substr($block['name'], 4); // Removes 'acf/' from the name.
|
|
16
|
-
$fields = get_fields();
|
|
17
|
-
$current_post =
|
|
18
|
-
$is_preview ? Timber::get_post(get_post()->ID) : Timber::get_post();
|
|
19
|
-
$context['current_post'] = $current_post;
|
|
20
|
-
$context['block'] = $block;
|
|
21
|
-
$context['fields'] = $fields;
|
|
22
|
-
$context['is_preview'] = $is_preview;
|
|
23
|
-
$context['environment'] = $_ENV['PANTHEON_ENVIRONMENT'] ?? 'local';
|
|
24
|
-
$context['global_settings'] = defined('GLOBAL_SETTINGS') ? GLOBAL_SETTINGS : [];
|
|
25
|
-
$context['market_settings'] = defined('MARKET_SETTINGS_OPTIONS') ? MARKET_SETTINGS_OPTIONS : [];
|
|
26
|
-
$context['options'] = defined('GLOBAL_SETTINGS') ? GLOBAL_SETTINGS : [];
|
|
27
|
-
$context['cta_styles'] = defined('GLOBAL_SETTINGS') ? GLOBAL_SETTINGS : [];
|
|
28
|
-
// $context['nav_menus'] = defined('SITE_MENUS') ? SITE_MENUS : [];
|
|
29
|
-
if (file_exists(__DIR__ . '/site-menus.php')) {
|
|
30
|
-
include_once __DIR__ . '/site-menus.php';
|
|
31
|
-
$context['nav_menus'] = assemble_menus();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if ($extraContext) {
|
|
35
|
-
foreach ($extraContext as $key => $value) {
|
|
36
|
-
$context[$key] = $value;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (defined('ICL_LANGUAGE_CODE')) {
|
|
41
|
-
$context['market_slug'] = ICL_LANGUAGE_CODE; // @phpstan-ignore-line
|
|
42
|
-
$languages = apply_filters('wpml_active_languages', null);
|
|
43
|
-
$context['languages'] = $languages;
|
|
44
|
-
}
|
|
45
|
-
if (file_exists(__DIR__ . '/../../views/blocks/' . $slug . '.twig')) {
|
|
46
|
-
\Timber\Timber::render("blocks/{$slug}.twig", $context);
|
|
47
|
-
} else {
|
|
48
|
-
echo 'could not find Twig template for ' . $slug . '. This block may no longer be in use.';
|
|
49
|
-
}
|
|
50
|
-
}
|