本文整理汇总了PHP中walk_nav_menu_tree函数的典型用法代码示例。如果您正苦于以下问题:PHP walk_nav_menu_tree函数的具体用法?PHP walk_nav_menu_tree怎么用?PHP walk_nav_menu_tree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了walk_nav_menu_tree函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cpt_navmenu_metabox_content
function cpt_navmenu_metabox_content()
{
$post_types = get_post_types(array('show_in_nav_menus' => true, 'has_archive' => true), 'object');
if ($post_types) {
foreach ($post_types as &$post_type) {
$post_type->classes = array();
$post_type->type = $post_type->name;
$post_type->object_id = $post_type->name;
$post_type->title = $post_type->labels->name;
$post_type->object = 'cpt-archive';
$post_type->menu_item_parent = '';
$post_type->url = '';
$post_type->target = '';
$post_type->attr_title = '';
$post_type->xfn = '';
$post_type->db_id = '';
}
$walker = new Walker_Nav_Menu_Checklist(array());
echo '<div id="cpt-archive" class="posttypediv">';
echo '<div id="tabs-panel-cpt-archive" class="tabs-panel tabs-panel-active">';
echo '<ul id="ctp-archive-checklist" class="categorychecklist form-no-clear">';
echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $post_types), 0, (object) array('walker' => $walker));
echo '</ul>';
echo '</div><!-- /.tabs-panel -->';
echo '</div>';
echo '<p class="button-controls">';
echo '<span class="add-to-menu">';
//echo '<img class="waiting" src="' . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . '" alt="" />';
echo '<input type="submit" class="button-secondary submit-add-to-menu" value="' . __('Add to Menu', 'allstruck') . '" name="add-ctp-archive-menu-item" id="submit-cpt-archive" />';
echo '</span>';
echo '</p>';
}
}
示例2: ajax_add_to_menu
/**
* Ajax callback for our menu items
*
* @wordpress-action wp_ajax_buggypress_add_to_menu
* @return void Exits the program on completion
*/
public function ajax_add_to_menu()
{
check_ajax_referer('buggypress-menu', 'buggypress_nonce');
if (empty($_POST['menu_items'])) {
die('-1');
}
require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
$menu_items = $_POST['menu_items'];
$item_ids = array();
foreach ($menu_items as $item) {
$item_ids[] = $this->add_menu_item($item);
}
if (is_wp_error($item_ids)) {
die('-1');
}
// Set up menu items
$output_menu_items = array();
foreach ($item_ids as $menu_item_id) {
$menu_obj = get_post($menu_item_id);
if (!empty($menu_obj->ID)) {
$menu_obj = wp_setup_nav_menu_item($menu_obj);
$menu_obj->label = $menu_obj->title;
// don't show "(pending)" in ajax-added items
$menu_obj->type_label = 'BuggyPress';
$output_menu_items[] = $menu_obj;
}
}
// build the HTML output
if (!empty($output_menu_items)) {
$args = array('after' => '', 'before' => '', 'link_after' => '', 'link_before' => '', 'walker' => new Walker_Nav_Menu_Edit());
echo walk_nav_menu_tree($output_menu_items, 0, (object) $args);
}
exit;
}
示例3: cjtheme_admin_do_wp_nav_menu_meta_box
/**
* Build and populate the BuddyPress accordion on Appearance > Menus.
*
* @since cjtheme 1.5.1
*
* @global $nav_menu_selected_id
*/
function cjtheme_admin_do_wp_nav_menu_meta_box()
{
global $nav_menu_selected_id;
$walker = new cjtheme_Walker_Nav_Menu_Checklist(false);
$args = array('walker' => $walker);
$post_type_name = 'cjtheme';
$tabs = array();
$menu_items = array();
$menu_items[] = array('name' => __('title', 'cjtheme'), 'slug' => 'title', 'link' => '#', 'class' => 'title');
$menu_items[] = array('name' => __('Login', 'cjtheme'), 'slug' => 'login', 'link' => '#');
$menu_items[] = array('name' => __('Logout', 'cjtheme'), 'slug' => 'logout', 'link' => wp_logout_url(site_url()));
$menu_items[] = array('name' => __('Register', 'cjtheme'), 'slug' => 'register', 'link' => "#");
$menu_items[] = array('name' => __('Instant Search', 'cjtheme'), 'slug' => 'instant-search', 'link' => "#instant-search");
$menu_items = apply_filters('cjtheme_nav_menu_items', $menu_items);
$page_args = array();
if (!empty($menu_items)) {
foreach ($menu_items as $item) {
$item_name = '';
// Remove <span>number</span>
$item_name = preg_replace('/([.0-9]+)/', '', $item['name']);
$item_name = trim(strip_tags($item_name));
$page_args[$item['slug']] = (object) array('ID' => -1, 'post_title' => $item_name, 'post_author' => 0, 'post_date' => 0, 'post_excerpt' => $item['slug'], 'post_type' => 'page', 'post_status' => 'publish', 'comment_status' => 'closed', 'guid' => $item['link']);
}
} else {
_e('No items available here for the moment', 'cjtheme');
return;
}
$tabs['pages'] = $page_args;
?>
<div id="cjtheme-menu" class="posttypediv">
<div id="tabs-panel-posttype-<?php
echo $post_type_name;
?>
-loggedin" class="tabs-panel tabs-panel-active">
<ul id="cjtheme-menu-checklist-loggedin" class="categorychecklist form-no-clear">
<?php
echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $tabs['pages']), 0, (object) $args);
?>
</ul>
</div>
<p class="button-controls">
<span class="add-to-menu">
<input type="submit"<?php
if (function_exists('wp_nav_menu_disabled_check')) {
wp_nav_menu_disabled_check($nav_menu_selected_id);
}
?>
class="button-secondary submit-add-to-menu right" value="<?php
esc_attr_e('Add to Menu', 'cjtheme');
?>
" name="add-custom-menu-item" id="submit-cjtheme-menu" />
<span class="spinner"></span>
</span>
</p>
</div><!-- /#cjtheme-menu -->
<?php
}
示例4: show_selected_languages
/**
* @return void
*/
public function show_selected_languages()
{
$menu_items = $this->data->get_ajax_menu_items();
if (empty($menu_items)) {
wp_send_json_error();
}
// Needed for the walker.
require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
$data = walk_nav_menu_tree($menu_items, 0, (object) array('after' => '', 'before' => '', 'link_after' => '', 'link_before' => '', 'walker' => new Walker_Nav_Menu_Edit()));
wp_send_json_success($data);
}
示例5: show_selected_languages
/**
* @return void
*/
public function show_selected_languages()
{
$menu_items = $this->data->get_ajax_menu_items();
if (empty($menu_items)) {
die(-1);
}
// Needed for the walker
require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
$args = array('after' => '', 'before' => '', 'link_after' => '', 'link_before' => '', 'walker' => new Walker_Nav_Menu_Edit());
echo walk_nav_menu_tree($menu_items, 0, (object) $args);
exit;
}
示例6: archives_meta_box
/**
* Archives Menu
*
* @param mixed $object Current object.
* @param array $metabox Box settings.
*/
public static function archives_meta_box($object, $metabox)
{
global $nav_menu_selected_id;
if (empty(static::$post_types)) {
echo '<p>' . __('No items.') . '</p>';
return;
}
$walker = new \Walker_Nav_Menu_Checklist([]);
?>
<div id="<?php
echo static::$obj_archive;
?>
" class="<?php
echo static::$obj_archive;
?>
div">
<div id="tabs-panel-<?php
echo static::$obj_archive;
?>
" class="tabs-panel tabs-panel-active">
<ul id="<?php
echo static::$obj_archive;
?>
-checklist" class="categorychecklist form-no-clear"><?php
echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', static::$post_types), 0, (object) ['walker' => $walker]);
?>
</ul>
</div><!-- /.tabs-panel -->
</div>
<p class="button-controls">
<span class="add-to-menu">
<input type="submit"<?php
wp_nav_menu_disabled_check($nav_menu_selected_id);
?>
class="button-secondary submit-add-to-menu right" value="<?php
esc_attr_e('Add to Menu');
?>
" name="add-<?php
echo static::$obj_archive;
?>
-menu-item" id="submit-<?php
echo static::$obj_archive;
?>
" />
<span class="spinner"></span>
</span>
</p>
<?php
}
示例7: callback
public function callback($params)
{
global $_nav_menu_placeholder, $nav_menu_selected_id;
$_nav_menu_placeholder = 0 > $_nav_menu_placeholder ? $_nav_menu_placeholder - 1 : -1;
/* get custom post types with archive support */
$args = array('show_in_nav_menus' => true, 'has_archive' => true);
$post_types = Post_Type::find($args, 'object');
/* hydrate the necessary object properties for the walker */
foreach ($post_types as &$post_type) {
$post_type->classes = array();
$post_type->type = $post_type->name;
$post_type->object_id = $post_type->name;
$post_type->title = $post_type->labels->name . ' ' . __('Archive', 'default');
$post_type->object = 'cpt-archive';
$post_type->menu_item_parent = null;
$post_type->url = null;
$post_type->xfn = null;
$post_type->db_id = null;
$post_type->target = null;
$post_type->attr_title = null;
}
$walker = new \Walker_Nav_Menu_Checklist(array());
?>
<div id="cpt-archive" class="posttypediv">
<div id="tabs-panel-cpt-archive" class="tabs-panel tabs-panel-active">
<ul id="ctp-archive-checklist" class="categorychecklist form-no-clear">
<?php
echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $post_types), 0, (object) array('walker' => $walker));
?>
</ul>
</div>
</div>
<p class="button-controls">
<span class="add-to-menu">
<input type="submit"<?php
wp_nav_menu_disabled_check($nav_menu_selected_id);
?>
class="button-secondary submit-add-to-menu right" value="<?php
esc_attr_e('Add to Menu');
?>
" name="add-ctp-archive-menu-item" id="submit-cpt-archive" />
<span class="spinner"></span>
</span>
</p>
<?php
}
示例8: wp_nav_menu_cpt_archives_meta_box
function wp_nav_menu_cpt_archives_meta_box()
{
global $nav_menu_selected_id;
/* get custom post types with archive support */
$post_types = get_post_types(array('show_in_nav_menus' => true, 'has_archive' => true), 'object');
/* hydrate the necessary object properties for the walker */
foreach ($post_types as &$post_type) {
$post_type->classes = array();
$post_type->type = $post_type->name;
$post_type->object_id = $post_type->name;
$post_type->title = $post_type->labels->name;
$post_type->object = 'custom';
$post_type->menu_item_parent = 0;
$post_type->url = 0;
$post_type->target = 0;
$post_type->attr_title = 0;
$post_type->xfn = 0;
$post_type->db_id = 0;
}
$walker = new Walker_Nav_Menu_Checklist(array());
?>
<div id="custom" class="posttypediv">
<div id="tabs-panel-custom" class="tabs-panel tabs-panel-active">
<ul id="ctp-archive-checklist" class="categorychecklist form-no-clear">
<?php
echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $post_types), 0, (object) array('walker' => $walker));
?>
</ul>
</div><!-- /.tabs-panel -->
<p class="button-controls">
<span class="add-to-menu">
<input type="submit"<?php
disabled($nav_menu_selected_id, 0);
?>
class="button-secondary right submit-add-to-menu" value="<?php
esc_attr_e('Add to Menu');
?>
" name="add-ctp-archive-menu-item" id="submit-custom" />
<span class="spinner"></span>
</span>
</p>
</div>
<?php
}
示例9: post_type_archive_meta_box
public function post_type_archive_meta_box()
{
$post_types = get_post_types(array('show_in_nav_menus' => true, 'has_archive' => true), 'object');
if ($post_types) {
$items = array();
$loop_index = 999999;
foreach ($post_types as $post_type) {
$item = new stdClass();
$loop_index++;
$item->object_id = $loop_index;
$item->db_id = 0;
$item->object = 'post_type_' . $post_type->query_var;
$item->menu_item_parent = 0;
$item->type = 'custom';
$item->title = $post_type->labels->name;
$item->url = get_post_type_archive_link($post_type->query_var);
$item->target = '';
$item->attr_title = '';
$item->classes = array();
$item->xfn = '';
$items[] = $item;
}
$walker = new Walker_Nav_Menu_Checklist(array());
$s = '<div id="posttype-archive" class="posttypediv">';
$s .= '<div id="tabs-panel-posttype-archive" class="tabs-panel tabs-panel-active">';
$s .= '<ul id="posttype-archive-checklist" class="categorychecklist form-no-clear">';
$s .= walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $items), 0, (object) array('walker' => $walker));
$s .= '</ul>';
$s .= '</div>';
$s .= '</div>';
$s .= '<p class="button-controls">';
$s .= '<span class="add-to-menu">';
$s .= '<input type="submit"' . disabled(1, 0) . ' class="button-secondary submit-add-to-menu right" value="' . __('Add to Menu', $this->args['namespace']) . '" name="add-posttype-archive-menu-item" id="submit-posttype-archive" />';
$s .= '<span class="spinner"></span>';
$s .= '</span>';
$s .= '</p>';
echo $s;
}
}
示例10: wp_get_nav_menu_to_edit
/**
* Returns the menu formatted to edit.
*
* @since 3.0.0
*
* @param int $menu_id Optional. The ID of the menu to format. Default 0.
* @return string|WP_Error $output The menu formatted to edit or error object on failure.
*/
function wp_get_nav_menu_to_edit($menu_id = 0)
{
$menu = wp_get_nav_menu_object($menu_id);
// If the menu exists, get its items.
if (is_nav_menu($menu)) {
$menu_items = wp_get_nav_menu_items($menu->term_id, array('post_status' => 'any'));
$result = '<div id="menu-instructions" class="post-body-plain';
$result .= !empty($menu_items) ? ' menu-instructions-inactive">' : '">';
$result .= '<p>' . __('Add menu items from the column on the left.') . '</p>';
$result .= '</div>';
if (empty($menu_items)) {
return $result . ' <ul class="menu" id="menu-to-edit"> </ul>';
}
/**
* Filter the Walker class used when adding nav menu items.
*
* @since 3.0.0
*
* @param string $class The walker class to use. Default 'Walker_Nav_Menu_Edit'.
* @param int $menu_id ID of the menu being rendered.
*/
$walker_class_name = apply_filters('wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id);
if (class_exists($walker_class_name)) {
$walker = new $walker_class_name();
} else {
return new WP_Error('menu_walker_not_exist', sprintf(__('The Walker class named <strong>%s</strong> does not exist.'), $walker_class_name));
}
$some_pending_menu_items = $some_invalid_menu_items = false;
foreach ((array) $menu_items as $menu_item) {
if (isset($menu_item->post_status) && 'draft' == $menu_item->post_status) {
$some_pending_menu_items = true;
}
if (!empty($menu_item->_invalid)) {
$some_invalid_menu_items = true;
}
}
if ($some_pending_menu_items) {
$result .= '<div class="updated inline"><p>' . __('Click Save Menu to make pending menu items public.') . '</p></div>';
}
if ($some_invalid_menu_items) {
$result .= '<div class="error inline"><p>' . __('There are some invalid menu items. Please check or delete them.') . '</p></div>';
}
$result .= '<ul class="menu" id="menu-to-edit"> ';
$result .= walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker));
$result .= ' </ul> ';
return $result;
} elseif (is_wp_error($menu)) {
return $menu;
}
}
示例11: ajax_add_menu_item
/**
* Ajax handler is triggered when
* something is added to the nav menu
* @ajax
*/
public function ajax_add_menu_item()
{
if (!tf_current_user_can(array('manage_options', 'edit_theme_options'), false)) {
die('-1');
}
check_ajax_referer('add-menu_item', 'menu-settings-column-nonce');
require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
// For performance reasons, we omit some object properties from the checklist.
// The following is a hacky way to restore them when adding non-custom items.
$menu_items_data = array();
if ($this->request->POST('menu-item')) {
foreach ((array) $this->request->POST('menu-item') as $menu_item_data) {
if (!empty($menu_item_data['menu-item-type']) && 'custom' != $menu_item_data['menu-item-type'] && !empty($menu_item_data['menu-item-object-id'])) {
switch ($menu_item_data['menu-item-type']) {
case 'post_type':
$_object = get_post($menu_item_data['menu-item-object-id']);
break;
case 'taxonomy':
$_object = get_term($menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object']);
break;
}
$_menu_items = array_map('wp_setup_nav_menu_item', array($_object));
$_menu_item = array_shift($_menu_items);
// Restore the missing menu item properties
$menu_item_data['menu-item-description'] = $_menu_item->description;
}
$menu_items_data[] = $menu_item_data;
}
}
$item_ids = wp_save_nav_menu_items(0, $menu_items_data);
if (is_wp_error($item_ids)) {
die('-1');
}
foreach ((array) $item_ids as $menu_item_id) {
$menu_obj = get_post($menu_item_id);
if (!empty($menu_obj->ID)) {
$menu_obj = wp_setup_nav_menu_item($menu_obj);
$menu_obj->label = $menu_obj->title;
// don't show "(pending)" in ajax-added items
$menu_items[] = $menu_obj;
}
}
if (!empty($menu_items)) {
$args = array('after' => '', 'before' => '', 'link_after' => '', 'link_before' => '', 'walker' => new TF_ADMIN_MENU_WALKER());
echo walk_nav_menu_tree($menu_items, 0, (object) $args);
}
die;
}
示例12: ajax_add_post_type
/**
*
*/
function ajax_add_post_type()
{
if (!current_user_can('edit_theme_options')) {
die('-1');
}
require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
if (empty($_POST['post_types'])) {
exit;
}
// Create menu items and store IDs in array
$item_ids = array();
foreach ((array) $_POST['post_types'] as $post_type) {
$post_type_obj = get_post_type_object($post_type);
if (!$post_type_obj) {
continue;
}
$menu_item_data = array('menu-item-title' => esc_attr($post_type_obj->labels->name), 'menu-item-type' => 'post_type_archive', 'menu-item-object' => esc_attr($post_type), 'menu-item-url' => get_post_type_archive_link($post_type));
//Collect the items' IDs.
$item_ids[] = wp_update_nav_menu_item(0, 0, $menu_item_data);
}
// If there was an error die here
if (is_wp_error($item_ids)) {
die('-1');
}
// Set up menu items
foreach ((array) $item_ids as $menu_item_id) {
$menu_obj = get_post($menu_item_id);
if (!empty($menu_obj->ID)) {
$menu_obj = wp_setup_nav_menu_item($menu_obj);
$menu_obj->label = $menu_obj->title;
// don't show "(pending)" in ajax-added items
$menu_items[] = $menu_obj;
}
}
// This gets the HTML to returns it to the menu
if (!empty($menu_items)) {
$args = array('after' => '', 'before' => '', 'link_after' => '', 'link_before' => '', 'walker' => new Walker_Nav_Menu_Edit());
echo walk_nav_menu_tree($menu_items, 0, (object) $args);
}
// Finally don't forget to exit
exit;
}
示例13: ajax_add_year
/**
* AJAX Callback to create the menu item and add it to menu
* @return string $HTML built with walk_nav_menu_tree()
* use \Post_Type_Archive_Links::is_allowed() Check request and return choosen post types
*/
public function ajax_add_year()
{
$years = $this->is_allowed();
// Create menu items and store IDs in array
$item_ids = array();
$menu_item_data = array('menu-item-title' => esc_attr($years[0]), 'menu-item-type' => 'cyear_archive', 'menu-item-object' => esc_attr($years[0]), 'menu-item-url' => get_year_link($years[0]));
// Collect the items' IDs.
$item_ids[] = wp_update_nav_menu_item(0, 0, $menu_item_data);
// If there was an error die here
is_wp_error($item_ids) and die('-1');
// Set up menu items
foreach ((array) $item_ids as $menu_item_id) {
$menu_obj = get_post($menu_item_id);
if (!empty($menu_obj->ID)) {
$menu_obj = wp_setup_nav_menu_item($menu_obj);
// don't show "(pending)" in ajax-added items
$menu_obj->label = $menu_obj->title;
$menu_items[] = $menu_obj;
}
}
// Needed to get the Walker up and running
require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
// This gets the HTML to returns it to the menu
if (!empty($menu_items)) {
$args = array('after' => '', 'before' => '', 'link_after' => '', 'link_before' => '', 'walker' => new Walker_Nav_Menu_Edit());
echo walk_nav_menu_tree($menu_items, 0, (object) $args);
}
// Finally don't forget to exit
exit;
}
示例14: ee_cpt_archive_pages
public function ee_cpt_archive_pages()
{
global $nav_menu_selected_id;
$db_fields = false;
$walker = new Walker_Nav_Menu_Checklist($db_fields);
$current_tab = 'event-archives';
/*if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
$current_tab = 'search';
}/**/
$removed_args = array('action', 'customlink-tab', 'edit-menu-item', 'menu-item', 'page-tab', '_wpnonce');
?>
<div id="posttype-extra-nav-menu-pages" class="posttypediv">
<ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs">
<li <?php
echo 'event-archives' == $current_tab ? ' class="tabs"' : '';
?>
>
<a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php
if ($nav_menu_selected_id) {
echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args)));
}
?>
#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
<?php
_e('Event Archive Pages', 'event_espresso');
?>
</a>
</li>
<?php
/* // temporarily removing but leaving skeleton in place in case we ever decide to add more tabs.
<li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>>
<a class="nav-tab-link" data-type="<?php echo esc_attr( $post_type_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#<?php echo $post_type_name; ?>-all">
<?php _e( 'View All' ); ?>
</a>
</li>
<li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>>
<a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-search" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-extra-nav-menu-pages-search">
<?php _e( 'Search'); ?>
</a>
</li> -->
</ul><!-- .posttype-tabs -->
<?php */
?>
<div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php
echo 'event-archives' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive';
?>
">
<ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear">
<?php
$pages = $this->_get_extra_nav_menu_pages_items();
$args['walker'] = $walker;
echo walk_nav_menu_tree(array_map(array($this, '_setup_extra_nav_menu_pages_items'), $pages), 0, (object) $args);
?>
</ul>
</div><!-- /.tabs-panel -->
<p class="button-controls">
<span class="list-controls">
<a href="<?php
echo esc_url(add_query_arg(array('extra-nav-menu-pages-tab' => 'event-archives', 'selectall' => 1), remove_query_arg($removed_args)));
?>
#posttype-extra-nav-menu-pages>" class="select-all"><?php
_e('Select All');
?>
</a>
</span>
<span class="add-to-menu">
<input type="submit"<?php
wp_nav_menu_disabled_check($nav_menu_selected_id);
?>
class="button-secondary submit-add-to-menu right" value="<?php
esc_attr_e(__('Add to Menu'));
?>
" name="add-post-type-menu-item" id="<?php
esc_attr_e('submit-posttype-extra-nav-menu-pages');
?>
" />
<span class="spinner"></span>
</span>
</p>
</div><!-- /.posttypediv -->
<?php
}
示例15: bp_nav_menu
/**
* Display a navigation menu.
*
* @since 1.7.0
*
* @param string|array $args {
* An array of optional arguments.
*
* @type string $after Text after the link text. Default: ''.
* @type string $before Text before the link text. Default: ''.
* @type string $container The name of the element to wrap the navigation
* with. 'div' or 'nav'. Default: 'div'.
* @type string $container_class The class that is applied to the container.
* Default: 'menu-bp-container'.
* @type string $container_id The ID that is applied to the container.
* Default: ''.
* @type int $depth How many levels of the hierarchy are to be included.
* 0 means all. Default: 0.
* @type bool $echo True to echo the menu, false to return it.
* Default: true.
* @type bool $fallback_cb If the menu doesn't exist, should a callback
* function be fired? Default: false (no fallback).
* @type string $items_wrap How the list items should be wrapped. Should be
* in the form of a printf()-friendly string, using numbered
* placeholders. Default: '<ul id="%1$s" class="%2$s">%3$s</ul>'.
* @type string $link_after Text after the link. Default: ''.
* @type string $link_before Text before the link. Default: ''.
* @type string $menu_class CSS class to use for the <ul> element which
* forms the menu. Default: 'menu'.
* @type string $menu_id The ID that is applied to the <ul> element which
* forms the menu. Default: 'menu-bp', incremented.
* @type string $walker Allows a custom walker class to be specified.
* Default: 'BP_Walker_Nav_Menu'.
* }
* @return string|null If $echo is false, returns a string containing the nav
* menu markup.
*/
function bp_nav_menu($args = array())
{
static $menu_id_slugs = array();
$defaults = array('after' => '', 'before' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'depth' => 0, 'echo' => true, 'fallback_cb' => false, 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>', 'link_after' => '', 'link_before' => '', 'menu_class' => 'menu', 'menu_id' => '', 'walker' => '');
$args = wp_parse_args($args, $defaults);
/**
* Filters the parsed bp_nav_menu arguments.
*
* @since 1.7.0
*
* @param array $args Array of parsed arguments.
*/
$args = apply_filters('bp_nav_menu_args', $args);
$args = (object) $args;
$items = $nav_menu = '';
$show_container = false;
// Create custom walker if one wasn't set.
if (empty($args->walker)) {
$args->walker = new BP_Walker_Nav_Menu();
}
// Sanitise values for class and ID.
$args->container_class = sanitize_html_class($args->container_class);
$args->container_id = sanitize_html_class($args->container_id);
// Whether to wrap the ul, and what to wrap it with.
if ($args->container) {
/**
* Filters the allowed tags for the wp_nav_menu_container.
*
* @since 1.7.0
*
* @param array $value Array of allowed tags. Default 'div' and 'nav'.
*/
$allowed_tags = apply_filters('wp_nav_menu_container_allowedtags', array('div', 'nav'));
if (in_array($args->container, $allowed_tags)) {
$show_container = true;
$class = $args->container_class ? ' class="' . esc_attr($args->container_class) . '"' : ' class="menu-bp-container"';
$id = $args->container_id ? ' id="' . esc_attr($args->container_id) . '"' : '';
$nav_menu .= '<' . $args->container . $id . $class . '>';
}
}
/**
* Filters the BuddyPress menu objects.
*
* @since 1.7.0
*
* @param array $value Array of nav menu objects.
* @param array $args Array of arguments for the menu.
*/
$menu_items = apply_filters('bp_nav_menu_objects', bp_get_nav_menu_items(), $args);
$items = walk_nav_menu_tree($menu_items, $args->depth, $args);
unset($menu_items);
// Set the ID that is applied to the ul element which forms the menu.
if (!empty($args->menu_id)) {
$wrap_id = $args->menu_id;
} else {
$wrap_id = 'menu-bp';
// If a specific ID wasn't requested, and there are multiple menus on the same screen, make sure the autogenerated ID is unique.
while (in_array($wrap_id, $menu_id_slugs)) {
if (preg_match('#-(\\d+)$#', $wrap_id, $matches)) {
$wrap_id = preg_replace('#-(\\d+)$#', '-' . ++$matches[1], $wrap_id);
} else {
$wrap_id = $wrap_id . '-1';
}
//.........这里部分代码省略.........