public function listColumnsSortingQuery($query)
    {
        if (!is_admin() || !$query->is_main_query() || $query->get('post_type') != $this->postTypeSlug) {
            return;
        }

        if (!empty($_GET['feedback_topic'])) {
            $query->set('tax_query', array(
                'relation' => 'AND',
                array(
                    'taxonomy' => 'feedback_topic',
                    'field' => 'slug',
                    'terms' => $_GET['feedback_topic'],
                    'operator' => 'IN'
                )
            ));
        }

        $metaQuery = array(
            'relation' => 'AND'
        );

        // Filter on has-comment
        if (isset($_GET['has-comment']) && $_GET['has-comment'] === 'yes') {
            $metaQuery[] = array(
                'key' => 'customer_feedback_comment',
                'compare' => 'EXISTS'
            );
        }

        if (isset($_GET['has-comment']) && $_GET['has-comment'] === 'no') {
            $metaQuery[] = array(
                'key' => 'customer_feedback_comment',
                'compare' => 'NOT EXISTS'
            );
        }

        if (!isset($_GET['has-comment']) || empty($_GET['has-comment'])) {
            $metaQuery[] = array(
                'relation' => 'OR',
                array(
                    'key' => 'customer_feedback_comment',
                    'compare' => 'EXISTS'
                ),
                array(
                    'key' => 'customer_feedback_comment',
                    'compare' => 'NOT EXISTS'
                )
            );
        }


        // Filter on answer
        if (isset($_GET['answer']) && $_GET['answer'] === 'yes') {
            $metaQuery[] = array(
                'relation' => 'OR',
                array(
                    'key' => 'customer_feedback_answer',
                    'value' => 'yes',
                    'compare' => '='
                )
            );
        }

        if (isset($_GET['answer']) && $_GET['answer'] === 'no') {
            $metaQuery[] = array(
                'relation' => 'OR',
                array(
                    'key' => 'customer_feedback_answer',
                    'compare' => 'NOT EXISTS'
                ),
                array(
                    'key' => 'customer_feedback_answer',
                    'value' => 'no',
                    'compare' => '='
                )
            );
        }

        $query->set('meta_query', $metaQuery);

        switch ($query->get('orderby')) {
            case 'has-comment':
                $query->set('orderby', 'customer_feedback_comment');
                break;

            case 'answer':
                $query->set('orderby', 'customer_feedback_answer');
                break;
        }
    }
public function listColumnsSortingQuery($query)
    {
        if (!is_admin() || !$query->is_main_query() || $query->get('post_type') != $this->postTypeSlug) {
            return;
        }

        if (!empty($_GET['feedback_topic'])) {
            $query->set('tax_query', array(
                'relation' => 'AND',
                array(
                    'taxonomy' => 'feedback_topic',
                    'field' => 'slug',
                    'terms' => $_GET['feedback_topic'],
                    'operator' => 'IN'
                )
            ));
        }

        $metaQuery = array(
            'relation' => 'AND'
        );

        // Filter on has-comment
        if (isset($_GET['has-comment']) && $_GET['has-comment'] === 'yes') {
            $metaQuery[] = array(
                'key' => 'customer_feedback_comment',
                'compare' => 'EXISTS'
            );
        }

        if (isset($_GET['has-comment']) && $_GET['has-comment'] === 'no') {
            $metaQuery[] = array(
                'key' => 'customer_feedback_comment',
                'compare' => 'NOT EXISTS'
            );
        }

        if (!isset($_GET['has-comment']) || empty($_GET['has-comment'])) {
            $metaQuery[] = array(
                'relation' => 'OR',
                array(
                    'key' => 'customer_feedback_comment',
                    'compare' => 'EXISTS'
                ),
                array(
                    'key' => 'customer_feedback_comment',
                    'compare' => 'NOT EXISTS'
                )
            );
        }


        // Filter on answer
        if (isset($_GET['answer']) && $_GET['answer'] === 'yes') {
            $metaQuery[] = array(
                'relation' => 'OR',
                array(
                    'key' => 'customer_feedback_answer',
                    'value' => 'yes',
                    'compare' => '='
                )
            );
        }

        if (isset($_GET['answer']) && $_GET['answer'] === 'no') {
            $metaQuery[] = array(
                'relation' => 'OR',
                array(
                    'key' => 'customer_feedback_answer',
                    'compare' => 'NOT EXISTS'
                ),
                array(
                    'key' => 'customer_feedback_answer',
                    'value' => 'no',
                    'compare' => '='
                )
            );
        }

        $query->set('meta_query', $metaQuery);

        switch ($query->get('orderby')) {
            case 'has-comment':
                $query->set('orderby', 'customer_feedback_comment');
                break;

            case 'answer':
                $query->set('orderby', 'customer_feedback_answer');
                break;
        }
    }
public function listColumnsSortingQuery ( $ query ) { if ( ! is_admin ( ) || ! $ query -> is_main_query ( ) || $ query -> get ( 'post_type' ) != $ this -> postTypeSlug ) { return ; } if ( ! empty ( $ _GET [ 'feedback_topic' ] ) ) { $ query -> set ( 'tax_query' , array ( 'relation' => 'AND' , array ( 'taxonomy' => 'feedback_topic' , 'field' => 'slug' , 'terms' => $ _GET [ 'feedback_topic' ] , 'operator' => 'IN' ) ) ) ; } $ metaQuery = array ( 'relation' => 'AND' ) ; // Filter on has-comment if ( isset ( $ _GET [ 'has-comment' ] ) && $ _GET [ 'has-comment' ] === 'yes' ) { $ metaQuery [ ] = array ( 'key' => 'customer_feedback_comment' , 'compare' => 'EXISTS' ) ; } if ( isset ( $ _GET [ 'has-comment' ] ) && $ _GET [ 'has-comment' ] === 'no' ) { $ metaQuery [ ] = array ( 'key' => 'customer_feedback_comment' , 'compare' => 'NOT EXISTS' ) ; } if ( ! isset ( $ _GET [ 'has-comment' ] ) || empty ( $ _GET [ 'has-comment' ] ) ) { $ metaQuery [ ] = array ( 'relation' => 'OR' , array ( 'key' => 'customer_feedback_comment' , 'compare' => 'EXISTS' ) , array ( 'key' => 'customer_feedback_comment' , 'compare' => 'NOT EXISTS' ) ) ; } // Filter on answer if ( isset ( $ _GET [ 'answer' ] ) && $ _GET [ 'answer' ] === 'yes' ) { $ metaQuery [ ] = array ( 'relation' => 'OR' , array ( 'key' => 'customer_feedback_answer' , 'value' => 'yes' , 'compare' => '=' ) ) ; } if ( isset ( $ _GET [ 'answer' ] ) && $ _GET [ 'answer' ] === 'no' ) { $ metaQuery [ ] = array ( 'relation' => 'OR' , array ( 'key' => 'customer_feedback_answer' , 'compare' => 'NOT EXISTS' ) , array ( 'key' => 'customer_feedback_answer' , 'value' => 'no' , 'compare' => '=' ) ) ; } $ query -> set ( 'meta_query' , $ metaQuery ) ; switch ( $ query -> get ( 'orderby' ) ) { case 'has-comment' : $ query -> set ( 'orderby' , 'customer_feedback_comment' ) ; break ; case 'answer' : $ query -> set ( 'orderby' , 'customer_feedback_answer' ) ; break ; } }
Handles the sorting of the table columns
@param  WP_Query $query
@return void
Handles the sorting of the table columns