<?php
/*===============================
Shortocde tz-section-video
===============================*/

function tzinteriart_our_service($atts)
{
    $tz_type = $tzinteriart_image = $tzinteriart_number = $tzinteriart_title = $tzinteriart_color = $tzinteriart_des = $tz_option_button = '';
    $tzinteriart_readmore_text = $tzinteriart_readmore_link = $tzinteriart_option = $tzinteriart_align_content = $tz_css_animation = $css = '';
    extract(shortcode_atts(array(
        'tz_type' => '1',
        'tzinteriart_image' => '',
        'tzinteriart_number' => '',
        'tzinteriart_title' => '',
        'tzinteriart_color' => '',
        'tzinteriart_des' => '',
        'tz_option_button' => 'show',
        'tzinteriart_readmore_text' => '',
        'tzinteriart_readmore_link' => '',
        'tzinteriart_option' => '1',
        'tzinteriart_align_content' => '1',
        'tz_css_animation' => '',
        'css' => '',
    ), $atts));
    ob_start();

    $tzinteriart_img_id = preg_replace('/[^\d]/', '', $tzinteriart_image);
    $tzinteriart_width_img = '';
    $tzinteriart_height_img = '';
    $tzinteriart_images_info = wp_get_attachment_image_src($tzinteriart_img_id, $size = 'large');
    if (isset($tzinteriart_images_info) && !empty($tzinteriart_images_info)) {
        $tzinteriart_url_img = $tzinteriart_images_info[0];
        $tzinteriart_width_img = $tzinteriart_images_info[1];
        $tzinteriart_height_img = $tzinteriart_images_info[2];
    }

    if ($tzinteriart_option == '1') {
        $tzinteriart_class = 'service_left';
    } else (
    $tzinteriart_class = 'service_right'
    );

    if ($tzinteriart_align_content == '1') :
        $tzinteriart_class_content = 'tz_content_top';
    elseif ($tzinteriart_align_content == '2') :
        $tzinteriart_class_content = 'tz_content_center';
    elseif($tzinteriart_align_content == '3') :
        $tzinteriart_class_content = 'tz_content_bottom';
    endif;

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

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

    if ($tz_type == '3') :
        $tz_class_type3 = 'tz_Service_type3';
    endif;


    ?>
    <?php if ($tz_type == '1' || $tz_type == '3') : ?>

    <div class="tzElement_Service-v2 <?php echo esc_attr($tz_class_type3); ?> <?php echo esc_attr($interiart_class); ?> <?php echo esc_attr($service_classes); ?>">
        <div class="tzService_Wrap <?php echo esc_html($tzinteriart_class); ?>">
            <div class="tzService_image col-md-5">
                <img src="<?php echo esc_url($tzinteriart_url_img); ?>"
                     width="<?php echo esc_attr($tzinteriart_width_img) ?>"
                     height="<?php echo esc_attr($tzinteriart_height_img) ?>"
                     alt="<?php echo esc_attr($tzinteriart_title); ?>">
            </div>
            <div class="tzService_Info <?php echo esc_attr($tzinteriart_class_content); ?> col-md-7">
                <div class="tzService_Info_Box">
                    <p class="tzService_v2_number"><?php echo esc_html($tzinteriart_number); ?></p>
                    <h3 class="tzService_v2_title" <?php if ($tzinteriart_color){ ?>style="color:<?php echo esc_attr($tzinteriart_color); ?>" <?php } ?> ><?php echo esc_html($tzinteriart_title); ?></h3>
                    <p class="tzService_v2_des"><?php echo esc_html($tzinteriart_des); ?></p>
                    <?php if ($tz_option_button == 'show' && $tzinteriart_readmore_link != '' && $tzinteriart_readmore_text != '') { ?>
                        <a href="<?php echo esc_url($tzinteriart_readmore_link); ?>"
                           class="tzService-v2-readmore"><?php echo esc_html($tzinteriart_readmore_text); ?><span class="lnr lnr-arrow-right"></span></a>
                    <?php } ?>
                </div>
            </div>
        </div>
    </div>

<?php endif; ?>

    <?php if ($tz_type == '2') : ?>

    <div class="interiart-our-process <?php echo esc_attr($interiart_class); ?>">
        <?php
        if ($tzinteriart_number != '') {
            ?>
            <span class="interiart-number-process"><?php echo esc_html($tzinteriart_number); ?></span>
            <?php
        }
        ?>

        <?php
        if ($tzinteriart_title != '') {
            ?>
            <h3 class="interiart-name-process"
                <?php if ($tzinteriart_color){ ?>style="color:<?php echo esc_attr($tzinteriart_color); ?>" <?php } ?>>
                <?php echo esc_html($tzinteriart_title); ?></h3>
            <?php
        }
        ?>
        <?php
        if ($tzinteriart_des != '') {
            ?>
            <p class="interiart-description-process">
                <?php echo balanceTags($tzinteriart_des); ?>
            </p>
            <?php
        }
        ?>

        <?php
        if ($tz_option_button == 'show' && $tzinteriart_readmore_link != '' && $tzinteriart_readmore_text != '') {
            ?>
            <a class="interiart_readmore"
               <?php if ($tzinteriart_color){ ?>style="color:<?php echo esc_attr($tzinteriart_color); ?>" <?php } ?>
               href="<?php echo esc_url($tzinteriart_readmore_link); ?>"><?php echo esc_html($tzinteriart_readmore_text); ?></a>
            <?php
        }
        ?>
    </div>

<?php endif; ?>

    <?php

    return ob_get_clean();
}

add_shortcode('our_service', 'tzinteriart_our_service');
?>
