| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
$content_security_policy = get_option('hh_content_security_policy', 0); |
| 6 |
?> |
| 7 |
<tr valign="top"> |
| 8 |
<th scope="row">Content Security Policy |
| 9 |
<p class="description"><?php _e('Content Security Policy (CSP) is an added layer of security that helps to detect and mitigate certain types of attacks, including Cross Site Scripting (XSS) and data injection attacks. These attacks are used for everything from data theft to site defacement or distribution of malware.', 'http-headers'); ?></p> |
| 10 |
|
| 11 |
<p> |
| 12 |
<label><input type="checkbox" class="http-header-value" |
| 13 |
name="hh_content_security_policy_report_only" value="1" |
| 14 |
<?php checked(get_option('hh_content_security_policy_report_only'), 1, true); ?> |
| 15 |
<?php echo $content_security_policy == 1 ? NULL : ' readonly'; ?> /> "Report-Only" (<?php _e('for reporting-only purposes', 'http-headers'); ?>)</label> |
| 16 |
</p> |
| 17 |
</th> |
| 18 |
<td> |
| 19 |
<fieldset> |
| 20 |
<legend class="screen-reader-text">Content-Security-Policy</legend> |
| 21 |
<?php |
| 22 |
foreach ($bools as $k => $v) |
| 23 |
{ |
| 24 |
?><p><label><input type="radio" class="http-header" name="hh_content_security_policy" value="<?php echo $k; ?>"<?php checked($content_security_policy, $k, true); ?> /> <?php echo $v; ?></label></p><?php |
| 25 |
} |
| 26 |
?> |
| 27 |
</fieldset> |
| 28 |
</td> |
| 29 |
<td> |
| 30 |
<?php settings_fields( 'http-headers-csp' ); ?> |
| 31 |
<?php do_settings_sections( 'http-headers-csp' ); ?> |
| 32 |
<table> |
| 33 |
<thead> |
| 34 |
<tr> |
| 35 |
<th><?php _e('Directive', 'http-headers'); ?></th> |
| 36 |
<th><?php _e('Value', 'http-headers'); ?></th> |
| 37 |
</tr> |
| 38 |
</thead> |
| 39 |
<tbody> |
| 40 |
<?php |
| 41 |
$directives = array('default-src', 'script-src', 'style-src', 'img-src', 'connect-src', |
| 42 |
'font-src', 'media-src', 'sandbox', 'report-uri', 'child-src', 'form-action', |
| 43 |
'frame-ancestors', 'plugin-types', |
| 44 |
'object-src', 'frame-src', 'worker-src', 'manifest-src', 'base-uri', 'report-to', |
| 45 |
); |
| 46 |
$csp = get_option('hh_content_security_policy_value'); |
| 47 |
foreach ($directives as $item) |
| 48 |
{ |
| 49 |
?> |
| 50 |
<tr> |
| 51 |
<td><?php echo $item; ?></td> |
| 52 |
<td class="hh-td-inner" valign="middle"> |
| 53 |
<input type="text" name="hh_content_security_policy_value[<?php echo $item; ?>]" class="http-header-value" size="40" |
| 54 |
value="<?php echo esc_attr(@$csp[$item]); ?>"<?php echo $content_security_policy == 1 ? NULL : ' readonly'; ?>> |
| 55 |
</td> |
| 56 |
</tr> |
| 57 |
<?php |
| 58 |
} |
| 59 |
?> |
| 60 |
</tbody> |
| 61 |
</table> |
| 62 |
</td> |
| 63 |
</tr> |