| @@ -109,16 +109,23 @@ | ||
| 109 | 109 | * |
| 110 | 110 | * @return string |
| 111 | 111 | */ |
| 112 | 112 | protected static function get_permalink_for_gated_item( $post_id ) { |
| 113 | + /** | |
| 114 | + * @var WP_Post|null $post | |
| 115 | + */ | |
| 113 | 116 | $post = get_post( $post_id ); |
| 114 | 117 | |
| 115 | - if ( $post && 'private' === $post->post_status ) { | |
| 118 | + if ( ! $post instanceof WP_Post ) { | |
| 119 | + return ''; | |
| 120 | + } | |
| 121 | + | |
| 122 | + if ( 'private' === $post->post_status ) { | |
| 116 | 123 | $post = clone $post; |
| 117 | 124 | $post->post_status = 'publish'; |
| 118 | 125 | } |
| 119 | 126 | |
| 120 | - return (string) get_permalink( $post ); | |
| 127 | + return get_permalink( $post ); | |
| 121 | 128 | } |
| 122 | 129 | |
| 123 | 130 | /** |
| 124 | 131 | * Return the display title for this item. |