theme_location ], 'nav_menu' );
endif;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$classes[] = 'menu-item-' . $item->ID;
$class_names = implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
$class_names = ' class="' . esc_attr( $class_names ) . '"';
$id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
$id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';
$output .= $indent . '
';
// Get the IDs for our target page (the page we're linking to), the parent of our target, and current page
$target_page = $item->object_id;
if ( get_post( $target_page ) ) :
$target_parent = get_post( $target_page )->post_parent;
else :
$target_parent = 0;
endif;
if ( $post ) :
$current_page = $post->ID;
else :
$current_page = null;
endif;
// Check to see if our target page's parent page is the front page. If so, we'll want to use a hash link.
if ( 0 !== $target_parent && 'page-templates/template-front.php' === get_page_template_slug( $target_parent ) ) :
if ( $current_page === $target_parent ) :
$item->url = '#post-' . $target_page;
else :
$item->url = get_page_link( $target_parent ) . '#post-' . $target_page;
endif;
endif;
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
if ( is_object( $args ) ) :
$item_output = $args->before;
$item_output .= '';
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
$item_output .= '';
$item_output .= $args->after;
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
endif;
}
}
/*
* Add an extra li to our nav for our priority+ navigation to use
*/
function add_more_to_nav( $items, $args ) {
if ( 'primary' === $args->theme_location ) :
$items .= '';
endif;
return $items;
}
add_filter( 'wp_nav_menu_items', 'add_more_to_nav', 10, 2 );
/*
* Let's customize our excerpt a bit, so it looks better
* First we decrease the default excerpt length, then
* we give it a proper hellip for the more text.
*/
function pique_custom_excerpt_length( $length ) {
return 27;
}
add_filter( 'excerpt_length', 'pique_custom_excerpt_length', 999 );
function pique_custom_excerpt_more($more) {
$more_link = '';
$more_link .= '';
$more_link .= sprintf(
wp_kses( __( 'Read more %s', 'pique' ), array( 'span' => array( 'class' => array() ) ) ),
the_title( '"', '"', false )
);
$more_link .= '';
return '… ' . $more_link;
}
add_filter( 'excerpt_more', 'pique_custom_excerpt_more' );
/*
* Filter the categories archive widget to add a span around post count
*/
function pique_cat_count_span( $links ) {
$links = str_replace( ' (', '(', $links );
$links = str_replace( ')', ')', $links );
return $links;
}
add_filter( 'wp_list_categories', 'pique_cat_count_span' );
/*
* Filter the archives widget to add a span around post count
*/
function pique_archive_count_span( $links ) {
$links = str_replace( ' (', '(', $links );
$links = str_replace( ')', ')', $links );
return $links;
}
add_filter( 'get_archives_link', 'pique_archive_count_span' );
/*
* Check if WooCommerce is activated and a single product is in view
*/
if ( ! function_exists( 'pique_is_woocommerce_in_view' ) ) {
function pique_is_woocommerce_in_view() {
if ( ! class_exists( 'woocommerce' ) ) {
return true;
} else {
if ( is_woocommerce() ) {
return false;
} else {
return true;
}
}
}
}