<?php
$is_new = \Elementor\Icons_Manager::is_migration_allowed();
$widget->add_render_attribute( 'wrapper', 'class', 'pxl-button'. ' ' . $settings['btn_action'] );
$widget->add_render_attribute('button', 'class', $settings['btn_style'] . ' ' . $settings['pxl_animate']);
if ( ! empty( $settings['link']['url'] ) ) {
    $widget->add_render_attribute( 'button', 'href', $settings['link']['url'] );

    if ( $settings['link']['is_external'] ) {
        $widget->add_render_attribute( 'button', 'target', '_blank' );
    }

    if ( $settings['link']['nofollow'] ) {
        $widget->add_render_attribute( 'button', 'rel', 'nofollow' );
    }
}

$template = (int)$widget->get_setting('popup_template','0');
if($template > 0 ){
    if ( !has_action( 'pxl_anchor_target_page_popup_'.$template) ){
        add_action( 'pxl_anchor_target_page_popup_'.$template, 'kaitex_hook_anchor_page_popup' );
    }
}
?>
<div <?php pxl_print_html($widget->get_render_attribute_string( 'wrapper' )); ?>>
    <a <?php pxl_print_html($widget->get_render_attribute_string( 'button' )); ?> data-wow-delay="<?php echo esc_attr($settings['pxl_animate_delay']); ?>ms" data-wow-duration="<?php echo esc_attr($settings['pxl_animate_duration']); ?>s">
        <?php if($settings['btn_style'] == 'button-icon btn-default') :
            $is_new = \Elementor\Icons_Manager::is_migration_allowed(); ?>
            <?php if ( $is_new ) : ?>
                <?php \Elementor\Icons_Manager::render_icon( $settings['pxl_icon'], [ 'aria-hidden' => 'true' ] ); ?>
            <?php elseif ( ! empty( $settings['pxl_icon'] ) ) : ?>
                <i class="<?php echo esc_attr( $settings['pxl_icon'] ); ?>" aria-hidden="true"></i>
            <?php endif; ?>
        <?php endif; ?>
        <?php if($settings['button_effect'] != '') { ?>
            <span class="btn-text pxl-wobble" data-text="<?php echo esc_attr($settings['text']); ?>" data-animation="<?php echo esc_attr($settings['button_effect']); ?>">
                <?php if(!empty($settings['text'])) {
                    $btn_text = $settings['text'];
                } else {
                    $btn_text = esc_html__('Click Here', 'kaitex');
                }
                $words = explode(' ', $btn_text);
                foreach ($words as $word) {
                    echo '<span>' . htmlspecialchars($word) . '</span> ';
                }
                ?>
            </span>
        <?php } else { ?>
            <span class="btn-text" data-text="<?php echo esc_attr($settings['text']); ?>">
                <?php echo pxl_print_html($settings['text']);?>
            </span>
        <?php } ?>
    </a>
</div>