minor formatting fixes
This commit is contained in:
@@ -77,12 +77,12 @@ add_filter('get_search_query', 'roots_search_query');
|
|||||||
// thanks to Scott Walkinshaw (scottwalkinshaw.com)
|
// thanks to Scott Walkinshaw (scottwalkinshaw.com)
|
||||||
function roots_root_relative_url($input) {
|
function roots_root_relative_url($input) {
|
||||||
preg_match('/(https?:\/\/[^\/|"]+)/', $input, $matches);
|
preg_match('/(https?:\/\/[^\/|"]+)/', $input, $matches);
|
||||||
// make sure we aren't making external links relative
|
// make sure we aren't making external links relative
|
||||||
if (isset($matches[0]) && strpos($matches[0], site_url()) === false) {
|
if (isset($matches[0]) && strpos($matches[0], site_url()) === false) {
|
||||||
return $input;
|
return $input;
|
||||||
} else {
|
} else {
|
||||||
return str_replace(end($matches), '', $input);
|
return str_replace(end($matches), '', $input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add_filter('bloginfo_url', 'roots_root_relative_url');
|
add_filter('bloginfo_url', 'roots_root_relative_url');
|
||||||
@@ -107,7 +107,7 @@ add_filter('the_author_posts_link', 'roots_root_relative_url');
|
|||||||
|
|
||||||
// Leaving plugins_url alone in admin to avoid potential issues (such as Gravity Forms)
|
// Leaving plugins_url alone in admin to avoid potential issues (such as Gravity Forms)
|
||||||
if (!is_admin()) {
|
if (!is_admin()) {
|
||||||
add_filter('plugins_url', 'roots_root_relative_url');
|
add_filter('plugins_url', 'roots_root_relative_url');
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove root relative URLs on any attachments in the feed
|
// remove root relative URLs on any attachments in the feed
|
||||||
@@ -349,42 +349,42 @@ function roots_nav_menu_args($args = '') {
|
|||||||
add_filter('wp_nav_menu_args', 'roots_nav_menu_args');
|
add_filter('wp_nav_menu_args', 'roots_nav_menu_args');
|
||||||
|
|
||||||
class roots_nav_walker extends Walker_Nav_Menu {
|
class roots_nav_walker extends Walker_Nav_Menu {
|
||||||
function start_el(&$output, $item, $depth, $args) {
|
function start_el(&$output, $item, $depth, $args) {
|
||||||
global $wp_query;
|
global $wp_query;
|
||||||
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
|
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
|
||||||
|
|
||||||
$slug = sanitize_title($item->title);
|
$slug = sanitize_title($item->title);
|
||||||
|
|
||||||
$class_names = $value = '';
|
$class_names = $value = '';
|
||||||
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
|
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
|
||||||
|
|
||||||
$classes = array_filter($classes, 'roots_check_current');
|
$classes = array_filter($classes, 'roots_check_current');
|
||||||
|
|
||||||
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
|
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
|
||||||
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
|
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
|
||||||
|
|
||||||
$id = apply_filters( 'nav_menu_item_id', 'menu-' . $slug, $item, $args );
|
$id = apply_filters( 'nav_menu_item_id', 'menu-' . $slug, $item, $args );
|
||||||
$id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';
|
$id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';
|
||||||
|
|
||||||
$output .= $indent . '<li' . $id . $class_names . '>';
|
$output .= $indent . '<li' . $id . $class_names . '>';
|
||||||
|
|
||||||
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
|
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
|
||||||
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
|
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
|
||||||
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
|
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
|
||||||
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
|
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
|
||||||
|
|
||||||
$item_output = $args->before;
|
$item_output = $args->before;
|
||||||
$item_output .= '<a'. $attributes .'>';
|
$item_output .= '<a'. $attributes .'>';
|
||||||
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
|
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
|
||||||
$item_output .= '</a>';
|
$item_output .= '</a>';
|
||||||
$item_output .= $args->after;
|
$item_output .= $args->after;
|
||||||
|
|
||||||
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
|
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function roots_check_current($val) {
|
function roots_check_current($val) {
|
||||||
return preg_match('/current-menu/', $val);
|
return preg_match('/current-menu/', $val);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
Reference in New Issue
Block a user