-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
53 lines (45 loc) · 1.64 KB
/
functions.php
File metadata and controls
53 lines (45 loc) · 1.64 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
add_action('init', static function () {
register_nav_menus([
'grave-main-menu' => 'Grave\'s main menu',
]);
});
add_action('customize_register', static function (WP_Customize_Manager $wp_customize) {
$wp_customize->add_section('grave_section' , [
'title' => 'Grave section title',
'priority' => 30,
]);
$wp_customize->add_setting('grave_footer_author', [
'default' => 'Zbigniew (Ferror) Malcherczyk',
]);
$wp_customize->add_setting('grave_footer_link', [
'default' => 'https://github.com/ferror',
]);
$wp_customize->add_control('grave_control_footer_author', [
'label' => 'Grave footer author',
'section' => 'grave_section',
'settings' => 'grave_footer_author',
]);
$wp_customize->add_control('grave_control_footer_link', [
'label' => 'Grave footer link',
'section' => 'grave_section',
'settings' => 'grave_footer_link',
]);
});
function clean_custom_menus($args = [])
{
$menuLocation = $args['theme_location'];
$locations = get_nav_menu_locations();
if ($locations && isset($locations[$menuLocation])) {
$menu = wp_get_nav_menu_object($locations[$menuLocation]);
$menuItems = wp_get_nav_menu_items($menu->term_id);
$menuList = '<nav>' ."\n";
$menuList .= "\t\t\t\t". '<ul>' ."\n";
foreach ((array) $menuItems as $key => $menuItem) {
$menuList .= "\t\t\t\t\t". '<li><a href="'. $menuItem->url .'">'. $menuItem->title .'</a></li>' ."\n";
}
$menuList .= "\t\t\t\t". '</ul>' ."\n";
$menuList .= "\t\t\t". '</nav>' ."\n";
}
echo $menuList;
}