Plugin Directory

Changeset 3031643


Ignore:
Timestamp:
02/05/2024 01:13:10 PM (2 years ago)
Author:
iubenda
Message:

3.10.1-beta - Add code quality checks

Location:
iubenda-cookie-law-solution/tags/beta
Files:
12 added
32 edited

Legend:

Unmodified
Added
Removed
  • iubenda-cookie-law-solution/tags/beta/assets/css/style.css

    r2922322 r3031643  
    171171.mx-4 {
    172172    margin-left: 1.5rem !important;
     173}
     174
     175.mxx-4 {
     176    margin-left: 2.5rem !important;
    173177}
    174178
     
    11611165    background-repeat: no-repeat;
    11621166    background-position: center;
     1167}
     1168
     1169.checkbox-regular input[type=checkbox]:disabled {
     1170    cursor: not-allowed;
    11631171}
    11641172
  • iubenda-cookie-law-solution/tags/beta/assets/js/admin.js

    r2965748 r3031643  
    8282            IUB.ELEMS.body.on( 'click', '.update-button-style', updateButtonStyle );
    8383            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 );
    8485            IUB.ELEMS.body.on( 'change click', '.iub-toggle-elements-status', toggleCheckboxes );
    8586            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 );
    8691        }
    8792    );
     
    229234                                500
    230235                            );
     236                            if (response.message_code != undefined && 'missing_legalisation' === response.message_code) {
     237                                return;
     238                            }
    231239                        }
    232240                        $( '#modal-no-website-found' ).addClass( 'shown' )
     
    654662                    }
    655663                }
    656             ).trigger( 'change' );
    657 
     664            );
     665            $('.cs-configuration-type:checked:first').trigger( 'change' )
    658666        }
    659667    );
     
    864872        let legislation_all_status = legislation_all.prop( "checked" );
    865873
    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 
    899874        if (legislation_uspr_status || legislation_all_status) {
    900875            $( '#explicit-fieldset input:checkbox' ).each(
     
    926901    );
    927902
    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                                 return
    953                             }
    954 
    955                             if (result.status === 'progress') {
    956                                 activeRequest = false;
    957                                 completed     = true;
    958                                 setTimeout( ajax, 10000 );
    959                                 return
    960                             }
    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 
    996903    function handleAlertDiv(alertImageMessage) {
    997904        let alert_div           = ("#alert-div")
     
    1007914        }
    1008915    }
     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
    10091039}(window, jQuery));
  • iubenda-cookie-law-solution/tags/beta/assets/js/tabs.js

    r2848150 r3031643  
    2323
    2424            groupTargets.hide();
     25
     26            target.addClass( 'active' );
    2527            target.show();
    2628
  • iubenda-cookie-law-solution/tags/beta/includes/block/class-iubenda-legal-block.php

    r2969392 r3031643  
    319319            $block_name = (string) iub_array_get( $block, 'name' );
    320320
    321             if ( strpos( $block_name, 'footer-default' ) !== false ) {
     321            if ( 'twentytwentyfour/footer' === $block_name || strpos( $block_name, 'footer-default' ) !== false ) {
    322322                // Unregister default footer.
    323323                $block_registry->unregister( iub_array_get( $block, 'name' ) );
     
    385385     * Remove specific string between $beginning and $end.
    386386     *
    387      * @param   string $beginning  beginning.
    388      * @param   string $end        end.
    389      * @param   string $string     string.
     387     * @param   string $beginning      beginning.
     388     * @param   string $end            end.
     389     * @param   string $target_string  string.
    390390     *
    391391     * @return mixed
    392392     */
    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 );
    396396        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 );
    401401
    402402        // 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 ) );
    404404    }
    405405
     
    426426        $previous_value = libxml_use_internal_errors( true );
    427427        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' );
    429429        }
    430430
     
    480480     */
    481481    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
    482486        $html = str_get_html( $footer_content, true, true, false );
    483487
     
    505509        return $footer_content;
    506510    }
    507 
    508511}
  • iubenda-cookie-law-solution/tags/beta/includes/class-cookie-solution-generator.php

    r2922322 r3031643  
    8888                $cs_configuration['banner']['customizeButtonDisplay'] = true;
    8989            }
    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             }
    9690        }
    9791
     
    120114        }
    121115
    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 
    132116        if ( $legislation_uspr_status || $legislation_lgpd_status || $legislation_all_status ) {
    133117            $cs_configuration['invalidateConsentWithoutLog'] = true;
    134             if ( 'br_only' === $require_consent ) {
    135                 $cs_configuration['lgpdAppliesGlobally'] = false;
    136             }
    137118        }
    138119
     
    186167        $after_configuration .= '<script type="text/javascript" src="https://plugins.trac.wordpress.org//cdn.iubenda.com/cs/iubenda_cs.js" charset="UTF-8" async></script>';
    187168
     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
    188178        return $before_configuration . wp_json_encode( $cs_configuration ) . '; ' . $after_configuration;
    189179    }
  • iubenda-cookie-law-solution/tags/beta/includes/class-iubenda-amp.php

    r2859244 r3031643  
    8686     * Add scripts and CSS to WP AMP plugin in Transitional mode.
    8787     *
    88      * @return mixed
     88     * @return void
    8989     */
    9090    public function wp_head_amp() {
     
    135135     * Add AMP consent HTML to WP AMP plugin in Transitional mode.
    136136     *
    137      * @return mixed
     137     * @return void
    138138     */
    139139    public function wp_footer_amp() {
     
    159159            // local file.
    160160            if ( 'local' === (string) iubenda()->options['cs']['amp_source'] ) {
    161                 // multi language support.
     161                // multi-language support.
    162162                if ( iubenda()->multilang && ! empty( iubenda()->lang_current ) ) {
    163163                    $template_url = $this->get_amp_template_url( iubenda()->lang_current );
     
    166166                }
    167167                // 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 ] : '' );
    168170            } 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'] );
    175172            }
    176173
     
    234231        }
    235232
     233        if ( ! class_exists( 'iubendaParser' ) ) {
     234            return $data;
     235        }
     236
    236237        global $redux_builder_amp;
    237238
     
    260261        }
    261262
     263        if ( ! class_exists( 'iubendaParser' ) ) {
     264            return $analytics_entries;
     265        }
     266
    262267        // 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() ) {
    264269            foreach ( $analytics_entries as $id => $entry ) {
    265270                $entry['attributes'] = ! empty( $entry['attributes'] ) ? $entry['attributes'] : array();
     
    282287        $html = '';
    283288
    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
    285296        $banner_configuration = iubenda()->parse_configuration(
    286297            $code,
     
    307318            $configuration = preg_replace( '/"([a-zA-Z]+[a-zA-Z0-9]*)":/', '$1:', $configuration );
    308319            // replace first and last bracket.
    309             $configuration = substr( $configuration, 1, -1 );
     320            $configuration = substr( $configuration, 1, - 1 );
    310321
    311322            // Here we are generating amp page, for this reason no need to use enqueue.
     
    380391        // get basic site host and template file data.
    381392        $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
    384394        $parsed_site  = wp_parse_url( home_url() );
    385395        $parsed_file  = wp_parse_url( $file_url );
     
    392402        // if not, we're good to go.
    393403        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'] ) {
    394409            $template_url = $file_url;
    395             // if are located on same host do additional tweaks.
    396410        } 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'] );
    400422            } 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;
    424433            }
    425434        }
     
    441450        }
    442451
    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 );
    446465
    447466        // bail if the template was not created properly.
     
    452471        if ( ! is_dir( $template_dir ) ) {
    453472            // 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 ) ) {
    458477            ( new Quick_Generator_Service() )->add_amp_permission_error();
    459478            return false;
    460479        }
    461480
    462         // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_file_put_contents
    463         $result = file_put_contents( $template_file, $html );
     481        // Use WP_Filesystem for file operations.
     482        $result = $wp_filesystem->put_contents( $template_file, $html );
    464483
    465484        return (bool) $result;
  • iubenda-cookie-law-solution/tags/beta/includes/class-iubenda-forms.php

    r2922322 r3031643  
    4242        add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
    4343        // 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' ) );
    4646    }
    4747
     
    4949     * Process entry for WP forms
    5050     *
    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 ) {
    5755        global $wp_version;
    5856        $public_api_key = iubenda()->options['cons']['public_api_key'];
    5957
    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".
    6159        // Or escape if the public api key is not defined.
    6260        // Check current WP version is newer than 4.7 to use the wp_doing_ajax function.
     
    208206            );
    209207        }
    210 
    211208    }
    212209
     
    288285     * Get form function.
    289286     *
    290      * @param int $id id.
     287     * @param   int $id id.
    291288     *
    292289     * @return object
     
    329326     * Delete form function.
    330327     *
    331      * @param int $id id.
     328     * @param   int $id id.
    332329     *
    333330     * @return int
     
    354351     * Insert form function.
    355352     *
    356      * @param   array $args args.
     353     * @param   array $args  args.
    357354     *
    358355     * @return int
     
    744741                $checkout_form = '';
    745742
     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
    746747                ob_start();
    747748
     
    808809
    809810                // Germanized for WooCommerce.
    810                 if ( class_exists( 'WooCommerce_Germanized' ) ) {
     811                if ( function_exists( 'woocommerce_gzd_template_render_checkout_checkboxes' ) && class_exists( 'WooCommerce_Germanized' ) ) {
    811812                    woocommerce_gzd_template_render_checkout_checkboxes();
    812813                }
     
    878879                        }
    879880
    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                                            }
    895896                                        }
    896897                                    }
    897898                                }
     899
     900                                $forms[] = $formdata;
    898901                            }
    899 
    900                             $forms[] = $formdata;
    901 
    902902                        }
    903903                    }
     
    995995                        }
    996996
    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                                            }
    10121013                                        }
    10131014                                    }
    10141015                                }
     1016
     1017                                $forms[] = $formdata;
     1018
    10151019                            }
    1016 
    1017                             $forms[] = $formdata;
    1018 
    10191020                        }
    10201021                    }
     
    11111112     * @param   array $args  args.
    11121113     *
    1113      * @return array
     1114     * @return false|object
    11141115     */
    11151116    public function get_form_by_object_id( $args = array() ) {
     
    11301131            ),
    11311132            'post_type'      => 'iubenda_form',
    1132             'post_status'    => isset( $args['post_status'] ) ? $args['post_status'] : 'any',
     1133            'post_status'    => $args['post_status'] ?? 'any',
    11331134            'posts_per_page' => '1',
    11341135            'fields'         => 'ids',
     
    11391140
    11401141        // check result.
    1141         if ( ! $posts || is_wp_error( $posts ) ) {
     1142        if ( empty( $posts ) ) {
    11421143            return false;
    11431144        }
    11441145
    1145         $form = $this->get_form( $posts[0] );
    1146 
    11471146        // kick back results.
    1148         return $form;
     1147        return $this->get_form( $posts[0] );
    11491148    }
    11501149
     
    11521151     * Convert nested array into one level
    11531152     *
    1154      * @param   array  $array array.
    1155      * @param   string $prepend prepend.
     1153     * @param   array  $target_array array.
     1154     * @param   string $prepend       prepend.
    11561155     *
    11571156     * @return array
    11581157     */
    1159     public function iub_array_dot( $array, $prepend = '' ) {
     1158    public function iub_array_dot( $target_array, $prepend = '' ) {
    11601159        $results = array();
    11611160
    1162         foreach ( $array as $key => $value ) {
     1161        foreach ( $target_array as $key => $value ) {
    11631162            if ( is_array( $value ) && ! empty( $value ) ) {
    11641163                $results = array_merge( $results, $this->iub_array_dot( $value, $prepend . $key . '.' ) );
     
    11741173     * Prepare mapped forms
    11751174     *
    1176      * @param   array $forms forms.
    1177      * @param   array $args args.
     1175     * @param   array $forms  forms.
     1176     * @param   array $args   args.
    11781177     *
    11791178     * @return array
     
    12721271
    12731272            // 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' ) ) {
    12751274                $wpform_content = wpforms()->form->get( $form->object_id )->post_content;
    12761275                $wpform_content = json_decode( $wpform_content, true );
     
    13051304    /**
    13061305     * 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.
    13111309     *
    13121310     * @return string[]
    13131311     */
    1314     public function mc4wp_integration_woocommerce_checkbox_attributes( $attributes, $integration ) {
     1312    public function mc4wp_integration_woocommerce_checkbox_attributes( $attributes ) {
    13151313        $attributes['id'] = '_mc4wp_subscribe_woocommerce';
    13161314
     
    13211319     * Finding elementor form id.
    13221320     *
    1323      * @param mixed $data Data.
    1324      * @param mixed $form_ids Form_ids.
     1321     * @param   mixed $data      Data.
     1322     * @param   mixed $form_ids Form_ids.
    13251323     */
    13261324    private function find_elementor_form_id( $data, &$form_ids ) {
  • iubenda-cookie-law-solution/tags/beta/includes/class-iubenda-list-table-forms.php

    r2965748 r3031643  
    201201        $output .= '<div class="row-actions">';
    202202        foreach ( $actions as $action => $link ) {
    203             ++ $i;
     203            ++$i;
    204204            $sep     = ( 1 === $i ) ? $sep = '' : $sep = ' | ';
    205205            $output .= '<span class="' . ( 'delete' === $action ? 'delete delete-form' : $action ) . '">' . $sep . $link . '</span>';
     
    309309
    310310            if ( ! empty( $output ) ) {
    311                 echo wp_kses( $output );
     311                echo wp_kses_post( $output );
    312312                submit_button( __( 'Filter', 'iubenda' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
    313313            }
     
    432432            $columns['cb']     = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'iubenda' ) . '</label>'
    433433                . '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
    434             $cb_counter++;
     434            ++$cb_counter;
    435435        }
    436436
    437437        foreach ( $columns as $column_key => $column_display_name ) {
    438             $class = array( 'manage-column', "column-$column_key" );
     438            $classes = array( 'manage-column', "column-$column_key" );
    439439
    440440            if ( in_array( $column_key, $hidden, true ) ) {
    441                 $class[] = 'hidden';
     441                $classes[] = 'hidden';
    442442            }
    443443
    444444            if ( 'cb' === $column_key ) {
    445                 $class[] = 'check-column';
     445                $classes[] = 'check-column';
    446446            } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ), true ) ) {
    447                 $class[] = 'num';
     447                $classes[] = 'num';
    448448            }
    449449
    450450            if ( $column_key === $primary ) {
    451                 $class[] = 'column-primary';
     451                $classes[] = 'column-primary';
    452452            }
    453453
     
    458458                    $order = 'asc' === $current_order ? 'desc' : 'asc';
    459459
    460                     $class[] = 'sorted';
    461                     $class[] = $current_order;
     460                    $classes[] = 'sorted';
     461                    $classes[] = $current_order;
    462462                } else {
    463463                    $order = strtolower( $desc_first );
     
    467467                    }
    468468
    469                     $class[] = 'sortable';
    470                     $class[] = 'desc' === $order ? 'asc' : 'desc';
     469                    $classes[] = 'sortable';
     470                    $classes[] = 'desc' === $order ? 'asc' : 'desc';
    471471                }
    472472
     
    481481            $scope = ( 'th' === $tag ) ? 'scope="col"' : '';
    482482            $id    = $with_id ? "id='$column_key'" : '';
    483 
    484             if ( ! empty( $class ) ) {
    485                 $class = "class='" . implode( ' ', $class ) . "'";
    486             }
     483            $class = "class='" . implode( ' ', $classes ) . "'";
    487484
    488485            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  
    142142        if ( ! empty( iub_get_request_parameter( 'iub_nonce' ) ) ) {
    143143            $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 );
    145145
    146146            // delay notice.
     
    167167    /**
    168168     * 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() {
    173171        if ( ! current_user_can( 'manage_options' ) ) {
    174172            return;
     
    346344    private function check_for_showing_rating_notice() {
    347345        $current_update = 10;
    348         $activation     = (array) get_option( 'iubenda_activation_data', iubenda()->activation, array() );
     346        $activation     = (array) get_option( 'iubenda_activation_data', iubenda()->activation );
    349347
    350348        // get current time.
  • iubenda-cookie-law-solution/tags/beta/includes/class-iubenda-settings.php

    r2969392 r3031643  
    7575     * @var string[]
    7676     */
    77     private $legal_notices;
     77    public $legal_notices;
    7878
    7979    /**
     
    193193                'how_tc_rate'                    => 'https://www.iubenda.com/en/help/19482-what-should-basic-terms-and-conditions-include',
    194194                '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',
    196196                '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',
    197198            ),
    198199            'it'    => array(
     
    223224                'how_tc_rate'                    => 'https://www.iubenda.com/it/help/19482-what-should-basic-terms-and-conditions-include',
    224225                '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',
    226227                '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',
    227229            ),
    228230            'de'    => array(
     
    253255                'how_tc_rate'                    => 'https://www.iubenda.com/de/help/19482-what-should-basic-terms-and-conditions-include',
    254256                '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',
    256258                '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',
    257260            ),
    258261            'es'    => array(
     
    283286                'how_tc_rate'                    => 'https://www.iubenda.com/es/help/19482-what-should-basic-terms-and-conditions-include',
    284287                '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',
    286289                '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',
    287291            ),
    288292            'fr'    => array(
     
    313317                'how_tc_rate'                    => 'https://www.iubenda.com/fr/help/19482-what-should-basic-terms-and-conditions-include',
    314318                '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',
    316320                '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',
    317322            ),
    318323            'pt-br' => array(
     
    343348                'how_tc_rate'                    => 'https://www.iubenda.com/pt-br/help/19482-what-should-basic-terms-and-conditions-include',
    344349                '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',
    346351                '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',
    347353            ),
    348354            'nl'    => array(
     
    373379                'how_tc_rate'                    => 'https://www.iubenda.com/nl/help/19482-what-should-basic-terms-and-conditions-include',
    374380                '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',
    376382                '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',
    377384            ),
    378385        );
     
    433440
    434441    /**
    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 ) {
    440449        $result = array_filter(
    441             array_column( $this->services, 'status' ),
     450            array_column( $services, 'status' ),
    442451            function ( $service ) {
    443                 return ( stripos( $service, 'false' ) === false );
     452                return ( 'true' === (string) $service || true === $service );
    444453            }
    445454        );
    446455
    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 ) {
    452467        $result = array_filter(
    453             array_column( iubenda()->options, 'configured' ),
     468            array_column( $services, 'configured' ),
    454469            function ( $service ) {
    455                 return ( stripos( $service, 'true' ) === true );
     470                return ( 'true' === (string) $service || true === $service );
    456471            }
    457472        );
    458473
    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 ) ) {
    460490            return true;
    461491        }
     
    472502        global $pagenow;
    473503
    474         $show_products_page = $this->check_site_is_already_made_setup();
     504        $show_products_page = $this->is_site_already_set_up();
    475505
    476506        if ( ! current_user_can( apply_filters( 'iubenda_cookie_law_cap', 'manage_options' ) ) ) {
     
    537567                break;
    538568            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";
    544570        }
    545571    }
     
    551577     */
    552578    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
    553604        if ( ! in_array( (string) $page, array( 'toplevel_page_iubenda', 'settings_page_iubenda' ), true ) ) {
    554605            wp_enqueue_style( 'iubenda-admin', IUBENDA_PLUGIN_URL . '/assets/css/admin.css', array(), iubenda()->version );
     
    557608        wp_enqueue_style( 'iubenda-admin', IUBENDA_PLUGIN_URL . '/assets/css/style.css', array(), iubenda()->version );
    558609        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         );
    579610
    580611        wp_localize_script( 'iubenda-admin', 'iub_js_vars', $iub_js_vars );
     
    911942     * Sanitize array helper function.
    912943     *
    913      * @param array $array array.
     944     * @param array $target_array  array.
     945     *
    914946     * @return array
    915947     */
    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 ) ) {
    918950            return array();
    919951        }
    920952
    921         return array_map( 'sanitize_text_field', $array );
     953        return array_map( 'sanitize_text_field', $target_array );
    922954    }
    923955
     
    939971     * Load admin style inline, for menu icon only.
    940972     *
    941      * @return mixed
     973     * @return void
    942974     */
    943975    public function admin_print_styles() {
     
    10721104            ),
    10731105        );
    1074 
    10751106    }
    10761107
     
    12571288        // Check if the API key is set in the $_SERVER variable.
    12581289        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'] ) ) );
    12601291        }
    12611292
    12621293        // Check if the API key is set in the $_ENV variable.
    12631294        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.
    12681304        return self::IUB_QG_API_KEY;
    12691305    }
  • iubenda-cookie-law-solution/tags/beta/includes/class-language-helper.php

    r2859244 r3031643  
    5050     */
    5151    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' ) ) {
    5353            $default_language_local_code = pll_default_language( 'locale' );
    5454            $website_language_code       = (string) iub_array_get( iubenda()->lang_mapping, $default_language_local_code );
     
    108108        return $iub_languages;
    109109    }
    110 
    111110}
  • iubenda-cookie-law-solution/tags/beta/includes/class-product-helper.php

    r2965748 r3031643  
    101101     */
    102102    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.
    104104        if ( iubenda()->multilang === true && defined( 'ICL_LANGUAGE_CODE' ) && isset( iubenda()->options['cs'][ 'code_' . ICL_LANGUAGE_CODE ] ) ) {
    105105            $iubenda_code = iubenda()->options[ $service_key ][ 'code_' . ICL_LANGUAGE_CODE ];
     
    178178    public function is_cs_service_simplified() {
    179179        // Get the configuration type from the 'cs' option in the iubenda options.
    180         $configurationType = iub_array_get(iubenda()->options['cs'], 'configuration_type');
     180        $configuration_type = iub_array_get( iubenda()->options['cs'], 'configuration_type' );
    181181
    182182        // Check if the configuration type is equal to 'simplified' and return the result.
    183         return 'simplified' === (string) $configurationType;
     183        return 'simplified' === (string) $configuration_type;
    184184    }
    185185
  • iubenda-cookie-law-solution/tags/beta/includes/class-quick-generator-service.php

    r2922322 r3031643  
    201201        require_once IUBENDA_PLUGIN_PATH . 'views/partials/auto-detect-forms.php';
    202202        wp_die();
    203 
    204203    }
    205204
  • iubenda-cookie-law-solution/tags/beta/includes/class-radar-service.php

    r2965748 r3031643  
    1111}
    1212
    13 
    1413/**
    1514 * Iubenda radar service.
     
    6261    /**
    6362     * Maximum allowable delay in seconds.
     63     *
     64     * @var int The maximum delay time in seconds.
    6465     */
    6566    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;
    6674
    6775    /**
     
    7179        $this->service_rating    = new Service_Rating();
    7280        $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' ) );
    7387    }
    7488
     
    7690     * Ask radar to send request.
    7791     *
    78      * @return bool
     92     * @return void
    7993     */
    8094    public function ask_radar_to_send_request() {
     
    8498
    8599        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();
    90105    }
    91106
     
    188203        if ( $next_trial > time() ) {
    189204            if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
    190                 // Calculate the remaining time until the next trial
     205                // Calculate the remaining time until the next trial.
    191206                $next_request_in_sec = $next_trial - time();
    192207
    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.
    194209                $next_request_in_sec = min( $next_request_in_sec, $this->max_delay_in_sec );
    195210
     
    214229            $next_trial = time() + ( pow( 30, $rounds ) );
    215230        }
    216         $trial_num++;
     231        ++$trial_num;
    217232
    218233        // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
     
    259274     * @param   int|string     $response_code  The response code as an integer. Empty string if incorrect parameter given.
    260275     *
    261      * @return bool
     276     * @return void
    262277     */
    263278    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 ) ) {
    265280            if ( ! is_numeric( $response_code ) ) {
    266281                $message = $this->update_message;
     
    284299                );
    285300            }
    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();
    288330    }
    289331}
  • iubenda-cookie-law-solution/tags/beta/includes/class-service-rating.php

    r2848150 r3031643  
    159159        $services['pp']   = $this->is_privacy_policy_activated();
    160160        $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() );
    162162        $services['tc']   = $this->is_terms_conditions_activated();
    163163
     
    180180                'status'    => boolval( $this->is_cookie_solution_activated() && $this->is_cookie_solution_automatically_parse_enabled() ),
    181181                'label'     => __( 'Only track users that give consent', 'iubenda' ),
    182                 'paragraph' => __( 'This accounts for 25&#37; 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&#37; 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' ),
    183183            ),
    184184            'pp'   => array(
     
    209209        return false;
    210210    }
    211 
    212211}
  • iubenda-cookie-law-solution/tags/beta/includes/functions.php

    r2965748 r3031643  
    1515     * Iubenda array get
    1616     *
    17      * @param   array  $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  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.
    2020     *
    2121     * @return array|ArrayAccess|mixed|null
    2222     */
    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;
    2626        }
    2727
    2828        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 ];
    3434        }
    3535
    3636        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 );
    3838        }
    3939
    4040        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 ];
    4343            } else {
    44                 return $default instanceof Closure ? $default() : $default;
     44                return $default_value instanceof Closure ? $default_value() : $default_value;
    4545            }
    4646        }
    4747
    48         return $array;
     48        return $target_array;
    4949    }
    5050}
     
    5454     * Return only intersects keys with the array
    5555     *
    56      * @param   array        $array Array.
    57      * @param   array|string $keys Keys.
     56     * @param   array        $target_array Array.
     57     * @param   array|string $keys          Keys.
    5858     *
    5959     * @return array
    6060     */
    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 ) );
    6363    }
    6464}
     
    6868     * Translate a specific string into a specific language.
    6969     *
    70      * @param string $string       specific 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.
    7373     *
    7474     * @return string|void
    7575     */
    76     function __iub_trans( $string, $locale, $text_domain = 'iubenda' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
     76    function __iub_trans( $target_string, $locale, $text_domain = 'iubenda' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
    7777
    7878        $mo     = new MO();
     
    8181            $mo->import_from_file( $mofile );
    8282            // 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 ) );
    8484        }
    8585
    8686        // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText, WordPress.WP.I18n.NonSingularStringLiteralDomain
    87         return $string;
     87        return $target_string;
    8888    }
    8989}
     
    9595     * @param   int|string   $action      Action nonce.
    9696     * @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.
    9999     * @param   string       $capability  Capability name.
    100      * @param   bool         $die         Optional. 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.
    102102     *
    103103     * @return void
    104104     */
    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 ) {
    106106        if (
    107             ! check_ajax_referer( $action, $query_arg, $die ) ||
     107            ! check_ajax_referer( $action, $query_arg, $should_die ) ||
    108108            ! current_user_can( apply_filters( 'iubenda_cookie_law_cap', $capability ) )
    109109        ) {
     
    168168     * Gets the request parameter.
    169169     *
    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.
    172173     *
    173174     * @return     string  The request parameter.
    174175     */
    175     function iub_get_request_parameter( string $key, $default = '' ) {
     176    function iub_get_request_parameter( string $key, $default_value = '', $with_sanitize = true ) {
    176177        // If key not exist or empty return default.
    177178        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
    178179        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 ];
    184190    }
    185191}
  • iubenda-cookie-law-solution/tags/beta/includes/services/class-iubenda-code-extractor.php

    r2969392 r3031643  
    6767
    6868    /**
     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    /**
    69103     * Extract scripts and styles from embed code and enqueue it
    70104     *
     
    76110        $this->code = $code;
    77111
     112        $this->set_auto_blocking_state( $code );
    78113        $this->extract_html_tags();
    79114        $this->handle_scripts();
     115        $this->dispatch_scripts_in_head();
    80116        $this->handle_styles();
    81117
    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        }
    83144    }
    84145
     
    130191        // Extract scripts with src to enqueue it.
    131192        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.
    133206            $this->script_attributes[ "iubenda-head-scripts-{$key}" ] = $script['attributes'];
    134207        }
     
    201274     * @param   string $tag     HTML for the script tag.
    202275     * @param   string $handle  Handle of script.
    203      * @param   string $src     Src of script.
    204276     *
    205277     * @return string
    206278     */
    207     public function iub_add_attribute_to_scripts( $tag, $handle, $src ) {
     279    public function iub_add_attribute_to_scripts( $tag, $handle ) {
    208280        $key = array_search( $handle, array_keys( $this->script_attributes ), true );
    209281
     
    303375        $previous_value = libxml_use_internal_errors( true );
    304376        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' );
    306378        }
    307379
     
    320392                        'attributes' => $this->fetch_attributes_and_add_skip_class( $script ),
    321393                    );
     394                } elseif ( $this->check_tampered_script( $script->nodeValue ) ) {
     395                    $this->tampered_scripts[] = $script->nodeValue;
     396                    $script->nodeValue        = '';
    322397                } 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                    );
    333402                }
    334403            }
     
    354423     */
    355424    private function extract_html_tags_with_simple_html_dom() {
     425        if ( ! function_exists( 'str_get_html' ) ) {
     426            return;
     427        }
     428
    356429        $html = str_get_html( $this->code, true, true, false );
    357430
     
    437510        return $str;
    438511    }
     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    }
    439560    // phpcs:enable
    440561}
  • iubenda-cookie-law-solution/tags/beta/includes/services/class-iubenda-cs-product-service.php

    r2965748 r3031643  
    8383                    array(
    8484                        'status'       => 'error',
     85                        'focus'        => '#legalisation-section',
     86                        'message_code' => 'missing_legalisation',
    8587                        'responseText' => esc_html__( 'You must select at least one legislation.', 'iubenda' ),
    8688                    )
     
    130132                    $new_cs_option['amp_template_done'][ $lang_id ] = iub_array_get( $amp_options, 'amp_template_done' );
    131133                }
     134
     135                iubenda()->iub_auto_blocking->fetch_auto_blocking_status_by_site_id( $site_id );
    132136            }
    133137        } elseif ( 'manual' === $new_cs_option['configuration_type'] ) {
     
    164168                        $new_cs_option['amp_template'][ $lang_id ]      = iub_array_get( $amp_options, 'amp_template' );
    165169                        $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 );
    166177                    }
    167178                }
     
    179190
    180191        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            }
    183203        }
    184204
     
    199219        $new_cs_option  = wp_parse_args( $new_cs_option, $old_cs_options );
    200220
     221        $new_cs_option['frontend_auto_blocking'] = iubenda()->iub_auto_blocking->auto_block_sites_status;
    201222        // Saving and update the current instance with new CS options.
    202223        iubenda()->options['cs'] = $new_cs_option;
     
    236257        $result = array();
    237258
    238         $template_done = (bool) iubenda()->AMP->generate_amp_template( $code, $lang_id );
     259        $template_done = (bool) iubenda()->amp->generate_amp_template( $code, $lang_id );
    239260
    240261        if ( ( 'local' === $source ) && false === $template_done ) {
     
    307328        return $result;
    308329    }
     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    }
    309339}
  • iubenda-cookie-law-solution/tags/beta/includes/widget/class-iubenda-legal-widget.php

    r2922322 r3031643  
    143143     * @param   array $instance instance.
    144144     *
    145      * @return false
     145     * @return false|void
    146146     */
    147147    public function widget( $args, $instance ) {
     
    240240     * Assign iubenda widget to registered sidebar if exists and not registered before
    241241     *
    242      * @return bool
     242     * @return void
    243243     */
    244244    public function assign_iubenda_widget() {
     
    255255        }
    256256
    257         // Check if wp_assign_widget_to_sidebar is exist.
     257        // Check if wp_assign_widget_to_sidebar is existing.
    258258        if ( ! function_exists( 'wp_assign_widget_to_sidebar' ) ) {
    259259            return;
     
    296296        }
    297297    }
    298 
    299298}
    300299
  • iubenda-cookie-law-solution/tags/beta/includes/widget/elementor/class-iubenda-elementor-legal-widget.php

    r2922322 r3031643  
    1010if ( ! defined( 'ABSPATH' ) ) {
    1111    exit; // Exit if accessed directly.
     12}
     13
     14if ( ! class_exists( '\Elementor\Widget_Base' ) ) {
     15    return;
    1216}
    1317
     
    5357    public function get_icon() {
    5458        wp_enqueue_style( 'iubenda-elementor-css', IUBENDA_PLUGIN_URL . '/includes/widget/elementor/style.css', array(), iubenda()->version );
     59
    5560        return 'iub-legal-elementor-widget-icon-class';
    5661    }
     
    8085     */
    8186    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        }
    8492
    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        }
    9298
    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        }
    105108
    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        }
    107127    }
    108128
     
    113133     */
    114134    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 );
    120146
    121147        echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    122148    }
    123 
    124149}
  • iubenda-cookie-law-solution/tags/beta/iubenda-cookie-class/README.md

    r2922322 r3031643  
    9999## Changelog
    100100
     101##### 4.1.15
     102* Support PHP 8.2 | Fix Creation of dynamic properties
     103
    101104##### 4.1.14
    102105* Bugfix: escape if custom scripts/iframes are empty
  • iubenda-cookie-law-solution/tags/beta/iubenda-cookie-class/iubenda.class.php

    r2922322 r3031643  
    66 * @copyright 2018-2020, iubenda s.r.l
    77 * @license GNU/GPL
    8  * @version 4.1.14
     8 * @version 4.1.15
    99 *
    1010 * This program is free software: you can redistribute it and/or modify
     
    165165
    166166    /**
     167     * @var mixed
     168     */
     169    private $original_content_page;
     170
     171    /**
     172     * @var mixed
     173     */
     174    private $content_page;
     175
     176    /**
    167177     * Construct: the whole HTML output of the page
    168178     *
  • iubenda-cookie-law-solution/tags/beta/iubenda_cookie_solution.php

    r2972337 r3031643  
    44 * Plugin URI: https://www.iubenda.com
    55 * 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.6
     6 * Version: 3.10.0
    77 * Author: iubenda
    88 * Author URI: https://www.iubenda.com
     
    4646 *
    4747 * @class   iubenda
    48  * @version 3.7.6
     48 * @version 3.10.0
    4949 */
    5050class iubenda {
     
    9393            'stop_showing_cs_for_admins' => false,
    9494            '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(
    9999                    'gdpr' => true,
    100100                    'uspr' => false,
     
    102102                    'all'  => false,
    103103                ),
    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(),
    108109            ),
    109110        ),
     
    138139     * @var string
    139140     */
    140     public $version = '3.7.6';
     141    public $version = '3.9.0';
    141142
    142143    /**
     
    237238     * @var Iubenda_AMP
    238239     */
    239     public $AMP;
     240    public $amp;
    240241
    241242    /**
     
    287288     */
    288289    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;
    289304
    290305    /**
     
    325340            // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
    326341            self::$instance->service_rating            = new Service_Rating();
    327             self::$instance->AMP                       = new Iubenda_AMP();
     342            self::$instance->amp                       = new Iubenda_AMP();
    328343            self::$instance->forms                     = new Iubenda_Forms();
    329344            self::$instance->settings                  = new Iubenda_Settings();
     
    332347            self::$instance->notice                    = new Iubenda_Notice();
    333348            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();
    334351        }
    335352
     
    375392        add_action( 'admin_init', array( $this, 'check_iubenda_version' ) );
    376393        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 );
    378395        add_action( 'upgrader_overwrote_package', array( $this, 'do_upgrade_processes' ) );
    379396        add_action( 'after_switch_theme', array( $this, 'assign_legal_block_or_widget' ) );
     
    437454        $iubenda_code = '';
    438455
    439         // Check if there is multi language plugin installed and activated.
     456        // Check if there is multi-language plugin installed and activated.
    440457        if ( true === $this->multilang && defined( 'ICL_LANGUAGE_CODE' ) && isset( $this->options['cs'][ 'code_' . ICL_LANGUAGE_CODE ] ) ) {
    441458            $iubenda_code .= $this->options['cs'][ 'code_' . ICL_LANGUAGE_CODE ];
     
    527544        include_once IUBENDA_PLUGIN_PATH . 'includes/services/class-iubenda-code-extractor.php';
    528545        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';
    529550    }
    530551
     
    539560
    540561        // 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() ) {
    542563            $this->multilang = true;
    543564
     
    558579
    559580            // WPML support.
    560         } elseif ( iub_is_wpml_active() ) {
     581        } elseif ( function_exists( 'icl_get_languages' ) && iub_is_wpml_active() ) {
    561582            $this->multilang = true;
    562583
     
    584605
    585606        // load iubenda parser.
    586         include_once dirname( __FILE__ ) . '/iubenda-cookie-class/iubenda.class.php';
     607        include_once __DIR__ . '/iubenda-cookie-class/iubenda.class.php';
    587608    }
    588609
     
    731752     * Add wp_head Consent Database content.
    732753     *
    733      * @return mixed
     754     * @return void
    734755     */
    735756    public function wp_head_cons() {
     
    834855        }
    835856
     857        if ( ! class_exists( 'iubendaParser' ) ) {
     858            return $output;
     859        }
     860
    836861        // bail if consent given and skip parsing enabled.
    837862        if ( iubendaParser::consent_given() && $this->options['cs']['skip_parsing'] ) {
     
    847872        }
    848873
    849         // bail if bot detectd, no html in output or 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() ) {
    851876            return $output;
    852877        }
     
    863888
    864889        // 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() ) {
    866891            return $output;
    867892        }
     
    877902        }
    878903
    879         $startime = microtime( true );
    880         $output   = apply_filters( 'iubenda_initial_output', $output );
     904        $star_time = microtime( true );
     905        $output    = apply_filters( 'iubenda_initial_output', $output );
    881906
    882907        // prepare scripts and iframes.
     
    898923        if ( 'new' === (string) $this->options['cs']['parser_engine'] && can_use_dom_document_class() ) {
    899924            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' );
    901926            }
    902927            $iubenda = new iubendaParser(
     
    914939
    915940            // append signature.
    916             $output .= '<!-- Parsed with iubenda experimental class in ' . round( microtime( true ) - $startime, 4 ) . ' sec. -->';
     941            $output .= '<!-- Parsed with iubenda experimental class in ' . round( microtime( true ) - $star_time, 4 ) . ' sec. -->';
    917942        } else {
    918943            // default.
     
    931956
    932957            // append signature.
    933             $output .= '<!-- Parsed with iubenda default class in ' . round( microtime( true ) - $startime, 4 ) . ' sec. -->';
     958            $output .= '<!-- Parsed with iubenda default class in ' . round( microtime( true ) - $star_time, 4 ) . ' sec. -->';
    934959        }
    935960
     
    10181043        }
    10191044
     1045        if ( ! class_exists( 'iubendaParser' ) ) {
     1046            return;
     1047        }
     1048
    10201049        // 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() ) {
    10221051            return;
    10231052        }
     
    11311160            }
    11321161        }
    1133 
    11341162    }
    11351163
     
    13741402                if ( ! empty( $code ) ) {
    13751403                    // 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 );
    13771405                }
    13781406            }
     
    13831411        // For one language.
    13841412        $code = iubenda()->options['cs']['code_default'];
    1385         iubenda()->AMP->generate_amp_template( $code );
     1413        iubenda()->amp->generate_amp_template( $code );
    13861414    }
    13871415
     
    14321460     * Find closing bracket.
    14331461     *
    1434      * @param string $string String.
    1435      * @param string $open_position Open Position.
     1462     * @param string $target_string String.
     1463     * @param string $open_position  Open Position.
    14361464     *
    14371465     * @return mixed
    14381466     */
    1439     private function find_closing_bracket( $string, $open_position ) {
     1467    private function find_closing_bracket( $target_string, $open_position ) {
    14401468        $close_pos = $open_position;
    14411469        $counter   = 1;
     
    14431471
    14441472            // To Avoid the infinity loop.
    1445             if ( ! isset( $string[ $close_pos + 1 ] ) ) {
     1473            if ( ! isset( $target_string[ $close_pos + 1 ] ) ) {
    14461474                break;
    14471475            }
    14481476
    1449             $c = $string[ ++ $close_pos ];
     1477            $c = $target_string[ ++$close_pos ];
    14501478            if ( '{' === (string) $c ) {
    1451                 $counter ++;
     1479                ++$counter;
    14521480            } elseif ( '}' === (string) $c ) {
    1453                 $counter --;
     1481                --$counter;
    14541482            }
    14551483        }
     
    15301558            $iubenda_terms_conditions_generator = new Terms_Conditions_Generator();
    15311559
     1560            // Is the current configuration type is simplified.
     1561            $is_cs_simplified = ( new Iubenda_CS_Product_Service() )->is_cs_simplified();
     1562
    15321563            // Check embed codes in CS product.
    15331564            foreach ( iubenda()->options['cs'] as $key => $option ) {
     
    15381569                    $iubenda_code_extractor->has_tampered_scripts( $option )
    15391570                ) {
    1540                     if ( 'simplified' === (string) iub_array_get( iubenda()->options['cs'], 'configuration_type' ) ) {
     1571                    if ( $is_cs_simplified ) {
    15411572                        $simplified_options              = iub_array_get( iubenda()->options['cs'], 'simplified' );
    15421573                        $lang_id                         = trim( substr( $key, strpos( $key, 'code_' ) + strlen( 'code_' ) ) );
     
    16441675     */
    16451676    public static function is_wp_cli() {
    1646         return defined('WP_CLI') && WP_CLI;
     1677        return defined( 'WP_CLI' ) && WP_CLI;
    16471678    }
    16481679}
     
    16661697    2
    16671698);
    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.
     1701require 'iubenda-init.php';
  • iubenda-cookie-law-solution/tags/beta/readme.txt

    r2972337 r3031643  
    55Requires at least: 5.0
    66Requires PHP: 7.0.0
    7 Tested up to: 6.3
    8 Stable tag: 3.7.6
     7Tested up to: 6.4
     8Stable tag: 3.10.0
    99License: MIT License
    1010License URI: http://opensource.org/licenses/MIT
     
    5656* **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.
    5757* 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**.
    5959* 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)
    6060* Compatible with **Google’s Accelerated Mobile Pages** (AMP)
     
    268268== Changelog ==
    269269
     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
    270289= 3.7.6 =
    271290* Tweak: Fix compatibility issues with PHP 8.2
     
    832851== Upgrade Notice ==
    833852
    834 = 3.7.6 =
    835 * Tweak: Fix compatibility issues with PHP 8.2
     853= 3.10.0 =
     854* Introduced iubenda automatic blocking feature.
  • iubenda-cookie-law-solution/tags/beta/views/cons-single-form.php

    r2922322 r3031643  
    1212// Including partial header.
    1313require_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 */
     21function 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
    1436?>
    1537<div class="main-box">
     
    2547    <form id="postbox-container-2" action="options.php" method="post">
    2648        <?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'] );
    2951        add_settings_section(
    3052            'iubenda_consent_form',
    3153            __( 'Field Mapping', 'iubenda' ),
    3254            array(
    33                 $this,
     55                iubenda()->settings,
    3456                'iubenda_consent_form',
    3557            ),
     
    3759        );
    3860
    39         $form_id = absint( iub_get_request_parameter( 'form_id', 0 ) );
     61        $form_id = (int) iub_get_request_parameter( 'form_id', 0 );
    4062        $form    = ! empty( $form_id ) ? iubenda()->forms->get_form( $form_id ) : false;
    4163
     
    5072
    5173        $available_fields = array();
    52 
    5374        if ( ! empty( $form->form_fields ) && is_array( $form->form_fields ) ) {
    5475            foreach ( $form->form_fields as $index => $form_field ) {
     
    6081            }
    6182        }
    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;
    168251                    }
    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>
    300343        <hr>
    301344        <div class="p-4 d-flex justify-content-end">
  • iubenda-cookie-law-solution/tags/beta/views/integrate-setup.php

    r2922322 r3031643  
    4545
    4646                <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">
    4758                    <label class="checkbox-regular">
    4859                        <input type="checkbox" class="mr-2 section-checkbox-control" name="iubenda_cookie_law_solution[amp_support]" value="1" checked data-section-name="#amp_support"/>
     
    6576                            <div class="border-1 border-gray rounded mt-2 py-2 px-3 d-flex flex-wrap align-items-center">
    6677                                <?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';
    10280                                ?>
    103                                     </tbody>
    104                                 </table>
    10581                            </div>
    10682                            <div class="notice notice--general mt-2 p-3 d-flex align-items-center text-xs">
     
    134110                <div class="my-5">
    135111                    <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>
    138114                    </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>
    139121                    <section id="iub_parser_engine_container" class="subOptions">
    140122                        <h4><?php esc_html_e( 'Select Parsing Engine', 'iubenda' ); ?></h4>
  • iubenda-cookie-law-solution/tags/beta/views/partials/cs-general-settings.php

    r2922322 r3031643  
    1010    exit;
    1111}
     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' );
    1216?>
    1317<div class="tabs">
     
    1721            <div class="d-flex tabs__nav">
    1822                <?php
    19                 if ( iub_array_get( iubenda()->options['global_options'], 'site_id' ) ) :
     23                if ( $site_id ) :
    2024                    $_status = '';
    21                     if ( 'simplified' === (string) iub_array_get( iubenda()->options['cs'], 'configuration_type' ) ) {
     25                    if ( $is_cs_simplified ) {
    2226                        $_status = 'active';
    2327                    }
     
    7175    <div class="my-4 subOptions">
    7276        <?php
    73         if ( iub_array_get( iubenda()->options['global_options'], 'site_id' ) ) {
     77        if ( $site_id ) {
    7478            $_status = '';
    75             if ( 'simplified' === (string) iub_array_get( iubenda()->options['cs'], 'configuration_type' ) ) {
     79            if ( $is_cs_simplified ) {
    7680                $_status = 'active';
    7781            }
     
    99103    </div>
    100104</div>
     105
     106<?php
     107// Including partial cs-simplified-configuration.
     108require_once IUBENDA_PLUGIN_PATH . '/views/partials/auto-block-section.php';
     109?>
    101110
    102111<div class="d-flex align-items-center pt-3">
     
    133142        <div class="border-1 border-gray rounded mt-2 py-2 px-3 d-flex flex-wrap align-items-center">
    134143            <?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';
    171146            ?>
    172                 </tbody>
    173             </table>
    174147        </div>
    175148
     
    200173        </table>
    201174    </section>
     175
    202176</section>
    203177
    204178<div class="d-flex align-items-center pt-3">
    205179    <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>
    208182    </label>
    209183</div>
     
    348322    </fieldset>
    349323</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>
    350330<div class="d-flex align-items-center pt-3">
    351331    <label class="checkbox-regular">
  • iubenda-cookie-law-solution/tags/beta/views/partials/cs-simplified-configuration.php

    r2922322 r3031643  
    2727$legislation_all_status  = (bool) iub_array_get( $legislation, 'all' );
    2828?>
    29 <div class="mb-5">
     29<div id="legalisation-section" class="mb-5">
    3030    <h4><?php esc_html_e( 'Legislation', 'iubenda' ); ?></h4>
    3131    <div class="scrollable gap-fixer">
     
    5050    </div>
    5151</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">
    5353    <h4><?php esc_html_e( 'Require consent from', 'iubenda' ); ?></h4>
    5454    <div class="scrollable gap-fixer">
    5555        <fieldset class="d-flex radio-large">
    5656            <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>
    5858                <label for="require-consent-worldwide">
    5959                    <div class="d-flex align-items-center">
     
    6666                        </svg>
    6767                        <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>
    10668                    </div>
    10769                </label>
  • iubenda-cookie-law-solution/tags/beta/views/partials/languages-tabs.php

    r2848150 r3031643  
    1010    exit;
    1111}
     12
     13// Check if $key is defined before using it.
     14if ( ! isset( $key ) ) {
     15    return;
     16}
     17
     18// Check if $service is defined before using it.
     19if ( empty( $service ) ) {
     20    return;
     21}
     22
    1223?>
    1324<div class="mb-3 p-0">
     
    2334                }
    2435                ?>
    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">
    2637                    <?php echo esc_html( strtoupper( $k ) ); ?>
    2738                </li>
     
    3647            $code   = $product_helper->{$method}( $lang_id );
    3748            ?>
    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>
    4058            </div>
    4159        <?php endforeach; ?>
  • iubenda-cookie-law-solution/tags/beta/views/partials/modals/modal-almost-there.php

    r2922322 r3031643  
    122122                    if ( 'cs' === (string) $key ) :
    123123                        ?>
    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">
    125125                        <input type="hidden" name="iubenda_cookie_law_solution[parser_engine]" value="<?php echo can_use_dom_document_class() ? esc_attr( 'new' ) : 'default'; ?>">
    126126                    <?php endif; ?>
  • iubenda-cookie-law-solution/tags/beta/views/partials/product-card.php

    r2848150 r3031643  
    99if ( ! defined( 'ABSPATH' ) ) {
    1010    exit;
     11}
     12
     13// Check if $service_key is defined before using it.
     14if ( ! isset( $service_key ) ) {
     15    return;
     16}
     17
     18// Check if $service_options is defined before using it.
     19if ( empty( $service_options ) ) {
     20    return;
    1121}
    1222?>
  • iubenda-cookie-law-solution/tags/beta/views/products-page.php

    r2848150 r3031643  
    2121        <?php
    2222            $result = array_filter(
    23                 array_column( $this->services, 'status' ),
     23                array_column( iubenda()->settings->services, 'status' ),
    2424                function ( $service ) {
    2525                    return ( stripos( $service, 'false' ) === false );
Note: See TracChangeset for help on using the changeset viewer.