Настройка на сайте Content Security Policy с директивой frame-ancestors

Content-Security-Policy — добавляется в заголовок ответа сайта.

В вордпресе можно сделать так, добавить код в файл functions.php своей темы

function add_csp_frame_ancestors_header() {
	if (!is_admin()) {
			header("Content-Security-Policy: frame-ancestors 'self';");
	}
}
add_action('send_headers', 'add_csp_frame_ancestors_header');

Оцените статью
Добавить комментарий