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

    class CIWS_Library
    {

        /**
         * Exit for unauthorized access
         *
         * @since 1.0.0
         */
        function permission_denied()
        {
            die('No script kiddies please!!');
        }



        /**
         * Fetches the account row from account table
         *
         * @global object $wpdb
         * @param int $account_id
         * @return object
         */
        public static function get_account_row_by_id($account_id)
        {
            global $wpdb;

            $account_row = $wpdb->get_row($wpdb->prepare("select * from %i where account_id = %d", CIWS_TABLE, $account_id));

            return $account_row;
        }

        /**
         * 
         * to show in specific page
         * @param mixed $main_settings
         * @return bool
         */
        function ciws_should_show_floating_icon($main_settings)
        {
            if (empty($main_settings['display']))
                return true;

            $display = $main_settings['display'];


            if (is_front_page() && !empty($display['home_page']))
                return false;
            if (is_archive() && !empty($display['archive_page']))
                return false;


            return true;
        }


    }

    // Initialize the class as a global variable
    $GLOBALS['ciws_library'] = new CIWS_Library();
}
