3a17009c by Chris Boden

Updated to work when placed symbolically

1 parent b0ef0a50
...@@ -15,12 +15,20 @@ use Exception; ...@@ -15,12 +15,20 @@ use Exception;
15 15
16 spl_autoload_register(__NAMESPACE__ . '\autoloader'); 16 spl_autoload_register(__NAMESPACE__ . '\autoloader');
17 17
18 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'wp_functions.php'); 18 // Code to prevent PHP from parsing Symlinks
19 if (defined(__NAMESPACE__ . '\DIR')) {
20 define(__NAMESPACE__ . '\OVERRIDE', 1);
21 } else {
22 define(__NAMESPACE__ . '\DIR', __DIR__);
23 }
24 define(__NAMESPACE__ . '\FILE', DIR . DIRECTORY_SEPARATOR . basename(__FILE__));
25
26 require_once(DIR . DIRECTORY_SEPARATOR . 'wp_functions.php');
19 27
20 _register_script('addEvent', url('scripts/addEvent.js', __FILE__)); 28 _register_script('addEvent', url('scripts/addEvent.js', FILE));
21 _register_script('xmlhttpHandler', url('scripts/xmlhttpHandler.js', __FILE__)); 29 _register_script('xmlhttpHandler', url('scripts/xmlhttpHandler.js', FILE));
22 _register_script('fireEvent', url('scripts/fireEvent.js', __FILE__)); 30 _register_script('fireEvent', url('scripts/fireEvent.js', FILE));
23 _register_script('Cookie', url('scripts/Cookie/Cookie.js', __FILE__)); 31 _register_script('Cookie', url('scripts/Cookie/Cookie.js', FILE));
24 32
25 import('ShortCodes'); 33 import('ShortCodes');
26 if (defined('Tz\DEBUG') && Tz\DEBUG === true) { 34 if (defined('Tz\DEBUG') && Tz\DEBUG === true) {
...@@ -28,7 +36,7 @@ use Exception; ...@@ -28,7 +36,7 @@ use Exception;
28 } 36 }
29 37
30 function import($com) { 38 function import($com) {
31 $dir = __DIR__ . DIRECTORY_SEPARATOR . 'com' . DIRECTORY_SEPARATOR . $com . DIRECTORY_SEPARATOR; 39 $dir = DIR . DIRECTORY_SEPARATOR . 'com' . DIRECTORY_SEPARATOR . $com . DIRECTORY_SEPARATOR;
32 $file = $dir . $com . '.php'; 40 $file = $dir . $com . '.php';
33 if (is_dir($dir) && is_file($file)) { 41 if (is_dir($dir) && is_file($file)) {
34 require_once($file); 42 require_once($file);
...@@ -40,14 +48,18 @@ function autoloader($class) { ...@@ -40,14 +48,18 @@ function autoloader($class) {
40 $a = explode('\\', $class); 48 $a = explode('\\', $class);
41 $class = array_pop($a); 49 $class = array_pop($a);
42 50
43 $file = __DIR__ . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . $class . '.php'; 51 $file = DIR . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . $class . '.php';
44 if (is_file($file)) { 52 if (is_file($file)) {
45 include($file); 53 include($file);
46 } 54 }
47 } 55 }
48 56
49 function url($script, $base_file = false) { 57 function url($script, $base_file = false) {
50 $base_dir = (false === $base_file ? __DIR__ : dirname($base_file)); 58 if (defined(__NAMESPACE__ . '\OVERRIDE')) {
59 $base_file = str_replace(__DIR__, DIR, $base_file);
60 }
61
62 $base_dir = (false === $base_file ? DIR : dirname($base_file));
51 $rel_path = str_replace(ABSPATH, '', $base_dir); 63 $rel_path = str_replace(ABSPATH, '', $base_dir);
52 $script = site_url() . '/' . $rel_path . '/' . $script; 64 $script = site_url() . '/' . $rel_path . '/' . $script;
53 65
......