feat: ajout de menus customizables

This commit is contained in:
Kazhnuz 2021-01-24 14:52:23 +01:00
parent 473c4da58a
commit 735b203e66
4 changed files with 46 additions and 35 deletions

View file

@ -1,11 +1,14 @@
<footer>
<ul class="social">
<li class="social-li"><a class="social-link" href="https://twitter.com/kazhnuz" alt="Twitter"><i class="fa fa-fw fa-twitter"></i></a></li>
<li class="social-li"><a class="social-link" href="https://octodon.social/users/kazhnuz" alt="Mastodon"><i class="fa fa-fw fa-mastodon"></i></a></li>
<li class="social-li"><a class="social-link" href="https://framasphere.org/u/kazhnuz" alt="Diaspora"><i class="fa fa-fw fa-diaspora"></i></a></li>
<li class="social-li"><a class="social-link" href="https://deviantart.com/kazhnuz" alt="DeviantART"><i class="fa fa-fw fa-deviantart"></i></a></li>
<li class="social-li"><a class="social-link" href="https://github.com/kazhnuz" alt="Github"><i class="fa fa-fw fa-github"></i></a></li>
<li class="social-li"><a class="social-link" href="https://git.kobold.cafe/kazhnuz" alt="Gitlab"><i class="fa fa-fw fa-git"></i></a></li>
<?php
$listmenu = get_nav_menu_locations();
$menu = wp_get_nav_menu_items($listmenu['social']);
if ($menu != null) {
foreach ($menu as $menuElement) {
echo '<li class="social-li"><a class="social-link" href="'. $menuElement->url .'" alt="'.$menuElement->title.'"><i class="fa fa-fw fa-'.$menuElement->title.'"></i></a></li> ';
}
}
?>
</ul>
<div class="footer-collumns">

View file

@ -1,29 +1,10 @@
<div class="navbar-area">
<?php
$categories = get_categories( array(
'orderby' => 'name',
'order' => 'ASC'
) );
foreach( $categories as $category ) {
if ($category->slug == "blog") {
echo '<a class="btn btn-navbar" href="' . get_category_link($category->term_id) . '">' . $category->name . '</a>';
}
}
$pages = get_pages( array(
"sort_column" => 'menu_order',
'sort_order' => 'ASC'
));
if ( $pages ) {
foreach( $pages as $page ) {
if ($page->post_name != "home") {
echo '<a class="btn btn-navbar" href="'. get_page_link( $page->ID ) . '">'. $page->post_title .'</a>';
}
$listmenu = get_nav_menu_locations();
$menu = wp_get_nav_menu_items($listmenu['top-navbar']);
foreach ($menu as $menuElement) {
echo '<a href="' . $menuElement->url . '" class="btn btn-navbar">'. $menuElement->title . '</a>';
}
}?>
<!-- <a href="/blog.html" class="btn btn-navbar">Blog</a> -->
<!-- <a href="/crea.html" class="btn btn-navbar">Romans</a> -->
<!-- <a href="/apropos.html" class="btn btn-navbar">A propos</a> -->
?>
<a href="<?php bloginfo('rss2_url'); ?>" class="btn btn-navbar"><i class="fa fa-rss"></i></a>
</div>

View file

@ -1,10 +1,19 @@
<?php
$listmenu = get_nav_menu_locations();
$menu = wp_get_nav_menu_items($listmenu['link-menu']);
if ($menu != null) {
?>
<div class="card card-primary">
<div class="card-header"><i class="fa fa-link"></i> Liens</div>
<div class="card-menu">
<a href="https://kobold.city" class="menu-element">Kobold City</a>
<a href="https://rulebook.kobold.city" class="menu-element">Mes JDR</a>
<a href="https://univers.kobold.city" class="menu-element">Mes Univers</a>
<a href="https://git.kobold.city" class="menu-element">Mon Gitea</a>
<a href="https://vault.kobold.city" class="menu-element">Vault</a>
<?php
$menu = wp_get_nav_menu_items( 'link-menu');
foreach ($menu as $menuElement) {
echo '<a href="' . $menuElement->url . '" class="menu-element">'. $menuElement->title . '</a>';
}
?>
</div>
</div>
<?php
}
?>

View file

@ -320,3 +320,21 @@ register_taxonomy('roman', 'post',
add_action( 'roman_add_form_fields', 'romans_taxonomy_custom_fields_add' );
add_action( 'created_roman', 'save_taxonomy_custom_fields' );
add_action( 'edited_roman', 'save_taxonomy_custom_fields', 10, 2 );
/* 4. Menus custom
*
* Quelques menus custom
*
*/
function wpb_custom_new_menu() {
register_nav_menus(
array(
'top-navbar' => __( 'Top Navbar' ),
'link-menu' => __( 'Links Menu' ),
'footer-pages' => __( 'Footer pages' ),
'social' => __( 'Reseaux sociaux' )
)
);
}
add_action( 'init', 'wpb_custom_new_menu' );