<?php
/**
 * My Account navigation
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/myaccount/navigation.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see     https://docs.woocommerce.com/document/template-structure/
 * @package WooCommerce/Templates
 * @version 9.3.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

do_action( 'woocommerce_before_account_navigation' );
?>

<style>
.woocommerce-MyAccount-navigation-link.woocommerce-MyAccount-navigation-link--downloads {
	display: none;
}
.woocommerce-MyAccount-navigation-link.woocommerce-MyAccount-navigation-link--mywishlist {
	display: none;
}
.woocommerce-MyAccount-navigation-link.woocommerce-MyAccount-navigation-link--following {
	display: none;
}

 <?php if((get_option('acc3') == true )): ?>

.woocommerce-MyAccount-navigation-link.woocommerce-MyAccount-navigation-link--downloads {
	display: block;
}

<?php endif; ?>
 <?php if((get_option('acc4') == true )): ?>

.woocommerce-MyAccount-navigation-link.woocommerce-MyAccount-navigation-link--mywishlist {
	display: block;
}
<?php endif; ?>

 <?php if((get_option('acc5') == true )): ?>

.woocommerce-MyAccount-navigation-link.woocommerce-MyAccount-navigation-link--following {
	display: block;
}<?php endif; ?>


</style>

<div class="nav-11">

<div class="new-user-farnam-401">
  <div class="user-avatar">
		<div class="in1"><?php

// Get current user id
$user_id = get_current_user_id();

// Get attachment id
$attachment_id = get_user_meta( $user_id, 'avatar', true );

// Get default avatar URL
$default_avatar = wp_get_attachment_image_src(get_option('avatar_default'), '100');

// True
if ( $attachment_id ) {

  // Get image url
  $image_url = wp_get_attachment_url( $attachment_id );

  // Display image
  if ( $image_url ) {
    echo wp_get_attachment_image( $attachment_id, '100' );
  } else {
    // Display default avatar
    echo '<img src="' . esc_url($default_avatar[0]) . '" alt="اواتار" width="100" height="100">';
  }
} else {

  // Display default avatar
  echo '<img src="' . get_template_directory_uri() . '/img/user.jpg' . '" alt="اواتار پیشفرض" width="100" height="100">';
}
?></div>
       <div class="in2">
	   <span>
	   سلام
	   <?php global $current_user;
      wp_get_current_user();
      echo '' . $current_user->user_firstname . "\n";
?>
</span>
<a href="<?php echo wp_logout_url( get_permalink() ); ?>" class="khotooj-az-site">خروج از سایت </a>
</div>
        
    
    </div>
	
	<div class="user-bar-401">
	<a href="<?php echo home_url() ?>" class="user-bar-401-link"><i class="fi fi-rr-home"></i></a>
	<a href="<?php echo get_permalink( wc_get_page_id( 'cart' ) ); ?>" class="user-bar-401-link"><i class="fi fi-rr-shopping-cart"></i><div class="header-cart-count"><?php echo WC()->cart->get_cart_contents_count(); ?></div></a>
		 <?php if((get_option('acc2') == true )): ?>

	<a href="#etelae" class="user-bar-401-link"><i class="fi fi-rr-bell-ring"></i></a>
	
	<?php endif; ?>
	 <?php if((get_option('acc4') == true )): ?>

	<a href="<?php echo home_url() ?>/wishlist" class="user-bar-401-link"><i class="fi fi-rr-heart"></i></a>
<?php endif; ?>
	</div>
	
</div>
<nav class="woocommerce-MyAccount-navigation">
 
	<ul>
		<?php foreach ( wc_get_account_menu_items() as $endpoint => $label ) : ?>
			<li class="<?php echo wc_get_account_menu_item_classes( $endpoint ); ?>">
				<a href="<?php echo esc_url( wc_get_account_endpoint_url( $endpoint ) ); ?>"><?php echo esc_html( $label ); ?></a>
			</li>
		<?php endforeach; ?>
	</ul>
</nav>
</div>
<?php do_action( 'woocommerce_after_account_navigation' ); ?>
