Created
March 21, 2025 12:14
-
-
Save jmabbas/f7b853803bfe00b44bfafda7a6e47c2c to your computer and use it in GitHub Desktop.
Mytravel - Header account
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mytravel_header_navbar_account() { | |
$header_style = mytravel_get_header_style(); | |
if ( mytravel_header_signin_enable() ) { | |
$myt_page_options = array(); | |
if ( function_exists( 'mytravel_option_enabled_post_types' ) && is_singular( mytravel_option_enabled_post_types() ) ) { | |
$clean_meta_data = get_post_meta( get_the_ID(), '_myt_page_options', true ); | |
$_myt_page_options = maybe_unserialize( $clean_meta_data ); | |
if ( is_array( $_myt_page_options ) ) { | |
$myt_page_options = $_myt_page_options; | |
} | |
} | |
if ( mytravel_has_custom_header( $myt_page_options ) ) { | |
$signin_button_color = isset( $myt_page_options['header']['mytravel_navbar_signin_button_skin'] ) ? $myt_page_options['header']['mytravel_navbar_signin_button_skin'] : 'white'; | |
$signin_button_size = isset( $myt_page_options['header']['mytravel_navbar_signin_button_size'] ) ? 'btn-' . $myt_page_options['header']['mytravel_navbar_signin_button_size'] : 'wide'; | |
$signin_button_shape = isset( $myt_page_options['header']['mytravel_navbar_signin_button_shape'] ) ? $myt_page_options['header']['mytravel_navbar_signin_button_shape'] : 'rounded-sm'; | |
$signin_button_variant = isset( $myt_page_options['header']['mytravel_navbar_signin_button_variant'] ) ? $myt_page_options['header']['mytravel_navbar_signin_button_variant'] : 'outline'; | |
$button_url = isset( $myt_page_options['header']['mytravel_navbar_signin_button_link'] ) ? $myt_page_options['header']['mytravel_navbar_signin_button_link'] : ''; | |
$button_css = isset( $myt_page_options['header']['mytravel_navbar_signin_button_css'] ) ? $myt_page_options['header']['mytravel_navbar_signin_button_css'] : ''; | |
} else { | |
$signin_button_color = get_theme_mod( 'header_navbar_signin_button_color', 'white' ); | |
$signin_button_size = 'btn-' . get_theme_mod( 'header_navbar_signin_button_size', 'wide' ); | |
$signin_button_shape = get_theme_mod( 'header_signin_button_shape', 'rounded-sm' ); | |
$signin_button_variant = get_theme_mod( 'header_navbar_signin_button_variant', 'outline' ); | |
$button_url = get_theme_mod( 'header_navbar_signin_button_url', '' ); | |
$button_css = get_theme_mod( 'header_navbar_signin_button_css' ); | |
} | |
$signin_button_variant = ! empty( $signin_button_variant ) ? 'btn-' . $signin_button_variant . '-' . $signin_button_color : 'btn-' . $signin_button_color; | |
$text_color = ( mytravel_transparent_header_enable() ? 'text-white' : 'text-dark' ); | |
if ( 'link' === $signin_button_color ) { | |
'btn-outline-' . $signin_button_color; | |
} else { | |
'btn-' . $signin_button_color; | |
} | |
$signin_button_class = 'btn ' . $signin_button_shape . ' ' . $signin_button_size . ' ' . $signin_button_variant . ' ' . $button_css . ' border-width-2 transition-3d-hover'; | |
$button_class = 'btn ' . $signin_button_shape . ' ' . $signin_button_size . ' ' . $signin_button_variant . ' ' . $button_css . ' transition-3d-hover'; | |
if ( 'v2' === $header_style ) { | |
$text_color = 'text-primary'; | |
} | |
if ( 'v4' === $header_style || 'v8' === $header_style ) { | |
$text_color = 'u-header__topbar-divider--dark text-dark'; | |
} | |
$divider = ''; | |
if ( mytravel_transparent_header_enable() ) { | |
$divider = 'u-header__topbar-divider'; | |
} else { | |
$divider = 'u-header__topbar-divider--dark'; | |
} | |
$signin_url = ''; | |
if ( ! empty( $button_url ) ) { | |
$signin_url = $button_url; | |
} else { | |
$signin_url = 'javascript:;'; | |
} | |
$classes = ''; | |
$icon_classes = ''; | |
if ( 'v1' === $header_style ) { | |
$classes = 'position-relative px-3 u-header__login-form dropdown-connector-xl ' . $divider; | |
$icon_classes = 'flaticon-user mr-2 ml-1 font-size-18'; | |
} elseif ( 'v2' === $header_style ) { | |
$classes = 'position-relative pl-4 pr-xl-4 ml-auto ml-md-0 u-header__divider-xl '; | |
$icon_classes = 'flaticon-user mx-xl-2'; | |
} elseif ( 'v3' === $header_style || 'v4' === $header_style ) { | |
$classes = 'position-relative u-header__login-form px-3 ' . $divider; | |
$icon_classes = 'flaticon-user mr-2 ml-1'; | |
} elseif ( 'v5' === $header_style ) { | |
$classes = 'pl-4 ml-1 u-header__last-item-btn u-header__last-item-btn-xl'; | |
$icon_classes = 'flaticon-user font-size-16 mr-2'; | |
} elseif ( 'v6' === $header_style ) { | |
$classes = 'position-relative u-header__login-form u-header__hide-content d-none d-lg-block'; | |
$icon_classes = 'flaticon-user font-size-18 mx-xl-2'; | |
} else { | |
$classes = 'u-header__login-form pl-4 ml-1 u-header__last-item-btn u-header__last-item-btn-lg'; | |
$icon_classes = 'flaticon-user font-size-16 mr-2'; | |
} | |
$anchor_classes = ''; | |
if ( 'v1' === $header_style ) { | |
$anchor_classes = $text_color . ' d-flex align-items-center py-3'; | |
} elseif ( 'v3' === $header_style ) { | |
$anchor_classes = $text_color . ' d-flex align-items-center py-2'; | |
} elseif ( 'v5' === $header_style ) { | |
$anchor_classes = $signin_button_class; | |
} elseif ( 'v7' === $header_style ) { | |
$anchor_classes = $text_color . ' ' . $button_class; | |
} else { | |
$anchor_classes = $text_color . ' d-flex align-items-center'; | |
} | |
$span_class = ''; | |
if ( 'v2' === $header_style ) { | |
$span_class = 'd-none d-xl-inline-block mr-1'; | |
} elseif ( 'v5' === $header_style || 'v7' === $header_style ) { | |
$span_class = 'd-inline-block'; | |
} elseif ( 'v2' === $header_style || 'v6' === $header_style ) { | |
$span_class = 'd-none d-xl-inline-block mr-1'; | |
} else { | |
$span_class = 'd-inline-block font-size-14 mr-1'; | |
} | |
if ( 'v8' === $header_style ) { | |
$classes = 'position-relative px-3 u-header__login-form dropdown-connector-xl u-header__topbar-divider--dark'; | |
$icon_classes = 'flaticon-user mr-2 ml-1 font-size-18'; | |
$anchor_classes = 'd-flex align-items-center text-dark py-3'; | |
$span_class = 'd-inline-block font-size-14 mr-1'; | |
} | |
?> | |
<div class="<?php echo esc_attr( $classes ); ?>"> | |
<?php | |
if ( is_user_logged_in() && mytravel_is_woocommerce_activated() ) : | |
?> | |
<a class="<?php echo esc_attr( $text_color ); ?>" href="<?php echo esc_url( get_permalink( wc_get_page_id( 'myaccount' ) ) ); ?>"> | |
<?php echo get_avatar( wp_get_current_user(), 36, '', '', [ 'class' => 'avatar-sm rounded-circle mr-2' ] ); ?> | |
<?php | |
$user = wp_get_current_user(); | |
echo esc_html( $user->display_name ); | |
?> | |
</a> | |
<?php | |
else : | |
?> | |
<a id="signUpDropdownInvoker" href="<?php echo esc_url( $signin_url ); ?>" class="<?php echo esc_attr( $anchor_classes ); ?>" aria-controls="signUpDropdown" aria-haspopup="true" aria-expanded="true" data-unfold-event="click" data-unfold-target="#signUpDropdown" data-unfold-type="css-animation" data-unfold-duration="300" data-unfold-delay="300" data-unfold-hide-on-scroll="true" data-unfold-animation-in="slideInUp" data-unfold-animation-out="fadeOut"> | |
<i class="<?php echo esc_attr( $icon_classes ); ?>"></i> | |
<span class="<?php echo esc_attr( $span_class ); ?>"><?php echo esc_html_x( 'Sign in or Register', 'front-end', 'mytravel' ); ?></span> | |
</a> | |
<?php | |
endif; | |
mytravel_wc_registration_form(); | |
?> | |
</div> | |
<?php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment