<?php
if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly

$wrapper_cls = 'rivax-advanced-button-wrapper';
if($settings['button_hover_animation']) {
    $wrapper_cls .= " elementor-animation-" . $settings['button_hover_animation'];
}

$this->add_link_attributes( 'button', $settings['button_url'] );
$this->add_render_attribute('button', 'class', "rivax-advanced-button style-" . $settings['button_style']);

if($settings['title_animation']) {
    $this->add_render_attribute('button', 'class', "hover-" . $settings['title_animation']);
}

if($settings['button_show_icon'] && $settings['button_icon']['value']) {
    $this->add_render_attribute('button', 'class', "icon-" . $settings['button_icon_position']);
}

?>
<div class="<?php echo esc_attr($wrapper_cls); ?>">
    <a <?php $this->print_render_attribute_string( 'button' ); ?> title="<?php echo esc_attr($settings['button_text']); ?>">
        <?php
        if(in_array(intval($settings['button_style']), [4, 5, 14, 15, 16, 9, 10])) {
            echo '<span class="bg"></span>';
        }
        if($settings['button_style'] == 11) {
            echo '<span class="circle"><span class="arrow"></span></span>';
        }
        ?>
        <span class="title-wrap">
            <?php if($settings['button_show_icon'] && $settings['button_icon']['value']): ?>
                <span class="icon">
		    <?php
            \Elementor\Icons_Manager::render_icon( $settings['button_icon'] );
                if($settings['title_animation'] == 'icon-up') {
                    \Elementor\Icons_Manager::render_icon( $settings['button_icon'] );
                }
            ?>
            </span>
            <?php endif; ?>
            <span class="title" data-title="<?php echo esc_attr($settings['button_text']); ?>"><?php echo esc_html($settings['button_text']); ?></span>
        </span>
    </a>
</div>

