Toolset end date inclusive filter

By

By default, Toolset date range filter will only filter the post on or after the start date and before the end date, function will filter the end date inclusively.

add_filter('wpv_filter_query', 'date_between_inclusive_func', 10, 2);
function date_between_inclusive_func($query, $setting) {
    if($setting['view_id'] == 402)
    {
        foreach($query['meta_query'] as $k => $v)
        {
            if(isset($v['key']) && $v['key'] == 'wpcf-invoice-date' && isset($v['compare']))
            {
                if($v['compare'] == '<='){
                    $query['meta_query'][$k]['value'] += 24*60*60;
                }
                elseif($v['compare'] == 'BETWEEN'){
                    $arr = explode(',', $v['value']);
                    $end_date = $arr[1];
                    $new_arr = array($arr[0], $end_date + 24*60*60);
                    $str = implode(',', $new_arr);
                    $query['meta_query'][$k]['value'] = $str;
                }
            }
        }
    }
    return $query;
}