add_field( array( 'name' => 'Add Content Security Policy', 'desc' => 'Upgrade insecure requests and block all mixed content.', 'id' => 'add_content_security_policy', 'type' => 'checkbox', ) ); return $cmb; } /** * Add the AdThrive ads script */ public function csp_head() { $add_content_security_policy = \AdThrive_Ads\Options::get( 'add_content_security_policy' ); $https_forwarded = isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' === $_SERVER['HTTP_X_FORWARDED_PROTO']; $ssl = is_ssl() || $https_forwarded; if ( $ssl && isset( $add_content_security_policy ) && 'on' === $add_content_security_policy ) { require 'partials/content-security-policy.php'; } } }