Skip to content

Instantly share code, notes, and snippets.

@ptahdunbar
Last active September 27, 2015 08:37
Show Gist options
  • Save ptahdunbar/1241505 to your computer and use it in GitHub Desktop.
Save ptahdunbar/1241505 to your computer and use it in GitHub Desktop.
// Find wp-config.php
for ( $i = 0; $i < $depth = 10; $i++ ) {
$path = str_repeat( '../', $i );
if ( file_exists( $path . 'wp-config.php' ) ) {
require_once( $path . 'wp-config.php' );
break;
}
}
// v2
define('SHORTINIT', true);
// Find wp-config.php
$subdirectory = 'wp/';
for ( $i = 0; $i < $depth = 10; $i++ ) {
$path = str_repeat( '../', $i );
$dir = rtrim(realpath($path . $subdirectory), '/');
if ( file_exists( $dir . '/wp-load.php' ) ) {
require_once( $dir . '/wp-config.php' );
break;
} else if ( file_exists( $dir . '/../wp-config.php' ) ) {
require_once( $dir . '/../wp-config.php' );
break;
}
}
// find wp-load.php
// Find wp-load.php
$subdirectory = 'wp/';
for ( $i = 0; $i < $depth = 10; $i++ ) {
$path = str_repeat( '../', $i );
$dir = rtrim(realpath($path . $subdirectory), '/');
if ( file_exists( $dir . '/wp-load.php' ) ) {
require_once( $dir . '/wp-load.php' );
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment