@@ -46,9 +46,12 @@ protected function pluginsLoader(string $root): void
4646 }
4747 }
4848
49- protected function readDir (string $ root = null ): bool
49+ protected function readDir (? string $ root = null ): bool
5050 {
51- if (empty ($ root ) === true || in_array (substr (basename ($ root ), 0 , 1 ), ['. ' , '.. ' ]) === true ) {
51+ if (
52+ $ root === null ||
53+ in_array (substr (basename ($ root ), 0 , 1 ), ['. ' , '.. ' ]) === true
54+ ) {
5255 return false ;
5356 }
5457
@@ -58,7 +61,7 @@ protected function readDir(string $root = null): bool
5861
5962 $ dirname = basename ($ root );
6063
61- $ entry = $ root . DIRECTORY_SEPARATOR . 'index.php ' ;
64+ $ entry = $ root . DIRECTORY_SEPARATOR . 'index.php ' ;
6265 $ script = $ root . DIRECTORY_SEPARATOR . 'index.js ' ;
6366 $ styles = $ root . DIRECTORY_SEPARATOR . 'index.css ' ;
6467
@@ -74,14 +77,18 @@ protected function readDir(string $root = null): bool
7477 return true ;
7578 }
7679
77- protected function getRootPath (string $ root = null ): string
80+ protected function getRootPath (? string $ root = null ): string
7881 {
79- $ index = kirby ()->root ();
80-
81- if (is_dir ($ root ) === false && strpos ($ root , $ index ) === false ) {
82- $ root = $ index . DIRECTORY_SEPARATOR . ltrim ($ root , DIRECTORY_SEPARATOR );
82+ $ baseRoot = App::instance ()->root ();
83+
84+ if (
85+ $ root !== null &&
86+ is_dir ($ root ) === false &&
87+ strpos ($ root , $ baseRoot ) === false
88+ ) {
89+ return $ baseRoot . DIRECTORY_SEPARATOR . ltrim ($ root , DIRECTORY_SEPARATOR );
8390 }
8491
85- return $ root ;
92+ return $ baseRoot ;
8693 }
8794}
0 commit comments