PluginProbe
NETSENSAI Shield / 1.2
NETSENSAI Shield v1.2
1.6.1 trunk 1.1 1.2 1.3 1.4 1.4.1 1.4.2 1.4.3 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.6.0
netsensai-shield / includes / apply_hsts_header.php

apply_hsts_header.php in NETSENSAI Shield 1.2, at includes/apply_hsts_header.php

23 lines 692 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // Exit if accessed directly.
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 /**
8 * Apply HSTS Header.
9 *
10 * Applies the Strict-Transport-Security header if the 'ns_shield_hsts' option is enabled
11 * and the current connection is secure (HTTPS). This header instructs browsers to only
12 * access the site over HTTPS for a specified period.
13 *
14 * @return void
15 */
16 function ns_shield_apply_hsts_header() {
17 // Apply HSTS only on secure connections.
18 if ( is_ssl() && get_option( 'ns_shield_hsts' ) ) {
19 header( 'Strict-Transport-Security: max-age=31536000; includeSubDomains; preload' );
20 }
21 }
22 add_action( 'send_headers', 'ns_shield_apply_hsts_header' );
23