public function eventFilterWhere($where)
    {
        $from = null;
        $to = null;

        if (isset($_GET['from']) && !empty($_GET['from'])) {
            $from = sanitize_text_field($_GET['from']);
        }

        if (isset($_GET['to']) && !empty($_GET['to'])) {
            $to = date('Y-m-d', strtotime("+1 day", strtotime(sanitize_text_field($_GET['to']))));
        }

        if (!is_null($from) && !is_null($to)) {
            // USE BETWEEN ON START DATE
            $where = str_replace(
                "{$this->db->posts}.post_date >= '{$from}'",
                "{$this->dbTable}.start_date BETWEEN CAST('{$from}' AS DATE) AND CAST('{$to}' AS DATE)",
                $where
            );
            $where = str_replace(
                "AND {$this->db->posts}.post_date <= '{$to}'",
                "",
                $where
            );
        } elseif (!is_null($from) || !is_null($to)) {
            // USE FROM OR TO
            $where = str_replace("{$this->db->posts}.post_date >=", "{$this->dbTable}.start_date >=", $where);
            $where = str_replace("{$this->db->posts}.post_date <=", "{$this->dbTable}.end_date <=", $where);
        }

        return $where;
    }
public function eventFilterWhere($where)
    {
        $from = null;
        $to = null;

        if (isset($_GET['from']) && !empty($_GET['from'])) {
            $from = sanitize_text_field($_GET['from']);
        }

        if (isset($_GET['to']) && !empty($_GET['to'])) {
            $to = date('Y-m-d', strtotime("+1 day", strtotime(sanitize_text_field($_GET['to']))));
        }

        if (!is_null($from) && !is_null($to)) {
            // USE BETWEEN ON START DATE
            $where = str_replace(
                "{$this->db->posts}.post_date >= '{$from}'",
                "{$this->dbTable}.start_date BETWEEN CAST('{$from}' AS DATE) AND CAST('{$to}' AS DATE)",
                $where
            );
            $where = str_replace(
                "AND {$this->db->posts}.post_date <= '{$to}'",
                "",
                $where
            );
        } elseif (!is_null($from) || !is_null($to)) {
            // USE FROM OR TO
            $where = str_replace("{$this->db->posts}.post_date >=", "{$this->dbTable}.start_date >=", $where);
            $where = str_replace("{$this->db->posts}.post_date <=", "{$this->dbTable}.end_date <=", $where);
        }

        return $where;
    }
public function eventFilterWhere ( $ where ) { $ from = null ; $ to = null ; if ( isset ( $ _GET [ 'from' ] ) && ! empty ( $ _GET [ 'from' ] ) ) { $ from = sanitize_text_field ( $ _GET [ 'from' ] ) ; } if ( isset ( $ _GET [ 'to' ] ) && ! empty ( $ _GET [ 'to' ] ) ) { $ to = date ( 'Y-m-d' , strtotime ( "+1 day" , strtotime ( sanitize_text_field ( $ _GET [ 'to' ] ) ) ) ) ; } if ( ! is_null ( $ from ) && ! is_null ( $ to ) ) { // USE BETWEEN ON START DATE $ where = str_replace ( "{$this->db->posts}.post_date >= '{$from}'" , "{$this->dbTable}.start_date BETWEEN CAST('{$from}' AS DATE) AND CAST('{$to}' AS DATE)" , $ where ) ; $ where = str_replace ( "AND {$this->db->posts}.post_date <= '{$to}'" , "" , $ where ) ; } elseif ( ! is_null ( $ from ) || ! is_null ( $ to ) ) { // USE FROM OR TO $ where = str_replace ( "{$this->db->posts}.post_date >=" , "{$this->dbTable}.start_date >=" , $ where ) ; $ where = str_replace ( "{$this->db->posts}.post_date <=" , "{$this->dbTable}.end_date <=" , $ where ) ; } return $ where ; }
Add where statements
@param  string $where current where statement
@return string        updated statement
Add where statements