<?php
//static::ASSETS_DATA_TRANSIENT_KEY => _elementor_home_screen_data
add_filter('pre_http_request',function($data,$parsed_args, $url){
    if ($url=='https://assets.elementor.com/home-screen/v1/home-screen.json'){
        $endpoint_data=checkAccessToEndpoint('https://assets.elementor.com/home-screen/v1/home-screen.json');
        if (empty($endpoint_data)){
            $file_data = file_get_contents( __DIR__."/online-data/home-screen.json" );
        }

        $data=[];
        $data['body'] = $endpoint_data ?? $file_data;
    }
    return $data;
},10,3);

//use Elementor\Includes\EditorAssetsAPI;

//add_filter( 'elementor/core/admin/homescreen', function ( $assets_data ) {
//    if (!empty($assets_data)){
//        return $assets_data;
//    }
//
//    $data= file_get_contents( __DIR__."/online-data/home-screen.json" );
//    $data = json_decode($data, true)['home-screen']??[];
//    if (!empty($data)){
//        $transitionData = [
//            'timeout' => strtotime( '+1 hour', current_time( 'timestamp' ) ),
//            'value' => wp_json_encode( $data ),
//        ];
//        update_option('_elementor_home_screen_data',$transitionData,false);
//    }
//    return $data;
//} );

