1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-07 09:10:03 +01:00
Files
laravel-valet/cli/Valet/Drivers/Specific/WordPressValetDriver.php
2023-02-07 21:13:39 -05:00

40 lines
1014 B
PHP

<?php
namespace Valet\Drivers\Specific;
use Valet\Drivers\BasicValetDriver;
class WordPressValetDriver extends BasicValetDriver
{
/**
* Determine if the driver serves the request.
*/
public function serves(string $sitePath, string $siteName, string $uri): bool
{
return file_exists($sitePath.'/wp-config.php') || file_exists($sitePath.'/wp-config-sample.php');
}
/**
* Get the fully resolved path to the application's front controller.
*/
public function frontControllerPath(string $sitePath, string $siteName, string $uri): ?string
{
return parent::frontControllerPath(
$sitePath, $siteName, $this->forceTrailingSlash($uri)
);
}
/**
* Redirect to uri with trailing slash.
*/
private function forceTrailingSlash($uri): ?string
{
if (substr($uri, -1 * strlen('/wp-admin')) == '/wp-admin') {
header('Location: '.$uri.'/');
exit;
}
return $uri;
}
}