PHP code example of phpwine / wpmenuwalker

1. Go to this page and download the library: Download phpwine/wpmenuwalker library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

phpwine / wpmenuwalker example snippets


 /* Installation */
 composer /
 composer 

  
 
 // functions.php 
 if ( ! defined( 'WPINC' ) ) { die; }

 // file on the very top 
 use \PHPWineOptimizedHtml\OptimizedHtml;

 /** PHPWine **/
 


  // Register custom navigation menu
  add_action( 'init', 'nielsoffice_nav_menus' );
  function nielsoffice_nav_menus() {

   $locations = array(
    'main-menu' => __( 'Primary menu', 'nielsoffice' )
   );
   register_nav_menus( $locations );
 }


// namespace
 use \PHPWineWPWalker\WineWPMenuWalker;

// init custom menu 
 wp_nav_menu( array(
   'theme_location'  => 'main-menu',
   'menu_id'         => 'primary-menu',

  'container' 	    => 'nav',
  'container_class' => 'menu-wine',   // %1$s
  'menu_class' 	    => 'wine', // %2$s .... %3$s = list items.
  'add_li_class'    => 'pwine',
  'items_wrap' 	    => '<ul class="p-wine %2$s" id="%1$s">%3$s</ul>',
  'walker' => new WineWPMenuWalker()
  )
);



 // Hooks sub-menu child parent [ assigned to depth]
 function one_sub_menut_child( $depth, $args ) { /***/ }

 // Hooks Replace Content menu specific item link
 function Courses( $item, $depth, $args, $id ) { /***/ }

 // Hooks Replace Content menu specific item no-link
 function item_24Courses( $item, $depth, $args, $id ) { /***/ }
  
 // Hooks insert element top and bottom from item
 function top_Courses( $item, $depth, $args, $id ) { /***/ }
 function bottom_Courses( $item, $depth, $args, $id ) { /***/ }


// replace link || no-link
function item_27English() {
  return [
   child=> [ 
     [h1, value=>["Hello Wolrd"]]	
   ]	
 ];
}