Plugin Directory

Changeset 3284346


Ignore:
Timestamp:
04/29/2025 06:49:28 PM (11 months ago)
Author:
termageddon
Message:

Update to version 1.7.1 from GitHub

Location:
termageddon-usercentrics
Files:
28 deleted
17 edited
1 copied

Legend:

Unmodified
Added
Removed
  • termageddon-usercentrics/assets/icon-256x256.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • termageddon-usercentrics/tags/1.7.1/README.txt

    r3266555 r3284346  
    1 === Termageddon + Usercentrics ===
     1=== Termageddon ===
    22Contributors: termageddon, dintriglia
    33Tags: termageddon, cookie, consent, embed, privacy, gdpr, ccpa, usercentrics
    44Requires at least: 5.0
    5 Tested up to: 6.7.2
    6 Stable tag: 1.7.0
     5Tested up to: 6.8
     6Stable tag: 1.7.1
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3333
    3434== Changelog ==
     35
     36= 1.7.1 =
     37-   [ADD] Settings toggle for Disable CDN
     38-   [ADD] Added data-no-optimize flag to all scripts for better compatibility with Litespeed caching systems
     39-   [CHANGE] Expand the min/max allowed for Priority
     40-   [CHANGE] Geo-location debug code always loads in the footer
     41-   [FIX] Bugs with wp_enqueue_scripts injection method
     42-   [FIX] Fixed a notice occurring on every page load related to load_plugin_textdomain.
    3543
    3644= 1.7.0 =
  • termageddon-usercentrics/tags/1.7.1/admin/class-termageddon-usercentrics-admin.php

    r3266555 r3284346  
    398398    public static function sanitize_embed_priority( $value ) {
    399399        $priority = self::sanitize_integer( $value );
    400         if ( $priority <= 10 && $priority >= 1 ) {
     400        if ( $priority <= 9999 && $priority >= -9999 ) {
    401401            return intval( $value );
    402402        }
     
    601601            array(
    602602                'label_for'   => 'termageddon_usercentrics_embed_priority',
    603                 'description' => __( 'Override the default priority of the embed code (Defaults to 1). By adjusting this value (number between 1 and 10), you can change the priority of the embed code. The higher the number, the sooner the embed code will be rendered in the source code.', 'termageddon-usercentrics' ),
     603                'description' => __( 'Override the default priority of the embed code (Defaults to 1). By adjusting this value, you can change the priority of the embed code. The lower the number, the sooner the embed code will be rendered in the source code. Note that selecting the wp_enqueue_scripts injection method will limit where the code can be placed (after stylesheets), regardless of this number.', 'termageddon-usercentrics' ),
    604604            )
    605605        );
     
    669669                'default'           => 'v2',
    670670            )
     671        );
     672
     673        // Disable CDN for Translations Script
     674        add_settings_field(
     675            'termageddon_usercentrics_disable_cdn',
     676            __( 'Disable CDN for Translations Script', 'termageddon-usercentrics' ),
     677            array( &$this, 'disable_cdn_html' ), // function which prints the field.
     678            'termageddon-usercentrics', // page slug.
     679            'termageddon_usercentrics_section_settings', // section ID.
     680            array(
     681                'label_for'   => 'termageddon_usercentrics_disable_cdn',
     682                'description' => __( 'This will switch the URL used for the Usercentrics translations script from our CDN provider to <code>app.termageddon.com</code>. If you are not sure what to do, please leave this off.', 'termageddon-usercentrics' ),
     683            )
     684        );
     685
     686        register_setting(
     687            'termageddon_usercentrics_settings', // settings group name.
     688            'termageddon_usercentrics_disable_cdn', // option name.
     689            '' // sanitization function.
    671690        );
    672691
     
    12291248    public function embed_priority_html( array $args ) {
    12301249        $args['default'] = 1;
    1231         $args['min']     = 1;
    1232         $args['max']     = 10;
     1250        $args['min']     = -9999;
     1251        $args['max']     = 9999;
    12331252        $args['type']    = 'number';
    12341253
     
    12441263    public function embed_implementation_html( array $args ) {
    12451264        self::generate_select( 'embed_injection_method', $args );
     1265    }
     1266
     1267    /**
     1268     * The HTML field for the disable CDN checkbox.
     1269     *
     1270     * @param array $args The arguments provided by the add_settings_field() method.
     1271     * @return void
     1272     */
     1273    public function disable_cdn_html( array $args ) {
     1274        self::generate_checkbox( 'cdn', 'disable', $args );
    12461275    }
    12471276
  • termageddon-usercentrics/tags/1.7.1/admin/js/termageddon-usercentrics-admin.js

    r3238690 r3284346  
    142142                )
    143143                .replace(
    144                     "<script>uc.setCustomTranslations('https://termageddon.ams3.cdn.digitaloceanspaces.com/translations/');</script>",
     144                    /<script>uc.setCustomTranslations.*<\/script>/g,
    145145                    ""
    146146                )
  • termageddon-usercentrics/tags/1.7.1/admin/js/termageddon-usercentrics-admin.min.js

    r3238690 r3284346  
    1 jQuery((function($){let animationSpeed=0,initialLoad=!1,loggedIn=$(".tu-tab-settings .tu-toggle-section input#termageddon_usercentrics_disable_logged_in"),editor=$(".tu-tab-settings .tu-toggle-section input#termageddon_usercentrics_disable_editor"),admin=$(".tu-tab-settings .tu-toggle-section input#termageddon_usercentrics_disable_admin");const check=(elem,checked=!0)=>{console.log(elem,checked),elem.prop("checked",checked).attr("readonly",checked).trigger("change")};1===loggedIn.length&&loggedIn.off("change.tu").on("change.tu",(function(){($(this).is(":checked")||initialLoad)&&(check(editor,$(this).is(":checked")),check(admin,$(this).is(":checked")))})).trigger("change");let geolocationToggle=$("input#termageddon_usercentrics_toggle_geolocation"),policyToggles=$(".tu-tab-geolocation .tu-toggle-section input");1===geolocationToggle.length&&(geolocationToggle.off("change.tu").on("change.tu",(function(){$(this).is(":checked")?$(".tu-tab-geolocation .tu-section-settings > div").slideDown(animationSpeed):$(".tu-tab-geolocation .tu-section-settings > div").slideUp(animationSpeed)})).trigger("change"),policyToggles.off("change.tu").on("change.tu",(function(){policyToggles.is(":checked")?jQuery("#no-geolocation-locations-selected,#no-geolocation-locations-selected-top").slideUp(animationSpeed):jQuery("#no-geolocation-locations-selected").slideDown(animationSpeed)})).trigger("change")),animationSpeed=300,initialLoad=!0;let migrationButton=$("#run_settings_migration");1===migrationButton.length&&migrationButton.off("click.tu").on("click.tu",(function(){const embedCode=document.querySelector("#termageddon_usercentrics_embed_code").value,settingsIdMatch=embedCode.match(/data-settings-id="([^"]+)"/);if(!settingsIdMatch||!settingsIdMatch[1])return void alert("Unable to find settings ID in embed code. Please ensure your embed code section contains a data-settings-id attribute. Please contact our support team if would like assistance.");const settingsId=settingsIdMatch[1];document.querySelector("#termageddon_usercentrics_settings_id").value=settingsId,document.querySelector("#termageddon_usercentrics_embed_code").value=embedCode.replace('<link rel="preconnect" href="https://plugins.trac.wordpress.org//privacy-proxy.usercentrics.eu">',"").replace('<link rel="preload" href="https://plugins.trac.wordpress.org//privacy-proxy.usercentrics.eu/latest/uc-block.bundle.js" as="script">',"").replace('<script type="application/javascript" src="https://privacy-proxy.usercentrics.eu/latest/uc-block.bundle.js"><\/script>',"").replace(/<script.*id="usercentrics-cmp".*async>.*<\/script>/g,"").replace("<script>uc.setCustomTranslations('https://termageddon.ams3.cdn.digitaloceanspaces.com/translations/');<\/script>","").trim();const migrationMessage=$(".migration-message");migrationMessage.removeClass("tu-alert-error").addClass("tu-alert-success"),migrationMessage.find("strong").text("Conversion Complete"),migrationMessage.find("p.alert-description").html("The embed code has been converted to a settings ID. All custom scripts outside of the original embed code have been maintained.<br/></br>\n\t\t\t\t\t<strong><em>The changes have been submitted.</em></strong>"),$(".tab-content form input.button").click()}))}));
     1jQuery((function($){let animationSpeed=0,initialLoad=!1,loggedIn=$(".tu-tab-settings .tu-toggle-section input#termageddon_usercentrics_disable_logged_in"),editor=$(".tu-tab-settings .tu-toggle-section input#termageddon_usercentrics_disable_editor"),admin=$(".tu-tab-settings .tu-toggle-section input#termageddon_usercentrics_disable_admin");const check=(elem,checked=!0)=>{console.log(elem,checked),elem.prop("checked",checked).attr("readonly",checked).trigger("change")};1===loggedIn.length&&loggedIn.off("change.tu").on("change.tu",(function(){($(this).is(":checked")||initialLoad)&&(check(editor,$(this).is(":checked")),check(admin,$(this).is(":checked")))})).trigger("change");let geolocationToggle=$("input#termageddon_usercentrics_toggle_geolocation"),policyToggles=$(".tu-tab-geolocation .tu-toggle-section input");1===geolocationToggle.length&&(geolocationToggle.off("change.tu").on("change.tu",(function(){$(this).is(":checked")?$(".tu-tab-geolocation .tu-section-settings > div").slideDown(animationSpeed):$(".tu-tab-geolocation .tu-section-settings > div").slideUp(animationSpeed)})).trigger("change"),policyToggles.off("change.tu").on("change.tu",(function(){policyToggles.is(":checked")?jQuery("#no-geolocation-locations-selected,#no-geolocation-locations-selected-top").slideUp(animationSpeed):jQuery("#no-geolocation-locations-selected").slideDown(animationSpeed)})).trigger("change")),animationSpeed=300,initialLoad=!0;let migrationButton=$("#run_settings_migration");1===migrationButton.length&&migrationButton.off("click.tu").on("click.tu",(function(){const embedCode=document.querySelector("#termageddon_usercentrics_embed_code").value,settingsIdMatch=embedCode.match(/data-settings-id="([^"]+)"/);if(!settingsIdMatch||!settingsIdMatch[1])return void alert("Unable to find settings ID in embed code. Please ensure your embed code section contains a data-settings-id attribute. Please contact our support team if would like assistance.");const settingsId=settingsIdMatch[1];document.querySelector("#termageddon_usercentrics_settings_id").value=settingsId,document.querySelector("#termageddon_usercentrics_embed_code").value=embedCode.replace('<link rel="preconnect" href="https://plugins.trac.wordpress.org//privacy-proxy.usercentrics.eu">',"").replace('<link rel="preload" href="https://plugins.trac.wordpress.org//privacy-proxy.usercentrics.eu/latest/uc-block.bundle.js" as="script">',"").replace('<script type="application/javascript" src="https://privacy-proxy.usercentrics.eu/latest/uc-block.bundle.js"><\/script>',"").replace(/<script.*id="usercentrics-cmp".*async>.*<\/script>/g,"").replace(/<script>uc.setCustomTranslations.*<\/script>/g,"").trim();const migrationMessage=$(".migration-message");migrationMessage.removeClass("tu-alert-error").addClass("tu-alert-success"),migrationMessage.find("strong").text("Conversion Complete"),migrationMessage.find("p.alert-description").html("The embed code has been converted to a settings ID. All custom scripts outside of the original embed code have been maintained.<br/></br>\n\t\t\t\t\t<strong><em>The changes have been submitted.</em></strong>"),$(".tab-content form input.button").click()}))}));
  • termageddon-usercentrics/tags/1.7.1/includes/class-termageddon-usercentrics-i18n.php

    r2756619 r3284346  
    3232     * @since    1.0.0
    3333     */
    34     public function load_plugin_textdomain() {
    35 
     34    public static function load_plugin_textdomain() {
    3635        load_plugin_textdomain(
    3736            'termageddon-usercentrics',
  • termageddon-usercentrics/tags/1.7.1/includes/class-termageddon-usercentrics.php

    r3266555 r3284346  
    7575
    7676        $this->load_dependencies();
    77         $this->set_locale();
     77        $this->setup_translations();
    7878        $this->define_admin_hooks();
    7979        $this->define_public_hooks();
     
    250250     * @access   private
    251251     */
    252     private function set_locale() {
    253 
    254         $plugin_i18n = new Termageddon_Usercentrics_I18n();
    255 
    256         $this->loader->add_action( 'init', $plugin_i18n, 'load_plugin_textdomain' );
     252    public static function setup_translations() {
     253
     254        Termageddon_Usercentrics_I18n::load_plugin_textdomain();
    257255
    258256    }
     
    361359            'build_termageddon_script',
    362360            self::get_embed_priority()
     361        );
     362
     363        // Put debug code in the footer
     364        $this->loader->add_action(
     365            'wp_footer',
     366            $plugin_public,
     367            'debug_display',
     368            999
    363369        );
    364370
     
    599605            $embed_code = preg_replace( '~<script type="application/javascript" src="https:\/\/privacy-proxy.usercentrics.eu\/latest\/uc-block.bundle.js"><\/script>~', '', $embed_code );
    600606            $embed_code = preg_replace( '~<script id="usercentrics-cmp".*async>.*<\/script>~', '', $embed_code );
    601             $embed_code = preg_replace( '~<script>uc.setCustomTranslations\(\'https://termageddon.ams3.cdn.digitaloceanspaces.com/translations/\'\);</script>~', '', $embed_code );
     607            $embed_code = preg_replace( '~<script>uc.setCustomTranslations\(.*\);</script>~', '', $embed_code );
    602608        }
    603609
     
    615621        }
    616622
    617         $embed_version = self::get_embed_script_version();
    618         $loader_url    = ( 'v2' === $embed_version ) ? '//app.usercentrics.eu/browser-ui/latest/loader.js' : '//web.cmp.usercentrics.eu/ui/loader.js';
     623        $embed_version   = self::get_embed_script_version();
     624        $loader_url      = ( 'v2' === $embed_version ) ? '//app.usercentrics.eu/browser-ui/latest/loader.js' : '//web.cmp.usercentrics.eu/ui/loader.js';
     625        $translations_url = self::get_translations_url();
    619626
    620627        $new_embed_code  = '<link rel="preconnect" href="https://plugins.trac.wordpress.org//privacy-proxy.usercentrics.eu">' . PHP_EOL;
    621628        $new_embed_code .= '<link rel="preload" href="https://plugins.trac.wordpress.org//privacy-proxy.usercentrics.eu/latest/uc-block.bundle.js" as="script">' . PHP_EOL;
    622         $new_embed_code .= '<script type="application/javascript" src="https://plugins.trac.wordpress.org//privacy-proxy.usercentrics.eu/latest/uc-block.bundle.js"></script>' . PHP_EOL;
    623         $new_embed_code .= '<script id="usercentrics-cmp" data-cmp-version="' . esc_attr( self::get_embed_script_version() ) . '" src="' . esc_url( $loader_url ) . '" data-settings-id="' . self::get_settings_id() . '" async></script>' . PHP_EOL;
    624         $new_embed_code .= '<script>uc.setCustomTranslations(\'https://termageddon.ams3.cdn.digitaloceanspaces.com/translations/\');</script>' . PHP_EOL;
     629        $new_embed_code .= '<script type="application/javascript" src="https://plugins.trac.wordpress.org//privacy-proxy.usercentrics.eu/latest/uc-block.bundle.js" data-no-optimize="1" data-no-defer="1"></script>' . PHP_EOL;
     630        $new_embed_code .= '<script id="usercentrics-cmp" data-cmp-version="' . esc_attr( self::get_embed_script_version() ) . '" src="' . esc_url( $loader_url ) . '" data-settings-id="' . self::get_settings_id() . '" data-no-optimize="1" data-no-defer="1" async></script>' . PHP_EOL;
     631        $new_embed_code .= '<script data-no-optimize="1" data-no-defer="1">uc.setCustomTranslations(\'' . $translations_url . '\');</script>' . PHP_EOL;
    625632        $new_embed_code .= self::filter_out_standard_embed_code( $embed_code );
    626633
     
    969976    }
    970977
     978    /**
     979     * Returns whether Disable CDN for Translations Script is set to Yes in the query params
     980     *
     981     * @return bool
     982     */
     983    public static function is_cdn_disabled() {
     984        return ( get_option( 'termageddon_usercentrics_disable_cdn', false ) ? true : false );
     985
     986    }
     987
     988    /**
     989     * Returns the translations URL for the Usercentrics script.
     990     *
     991     * @return string
     992     */
     993    public static function get_translations_url() {
     994        $translations_url = 'https://termageddon.ams3.cdn.digitaloceanspaces.com/translations/';
     995        if ( self::is_cdn_disabled() ) {
     996            $translations_url = 'https://app.termageddon.com/js/uc/translations/';
     997        }
     998        return $translations_url;
     999    }
     1000
    9711001
    9721002    /**
     
    11691199        $priority = get_option( 'termageddon_usercentrics_embed_priority', 1 );
    11701200        $priority = intval( $priority );
    1171         if ( $priority <= 10 && $priority >= 1 ) {
     1201        if ( $priority <= 9999 && $priority >= -9999 ) {
    11721202            return $priority;
    11731203        }
  • termageddon-usercentrics/tags/1.7.1/public/class-termageddon-usercentrics-public.php

    r3266555 r3284346  
    163163     */
    164164    public function debug_display() {
    165         if ( ( Termageddon_Usercentrics::is_geoip_enabled() || Termageddon_Usercentrics::is_debug_mode_enabled() )
    166             &&
     165        if (
     166            Termageddon_Usercentrics::is_geoip_enabled() &&
     167            Termageddon_Usercentrics::is_debug_mode_enabled() &&
    167168            ! Termageddon_Usercentrics::is_ajax_mode_enabled()
    168             ) {
    169                 list('city' => $city, 'state' => $state, 'country' => $country) = Termageddon_Usercentrics::lookup_ip_address();
    170 
    171                 // Iterate through locations.
    172                 $locations = array();
     169        ) {
     170            list('city' => $city, 'state' => $state, 'country' => $country) = Termageddon_Usercentrics::lookup_ip_address();
     171
     172            // Iterate through locations.
     173            $locations = array();
    173174            foreach ( Termageddon_Usercentrics::get_geolocation_locations() as $loc_key => $loc ) {
    174175                list ( 'title' => $loc_name ) = $loc;
     
    176177            }
    177178
    178                 // Output debug message to console.
    179                 Termageddon_Usercentrics::debug(
    180                     'IP Address: ' . Termageddon_Usercentrics::get_processed_ip_address(),
    181                     'City: ' . ( $city ?? 'Unknown' ),
    182                     'State: ' . ( $state ?? 'Unknown' ),
    183                     'Country: ' . ( $country ?? 'Unknown' ),
    184                     '--',
    185                     $locations,
    186                     '--',
    187                     'Geo-Location Mode?: ' . ( Termageddon_Usercentrics::is_geoip_enabled() ? 'Yes' : 'No' ),
    188                     'AJAX Mode?: ' . ( Termageddon_Usercentrics::is_ajax_mode_enabled() ? 'Yes' : 'No' ),
    189                 );
     179            // Output debug message to console.
     180            Termageddon_Usercentrics::debug(
     181                'IP Address: ' . Termageddon_Usercentrics::get_processed_ip_address(),
     182                'City: ' . ( $city ?? 'Unknown' ),
     183                'State: ' . ( $state ?? 'Unknown' ),
     184                'Country: ' . ( $country ?? 'Unknown' ),
     185                '--',
     186                $locations,
     187                '--',
     188                'Geo-Location Mode?: ' . ( Termageddon_Usercentrics::is_geoip_enabled() ? 'Yes' : 'No' ),
     189                'AJAX Mode?: ' . ( Termageddon_Usercentrics::is_ajax_mode_enabled() ? 'Yes' : 'No' ),
     190            );
    190191        }
    191192    }
     
    218219     * Dynamically hide or show the termageddon script based on settings. Outputs directly to script tag.
    219220     */
    220     public function build_termageddon_script() {
     221    public function build_termageddon_script( $is_enqueue = false ) {
    221222
    222223        // If forcibly enabled, bypass individual detections.
     
    227228            }
    228229
    229             // Debug display to console if applicable.
    230             self::debug_display();
    231 
    232230            // Check for individual disable detections.
    233231            $disable_on_logged_in = get_option( 'termageddon_usercentrics_disable_logged_in', false ) ? true : false;
     
    249247                return;
    250248            }
    251         } else {
    252             // Debug display to console if applicable.
    253             self::debug_display();
    254         }
    255 
    256         $should_append_settings_id_embed_code = ! empty( Termageddon_Usercentrics::get_settings_id() ) && Termageddon_Usercentrics::get_embed_injection_method() === 'wp_head' ? true : false;
     249
     250            // don't double output in enqueue mode
     251            $should_enqueue_scripts = Termageddon_Usercentrics::get_embed_injection_method() === 'wp_enqueue_scripts';
     252            if ( $should_enqueue_scripts && ! $is_enqueue ) {
     253                return;
     254            }
     255        }
     256
     257        $should_append_settings_id_embed_code = ! empty( Termageddon_Usercentrics::get_settings_id() ) ? true : false;
    257258
    258259        $script = Termageddon_Usercentrics::get_embed_code(
     
    267268
    268269        // Output to HTML HEAD.
    269         echo '<!-- TERMAGEDDON + USERCENTRICS -->';
    270         echo wp_kses( $script, Termageddon_Usercentrics::ALLOWED_HTML );
    271         echo '<!-- END TERMAGEDDON + USERCENTRICS -->';
     270        $output  = '<!-- TERMAGEDDON + USERCENTRICS -->' . PHP_EOL;
     271        $output .= wp_kses( $script, Termageddon_Usercentrics::ALLOWED_HTML );
     272        $output .= '<!-- END TERMAGEDDON + USERCENTRICS -->' . PHP_EOL;
     273
     274        if ( $is_enqueue ) {
     275            return $output;
     276        } else {
     277           
     278            echo $output;
     279        }
    272280
    273281    }
     
    276284     */
    277285    public function build_termageddon_enqueue() {
    278         // If forcibly enabled, bypass individual detections.
    279         if ( ! Termageddon_Usercentrics::is_enabled_via_get_override() ) {
    280             // Check for Disable for troubleshooting.
    281             if ( Termageddon_Usercentrics::is_disabled_for_troubleshooting() ) {
    282                 return self::disable_termageddon_enqueue();
    283             }
    284 
    285             // Check for individual disable detections.
    286             $disable_on_logged_in = get_option( 'termageddon_usercentrics_disable_logged_in', false ) ? true : false;
    287             if ( $disable_on_logged_in && is_user_logged_in() ) {
    288                 return self::disable_termageddon_enqueue();
    289             }
    290 
    291             $disable_on_editor = get_option( 'termageddon_usercentrics_disable_editor', false ) ? true : false;
    292             if ( $disable_on_editor && current_user_can( 'editor' ) ) {
    293                 return self::disable_termageddon_enqueue();
    294             }
    295 
    296             $disable_on_admin = get_option( 'termageddon_usercentrics_disable_admin', false ) ? true : false;
    297             if ( $disable_on_admin && current_user_can( 'administrator' ) ) {
    298                 return self::disable_termageddon_enqueue();
    299             }
    300 
    301             if ( Termageddon_Usercentrics::is_geoip_enabled() && ! Termageddon_Usercentrics::is_ajax_mode_enabled() && Termageddon_Usercentrics::should_hide_due_to_location() ) {
    302                 return self::disable_termageddon_enqueue();
    303             }
    304         }
    305 
     286       
    306287        $settings_id            = Termageddon_Usercentrics::get_settings_id();
    307         $embed_version          = Termageddon_Usercentrics::get_embed_script_version();
    308288        $should_enqueue_scripts = Termageddon_Usercentrics::get_embed_injection_method() === 'wp_enqueue_scripts';
    309289
    310290        if ( $settings_id && $should_enqueue_scripts ) {
    311291            // Enqueue Embed Script.
    312             wp_enqueue_script( $this->plugin_name . '-preconnect', '//privacy-proxy.usercentrics.eu', array(), $this->version, false );
    313             wp_enqueue_script( $this->plugin_name . '-sdp', '//privacy-proxy.usercentrics.eu/latest/uc-block.bundle.js', array(), $this->version, false );
    314             if ( 'v2' === $embed_version ) {
    315                 wp_enqueue_script( $this->plugin_name . '-cmp', '//app.usercentrics.eu/browser-ui/latest/loader.js', array(), $this->version, false );
    316             } else {
    317                 wp_enqueue_script( $this->plugin_name . '-cmp', '//web.cmp.usercentrics.eu/ui/loader.js', array(), $this->version, false );
    318             }
    319             wp_enqueue_script( $this->plugin_name . '-translations', TERMAGEDDON_COOKIE_URL . 'public/js/termageddon-usercentrics-translations.min.js', array(), $this->version, false );
     292            wp_enqueue_script( $this->plugin_name . '-scripts', '//privacy-proxy.usercentrics.eu/latest/uc-block.bundle.js', array(), $this->version, false );
     293            // note: this URL is placed here to "play by the rules"... but it doesn't actually do anything.
     294            // the whole thing will be overwritten by the script_loader_tag filter.
    320295        }
    321296
     
    342317     */
    343318    public function filter_script_loader_tag( $tag, $handle, $src ) {
    344         switch ( $handle ) {
    345             case $this->plugin_name . '-preconnect':
    346                 $tag = '<link rel="preconnect" href="' . esc_url( $src ) . '">';
    347                 break;
    348             case $this->plugin_name . '-preload':
    349                 $tag = '<link rel="preload" href="' . esc_url( $src ) . '" as="script">';
    350                 break;
    351             case $this->plugin_name . '-cmp':
    352                 $tag = '<script type="text/javascript" id="usercentrics-cmp" data-cmp-version="' . esc_attr( Termageddon_Usercentrics::get_embed_script_version() ) . '" src="' . esc_url( $src ) . '" data-settings-id="' . esc_attr( Termageddon_Usercentrics::get_settings_id() ) . '" async></script>';
    353                 break;
    354             case $this->plugin_name . '-translations':
    355                 $tag = '<script type="text/javascript" id="usercentrics-translations" src="' . esc_url( $src ) . '"></script>';
    356                 break;
    357         }
    358 
     319        if ( $this->plugin_name . '-scripts' === $handle ) {
     320            $tag = self::build_termageddon_script( true );
     321        }
    359322        return $tag;
    360323    }
  • termageddon-usercentrics/tags/1.7.1/termageddon-usercentrics.php

    r3266555 r3284346  
    1515 * Plugin Name:       Termageddon
    1616 * Description:       Each Termageddon license includes a consent solution. This plugin helps you install the consent solution with ease, while offering additional features.
    17  * Version:           1.7.0
     17 * Version:           1.7.1
    1818 * Author:            Termageddon
    1919 * Author URI:        https://termageddon.com
     
    3434 * Rename this for your plugin and update it as you release new versions.
    3535 */
    36 define( 'TERMAGEDDON_COOKIE_VERSION', '1.7.0' );
     36define( 'TERMAGEDDON_COOKIE_VERSION', '1.7.1' );
    3737
    3838define( 'TERMAGEDDON_COOKIE_PLUGIN_PATH', dirname( __FILE__ ) );// No trailing slash.
     
    9494    $plugin = new Termageddon_Usercentrics();
    9595    $plugin->run();
     96}
    9697
    97 }
    98 run_termageddon_cookie();
     98// Hook the plugin initialization to plugins_loaded
     99add_action('init', 'run_termageddon_cookie');
  • termageddon-usercentrics/trunk/README.txt

    r3266555 r3284346  
    1 === Termageddon + Usercentrics ===
     1=== Termageddon ===
    22Contributors: termageddon, dintriglia
    33Tags: termageddon, cookie, consent, embed, privacy, gdpr, ccpa, usercentrics
    44Requires at least: 5.0
    5 Tested up to: 6.7.2
    6 Stable tag: 1.7.0
     5Tested up to: 6.8
     6Stable tag: 1.7.1
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3333
    3434== Changelog ==
     35
     36= 1.7.1 =
     37-   [ADD] Settings toggle for Disable CDN
     38-   [ADD] Added data-no-optimize flag to all scripts for better compatibility with Litespeed caching systems
     39-   [CHANGE] Expand the min/max allowed for Priority
     40-   [CHANGE] Geo-location debug code always loads in the footer
     41-   [FIX] Bugs with wp_enqueue_scripts injection method
     42-   [FIX] Fixed a notice occurring on every page load related to load_plugin_textdomain.
    3543
    3644= 1.7.0 =
  • termageddon-usercentrics/trunk/admin/class-termageddon-usercentrics-admin.php

    r3266555 r3284346  
    398398    public static function sanitize_embed_priority( $value ) {
    399399        $priority = self::sanitize_integer( $value );
    400         if ( $priority <= 10 && $priority >= 1 ) {
     400        if ( $priority <= 9999 && $priority >= -9999 ) {
    401401            return intval( $value );
    402402        }
     
    601601            array(
    602602                'label_for'   => 'termageddon_usercentrics_embed_priority',
    603                 'description' => __( 'Override the default priority of the embed code (Defaults to 1). By adjusting this value (number between 1 and 10), you can change the priority of the embed code. The higher the number, the sooner the embed code will be rendered in the source code.', 'termageddon-usercentrics' ),
     603                'description' => __( 'Override the default priority of the embed code (Defaults to 1). By adjusting this value, you can change the priority of the embed code. The lower the number, the sooner the embed code will be rendered in the source code. Note that selecting the wp_enqueue_scripts injection method will limit where the code can be placed (after stylesheets), regardless of this number.', 'termageddon-usercentrics' ),
    604604            )
    605605        );
     
    669669                'default'           => 'v2',
    670670            )
     671        );
     672
     673        // Disable CDN for Translations Script
     674        add_settings_field(
     675            'termageddon_usercentrics_disable_cdn',
     676            __( 'Disable CDN for Translations Script', 'termageddon-usercentrics' ),
     677            array( &$this, 'disable_cdn_html' ), // function which prints the field.
     678            'termageddon-usercentrics', // page slug.
     679            'termageddon_usercentrics_section_settings', // section ID.
     680            array(
     681                'label_for'   => 'termageddon_usercentrics_disable_cdn',
     682                'description' => __( 'This will switch the URL used for the Usercentrics translations script from our CDN provider to <code>app.termageddon.com</code>. If you are not sure what to do, please leave this off.', 'termageddon-usercentrics' ),
     683            )
     684        );
     685
     686        register_setting(
     687            'termageddon_usercentrics_settings', // settings group name.
     688            'termageddon_usercentrics_disable_cdn', // option name.
     689            '' // sanitization function.
    671690        );
    672691
     
    12291248    public function embed_priority_html( array $args ) {
    12301249        $args['default'] = 1;
    1231         $args['min']     = 1;
    1232         $args['max']     = 10;
     1250        $args['min']     = -9999;
     1251        $args['max']     = 9999;
    12331252        $args['type']    = 'number';
    12341253
     
    12441263    public function embed_implementation_html( array $args ) {
    12451264        self::generate_select( 'embed_injection_method', $args );
     1265    }
     1266
     1267    /**
     1268     * The HTML field for the disable CDN checkbox.
     1269     *
     1270     * @param array $args The arguments provided by the add_settings_field() method.
     1271     * @return void
     1272     */
     1273    public function disable_cdn_html( array $args ) {
     1274        self::generate_checkbox( 'cdn', 'disable', $args );
    12461275    }
    12471276
  • termageddon-usercentrics/trunk/admin/js/termageddon-usercentrics-admin.js

    r3238690 r3284346  
    142142                )
    143143                .replace(
    144                     "<script>uc.setCustomTranslations('https://termageddon.ams3.cdn.digitaloceanspaces.com/translations/');</script>",
     144                    /<script>uc.setCustomTranslations.*<\/script>/g,
    145145                    ""
    146146                )
  • termageddon-usercentrics/trunk/admin/js/termageddon-usercentrics-admin.min.js

    r3238690 r3284346  
    1 jQuery((function($){let animationSpeed=0,initialLoad=!1,loggedIn=$(".tu-tab-settings .tu-toggle-section input#termageddon_usercentrics_disable_logged_in"),editor=$(".tu-tab-settings .tu-toggle-section input#termageddon_usercentrics_disable_editor"),admin=$(".tu-tab-settings .tu-toggle-section input#termageddon_usercentrics_disable_admin");const check=(elem,checked=!0)=>{console.log(elem,checked),elem.prop("checked",checked).attr("readonly",checked).trigger("change")};1===loggedIn.length&&loggedIn.off("change.tu").on("change.tu",(function(){($(this).is(":checked")||initialLoad)&&(check(editor,$(this).is(":checked")),check(admin,$(this).is(":checked")))})).trigger("change");let geolocationToggle=$("input#termageddon_usercentrics_toggle_geolocation"),policyToggles=$(".tu-tab-geolocation .tu-toggle-section input");1===geolocationToggle.length&&(geolocationToggle.off("change.tu").on("change.tu",(function(){$(this).is(":checked")?$(".tu-tab-geolocation .tu-section-settings > div").slideDown(animationSpeed):$(".tu-tab-geolocation .tu-section-settings > div").slideUp(animationSpeed)})).trigger("change"),policyToggles.off("change.tu").on("change.tu",(function(){policyToggles.is(":checked")?jQuery("#no-geolocation-locations-selected,#no-geolocation-locations-selected-top").slideUp(animationSpeed):jQuery("#no-geolocation-locations-selected").slideDown(animationSpeed)})).trigger("change")),animationSpeed=300,initialLoad=!0;let migrationButton=$("#run_settings_migration");1===migrationButton.length&&migrationButton.off("click.tu").on("click.tu",(function(){const embedCode=document.querySelector("#termageddon_usercentrics_embed_code").value,settingsIdMatch=embedCode.match(/data-settings-id="([^"]+)"/);if(!settingsIdMatch||!settingsIdMatch[1])return void alert("Unable to find settings ID in embed code. Please ensure your embed code section contains a data-settings-id attribute. Please contact our support team if would like assistance.");const settingsId=settingsIdMatch[1];document.querySelector("#termageddon_usercentrics_settings_id").value=settingsId,document.querySelector("#termageddon_usercentrics_embed_code").value=embedCode.replace('<link rel="preconnect" href="https://plugins.trac.wordpress.org//privacy-proxy.usercentrics.eu">',"").replace('<link rel="preload" href="https://plugins.trac.wordpress.org//privacy-proxy.usercentrics.eu/latest/uc-block.bundle.js" as="script">',"").replace('<script type="application/javascript" src="https://privacy-proxy.usercentrics.eu/latest/uc-block.bundle.js"><\/script>',"").replace(/<script.*id="usercentrics-cmp".*async>.*<\/script>/g,"").replace("<script>uc.setCustomTranslations('https://termageddon.ams3.cdn.digitaloceanspaces.com/translations/');<\/script>","").trim();const migrationMessage=$(".migration-message");migrationMessage.removeClass("tu-alert-error").addClass("tu-alert-success"),migrationMessage.find("strong").text("Conversion Complete"),migrationMessage.find("p.alert-description").html("The embed code has been converted to a settings ID. All custom scripts outside of the original embed code have been maintained.<br/></br>\n\t\t\t\t\t<strong><em>The changes have been submitted.</em></strong>"),$(".tab-content form input.button").click()}))}));
     1jQuery((function($){let animationSpeed=0,initialLoad=!1,loggedIn=$(".tu-tab-settings .tu-toggle-section input#termageddon_usercentrics_disable_logged_in"),editor=$(".tu-tab-settings .tu-toggle-section input#termageddon_usercentrics_disable_editor"),admin=$(".tu-tab-settings .tu-toggle-section input#termageddon_usercentrics_disable_admin");const check=(elem,checked=!0)=>{console.log(elem,checked),elem.prop("checked",checked).attr("readonly",checked).trigger("change")};1===loggedIn.length&&loggedIn.off("change.tu").on("change.tu",(function(){($(this).is(":checked")||initialLoad)&&(check(editor,$(this).is(":checked")),check(admin,$(this).is(":checked")))})).trigger("change");let geolocationToggle=$("input#termageddon_usercentrics_toggle_geolocation"),policyToggles=$(".tu-tab-geolocation .tu-toggle-section input");1===geolocationToggle.length&&(geolocationToggle.off("change.tu").on("change.tu",(function(){$(this).is(":checked")?$(".tu-tab-geolocation .tu-section-settings > div").slideDown(animationSpeed):$(".tu-tab-geolocation .tu-section-settings > div").slideUp(animationSpeed)})).trigger("change"),policyToggles.off("change.tu").on("change.tu",(function(){policyToggles.is(":checked")?jQuery("#no-geolocation-locations-selected,#no-geolocation-locations-selected-top").slideUp(animationSpeed):jQuery("#no-geolocation-locations-selected").slideDown(animationSpeed)})).trigger("change")),animationSpeed=300,initialLoad=!0;let migrationButton=$("#run_settings_migration");1===migrationButton.length&&migrationButton.off("click.tu").on("click.tu",(function(){const embedCode=document.querySelector("#termageddon_usercentrics_embed_code").value,settingsIdMatch=embedCode.match(/data-settings-id="([^"]+)"/);if(!settingsIdMatch||!settingsIdMatch[1])return void alert("Unable to find settings ID in embed code. Please ensure your embed code section contains a data-settings-id attribute. Please contact our support team if would like assistance.");const settingsId=settingsIdMatch[1];document.querySelector("#termageddon_usercentrics_settings_id").value=settingsId,document.querySelector("#termageddon_usercentrics_embed_code").value=embedCode.replace('<link rel="preconnect" href="https://plugins.trac.wordpress.org//privacy-proxy.usercentrics.eu">',"").replace('<link rel="preload" href="https://plugins.trac.wordpress.org//privacy-proxy.usercentrics.eu/latest/uc-block.bundle.js" as="script">',"").replace('<script type="application/javascript" src="https://privacy-proxy.usercentrics.eu/latest/uc-block.bundle.js"><\/script>',"").replace(/<script.*id="usercentrics-cmp".*async>.*<\/script>/g,"").replace(/<script>uc.setCustomTranslations.*<\/script>/g,"").trim();const migrationMessage=$(".migration-message");migrationMessage.removeClass("tu-alert-error").addClass("tu-alert-success"),migrationMessage.find("strong").text("Conversion Complete"),migrationMessage.find("p.alert-description").html("The embed code has been converted to a settings ID. All custom scripts outside of the original embed code have been maintained.<br/></br>\n\t\t\t\t\t<strong><em>The changes have been submitted.</em></strong>"),$(".tab-content form input.button").click()}))}));
  • termageddon-usercentrics/trunk/includes/class-termageddon-usercentrics-i18n.php

    r2756619 r3284346  
    3232     * @since    1.0.0
    3333     */
    34     public function load_plugin_textdomain() {
    35 
     34    public static function load_plugin_textdomain() {
    3635        load_plugin_textdomain(
    3736            'termageddon-usercentrics',
  • termageddon-usercentrics/trunk/includes/class-termageddon-usercentrics.php

    r3266555 r3284346  
    7575
    7676        $this->load_dependencies();
    77         $this->set_locale();
     77        $this->setup_translations();
    7878        $this->define_admin_hooks();
    7979        $this->define_public_hooks();
     
    250250     * @access   private
    251251     */
    252     private function set_locale() {
    253 
    254         $plugin_i18n = new Termageddon_Usercentrics_I18n();
    255 
    256         $this->loader->add_action( 'init', $plugin_i18n, 'load_plugin_textdomain' );
     252    public static function setup_translations() {
     253
     254        Termageddon_Usercentrics_I18n::load_plugin_textdomain();
    257255
    258256    }
     
    361359            'build_termageddon_script',
    362360            self::get_embed_priority()
     361        );
     362
     363        // Put debug code in the footer
     364        $this->loader->add_action(
     365            'wp_footer',
     366            $plugin_public,
     367            'debug_display',
     368            999
    363369        );
    364370
     
    599605            $embed_code = preg_replace( '~<script type="application/javascript" src="https:\/\/privacy-proxy.usercentrics.eu\/latest\/uc-block.bundle.js"><\/script>~', '', $embed_code );
    600606            $embed_code = preg_replace( '~<script id="usercentrics-cmp".*async>.*<\/script>~', '', $embed_code );
    601             $embed_code = preg_replace( '~<script>uc.setCustomTranslations\(\'https://termageddon.ams3.cdn.digitaloceanspaces.com/translations/\'\);</script>~', '', $embed_code );
     607            $embed_code = preg_replace( '~<script>uc.setCustomTranslations\(.*\);</script>~', '', $embed_code );
    602608        }
    603609
     
    615621        }
    616622
    617         $embed_version = self::get_embed_script_version();
    618         $loader_url    = ( 'v2' === $embed_version ) ? '//app.usercentrics.eu/browser-ui/latest/loader.js' : '//web.cmp.usercentrics.eu/ui/loader.js';
     623        $embed_version   = self::get_embed_script_version();
     624        $loader_url      = ( 'v2' === $embed_version ) ? '//app.usercentrics.eu/browser-ui/latest/loader.js' : '//web.cmp.usercentrics.eu/ui/loader.js';
     625        $translations_url = self::get_translations_url();
    619626
    620627        $new_embed_code  = '<link rel="preconnect" href="https://plugins.trac.wordpress.org//privacy-proxy.usercentrics.eu">' . PHP_EOL;
    621628        $new_embed_code .= '<link rel="preload" href="https://plugins.trac.wordpress.org//privacy-proxy.usercentrics.eu/latest/uc-block.bundle.js" as="script">' . PHP_EOL;
    622         $new_embed_code .= '<script type="application/javascript" src="https://plugins.trac.wordpress.org//privacy-proxy.usercentrics.eu/latest/uc-block.bundle.js"></script>' . PHP_EOL;
    623         $new_embed_code .= '<script id="usercentrics-cmp" data-cmp-version="' . esc_attr( self::get_embed_script_version() ) . '" src="' . esc_url( $loader_url ) . '" data-settings-id="' . self::get_settings_id() . '" async></script>' . PHP_EOL;
    624         $new_embed_code .= '<script>uc.setCustomTranslations(\'https://termageddon.ams3.cdn.digitaloceanspaces.com/translations/\');</script>' . PHP_EOL;
     629        $new_embed_code .= '<script type="application/javascript" src="https://plugins.trac.wordpress.org//privacy-proxy.usercentrics.eu/latest/uc-block.bundle.js" data-no-optimize="1" data-no-defer="1"></script>' . PHP_EOL;
     630        $new_embed_code .= '<script id="usercentrics-cmp" data-cmp-version="' . esc_attr( self::get_embed_script_version() ) . '" src="' . esc_url( $loader_url ) . '" data-settings-id="' . self::get_settings_id() . '" data-no-optimize="1" data-no-defer="1" async></script>' . PHP_EOL;
     631        $new_embed_code .= '<script data-no-optimize="1" data-no-defer="1">uc.setCustomTranslations(\'' . $translations_url . '\');</script>' . PHP_EOL;
    625632        $new_embed_code .= self::filter_out_standard_embed_code( $embed_code );
    626633
     
    969976    }
    970977
     978    /**
     979     * Returns whether Disable CDN for Translations Script is set to Yes in the query params
     980     *
     981     * @return bool
     982     */
     983    public static function is_cdn_disabled() {
     984        return ( get_option( 'termageddon_usercentrics_disable_cdn', false ) ? true : false );
     985
     986    }
     987
     988    /**
     989     * Returns the translations URL for the Usercentrics script.
     990     *
     991     * @return string
     992     */
     993    public static function get_translations_url() {
     994        $translations_url = 'https://termageddon.ams3.cdn.digitaloceanspaces.com/translations/';
     995        if ( self::is_cdn_disabled() ) {
     996            $translations_url = 'https://app.termageddon.com/js/uc/translations/';
     997        }
     998        return $translations_url;
     999    }
     1000
    9711001
    9721002    /**
     
    11691199        $priority = get_option( 'termageddon_usercentrics_embed_priority', 1 );
    11701200        $priority = intval( $priority );
    1171         if ( $priority <= 10 && $priority >= 1 ) {
     1201        if ( $priority <= 9999 && $priority >= -9999 ) {
    11721202            return $priority;
    11731203        }
  • termageddon-usercentrics/trunk/public/class-termageddon-usercentrics-public.php

    r3266555 r3284346  
    163163     */
    164164    public function debug_display() {
    165         if ( ( Termageddon_Usercentrics::is_geoip_enabled() || Termageddon_Usercentrics::is_debug_mode_enabled() )
    166             &&
     165        if (
     166            Termageddon_Usercentrics::is_geoip_enabled() &&
     167            Termageddon_Usercentrics::is_debug_mode_enabled() &&
    167168            ! Termageddon_Usercentrics::is_ajax_mode_enabled()
    168             ) {
    169                 list('city' => $city, 'state' => $state, 'country' => $country) = Termageddon_Usercentrics::lookup_ip_address();
    170 
    171                 // Iterate through locations.
    172                 $locations = array();
     169        ) {
     170            list('city' => $city, 'state' => $state, 'country' => $country) = Termageddon_Usercentrics::lookup_ip_address();
     171
     172            // Iterate through locations.
     173            $locations = array();
    173174            foreach ( Termageddon_Usercentrics::get_geolocation_locations() as $loc_key => $loc ) {
    174175                list ( 'title' => $loc_name ) = $loc;
     
    176177            }
    177178
    178                 // Output debug message to console.
    179                 Termageddon_Usercentrics::debug(
    180                     'IP Address: ' . Termageddon_Usercentrics::get_processed_ip_address(),
    181                     'City: ' . ( $city ?? 'Unknown' ),
    182                     'State: ' . ( $state ?? 'Unknown' ),
    183                     'Country: ' . ( $country ?? 'Unknown' ),
    184                     '--',
    185                     $locations,
    186                     '--',
    187                     'Geo-Location Mode?: ' . ( Termageddon_Usercentrics::is_geoip_enabled() ? 'Yes' : 'No' ),
    188                     'AJAX Mode?: ' . ( Termageddon_Usercentrics::is_ajax_mode_enabled() ? 'Yes' : 'No' ),
    189                 );
     179            // Output debug message to console.
     180            Termageddon_Usercentrics::debug(
     181                'IP Address: ' . Termageddon_Usercentrics::get_processed_ip_address(),
     182                'City: ' . ( $city ?? 'Unknown' ),
     183                'State: ' . ( $state ?? 'Unknown' ),
     184                'Country: ' . ( $country ?? 'Unknown' ),
     185                '--',
     186                $locations,
     187                '--',
     188                'Geo-Location Mode?: ' . ( Termageddon_Usercentrics::is_geoip_enabled() ? 'Yes' : 'No' ),
     189                'AJAX Mode?: ' . ( Termageddon_Usercentrics::is_ajax_mode_enabled() ? 'Yes' : 'No' ),
     190            );
    190191        }
    191192    }
     
    218219     * Dynamically hide or show the termageddon script based on settings. Outputs directly to script tag.
    219220     */
    220     public function build_termageddon_script() {
     221    public function build_termageddon_script( $is_enqueue = false ) {
    221222
    222223        // If forcibly enabled, bypass individual detections.
     
    227228            }
    228229
    229             // Debug display to console if applicable.
    230             self::debug_display();
    231 
    232230            // Check for individual disable detections.
    233231            $disable_on_logged_in = get_option( 'termageddon_usercentrics_disable_logged_in', false ) ? true : false;
     
    249247                return;
    250248            }
    251         } else {
    252             // Debug display to console if applicable.
    253             self::debug_display();
    254         }
    255 
    256         $should_append_settings_id_embed_code = ! empty( Termageddon_Usercentrics::get_settings_id() ) && Termageddon_Usercentrics::get_embed_injection_method() === 'wp_head' ? true : false;
     249
     250            // don't double output in enqueue mode
     251            $should_enqueue_scripts = Termageddon_Usercentrics::get_embed_injection_method() === 'wp_enqueue_scripts';
     252            if ( $should_enqueue_scripts && ! $is_enqueue ) {
     253                return;
     254            }
     255        }
     256
     257        $should_append_settings_id_embed_code = ! empty( Termageddon_Usercentrics::get_settings_id() ) ? true : false;
    257258
    258259        $script = Termageddon_Usercentrics::get_embed_code(
     
    267268
    268269        // Output to HTML HEAD.
    269         echo '<!-- TERMAGEDDON + USERCENTRICS -->';
    270         echo wp_kses( $script, Termageddon_Usercentrics::ALLOWED_HTML );
    271         echo '<!-- END TERMAGEDDON + USERCENTRICS -->';
     270        $output  = '<!-- TERMAGEDDON + USERCENTRICS -->' . PHP_EOL;
     271        $output .= wp_kses( $script, Termageddon_Usercentrics::ALLOWED_HTML );
     272        $output .= '<!-- END TERMAGEDDON + USERCENTRICS -->' . PHP_EOL;
     273
     274        if ( $is_enqueue ) {
     275            return $output;
     276        } else {
     277           
     278            echo $output;
     279        }
    272280
    273281    }
     
    276284     */
    277285    public function build_termageddon_enqueue() {
    278         // If forcibly enabled, bypass individual detections.
    279         if ( ! Termageddon_Usercentrics::is_enabled_via_get_override() ) {
    280             // Check for Disable for troubleshooting.
    281             if ( Termageddon_Usercentrics::is_disabled_for_troubleshooting() ) {
    282                 return self::disable_termageddon_enqueue();
    283             }
    284 
    285             // Check for individual disable detections.
    286             $disable_on_logged_in = get_option( 'termageddon_usercentrics_disable_logged_in', false ) ? true : false;
    287             if ( $disable_on_logged_in && is_user_logged_in() ) {
    288                 return self::disable_termageddon_enqueue();
    289             }
    290 
    291             $disable_on_editor = get_option( 'termageddon_usercentrics_disable_editor', false ) ? true : false;
    292             if ( $disable_on_editor && current_user_can( 'editor' ) ) {
    293                 return self::disable_termageddon_enqueue();
    294             }
    295 
    296             $disable_on_admin = get_option( 'termageddon_usercentrics_disable_admin', false ) ? true : false;
    297             if ( $disable_on_admin && current_user_can( 'administrator' ) ) {
    298                 return self::disable_termageddon_enqueue();
    299             }
    300 
    301             if ( Termageddon_Usercentrics::is_geoip_enabled() && ! Termageddon_Usercentrics::is_ajax_mode_enabled() && Termageddon_Usercentrics::should_hide_due_to_location() ) {
    302                 return self::disable_termageddon_enqueue();
    303             }
    304         }
    305 
     286       
    306287        $settings_id            = Termageddon_Usercentrics::get_settings_id();
    307         $embed_version          = Termageddon_Usercentrics::get_embed_script_version();
    308288        $should_enqueue_scripts = Termageddon_Usercentrics::get_embed_injection_method() === 'wp_enqueue_scripts';
    309289
    310290        if ( $settings_id && $should_enqueue_scripts ) {
    311291            // Enqueue Embed Script.
    312             wp_enqueue_script( $this->plugin_name . '-preconnect', '//privacy-proxy.usercentrics.eu', array(), $this->version, false );
    313             wp_enqueue_script( $this->plugin_name . '-sdp', '//privacy-proxy.usercentrics.eu/latest/uc-block.bundle.js', array(), $this->version, false );
    314             if ( 'v2' === $embed_version ) {
    315                 wp_enqueue_script( $this->plugin_name . '-cmp', '//app.usercentrics.eu/browser-ui/latest/loader.js', array(), $this->version, false );
    316             } else {
    317                 wp_enqueue_script( $this->plugin_name . '-cmp', '//web.cmp.usercentrics.eu/ui/loader.js', array(), $this->version, false );
    318             }
    319             wp_enqueue_script( $this->plugin_name . '-translations', TERMAGEDDON_COOKIE_URL . 'public/js/termageddon-usercentrics-translations.min.js', array(), $this->version, false );
     292            wp_enqueue_script( $this->plugin_name . '-scripts', '//privacy-proxy.usercentrics.eu/latest/uc-block.bundle.js', array(), $this->version, false );
     293            // note: this URL is placed here to "play by the rules"... but it doesn't actually do anything.
     294            // the whole thing will be overwritten by the script_loader_tag filter.
    320295        }
    321296
     
    342317     */
    343318    public function filter_script_loader_tag( $tag, $handle, $src ) {
    344         switch ( $handle ) {
    345             case $this->plugin_name . '-preconnect':
    346                 $tag = '<link rel="preconnect" href="' . esc_url( $src ) . '">';
    347                 break;
    348             case $this->plugin_name . '-preload':
    349                 $tag = '<link rel="preload" href="' . esc_url( $src ) . '" as="script">';
    350                 break;
    351             case $this->plugin_name . '-cmp':
    352                 $tag = '<script type="text/javascript" id="usercentrics-cmp" data-cmp-version="' . esc_attr( Termageddon_Usercentrics::get_embed_script_version() ) . '" src="' . esc_url( $src ) . '" data-settings-id="' . esc_attr( Termageddon_Usercentrics::get_settings_id() ) . '" async></script>';
    353                 break;
    354             case $this->plugin_name . '-translations':
    355                 $tag = '<script type="text/javascript" id="usercentrics-translations" src="' . esc_url( $src ) . '"></script>';
    356                 break;
    357         }
    358 
     319        if ( $this->plugin_name . '-scripts' === $handle ) {
     320            $tag = self::build_termageddon_script( true );
     321        }
    359322        return $tag;
    360323    }
  • termageddon-usercentrics/trunk/termageddon-usercentrics.php

    r3266555 r3284346  
    1515 * Plugin Name:       Termageddon
    1616 * Description:       Each Termageddon license includes a consent solution. This plugin helps you install the consent solution with ease, while offering additional features.
    17  * Version:           1.7.0
     17 * Version:           1.7.1
    1818 * Author:            Termageddon
    1919 * Author URI:        https://termageddon.com
     
    3434 * Rename this for your plugin and update it as you release new versions.
    3535 */
    36 define( 'TERMAGEDDON_COOKIE_VERSION', '1.7.0' );
     36define( 'TERMAGEDDON_COOKIE_VERSION', '1.7.1' );
    3737
    3838define( 'TERMAGEDDON_COOKIE_PLUGIN_PATH', dirname( __FILE__ ) );// No trailing slash.
     
    9494    $plugin = new Termageddon_Usercentrics();
    9595    $plugin->run();
     96}
    9697
    97 }
    98 run_termageddon_cookie();
     98// Hook the plugin initialization to plugins_loaded
     99add_action('init', 'run_termageddon_cookie');
Note: See TracChangeset for help on using the changeset viewer.