custom-headers.php
2.73 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
<?php
if (!defined('ABSPATH')) {
exit;
}
?>
<tr>
<th scope="row">Custom headers
<p class="description"><?php _e('Common non-standard response fields:', 'http-headers'); ?>
<br>X-Pingback
<br>X-Cache
<br>X-Edge-Location
<br>X-HTTP-Method-Override
<br>X-Csrf-Token
<br>X-Request-ID
<br>X-Correlation-ID
<br>X-Content-Duration
</p>
</th>
<td>
<fieldset>
<legend class="screen-reader-text">Custom headers</legend>
<?php
$custom_headers = get_option('hh_custom_headers', 0);
foreach ($bools as $k => $v)
{
?><p><label><input type="radio" class="http-header" name="hh_custom_headers" value="<?php echo $k; ?>"<?php checked($custom_headers, $k); ?> /> <?php echo $v; ?></label></p><?php
}
?>
</fieldset>
</td>
<td>
<?php settings_fields( 'http-headers-che' ); ?>
<?php do_settings_sections( 'http-headers-che' ); ?>
<?php
$custom_headers_value = get_option('hh_custom_headers_value');
if (!$custom_headers_value) {
$custom_headers_value = array();
}
?>
<table>
<thead>
<tr>
<th><?php _e('Header', 'http-headers'); ?></th>
<th><?php _e('Value', 'http-headers'); ?></th>
<th></th>
</tr>
</thead>
<tbody>
<?php
if (empty($custom_headers_value))
{
?>
<tr>
<td><input type="text" name="hh_custom_headers_value[name][]" class="http-header-value" placeholder="X-Custom-Name"></td>
<td><input type="text" name="hh_custom_headers_value[value][]" class="http-header-value" placeholder="<?php esc_attr_e('Value', 'http-headers'); ?>"></td>
<td></td>
</tr>
<?php
} else {
foreach ($custom_headers_value['name'] as $key => $name)
{
if (empty($name) || empty($custom_headers_value['value'][$key]))
{
continue;
}
?>
<tr>
<td><input type="text" name="hh_custom_headers_value[name][]" class="http-header-value" placeholder="X-Custom-Name" value="<?php echo esc_attr($name); ?>"<?php echo $custom_headers == 1 ? NULL : ' readonly'; ?>></td>
<td><input type="text" name="hh_custom_headers_value[value][]" class="http-header-value" placeholder="<?php esc_attr_e('Value', 'http-headers'); ?>" value="<?php echo esc_attr($custom_headers_value['value'][$key]); ?>"<?php echo $custom_headers == 1 ? NULL : ' readonly'; ?>></td>
<td><button type="button" class="button button-small hh-btn-delete-header" title="<?php esc_attr_e('Delete', 'http-headers'); ?>">x</button></td>
</tr>
<?php
}
}
?>
<tr>
<td colspan="3"><button type="button" class="button" id="hh-btn-add-header">+ <?php _e('Add header', 'http-headers'); ?></button></td>
</tr>
</tbody>
</table>
</td>
</tr>