3a17009c by Chris Boden

Updated to work when placed symbolically

1 parent b0ef0a50
......@@ -15,12 +15,20 @@ use Exception;
spl_autoload_register(__NAMESPACE__ . '\autoloader');
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'wp_functions.php');
// Code to prevent PHP from parsing Symlinks
if (defined(__NAMESPACE__ . '\DIR')) {
define(__NAMESPACE__ . '\OVERRIDE', 1);
} else {
define(__NAMESPACE__ . '\DIR', __DIR__);
}
define(__NAMESPACE__ . '\FILE', DIR . DIRECTORY_SEPARATOR . basename(__FILE__));
require_once(DIR . DIRECTORY_SEPARATOR . 'wp_functions.php');
_register_script('addEvent', url('scripts/addEvent.js', __FILE__));
_register_script('xmlhttpHandler', url('scripts/xmlhttpHandler.js', __FILE__));
_register_script('fireEvent', url('scripts/fireEvent.js', __FILE__));
_register_script('Cookie', url('scripts/Cookie/Cookie.js', __FILE__));
_register_script('addEvent', url('scripts/addEvent.js', FILE));
_register_script('xmlhttpHandler', url('scripts/xmlhttpHandler.js', FILE));
_register_script('fireEvent', url('scripts/fireEvent.js', FILE));
_register_script('Cookie', url('scripts/Cookie/Cookie.js', FILE));
import('ShortCodes');
if (defined('Tz\DEBUG') && Tz\DEBUG === true) {
......@@ -28,7 +36,7 @@ use Exception;
}
function import($com) {
$dir = __DIR__ . DIRECTORY_SEPARATOR . 'com' . DIRECTORY_SEPARATOR . $com . DIRECTORY_SEPARATOR;
$dir = DIR . DIRECTORY_SEPARATOR . 'com' . DIRECTORY_SEPARATOR . $com . DIRECTORY_SEPARATOR;
$file = $dir . $com . '.php';
if (is_dir($dir) && is_file($file)) {
require_once($file);
......@@ -40,14 +48,18 @@ function autoloader($class) {
$a = explode('\\', $class);
$class = array_pop($a);
$file = __DIR__ . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . $class . '.php';
$file = DIR . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . $class . '.php';
if (is_file($file)) {
include($file);
}
}
function url($script, $base_file = false) {
$base_dir = (false === $base_file ? __DIR__ : dirname($base_file));
if (defined(__NAMESPACE__ . '\OVERRIDE')) {
$base_file = str_replace(__DIR__, DIR, $base_file);
}
$base_dir = (false === $base_file ? DIR : dirname($base_file));
$rel_path = str_replace(ABSPATH, '', $base_dir);
$script = site_url() . '/' . $rel_path . '/' . $script;
......