<?php
if (
    (is_single() && espresso_display_venue_in_event_details())
    || (is_archive() && espresso_display_venue_in_event_list())
) :
    global $post;
    do_action('AHEE_event_details_before_venue_details', $post);
    $venue_name = espresso_venue_name(0, 'details', FALSE);
    if (empty($venue_name) && espresso_is_venue_private()) {
        do_action('AHEE_event_details_after_venue_details', $post);
        return '';
    }
    ?>
    <div class="espresso-venue-dv<?php echo espresso_is_venue_private() ? ' espresso-private-venue-dv' : ''; ?>">
        <h3 class="event-venues-h3 ee-event-h3">
            <?php esc_html_e('Location', 'sparta'); ?>
        </h3>
        <h4><strong><?php esc_html_e('Venue:', 'sparta'); ?></strong>&nbsp;&nbsp; <strong>
                <?php
                printf(' %s', $venue_name);
                ?>
            </strong>
        </h4>
        <p><span class="smaller-text tags-links"><?php echo espresso_venue_categories(); ?></span></p>
        <?php if ($venue_phone = espresso_venue_phone($post->ID, FALSE)) : ?>
            <p>
                <span class="small-text"><strong><?php esc_html_e('Phone:', 'sparta'); ?></strong></span>
                <?php
                printf(' %s', $venue_phone);
                ?>
            </p>
        <?php endif; ?>
        <?php if ($venue_website = espresso_venue_website($post->ID, FALSE)) : ?>
            <p>
                <span class="small-text"><strong><?php esc_html_e('Website:', 'sparta'); ?></strong></span>
                <?php
                printf(' %s', $venue_website);
                ?>
            </p>
        <?php endif; ?>
        <?php if (espresso_venue_has_address($post->ID)) : ?>
            <strong><span class="dashicons dashicons-location-alt"></span><?php esc_html_e('Address:', 'sparta'); ?>
            </strong>
            <?php espresso_venue_address('inline'); ?>
            <?php espresso_venue_gmap($post->ID); ?>
            <div class="clear"><br/></div>
        <?php endif; ?>

        <?php $VNU_ID = espresso_venue_id($post->ID); ?>
        <?php if (is_single()) : ?>

        <?php else : ?>
            <?php $venue_excerpt = espresso_venue_excerpt($VNU_ID, FALSE); ?>
            <?php if ($venue_excerpt) : ?>
                <p>
                    <strong><?php esc_html_e('Description:', 'sparta'); ?></strong><br/>
                    <?php
                    printf(' %s', $venue_excerpt);
                    ?>
                </p>
            <?php endif; ?>
        <?php endif; ?>
    </div>
    <!-- .espresso-venue-dv -->
    <?php
    do_action('AHEE_event_details_after_venue_details', $post);
else :
    if (espresso_venue_is_password_protected()) :
        ?>
        <div class="espresso-venue-dv  espresso-password-protected-venue-dv">
            <h3 class="event-venues-h3 ee-event-h3">
                <?php esc_html_e('Location', 'sparta'); ?>
            </h3>
            <?php echo espresso_password_protected_venue_form(); ?>
        </div>
    <?php
    endif;
endif;
?>
