<?php

    if ( ! defined( 'ABSPATH' ) ) exit; //It was a ajax file
    
    if (file_exists("./../../../../wp-load.php")) {
        define('WP_USE_THEMES', false); // Don't load theme support functionality
        require('./../../../../wp-load.php');
    } else {
        require('./../../../../config/config.inc.php');
        require('./../../../../init.php');
        require_once"./../../digitalsignage4.php";
    }

    require_once './DigitalSignage4_CreationVideoSpecialDataProvider.php';


    if (isset($_GET['digitalSignageSpecialData'])) {
		
		
		if (isset($_GET['ia_question'])) {
			$datasProvider = new DigitalSignage4_CreationVideoSpecialDataProvider();
			$retour=$datasProvider->IA_description((isset($_GET['ia_question'])?sanitize_text_field(wp_unslash($_GET['ia_question'])):""),(isset($_GET['id_product'])?sanitize_text_field(wp_unslash($_GET['id_product'])):""));
			ob_get_clean();
            echo(esc_html($retour));
			
		} else {
		    $handler = new DigitalSignage4_CreationVideoSpecialDataProviderAjaxHandler((isset($_GET['digitalSignageSpecialData'])?sanitize_text_field(wp_unslash($_GET['digitalSignageSpecialData'])):""));
			$handler->display();
		}
    }


    class DigitalSignage4_CreationVideoSpecialDataProviderAjaxHandler
    {
        public $data = "";

        public function __construct($request)
        {
            $datasProvider = new DigitalSignage4_CreationVideoSpecialDataProvider();
            
            $callableFunctionData = array($datasProvider, $request);
            if (is_callable($callableFunctionData)) {
                $this->data = call_user_func($callableFunctionData);
            } else {
                $this->data=$request;
            }
        }

        public function display()
        {
            ob_get_clean();
            echo(esc_html($this->data));
            die();
        }
    }
