php 扩展Walker_Nav_Menu
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 扩展Walker_Nav_Menu相关的知识,希望对你有一定的参考价值。
class Description_Walker extends Walker_Nav_Menu {
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
$classes = empty($item->classes) ? array () : (array) $item->classes;
$class_names = join(' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
!empty ( $class_names ) and $class_names = ' class="'. esc_attr( $class_names ) . '"';
$output .= "";
$attributes = '';
!empty( $item->attr_title ) and $attributes .= ' title="' . esc_attr( $item->attr_title ) .'"';
!empty( $item->target ) and $attributes .= ' target="' . esc_attr( $item->target ) .'"';
!empty( $item->xfn ) and $attributes .= ' rel="' . esc_attr( $item->xfn ) .'"';
!empty( $item->url ) and $attributes .= ' href="' . esc_attr( $item->url ) .'"';
$title = apply_filters( 'the_title', $item->title, $item->ID );
$item_output = $args->before
. "<a $attributes $class_names>"
. $args->link_before
. $title
. '</a>'
. $args->link_after
. $args->after;
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
}
}
//Llamado en el theme:
wp_nav_menu(
array(
'theme_location' => 'home-menu',
'container' => false,
'items_wrap' => '<nav class="%2$s">%3$s</nav>', // replacing the ul with nav
'walker' => new Description_Walker,
'menu_class' => 'nav-principal'
)
);
以上是关于php 扩展Walker_Nav_Menu的主要内容,如果未能解决你的问题,请参考以下文章
关于php7.0.4的pcntl扩展
Docker php安装扩展步骤详解
php 怎么安装扩展
PHP 扩展开发初探
我要安装php的mcrypt扩展
php环境下如何开启MySQL扩展