<?php

add_shortcode('service_cat', 'service_cat_func');
function service_cat_func()
{
    ob_start();
    $taxonomies = get_terms('service_cat', array('hide_empty' => 0));
    echo '<div class="service-categories"><ul>';
    foreach ($taxonomies as $tax):
        $link = get_term_link($tax->term_id, 'service_cat');
        echo '<li><a href="' . $link . '">' . $tax->name . '</a></li>';
    endforeach;
    echo '</ul></div>';
    $output = ob_get_clean();
    return $output;
}

add_shortcode('service_info', 'service_info_func');
function service_info_func()
{
    ob_start();
    $id = get_the_ID();
    $tfl_ceo = get_post_meta( $id , '_tfl_ceo', true);
    $tfl_fone = get_post_meta( $id , '_tfl_fone', true);
    $tfl_location = get_post_meta( $id , '_tfl_location', true);
    $tfl_mail = get_post_meta( $id , '_tfl_mail', true);
    $listInfo = array(
        'ceo' => array(
            'icon' => 'ceo',
            'title' => esc_html__('Ceo', 'gettree'),
            'value' => $tfl_ceo,
        ),
        'phone' => array(
            'icon' => 'phone',
            'title' => esc_html__('Phone', 'gettree'),
            'value' => $tfl_fone,
        ),
        'location' => array(
            'icon' => 'location',
            'title' => esc_html__('Location', 'gettree'),
            'value' => $tfl_location,
        ),
        'email' => array(
            'icon' => 'mail',
            'title' => esc_html__('Email', 'gettree'),
            'value' => $tfl_mail,
        ),
    );

    echo '<div class="service-contact"><ul>';
    foreach ($listInfo as $info):
        echo '<li>
        <div class="title"><i class="icon-'.$info['icon'].'"></i>'.$info['title'].':</div>
        <div class="value">'.$info['value'].'</div></li>';
    endforeach;
    echo '</ul></div>';
    $output = ob_get_clean();
    return $output;
}


add_shortcode('service_brochure', 'service_brochure_func');
function service_brochure_func()
{
    ob_start();
    $id = get_the_ID();
    $tfl_download = get_post_meta( $id , '_tfl_download', true);
    $tfl_discover = get_post_meta( $id , '_tfl_discover', true);
    $tfl_textareafield = get_post_meta( $id, '_tfl_textarea_field', true);

//    echo '<ul>';
        echo '<div class="content">'.$tfl_textareafield.'</div>
        <div class="buttons">
            <a class="left" href="'.$tfl_download.'">'.esc_html__('Download', 'gettree').'</a>
            <a class="right" href="'.$tfl_discover.'">'.esc_html__('Discover', 'gettree').'</a>
        </div>';
//    echo '</ul>';

    $output = ob_get_clean();
    return $output;
}

add_shortcode('socials_shortcode', 'socials_shortcode_func');

function socials_shortcode_func()
{
    return tfl_socials();
}