Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter d1gsolutions

    (@d1gsolutions)

    Hi @valwa ,
    Thank you for your quick answer. I’ve tried to use both (meow_mwcode_white_listed_rest,meow_mwcode_white_listed_rest_authorized) hooks, but it didn’t worked. Maybe I’m doing something wrong, or I don’t understand how to use it.
    I’m quite new with WordPress&Wordpress plugins. I added the following code to functions.php, but the function is never executed.

    // Custom function to authorize specific routes
    function custom_meow_mwcode_white_listed_rest_authorized($authorized, $requested_route) {
    // Debug: Log the function call
    error_log('custom_meow_mwcode_white_listed_rest_authorized called');
    
    // Custom allowed routes
    $custom_allowed_routes = array(
        '/',
        '/blog/'
    );
    
    // Check if the requested route starts with any of the custom allowed routes
    foreach ($custom_allowed_routes as $route) {
        if (strpos($requested_route, $route) === 0) {
            // Debug: Log the matched route
            error_log('Authorized route: ' . $route);
    
            $authorized = true;
            break;
        }
    }
    
    return $authorized;
    }
    
    // Adding the custom function to the filter
    add_filter('meow_mwcode_white_listed_rest_authorized', 'custom_meow_mwcode_white_listed_rest_authorized', 10, 2);

    I’m trying to use Snippet Vault Plugin to store the code that I usually put inside functions.php.
    I like the idea that I can Import/Export my snippets and that I have a Snippet Endpoint that I can use.

    Thank you,
    Catalin

Viewing 1 replies (of 1 total)