The goal here is to make a Wordpress boostrap main menu top level item which has sub-items act as a clickable link for devices > 768 px wide and retain the default behavior for small device.
There is the following code in the navwalker.php file around line 83:
// If item has_children add atts to a.
if ( $args->has_children && $depth === 0 ) {
$atts['href'] = '#';
$atts['data-toggle'] = 'dropdown';
$atts['class'] = 'dropdown-toggle';
}
To make the link clickable for normal screens I need to modify the code but then add an else statement so that it retains the default behavior, something like:
// If item has_children add atts to a.
if ( $args->has_children && $depth === 0 ) {
if ( $windowwidth < 768) {
$atts['href'] = '#';
$atts['data-toggle'] = 'dropdown';
$atts['class'] = 'dropdown-toggle';
} else {
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
//$atts['data-toggle'] = 'dropdown';
$atts['class'] = 'dropdown-toggle';
}
}
The question is how to obtain the $windowwidth, presumably in JavaScript, so that I can use it in a PHP if/else clause.