Advertisement
phpface

Untitled

Feb 14th, 2023 (edited)
1,361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.22 KB | None | 0 0
  1. /**
  2.  *
  3.  * Filter the player output
  4.  *
  5.  * @param  string $player
  6.  */
  7. function streamtube_child_filter_player_output( $player ){
  8.  
  9.     if( user_clicked_the_consent_button() ){
  10.         // If the user clicked the consent button, then, we return the player
  11.         // And Refreshing the browser is required to show the player
  12.         return $player;
  13.     }
  14.     else{
  15.  
  16.         // Unload all player scripts including YouTube player API.
  17.         wp_dequeue_script( 'videojs' );
  18.         wp_deregister_script( 'videojs-youtube' );
  19.  
  20.         // Otherwise, display a warning message instead of the actual player
  21.         // And nothing sent to YouTube
  22.         ob_start();
  23.         ?>
  24.         <div class="no-permission error-message">
  25.  
  26.             <div class="top-50 start-50 translate-middle position-absolute">
  27.                 <?php
  28.                 esc_html_e( 'You did not click the consent button', 'streamtube-child' );
  29.                 ?>
  30.             </div>
  31.  
  32.         </div>
  33.         <?php
  34.  
  35.         return ob_get_clean();
  36.     }
  37.  
  38. }
  39. add_filter( 'streamtube/player/file/output', 'streamtube_child_filter_player_output', 99999, 1 );
  40. add_filter( 'streamtube/player/embed/output', 'streamtube_child_filter_player_output', 99999, 1 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement