Created
November 14, 2019 16:45
-
-
Save wpmudev-sls/fc6ca3cb7424d5038a799d84459e8f5c to your computer and use it in GitHub Desktop.
[Hustle Pro] - Stop custom video/audio after close the popup/slidein
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: [Hustle Pro] - Stop custom video/audio after close the popup/slidein | |
* Description: [Hustle Pro] - Stop custom video/audio after close the popup/slidein - 1149293365661594 | |
* Author: Thobk @ WPMUDEV | |
* Author URI: https://premium.wpmudev.org | |
* License: GPLv2 or later | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
add_action( 'plugins_loaded', 'wpmudev_hustle_stop_video_audio_after_close_popup_func', 100 ); | |
function wpmudev_hustle_stop_video_audio_after_close_popup_func() { | |
if( defined('HUSTLE_SUI_VERSION') && class_exists( 'Hustle_Module_Collection' ) ){ | |
add_action( 'wp_footer', 'wpmudev_hustle_stop_video_audio_after_close_popup', 21 ); | |
function wpmudev_hustle_stop_video_audio_after_close_popup(){ | |
$custom_script = '<script> | |
(function($){ | |
$(function(){ | |
if( window.HUI ){ | |
var _slide_ins = $(".hustle-slidein"), | |
_popups = $(".hustle-popup"); | |
if( _slide_ins.length ){ | |
_slide_ins.on("hustle:module:hidden", function(){ | |
close_video_audio( $(this) ); | |
}); | |
} | |
if( _popups.length ){ | |
_popups.on("hustle:module:closed", function(){ | |
close_video_audio( $(this) ); | |
}); | |
} | |
function close_video_audio( _element ){ | |
var _audios = _element.find("audio"); | |
if( _audios.length ){ | |
_audios.each( function(){ | |
this.player.pause(); | |
}); | |
} | |
var _videos = _element.find("video"); | |
if( _videos.length ){ | |
_videos.each( function(){ | |
this.player.pause(); | |
}); | |
} | |
} | |
} | |
}); | |
})(window.jQuery) | |
</script>'; | |
echo $custom_script; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment