| @@ -19,8 +19,16 @@ | ||
| 19 | 19 | // No update required |
| 20 | 20 | if($current_version == COOKIEADMIN_VERSION){ |
| 21 | 21 | return true; |
| 22 | 22 | } |
| 23 | + | |
| 24 | + // We added a option to disable Script Delaying | |
| 25 | + if($version < 120){ | |
| 26 | + $settings = get_option('cookieadmin_settings', []); | |
| 27 | + $settings['block_scripts'] = true; | |
| 28 | + | |
| 29 | + update_option('cookieadmin_settings', $settings); | |
| 30 | + } | |
| 23 | 31 | |
| 24 | 32 | // Save the new Version |
| 25 | 33 | update_option('cookieadmin_version', COOKIEADMIN_VERSION); |
| 26 | 34 | |
| @@ -61,9 +69,13 @@ | ||
| 61 | 69 | |
| 62 | 70 | add_action('wp_enqueue_scripts', '\CookieAdmin\Enduser::enqueue_scripts'); |
| 63 | 71 | |
| 64 | 72 | // Insert Cookie blocker in the head. |
| 65 | - //add_action('send_headers', '\CookieAdmin\Enduser::cookieadmin_block_cookie_init_php', 100); | |
| 73 | + add_action('send_headers', '\CookieAdmin\Enduser::cookieadmin_block_cookie_init_php', 100); | |
| 74 | + add_filter( 'rest_pre_serve_request', function ( $served ) { | |
| 75 | + \CookieAdmin\Enduser::cookieadmin_block_cookie_init_php(); | |
| 76 | + return $served; | |
| 77 | + }, 999 ); | |
| 66 | 78 | // add_action('init', '\CookieAdmin\Enduser::cookieadmin_block_cookie_head_js', 0); |
| 67 | 79 | |
| 68 | 80 | //add Cookie Banner to user page |
| 69 | 81 | if(!cookieadmin_is_editor_mode()){ |
| @@ -69,9 +81,9 @@ | ||
| 69 | 81 | if(!cookieadmin_is_editor_mode()){ |
| 70 | 82 | add_action('wp_footer', '\CookieAdmin\Enduser::cookieadmin_show_banner'); |
| 71 | 83 | } |
| 72 | 84 | |
| 73 | - add_filter('script_loader_tag', '\CookieAdmin\Enduser::check_if_cookies_allowed', 10, 3); | |
| 85 | + add_action('template_redirect', '\CookieAdmin\Enduser::block_scripts', 1); | |
| 74 | 86 | |
| 75 | 87 | } |
| 76 | 88 | |
| 77 | 89 | function cookieadmin_load_plugin_admin(){ |
| @@ -110,8 +122,18 @@ | ||
| 110 | 122 | if (isset($_GET['pagelayer-live']) || isset($_GET['fl_builder'])) { |
| 111 | 123 | return true; |
| 112 | 124 | } |
| 113 | 125 | |
| 126 | + // Avada builder | |
| 127 | + if(isset($_GET['fb-edit']) || isset($_GET['builder']) || isset($_GET['builder_id'])){ | |
| 128 | + return true; | |
| 129 | + } | |
| 130 | + | |
| 131 | + // Bricks Builder | |
| 132 | + if(isset($_GET['bricks']) || isset($_GET['brickspreview'])){ | |
| 133 | + return true; | |
| 134 | + } | |
| 135 | + | |
| 114 | 136 | if(isset($_GET['vc_action']) && $_GET['vc_action'] == 'vc_inline'){ |
| 115 | 137 | return true; |
| 116 | 138 | } |
| 117 | 139 | |
| @@ -118,8 +140,12 @@ | ||
| 118 | 140 | if(isset($_GET['elementor-preview']) || (isset($_GET['action']) && $_GET['action'] == 'elementor')){ |
| 119 | 141 | return true; |
| 120 | 142 | } |
| 121 | 143 | |
| 144 | + if(isset($_GET['et_fb']) && ($_GET['et_fb'] == 1)){ | |
| 145 | + return true; | |
| 146 | + } | |
| 147 | + | |
| 122 | 148 | return false; |
| 123 | 149 | |
| 124 | 150 | } |
| 125 | 151 | |
| @@ -138,9 +164,11 @@ | ||
| 138 | 164 | 'scan_cookies' => '\CookieAdmin\Admin\Scan::scan_cookies_ajax', |
| 139 | 165 | 'cookieadmin-edit-cookie' => '\CookieAdmin\Admin\Scan::edit_cookies', |
| 140 | 166 | 'cookieadmin-delete-cookie' => '\CookieAdmin\Admin\Scan::delete_cookies', |
| 141 | 167 | 'close-update-notice' => '\CookieAdmin\Admin::close_plugin_update_notice', |
| 142 | - 'close-notice' => '\CookieAdmin\Admin::close_notices' | |
| 168 | + 'close-notice' => '\CookieAdmin\Admin::close_notices', | |
| 169 | + 'install_recommended_plugin' => '\CookieAdmin\Admin\Dashboard::install_recommended_plugin', | |
| 170 | + 'activate_recommended_plugin' => '\CookieAdmin\Admin\Dashboard::activate_recommended_plugin', | |
| 143 | 171 | ); |
| 144 | 172 | |
| 145 | 173 | $general_actions = array( |
| 146 | 174 | 'categorize_cookies' => 'cookieadmin_categorize_cookies', |
| @@ -207,53 +235,70 @@ | ||
| 207 | 235 | $cookieadmin_powered_by_html = apply_filters('cookieadmin_powered_by_html', $cookieadmin_powered_by_html); |
| 208 | 236 | $privacy_policy_links = apply_filters('cookieadmin_privacy_policy_links', array(), $policy); |
| 209 | 237 | $reconsent_icon_url = apply_filters('cookieadmin_reconsent_icon_url', '', $policy); |
| 210 | 238 | |
| 211 | - return [ | |
| 212 | - 'override_gpc' => apply_filters('cookieadmin_override_gpc_html', ''), | |
| 213 | - 'powered_by_html' => $cookieadmin_powered_by_html, | |
| 214 | - 'banner_policy_links' => !empty($privacy_policy_links['banner']) ? $privacy_policy_links['banner'] : '', | |
| 215 | - 'modal_policy_links' => !empty($privacy_policy_links['modal']) ? $privacy_policy_links['modal'] : '', | |
| 216 | - 'reconsent_icon_url' => esc_url($reconsent_icon_url), | |
| 217 | - 'logo_svg' => cookieadmin_logo_svg(), | |
| 218 | - 'plugin_url' => esc_url(COOKIEADMIN_PLUGIN_URL), | |
| 219 | - 'powered_by' => __('Powered by', 'cookieadmin'), | |
| 220 | - 'reconsent' => __('Re-consent', 'cookieadmin'), | |
| 221 | - 'cookie_preferences' => __('Cookie Preferences', 'cookieadmin'), | |
| 222 | - 'remark_standard' => __('Always Active', 'cookieadmin'), | |
| 223 | - 'remark' => __('Remark', 'cookieadmin'), | |
| 224 | - 'none' => __('None', 'cookieadmin'), | |
| 225 | - 'necessary_cookies' => __('Necessary Cookies', 'cookieadmin'), | |
| 226 | - 'necessary_cookies_desc' => __('Necessary cookies enable essential site features like secure log-ins and consent preference adjustments. They do not store personal data.', 'cookieadmin'), | |
| 227 | - 'functional_cookies' => __('Functional Cookies', 'cookieadmin'), | |
| 228 | - 'functional_cookies_desc' => __('Functional cookies support features like content sharing on social media, collecting feedback, and enabling third-party tools.', 'cookieadmin'), | |
| 229 | - 'analytical_cookies' => __('Analytical Cookies', 'cookieadmin'), | |
| 230 | - 'analytical_cookies_desc' => __('Analytical cookies track visitor interactions, providing insights on metrics like visitor count, bounce rate, and traffic sources.', 'cookieadmin'), | |
| 231 | - 'advertisement_cookies' => __('Advertisement Cookies', 'cookieadmin'), | |
| 232 | - 'advertisement_cookies_desc' => __('Advertisement cookies deliver personalized ads based on your previous visits and analyze the effectiveness of ad campaigns.', 'cookieadmin'), | |
| 233 | - 'unclassified_cookies' => __('Unclassified Cookies', 'cookieadmin'), | |
| 234 | - 'unclassified_cookies_desc' => __('Unclassified cookies are cookies that we are in the process of classifying, together with the providers of individual cookies.', 'cookieadmin'), | |
| 235 | - ]; | |
| 239 | + $strings = [ | |
| 240 | + 'override_gpc' => apply_filters('cookieadmin_override_gpc_html', ''), | |
| 241 | + 'powered_by_html' => $cookieadmin_powered_by_html, | |
| 242 | + 'banner_policy_links' => !empty($privacy_policy_links['banner']) ? $privacy_policy_links['banner'] : '', | |
| 243 | + 'modal_policy_links' => !empty($privacy_policy_links['modal']) ? $privacy_policy_links['modal'] : '', | |
| 244 | + 'reconsent_icon_url' => esc_url($reconsent_icon_url), | |
| 245 | + 'logo_svg' => cookieadmin_logo_svg(), | |
| 246 | + 'plugin_url' => esc_url(COOKIEADMIN_PLUGIN_URL), | |
| 247 | + 'powered_by' => __('Powered by', 'cookieadmin'), | |
| 248 | + 'reconsent' => __('Re-consent', 'cookieadmin'), | |
| 249 | + 'close' => __('Close', 'cookieadmin'), | |
| 250 | + 'cookie_consent' => __('Cookie Consent', 'cookieadmin'), | |
| 251 | + 'cookie_preferences' => __('Cookie Preferences', 'cookieadmin'), | |
| 252 | + 'remark_standard' => __('Always Active', 'cookieadmin'), | |
| 253 | + 'remark' => __('Remark', 'cookieadmin'), | |
| 254 | + 'none' => __('None', 'cookieadmin'), | |
| 255 | + 'necessary_cookies' => __('Necessary Cookies', 'cookieadmin'), | |
| 256 | + 'necessary_cookies_desc' => __('Necessary cookies enable essential site features like secure log-ins and consent preference adjustments. They do not store personal data.', 'cookieadmin'), | |
| 257 | + 'functional_cookies' => __('Functional Cookies', 'cookieadmin'), | |
| 258 | + 'functional_cookies_desc' => __('Functional cookies support features like content sharing on social media, collecting feedback, and enabling third-party tools.', 'cookieadmin'), | |
| 259 | + 'analytical_cookies' => __('Analytical Cookies', 'cookieadmin'), | |
| 260 | + 'analytical_cookies_desc' => __('Analytical cookies track visitor interactions, providing insights on metrics like visitor count, bounce rate, and traffic sources.', 'cookieadmin'), | |
| 261 | + 'advertisement_cookies' => __('Advertisement Cookies', 'cookieadmin'), | |
| 262 | + 'advertisement_cookies_desc' => __('Advertisement cookies deliver personalized ads based on your previous visits and analyze the effectiveness of ad campaigns.', 'cookieadmin'), | |
| 263 | + 'unclassified_cookies' => __('Unclassified Cookies', 'cookieadmin'), | |
| 264 | + 'unclassified_cookies_desc' => __('Unclassified cookies are cookies that we are in the process of classifying, together with the providers of individual cookies.', 'cookieadmin'), | |
| 265 | + ]; | |
| 266 | + | |
| 267 | + return apply_filters('cookieadmin_default_strings', $strings); | |
| 236 | 268 | } |
| 237 | 269 | |
| 238 | 270 | //Loads consent data from file |
| 239 | 271 | function cookieadmin_load_consent_template($policy, $view){ |
| 240 | 272 | |
| 273 | + $template = array(); | |
| 274 | + | |
| 241 | 275 | if(!file_exists(COOKIEADMIN_DIR.'assets/cookie/template.php')){ |
| 242 | - return false; | |
| 276 | + if(defined('WP_DEBUG') && WP_DEBUG){ | |
| 277 | + error_log('CookieAdmin: template file missing'); | |
| 278 | + } | |
| 279 | + return $template; | |
| 243 | 280 | } |
| 244 | 281 | |
| 245 | 282 | include_once(COOKIEADMIN_DIR.'assets/cookie/template.php'); |
| 246 | 283 | |
| 247 | 284 | if(empty($content)){ |
| 248 | - return false; | |
| 285 | + if(defined('WP_DEBUG') && WP_DEBUG){ | |
| 286 | + error_log('CookieAdmin: Could not load template file'); | |
| 287 | + } | |
| 288 | + return $template; | |
| 249 | 289 | } |
| 250 | 290 | |
| 251 | - $template = array(); | |
| 252 | 291 | $template[$view] = ($policy['cookieadmin_layout'] != 'popup') ? $content['cookieadmin_layout'][$policy['cookieadmin_layout']] : ''; |
| 253 | 292 | $template[$view] .= $content['cookieadmin_modal'][$policy['cookieadmin_modal']]; |
| 254 | - $template[$view] .= $content['cookieadmin_reconsent']; | |
| 255 | 293 | |
| 294 | + global $cookieadmin_settings; | |
| 295 | + | |
| 296 | + // Show consent only if hide reconsent is not enabled | |
| 297 | + if(defined('COOKIEADMIN_PRO_VERSION') && empty($cookieadmin_settings['hide_reconsent'])){ | |
| 298 | + $template[$view] .= $content['cookieadmin_reconsent']; | |
| 299 | + } | |
| 300 | + | |
| 256 | 301 | $cookieadmin_strings = cookieadmin_load_strings($policy); |
| 257 | 302 | |
| 258 | 303 | foreach($cookieadmin_strings as $ck => $cv){ |
| 259 | 304 | $template[$view] = str_replace('[['.$ck.']]', $cv, $template[$view]); |
| @@ -259,9 +304,9 @@ | ||
| 259 | 304 | $template[$view] = str_replace('[['.$ck.']]', $cv, $template[$view]); |
| 260 | 305 | } |
| 261 | 306 | |
| 262 | 307 | $template[$view] = apply_filters('cookieadmin_consent_banner_template', $template[$view]); |
| 263 | - | |
| 308 | + | |
| 264 | 309 | return $template; |
| 265 | 310 | |
| 266 | 311 | } |
| 267 | 312 | |
| @@ -448,8 +493,11 @@ | ||
| 448 | 493 | 'placeholder' => true, |
| 449 | 494 | ); |
| 450 | 495 | |
| 451 | 496 | $allowed_tags['defs'] = array(); |
| 497 | + | |
| 498 | + // aria-modal is not part of the wp_kses post-context globals | |
| 499 | + $allowed_tags['div']['aria-modal'] = true; | |
| 452 | 500 | |
| 453 | 501 | $allowed_tags['a'] = array( |
| 454 | 502 | 'href' => true, |
| 455 | 503 | 'target' => true, |