Skip to content

Commit

Permalink
PLANET-7714 Fix ErrorExceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
sagarsdeshmukh committed Jan 1, 2025
1 parent f4e88a1 commit 4d35adf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,9 @@ function render_navigation_block(array $attributes): string
// For parent pages, get the previous and next siblings in the menu order
$output = '';
$siblings = array_filter($menu_items, function ($item) use ($nav_menu_item) {
return $item->menu_item_parent === $nav_menu_item->menu_item_parent;
return $item !== null
&& $nav_menu_item !== null
&& $item->menu_item_parent === $nav_menu_item->menu_item_parent;
});

$siblings = array_values($siblings);
Expand All @@ -435,7 +437,7 @@ function render_navigation_block(array $attributes): string
// For child pages, only show link to the parent
if ($submenu_page->menu_item_parent !== 0) {
$parent_item = array_filter($menu_items, function ($item) use ($submenu_page) {
return (int) $item->ID === (int) $submenu_page->menu_item_parent;
return $submenu_page !== null && (int) $item->ID === (int) $submenu_page->menu_item_parent;
});

$parent_item = reset($parent_item);
Expand Down
6 changes: 3 additions & 3 deletions tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
}

$tag = get_queried_object();
$redirect_id = get_term_meta($tag->term_id, 'redirect_page', true);
$redirect_id = $tag !== null && get_term_meta($tag->term_id, 'redirect_page', true);
$redirect_page = get_post($redirect_id);

if ($redirect_id) {
if ($redirect_page) {
global $wp_query;
$redirect_page = get_post($redirect_id);
$wp_query->queried_object = $redirect_page;
$wp_query->queried_object_id = $redirect_page->ID;

Expand Down

0 comments on commit 4d35adf

Please sign in to comment.