[READ-ONLY] Mirror of https://github.com/danielroe/trellis-valet-driver. A driver for Laravel Valet that supports the default Trellis install.
0

Configure Feed

Select the types of activity you want to include in your feed.

Up to date with Bedrock driver

+27 -10
+27 -10
TrellisValetDriver.php
··· 8 8 * @param string $sitePath 9 9 * @param string $siteName 10 10 * @param string $uri 11 - * @return void 11 + * @return bool 12 12 */ 13 13 public function serves($sitePath, $siteName, $uri) 14 14 { 15 - return ( 16 - file_exists("$sitePath/site/config/application.php") 17 - && file_exists("$sitePath/site/web/wp-config.php") 18 - && is_dir("$sitePath/site/web/app/") 19 - ); 15 + return file_exists($sitePath . '/site/web/app/mu-plugins/bedrock-autoloader.php') || 16 + (is_dir($sitePath . '/site/web/app/') && 17 + file_exists($sitePath . '/site/web/wp-config.php') && 18 + file_exists($sitePath . '/site/config/application.php')); 20 19 } 21 20 22 21 /** ··· 29 28 */ 30 29 public function isStaticFile($sitePath, $siteName, $uri) 31 30 { 32 - $staticFilePath = $sitePath . '/site/web/' . $uri; 33 - if (file_exists($staticFilePath) && !is_dir($staticFilePath)) { 31 + $staticFilePath = $sitePath . '/site/web' . $uri; 32 + if ($this->isActualFile($staticFilePath)) { 34 33 return $staticFilePath; 35 34 } 36 35 return false; ··· 46 45 */ 47 46 public function frontControllerPath($sitePath, $siteName, $uri) 48 47 { 49 - if (0 === strpos($uri, '/wp/')) { 50 - return $sitePath . '/site/web' . $uri; 48 + $_SERVER['PHP_SELF'] = $uri; 49 + if (strpos($uri, '/wp/') === 0) { 50 + return is_dir($sitePath . '/site/web' . $uri) 51 + ? $sitePath . '/site/web' . $this->forceTrailingSlash($uri) . '/index.php' 52 + : $sitePath . '/site/web' . $uri; 51 53 } 52 54 return $sitePath . '/site/web/index.php'; 55 + } 56 + 57 + /** 58 + * Redirect to uri with trailing slash. 59 + * 60 + * @param string $uri 61 + * @return string 62 + */ 63 + private function forceTrailingSlash($uri) 64 + { 65 + if (substr($uri, -1 * strlen('/wp/wp-admin')) == '/wp/wp-admin') { 66 + header('Location: ' . $uri . '/'); 67 + die; 68 + } 69 + return $uri; 53 70 } 54 71 }