-
Notifications
You must be signed in to change notification settings - Fork 1
/
settings.php
168 lines (139 loc) · 7.47 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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?php
add_action('init', 'dxw_members_only_metasettings');
function dxw_members_only_metasettings()
{
$ms = new dmometasettings(__FILE__, 'dxw_members_only');
$ms->add_settings(__('dxw Members Only', 'dxwmembersonly'), [
'list_type',
'list_content',
'ip_whitelist',
'referrer_allow_list',
'redirect',
'redirect_root',
'upload_default',
'max_age',
'max_age_static',
'max_age_public'
], 'dxw_members_only_options_page');
}
/**
* Output settings page content
*
* @return void
*/
function dxw_members_only_options_page()
{
?>
<div class="wrap">
<h2><?php _e('dxw Members Only', 'dxwmembersonly') ?></h2>
<form method="post" action="options.php">
<?php settings_fields('dxw_members_only') ?>
<h3><?php _e('Content whitelist', 'dxwmembersonly') ?></h3>
<p><?php _e('Enter a list of content that all users can view without logging in.', 'dxwmembersonly') ?></p>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="dxw_members_only_list_content"><?php _e('List of content URIs', 'dxwmembersonly') ?></label></th>
<td>
<textarea cols="30" rows="5" name="dxw_members_only_list_content" id="dxw_members_only_list_content" class="large-text code"><?php echo esc_html(get_option('dxw_members_only_list_content')) ?></textarea>
<br>
<span class="description"><?php _e('One host-relative URI per line. A * may be used at the end of a line. Query string ignored. /wp-login.php will always be allowed.', 'dxwmembersonly') ?></span>
</td>
</tr>
</table>
<h3><?php _e('IP whitelist') ?></h3>
<p><?php _e('Enter a list of IP addresses that can be allowed to view the site without logging in.', 'dxwmembersonly') ?></p>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="dxw_members_only_ip_whitelist"><?php _e('List of IP addresses', 'dxwmembersonly') ?></label></th>
<td>
<textarea cols="30" rows="5" name="dxw_members_only_ip_whitelist" id="dxw_members_only_ip_whitelist" class="large-text code"><?php echo esc_html(get_option('dxw_members_only_ip_whitelist')) ?></textarea>
<br>
<span class="description"><?php _e('One IPv4 address or CIDRv4 address range per line.', 'dxwmembersonly') ?></span>
</td>
</tr>
</table>
<h3><?php _e('Referrer Allow list') ?></h3>
<p><?php _e('Enter a list of internal referrers to whitelist.', 'dxwmembersonly') ?></p>
<p><?php _e('This is for enabling certain plugins such as Nelio AB to function correctly, do not use unless required', 'dxwmembersonly') ?></p>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="dxw_members_only_referrer_allow_list"><?php _e('List of referrers', 'dxwmembersonly') ?></label></th>
<td>
<textarea cols="30" rows="5" name="dxw_members_only_referrer_allow_list" id="dxw_members_only_referrer_allow_list" class="large-text code"><?php echo esc_html(get_option('dxw_members_only_referrer_allow_list')) ?></textarea>
<br>
<span class="description"><?php _e('One address per line, do not include the domain (eg /admin.php?page=test)', 'dxwmembersonly') ?></span>
</td>
</tr>
</table>
<?php echo get_option('dxw_members_only_referrer_whitelist'); ?>
<h3><?php _e('Redirection', 'dxwmembersonly') ?></h3>
<p><?php _e('In both the following options, <code>%return_path%</code> will be converted to the URL that was originally visited. i.e. <code>/wp-login.php?redirect_to=http://example.com/private-page</code>', 'dxwmembersonly') ?></p>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="dxw_members_only_redirect"><?php _e('Redirect visitors to', 'dxwmembersonly') ?></label></th>
<td>
<input type="text" name="dxw_members_only_redirect" id="dxw_members_only_redirect" value="<?php form_option('dxw_members_only_redirect') ?>" class="regular-text">
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="dxw_members_only_redirect_root"><?php _e('Redirect visitors to / to', 'dxwmembersonly') ?></label></th>
<td>
<input type="text" name="dxw_members_only_redirect_root" id="dxw_members_only_redirect_root" value="<?php form_option('dxw_members_only_redirect_root') ?>" class="regular-text">
<span class="description"><?php _e("Only applies if / isn't whitelisted.", 'dxwmembersonly') ?></span>
</td>
</tr>
</table>
<h3><?php _e('File uploads', 'dxwmembersonly') ?></h3>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('New uploads by default are', 'dxwmembersonly') ?></th>
<td>
<fieldset>
<label>
<input type="radio" name="dxw_members_only_upload_default" value="true" <?php echo get_option('dxw_members_only_upload_default') === 'true' ? 'checked' : '' ?>>
<?php _e('Added to list', 'dxwmembersonly') ?>
</label>
<br>
<label>
<input type="radio" name="dxw_members_only_upload_default" value="false" <?php echo get_option('dxw_members_only_upload_default') === 'true' ? '' : 'checked' ?>>
<?php _e('Not added to list', 'dxwmembersonly') ?>
</label>
</fieldset>
<span class="description"><?php _e('You can change this on a per-file basis when uploading', 'dxwmembersonly') ?></span>
</td>
</tr>
</table>
<h3><?php _e('Browser Cache Max Age', 'dxwmembersonly') ?></h3>
<p><?php _e('A Cache-Control header will be set that prevents server caching on non-public responses, but allows browsers to cache for a maximum number of seconds.', 'dxwmembersonly') ?></p>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="dxw_members_only_max_age"><?php _e('Browser cache max age in seconds', 'dxwmembersonly') ?></label></th>
<td>
<input type="number" min="0" step="1" name="dxw_members_only_max_age" id="dxw_members_only_max_age" value="<?php form_option('dxw_members_only_max_age') ?>" class="regular-text">
<span class="description">Defaults to 0 if not set.</span>
</td>
</tr>
</table>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="dxw_members_only_max_age_static"><?php _e('Browser cache max age in seconds (static content)', 'dxwmembersonly') ?></label></th>
<td>
<input type="number" min="0" step="1" name="dxw_members_only_max_age_static" id="dxw_members_only_max_age_static" value="<?php form_option('dxw_members_only_max_age_static') ?>" class="regular-text">
<span class="description">Defaults to 0 if not set.</span>
</td>
</tr>
</table>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="dxw_members_only_max_age_public"><?php _e('Browser cache max age in seconds (public content)', 'dxwmembersonly') ?></label></th>
<td>
<input type="number" min="0" step="1" name="dxw_members_only_max_age_public" id="dxw_members_only_max_age_public" value="<?php form_option('dxw_members_only_max_age_public') ?>" class="regular-text">
<span class="description">Defaults to 86400 if not set.</span>
</td>
</tr>
</table>
<?php submit_button() ?>
</form>
</div>
<?php
}