<?php
/*===============================
Shortocde tz-skill-item
===============================*/

function tzinteriart_title($atts)
{
    $tz_type = $tz_title = $tz_title_size = $tz_title_line_height = $tz_color_title = $tz_subtitle = $tz_color_subtitle = $tz_description = '';
    $tz_color_des = $tz_text_align = $tz_css_animation = $tz_extra_class = $css = $tz_fontsize_des = $tz_padding_des = $tz_fontweight_des = '';
    $tz_type_dash = $tz_text_view_more = $link = $tz_color_viewmore = '';
    extract(shortcode_atts(array(
        'tz_type' => '1',
        'tz_title' => '',
        'tz_title_size' => '',
        'tz_title_line_height' => '',
        'tz_color_title' => '',
        'tz_subtitle' => '',
        'tz_color_subtitle' => '',
        'tz_description' => '',
        'tz_color_des' => '',
        'tz_text_align' => 'center',
        'tz_css_animation' => '',
        'tz_extra_class' => '',
        'css' => '',
        'tz_fontsize_des' => '',
        'tz_padding_des' => '',
        'tz_fontweight_des' => '',
        'tz_type_dash' => 'tz_on_title',
        'tz_text_view_more' => '',
        'tz_color_viewmore' => '',
        'link' => '',

    ), $atts));
    ob_start();

    $vc_link = vc_build_link($link);

    $tzinteriart_class = '';

    if ($tz_type != '') {
        $tzinteriart_class .= 'tz-title-type-' . $tz_type;
    }

    if ($tz_text_align != '') {
        $tzinteriart_class .= ' tz-text-align-' . $tz_text_align;
    }

    if ($tz_css_animation != '') {
        wp_enqueue_script('waypoints');
        $tzinteriart_class .= ' wpb_animate_when_almost_visible wpb_' . $tz_css_animation;
    }

    $title_classes = '';
    if (isset($css) && $css != ''):
        $title_classes .= ' ' . vc_shortcode_custom_css_class($css);
    endif;

    ?>
    <div class="tzElement-title <?php echo esc_attr($tz_type_dash); ?> <?php if ($tz_extra_class != '') {
        echo esc_attr($tz_extra_class);
    } ?> <?php echo esc_attr($tzinteriart_class); ?> <?php echo esc_attr($title_classes); ?>">
        <?php
        if ($tz_type == '3' || $tz_type == '4' && $tz_subtitle != '') {
            ?>
            <span class="tzSubTitle" <?php
            if ($tz_color_subtitle != '') {
                echo 'style="color:' . esc_attr($tz_color_subtitle) . '"';
            }
            ?>><?php echo esc_html($tz_subtitle); ?></span>
            <?php
        }

        if ($tz_type != '11') {


            if ($tz_title != '') {
                ?>
                <span class="tzTitle"<?php if ($tz_color_title != '' || $tz_title_size != '') {
                    echo 'style="color:' . esc_attr($tz_color_title) . '; font-size:' . esc_attr($tz_title_size) . '; line-height: ' . esc_attr($tz_title_line_height) . '; "';
                }
                ?>>
                    <?php
                    if ($tz_type == '1') {
                        echo '{ ';
                    }
                    echo balanceTags($tz_title);
                    if ($tz_type == '1') {
                        echo ' }';
                    }
                    ?>
                </span>
                <?php
            }
            ?>

            <?php
            if ($tz_type == '1' && $tz_subtitle != '') {
                ?>
                <span class="tzSubTitle" <?php
                if ($tz_color_subtitle != '') {
                    echo 'style="color:' . esc_attr($tz_color_subtitle) . '"';
                }
                ?>><?php echo esc_html($tz_subtitle); ?></span>
                <?php
            }
            ?>
        <?php } elseif ($tz_type == '11') {
            if ($tz_subtitle != '') {
                ?>
                <span class="tzSubTitle" <?php if ($tz_color_subtitle != '') {
                    echo 'style="color:' . esc_attr($tz_color_subtitle) . '"';
                } ?>>
                    <?php echo esc_html($tz_subtitle); ?>
                </span>
                <?php
            }
            if ($tz_title != '') {
                ?>
                <h3 class="tzTitle" <?php if ($tz_color_title != '') {
                    echo 'style="color:' . esc_attr($tz_color_title) . '"';
                } ?> >
                    <?php
                    echo balanceTags($tz_title);
                    ?>
                </h3>

                <?php
            }
        } ?>

        <?php if ($tz_description !== '') { ?>
            <p class="tzDescription" <?php
            if ($tz_color_des != '' || $tz_padding_des != '' || $tz_fontweight_des != '') {
                echo 'style="
                font-size:' . esc_attr($tz_fontsize_des) . ';
                color:' . esc_attr($tz_color_des) . ';
                padding:' . esc_attr($tz_padding_des) . ';
                font-weight:' . esc_attr($tz_fontweight_des) . ';
                "';
            }
            ?>><?php echo ent2ncr($tz_description); ?></p>
            <p style="color: red;">

            </p>
        <?php } ?>

        <?php if ($tz_text_view_more !='' && $vc_link['url'] == true && $tz_type == '12') : ?>

            <a class="tz_viewmore"
                <?php echo ($vc_link['target'] != '' ? 'target="' . esc_attr($vc_link['target']) . '"' : '')
                    . ' ' . ($vc_link['url'] != '' ? 'href="' . esc_attr($vc_link['url']) . '"' : '')
                    . ' ' . ($vc_link['title'] != '' ? 'title="' . esc_attr($vc_link['title']) . '"' : ''); ?> style="color:<?php echo esc_attr($tz_color_viewmore);?>">
                <?php if ($tz_text_view_more != ''): ?>
                    <?php echo esc_attr($tz_text_view_more); ?><span class="lnr lnr-arrow-right"></span></i>
                <?php endif; ?>
            </a>

        <?php endif; ?>

    </div>
    <?php
    return ob_get_clean();
}

add_shortcode('tz-title', 'tzinteriart_title');
?>
