Skip to content
Open
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Update taghandlers.php
  • Loading branch information
bloatware authored Oct 25, 2016
commit 62e8be2dfb4eebae8947192a06a76ffd322d9359
12 changes: 10 additions & 2 deletions textpattern/publish/taghandlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ function recent_comments($atts, $thing = null)
function related_articles($atts, $thing = null)
{
global $thisarticle, $prefs;
static $fields = null;

assert_article();

Expand All @@ -1113,7 +1114,12 @@ function related_articles($atts, $thing = null)
'wraptag' => '',
), $atts);

$match = array_intersect(do_list_unique(strtolower($atts['match'])), array_merge(array('category1', 'category2', 'author', 'keywords'), getCustomFields()));
if (!isset($fields)) {
$fields = array_merge(array('category1', 'category2', 'author', 'keywords'), getCustomFields());
}

$match = do_list_unique(strtolower($atts['match']));
$matches = array_intersect($match, $fields);
$categories = $cats = array();

foreach ($match as $cf) {
Expand All @@ -1130,6 +1136,8 @@ function related_articles($atts, $thing = null)
$atts['author'] = $thisarticle['authorid'];
break;
default:
$cf = strtok($cf, '[');

if (empty($thisarticle[$cf])) {
return;
}
Expand All @@ -1145,7 +1153,7 @@ function related_articles($atts, $thing = null)
return;
}

$atts['match'] = implode(',', $categories);
$atts['match'] = implode(',', array_merge(array_diff($match, $fields), $categories));
$atts['exclude'] = $thisarticle['thisid'];

if ($atts['form'] === '' && $thing === null) {
Expand Down