Skip to content

Commit deed51e

Browse files
authored
Merge pull request #121 from iMattPro/fixes
Fixes in anticipation of phpBB4 again
2 parents 13250b5 + 79ce9b8 commit deed51e

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

event/main_listener.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ public function __construct(auth $auth, config $config, db_text $config_text, la
104104
*/
105105
public function add_custom_sites($event)
106106
{
107-
$is_phpbb4 = phpbb_version_compare($this->config['version'], '4.0.0-a1', '>=');
108107
$phpbb4_builtins = array_flip([
109108
'applepodcasts', 'bluesky', 'bunny', 'mastodon', 'pastebin', 'threads', 'twitter',
110109
]);
@@ -114,7 +113,7 @@ public function add_custom_sites($event)
114113
$name = basename($site, ext::YML);
115114

116115
// Skip built-in sites when running phpBB 4
117-
if ($is_phpbb4 && isset($phpbb4_builtins[$name]))
116+
if ($this->is_phpbb4() && isset($phpbb4_builtins[$name]))
118117
{
119118
continue;
120119
}
@@ -178,7 +177,11 @@ public function modify_tag_templates($event)
178177
{
179178
// force YouTube to use the no cookies until the user starts video playback, and fix referrer policy issues
180179
$tag = $event['configurator']->tags['YOUTUBE'];
181-
$tag->template = str_replace(['www.youtube.com', ' allowfullscreen'], ['www.youtube-nocookie.com', ' referrerpolicy="origin" allowfullscreen'], $tag->template);
180+
$tag->template = str_replace(['www.youtube.com'], 'www.youtube-nocookie.com', $tag->template);
181+
if (!$this->is_phpbb4())
182+
{
183+
$tag->template = str_replace([' allowfullscreen'], ' referrerpolicy="origin" allowfullscreen', $tag->template);
184+
}
182185

183186
$event['configurator']->finalize();
184187
}
@@ -394,4 +397,12 @@ public function append_agreement()
394397

395398
$this->template->append_var('AGREEMENT_TEXT', $this->language->lang('MEDIA_EMBED_PRIVACY_POLICY', $this->config['sitename']));
396399
}
400+
401+
/**
402+
* @return mixed
403+
*/
404+
private function is_phpbb4()
405+
{
406+
return phpbb_version_compare($this->config['version'], '4.0.0-a1', '>=');
407+
}
397408
}

0 commit comments

Comments
 (0)