Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function is_allowed_referer() {
- $self = parse_url( home_url('/') );
- $search_engine_terms = [ 'google', 'bing', 'yahoo', 'ask', 'duckduckgo', 'ecosia', $self['host'] ];
- $referer_url = $_SERVER['HTTP_REFERER'];
- $referer_host = parse_url( $referer_url, PHP_URL_HOST );
- foreach ( $search_engine_terms as $term ) {
- if( strpos( $term , $referer_host ) !== false ){
- return true;
- }
- }
- return false;
- }
- /**
- *
- * Block embedding from other websites
- *
- */
- add_filter( 'streamtube/player/file/output', function( $player, $setup, $source ){
- if( is_embed() ){
- if( ! is_allowed_referer() ){
- $player = '';
- }
- }
- return $player;
- }, 999, 3 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement