Changeset 3031643
- Timestamp:
- 02/05/2024 01:13:10 PM (2 years ago)
- Location:
- iubenda-cookie-law-solution/tags/beta
- Files:
-
- 12 added
- 32 edited
-
assets/css/radar_dashboard_widget.css (added)
-
assets/css/style.css (modified) (2 diffs)
-
assets/images/party-popper.svg (added)
-
assets/images/warning-icon-colored.svg (added)
-
assets/js/admin.js (modified) (6 diffs)
-
assets/js/radar.js (added)
-
assets/js/radar_dashboard_widget.js (added)
-
assets/js/tabs.js (modified) (1 diff)
-
includes/block/class-iubenda-legal-block.php (modified) (5 diffs)
-
includes/class-auto-blocking-script-appender.php (added)
-
includes/class-auto-blocking.php (added)
-
includes/class-cookie-solution-generator.php (modified) (3 diffs)
-
includes/class-iubenda-amp.php (modified) (12 diffs)
-
includes/class-iubenda-forms.php (modified) (18 diffs)
-
includes/class-iubenda-list-table-forms.php (modified) (6 diffs)
-
includes/class-iubenda-notice.php (modified) (3 diffs)
-
includes/class-iubenda-settings.php (modified) (17 diffs)
-
includes/class-language-helper.php (modified) (2 diffs)
-
includes/class-product-helper.php (modified) (2 diffs)
-
includes/class-quick-generator-service.php (modified) (1 diff)
-
includes/class-radar-dashboard-widget.php (added)
-
includes/class-radar-service.php (modified) (9 diffs)
-
includes/class-service-rating.php (modified) (3 diffs)
-
includes/class-sync-script-appender.php (added)
-
includes/functions.php (modified) (6 diffs)
-
includes/services/class-iubenda-code-extractor.php (modified) (8 diffs)
-
includes/services/class-iubenda-cs-product-service.php (modified) (7 diffs)
-
includes/widget/class-iubenda-legal-widget.php (modified) (4 diffs)
-
includes/widget/elementor/class-iubenda-elementor-legal-widget.php (modified) (4 diffs)
-
iubenda-cookie-class/README.md (modified) (1 diff)
-
iubenda-cookie-class/iubenda.class.php (modified) (2 diffs)
-
iubenda-init.php (added)
-
iubenda_cookie_solution.php (modified) (33 diffs)
-
readme.txt (modified) (4 diffs)
-
views/cons-single-form.php (modified) (5 diffs)
-
views/integrate-setup.php (modified) (3 diffs)
-
views/partials/amp-template-links.php (added)
-
views/partials/auto-block-section.php (added)
-
views/partials/cs-general-settings.php (modified) (7 diffs)
-
views/partials/cs-simplified-configuration.php (modified) (3 diffs)
-
views/partials/languages-tabs.php (modified) (3 diffs)
-
views/partials/modals/modal-almost-there.php (modified) (1 diff)
-
views/partials/product-card.php (modified) (1 diff)
-
views/products-page.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
iubenda-cookie-law-solution/tags/beta/assets/css/style.css
r2922322 r3031643 171 171 .mx-4 { 172 172 margin-left: 1.5rem !important; 173 } 174 175 .mxx-4 { 176 margin-left: 2.5rem !important; 173 177 } 174 178 … … 1161 1165 background-repeat: no-repeat; 1162 1166 background-position: center; 1167 } 1168 1169 .checkbox-regular input[type=checkbox]:disabled { 1170 cursor: not-allowed; 1163 1171 } 1164 1172 -
iubenda-cookie-law-solution/tags/beta/assets/js/admin.js
r2965748 r3031643 82 82 IUB.ELEMS.body.on( 'click', '.update-button-style', updateButtonStyle ); 83 83 IUB.ELEMS.body.on( 'change keyup past', '.iub-embed-code-tc, .iub-embed-code-pp', syncEmbedCode ); 84 IUB.ELEMS.body.on( 'change past', '.iub-embed-code-tc, .iub-embed-code-pp', syncEmbedCode ); 84 85 IUB.ELEMS.body.on( 'change click', '.iub-toggle-elements-status', toggleCheckboxes ); 85 86 IUB.ELEMS.body.on( 'click', '.legislation-checkbox', legislationDivVisibilityHandle ); 87 IUB.ELEMS.body.on( 'change', '.iub-embed-code-cs', updateFrontendAutoBlockingStatus); 88 IUB.ELEMS.body.on( 'change', '.cs-configuration-type', updateFrontendAutoBlockingStatus); 89 IUB.ELEMS.body.on( 'click', '.iub-language-tab', handleTabClickForCheckAutoBlockingStatus ); 90 IUB.ELEMS.body.on( 'change', '.blocking-method', handleChangeOfBlockingMethods ); 86 91 } 87 92 ); … … 229 234 500 230 235 ); 236 if (response.message_code != undefined && 'missing_legalisation' === response.message_code) { 237 return; 238 } 231 239 } 232 240 $( '#modal-no-website-found' ).addClass( 'shown' ) … … 654 662 } 655 663 } 656 ) .trigger( 'change' );657 664 ); 665 $('.cs-configuration-type:checked:first').trigger( 'change' ) 658 666 } 659 667 ); … … 864 872 let legislation_all_status = legislation_all.prop( "checked" ); 865 873 866 const div_visibility_structure = {867 'require-consent': [868 legislation_all_status,869 legislation_gdpr_status,870 legislation_lgpd_status,871 ],872 'require-consent-eu': [873 legislation_all_status,874 legislation_gdpr_status,875 ],876 'require-consent-br': [877 legislation_all_status,878 legislation_lgpd_status,879 ],880 'iab': [881 legislation_all_status,882 legislation_gdpr_status,883 ],884 }885 886 $.each(887 div_visibility_structure,888 function (index, conditions) {889 if (conditions.filter( Boolean ).length > 0) {890 $( '#' + index + '-div' ).removeClass( 'hidden' );891 $( '#' + index + '-div :input' ).attr( "disabled", false ).change();892 } else {893 $( '#' + index + '-div' ).addClass( 'hidden' );894 $( '#' + index + '-div :input' ).attr( "disabled", true ).attr( "checked", false ).change();895 }896 }897 )898 899 874 if (legislation_uspr_status || legislation_all_status) { 900 875 $( '#explicit-fieldset input:checkbox' ).each( … … 926 901 ); 927 902 928 $( document ).ready(929 function($){930 let activeRequest = false;931 let completed = false;932 setTimeout( ajax, 10 );933 934 function ajax(){935 if ((activeRequest) || (iub_js_vars['radar_status'] === 'completed')) {936 return;937 }938 activeRequest = true;939 $.ajax(940 {941 type: "post",942 dataType: "json",943 url: iub_js_vars['site_url'] + "/wp-admin/admin-ajax.php",944 data: {945 action: "radar_percentage_reload",946 iub_nonce: iub_js_vars['iub_radar_percentage_reload_nonce']947 },948 success: function(result){949 if (result.status === 'timeout') {950 activeRequest = false;951 setTimeout( ajax, (parseInt( result.data ) * 1000) );952 return953 }954 955 if (result.status === 'progress') {956 activeRequest = false;957 completed = true;958 setTimeout( ajax, 10000 );959 return960 }961 962 if (result.status === 'error') {963 handleAlertDiv( result.message )964 }965 966 if (result.status === 'complete' && completed) {967 if ($( '#frontpage-main-box' ).length) {968 $.ajax(969 {970 type: "post",971 url: iub_js_vars['site_url'] + "/wp-admin/admin-ajax.php",972 data: {973 action: "frontpage_main_box",974 iub_nonce: iub_js_vars['iub_frontpage_main_box_nonce']975 },976 success: function(response) {977 $( '#frontpage-main-box' ).html( response )978 document.querySelectorAll( ".circularBar" ).forEach(979 function (el) {980 $( el ).attr( 'data-perc', result.data.percentage );981 circularBar( el );982 }983 );984 },985 }986 );987 }988 }989 }990 }991 )992 }993 }994 );995 996 903 function handleAlertDiv(alertImageMessage) { 997 904 let alert_div = ("#alert-div") … … 1007 914 } 1008 915 } 916 917 /** 918 * Gets the code from the event target textarea, if available. 919 * @param {Event} evt - The event object. 920 * @returns {string} The code value. 921 */ 922 function getCodeFromEvent(evt) { 923 let targetTextarea = $(evt.target).data('target-textarea'); 924 return targetTextarea ? $(targetTextarea).val() : ''; 925 } 926 927 /** 928 * Updates the frontend auto-blocking status based on the event target value. 929 * @param {Event} evt - The event object. 930 */ 931 function updateFrontendAutoBlockingStatus(evt) { 932 let code = $(evt.target).val(); 933 if (code == 'manual') { 934 code = $('.iub-embed-code-cs-container.active textarea.iub-embed-code-cs').val(); 935 } 936 937 let configurationType = $('input[name="iubenda_cookie_law_solution[configuration_type]"]:checked').val(); 938 939 if (code !== null) { 940 fetchAjaxAutoBlockingStatus(code, configurationType); 941 } 942 } 943 944 /** 945 * Handles tab clicks to check the auto-blocking status. 946 * @param {Event} evt - The event object. 947 */ 948 function handleTabClickForCheckAutoBlockingStatus(evt) { 949 let code = getCodeFromEvent(evt); 950 let configurationType = $('input[name="iubenda_cookie_law_solution[configuration_type]"]:checked').val(); 951 952 if (code !== null) { 953 fetchAjaxAutoBlockingStatus(code, configurationType); 954 } 955 } 956 957 /** 958 * Fetches the auto-blocking status via Ajax and updates the UI. 959 * @param {string} code - The code value. 960 * @param {string} configurationType - The configuration type. 961 */ 962 function fetchAjaxAutoBlockingStatus(code, configurationType){ 963 let activeRequest = false; 964 if (activeRequest) { 965 return; 966 } 967 activeRequest = true; 968 969 $.ajax( 970 { 971 type: "post", 972 dataType: "json", 973 url: iub_js_vars['site_url'] + "/wp-admin/admin-ajax.php", 974 data: { 975 action: "check_frontend_auto_blocking_status", 976 code: code, 977 configuration_type: configurationType, 978 iub_nonce: iub_js_vars['check_frontend_auto_blocking_status'], 979 }, 980 success: function(response) { 981 $( '#frontend_auto_blocking' ).prop('checked', response).change() 982 toggleAutoBlockingMessageBox(response) 983 activeRequest = false; 984 }, 985 error: function() { 986 activeRequest = false; 987 }, 988 complete: function() { 989 activeRequest = false; 990 }, 991 } 992 ) 993 } 994 995 /** 996 * Toggles the visibility of the auto-blocking message box based on the provided flag. 997 * If shouldShow is true, the warning message is shown; if false, the info message is shown. 998 * @param {boolean} shouldShowWarning - A flag indicating whether to show the warning message (true) or info message (false). 999 */ 1000 function toggleAutoBlockingMessageBox(shouldShowWarning) { 1001 let warningEl = $('#auto-blocking-warning-message'); 1002 let infoEl = $('#auto-blocking-info-message'); 1003 1004 if (shouldShowWarning) { 1005 warningEl.removeClass('d-flex'); 1006 infoEl.addClass('d-flex'); 1007 } else { 1008 warningEl.addClass('d-flex'); 1009 infoEl.removeClass('d-flex'); 1010 } 1011 } 1012 1013 /** 1014 * Handles changes in blocking methods and displays a warning message if all blocking methods are disabled. 1015 */ 1016 function handleChangeOfBlockingMethods() { 1017 // Get all elements with class "blocking-method" 1018 let blockingMethods = $(".blocking-method"); 1019 1020 // Check if all blocking methods are false 1021 let allFalse = blockingMethods.toArray().every(function (element) { 1022 return !$(element).prop("checked"); 1023 }); 1024 1025 // Get the warning message element 1026 let bothBlockingMethodsDisabledWarningMessage = $("#both-blocking-methods-disabled-warning-message"); 1027 1028 // Show/hide the warning message based on the condition 1029 if (allFalse) { 1030 // If all blocking methods are disabled, display the warning message 1031 bothBlockingMethodsDisabledWarningMessage.addClass('d-flex'); 1032 } else { 1033 // If at least one blocking method is enabled, hide the warning message 1034 bothBlockingMethodsDisabledWarningMessage.removeClass('d-flex'); 1035 } 1036 } 1037 handleChangeOfBlockingMethods(); 1038 1009 1039 }(window, jQuery)); -
iubenda-cookie-law-solution/tags/beta/assets/js/tabs.js
r2848150 r3031643 23 23 24 24 groupTargets.hide(); 25 26 target.addClass( 'active' ); 25 27 target.show(); 26 28 -
iubenda-cookie-law-solution/tags/beta/includes/block/class-iubenda-legal-block.php
r2969392 r3031643 319 319 $block_name = (string) iub_array_get( $block, 'name' ); 320 320 321 if ( strpos( $block_name, 'footer-default' ) !== false ) {321 if ( 'twentytwentyfour/footer' === $block_name || strpos( $block_name, 'footer-default' ) !== false ) { 322 322 // Unregister default footer. 323 323 $block_registry->unregister( iub_array_get( $block, 'name' ) ); … … 385 385 * Remove specific string between $beginning and $end. 386 386 * 387 * @param string $beginning beginning.388 * @param string $end end.389 * @param string $ stringstring.387 * @param string $beginning beginning. 388 * @param string $end end. 389 * @param string $target_string string. 390 390 * 391 391 * @return mixed 392 392 */ 393 private function iub_delete_in_between( $beginning, $end, $ string ) {394 $beginning_pos = strpos( $ string, $beginning );395 $end_pos = strpos( $ string, $end );393 private function iub_delete_in_between( $beginning, $end, $target_string ) { 394 $beginning_pos = strpos( $target_string, $beginning ); 395 $end_pos = strpos( $target_string, $end ); 396 396 if ( false === $beginning_pos || false === $end_pos ) { 397 return $ string;398 } 399 400 $text_to_delete = substr( $ string, $beginning_pos, ( $end_pos + strlen( $end ) ) - $beginning_pos );397 return $target_string; 398 } 399 400 $text_to_delete = substr( $target_string, $beginning_pos, ( $end_pos + strlen( $end ) ) - $beginning_pos ); 401 401 402 402 // recursion to ensure occurrences are removed. 403 return $this->iub_delete_in_between( $beginning, $end, str_replace( $text_to_delete, '', $ string ) );403 return $this->iub_delete_in_between( $beginning, $end, str_replace( $text_to_delete, '', $target_string ) ); 404 404 } 405 405 … … 426 426 $previous_value = libxml_use_internal_errors( true ); 427 427 if ( function_exists( 'mb_encode_numericentity' ) ) { 428 $footer_content = (string) mb_encode_numericentity( $footer_content, [0x80, 0x10FFFF, 0, ~0], 'UTF-8');428 $footer_content = (string) mb_encode_numericentity( $footer_content, array( 0x80, 0x10FFFF, 0, ~0 ), 'UTF-8' ); 429 429 } 430 430 … … 480 480 */ 481 481 private function insert_iub_block_shortcode_into_footer_by_simple_html_dom( string $footer_content ) { 482 if ( ! function_exists( 'str_get_html' ) ) { 483 return false; 484 } 485 482 486 $html = str_get_html( $footer_content, true, true, false ); 483 487 … … 505 509 return $footer_content; 506 510 } 507 508 511 } -
iubenda-cookie-law-solution/tags/beta/includes/class-cookie-solution-generator.php
r2922322 r3031643 88 88 $cs_configuration['banner']['customizeButtonDisplay'] = true; 89 89 } 90 91 // If Require Consent is Users in Europe only.92 if ( 'eu_only' === $require_consent ) {93 $cs_configuration['countryDetection'] = true;94 $cs_configuration['gdprAppliesGlobally'] = false;95 }96 90 } 97 91 … … 120 114 } 121 115 122 // If legislation is USPR and Require Consent is Users in Europe only.123 if ( $legislation_uspr_status && 'eu_only' === $require_consent ) {124 $cs_configuration['gdprAppliesGlobally'] = false;125 }126 127 // If legislation Is USPR or ALL or Require Consent is Not Worldwide.128 if ( 'worldwide' !== $require_consent || $legislation_uspr_status || $legislation_all_status ) {129 $cs_configuration['countryDetection'] = true;130 }131 132 116 if ( $legislation_uspr_status || $legislation_lgpd_status || $legislation_all_status ) { 133 117 $cs_configuration['invalidateConsentWithoutLog'] = true; 134 if ( 'br_only' === $require_consent ) {135 $cs_configuration['lgpdAppliesGlobally'] = false;136 }137 118 } 138 119 … … 186 167 $after_configuration .= '<script type="text/javascript" src="https://plugins.trac.wordpress.org//cdn.iubenda.com/cs/iubenda_cs.js" charset="UTF-8" async></script>'; 187 168 169 $autoblocking_feature_status = iubenda()->iub_auto_blocking->is_autoblocking_feature_available( $site_id ); 170 if ( $autoblocking_feature_status ) { 171 // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript 172 $after_configuration .= '<script type="text/javascript" src="https://plugins.trac.wordpress.org//iubenda.com/autoblocking/" . $site_id . '.js" charset="UTF-8" async></script>'; 173 } else { 174 // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript 175 $after_configuration .= '<script type="text/javascript" src="https://plugins.trac.wordpress.org//iubenda.com/sync/" . $site_id . '.js" charset="UTF-8" async></script>'; 176 } 177 188 178 return $before_configuration . wp_json_encode( $cs_configuration ) . '; ' . $after_configuration; 189 179 } -
iubenda-cookie-law-solution/tags/beta/includes/class-iubenda-amp.php
r2859244 r3031643 86 86 * Add scripts and CSS to WP AMP plugin in Transitional mode. 87 87 * 88 * @return mixed88 * @return void 89 89 */ 90 90 public function wp_head_amp() { … … 135 135 * Add AMP consent HTML to WP AMP plugin in Transitional mode. 136 136 * 137 * @return mixed137 * @return void 138 138 */ 139 139 public function wp_footer_amp() { … … 159 159 // local file. 160 160 if ( 'local' === (string) iubenda()->options['cs']['amp_source'] ) { 161 // multi language support.161 // multi-language support. 162 162 if ( iubenda()->multilang && ! empty( iubenda()->lang_current ) ) { 163 163 $template_url = $this->get_amp_template_url( iubenda()->lang_current ); … … 166 166 } 167 167 // remote file. 168 } elseif ( iubenda()->multilang && ! empty( iubenda()->lang_current ) ) { 169 $template_url = esc_url( isset( iubenda()->options['cs']['amp_template'][ iubenda()->lang_current ] ) ? iubenda()->options['cs']['amp_template'][ iubenda()->lang_current ] : '' ); 168 170 } else { 169 // multi language support. 170 if ( iubenda()->multilang && ! empty( iubenda()->lang_current ) ) { 171 $template_url = esc_url( isset( iubenda()->options['cs']['amp_template'][ iubenda()->lang_current ] ) ? iubenda()->options['cs']['amp_template'][ iubenda()->lang_current ] : '' ); 172 } else { 173 $template_url = esc_url( iubenda()->options['cs']['amp_template'] ); 174 } 171 $template_url = esc_url( iubenda()->options['cs']['amp_template'] ); 175 172 } 176 173 … … 234 231 } 235 232 233 if ( ! class_exists( 'iubendaParser' ) ) { 234 return $data; 235 } 236 236 237 global $redux_builder_amp; 237 238 … … 260 261 } 261 262 263 if ( ! class_exists( 'iubendaParser' ) ) { 264 return $analytics_entries; 265 } 266 262 267 // block the analytics using the entries filter hook. 263 if ( ! iubendaParser::consent_given() && ! empty( $analytics_entries ) && is_array( $analytics_entries) ) {268 if ( is_array( $analytics_entries ) && ! empty( $analytics_entries ) && ! iubendaParser::consent_given() ) { 264 269 foreach ( $analytics_entries as $id => $entry ) { 265 270 $entry['attributes'] = ! empty( $entry['attributes'] ) ? $entry['attributes'] : array(); … … 282 287 $html = ''; 283 288 284 $configuration_raw = iubenda()->parse_configuration( $code ); 289 $configuration_raw = iubenda()->parse_configuration( $code ); 290 291 if ( empty( $configuration_raw ) ) { 292 $code = stripslashes( $code ); 293 $configuration_raw = iubenda()->parse_configuration( $code ); 294 } 295 285 296 $banner_configuration = iubenda()->parse_configuration( 286 297 $code, … … 307 318 $configuration = preg_replace( '/"([a-zA-Z]+[a-zA-Z0-9]*)":/', '$1:', $configuration ); 308 319 // replace first and last bracket. 309 $configuration = substr( $configuration, 1, - 1 );320 $configuration = substr( $configuration, 1, - 1 ); 310 321 311 322 // Here we are generating amp page, for this reason no need to use enqueue. … … 380 391 // get basic site host and template file data. 381 392 $file_url = ! empty( $template_lang ) ? IUBENDA_PLUGIN_URL . '/templates/amp-' . $template_lang . '.html' : IUBENDA_PLUGIN_URL . '/templates/amp.html'; 382 // phpcs:ignore Squiz.PHP.CommentedOutCode.Found 383 // $file_url = 'https://cdn.iubenda.com/cs/test/cs-for-amp.html'; // debug only. 393 384 394 $parsed_site = wp_parse_url( home_url() ); 385 395 $parsed_file = wp_parse_url( $file_url ); … … 392 402 // if not, we're good to go. 393 403 if ( $site_host !== $file_host ) { 404 return $file_url; 405 } 406 407 // all ok if we're on different subdomains. 408 if ( $parsed_site['host'] !== $parsed_file['host'] ) { 394 409 $template_url = $file_url; 395 // if are located on same host do additional tweaks.396 410 } else { 397 // all ok if we're on different subdomains. 398 if ( $parsed_site['host'] !== $parsed_file['host'] ) { 399 $template_url = $file_url; 411 // same hosts, let's tweak the http/https. 412 $has_www = strpos( $parsed_file['host'], 'www.' ) === 0; 413 414 // add or remove www from url string to make iframe url pass AMP validation. 415 // 1 Check if not localhost and not subdomain or doesn't have www. 416 if ( ! $is_localhost && ! $has_www ) { 417 // 2 Append www if not exist. 418 $tweaked_host = 'www.' . $parsed_file['host']; 419 } elseif ( ! $is_localhost && $has_www ) { 420 // 3 Remove www if exist. 421 $tweaked_host = preg_replace( '/^www\./i', '', $parsed_file['host'] ); 400 422 } else { 401 // same hosts, let's tweak the http/https. 402 $has_www = strpos( $parsed_file['host'], 'www.' ) === 0; 403 404 // add or remove www from url string to make iframe url pass AMP validation. 405 // 1 Check if not localhost and not subdomain or doesn't have www. 406 if ( ! $is_localhost && ! $has_www ) { 407 // 2 Append www if not exist. 408 $tweaked_host = 'www.' . $parsed_file['host']; 409 } elseif ( ! $is_localhost && $has_www ) { 410 // 3 Remove www if exist. 411 $tweaked_host = preg_replace( '/^www\./i', '', $parsed_file['host'] ); 412 } else { 413 // 4 else Get the current host normally. 414 $tweaked_host = $parsed_file['host']; 415 } 416 417 // generate new url. 418 $tweaked_url = $parsed_file['scheme'] . '://' . $tweaked_host . ( isset( $parsed_file['port'] ) ? ':' . $parsed_file['port'] : '' ) . $parsed_file['path'] . ( ! empty( $parsed_file['query'] ) ? '?' . $parsed_file['query'] : '' ); 419 420 // check if file url is valid. 421 if ( $tweaked_url ) { 422 $template_url = $tweaked_url; 423 } 423 // 4 else Get the current host normally. 424 $tweaked_host = $parsed_file['host']; 425 } 426 427 // generate new url. 428 $tweaked_url = $parsed_file['scheme'] . '://' . $tweaked_host . ( isset( $parsed_file['port'] ) ? ':' . $parsed_file['port'] : '' ) . $parsed_file['path'] . ( ! empty( $parsed_file['query'] ) ? '?' . $parsed_file['query'] : '' ); 429 430 // check if file url is valid. 431 if ( $tweaked_url ) { 432 $template_url = $tweaked_url; 424 433 } 425 434 } … … 441 450 } 442 451 443 $template_dir = IUBENDA_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR; 444 $template_file = $template_dir . ( ! empty( $lang ) && in_array( (string) $lang, array_keys( iubenda()->languages ), true ) ? 'amp-' . $lang . '.html' : 'amp.html' ); 445 $html = $this->prepare_amp_template( $code ); 452 global $wp_filesystem; 453 if ( empty( $wp_filesystem ) ) { 454 require_once ABSPATH . 'wp-admin/includes/file.php'; 455 WP_Filesystem(); 456 } 457 458 $template_dir = IUBENDA_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR; 459 if ( ! empty( $lang ) && array_key_exists( (string) $lang, iubenda()->languages ) ) { 460 $template_file = $template_dir . ( 'amp-' . $lang . '.html' ); 461 } else { 462 $template_file = $template_dir . ( 'amp.html' ); 463 } 464 $html = $this->prepare_amp_template( $code ); 446 465 447 466 // bail if the template was not created properly. … … 452 471 if ( ! is_dir( $template_dir ) ) { 453 472 // dir doesn't exist, make it. 454 mkdir( $template_dir );455 } 456 457 if ( ! is_writable( $template_dir ) ) {473 $wp_filesystem->mkdir( $template_dir ); 474 } 475 476 if ( ! $wp_filesystem->is_writable( $template_dir ) ) { 458 477 ( new Quick_Generator_Service() )->add_amp_permission_error(); 459 478 return false; 460 479 } 461 480 462 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_file_put_contents463 $result = file_put_contents( $template_file, $html );481 // Use WP_Filesystem for file operations. 482 $result = $wp_filesystem->put_contents( $template_file, $html ); 464 483 465 484 return (bool) $result; -
iubenda-cookie-law-solution/tags/beta/includes/class-iubenda-forms.php
r2922322 r3031643 42 42 add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) ); 43 43 // Save cons for non ajax forms. 44 add_action( 'wpforms_process_complete', array( $this, 'process_entry_for_wp_forms' ), 10, 4);45 add_filter( 'mc4wp_integration_woocommerce_checkbox_attributes', array( $this, 'mc4wp_integration_woocommerce_checkbox_attributes' ) , 10, 2);44 add_action( 'wpforms_process_complete', array( $this, 'process_entry_for_wp_forms' ), 10, 2 ); 45 add_filter( 'mc4wp_integration_woocommerce_checkbox_attributes', array( $this, 'mc4wp_integration_woocommerce_checkbox_attributes' ) ); 46 46 } 47 47 … … 49 49 * Process entry for WP forms 50 50 * 51 * @param array $fields Sanitized entry field values/properties. 52 * @param array $entry Original $_POST global. 53 * @param array $form_data Processed form settings/data, prepared to be used later. 54 * @param int $entry_id Entry ID. Will return 0 if entry storage is disabled or using WPForms Lite. 55 */ 56 public function process_entry_for_wp_forms( $fields, $entry, $form_data, $entry_id ) { 51 * @param array $fields Sanitized entry field values/properties. 52 * @param array $entry Original $_POST global. 53 */ 54 public function process_entry_for_wp_forms( $fields, $entry ) { 57 55 global $wp_version; 58 56 $public_api_key = iubenda()->options['cons']['public_api_key']; 59 57 60 // Escape on ajax request because it will be handle by injected JS "frontend.js".58 // Escape on ajax request because it will be handled by injected JS "frontend.js". 61 59 // Or escape if the public api key is not defined. 62 60 // Check current WP version is newer than 4.7 to use the wp_doing_ajax function. … … 208 206 ); 209 207 } 210 211 208 } 212 209 … … 288 285 * Get form function. 289 286 * 290 * @param int $idid.287 * @param int $id id. 291 288 * 292 289 * @return object … … 329 326 * Delete form function. 330 327 * 331 * @param int $idid.328 * @param int $id id. 332 329 * 333 330 * @return int … … 354 351 * Insert form function. 355 352 * 356 * @param array $args args.353 * @param array $args args. 357 354 * 358 355 * @return int … … 744 741 $checkout_form = ''; 745 742 743 if ( ! function_exists( 'WC' ) || ! class_exists( 'WC_Session_Handler' ) || ! class_exists( 'WC_Customer' ) || ! class_exists( 'WC_Cart' ) || ! class_exists( 'WC_Order' ) || ! defined( 'WC_ABSPATH' ) || ! function_exists( 'wc_get_template' ) ) { 744 break; 745 } 746 746 747 ob_start(); 747 748 … … 808 809 809 810 // Germanized for WooCommerce. 810 if ( class_exists( 'WooCommerce_Germanized' ) ) {811 if ( function_exists( 'woocommerce_gzd_template_render_checkout_checkboxes' ) && class_exists( 'WooCommerce_Germanized' ) ) { 811 812 woocommerce_gzd_template_render_checkout_checkboxes(); 812 813 } … … 878 879 } 879 880 880 $html = str_get_html( $checkout_form, $lowercase = true, $force_tags_closed = true, $strip = false );881 882 if ( is_object( $html ) ) {883 // search for nodes.884 foreach ( $input_fields as $input_field ) {885 $fields_raw = $html->find( $input_field );886 887 if ( is_array( $fields_raw ) ) {888 foreach ( $fields_raw as $field ) {889 $field_name = $field->name;890 $field_type = $field->type; 891 892 // exclude submit.893 if ( ! empty( $field_type ) && ! in_array( (string) $field_type, array( 'submit', 'hidden' ), true ) ) {894 $formdata['form_fields'][] = $field->getAttribute( 'name' );881 if ( function_exists( 'str_get_html' ) ) { 882 $html = str_get_html( $checkout_form, $lowercase = true, $force_tags_closed = true, $strip = false ); 883 if ( is_object( $html ) ) { 884 // search for nodes. 885 foreach ( $input_fields as $input_field ) { 886 $fields_raw = $html->find( $input_field ); 887 888 if ( is_array( $fields_raw ) ) { 889 foreach ( $fields_raw as $field ) { 890 $field_type = $field->type; 891 892 // exclude submit. 893 if ( ! empty( $field_type ) && ! in_array( (string) $field_type, array( 'submit', 'hidden' ), true ) ) { 894 $formdata['form_fields'][] = $field->getAttribute( 'name' ); 895 } 895 896 } 896 897 } 897 898 } 899 900 $forms[] = $formdata; 898 901 } 899 900 $forms[] = $formdata;901 902 902 } 903 903 } … … 995 995 } 996 996 997 $html = str_get_html( $comment_form, $lowercase = true, $force_tags_closed = true, $strip = false ); 998 999 if ( is_object( $html ) ) { 1000 // search for nodes. 1001 foreach ( $input_fields as $input_field ) { 1002 $fields_raw = $html->find( $input_field ); 1003 1004 if ( is_array( $fields_raw ) ) { 1005 foreach ( $fields_raw as $field ) { 1006 $field_name = $field->name; 1007 $field_type = $field->type; 1008 1009 // exclude submit. 1010 if ( ! empty( $field_type ) && ! in_array( (string) $field_type, array( 'submit' ), true ) ) { 1011 $formdata['form_fields'][] = $field->getAttribute( 'name' ); 997 if ( function_exists( 'str_get_html' ) ) { 998 $html = str_get_html( $comment_form, $lowercase = true, $force_tags_closed = true, $strip = false ); 999 if ( is_object( $html ) ) { 1000 // search for nodes. 1001 foreach ( $input_fields as $input_field ) { 1002 $fields_raw = $html->find( $input_field ); 1003 1004 if ( is_array( $fields_raw ) ) { 1005 foreach ( $fields_raw as $field ) { 1006 $field_name = $field->name; 1007 $field_type = $field->type; 1008 1009 // exclude submit. 1010 if ( ! empty( $field_type ) && ! in_array( (string) $field_type, array( 'submit' ), true ) ) { 1011 $formdata['form_fields'][] = $field->getAttribute( 'name' ); 1012 } 1012 1013 } 1013 1014 } 1014 1015 } 1016 1017 $forms[] = $formdata; 1018 1015 1019 } 1016 1017 $forms[] = $formdata;1018 1019 1020 } 1020 1021 } … … 1111 1112 * @param array $args args. 1112 1113 * 1113 * @return array1114 * @return false|object 1114 1115 */ 1115 1116 public function get_form_by_object_id( $args = array() ) { … … 1130 1131 ), 1131 1132 'post_type' => 'iubenda_form', 1132 'post_status' => isset( $args['post_status'] ) ? $args['post_status'] :'any',1133 'post_status' => $args['post_status'] ?? 'any', 1133 1134 'posts_per_page' => '1', 1134 1135 'fields' => 'ids', … … 1139 1140 1140 1141 // check result. 1141 if ( ! $posts || is_wp_error( $posts ) ) {1142 if ( empty( $posts ) ) { 1142 1143 return false; 1143 1144 } 1144 1145 1145 $form = $this->get_form( $posts[0] );1146 1147 1146 // kick back results. 1148 return $ form;1147 return $this->get_form( $posts[0] ); 1149 1148 } 1150 1149 … … 1152 1151 * Convert nested array into one level 1153 1152 * 1154 * @param array $ arrayarray.1155 * @param string $prepend prepend.1153 * @param array $target_array array. 1154 * @param string $prepend prepend. 1156 1155 * 1157 1156 * @return array 1158 1157 */ 1159 public function iub_array_dot( $ array, $prepend = '' ) {1158 public function iub_array_dot( $target_array, $prepend = '' ) { 1160 1159 $results = array(); 1161 1160 1162 foreach ( $ array as $key => $value ) {1161 foreach ( $target_array as $key => $value ) { 1163 1162 if ( is_array( $value ) && ! empty( $value ) ) { 1164 1163 $results = array_merge( $results, $this->iub_array_dot( $value, $prepend . $key . '.' ) ); … … 1174 1173 * Prepare mapped forms 1175 1174 * 1176 * @param array $forms forms.1177 * @param array $args args.1175 * @param array $forms forms. 1176 * @param array $args args. 1178 1177 * 1179 1178 * @return array … … 1272 1271 1273 1272 // Special handling for preferences to cast into boolean if the field type is checkbox. 1274 if ( 'preferences' === (string) $key && 'checkbox' === $form->form_fields[ $index ]['type'] ) {1273 if ( 'preferences' === (string) $key && 'checkbox' === $form->form_fields[ $index ]['type'] && function_exists( 'wpforms' ) ) { 1275 1274 $wpform_content = wpforms()->form->get( $form->object_id )->post_content; 1276 1275 $wpform_content = json_decode( $wpform_content, true ); … … 1305 1304 /** 1306 1305 * Integrate with mailchimp 1307 * Add Id attribute to add event on it from frontend 1308 * 1309 * @param array $attributes attributes. 1310 * @param mixed $integration integration. 1306 * Add id attribute to add event on it from frontend 1307 * 1308 * @param array $attributes attributes. 1311 1309 * 1312 1310 * @return string[] 1313 1311 */ 1314 public function mc4wp_integration_woocommerce_checkbox_attributes( $attributes , $integration) {1312 public function mc4wp_integration_woocommerce_checkbox_attributes( $attributes ) { 1315 1313 $attributes['id'] = '_mc4wp_subscribe_woocommerce'; 1316 1314 … … 1321 1319 * Finding elementor form id. 1322 1320 * 1323 * @param mixed $dataData.1324 * @param mixed $form_idsForm_ids.1321 * @param mixed $data Data. 1322 * @param mixed $form_ids Form_ids. 1325 1323 */ 1326 1324 private function find_elementor_form_id( $data, &$form_ids ) { -
iubenda-cookie-law-solution/tags/beta/includes/class-iubenda-list-table-forms.php
r2965748 r3031643 201 201 $output .= '<div class="row-actions">'; 202 202 foreach ( $actions as $action => $link ) { 203 ++ $i;203 ++$i; 204 204 $sep = ( 1 === $i ) ? $sep = '' : $sep = ' | '; 205 205 $output .= '<span class="' . ( 'delete' === $action ? 'delete delete-form' : $action ) . '">' . $sep . $link . '</span>'; … … 309 309 310 310 if ( ! empty( $output ) ) { 311 echo wp_kses ( $output );311 echo wp_kses_post( $output ); 312 312 submit_button( __( 'Filter', 'iubenda' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); 313 313 } … … 432 432 $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'iubenda' ) . '</label>' 433 433 . '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />'; 434 $cb_counter++;434 ++$cb_counter; 435 435 } 436 436 437 437 foreach ( $columns as $column_key => $column_display_name ) { 438 $class = array( 'manage-column', "column-$column_key" );438 $classes = array( 'manage-column', "column-$column_key" ); 439 439 440 440 if ( in_array( $column_key, $hidden, true ) ) { 441 $class [] = 'hidden';441 $classes[] = 'hidden'; 442 442 } 443 443 444 444 if ( 'cb' === $column_key ) { 445 $class [] = 'check-column';445 $classes[] = 'check-column'; 446 446 } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ), true ) ) { 447 $class [] = 'num';447 $classes[] = 'num'; 448 448 } 449 449 450 450 if ( $column_key === $primary ) { 451 $class [] = 'column-primary';451 $classes[] = 'column-primary'; 452 452 } 453 453 … … 458 458 $order = 'asc' === $current_order ? 'desc' : 'asc'; 459 459 460 $class [] = 'sorted';461 $class [] = $current_order;460 $classes[] = 'sorted'; 461 $classes[] = $current_order; 462 462 } else { 463 463 $order = strtolower( $desc_first ); … … 467 467 } 468 468 469 $class [] = 'sortable';470 $class [] = 'desc' === $order ? 'asc' : 'desc';469 $classes[] = 'sortable'; 470 $classes[] = 'desc' === $order ? 'asc' : 'desc'; 471 471 } 472 472 … … 481 481 $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; 482 482 $id = $with_id ? "id='$column_key'" : ''; 483 484 if ( ! empty( $class ) ) { 485 $class = "class='" . implode( ' ', $class ) . "'"; 486 } 483 $class = "class='" . implode( ' ', $classes ) . "'"; 487 484 488 485 echo wp_kses_post( "<{$tag} {$scope} {$id} {$class}>{$column_display_name}</{$tag}>" ); -
iubenda-cookie-law-solution/tags/beta/includes/class-iubenda-notice.php
r2859244 r3031643 142 142 if ( ! empty( iub_get_request_parameter( 'iub_nonce' ) ) ) { 143 143 $delay = ! empty( iub_get_request_parameter( 'delay' ) ) ? absint( iub_get_request_parameter( 'delay' ) ) : 0; 144 $activation = (array) get_option( 'iubenda_activation_data', iubenda()->activation , array());144 $activation = (array) get_option( 'iubenda_activation_data', iubenda()->activation ); 145 145 146 146 // delay notice. … … 167 167 /** 168 168 * Checking for iubenda notice. 169 * 170 * @param string $notice_key Notice key. 171 */ 172 public function maybe_show_notice( string $notice_key ) { 169 */ 170 public function maybe_show_notice() { 173 171 if ( ! current_user_can( 'manage_options' ) ) { 174 172 return; … … 346 344 private function check_for_showing_rating_notice() { 347 345 $current_update = 10; 348 $activation = (array) get_option( 'iubenda_activation_data', iubenda()->activation , array());346 $activation = (array) get_option( 'iubenda_activation_data', iubenda()->activation ); 349 347 350 348 // get current time. -
iubenda-cookie-law-solution/tags/beta/includes/class-iubenda-settings.php
r2969392 r3031643 75 75 * @var string[] 76 76 */ 77 p rivate$legal_notices;77 public $legal_notices; 78 78 79 79 /** … … 193 193 'how_tc_rate' => 'https://www.iubenda.com/en/help/19482-what-should-basic-terms-and-conditions-include', 194 194 'user_account' => 'https://www.iubenda.com/en/account', 195 'amp_permission_support' => 'https://www.iubenda.com/en/help/ 1215#amp-permissions',195 'amp_permission_support' => 'https://www.iubenda.com/en/help/22135-cookie-solution-amp-wordpress#folder-permissions', 196 196 'google_tag_manager_blocking' => 'https://www.iubenda.com/en/help/1235-google-tag-manager-blocking-cookies', 197 'frontend_auto_blocking' => 'https://www.iubenda.com/en/help/133036-prior-blocking-of-cookies-automatic-blocking-auto-blocking', 197 198 ), 198 199 'it' => array( … … 223 224 'how_tc_rate' => 'https://www.iubenda.com/it/help/19482-what-should-basic-terms-and-conditions-include', 224 225 'user_account' => 'https://www.iubenda.com/it/account', 225 'amp_permission_support' => 'https://www.iubenda.com/it/help/ 1215#amp-permissions',226 'amp_permission_support' => 'https://www.iubenda.com/it/help/22135-cookie-solution-amp-wordpress#folder-permissions', 226 227 'google_tag_manager_blocking' => 'https://www.iubenda.com/it/help/1235-google-tag-manager-blocking-cookies', 228 'frontend_auto_blocking' => 'https://www.iubenda.com/it/help/133036-prior-blocking-of-cookies-automatic-blocking-auto-blocking', 227 229 ), 228 230 'de' => array( … … 253 255 'how_tc_rate' => 'https://www.iubenda.com/de/help/19482-what-should-basic-terms-and-conditions-include', 254 256 'user_account' => 'https://www.iubenda.com/de/account', 255 'amp_permission_support' => 'https://www.iubenda.com/de/help/ 1215#amp-permissions',257 'amp_permission_support' => 'https://www.iubenda.com/de/help/22135-cookie-solution-amp-wordpress#folder-permissions', 256 258 'google_tag_manager_blocking' => 'https://www.iubenda.com/de/help/1235-google-tag-manager-blocking-cookies', 259 'frontend_auto_blocking' => 'https://www.iubenda.com/de/help/133036-prior-blocking-of-cookies-automatic-blocking-auto-blocking', 257 260 ), 258 261 'es' => array( … … 283 286 'how_tc_rate' => 'https://www.iubenda.com/es/help/19482-what-should-basic-terms-and-conditions-include', 284 287 'user_account' => 'https://www.iubenda.com/es/account', 285 'amp_permission_support' => 'https://www.iubenda.com/es/help/ 1215#amp-permissions',288 'amp_permission_support' => 'https://www.iubenda.com/es/help/22135-cookie-solution-amp-wordpress#folder-permissions', 286 289 'google_tag_manager_blocking' => 'https://www.iubenda.com/es/help/1235-google-tag-manager-blocking-cookies', 290 'frontend_auto_blocking' => 'https://www.iubenda.com/es/help/133036-prior-blocking-of-cookies-automatic-blocking-auto-blocking', 287 291 ), 288 292 'fr' => array( … … 313 317 'how_tc_rate' => 'https://www.iubenda.com/fr/help/19482-what-should-basic-terms-and-conditions-include', 314 318 'user_account' => 'https://www.iubenda.com/fr/account', 315 'amp_permission_support' => 'https://www.iubenda.com/fr/help/ 1215#amp-permissions',319 'amp_permission_support' => 'https://www.iubenda.com/fr/help/22135-cookie-solution-amp-wordpress#folder-permissions', 316 320 'google_tag_manager_blocking' => 'https://www.iubenda.com/fr/help/1235-google-tag-manager-blocking-cookies', 321 'frontend_auto_blocking' => 'https://www.iubenda.com/fr/help/133036-prior-blocking-of-cookies-automatic-blocking-auto-blocking', 317 322 ), 318 323 'pt-br' => array( … … 343 348 'how_tc_rate' => 'https://www.iubenda.com/pt-br/help/19482-what-should-basic-terms-and-conditions-include', 344 349 'user_account' => 'https://www.iubenda.com/pt-br/account', 345 'amp_permission_support' => 'https://www.iubenda.com/pt-br/help/ 1215#amp-permissions',350 'amp_permission_support' => 'https://www.iubenda.com/pt-br/help/22135-cookie-solution-amp-wordpress#folder-permissions', 346 351 'google_tag_manager_blocking' => 'https://www.iubenda.com/pt-br/help/1235-google-tag-manager-blocking-cookies', 352 'frontend_auto_blocking' => 'https://www.iubenda.com/pt-br/help/133036-prior-blocking-of-cookies-automatic-blocking-auto-blocking', 347 353 ), 348 354 'nl' => array( … … 373 379 'how_tc_rate' => 'https://www.iubenda.com/nl/help/19482-what-should-basic-terms-and-conditions-include', 374 380 'user_account' => 'https://www.iubenda.com/nl/account', 375 'amp_permission_support' => 'https://www.iubenda.com/nl/help/ 1215#amp-permissions',381 'amp_permission_support' => 'https://www.iubenda.com/nl/help/22135-cookie-solution-amp-wordpress#folder-permissions', 376 382 'google_tag_manager_blocking' => 'https://www.iubenda.com/nl/help/1235-google-tag-manager-blocking-cookies', 383 'frontend_auto_blocking' => 'https://www.iubenda.com/nl/help/133036-prior-blocking-of-cookies-automatic-blocking-auto-blocking', 377 384 ), 378 385 ); … … 433 440 434 441 /** 435 * Check site is already made setup? 436 * 437 * @return bool 438 */ 439 private function check_site_is_already_made_setup() { 442 * Check if at least one service is activated. 443 * 444 * @param array $services Array of services with 'status' key. 445 * 446 * @return bool True if at least one service has a true status, false otherwise. 447 */ 448 public function is_any_service_activated( $services ) { 440 449 $result = array_filter( 441 array_column( $ this->services, 'status' ),450 array_column( $services, 'status' ), 442 451 function ( $service ) { 443 return ( stripos( $service, 'false' ) === false );452 return ( 'true' === (string) $service || true === $service ); 444 453 } 445 454 ); 446 455 447 if ( $result ) { 448 return true; 449 } 450 451 // Check if the services are configured. 456 return ! empty( $result ); 457 } 458 459 /** 460 * Check if at least one service is configured. 461 * 462 * @param array $services Array of services with 'configured' key. 463 * 464 * @return bool True if at least one service is configured as true, false otherwise. 465 */ 466 public function is_any_service_configured( $services ) { 452 467 $result = array_filter( 453 array_column( iubenda()->options, 'configured' ),468 array_column( $services, 'configured' ), 454 469 function ( $service ) { 455 return ( stripos( $service, 'true' ) === true );470 return ( 'true' === (string) $service || true === $service ); 456 471 } 457 472 ); 458 473 459 if ( $result ) { 474 return ! empty( $result ); 475 } 476 477 /** 478 * Check if the site is already set up. 479 * 480 * @return bool True if the site is already set up, false otherwise. 481 */ 482 public function is_site_already_set_up() { 483 // Check if the services has a activated service. 484 if ( $this->is_any_service_activated( $this->services ) ) { 485 return true; 486 } 487 488 // Check if the services are configured. 489 if ( $this->is_any_service_configured( iubenda()->options ) ) { 460 490 return true; 461 491 } … … 472 502 global $pagenow; 473 503 474 $show_products_page = $this-> check_site_is_already_made_setup();504 $show_products_page = $this->is_site_already_set_up(); 475 505 476 506 if ( ! current_user_can( apply_filters( 'iubenda_cookie_law_cap', 'manage_options' ) ) ) { … … 537 567 break; 538 568 default: 539 if ( $show_products_page ) { 540 require_once IUBENDA_PLUGIN_PATH . 'views/products-page.php'; 541 } else { 542 require_once IUBENDA_PLUGIN_PATH . 'views/frontpage.php'; 543 } 569 require_once IUBENDA_PLUGIN_PATH . "views/{$default}.php"; 544 570 } 545 571 } … … 551 577 */ 552 578 public function admin_enqueue_scripts( $page ) { 579 // Get radar api status. 580 $iubenda_radar_api_configuration = (array) get_option( 'iubenda_radar_api_configuration', array() ); 581 582 // Localize the script with new data. 583 $iub_js_vars = array( 584 'site_url' => get_site_url(), 585 'plugin_url' => IUBENDA_PLUGIN_URL, 586 'site_language' => iubenda()->lang_current, 587 'site_locale' => get_locale(), 588 'radar_status' => iub_array_get( $iubenda_radar_api_configuration, 'status' ), 589 'form_id' => iub_get_request_parameter( 'form_id', 0 ), 590 'iub_dismiss_general_notice' => wp_create_nonce( 'iub_dismiss_general_notice' ), 591 'iub_quick_generator_callback_nonce' => wp_create_nonce( 'iub_quick_generator_callback_nonce' ), 592 'iub_toggle_service_nonce' => wp_create_nonce( 'iub_toggle_service_nonce' ), 593 'iub_save_cons_options_nonce' => wp_create_nonce( 'iub_save_cons_options_nonce' ), 594 'iub_auto_detect_forms_nonce' => wp_create_nonce( 'iub_auto_detect_forms_nonce' ), 595 'iub_radar_percentage_reload_nonce' => wp_create_nonce( 'iub_radar_percentage_reload_nonce' ), 596 'iub_frontpage_main_box_nonce' => wp_create_nonce( 'iub_frontpage_main_box_nonce' ), 597 'check_frontend_auto_blocking_status' => wp_create_nonce( 'check_frontend_auto_blocking_status' ), 598 'iub_dashboard_compliance_nonce' => wp_create_nonce( 'iub_dashboard_compliance_nonce' ), 599 ); 600 601 wp_enqueue_script( 'iubenda-radar', IUBENDA_PLUGIN_URL . '/assets/js/radar.js', array( 'jquery' ), iubenda()->version, true ); 602 wp_localize_script( 'iubenda-radar', 'iub_js_vars', $iub_js_vars ); 603 553 604 if ( ! in_array( (string) $page, array( 'toplevel_page_iubenda', 'settings_page_iubenda' ), true ) ) { 554 605 wp_enqueue_style( 'iubenda-admin', IUBENDA_PLUGIN_URL . '/assets/css/admin.css', array(), iubenda()->version ); … … 557 608 wp_enqueue_style( 'iubenda-admin', IUBENDA_PLUGIN_URL . '/assets/css/style.css', array(), iubenda()->version ); 558 609 wp_enqueue_script( 'iubenda-admin', IUBENDA_PLUGIN_URL . '/assets/js/admin.js', array( 'jquery' ), iubenda()->version, true ); 559 560 // Get radar api status.561 $iubenda_radar_api_configuration = (array) get_option( 'iubenda_radar_api_configuration', array() );562 563 // Localize the script with new data.564 $iub_js_vars = array(565 'site_url' => get_site_url(),566 'plugin_url' => IUBENDA_PLUGIN_URL,567 'site_language' => iubenda()->lang_current,568 'site_locale' => get_locale(),569 'radar_status' => iub_array_get( $iubenda_radar_api_configuration, 'status' ),570 'form_id' => iub_get_request_parameter( 'form_id', 0 ),571 'iub_dismiss_general_notice' => wp_create_nonce( 'iub_dismiss_general_notice' ),572 'iub_quick_generator_callback_nonce' => wp_create_nonce( 'iub_quick_generator_callback_nonce' ),573 'iub_toggle_service_nonce' => wp_create_nonce( 'iub_toggle_service_nonce' ),574 'iub_save_cons_options_nonce' => wp_create_nonce( 'iub_save_cons_options_nonce' ),575 'iub_auto_detect_forms_nonce' => wp_create_nonce( 'iub_auto_detect_forms_nonce' ),576 'iub_radar_percentage_reload_nonce' => wp_create_nonce( 'iub_radar_percentage_reload_nonce' ),577 'iub_frontpage_main_box_nonce' => wp_create_nonce( 'iub_frontpage_main_box_nonce' ),578 );579 610 580 611 wp_localize_script( 'iubenda-admin', 'iub_js_vars', $iub_js_vars ); … … 911 942 * Sanitize array helper function. 912 943 * 913 * @param array $array array. 944 * @param array $target_array array. 945 * 914 946 * @return array 915 947 */ 916 public function array_map_callback( $ array ) {917 if ( ! is_array( $ array ) ) {948 public function array_map_callback( $target_array ) { 949 if ( ! is_array( $target_array ) ) { 918 950 return array(); 919 951 } 920 952 921 return array_map( 'sanitize_text_field', $ array );953 return array_map( 'sanitize_text_field', $target_array ); 922 954 } 923 955 … … 939 971 * Load admin style inline, for menu icon only. 940 972 * 941 * @return mixed973 * @return void 942 974 */ 943 975 public function admin_print_styles() { … … 1072 1104 ), 1073 1105 ); 1074 1075 1106 } 1076 1107 … … 1257 1288 // Check if the API key is set in the $_SERVER variable. 1258 1289 if ( isset( $_SERVER['iubenda_api_key'] ) && ! empty( $_SERVER['iubenda_api_key'] ) ) { 1259 return trim( $_SERVER['iubenda_api_key']);1290 return trim( sanitize_text_field( wp_unslash( $_SERVER['iubenda_api_key'] ) ) ); 1260 1291 } 1261 1292 1262 1293 // Check if the API key is set in the $_ENV variable. 1263 1294 if ( isset( $_ENV['iubenda_api_key'] ) && ! empty( $_ENV['iubenda_api_key'] ) ) { 1264 return trim( $_ENV['iubenda_api_key'] ); 1265 } 1266 1267 // If the API key is not set in $_SERVER or $_ENV, use the predefined constant. 1295 return trim( sanitize_text_field( wp_unslash( $_ENV['iubenda_api_key'] ) ) ); 1296 } 1297 1298 $iub_api_key = get_option( 'iubenda_api_key' ); 1299 if ( $iub_api_key ) { 1300 return trim( sanitize_text_field( wp_unslash( $iub_api_key ) ) ); 1301 } 1302 1303 // If the API key is not set in $_SERVER or $_ENV or in DB, use the predefined constant. 1268 1304 return self::IUB_QG_API_KEY; 1269 1305 } -
iubenda-cookie-law-solution/tags/beta/includes/class-language-helper.php
r2859244 r3031643 50 50 */ 51 51 public function get_default_website_language_code( $lower_case = false ): string { 52 if ( iub_is_polylang_active() ) {52 if ( iub_is_polylang_active() && function_exists( 'pll_default_language' ) ) { 53 53 $default_language_local_code = pll_default_language( 'locale' ); 54 54 $website_language_code = (string) iub_array_get( iubenda()->lang_mapping, $default_language_local_code ); … … 108 108 return $iub_languages; 109 109 } 110 111 110 } -
iubenda-cookie-law-solution/tags/beta/includes/class-product-helper.php
r2965748 r3031643 101 101 */ 102 102 private function check_iub_code_exists_current_lang( $service_key ) { 103 // Check if there is multi language plugin installed and activated.103 // Check if there is multi-language plugin installed and activated. 104 104 if ( iubenda()->multilang === true && defined( 'ICL_LANGUAGE_CODE' ) && isset( iubenda()->options['cs'][ 'code_' . ICL_LANGUAGE_CODE ] ) ) { 105 105 $iubenda_code = iubenda()->options[ $service_key ][ 'code_' . ICL_LANGUAGE_CODE ]; … … 178 178 public function is_cs_service_simplified() { 179 179 // Get the configuration type from the 'cs' option in the iubenda options. 180 $configuration Type = iub_array_get(iubenda()->options['cs'], 'configuration_type');180 $configuration_type = iub_array_get( iubenda()->options['cs'], 'configuration_type' ); 181 181 182 182 // Check if the configuration type is equal to 'simplified' and return the result. 183 return 'simplified' === (string) $configuration Type;183 return 'simplified' === (string) $configuration_type; 184 184 } 185 185 -
iubenda-cookie-law-solution/tags/beta/includes/class-quick-generator-service.php
r2922322 r3031643 201 201 require_once IUBENDA_PLUGIN_PATH . 'views/partials/auto-detect-forms.php'; 202 202 wp_die(); 203 204 203 } 205 204 -
iubenda-cookie-law-solution/tags/beta/includes/class-radar-service.php
r2965748 r3031643 11 11 } 12 12 13 14 13 /** 15 14 * Iubenda radar service. … … 62 61 /** 63 62 * Maximum allowable delay in seconds. 63 * 64 * @var int The maximum delay time in seconds. 64 65 */ 65 66 private $max_delay_in_sec = MINUTE_IN_SECONDS * 15; 67 68 /** 69 * The dynamic interval for reloading radar configuration in seconds. 70 * 71 * @var int 72 */ 73 const RELOAD_INTERVAL = 3 * WEEK_IN_SECONDS; 66 74 67 75 /** … … 71 79 $this->service_rating = new Service_Rating(); 72 80 $this->api_configuration = array_filter( (array) get_option( 'iubenda_radar_api_configuration', array() ) ); 81 82 add_action( 'init', array( $this, 'check_schedule_reload_radar_config' ) ); 83 add_action( 'wp_ajax_force_reload_radar_config', array( $this, 'force_reload_radar_config' ) ); 84 85 // Hook the scheduled event. 86 add_action( 'iubenda_schedule_reload_radar_config', array( $this, 'force_reload_radar_config' ) ); 73 87 } 74 88 … … 76 90 * Ask radar to send request. 77 91 * 78 * @return bool92 * @return void 79 93 */ 80 94 public function ask_radar_to_send_request() { … … 84 98 85 99 if ( ! empty( $this->api_configuration ) ) { 86 return $this->send_radar_progress_request(); 87 } 88 89 return $this->send_radar_sync_request(); 100 $this->send_radar_progress_request(); 101 return; 102 } 103 104 $this->send_radar_sync_request(); 90 105 } 91 106 … … 188 203 if ( $next_trial > time() ) { 189 204 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { 190 // Calculate the remaining time until the next trial 205 // Calculate the remaining time until the next trial. 191 206 $next_request_in_sec = $next_trial - time(); 192 207 193 // Fallback to the maximum allowable value if $next_request_in_sec exceeds $max_delay_in_sec 208 // Fallback to the maximum allowable value if $next_request_in_sec exceeds $max_delay_in_sec. 194 209 $next_request_in_sec = min( $next_request_in_sec, $this->max_delay_in_sec ); 195 210 … … 214 229 $next_trial = time() + ( pow( 30, $rounds ) ); 215 230 } 216 $trial_num++;231 ++$trial_num; 217 232 218 233 // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode … … 259 274 * @param int|string $response_code The response code as an integer. Empty string if incorrect parameter given. 260 275 * 261 * @return bool276 * @return void 262 277 */ 263 278 private function check_response( $response, $response_code ) { 264 if ( is_wp_error( $response ) || 200 !== (int) $response_code) {279 if ( 200 !== (int) $response_code || is_wp_error( $response ) ) { 265 280 if ( ! is_numeric( $response_code ) ) { 266 281 $message = $this->update_message; … … 284 299 ); 285 300 } 286 return true; 287 } 301 } 302 } 303 304 /** 305 * Checks and schedules the reload of radar configuration after a specific interval. 306 * 307 * This function is responsible for checking if there is already a scheduled event 308 * for reloading radar configuration. If none exists, it creates a new schedule 309 * to reload the radar data after a specific interval. 310 */ 311 public function check_schedule_reload_radar_config() { 312 // Check if the scheduled event already exists. 313 if ( ! wp_next_scheduled( 'iubenda_schedule_reload_radar_config' ) ) { 314 // Schedule the event with the specified dynamic interval. 315 wp_schedule_single_event( time() + self::RELOAD_INTERVAL, 'iubenda_schedule_reload_radar_config' ); 316 } 317 } 318 319 /** 320 * Callback function for the reload_radar_config. 321 * 322 * This function is triggered when the scheduled event is executed. 323 * It forces the deletion of radar configuration and asks radar to send a request. 324 * 325 * @return void 326 */ 327 public function force_reload_radar_config() { 328 $this->force_delete_radar_configuration(); 329 $this->send_radar_sync_request(); 288 330 } 289 331 } -
iubenda-cookie-law-solution/tags/beta/includes/class-service-rating.php
r2848150 r3031643 159 159 $services['pp'] = $this->is_privacy_policy_activated(); 160 160 $services['cs'] = $this->is_cookie_solution_activated(); 161 $services['cons'] = boolval( $this->is_cookie_solution_activated() && $this->is_cookie_solution_automatically_parse_enabled() );161 $services['cons'] = ( $this->is_cookie_solution_activated() && $this->is_cookie_solution_automatically_parse_enabled() ); 162 162 $services['tc'] = $this->is_terms_conditions_activated(); 163 163 … … 180 180 'status' => boolval( $this->is_cookie_solution_activated() && $this->is_cookie_solution_automatically_parse_enabled() ), 181 181 'label' => __( 'Only track users that give consent', 'iubenda' ), 182 'paragraph' => __( 'This accounts for 25% of your score. If you’re based in Europe or have Europe-based users, you likely need to block cookies from running until you receive user consent. To do this, select “ Automatically block scripts detected by the plugin”.', 'iubenda' ),182 'paragraph' => __( 'This accounts for 25% of your score. If you’re based in Europe or have Europe-based users, you likely need to block cookies from running until you receive user consent. To do this, select “Native Blocking”.', 'iubenda' ), 183 183 ), 184 184 'pp' => array( … … 209 209 return false; 210 210 } 211 212 211 } -
iubenda-cookie-law-solution/tags/beta/includes/functions.php
r2965748 r3031643 15 15 * Iubenda array get 16 16 * 17 * @param array $ arrayAn array from which we want to retrieve some information.18 * @param string $key A string separated by . of keys describing the path with which to retrieve information.19 * @param mixed $default Optional. The return value if the path does not exist within the array.17 * @param array $target_array An array from which we want to retrieve some information. 18 * @param string $key A string separated by . of keys describing the path with which to retrieve information. 19 * @param mixed $default_value Optional. The return value if the path does not exist within the array. 20 20 * 21 21 * @return array|ArrayAccess|mixed|null 22 22 */ 23 function iub_array_get( $ array, $key, $default= null ) {24 if ( ! ( is_array( $ array ) || $array instanceof ArrayAccess ) ) {25 return $default instanceof Closure ? $default() : $default;23 function iub_array_get( $target_array, $key, $default_value = null ) { 24 if ( ! ( is_array( $target_array ) || $target_array instanceof ArrayAccess ) ) { 25 return $default_value instanceof Closure ? $default_value() : $default_value; 26 26 } 27 27 28 28 if ( is_null( $key ) ) { 29 return $ array;30 } 31 32 if ( array_key_exists( $key, $ array ) ) {33 return $ array[ $key ];29 return $target_array; 30 } 31 32 if ( array_key_exists( $key, $target_array ) ) { 33 return $target_array[ $key ]; 34 34 } 35 35 36 36 if ( strpos( $key, '.' ) === false ) { 37 return $ array[ $key ] ?? ( $default instanceof Closure ? $default() : $default);37 return $target_array[ $key ] ?? ( $default_value instanceof Closure ? $default_value() : $default_value ); 38 38 } 39 39 40 40 foreach ( explode( '.', $key ) as $segment ) { 41 if ( ( is_array( $ array ) || $array instanceof ArrayAccess ) && ( array_key_exists( $segment, $array ) ) ) {42 $ array = $array[ $segment ];41 if ( ( is_array( $target_array ) || $target_array instanceof ArrayAccess ) && ( array_key_exists( $segment, $target_array ) ) ) { 42 $target_array = $target_array[ $segment ]; 43 43 } else { 44 return $default instanceof Closure ? $default() : $default;44 return $default_value instanceof Closure ? $default_value() : $default_value; 45 45 } 46 46 } 47 47 48 return $ array;48 return $target_array; 49 49 } 50 50 } … … 54 54 * Return only intersects keys with the array 55 55 * 56 * @param array $ arrayArray.57 * @param array|string $keys Keys.56 * @param array $target_array Array. 57 * @param array|string $keys Keys. 58 58 * 59 59 * @return array 60 60 */ 61 function iub_array_only( array $ array, $keys ) {62 return array_intersect_key( $ array, array_flip( (array) $keys ) );61 function iub_array_only( array $target_array, $keys ) { 62 return array_intersect_key( $target_array, array_flip( (array) $keys ) ); 63 63 } 64 64 } … … 68 68 * Translate a specific string into a specific language. 69 69 * 70 * @param string $ stringspecific string.71 * @param string $locale specific language.72 * @param string $text_domain Optional. as default iubenda.70 * @param string $target_string specific string. 71 * @param string $locale specific language. 72 * @param string $text_domain Optional. as default iubenda. 73 73 * 74 74 * @return string|void 75 75 */ 76 function __iub_trans( $ string, $locale, $text_domain = 'iubenda' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore76 function __iub_trans( $target_string, $locale, $text_domain = 'iubenda' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore 77 77 78 78 $mo = new MO(); … … 81 81 $mo->import_from_file( $mofile ); 82 82 // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText, WordPress.WP.I18n.NonSingularStringLiteralDomain 83 $ string = esc_html__( $mo->translate( $string ) );83 $target_string = esc_html__( $mo->translate( $target_string ) ); 84 84 } 85 85 86 86 // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText, WordPress.WP.I18n.NonSingularStringLiteralDomain 87 return $ string;87 return $target_string; 88 88 } 89 89 } … … 95 95 * @param int|string $action Action nonce. 96 96 * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false, 97 * `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'98 * (in that order). Default false.97 * `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce' 98 * (in that order). Default false. 99 99 * @param string $capability Capability name. 100 * @param bool $ dieOptional. Whether to die early when the nonce cannot be verified.101 * Default true.100 * @param bool $should_die Optional. Whether to die early when the nonce cannot be verified. 101 * Default true. 102 102 * 103 103 * @return void 104 104 */ 105 function iub_verify_ajax_request( $action, $query_arg = false, $capability = 'manage_options', $ die = false ) {105 function iub_verify_ajax_request( $action, $query_arg = false, $capability = 'manage_options', $should_die = false ) { 106 106 if ( 107 ! check_ajax_referer( $action, $query_arg, $ die ) ||107 ! check_ajax_referer( $action, $query_arg, $should_die ) || 108 108 ! current_user_can( apply_filters( 'iubenda_cookie_law_cap', $capability ) ) 109 109 ) { … … 168 168 * Gets the request parameter. 169 169 * 170 * @param string $key The query parameter. 171 * @param string $default The default value to return if not found. 170 * @param string $key The query parameter. 171 * @param string $default_value The default value to return if not found. 172 * @param string $with_sanitize With sanitize. Default true. 172 173 * 173 174 * @return string The request parameter. 174 175 */ 175 function iub_get_request_parameter( string $key, $default = '') {176 function iub_get_request_parameter( string $key, $default_value = '', $with_sanitize = true ) { 176 177 // If key not exist or empty return default. 177 178 // phpcs:ignore WordPress.Security.NonceVerification.Recommended 178 179 if ( ! isset( $_REQUEST[ $key ] ) || empty( $_REQUEST[ $key ] ) ) { 179 return $default; 180 } 181 182 // phpcs:ignore WordPress.Security.NonceVerification.Recommended 183 return sanitize_key( $_REQUEST[ $key ] ); 180 return $default_value; 181 } 182 183 if ( $with_sanitize ) { 184 // phpcs:ignore WordPress.Security.NonceVerification.Recommended 185 return sanitize_key( $_REQUEST[ $key ] ); 186 } 187 188 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized 189 return $_REQUEST[ $key ]; 184 190 } 185 191 } -
iubenda-cookie-law-solution/tags/beta/includes/services/class-iubenda-code-extractor.php
r2969392 r3031643 67 67 68 68 /** 69 * Auto Blocking Enabled. 70 * 71 * @var bool 72 */ 73 private $is_auto_blocking_enabled = false; 74 75 /** 76 * Site ID. 77 * 78 * @var string 79 */ 80 private $site_id; 81 82 /** 83 * List of scripts that will be ignored from appending to body 84 * 85 * @var string[] 86 */ 87 private $escaped_scripts_from_body = array( 88 'iubenda.com/sync/', 89 'iubenda.com/autoblocking/', 90 ); 91 92 /** 93 * Array of classes required for appending scripts in the head section. 94 * 95 * @var string[] Class names of the script appenders. 96 */ 97 private $required_scripts_in_head = array( 98 Auto_Blocking_Script_Appender::class, 99 Sync_Script_Appender::class, 100 ); 101 102 /** 69 103 * Extract scripts and styles from embed code and enqueue it 70 104 * … … 76 110 $this->code = $code; 77 111 112 $this->set_auto_blocking_state( $code ); 78 113 $this->extract_html_tags(); 79 114 $this->handle_scripts(); 115 $this->dispatch_scripts_in_head(); 80 116 $this->handle_styles(); 81 117 82 add_filter( 'script_loader_tag', array( $this, 'iub_add_attribute_to_scripts' ), 10, 3 ); 118 add_filter( 'script_loader_tag', array( $this, 'iub_add_attribute_to_scripts' ), 10, 2 ); 119 } 120 121 /** 122 * Dispatch the required scripts in head based on conditions 123 * 124 * @return void 125 */ 126 private function dispatch_scripts_in_head() { 127 foreach ( $this->required_scripts_in_head as $class ) { 128 $instance = new $class( $this ); 129 $instance->handle(); 130 } 131 } 132 133 /** 134 * Declare auto blocking feature state 135 * 136 * @param string $code embed code. 137 */ 138 private function set_auto_blocking_state( $code ) { 139 $instance = new Auto_Blocking(); 140 $this->site_id = $instance->get_site_id_from_cs_code( $code ); 141 if ( $this->site_id ) { 142 $this->is_auto_blocking_enabled = (bool) iub_array_get( iubenda()->options, "cs.frontend_auto_blocking.{$this->site_id}" ); 143 } 83 144 } 84 145 … … 130 191 // Extract scripts with src to enqueue it. 131 192 foreach ( $this->scripts as $key => $script ) { 132 wp_enqueue_script( "iubenda-head-scripts-{$key}", $script['src'], array(), iubenda()->version, false ); 193 if ( $this->may_escape_script_from_body( $script ) ) { 194 continue; 195 } 196 197 wp_enqueue_script( 198 "iubenda-head-scripts-{$key}", 199 $script['src'], 200 array(), 201 iubenda()->version, 202 false 203 ); 204 205 // Store script attributes for reference. 133 206 $this->script_attributes[ "iubenda-head-scripts-{$key}" ] = $script['attributes']; 134 207 } … … 201 274 * @param string $tag HTML for the script tag. 202 275 * @param string $handle Handle of script. 203 * @param string $src Src of script.204 276 * 205 277 * @return string 206 278 */ 207 public function iub_add_attribute_to_scripts( $tag, $handle , $src) {279 public function iub_add_attribute_to_scripts( $tag, $handle ) { 208 280 $key = array_search( $handle, array_keys( $this->script_attributes ), true ); 209 281 … … 303 375 $previous_value = libxml_use_internal_errors( true ); 304 376 if ( function_exists( 'mb_encode_numericentity' ) ) { 305 $this->code = mb_encode_numericentity( $this->code, [0x80, 0x10FFFF, 0, ~0], 'UTF-8');377 $this->code = mb_encode_numericentity( $this->code, array( 0x80, 0x10FFFF, 0, ~0 ), 'UTF-8' ); 306 378 } 307 379 … … 320 392 'attributes' => $this->fetch_attributes_and_add_skip_class( $script ), 321 393 ); 394 } elseif ( $this->check_tampered_script( $script->nodeValue ) ) { 395 $this->tampered_scripts[] = $script->nodeValue; 396 $script->nodeValue = ''; 322 397 } else { 323 // Inline scripts. 324 if ( $this->check_tampered_script( $script->nodeValue ) ) { 325 $this->tampered_scripts[] = $script->nodeValue; 326 $script->nodeValue = ''; 327 } else { 328 $this->scripts_inline[] = array( 329 'content' => $script->nodeValue, 330 'attributes' => $this->fetch_attributes_and_add_skip_class( $script ), 331 ); 332 } 398 $this->scripts_inline[] = array( 399 'content' => $script->nodeValue, 400 'attributes' => $this->fetch_attributes_and_add_skip_class( $script ), 401 ); 333 402 } 334 403 } … … 354 423 */ 355 424 private function extract_html_tags_with_simple_html_dom() { 425 if ( ! function_exists( 'str_get_html' ) ) { 426 return; 427 } 428 356 429 $html = str_get_html( $this->code, true, true, false ); 357 430 … … 437 510 return $str; 438 511 } 512 513 /** 514 * Determines whether a given script should be excluded from the body based on predefined criteria. 515 * 516 * This method iterates over a list of specific script URLs (or patterns) that are meant to be escaped 517 * from being placed in the body. It checks if the source URL of the provided script matches any of 518 * these predefined URLs or patterns. If a match is found, the script is considered for exclusion. 519 * 520 * @param array $script An associative array containing script attributes, with 'src' being one of the keys representing the script's source URL. 521 * 522 * @return bool Returns true if the script matches any of the predefined URLs or patterns and should be excluded from the body; otherwise, false. 523 */ 524 private function may_escape_script_from_body( $script ): bool { 525 foreach ( $this->escaped_scripts_from_body as $url ) { 526 if ( strpos( $script['src'], $url ) !== false ) { 527 return true; 528 } 529 } 530 531 return false; 532 } 533 534 /** 535 * Get List of scripts 536 * 537 * @return array 538 */ 539 public function get_scripts() { 540 return $this->scripts; 541 } 542 543 /** 544 * Get Site ID 545 * 546 * @return string 547 */ 548 public function get_site_id() { 549 return $this->site_id; 550 } 551 552 /** 553 * Get Auto Blocking State 554 * 555 * @return bool 556 */ 557 public function is_auto_blocking_enabled() { 558 return $this->is_auto_blocking_enabled; 559 } 439 560 // phpcs:enable 440 561 } -
iubenda-cookie-law-solution/tags/beta/includes/services/class-iubenda-cs-product-service.php
r2965748 r3031643 83 83 array( 84 84 'status' => 'error', 85 'focus' => '#legalisation-section', 86 'message_code' => 'missing_legalisation', 85 87 'responseText' => esc_html__( 'You must select at least one legislation.', 'iubenda' ), 86 88 ) … … 130 132 $new_cs_option['amp_template_done'][ $lang_id ] = iub_array_get( $amp_options, 'amp_template_done' ); 131 133 } 134 135 iubenda()->iub_auto_blocking->fetch_auto_blocking_status_by_site_id( $site_id ); 132 136 } 133 137 } elseif ( 'manual' === $new_cs_option['configuration_type'] ) { … … 164 168 $new_cs_option['amp_template'][ $lang_id ] = iub_array_get( $amp_options, 'amp_template' ); 165 169 $new_cs_option['amp_template_done'][ $lang_id ] = iub_array_get( $amp_options, 'amp_template_done' ); 170 } 171 172 // Try to get the Site ID from code. 173 $parsed_site_id = iub_array_get( $parsed_code, 'siteId' ); 174 if ( $parsed_site_id ) { 175 // Check if auto-blocking is enabled for this site. 176 iubenda()->iub_auto_blocking->fetch_auto_blocking_status_by_site_id( $parsed_site_id ); 166 177 } 167 178 } … … 179 190 180 191 if ( isset( $new_cs_option['amp_template'] ) && is_array( $new_cs_option['amp_template'] ) ) { 181 // esc_url_raw for remote AMP links to languages that files are not generated. 182 $new_cs_option['amp_template'] = array_map( 'esc_url_raw', $new_cs_option['amp_template'] ); 192 // Loop through each template key and value. 193 foreach ( $new_cs_option['amp_template'] as $template_key => $template_value ) { 194 // Check if the value is empty (null or empty string). 195 if ( empty( $template_value ) ) { 196 // In this example, we're skipping it. 197 continue; 198 } 199 200 // Apply the esc_url_raw function to non-empty values. 201 $new_cs_option['amp_template'][ $template_key ] = esc_url_raw( $template_value ); 202 } 183 203 } 184 204 … … 199 219 $new_cs_option = wp_parse_args( $new_cs_option, $old_cs_options ); 200 220 221 $new_cs_option['frontend_auto_blocking'] = iubenda()->iub_auto_blocking->auto_block_sites_status; 201 222 // Saving and update the current instance with new CS options. 202 223 iubenda()->options['cs'] = $new_cs_option; … … 236 257 $result = array(); 237 258 238 $template_done = (bool) iubenda()-> AMP->generate_amp_template( $code, $lang_id );259 $template_done = (bool) iubenda()->amp->generate_amp_template( $code, $lang_id ); 239 260 240 261 if ( ( 'local' === $source ) && false === $template_done ) { … … 307 328 return $result; 308 329 } 330 331 /** 332 * Is the current configuration type is simplified. 333 * 334 * @return bool 335 */ 336 public function is_cs_simplified() { 337 return 'simplified' === (string) iub_array_get( iubenda()->options['cs'], 'configuration_type' ); 338 } 309 339 } -
iubenda-cookie-law-solution/tags/beta/includes/widget/class-iubenda-legal-widget.php
r2922322 r3031643 143 143 * @param array $instance instance. 144 144 * 145 * @return false 145 * @return false|void 146 146 */ 147 147 public function widget( $args, $instance ) { … … 240 240 * Assign iubenda widget to registered sidebar if exists and not registered before 241 241 * 242 * @return bool242 * @return void 243 243 */ 244 244 public function assign_iubenda_widget() { … … 255 255 } 256 256 257 // Check if wp_assign_widget_to_sidebar is exist .257 // Check if wp_assign_widget_to_sidebar is existing. 258 258 if ( ! function_exists( 'wp_assign_widget_to_sidebar' ) ) { 259 259 return; … … 296 296 } 297 297 } 298 299 298 } 300 299 -
iubenda-cookie-law-solution/tags/beta/includes/widget/elementor/class-iubenda-elementor-legal-widget.php
r2922322 r3031643 10 10 if ( ! defined( 'ABSPATH' ) ) { 11 11 exit; // Exit if accessed directly. 12 } 13 14 if ( ! class_exists( '\Elementor\Widget_Base' ) ) { 15 return; 12 16 } 13 17 … … 53 57 public function get_icon() { 54 58 wp_enqueue_style( 'iubenda-elementor-css', IUBENDA_PLUGIN_URL . '/includes/widget/elementor/style.css', array(), iubenda()->version ); 59 55 60 return 'iub-legal-elementor-widget-icon-class'; 56 61 } … … 80 85 */ 81 86 protected function register_controls() { 82 $tab_content = property_exists( '\Elementor\Controls_Manager', 'TAB_CONTENT' ) ? \Elementor\Controls_Manager::TAB_CONTENT : 'content'; 83 $text = property_exists( '\Elementor\Controls_Manager', 'TEXT' ) ? \Elementor\Controls_Manager::TEXT : 'text'; 87 if ( class_exists( '\Elementor\Controls_Manager' ) && property_exists( '\Elementor\Controls_Manager', 'TAB_CONTENT' ) ) { 88 $tab_content = \Elementor\Controls_Manager::TAB_CONTENT; 89 } else { 90 $tab_content = 'content'; 91 } 84 92 85 $this->start_controls_section( 86 'title_section', 87 array( 88 'label' => esc_html__( 'Title:', 'iubenda' ), 89 'tab' => $tab_content, 90 ) 91 ); 93 if ( class_exists( '\Elementor\Controls_Manager' ) && property_exists( '\Elementor\Controls_Manager', 'TEXT' ) ) { 94 $text = \Elementor\Controls_Manager::TEXT; 95 } else { 96 $text = 'text'; 97 } 92 98 93 $this->add_control( 94 'title', 95 array( 96 'label' => esc_html__( 'Title:', 'iubenda' ), 97 'type' => $text, 98 'input_type' => 'title', 99 // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText 100 'placeholder' => esc_html__( $this->default_widget_title, 'iubenda' ), 101 // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText 102 'default' => esc_html__( $this->default_widget_title, 'iubenda' ), 103 ) 104 ); 99 if ( method_exists( $this, 'start_controls_section' ) ) { 100 $this->start_controls_section( 101 'title_section', 102 array( 103 'label' => esc_html__( 'Title:', 'iubenda' ), 104 'tab' => $tab_content, 105 ) 106 ); 107 } 105 108 106 $this->end_controls_section(); 109 if ( method_exists( $this, 'add_control' ) ) { 110 $this->add_control( 111 'title', 112 array( 113 'label' => esc_html__( 'Title:', 'iubenda' ), 114 'type' => $text, 115 'input_type' => 'title', 116 // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText 117 'placeholder' => esc_html__( $this->default_widget_title, 'iubenda' ), 118 // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText 119 'default' => esc_html__( $this->default_widget_title, 'iubenda' ), 120 ) 121 ); 122 } 123 124 if ( method_exists( $this, 'end_controls_section' ) ) { 125 $this->end_controls_section(); 126 } 107 127 } 108 128 … … 113 133 */ 114 134 protected function render() { 115 $settings = $this->get_settings_for_display(); 116 $html = ''; 117 $html = apply_filters( 'before_iub_legal_elementor_widget_section', $html ); 118 $html .= iub_array_get( $settings, 'title' ) . '<section>' . ( new Iubenda_Legal_Block() )->iub_legal_block_html( $html ) . '</section>'; 119 $html = apply_filters( 'after_iub_legal_elementor_widget_section', $html ); 135 if ( method_exists( $this, 'get_settings_for_display' ) ) { 136 $settings = $this->get_settings_for_display(); 137 $title = iub_array_get( $settings, 'title' ); 138 } else { 139 $title = 'Legal'; 140 } 141 142 $html = ''; 143 $html = apply_filters( 'before_iub_legal_elementor_widget_section', $html ); 144 $html .= $title . '<section>' . ( new Iubenda_Legal_Block() )->iub_legal_block_html( $html ) . '</section>'; 145 $html = apply_filters( 'after_iub_legal_elementor_widget_section', $html ); 120 146 121 147 echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 122 148 } 123 124 149 } -
iubenda-cookie-law-solution/tags/beta/iubenda-cookie-class/README.md
r2922322 r3031643 99 99 ## Changelog 100 100 101 ##### 4.1.15 102 * Support PHP 8.2 | Fix Creation of dynamic properties 103 101 104 ##### 4.1.14 102 105 * Bugfix: escape if custom scripts/iframes are empty -
iubenda-cookie-law-solution/tags/beta/iubenda-cookie-class/iubenda.class.php
r2922322 r3031643 6 6 * @copyright 2018-2020, iubenda s.r.l 7 7 * @license GNU/GPL 8 * @version 4.1.1 48 * @version 4.1.15 9 9 * 10 10 * This program is free software: you can redistribute it and/or modify … … 165 165 166 166 /** 167 * @var mixed 168 */ 169 private $original_content_page; 170 171 /** 172 * @var mixed 173 */ 174 private $content_page; 175 176 /** 167 177 * Construct: the whole HTML output of the page 168 178 * -
iubenda-cookie-law-solution/tags/beta/iubenda_cookie_solution.php
r2972337 r3031643 4 4 * Plugin URI: https://www.iubenda.com 5 5 * Description: The iubenda plugin is an <strong>all-in-one</strong>, extremely easy to use 360° compliance solution, with text crafted by actual lawyers, that quickly <strong>scans your site and auto-configures to match your specific setup</strong>. It supports the GDPR (DSGVO, RGPD), UK-GDPR, ePrivacy, LGPD, USPR, CalOPPA, PECR and more. 6 * Version: 3. 7.66 * Version: 3.10.0 7 7 * Author: iubenda 8 8 * Author URI: https://www.iubenda.com … … 46 46 * 47 47 * @class iubenda 48 * @version 3. 7.648 * @version 3.10.0 49 49 */ 50 50 class iubenda { … … 93 93 'stop_showing_cs_for_admins' => false, 94 94 'simplified' => array( 95 'position' => 'float-top-center',96 'background_overlay' => false,97 'banner_style' => 'dark',98 'legislation' => array(95 'position' => 'float-top-center', 96 'background_overlay' => false, 97 'banner_style' => 'dark', 98 'legislation' => array( 99 99 'gdpr' => true, 100 100 'uspr' => false, … … 102 102 'all' => false, 103 103 ), 104 'require_consent' => 'worldwide', 105 'explicit_accept' => true, 106 'explicit_reject' => true, 107 'tcf' => true, 104 'require_consent' => 'worldwide', 105 'explicit_accept' => true, 106 'explicit_reject' => true, 107 'tcf' => true, 108 'frontend_auto_blocking' => array(), 108 109 ), 109 110 ), … … 138 139 * @var string 139 140 */ 140 public $version = '3. 7.6';141 public $version = '3.9.0'; 141 142 142 143 /** … … 237 238 * @var Iubenda_AMP 238 239 */ 239 public $ AMP;240 public $amp; 240 241 241 242 /** … … 287 288 */ 288 289 public $widget; 290 291 /** 292 * Iubenda radar dashboard class. 293 * 294 * @var Radar_Dashboard_Widget 295 */ 296 private $radar_dashboard_widget; 297 298 /** 299 * Iubenda Auto Blocking class. 300 * 301 * @var Auto_Blocking 302 */ 303 public $iub_auto_blocking; 289 304 290 305 /** … … 325 340 // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase 326 341 self::$instance->service_rating = new Service_Rating(); 327 self::$instance-> AMP= new Iubenda_AMP();342 self::$instance->amp = new Iubenda_AMP(); 328 343 self::$instance->forms = new Iubenda_Forms(); 329 344 self::$instance->settings = new Iubenda_Settings(); … … 332 347 self::$instance->notice = new Iubenda_Notice(); 333 348 self::$instance->no_script_policy_embedder = new No_Script_Policy_Embedder(); 349 self::$instance->iub_auto_blocking = new Auto_Blocking(); 350 self::$instance->radar_dashboard_widget = new Radar_Dashboard_Widget(); 334 351 } 335 352 … … 375 392 add_action( 'admin_init', array( $this, 'check_iubenda_version' ) ); 376 393 add_action( 'upgrader_process_complete', array( $this, 'upgrade' ), 10, 2 ); 377 add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 5);394 add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2 ); 378 395 add_action( 'upgrader_overwrote_package', array( $this, 'do_upgrade_processes' ) ); 379 396 add_action( 'after_switch_theme', array( $this, 'assign_legal_block_or_widget' ) ); … … 437 454 $iubenda_code = ''; 438 455 439 // Check if there is multi language plugin installed and activated.456 // Check if there is multi-language plugin installed and activated. 440 457 if ( true === $this->multilang && defined( 'ICL_LANGUAGE_CODE' ) && isset( $this->options['cs'][ 'code_' . ICL_LANGUAGE_CODE ] ) ) { 441 458 $iubenda_code .= $this->options['cs'][ 'code_' . ICL_LANGUAGE_CODE ]; … … 527 544 include_once IUBENDA_PLUGIN_PATH . 'includes/services/class-iubenda-code-extractor.php'; 528 545 include_once IUBENDA_PLUGIN_PATH . 'includes/class-no-script-policy-embedder.php'; 546 include_once IUBENDA_PLUGIN_PATH . 'includes/class-auto-blocking.php'; 547 include_once IUBENDA_PLUGIN_PATH . 'includes/class-auto-blocking-script-appender.php'; 548 include_once IUBENDA_PLUGIN_PATH . 'includes/class-sync-script-appender.php'; 549 include_once IUBENDA_PLUGIN_PATH . 'includes/class-radar-dashboard-widget.php'; 529 550 } 530 551 … … 539 560 540 561 // Polylang support. 541 if ( iub_is_polylang_active() ) {562 if ( function_exists( 'pll_default_language' ) && function_exists( 'PLL' ) && function_exists( 'pll_current_language' ) && iub_is_polylang_active() ) { 542 563 $this->multilang = true; 543 564 … … 558 579 559 580 // WPML support. 560 } elseif ( iub_is_wpml_active() ) {581 } elseif ( function_exists( 'icl_get_languages' ) && iub_is_wpml_active() ) { 561 582 $this->multilang = true; 562 583 … … 584 605 585 606 // load iubenda parser. 586 include_once dirname( __FILE__ ). '/iubenda-cookie-class/iubenda.class.php';607 include_once __DIR__ . '/iubenda-cookie-class/iubenda.class.php'; 587 608 } 588 609 … … 731 752 * Add wp_head Consent Database content. 732 753 * 733 * @return mixed754 * @return void 734 755 */ 735 756 public function wp_head_cons() { … … 834 855 } 835 856 857 if ( ! class_exists( 'iubendaParser' ) ) { 858 return $output; 859 } 860 836 861 // bail if consent given and skip parsing enabled. 837 862 if ( iubendaParser::consent_given() && $this->options['cs']['skip_parsing'] ) { … … 847 872 } 848 873 849 // bail if bot detect d, no html in outputor it's a post request.850 if ( iubendaParser::bot_detected() || $this->no_html) {874 // bail if bot detected, no html in output, or it's a post request. 875 if ( $this->no_html || iubendaParser::bot_detected() ) { 851 876 return $output; 852 877 } … … 863 888 864 889 // bail if the current page is page builder for any theme. 865 if ( is_customize_preview() ) {890 if ( function_exists( 'is_customize_preview' ) && is_customize_preview() ) { 866 891 return $output; 867 892 } … … 877 902 } 878 903 879 $star time = microtime( true );880 $output = apply_filters( 'iubenda_initial_output', $output );904 $star_time = microtime( true ); 905 $output = apply_filters( 'iubenda_initial_output', $output ); 881 906 882 907 // prepare scripts and iframes. … … 898 923 if ( 'new' === (string) $this->options['cs']['parser_engine'] && can_use_dom_document_class() ) { 899 924 if ( function_exists( 'mb_encode_numericentity' ) ) { 900 $output = (string) mb_encode_numericentity( $output, [0x80, 0x10FFFF, 0, ~0], 'UTF-8');925 $output = (string) mb_encode_numericentity( $output, array( 0x80, 0x10FFFF, 0, ~0 ), 'UTF-8' ); 901 926 } 902 927 $iubenda = new iubendaParser( … … 914 939 915 940 // append signature. 916 $output .= '<!-- Parsed with iubenda experimental class in ' . round( microtime( true ) - $star time, 4 ) . ' sec. -->';941 $output .= '<!-- Parsed with iubenda experimental class in ' . round( microtime( true ) - $star_time, 4 ) . ' sec. -->'; 917 942 } else { 918 943 // default. … … 931 956 932 957 // append signature. 933 $output .= '<!-- Parsed with iubenda default class in ' . round( microtime( true ) - $star time, 4 ) . ' sec. -->';958 $output .= '<!-- Parsed with iubenda default class in ' . round( microtime( true ) - $star_time, 4 ) . ' sec. -->'; 934 959 } 935 960 … … 1018 1043 } 1019 1044 1045 if ( ! class_exists( 'iubendaParser' ) ) { 1046 return; 1047 } 1048 1020 1049 // bail if consent given and skip parsing enabled. 1021 if ( iubendaParser::consent_given() && $this->options['cs']['skip_parsing']) {1050 if ( $this->options['cs']['skip_parsing'] && iubendaParser::consent_given() ) { 1022 1051 return; 1023 1052 } … … 1131 1160 } 1132 1161 } 1133 1134 1162 } 1135 1163 … … 1374 1402 if ( ! empty( $code ) ) { 1375 1403 // Generate code if it was set for the selected language. 1376 iubenda()-> AMP->generate_amp_template( $code, $lang_id );1404 iubenda()->amp->generate_amp_template( $code, $lang_id ); 1377 1405 } 1378 1406 } … … 1383 1411 // For one language. 1384 1412 $code = iubenda()->options['cs']['code_default']; 1385 iubenda()-> AMP->generate_amp_template( $code );1413 iubenda()->amp->generate_amp_template( $code ); 1386 1414 } 1387 1415 … … 1432 1460 * Find closing bracket. 1433 1461 * 1434 * @param string $ stringString.1435 * @param string $open_position Open Position.1462 * @param string $target_string String. 1463 * @param string $open_position Open Position. 1436 1464 * 1437 1465 * @return mixed 1438 1466 */ 1439 private function find_closing_bracket( $ string, $open_position ) {1467 private function find_closing_bracket( $target_string, $open_position ) { 1440 1468 $close_pos = $open_position; 1441 1469 $counter = 1; … … 1443 1471 1444 1472 // To Avoid the infinity loop. 1445 if ( ! isset( $ string[ $close_pos + 1 ] ) ) {1473 if ( ! isset( $target_string[ $close_pos + 1 ] ) ) { 1446 1474 break; 1447 1475 } 1448 1476 1449 $c = $ string[ ++$close_pos ];1477 $c = $target_string[ ++$close_pos ]; 1450 1478 if ( '{' === (string) $c ) { 1451 $counter ++;1479 ++$counter; 1452 1480 } elseif ( '}' === (string) $c ) { 1453 $counter --;1481 --$counter; 1454 1482 } 1455 1483 } … … 1530 1558 $iubenda_terms_conditions_generator = new Terms_Conditions_Generator(); 1531 1559 1560 // Is the current configuration type is simplified. 1561 $is_cs_simplified = ( new Iubenda_CS_Product_Service() )->is_cs_simplified(); 1562 1532 1563 // Check embed codes in CS product. 1533 1564 foreach ( iubenda()->options['cs'] as $key => $option ) { … … 1538 1569 $iubenda_code_extractor->has_tampered_scripts( $option ) 1539 1570 ) { 1540 if ( 'simplified' === (string) iub_array_get( iubenda()->options['cs'], 'configuration_type' )) {1571 if ( $is_cs_simplified ) { 1541 1572 $simplified_options = iub_array_get( iubenda()->options['cs'], 'simplified' ); 1542 1573 $lang_id = trim( substr( $key, strpos( $key, 'code_' ) + strlen( 'code_' ) ) ); … … 1644 1675 */ 1645 1676 public static function is_wp_cli() { 1646 return defined( 'WP_CLI') && WP_CLI;1677 return defined( 'WP_CLI' ) && WP_CLI; 1647 1678 } 1648 1679 } … … 1666 1697 2 1667 1698 ); 1668 /** 1669 * Initialise iubenda Privacy Controls and Cookie Solution 1670 * 1671 * @return iubenda 1672 */ 1673 function iubenda() { 1674 static $instance; 1675 1676 // first call to instance() initializes the plugin. 1677 if ( null === $instance || ! ( $instance instanceof iubenda ) ) { 1678 $instance = iubenda::instance(); 1679 } 1680 1681 return $instance; 1682 } 1683 1684 $iubenda = iubenda(); 1699 1700 // iubenda Plugin instance Initialization. 1701 require 'iubenda-init.php'; -
iubenda-cookie-law-solution/tags/beta/readme.txt
r2972337 r3031643 5 5 Requires at least: 5.0 6 6 Requires PHP: 7.0.0 7 Tested up to: 6. 38 Stable tag: 3. 7.67 Tested up to: 6.4 8 Stable tag: 3.10.0 9 9 License: MIT License 10 10 License URI: http://opensource.org/licenses/MIT … … 56 56 * **Auto-detects and blocks a wide range of 3rd party script**s like Google Analytics, Google Maps, Facebook and Instagram widgets, Youtube, Twitter, PayPal, Disqus, Outbrain, AdRoll, Kissmetrics, Freshchat and more. 57 57 * Allows you to provide your users with **granular, per-category preference control** (e.g. basic functionalities, experience enhancement, targeting & advertising) 58 * **Google Consent Mode ** support.58 * **Google Consent Mode v2** support (no extra setup required): Enables **efficient conversion tracking** even without user consent for cookies and tracking technologies, **enhancing Google Analytics and Ads performance**. 59 59 * Integrates with IAB’s [Transparency and Consent Framework](https://www.iubenda.com/en/help/7440-enable-preference-management-iab-framework#revenue) (**TCF**) to maximize ad revenue (needed if your site uses ad networks like Google ads and more) 60 60 * Compatible with **Google’s Accelerated Mobile Pages** (AMP) … … 268 268 == Changelog == 269 269 270 = 3.10.0 = 271 * Introduced iubenda automatic blocking feature. 272 273 = 3.9.0 = 274 * Introduced home page widget with compliance report summary. 275 276 = 3.8.0 = 277 * Add Google Consent Mode v2 support for seamless conversion tracking. 278 279 = 3.7.9 = 280 * Resolved issue preventing the saving of the consent database when using Elementor forms. 281 * Corrected the problem of adding multiple Elementor forms on a single page. 282 283 = 3.7.8 = 284 * Fix ConS saving preference issue 285 286 = 3.7.7 = 287 * Support WordPress 6.4 288 270 289 = 3.7.6 = 271 290 * Tweak: Fix compatibility issues with PHP 8.2 … … 832 851 == Upgrade Notice == 833 852 834 = 3. 7.6=835 * Tweak: Fix compatibility issues with PHP 8.2853 = 3.10.0 = 854 * Introduced iubenda automatic blocking feature. -
iubenda-cookie-law-solution/tags/beta/views/cons-single-form.php
r2922322 r3031643 12 12 // Including partial header. 13 13 require_once IUBENDA_PLUGIN_PATH . 'views/partials/header.php'; 14 15 /** 16 * Generate HTML for select options based on an array of form fields. 17 * 18 * @param array $form_fields The array of form fields. 19 * @param mixed $selected The selected value. 20 */ 21 function generate_select_options( $form_fields, $selected ) { 22 foreach ( $form_fields as $index => $form_field ) { 23 $form_field_is_array = is_array( $form_field ); 24 $form_field_value = $form_field_is_array ? $index : $form_field; 25 $form_field_label = $form_field_is_array ? $form_field['label'] . ' (' . $form_field['type'] . ')' : $form_field; 26 $form_field_selected = $form_field_is_array ? $index : $form_field; 27 28 ?> 29 <option value="<?php echo esc_html( $form_field_value ); ?>" <?php selected( $selected, $form_field_selected ); ?>> 30 <?php echo esc_html( $form_field_label ); ?> 31 </option> 32 <?php 33 } 34 } 35 14 36 ?> 15 37 <div class="main-box"> … … 25 47 <form id="postbox-container-2" action="options.php" method="post"> 26 48 <?php 27 settings_fields( $this->tabs['cons']['key'] );28 do_settings_sections( $this->tabs['cons']['key'] );49 settings_fields( iubenda()->settings->tabs['cons']['key'] ); 50 do_settings_sections( iubenda()->settings->tabs['cons']['key'] ); 29 51 add_settings_section( 30 52 'iubenda_consent_form', 31 53 __( 'Field Mapping', 'iubenda' ), 32 54 array( 33 $this,55 iubenda()->settings, 34 56 'iubenda_consent_form', 35 57 ), … … 37 59 ); 38 60 39 $form_id = absint( iub_get_request_parameter( 'form_id', 0 ));61 $form_id = (int) iub_get_request_parameter( 'form_id', 0 ); 40 62 $form = ! empty( $form_id ) ? iubenda()->forms->get_form( $form_id ) : false; 41 63 … … 50 72 51 73 $available_fields = array(); 52 53 74 if ( ! empty( $form->form_fields ) && is_array( $form->form_fields ) ) { 54 75 foreach ( $form->form_fields as $index => $form_field ) { … … 60 81 } 61 82 } 62 echo ' 63 <input type="hidden" value="' . esc_html( $form_id ) . '" name="form_id"> 64 <div class="px-4 px-lg-5"> 65 <div class="py-5"> 66 <div class="d-block d-lg-flex justify-content-between mb-4"> 67 <div class="d-block d-lg-flex align-items-center text-center text-lg-left"> 68 <h3 class="m-0 mb-4">' . esc_html__( 'Map fields', 'iubenda' ) . '</h3> 69 </div> 70 <div class="d-block d-lg-flex align-items-center text-center text-lg-right"> 71 <div class="misc-pub-section misc-pub-post-status p-0"> 72 <label for="status">' . esc_html__( 'Status', 'iubenda' ) . ':</label> 73 <div id="status-select" class="" style="margin: 3px 0 0;"> 74 <select id="status" name="status">'; 75 foreach ( iubenda()->forms->statuses as $name => $label ) { 76 echo '<option value="' . esc_html( $name ) . '"' . selected( $form->post_status, $name, true ) . '>' . esc_html( $label ) . '</option>'; 77 } 78 echo ' 79 </select> 80 </div> 81 </div> 82 </div> 83 </div> 84 85 <h4 class="m-0 mb-2">' . esc_html__( 'Subject fields', 'iubenda' ) . ' <span class="required">(required)</span></h4> 86 <p class="mb-3 description">' . esc_html__( 'Subject fields allow you to store a series of identifying values about your individual subjects/users. Please map the subject field with the corresponding form fields where applicable.', 'iubenda' ) . '</p> 87 <table class="widefat mb-4 subject-table"> 88 <thead> 89 <td class="label">' . esc_html__( 'Subject field', 'iubenda' ) . '</td> 90 <td class="label">' . esc_html__( 'Form field', 'iubenda' ) . '</td> 91 </thead> 92 <tbody>'; 93 foreach ( $this->subject_fields as $field_name => $field_label ) { 94 $selected = isset( $subject[ $field_name ] ) ? $subject[ $field_name ] : ''; 95 $none = 'id' === $field_name ? esc_html__( 'Autogenerated', 'iubenda' ) : esc_html__( 'None', 'iubenda' ); 96 97 echo ' 98 <tr class="subject-field options-field"> 99 <td>' . esc_html( $field_name ) . ' (' . esc_html( $field_label ) . ') </td> 100 <td> 101 <select class="subject-fields-select select-' . esc_html( $field_name ) . '" name="subject[' . esc_html( $field_name ) . ']"> 102 <option value="" ' . selected( $selected, '', false ) . '>' . esc_html( $none ) . '</option>'; 103 if ( ! empty( $form->form_fields ) ) { 104 foreach ( $form->form_fields as $index => $form_field ) { 105 // get field data. 106 $form_field_value = is_array( $form_field ) ? $index : $form_field; 107 $form_field_label = is_array( $form_field ) ? $form_field['label'] . ' (' . $form_field['type'] . ')' : $form_field; 108 $form_field_selected = is_array( $form_field ) ? $index : $form_field; 109 110 echo '<option value="' . esc_html( $form_field_value ) . '" ' . selected( $selected, $form_field_selected, false ) . '>' . esc_html( $form_field_label ) . '</option>'; 111 } 112 } 113 echo ' 114 </select> 115 </td> 116 </tr>'; 117 } 118 echo ' 119 </tbody> 120 </table> 121 <br> 122 <h4 class="m-0 mb-2">' . esc_html__( 'Preferences fields', 'iubenda' ) . '</h4> 123 <p class="mb-3 description">' . esc_html__( 'Preferences fields allow you to store a record of the various opt-ins points at which the user has agreed or given consent, such as fields for agreeing to terms and conditions, newsletter, profiling, etc.', 'iubenda' ) . '</p> 124 <table class="widefat mb-4 preferences-table"> 125 <thead> 126 <td class="label">' . esc_html__( 'Preferences field', 'iubenda' ) . '</td> 127 <td class="label">' . esc_html__( 'Form field', 'iubenda' ) . '</td> 128 </thead> 129 <tbody>'; 130 echo ' 131 <tr id="preferences-field-template" class="template-field" style="display: none;"> 132 <td><input type="text" class="preferences-inputs regular-text" value="" name="preferences[__PREFERENCE_ID__][field]" placeholder="' . esc_html__( 'Enter field name', 'iubenda' ) . '" disabled/></td> 133 <td> 134 <select class="preferences-inputs preferences-fields-select select-' . esc_html( $field_name ) . '" name="preferences[__PREFERENCE_ID__][value]" disabled>'; 135 if ( ! empty( $form->form_fields ) ) { 136 foreach ( $form->form_fields as $index => $form_field ) { 137 // get field data. 138 $form_field_value = is_array( $form_field ) ? $index : $form_field; 139 $form_field_label = is_array( $form_field ) ? $form_field['label'] . ' (' . $form_field['type'] . ')' : $form_field; 140 141 echo '<option value="' . esc_html( $form_field_value ) . '">' . esc_html( $form_field_label ) . '</option>'; 142 } 143 } 144 echo ' 145 </select> 146 <a href="javascript:void(0)" class="remove-preferences-field button-secondary" title="' . esc_html__( 'Remove', 'iubenda' ) . '">-</a> 147 </td> 148 </tr>'; 149 if ( $preferences ) { 150 $index = 0; 151 152 foreach ( $preferences as $field_name => $field_value ) { 153 $selected = isset( $preferences[ $field_name ] ) ? $preferences[ $field_name ] : ''; 154 155 echo ' 156 <tr class="preferences-field options-field"> 157 <td><input type="text" class="regular-text" value="' . esc_html( $field_name ) . '" name="preferences[' . esc_html( $index ) . '][field]" placeholder="' . esc_html__( 'Enter field name', 'iubenda' ) . '" /></td> 158 <td> 159 <select class="preferences-fields-select select-' . esc_html( $field_name ) . '" name="preferences[' . esc_html( $index ) . '][value]">'; 160 if ( ! empty( $form->form_fields ) ) { 161 foreach ( $form->form_fields as $index => $form_field ) { 162 // get field data. 163 $form_field_value = is_array( $form_field ) ? $index : $form_field; 164 $form_field_label = is_array( $form_field ) ? $form_field['label'] . ' (' . $form_field['type'] . ')' : $form_field; 165 $form_field_selected = is_array( $form_field ) ? $index : $form_field; 166 167 echo '<option value="' . esc_html( $form_field_value ) . '" ' . selected( $selected, $form_field_selected, false ) . '>' . esc_html( $form_field_label ) . '</option>'; 83 ?> 84 <input type="hidden" value="<?php echo esc_attr( $form_id ); ?>" name="form_id"> 85 <div class="px-4 px-lg-5"> 86 <div class="py-5"> 87 <div class="d-block d-lg-flex justify-content-between mb-4"> 88 <div class="d-block d-lg-flex align-items-center text-center text-lg-left"> 89 <h3 class="m-0 mb-4"><?php esc_html_e( 'Map fields', 'iubenda' ); ?></h3> 90 </div> 91 <div class="d-block d-lg-flex align-items-center text-center text-lg-right"> 92 <div class="misc-pub-section misc-pub-post-status p-0"> 93 <label for="status"><?php esc_html_e( 'Status', 'iubenda' ); ?>:</label> 94 <div id="status-select" class="" style="margin: 3px 0 0;"> 95 <select id="status" name="status"> 96 <?php foreach ( iubenda()->forms->statuses as $name => $label ) : ?> 97 <option value="<?php echo esc_html( $name ); ?>" <?php selected( $form->post_status, $name ); ?>><?php echo esc_html( $label ); ?></option> 98 <?php endforeach; ?> 99 </select> 100 </div> 101 </div> 102 </div> 103 </div> 104 105 <h4 class="m-0 mb-2"><?php esc_html_e( 'Subject fields', 'iubenda' ); ?> <span class="required">(required)</span></h4> 106 <p class="mb-3 description"><?php esc_html_e( 'Subject fields allow you to store a series of identifying values about your individual subjects/users. Please map the subject field with the corresponding form fields where applicable.', 'iubenda' ); ?></p> 107 <table class="widefat mb-4 subject-table"> 108 <thead> 109 <td class="label"><?php esc_html_e( 'Subject field', 'iubenda' ); ?></td> 110 <td class="label"><?php esc_html_e( 'Form field', 'iubenda' ); ?></td> 111 </thead> 112 <tbody> 113 <?php 114 foreach ( iubenda()->settings->subject_fields as $field_name => $field_label ) : 115 $selected = isset( $subject[ $field_name ] ) ? $subject[ $field_name ] : ''; 116 $none = 'id' === $field_name ? esc_html__( 'Autogenerated', 'iubenda' ) : esc_html__( 'None', 'iubenda' ); 117 ?> 118 <tr class="subject-field options-field"> 119 <td><?php echo esc_html( $field_name ) . '(' . esc_html( $field_label ) . ')'; ?> </td> 120 <td> 121 <select 122 class="subject-fields-select select-<?php echo esc_html( $field_name ); ?>" 123 name="subject[<?php echo esc_html( $field_name ); ?>]" 124 > 125 <option value="" <?php selected( $selected, '' ); ?>><?php echo esc_html( $none ); ?></option> 126 <?php 127 if ( ! empty( $form->form_fields ) ) { 128 generate_select_options( $form->form_fields, $selected ); 129 } 130 ?> 131 </select> 132 </td> 133 </tr> 134 <?php endforeach; ?> 135 </tbody> 136 </table> 137 <br> 138 <h4 class="m-0 mb-2"><?php esc_html_e( 'Preferences fields', 'iubenda' ); ?></h4> 139 <p class="mb-3 description"><?php esc_html_e( 'Preferences fields allow you to store a record of the various opt-ins points at which the user has agreed or given consent, such as fields for agreeing to terms and conditions, newsletter, profiling, etc.', 'iubenda' ); ?></p> 140 <table class="widefat mb-4 preferences-table"> 141 <thead> 142 <td class="label"><?php esc_html_e( 'Preferences field', 'iubenda' ); ?></td> 143 <td class="label"><?php esc_html_e( 'Form field', 'iubenda' ); ?></td> 144 </thead> 145 <tbody> 146 <tr id="preferences-field-template" class="template-field" style="display: none;"> 147 <td><input type="text" class="preferences-inputs regular-text" value="" name="preferences[__PREFERENCE_ID__][field]" placeholder="<?php esc_html_e( 'Enter field name', 'iubenda' ); ?>" disabled/></td> 148 <td> 149 <select class="preferences-inputs preferences-fields-select" name="preferences[__PREFERENCE_ID__][value]" disabled> 150 <?php 151 if ( ! empty( $form->form_fields ) ) { 152 foreach ( $form->form_fields as $index => $form_field ) : 153 // get field data. 154 $form_field_value = is_array( $form_field ) ? $index : $form_field; 155 $form_field_label = is_array( $form_field ) ? $form_field['label'] . ' (' . $form_field['type'] . ')' : $form_field; 156 157 ?> 158 <option value="<?php echo esc_html( $form_field_value ); ?>"><?php echo esc_html( $form_field_label ); ?></option> 159 <?php 160 endforeach; 161 } 162 ?> 163 </select> 164 <a href="javascript:void(0)" class="remove-preferences-field button-secondary" title="<?php esc_html_e( 'Remove', 'iubenda' ); ?>">-</a> 165 </td> 166 </tr> 167 <?php 168 if ( $preferences ) : 169 $index = 0; 170 foreach ( $preferences as $field_name => $field_value ) : 171 $selected = isset( $field_value ) ? $field_value : ''; 172 173 ?> 174 <tr class="preferences-field options-field"> 175 <td><input type="text" class="regular-text" value="<?php echo esc_html( $field_name ); ?>" name="preferences[<?php echo esc_html( $index ); ?>][field]" placeholder="<?php esc_html_e( 'Enter field name', 'iubenda' ); ?>"/></td> 176 <td> 177 <select class="preferences-fields-select select-<?php echo esc_html( $field_name ); ?>" name="preferences[<?php echo esc_html( $index ); ?>][value]"> 178 <?php 179 if ( ! empty( $form->form_fields ) ) { 180 generate_select_options( $form->form_fields, $selected ); 181 } 182 ?> 183 </select> 184 <a href="javascript:void(0)" class="remove-preferences-field button-secondary" title="<?php esc_html_e( 'Remove', 'iubenda' ); ?>">-</a> 185 </td> 186 </tr> 187 <?php 188 ++$index; 189 endforeach; 190 endif; 191 ?> 192 <tr class="submit-field"> 193 <td colspan="2"><a href="javascript:void(0)" class="add-preferences-field button-secondary"><?php esc_html_e( 'Add New Preference', 'iubenda' ); ?></a></td> 194 </tr> 195 </tbody> 196 </table> 197 <br> 198 <h4 class="m-0 mb-2"><?php esc_html_e( 'Exclude fields', 'iubenda' ); ?></h4> 199 <p class="mb-3 description"> 200 <?php esc_html_e( 'Exclude fields allow you to create a list of fields that you would like to exclude from your Consent Database recorded proofs (for e.g. password or other fields not related to the consent).', 'iubenda' ); ?> 201 </p> 202 <table class="widefat mb-4 exclude-table"> 203 <thead> 204 <td class="label"><?php esc_html_e( 'Exclude field', 'iubenda' ); ?></td> 205 <td class="label"></td> 206 </thead> 207 <tbody> 208 <tr id="exclude-field-template" class="template-field" style="display: none;"> 209 <td> 210 <select class="exclude-fields-select" name="exclude[__EXCLUDE_ID__][field]" disabled> 211 <?php 212 if ( ! empty( $form->form_fields ) ) { 213 foreach ( $form->form_fields as $index => $form_field ) : 214 // get field data. 215 $form_field_value = is_array( $form_field ) ? $index : $form_field; 216 $form_field_label = is_array( $form_field ) ? $form_field['label'] . ' (' . $form_field['type'] . ')' : $form_field; 217 218 ?> 219 <option value="<?php echo esc_html( $form_field_value ); ?>"><?php echo esc_html( $form_field_label ); ?></option> 220 <?php 221 endforeach; 222 } 223 ?> 224 </select> 225 <a href="javascript:void(0)" class="remove-exclude-field button-secondary" title="<?php esc_html_e( 'Remove', 'iubenda' ); ?>">-</a> 226 </td> 227 </tr> 228 <?php 229 if ( $exclude ) { 230 $index = 0; 231 foreach ( $exclude as $index => $field_name ) : 232 $selected = isset( $field_name ) ? $field_name : ''; 233 234 ?> 235 <tr class="exclude-field options-field"> 236 <td> 237 <select class="exclude-fields-select select-<?php echo esc_html( $field_name ); ?>" name="exclude[<?php echo esc_html( $index ); ?>][field]"> 238 <?php 239 if ( ! empty( $form->form_fields ) ) { 240 generate_select_options( $form->form_fields, $selected ); 241 } 242 ?> 243 </select> 244 <a href="javascript:void(0)" class="remove-exclude-field button-secondary" title="<?php esc_html_e( 'Remove', 'iubenda' ); ?>">-</a> 245 </td> 246 <td></td> 247 </tr> 248 <?php 249 ++$index; 250 endforeach; 168 251 } 169 } 170 echo ' 171 </select> 172 <a href="javascript:void(0)" class="remove-preferences-field button-secondary" title="' . esc_html__( 'Remove', 'iubenda' ) . '">-</a> 173 </td> 174 </tr>'; 175 $index ++; 176 } 177 } 178 echo ' 179 <tr class="submit-field"><td colspan="2"><a href="javascript:void(0)" class="add-preferences-field button-secondary">' . esc_html__( 'Add New Preference', 'iubenda' ) . '</a></td></tr> 180 </tbody> 181 </table> 182 <br> 183 <h4 class="m-0 mb-2">' . esc_html__( 'Exclude fields', 'iubenda' ) . '</h4> 184 <p class="mb-3 description">' . esc_html__( 'Exclude fields allow you to create a list of fields that you would like to exclude from your Consent Database recorded proofs (for e.g. password or other fields not related to the consent).', 'iubenda' ) . '</p> 185 186 <table class="widefat mb-4 exclude-table"> 187 <thead> 188 <td class="label">' . esc_html__( 'Exclude field', 'iubenda' ) . '</td> 189 <td class="label"></td> 190 </thead> 191 <tbody>'; 192 echo ' 193 <tr id="exclude-field-template" class="template-field" style="display: none;"> 194 <td> 195 <select class="exclude-fields-select select-' . esc_html( $field_name ) . '" name="exclude[__EXCLUDE_ID__][field]" disabled>'; 196 if ( ! empty( $form->form_fields ) ) { 197 foreach ( $form->form_fields as $index => $form_field ) { 198 // get field data. 199 $form_field_value = is_array( $form_field ) ? $index : $form_field; 200 $form_field_label = is_array( $form_field ) ? $form_field['label'] . ' (' . $form_field['type'] . ')' : $form_field; 201 202 echo '<option value="' . esc_html( $form_field_value ) . '">' . esc_html( $form_field_label ) . '</option>'; 203 } 204 } 205 echo ' 206 </select> 207 <a href="javascript:void(0)" class="remove-exclude-field button-secondary" title="' . esc_html__( 'Remove', 'iubenda' ) . '">-</a> 208 </td> 209 </tr>'; 210 if ( $exclude ) { 211 $index = 0; 212 foreach ( $exclude as $index => $field_name ) { 213 $selected = isset( $exclude[ $index ] ) ? $exclude[ $index ] : ''; 214 215 echo ' 216 <tr class="exclude-field options-field"> 217 <td> 218 <select class="exclude-fields-select select-' . esc_html( $field_name ) . '" name="exclude[' . esc_html( $index ) . '][field]">'; 219 if ( ! empty( $form->form_fields ) ) { 220 foreach ( $form->form_fields as $index => $form_field ) { 221 // get field data. 222 $form_field_value = is_array( $form_field ) ? $index : $form_field; 223 $form_field_label = is_array( $form_field ) ? $form_field['label'] . ' (' . $form_field['type'] . ')' : $form_field; 224 $form_field_selected = is_array( $form_field ) ? $index : $form_field; 225 226 echo '<option value="' . esc_html( $form_field_value ) . '" ' . selected( $selected, $form_field_selected, false ) . '>' . esc_html( $form_field_label ) . '</option>'; 227 } 228 } 229 echo ' 230 </select> 231 <a href="javascript:void(0)" class="remove-exclude-field button-secondary" title="' . esc_html__( 'Remove', 'iubenda' ) . '">-</a> 232 </td> 233 <td></td> 234 </tr>'; 235 236 $index ++; 237 } 238 } 239 echo ' 240 <tr class="submit-field"><td colspan="2"><a href="javascript:void(0)" class="add-exclude-field button-secondary">' . esc_html__( 'Add New Exclude', 'iubenda' ) . '</a></td></tr> 241 </tbody> 242 </table> 243 244 <br> 245 <h4 class="m-0 mb-2">' . esc_html__( 'Legal documents', 'iubenda' ) . '</h4> 246 <p class="mb-3 description">' . esc_html__( 'In general, it\'s important that you declare which legal documents are being agreed upon when each consent is collected. However, if you use iubenda for your legal documents, it is *required* that you identify the documents by selecting them here.', 'iubenda' ) . '</p> 247 <table class="widefat mb-4 legal_notices-table"> 248 <thead> 249 <td class="label">' . esc_html__( 'Identifier', 'iubenda' ) . '</td> 250 <td class="label"></td> 251 </thead> 252 <tbody>'; 253 254 // default identifiers. 255 foreach ( $this->legal_notices as $index => $field_name ) { 256 echo ' 257 <tr class="legal_notices-field default-field"> 258 <td>' . ( esc_html( $index ) === 0 ? '<p class="description">' . esc_html__( 'Please select each legal document available on your site.', 'iubenda' ) . '</p>' : '' ) . '<label for="legal_notices-default-field=' . esc_html( $index ) . '"><input id="legal_notices-default-field=' . esc_html( $index ) . '" type="checkbox" value="' . esc_html( $field_name ) . '" name="legal_notices[' . esc_html( $index ) . '][field]"' . checked( in_array( $field_name, $legal_notices, true ), true, false ) . 'placeholder="' . esc_html__( 'Enter field name', 'iubenda' ) . '" />' . esc_html( $field_name ) . '</label></td> 259 <td></td> 260 </tr>'; 261 } 262 263 $index ++; 264 265 // custom identifiers. 266 echo ' 267 <tr id="legal_notices-field-template" class="template-field" style="display: none;"> 268 <td><input type="text" value="" name="legal_notices[__LEGAL_NOTICE_ID__][field]" placeholder="' . esc_html__( 'Enter field name', 'iubenda' ) . '" class="regular-text legal-notices-inputs" disabled /> <a href="javascript:void(0)" class="remove-legal_notices-field button-secondary" title="' . esc_html__( 'Remove', 'iubenda' ) . '">-</a></td> 269 <td></td> 270 </tr>'; 271 272 echo ' 273 <tr> 274 <td colspan="2"><p class="description" style="margin-bottom: 0;">' . esc_html__( 'Alternatively, you may add your own custom document identifiers.', 'iubenda' ) . '</p></td> 275 </tr>'; 276 277 if ( $legal_notices ) { 278 foreach ( $legal_notices as $field_name ) { 279 if ( in_array( $field_name, $this->legal_notices, true ) ) { 280 continue; 281 } 282 283 echo ' 284 <tr class="legal_notices-field options-field"> 285 <td><input type="text" class="regular-text" value="' . esc_html( $field_name ) . '" name="legal_notices[' . esc_html( $index ) . '][field]" placeholder="' . esc_html__( 'Enter field name', 'iubenda' ) . '" /> <a href="javascript:void(0)" class="remove-legal_notices-field button-secondary" title="' . esc_html__( 'Remove', 'iubenda' ) . '">-</a></td> 286 <td></td> 287 </tr>'; 288 289 $index ++; 290 } 291 } 292 echo ' 293 <tr class="submit-field"><td colspan="2"><a href="javascript:void(0)" class="add-legal_notices-field button-secondary">' . esc_html__( 'Add New Document', 'iubenda' ) . '</a></td></tr>'; 294 echo ' 295 </tbody> 296 </table> 297 </div> 298 </div>'; 299 ?> 252 ?> 253 <tr class="submit-field"> 254 <td colspan="2"><a href="javascript:void(0)" class="add-exclude-field button-secondary"><?php esc_html_e( 'Add New Exclude', 'iubenda' ); ?></a></td> 255 </tr> 256 </tbody> 257 </table> 258 259 <br> 260 <h4 class="m-0 mb-2"><?php esc_html_e( 'Legal documents', 'iubenda' ); ?></h4> 261 <p class="mb-3 description"><?php esc_html_e( 'In general, it\'s important that you declare which legal documents are being agreed upon when each consent is collected. However, if you use iubenda for your legal documents, it is *required* that you identify the documents by selecting them here.', 'iubenda' ); ?></p> 262 <table class="widefat mb-4 legal_notices-table"> 263 <thead> 264 <td class="label"><?php esc_html_e( 'Identifier', 'iubenda' ); ?></td> 265 <td class="label"></td> 266 </thead> 267 <tbody> 268 <?php 269 // default identifiers. 270 foreach ( iubenda()->settings->legal_notices as $index => $field_name ) : 271 ?> 272 <tr class="legal_notices-field default-field"> 273 <td> 274 <?php if ( esc_html( $index ) === 0 ) : ?> 275 <p class="description"> 276 <?php esc_html_e( 'Please select each legal document available on your site.', 'iubenda' ); ?> 277 </p> 278 <?php endif; ?> 279 <label for="legal_notices-default-field=<?php echo esc_html( $index ); ?>"> 280 <input 281 id="legal_notices-default-field=<?php echo esc_html( $index ); ?>" 282 type="checkbox" value="<?php echo esc_html( $field_name ); ?>" 283 name="legal_notices[<?php echo esc_html( $index ); ?>][field]" 284 <?php checked( in_array( $field_name, $legal_notices, true ) ); ?> 285 placeholder="<?php esc_html_e( 'Enter field name', 'iubenda' ); ?>"/> 286 <?php echo esc_html( $field_name ); ?> 287 </label> 288 </td> 289 <td></td> 290 </tr> 291 <?php 292 endforeach; 293 $next_legal_notice = count( iubenda()->settings->legal_notices ) + 1; 294 ?> 295 <tr id="legal_notices-field-template" class="template-field" style="display: none;"> 296 <td> 297 <input type="text" value="" name="legal_notices[__LEGAL_NOTICE_ID__][field]" 298 placeholder="<?php esc_html_e( 'Enter field name', 'iubenda' ); ?>" 299 class="regular-text legal-notices-inputs" disabled/> 300 <a href="javascript:void(0)" class="remove-legal_notices-field button-secondary" title="<?php esc_html_e( 'Remove', 'iubenda' ); ?>">-</a> 301 </td> 302 <td></td> 303 </tr> 304 <tr> 305 <td colspan="2"> 306 <p class="description" style="margin-bottom: 0;"> 307 <?php esc_html_e( 'Alternatively, you may add your own custom document identifiers.', 'iubenda' ); ?> 308 </p> 309 </td> 310 </tr> 311 <?php 312 if ( $legal_notices ) : 313 foreach ( $legal_notices as $field_name ) : 314 if ( in_array( $field_name, iubenda()->settings->legal_notices, true ) ) { 315 continue; 316 } 317 ?> 318 <tr class="legal_notices-field options-field"> 319 <td> 320 <input type="text" class="regular-text" value="<?php echo esc_html( $field_name ); ?>" 321 name="legal_notices[<?php echo esc_html( $next_legal_notice ); ?>][field]" 322 placeholder="<?php esc_html_e( 'Enter field name', 'iubenda' ); ?>"/> 323 <a href="javascript:void(0)" class="remove-legal_notices-field button-secondary" title="<?php esc_html_e( 'Remove', 'iubenda' ); ?>">-</a> 324 </td> 325 <td></td> 326 </tr> 327 <?php 328 ++$next_legal_notice; 329 endforeach; 330 endif; 331 ?> 332 <tr class="submit-field"> 333 <td colspan="2"> 334 <a href="javascript:void(0)" class="add-legal_notices-field button-secondary"> 335 <?php esc_html_e( 'Add New Document', 'iubenda' ); ?> 336 </a> 337 </td> 338 </tr> 339 </tbody> 340 </table> 341 </div> 342 </div> 300 343 <hr> 301 344 <div class="p-4 d-flex justify-content-end"> -
iubenda-cookie-law-solution/tags/beta/views/integrate-setup.php
r2922322 r3031643 45 45 46 46 <div class="my-5"> 47 <?php 48 $site_id = iub_array_get( iubenda()->options['global_options'], 'site_id' ); 49 $predefined_auto_block_section_data = array( 50 'frontend-auto-blocking-checkbox-status' => iubenda()->iub_auto_blocking->is_autoblocking_feature_available( $site_id ), 51 ); 52 53 // Including partial auto-block-section. 54 require_once IUBENDA_PLUGIN_PATH . '/views/partials/auto-block-section.php'; 55 ?> 56 </div> 57 <div class="my-5"> 47 58 <label class="checkbox-regular"> 48 59 <input type="checkbox" class="mr-2 section-checkbox-control" name="iubenda_cookie_law_solution[amp_support]" value="1" checked data-section-name="#amp_support"/> … … 65 76 <div class="border-1 border-gray rounded mt-2 py-2 px-3 d-flex flex-wrap align-items-center"> 66 77 <?php 67 if ( empty( iubenda()->options['cs']['amp_template_done'] ) ) { 68 echo ' 69 <p class="description">' . esc_html_e( 'No file available. Save changes to generate iubenda AMP configuration file.', 'iubenda' ) . '</p>'; 70 } else { 71 ?> 72 <table class="table"> 73 <tbody> 74 <?php 75 // multi-language support. 76 if ( iubenda()->multilang && ! empty( iubenda()->languages ) ) { 77 foreach ( iubenda()->languages as $lang_id => $lang_name ) { 78 $is_amp_template_done = (bool) ! iub_array_get( iubenda()->options['cs']['amp_template_done'], $lang_id, false ); 79 if ( $is_amp_template_done ) { 80 continue; 81 } 82 ?> 83 <tr> 84 <td><p class="text-bold"><?php echo esc_html( $lang_name ); ?></p></td> 85 <td> 86 <a href="<?php echo esc_url( iubenda()->AMP->get_amp_template_url( $lang_id ) ); ?>" target="_blank"><?php echo esc_url( iubenda()->AMP->get_amp_template_url( $lang_id ) ); ?></a> 87 </td> 88 </tr> 89 <?php 90 } 91 } else { 92 ?> 93 <tr> 94 <td><p class="text-bold"><?php esc_html_e( 'Default language', 'iubenda' ); ?></p></td> 95 <td> 96 <a href="<?php echo esc_url( iubenda()->AMP->get_amp_template_url() ); ?>" target="_blank"><?php echo esc_url( iubenda()->AMP->get_amp_template_url() ); ?></a> 97 </td> 98 </tr> 99 <?php 100 } 101 } 78 // Including partial amp-files-section. 79 require_once IUBENDA_PLUGIN_PATH . '/views/partials/amp-template-links.php'; 102 80 ?> 103 </tbody>104 </table>105 81 </div> 106 82 <div class="notice notice--general mt-2 p-3 d-flex align-items-center text-xs"> … … 134 110 <div class="my-5"> 135 111 <label class="checkbox-regular"> 136 <input type="checkbox" name="iubenda_cookie_law_solution[parse]" value="1" class="mr-2 section-checkbox-control " data-section-name="#iub_parser_engine_container" checked>137 <span><?php esc_html_e( ' Automatically block scripts detected by the plugin', 'iubenda' ); ?> <a target="_blank" href="<?php echo esc_url( iubenda()->settings->links['automatic_block_scripts'] ); ?>" class="ml-1 tooltip-icon">?</a></span>112 <input type="checkbox" name="iubenda_cookie_law_solution[parse]" value="1" class="mr-2 section-checkbox-control blocking-method native-blocking-method" data-section-name="#iub_parser_engine_container" checked> 113 <span><?php esc_html_e( 'Native Blocking', 'iubenda' ); ?> <a target="_blank" href="<?php echo esc_url( iubenda()->settings->links['automatic_block_scripts'] ); ?>" class="ml-1 tooltip-icon">?</a></span> 138 114 </label> 115 <div id="both-blocking-methods-disabled-warning-message" class="mxx-4 mb-4 notice notice--warning mt-2 p-3 align-items-center text-warning text-xs <?php echo iubenda()->options['cs']['parse'] ? 'd-flex' : ''; ?>"> 116 <img class="mr-2" src="<?php echo esc_url( IUBENDA_PLUGIN_URL ); ?>/assets/images/warning-icon.svg"> 117 <p> 118 <?php esc_html_e( 'Most legislation explicitly require prior consent in order to process user’s data. By disabling these blocking options you may be in breach of such requirements', 'iubenda' ); ?> 119 </p> 120 </div> 139 121 <section id="iub_parser_engine_container" class="subOptions"> 140 122 <h4><?php esc_html_e( 'Select Parsing Engine', 'iubenda' ); ?></h4> -
iubenda-cookie-law-solution/tags/beta/views/partials/cs-general-settings.php
r2922322 r3031643 10 10 exit; 11 11 } 12 13 // Is the current configuration type is simplified. 14 $is_cs_simplified = ( new Iubenda_CS_Product_Service() )->is_cs_simplified(); 15 $site_id = iub_array_get( iubenda()->options['global_options'], 'site_id' ); 12 16 ?> 13 17 <div class="tabs"> … … 17 21 <div class="d-flex tabs__nav"> 18 22 <?php 19 if ( iub_array_get( iubenda()->options['global_options'], 'site_id' )) :23 if ( $site_id ) : 20 24 $_status = ''; 21 if ( 'simplified' === (string) iub_array_get( iubenda()->options['cs'], 'configuration_type' )) {25 if ( $is_cs_simplified ) { 22 26 $_status = 'active'; 23 27 } … … 71 75 <div class="my-4 subOptions"> 72 76 <?php 73 if ( iub_array_get( iubenda()->options['global_options'], 'site_id' )) {77 if ( $site_id ) { 74 78 $_status = ''; 75 if ( 'simplified' === (string) iub_array_get( iubenda()->options['cs'], 'configuration_type' )) {79 if ( $is_cs_simplified ) { 76 80 $_status = 'active'; 77 81 } … … 99 103 </div> 100 104 </div> 105 106 <?php 107 // Including partial cs-simplified-configuration. 108 require_once IUBENDA_PLUGIN_PATH . '/views/partials/auto-block-section.php'; 109 ?> 101 110 102 111 <div class="d-flex align-items-center pt-3"> … … 133 142 <div class="border-1 border-gray rounded mt-2 py-2 px-3 d-flex flex-wrap align-items-center"> 134 143 <?php 135 136 if ( empty( iubenda()->options['cs']['amp_template_done'] ) ) { 137 echo ' 138 <p class="description">' . esc_html_e( 'No file available. Save changes to generate iubenda AMP configuration file.', 'iubenda' ) . '</p>'; 139 } else { 140 ?> 141 <table class="table"> 142 <tbody> 143 <?php 144 // multi-language support. 145 if ( iubenda()->multilang && ! empty( iubenda()->languages ) ) { 146 foreach ( iubenda()->languages as $lang_id => $lang_name ) { 147 $is_amp_template_done = (bool) ! iub_array_get( iubenda()->options['cs']['amp_template_done'], $lang_id, false ); 148 if ( $is_amp_template_done ) { 149 continue; 150 } 151 ?> 152 <tr> 153 <td><p class="text-bold"><?php echo esc_html( $lang_name ); ?></p></td> 154 <td> 155 <a href="<?php echo esc_url( iubenda()->AMP->get_amp_template_url( $lang_id ) ); ?>" target="_blank"><?php echo esc_url( iubenda()->AMP->get_amp_template_url( $lang_id ) ); ?></a> 156 </td> 157 </tr> 158 <?php 159 } 160 } else { 161 ?> 162 <tr> 163 <td><p class="text-bold"><?php esc_html_e( 'Default language', 'iubenda' ); ?></p></td> 164 <td> 165 <a href="<?php echo esc_url( iubenda()->AMP->get_amp_template_url() ); ?>" target="_blank"><?php echo esc_url( iubenda()->AMP->get_amp_template_url() ); ?></a> 166 </td> 167 </tr> 168 <?php 169 } 170 } 144 // Including partial amp-files-section. 145 require_once IUBENDA_PLUGIN_PATH . '/views/partials/amp-template-links.php'; 171 146 ?> 172 </tbody>173 </table>174 147 </div> 175 148 … … 200 173 </table> 201 174 </section> 175 202 176 </section> 203 177 204 178 <div class="d-flex align-items-center pt-3"> 205 179 <label class="checkbox-regular"> 206 <input type="checkbox" name="iubenda_cookie_law_solution[parse]" value="1" class="mr-2 section-checkbox-control " data-section-name="#iub_parser_engine_container" <?php checked( true, (bool) iubenda()->options['cs']['parse'] ); ?>>207 <span><?php esc_html_e( ' Automatically block scripts detected by the plugin', 'iubenda' ); ?> <a target="_blank" href="<?php echo esc_url( iubenda()->settings->links['automatic_block_scripts'] ); ?>" class="ml-1 tooltip-icon">?</a></span>180 <input type="checkbox" name="iubenda_cookie_law_solution[parse]" value="1" class="mr-2 section-checkbox-control blocking-method native-blocking-method" data-section-name="#iub_parser_engine_container" <?php checked( true, (bool) iubenda()->options['cs']['parse'] ); ?>> 181 <span><?php esc_html_e( 'Native Blocking', 'iubenda' ); ?> <a target="_blank" href="<?php echo esc_url( iubenda()->settings->links['automatic_block_scripts'] ); ?>" class="ml-1 tooltip-icon">?</a></span> 208 182 </label> 209 183 </div> … … 348 322 </fieldset> 349 323 </section> 324 <div id="both-blocking-methods-disabled-warning-message" class="mxx-4 mb-4 notice notice--warning mt-2 p-3 align-items-center text-warning text-xs d-flex <?php echo iubenda()->options['cs']['parse'] ? 'd-flex' : ''; ?>"> 325 <img class="mr-2" src="<?php echo esc_url( IUBENDA_PLUGIN_URL ); ?>/assets/images/warning-icon.svg"> 326 <p> 327 <?php esc_html_e( 'Most legislation explicitly require prior consent in order to process user’s data. By disabling these blocking options you may be in breach of such requirements', 'iubenda' ); ?> 328 </p> 329 </div> 350 330 <div class="d-flex align-items-center pt-3"> 351 331 <label class="checkbox-regular"> -
iubenda-cookie-law-solution/tags/beta/views/partials/cs-simplified-configuration.php
r2922322 r3031643 27 27 $legislation_all_status = (bool) iub_array_get( $legislation, 'all' ); 28 28 ?> 29 <div class="mb-5">29 <div id="legalisation-section" class="mb-5"> 30 30 <h4><?php esc_html_e( 'Legislation', 'iubenda' ); ?></h4> 31 31 <div class="scrollable gap-fixer"> … … 50 50 </div> 51 51 </div> 52 <div id="require-consent-div" class="mb-5 <?php echo $legislation_all_status || $legislation_gdpr_status || $legislation_lgpd_status ? '' : esc_attr( 'hidden' ); ?>">52 <div id="require-consent-div" class="mb-5"> 53 53 <h4><?php esc_html_e( 'Require consent from', 'iubenda' ); ?></h4> 54 54 <div class="scrollable gap-fixer"> 55 55 <fieldset class="d-flex radio-large"> 56 56 <div class="radio-controller" id="require-consent-worldwide-div"> 57 <input type="radio" id="require-consent-worldwide" name="iubenda_cookie_law_solution[simplified][require_consent]" value="worldwide" <?php checked( 'worldwide', iub_array_get( iubenda()->options['cs'], 'simplified.require_consent' ) ); ?>required>57 <input type="radio" id="require-consent-worldwide" name="iubenda_cookie_law_solution[simplified][require_consent]" value="worldwide" checked required> 58 58 <label for="require-consent-worldwide"> 59 59 <div class="d-flex align-items-center"> … … 66 66 </svg> 67 67 <span class="ml-2"><?php esc_html_e( 'Worldwide', 'iubenda' ); ?></span> 68 </div>69 </label>70 </div>71 <div class="radio-controller <?php echo $legislation_all_status || $legislation_gdpr_status ? '' : esc_attr( 'hidden' ); ?>" id="require-consent-eu-div">72 <input type="radio" id="require-consent-eu" name="iubenda_cookie_law_solution[simplified][require_consent]" value="eu_only" <?php checked( 'eu_only', iub_array_get( iubenda()->options['cs'], 'simplified.require_consent' ), true ); ?> required>73 <label for="require-consent-eu">74 <div class=" d-flex align-items-center">75 <svg xmlns="http://www.w3.org/2000/svg" width="30" height="28" viewBox="0 0 30 28">76 <g fill="none" fill-rule="evenodd">77 <path fill="currentColor" fill-opacity=".1" d="M4.5 5.5H30v18H4.5z"/>78 <path fill="currentColor" d="M13.5 7a.75.75 0 100-1.5.75.75 0 000 1.5zM13.5 17.5a.75.75 0 100-1.5.75.75 0 000 1.5zM18 11.5a.75.75 0 101.5 0 .75.75 0 00-1.5 0zM7.5 11.5a.75.75 0 101.5 0 .75.75 0 00-1.5 0zM16.682 14.682a.75.75 0 101.06 1.06.75.75 0 00-1.06-1.06zM9.257 7.257a.75.75 0 101.061 1.061.75.75 0 00-1.06-1.06zM10.318 14.682a.75.75 0 10-1.06 1.06.75.75 0 001.06-1.06zM17.743 7.257a.75.75 0 10-1.061 1.061.75.75 0 001.06-1.06z"/>79 <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" d="M.75 2.5h25.391v18H.75z"/>80 <path class="svg-stroke" fill="#D8D8D8" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" d="M.75 1v26.027"/>81 </g>82 </svg>83 <span class="ml-2"><?php esc_html_e( 'Users in Europe only', 'iubenda' ); ?></span>84 </div>85 </label>86 </div>87 <div class="radio-controller <?php echo $legislation_all_status || $legislation_lgpd_status ? '' : esc_attr( 'hidden' ); ?>" id="require-consent-br-div">88 <input type="radio" id="require-consent-br" name="iubenda_cookie_law_solution[simplified][require_consent]" value="br_only" <?php checked( 'br_only', iub_array_get( iubenda()->options['cs'], 'simplified.require_consent' ), true ); ?> required>89 <label for="require-consent-br">90 <div class=" d-flex align-items-center">91 <svg data-v-4fb2c280="" xmlns="http://www.w3.org/2000/svg" role="presentation" viewBox="0 0 32 32" width="32" height="32" aria-label="iub-flagBr" class="cscr_i iub-icon icon-flagbr size-md">92 <defs><circle id="a" cx="2" cy="2.122" r="2"></circle></defs>93 <g fill="none" fill-rule="evenodd">94 <path fill="currentColor" fill-opacity=".1" fill-rule="nonzero" d="M4.667 5h22.667v16H4.667z"></path>95 <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.333" d="M1.333 2.333h22.57v16H1.333z"></path>96 <path fill="#D8D8D8" fill-rule="nonzero" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.333" d="M1.333 1v23.135"></path>97 <path stroke="currentColor" stroke-linejoin="round" d="m6 10.388 6.872 4.389 6.873-4.389L12.872 6z"></path>98 <g transform="translate(10.974 8.368)">99 <mask id="b" fill="#fff"><use xlink:href="#a"></use></mask>100 <use xlink:href="#a" fill="currentColor"></use>101 <path stroke="currentColor" stroke-width=".6" d="M3.077 4c-.231-1.554-1.09-2.995-2.26-4" mask="url(#b)" transform="rotate(-47 1.947 2)"></path>102 </g>103 </g>104 </svg>105 <span class="ml-2"><?php esc_html_e( 'Users in Brazil only', 'iubenda' ); ?></span>106 68 </div> 107 69 </label> -
iubenda-cookie-law-solution/tags/beta/views/partials/languages-tabs.php
r2848150 r3031643 10 10 exit; 11 11 } 12 13 // Check if $key is defined before using it. 14 if ( ! isset( $key ) ) { 15 return; 16 } 17 18 // Check if $service is defined before using it. 19 if ( empty( $service ) ) { 20 return; 21 } 22 12 23 ?> 13 24 <div class="mb-3 p-0"> … … 23 34 } 24 35 ?> 25 <li id="<?php echo esc_html( "code_{$k}-iubenda_{$service['name']}_solution_tab" ); ?>" class=" tabs__nav__item <?php echo esc_html( $_status ); ?>" data-target="tab-<?php echo esc_html( $k); ?>" data-group="language-tabs">36 <li id="<?php echo esc_html( "code_{$k}-iubenda_{$service['name']}_solution_tab" ); ?>" class="iub-language-tab tabs__nav__item <?php echo esc_html( $_status ); ?>" data-target="tab-<?php echo esc_html( $k ); ?>" data-target-textarea="#<?php echo esc_html( "iub-embed-code-{$k}-{$service['name']}" ); ?>" data-group="language-tabs"> 26 37 <?php echo esc_html( strtoupper( $k ) ); ?> 27 38 </li> … … 36 47 $code = $product_helper->{$method}( $lang_id ); 37 48 ?> 38 <div data-target="tab-<?php echo esc_html( $lang_id ); ?>" class="tabs__target <?php echo (string) iubenda()->lang_default === (string) $lang_id || 'default' === (string) $lang_id ? 'active' : ''; ?>" data-group="language-tabs"> 39 <textarea class='form-control text-sm m-0 iub-language-code iub-embed-code-<?php echo esc_html( $key ); ?>' data-language="<?php echo esc_html( $lang_id ); ?>" placeholder='<?php esc_html_e( 'Paste your embed code here', 'iubenda' ); ?>' name='iubenda_<?php echo esc_html( $service['name'] ); ?>_solution[code_<?php echo esc_html( $lang_id ); ?>]' rows='4'><?php echo esc_html( $code ); ?></textarea> 49 <div data-target="tab-<?php echo esc_html( $lang_id ); ?>" class="tabs__target iub-embed-code-<?php echo esc_html( $key ); ?>-container <?php echo (string) iubenda()->lang_default === (string) $lang_id || 'default' === (string) $lang_id ? 'active' : ''; ?>" data-group="language-tabs"> 50 <textarea 51 class='form-control text-sm m-0 iub-language-code iub-embed-code-<?php echo esc_html( $key ); ?>' 52 data-language="<?php echo esc_html( $lang_id ); ?>" 53 placeholder='<?php esc_html_e( 'Paste your embed code here', 'iubenda' ); ?>' 54 id='<?php echo esc_html( "iub-embed-code-{$lang_id}-{$service['name']}" ); ?>' 55 name='iubenda_<?php echo esc_html( $service['name'] ); ?>_solution[code_<?php echo esc_html( $lang_id ); ?>]' 56 rows='4' 57 ><?php echo esc_html( $code ); ?></textarea> 40 58 </div> 41 59 <?php endforeach; ?> -
iubenda-cookie-law-solution/tags/beta/views/partials/modals/modal-almost-there.php
r2922322 r3031643 122 122 if ( 'cs' === (string) $key ) : 123 123 ?> 124 <input type="hidden" name="iubenda_cookie_law_solution[parse]" value="1">124 <input type="hidden" class="blocking-method native-blocking-method" name="iubenda_cookie_law_solution[parse]" value="1"> 125 125 <input type="hidden" name="iubenda_cookie_law_solution[parser_engine]" value="<?php echo can_use_dom_document_class() ? esc_attr( 'new' ) : 'default'; ?>"> 126 126 <?php endif; ?> -
iubenda-cookie-law-solution/tags/beta/views/partials/product-card.php
r2848150 r3031643 9 9 if ( ! defined( 'ABSPATH' ) ) { 10 10 exit; 11 } 12 13 // Check if $service_key is defined before using it. 14 if ( ! isset( $service_key ) ) { 15 return; 16 } 17 18 // Check if $service_options is defined before using it. 19 if ( empty( $service_options ) ) { 20 return; 11 21 } 12 22 ?> -
iubenda-cookie-law-solution/tags/beta/views/products-page.php
r2848150 r3031643 21 21 <?php 22 22 $result = array_filter( 23 array_column( $this->services, 'status' ),23 array_column( iubenda()->settings->services, 'status' ), 24 24 function ( $service ) { 25 25 return ( stripos( $service, 'false' ) === false );
Note: See TracChangeset
for help on using the changeset viewer.