WP_List_Table::prepare_items()

Prepares the list of items for displaying.

More Information

Developers should use this class to query and filter data, handle sorting, and pagination, and any other data-manipulation required prior to rendering. This method should be called explicitly after instantiating your class, and before rendering.

Source

public function prepare_items() {
	die( 'function WP_List_Table::prepare_items() must be overridden in a subclass.' );
}

Changelog

VersionDescription
3.1.0Introduced.

User Contributed Notes

  1. Skip to note 2 content
       /**
         * Prepares the list of items for displaying.
         */
        public function prepare_items() {
        
            $columns = $this->get_columns(); 
            $hidden = array();
            $sortable = $this->get_sortable_columns();
    
            $per_page = 10;
            $current_page = $this->get_pagenum();
            $offset = ( $current_page - 1 ) * $per_page;
    
            $this->_column_headers = array($columns, $hidden, $sortable);
    
            $args = array(
                    'numberposts' => $per_page,
                    'offset'      => $offset,
            );
            
            if( isset( $_REQUEST['orderby'] ) && isset( $_REQUEST['order'] ) ) {
                $args['orderby'] = $_REQUEST['orderby'];
                $args['order'] = $_REQUEST['order'];
            }
    
            $this->items = woo_deposits_get_orders($args);
    
            $this->set_pagination_args(
                array(
                'total_items' => woo_deposits_count(),
                'per_page'    => $per_page,
                )
            );
            
        }

You must log in before being able to contribute a note or feedback.