WithdrawalsList::prepare_items()


Source

File: classes/WithdrawalsList.php

	function prepare_items() {
		$per_page = 20;

		$search_term = '';
		if ( isset( $_REQUEST['s'] ) ) {
			$search_term = sanitize_text_field( $_REQUEST['s'] );
		}

		$columns               = $this->get_columns();
		$hidden                = [];
		$this->_column_headers = [ $columns, $hidden ];
		$current_page          = $this->get_pagenum();
		$start                 = ( $current_page - 1 ) * $per_page;
		$withdraw_requests     = dozent_get_withdrawals( null, compact( 'start', 'per_page', 'search_term' ) );
		$this->items           = $withdraw_requests->results;
		$count_result          = $withdraw_requests->count;

		$this->set_pagination_args( [
			'total_items' => $count_result,
			'per_page'    => $per_page,
			'total_pages' => ceil( $count_result / $per_page )
		] );
	}