public function modifyColumns($columns)
    {
        // if user defined set columns, return those
        if (!empty($this->items)) {
            return $this->items;
        }

        // add additional columns
        if (!empty($this->add)) {
            foreach ($this->add as $key => $label) {
                $columns[$key] = $label;
            }
        }

        // unset hidden columns
        if (!empty($this->hide)) {
            foreach ($this->hide as $key) {
                unset($columns[$key]);
            }
        }

        // if user has made added custom columns
        if (!empty($this->positions)) {
            foreach ($this->positions as $key => $position) {
                // find index of the element in the array
                $index = array_search($key, array_keys($columns));
                // retrieve the element in the array of columns
                $item = array_slice($columns, $index, 1);
                // remove item from the array
                unset($columns[$key]);

                // split columns array into two at the desired position
                $start = array_slice($columns, 0, $position, true);
                $end = array_slice($columns, $position, count($columns) - 1, true);

                // insert column into position
                $columns = $start + $item + $end;
            }
        }

        return $columns;
    }
public function modifyColumns($columns)
    {
        // if user defined set columns, return those
        if (!empty($this->items)) {
            return $this->items;
        }

        // add additional columns
        if (!empty($this->add)) {
            foreach ($this->add as $key => $label) {
                $columns[$key] = $label;
            }
        }

        // unset hidden columns
        if (!empty($this->hide)) {
            foreach ($this->hide as $key) {
                unset($columns[$key]);
            }
        }

        // if user has made added custom columns
        if (!empty($this->positions)) {
            foreach ($this->positions as $key => $position) {
                // find index of the element in the array
                $index = array_search($key, array_keys($columns));
                // retrieve the element in the array of columns
                $item = array_slice($columns, $index, 1);
                // remove item from the array
                unset($columns[$key]);

                // split columns array into two at the desired position
                $start = array_slice($columns, 0, $position, true);
                $end = array_slice($columns, $position, count($columns) - 1, true);

                // insert column into position
                $columns = $start + $item + $end;
            }
        }

        return $columns;
    }
public function modifyColumns ( $ columns ) { // if user defined set columns, return those if ( ! empty ( $ this -> items ) ) { return $ this -> items ; } // add additional columns if ( ! empty ( $ this -> add ) ) { foreach ( $ this -> add as $ key => $ label ) { $ columns [ $ key ] = $ label ; } } // unset hidden columns if ( ! empty ( $ this -> hide ) ) { foreach ( $ this -> hide as $ key ) { unset ( $ columns [ $ key ] ) ; } } // if user has made added custom columns if ( ! empty ( $ this -> positions ) ) { foreach ( $ this -> positions as $ key => $ position ) { // find index of the element in the array $ index = array_search ( $ key , array_keys ( $ columns ) ) ; // retrieve the element in the array of columns $ item = array_slice ( $ columns , $ index , 1 ) ; // remove item from the array unset ( $ columns [ $ key ] ) ; // split columns array into two at the desired position $ start = array_slice ( $ columns , 0 , $ position , true ) ; $ end = array_slice ( $ columns , $ position , count ( $ columns ) - 1 , true ) ; // insert column into position $ columns = $ start + $ item + $ end ; } } return $ columns ; }
Modify the columns for the object
@param  array  $columns WordPress default columns
@return array           The modified columns
Modify the columns for the object