WP_Terms_List_Table::prepare_items()publicWP 1.0

Method of the class: WP_Terms_List_Table{}

Return

null. Nothing (null).

Usage

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

WP_Terms_List_Table::prepare_items() code WP 6.6.2

public function prepare_items() {
	$taxonomy = $this->screen->taxonomy;

	$tags_per_page = $this->get_items_per_page( "edit_{$taxonomy}_per_page" );

	if ( 'post_tag' === $taxonomy ) {
		/**
		 * Filters the number of terms displayed per page for the Tags list table.
		 *
		 * @since 2.8.0
		 *
		 * @param int $tags_per_page Number of tags to be displayed. Default 20.
		 */
		$tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page );

		/**
		 * Filters the number of terms displayed per page for the Tags list table.
		 *
		 * @since 2.7.0
		 * @deprecated 2.8.0 Use {@see 'edit_tags_per_page'} instead.
		 *
		 * @param int $tags_per_page Number of tags to be displayed. Default 20.
		 */
		$tags_per_page = apply_filters_deprecated( 'tagsperpage', array( $tags_per_page ), '2.8.0', 'edit_tags_per_page' );
	} elseif ( 'category' === $taxonomy ) {
		/**
		 * Filters the number of terms displayed per page for the Categories list table.
		 *
		 * @since 2.8.0
		 *
		 * @param int $tags_per_page Number of categories to be displayed. Default 20.
		 */
		$tags_per_page = apply_filters( 'edit_categories_per_page', $tags_per_page );
	}

	$search = ! empty( $_REQUEST['s'] ) ? trim( wp_unslash( $_REQUEST['s'] ) ) : '';

	$args = array(
		'taxonomy'   => $taxonomy,
		'search'     => $search,
		'page'       => $this->get_pagenum(),
		'number'     => $tags_per_page,
		'hide_empty' => 0,
	);

	if ( ! empty( $_REQUEST['orderby'] ) ) {
		$args['orderby'] = trim( wp_unslash( $_REQUEST['orderby'] ) );
	}

	if ( ! empty( $_REQUEST['order'] ) ) {
		$args['order'] = trim( wp_unslash( $_REQUEST['order'] ) );
	}

	$args['offset'] = ( $args['page'] - 1 ) * $args['number'];

	// Save the values because 'number' and 'offset' can be subsequently overridden.
	$this->callback_args = $args;

	if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $args['orderby'] ) ) {
		// We'll need the full set of terms then.
		$args['number'] = 0;
		$args['offset'] = $args['number'];
	}

	$this->items = get_terms( $args );

	$this->set_pagination_args(
		array(
			'total_items' => wp_count_terms(
				array(
					'taxonomy' => $taxonomy,
					'search'   => $search,
				)
			),
			'per_page'    => $tags_per_page,
		)
	);
}