Skip to content

Commit 1c81fb6

Browse files
authored
Subscriptions: Prevent warning when $post global is malformed (#48074)
1 parent 6e3c08f commit 1c81fb6

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: other
3+
4+
Subscriptions: Prevent warning when $post global is malformed.

projects/plugins/jetpack/modules/subscriptions/subscribe-modal/class-jetpack-subscribe-modal.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,11 @@ public function should_user_see_modal() {
233233
return false;
234234
}
235235

236-
// Don't show if post is for subscribers only or has paywall block
236+
// Don't show if post is not a post, is for subscribers only, or has paywall block
237237
global $post;
238+
if ( ! $post instanceof WP_Post ) {
239+
return false;
240+
}
238241
if ( defined( 'Automattic\\Jetpack\\Extensions\\Subscriptions\\META_NAME_FOR_POST_LEVEL_ACCESS_SETTINGS' ) ) {
239242
$access_level = get_post_meta( $post->ID, META_NAME_FOR_POST_LEVEL_ACCESS_SETTINGS, true );
240243
} else {

0 commit comments

Comments
 (0)