item_spacing ) && 'discard' === $args->item_spacing ) { $t = ''; $n = ''; } else { $t = "\t"; $n = "\n"; } $indent = str_repeat( $t, $depth ); // Default class to add to the file. $classes = array( 'dropdown-menu' ); /** * Filters the CSS class(es) applied to a menu list element. * * @since WP 4.8.0 * * @param array $classes The CSS classes that are applied to the menu `'; if ( $container ) { $fallback_output .= ''; } // Display the fallback html. echo $fallback_output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } /** * Pluck linkmod or icon classes from an array of classes. * * Supported linkmods: .disabled, .dropdown-header, .dropdown-divider, .sr-only. * Supported iconsets: Font Awesome 4/5, Glypicons. * * Any of the above linkmod classes and icon classes will be removed * from the passed array of classes. This is necessary so that we can * separately use these classes to wrap the or generate the icon * element respectively. * * @since WP 4.6.0 * * @param array $classes An array of classes currently assigned to the item. * @param array $linkmod_classes An array to hold linkmod classes. * @param array $icon_classes An array to hold icon classes. * @param int $depth Depth of menu item. * * @return array An array of classes with linkmod and icon classes plucked. */ private static function separate_linkmods_and_icons_from_classes( $classes, &$linkmod_classes, &$icon_classes, $depth ) { // Separate linkmod classes. $linkmod_classes = array_intersect( $classes, array( 'disabled', 'dropdown-header', 'dropdown-divider', 'sr-only' ) ); $classes = array_diff( $classes, $linkmod_classes ); // Separate icon classes. $icon_classes = array_filter( $classes, function( $class ) { return preg_match( '/^fa-(?:\S+)/i', $class ) || preg_match( '/^glyphicon-(?:\S+)/i', $class ); } ); $classes = array_diff( $classes, $icon_classes ); // Remove the default 'menu-item' classes that WordPress generates. $classes = array_diff( $classes, array( 'menu-item', 'menu-item-type-post_type', 'menu-item-object-page' ) ); return $classes; } /** * Remove linkmod attributes from elements. * * This method will take an array of attributes and remove linkmod specific * attributes. This is necessary so that the attributes do not interfere * with the output of the element. For example, .dropdown-header should * not have a href attribute. * * @since WP 4.6.0 * * @param array $atts An array of link attributes. * @param array $linkmod_classes An array of linkmod classes. * * @return array An array of link attributes with linkmod attributes removed. */ private static function unset_linkmod_attributes( $atts, $linkmod_classes ) { // Remove the href attribute if the item is a dropdown-header or divider. if ( in_array( 'dropdown-header', $linkmod_classes, true ) || in_array( 'dropdown-divider', $linkmod_classes, true ) ) { unset( $atts['href'] ); } // Remove the href attribute if the item is disabled. if ( in_array( 'disabled', $linkmod_classes, true ) ) { unset( $atts['href'] ); } // Return the array of $atts sans linkmod attributes. return $atts; } } // End of wp_bootstrap_navwalker class. } // End of function_exists().