@@ -594,28 +594,25 @@ function apbct_hook__wp_footer()
594594 } " ;
595595 }
596596
597- $ cookie_bot_asset = (class_exists ('Cookiebot_WP ' )) ? 'data-cookieconsent="ignore" ' : '' ;
597+ $ script_attrs = array ();
598+ if ( class_exists ('Cookiebot_WP ' ) ) {
599+ $ script_attrs ['data-cookieconsent ' ] = 'ignore ' ;
600+ }
598601
599- $ script =
600- '<script ' . $ cookie_bot_asset
601- . ">
602- document.addEventListener('DOMContentLoaded', function () {
602+ $ script = apbct_get_inline_script_tag (
603+ "document.addEventListener('DOMContentLoaded', function () {
603604 setTimeout(function(){
604605 if( document.querySelectorAll('[name^=ct_checkjs]').length > 0 ) {
605606 " . $ send_way_asset . "
606607 }
607- }, " . $ timeout . ")
608- })
609- </script> " ;
608+ }, " . $ timeout . ")
609+ }) " ,
610+ $ script_attrs
611+ );
610612
611613 echo Escape::escKses (
612614 $ script ,
613- array (
614- 'script ' => array (
615- 'type ' => true ,
616- 'data-cookieconsent ' => true
617- )
618- )
615+ apbct_get_inline_script_kses ()
619616 );
620617 }
621618}
@@ -674,18 +671,24 @@ function ct_add_hidden_fields(
674671 return ;
675672 }
676673
674+ $ script_attrs = array ();
675+ if ( class_exists ('Cookiebot_WP ' ) ) {
676+ $ script_attrs ['data-cookieconsent ' ] = 'ignore ' ;
677+ }
678+
677679 $ ct_input_challenge = sprintf ("'%s' " , is_null ($ ct_checkjs_key ) ? $ ct_checkjs_def : $ ct_checkjs_key );
678680 $ field_id = $ field_name . '_ ' . $ field_id_hash ;
679- $ html = "<input type= \"hidden \" id= \"{$ field_id }\" name= \"{$ field_name }\" value= \"{$ ct_checkjs_def }\" />
680- <script " . ( class_exists ( ' Cookiebot_WP ' ) ? ' data-cookieconsent="ignore" ' : '' ) . " >
681- setTimeout(function(){
681+ $ html = "<input type= \"hidden \" id= \"{$ field_id }\" name= \"{$ field_name }\" value= \"{$ ct_checkjs_def }\" /> "
682+ . apbct_get_inline_script_tag (
683+ " setTimeout(function(){
682684 var ct_input_name = \"{$ field_id }\";
683685 if (document.getElementById(ct_input_name) !== null) {
684686 var ct_input_value = document.getElementById(ct_input_name).value;
685687 document.getElementById(ct_input_name).value = document.getElementById(ct_input_name).value.replace(ct_input_value, {$ ct_input_challenge });
686688 }
687- }, 1000);
688- </script> " ;
689+ }, 1000); " ,
690+ $ script_attrs
691+ );
689692 }
690693
691694 // Simplify JS code and Fixing issue with wpautop()
@@ -696,17 +699,16 @@ function ct_add_hidden_fields(
696699 } else {
697700 echo Escape::escKses (
698701 $ html ,
699- array (
700- 'script ' => array (
701- 'type ' => true ,
702- 'data-cookieconsent ' => true
703- ),
702+ array_merge (
703+ apbct_get_inline_script_kses (),
704+ array (
704705 'input ' => array (
705706 'type ' => true ,
706707 'id ' => true ,
707708 'name ' => true ,
708709 'value ' => true
709710 )
711+ )
710712 )
711713 );
712714 }
0 commit comments