VersionPress\Api\VersionPressApi::handleAsAdminSectionRoute PHP Method

handleAsAdminSectionRoute() private method

Adds WP_ADMIN constant before route handling function is called. Routes calls are than evaluated as called in admin section of WordPress even if the routes are called using AJAX (WordPress native function is_admin() evaluates call correctly.
private handleAsAdminSectionRoute ( string $routeHandler ) : Closure
$routeHandler string
return Closure
    private function handleAsAdminSectionRoute($routeHandler)
    {
        return function (WP_REST_Request $request) use($routeHandler) {
            if (!defined('WP_ADMIN')) {
                define('WP_ADMIN', true);
            }
            return $this->{$routeHandler}($request);
        };
    }