Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * Filter the player output
- *
- * @param string $player
- */
- function streamtube_child_filter_player_output( $player ){
- if( user_clicked_the_consent_button() ){
- // If the user clicked the consent button, then, we return the player
- // And Refreshing the browser is required to show the player
- return $player;
- }
- else{
- // Unload all player scripts including YouTube player API.
- wp_dequeue_script( 'videojs' );
- wp_deregister_script( 'videojs-youtube' );
- // Otherwise, display a warning message instead of the actual player
- // And nothing sent to YouTube
- ob_start();
- ?>
- <div class="no-permission error-message">
- <div class="top-50 start-50 translate-middle position-absolute">
- <?php
- esc_html_e( 'You did not click the consent button', 'streamtube-child' );
- ?>
- </div>
- </div>
- <?php
- return ob_get_clean();
- }
- }
- add_filter( 'streamtube/player/file/output', 'streamtube_child_filter_player_output', 99999, 1 );
- add_filter( 'streamtube/player/embed/output', 'streamtube_child_filter_player_output', 99999, 1 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement