Changeset 3284346
- Timestamp:
- 04/29/2025 06:49:28 PM (11 months ago)
- Location:
- termageddon-usercentrics
- Files:
-
- 28 deleted
- 17 edited
- 1 copied
-
assets/icon-256x256.png (modified) (1 prop) (previous)
-
tags/1.7.1 (copied) (copied from termageddon-usercentrics/trunk)
-
tags/1.7.1/README.txt (modified) (2 diffs)
-
tags/1.7.1/admin/class-termageddon-usercentrics-admin.php (modified) (5 diffs)
-
tags/1.7.1/admin/js/termageddon-usercentrics-admin.js (modified) (1 diff)
-
tags/1.7.1/admin/js/termageddon-usercentrics-admin.min.js (modified) (1 diff)
-
tags/1.7.1/composer.json (deleted)
-
tags/1.7.1/composer.lock (deleted)
-
tags/1.7.1/includes/class-termageddon-usercentrics-i18n.php (modified) (1 diff)
-
tags/1.7.1/includes/class-termageddon-usercentrics.php (modified) (7 diffs)
-
tags/1.7.1/public/class-termageddon-usercentrics-public.php (modified) (8 diffs)
-
tags/1.7.1/public/js/termageddon-usercentrics-translations.js (deleted)
-
tags/1.7.1/public/js/termageddon-usercentrics-translations.min.js (deleted)
-
tags/1.7.1/termageddon-usercentrics.code-workspace (deleted)
-
tags/1.7.1/termageddon-usercentrics.php (modified) (3 diffs)
-
tags/1.7.1/vendor/bin (deleted)
-
tags/1.7.1/vendor/composer/ca-bundle/README.md (deleted)
-
tags/1.7.1/vendor/composer/ca-bundle/composer.json (deleted)
-
tags/1.7.1/vendor/geoip2/geoip2/README.md (deleted)
-
tags/1.7.1/vendor/geoip2/geoip2/composer.json (deleted)
-
tags/1.7.1/vendor/maxmind-db/reader/README.md (deleted)
-
tags/1.7.1/vendor/maxmind-db/reader/composer.json (deleted)
-
tags/1.7.1/vendor/maxmind/web-service-common/README.md (deleted)
-
tags/1.7.1/vendor/maxmind/web-service-common/composer.json (deleted)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/admin/class-termageddon-usercentrics-admin.php (modified) (5 diffs)
-
trunk/admin/js/termageddon-usercentrics-admin.js (modified) (1 diff)
-
trunk/admin/js/termageddon-usercentrics-admin.min.js (modified) (1 diff)
-
trunk/composer.json (deleted)
-
trunk/composer.lock (deleted)
-
trunk/includes/class-termageddon-usercentrics-i18n.php (modified) (1 diff)
-
trunk/includes/class-termageddon-usercentrics.php (modified) (7 diffs)
-
trunk/public/class-termageddon-usercentrics-public.php (modified) (8 diffs)
-
trunk/public/js/termageddon-usercentrics-translations.js (deleted)
-
trunk/public/js/termageddon-usercentrics-translations.min.js (deleted)
-
trunk/termageddon-usercentrics.code-workspace (deleted)
-
trunk/termageddon-usercentrics.php (modified) (3 diffs)
-
trunk/vendor/bin (deleted)
-
trunk/vendor/composer/ca-bundle/README.md (deleted)
-
trunk/vendor/composer/ca-bundle/composer.json (deleted)
-
trunk/vendor/geoip2/geoip2/README.md (deleted)
-
trunk/vendor/geoip2/geoip2/composer.json (deleted)
-
trunk/vendor/maxmind-db/reader/README.md (deleted)
-
trunk/vendor/maxmind-db/reader/composer.json (deleted)
-
trunk/vendor/maxmind/web-service-common/README.md (deleted)
-
trunk/vendor/maxmind/web-service-common/composer.json (deleted)
Legend:
- Unmodified
- Added
- Removed
-
termageddon-usercentrics/assets/icon-256x256.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
termageddon-usercentrics/tags/1.7.1/README.txt
r3266555 r3284346 1 === Termageddon + Usercentrics===1 === Termageddon === 2 2 Contributors: termageddon, dintriglia 3 3 Tags: termageddon, cookie, consent, embed, privacy, gdpr, ccpa, usercentrics 4 4 Requires at least: 5.0 5 Tested up to: 6. 7.26 Stable tag: 1.7. 05 Tested up to: 6.8 6 Stable tag: 1.7.1 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 33 33 34 34 == 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. 35 43 36 44 = 1.7.0 = -
termageddon-usercentrics/tags/1.7.1/admin/class-termageddon-usercentrics-admin.php
r3266555 r3284346 398 398 public static function sanitize_embed_priority( $value ) { 399 399 $priority = self::sanitize_integer( $value ); 400 if ( $priority <= 10 && $priority >= 1) {400 if ( $priority <= 9999 && $priority >= -9999 ) { 401 401 return intval( $value ); 402 402 } … … 601 601 array( 602 602 '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' ), 604 604 ) 605 605 ); … … 669 669 'default' => 'v2', 670 670 ) 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. 671 690 ); 672 691 … … 1229 1248 public function embed_priority_html( array $args ) { 1230 1249 $args['default'] = 1; 1231 $args['min'] = 1;1232 $args['max'] = 10;1250 $args['min'] = -9999; 1251 $args['max'] = 9999; 1233 1252 $args['type'] = 'number'; 1234 1253 … … 1244 1263 public function embed_implementation_html( array $args ) { 1245 1264 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 ); 1246 1275 } 1247 1276 -
termageddon-usercentrics/tags/1.7.1/admin/js/termageddon-usercentrics-admin.js
r3238690 r3284346 142 142 ) 143 143 .replace( 144 "<script>uc.setCustomTranslations('https://termageddon.ams3.cdn.digitaloceanspaces.com/translations/');</script>",144 /<script>uc.setCustomTranslations.*<\/script>/g, 145 145 "" 146 146 ) -
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()}))}));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.*<\/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 32 32 * @since 1.0.0 33 33 */ 34 public function load_plugin_textdomain() { 35 34 public static function load_plugin_textdomain() { 36 35 load_plugin_textdomain( 37 36 'termageddon-usercentrics', -
termageddon-usercentrics/tags/1.7.1/includes/class-termageddon-usercentrics.php
r3266555 r3284346 75 75 76 76 $this->load_dependencies(); 77 $this->set _locale();77 $this->setup_translations(); 78 78 $this->define_admin_hooks(); 79 79 $this->define_public_hooks(); … … 250 250 * @access private 251 251 */ 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(); 257 255 258 256 } … … 361 359 'build_termageddon_script', 362 360 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 363 369 ); 364 370 … … 599 605 $embed_code = preg_replace( '~<script type="application/javascript" src="https:\/\/privacy-proxy.usercentrics.eu\/latest\/uc-block.bundle.js"><\/script>~', '', $embed_code ); 600 606 $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 ); 602 608 } 603 609 … … 615 621 } 616 622 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(); 619 626 620 627 $new_embed_code = '<link rel="preconnect" href="https://plugins.trac.wordpress.org//privacy-proxy.usercentrics.eu">' . PHP_EOL; 621 628 $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; 625 632 $new_embed_code .= self::filter_out_standard_embed_code( $embed_code ); 626 633 … … 969 976 } 970 977 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 971 1001 972 1002 /** … … 1169 1199 $priority = get_option( 'termageddon_usercentrics_embed_priority', 1 ); 1170 1200 $priority = intval( $priority ); 1171 if ( $priority <= 10 && $priority >= 1) {1201 if ( $priority <= 9999 && $priority >= -9999 ) { 1172 1202 return $priority; 1173 1203 } -
termageddon-usercentrics/tags/1.7.1/public/class-termageddon-usercentrics-public.php
r3266555 r3284346 163 163 */ 164 164 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() && 167 168 ! 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(); 173 174 foreach ( Termageddon_Usercentrics::get_geolocation_locations() as $loc_key => $loc ) { 174 175 list ( 'title' => $loc_name ) = $loc; … … 176 177 } 177 178 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 ); 190 191 } 191 192 } … … 218 219 * Dynamically hide or show the termageddon script based on settings. Outputs directly to script tag. 219 220 */ 220 public function build_termageddon_script( ) {221 public function build_termageddon_script( $is_enqueue = false ) { 221 222 222 223 // If forcibly enabled, bypass individual detections. … … 227 228 } 228 229 229 // Debug display to console if applicable.230 self::debug_display();231 232 230 // Check for individual disable detections. 233 231 $disable_on_logged_in = get_option( 'termageddon_usercentrics_disable_logged_in', false ) ? true : false; … … 249 247 return; 250 248 } 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; 257 258 258 259 $script = Termageddon_Usercentrics::get_embed_code( … … 267 268 268 269 // 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 } 272 280 273 281 } … … 276 284 */ 277 285 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 306 287 $settings_id = Termageddon_Usercentrics::get_settings_id(); 307 $embed_version = Termageddon_Usercentrics::get_embed_script_version();308 288 $should_enqueue_scripts = Termageddon_Usercentrics::get_embed_injection_method() === 'wp_enqueue_scripts'; 309 289 310 290 if ( $settings_id && $should_enqueue_scripts ) { 311 291 // 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. 320 295 } 321 296 … … 342 317 */ 343 318 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 } 359 322 return $tag; 360 323 } -
termageddon-usercentrics/tags/1.7.1/termageddon-usercentrics.php
r3266555 r3284346 15 15 * Plugin Name: Termageddon 16 16 * 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. 017 * Version: 1.7.1 18 18 * Author: Termageddon 19 19 * Author URI: https://termageddon.com … … 34 34 * Rename this for your plugin and update it as you release new versions. 35 35 */ 36 define( 'TERMAGEDDON_COOKIE_VERSION', '1.7. 0' );36 define( 'TERMAGEDDON_COOKIE_VERSION', '1.7.1' ); 37 37 38 38 define( 'TERMAGEDDON_COOKIE_PLUGIN_PATH', dirname( __FILE__ ) );// No trailing slash. … … 94 94 $plugin = new Termageddon_Usercentrics(); 95 95 $plugin->run(); 96 } 96 97 97 } 98 run_termageddon_cookie();98 // Hook the plugin initialization to plugins_loaded 99 add_action('init', 'run_termageddon_cookie'); -
termageddon-usercentrics/trunk/README.txt
r3266555 r3284346 1 === Termageddon + Usercentrics===1 === Termageddon === 2 2 Contributors: termageddon, dintriglia 3 3 Tags: termageddon, cookie, consent, embed, privacy, gdpr, ccpa, usercentrics 4 4 Requires at least: 5.0 5 Tested up to: 6. 7.26 Stable tag: 1.7. 05 Tested up to: 6.8 6 Stable tag: 1.7.1 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 33 33 34 34 == 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. 35 43 36 44 = 1.7.0 = -
termageddon-usercentrics/trunk/admin/class-termageddon-usercentrics-admin.php
r3266555 r3284346 398 398 public static function sanitize_embed_priority( $value ) { 399 399 $priority = self::sanitize_integer( $value ); 400 if ( $priority <= 10 && $priority >= 1) {400 if ( $priority <= 9999 && $priority >= -9999 ) { 401 401 return intval( $value ); 402 402 } … … 601 601 array( 602 602 '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' ), 604 604 ) 605 605 ); … … 669 669 'default' => 'v2', 670 670 ) 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. 671 690 ); 672 691 … … 1229 1248 public function embed_priority_html( array $args ) { 1230 1249 $args['default'] = 1; 1231 $args['min'] = 1;1232 $args['max'] = 10;1250 $args['min'] = -9999; 1251 $args['max'] = 9999; 1233 1252 $args['type'] = 'number'; 1234 1253 … … 1244 1263 public function embed_implementation_html( array $args ) { 1245 1264 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 ); 1246 1275 } 1247 1276 -
termageddon-usercentrics/trunk/admin/js/termageddon-usercentrics-admin.js
r3238690 r3284346 142 142 ) 143 143 .replace( 144 "<script>uc.setCustomTranslations('https://termageddon.ams3.cdn.digitaloceanspaces.com/translations/');</script>",144 /<script>uc.setCustomTranslations.*<\/script>/g, 145 145 "" 146 146 ) -
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()}))}));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.*<\/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 32 32 * @since 1.0.0 33 33 */ 34 public function load_plugin_textdomain() { 35 34 public static function load_plugin_textdomain() { 36 35 load_plugin_textdomain( 37 36 'termageddon-usercentrics', -
termageddon-usercentrics/trunk/includes/class-termageddon-usercentrics.php
r3266555 r3284346 75 75 76 76 $this->load_dependencies(); 77 $this->set _locale();77 $this->setup_translations(); 78 78 $this->define_admin_hooks(); 79 79 $this->define_public_hooks(); … … 250 250 * @access private 251 251 */ 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(); 257 255 258 256 } … … 361 359 'build_termageddon_script', 362 360 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 363 369 ); 364 370 … … 599 605 $embed_code = preg_replace( '~<script type="application/javascript" src="https:\/\/privacy-proxy.usercentrics.eu\/latest\/uc-block.bundle.js"><\/script>~', '', $embed_code ); 600 606 $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 ); 602 608 } 603 609 … … 615 621 } 616 622 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(); 619 626 620 627 $new_embed_code = '<link rel="preconnect" href="https://plugins.trac.wordpress.org//privacy-proxy.usercentrics.eu">' . PHP_EOL; 621 628 $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; 625 632 $new_embed_code .= self::filter_out_standard_embed_code( $embed_code ); 626 633 … … 969 976 } 970 977 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 971 1001 972 1002 /** … … 1169 1199 $priority = get_option( 'termageddon_usercentrics_embed_priority', 1 ); 1170 1200 $priority = intval( $priority ); 1171 if ( $priority <= 10 && $priority >= 1) {1201 if ( $priority <= 9999 && $priority >= -9999 ) { 1172 1202 return $priority; 1173 1203 } -
termageddon-usercentrics/trunk/public/class-termageddon-usercentrics-public.php
r3266555 r3284346 163 163 */ 164 164 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() && 167 168 ! 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(); 173 174 foreach ( Termageddon_Usercentrics::get_geolocation_locations() as $loc_key => $loc ) { 174 175 list ( 'title' => $loc_name ) = $loc; … … 176 177 } 177 178 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 ); 190 191 } 191 192 } … … 218 219 * Dynamically hide or show the termageddon script based on settings. Outputs directly to script tag. 219 220 */ 220 public function build_termageddon_script( ) {221 public function build_termageddon_script( $is_enqueue = false ) { 221 222 222 223 // If forcibly enabled, bypass individual detections. … … 227 228 } 228 229 229 // Debug display to console if applicable.230 self::debug_display();231 232 230 // Check for individual disable detections. 233 231 $disable_on_logged_in = get_option( 'termageddon_usercentrics_disable_logged_in', false ) ? true : false; … … 249 247 return; 250 248 } 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; 257 258 258 259 $script = Termageddon_Usercentrics::get_embed_code( … … 267 268 268 269 // 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 } 272 280 273 281 } … … 276 284 */ 277 285 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 306 287 $settings_id = Termageddon_Usercentrics::get_settings_id(); 307 $embed_version = Termageddon_Usercentrics::get_embed_script_version();308 288 $should_enqueue_scripts = Termageddon_Usercentrics::get_embed_injection_method() === 'wp_enqueue_scripts'; 309 289 310 290 if ( $settings_id && $should_enqueue_scripts ) { 311 291 // 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. 320 295 } 321 296 … … 342 317 */ 343 318 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 } 359 322 return $tag; 360 323 } -
termageddon-usercentrics/trunk/termageddon-usercentrics.php
r3266555 r3284346 15 15 * Plugin Name: Termageddon 16 16 * 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. 017 * Version: 1.7.1 18 18 * Author: Termageddon 19 19 * Author URI: https://termageddon.com … … 34 34 * Rename this for your plugin and update it as you release new versions. 35 35 */ 36 define( 'TERMAGEDDON_COOKIE_VERSION', '1.7. 0' );36 define( 'TERMAGEDDON_COOKIE_VERSION', '1.7.1' ); 37 37 38 38 define( 'TERMAGEDDON_COOKIE_PLUGIN_PATH', dirname( __FILE__ ) );// No trailing slash. … … 94 94 $plugin = new Termageddon_Usercentrics(); 95 95 $plugin->run(); 96 } 96 97 97 } 98 run_termageddon_cookie();98 // Hook the plugin initialization to plugins_loaded 99 add_action('init', 'run_termageddon_cookie');
Note: See TracChangeset
for help on using the changeset viewer.