← All changes
|
modules/seo-tools/class-jetpack-seo-posts.php
+12
-2
16.2-beta
→
16.3-a.5
View file →
| @@ -43,9 +43,10 @@ | ||
| 43 | 43 | if ( ! ( $post instanceof WP_Post ) ) { |
| 44 | 44 | return ''; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if ( post_password_required() || ! is_singular() ) { | |
| 47 | + // Check the post being described, not the global one. | |
| 48 | + if ( post_password_required( $post ) || ! is_singular() ) { | |
| 48 | 49 | return ''; |
| 49 | 50 | } |
| 50 | 51 | |
| 51 | 52 | // Business users can overwrite the description. |
| @@ -58,10 +59,19 @@ | ||
| 58 | 59 | if ( ! empty( $post->post_excerpt ) ) { |
| 59 | 60 | return $post->post_excerpt; |
| 60 | 61 | } |
| 61 | 62 | |
| 63 | + // The fall-through reads raw post_content, which never passes the `the_content` paywall. | |
| 64 | + $content = $post->post_content; | |
| 65 | + if ( \Automattic\Jetpack\SEO\Content_Gate::is_gated( $post ) ) { | |
| 66 | + $content = \Automattic\Jetpack\SEO\Content_Gate::public_teaser( $post ); | |
| 67 | + if ( '' === $content ) { | |
| 68 | + return ''; | |
| 69 | + } | |
| 70 | + } | |
| 71 | + | |
| 62 | 72 | // Remove content within wp:query blocks and return. |
| 63 | - return Jetpack_SEO_Utils::remove_query_blocks( $post->post_content ); | |
| 73 | + return Jetpack_SEO_Utils::remove_query_blocks( $content ); | |
| 64 | 74 | } |
| 65 | 75 | |
| 66 | 76 | /** |
| 67 | 77 | * Returns post's custom meta description if it is set, and if |