fix
This commit is contained in:
@@ -452,7 +452,7 @@ add_filter( 'template_include', 'twentytwentyfour_single_post_template', 25 );
|
||||
* @return void
|
||||
*/
|
||||
function twentytwentyfour_test1_assets() {
|
||||
$use_test1_assets = is_front_page() || is_home() || is_singular( 'post' ) || is_page( array( 'test1', 'faq', 'contacts', 'delivery', 'service' ) );
|
||||
$use_test1_assets = is_front_page() || is_home() || is_singular( 'post' ) || is_page( array( 'test1', 'faq', 'contacts', 'delivery', 'service' ) ) || twentytwentyfour_is_privacy_policy_request();
|
||||
|
||||
if ( ! $use_test1_assets ) {
|
||||
return;
|
||||
@@ -648,6 +648,10 @@ function twentytwentyfour_submit_lead_ajax() {
|
||||
$form_type = isset( $_POST['form_type'] ) ? sanitize_key( wp_unslash( $_POST['form_type'] ) ) : 'contacts_page';
|
||||
$page_url = isset( $_POST['page_url'] ) ? esc_url_raw( wp_unslash( $_POST['page_url'] ) ) : '';
|
||||
|
||||
if ( empty( $_POST['privacy_consent'] ) ) {
|
||||
wp_send_json_error( array( 'message' => __( 'Необходимо согласиться на обработку персональных данных.', 'twentytwentyfour' ) ), 422 );
|
||||
}
|
||||
|
||||
if ( 'contacts' === $form_type ) {
|
||||
$form_type = false !== strpos( $page_url, '/contacts' ) ? 'contacts_page' : 'landing_contacts';
|
||||
}
|
||||
@@ -728,6 +732,96 @@ function twentytwentyfour_submit_lead_ajax() {
|
||||
add_action( 'wp_ajax_twentytwentyfour_submit_lead', 'twentytwentyfour_submit_lead_ajax' );
|
||||
add_action( 'wp_ajax_nopriv_twentytwentyfour_submit_lead', 'twentytwentyfour_submit_lead_ajax' );
|
||||
|
||||
function twentytwentyfour_is_privacy_policy_request() {
|
||||
if ( is_admin() || empty( $_SERVER['REQUEST_URI'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$request_path = trim( wp_parse_url( wp_unslash( $_SERVER['REQUEST_URI'] ), PHP_URL_PATH ), '/' );
|
||||
|
||||
return 'privacy-policy' === $request_path;
|
||||
}
|
||||
|
||||
function twentytwentyfour_privacy_policy_url() {
|
||||
return home_url( '/privacy-policy/' );
|
||||
}
|
||||
|
||||
function twentytwentyfour_privacy_policy_template() {
|
||||
if ( twentytwentyfour_is_privacy_policy_request() ) {
|
||||
status_header( 200 );
|
||||
include get_theme_file_path( 'page-privacy-policy.php' );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
add_action( 'template_redirect', 'twentytwentyfour_privacy_policy_template', 0 );
|
||||
|
||||
function twentytwentyfour_privacy_consent_checkbox() {
|
||||
?>
|
||||
<label class="personal-data-consent">
|
||||
<input type="checkbox" name="privacy_consent" value="1" required>
|
||||
<span><?php echo wp_kses_post( sprintf( __( 'Согласен(на) на обработку персональных данных и принимаю <a href="%s">Политику конфиденциальности</a>', 'twentytwentyfour' ), esc_url( twentytwentyfour_privacy_policy_url() ) ) ); ?></span>
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
|
||||
function twentytwentyfour_cookie_consent_banner() {
|
||||
?>
|
||||
<div class="cookie-consent-banner" data-cookie-consent-banner hidden>
|
||||
<p>
|
||||
<?php esc_html_e( 'Мы используем файлы cookie для улучшения работы сайта. Продолжая использовать сайт, Вы соглашаетесь с нашей', 'twentytwentyfour' ); ?>
|
||||
<a href="<?php echo esc_url( twentytwentyfour_privacy_policy_url() ); ?>"><?php esc_html_e( 'Политикой конфиденциальности', 'twentytwentyfour' ); ?></a>.
|
||||
</p>
|
||||
<button type="button" class="cookie-consent-accept" data-cookie-consent-accept><?php esc_html_e( 'Принять', 'twentytwentyfour' ); ?></button>
|
||||
</div>
|
||||
<script>
|
||||
(function () {
|
||||
var consentName = 'water_delivery_cookie_consent';
|
||||
var banner = document.querySelector('[data-cookie-consent-banner]');
|
||||
var acceptButton = document.querySelector('[data-cookie-consent-accept]');
|
||||
var privacyUrl = <?php echo wp_json_encode( twentytwentyfour_privacy_policy_url() ); ?>;
|
||||
var consentHtml = 'Согласен(на) на обработку персональных данных и принимаю <a href="' + privacyUrl + '">Политику конфиденциальности</a>';
|
||||
var hasConsent = document.cookie.split('; ').some(function (cookie) {
|
||||
return cookie === consentName + '=accepted';
|
||||
});
|
||||
|
||||
if (banner && !hasConsent) {
|
||||
banner.hidden = false;
|
||||
}
|
||||
|
||||
if (acceptButton) {
|
||||
acceptButton.addEventListener('click', function () {
|
||||
document.cookie = consentName + '=accepted; max-age=31536000; path=/; SameSite=Lax';
|
||||
if (banner) {
|
||||
banner.hidden = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.querySelectorAll('form').forEach(function (form) {
|
||||
var ignored = form.matches('.search-form, .woocommerce-cart-form, form[role="search"]');
|
||||
var hasPersonalFields = form.querySelector('input[type="email"], input[type="tel"], input[name*="phone"], input[name*="email"], textarea, .wpforms-submit, .wpcf7-submit');
|
||||
|
||||
if (ignored || !hasPersonalFields || form.querySelector('.personal-data-consent')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var field = document.createElement('label');
|
||||
field.className = 'personal-data-consent';
|
||||
field.innerHTML = '<input type="checkbox" name="privacy_consent" value="1" required> <span>' + consentHtml + '</span>';
|
||||
|
||||
var submit = form.querySelector('button[type="submit"], input[type="submit"], .wpforms-submit, .wpcf7-submit');
|
||||
if (submit && submit.parentNode) {
|
||||
submit.parentNode.insertBefore(field, submit);
|
||||
} else {
|
||||
form.appendChild(field);
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
add_action( 'wp_footer', 'twentytwentyfour_cookie_consent_banner', 20 );
|
||||
|
||||
/**
|
||||
* Send WooCommerce checkout orders to Telegram.
|
||||
*
|
||||
@@ -785,7 +879,7 @@ add_action( 'woocommerce_checkout_order_processed', 'twentytwentyfour_send_check
|
||||
* @return void
|
||||
*/
|
||||
function twentytwentyfour_test1_shared_shell_assets() {
|
||||
if ( ! ( ( function_exists( 'is_checkout' ) && is_checkout() && ! is_order_received_page() ) || ( function_exists( 'is_cart' ) && is_cart() ) || ( function_exists( 'is_shop' ) && is_shop() ) || is_home() || is_singular( 'post' ) || is_page( 'faq' ) || is_page( 'contacts' ) || is_page( 'delivery' ) || is_page( 'service' ) ) ) {
|
||||
if ( ! ( ( function_exists( 'is_checkout' ) && is_checkout() && ! is_order_received_page() ) || ( function_exists( 'is_cart' ) && is_cart() ) || ( function_exists( 'is_shop' ) && is_shop() ) || is_home() || is_singular( 'post' ) || is_page( 'faq' ) || is_page( 'contacts' ) || is_page( 'delivery' ) || is_page( 'service' ) || twentytwentyfour_is_privacy_policy_request() ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user