This repository has been archived by the owner on Mar 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathabc-settings-page.php
208 lines (192 loc) · 12.3 KB
/
abc-settings-page.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<?php
class ABC_Settings extends ABC_Core
{
/**
* ABC_Settings constructor.
*/
public function __construct()
{
parent::__construct();
}
/**
*
*/
function settings_panel()
{
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
$abc = $this->default_setting_values();
?>
<div class="wrap abc-settings">
<h2><?php _e( 'Advanced Browser Check', 'advanced-browser-check' ); ?></h2>
<form method="post" action="options.php">
<?php wp_nonce_field( 'update-options' ); ?>
<table class="form-table abc-settings">
<tbody>
<tr valign="top">
<th scope="row">
<label for="abc_title"><?php _e( 'Title', 'advanced-browser-check' ); ?></label>
</th>
<td>
<input type="text" class="large-text" id="abc_title" name="abc_title" value="<?php echo $abc['title']; ?>">
</td>
</tr>
<tr valign="top">
<th scope="row">
<label for="abc_message"><?php _e( 'Message', 'advanced-browser-check' ); ?></label>
<p class="description"><?php _e( 'You can use basic HTML code in your message. Like <strong>, <i>, <a> and <img>', 'advanced-browser-check' ); ?></p>
</th>
<td>
<textarea class="large-text" id="abc_message" name="abc_message" cols="50" rows="8"><?php echo $abc['msg']; ?></textarea>
</td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e( 'Let user hide the popup', 'advanced-browser-check'); ?>
<p class="description"><?php _e( 'Let the user hide the popup and use your site. The popup will be hidden for 24h only, this is set by a cookie', 'advanced-browser-check' ); ?></p>
</th>
<td>
<label for="hide">
<input type="checkbox" id="abc_hide" name="abc_hide" value="yes" <?php echo ! empty( $abc['hide'] ) ? 'checked="checked"' : ''; ?> /> <?php _e( 'Yes', 'advanced-browser-check' ); ?>
</label>
</td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e( 'Choose browsers to link', 'advanced-browser-check' ); ?>
<p class="description"><?php _e( 'These are the browsers that you can display a link to and tell your visitor to use', 'advanced-browser-check' ); ?></p>
</th>
<td>
<ul>
<li>
<label for="ie">
<input type="checkbox" id="ie" name="abc_show[ie]" value="https://www.microsoft.com/en-us/download/internet-explorer-11-for-windows-7-details.aspx" <?php echo ! empty( $abc['show_browser']['ie'] ) ? 'checked="checked"' : ''; ?> /> <?php _e( 'Internet Explorer', 'advanced-browser-check' ); ?>
</label>
</li>
<li>
<label for="edge">
<input type="checkbox" id="edge" name="abc_show[edge]" value="https://www.microsoft.com/EN-US/windows/microsoft-edge" <?php echo ! empty( $abc['show_browser']['edge'] ) ? 'checked="checked"' : ''; ?> /> <?php _e( 'Edge', 'advanced-browser-check' ); ?>
</label>
</li>
<li>
<label for="ff">
<input type="checkbox" id="ff" name="abc_show[ff]" value="http://www.mozilla.com/en-US/firefox/all.html" <?php echo ! empty( $abc['show_browser']['ff'] ) ? 'checked="checked"' : ''; ?> /> <?php _e( 'Firefox', 'advanced-browser-check' ); ?>
</label>
</li>
<li>
<label for="safari">
<input type="checkbox" id="safari" name="abc_show[safari]" value="http://www.apple.com/safari/download/" <?php echo ! empty( $abc['show_browser']['safari'] ) ? 'checked="checked"' : ''; ?> /> <?php _e( 'Safari', 'advanced-browser-check' ); ?>
</label>
</li>
<li>
<label for="opera">
<input type="checkbox" id="opera" name="abc_show[opera]" value="http://www.opera.com/download/" <?php echo ! empty( $abc['show_browser']['opera'] ) ? 'checked="checked"' : ''; ?> /> <?php _e( 'Opera', 'advanced-browser-check' ); ?>
</label>
</li>
<li>
<label for="chrome">
<input type="checkbox" id="chrome" name="abc_show[chrome]" value="https://www.google.com/chrome/browser/desktop/index.html" <?php echo ! empty( $abc['show_browser']['chrome'] ) ? 'checked="checked"' : ''; ?> /> <?php _e( 'Chrome', 'advanced-browser-check' ); ?>
</label>
</li>
</ul>
</td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e( 'Browsers and versions to check', 'advanced-browser-check' ); ?>
</th>
<td>
<ul>
<?php $browsers = $this->default_browsers(); ?>
<?php $browser_selects = ''; ?>
<?php foreach ( $browsers as $key => $browser ) : ?>
<?php
switch( $key )
{
case $key == 'edge' :
$browser_name = 'Edge';
break;
case $key == 'ff' :
$browser_name = 'Firefox';
break;
case $key == 'ie' :
$browser_name = 'Internet Explorer';
break;
case $key == 'safari' :
$browser_name = 'Safari';
break;
case $key == 'opera' :
$browser_name = 'Opera';
break;
case $key == 'chrome' :
$browser_name = 'Chrome';
break;
}
?>
<li>
<?php $browser_selects .= $key . ','; ?>
<span class="abc-browser-select-name">
<?php _e( $browser_name, 'advanced-browser-check' ); ?>:
</span>
<select name="abc_check[<?php echo $key; ?>]">
<?php foreach ( $browser as $b ) : ?>
<?php if ( $b == '0' ) : ?>
<option value="<?php echo $b; ?>" <?php echo $abc['check_browser'][$key] == $b ? 'selected="selected"' : ''; ?>>
<?php _e( 'Do not block ', 'advanced-browser-check' ); ?>
</option>
<?php else : ?>
<option value="<?php echo $b; ?>" <?php echo $abc['check_browser'][$key] == $b ? 'selected="selected"' : ''; ?>>
<?php _e( 'version ', 'advanced-browser-check' ); echo $b; ?> <?php _e( ' or lower', 'advanced-browser-check' ); ?>
</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</li>
<?php endforeach; ?>
</ul>
</td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e( 'Debug', 'advanced-browser-check' ); ?>
<p class="description"><?php _e( 'Having problems. Activate debug and see what information the plugin detects about your browser. Debug is only visible for administrators!', 'advanced-browser-check' ); ?></p>
</th>
<td>
<?php
$debug_on = $debug_off = null;
if ( ! empty( $abc['debug'] ) )
{
$debug_on = $abc['debug'] === 'on' ? 'checked="checked"' : '';
$debug_off = $abc['debug'] === 'off' ? 'checked="checked"' : '';
}
?>
<label for="hide">
<input type="radio" id="abc_debug" name="abc_debug" value="on" <?php echo $debug_on; ?> /> <?php _e( 'On', 'advanced-browser-check' ); ?>
<br/>
<input type="radio" id="abc_debug" name="abc_debug" value="off" <?php echo $debug_off; ?> /> <?php _e( 'Off', 'advanced-browser-check' ); ?>
</label>
</td>
</tr>
</tbody>
</table>
<div class="form-row">
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="abc_title,abc_message,abc_hide,abc_show,abc_check,abc_debug" />
<input type="submit" name="submit" value="<?php _e( 'Save', 'advanced-browser-check' ); ?>" class="button-primary save" />
</div>
</form>
</div>
<?php
}
}
function abc_settings()
{
$settings_panel = new ABC_Settings;
return $settings_panel->settings_panel();
}
function abc_adminmenu()
{
add_submenu_page( 'options-general.php', 'Advanced Browser Check', 'Advanced Browser Check', 'manage_options', 'advanced-browser-check', 'abc_settings' );
}
add_action( 'admin_menu','abc_adminmenu' );