-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.php
More file actions
41 lines (30 loc) · 819 Bytes
/
init.php
File metadata and controls
41 lines (30 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/**
* Created by PhpStorm.
* User: Bryce Meyer
* Date: 8/12/15
* Time: 1:56 PM
*/
$parentDirectory = dirname(__DIR__);
$wordPressLoad = findWordPressLoad($parentDirectory);
if($wordPressLoad) {
require($wordPressLoad);
}
else
throw new Exception("Unable to find word press root");
function findWordPressLoad($directory) {
$dir = new DirectoryIterator($directory);
$wordPressRoot = false;
foreach ($dir as $file) {
if($file->isDir() && !$file->isDot()) {
$wordPressRoot = findWordPressLoad($directory . "/" . $file);
if($wordPressRoot)
break;
}
elseif($file->getFilename() == "wp-load.php") {
$wordPressRoot = $directory . "/wp-load.php";
break;
}
}
return $wordPressRoot;
}