WP_Posts_List_Table::_page_rows

Advertisement

Private Access Private Access

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Summery Summery

Given a top level page ID, display the nested hierarchy of sub-pages together with paging support

Syntax Syntax

WP_Posts_List_Table::_page_rows( array $children_pages, int $count, int $parent, int $level, int $pagenum, int $per_page, array $to_display )

Parameters Parameters

$children_pages

(Required)

$count

(Required)

$parent

(Required)

$level

(Required)

$pagenum

(Required)

$per_page

(Required)

$to_display

(Required) List of pages to be displayed. Passed by reference.

Source Source

File: wp-admin/includes/class-wp-posts-list-table.php

	 * @since 4.2.0 Added the `$to_display` parameter.
	 *
	 * @param array $children_pages
	 * @param int   $count
	 * @param int   $parent
	 * @param int   $level
	 * @param int   $pagenum
	 * @param int   $per_page
	 * @param array $to_display List of pages to be displayed. Passed by reference.
	 */
	private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display ) {
		if ( ! isset( $children_pages[ $parent ] ) ) {
			return;
		}

		$start = ( $pagenum - 1 ) * $per_page;
		$end   = $start + $per_page;

		foreach ( $children_pages[ $parent ] as $page ) {
			if ( $count >= $end ) {
				break;
			}

			// If the page starts in a subtree, print the parents.
			if ( $count == $start && $page->post_parent > 0 ) {
				$my_parents = array();
				$my_parent  = $page->post_parent;
				while ( $my_parent ) {
					// Get the ID from the list or the attribute if my_parent is an object.
					$parent_id = $my_parent;
					if ( is_object( $my_parent ) ) {
						$parent_id = $my_parent->ID;
					}

					$my_parent    = get_post( $parent_id );
					$my_parents[] = $my_parent;
					if ( ! $my_parent->post_parent ) {
						break;
					}
					$my_parent = $my_parent->post_parent;
				}
				$num_parents = count( $my_parents );
				while ( $my_parent = array_pop( $my_parents ) ) {
					$to_display[ $my_parent->ID ] = $level - $num_parents;
					$num_parents--;
				}
			}

			if ( $count >= $start ) {

Advertisement

Changelog Changelog

Changelog
Version Description
4.2.0 Added the $to_display parameter.
3.1.0 Introduced.

Advertisement

Leave a Reply