| @@ -146,8 +146,22 @@ | ||
| 146 | 146 | </div> |
| 147 | 147 | </div> |
| 148 | 148 | |
| 149 | 149 | <div class="cookieadmin-setting"> |
| 150 | + <label class="cookieadmin-title" for="cookieadmin_google_advance_consent_mode">'.esc_html__('Load Google tags before consent', 'cookieadmin').' | |
| 151 | + <span class="dashicons dashicons-info cookieadmin-tooltip-box" data-tip="'.esc_html__('Google tags will fire immediately on the page load before consent.', 'cookieadmin').'"></span> | |
| 152 | + </label> | |
| 153 | + <div class="cookieadmin-setting-contents"> | |
| 154 | + <label class="cookieadmin-toggle-wrap"> | |
| 155 | + <input name="cookieadmin_google_advance_consent_mode" type="checkbox" id="cookieadmin_google_advance_consent_mode" '.(!empty($cookieadmin_settings['cookieadmin_google_advance_consent_mode']) && cookieadmin_is_pro() ? 'checked' : '').'> | |
| 156 | + <div class="cookieadmin-toggle-track"> | |
| 157 | + <div class="cookieadmin-toggle-thumb"></div> | |
| 158 | + </div> | |
| 159 | + </label> | |
| 160 | + </div> | |
| 161 | + </div> | |
| 162 | + | |
| 163 | + <div class="cookieadmin-setting"> | |
| 150 | 164 | <label class="cookieadmin-title" for="cookieadmin_clarity_consent">'.esc_html__('Clarity Consent Mode V2', 'cookieadmin').' |
| 151 | 165 | <span class="dashicons dashicons-info cookieadmin-tooltip-box" data-tip="'.esc_html__('Enable Microsoft Clarity consent mode v2.', 'cookieadmin').'"></span> |
| 152 | 166 | </label> |
| 153 | 167 | <div class="cookieadmin-setting-contents"> |
| @@ -324,8 +338,11 @@ | ||
| 324 | 338 | if(!empty($_REQUEST['cookieadmin_content_blocking_services'])){ |
| 325 | 339 | $cookieadmin_settings['content_blocking_services'] = array_map('sanitize_text_field', wp_unslash($_REQUEST['cookieadmin_content_blocking_services'])); |
| 326 | 340 | } |
| 327 | 341 | |
| 342 | + // Google's advance consent mode (Google tags will be loaded on page load is enabled) | |
| 343 | + $cookieadmin_settings['cookieadmin_google_advance_consent_mode'] = (isset( $_REQUEST['cookieadmin_google_advance_consent_mode'] ) ? 1 : 0); | |
| 344 | + | |
| 328 | 345 | if(empty($cookieadmin_error)){ |
| 329 | 346 | update_option('cookieadmin_settings', $cookieadmin_settings); |
| 330 | 347 | } |
| 331 | 348 | |
| @@ -344,8 +361,19 @@ | ||
| 344 | 361 | |
| 345 | 362 | //set preload and consent field for "cookieadmin-settings" page |
| 346 | 363 | $policy[$law]['preload'] = !empty($_REQUEST['cookieadmin_preload']) ? array_map('sanitize_text_field', wp_unslash($_REQUEST['cookieadmin_preload'])) : []; |
| 347 | 364 | $policy[$law]['reload_on_consent'] = !empty($_REQUEST['cookieadmin_reload_on_consent']) ? sanitize_text_field(wp_unslash($_REQUEST['cookieadmin_reload_on_consent'])) : ''; |
| 365 | + | |
| 366 | + // Check for certain fields to be saved only if their values is not the same as default | |
| 367 | + $cookieadmin_check_changes = array('cookieadmin_notice_title', 'cookieadmin_notice', 'cookieadmin_preference_title', 'cookieadmin_preference', 'reConsent_title', 'cookieadmin_customize_btn', 'cookieadmin_reject_btn', 'cookieadmin_accept_btn', 'cookieadmin_save_btn'); | |
| 368 | + | |
| 369 | + foreach($cookieadmin_check_changes as $c_field){ | |
| 370 | + foreach($policy as $c_law => $c_val){ | |
| 371 | + if(!empty($c_val[$c_field]) && $c_val[$c_field] == $cookieadmin_policies[$c_law][$c_field]){ | |
| 372 | + unset($policy[$c_law][$c_field]); | |
| 373 | + } | |
| 374 | + } | |
| 375 | + } | |
| 348 | 376 | |
| 349 | 377 | update_option('cookieadmin_consent_settings', $policy); |
| 350 | 378 | |
| 351 | 379 | if(empty($cookieadmin_error)){ |