Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Notice on undefined index: add_bu_links. #47

Open
ravigehlot opened this issue Sep 18, 2019 · 0 comments
Open

PHP Notice on undefined index: add_bu_links. #47

ravigehlot opened this issue Sep 18, 2019 · 0 comments

Comments

@ravigehlot
Copy link

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant