• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_nav_menu函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_nav_menu函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_nav_menu函数的具体用法?PHP wp_nav_menu怎么用?PHP wp_nav_menu使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_nav_menu函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: widget

    function widget($args, $instance)
    {
        extract($args);
        // Get menu
        if (!isset($instance['speed'])) {
            $instance['speed'] = 'slow';
        }
        $widget_options = wp_parse_args($instance, $this->defaults);
        extract($widget_options, EXTR_SKIP);
        $nav_menu = wp_get_nav_menu_object($instance['nav_menu']);
        if (!$nav_menu) {
            return;
        }
        $instance['title'] = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
        $classMenu = $instance['classMenu'] != '' ? $instance['classMenu'] : 'menu';
        echo $args['before_widget'];
        if (!empty($instance['title'])) {
            echo $args['before_title'] . $instance['title'] . $args['after_title'];
        }
        ?>
		
		<div class="dcjq-accordion" id="<?php 
        echo $this->id . '-item';
        ?>
">
		
			<?php 
        wp_nav_menu(array('fallback_cb' => '', 'menu' => $nav_menu, 'container' => false, 'menu_class' => $classMenu));
        ?>
		
		</div>
		<?php 
        echo $args['after_widget'];
    }
开发者ID:healthcommcore,项目名称:osnap,代码行数:34,代码来源:dcwp_jquery_accordion_widget.php


示例2: header_style

function header_style()
{
    $nav_items = wp_nav_menu(array('echo' => false, 'theme_location' => 'primary', 'depth' => 1));
    $nav_items_count = substr_count($nav_items, 'class="menu-item ');
    $nav_item_width = 100 / $nav_items_count - 0.3;
    return "<style type='text/css'>\n\n\t\t\t\t.nav ul li, .footer-nav ul li {\n\t\t\t\t\twidth: " . $nav_item_width . "%;\n\t\t\t\t}\n\t\t\t</style>";
}
开发者ID:jdillman1989,项目名称:Composer-WP-Theme,代码行数:7,代码来源:functions.php


示例3: widget

 public function widget($args, $instance)
 {
     // Get menu
     $nav_menu = !empty($instance['nav_menu']) ? wp_get_nav_menu_object($instance['nav_menu']) : false;
     if (!$nav_menu) {
         return;
     }
     /** This filter is documented in wp-includes/default-widgets.php */
     $instance['title'] = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
     echo $args['before_widget'];
     if (!empty($instance['title'])) {
         echo $args['before_title'] . $instance['title'] . $args['after_title'];
     }
     $nav_menu_args = array('fallback_cb' => '', 'menu' => $nav_menu, 'container-class' => 'container-fluid', 'items_wrap' => '<ul id="%1$s" class="nav nav-sidebar">%3$s</ul>', 'depth' => 1);
     /**
      * Filter the arguments for the Custom Menu widget.
      *
      * @since 4.2.0
      *
      * @param array    $nav_menu_args {
      *     An array of arguments passed to wp_nav_menu() to retrieve a custom menu.
      *
      *     @type callback|bool $fallback_cb Callback to fire if the menu doesn't exist. Default empty.
      *     @type mixed         $menu        Menu ID, slug, or name.
      * }
      * @param stdClass $nav_menu      Nav menu object for the current menu.
      * @param array    $args          Display arguments for the current widget.
      */
     wp_nav_menu(apply_filters('widget_nav_menu_args', $nav_menu_args, $nav_menu, $args));
     echo $args['after_widget'];
 }
开发者ID:eggmatters,项目名称:monsoon-responsive,代码行数:31,代码来源:MR_Widgets.php


示例4: widget

 /**
  * Outputs the content for the current Custom Menu widget instance.
  *
  * @since 3.0.0
  * @access public
  *
  * @param array $args     Display arguments including 'before_title', 'after_title',
  *                        'before_widget', and 'after_widget'.
  * @param array $instance Settings for the current Custom Menu widget instance.
  */
 public function widget($args, $instance)
 {
     // Get menu
     $nav_menu = !empty($instance['nav_menu']) ? wp_get_nav_menu_object($instance['nav_menu']) : false;
     if (!$nav_menu) {
         return;
     }
     /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
     $instance['title'] = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
     echo $args['before_widget'];
     if (!empty($instance['title'])) {
         echo $args['before_title'] . $instance['title'] . $args['after_title'];
     }
     $nav_menu_args = array('fallback_cb' => '', 'menu' => $nav_menu);
     /**
      * Filter the arguments for the Custom Menu widget.
      *
      * @since 4.2.0
      * @since 4.4.0 Added the `$instance` parameter.
      *
      * @param array    $nav_menu_args {
      *     An array of arguments passed to wp_nav_menu() to retrieve a custom menu.
      *
      *     @type callable|bool $fallback_cb Callback to fire if the menu doesn't exist. Default empty.
      *     @type mixed         $menu        Menu ID, slug, or name.
      * }
      * @param stdClass $nav_menu      Nav menu object for the current menu.
      * @param array    $args          Display arguments for the current widget.
      * @param array    $instance      Array of settings for the current widget.
      */
     wp_nav_menu(apply_filters('widget_nav_menu_args', $nav_menu_args, $nav_menu, $args, $instance));
     echo $args['after_widget'];
 }
