Migrate @Foxaii's nav-rejig for 8.0.0
This commit is contained in:
@@ -24,3 +24,38 @@ function body_class($classes) {
|
||||
return $classes;
|
||||
}
|
||||
add_filter('body_class', __NAMESPACE__ . '\\body_class');
|
||||
|
||||
/**
|
||||
* Make a URL relative
|
||||
*/
|
||||
function root_relative_url($input) {
|
||||
preg_match('|https?://([^/]+)(/.*)|i', $input, $matches);
|
||||
if (!isset($matches[1]) || !isset($matches[2])) {
|
||||
return $input;
|
||||
} elseif (($matches[1] === $_SERVER['SERVER_NAME']) || $matches[1] === $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']) {
|
||||
return wp_make_link_relative($input);
|
||||
} else {
|
||||
return $input;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare URL against relative URL
|
||||
*/
|
||||
function url_compare($url, $rel) {
|
||||
$url = trailingslashit($url);
|
||||
$rel = trailingslashit($rel);
|
||||
if ((strcasecmp($url, $rel) === 0) || root_relative_url($url) == $rel) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if element is empty
|
||||
*/
|
||||
function is_element_empty($element) {
|
||||
$element = trim($element);
|
||||
return !empty($element);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user