<?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 __DIR__ . "/../../Classes/DigitalSignage4_Tools.php";
    require_once __DIR__ . "/../../Kernel/API/Manager/DigitalSignage4_Exception.php";
    require_once __DIR__ . "/../../Kernel/Translations/DigitalSignage4_Translate.php";
    require_once __DIR__ . "/../../Classes/DigitalSignage4_caller.php";
    require_once __DIR__ . "/../../Kernel/API/Manager/DigitalSignage4_DemandeManager.php";
    require_once __DIR__ . "/../../controllers/override/UpdateVideoHandleManager.php";

    $demande_items = "false";

    check_admin_referer( 'ds4_form_nonce' );
    
    if (isset($_GET['demande_items']) && $_GET['demande_items'] == "true") {
        $demande_items = "true";
    }

    $videoHandlerManager = new DigitalSignage4_UpdateVideoHandlerManager($demande_items, (isset($_GET['demande_id'])) ? sanitize_text_field(wp_unslash($_GET['demande_id'])) : null, (isset($_GET['product_id'])) ? sanitize_text_field(wp_unslash($_GET['product_id'])) : null);
    $videoHandlerManager->echoHtmlDatas();