开发者ID:qaryas,项目名称:qaryas_site,代码行数:43,代码来源:class-wp-nav-menu-widget.php


示例5: vc_menu_func

function vc_menu_func($atts, $content)
{
    ob_start();
    ?>
	<nav class="navbar navbar-default" id="menunav">
				<div class="container">
					<div class="row">
						<ul class="nav navbar-nav pull-right margin-right-15">
							<li class="dropdown resv-dropdown" id="ibe-dropdown">
								<a class="resv-link dropdown-toggle" href="#back-to-reserve" id="ibe-dropdown-button"><?php 
    echo esc_html(get_theme_mod('booking_button_text', esc_attr__('Reservations', 'Property Theme')));
    ?>
								</a>
							</li>
						</ul>

						<?php 
    if (has_nav_menu('primary_navigation')) {
        wp_nav_menu(['theme_location' => 'primary_navigation', 'menu_class' => 'nav navbar-nav navbar-right']);
    }
    ?>
					</div>
				</div>
			</nav>
	<?php 
    $returnvariable = ob_get_clean();
    return $returnvariable;
}
开发者ID:ratheeshpkr,项目名称:snhotel,代码行数:28,代码来源:snhotel-vc_addons.php


示例6: bigblank_footer_menu_fallback

 /**
  * Footer menu fallback
  */
 function bigblank_footer_menu_fallback()
 {
     $menus = wp_get_nav_menus();
     if (!empty($menus)) {
         return wp_nav_menu(array('container' => 'nav', 'depth' => 1, 'container_id' => 'footer-nav'));
     }
 }
开发者ID:victorknust,项目名称:BigBlankTheme,代码行数:10,代码来源:template-tags.php


示例7: widget

 /**
  * load widget
  *
  * @name    widget
  * @author  Marcelo Mesquita <[email protected]>
  * @since   2012-12-30
  * @updated 2012-04-25
  * @param   array $args - widget structure
  * @param   array $instance - widget data
  * @return  void
  */
 function widget($args, $instance)
 {
     global $wpdb;
     if (function_exists('switch_to_blog')) {
         switch_to_blog($instance['blog']);
     }
     if (is_multisite()) {
         $site_path = $wpdb->get_var($wpdb->prepare("SELECT path FROM {$wpdb->blogs} WHERE blog_id = 1"));
         $blog_path = $wpdb->get_var($wpdb->prepare("SELECT path FROM {$wpdb->blogs} WHERE blog_id = %d", get_current_blog_id()));
         $area = str_replace(array($site_path, '/'), '', $blog_path);
     }
     $blog_url = get_bloginfo('url');
     // show tags
     print $args['before_widget'];
     if (!empty($instance['title'])) {
         print $args['before_head'];
         print $args['before_title'] . $instance['title'] . $args['after_title'];
         print $args['after_head'];
     }
     print $args['before_body'];
     wp_nav_menu("menu={$instance['menu']}");
     print $args['after_body'];
     print $args['after_widget'];
     if (function_exists('restore_current_blog')) {
         restore_current_blog();
     }
 }
开发者ID:CoordCulturaDigital-Minc,项目名称:setoriais,代码行数:38,代码来源:sav-widget-custom-menu.php


示例8: ds_add_top_header

function ds_add_top_header()
{
    $enable_header_top = esc_attr(get_theme_mod('dt_enable_header_top', DT_ENABLE_HEADER_TOP));
    if ($enable_header_top != '1') {
        return;
    }
    ?>
    <div class="ds-top-header">
        <div class="container">
            <div class="ds-top-header-inner">
                <div class="ds-top-head-left">
                    <?php 
    if (display_header_text()) {
        echo get_bloginfo('description', 'display');
    }
    ?>
                </div>
                <div class="ds-top-head-right">
                    <?php 
    wp_nav_menu(array('theme_location' => 'header-top', 'container_class' => 'header_top_menu', 'menu_class' => 'ds-top-menu-ul'));
    ?>
                </div>
            </div>
        </div>
    </div>
    <?php 
}
开发者ID:mistergiri,项目名称:directory-starter,代码行数:27,代码来源:custom.php


