es 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; } /** * Adds all child pages due to be shown on the current page to the $to_display array. * Copied over with some changes from WP_Posts_List_Table::_page_rows. * * @param array $children_pages The full map of child pages. * @param int $count The number of pages already processed. * @param int $parent_id The id of the parent that's currently being processed. * @param int $start The number at which the current overview starts. * @param int $end The number at which the current overview ends. * @param int $to_display The page IDs to be shown. * @param int $pages_map A map of page ID to an object with ID and post_parent. * * @return void */ private function get_child_page_ids( &$children_pages, &$count, $parent_id, $start, $end, &$to_display, &$pages_map ) { if ( ! isset( $children_pages[ $parent_id ] ) ) { return; } foreach ( $children_pages[ $parent_id ] 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 = []; $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 = $pages_map[ $parent_id ]; $my_parents[] = $my_parent; if ( ! $my_parent->post_parent ) { break; } $my_parent = $my_parent->post_parent; } while ( $my_parent = \array_pop( $my_parents ) ) { $to_display[] = $my_parent->ID; } } if ( $count >= $start ) { $to_display[] = $page->ID; } ++$count; $this->get_child_page_ids( $children_pages, $count, $page->ID, $start, $end, $to_display, $pages_map ); } unset( $children_pages[ $parent_id ] ); // Required in order to keep track of orphans. } }
Fatal error: Uncaught Error: Interface "iThemesSecurity\Ban_Hosts\Updatable" not found in /htdocs/wp-content/plugins/better-wp-security/core/modules/ban-users/Database_Repository.php:19 Stack trace: #0 /htdocs/wp-content/plugins/better-wp-security/vendor-prod/composer/ClassLoader.php(582): include() #1 /htdocs/wp-content/plugins/better-wp-security/vendor-prod/composer/ClassLoader.php(433): Composer\Autoload\{closure}('/htdocs/wp-cont...') #2 /htdocs/wp-content/plugins/better-wp-security/core/modules/ban-users/container.php(23): Composer\Autoload\ClassLoader->loadClass('iThemesSecurity...') #3 /htdocs/wp-content/plugins/better-wp-security/vendor-prod/pimple/pimple/src/Pimple/Container.php(125): ITSEC_Modules::iThemesSecurity\Ban_Users\{closure}(Object(iThemesSecurity\Strauss\Pimple\Container)) #4 [internal function]: iThemesSecurity\Strauss\Pimple\Container->offsetGet('iThemesSecurity...') #5 /htdocs/wp-content/plugins/better-wp-security/core/container.php(63): array_map(Array, Array) #6 /htdocs/wp-content/plugins/better-wp-security/vendor-prod/pimple/pimple/src/Pimple/Container.php(125): ITSEC_Modules::iThemesSecurity\{closure}(Object(iThemesSecurity\Strauss\Pimple\Container)) #7 /htdocs/wp-content/plugins/better-wp-security/vendor-prod/pimple/pimple/src/Pimple/Psr11/Container.php(51): iThemesSecurity\Strauss\Pimple\Container->offsetGet('iThemesSecurity...') #8 /htdocs/wp-content/plugins/better-wp-security/core/lib.php(281): iThemesSecurity\Strauss\Pimple\Psr11\Container->get('iThemesSecurity...') #9 /htdocs/wp-content/plugins/better-wp-security/core/lockout.php(144): ITSEC_Lib::is_ip_banned() #10 /htdocs/wp-includes/class-wp-hook.php(308): ITSEC_Lockout->check_for_host_lockouts('') #11 /htdocs/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array) #12 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #13 /htdocs/wp-settings.php(617): do_action('init') #14 /htdocs/wp-config.php(92): require_once('/htdocs/wp-sett...') #15 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #16 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #17 /htdocs/index.php(17): require('/htdocs/wp-blog...') #18 {main} thrown in /htdocs/wp-content/plugins/better-wp-security/core/modules/ban-users/Database_Repository.php on line 19