mirror of
https://github.com/woocommerce/storefront.git
synced 2025-10-04 14:11:16 +08:00
* Add support for menu description. * Remove version number from menu description function * Update menu item description styles * Make nav menu description and cart icon product count text contrast WCAG 2.0 AA compliant contrast was ~2.5, target is 4.5+ Co-authored-by: Tomasz Tunik <tomasztunik@gmail.com>
25 lines
827 B
PHP
25 lines
827 B
PHP
<?php
|
|
/**
|
|
* Storefront menu functions.
|
|
*
|
|
* @package storefront
|
|
*/
|
|
|
|
/**
|
|
* Filters the arguments for a single nav menu item.
|
|
*
|
|
* @param stdClass $args An object of wp_nav_menu() arguments.
|
|
* @param WP_Post $item Menu item data object.
|
|
* @param int $depth Depth of menu item. Used for padding.
|
|
*
|
|
* @return stdClass
|
|
*/
|
|
function storefront_add_menu_description_args( $args, $item, $depth ) {
|
|
$args->link_after = '';
|
|
if ( 0 === $depth && isset( $item->description ) && $item->description ) {
|
|
// The extra <span> element is here for styling purposes: Allows the description to not be underlined on hover.
|
|
$args->link_after = '<p class="menu-item-description"><span>' . $item->description . '</span></p>';
|
|
}
|
|
return $args;
|
|
}
|
|
add_filter( 'nav_menu_item_args', 'storefront_add_menu_description_args', 10, 3 );
|