Skip to content

Commit

Permalink
Update/check post exists under context in widget visibility module (#…
Browse files Browse the repository at this point in the history
…39746)

* Added check to ensure post exists before checking post_author
  • Loading branch information
darssen authored Oct 11, 2024
1 parent 6ee4b21 commit 492773f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: other

Widget Visibility. Added check to ensure post exists before accesing post_author
Original file line number Diff line number Diff line change
Expand Up @@ -976,13 +976,15 @@ public static function filter_widget_check_conditions( $conditions ) {
}
break;
case 'author':
$post = get_post();
if ( ! $rule['minor'] && is_author() ) {
$condition_result = true;
} elseif ( $rule['minor'] && is_author( $rule['minor'] ) ) {
$condition_result = true;
} elseif ( is_singular() && $rule['minor'] && $rule['minor'] === $post->post_author ) {
$condition_result = true;
} elseif ( is_singular() && $rule['minor'] ) {
$post = get_post();
if ( $post && $rule['minor'] === $post->post_author ) {
$condition_result = true;
}
}
break;
case 'role':
Expand Down

0 comments on commit 492773f

Please sign in to comment.