- Timestamp:
- 06/20/2020 11:20:25 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentynineteen/inc/icon-functions.php
r48101 r48103 32 32 * Display SVG icons in social links menu. 33 33 * 34 * @param string $item_output The menu itemoutput.35 * @param WP_Post $item Menu itemobject.36 * @param int $depth Depth of the menu.37 * @param object $argswp_nav_menu() arguments.34 * @param string $item_output The menu item's starting HTML output. 35 * @param WP_Post $item Menu item data object. 36 * @param int $depth Depth of the menu. Used for padding. 37 * @param stdClass $args An object of wp_nav_menu() arguments. 38 38 * @return string The menu item output with social icon. 39 39 */ … … 55 55 * Add a dropdown icon to top-level menu items. 56 56 * 57 * @param string $output Nav menu item start element.58 * @param object $item Nav menu item.59 * @param int $depth Depth.60 * @param object $args Nav menu args.57 * @param string $item_output The menu item's starting HTML output. 58 * @param WP_Post $item Menu item data object. 59 * @param int $depth Depth of the menu. Used for padding. 60 * @param stdClass $args An object of wp_nav_menu() arguments. 61 61 * @return string Nav menu item start element. 62 * Add a dropdown icon to top-level menu items63 62 */ 64 function twentynineteen_add_dropdown_icons( $ output, $item, $depth, $args ) {63 function twentynineteen_add_dropdown_icons( $item_output, $item, $depth, $args ) { 65 64 66 65 // Only add class to 'top level' items on the 'primary' menu. 67 66 if ( ! isset( $args->theme_location ) || 'menu-1' !== $args->theme_location ) { 68 return $ output;67 return $item_output; 69 68 } 70 69 … … 78 77 79 78 // Replace opening <a> with <button>. 80 $ output = preg_replace(79 $item_output = preg_replace( 81 80 '/<a\s.*?>/', 82 81 $link, 83 $ output,82 $item_output, 84 83 1 // Limit. 85 84 ); 86 85 87 86 // Replace closing </a> with </button>. 88 $ output = preg_replace(87 $item_output = preg_replace( 89 88 '#</a>#i', 90 89 '</button>', 91 $ output,90 $item_output, 92 91 1 // Limit. 93 92 ); … … 98 97 $icon = twentynineteen_get_icon_svg( 'keyboard_arrow_down', 24 ); 99 98 100 $ output .= sprintf(99 $item_output .= sprintf( 101 100 '<button class="submenu-expand" tabindex="-1">%s</button>', 102 101 $icon … … 104 103 } 105 104 106 return $ output;105 return $item_output; 107 106 } 108 107 add_filter( 'walker_nav_menu_start_el', 'twentynineteen_add_dropdown_icons', 10, 4 );
Note: See TracChangeset
for help on using the changeset viewer.