| @@ -1,7 +1,8 @@ | ||
| 1 | 1 | <?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | 2 | |
| 3 | 3 | use Automattic\Jetpack\Assets; |
| 4 | +use Automattic\Jetpack\Post_Media\Images; | |
| 4 | 5 | use Automattic\Jetpack\Stats\Tracking_Pixel as Stats_Tracking_Pixel; |
| 5 | 6 | use Automattic\Jetpack\Sync\Functions; |
| 6 | 7 | |
| 7 | 8 | /** |
| @@ -145,9 +146,9 @@ | ||
| 145 | 146 | * @param string $content Post content. |
| 146 | 147 | */ |
| 147 | 148 | public static function disable_comment_likes_before_the_content( $content ) { |
| 148 | 149 | if ( self::is_amp_request() ) { |
| 149 | - remove_filter( 'comment_text', 'comment_like_button', 12, 2 ); | |
| 150 | + remove_filter( 'comment_text', 'comment_like_button', 12 ); | |
| 150 | 151 | } |
| 151 | 152 | return $content; |
| 152 | 153 | } |
| 153 | 154 | |
| @@ -227,18 +228,27 @@ | ||
| 227 | 228 | * @param WP_Post $post Post. |
| 228 | 229 | * @return array Metadata. |
| 229 | 230 | */ |
| 230 | 231 | private static function add_image_to_metadata( $metadata, $post ) { |
| 231 | - $image = Jetpack_PostImages::get_image( | |
| 232 | - $post->ID, | |
| 233 | - array( | |
| 234 | - 'fallback_to_avatars' => true, | |
| 235 | - 'avatar_size' => 200, | |
| 236 | - // AMP already attempts these. | |
| 237 | - 'from_thumbnail' => false, | |
| 238 | - 'from_attachment' => false, | |
| 239 | - ) | |
| 232 | + $image_args = array( | |
| 233 | + 'fallback_to_avatars' => true, | |
| 234 | + 'avatar_size' => 200, | |
| 235 | + // AMP already attempts these. | |
| 236 | + 'from_thumbnail' => false, | |
| 237 | + 'from_attachment' => false, | |
| 240 | 238 | ); |
| 239 | + | |
| 240 | + // Every source left enabled above is parsed out of the body. | |
| 241 | + if ( \Automattic\Jetpack\SEO\Content_Gate::is_gated( $post ) ) { | |
| 242 | + $image_args += array( | |
| 243 | + 'from_slideshow' => false, | |
| 244 | + 'from_gallery' => false, | |
| 245 | + 'from_blocks' => false, | |
| 246 | + 'from_html' => false, | |
| 247 | + ); | |
| 248 | + } | |
| 249 | + | |
| 250 | + $image = Images::get_image( $post->ID, $image_args ); | |
| 241 | 251 | |
| 242 | 252 | if ( empty( $image ) ) { |
| 243 | 253 | return self::add_fallback_image_to_metadata( $metadata ); |
| 244 | 254 | } |