PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.7
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.7
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 13.7.2 13.8.3 All 506 releases
← All changes | modules/videopress/class.videopress-player.php +36 -27 16.2 → 16.3-a.7 View file →
@@ -1,5 +1,6 @@
1 1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 +use Automattic\Jetpack\VideoPress\Inline_Player;
2 3 use Automattic\Jetpack\VideoPress\Jwt_Token_Bridge;
3 4
4 5 if ( ! defined( 'ABSPATH' ) ) {
5 6 exit( 0 );
@@ -634,22 +635,10 @@
634 635 // Must not use iframes for IE11 due to a fullscreen bug
635 636 if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && stristr( sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ), 'Trident/7.0; rv:11.0' ) ) {
636 637 $iframe_embed = false;
637 638 } else {
638 -
639 - /**
640 - * Filter the VideoPress iframe embed
641 - *
642 - * This filter allows you to control whether the videos will be embedded using an iframe.
643 - * Set this to false in order to use an in-page embed rather than an iframe.
644 - *
645 - * @module videopress
646 - *
647 - * @since 3.7.0
648 - *
649 - * @param boolean $videopress_player_use_iframe
650 - */
651 - $iframe_embed = apply_filters( 'jetpack_videopress_player_use_iframe', true );
639 + // The site setting and the `jetpack_videopress_player_use_iframe` filter decide; see Inline_Player::is_enabled().
640 + $iframe_embed = ! Inline_Player::is_enabled();
652 641 }
653 642
654 643 if ( ! array_key_exists( 'hd', $this->options ) ) {
655 644 $this->options['hd'] = (bool) get_option( 'video_player_high_quality', false );
@@ -725,23 +714,43 @@
725 714 . $cover
726 715 . " allow='clipboard-write; presentation'></iframe>";
727 716
728 717 } else {
729 - $videopress_options = wp_json_encode( $videopress_options, JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP );
730 - $js_url = 'https://s0.wp.com/wp-content/plugins/video/assets/js/videojs/videopress.js';
731 - $css_url = 'https://s0.wp.com/wp-content/plugins/video/assets/js/videojs/videopress.css';
732 - $guid_js = wp_json_encode( (string) $this->video->guid, JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP );
733 - $selector_js = wp_json_encode( '#' . $video_container_id, JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP );
718 + $attributes = array(
719 + 'autoplay' => $videopress_options['autoPlay'] ?? false,
720 + 'controls' => $videopress_options['controls'] ?? true,
721 + 'loop' => $videopress_options['loop'] ?? false,
722 + 'muted' => $videopress_options['muted'] ?? false,
723 + 'playsinline' => $videopress_options['playsinline'] ?? false,
724 + 'useAverageColor' => $videopress_options['useAverageColor'] ?? true,
725 + 'cover' => $videopress_options['cover'],
726 + 'hd' => $videopress_options['hd'],
727 + 'at' => $videopress_options['at'] ?? 0,
728 + 'preload' => $videopress_options['preloadContent'] ?? 'metadata',
729 + 'defaultLangCode' => $videopress_options['defaultLangCode'] ?? '',
730 + );
731 + $ratio = $videopress_options['width'] > 0
732 + ? ( $videopress_options['height'] / $videopress_options['width'] ) * 100
733 + : null;
734 734
735 - // Without the player styles the <video> renders at its native size and overflows the page.
736 - wp_enqueue_style( 'videopress-videojs', $css_url, array(), JETPACK__VERSION );
737 - wp_enqueue_script( 'videopress-videojs', $js_url, array(), JETPACK__VERSION, true );
738 - wp_add_inline_script(
739 - 'videopress-videojs',
740 - "videopress({$guid_js}, document.querySelector({$selector_js}), {$videopress_options});"
741 - );
735 + $guid = (string) $this->video->guid;
742 736
743 - return "<div id='" . esc_attr( $video_container_id ) . "'></div>";
737 + // The video data already carries the poster frame VideoPress serves for this site.
738 + $poster = ! empty( $this->video->poster_frame_uri ) && is_string( $this->video->poster_frame_uri )
739 + ? $this->video->poster_frame_uri
740 + : Inline_Player::get_poster_url( $guid );
741 +
742 + return "<div id='" . esc_attr( $video_container_id ) . "'>"
743 + . Inline_Player::render(
744 + $guid,
745 + Inline_Player::get_player_options( $attributes ),
746 + $ratio,
747 + array(
748 + 'poster' => $poster,
749 + 'title' => isset( $this->video->title ) ? (string) $this->video->title : '',
750 + )
751 + )
752 + . '</div>';
744 753 }
745 754 }
746 755
747 756 /**