Skip to content

Commit 17c7efb

Browse files
committed
allows menu selection in vf hero blocks and templates
1 parent 1941f25 commit 17c7efb

24 files changed

Lines changed: 460 additions & 81 deletions

File tree

wp-content/plugins/vf-hero-container-custom-blog/group_vf_wp_hero_group.json

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,36 @@
206206
"ui_on_text": "",
207207
"ui_off_text": ""
208208
},
209+
{
210+
"key": "field_67ea9901b0a03",
211+
"label": "Navigation menu",
212+
"name": "vf_navigation_menu",
213+
"type": "select",
214+
"instructions": "Choose which menu to display when navigation is enabled.",
215+
"required": 0,
216+
"conditional_logic": [
217+
[
218+
{
219+
"field": "field_621c9cc1c7da0",
220+
"operator": "==",
221+
"value": "1"
222+
}
223+
]
224+
],
225+
"wrapper": {
226+
"width": "",
227+
"class": "",
228+
"id": ""
229+
},
230+
"choices": {},
231+
"default_value": "",
232+
"allow_null": 0,
233+
"multiple": 0,
234+
"ui": 1,
235+
"return_format": "value",
236+
"ajax": 0,
237+
"placeholder": ""
238+
},
209239
{
210240
"key": "field_621c9cc1c7e36",
211241
"label": "Heading link",
@@ -239,5 +269,5 @@
239269
"hide_on_screen": "",
240270
"active": true,
241271
"description": "VF-Hero container for blog pages",
242-
"modified": 1646044300
243-
}
272+
"modified": 1774955400
273+
}

wp-content/plugins/vf-hero-container-custom-blog/index.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ public function __construct(array $params = array()) {
3636
'acf/settings/load_json',
3737
array($this, 'acf_settings_load_json')
3838
);
39+
add_filter(
40+
'acf/load_field/name=vf_navigation_menu',
41+
array($this, 'acf_load_navigation_menu')
42+
);
3943
}
4044

4145
// public function template_callback($block, $content, $is_preview = false, $acf_id) {
@@ -50,6 +54,17 @@ public function acf_settings_load_json($paths) {
5054
return $paths;
5155
}
5256

57+
public function acf_load_navigation_menu($field) {
58+
$field['choices'] = class_exists('VF_Navigation')
59+
? VF_Navigation::get_navigation_menu_choices()
60+
: array();
61+
$field['default_value'] = class_exists('VF_Navigation')
62+
? VF_Navigation::get_primary_menu_source()
63+
: '';
64+
65+
return $field;
66+
}
67+
5368
} // VF_WP_Hero_Blog
5469

5570
$plugin = new VF_WP_Hero_Blog(

wp-content/plugins/vf-hero-container-custom-blog/template.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
$hero_subheading = get_field('vf_hero_subheading');
1111
$hero_heading = get_field('vf_hero_heading');
1212
$hero_url = get_field('vf_hero_url');
13+
$navigation_enable = get_field('vf_navigation_enable');
14+
$navigation_menu_source = class_exists('VF_Navigation')
15+
? VF_Navigation::resolve_menu_source(get_field('vf_navigation_menu'))
16+
: 'location:primary';
1317

1418
$spacing = get_field('vf_hero_spacing');
1519
$spacing_class = "| vf-hero--";
@@ -91,4 +95,8 @@
9195
</div>
9296
</section>
9397
<!--/vf-hero-->
94-
98+
<?php
99+
if ($navigation_enable && class_exists('VF_Navigation')) {
100+
VF_Navigation::render_menu($navigation_menu_source);
101+
}
102+
?>

wp-content/plugins/vf-hero-container-secondary/group_vf_wp_hero_group.json

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,36 @@
220220
"ui": 1,
221221
"ui_on_text": "",
222222
"ui_off_text": ""
223+
},
224+
{
225+
"key": "field_67ea9901b0a02",
226+
"label": "Navigation menu",
227+
"name": "vf_navigation_menu",
228+
"type": "select",
229+
"instructions": "Choose which menu to display when navigation is enabled.",
230+
"required": 0,
231+
"conditional_logic": [
232+
[
233+
{
234+
"field": "field_614326ab47614",
235+
"operator": "==",
236+
"value": "1"
237+
}
238+
]
239+
],
240+
"wrapper": {
241+
"width": "",
242+
"class": "",
243+
"id": ""
244+
},
245+
"choices": {},
246+
"default_value": "",
247+
"allow_null": 0,
248+
"multiple": 0,
249+
"ui": 1,
250+
"return_format": "value",
251+
"ajax": 0,
252+
"placeholder": ""
223253
}
224254
],
225255
"location": [
@@ -239,5 +269,5 @@
239269
"hide_on_screen": "",
240270
"active": true,
241271
"description": "VF-Hero container",
242-
"modified": 1642150579
243-
}
272+
"modified": 1774955400
273+
}

wp-content/plugins/vf-hero-container-secondary/index.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ public function __construct(array $params = array()) {
3636
'acf/settings/load_json',
3737
array($this, 'acf_settings_load_json')
3838
);
39+
add_filter(
40+
'acf/load_field/name=vf_navigation_menu',
41+
array($this, 'acf_load_navigation_menu')
42+
);
3943
}
4044

