WP_Posts_List_Table::_page_rows( array $children_pages, int $count, int $parent_page, int $level, int $pagenum, int $per_page, array $to_display )
- Since
- 3.1.0, 4.2.0
- Source
wp-admin/includes/class-wp-posts-list-table.php:959
Compatibility
- WordPress
- since 4.2.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$children_pagesarray$countint$parent_pageint$levelint$pagenumint$per_pageint$to_displayarray- List of pages to be displayed. Passed by reference.
Performance profile
How much work a call to WP_Posts_List_Table::_page_rows() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Heavy
- Scaling
- Scales with input
- Instructions
- 10–20
- Plugin surface
- None
- Called by
- 2
Reaches the database via get_post().
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 76.
Nothing here hands control to plugin code.
2 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- querycontent query
get_post()called directly
Further down the call graph this can also reach hook, option, cache, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Posts_List_Table::_page_rows() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 10–20 | none |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 76 | 10–20 | 11 | |
| 8.5 | 76 | 10–20 | 11 | |
| 8.4 | 76 | 10–20 | 11 | |
| 8.3 | 76 | 10–20 | 11 | |
| 8.2 | 76 | 10–20 | 11 | |
| 8.1 | 76 | 10–20 | 11 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 77 | 10–20 | 11 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 2
- get_post()Retrieves post data given a post ID or post object.
- WP_Posts_List_Table::_page_rows()Displays the nested hierarchy of sub-pages together with paging support, based on a top level page ID.
Used by · 2
- WP_Posts_List_Table::_display_rows_hierarchical()
- WP_Posts_List_Table::_page_rows()Displays the nested hierarchy of sub-pages together with paging support, based on a top level page ID.
Source code
private function _page_rows( &$children_pages, &$count, $parent_page, $level, $pagenum, $per_page, &$to_display ) { if ( ! isset( $children_pages[ $parent_page ] ) ) { return; } $start = ( $pagenum - 1 ) * $per_page; $end = $start + $per_page; foreach ( $children_pages[ $parent_page ] 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 ) { $to_display[ $page->ID ] = $level; } ++$count; $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); } unset( $children_pages[ $parent_page ] ); // Required in order to keep track of orphans. }Changelog
Introduced in 4.2.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
$to_display parameter.from the docblockAbout this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-admin/includes/class-wp-posts-list-table.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.