Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "phpbb-extension",
"description": "An official phpBB extension that allows users to embed content from allowed sites using a [media] BBCode, or from simply posting a supported URL in plain text.",
"homepage": "https://www.phpbb.com/customise/db/extension/mediaembed/",
"version": "2.0.4",
"version": "2.0.5-dev",
"license": "GPL-2.0-only",
"authors": [
{
Expand Down
26 changes: 21 additions & 5 deletions event/main_listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class main_listener implements EventSubscriberInterface
/** @var bool Disable the media tag (bbcode parsing) */
protected $disable_tag = false;

/** @var bool|null Cached result of is_phpbb4() */
protected $is_phpbb4;

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -105,15 +108,23 @@ public function __construct(auth $auth, config $config, db_text $config_text, la
public function add_custom_sites($event)
{
$phpbb4_builtins = array_flip([
'applepodcasts', 'bluesky', 'bunny', 'mastodon', 'pastebin', 'threads', 'twitter',
'applepodcasts',
'bluesky',
'bunny',
'facebook',
'mastodon',
'pastebin',
'threads',
'twitter',
'vk',
]);

foreach ($this->custom_sites->get_collection() as $site)
{
$name = basename($site, ext::YML);

// Skip built-in sites when running phpBB 4
if ($this->is_phpbb4() && isset($phpbb4_builtins[$name]))
if (isset($phpbb4_builtins[$name]) && $this->is_phpbb4())
Comment thread
iMattPro marked this conversation as resolved.
{
continue;
}
Expand Down Expand Up @@ -177,10 +188,10 @@ 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'], 'www.youtube-nocookie.com', $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);
$tag->template = str_replace(' allowfullscreen', ' referrerpolicy="origin" allowfullscreen', $tag->template);
}

$event['configurator']->finalize();
Expand Down Expand Up @@ -403,6 +414,11 @@ public function append_agreement()
*/
private function is_phpbb4()
{
return phpbb_version_compare($this->config['version'], '4.0.0-a1', '>=');
if ($this->is_phpbb4 === null)
{
$this->is_phpbb4 = phpbb_version_compare($this->config['version'], '4.0.0-a1', '>=');
}

return $this->is_phpbb4;
}
}
Loading