feat: add affiliate links
This commit is contained in:
parent
15bf22ba80
commit
a4f70b3e05
6 changed files with 38 additions and 11 deletions
|
@ -142,11 +142,11 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Update */
|
/** Update */
|
||||||
$wish_title = empty($wish_title) ? null : substr($wish_title, 0, 128);
|
$wish_title = empty($wish_title) ? null : substr($wish_title, 0, 128) ;
|
||||||
$wish_description = empty($wish_description) ? null : $wish_description ;
|
$wish_description = empty($wish_description) ? null : $wish_description ;
|
||||||
$wish_image = empty($wish_image) || Wish::NO_IMAGE === $wish_image ? null : $wish_image ;
|
$wish_image = empty($wish_image) || Wish::NO_IMAGE === $wish_image ? null : $wish_image ;
|
||||||
$wish_url = empty($wish_url) ? null : $wish_url ;
|
$wish_url = empty($wish_url) ? null : Wish::getAffiliateLink($wish_url);
|
||||||
$wish_priority = empty($wish_priority) ? null : $wish_priority ;
|
$wish_priority = empty($wish_priority) ? null : $wish_priority ;
|
||||||
|
|
||||||
$database
|
$database
|
||||||
->query(
|
->query(
|
||||||
|
@ -229,10 +229,10 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Update */
|
/** Update */
|
||||||
$wish_title = empty($wish_title) ? null : substr($wish_title, 0, 128);
|
$wish_title = empty($wish_title) ? null : substr($wish_title, 0, 128) ;
|
||||||
$wish_description = empty($wish_description) ? null : $wish_description ;
|
$wish_description = empty($wish_description) ? null : $wish_description ;
|
||||||
$wish_image = empty($wish_image) || Wish::NO_IMAGE === $wish_image ? null : $wish_image ;
|
$wish_image = empty($wish_image) || Wish::NO_IMAGE === $wish_image ? null : $wish_image ;
|
||||||
$wish_url = empty($wish_url) ? null : $wish_url ;
|
$wish_url = empty($wish_url) ? null : Wish::getAffiliateLink($wish_url);
|
||||||
|
|
||||||
$database
|
$database
|
||||||
->query(
|
->query(
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
--gap: 0.5rem;
|
--gap: 0.5rem;
|
||||||
|
|
||||||
gap: var(--gap);
|
gap: var(--gap);
|
||||||
|
margin-bottom: 1em;
|
||||||
}
|
}
|
||||||
.flex.why-wishthis > ul {
|
.flex.why-wishthis > ul {
|
||||||
flex: 0 0 calc(50% - var(--gap) / 2);
|
flex: 0 0 calc(50% - var(--gap) / 2);
|
||||||
|
|
|
@ -68,6 +68,25 @@ class Wish
|
||||||
return $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
|
* Non-Static
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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.');
|
echo __('After creating an account your language is automatically set to your browser\'s (if it is available), instead of defaulting to en_GB.');
|
||||||
?>
|
?>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<?php
|
||||||
|
/** TRANSLATORS: Changelog: Added */
|
||||||
|
echo __('Amazon links are now automatically converted to affiliate links to help support wishthis financially.');
|
||||||
|
?>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h3 class="ui header"><?= __('Fixed') ?></h3>
|
<h3 class="ui header"><?= __('Fixed') ?></h3>
|
||||||
|
|
|
@ -105,7 +105,7 @@ $user = User::getCurrent();
|
||||||
'</a>'
|
'</a>'
|
||||||
) ?></p>
|
) ?></p>
|
||||||
|
|
||||||
<p><?= __('As a non-commercial project it remains') ?></p>
|
<p><?= __('As an open source project it remains') ?></p>
|
||||||
<div class="flex why-wishthis">
|
<div class="flex why-wishthis">
|
||||||
<ul class="ui list">
|
<ul class="ui list">
|
||||||
<li class="item" data-content="<?= __('unless you want them') ?>">
|
<li class="item" data-content="<?= __('unless you want them') ?>">
|
||||||
|
@ -137,6 +137,7 @@ $user = User::getCurrent();
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<p><?= __('Plese note that wishthis automatically converts amazon links to affiliate links to help support the project financially.') ?></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ui segment">
|
<div class="ui segment">
|
||||||
|
|
|
@ -301,7 +301,7 @@ $page->navigation();
|
||||||
<h2 class="ui header"><?= __('About your email address') ?></h2>
|
<h2 class="ui header"><?= __('About your email address') ?></h2>
|
||||||
|
|
||||||
<p><?= __('Currently the email address is used as a unique identifier and does not have to be verified. You may enter a fake address.') ?></p>
|
<p><?= __('Currently the email address is used as a unique identifier and does not have to be verified. You may enter a fake address.') ?></p>
|
||||||
<p><?= __('wishthis is not a commercial project and is not interested in sending you marketing emails or selling your information to third parties. Although possible to do otherwise, it is strongly recommend to enter your real email address in case you need to recover your password or receive important notifications. These do not exist yet, but some future features and options might require sending you an email (e. g. when a wish has been fulfilled).') ?></p>
|
<p><?= __('wishthis is not interested in sending you marketing emails or selling your information to third parties. Although possible to do otherwise, it is strongly recommend to enter your real email address in case you need to recover your password or receive important notifications. These do not exist yet, but some future features and options might require sending you an email (e. g. when a wish has been fulfilled).') ?></p>
|
||||||
<p>
|
<p>
|
||||||
<?=
|
<?=
|
||||||
sprintf(
|
sprintf(
|
||||||
|
|
Loading…
Reference in a new issue