File: /var/www/linde/wp-content/plugins/lindevr-site-plugin/video/rest.php
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
// create a REST API endpoint on /wp-json/linde-vr-video/v1/checkVersion that triggers check_version function
add_action('rest_api_init', function () {
register_rest_route( 'linde-vr-video/v1', 'checkVersion',array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'linde_check_video_version',
'permission_callback' => '__return_true'
));
});
function linde_check_video_version(){
$video = get_field('video_file', 'option');
$version = get_field( 'video_version', 'option', true );
echo json_encode(array(
'url' => $video['url'],
'version' => $version
));
}
?>