From 1e13890ef7cd5d782e4c6d4a4186b9745ae3f5a2 Mon Sep 17 00:00:00 2001 From: Igor Zinovyev Date: Fri, 7 Feb 2025 15:04:50 +0300 Subject: [PATCH] Moved the check upwards and changed it to instance detection, h/t @jeherve. --- .../jetpack/modules/sharedaddy/sharing-service.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 );