From 2bb11658a8b032dc345b402de25265befa54608e Mon Sep 17 00:00:00 2001 From: Dave Zaikos Date: Mon, 12 May 2014 00:59:27 -0400 Subject: Added HOOK_FORMAT_ENCLOSURES plugin hook. Runs HTML and enclosures array through a plugin hook when rendering an article's enclosures in format_article_enclosures(). Allows plugins to override handling of how enclosures are presented by either filtering the array of enclosures, or generating the HTML to add to the article content. --- include/functions2.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/functions2.php b/include/functions2.php index 959e7154d..cf1fba17c 100644 --- a/include/functions2.php +++ b/include/functions2.php @@ -1846,8 +1846,17 @@ $result = get_article_enclosures($id); $rv = ''; - if (count($result) > 0) { + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FORMAT_ENCLOSURES) as $plugin) { + $retval = $plugin->hook_format_enclosures($rv, $result, $id, $always_display_enclosures, $article_content, $hide_images); + if (is_array($retval)) { + $rv = $retval[0]; + $result = $retval[1]; + } else { + $rv = $retval; + } + } + if ($rv === '' && is_array($result)) { $entries_html = array(); $entries = array(); $entries_inline = array(); -- cgit v1.2.3 From c6ce584dd56320da336ecbf69d424f0bc05f4f5a Mon Sep 17 00:00:00 2001 From: Dave Zaikos Date: Mon, 12 May 2014 13:54:04 -0400 Subject: Changed how the enclosures array is checked for content so an empty array is not processed. Fixes a change from the previous branch commit. --- include/functions2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/functions2.php b/include/functions2.php index cf1fba17c..5228d875c 100644 --- a/include/functions2.php +++ b/include/functions2.php @@ -1856,7 +1856,7 @@ } } - if ($rv === '' && is_array($result)) { + if ($rv === '' && !empty($result)) { $entries_html = array(); $entries = array(); $entries_inline = array(); -- cgit v1.2.3