From: Anthony Talarico Date: Wed, 5 Jul 2017 16:09:25 +0000 (-0400) Subject: adjusting the dataCategories sortParentChild function X-Git-Tag: v1.6.49^2~2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=3bea0c1227f9ec32f427155393e3f9403b6d7b9c;p=WP-Plugins%2Fglm-member-db-events.git adjusting the dataCategories sortParentChild function the parentChild sorting function in the dataCategories data class file needed to add the tilde appended to not just the parent but the child as well in order to properly sort categories that are similar in name except for numbers or characters at the end --- diff --git a/classes/data/dataCategories.php b/classes/data/dataCategories.php index eabf097..aa4dd0b 100644 --- a/classes/data/dataCategories.php +++ b/classes/data/dataCategories.php @@ -403,25 +403,24 @@ class GlmDataEventsCategories extends GlmDataAbstract if (!is_array($array) || count($array) == 0) { return false; } - + // Do a sort by custom function with it included in the call // This lets me directly use $name and $parent in the sort function uasort($array, function ($a, $b) use ($name, $parent) { - // If there's a parent, append the name of this entry to the parent // The '~~~' simply keeps appended strings from any chance of a match with something else if ($a[$parent]['value']) { $aVal = $a[$parent]['name'].'~~~'.$a['name']; } else { // Otheriwse just use the name. - $aVal = $a['name']; + $aVal = $a['name'].'~~~'; } // Same for b value if ($b[$parent]['value']) { $bVal = $b[$parent]['name'].'~~~'.$b['name']; } else { - $bVal = $b['name']; + $bVal = $b['name'].'~~~'; } if ($aVal > $bVal) {