In functions.php (functie om actieve endpoint te krijgen)
function get_active_account_menu_item() {
global $wp;
$items = wc_get_account_menu_items();
$current = false;
foreach ($items as $endpoint => $label) {
// Set current item class.
$current = isset( $wp->query_vars[ $endpoint ] );
if ( 'dashboard' === $endpoint && ( isset( $wp->query_vars['page'] ) || empty( $wp->query_vars ) ) ) {
$current = true; // Dashboard is not an endpoint, so needs a custom check.
}
if($current) {
$current = $endpoint;
break;
}
}
return $current;
}
/theme/woocommerce/myaccount/navigation.php
<nav class="woocommerce-MyAccount-navigation bg-info" role="navigation"> <div class="list-group"> <?php foreach ( wc_get_account_menu_items() as $endpoint => $label ) : ?> <a href="<?php echo esc_url( wc_get_account_endpoint_url( $endpoint ) ); ?>" class="list-group-item list-group-item-action <?php if(get_active_account_menu_item() == sanitize_title(esc_html( $endpoint ))): echo 'active'; endif; ?>"><?php echo esc_html( $label ); ?></a> <?php endforeach; ?> </div> </nav>
CSS (SASS)
.list-group-item {
&.active, &:hover {
background: $primary!important;
color: $white;
}
}
#active #class #klasse #mijn account #navigation #woocommerce