File "CapCheckerMiddleware.php"

Full Path: /home/warrior1/public_html/wp-content-20241001222009/plugins/file-manager/backend/app/Http/Middleware/CapCheckerMiddleware.php
File size: 611 bytes
MIME-type: text/x-php
Charset: utf-8

<?php

namespace BitApps\FM\Http\Middleware;

use BitApps\WPKit\Http\Request\Request;
use BitApps\WPKit\Utils\Capabilities;

final class CapCheckerMiddleware
{
    public function handle(Request $request, $cap)
    {
        if (!$cap || !Capabilities::filter($cap)) {
            echo wp_json_encode(
                [
                    'message' => __('You are not authorized to access this endpoint', 'file-manager'),
                    'code'    => 'NOT_AUTHORIZED',
                    'status'  => 'error',
                ]
            );
            wp_die();
        }

        return true;
    }
}