Skip to content

Commit

Permalink
Moved the check upwards and changed it to instance detection, h/t @je…
Browse files Browse the repository at this point in the history
  • Loading branch information
zinigor committed Feb 7, 2025
1 parent 7208205 commit 1e13890
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions projects/plugins/jetpack/modules/sharedaddy/sharing-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {

Check failure on line 968 in projects/plugins/jetpack/modules/sharedaddy/sharing-service.php

View workflow job for this annotation

GitHub Actions / Static analysis

TypeError PhanImpossibleCondition Impossible attempt to cast $post of type non-empty-mixed to empty FAQ on Phan issues: pdWQjU-Jb-p2
return $text;
}
Expand Down Expand Up @@ -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 );

Expand Down

0 comments on commit 1e13890

Please sign in to comment.