My site link is: https://staging.buellairhorns.com/
When I try the search function, the search result page shows nothing but a white blank page. Can anyone help me figure out what's wrong?
This is my: search.php
<?php
$container_class = apply_filters( 'neve_container_class_filter', 'container', 'blog-archive' );
get_header();
$wrapper_classes = [ 'posts-wrapper' ];
if ( ! neve_is_new_skin() ) {
$wrapper_classes[] = 'row';
}
?>
<div class="<?php echo esc_attr( $container_class ); ?> archive-container">
<div class="row">
<?php do_action( 'neve_do_sidebar', 'blog-archive', 'left' ); ?>
<div class="nv-index-posts search col">
<?php
do_action( 'neve_page_header', 'search' );
if ( have_posts() ) {
/* Start the Loop. */
echo '<div class="' . esc_attr( join( ' ', $wrapper_classes ) ) . '">';
while ( have_posts() ) {
the_post();
get_template_part( 'template-parts/content' );
}
echo '</div>';
if ( ! is_singular() ) {
do_action( 'neve_do_pagination', 'blog-archive' );
}
} else {
get_template_part( 'template-parts/content', 'none' );
}
?>
<div class="w-100"></div>
</div>
<?php do_action( 'neve_do_sidebar', 'blog-archive', 'right' ); ?>
</div>
</div>
<?php
get_footer();
This is my searchform.php
<?php
$form_classes = [ 'search-form' ];
$placeholder = array_key_exists( 'placeholder', $args ) ? $args['placeholder'] : __( 'Search for...', 'neve' );
if ( array_key_exists( 'additional_form_classes', $args ) && is_array( $args['additional_form_classes'] ) ) {
$form_classes = array_merge( $form_classes, $args['additional_form_classes'] );
}
$value = array_key_exists( 'value', $args ) ? $args['value'] : '';
$placeholder = apply_filters( 'nv_search_placeholder', $placeholder );
$aria_label = __( 'Search', 'neve' );
$home_url = home_url( '/' );
if ( function_exists( 'PLL' ) ) {
$pll_data = PLL();
if ( property_exists( $pll_data, 'links' ) && method_exists( $pll_data->links, 'get_home_url' ) ) {
$home_url = $pll_data->links->get_home_url( null, true );
}
}
?>
<form role="search"
method="get"
class="<?php echo esc_attr( implode( ' ', $form_classes ) ); ?>"
action="<?php echo esc_url( $home_url ); ?>">
<label>
<span class="screen-reader-text"><?php echo esc_html__( 'Search for...', 'neve' ); ?></span>
</label>
<input type="search"
class="search-field"
aria-label="<?php echo esc_attr__( 'Search', 'neve' ); ?>"
placeholder="<?php echo esc_attr( $placeholder ); ?>"
value="<?php echo esc_attr( $value ); ?>"
name="s"/>
<button type="submit"
class="search-submit"
aria-label="<?php echo esc_attr( $aria_label ); ?>">
<span class="nv-search-icon-wrap">
<?php neve_search_icon( false, true ); ?>
</span>
</button>
<?php
if ( array_key_exists( 'post_type', $args ) ) {
echo '<input type="hidden" name="post_type" value="' . esc_attr( $args['post_type'] ) . '"/>';
}
?>
</form>
I'am using neve theme. I created a custom search result page using Elementor Pro but still not working.
Related
How do i add the selected product variation and - if the quantity is increased - the updated quantity to the cart? Code below works fine if i only add 1 product to the cart if it has no variations.
In page-shop.php (the main shop page, no deep links to products wanted) i'm getting all the food of category "vorspeisen" (appetizer):
<div class="clearfix trichter" id="vorspeisen">
<div class="triangle"></div>
<div class="trichtertitel" data-aos="flip-up"><h2><span>1</span>Zuerst eine feine Vorspeise</h2></div>
<?php $args = array(
'post_type' => 'product',
'posts_per_page' => -1,
'product_cat' => 'vorspeisen'
);
$loop = new WP_Query( $args );
while ($loop->have_posts()):$loop->the_post();global $product;?>
<?php include 'single-food.php';?>
<?php endwhile;wp_reset_query();?>
</div>
and in the included single-food.php i'm getting all the needed infos about the appetizer (thumbnail, title) and also all product variations with differenz prizes:
<article class="prdct_holder clearfix" id="p<?php echo get_the_ID(); ?>">
<div class="lefty">
<?php $img0 = wp_get_attachment_image_src(get_post_thumbnail_id($product->ID),'prdct');?>
<img src="<?php echo $img0[0];?>" alt="<?php the_title(); ?>" />
</div>
<div class="righty">
<h1><?php echo get_the_title();?></h1>
<?php if( '' !== get_post()->post_content ) { ?>
<div class="contento">
<?php echo onlytext();?>
<form class="cart" action="?add-to-cart=<?php echo get_the_ID(); ?>#<?php echo get_the_ID(); ?>" method="post" enctype='multipart/form-data'>
<?php // do_action( 'woocommerce_before_add_to_cart_button' ); ?>
<?php $min_value = 0; $max_value = -1; $input_value = 1; $step = 1; $pattern = ''; $inputmode = 'numeric'; $input_id = ''; $input_name = 'quantity';?>
<div class="quantity">
<label class="screen-reader-text" for="product<?php echo esc_attr($product->get_id());?>"><?php esc_html_e( 'Quantity', 'woocommerce' ); ?></label>
<div class="quantity-button minus"><span>-</span></div>
<input type="number" id="product<?php echo esc_attr($product->get_id());?>" class="input-text qty text" step="<?php echo esc_attr( $step ); ?>" min="<?php echo esc_attr( $min_value ); ?>" max="<?php echo esc_attr( 0 < $max_value ? $max_value : '' ); ?>" name="<?php echo esc_attr( $input_name ); ?>"
value="<?php echo esc_attr( $input_value ); ?>" title="<?php echo esc_attr_x( 'Qty', 'Product quantity input tooltip', 'woocommerce' ) ?>" size="4" pattern="<?php echo esc_attr( $pattern ); ?>" inputmode="<?php echo esc_attr( $inputmode ); ?>" />
<div class="quantity-button plus"><span>+</span></div>
</div>
<?php if ($product->is_type('variable')){
global $product; // echo 'ist variabel!<br>';
$attributes = $product->get_variation_attributes();
$attribute_keys = array_keys( $attributes );
?>
<?php foreach ( $attributes as $attribute_name => $options ) : ?>
<tr>
<td class="label"><label for="<?php echo sanitize_title( $attribute_name ); ?>"><?php echo wc_attribute_label( $attribute_name ); ?></label></td>
<td class="value">
<?php
$selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? wc_clean( urldecode( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ) : $product->get_variation_default_attribute( $attribute_name );
$args = array( 'options' => $options, 'attribute' => $attribute_name, 'product' => $product, 'selected' => $selected );
wc_dropdown_variation_attribute_options( $args );
?>
</td>
</tr>
<?php endforeach; ?>
<?php } ?>
<a href="/shop/?add-to-cart=<?php echo esc_attr( $product->get_id() ); ?>#p<?php echo get_the_ID(); ?>"
value="<?php echo esc_attr( $product->get_id() ); ?>"
class="ajax_add_to_cart add_to_cart_button" data-product_id="<?php echo get_the_ID(); ?>"
aria-label="<?php the_title_attribute() ?> zum Warenkorb hinzufügen"><div class="add"><span>+</span> Bestellen!</div></a>
<?php // do_action( 'woocommerce_after_add_to_cart_button' ); ?>
</form>
</div>
<?php }?>
</div>
</article>
I have a custom post type in WordPress.
The mobile archive page is a slider through ALL the posts.
The desktop archive page is a normal archive page, with numbered navigation and only shows 6 posts per page.
I see to have this working, however on the desktop, there should only be 3 pages, but instead, there are 4 pages, and the fourth page is empty.
I'm baffled as to what I've done wrong, so if anyone can take a look, that would be brill.
Thank you
archive-projects.php:
<?php
if ( !have_posts() ) {
// If no posts match the query
get_template_part( '404' );
return;
}
get_header();
?>
<div class="container">
<div class="content-area mobile" id="mobile-projects-slider">
<?php
$args = array(
'post_type' => 'projects',
'order-by' => 'date',
'order' => 'des',
'posts_per_page' => -1
);
$the_query = new WP_Query( $args );
if($the_query->have_posts() ) :
while ( $the_query->have_posts() ) :
$the_query->the_post();
?>
<article <?php post_class( 'entry entry-archive' ); ?> data-aos="fade">
<?php $backgroundImg = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' ); ?>
<div class="entry-image">
<a href="<?php the_permalink(); ?>">
<div class="post-image" style="background-image: url('<?php echo $backgroundImg[0]; ?>')"></div>
</a>
</div>
<div class="entry-content">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
See More
</div>
</article>
<?php
endwhile;
wp_reset_postdata();
else:
endif;
?>
</div>
<div class="content-area desktop" id="desktop-projects">
<?php
$args = array(
'post_type' => 'projects',
'order-by' => 'date',
'order' => 'des',
'paged' => $paged,
'posts_per_page' => 6
);
$the_query = new WP_Query( $args );
if($the_query->have_posts() ) :
while ( $the_query->have_posts() ) :
$the_query->the_post();
?>
<article <?php post_class( 'entry entry-archive' ); ?> data-aos="fade">
<?php $backgroundImg = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' ); ?>
<div class="entry-image">
<a href="<?php the_permalink(); ?>">
<div class="post-image" style="background-image: url('<?php echo $backgroundImg[0]; ?>')"></div>
</a>
</div>
<div class="entry-content">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
See More
</div>
</article>
<?php
endwhile;
wp_reset_postdata();
else:
endif;
?>
<?php
get_template_part( '_template-parts/page-navigation' );
?>
</div>
<!-- <div class="aside"> -->
<?php /* get_sidebar(); */ ?>
<!-- </div> -->
</div>
<?php
get_footer();
page-navigation.php:
<?php if ( is_singular() ) : ?>
<?php if( get_post_type() == 'projects' ) { ?>
<div id="navigation" data-aos="fade">
<div class="pagination pagination-singular">
<?php if ( get_next_post() ) { ?>
<div class="nav-next"><?php next_post_link( '%link', 'Previous Project' ) ?></div>
<?php } ?>
<?php if ( get_previous_post() ) { ?>
<div class="nav-previous"><?php previous_post_link( '%link', 'Next Project' ) ?></div>
<?php } ?>
</div>
</div>
<?php } else { ?>
<div id="navigation" data-aos="fade">
<div class="pagination pagination-singular">
<?php if ( get_next_post() ) { ?>
<div class="nav-next"><?php next_post_link( '%link', 'Previous Post' ) ?></div>
<?php } ?>
<?php if ( get_previous_post() ) { ?>
<div class="nav-previous"><?php previous_post_link( '%link', 'Next Post' ) ?></div>
<?php } ?>
</div>
</div>
<?php } ?>
<?php else : ?>
<?php
aa_numeric_posts_nav();
// located in includes > functions > theme-functions.php
?>
<?php endif; ?>
aa_posts_nav_function():
function aa_numeric_posts_nav() {
if( is_singular() )
return;
global $wp_query;
// $paged = 0;
/** Stop execution if there's only 1 page */
if( $wp_query->max_num_pages <= 1 )
return;
$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
$max = intval( $wp_query->max_num_pages );
/** Add current page to the array */
if ( $paged >= 1 )
$links[] = $paged;
/** Add the pages around the current page to the array */
if ( $paged >= 3 ) {
$links[] = $paged - 1;
$links[] = $paged - 2;
}
//
if ( ( $paged + 2 ) <= $max ) {
$links[] = $paged + 2;
$links[] = $paged + 1;
}
echo '<div id="navigation"><ul class="pagination numbered-pagination">' . "\n";
/** Previous Post Link */
if ( get_previous_posts_link() )
printf( '<li class="nav-prev">%s</li>' . "\n", get_previous_posts_link() );
/** Link to first page, plus ellipses if necessary */
if ( ! in_array( 1, $links ) ) {
$class = 1 == $paged ? ' class="active"' : '';
printf( '<li%s>%s</li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
if ( ! in_array( 2, $links ) )
echo '<li>…</li>';
}
/** Link to current page, plus 2 pages in either direction if necessary */
sort( $links );
foreach ( (array) $links as $link ) {
$class = $paged == $link ? ' class="active"' : '';
printf( '<li%s>%s</li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
}
/** Link to last page, plus ellipses if necessary */
if ( ! in_array( $max, $links ) ) {
if ( ! in_array( $max - 1, $links ) )
echo '<li>…</li>' . "\n";
$class = $paged == $max ? ' class="active"' : '';
printf( '<li%s>%s</li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
}
/** Next Post Link */
if ( get_next_posts_link() )
printf( '<li class="nav-next">%s</li>' . "\n", get_next_posts_link() );
echo '</ul></div>' . "\n";
}
Fixed it. I removed the WP_Query completely for the desktop version (in archive- and added it using a separate function. This is what I have now and works:
archive-projects.php
<?php
if ( !have_posts() ) {
// If no posts match the query
get_template_part( '404' );
return;
}
get_header();
?>
<div class="container">
<div class="content-area mobile" id="mobile-projects-slider">
<?php
$args = array(
'post_type' => 'projects',
'order-by' => 'date',
'order' => 'des',
'posts_per_page' => -1
);
$the_query = new WP_Query( $args );
if($the_query->have_posts() ) :
while ( $the_query->have_posts() ) :
$the_query->the_post();
?>
<article <?php post_class( 'entry entry-archive' ); ?> data-aos="fade">
<?php $backgroundImg = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' ); ?>
<div class="entry-image">
<a href="<?php the_permalink(); ?>">
<div class="post-image" style="background-image: url('<?php echo $backgroundImg[0]; ?>')"></div>
</a>
</div>
<div class="entry-content">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
See More
</div>
</article>
<?php
endwhile;
wp_reset_postdata();
else:
endif;
?>
</div>
<div class="content-area desktop" id="desktop-projects">
<?php
if(have_posts() ) :
while ( have_posts() ) : the_post();
?>
<article <?php post_class( 'entry entry-archive' ); ?> data-aos="fade">
<?php $backgroundImg = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' ); ?>
<div class="entry-image">
<a href="<?php the_permalink(); ?>">
<div class="post-image" style="background-image: url('<?php echo $backgroundImg[0]; ?>')"></div>
</a>
</div>
<div class="entry-content">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
See More
</div>
</article>
<?php
endwhile;
wp_reset_postdata();
else:
echo '<h2>No posts found!</h2>';
endif;
aa_numeric_posts_nav();
?>
</div>
<!-- <div class="aside"> -->
<?php /* get_sidebar(); */ ?>
<!-- </div> -->
</div>
<?php
get_footer();
aa_numeric_posts_nav(); function
function aa_numeric_posts_nav() {
if( is_singular() )
return;
global $wp_query;
// $paged = 0;
/** Stop execution if there's only 1 page */
if( $wp_query->max_num_pages <= 1 )
return;
$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
$max = intval( $wp_query->max_num_pages );
/** Add current page to the array */
if ( $paged >= 1 )
$links[] = $paged;
/** Add the pages around the current page to the array */
if ( $paged >= 3 ) {
$links[] = $paged - 1;
$links[] = $paged - 2;
}
//
if ( ( $paged + 2 ) <= $max ) {
$links[] = $paged + 2;
$links[] = $paged + 1;
}
echo '<div id="navigation"><ul class="pagination numbered-pagination">' . "\n";
/** Previous Post Link */
if ( get_previous_posts_link() )
printf( '<li class="nav-prev">%s</li>' . "\n", get_previous_posts_link() );
/** Link to first page, plus ellipses if necessary */
if ( ! in_array( 1, $links ) ) {
$class = 1 == $paged ? ' class="active"' : '';
printf( '<li%s>%s</li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
if ( ! in_array( 2, $links ) )
echo '<li>…</li>';
}
/** Link to current page, plus 2 pages in either direction if necessary */
sort( $links );
foreach ( (array) $links as $link ) {
$class = $paged == $link ? ' class="active"' : '';
printf( '<li%s>%s</li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
}
/** Link to last page, plus ellipses if necessary */
if ( ! in_array( $max, $links ) ) {
if ( ! in_array( $max - 1, $links ) )
echo '<li>…</li>' . "\n";
$class = $paged == $max ? ' class="active"' : '';
printf( '<li%s>%s</li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
}
/** Next Post Link */
if ( get_next_posts_link() )
printf( '<li class="nav-next">%s</li>' . "\n", get_next_posts_link() );
echo '</ul></div>' . "\n";
}
function for posts per page CPT for my desktop:
function aa_order_cpt( $query ) {
// exit out if it's the admin or it isn't the main query
if ( is_admin() || ! $query->is_main_query() ) {
return;
}
// order category archives by title in ascending order
if ( is_archive() ) {
$query->set( 'order' , 'desc' );
$query->set( 'orderby', 'date');
$query->set('posts_per_page', 6 );
}
return;
}
add_action( 'pre_get_posts', 'aa_order_cpt', 1 );
I have this template(header.php). Now i'm working on a site, and i want to to some changes in this template. According to this template i get 2 menu locations, but i want to change the order of them.
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<?php
elegant_description();
elegant_keywords();
elegant_canonical();
/**
* Fires in the head, before {#see wp_head()} is called. This action can be used to
* insert elements into the beginning of the head before any styles or scripts.
*
* #since 1.0
*/
do_action( 'et_head_meta' );
$template_directory_uri = get_template_directory_uri();
?>
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<script type="text/javascript">
document.documentElement.className = 'js';
</script>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php
$product_tour_enabled = et_builder_is_product_tour_enabled();
$page_container_style = $product_tour_enabled ? ' style="padding-top: 0px;"' : ''; ?>
<div id="page-container"<?php echo et_core_intentionally_unescaped( $page_container_style, 'fixed_string' ); ?>>
<?php
if ( $product_tour_enabled || is_page_template( 'page-template-blank.php' ) ) {
return;
}
$et_secondary_nav_items = et_divi_get_top_nav_items();
$et_phone_number = $et_secondary_nav_items->phone_number;
$et_email = $et_secondary_nav_items->email;
$et_contact_info_defined = $et_secondary_nav_items->contact_info_defined;
$show_header_social_icons = $et_secondary_nav_items->show_header_social_icons;
$et_secondary_nav = $et_secondary_nav_items->secondary_nav;
$et_top_info_defined = $et_secondary_nav_items->top_info_defined;
$et_slide_header = 'slide' === et_get_option( 'header_style', 'left' ) || 'fullscreen' === et_get_option( 'header_style', 'left' ) ? true : false;
?>
<?php if ( $et_top_info_defined && ! $et_slide_header || is_customize_preview() ) : ?>
<?php ob_start(); ?>
<div id="top-header"<?php echo $et_top_info_defined ? '' : 'style="display: none;"'; ?>>
<div class="container clearfix">
<?php if ( $et_contact_info_defined ) : ?>
<div id="et-info">
<?php if ( '' !== ( $et_phone_number = et_get_option( 'phone_number' ) ) ) : ?>
<span id="et-info-phone"><?php echo et_core_esc_previously( et_sanitize_html_input_text( $et_phone_number ) ); ?></span>
<?php endif; ?>
<?php if ( '' !== ( $et_email = et_get_option( 'header_email' ) ) ) : ?>
<span id="et-info-email"><?php echo esc_html( $et_email ); ?></span>
<?php endif; ?>
<?php
if ( true === $show_header_social_icons ) {
get_template_part( 'includes/social_icons', 'header' );
} ?>
</div> <!-- #et-info -->
<?php endif; // true === $et_contact_info_defined ?>
<div id="et-secondary-menu">
<?php
if ( ! $et_contact_info_defined && true === $show_header_social_icons ) {
get_template_part( 'includes/social_icons', 'header' );
} else if ( $et_contact_info_defined && true === $show_header_social_icons ) {
ob_start();
get_template_part( 'includes/social_icons', 'header' );
$duplicate_social_icons = ob_get_contents();
ob_end_clean();
printf(
'<div class="et_duplicate_social_icons">
%1$s
</div>',
et_core_esc_previously( $duplicate_social_icons )
);
}
if ( '' !== $et_secondary_nav ) {
echo et_core_esc_wp( $et_secondary_nav );
}
et_show_cart_total();
?>
</div> <!-- #et-secondary-menu -->
</div> <!-- .container -->
</div> <!-- #top-header -->
<?php
$top_header = ob_get_clean();
/**
* Filters the HTML output for the top header.
*
* #since 3.10
*
* #param string $top_header
*/
echo et_core_intentionally_unescaped( apply_filters( 'et_html_top_header', $top_header ), 'html' );
?>
<?php endif; // true ==== $et_top_info_defined ?>
<?php if ( $et_slide_header || is_customize_preview() ) : ?>
<?php ob_start(); ?>
<div class="et_slide_in_menu_container">
<?php if ( 'fullscreen' === et_get_option( 'header_style', 'left' ) || is_customize_preview() ) { ?>
<span class="mobile_menu_bar et_toggle_fullscreen_menu"></span>
<?php } ?>
<?php
if ( $et_contact_info_defined || true === $show_header_social_icons || false !== et_get_option( 'show_search_icon', true ) || class_exists( 'woocommerce' ) || is_customize_preview() ) { ?>
<div class="et_slide_menu_top">
<?php if ( 'fullscreen' === et_get_option( 'header_style', 'left' ) ) { ?>
<div class="et_pb_top_menu_inner">
<?php } ?>
<?php }
if ( true === $show_header_social_icons ) {
get_template_part( 'includes/social_icons', 'header' );
}
et_show_cart_total();
?>
<?php if ( false !== et_get_option( 'show_search_icon', true ) || is_customize_preview() ) : ?>
<?php if ( 'fullscreen' !== et_get_option( 'header_style', 'left' ) ) { ?>
<div class="clear"></div>
<?php } ?>
<form role="search" method="get" class="et-search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<?php
printf( '<input type="search" class="et-search-field" placeholder="%1$s" value="%2$s" name="s" title="%3$s" />',
esc_attr__( 'Search …', 'Divi' ),
get_search_query(),
esc_attr__( 'Search for:', 'Divi' )
);
?>
<button type="submit" id="searchsubmit_header"></button>
</form>
<?php endif; // true === et_get_option( 'show_search_icon', false ) ?>
<?php if ( $et_contact_info_defined ) : ?>
<div id="et-info">
<?php if ( '' !== ( $et_phone_number = et_get_option( 'phone_number' ) ) ) : ?>
<span id="et-info-phone"><?php echo et_core_esc_previously( et_sanitize_html_input_text( $et_phone_number ) ); ?></span>
<?php endif; ?>
<?php if ( '' !== ( $et_email = et_get_option( 'header_email' ) ) ) : ?>
<span id="et-info-email"><?php echo esc_html( $et_email ); ?></span>
<?php endif; ?>
</div> <!-- #et-info -->
<?php endif; // true === $et_contact_info_defined ?>
<?php if ( $et_contact_info_defined || true === $show_header_social_icons || false !== et_get_option( 'show_search_icon', true ) || class_exists( 'woocommerce' ) || is_customize_preview() ) { ?>
<?php if ( 'fullscreen' === et_get_option( 'header_style', 'left' ) ) { ?>
</div> <!-- .et_pb_top_menu_inner -->
<?php } ?>
</div> <!-- .et_slide_menu_top -->
<?php } ?>
<div class="et_pb_fullscreen_nav_container">
<?php
$slide_nav = '';
$slide_menu_class = 'et_mobile_menu';
$slide_nav = wp_nav_menu( array( 'theme_location' => 'primary-menu', 'container' => '', 'fallback_cb' => '', 'echo' => false, 'items_wrap' => '%3$s' ) );
$slide_nav .= wp_nav_menu( array( 'theme_location' => 'secondary-menu', 'container' => '', 'fallback_cb' => '', 'echo' => false, 'items_wrap' => '%3$s' ) );
?>
<ul id="mobile_menu_slide" class="<?php echo esc_attr( $slide_menu_class ); ?>">
<?php
if ( '' === $slide_nav ) :
?>
<?php if ( 'on' === et_get_option( 'divi_home_link' ) ) { ?>
<li <?php if ( is_home() ) echo( 'class="current_page_item"' ); ?>><?php esc_html_e( 'Home', 'Divi' ); ?></li>
<?php }; ?>
<?php show_page_menu( $slide_menu_class, false, false ); ?>
<?php show_categories_menu( $slide_menu_class, false ); ?>
<?php
else :
echo et_core_esc_wp( $slide_nav ) ;
endif;
?>
</ul>
</div>
</div>
<?php
$slide_header = ob_get_clean();
/**
* Filters the HTML output for the slide header.
*
* #since 3.10
*
* #param string $top_header
*/
echo et_core_intentionally_unescaped( apply_filters( 'et_html_slide_header', $slide_header ), 'html' );
?>
<?php endif; // true ==== $et_slide_header ?>
<?php ob_start(); ?>
<header id="main-header" data-height-onload="<?php echo esc_attr( et_get_option( 'menu_height', '66' ) ); ?>">
<div class="container clearfix et_menu_container">
<?php
$logo = ( $user_logo = et_get_option( 'divi_logo' ) ) && ! empty( $user_logo )
? $user_logo
: $template_directory_uri . '/images/logo.png';
ob_start();
?>
<div class="logo_container">
<span class="logo_helper"></span>
<a href="<?php echo esc_url( home_url( '/' ) ); ?>">
<img src="<?php echo esc_attr( $logo ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>" id="logo" data-height-percentage="<?php echo esc_attr( et_get_option( 'logo_height', '54' ) ); ?>" />
</a>
</div>
<?php
$logo_container = ob_get_clean();
/**
* Filters the HTML output for the logo container.
*
* #since 3.10
*
* #param string $logo_container
*/
echo et_core_intentionally_unescaped( apply_filters( 'et_html_logo_container', $logo_container ), 'html' );
?>
<div id="et-top-navigation" data-height="<?php echo esc_attr( et_get_option( 'menu_height', '66' ) ); ?>" data-fixed-height="<?php echo esc_attr( et_get_option( 'minimized_menu_height', '40' ) ); ?>">
<?php if ( ! $et_slide_header || is_customize_preview() ) : ?>
<nav id="top-menu-nav">
<?php
$menuClass = 'nav';
if ( 'on' === et_get_option( 'divi_disable_toptier' ) ) $menuClass .= ' et_disable_top_tier';
$primaryNav = '';
$primaryNav = wp_nav_menu( array( 'theme_location' => 'primary-menu', 'container' => '', 'fallback_cb' => '', 'menu_class' => $menuClass, 'menu_id' => 'top-menu', 'echo' => false ) );
if ( empty( $primaryNav ) ) :
?>
<ul id="top-menu" class="<?php echo esc_attr( $menuClass ); ?>">
<?php if ( 'on' === et_get_option( 'divi_home_link' ) ) { ?>
<li <?php if ( is_home() ) echo( 'class="current_page_item"' ); ?>><?php esc_html_e( 'Home', 'Divi' ); ?></li>
<?php }; ?>
<?php show_page_menu( $menuClass, false, false ); ?>
<?php show_categories_menu( $menuClass, false ); ?>
</ul>
<?php
else :
echo et_core_esc_wp( $primaryNav );
endif;
?>
</nav>
<?php endif; ?>
<?php
if ( ! $et_top_info_defined && ( ! $et_slide_header || is_customize_preview() ) ) {
et_show_cart_total( array(
'no_text' => true,
) );
}
?>
<?php if ( $et_slide_header || is_customize_preview() ) : ?>
<span class="mobile_menu_bar et_pb_header_toggle et_toggle_<?php echo esc_attr( et_get_option( 'header_style', 'left' ) ); ?>_menu"></span>
<?php endif; ?>
<?php if ( ( false !== et_get_option( 'show_search_icon', true ) && ! $et_slide_header ) || is_customize_preview() ) : ?>
<div id="et_top_search">
<span id="et_search_icon"></span>
</div>
<?php endif; // true === et_get_option( 'show_search_icon', false ) ?>
<?php
/**
* Fires at the end of the 'et-top-navigation' element, just before its closing tag.
*
* #since 1.0
*/
do_action( 'et_header_top' );
?>
</div> <!-- #et-top-navigation -->
</div> <!-- .container -->
<div class="et_search_outer">
<div class="container et_search_form_container">
<form role="search" method="get" class="et-search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<?php
printf( '<input type="search" class="et-search-field" placeholder="%1$s" value="%2$s" name="s" title="%3$s" />',
esc_attr__( 'Search …', 'Divi' ),
get_search_query(),
esc_attr__( 'Search for:', 'Divi' )
);
?>
</form>
<span class="et_close_search_field"></span>
</div>
</div>
</header> <!-- #main-header -->
<?php
$main_header = ob_get_clean();
/**
* Filters the HTML output for the main header.
*
* #since 3.10
*
* #param string $main_header
*/
echo et_core_intentionally_unescaped( apply_filters( 'et_html_main_header', $main_header ), 'html' );
?>
<div id="et-main-area">
<?php
/**
* Fires after the header, before the main content is output.
*
* #since 3.10
*/
do_action( 'et_before_main_content' );
In practice the secondary menu appears first, before primary menu. How to change the ordering for displaying:
FIRST: Primary menu;
SECOND: Secondary menu;
Who knows how could i change the order, for displaying the same order that i described above?
First of all, it is not advisable to change the order of the menu in the DIVI theme. Just rearranging the code will collapse the header.
So it is better to register a new Navigation Menu and then use it where you wanted.
Before making any changes to the theme files, make sure you are using Divi Child Theme. If you don't have one, You can download it here (Divi Child Theme Download Link)
Then you can copy your header.php file from Divi theme folder and paste it into the Child theme folder.
To register a custom menu, use the below code in the Functions.php file.
function wpb_custom_new_menu() {
register_nav_menu('my-custom-menu',__( 'My Custom Menu' ));
}
add_action( 'init', 'wpb_custom_new_menu' );
Now go to Appearance -> Menus and create a New Menu and assign it as "My Custom Menu".
To add this menu to the header, Add the below code in header.php where you want to display the menu.
'my-custom-menu',
'container_class' => 'custom-menu-class' ) );
?>
Then you can use the .custom_menu_class CSS class to style the menu.
The ajax add to cart function of woocommerce doesn't seem to update the cart untill after I manually refresh the website.
This is the function for the cart widget I edited, and it seems to be working fine. It just doesn't refresh automatically.
class GeminiCart extends WP_Widget {
public function __construct() {
parent::__construct(
'gb_woocommerce_dropdown_cart',
esc_html__('Gemini Bracelet Woocommerce Dropdown Cart', 'depot'),
array( 'description' => esc_html__( 'Display a shop cart icon with a dropdown that shows products that are in the cart', 'depot' ), )
);
$this->setParams();
}
protected function setParams() {
$this->params = array(
array(
'type' => 'textfield',
'name' => 'woocommerce_dropdown_cart_margin',
'title' => esc_html__('Icon Margin', 'depot'),
'description' => esc_html__('Insert margin in format: top right bottom left (e.g. 10px 5px 10px 5px)', 'depot')
),
array(
'type' => 'dropdown',
'name' => 'woocommerce_enable_cart_info',
'title' => esc_html__('Enable Cart Info', 'depot'),
'options' => depot_mikado_get_yes_no_select_array(false),
'description' => esc_html__('Enabling this option will show cart info (products number and price) at the right side of dropdown cart icon', 'depot')
),
);
}
/**
* Generate widget form based on $params attribute
*
* #param array $instance
*
* #return null
*/
public function form($instance) {
if(is_array($this->params) && count($this->params)) {
foreach($this->params as $param_array) {
$param_name = $param_array['name'];
${$param_name} = isset($instance[$param_name]) ? esc_attr($instance[$param_name]) : '';
}
foreach($this->params as $param) {
switch($param['type']) {
case 'textfield':
?>
<p>
<label for="<?php echo esc_attr($this->get_field_id($param['name'])); ?>"><?php echo
esc_html($param['title']); ?>:</label>
<input class="widefat" id="<?php echo esc_attr($this->get_field_id($param['name'])); ?>" name="<?php echo esc_attr($this->get_field_name($param['name'])); ?>" type="text" value="<?php echo esc_attr(${$param['name']}); ?>"/>
<?php if(!empty($param['description'])) : ?>
<span class="mkd-field-description"><?php echo esc_html($param['description']); ?></span>
<?php endif; ?>
</p>
<?php
break;
case 'dropdown':
?>
<p>
<label for="<?php echo esc_attr($this->get_field_id($param['name'])); ?>"><?php echo
esc_html($param['title']); ?>:</label>
<?php if(isset($param['options']) && is_array($param['options']) && count($param['options'])) { ?>
<select class="widefat" name="<?php echo esc_attr($this->get_field_name($param['name'])); ?>" id="<?php echo esc_attr($this->get_field_id($param['name'])); ?>">
<?php foreach($param['options'] as $param_option_key => $param_option_val) {
$option_selected = '';
if(${$param['name']} == $param_option_key) {
$option_selected = 'selected';
}
?>
<option <?php echo esc_attr($option_selected); ?> value="<?php echo esc_attr($param_option_key); ?>"><?php echo esc_attr($param_option_val); ?></option>
<?php } ?>
</select>
<?php } ?>
<?php if(!empty($param['description'])) : ?>
<span class="mkd-field-description"><?php echo esc_html($param['description']); ?></span>
<?php endif; ?>
</p>
<?php
break;
}
}
} else { ?>
<p><?php esc_html_e('There are no options for this widget.', 'depot'); ?></p>
<?php }
}
/**
* #param array $new_instance
* #param array $old_instance
*
* #return array
*/
public function update($new_instance, $old_instance) {
$instance = array();
foreach($this->params as $param) {
$param_name = $param['name'];
$instance[$param_name] = sanitize_text_field($new_instance[$param_name]);
}
return $instance;
}
public function widget( $args, $instance ) {
extract( $args );
global $woocommerce;
$icon_styles = array();
if ($instance['woocommerce_dropdown_cart_margin'] !== '') {
$icon_styles[] = 'padding: ' . $instance['woocommerce_dropdown_cart_margin'];
}
$icon_class = 'mkd-cart-info-is-disabled';
if (!empty($instance['woocommerce_enable_cart_info']) && $instance['woocommerce_enable_cart_info'] === 'yes') {
$icon_class = 'mkd-cart-info-is-active';
}
$cart_description = depot_mikado_options()->getOptionValue('mkd_woo_dropdown_cart_description');
?>
<div class="mkd-shopping-cart-holder <?php echo esc_html($icon_class); ?>" <?php depot_mikado_inline_style($icon_styles) ?>>
<div class="mkd-shopping-cart-inner">
<?php $cart_is_empty = sizeof( $woocommerce->cart->get_cart() ) <= 0; ?>
<a itemprop="url" class="mkd-header-cart" href="<?php echo esc_url($woocommerce->cart->get_cart_url()); ?>">
<span class="mkd-cart-icon-text"><?php esc_html_e('CART', 'depot'); ?></span>
<span class="mkd-cart-info">
<span class="mkd-cart-info-total">( <?php echo wp_kses($woocommerce->cart->get_cart_contents_count()); ?> )</span>
</span>
</a>
<?php if ( !$cart_is_empty ) : ?>
<div class="mkd-shopping-cart-dropdown">
<ul>
<?php foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) :
$_product = $cart_item['data'];
// Only display if allowed
if ( ! $_product->exists() || $cart_item['quantity'] == 0 ) {
continue;
}
// Get price
if ( version_compare( WOOCOMMERCE_VERSION, '3.0' ) >= 0 ) {
$product_price = get_option( 'woocommerce_tax_display_cart' ) == 'excl' ? wc_get_price_excluding_tax( $_product ) : wc_get_price_including_tax( $_product );
} else {
$product_price = get_option( 'woocommerce_tax_display_cart' ) == 'excl' ? $_product->get_price_excluding_tax() : $_product->get_price_including_tax();
}
?>
<li>
<div class="mkd-item-image-holder">
<a itemprop="url" href="<?php echo esc_url(get_permalink( $cart_item['product_id'] )); ?>">
<?php echo wp_kses($_product->get_image(), array(
'img' => array(
'src' => true,
'width' => true,
'height' => true,
'class' => true,
'alt' => true,
'title' => true,
'id' => true
)
)); ?>
</a>
</div>
<div class="mkd-item-info-holder">
<h5 itemprop="name" class="mkd-product-title"><a itemprop="url" href="<?php echo esc_url(get_permalink( $cart_item['product_id'] )); ?>"><?php echo apply_filters('depot_mikado_woo_widget_cart_product_title', $_product->get_title(), $_product ); ?></a></h5>
<span class="mkd-quantity"><?php echo esc_html($cart_item['quantity']); ?></span>
<?php echo apply_filters( 'depot_mikado_woo_cart_item_price_html', wc_price( $product_price ), $cart_item, $cart_item_key ); ?>
<?php echo apply_filters( 'depot_mikado_woo_cart_item_remove_link', sprintf('<span class="icon-arrows-remove"></span>', esc_url( $woocommerce->cart->get_remove_url( $cart_item_key ) ), esc_html__('Remove this item', 'depot') ), $cart_item_key ); ?>
</div>
</li>
<?php endforeach; ?>
<div class="mkd-cart-bottom">
<div class="mkd-subtotal-holder clearfix">
<span class="mkd-total"><?php esc_html_e( 'TOTAL:', 'depot' ); ?></span>
<span class="mkd-total-amount">
<?php echo wp_kses($woocommerce->cart->get_cart_subtotal(), array(
'span' => array(
'class' => true,
'id' => true
)
)); ?>
</span>
</div>
<?php if(!empty($cart_description)) { ?>
<div class="mkd-cart-description">
<div class="mkd-cart-description-inner">
<span><?php echo esc_html($cart_description); ?></span>
</div>
</div>
<?php } ?>
<div class="mkd-btn-holder clearfix">
<a itemprop="url" href="<?php echo esc_url($woocommerce->cart->get_cart_url()); ?>" class="mkd-view-cart" data-title="<?php esc_html_e('VIEW CART','depot'); ?>"><span><?php esc_html_e('VIEW CART','depot'); ?></span></a>
</div>
<div class="mkd-btn-holder clearfix">
<a itemprop="url" href="<?php echo esc_url($woocommerce->cart->get_checkout_url()); ?>" class="mkd-view-cart" data-title="<?php esc_html_e('CHECKOUT','depot'); ?>"><span><?php esc_html_e('CHECKOUT','depot'); ?></span></a>
</div>
</div>
</ul>
</div>
<?php else : ?>
<div class="mkd-shopping-cart-dropdown">
<ul>
<li class="mkd-empty-cart"><?php esc_html_e( 'No products in the cart.', 'depot' ); ?></li>
</ul>
</div>
<?php endif; ?>
</div>
</div>
<?php
}
}
I already implemented this function to make it update; but it doesn't change anything:
add_filter( 'woocommerce_add_to_cart_fragments', 'iconic_cart_count_fragments', 10, 1 );
function iconic_cart_count_fragments( $fragments ) {
$fragments['mkd-header-cart'] = '<span class="mkd-cart-icon-text"><?php esc_html_e(\'CART\', \'depot\'); ?></span>
<span class="mkd-cart-info">
<span class="mkd-cart-info-total">( <?php echo wp_kses($woocommerce->cart->get_cart_contents_count()); ?> )</span>
</span>';
return $fragments;
}
In wordpress itself I enabled the AJAX add to cart.
The add to cart button also has the class add_to_cart_button
The code that reloads those fragments can be found here: \plugins\woocommerce\assets\js\frontend\cart-fragments.js
To refresh WooCommerce widget you have to copy the code below
var $fragment_refresh = {
url: wc_cart_fragments_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'get_refreshed_fragments' ),
type: 'POST',
success: function( data ) {
if ( data && data.fragments ) {
$.each( data.fragments, function( key, value ) {
$( key ).replaceWith( value );
});
if ( $supports_html5_storage ) {
sessionStorage.setItem( wc_cart_fragments_params.fragment_name, JSON.stringify( data.fragments ) );
set_cart_hash( data.cart_hash );
if ( data.cart_hash ) {
set_cart_creation_timestamp();
}
}
$( document.body ).trigger( 'wc_fragments_refreshed' );
}
}
};
and to trigger the event you do this: $.ajax( $fragment_refresh ); OR jQuery.ajax( $fragment_refresh );
I am trying to add custom data to my menu items (say, for example, data-* attributes) or a dropdown to select the link target, etc.
Through the Screen Options, we have Link Target, Title Attribute, CSS Classes, Link Relationship (XFN) and Description (see screenshot below), but none really offer what I want.
I thought of looking for extensions to Advanced Custom Fields, or something of the sort, but I have not seen anything like it, nor anything through my theme functions.php file.
I finally found a good tutorial with lots of details and explanations as to how to achieve this. The article explains how the WordPress plugin Sweet Custom Menu works, and I've been able to add the functionality to my current theme.
As of today, the plugin hasn't been updated in over two years, but it still does what is expected of it.
You can try Carbon Fields Framework. It provides a custom fields for menu items.
Even if you are using ACF (Advanced Custom Fields) plugin, you still can add the plugin since both can work together.
add_filter( 'wp_edit_nav_menu_walker', 'custom_nav_edit_walker',10,2 );
function custom_nav_edit_walker($walker,$menu_id) {
return 'Walker_Nav_Menu_Edit_Custom';
}
/*
* Saves new field navmenu
*/
add_action('wp_update_nav_menu_item', 'custom_nav_update',10, 3);
function custom_nav_update($menu_id, $menu_item_db_id, $args ) {
if ( is_array($_REQUEST['menu-item-custom']) ) {
$custom_value = $_REQUEST['menu-item-custom'][$menu_item_db_id];
update_post_meta( $menu_item_db_id, '_menu_item_custom', $custom_value );
}
}
/*
* Adds value of new field to Navmenu
*/
add_filter( 'wp_setup_nav_menu_item','custom_nav_item' );
function custom_nav_item($menu_item) {
$menu_item->custom = get_post_meta( $menu_item->ID, '_menu_item_custom', true );
return $menu_item;
}
class Walker_Nav_Menu_Edit_Custom extends Walker_Nav_Menu {
function start_lvl( &$output, $depth = 0, $args = array() ) {}
/**
* Ends the list of after the elements are added.
*
* #see Walker_Nav_Menu::end_lvl()
*
* #since 3.0.0
*
* #param string $output Passed by reference.
* #param int $depth Depth of menu item. Used for padding.
* #param array $args Not used.
*/
function end_lvl( &$output, $depth = 0, $args = array() ) {}
/**
* Start the element output.
*
* #see Walker_Nav_Menu::start_el()
* #since 3.0.0
*
* #global int $_wp_nav_menu_max_depth
*
* #param string $output Used to append additional content (passed by reference).
* #param object $item Menu item data object.
* #param int $depth Depth of menu item. Used for padding.
* #param array $args Not used.
* #param int $id Not used.
*/
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
global $_wp_nav_menu_max_depth;
$_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
ob_start();
$item_id = esc_attr( $item->ID );
$removed_args = array(
'action',
'customlink-tab',
'edit-menu-item',
'menu-item',
'page-tab',
'_wpnonce',
);
$original_title = false;
if ( 'taxonomy' == $item->type ) {
$original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
if ( is_wp_error( $original_title ) ) {
$original_title = false;
}
} elseif ( 'post_type' == $item->type ) {
$original_object = get_post( $item->object_id );
$original_title = get_the_title( $original_object->ID );
} elseif ( 'post_type_archive' == $item->type ) {
$original_object = get_post_type_object( $item->object );
if ( $original_object ) {
$original_title = $original_object->labels->archives;
}
}
$classes = array(
'menu-item menu-item-depth-' . $depth,
'menu-item-' . esc_attr( $item->object ),
'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive' ),
);
$title = $item->title;
if ( ! empty( $item->_invalid ) ) {
$classes[] = 'menu-item-invalid';
/* translators: %s: title of menu item which is invalid */
$title = sprintf( __( '%s (Invalid)' ), $item->title );
} elseif ( isset( $item->post_status ) && 'draft' == $item->post_status ) {
$classes[] = 'pending';
/* translators: %s: title of menu item in draft status */
$title = sprintf( __( '%s (Pending)' ), $item->title );
}
$title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label;
$submenu_text = '';
if ( 0 == $depth ) {
$submenu_text = 'style="display: none;"';
}
?>
<li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode( ' ', $classes ); ?>">
<div class="menu-item-bar">
<div class="menu-item-handle">
<span class="item-title"><span class="menu-item-title"><?php echo esc_html( $title ); ?></span> <span class="is-submenu" <?php echo $submenu_text; ?>><?php _e( 'sub item' ); ?></span></span>
<span class="item-controls">
<span class="item-type"><?php echo esc_html( $item->type_label ); ?></span>
<span class="item-order hide-if-js">
<a href="
<?php
echo wp_nonce_url(
add_query_arg(
array(
'action' => 'move-up-menu-item',
'menu-item' => $item_id,
),
remove_query_arg( $removed_args, admin_url( 'nav-menus.php' ) )
),
'move-menu_item'
);
?>
" class="item-move-up" aria-label="<?php esc_attr_e( 'Move up' ); ?>">↑</a>
|
<a href="
<?php
echo wp_nonce_url(
add_query_arg(
array(
'action' => 'move-down-menu-item',
'menu-item' => $item_id,
),
remove_query_arg( $removed_args, admin_url( 'nav-menus.php' ) )
),
'move-menu_item'
);
?>
" class="item-move-down" aria-label="<?php esc_attr_e( 'Move down' ); ?>">↓</a>
</span>
<a class="item-edit" id="edit-<?php echo $item_id; ?>" href="
<?php
echo ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? admin_url( 'nav-menus.php' ) : add_query_arg( 'edit-menu-item', $item_id, remove_query_arg( $removed_args, admin_url( 'nav-menus.php#menu-item-settings-' . $item_id ) ) );
?>
" aria-label="<?php esc_attr_e( 'Edit menu item' ); ?>"><span class="screen-reader-text"><?php _e( 'Edit' ); ?></span></a>
</span>
</div>
</div>
<div class="menu-item-settings wp-clearfix" id="menu-item-settings-<?php echo $item_id; ?>">
<?php if ( 'custom' == $item->type ) : ?>
<p class="field-url description description-wide">
<label for="edit-menu-item-url-<?php echo $item_id; ?>">
<?php _e( 'URL' ); ?><br />
<input type="text" id="edit-menu-item-url-<?php echo $item_id; ?>" class="widefat code edit-menu-item-url" name="menu-item-url[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->url ); ?>" />
</label>
</p>
<?php endif; ?>
<p class="description description-wide">
<label for="edit-menu-item-title-<?php echo $item_id; ?>">
<?php _e( 'Navigation Label' ); ?><br />
<input type="text" id="edit-menu-item-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-title" name="menu-item-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->title ); ?>" />
</label>
</p>
<p class="field-title-attribute field-attr-title description description-wide">
<label for="edit-menu-item-attr-title-<?php echo $item_id; ?>">
<?php _e( 'Title Attribute' ); ?><br />
<input type="text" id="edit-menu-item-attr-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-attr-title" name="menu-item-attr-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->post_excerpt ); ?>" />
</label>
</p>
<p class="field-link-target description">
<label for="edit-menu-item-target-<?php echo $item_id; ?>">
<input type="checkbox" id="edit-menu-item-target-<?php echo $item_id; ?>" value="_blank" name="menu-item-target[<?php echo $item_id; ?>]"<?php checked( $item->target, '_blank' ); ?> />
<?php _e( 'Open link in a new tab' ); ?>
</label>
</p>
<p class="field-css-classes description description-thin">
<label for="edit-menu-item-classes-<?php echo $item_id; ?>">
<?php _e( 'CSS Classes (optional)' ); ?><br />
<input type="text" id="edit-menu-item-classes-<?php echo $item_id; ?>" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php echo $item_id; ?>]" value="<?php echo esc_attr( implode( ' ', $item->classes ) ); ?>" />
</label>
</p>
<p class="field-xfn description description-thin">
<label for="edit-menu-item-xfn-<?php echo $item_id; ?>">
<?php _e( 'Link Relationship (XFN)' ); ?><br />
<input type="text" id="edit-menu-item-xfn-<?php echo $item_id; ?>" class="widefat code edit-menu-item-xfn" name="menu-item-xfn[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->xfn ); ?>" />
</label>
</p>
<p class="field-description description description-wide">
<label for="edit-menu-item-description-<?php echo $item_id; ?>">
<?php _e( 'Description' ); ?><br />
<textarea id="edit-menu-item-description-<?php echo $item_id; ?>" class="widefat edit-menu-item-description" rows="3" cols="20" name="menu-item-description[<?php echo $item_id; ?>]"><?php echo esc_html( $item->description ); // textarea_escaped ?></textarea>
<span class="description"><?php _e( 'The description will be displayed in the menu if the current theme supports it.' ); ?></span>
</label>
</p>
<p class="field-custom description description-wide">
<label for="edit-menu-item-custom-<?php echo $item_id; ?>">
<?php _e( 'Custom' ); ?><br />
<input type="text" id="edit-menu-item-custom-<?php echo $item_id; ?>" class="widefat code edit-menu-item-custom" name="menu-item-custom[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->custom ); ?>" />
</label>
</p>
<fieldset class="field-move hide-if-no-js description description-wide">
<span class="field-move-visual-label" aria-hidden="true"><?php _e( 'Move' ); ?></span>
<button type="button" class="button-link menus-move menus-move-up" data-dir="up"><?php _e( 'Up one' ); ?></button>
<button type="button" class="button-link menus-move menus-move-down" data-dir="down"><?php _e( 'Down one' ); ?></button>
<button type="button" class="button-link menus-move menus-move-left" data-dir="left"></button>
<button type="button" class="button-link menus-move menus-move-right" data-dir="right"></button>
<button type="button" class="button-link menus-move menus-move-top" data-dir="top"><?php _e( 'To the top' ); ?></button>
</fieldset>
<div class="menu-item-actions description-wide submitbox">
<?php if ( 'custom' != $item->type && $original_title !== false ) : ?>
<p class="link-to-original">
<?php
/* translators: %s: original title */
printf( __( 'Original: %s' ), '' . esc_html( $original_title ) . '' );
?>
</p>
<?php endif; ?>
<a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="
<?php
echo wp_nonce_url(
add_query_arg(
array(
'action' => 'delete-menu-item',
'menu-item' => $item_id,
),
admin_url( 'nav-menus.php' )
),
'delete-menu_item_' . $item_id
);
?>
"><?php _e( 'Remove' ); ?></a> <span class="meta-sep hide-if-no-js"> | </span> <a class="item-cancel submitcancel hide-if-no-js" id="cancel-<?php echo $item_id; ?>" href="
<?php
echo esc_url(
add_query_arg(
array(
'edit-menu-item' => $item_id,
'cancel' => time(),
),
admin_url( 'nav-menus.php' )
)
);
?>
#menu-item-settings-<?php echo $item_id; ?>"><?php _e( 'Cancel' ); ?></a>
</div>
<input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" />
<input class="menu-item-data-object-id" type="hidden" name="menu-item-object-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object_id ); ?>" />
<input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object ); ?>" />
<input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_item_parent ); ?>" />
<input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_order ); ?>" />
<input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->type ); ?>" />
</div><!-- .menu-item-settings-->
<ul class="menu-item-transport"></ul>
<?php
$output .= ob_get_clean();
}
}