diff --git a/projects/plugins/jetpack/modules/sharedaddy/sharing-service.php b/projects/plugins/jetpack/modules/sharedaddy/sharing-service.php index ac693dd843f08..b188810580110 100644 --- a/projects/plugins/jetpack/modules/sharedaddy/sharing-service.php +++ b/projects/plugins/jetpack/modules/sharedaddy/sharing-service.php @@ -960,6 +960,11 @@ function sharing_display( $text = '', $echo = false ) { return $text; } + // We require the post to not be empty and be an actual WordPress post object. If it's not - we just return. + if ( empty( $post ) || ! $post instanceof \WP_Post ) { + return $text; + } + if ( empty( $post ) ) { return $text; } @@ -1046,11 +1051,6 @@ function_exists( '\Activitypub\is_activitypub_request' ) */ $show = apply_filters( 'sharing_show', $show, $post ); - // We require the post to remain an object after all filters. If it's not - we just return. - if ( ! is_object( $post ) || ! isset( $post->ID ) ) { - return $text; - } - // Disabled for this post? $switched_status = get_post_meta( $post->ID, 'sharing_disabled', false );