Skip to content

Commit

Permalink
fix: invert analytics settings (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
greatislander authored Sep 4, 2020
1 parent e798ae5 commit 231b489
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions app/Controllers/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public function notifications()
}
}

public function trackViewedResources()
public function doNotTrackViewedResources()
{
if (isset($_POST['track_viewed_resources']) && $_POST['track_viewed_resources'] === 'on') {
if (isset($_POST['do_not_track_viewed_resources']) && $_POST['do_not_track_viewed_resources'] === 'on') {
return 'on';
} elseif (isset($_POST['track_viewed_resources']) && $_POST['track_viewed_resources'] === '') {
} elseif (isset($_POST['do_not_track_viewed_resources']) && $_POST['do_not_track_viewed_resources'] === '') {
return false;
}
if (isset($_COOKIE['track_viewed_resources']) && $_COOKIE['track_viewed_resources'] === 'on') {
if (isset($_COOKIE['do_not_track_viewed_resources']) && $_COOKIE['do_not_track_viewed_resources'] === 'on') {
return 'on';
}
return false;
Expand Down
6 changes: 3 additions & 3 deletions app/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@
}, 10, 2);

add_filter('koko_analytics_load_tracking_script', function () {
if (isset($_COOKIE['track_viewed_resources']) && $_COOKIE['track_viewed_resources'] === 'on') {
return true;
if (isset($_COOKIE['do_not_track_viewed_resources']) && $_COOKIE['do_not_track_viewed_resources'] === 'on') {
return false;
}
return false;
return true;
});
6 changes: 3 additions & 3 deletions app/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@
* Set language cookies when settings form is submitted.
*/
add_action('init', function () {
if (isset($_POST['track_viewed_resources'])) {
if (isset($_POST['do_not_track_viewed_resources'])) {
setcookie(
'track_viewed_resources',
sanitize_text_field($_POST['track_viewed_resources']),
'do_not_track_viewed_resources',
sanitize_text_field($_POST['do_not_track_viewed_resources']),
time() + YEAR_IN_SECONDS,
COOKIEPATH,
COOKIE_DOMAIN
Expand Down
4 changes: 2 additions & 2 deletions resources/views/partials/content-page-settings.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
</div>
<ul class="input-group">
<li>
<input id="allow" type="radio" name="track_viewed_resources" value="on" {{ checked('on', $track_viewed_resources) }}>
<input id="allow" type="radio" name="do_not_track_viewed_resources" value="" {{ checked(false, $do_not_track_viewed_resources) }}>
<label for="allow">{!! __('Allow', 'coop-library') !!}</label>
</li>
<li>
<input id="disallow" type="radio" name="track_viewed_resources" value="" {{ checked(false, $track_viewed_resources) }}>
<input id="disallow" type="radio" name="do_not_track_viewed_resources" value="on" {{ checked('on', $do_not_track_viewed_resources) }}>
<label for="disallow">{!! __('Don&rsquo;t allow', 'coop-library') !!}</label>
</li>
</ul>
Expand Down

0 comments on commit 231b489

Please sign in to comment.