Better rewrite/clean URL handling

- New roots-utils.php file for base functions
- Defined useful constants for dealing with common paths
- Refactored rewrites and clean URLs to be more flexible for non
  standard setups
- Custom scripts handler now deals with plugin scripts correctly
- Fixes #204, #270, #278
This commit is contained in:
Scott Walkinshaw
2012-02-20 16:13:35 -05:00
parent 47eb95be69
commit db09a64d94
6 changed files with 93 additions and 69 deletions

28
inc/roots-utils.php Normal file
View File

@@ -0,0 +1,28 @@
<?
// returns WordPress subdirectory if applicable
function wp_base_dir() {
preg_match('!(https?://[^/|"]+)([^"]+)?!', site_url(), $matches);
if (count($matches) === 3) {
return end($matches);
} else {
return '';
}
}
// opposite of built in WP functions for trailing slashes
function leadingslashit($string) {
return '/' . unleadingslashit($string);
}
function unleadingslashit($string) {
return ltrim($string, '/');
}
function add_filters($tags, $function) {
foreach($tags as $tag) {
add_filter($tag, $function);
}
}
?>