Skip to content

Commit

Permalink
fixed youtube channel ad issue
Browse files Browse the repository at this point in the history
  • Loading branch information
akashmdiu committed Dec 10, 2023
1 parent 7d22dc9 commit 17eda4b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
7 changes: 6 additions & 1 deletion EmbedPress/Includes/Classes/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -797,8 +797,13 @@ public static function generateAdTemplate($client_id, $attributes, $editor = 'el

$showSkipButton = true;

$isYTChannelClass = '';
if(self::is_youtube_channel($attributes['url'])){
$isYTChannelClass = ' ep-youtube-channel';
}

?>
<div class="main-ad-template <?php echo esc_attr($adSource); ?>" id="<?php echo esc_attr('ad-' . $client_id); ?>" style="display:none">
<div class="main-ad-template <?php echo esc_attr($adSource); echo esc_attr($isYTChannelClass); ?>" id="<?php echo esc_attr('ad-' . $client_id); ?>" style="display:none">
<div class="ep-ad-container">
<div class="ep-ad-content" style="position: relative;">
<?php if (!empty($adUrl)) : ?> <a target="_blank" href="<?php echo esc_url($adUrl); ?>"> <?php endif; ?>
Expand Down
2 changes: 0 additions & 2 deletions Gutenberg/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -774,12 +774,10 @@ function embedpress_pdf_render_block($attributes)

$embed_code = '<iframe title="' . esc_attr(Helper::get_file_title($attributes['href'])) . '" class="embedpress-embed-document-pdf ' . esc_attr($id) . '" style="' . esc_attr($dimension) . '; max-width:100%; display: inline-block" src="' . esc_attr($src) . '" frameborder="0" oncontextmenu="return false;"></iframe> ';


if ($powered_by) {
$embed_code .= sprintf('<p class="embedpress-el-powered">%s</p>', __('Powered By EmbedPress', 'embedpress'));
}


$url = !empty($attributes['href']) ? $attributes['href'] : '';

$adsAtts = '';
Expand Down
14 changes: 10 additions & 4 deletions assets/js/ads.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const adInitialization = (adContainer, index) => {
const srcUrl = adAtts.url || adAtts.embedpress_embeded_link;
const adSkipButtonAfter = parseInt(adAtts.adSkipButtonAfter);


addWrapperForYoutube(adContainer, srcUrl, adAtts);

// let adVideo = adContainer.querySelector('#ad-' + blockId + ' .ep-ad');
Expand Down Expand Up @@ -224,9 +224,15 @@ window.onload = function () {
clearInterval(yVideos);

youtubeVideos.forEach((yVideo, index) => {
const srcUrl = yVideo.querySelector('iframe').getAttribute('src');
const adVideo = yVideo.closest('.ad-mask').querySelector('.ep-ad');
onYouTubeIframeAPIReady(yVideo, srcUrl, adVideo, index);
const srcUrl = yVideo.querySelector('iframe')?.getAttribute('src');
const adVideo = yVideo.closest('.ad-mask')?.querySelector('.ep-ad');
const isYTChannel = yVideo.closest('.ad-mask')?.querySelector('.ep-youtube-channel');
if(adVideo && !isYTChannel){

console.log(isYTChannel);

onYouTubeIframeAPIReady(yVideo, srcUrl, adVideo, index);
}
});
}
}, 100);
Expand Down
2 changes: 1 addition & 1 deletion vendor/wpdevelopers/embera/src/Embera/Provider/Youtube.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function getFakeResponse()

return [
'type' => 'video',
'provider_name' => 'Youtube',
'provider_name' => 'Youtube Channel',
'provider_url' => 'https://www.youtube.com',
'title' => 'Unknown title',
'html' => '<iframe ' . implode(' ', $attr). '></iframe>',
Expand Down

0 comments on commit 17eda4b

Please sign in to comment.