Skip to content

Commit

Permalink
cpt-nova: Check the return value of get_menu_item_menu_leaf() (#35182)
Browse files Browse the repository at this point in the history
* cpt-nova: Check the return value of `get_menu_item_menu_leaf()`

* Update changelog entry

* Additional checks on the value of menu_item_loop_current_term

---------

Co-authored-by: Jeremy Herve <[email protected]>
  • Loading branch information
josephscott and jeherve authored Jan 30, 2024
1 parent fa5ee3f commit 7951333
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions projects/plugins/jetpack/changelog/fix-cpt-nova
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: other
Comment: Nova Custom Content Type: avoid PHP notice.


8 changes: 8 additions & 0 deletions projects/plugins/jetpack/modules/custom-post-types/nova.php
Original file line number Diff line number Diff line change
Expand Up @@ -1587,6 +1587,14 @@ public function start_menu_item_loop( $query ) {
public function menu_item_loop_each_post( $post ) {
$this->menu_item_loop_current_term = $this->get_menu_item_menu_leaf( $post->ID );

if (
false === $this->menu_item_loop_current_term
|| null === $this->menu_item_loop_current_term
|| is_wp_error( $this->menu_item_loop_current_term )
) {
return;
}

if ( false === $this->menu_item_loop_last_term_id ) {
// We're at the very beginning of the loop

Expand Down

0 comments on commit 7951333

Please sign in to comment.