-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.php
More file actions
119 lines (110 loc) · 4.07 KB
/
options.php
File metadata and controls
119 lines (110 loc) · 4.07 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/**
* check that option ReplaceMode is valid
* @param string $input
* @return $input, if ok; default value otherwise;
*/
function validateReplaceMode($input)
{
$ret = "full";
if (($input == "hardcore") || ($input == "softcore"))
{
$ret = $input;
}
_log("validate replace mode [$input]: [$ret]");
return $ret;
}
/**
* do nothing but log
* @param string $input new value
* @return string $input
*/
function validateWellKnownParameter($input)
{
_log("validate well known parameter [$input]: ok");
return $input;
}
/**
* make sure that value is empty or the string "on"
* @param string $input new value
* @return unmodified $input if empty or "on; empty string otherwise
*/
function validateParanoiaParameter($input)
{
$ret = $input;
if ((empty($ret)) || ($ret == "on"))
{
_log("validate paranoia parameter [$input]: ok");
} else
{
_log("validate paranoia parameter [$input]: unknown value; turn paranoia off");
$ret = "";
}
return $ret;
}
/**
* Register the needed settings for feedproxy resolver.
*/
function registerFeedproxySettings()
{
register_setting( 'feedproxyResolver', 'replacementMode', 'validateReplaceMode');
register_setting( 'feedproxyResolver', 'wellKnownParameter', 'validateWellKnownParameter');
register_setting( 'feedproxyResolver', 'paranoia', 'validateParanoiaParameter');
}
/**
* Do all settings related stuff to wordpress.
* 1. Register the menu entry.
* 2. Hook into admin init to register our settings.
*/
function initFeedproxySettings()
{
add_submenu_page( 'options-general.php', 'Feedp Resolver', 'Feedp Resolver', 'administrator' , __FILE__, 'feedproxyOptionDrawPage');
add_action('admin_init', 'registerFeedproxySettings');
}
/**
* Draw the menu page itself
*/
function feedproxyOptionDrawPage()
{
?>
<div class="wrap">
<h2>Feedproxy Resolver Options</h2>
<form method="post" action="options.php">
<?php settings_fields('feedproxyResolver'); ?>
<?php $replacementMode = get_option('replacementMode'); ?>
<?php $wellKnownParameter = get_option('wellKnownParameter'); ?>
<?php $paranoia = get_option('paranoia'); ?>
<p>Choose the parameter replacement mode</p>
<p>
<input type="radio" name="replacementMode" value="full" <?php checked( $replacementMode == "full" ); ?> > no replacement<br>
<input type="radio" name="replacementMode" value="softcore" <?php checked( $replacementMode == "softcore" ); ?>> softcore<br>
<input type="radio" name="replacementMode" value="hardcore" <?php checked( $replacementMode == "hardcore" ); ?>> hardcore
</p>
<p>Blacklist for softcore (leave empty for default)<br>Whitelist for hardcore</p>
<p>
<input type="text" name ="wellKnownParameter" style="width:500px" value="<?php echo $wellKnownParameter;?>" />
</p>
<p>
<input type="checkbox" name ="paranoia" <?php if($paranoia == 'on') echo 'checked="checked"';?> >check links after parameter replacing (paranoia)</input>
</p>
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
</p>
</form>
<hr/>
<h3>Help</h3>
After the resolving of a feedproxy url, the url may contains ugly feedproxy GET parameters. You can specify, how to handle these.
<h4>No replacement</h4>
This is the savest option. The url will be used, exacly as received, containing all GET parameters.
<h4>softcore</h4>
Some known GET parameters will be removed from url, rest of them are not touched. Leave parameter textbox empty to use default settings (utm_medium, utm_source and utm_campaign).
<h4>hardcore (naming creds goes to daMax)</h4>
All GET parameters are removed from url, except the whitelisted ones from the parameter textbox.
<h4>paranoia</h4>
Activating this option, let Feedproxy Resolver check the url after parameter cutting. If no 200 OK is returned from server, The original url with all parameters will be used.
</div>
<?php
}
// register our admin page to wordpress
add_action('admin_menu', 'initFeedproxySettings');
?>