updated theme Twenty Nineteen
version 1.7
This commit is contained in:
@ -31,11 +31,11 @@ function twentynineteen_get_social_link_svg( $uri, $size = 24 ) {
|
||||
/**
|
||||
* Display SVG icons in social links menu.
|
||||
*
|
||||
* @param string $item_output The menu item output.
|
||||
* @param WP_Post $item Menu item object.
|
||||
* @param int $depth Depth of the menu.
|
||||
* @param array $args wp_nav_menu() arguments.
|
||||
* @return string $item_output The menu item output with social icon.
|
||||
* @param string $item_output The menu item's starting HTML output.
|
||||
* @param WP_Post $item Menu item data object.
|
||||
* @param int $depth Depth of the menu. Used for padding.
|
||||
* @param stdClass $args An object of wp_nav_menu() arguments.
|
||||
* @return string The menu item output with social icon.
|
||||
*/
|
||||
function twentynineteen_nav_menu_social_icons( $item_output, $item, $depth, $args ) {
|
||||
// Change SVG icon inside social links menu if there is supported URL.
|
||||
@ -54,18 +54,17 @@ add_filter( 'walker_nav_menu_start_el', 'twentynineteen_nav_menu_social_icons',
|
||||
/**
|
||||
* Add a dropdown icon to top-level menu items.
|
||||
*
|
||||
* @param string $output Nav menu item start element.
|
||||
* @param object $item Nav menu item.
|
||||
* @param int $depth Depth.
|
||||
* @param object $args Nav menu args.
|
||||
* @param string $item_output The menu item's starting HTML output.
|
||||
* @param WP_Post $item Menu item data object.
|
||||
* @param int $depth Depth of the menu. Used for padding.
|
||||
* @param stdClass $args An object of wp_nav_menu() arguments.
|
||||
* @return string Nav menu item start element.
|
||||
* Add a dropdown icon to top-level menu items
|
||||
*/
|
||||
function twentynineteen_add_dropdown_icons( $output, $item, $depth, $args ) {
|
||||
function twentynineteen_add_dropdown_icons( $item_output, $item, $depth, $args ) {
|
||||
|
||||
// Only add class to 'top level' items on the 'primary' menu.
|
||||
if ( ! isset( $args->theme_location ) || 'menu-1' !== $args->theme_location ) {
|
||||
return $output;
|
||||
return $item_output;
|
||||
}
|
||||
|
||||
if ( in_array( 'mobile-parent-nav-menu-item', $item->classes, true ) && isset( $item->original_id ) ) {
|
||||
@ -77,18 +76,18 @@ function twentynineteen_add_dropdown_icons( $output, $item, $depth, $args ) {
|
||||
);
|
||||
|
||||
// Replace opening <a> with <button>.
|
||||
$output = preg_replace(
|
||||
$item_output = preg_replace(
|
||||
'/<a\s.*?>/',
|
||||
$link,
|
||||
$output,
|
||||
$item_output,
|
||||
1 // Limit.
|
||||
);
|
||||
|
||||
// Replace closing </a> with </button>.
|
||||
$output = preg_replace(
|
||||
$item_output = preg_replace(
|
||||
'#</a>#i',
|
||||
'</button>',
|
||||
$output,
|
||||
$item_output,
|
||||
1 // Limit.
|
||||
);
|
||||
|
||||
@ -97,12 +96,12 @@ function twentynineteen_add_dropdown_icons( $output, $item, $depth, $args ) {
|
||||
// Add SVG icon to parent items.
|
||||
$icon = twentynineteen_get_icon_svg( 'keyboard_arrow_down', 24 );
|
||||
|
||||
$output .= sprintf(
|
||||
$item_output .= sprintf(
|
||||
'<button class="submenu-expand" tabindex="-1">%s</button>',
|
||||
$icon
|
||||
);
|
||||
}
|
||||
|
||||
return $output;
|
||||
return $item_output;
|
||||
}
|
||||
add_filter( 'walker_nav_menu_start_el', 'twentynineteen_add_dropdown_icons', 10, 4 );
|
||||
|
Reference in New Issue
Block a user