PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 All 504 releases
← All changes | 3rd-party/class.jetpack-amp-support.php +21 -32 12.5.2 → 16.3-a.1 View file →
@@ -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 /**
@@ -23,14 +24,8 @@
23 24 ) {
24 25 add_action( 'amp_post_template_footer', array( 'Jetpack_AMP_Support', 'add_stats_pixel' ) );
25 26 }
26 27
27 - /**
28 - * Remove this during the init hook in case users have enabled it during
29 - * the after_setup_theme hook, which triggers before init.
30 - */
31 - remove_theme_support( 'jetpack-devicepx' );
32 -
33 28 // Sharing.
34 29 add_filter( 'jetpack_sharing_display_markup', array( 'Jetpack_AMP_Support', 'render_sharing_html' ), 10, 2 );
35 30 add_filter( 'sharing_enqueue_scripts', array( 'Jetpack_AMP_Support', 'amp_disable_sharedaddy_css' ) );
36 31 add_action( 'wp_enqueue_scripts', array( 'Jetpack_AMP_Support', 'amp_enqueue_sharing_css' ) );
@@ -55,11 +50,8 @@
55 50
56 51 // Transitional mode AMP should not have comment likes.
57 52 add_filter( 'the_content', array( 'Jetpack_AMP_Support', 'disable_comment_likes_before_the_content' ) );
58 53
59 - // Remove the Likes button from the admin bar.
60 - add_filter( 'jetpack_admin_bar_likes_enabled', array( 'Jetpack_AMP_Support', 'disable_likes_admin_bar' ) );
61 -
62 54 // Add post template metadata for legacy AMP.
63 55 add_filter( 'amp_post_template_metadata', array( 'Jetpack_AMP_Support', 'amp_post_template_metadata' ), 10, 2 );
64 56
65 57 // Filter photon image args for AMP Stories.
@@ -154,26 +146,14 @@
154 146 * @param string $content Post content.
155 147 */
156 148 public static function disable_comment_likes_before_the_content( $content ) {
157 149 if ( self::is_amp_request() ) {
158 - remove_filter( 'comment_text', 'comment_like_button', 12, 2 );
150 + remove_filter( 'comment_text', 'comment_like_button', 12 );
159 151 }
160 152 return $content;
161 153 }
162 154
163 155 /**
164 - * Do not display the Likes' Admin bar on AMP requests.
165 - *
166 - * @param bool $is_admin_bar_button_visible Should the Like button be visible in the Admin bar. Default to true.
167 - */
168 - public static function disable_likes_admin_bar( $is_admin_bar_button_visible ) {
169 - if ( self::is_amp_request() ) {
170 - return false;
171 - }
172 - return $is_admin_bar_button_visible;
173 - }
174 -
175 - /**
176 156 * Add Jetpack stats pixel.
177 157 *
178 158 * @since 6.2.1
179 159 */
@@ -248,19 +228,28 @@
248 228 * @param WP_Post $post Post.
249 229 * @return array Metadata.
250 230 */
251 231 private static function add_image_to_metadata( $metadata, $post ) {
252 - $image = Jetpack_PostImages::get_image(
253 - $post->ID,
254 - array(
255 - 'fallback_to_avatars' => true,
256 - 'avatar_size' => 200,
257 - // AMP already attempts these.
258 - 'from_thumbnail' => false,
259 - 'from_attachment' => false,
260 - )
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,
261 238 );
262 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 );
251 +
263 252 if ( empty( $image ) ) {
264 253 return self::add_fallback_image_to_metadata( $metadata );
265 254 }
266 255
@@ -499,9 +488,9 @@
499 488 return $args;
500 489 }
501 490
502 491 // Percentage-based dimensions are not allowed in AMP, so this shouldn't happen, but short-circuit just in case.
503 - if ( false !== strpos( $details['width_orig'], '%' ) || false !== strpos( $details['height_orig'], '%' ) ) {
492 + if ( str_contains( $details['width_orig'], '%' ) || str_contains( $details['height_orig'], '%' ) ) {
504 493 return $args;
505 494 }
506 495
507 496 $max_height = 1280; // See image size with the slug \AMP_Story_Post_Type::MAX_IMAGE_SIZE_SLUG.