diff --git a/src/api/wishes.php b/src/api/wishes.php index 33706385..9304493c 100644 --- a/src/api/wishes.php +++ b/src/api/wishes.php @@ -142,11 +142,11 @@ switch ($_SERVER['REQUEST_METHOD']) { } /** Update */ - $wish_title = empty($wish_title) ? null : substr($wish_title, 0, 128); - $wish_description = empty($wish_description) ? null : $wish_description ; - $wish_image = empty($wish_image) || Wish::NO_IMAGE === $wish_image ? null : $wish_image ; - $wish_url = empty($wish_url) ? null : $wish_url ; - $wish_priority = empty($wish_priority) ? null : $wish_priority ; + $wish_title = empty($wish_title) ? null : substr($wish_title, 0, 128) ; + $wish_description = empty($wish_description) ? null : $wish_description ; + $wish_image = empty($wish_image) || Wish::NO_IMAGE === $wish_image ? null : $wish_image ; + $wish_url = empty($wish_url) ? null : Wish::getAffiliateLink($wish_url); + $wish_priority = empty($wish_priority) ? null : $wish_priority ; $database ->query( @@ -229,10 +229,10 @@ switch ($_SERVER['REQUEST_METHOD']) { } /** Update */ - $wish_title = empty($wish_title) ? null : substr($wish_title, 0, 128); - $wish_description = empty($wish_description) ? null : $wish_description ; - $wish_image = empty($wish_image) || Wish::NO_IMAGE === $wish_image ? null : $wish_image ; - $wish_url = empty($wish_url) ? null : $wish_url ; + $wish_title = empty($wish_title) ? null : substr($wish_title, 0, 128) ; + $wish_description = empty($wish_description) ? null : $wish_description ; + $wish_image = empty($wish_image) || Wish::NO_IMAGE === $wish_image ? null : $wish_image ; + $wish_url = empty($wish_url) ? null : Wish::getAffiliateLink($wish_url); $database ->query( diff --git a/src/assets/css/home.css b/src/assets/css/home.css index d9ed5ef6..cb2505d3 100644 --- a/src/assets/css/home.css +++ b/src/assets/css/home.css @@ -39,6 +39,7 @@ --gap: 0.5rem; gap: var(--gap); + margin-bottom: 1em; } .flex.why-wishthis > ul { flex: 0 0 calc(50% - var(--gap) / 2); diff --git a/src/classes/wishthis/Wish.php b/src/classes/wishthis/Wish.php index 5bd852bb..d942fe9b 100644 --- a/src/classes/wishthis/Wish.php +++ b/src/classes/wishthis/Wish.php @@ -68,6 +68,25 @@ class Wish return $wish; } + public static function getAffiliateLink(string $url): string + { + $urlParts = parse_url($url); + + if (isset($urlParts['query'])) { + \parse_str($urlParts['query'], $urlParameters); + } else { + $urlParameters = array(); + } + + if (\str_contains($urlParts['host'], 'amazon')) { + $urlParameters['tag'] = 'grandel-21'; + $urlParts['query'] = \http_build_query($urlParameters); + $url = $urlParts['scheme'] . '://' . $urlParts['host'] . $urlParts['path'] . '?' . $urlParts['query']; + } + + return $url; + } + /** * Non-Static */ diff --git a/src/pages/changelog.php b/src/pages/changelog.php index 793fab60..0caa3dad 100644 --- a/src/pages/changelog.php +++ b/src/pages/changelog.php @@ -124,6 +124,12 @@ $page->navigation(); echo __('After creating an account your language is automatically set to your browser\'s (if it is available), instead of defaulting to en_GB.'); ?> +
  • + +
  • diff --git a/src/pages/home.php b/src/pages/home.php index 2964cd09..f228fd6c 100644 --- a/src/pages/home.php +++ b/src/pages/home.php @@ -105,7 +105,7 @@ $user = User::getCurrent(); '' ) ?>

    -

    +

    +

    diff --git a/src/pages/register.php b/src/pages/register.php index de14b1a6..b221df52 100644 --- a/src/pages/register.php +++ b/src/pages/register.php @@ -301,7 +301,7 @@ $page->navigation();

    -

    +