BP_Members_Invitations_List_Table::prepare_items()

Set up items for display in the list table.


Description Description

Handles filtering of data, sorting, pagination, and any other data manipulation required prior to rendering.


Source Source

File: bp-members/classes/class-bp-members-invitations-list-table.php

	public function prepare_items() {
		global $usersearch;

		$search   = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
		$per_page = $this->get_items_per_page( str_replace( '-', '_', "{$this->screen->id}_per_page" ) );
		$paged    = $this->get_pagenum();

		$args = array(
			'invite_sent'  => 'all',
			'accepted'     => 'all',
			'search_terms' => $search,
			'order_by'     => 'date_modified',
			'sort_order'   => 'DESC',
			'page'         => $paged,
			'per_page'     => $per_page,
		);

		if ( isset( $_REQUEST['accepted'] ) && in_array( $_REQUEST['accepted'], array( 'pending', 'accepted' ), true ) ) {
			$args['accepted']       = $_REQUEST['accepted'];
			$this->active_filters[] = $_REQUEST['accepted'];
		}
		if ( isset( $_REQUEST['sent'] ) && in_array( $_REQUEST['sent'], array( 'draft', 'sent' ), true ) ) {
			$args['invite_sent']    = $_REQUEST['sent'];
			$this->active_filters[] = $_REQUEST['sent'];
		}

		if ( isset( $_REQUEST['orderby'] ) ) {
			$args['order_by'] = $_REQUEST['orderby'];
		}

		if ( isset( $_REQUEST['order'] ) ) {
			$args['sort_order'] = $_REQUEST['order'];
		}

		$invites_class     = new BP_Members_Invitation_Manager();
		$this->items       = $invites_class->get_invitations( $args );
		$this->total_items = $invites_class->get_invitations_total_count( $args );

		$this->set_pagination_args( array(
			'total_items' => $this->total_items,
			'per_page'    => $per_page,
		) );
	}


Top ↑

Changelog Changelog

Changelog
Version Description
8.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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