SHARE
TWEET

Untitled

a guest Aug 25th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. class WordpressSubdirectoryValetDriver extends BasicValetDriver
  4. {
  5.     /**
  6.      * Determine if the driver serves the request.
  7.      *
  8.      * @param  string  $sitePath
  9.      * @param  string  $siteName
  10.      * @param  string  $uri
  11.      * @return bool
  12.      */
  13.     public function __construct() {
  14.         $this->subfolder = 'wp';
  15.     }
  16.  
  17.  
  18.     public function serves($sitePath, $siteName, $uri)
  19.     {        
  20.         return is_dir($sitePath . '/public/' . $this->subfolder . '/wp-admin');
  21.     }
  22.  
  23.     /**
  24.      * Get the fully resolved path to the application's front controller.
  25.      *
  26.      * @param  string  $sitePath
  27.      * @param  string  $siteName
  28.      * @param  string  $uri
  29.      * @return string
  30.      */
  31.     public function frontControllerPath($sitePath, $siteName, $uri)
  32.     {
  33.         $_SERVER['PHP_SELF'] = $uri;
  34.         if (0 === strpos($uri, '/wp/')) {
  35.             return is_dir($sitePath.'/public'.$uri)
  36.                 ? $sitePath.'/public'.$uri.'/index.php'
  37.                 : $sitePath.'/public'.$uri;
  38.         }
  39.         return $sitePath.'/public/index.php';
  40.     }
  41.  
  42.     public function isStaticFile($sitePath, $siteName, $uri)
  43.     {
  44.         $staticFilePath = $sitePath.'/public/'.$uri;
  45.         if (file_exists($staticFilePath) && ! is_dir($staticFilePath)) {
  46.             return $staticFilePath;
  47.         }
  48.         return false;
  49.     }    
  50. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top