';
if ( empty( $logo_main ) ) :
$output .= '
' . esc_attr( get_bloginfo( 'name' ) ) . '
';
else :
$output .= '
 . ')
';
endif;
$output .= '
';
$title = $output;
}
if ( 1 === $depth && 'checked' === $special_offers ) {
$specials = stm_mm_get_featured_listings( 2, 'stm-img-120-120' );
$output = '';
foreach ( $specials as $special ) {
$special_url = get_the_permalink( $special['ID'] );
$link = sprintf( '
%s', $special_url, $special['title'] );
$output .= '
';
$output .= '
';
$output .= '
';
$output .= '
' . $link . '
';
$output .= '
';
$output .= ( ! empty( $special['sale_price'] ) ) ? '' . $special['price'] . '' . $special['sale_price'] . '' : '' . $special['price'] . '';
$output .= '
';
$output .= '
';
$output .= '
';
}
$output .= '
';
$title = $output;
}
return $title;
}
add_filter( 'nav_menu_link_attributes', 'stm_nav_menu_link_attributes', 10, 4 );
function stm_nav_menu_link_attributes( $atts, $item, $args, $depth ) {
/*ONLY LVL 0*/
if ( ! $depth ) {
$id = $item->ID;
$bg = get_post_meta( $id, stm_menu_meta( 'stm_menu_bg' ), true );
if ( ! empty( $bg ) ) {
$bg = wp_get_attachment_image_src( $bg, 'full' );
if ( ! empty( $bg[0] ) ) {
$atts['data-megabg'] = esc_url( $bg[0] );
}
}
}
return $atts;
}
add_filter( 'walker_nav_menu_start_el', 'stm_nav_start_el', 100, 4 );
function stm_nav_start_el( $item_output, $item, $depth, $args ) {
$atts = array();
$atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : '';
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
if ( '_blank' === $item->target && empty( $item->xfn ) ) {
$atts['rel'] = 'noopener noreferrer';
} else {
$atts['rel'] = $item->xfn;
}
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
$atts['aria-current'] = $item->current ? 'page' : '';
$attributes = '';
foreach ( $atts as $attr => $value ) {
if ( is_scalar( $value ) && '' !== $value && false !== $value ) {
$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
$attributes .= ' ' . $attr . '="' . $value . '"';
}
}
$title = apply_filters( 'the_title', $item->title, $item->ID );
$title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth );
$content = '';
if ( stm_mm_is_elementor_active() ) {
ob_start();
apply_filters( 'motors_render_elementor_content', $item->object_id );
$content .= ob_get_clean();
} else {
$content .= apply_filters( 'the_content', $post_content );
}
$content .= '
';
}
$item_output = $args->before;
$item_output .= $content;
$item_output .= $args->after;
return $item_output;
}
function stm_menu_meta( $name ) {
return '_menu_item_' . $name;
}
function stm_mm_subcat_list( $parent_id ) {
$categories = get_categories(
array(
'child_of' => $parent_id,
'current_category' => 0,
'depth' => 0,
'echo' => 1,
'exclude' => '',
'exclude_tree' => '',
'feed' => '',
'feed_image' => '',
'feed_type' => '',
'hide_empty' => 0,
'hide_title_if_empty' => false,
'hierarchical' => true,
'order' => 'ASC',
'orderby' => 'name',
'separator' => '