WPCF7_List_Table::prepare_items │ public │ CF7 1.0

Метод класса: WPCF7_List_Table{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$WPCF7_List_Table = new WPCF7_List_Table();
$WPCF7_List_Table->prepare_items();

Код WPCF7_List_Table::prepare_items() CF7 6.2.4.1

public function prepare_items() {
	$current_orderby = wpcf7_superglobal_get( 'orderby' );
	$current_order = wpcf7_superglobal_get( 'order' );

	list( $columns, $hidden, $sortable ) = $this->get_column_info();

	foreach ( array_keys( $columns ) as $column_key ) {
		if ( isset( $sortable[$column_key] ) ) {
			$orderby = $sortable[$column_key][0] ?? '';
			$initial_order = $sortable[$column_key][4] ?? '';

			if ( '' === $current_orderby and $initial_order ) {
				$current_orderby = $orderby;
				$current_order = $initial_order;

				break;
			}
		}
	}

	$per_page = $this->get_items_per_page( 'wpcf7_contact_forms_per_page' );

	$args = array(
		'posts_per_page' => $per_page,
		'orderby' => $current_orderby,
		'order' => $current_order,
		'offset' => ( $this->get_pagenum() - 1 ) * $per_page,
		's' => wpcf7_superglobal_get( 's' ),
	);

	$this->items = WPCF7_ContactForm::find( $args );

	$total_items = WPCF7_ContactForm::count();
	$total_pages = ceil( $total_items / $per_page );

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