<?php
extract(shortcode_atts(array(
    'icon_type' => 'fontawesome',
    'button_text'  => 'Button',
    'link_button'  => '#',
    'button_style'  => 'btn',
    'button_size'  => 'size-default',
    'icon_align'  => 'left',
    'button_duplicated'  => '',
    'button_text_duplicated'  => '',
    'link_button_duplicated'  => '',
    'button_style_duplicated'  => '',
    'button_align'  => 'cta-right',
    'cta_subtext'  => '',
    'cta_text'  => '',
    'cta_text_color'  => '',
    'cta_subtext_color'  => '',
    'button_quote'  => 'no',
    'el_class'  => ''       
), $atts));
 
    $icon_name = "icon_" . $icon_type;
    $iconClass = isset($atts[$icon_name])?$atts[$icon_name]:'';
    $link = vc_build_link($link_button);
    $link_duplicated = vc_build_link($link_button_duplicated);
    if ( strlen( $link['url'] ) > 0 ) {
        $a_href = $link['url'];
    }
    if ( strlen( $link_duplicated['url'] ) > 0 ) {
        $a_href_d = $link_duplicated['url'];
    }
?>
<div class="cms-cta-wrapper cms-style-default style1 clearfix <?php echo esc_attr($el_class); ?> <?php echo esc_attr($button_align); ?>">
    <div class="cms-cta-text text-center-md">
        <?php if (!empty($cta_subtext) && $cta_subtext) { ?>
            <div class="subtext" style="color: <?php echo esc_attr($cta_subtext_color); ?>;">
                <?php echo esc_attr($cta_subtext); ?>
            </div> 
        <?php } ?>

        <?php if (!empty($cta_text) && $cta_text) { ?>
        <div class="text" style="color: <?php echo esc_attr($cta_text_color); ?>;">
            <?php echo esc_attr($cta_text); ?>
        </div>
        <?php } ?>
    </div>
    <div class="cms-cta-button text-center-md">
        <?php if($button_duplicated == 'yes') { ?>
            <a href="<?php echo esc_url($a_href_d);?>" class="btn <?php echo esc_attr($button_style_duplicated); ?> <?php echo esc_attr($button_size); ?>">
                <?php switch ($icon_align) {
                    case 'right':
                        ?>
                            <?php echo esc_attr($button_text_duplicated); ?>
                            <?php if(!empty($iconClass)):?>
                            <i class="<?php echo esc_attr($iconClass);?>" style="padding-left: 6px;"></i>
                            <?php endif;?>
                        <?php
                        break;
                    case 'left':
                    default:
                        ?>
                            <?php if(!empty($iconClass)):?>
                                <i class="<?php echo esc_attr($iconClass);?>" style="padding-right: 6px;"></i>     
                            <?php endif;?>
                            <?php echo esc_attr($button_text_duplicated); ?>
                        <?php
                        break;
                }?>
            </a>
        <?php } ?>

        <a href="<?php echo esc_url($a_href);?>" class="<?php if($button_quote == 'yes') { echo 'get-form-quote'; } ?> btn <?php echo esc_attr($button_style); ?> <?php echo esc_attr($button_size); ?>">
            <?php switch ($icon_align) {
                case 'right':
                    ?>
                        <?php echo esc_attr($button_text); ?>
                        <?php if(!empty($iconClass)):?>
                        <i class="<?php echo esc_attr($iconClass);?>" style="padding-left: 6px;"></i>
                        <?php endif;?>
                    <?php
                    break;
                case 'left':
                default:
                    ?>
                        <?php if(!empty($iconClass)):?>
                            <i class="<?php echo esc_attr($iconClass);?>" style="padding-right: 6px;"></i>     
                        <?php endif;?>
                        <?php echo esc_attr($button_text); ?>
                    <?php
                    break;
            }?>
        </a>
    </div>
</div>