Last active
December 19, 2018 15:08
-
-
Save JPry/7dcf1cea70e9cf21a4be30d98e9ab354 to your computer and use it in GitHub Desktop.
The purpose of these files is explained here: http://jeremypry.com/plugin-theme-development-wordpress-trunk/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// PR #237 broke Valet+ custom drivers, this is a workaround. | |
if ( ! class_exists( 'WordPressValetDriver' ) ) { | |
$driverPath = realpath( $_SERVER['HOME'] ) . '/.composer/vendor/weprovide/valet-plus/cli/drivers/WordPressValetDriver.php'; | |
if ( ! is_readable( $driverPath ) ) { | |
throw new Exception( 'Unable to load the WordPress Valet Driver.' ); | |
} | |
require_once $driverPath; | |
unset( $driverPath ); | |
} | |
/** | |
* Site-specific valet driver. | |
* | |
* @author Jeremy Pry | |
*/ | |
class LocalValetDriver extends WordPressValetDriver { | |
/** | |
* The root of the site. | |
* | |
* @var string | |
*/ | |
protected $siteRoot; | |
/** | |
* Determine if the driver serves the request. | |
* | |
* Always return true, since this is a local driver. | |
* | |
* @param string $sitePath The root path to the current site. | |
* @param string $siteName The name of the current site. | |
* @param string $uri The relative URI to serve. | |
* | |
* @return bool | |
*/ | |
public function serves( $sitePath, $siteName, $uri ) { | |
$this->siteRoot = $sitePath; | |
return true; | |
} | |
/** | |
* Get the fully resolved path to the application's front controller. | |
* | |
* @param string $sitePath The root path to the current site. | |
* @param string $siteName The name of the current site. | |
* @param string $uri The relative URI to serve. | |
* | |
* @return string | |
*/ | |
public function frontControllerPath( $sitePath, $siteName, $uri ) { | |
// Allow serving random PHP files. | |
if ( 'php' === substr( $uri, -3 ) && file_exists( "{$sitePath}{$uri}" ) ) { | |
return "{$sitePath}{$uri}"; | |
} | |
if ( preg_match( '#/(?:wp-)?content#', $uri ) ) { | |
$sitePath .= '/content'; | |
} else { | |
$sitePath .= '/wp/build'; | |
} | |
return parent::frontControllerPath( $sitePath, $siteName, $uri ); | |
} | |
/** | |
* Determine if this is a static file. | |
* | |
* This first tries to find the file at the actual URI. It will then | |
* fall back to the WordPress build directory. If it still doesn't | |
* match a known file, then return false. | |
* | |
* @param string $sitePath The root path to the current site. | |
* @param string $siteName The name of the current site. | |
* @param string $uri The relative URI to serve. | |
* | |
* @return string|false | |
*/ | |
public function isStaticFile( $sitePath, $siteName, $uri ) { | |
if ( $this->isActualFile( $staticFilePath = $sitePath . $uri ) ) { | |
return $staticFilePath; | |
} elseif ( $this->isActualFile( $staticFilePath = "{$sitePath}/wp/build{$uri}" ) ) { | |
return $staticFilePath; | |
} | |
return false; | |
} | |
/** | |
* Load server environment variables if available. | |
* | |
* @param string $sitePath The root path to the current site. | |
* @param string $siteName The name of the current site. | |
*/ | |
protected function loadServerEnvironmentVariables( $sitePath, $siteName ) { | |
if ( file_exists( $varFilePath = $this->siteRoot . '/.env.valet' ) ) { | |
$variables = include $varFilePath; | |
} elseif ( file_exists( $varFilePath = $sitePath . '/.env.valet' ) ) { | |
$variables = include $varFilePath; | |
} else { | |
return; | |
} | |
if ( ! isset( $variables[ $siteName ] ) ) { | |
return; | |
} | |
foreach ( $variables[ $siteName ] as $key => $value ) { | |
$_SERVER[ $key ] = $value; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
path: wp/build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The base configuration for WordPress. | |
* | |
* All extraneous comments (besides this one) removed for brevity. | |
*/ | |
// ** MySQL settings ** // | |
define( 'DB_NAME', '<PROJECT NAME>' ); // Update this value based on the project | |
define( 'DB_USER', '<PROJECT DB USER>' ); | |
define( 'DB_PASSWORD', '<PROJECT DB PASSWORD>' ); | |
define( 'DB_HOST', 'localhost' ); | |
define( 'DB_CHARSET', 'utf8' ); | |
define( 'DB_COLLATE', '' ); | |
/** Authentication Unique Keys and Salts. */ | |
define( 'AUTH_KEY', 'put your unique phrase here' ); | |
define( 'SECURE_AUTH_KEY', 'put your unique phrase here' ); | |
define( 'LOGGED_IN_KEY', 'put your unique phrase here' ); | |
define( 'NONCE_KEY', 'put your unique phrase here' ); | |
define( 'AUTH_SALT', 'put your unique phrase here' ); | |
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' ); | |
define( 'LOGGED_IN_SALT', 'put your unique phrase here' ); | |
define( 'NONCE_SALT', 'put your unique phrase here' ); | |
$table_prefix = 'wp_'; | |
define( 'WP_DEBUG', true ); | |
define( 'WP_DEBUG_DISPLAY', false ); | |
define( 'WP_DEBUG_LOG', true ); | |
define( 'SCRIPT_DEBUG', true ); | |
define( 'JETPACK_DEV_DEBUG', true ); | |
define( 'JETPACK_STAGING_MODE', true ); | |
define( 'WP_POST_REVISIONS', 5 ); | |
define( 'WCS_DEBUG', true ); | |
// Custom content directory | |
define( 'WP_CONTENT_DIR', dirname( __DIR__ ) . '/content' ); | |
define( 'WP_CONTENT_URL', 'https://<PROJECT FOLDER NAME>.test/content' ); | |
/* That's all, stop editing! Happy blogging. */ | |
/** Absolute path to the WordPress directory. */ | |
if ( ! defined( 'ABSPATH' ) ) { | |
define( 'ABSPATH', __DIR__ . '/build/' ); | |
} | |
/** Sets up WordPress vars and included files. */ | |
require_once ABSPATH . 'wp-settings.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The base configuration for WordPress tests. | |
* | |
* All extraneous comments (besides this one) removed for brevity. See wp-tests-config-sample.php. | |
*/ | |
/* Path to the WordPress codebase you'd like to test. Add a forward slash in the end. */ | |
if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) { | |
define( 'ABSPATH', dirname( __FILE__ ) . '/build/' ); | |
} else { | |
define( 'ABSPATH', dirname( __FILE__ ) . '/src/' ); | |
} | |
define( 'WP_DEFAULT_THEME', 'default' ); | |
define( 'WP_TESTS_MULTISITE', false ); | |
define( 'WP_TESTS_FORCE_KNOWN_BUGS', false ); | |
define( 'WP_DEBUG', true ); | |
// ** MySQL settings ** // | |
// WARNING WARNING WARNING! | |
// These tests will DROP ALL TABLES in the database with the prefix named below. | |
// DO NOT use a production database or one that is shared with something else. | |
define( 'DB_NAME', 'wp_test_db' ); // Different from the DB found in wp-config.php!!! | |
define( 'DB_USER', '<TESTS DB USER>' ); | |
define( 'DB_PASSWORD', '<TESTS DB PASSWORD>' ); | |
define( 'DB_HOST', 'localhost' ); | |
define( 'DB_CHARSET', 'utf8' ); | |
define( 'DB_COLLATE', '' ); | |
define( 'AUTH_KEY', 'put your unique phrase here' ); | |
define( 'SECURE_AUTH_KEY', 'put your unique phrase here' ); | |
define( 'LOGGED_IN_KEY', 'put your unique phrase here' ); | |
define( 'NONCE_KEY', 'put your unique phrase here' ); | |
define( 'AUTH_SALT', 'put your unique phrase here' ); | |
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' ); | |
define( 'LOGGED_IN_SALT', 'put your unique phrase here' ); | |
define( 'NONCE_SALT', 'put your unique phrase here' ); | |
$table_prefix = 'wptests_'; | |
// Custom content directory | |
define( 'WP_CONTENT_DIR', dirname( __DIR__ ) . '/content' ); | |
define( 'WP_CONTENT_URL', 'https://<PROJECT FOLDER NAME>.test/content' ); | |
define( 'WP_TESTS_DOMAIN', 'example.org' ); | |
define( 'WP_TESTS_EMAIL', '[email protected]' ); | |
define( 'WP_TESTS_TITLE', 'Test Blog' ); | |
define( 'WP_PHP_BINARY', 'php' ); | |
define( 'WPLANG', '' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment