Skip to content

Commit

Permalink
Update RelatedContentPlugin.php
Browse files Browse the repository at this point in the history
  • Loading branch information
DBinaghi authored Jul 27, 2021
1 parent 4bd9bbe commit b5e587d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions RelatedContentPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ public function hookPublicItemsShow($args)
$element = self::findElementById($key);
if ($metadata = metadata($item, array($element->set_name, $element->name), array('all' => true, 'no_filter' => true))) {
//shorten date, if required
if (isset($value['isDate']) && (bool)$value['isDate'] && (bool)get_option('related_content_short_date')) $metadata = substr($metadata, 0, 4);
if (isset($value['isDate']) && (bool)$value['isDate'] && (bool)get_option('related_content_short_date')) {
$metadata = substr($metadata, 0, 4);
}

// retrieve results
$results_element = self::getResultsByElement($key, $metadata, $weight);
Expand All @@ -194,7 +196,9 @@ public function hookPublicItemsShow($args)
$results_tags = self::countAndMultiply($results_tags, $weight);

// filter constraints array if needed
if (isset($criteria['tags']['constraint']) && (bool)$criteria['tags']['constraint']) $constraints = self::updateConstraints($constraints, array_keys($results_tags));
if (isset($criteria['tags']['constraint']) && (bool)$criteria['tags']['constraint']) {
$constraints = self::updateConstraints($constraints, array_keys($results_tags));
}

// adds values to $results
$results = self::addAndMergeArrays($results, $results_tags);
Expand All @@ -206,7 +210,9 @@ public function hookPublicItemsShow($args)
$results_collection = self::getResultsByCollection($collection, $weight);

// filter constraints array if needed
if (isset($criteria['collection']['constraint']) && (bool)$criteria['collection']['constraint']) $constraints = self::updateConstraints($constraints, array_keys($results_collection));
if (isset($criteria['collection']['constraint']) && (bool)$criteria['collection']['constraint']) {
$constraints = self::updateConstraints($constraints, array_keys($results_collection));
}

// adds values to $results
$results = self::addAndMergeArrays($results, $results_collection);
Expand All @@ -218,7 +224,9 @@ public function hookPublicItemsShow($args)
$results_item_type = self::getResultsByItemType($itemTypeID, $weight);

// filter constraints array if needed
if (isset($criteria['item type']['constraint']) && (bool)$criteria['item type']['constraint']) $constraints = self::updateConstraints($constraints, array_keys($results_item_type));
if (isset($criteria['item type']['constraint']) && (bool)$criteria['item type']['constraint']) {
$constraints = self::updateConstraints($constraints, array_keys($results_item_type));
}

// adds values to $results
$results = self::addAndMergeArrays($results, $results_item_type);
Expand Down

0 comments on commit b5e587d

Please sign in to comment.