Skip to content

Commit

Permalink
Spotify support
Browse files Browse the repository at this point in the history
  • Loading branch information
tvalimaa committed May 9, 2023
1 parent f1abba3 commit 2ab2784
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Plugin/Filter/IframeCookieConsent.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function process($text, $langcode) {
$html5 = new HTML5();
libxml_use_internal_errors(true);
$dom = $html5->loadHTML(mb_convert_encoding($text, 'HTML-ENTITIES', 'UTF-8'));
// Youtube regex pattern.
$regex_pattern = "/(youtube.com|youtu.be)\/(embed)?(\?v=)?(\S+)?/";
// Spotify & Youtube regex pattern.
$regex_pattern = "/(open.spotify.com|youtube.com|youtu.be)\/(embed)?(\?v=)?(\S+)?/";
$match = NULL;

// Loop all content iframes.
Expand Down Expand Up @@ -59,7 +59,7 @@ public function process($text, $langcode) {
$optout->setAttribute('class', 'cookieconsent-optout-' . $consent_cat);
// Use a helper to create string including html.
$helper = new \DOMDocument();
$helper->loadHTML($this->t('Please <a href="javascript:Cookiebot.renew()">accept marketing-cookies</a> to watch this video.'));
$helper->loadHTML($this->t('Please <a href="javascript:Cookiebot.renew()">accept marketing-cookies</a> to watch this content.'));
// Put optout html string inside optout div.
$optout->appendChild($dom->importNode($helper->documentElement, TRUE));
// Insert optin element before iframe.
Expand Down

0 comments on commit 2ab2784

Please sign in to comment.