some more hooks

This commit is contained in:
Andrew Dolgov 2021-02-08 20:45:11 +03:00
parent ca4c93c6b9
commit 54bbd08f38
1 changed files with 21 additions and 15 deletions

View File

@ -352,16 +352,16 @@ class Article extends Handler_Protected {
$result = self::get_article_enclosures($id); $result = self::get_article_enclosures($id);
$rv = ''; $rv = '';
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FORMAT_ENCLOSURES) as $plugin) { PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_FORMAT_ENCLOSURES,
$retval = $plugin->hook_format_enclosures($rv, $result, $id, $always_display_enclosures, $article_content, $hide_images); function ($result) use (&$rv) {
if (is_array($retval)) { if (is_array($result)) {
$rv = $retval[0]; $rv = $result[0];
$result = $retval[1]; $result = $result[1];
} else { } else {
$rv = $retval; $rv = $result;
} }
} },
unset($retval); // Unset to prevent breaking render if there are no HOOK_RENDER_ENCLOSURE hooks below. $rv, $result, $id, $always_display_enclosures, $article_content, $hide_images);
if ($rv === '' && !empty($result)) { if ($rv === '' && !empty($result)) {
$entries_html = array(); $entries_html = array();
@ -370,9 +370,11 @@ class Article extends Handler_Protected {
foreach ($result as $line) { foreach ($result as $line) {
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ENCLOSURE_ENTRY) as $plugin) { PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_ENCLOSURE_ENTRY,
$line = $plugin->hook_enclosure_entry($line, $id); function($result) use (&$line) {
} $line = $result;
},
$line, $id);
$url = $line["content_url"]; $url = $line["content_url"];
$ctype = $line["content_type"]; $ctype = $line["content_type"];
@ -415,9 +417,13 @@ class Article extends Handler_Protected {
foreach ($entries as $entry) { foreach ($entries as $entry) {
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ENCLOSURE) as $plugin) $retval = null;
$retval = $plugin->hook_render_enclosure($entry, $hide_images);
PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_RENDER_ENCLOSURE,
function($result) use (&$retval) {
$retval = $result;
},
$entry, $hide_images);
if (!empty($retval)) { if (!empty($retval)) {
$rv .= $retval; $rv .= $retval;