1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
| <?php
|
|
| use JVBase\base\Options;
| use JVBase\meta\Meta;
|
| function jvb_menu_sections():array
| {
| $sections = Options::get('menu_section_order');
| if (empty($sections)) {
| $sections = [];
| }
| $sections = array_map(function($section) {
| $section['id'] = absint($section['id']);
| return $section;
| }, $sections);
|
| $ids = array_column($sections, 'id');
|
| $terms = get_terms([
| 'taxonomy' => 'product_cat',
| 'hide_empty'=> false,
| 'exclude' => $ids
| ]);
| if (!empty($terms) && !is_wp_error($terms)) {
| foreach ($terms as $term) {
| if ($term->name === 'Uncategorized') {
| continue;
| }
| $sections[] = [
| 'id' => $term->term_id,
| 'name' => $term->name,
| 'image' => Meta::forTerm($term->term_id)->get('image'),
| 'description' => $term->description,
| ];
| }
| }
| return $sections;
| }
|
|