<?php
/*
 * security - Securize the API
 *
 * This function is used to secure the API
 */

 /*add_filter('rest_endpoints', function($endpoints) {

    $allowed_endpoints = array(
        "cass-group-list",
        "cass-level-list",
        "cass-race-list",
        "cass-shortcode-member-course-list",
        "cass-race-list-element",
        "cass-member-signedup",
        "cass-dashboard-course-state",
        "cass-race-list-element",
    );

    //Disable all other endpoints
    foreach ($endpoints as $route => $details) {
        //Check if the route is contained in une part of string of allowed_endpoints
        $isAllowed = false;
        foreach ($allowed_endpoints as $allowed_endpoint) {
            if (strpos($route, $allowed_endpoint) !== false) {
                $isAllowed = true;
            }
        }

        if (!$isAllowed) {
            unset($endpoints[$route]);
        }
    }

    return $endpoints;
});*/
