Skip to content

Commit 1ac8e4d

Browse files
committed
Use more accurate regex for matching icon and linkmod classnames
1 parent bf6dc87 commit 1ac8e4d

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#CHANGELOG
22
## [4.0.2]
33
- Fix dropdown opener having empty string for href value.
4+
- More accurate regex matching of icon and linkmod classnames.
45

56
## [4.0.1]
67
- Fix untranslated string in fallback (this was lost in transition between v3 and v4, fixed again).

class-wp-bootstrap-navwalker.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,20 +403,20 @@ private function seporate_linkmods_and_icons_from_classes( $classes, &$linkmod_c
403403
foreach ( $classes as $key => $class ) {
404404
// If any special classes are found, store the class in it's
405405
// holder array and and unset the item from $classes.
406-
if ( preg_match( '/disabled|sr-only/', $class ) ) {
406+
if ( preg_match( '/^disabled|^sr-only/', $class ) ) {
407407
// Test for .disabled or .sr-only classes.
408408
$linkmod_classes[] = $class;
409409
unset( $classes[ $key ] );
410-
} elseif ( preg_match( '/dropdown-header|dropdown-divider/', $class ) && $depth > 0 ) {
410+
} elseif ( preg_match( '/^dropdown-header|^dropdown-divider/', $class ) && $depth > 0 ) {
411411
// Test for .dropdown-header or .dropdown-divider and a
412412
// depth greater than 0 - IE inside a dropdown.
413413
$linkmod_classes[] = $class;
414414
unset( $classes[ $key ] );
415-
} elseif ( preg_match( '/fa-(\S*)?|fas(\s?)|far(\s?)|fal(\s?)|fab(\s?)|fa(\s?)/', $class ) ) {
415+
} elseif ( preg_match( '/^fa-(\S*)?|^fa(s|r|l|b)?(\s?)?$/', $class ) ) {
416416
// Font Awesome.
417417
$icon_classes[] = $class;
418418
unset( $classes[ $key ] );
419-
} elseif ( preg_match( '/glyphicons-(\S*)?|glyphicons(\s?)/', $class ) ) {
419+
} elseif ( preg_match( '/^glyphicon-(\S*)?|^glyphicon(\s?)$/', $class ) ) {
420420
// Glyphicons.
421421
$icon_classes[] = $class;
422422
unset( $classes[ $key ] );

0 commit comments

Comments
 (0)