Yoast\WP\SEO\Integrations\Admin
Admin_Columns_Cache_Integration::get_current_page_page_ids() private Yoast 1.0
Gets all the page IDs set to be shown on the current page. This is copied over with some changes from WP_Posts_List_Table::_display_rows_hierarchical.
{} Это метод класса: Admin_Columns_Cache_Integration{}
Хуков нет.
Возвращает
Массив. The IDs of all pages shown on the current page.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_current_page_page_ids( $pages );
- $pages(массив) (обязательный)
- The pages, each containing an ID and post_parent.
Код Admin_Columns_Cache_Integration::get_current_page_page_ids() Admin Columns Cache Integration::get current page page ids Yoast 15.6.2
private function get_current_page_page_ids( $pages ) {
global $per_page;
$pagenum = isset( $_REQUEST['paged'] ) ? \absint( $_REQUEST['paged'] ) : 0;
$pagenum = \max( 1, $pagenum );
/*
* Arrange pages into two parts: top level pages and children_pages
* children_pages is two dimensional array, eg.
* children_pages[10][] contains all sub-pages whose parent is 10.
* It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations
* If searching, ignore hierarchy and treat everything as top level
*/
if ( empty( $_REQUEST['s'] ) ) {
$top_level_pages = [];
$children_pages = [];
$pages_map = [];
foreach ( $pages as $page ) {
// Catch and repair bad pages.
if ( $page->post_parent === $page->ID ) {
$page->post_parent = 0;
}
if ( $page->post_parent === 0 ) {
$top_level_pages[] = $page;
}
else {
$children_pages[ $page->post_parent ][] = $page;
}
$pages_map[ $page->ID ] = $page;
}
$pages = &$top_level_pages;
}
$count = 0;
$start = ( ( $pagenum - 1 ) * $per_page );
$end = ( $start + $per_page );
$to_display = [];
foreach ( $pages as $page ) {
if ( $count >= $end ) {
break;
}
if ( $count >= $start ) {
$to_display[] = $page->ID;
}
++$count;
$this->get_child_page_ids( $children_pages, $count, $page->ID, $start, $end, $to_display, $pages_map );
}
// If it is the last pagenum and there are orphaned pages, display them with paging as well.
if ( isset( $children_pages ) && $count < $end ) {
foreach ( $children_pages as $orphans ) {
foreach ( $orphans as $op ) {
if ( $count >= $end ) {
break;
}
if ( $count >= $start ) {
$to_display[] = $op->ID;
}
++$count;
}
}
}
return $to_display;
}