diff --git a/event/main_listener.php b/event/main_listener.php index 07ed675..4e19f2d 100644 --- a/event/main_listener.php +++ b/event/main_listener.php @@ -104,7 +104,6 @@ public function __construct(auth $auth, config $config, db_text $config_text, la */ public function add_custom_sites($event) { - $is_phpbb4 = phpbb_version_compare($this->config['version'], '4.0.0-a1', '>='); $phpbb4_builtins = array_flip([ 'applepodcasts', 'bluesky', 'bunny', 'mastodon', 'pastebin', 'threads', 'twitter', ]); @@ -114,7 +113,7 @@ public function add_custom_sites($event) $name = basename($site, ext::YML); // Skip built-in sites when running phpBB 4 - if ($is_phpbb4 && isset($phpbb4_builtins[$name])) + if ($this->is_phpbb4() && isset($phpbb4_builtins[$name])) { continue; } @@ -178,7 +177,11 @@ public function modify_tag_templates($event) { // force YouTube to use the no cookies until the user starts video playback, and fix referrer policy issues $tag = $event['configurator']->tags['YOUTUBE']; - $tag->template = str_replace(['www.youtube.com', ' allowfullscreen'], ['www.youtube-nocookie.com', ' referrerpolicy="origin" allowfullscreen'], $tag->template); + $tag->template = str_replace(['www.youtube.com'], 'www.youtube-nocookie.com', $tag->template); + if (!$this->is_phpbb4()) + { + $tag->template = str_replace([' allowfullscreen'], ' referrerpolicy="origin" allowfullscreen', $tag->template); + } $event['configurator']->finalize(); } @@ -394,4 +397,12 @@ public function append_agreement() $this->template->append_var('AGREEMENT_TEXT', $this->language->lang('MEDIA_EMBED_PRIVACY_POLICY', $this->config['sitename'])); } + + /** + * @return mixed + */ + private function is_phpbb4() + { + return phpbb_version_compare($this->config['version'], '4.0.0-a1', '>='); + } }