I’ve done some modifications, now it works better for me and I’d like to share it…
1. Using <optgroup> for the first level of categories gives a better overview. You can do it by changing _submit.php (@68) (search for function ldl_submit_multi_categories_dropdown):
foreach ($categories as $key => $cat) {
$result .= "<optgroup label=\"".$cat->name."\">";
$result .= get_child_categories($cat->term_id,LDDLITE_TAX_CAT);
$result .= "</optgroup>";
}
2.) Correct the “brute force” tabbing in function get_child_categories (in file _submit.php):
2.1) change $indent to 0:
function get_child_categories($parent_id,$tax,$indent = 0){
(this is because the optgroup is the first indent level, no need to indent the next level too)
2.2) indenting disturbs the filter, so we need to add a real space character in this function in the $child_cat_name. The following code also takes the $indent=0 of 2.1 into account:
if ($indent) {
$child_cat_name = str_repeat(' ', $indent).' '.$child_term->name;
}else{
$child_cat_name = $child_term->name;
}
3.) Update chosen jquery plugin:
- Download from https://github.com/harvesthq/chosen/releases/
- Copy to \wp-content\plugins\ldd-directory-lite\public\plugins
- Add the init to chosen.jquery.min.js as in previous version, I’ve copied the code below in case you didn’t preserve it
Init code for chosen:
jQuery(document).ready(function(){
jQuery(".multi_select_chosen").chosen({search_contains: true, no_results_text: "Oops, nothing found!"});
});
DONE. Now the category selector is more subcategory friendly and filter works for partial words (which is a huge benefit for usability).
-
This reply was modified 6 years, 7 months ago by
Shnipsel.