PluginProbe
HTTP Headers / trunk
HTTP Headers vtrunk
1.19.5 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.12.0 1.12.1 1.12.2 1.13.0 1.13.1 1.13.2 1.13.3 1.13.4 1.14.0 1.14.1 1.14.2 1.15.0 All 60 releases
http-headers / views / feature-policy.php

feature-policy.php in HTTP Headers trunk, at views/feature-policy.php

105 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) {
3 exit;
4 }
5 ?>
6 <tr valign="top">
7 <th scope="row">Feature-Policy
8 <p class="description"><?php esc_html_e('With Feature Policy, you opt-in to a set of policies for the browser to enforce on specific features used throughout your site. These policies restrict what APIs the site can access or modify the browser\'s default behavior for certain features.', 'http-headers'); ?></p>
9 <hr>
10 <p class="description"><?php esc_html_e('Read more at', 'http-headers'); ?>
11 <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Feature-Policy"><?php esc_html_e('MDN Web Docs', 'http-headers'); ?></a>
12 </p>
13 </th>
14 <td>
15 <fieldset>
16 <legend class="screen-reader-text">Feature-Policy</legend>
17 <?php
18 $http_headers_feature_policy = get_option('hh_feature_policy', 0);
19 foreach ($http_headers_bools as $http_headers_k => $http_headers_v)
20 {
21 ?><p><label><input type="radio" class="http-header" name="hh_feature_policy" value="<?php echo esc_attr($http_headers_k); ?>"<?php checked($http_headers_feature_policy, $http_headers_k, true); ?> /> <?php echo esc_html($http_headers_v); ?></label></p><?php
22 }
23 ?>
24 </fieldset>
25 </td>
26 <td>
27 <?php settings_fields( 'http-headers-fp' ); ?>
28 <?php do_settings_sections( 'http-headers-fp' ); ?>
29 <table>
30 <tbody>
31 <?php
32 $http_headers_features = array(
33 'accelerometer',
34 'ambient-light-sensor',
35 'autoplay',
36 'camera',
37 'cookie',
38 'docwrite',
39 'domain',
40 'encrypted-media',
41 'fullscreen',
42 'geolocation',
43 'gyroscope',
44 'magnetometer',
45 'microphone',
46 'midi',
47 'payment',
48 'picture-in-picture',
49 'speaker',
50 'sync-script',
51 'sync-xhr',
52 'unsized-media',
53 'usb',
54 'vertical-scroll',
55 'vibrate',
56 'vr',
57 );
58 $http_headers_origins = array("'self'", "'none'", '*', 'origin(s)');
59
60 $http_headers_feature_policy_value = get_option('hh_feature_policy_value');
61 $http_headers_feature_policy_feature = get_option('hh_feature_policy_feature');
62 $http_headers_feature_policy_origin = get_option('hh_feature_policy_origin');
63 if (!$http_headers_feature_policy_value)
64 {
65 $http_headers_feature_policy_value = array();
66 }
67 if (!$http_headers_feature_policy_feature)
68 {
69 $http_headers_feature_policy_feature = array();
70 }
71 if (!$http_headers_feature_policy_origin)
72 {
73 $http_headers_feature_policy_origin = array();
74 }
75
76 foreach ($http_headers_features as $http_headers_feature)
77 {
78 ?>
79 <tr>
80 <td><input type="checkbox" name="hh_feature_policy_feature[<?php echo esc_attr($http_headers_feature); ?>]" class="http-header-value"
81 value="1"<?php echo !is_array($http_headers_feature_policy_feature) || !array_key_exists($http_headers_feature, $http_headers_feature_policy_feature) ? NULL : ' checked'; ?><?php echo $http_headers_feature_policy == 1 ? NULL : ' readonly'; ?>></td>
82 <td><?php echo esc_html($http_headers_feature); ?></td>
83 <td>
84 <select name="hh_feature_policy_value[<?php echo esc_attr($http_headers_feature); ?>]"
85 class="http-header-value"<?php echo $http_headers_feature_policy == 1 ? NULL : ' readonly'; ?>>
86 <?php
87 foreach ($http_headers_origins as $http_headers_origin)
88 {
89 ?><option value="<?php echo esc_attr($http_headers_origin); ?>"<?php isset($http_headers_feature_policy_value[$http_headers_feature]) ? selected($http_headers_feature_policy_value[$http_headers_feature], $http_headers_origin) : NULL; ?>><?php echo esc_html($http_headers_origin); ?></option><?php
90 }
91 ?>
92 </select>
93 <input type="text" name="hh_feature_policy_origin[<?php echo esc_attr($http_headers_feature); ?>]"
94 value="<?php echo isset($http_headers_feature_policy_origin[$http_headers_feature]) ? esc_attr($http_headers_feature_policy_origin[$http_headers_feature]) : NULL; ?>"
95 size="30"<?php echo isset($http_headers_feature_policy_value[$http_headers_feature]) && in_array($http_headers_feature_policy_value[$http_headers_feature], array('origin(s)', "'self'")) ? NULL : ' style="display: none"'; ?>
96 class="http-header-value"<?php echo $http_headers_feature_policy == 1 ? NULL : ' readonly'; ?>>
97 </td>
98 </tr>
99 <?php
100 }
101 ?>
102 </tbody>
103 </table>
104 </td>
105 </tr>