This repository has been archived by the owner on Feb 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
settings.php
74 lines (64 loc) · 2.32 KB
/
settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
class Flattr_Settings
{
public function __construct()
{
add_action('admin_init', array( $this, 'register_settings') );
add_action('admin_menu', array( $this, 'init_ui') );
}
public function init_ui()
{
add_options_page('Flattr Setup', 'Flattr', 'manage_options', __FILE__, array($this, 'render'));
}
public function register_settings()
{
register_setting('flattr-settings-uid-group', 'flattr_uid', array($this, 'sanitize_userid'));
register_setting('flattr-settings-group', 'flattr_aut', array($this, 'sanitize_auto'));
register_setting('flattr-settings-group', 'flattr_aut_page', array($this, 'sanitize_auto_page'));
register_setting('flattr-settings-group', 'flattr_cat', array($this, 'sanitize_category'));
register_setting('flattr-settings-group', 'flattr_lng', array($this, 'sanitize_language'));
register_setting('flattr-settings-group', 'flattr_compact', array($this, 'sanitize_checkbox'));
register_setting('flattr-settings-group', 'flattr_hide', array($this, 'sanitize_checkbox'));
register_setting('flattr-settings-group', 'flattr_top', array($this, 'sanitize_checkbox'));
register_setting('flattr-settings-group', 'flattr_override_sharethis', array($this, 'sanitize_checkbox'));
}
public function render()
{
if (array_key_exists('FlattrId', $_GET)) {
include('settings-confirm-template.php');
}
else {
include('settings-template.php');
}
}
public function sanitize_category($category)
{
return $category;
}
public function sanitize_language($language)
{
return $language;
}
public function sanitize_checkbox($input)
{
return ($input == 'true' ? 'true' : '');
}
public function sanitize_auto($input)
{
return ($input == 'on' ? 'on' : '');
}
public function sanitize_auto_page($input)
{
return ($input == 'on' ? 'on' : '');
}
public function sanitize_userid($userId)
{
if (preg_match('/[^A-Za-z0-9-_.]/', $userId)) {
$userId = false;
}
else if (is_numeric($userId)) {
$userId = intval($userId);
}
return $userId;
}
}