From cbe715b0a5ab0e6a2f3bb28c2cc11747d27e0dd6 Mon Sep 17 00:00:00 2001 From: Mats Mikkel Rummelhoff Date: Fri, 27 Jan 2023 19:29:41 +0100 Subject: [PATCH] Input link types (email, phone, URL, custom) now return their raw URLs for the getText() method. Bump to 2.3.1 --- CHANGELOG.MD | 4 ++++ composer.json | 2 +- src/models/InputLinkType.php | 2 +- src/models/Link.php | 9 +++------ 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 0e99f4a..d82c7c8 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,5 +1,9 @@ # Release Notes for LinkMate +## 2.3.1 - 2023-01-27 +### Changed +- Input link types (email, phone, URL, custom) now return their raw URLs for the `getText()` method + ## 2.3.0 - 2023-01-20 ### Added - Added the "Allow element sources without URLs" setting to entry, categories and asset link types. This setting applies when "All" is selected as the source for these element types. diff --git a/composer.json b/composer.json index 875f329..0f37f4d 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "vaersaagod/linkmate", "description": "Let's hook you up, mate!", "type": "craft-plugin", - "version": "2.3.0", + "version": "2.3.1", "keywords": [ "craft", "cms", diff --git a/src/models/InputLinkType.php b/src/models/InputLinkType.php index 8dd1a97..aa703ab 100644 --- a/src/models/InputLinkType.php +++ b/src/models/InputLinkType.php @@ -207,7 +207,7 @@ public function getSettingsHtml(string $linkTypeName, LinkField $field): string */ public function getText(Link $link): ?string { - return null; + return $this->getRawUrl($link); } /** diff --git a/src/models/Link.php b/src/models/Link.php index 863a60b..835d13d 100644 --- a/src/models/Link.php +++ b/src/models/Link.php @@ -344,13 +344,10 @@ public function getText(): ?string return $this->customText; } - $linkType = $this->getLinkType(); - if (!is_null($linkType)) { - $linkText = $linkType->getText($this); + $linkText = $this->getLinkType()?->getText($this); - if (!is_null($linkText)) { - return $linkText; - } + if (!empty($linkText)) { + return $linkText; } return Craft::t('site', $this->getDefaultText());