Advertisement
Guest User

mike

a guest
Dec 6th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.36 KB | None | 0 0
  1. function materialis_print_header_video()
  2. {
  3.  
  4.     add_filter('oembed_fetch_url', 'materialis_oembed_autoplay_loop_args', 10, 3);
  5.     add_filter('oembed_result', 'materialis_add_autoplay_loop_to_oembed', 10, 3);
  6.  
  7.     $video = materialis_get_theme_mod('playsinline', 'header_content_video', 'https://www.youtube.com/watch?v=3iXYciBTQ0c');
  8.     $embed = new WP_Embed();
  9.  
  10.     $autoplay = materialis_get_theme_mod('header_content_video_autoplay', '1');
  11.     $mute = materialis_get_theme_mod('header_content_video_mute', '0');
  12.  
  13.     if (materialis_is_customize_preview()) {
  14.         $autoplay = false;
  15.     }
  16.  
  17.     $content = $embed->shortcode(array(
  18.         'src'      => $video,
  19.         'autoplay' => $autoplay,
  20.         'playsinline' => $autoplay,
  21.         'mute'     => $mute,
  22.         'loop'     => materialis_get_theme_mod('header_content_video_loop', '0'),
  23.     ));
  24.  
  25.     $content = preg_replace('/width="\d+"/', "", $content);
  26.     $content = preg_replace('/height="\d+"/', 'class="header-hero-video"', $content);
  27.  
  28.     $class = "";
  29.  
  30.     if (strpos($content, '<iframe') !== false) {
  31.         $class = "iframe-holder ";
  32.     }
  33.  
  34.     remove_filter('oembed_fetch_url', 'materialis_oembed_autoplay_loop_args');
  35.     remove_filter('oembed_result', 'materialis_add_autoplay_loop_to_oembed');
  36.  
  37.  
  38.     echo '<div class="content-video-container ' . $class . '">' . $content . '</div>';
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement