PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3 16.3-beta 16.3-a.5 16.3-a.7 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 All 508 releases
← All changes | modules/carousel/jetpack-carousel.php +2 -45 16.3-a.5 → 16.3-a.1 View file →
@@ -454,9 +454,8 @@
454 454 $swiper_library_path = array(
455 455 'url' => plugins_url( '_inc/blocks/swiper.js', JETPACK__PLUGIN_FILE ),
456 456 );
457 457 wp_localize_script( 'jetpack-carousel', 'jetpackSwiperLibraryPath', $swiper_library_path );
458 - add_action( 'wp_footer', array( $this, 'prefetch_swiper_library' ) );
459 458
460 459 // Note: using home_url() instead of admin_url() for ajaxurl to be sure to get same domain on wpcom when using mapped domains (also works on self-hosted).
461 460 // Also: not hardcoding path since there is no guarantee site is running on site root in self-hosted context.
462 461 $is_logged_in = is_user_logged_in();
@@ -572,24 +571,8 @@
572 571 }
573 572 }
574 573
575 574 /**
576 - * Hint the browser to fetch the Swiper library while it is idle.
577 - *
578 - * Swiper is only requested when the lightbox is first opened, which puts a network
579 - * round trip in front of that first click. This is deliberately `prefetch` rather than
580 - * `preload`: most visitors never open the lightbox, so the fetch must stay at low
581 - * priority and out of the way of the page's own images. `loadSwiper()` still loads the
582 - * library on demand, since a prefetch is a hint the browser is free to ignore.
583 - */
584 - public function prefetch_swiper_library() {
585 - printf(
586 - '<link rel="prefetch" href="%s" as="script" />' . "\n",
587 - esc_url( plugins_url( '_inc/blocks/swiper.js', JETPACK__PLUGIN_FILE ) )
588 - );
589 - }
590 -
591 - /**
592 575 * Generate the HTML skeleton that will be picked up by the Carousel JS and used for showing the carousel.
593 576 */
594 577 public function add_carousel_skeleton() {
595 578 $localize_strings = $this->localize_strings;
@@ -1001,18 +984,8 @@
1001 984 $attr['data-orig-file'] = esc_attr( $orig_file );
1002 985 $attr['data-orig-size'] = $size;
1003 986 $attr['data-comments-opened'] = $comments_opened;
1004 987
1005 - /*
1006 - Lets the Carousel show its "has comments" badge without fetching the comments
1007 - themselves. Omitted when there are none, which is the common case, so galleries
1008 - without comments pay nothing for it.
1009 - */
1010 - $comments_count = (int) $attachment->comment_count;
1011 - if ( $comments_count > 0 ) {
1012 - $attr['data-comments-count'] = $comments_count;
1013 - }
1014 -
1015 988 if ( $display_exif ) {
1016 989 // See https://github.com/Automattic/jetpack/issues/2765.
1017 990 if ( isset( $img_meta['keywords'] ) ) {
1018 991 unset( $img_meta['keywords'] );
@@ -1017,26 +990,10 @@
1017 990 if ( isset( $img_meta['keywords'] ) ) {
1018 991 unset( $img_meta['keywords'] );
1019 992 }
1020 993
1021 - /*
1022 - Filtering on `is_scalar` alone kept every "" and "0" in the metadata array, which
1023 - on a typical photo is most of it. The carousel skips those values when it renders
1024 - the EXIF panel anyway, so serialising them only inflates the page. Mirror that
1025 - check here: drop empties and numeric zeroes, but keep text that merely casts to
1026 - zero, such as a camera name.
1027 - */
1028 - $img_meta = array_filter(
1029 - array_map( 'strval', array_filter( $img_meta, 'is_scalar' ) ),
1030 - function ( $value ) {
1031 - return '' !== $value && ! ( is_numeric( $value ) && 0.0 === (float) $value );
1032 - }
1033 - );
1034 -
1035 - // With nothing left to show, the attribute itself is dead weight.
1036 - if ( ! empty( $img_meta ) ) {
1037 - $attr['data-image-meta'] = esc_attr( wp_json_encode( $img_meta, JSON_UNESCAPED_SLASHES | JSON_HEX_AMP ) );
1038 - }
994 + $img_meta = wp_json_encode( array_map( 'strval', array_filter( $img_meta, 'is_scalar' ) ), JSON_UNESCAPED_SLASHES | JSON_HEX_AMP );
995 + $attr['data-image-meta'] = esc_attr( $img_meta );
1039 996 }
1040 997
1041 998 // The lines below use `esc_attr( htmlspecialchars( ) )` because esc_attr tries to be too smart and won't double-encode, and we need that here.
1042 999 $attr['data-image-title'] = esc_attr( htmlspecialchars( $attachment_title, ENT_COMPAT ) );