<?php
defined('ABSPATH') or die('No script kiddies please!!');
if (!class_exists('CIWS_Floating_Icon')) {
    class CIWS_Floating_Icon extends CIWS_Library {
        function __construct() {

            add_action('wp_footer', [$this, 'ciws_floating_icon']);
        }

        function ciws_floating_icon() {
            $ciws_floating_settings = get_option('ciws_floating_settings');
            if (empty($ciws_floating_settings)) {
                return;
            }
            $selected_account = (!empty($ciws_floating_settings['select_account']['ciws_floating_account_id'])) ? $ciws_floating_settings['select_account']['ciws_floating_account_id'] : '';
            $account_row = $this->get_account_row_by_id($selected_account);
            $account_details = maybe_unserialize($account_row->ciws_account_details);
            
            $box_status = (!empty($ciws_floating_settings['layout']['box_status'])) ? $ciws_floating_settings['layout']['box_status'] : 'none';
          
            $form_label = (!empty($ciws_floating_settings['layout']['form_label'])) ? $ciws_floating_settings['layout']['form_label'] : [];
            $form_label_array = maybe_unserialize($form_label);
            $ciws_main_settings = get_option('ciws_main_settings');
            if (!$this->ciws_should_show_floating_icon($ciws_main_settings)) {
                return;
            }
            if ($box_status == 'greeting') {
                include(CIWS_PATH . '/includes/views/frontend/ciws-greeting-template.php');
            }
            elseif ($box_status == 'floating') {
                include(CIWS_PATH . '/includes/views/frontend/ciws-floating-icon-with-box.php');
            }  else {
                include(CIWS_PATH . '/includes/views/frontend/ciws-floating-icon.php');
            }
        }
    }

    new CIWS_Floating_Icon();
}
 