Skip to content

Commit

Permalink
feat: original link filter (#771)
Browse files Browse the repository at this point in the history
* feat: original link filter

* feat: use general filter

* fix: correct array item
  • Loading branch information
NiclasNorin authored Nov 23, 2023
1 parent 744de0a commit 059569b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions library/Controller/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,20 @@ public function __construct()
return (object) array_merge((array) $obj, $lang);
}, 10, 1);

if (!empty($_SERVER['HTTP_HOST'])) {
add_filter("ComponentLibrary/Component/Attribute", function ($attributes) {
if (!empty($attributes['href'])) {
$parsedUrl = parse_url($attributes['href']);

if (!empty($parsedUrl['host']) && $parsedUrl['host'] !== $_SERVER['HTTP_HOST']) {
$attributes['data-js-original-link'] = $attributes['href'];
}
}

return $attributes;
}, 10, 1);
}


//Wordpress hooks
$this->data['hook'] = (object) array(
Expand Down

0 comments on commit 059569b

Please sign in to comment.