<?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";
        DigitalSignage4_Translate::setLang(substr(get_bloginfo('language'), 0, 2));
    }


    require_once './DigitalSignage4_DisplayedVideoProduct.php';

    DigitalSignage4_DisplayedVideoProductAjaxHandler::ajax();

    class DigitalSignage4_DisplayedVideoProductAjaxHandler
    {
        public static function ajax()
        {
            $idVideo = isset($_GET['idDemande'])?sanitize_text_field(wp_unslash($_GET['idDemande'])):"";
            $idProduct = isset($_GET['idProduct'])?sanitize_text_field(wp_unslash($_GET['idProduct'])):"";
            if ($idProduct && $idVideo) {
                DigitalSignage4_DisplayedVideoProduct::setDisplayedVideoProduct($idProduct, $idVideo);
                if (DigitalSignage4_DisplayedVideoProduct::getDisplayedVideoProduct($idProduct) == $idVideo) {
                    die("ok");
                }
            }
            die("ko");
        }
    }
