protected function is_valid_file($path) {
        global $CFG;

        $realpath = realpath($path);

        // Additional theme directory.
        $addthemedirectory = core_component::get_plugin_types()['theme'];
        $addrealroot = realpath($addthemedirectory);

        // Original theme directory.
        $themedirectory = $CFG->dirroot . "/theme";
        $realroot = realpath($themedirectory);

        // File should end in .scss and must be in sites theme directory, else ignore it.
        $pathvalid = $realpath !== false;
        $pathvalid = $pathvalid && (substr($path, -5) === '.scss');
        $pathvalid = $pathvalid && (strpos($realpath, $realroot) === 0 || strpos($realpath, $addrealroot) === 0);
        return $pathvalid;
    }