<?php
/**
 * Its used for dependacy check
 *
 * @since: 21/09/2021
 * @author: Sarwar Hasan
 * @version 1.0.0
 * @package VitePos\Libs
 */

namespace Vite_Reward_Lite\Libs;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

use Appsbd_DCI\v1\Appsbd_Insights_SDK;
use Appsbd_Lite\V5\libs\WP_Loader;

require_once __DIR__ . '/class-vite-reward-addons.php';

if ( ! class_exists( __NAMESPACE__ . '\Vite_Reward_Loader' ) ) {
	/**
	 * Class Vitepos_Loader
	 *
	 * @package VitePos\Libs
	 */
	class Vite_Reward_Loader extends WP_Loader {

		/**
		 * The set details is generated by appsbd
		 *
		 * @return mixed|void
		 */
		public function set_details() {
			$this->plugin_file     = 'vite-rewards/vite-rewards.php';
			$this->pro_plugin_file = 'vite-rewards-pro/vite-rewards-pro.php';
		}

		/**
		 * The dci plugin vitepos lite is generated by appsbd
		 */
		public function dci_plugin_vite_reward_lite() {
			$custom_data = array(
				'version' => $this->plugin_version,
			);
			$data_skip   = false;
			if ( function_exists( 'appsbd_is_activated_plugin' ) && appsbd_is_activated_plugin( 'vite-rewards-pro/vite-rewards-pro.php' ) ) {
				$data_skip = true;
			}
			Appsbd_Insights_SDK::start_dci(
				array(
					'sdk_version'          => '1.2.1',
					'product_id'           => 4,
					'plugin_name'          => 'Vite Rewards',
					'data_skip'            => $data_skip,
					'version'              => $this->plugin_version,

					'plugin_title'         => 'Vite Rewards',

					'plugin_icon'          => 'rwd rwd-website-icon',
					'icon_size'            => '25px',
					'color'                => array(
						'icon'         => '#9f0a56',
						'color1'       => '#9f0a56',
						'color2'       => '#e166a5',
						'hover_color1' => '#e166a5',
						'hover_color2' => '#9f0a56',
						'skip'         => '#f6e0ff',
						'skip_hover'   => '#f7a6d7',

					),

					'api_endpoint'         => 'https://analytics.appsbd.com/wp-json/dci/v1/data-insights',
					'slug'                 => 'vite-rewards',

					'core_file'            => false,
					'plugin_deactivate_id' => 'vite-rewards',
					'menu'                 => array(
						'slug' => 'ab-vite-rewards',
					),
					'public_key'           => 'pk_nqplaUBrIXDS1sbx0dst7vku6yHEdOZ0',
					'key_prefix'           => 'vite_rewards',
					'is_premium'           => false,
					'custom_data'          => $custom_data,
					'popup_notice'         => false,
					'deactivate_feedback'  => true,
					'delay_time'           => array(
						'time' => 0,
					),
					'text_domain'          => 'vite-rewards',
					'plugin_msg'           => __(
						'Please help us by contributing anonymous usage data to improve our product, without collecting any sensitive information.',
						'vite-rewards'
					),
				)
			);
		}

		/**
		 * The load before ready is generated by appsbd
		 *
		 * @param bool $result Its a result.
		 *
		 * @return bool
		 */
		public function load_before_ready( $result ) {
			add_action( 'admin_init', array( $this, 'dci_plugin_vite_reward_lite' ) );
			new Vite_Reward_Addons( $result, $this->base_file, $this );

			return parent::load_before_ready( $result );
		}
	}
}
