| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
?> |
| 6 |
<tr valign="top"> |
| 7 |
<th scope="row">Permissions-Policy |
| 8 |
<p class="description"><?php esc_html_e('Permissions Policy is a web platform API which gives a website the ability to allow or block the use of browser features in its own frame or in iframes that it embeds.', 'http-headers'); ?></p> |
| 9 |
<hr> |
| 10 |
<p class="description"><?php esc_html_e('Read more at', 'http-headers'); ?> |
| 11 |
<a target="_blank" href="https://www.w3.org/TR/permissions-policy-1/"><?php esc_html_e('W3C Working Draft', 'http-headers'); ?></a> |
| 12 |
</p> |
| 13 |
</th> |
| 14 |
<td> |
| 15 |
<fieldset> |
| 16 |
<legend class="screen-reader-text">Permissions-Policy</legend> |
| 17 |
<?php |
| 18 |
$http_headers_permissions_policy = get_option('hh_permissions_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_permissions_policy" value="<?php echo esc_attr($http_headers_k); ?>"<?php checked($http_headers_permissions_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-pp' ); ?> |
| 28 |
<?php do_settings_sections( 'http-headers-pp' ); ?> |
| 29 |
<table> |
| 30 |
<tbody> |
| 31 |
<?php |
| 32 |
# https://github.com/w3c/webappsec-permissions-policy/blob/master/features.md |
| 33 |
$http_headers_features = array( |
| 34 |
'accelerometer', |
| 35 |
'ambient-light-sensor', |
| 36 |
'autoplay', |
| 37 |
'battery', |
| 38 |
'camera', |
| 39 |
'cross-origin-isolated', |
| 40 |
'display-capture', |
| 41 |
'document-domain', |
| 42 |
'encrypted-media', |
| 43 |
'execution-while-not-rendered', |
| 44 |
'execution-while-out-of-viewport', |
| 45 |
'fullscreen', |
| 46 |
'geolocation', |
| 47 |
'gyroscope', |
| 48 |
'interest-cohort', |
| 49 |
'layout-animations', |
| 50 |
'legacy-image-formats', |
| 51 |
'magnetometer', |
| 52 |
'microphone', |
| 53 |
'midi', |
| 54 |
'navigation-override', |
| 55 |
'oversized-images', |
| 56 |
'payment', |
| 57 |
'picture-in-picture', |
| 58 |
'publickey-credentials-get', |
| 59 |
'screen-wake-lock', |
| 60 |
'sync-script', |
| 61 |
'sync-xhr', |
| 62 |
'usb', |
| 63 |
'vertical-scroll', |
| 64 |
'web-share', |
| 65 |
'wake-lock', |
| 66 |
'xr-spatial-tracking', |
| 67 |
); |
| 68 |
$http_headers_origins = array('none', 'self', '*', 'origin(s)'); |
| 69 |
|
| 70 |
$http_headers_permissions_policy_value = get_option('hh_permissions_policy_value'); |
| 71 |
$http_headers_permissions_policy_feature = get_option('hh_permissions_policy_feature'); |
| 72 |
$http_headers_permissions_policy_origin = get_option('hh_permissions_policy_origin'); |
| 73 |
if (!$http_headers_permissions_policy_value) |
| 74 |
{ |
| 75 |
$http_headers_permissions_policy_value = array(); |
| 76 |
} |
| 77 |
if (!$http_headers_permissions_policy_feature) |
| 78 |
{ |
| 79 |
$http_headers_permissions_policy_feature = array(); |
| 80 |
} |
| 81 |
if (!$http_headers_permissions_policy_origin) |
| 82 |
{ |
| 83 |
$http_headers_permissions_policy_origin = array(); |
| 84 |
} |
| 85 |
|
| 86 |
foreach ($http_headers_features as $http_headers_feature) |
| 87 |
{ |
| 88 |
?> |
| 89 |
<tr> |
| 90 |
<td><input type="checkbox" name="hh_permissions_policy_feature[<?php echo esc_attr($http_headers_feature); ?>]" class="http-header-value" |
| 91 |
value="1"<?php echo !is_array($http_headers_permissions_policy_feature) || !array_key_exists($http_headers_feature, $http_headers_permissions_policy_feature) ? NULL : ' checked'; ?><?php echo $http_headers_permissions_policy == 1 ? NULL : ' readonly'; ?>></td> |
| 92 |
<td><?php echo esc_html($http_headers_feature); ?></td> |
| 93 |
<td> |
| 94 |
<select name="hh_permissions_policy_value[<?php echo esc_attr($http_headers_feature); ?>]" |
| 95 |
class="http-header-value"<?php echo $http_headers_permissions_policy == 1 ? NULL : ' readonly'; ?>> |
| 96 |
<?php |
| 97 |
foreach ($http_headers_origins as $http_headers_origin) |
| 98 |
{ |
| 99 |
?><option value="<?php echo esc_attr($http_headers_origin); ?>"<?php isset($http_headers_permissions_policy_value[$http_headers_feature]) ? selected($http_headers_permissions_policy_value[$http_headers_feature], $http_headers_origin) : NULL; ?>><?php echo esc_html($http_headers_origin); ?></option><?php |
| 100 |
} |
| 101 |
?> |
| 102 |
</select> |
| 103 |
<input type="text" name="hh_permissions_policy_origin[<?php echo esc_attr($http_headers_feature); ?>]" |
| 104 |
value="<?php echo isset($http_headers_permissions_policy_origin[$http_headers_feature]) ? esc_attr( $http_headers_permissions_policy_origin[$http_headers_feature] ) : NULL; ?>" size="30"<?php echo isset($http_headers_permissions_policy_value[$http_headers_feature]) && in_array($http_headers_permissions_policy_value[$http_headers_feature], array('origin(s)', 'self')) ? NULL : ' style="display: none"'; ?> |
| 105 |
class="http-header-value"<?php echo $http_headers_permissions_policy == 1 ? NULL : ' readonly'; ?>> |
| 106 |
</td> |
| 107 |
</tr> |
| 108 |
<?php |
| 109 |
} |
| 110 |
?> |
| 111 |
</tbody> |
| 112 |
</table> |
| 113 |
</td> |
| 114 |
</td> |
| 115 |
</tr> |