2010-02-24 09:06:36 +01:00
|
|
|
<?php
|
2010-03-31 09:54:09 +02:00
|
|
|
/**
|
2016-06-06 17:18:31 +02:00
|
|
|
* Nav Menu API: Template functions
|
2010-03-31 09:54:09 +02:00
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Nav_Menus
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
|
|
|
|
2016-08-31 18:31:29 +02:00
|
|
|
/** Walker_Nav_Menu class */
|
|
|
|
require_once ABSPATH . WPINC . '/class-walker-nav-menu.php';
|
|
|
|
|
2010-02-24 09:06:36 +01:00
|
|
|
/**
|
2010-02-28 21:00:49 +01:00
|
|
|
* Displays a navigation menu.
|
2010-02-24 09:06:36 +01:00
|
|
|
*
|
|
|
|
* @since 3.0.0
|
2016-09-08 07:32:03 +02:00
|
|
|
* @since 4.7.0 Added the `item_spacing` argument.
|
2010-02-24 09:06:36 +01:00
|
|
|
*
|
2014-02-21 19:32:15 +01:00
|
|
|
* @param array $args {
|
|
|
|
* Optional. Array of nav menu arguments.
|
|
|
|
*
|
2017-06-30 06:49:40 +02:00
|
|
|
* @type int|string|WP_Term $menu Desired menu. Accepts a menu ID, slug, name, or object. Default empty.
|
2016-08-26 18:51:28 +02:00
|
|
|
* @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 is the menu slug, incremented.
|
|
|
|
* @type string $container Whether to wrap the ul, and what to wrap it with. Default 'div'.
|
|
|
|
* @type string $container_class Class that is applied to the container. Default 'menu-{menu slug}-container'.
|
|
|
|
* @type string $container_id The ID that is applied to the container. Default empty.
|
2020-02-09 17:55:09 +01:00
|
|
|
* @type callable|bool $fallback_cb If the menu doesn't exist, a callback function will fire.
|
2016-08-26 18:51:28 +02:00
|
|
|
* Default is 'wp_page_menu'. Set to false for no fallback.
|
|
|
|
* @type string $before Text before the link markup. Default empty.
|
|
|
|
* @type string $after Text after the link markup. Default empty.
|
|
|
|
* @type string $link_before Text before the link text. Default empty.
|
|
|
|
* @type string $link_after Text after the link text. Default empty.
|
|
|
|
* @type bool $echo Whether to echo the menu or return it. Default true.
|
|
|
|
* @type int $depth How many levels of the hierarchy are to be included. 0 means all. Default 0.
|
|
|
|
* @type object $walker Instance of a custom walker class. Default empty.
|
|
|
|
* @type string $theme_location Theme location to be used. Must be registered with register_nav_menu()
|
|
|
|
* in order to be selectable by the user.
|
|
|
|
* @type string $items_wrap How the list items should be wrapped. Default is a ul with an id and class.
|
|
|
|
* Uses printf() format with numbered placeholders.
|
2016-09-08 07:32:03 +02:00
|
|
|
* @type string $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' or 'discard'. Default 'preserve'.
|
2014-02-21 19:32:15 +01:00
|
|
|
* }
|
2020-01-21 21:13:05 +01:00
|
|
|
* @return void|string|false Void if 'echo' argument is true, menu output if 'echo' is false.
|
|
|
|
* False if there are no items or no menu was found.
|
2010-02-24 09:06:36 +01:00
|
|
|
*/
|
|
|
|
function wp_nav_menu( $args = array() ) {
|
2010-06-02 19:04:07 +02:00
|
|
|
static $menu_id_slugs = array();
|
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
$defaults = array(
|
|
|
|
'menu' => '',
|
|
|
|
'container' => 'div',
|
|
|
|
'container_class' => '',
|
|
|
|
'container_id' => '',
|
|
|
|
'menu_class' => 'menu',
|
|
|
|
'menu_id' => '',
|
|
|
|
'echo' => true,
|
|
|
|
'fallback_cb' => 'wp_page_menu',
|
|
|
|
'before' => '',
|
|
|
|
'after' => '',
|
|
|
|
'link_before' => '',
|
|
|
|
'link_after' => '',
|
|
|
|
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
|
|
|
|
'item_spacing' => 'preserve',
|
|
|
|
'depth' => 0,
|
|
|
|
'walker' => '',
|
|
|
|
'theme_location' => '',
|
|
|
|
);
|
2010-03-17 17:27:25 +01:00
|
|
|
|
2010-02-28 00:06:56 +01:00
|
|
|
$args = wp_parse_args( $args, $defaults );
|
2016-09-06 11:06:31 +02:00
|
|
|
|
|
|
|
if ( ! in_array( $args['item_spacing'], array( 'preserve', 'discard' ), true ) ) {
|
2020-01-29 01:45:18 +01:00
|
|
|
// Invalid value, fall back to default.
|
2016-09-06 11:06:31 +02:00
|
|
|
$args['item_spacing'] = $defaults['item_spacing'];
|
|
|
|
}
|
|
|
|
|
2013-09-12 20:48:09 +02:00
|
|
|
/**
|
2016-05-22 20:28:27 +02:00
|
|
|
* Filters the arguments used to display a navigation menu.
|
2013-09-12 20:48:09 +02:00
|
|
|
*
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2014-02-20 06:08:13 +01:00
|
|
|
* @see wp_nav_menu()
|
|
|
|
*
|
|
|
|
* @param array $args Array of wp_nav_menu() arguments.
|
2013-09-12 20:48:09 +02:00
|
|
|
*/
|
2010-02-28 21:00:49 +01:00
|
|
|
$args = apply_filters( 'wp_nav_menu_args', $args );
|
2010-02-24 09:45:26 +01:00
|
|
|
$args = (object) $args;
|
2010-03-01 13:53:51 +01:00
|
|
|
|
2014-03-03 21:43:15 +01:00
|
|
|
/**
|
2016-05-22 20:28:27 +02:00
|
|
|
* Filters whether to short-circuit the wp_nav_menu() output.
|
2014-03-03 21:43:15 +01:00
|
|
|
*
|
2020-06-03 12:02:13 +02:00
|
|
|
* Passing a non-null value to the filter will short-circuit
|
2014-03-03 21:43:15 +01:00
|
|
|
* wp_nav_menu(), echoing that value if $args->echo is true,
|
|
|
|
* returning that value otherwise.
|
|
|
|
*
|
|
|
|
* @since 3.9.0
|
|
|
|
*
|
|
|
|
* @see wp_nav_menu()
|
|
|
|
*
|
|
|
|
* @param string|null $output Nav menu output to short-circuit with. Default null.
|
2016-09-07 18:15:30 +02:00
|
|
|
* @param stdClass $args An object containing wp_nav_menu() arguments.
|
2014-03-03 21:43:15 +01:00
|
|
|
*/
|
|
|
|
$nav_menu = apply_filters( 'pre_wp_nav_menu', null, $args );
|
|
|
|
|
|
|
|
if ( null !== $nav_menu ) {
|
|
|
|
if ( $args->echo ) {
|
|
|
|
echo $nav_menu;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $nav_menu;
|
|
|
|
}
|
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// Get the nav menu based on the requested menu.
|
2010-02-28 21:00:49 +01:00
|
|
|
$menu = wp_get_nav_menu_object( $args->menu );
|
2010-03-17 17:27:25 +01:00
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// Get the nav menu based on the theme_location.
|
2019-07-03 01:42:58 +02:00
|
|
|
$locations = get_nav_menu_locations();
|
|
|
|
if ( ! $menu && $args->theme_location && $locations && isset( $locations[ $args->theme_location ] ) ) {
|
2010-05-14 08:20:30 +02:00
|
|
|
$menu = wp_get_nav_menu_object( $locations[ $args->theme_location ] );
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2010-05-14 00:14:54 +02:00
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// Get the first menu that has items if we still can't find a menu.
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! $menu && ! $args->theme_location ) {
|
2014-09-29 17:45:16 +02:00
|
|
|
$menus = wp_get_nav_menus();
|
2010-02-24 09:45:26 +01:00
|
|
|
foreach ( $menus as $menu_maybe ) {
|
2019-07-03 01:42:58 +02:00
|
|
|
$menu_items = wp_get_nav_menu_items( $menu_maybe->term_id, array( 'update_post_term_cache' => false ) );
|
|
|
|
if ( $menu_items ) {
|
2010-02-24 09:45:26 +01:00
|
|
|
$menu = $menu_maybe;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-05-03 22:26:11 +02:00
|
|
|
|
2015-06-16 22:33:25 +02:00
|
|
|
if ( empty( $args->menu ) ) {
|
|
|
|
$args->menu = $menu;
|
|
|
|
}
|
|
|
|
|
2010-04-27 03:05:58 +02:00
|
|
|
// If the menu exists, get its items.
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( $menu && ! is_wp_error( $menu ) && ! isset( $menu_items ) ) {
|
2012-10-15 16:17:50 +02:00
|
|
|
$menu_items = wp_get_nav_menu_items( $menu->term_id, array( 'update_post_term_cache' => false ) );
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2010-03-26 20:36:49 +01:00
|
|
|
|
2012-09-16 19:07:56 +02:00
|
|
|
/*
|
|
|
|
* If no menu was found:
|
2013-07-10 07:14:43 +02:00
|
|
|
* - Fall back (if one was specified), or bail.
|
2012-09-16 19:07:56 +02:00
|
|
|
*
|
|
|
|
* If no menu items were found:
|
2013-07-10 07:14:43 +02:00
|
|
|
* - Fall back, but only if no theme location was specified.
|
2012-09-16 19:07:56 +02:00
|
|
|
* - Otherwise, bail.
|
|
|
|
*/
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ( ! $menu || is_wp_error( $menu ) || ( isset( $menu_items ) && empty( $menu_items ) && ! $args->theme_location ) )
|
|
|
|
&& isset( $args->fallback_cb ) && $args->fallback_cb && is_callable( $args->fallback_cb ) ) {
|
2010-04-07 17:25:48 +02:00
|
|
|
return call_user_func( $args->fallback_cb, (array) $args );
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2010-05-03 22:26:11 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! $menu || is_wp_error( $menu ) ) {
|
2010-05-04 00:03:52 +02:00
|
|
|
return false;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2010-05-04 00:03:52 +02:00
|
|
|
|
2019-07-03 01:42:58 +02:00
|
|
|
$nav_menu = '';
|
|
|
|
$items = '';
|
2010-04-07 17:25:48 +02:00
|
|
|
|
2010-06-02 19:04:07 +02:00
|
|
|
$show_container = false;
|
|
|
|
if ( $args->container ) {
|
2013-09-12 20:48:09 +02:00
|
|
|
/**
|
2016-05-22 20:28:27 +02:00
|
|
|
* Filters the list of HTML tags that are valid for use as menu containers.
|
2013-09-12 20:48:09 +02:00
|
|
|
*
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2019-10-26 23:09:04 +02:00
|
|
|
* @param string[] $tags The acceptable HTML tags for use as menu containers.
|
|
|
|
* Default is array containing 'div' and 'nav'.
|
2013-09-12 20:48:09 +02:00
|
|
|
*/
|
2010-06-02 19:04:07 +02:00
|
|
|
$allowed_tags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) );
|
2020-04-05 05:02:11 +02:00
|
|
|
|
|
|
|
if ( is_string( $args->container ) && in_array( $args->container, $allowed_tags, true ) ) {
|
2010-06-02 19:04:07 +02:00
|
|
|
$show_container = true;
|
2017-12-01 00:11:00 +01:00
|
|
|
$class = $args->container_class ? ' class="' . esc_attr( $args->container_class ) . '"' : ' class="menu-' . $menu->slug . '-container"';
|
|
|
|
$id = $args->container_id ? ' id="' . esc_attr( $args->container_id ) . '"' : '';
|
|
|
|
$nav_menu .= '<' . $args->container . $id . $class . '>';
|
2010-06-02 19:04:07 +02:00
|
|
|
}
|
2010-04-07 17:25:48 +02:00
|
|
|
}
|
2010-03-26 20:36:49 +01:00
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// Set up the $menu_item variables.
|
2010-05-31 16:54:50 +02:00
|
|
|
_wp_menu_item_classes_by_context( $menu_items );
|
2010-05-25 15:30:10 +02:00
|
|
|
|
2019-07-03 01:42:58 +02:00
|
|
|
$sorted_menu_items = array();
|
|
|
|
$menu_items_with_children = array();
|
2013-09-24 18:01:09 +02:00
|
|
|
foreach ( (array) $menu_items as $menu_item ) {
|
|
|
|
$sorted_menu_items[ $menu_item->menu_order ] = $menu_item;
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( $menu_item->menu_item_parent ) {
|
2013-09-24 18:01:09 +02:00
|
|
|
$menu_items_with_children[ $menu_item->menu_item_parent ] = true;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2013-09-24 18:01:09 +02:00
|
|
|
}
|
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// Add the menu-item-has-children class where applicable.
|
2013-09-24 18:01:09 +02:00
|
|
|
if ( $menu_items_with_children ) {
|
|
|
|
foreach ( $sorted_menu_items as &$menu_item ) {
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( isset( $menu_items_with_children[ $menu_item->ID ] ) ) {
|
2013-09-24 18:01:09 +02:00
|
|
|
$menu_item->classes[] = 'menu-item-has-children';
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2013-09-24 18:01:09 +02:00
|
|
|
}
|
|
|
|
}
|
2010-05-26 04:42:15 +02:00
|
|
|
|
2013-09-24 18:01:09 +02:00
|
|
|
unset( $menu_items, $menu_item );
|
2010-10-19 09:48:22 +02:00
|
|
|
|
2013-09-12 20:48:09 +02:00
|
|
|
/**
|
2016-05-22 20:28:27 +02:00
|
|
|
* Filters the sorted list of menu item objects before generating the menu's HTML.
|
2013-09-12 20:48:09 +02:00
|
|
|
*
|
|
|
|
* @since 3.1.0
|
|
|
|
*
|
2016-09-07 18:15:30 +02:00
|
|
|
* @param array $sorted_menu_items The menu items, sorted by each menu item's menu order.
|
|
|
|
* @param stdClass $args An object containing wp_nav_menu() arguments.
|
2013-09-12 20:48:09 +02:00
|
|
|
*/
|
2010-08-27 18:13:39 +02:00
|
|
|
$sorted_menu_items = apply_filters( 'wp_nav_menu_objects', $sorted_menu_items, $args );
|
2010-03-26 20:36:49 +01:00
|
|
|
|
2010-04-27 03:05:58 +02:00
|
|
|
$items .= walk_nav_menu_tree( $sorted_menu_items, $args->depth, $args );
|
2017-12-01 00:11:00 +01:00
|
|
|
unset( $sorted_menu_items );
|
2010-03-26 20:36:49 +01:00
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// Attributes.
|
2010-06-02 19:04:07 +02:00
|
|
|
if ( ! empty( $args->menu_id ) ) {
|
2010-11-21 14:37:09 +01:00
|
|
|
$wrap_id = $args->menu_id;
|
2010-06-02 19:04:07 +02:00
|
|
|
} else {
|
2010-11-21 14:37:09 +01:00
|
|
|
$wrap_id = 'menu-' . $menu->slug;
|
2020-04-05 05:02:11 +02:00
|
|
|
|
|
|
|
while ( in_array( $wrap_id, $menu_id_slugs, true ) ) {
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( preg_match( '#-(\d+)$#', $wrap_id, $matches ) ) {
|
|
|
|
$wrap_id = preg_replace( '#-(\d+)$#', '-' . ++$matches[1], $wrap_id );
|
|
|
|
} else {
|
2010-11-21 14:37:09 +01:00
|
|
|
$wrap_id = $wrap_id . '-1';
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2010-06-02 19:04:07 +02:00
|
|
|
}
|
2010-05-28 18:32:57 +02:00
|
|
|
}
|
2010-11-21 14:37:09 +01:00
|
|
|
$menu_id_slugs[] = $wrap_id;
|
|
|
|
|
2010-11-21 14:32:02 +01:00
|
|
|
$wrap_class = $args->menu_class ? $args->menu_class : '';
|
2010-03-26 20:36:49 +01:00
|
|
|
|
2013-09-12 20:48:09 +02:00
|
|
|
/**
|
2016-05-22 20:28:27 +02:00
|
|
|
* Filters the HTML list content for navigation menus.
|
2013-09-12 20:48:09 +02:00
|
|
|
*
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2014-02-20 06:08:13 +01:00
|
|
|
* @see wp_nav_menu()
|
|
|
|
*
|
2016-09-07 18:15:30 +02:00
|
|
|
* @param string $items The HTML list content for the menu items.
|
|
|
|
* @param stdClass $args An object containing wp_nav_menu() arguments.
|
2013-09-12 20:48:09 +02:00
|
|
|
*/
|
2010-05-13 05:50:26 +02:00
|
|
|
$items = apply_filters( 'wp_nav_menu_items', $items, $args );
|
2013-09-12 20:48:09 +02:00
|
|
|
/**
|
2016-05-22 20:28:27 +02:00
|
|
|
* Filters the HTML list content for a specific navigation menu.
|
2013-09-12 20:48:09 +02:00
|
|
|
*
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2014-02-20 06:08:13 +01:00
|
|
|
* @see wp_nav_menu()
|
|
|
|
*
|
2016-09-07 18:15:30 +02:00
|
|
|
* @param string $items The HTML list content for the menu items.
|
|
|
|
* @param stdClass $args An object containing wp_nav_menu() arguments.
|
2013-09-12 20:48:09 +02:00
|
|
|
*/
|
2010-05-13 05:50:26 +02:00
|
|
|
$items = apply_filters( "wp_nav_menu_{$menu->slug}_items", $items, $args );
|
2010-11-21 14:37:09 +01:00
|
|
|
|
2013-07-10 07:14:43 +02:00
|
|
|
// Don't print any markup if there are no items at this point.
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( empty( $items ) ) {
|
2013-07-10 07:14:43 +02:00
|
|
|
return false;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2013-07-10 07:14:43 +02:00
|
|
|
|
2010-11-21 14:37:09 +01:00
|
|
|
$nav_menu .= sprintf( $args->items_wrap, esc_attr( $wrap_id ), esc_attr( $wrap_class ), $items );
|
|
|
|
unset( $items );
|
2010-03-26 20:36:49 +01:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( $show_container ) {
|
2010-06-02 19:04:07 +02:00
|
|
|
$nav_menu .= '</' . $args->container . '>';
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2010-04-07 17:25:48 +02:00
|
|
|
|
2013-09-12 20:48:09 +02:00
|
|
|
/**
|
2016-05-22 20:28:27 +02:00
|
|
|
* Filters the HTML content for navigation menus.
|
2013-09-12 20:48:09 +02:00
|
|
|
*
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2014-02-20 06:08:13 +01:00
|
|
|
* @see wp_nav_menu()
|
|
|
|
*
|
2016-09-07 18:15:30 +02:00
|
|
|
* @param string $nav_menu The HTML content for the navigation menu.
|
|
|
|
* @param stdClass $args An object containing wp_nav_menu() arguments.
|
2013-09-12 20:48:09 +02:00
|
|
|
*/
|
2010-04-07 17:25:48 +02:00
|
|
|
$nav_menu = apply_filters( 'wp_nav_menu', $nav_menu, $args );
|
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( $args->echo ) {
|
2010-04-07 17:25:48 +02:00
|
|
|
echo $nav_menu;
|
2017-12-01 00:11:00 +01:00
|
|
|
} else {
|
2010-04-07 17:25:48 +02:00
|
|
|
return $nav_menu;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2010-02-24 09:06:36 +01:00
|
|
|
}
|
|
|
|
|
2010-05-25 15:30:10 +02:00
|
|
|
/**
|
2010-05-31 16:54:50 +02:00
|
|
|
* Add the class property classes for the current context, if applicable.
|
2010-05-25 15:30:10 +02:00
|
|
|
*
|
|
|
|
* @access private
|
2013-12-24 19:57:12 +01:00
|
|
|
* @since 3.0.0
|
2010-05-25 15:30:10 +02:00
|
|
|
*
|
2019-08-04 03:59:56 +02:00
|
|
|
* @global WP_Query $wp_query WordPress Query object.
|
2019-08-04 03:19:56 +02:00
|
|
|
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
|
2015-05-27 00:10:25 +02:00
|
|
|
*
|
2010-05-25 15:30:10 +02:00
|
|
|
* @param array $menu_items The current menu item objects to which to add the class property information.
|
|
|
|
*/
|
2010-05-26 18:25:29 +02:00
|
|
|
function _wp_menu_item_classes_by_context( &$menu_items ) {
|
2013-01-21 15:44:30 +01:00
|
|
|
global $wp_query, $wp_rewrite;
|
2010-05-25 15:30:10 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
$queried_object = $wp_query->get_queried_object();
|
2010-05-25 15:30:10 +02:00
|
|
|
$queried_object_id = (int) $wp_query->queried_object_id;
|
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
$active_object = '';
|
|
|
|
$active_ancestor_item_ids = array();
|
|
|
|
$active_parent_item_ids = array();
|
|
|
|
$active_parent_object_ids = array();
|
2010-06-11 18:00:29 +02:00
|
|
|
$possible_taxonomy_ancestors = array();
|
2017-12-01 00:11:00 +01:00
|
|
|
$possible_object_parents = array();
|
|
|
|
$home_page_id = (int) get_option( 'page_for_posts' );
|
2010-05-26 04:42:15 +02:00
|
|
|
|
2010-05-25 15:30:10 +02:00
|
|
|
if ( $wp_query->is_singular && ! empty( $queried_object->post_type ) && ! is_post_type_hierarchical( $queried_object->post_type ) ) {
|
|
|
|
foreach ( (array) get_object_taxonomies( $queried_object->post_type ) as $taxonomy ) {
|
|
|
|
if ( is_taxonomy_hierarchical( $taxonomy ) ) {
|
2010-06-11 18:00:29 +02:00
|
|
|
$term_hierarchy = _get_term_hierarchy( $taxonomy );
|
2017-12-01 00:11:00 +01:00
|
|
|
$terms = wp_get_object_terms( $queried_object_id, $taxonomy, array( 'fields' => 'ids' ) );
|
2010-06-11 18:00:29 +02:00
|
|
|
if ( is_array( $terms ) ) {
|
2010-05-25 15:30:10 +02:00
|
|
|
$possible_object_parents = array_merge( $possible_object_parents, $terms );
|
2017-12-01 00:11:00 +01:00
|
|
|
$term_to_ancestor = array();
|
2010-06-11 18:00:29 +02:00
|
|
|
foreach ( (array) $term_hierarchy as $anc => $descs ) {
|
2017-12-01 00:11:00 +01:00
|
|
|
foreach ( (array) $descs as $desc ) {
|
2010-06-11 18:00:29 +02:00
|
|
|
$term_to_ancestor[ $desc ] = $anc;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2010-06-11 18:00:29 +02:00
|
|
|
}
|
2010-06-11 22:19:35 +02:00
|
|
|
|
2010-06-11 18:00:29 +02:00
|
|
|
foreach ( $terms as $desc ) {
|
|
|
|
do {
|
|
|
|
$possible_taxonomy_ancestors[ $taxonomy ][] = $desc;
|
|
|
|
if ( isset( $term_to_ancestor[ $desc ] ) ) {
|
|
|
|
$_desc = $term_to_ancestor[ $desc ];
|
|
|
|
unset( $term_to_ancestor[ $desc ] );
|
|
|
|
$desc = $_desc;
|
|
|
|
} else {
|
|
|
|
$desc = 0;
|
|
|
|
}
|
|
|
|
} while ( ! empty( $desc ) );
|
|
|
|
}
|
|
|
|
}
|
2010-05-25 15:30:10 +02:00
|
|
|
}
|
|
|
|
}
|
2010-06-11 18:00:29 +02:00
|
|
|
} elseif ( ! empty( $queried_object->taxonomy ) && is_taxonomy_hierarchical( $queried_object->taxonomy ) ) {
|
2017-12-01 00:11:00 +01:00
|
|
|
$term_hierarchy = _get_term_hierarchy( $queried_object->taxonomy );
|
2010-06-11 18:00:29 +02:00
|
|
|
$term_to_ancestor = array();
|
|
|
|
foreach ( (array) $term_hierarchy as $anc => $descs ) {
|
2017-12-01 00:11:00 +01:00
|
|
|
foreach ( (array) $descs as $desc ) {
|
2010-06-11 18:00:29 +02:00
|
|
|
$term_to_ancestor[ $desc ] = $anc;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2010-06-11 18:00:29 +02:00
|
|
|
}
|
|
|
|
$desc = $queried_object->term_id;
|
|
|
|
do {
|
|
|
|
$possible_taxonomy_ancestors[ $queried_object->taxonomy ][] = $desc;
|
|
|
|
if ( isset( $term_to_ancestor[ $desc ] ) ) {
|
|
|
|
$_desc = $term_to_ancestor[ $desc ];
|
|
|
|
unset( $term_to_ancestor[ $desc ] );
|
|
|
|
$desc = $_desc;
|
|
|
|
} else {
|
|
|
|
$desc = 0;
|
|
|
|
}
|
|
|
|
} while ( ! empty( $desc ) );
|
2010-05-25 15:30:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$possible_object_parents = array_filter( $possible_object_parents );
|
|
|
|
|
2019-03-21 20:48:50 +01:00
|
|
|
$front_page_url = home_url();
|
|
|
|
$front_page_id = (int) get_option( 'page_on_front' );
|
|
|
|
$privacy_policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' );
|
2010-12-06 04:54:57 +01:00
|
|
|
|
2010-05-25 20:54:42 +02:00
|
|
|
foreach ( (array) $menu_items as $key => $menu_item ) {
|
2010-10-21 21:55:28 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
$menu_items[ $key ]->current = false;
|
2010-10-21 21:55:28 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
$classes = (array) $menu_item->classes;
|
2010-06-02 15:48:26 +02:00
|
|
|
$classes[] = 'menu-item';
|
|
|
|
$classes[] = 'menu-item-type-' . $menu_item->type;
|
2010-10-30 00:49:42 +02:00
|
|
|
$classes[] = 'menu-item-object-' . $menu_item->object;
|
2010-06-02 15:48:26 +02:00
|
|
|
|
2016-10-26 03:58:30 +02:00
|
|
|
// This menu item is set as the 'Front Page'.
|
|
|
|
if ( 'post_type' === $menu_item->type && $front_page_id === (int) $menu_item->object_id ) {
|
|
|
|
$classes[] = 'menu-item-home';
|
|
|
|
}
|
|
|
|
|
2019-03-21 20:48:50 +01:00
|
|
|
// This menu item is set as the 'Privacy Policy Page'.
|
|
|
|
if ( 'post_type' === $menu_item->type && $privacy_policy_page_id === (int) $menu_item->object_id ) {
|
|
|
|
$classes[] = 'menu-item-privacy-policy';
|
|
|
|
}
|
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// If the menu item corresponds to a taxonomy term for the currently queried non-hierarchical post object.
|
2020-05-16 20:42:12 +02:00
|
|
|
if ( $wp_query->is_singular && 'taxonomy' === $menu_item->type
|
2020-04-09 17:43:10 +02:00
|
|
|
&& in_array( (int) $menu_item->object_id, $possible_object_parents, true )
|
|
|
|
) {
|
2010-05-25 15:30:10 +02:00
|
|
|
$active_parent_object_ids[] = (int) $menu_item->object_id;
|
2017-12-01 00:11:00 +01:00
|
|
|
$active_parent_item_ids[] = (int) $menu_item->db_id;
|
|
|
|
$active_object = $queried_object->post_type;
|
2010-05-26 04:42:15 +02:00
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// If the menu item corresponds to the currently queried post or taxonomy object.
|
2010-05-25 15:30:10 +02:00
|
|
|
} elseif (
|
2020-04-05 05:02:11 +02:00
|
|
|
$menu_item->object_id == $queried_object_id
|
|
|
|
&& (
|
2020-05-16 20:42:12 +02:00
|
|
|
( ! empty( $home_page_id ) && 'post_type' === $menu_item->type
|
|
|
|
&& $wp_query->is_home && $home_page_id == $menu_item->object_id )
|
|
|
|
|| ( 'post_type' === $menu_item->type && $wp_query->is_singular )
|
|
|
|
|| ( 'taxonomy' === $menu_item->type
|
2020-04-09 17:43:10 +02:00
|
|
|
&& ( $wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax )
|
|
|
|
&& $queried_object->taxonomy == $menu_item->object )
|
2010-05-26 04:42:15 +02:00
|
|
|
)
|
2010-05-25 15:30:10 +02:00
|
|
|
) {
|
2017-12-01 00:11:00 +01:00
|
|
|
$classes[] = 'current-menu-item';
|
|
|
|
$menu_items[ $key ]->current = true;
|
|
|
|
$_anc_id = (int) $menu_item->db_id;
|
2010-06-14 23:19:55 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
while (
|
2020-04-05 05:02:11 +02:00
|
|
|
( $_anc_id = (int) get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) )
|
|
|
|
&& ! in_array( $_anc_id, $active_ancestor_item_ids, true )
|
2010-06-14 23:19:55 +02:00
|
|
|
) {
|
|
|
|
$active_ancestor_item_ids[] = $_anc_id;
|
|
|
|
}
|
|
|
|
|
2020-05-16 20:42:12 +02:00
|
|
|
if ( 'post_type' === $menu_item->type && 'page' === $menu_item->object ) {
|
2020-01-29 01:45:18 +01:00
|
|
|
// Back compat classes for pages to match wp_page_menu().
|
2010-06-02 15:48:26 +02:00
|
|
|
$classes[] = 'page_item';
|
|
|
|
$classes[] = 'page-item-' . $menu_item->object_id;
|
|
|
|
$classes[] = 'current_page_item';
|
|
|
|
}
|
2016-10-24 02:32:32 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
$active_parent_item_ids[] = (int) $menu_item->menu_item_parent;
|
2010-05-25 15:30:10 +02:00
|
|
|
$active_parent_object_ids[] = (int) $menu_item->post_parent;
|
2017-12-01 00:11:00 +01:00
|
|
|
$active_object = $menu_item->object;
|
2010-05-25 15:30:10 +02:00
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// If the menu item corresponds to the currently queried post type archive.
|
2015-10-24 19:46:25 +02:00
|
|
|
} elseif (
|
2020-05-16 20:42:12 +02:00
|
|
|
'post_type_archive' === $menu_item->type
|
2020-04-05 05:02:11 +02:00
|
|
|
&& is_post_type_archive( array( $menu_item->object ) )
|
2015-10-24 19:46:25 +02:00
|
|
|
) {
|
2017-12-01 00:11:00 +01:00
|
|
|
$classes[] = 'current-menu-item';
|
|
|
|
$menu_items[ $key ]->current = true;
|
|
|
|
$_anc_id = (int) $menu_item->db_id;
|
2017-07-05 23:31:44 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
while (
|
2020-04-05 05:02:11 +02:00
|
|
|
( $_anc_id = (int) get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) )
|
|
|
|
&& ! in_array( $_anc_id, $active_ancestor_item_ids, true )
|
2017-07-05 23:31:44 +02:00
|
|
|
) {
|
|
|
|
$active_ancestor_item_ids[] = $_anc_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
$active_parent_item_ids[] = (int) $menu_item->menu_item_parent;
|
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// If the menu item corresponds to the currently requested URL.
|
2020-05-16 20:42:12 +02:00
|
|
|
} elseif ( 'custom' === $menu_item->object && isset( $_SERVER['HTTP_HOST'] ) ) {
|
2011-09-22 04:25:57 +02:00
|
|
|
$_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] );
|
2017-05-12 22:35:43 +02:00
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// If it's the customize page then it will strip the query var off the URL before entering the comparison block.
|
2017-05-12 22:35:43 +02:00
|
|
|
if ( is_customize_preview() ) {
|
|
|
|
$_root_relative_current = strtok( untrailingslashit( $_SERVER['REQUEST_URI'] ), '?' );
|
|
|
|
}
|
2018-02-24 14:44:31 +01:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_root_relative_current );
|
|
|
|
$raw_item_url = strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url;
|
|
|
|
$item_url = set_url_scheme( untrailingslashit( $raw_item_url ) );
|
2013-01-18 14:44:22 +01:00
|
|
|
$_indexless_current = untrailingslashit( preg_replace( '/' . preg_quote( $wp_rewrite->index, '/' ) . '$/', '', $current_url ) );
|
2010-10-21 21:55:28 +02:00
|
|
|
|
2018-02-24 14:44:31 +01:00
|
|
|
$matches = array(
|
2018-08-17 03:51:36 +02:00
|
|
|
$current_url,
|
|
|
|
urldecode( $current_url ),
|
|
|
|
$_indexless_current,
|
|
|
|
urldecode( $_indexless_current ),
|
|
|
|
$_root_relative_current,
|
|
|
|
urldecode( $_root_relative_current ),
|
2018-02-24 14:44:31 +01:00
|
|
|
);
|
|
|
|
|
2020-04-05 05:02:11 +02:00
|
|
|
if ( $raw_item_url && in_array( $item_url, $matches, true ) ) {
|
2017-12-01 00:11:00 +01:00
|
|
|
$classes[] = 'current-menu-item';
|
|
|
|
$menu_items[ $key ]->current = true;
|
|
|
|
$_anc_id = (int) $menu_item->db_id;
|
2010-06-14 23:19:55 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
while (
|
2020-04-05 05:02:11 +02:00
|
|
|
( $_anc_id = (int) get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) )
|
|
|
|
&& ! in_array( $_anc_id, $active_ancestor_item_ids, true )
|
2010-06-14 23:19:55 +02:00
|
|
|
) {
|
|
|
|
$active_ancestor_item_ids[] = $_anc_id;
|
|
|
|
}
|
|
|
|
|
2020-04-05 05:02:11 +02:00
|
|
|
if ( in_array( home_url(), array( untrailingslashit( $current_url ), untrailingslashit( $_indexless_current ) ), true ) ) {
|
2020-01-29 01:45:18 +01:00
|
|
|
// Back compat for home link to match wp_page_menu().
|
2010-06-02 15:48:26 +02:00
|
|
|
$classes[] = 'current_page_item';
|
|
|
|
}
|
2017-12-01 00:11:00 +01:00
|
|
|
$active_parent_item_ids[] = (int) $menu_item->menu_item_parent;
|
2010-05-25 15:30:10 +02:00
|
|
|
$active_parent_object_ids[] = (int) $menu_item->post_parent;
|
2017-12-01 00:11:00 +01:00
|
|
|
$active_object = $menu_item->object;
|
2010-12-06 04:54:57 +01:00
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// Give front page item the 'current-menu-item' class when extra query arguments are involved.
|
2010-12-06 04:54:57 +01:00
|
|
|
} elseif ( $item_url == $front_page_url && is_front_page() ) {
|
|
|
|
$classes[] = 'current-menu-item';
|
2010-05-25 15:30:10 +02:00
|
|
|
}
|
2010-10-21 21:55:28 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( untrailingslashit( $item_url ) == home_url() ) {
|
2010-06-23 00:05:43 +02:00
|
|
|
$classes[] = 'menu-item-home';
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2010-05-25 15:30:10 +02:00
|
|
|
}
|
2010-06-02 22:04:07 +02:00
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// Back-compat with wp_page_menu(): add "current_page_parent" to static home page link for any non-page query.
|
2020-05-16 20:42:12 +02:00
|
|
|
if ( ! empty( $home_page_id ) && 'post_type' === $menu_item->type
|
|
|
|
&& empty( $wp_query->is_page ) && $home_page_id == $menu_item->object_id
|
|
|
|
) {
|
2010-06-02 15:48:26 +02:00
|
|
|
$classes[] = 'current_page_parent';
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2010-06-02 15:48:26 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
$menu_items[ $key ]->classes = array_unique( $classes );
|
2010-05-25 15:30:10 +02:00
|
|
|
}
|
2010-06-14 23:19:55 +02:00
|
|
|
$active_ancestor_item_ids = array_filter( array_unique( $active_ancestor_item_ids ) );
|
2017-12-01 00:11:00 +01:00
|
|
|
$active_parent_item_ids = array_filter( array_unique( $active_parent_item_ids ) );
|
2010-05-25 15:30:10 +02:00
|
|
|
$active_parent_object_ids = array_filter( array_unique( $active_parent_object_ids ) );
|
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// Set parent's class.
|
2010-05-25 20:54:42 +02:00
|
|
|
foreach ( (array) $menu_items as $key => $parent_item ) {
|
2017-12-01 00:11:00 +01:00
|
|
|
$classes = (array) $parent_item->classes;
|
|
|
|
$menu_items[ $key ]->current_item_ancestor = false;
|
|
|
|
$menu_items[ $key ]->current_item_parent = false;
|
2010-10-21 21:55:28 +02:00
|
|
|
|
2010-05-26 04:42:15 +02:00
|
|
|
if (
|
2020-04-05 05:02:11 +02:00
|
|
|
isset( $parent_item->type )
|
|
|
|
&& (
|
2020-01-29 01:45:18 +01:00
|
|
|
// Ancestral post object.
|
2010-06-11 18:00:29 +02:00
|
|
|
(
|
2020-05-16 20:42:12 +02:00
|
|
|
'post_type' === $parent_item->type
|
2020-04-05 05:02:11 +02:00
|
|
|
&& ! empty( $queried_object->post_type )
|
|
|
|
&& is_post_type_hierarchical( $queried_object->post_type )
|
2020-04-09 17:43:10 +02:00
|
|
|
&& in_array( (int) $parent_item->object_id, $queried_object->ancestors, true )
|
2020-04-05 05:02:11 +02:00
|
|
|
&& $parent_item->object != $queried_object->ID
|
2010-06-11 18:00:29 +02:00
|
|
|
) ||
|
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// Ancestral term.
|
2010-06-11 18:00:29 +02:00
|
|
|
(
|
2020-05-16 20:42:12 +02:00
|
|
|
'taxonomy' === $parent_item->type
|
2020-04-05 05:02:11 +02:00
|
|
|
&& isset( $possible_taxonomy_ancestors[ $parent_item->object ] )
|
2020-04-09 17:43:10 +02:00
|
|
|
&& in_array( (int) $parent_item->object_id, $possible_taxonomy_ancestors[ $parent_item->object ], true )
|
2020-04-05 05:02:11 +02:00
|
|
|
&& (
|
2010-12-22 18:40:51 +01:00
|
|
|
! isset( $queried_object->term_id ) ||
|
|
|
|
$parent_item->object_id != $queried_object->term_id
|
|
|
|
)
|
2010-06-11 18:00:29 +02:00
|
|
|
)
|
|
|
|
)
|
2010-06-02 15:48:26 +02:00
|
|
|
) {
|
2020-04-05 05:02:11 +02:00
|
|
|
if ( ! empty( $queried_object->taxonomy ) ) {
|
|
|
|
$classes[] = 'current-' . $queried_object->taxonomy . '-ancestor';
|
|
|
|
} else {
|
|
|
|
$classes[] = 'current-' . $queried_object->post_type . '-ancestor';
|
|
|
|
}
|
2010-06-02 15:48:26 +02:00
|
|
|
}
|
2010-06-11 18:00:29 +02:00
|
|
|
|
2020-04-05 05:02:11 +02:00
|
|
|
if ( in_array( (int) $parent_item->db_id, $active_ancestor_item_ids, true ) ) {
|
|
|
|
$classes[] = 'current-menu-ancestor';
|
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
$menu_items[ $key ]->current_item_ancestor = true;
|
2010-06-14 23:19:55 +02:00
|
|
|
}
|
2020-04-05 05:02:11 +02:00
|
|
|
if ( in_array( (int) $parent_item->db_id, $active_parent_item_ids, true ) ) {
|
|
|
|
$classes[] = 'current-menu-parent';
|
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
$menu_items[ $key ]->current_item_parent = true;
|
2010-08-27 18:13:39 +02:00
|
|
|
}
|
2020-04-05 05:02:11 +02:00
|
|
|
if ( in_array( (int) $parent_item->object_id, $active_parent_object_ids, true ) ) {
|
2010-06-02 15:48:26 +02:00
|
|
|
$classes[] = 'current-' . $active_object . '-parent';
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2010-06-02 22:04:07 +02:00
|
|
|
|
2020-05-16 20:42:12 +02:00
|
|
|
if ( 'post_type' === $parent_item->type && 'page' === $parent_item->object ) {
|
2020-01-29 01:45:18 +01:00
|
|
|
// Back compat classes for pages to match wp_page_menu().
|
2020-04-05 05:02:11 +02:00
|
|
|
if ( in_array( 'current-menu-parent', $classes, true ) ) {
|
2010-06-02 15:48:26 +02:00
|
|
|
$classes[] = 'current_page_parent';
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2020-04-05 05:02:11 +02:00
|
|
|
if ( in_array( 'current-menu-ancestor', $classes, true ) ) {
|
2010-06-02 15:48:26 +02:00
|
|
|
$classes[] = 'current_page_ancestor';
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2010-06-02 15:48:26 +02:00
|
|
|
}
|
2010-06-02 22:04:07 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
$menu_items[ $key ]->classes = array_unique( $classes );
|
2010-05-25 15:30:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-28 21:00:49 +01:00
|
|
|
/**
|
2010-04-27 03:05:58 +02:00
|
|
|
* Retrieve the HTML list content for nav menu items.
|
2010-02-28 21:00:49 +01:00
|
|
|
*
|
2010-04-27 03:05:58 +02:00
|
|
|
* @uses Walker_Nav_Menu to create HTML list content.
|
2010-07-13 23:30:59 +02:00
|
|
|
* @since 3.0.0
|
2015-05-27 00:10:25 +02:00
|
|
|
*
|
2016-09-07 18:15:30 +02:00
|
|
|
* @param array $items The menu items, sorted by each menu item's menu order.
|
|
|
|
* @param int $depth Depth of the item in reference to parents.
|
|
|
|
* @param stdClass $r An object containing wp_nav_menu() arguments.
|
|
|
|
* @return string The HTML list content for the menu items.
|
2010-03-15 17:26:46 +01:00
|
|
|
*/
|
2010-04-27 03:05:58 +02:00
|
|
|
function walk_nav_menu_tree( $items, $depth, $r ) {
|
2017-12-01 00:11:00 +01:00
|
|
|
$walker = ( empty( $r->walker ) ) ? new Walker_Nav_Menu : $r->walker;
|
2010-03-26 20:36:49 +01:00
|
|
|
|
2019-09-15 13:31:57 +02:00
|
|
|
return $walker->walk( $items, $depth, $r );
|
2010-02-24 09:06:36 +01:00
|
|
|
}
|
2010-04-27 03:05:58 +02:00
|
|
|
|
2010-07-13 23:30:59 +02:00
|
|
|
/**
|
|
|
|
* Prevents a menu item ID from being used more than once.
|
|
|
|
*
|
|
|
|
* @since 3.0.1
|
|
|
|
* @access private
|
2015-05-27 00:10:25 +02:00
|
|
|
*
|
|
|
|
* @param string $id
|
|
|
|
* @param object $item
|
|
|
|
* @return string
|
2010-07-13 23:30:59 +02:00
|
|
|
*/
|
|
|
|
function _nav_menu_item_id_use_once( $id, $item ) {
|
|
|
|
static $_used_ids = array();
|
2020-04-05 05:02:11 +02:00
|
|
|
|
|
|
|
if ( in_array( $item->ID, $_used_ids, true ) ) {
|
2010-07-13 23:30:59 +02:00
|
|
|
return '';
|
2015-05-27 00:10:25 +02:00
|
|
|
}
|
2020-04-05 05:02:11 +02:00
|
|
|
|
2010-07-13 23:30:59 +02:00
|
|
|
$_used_ids[] = $item->ID;
|
2020-04-05 05:02:11 +02:00
|
|
|
|
2010-07-13 23:30:59 +02:00
|
|
|
return $id;
|
|
|
|
}
|