bu-navigation
bu-navigation copied to clipboard
PHP Notice on undefined index: add_bu_links.
I confirm that this notice comes up for PHP 7.1, 7.2 and 7.3:
[15-Sep-2019 08:22:32 America/New_York] PHP Notice: Undefined index: add_bu_links in /wp-content/plugins/bu-navigation/extras/bu-navigation-external-links.php on line 128
This is the block of code in question:
function bu_navigation_add_links_to_pages_list( $pages, $r ){
if( $r['add_bu_links'] ){
$post_parents = array();
foreach($pages as $page){
if( array_search( $page->post_parent, $post_parents ) === false ){
$post_parents[] = $page->post_parent;
}
}
$args = array(
'post_type' => BU_NAVIGATION_LINK_POST_TYPE,
'post_parent__in' => $post_parents,
'posts_per_page' => -1,
);
$bu_query = new WP_Query( $args );
$bu_links = $bu_query->posts;
for($i = 0; $i < count($bu_links); $i++ ){
$bu_links[$i]->post_type = 'page';
}
$pages = array_merge( $pages, $bu_links );
usort( $pages, function ( $a, $b ){
if( $a->post_parent == $b->post_parent ){
return $a->menu_order > $b->menu_order ? 1 : -1;
}
return $a->post_parent > $b->post_parent ? 1 : -1;
});
}
return $pages;
}