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:
28
inc/roots-utils.php
Normal file
28
inc/roots-utils.php
Normal 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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user