src/FrontendLoader.php
public function fileServe($query, $callback=null)
    {
        if (!array_key_exists('REQUEST_URI', $_SERVER)) return $query;
        $path_prefix = $this->getPathPrefix();

        if (!preg_match("/$path_prefix\/assets\/(.*)$/i",
         $_SERVER['REQUEST_URI'])) return $query;
            
        $file_path = self::getAssetPath();

        if (!$file_path) return $query;
        
        // check if this file is whitelisted
        if (!$this->shouldLoadFile($this->getAssetFileName())) return $query;

        $content_type = self::getContentType($file_path);
        header('Content-type: ' . $content_type);
        header('Content-Length: ' . filesize($file_path));
        http_response_code(200);
        readfile($file_path);
        if ($callback) {
            $callback();
        }
        exit;
        return $query;
    }
public function fileServe($query, $callback=null)
    {
        if (!array_key_exists('REQUEST_URI', $_SERVER)) return $query;
        $path_prefix = $this->getPathPrefix();

        if (!preg_match("/$path_prefix\/assets\/(.*)$/i",
         $_SERVER['REQUEST_URI'])) return $query;
            
        $file_path = self::getAssetPath();

        if (!$file_path) return $query;
        
        // check if this file is whitelisted
        if (!$this->shouldLoadFile($this->getAssetFileName())) return $query;

        $content_type = self::getContentType($file_path);
        header('Content-type: ' . $content_type);
        header('Content-Length: ' . filesize($file_path));
        http_response_code(200);
        readfile($file_path);
        if ($callback) {
            $callback();
        }
        exit;
        return $query;
    }
public function fileServe ( $ query , $ callback = null ) { if ( ! array_key_exists ( 'REQUEST_URI' , $ _SERVER ) ) return $ query ; $ path_prefix = $ this -> getPathPrefix ( ) ; if ( ! preg_match ( "/$path_prefix\/assets\/(.*)$/i" , $ _SERVER [ 'REQUEST_URI' ] ) ) return $ query ; $ file_path = self :: getAssetPath ( ) ; if ( ! $ file_path ) return $ query ; // check if this file is whitelisted if ( ! $ this -> shouldLoadFile ( $ this -> getAssetFileName ( ) ) ) return $ query ; $ content_type = self :: getContentType ( $ file_path ) ; header ( 'Content-type: ' . $ content_type ) ; header ( 'Content-Length: ' . filesize ( $ file_path ) ) ; http_response_code ( 200 ) ; readfile ( $ file_path ) ; if ( $ callback ) { $ callback ( ) ; } exit ; return $ query ; }
Return a file given the query string
@param array $query - wordpress passes this in and it must be returned
@return file
Return a file given the query string