<?php

function aurora_lite_menu_fallback() {
    if ( current_user_can('edit_theme_options') ) {
        echo '<span class="menu-warning">' . esc_html__('Assign a menu to this location', 'aurora-lite') . '</span>';
    }
}

function aurora_lite_show_logo($location = 'header') {

    $logo_id = get_theme_mod('custom_logo');

    if ($location === 'footer') {

        $footer_logo_id = get_theme_mod('aurora_lite_footer_logo');

        if (!empty($footer_logo_id)) {
            $logo_id = $footer_logo_id;
        }
    }

    $logo_url = $logo_id ? wp_get_attachment_image_url($logo_id, 'full') : '';

    return esc_url($logo_url);
}

function aurora_lite_show_socials() {
    $social_networks = [
        'facebook'  => ['label' => esc_html__('Facebook',  'aurora-lite'), 'icon' => 'fa-brands fa-facebook-f'],
        'twitter'   => ['label' => esc_html__('X',   'aurora-lite'),       'icon' => 'fa-brands fa-x-twitter'],
        'tiktok'    => ['label' => esc_html__('TikTok',    'aurora-lite'), 'icon' => 'fa-brands fa-tiktok'],
        'instagram' => ['label' => esc_html__('Instagram', 'aurora-lite'), 'icon' => 'fa-brands fa-instagram'],
        'whatsapp'  => ['label' => esc_html__('WhatsApp',  'aurora-lite'), 'icon' => 'fa-brands fa-whatsapp'],
        'linkedin'  => ['label' => esc_html__('LinkedIn',  'aurora-lite'), 'icon' => 'fa-brands fa-linkedin-in'],
        'pinterest' => ['label' => esc_html__('Pinterest', 'aurora-lite'), 'icon' => 'fa-brands fa-pinterest'],
        'reddit'    => ['label' => esc_html__('Reddit',    'aurora-lite'), 'icon' => 'fa-brands fa-reddit'],
        'youtube'   => ['label' => esc_html__('YouTube',   'aurora-lite'), 'icon' => 'fa-brands fa-youtube'],
    ];

    foreach ( $social_networks as $key => $data ) {
        $url   = get_theme_mod( "aurora_lite_social_{$key}" );
        $label = $data['label'];

        if ( ! empty( $url ) ) {
            echo '<a href="' . esc_url( $url ) . '" class="social-icon" target="_blank" 
                    rel="noopener noreferrer" title="' . esc_attr( $label ) . '" aria-label="' . esc_attr( $label ) . '">
                    <i class="' . esc_attr( $data['icon'] ) . '"></i></a>';
        }
    }
}

function aurora_lite_header_buttons( $hide_btn2 = '' ) {
    $btn1_text = get_theme_mod( 'aurora_lite_header_btn1_text', '' );
    $btn1_url  = get_theme_mod( 'aurora_lite_header_btn1_url', '' );
    $btn2_text = get_theme_mod( 'aurora_lite_header_btn2_text', '' );
    $btn2_url  = get_theme_mod( 'aurora_lite_header_btn2_url', '' );

    if ( ($btn1_text && $btn1_url) || ($btn2_text && $btn2_url && $hide_btn2 !== 'x') ) {
        echo '<div class="aurora-lite-header-buttons">';

        if ( $btn2_text && $btn2_url && $hide_btn2 !== 'x' ) {
            echo '<a id="btn-secondary" href="' . esc_url( $btn2_url ) . '">'
                . esc_html( $btn2_text ) .
                '</a>';
        }

        if ( $btn1_text && $btn1_url ) {
            echo '<a id="btn-primary" href="' . esc_url( $btn1_url ) . '">'
                . esc_html( $btn1_text ) .
                '</a>';
        }

        echo '</div>';
    }
}