4145
// public function template_callback($block, $content, $is_preview = false, $acf_id) {
@@ -50,6 +54,17 @@ public function acf_settings_load_json($paths) {
5054
return $paths;
5155
}
5256

57+
public function acf_load_navigation_menu($field) {
58+
$field['choices'] = class_exists('VF_Navigation')
59+
? VF_Navigation::get_navigation_menu_choices()
60+
: array();
61+
$field['default_value'] = class_exists('VF_Navigation')
62+
? VF_Navigation::get_primary_menu_source()
63+
: '';
64+
65+
return $field;
66+
}
67+
5368
} // VF_WP_Hero_Secondary
5469

5570
$plugin = new VF_WP_Hero_Secondary(

wp-content/plugins/vf-hero-container-secondary/template.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
$hero_subheading = get_field('vf_hero_subheading');
1111
$hero_heading = get_field('vf_hero_heading');
1212
$hero_url = get_field('vf_hero_url');
13+
$navigation_enable = get_field('vf_navigation_enable');
14+
$navigation_menu_source = class_exists('VF_Navigation')
15+
? VF_Navigation::resolve_menu_source(get_field('vf_navigation_menu'))
16+
: 'location:primary';
1317

1418
$spacing = get_field('vf_hero_spacing');
1519
$spacing_class = "| vf-hero--";
@@ -91,4 +95,8 @@
9195
</div>
9296
</section>
9397
<!--/vf-hero-->
94-
98+
<?php
99+
if ($navigation_enable && class_exists('VF_Navigation')) {
100+
VF_Navigation::render_menu($navigation_menu_source);
101+
}
102+
?>

wp-content/plugins/vf-hero-container/group_vf_wp_hero_group.json

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,36 @@
225225
"ui": 1,
226226
"ui_on_text": "",
227227
"ui_off_text": ""
228+
},
229+
{
230+
"key": "field_67ea9901b0a01",
231+
"label": "Navigation menu",
232+
"name": "vf_navigation_menu",
233+
"type": "select",
234+
"instructions": "Choose which menu to display when navigation is enabled.",
235+
"required": 0,
236+
"conditional_logic": [
237+
[
238+
{
239+
"field": "field_603b3d040391d",
240+
"operator": "==",
241+
"value": "1"
242+
}
243+
]
244+
],
245+
"wrapper": {
246+
"width": "",
247+
"class": "",
248+
"id": ""
249+
},
250+
"choices": {},
251+
"default_value": "",
252+
"allow_null": 0,
253+
"multiple": 0,
254+
"ui": 1,
255+
"return_format": "value",
256+
"ajax": 0,
257+
"placeholder": ""
228258
}
229259
],
230260
"location": [
@@ -244,5 +274,5 @@
244274
"hide_on_screen": "",
245275
"active": true,
246276
"description": "VF-Hero container",
247-
"modified": 1635940900
248-
}
277+
"modified": 1774955400
278+
}

wp-content/plugins/vf-hero-container/index.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ public function __construct(array $params = array()) {
3636
'acf/settings/load_json',
3737
array($this, 'acf_settings_load_json')
3838
);
39+
add_filter(
40+
'acf/load_field/name=vf_navigation_menu',
41+
array($this, 'acf_load_navigation_menu')
42+
);
3943
}
4044

4145
// public function template_callback($block, $content, $is_preview = false, $acf_id) {
@@ -50,6 +54,17 @@ public function acf_settings_load_json($paths) {
5054
return $paths;
5155
}
5256

57+
public function acf_load_navigation_menu($field) {
58+
$field['choices'] = class_exists('VF_Navigation')
59+
? VF_Navigation::get_navigation_menu_choices()
60+
: array();
61+
$field['default_value'] = class_exists('VF_Navigation')
62+
? VF_Navigation::get_primary_menu_source()
63+
: '';
64+
65+
return $field;
66+
}
67+
5368
} // VF_WP_Hero
5469

5570
$plugin = new VF_WP_Hero(

wp-content/plugins/vf-hero-container/template.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
$hero_subheading = get_field('vf_hero_subheading');
1111
$hero_heading = get_field('vf_hero_heading');
1212
$search = get_field('vf_hero_search');
13+
$navigation_enable = get_field('vf_navigation_enable');
14+
$navigation_menu_source = class_exists('VF_Navigation')
15+
? VF_Navigation::resolve_menu_source(get_field('vf_navigation_menu'))
16+
: 'location:primary';
1317
$theme = wp_get_theme();
1418
$spacing = get_field('vf_hero_spacing');
1519
$spacing_class = "| vf-hero--";
@@ -171,3 +175,8 @@ class="vf-search__button | vf-button vf-button--primary">
171175
</div>
172176
</section>
173177
<!--/vf-hero-->
178+
<?php
179+
if ($navigation_enable && class_exists('VF_Navigation')) {
180+
VF_Navigation::render_menu($navigation_menu_source);
181+
}
182+
?>

0 commit comments

Comments
 (0)