Add option to enable advertisements
This commit is contained in:
parent
a7d0411352
commit
2eab3691c9
8 changed files with 82 additions and 0 deletions
|
@ -153,6 +153,10 @@
|
|||
/**
|
||||
* Checkbox
|
||||
*/
|
||||
.ui.checkbox label,
|
||||
.ui.checkbox + label {
|
||||
color: rgba(255, 255, 255, .9) !important;
|
||||
}
|
||||
.ui.toggle.checkbox input:checked ~ label {
|
||||
color: #fff !important;
|
||||
}
|
||||
|
|
|
@ -92,4 +92,7 @@ $(function() {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** Advertisements */
|
||||
$('.ui.checkbox.advertisements').checkbox();
|
||||
});
|
||||
|
|
|
@ -231,6 +231,8 @@ class Page
|
|||
public function header(): void
|
||||
{
|
||||
global $locales;
|
||||
|
||||
$user = isset($_SESSION['user']->id) ? $_SESSION['user'] : new User();
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?= $this->language ?>">
|
||||
|
@ -395,6 +397,22 @@ class Page
|
|||
data-domain="<?= $_SERVER['HTTP_HOST'] ?>"
|
||||
src="https://plausible.io/js/plausible.js">
|
||||
</script>
|
||||
<?php
|
||||
|
||||
/** AdSense */
|
||||
$wishthis_hosts = array(
|
||||
'wishthis.localhost',
|
||||
'wishthis.online',
|
||||
'rc.wishthis.online',
|
||||
'dev.wishthis.online',
|
||||
);
|
||||
|
||||
if (in_array($_SERVER['HTTP_HOST'], $wishthis_hosts, true) && (true === $user->advertisements || $CrawlerDetect->isCrawler())) {
|
||||
?>
|
||||
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-7093703034691766" crossorigin="anonymous"></script>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<title><?= $this->title ?> - wishthis - <?= __('Make a wish') ?></title>
|
||||
</head>
|
||||
|
|
|
@ -51,6 +51,7 @@ class User
|
|||
*/
|
||||
public int $power = 0;
|
||||
public ?\Gettext\Translations $translations = null;
|
||||
public bool $advertisements = false;
|
||||
|
||||
public function __construct(array $fields = array())
|
||||
{
|
||||
|
|
|
@ -112,6 +112,12 @@ $page->navigation();
|
|||
echo __('Compact/list view for wishes');
|
||||
?>
|
||||
</li>
|
||||
<li>
|
||||
<?php
|
||||
/** TRANSLATORS: Changelog: Roadmap */
|
||||
echo __('Option to enable advertisements');
|
||||
?>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3 class="ui header"><?= __('Improved') ?></h3>
|
||||
|
|
|
@ -162,6 +162,7 @@ switch ($step) {
|
|||
`name_last` VARCHAR(32) NULL DEFAULT NULL,
|
||||
`name_nick` VARCHAR(32) NULL DEFAULT NULL,
|
||||
`channel` VARCHAR(24) NULL DEFAULT NULL,
|
||||
`advertisements` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
|
||||
INDEX `idx_password` (`password`)
|
||||
);'
|
||||
|
|
|
@ -115,6 +115,18 @@ if (isset($_POST['user-id'], $_POST['section'])) {
|
|||
}
|
||||
}
|
||||
|
||||
/** Advertisements */
|
||||
if (isset($_POST['enable-advertisements'])) {
|
||||
$_SESSION['user']->advertisements = true;
|
||||
|
||||
$set[] = '`advertisements` = TRUE';
|
||||
} else {
|
||||
$_SESSION['user']->advertisements = false;
|
||||
|
||||
$set[] = '`advertisements` = FALSE';
|
||||
}
|
||||
|
||||
/** Save */
|
||||
if ($set) {
|
||||
$database
|
||||
->query(
|
||||
|
@ -343,6 +355,35 @@ $page->navigation();
|
|||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label><?= __('Advertisements') ?></label>
|
||||
|
||||
<div class="ui toggle checkbox advertisements">
|
||||
<?php
|
||||
$user = isset($_SESSION['user']->id) ? $_SESSION['user'] : new User();
|
||||
?>
|
||||
|
||||
<?php if (true === $user->advertisements) { ?>
|
||||
<input type="checkbox" name="enable-advertisements" checked="checked" />
|
||||
<?php } else { ?>
|
||||
<input type="checkbox" name="enable-advertisements" />
|
||||
<?php } ?>
|
||||
|
||||
<label><?= __('Enable advertisements') ?></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<p>
|
||||
<?php
|
||||
printf(
|
||||
/** TRANSLATORS: %s: sponsor me */
|
||||
__('Time spent on wishthis is time not doing for-profit work. If you would like to support me but either can\'t or don\'t want to %s, consider selling your body to Google and becoming its product.'),
|
||||
'<a href="https://github.com/sponsors/grandeljay" target="_blank">' . __('sponsor me') . '</a>'
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="ui error message"></div>
|
||||
|
||||
<input class="ui primary button"
|
||||
|
|
|
@ -2,3 +2,11 @@
|
|||
* Sessions
|
||||
*/
|
||||
TRUNCATE `sessions`;
|
||||
|
||||
/**
|
||||
* Users
|
||||
*/
|
||||
ALTER TABLE
|
||||
`users`
|
||||
ADD
|
||||
COLUMN `advertisements` TINYINT(1) NOT NULL DEFAULT 0;
|
||||
|
|
Loading…
Reference in a new issue