1. Go to this page and download the library: Download livy/climber 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/ */
livy / climber example snippets
use Livy\Climber;
echo new Climber(
new Tree(
new Spotter\WordPress(wp_get_nav_menu_items($menuID))
)
);
// <nav class="simpleMenu" >
// <ul class="simpleMenu__menu level-0">
// ...etc
/**
* Instantiate our Climber, and tell it where we are.
*/
$Climber = new Climber(
new Tree(new Spotter\WordPress(wp_get_nav_menu_items($menuID))),
get_permalink(get_the_ID())) // This returns the URL for the current page.
);
/**
* Open all links in a new window.
*/
$Climber->hook(
'link',
function ($data) {
$data['attrs'][] = ['target', '_blank'];
return $data;
}
);
/**
* Put the link after the submenu, instead of before.
*/
$Climber->hook(
'itemOutput',
function($data) {
$data['format'] = '%2$s%1$s';
return $data;
}
);
/**
* Print out our menu
*/
echo $Climber;
// For string-type properties...
$Climber->topClass = 'newMenuClass';
// For array-type properties...
$Climber->topAttrs = ['target', '_blank'];
function pulley__wp_get_menu_by_location(
string $location,
string $currentUrl = null
)
function pulley__wp_menu_by_location(
string $location,
string $currentUrl = null
)
$Climber = new Climber(
new Tree(new Spotter\WordPress(wp_get_nav_menu_items($menuID)))
);
$Climber->setCurrentURL(get_permalink(get_the_ID())); // Now this is the current URL!