aiwoo_setup_nav_menu_item

The WooCommerce Menu Extension aiwoo setup nav menu item function.

Description

aiwoo_setup_nav_menu_item( $item ); 

Parameters (1)

0. $item
The item.

Usage

  1. if ( !function_exists( 'aiwoo_setup_nav_menu_item' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-menu-extension/include/frontend.inc.php'; 
  3.  
  4. // The item. 
  5. $item = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = aiwoo_setup_nav_menu_item($item); 
  9.  

Defined (1)

The function is defined in the following location(s).

/include/frontend.inc.php  
  1. function aiwoo_setup_nav_menu_item( $item ) { 
  2. global $pagenow, $woocommerce; 
  3. if( $pagenow!='nav-menus.php' && !defined('DOING_AJAX') && isset( $item->url ) && strstr( $item->url, '#aiwoo' ) != '' ) { 
  4. $item_url = substr( $item->url, 0, strpos( $item->url, '#', 1 ) ) . '#'; 
  5. $item_redirect = str_replace( $item_url, '', $item->url ); 
  6.  
  7. if(!empty($item_redirect)) 
  8. $item_redirect = $item_redirect; 
  9. else 
  10. $item_redirect = get_permalink( woocommerce_get_page_id( 'myaccount' ) ); 
  11.  
  12. switch( $item_url ) { 
  13. case '#aiwooshop#' : $item->url = get_permalink( woocommerce_get_page_id( 'shop' ) ); break; 
  14.  
  15. case '#aiwoocart#' : $item->url = get_permalink( woocommerce_get_page_id( 'cart' ) ); break; 
  16.  
  17. case '#aiwoobasket#' : $item->url = get_permalink( woocommerce_get_page_id( 'cart' ) );  
  18. $item->title = aiwoo_basket_title( $item->title ); break; 
  19.  
  20. case '#aiwoologin#' : $item->url = get_permalink( woocommerce_get_page_id( 'myaccount' ) ); break; 
  21.  
  22. case '#aiwoologout#' : $item->url = wp_logout_url( $item_redirect ); break; 
  23.  
  24. case '#aiwoologinout#' : $item->url = is_user_logged_in() ? wp_logout_url( $item_redirect ) : get_permalink( woocommerce_get_page_id( 'myaccount' ) ); 
  25. $item->title = aiwoo_loginout_title( $item->title ) ; break; 
  26.  
  27. case '#aiwoocheckout#' : $item->url = get_permalink( woocommerce_get_page_id( 'checkout' ) ); break;  
  28.  
  29. case '#aiwooterms#' : $item->url = get_permalink( woocommerce_get_page_id( 'terms' ) ); break; 
  30.  
  31. case '#aiwoomyaccount#' : $item->url = get_permalink( woocommerce_get_page_id( 'myaccount' ) ); break; 
  32.  
  33. case '#aiwoosearch#' : $titles = explode( '|', $item->title ); 
  34. $item->title = '<form action="'.esc_url( home_url( '/' ) ).'" class="woocommerce-product-search" method="get" role="search"> 
  35. <input type="search" title="'.esc_attr_x( 'Search for:', 'label' ).'" name="s" value="'.get_search_query().'" placeholder="'.esc_html( isset( $titles[0] ) ? $titles[0] : $item->title ).'" class="search-field"> 
  36. <input type="submit" value="'.esc_html( isset( $titles[1] ) ? $titles[1] : esc_attr_x( 'Search', 'submit button' ) ).'"> 
  37. <input type="hidden" value="product" name="post_type"> 
  38. </form>'; break; 
  39. $item->url = esc_url( $item->url ); 
  40. return $item;