示例9: msd_inline_menu

function msd_inline_menu($atts)
{
    extract(shortcode_atts(array('menu' => 'primary-links', 'walker' => 'msd_icon_desc_walker'), $atts));
    $walker = new $walker();
    $defaults = array('menu' => $menu, 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => '', 'echo' => false, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '<h3>', 'link_after' => '</h3>', 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>', 'depth' => 0, 'walker' => $walker);
    return wp_nav_menu($defaults);
}
开发者ID:foxydot,项目名称:madvia,代码行数:7,代码来源:shortcodes.php


示例10: listify_tertiary_menu

function listify_tertiary_menu()
{
    global $post;
    $enabled = get_post_meta($post->ID, 'enable_tertiary_navigation', true);
    if (1 != $enabled) {
        return;
    }
    ob_start();
    wp_nav_menu(array('theme_location' => 'tertiary', 'container_class' => 'navigation-bar nav-menu', 'menu_class' => 'tertiary nav-menu'));
    $menu = ob_get_clean();
    if ('' == $menu) {
        return;
    }
    remove_filter('the_title', 'wc_page_endpoint_title');
    ?>
	<nav class="tertiary-navigation" role="navigation">
		<div class="container">
			<a href="#" class="navigation-bar-toggle">
				<i class="ion-navicon-round"></i>
				<?php 
    echo listify_get_theme_menu_name('tertiary');
    ?>
			</a>
			<div class="navigation-bar-wrapper">
				<?php 
    echo $menu;
    ?>
			</div>
		</div>
	</nav><!-- #site-navigation -->
<?php 
    add_filter('the_title', 'wc_page_endpoint_title');
}
开发者ID:abdullahrahim,项目名称:shadighar,代码行数:33,代码来源:template-tags.php


示例11: atp_secondary_menu

 function atp_secondary_menu()
 {
     if (has_nav_menu('secondary-menu')) {
         wp_nav_menu(array('container' => false, 'theme_location' => 'secondary-menu', 'menu_class' => 'sf-menu', 'echo' => true, 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'depth' => 0, 'walker' => new description_walker()));
     } else {
     }
 }
开发者ID:pryspry,项目名称:MusicPlay,代码行数:7,代码来源:atp_generator.php


示例12: bfa_new_wp3_menus

function bfa_new_wp3_menus($theme_location = "menu1", $alignment = "left")
{
    $before_menu = '';
    $after_menu = '';
    /*
    if ( $theme_location == "menu1" ) $menu_id = "rmenu2-page";
    if ( $theme_location == "menu2" ) $menu_id = "rmenu-cat";
    */
    if ($theme_location == "menu1") {
        $menu_id = "rmenu2";
    }
    if ($theme_location == "menu2") {
        $menu_id = "rmenu";
    }
    $menu_class = "clearfix rMenu-hor rMenu";
    if ($alignment == "right") {
        $menu_class .= " rMenu-hRight";
    }
    if ($alignment == "center") {
        if ($theme_location == "menu1") {
            $before_menu = '<div id="bfa_page_menu"><table cellpadding="0" cellspacing="0" style="margin: 0 auto"><tr><td align="center">';
        }
        if ($theme_location == "menu2") {
            $before_menu = '<div id="bfa_cat_menu"><table cellpadding="0" cellspacing="0" style="margin: 0 auto"><tr><td align="center">';
        }
        $after_menu = '</td></tr></table></div>';
    }
    ob_start();
    wp_nav_menu(array('theme_location' => $theme_location, 'container' => 'div', 'container_id' => $theme_location, 'menu_class' => $menu_class, 'menu_id' => $menu_id, 'link_before' => '<span>', 'link_after' => '</span>'));
    $newmenu = ob_get_contents();
    ob_end_clean();
    $newmenu = preg_replace("/<li (.*?)class=\"(.*?)\">(.*?)\n(.*?)<ul class=\"/i", "<li \\1 class=\"rMenu-expand \\2\">\\3\n\\4<ul class=\"rMenu-ver ", $newmenu);
    return $before_menu . $newmenu . $after_menu;
}
开发者ID:ricofreak,项目名称:wordPressBlog,代码行数:34,代码来源:bfa_new_wp3_menus.php


示例13: add_section_menu

 /**
  * Add Section Menu
  * Matches a menu and location to the Section Page slug
  *
  * @author Jordan Pakrosnis
  */
 function add_section_menu()
 {
     $post = get_post();
     $section_menu_args = array('menu' => $post->post_name, 'container' => 'nav', 'container_class' => 'section-menu', 'echo' => true, 'depth' => 2);
     // Output Menu
     wp_nav_menu($section_menu_args);
 }
开发者ID:JordanPak,项目名称:UCFBands,代码行数:13,代码来源:menus.php


示例14: toolset_starter_menu

function toolset_starter_menu($menu_position, $menu_class, $menu_container_class)
{
    ?>
<nav class="<?php 
    echo $menu_container_class;
    ?>
" role="navigation">
	<?php 
    if ($menu_position === 'static-top' || $menu_position === 'fixed-top') {
        echo '<div class="container">';
    }
    ?>
	<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
		<span class="sr-only"><?php 
    _e('Toggle navigation', "toolset_starter");
    ?>
</span>
		<span class="icon-bar"></span>
		<span class="icon-bar"></span>
		<span class="icon-bar"></span>
	</button>
	<div class="collapse navbar-collapse" id="nav-main">
		<?php 
    wp_nav_menu(array('theme_location' => 'header-menu', 'depth' => 5, 'menu_class' => $menu_class, 'fallback_cb' => 'wpbootstrap_menu_fallback', 'walker' => new Wpbootstrap_Nav_Walker()));
    ?>
<!-- #nav-main -->
	</div><!-- .navbar-collapse -->
	<?php 
    if ($menu_position === 'static-top' || $menu_position === 'fixed-top') {
        echo '</div>';
    }
    ?>
</nav><!-- .navbar -->
<?php 
}
开发者ID:twelch555,项目名称:core_toolsetstarter,代码行数:35,代码来源:header.php


示例15: get_menu

 public static function get_menu()
 {
     if (!self::$_menu) {
         self::$_menu = wp_nav_menu(array('theme_location' => 'social', 'menu_class' => 'social-menu', 'echo' => false, 'depth' => 0, 'fallback_cb' => ''));
     }
     return self::$_menu;
 }
开发者ID:Teplitsa,项目名称:giger,代码行数:7,代码来源:class-statics.php


示例16: df_footer_nav

function df_footer_nav($newOptions = array())
{
    $options = array('container' => 'nav', 'container_class' => 'footer-nav clearfix', 'menu' => __('Footer Navigation', 'df_framework'), 'menu_class' => 'inner-nav clearfix', 'theme_location' => 'footer-nav', 'items_wrap' => '<ul id="%1$s" class="%2$s">' . apply_filters('df_footer_nav_items', '%3$s') . '</ul>', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'depth' => 1, 'fallback_cb' => '__return_false');
    if (has_nav_menu('footer-nav')) {
        wp_nav_menu(array_merge($options, apply_filters('df_footer_nav', $newOptions)));
    }
}
开发者ID:WordPress-Phoenix,项目名称:div-framework,代码行数:7,代码来源:admin.php


示例17: tfuse_menu

function tfuse_menu($menu_type)
{
    global $menus;
    if (isset($menus[$menu_type])) {
        wp_nav_menu($menus[$menu_type]);
    }
}
开发者ID:aaronfrey,项目名称:PepperLillie-GVCO,代码行数:7,代码来源:MENU.php


示例18: dt_menu

function dt_menu($data = array())
{
    $defaults = array('menu_wraper' => '<ul id="%MENU_ID%">%MENU_ITEMS%</ul>', 'menu_items' => '<li class="testingg %ITEM_CLASS%"><a href="%ITEM_HREF%" title="%ESC_ITEM_TITLE%">%ITEM_TITLE%</a>%SUBMENU%</li>', 'submenu' => '<div style="visibility: hidden; display: block;"><ul>%ITEM%</ul><i></i></div>', 'parent_clicable' => true, 'params' => array('act_class' => 'act'), 'force_fallback' => false, 'fallback_cb' => 'dt_page_menu', 'echo' => true, 'location' => 'primary');
    $options = wp_parse_args($data, $defaults);
    $options['menu_wraper'] = str_replace(array('%MENU_ID%', '%MENU_CLASS%', '%MENU_ITEMS%'), array('%1$s', '%2$s', '%3$s'), $options['menu_wraper']);
    $options['menu_items'] = explode('%SUBMENU%', $options['menu_items']);
    $options['submenu'] = explode('%ITEM%', $options['submenu']);
    $options = apply_filters('dt_menu_options', $options);
    $theme_location = $options['location'];
    $parent_clicable = apply_filters('dt_menu-parent_clicable', $options['parent_clicable']);
    $args = array('container' => false, 'menu_id' => 'mainmenu', 'fallback_cb' => $options['fallback_cb'], 'theme_location' => $theme_location, 'parent_clicable' => $parent_clicable, 'menu_class' => false, 'container_class' => false, 'dt_has_nav_menu' => has_nav_menu($theme_location), 'dt_item_wrap_start' => $options['menu_items'][0], 'dt_item_wrap_end' => $options['menu_items'][1], 'dt_submenu_wrap_start' => $options['submenu'][0], 'dt_submenu_wrap_end' => $options['submenu'][1], 'items_wrap' => $options['menu_wraper'], 'please_be_fat' => true);
    $args = array_merge($args, $options['params']);
    if ($options['force_fallback']) {
        $output = dt_page_menu($args);
        if (!isset($options['params'], $options['params']['echo']) || $options['params']['echo']) {
            echo $output;
        }
        return $output;
    }
    if ($args['dt_has_nav_menu']) {
        $walker_args = array('theme_location' => $theme_location, 'parent_clicable' => $parent_clicable);
        $args['walker'] = new Dt_Walker_Nav_Menu($walker_args);
    }
    return wp_nav_menu($args);
}
开发者ID:RDePoppe,项目名称:luminaterealestate,代码行数:25,代码来源:core-menu.php


示例19: widget

 public function widget($args, $instance)
 {
     // Get menu
     $nav_menu = !empty($instance['offcanvas_nav_menu']) ? wp_get_nav_menu_object($instance['offcanvas_nav_menu']) : false;
     if (!$nav_menu) {
         return;
     }
     /** This filter is documented in wp-includes/default-widgets.php */
     $instance['title'] = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
     echo $args['before_widget'];
     if (!empty($instance['title'])) {
         echo $args['before_title'] . $instance['title'] . $args['after_title'];
     }
     $nav_menu_args = array('fallback_cb' => '', 'menu' => $nav_menu, 'echo' => false, 'container' => 'ul', 'menu_class' => 'off-canvas-list');
     /**
      * Filter the arguments for the Custom Menu widget.
      *
      * @since 4.2.0
      *
      * @param array    $nav_menu_args {
      *     An array of arguments passed to wp_nav_menu() to retrieve a custom menu.
      *
      *     @type callback|bool $fallback_cb Callback to fire if the menu doesn't exist. Default empty.
      *     @type mixed         $menu        Menu ID, slug, or name.
      * }
      * @param stdClass $nav_menu      Nav menu object for the current menu.
      * @param array    $args          Display arguments for the current widget.
      */
     echo str_replace('sub-menu', 'sub-menu left-submenu', wp_nav_menu(apply_filters('widget_nav_menu_args', $nav_menu_args, $nav_menu, $args)));
     echo $args['after_widget'];
 }
开发者ID:adamplabarge,项目名称:bermstyle,代码行数:31,代码来源:Custom_Foundation_OffCanvas_Nav_Menu_Widget.php


示例20: wp_nav_menu_extended

function wp_nav_menu_extended($args = array())
{
    $_echo = array_key_exists('echo', $args) ? $args['echo'] : true;
    $args['echo'] = false;
    $menu = wp_nav_menu($args);
    // Load menu as xml
    $menu = simplexml_load_string($menu);
    // Find current menu item with xpath selector
    if (array_key_exists('xpath', $args)) {
        $xpath = $args['xpath'];
    } else {
        $xpath = '//li[contains(@class, "current-menu-item") or contains(@class, "current_page_item")]';
    }
    $current = $menu->xpath($xpath);
    // If current item exists
    if (!empty($current)) {
        $text_node = (string) $current[0]->children();
        // Remove link
        unset($current[0]->a);
        // Create required element with text from link
        $element_name = $args['replace_a_by'] ? $args['replace_a_by'] : 'span';
        $dom = dom_import_simplexml($current[0]);
        $n = $dom->insertBefore($dom->ownerDocument->createElement($element_name, $text_node), $dom->firstChild);
        $current[0] = simplexml_import_dom($n);
    }
    $xml_doc = new DOMDocument('1.0', 'utf-8');
    $menu_x = $xml_doc->importNode(dom_import_simplexml($menu), true);
    $xml_doc->appendChild($menu_x);
    $menu = $xml_doc->saveXML($xml_doc->documentElement);
    if ($_echo) {
        echo $menu;
    } else {
        return $menu;
    }
}
开发者ID:valerol,项目名称:korpus,代码行数:35,代码来源:functions.php



注:本文中的wp_nav_menu函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_nav_menu_disabled_check函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_mod函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap