PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 1.3
Independent Analytics – WordPress Analytics Plugin v1.3
2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / inc / settings.php
independent-analytics / inc Last commit date
models 4 years ago queries 4 years ago utils 4 years ago chart.php 4 years ago db.php 4 years ago filters-ajax.php 4 years ago filters.php 4 years ago rest-api.php 4 years ago settings-ajax.php 4 years ago settings.php 4 years ago super-secret-content-generator.php 4 years ago table-referrers.php 4 years ago table-views.php 4 years ago table.php 4 years ago track-resource-changes.php 4 years ago
settings.php
96 lines
1 <?php
2
3 if (!class_exists('IAWP_Settings')) {
4 class IAWP_Settings
5 {
6 public function __construct()
7 {
8 add_action('admin_init', [$this, 'register_settings']);
9 }
10
11 public function render_settings()
12 {
13 $this->output_settings();
14
15 $template = IAWP()->twig->load('settings/settings.html');
16
17 echo $template->render([
18 'export_views_url' => get_site_url() . '/?rest_route=/iawp/export/views',
19 'export_referrers_url' => get_site_url() . '/?rest_route=/iawp/export/referrers',
20 ]);
21 }
22
23 public function register_settings()
24 {
25 add_settings_section('iawp-settings-section', esc_html__('Settings', 'iawp'), '', 'independent-analytics-settings');
26
27 $args = [
28 'type' => 'boolean',
29 'default' => false,
30 'sanitize_callback' => 'rest_sanitize_boolean',
31 ];
32 register_setting('iawp_settings', 'iawp_dark_mode', $args);
33 register_setting('iawp_settings', 'iawp_track_authenticated_users', $args);
34 add_settings_field('iawp_dark_mode', esc_html__('Dark mode', 'iawp'), [$this, 'dark_mode_callback'], 'independent-analytics-settings', 'iawp-settings-section', ['class' => 'dark-mode']);
35 add_settings_field('iawp_track_authenticated_users', esc_html__('Track logged in users', 'iawp'), [$this, 'track_authenticated_users_callback'], 'independent-analytics-settings', 'iawp-settings-section', ['class' => 'logged-in']);
36
37 $args = [
38 'type' => 'integer',
39 'default' => 1,
40 'sanitize_callback' => 'absint',
41 ];
42 register_setting('iawp_settings', 'iawp_dow', $args);
43 add_settings_field('iawp_dow', esc_html__('Calendar first day of the week', 'iawp'), [$this, 'starting_dow_callback'], 'independent-analytics-settings', 'iawp-settings-section', ['class' => 'dow']);
44 }
45
46 public function dark_mode_callback()
47 {
48 $saved = IAWP()->get_option('iawp_dark_mode', false); ?>
49 <label class="column-label" for="iawp_dark_mode">
50 <input type="checkbox" name="iawp_dark_mode" id="iawp_dark_mode" <?php checked(true, $saved, true); ?>>
51 <span><?php esc_html_e('Enable dark mode', 'iawp'); ?></span>
52 </label><?php
53 }
54
55 public function track_authenticated_users_callback()
56 {
57 $saved = IAWP()->get_option('iawp_track_authenticated_users', false); ?>
58 <label class="column-label" for="iawp_track_authenticated_users">
59 <input type="checkbox" name="iawp_track_authenticated_users" id="iawp_track_authenticated_users" <?php checked(true, $saved, true); ?>>
60 <span><?php esc_html_e('Track logged in users', 'iawp'); ?></span>
61 </label><?php
62 }
63
64 public function starting_dow_callback()
65 {
66 $saved = IAWP()->get_option('iawp_dow', 1);
67 $dows = [
68 0 => esc_html__('Sunday', 'iawp'),
69 1 => esc_html__('Monday', 'iawp'),
70 2 => esc_html__('Tuesday', 'iawp'),
71 3 => esc_html__('Wednesday', 'iawp'),
72 4 => esc_html__('Thursday', 'iawp'),
73 5 => esc_html__('Friday', 'iawp'),
74 6 => esc_html__('Saturday', 'iawp'),
75 ];
76
77 echo '<select id="iawp_dow" name="iawp_dow" value="' . esc_attr($saved) . '" >';
78 foreach ($dows as $key => $value) {
79 echo '<option value="' . esc_attr($key) . '" ' . selected($saved, $key, false) . '>' . esc_html($value) . '</option>';
80 }
81 echo '</select>';
82 }
83
84 public function output_settings()
85 {
86 echo '<div id="iawp-settings" class="iawp-settings settings-container">';
87 echo '<form method="post" action="options.php">';
88 settings_fields('iawp_settings');
89 do_settings_sections('independent-analytics-settings');
90 submit_button(esc_html__('Save settings', 'iawp'), 'iawp-button purple', 'save-settings');
91 echo '</form>';
92 echo '</div>';
93 }
94 }
95 }
96