Changeset 3104855
- Timestamp:
- 06/20/2024 05:58:04 AM (22 months ago)
- Location:
- termageddon-usercentrics
- Files:
-
- 3 deleted
- 8 edited
- 66 copied
-
tags/1.4.1 (copied) (copied from termageddon-usercentrics/trunk)
-
tags/1.4.1/README.txt (copied) (copied from termageddon-usercentrics/trunk/README.txt) (2 diffs)
-
tags/1.4.1/admin/class-termageddon-usercentrics-admin.php (copied) (copied from termageddon-usercentrics/trunk/admin/class-termageddon-usercentrics-admin.php) (1 diff)
-
tags/1.4.1/admin/css/termageddon-usercentrics-admin.css (copied) (copied from termageddon-usercentrics/trunk/admin/css/termageddon-usercentrics-admin.css)
-
tags/1.4.1/admin/css/termageddon-usercentrics-admin.min.css (copied) (copied from termageddon-usercentrics/trunk/admin/css/termageddon-usercentrics-admin.min.css)
-
tags/1.4.1/admin/js (copied) (copied from termageddon-usercentrics/trunk/admin/js)
-
tags/1.4.1/admin/js/termageddon-usercentrics-admin.js (copied) (copied from termageddon-usercentrics/trunk/admin/js/termageddon-usercentrics-admin.js)
-
tags/1.4.1/admin/js/termageddon-usercentrics-admin.min.js (copied) (copied from termageddon-usercentrics/trunk/admin/js/termageddon-usercentrics-admin.min.js)
-
tags/1.4.1/composer.json (copied) (copied from termageddon-usercentrics/trunk/composer.json)
-
tags/1.4.1/composer.lock (copied) (copied from termageddon-usercentrics/trunk/composer.lock)
-
tags/1.4.1/includes/.intelephense-helper.php (copied) (copied from termageddon-usercentrics/trunk/includes/.intelephense-helper.php)
-
tags/1.4.1/includes/class-termageddon-usercentrics-activator.php (copied) (copied from termageddon-usercentrics/trunk/includes/class-termageddon-usercentrics-activator.php)
-
tags/1.4.1/includes/class-termageddon-usercentrics-deactivator.php (copied) (copied from termageddon-usercentrics/trunk/includes/class-termageddon-usercentrics-deactivator.php)
-
tags/1.4.1/includes/class-termageddon-usercentrics.php (copied) (copied from termageddon-usercentrics/trunk/includes/class-termageddon-usercentrics.php) (6 diffs)
-
tags/1.4.1/languages/termageddon-usercentrics-en_US.po (copied) (copied from termageddon-usercentrics/trunk/languages/termageddon-usercentrics-en_US.po)
-
tags/1.4.1/languages/termageddon-usercentrics.pot (copied) (copied from termageddon-usercentrics/trunk/languages/termageddon-usercentrics.pot) (1 diff)
-
tags/1.4.1/public/class-termageddon-usercentrics-public.php (copied) (copied from termageddon-usercentrics/trunk/public/class-termageddon-usercentrics-public.php) (2 diffs)
-
tags/1.4.1/public/js (copied) (copied from termageddon-usercentrics/trunk/public/js)
-
tags/1.4.1/public/js/termageddon-usercentrics-ajax.js (copied) (copied from termageddon-usercentrics/trunk/public/js/termageddon-usercentrics-ajax.js) (3 diffs)
-
tags/1.4.1/public/js/termageddon-usercentrics-ajax.min.js (copied) (copied from termageddon-usercentrics/trunk/public/js/termageddon-usercentrics-ajax.min.js) (1 diff)
-
tags/1.4.1/termageddon-usercentrics.code-workspace (copied) (copied from termageddon-usercentrics/trunk/termageddon-usercentrics.code-workspace)
-
tags/1.4.1/termageddon-usercentrics.php (copied) (copied from termageddon-usercentrics/trunk/termageddon-usercentrics.php) (2 diffs)
-
tags/1.4.1/vendor/bin (copied) (copied from termageddon-usercentrics/trunk/vendor/bin)
-
tags/1.4.1/vendor/composer/ClassLoader.php (copied) (copied from termageddon-usercentrics/trunk/vendor/composer/ClassLoader.php)
-
tags/1.4.1/vendor/composer/InstalledVersions.php (copied) (copied from termageddon-usercentrics/trunk/vendor/composer/InstalledVersions.php)
-
tags/1.4.1/vendor/composer/autoload_real.php (copied) (copied from termageddon-usercentrics/trunk/vendor/composer/autoload_real.php)
-
tags/1.4.1/vendor/composer/autoload_static.php (copied) (copied from termageddon-usercentrics/trunk/vendor/composer/autoload_static.php)
-
tags/1.4.1/vendor/composer/ca-bundle/res/cacert.pem (copied) (copied from termageddon-usercentrics/trunk/vendor/composer/ca-bundle/res/cacert.pem)
-
tags/1.4.1/vendor/composer/ca-bundle/src/CaBundle.php (copied) (copied from termageddon-usercentrics/trunk/vendor/composer/ca-bundle/src/CaBundle.php)
-
tags/1.4.1/vendor/composer/installed.json (copied) (copied from termageddon-usercentrics/trunk/vendor/composer/installed.json)
-
tags/1.4.1/vendor/composer/installed.php (copied) (copied from termageddon-usercentrics/trunk/vendor/composer/installed.php)
-
tags/1.4.1/vendor/geoip2/geoip2/.github (deleted)
-
tags/1.4.1/vendor/geoip2/geoip2/.php-cs-fixer.php (deleted)
-
tags/1.4.1/vendor/geoip2/geoip2/CHANGELOG.md (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/CHANGELOG.md)
-
tags/1.4.1/vendor/geoip2/geoip2/README.md (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/README.md)
-
tags/1.4.1/vendor/geoip2/geoip2/composer.json (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/composer.json)
-
tags/1.4.1/vendor/geoip2/geoip2/examples/benchmark.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/examples/benchmark.php)
-
tags/1.4.1/vendor/geoip2/geoip2/phpstan.neon (deleted)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Database/Reader.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Database/Reader.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Exception/AddressNotFoundException.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Exception/AddressNotFoundException.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Exception/AuthenticationException.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Exception/AuthenticationException.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Exception/GeoIp2Exception.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Exception/GeoIp2Exception.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Exception/HttpException.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Exception/HttpException.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Exception/InvalidRequestException.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Exception/InvalidRequestException.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Exception/OutOfQueriesException.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Exception/OutOfQueriesException.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Model/AbstractModel.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Model/AbstractModel.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Model/AnonymousIp.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Model/AnonymousIp.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Model/Asn.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Model/Asn.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Model/City.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Model/City.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Model/ConnectionType.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Model/ConnectionType.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Model/Country.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Model/Country.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Model/Domain.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Model/Domain.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Model/Enterprise.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Model/Enterprise.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Model/Insights.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Model/Insights.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Model/Isp.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Model/Isp.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/ProviderInterface.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/ProviderInterface.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Record/AbstractPlaceRecord.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Record/AbstractPlaceRecord.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Record/AbstractRecord.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Record/AbstractRecord.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Record/City.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Record/City.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Record/Continent.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Record/Continent.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Record/Country.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Record/Country.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Record/Location.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Record/Location.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Record/MaxMind.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Record/MaxMind.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Record/Postal.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Record/Postal.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Record/RepresentedCountry.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Record/RepresentedCountry.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Record/Subdivision.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Record/Subdivision.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Record/Traits.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Record/Traits.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/Util.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/Util.php)
-
tags/1.4.1/vendor/geoip2/geoip2/src/WebService/Client.php (copied) (copied from termageddon-usercentrics/trunk/vendor/geoip2/geoip2/src/WebService/Client.php)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/admin/class-termageddon-usercentrics-admin.php (modified) (1 diff)
-
trunk/includes/class-termageddon-usercentrics.php (modified) (6 diffs)
-
trunk/languages/termageddon-usercentrics.pot (modified) (1 diff)
-
trunk/public/class-termageddon-usercentrics-public.php (modified) (2 diffs)
-
trunk/public/js/termageddon-usercentrics-ajax.js (modified) (3 diffs)
-
trunk/public/js/termageddon-usercentrics-ajax.min.js (modified) (1 diff)
-
trunk/termageddon-usercentrics.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
termageddon-usercentrics/tags/1.4.1/README.txt
r3060868 r3104855 5 5 Requires at least: 3.0.1 6 6 Tested up to: 6.4.3 7 Stable tag: 1.4. 07 Stable tag: 1.4.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 27 27 == Changelog == 28 28 29 = 1.4.1 = 30 31 - [FIX] Fixed an issue where the plugin with Ajax Mode would bust cache for every request for some providers such as Pressable. 32 29 33 = 1.4.0 = 30 34 31 - [ADD] Added ability to disableplugin for troubleshooting to all visitors unless ?enable-usercentrics is added as a query parameter to the URL.35 - [ADD] Added ability to turn off plugin for troubleshooting to all visitors unless ?enable-usercentrics is added as a query parameter to the URL. 32 36 33 37 = 1.3.9 = -
termageddon-usercentrics/tags/1.4.1/admin/class-termageddon-usercentrics-admin.php
r3060868 r3104855 505 505 array( 506 506 'label_for' => 'termageddon_usercentrics_disable_troubleshooting', 507 'description' => __( 'When enabled, this feature allows you to disablethe consent tool for all site visitors, however by adding <code>?enable-usercentrics</code> to the end of a URL, the consent tool will load, allowing you to troubleshoot any issues (or to reach out to Termageddon support to help assist with troubleshooting)', 'termageddon-usercentrics' ),507 'description' => __( 'When enabled, this feature allows you to turn off the consent tool for all site visitors, however by adding <code>?enable-usercentrics</code> to the end of a URL, the consent tool will load, allowing you to troubleshoot any issues (or to reach out to Termageddon support to help assist with troubleshooting)', 'termageddon-usercentrics' ), 508 508 ) 509 509 ); -
termageddon-usercentrics/tags/1.4.1/includes/class-termageddon-usercentrics.php
r3060868 r3104855 267 267 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); 268 268 269 if ( self::is_geoip_enabled() && ! wp_doing_cron() ) {269 if ( self::is_geoip_enabled() && ! self::is_ajax_mode_enabled() && ! wp_doing_cron() ) { 270 270 $this->loader->add_action( 'init', $this, 'lookup_ip_address' ); 271 271 … … 421 421 // Check for fatal errors. 422 422 if ( self::check_for_download_errors() ) { 423 return false; 424 } 425 426 // If Geo IP is enabled, download. 427 if ( ! self::is_geoip_enabled() ) { 423 428 return false; 424 429 } … … 750 755 751 756 } 752 753 757 758 754 759 /** 755 760 * Returns whether disabled for troubleshooting mode is enabled and not in the query params … … 758 763 */ 759 764 public static function is_disabled_for_troubleshooting() { 760 $enabled = ( get_option( 'termageddon_usercentrics_disable_troubleshooting', false ) ? true : false ); 761 762 if ($enabled && !isset($_GET['enable-usercentrics'])) return true; 763 return false; 765 return ( get_option( 'termageddon_usercentrics_disable_troubleshooting', false ) ? true : false ); 766 767 } 768 769 770 /** 771 * Returns whether user wants to force enable via the query params. 772 * 773 * @return bool 774 */ 775 public static function is_enabled_via_get_override() { 776 return isset( $_GET['enable-usercentrics'] ); 764 777 765 778 } … … 834 847 $cookie_title = self::get_cookie_title(); 835 848 836 // Validate Database && download database if needed.837 self::verify_maxmind_database();838 839 // If Email is not in blacklist, try to calculate geo ip location.840 if ( '::1' !== $ip_address ) { 841 // Check for cached location via cookie, or check the geo ip database if no cookie found.842 if ( isset( $_COOKIE[ $cookie_title ] ) && ! self::is_debug_mode_enabled()) {843 @list('city' => $city, 'state' => $state, 'country' => $country) = json_decode( sanitize_text_field( wp_unslash( $_COOKIE[ $cookie_title ] ) ), true );844 } else{845 try {846 847 $reader = new Reader( self::get_maxmind_db_path() );848 849 $record = $reader->City( $ip_address);850 851 if ( isset( $record->city->names ) && isset( $record->city->names['en'] ) ) {852 $city = $record->city->names['en']; 853 }854 if ( isset( $record->subdivisions[0] ) && isset( $record->subdivisions[0]->names ) && isset( $record->subdivisions[0]->names['en'] ) ) {855 $state = $record->subdivisions[0]->names['en'];856 }857 if ( isset( $record->country->names ) && isset( $record->country->names['en'] ) ) {858 $country = $record->country->names['en'];859 }860 861 // If able to, set cookie to allow future page loads to simply use the cookie for processing.862 if ( ! headers_sent() ) { 863 setcookie(864 $cookie_title,865 wp_json_encode(849 // If Geo IP is enabled, download. 850 if ( self::is_geoip_enabled() ) { 851 // Validate Database && download database if needed. 852 self::verify_maxmind_database(); 853 854 // If Email is not in blacklist, try to calculate geo ip location. 855 if ( '::1' !== $ip_address ) { 856 // Check for cached location via cookie, or check the geo ip database if no cookie found. 857 if ( isset( $_COOKIE[ $cookie_title ] ) && ! self::is_debug_mode_enabled() ) { 858 @list('city' => $city, 'state' => $state, 'country' => $country) = json_decode( sanitize_text_field( wp_unslash( $_COOKIE[ $cookie_title ] ) ), true ); 859 } else { 860 try { 861 862 $reader = new Reader( self::get_maxmind_db_path() ); 863 864 $record = $reader->City( $ip_address ); 865 866 if ( isset( $record->city->names ) && isset( $record->city->names['en'] ) ) { 867 $city = $record->city->names['en']; 868 } 869 if ( isset( $record->subdivisions[0] ) && isset( $record->subdivisions[0]->names ) && isset( $record->subdivisions[0]->names['en'] ) ) { 870 $state = $record->subdivisions[0]->names['en']; 871 } 872 if ( isset( $record->country->names ) && isset( $record->country->names['en'] ) ) { 873 $country = $record->country->names['en']; 874 } 875 876 // If able to, set cookie to allow future page loads to simply use the cookie for processing. 877 if ( ! headers_sent() && ! isset( $_COOKIE[ $cookie_title ] ) ) { 878 $cookie_value = wp_json_encode( 866 879 array( 867 880 'city' => $city, … … 869 882 'country' => $country, 870 883 ) 871 ), 872 0, 873 COOKIEPATH, 874 COOKIE_DOMAIN 875 ); 876 } 877 } catch ( \Throwable $th ) { 878 // Error with GEO IP. 879 // Display it IF debug via GET is enabled and administrator. 880 if ( current_user_can( 'administrator' ) || self::is_debug_mode_enabled() ) { 881 self::debug( 'Error Calculating Location', $th->getMessage() ); 884 ); 885 886 setcookie( 887 $cookie_title, 888 $cookie_value, 889 0, 890 COOKIEPATH, 891 COOKIE_DOMAIN 892 ); 893 $_COOKIE[ $cookie_title ] = $cookie_value; 894 } 895 } catch ( \Throwable $th ) { 896 // Error with GEO IP. 897 // Display it IF debug via GET is enabled and administrator. 898 if ( current_user_can( 'administrator' ) || self::is_debug_mode_enabled() ) { 899 self::debug( 'Error Calculating Location', $th->getMessage() ); 900 } 882 901 } 883 902 } -
termageddon-usercentrics/tags/1.4.1/languages/termageddon-usercentrics.pot
r3060868 r3104855 286 286 #: admin/class-termageddon-usercentrics-admin.php:507 287 287 msgid "" 288 "When enabled, this feature allows you to disablethe consent tool for all "288 "When enabled, this feature allows you to turn off the consent tool for all " 289 289 "site visitors, however by adding <code>?enable-usercentrics</code> to the " 290 290 "end of a URL, the consent tool will load, allowing you to troubleshoot any " -
termageddon-usercentrics/tags/1.4.1/public/class-termageddon-usercentrics-public.php
r3060868 r3104855 120 120 echo wp_kses( $script, Termageddon_Usercentrics::ALLOWED_HTML ); 121 121 echo '<!-- END TERMAGEDDON + USERCENTRICS -->'; 122 } 123 124 /** 125 * Display debug information to console if applicable 126 * 127 * @return void 128 */ 129 public function debug_display() { 130 if ( ( Termageddon_Usercentrics::is_geoip_enabled() || Termageddon_Usercentrics::is_debug_mode_enabled() ) 131 && 132 ! Termageddon_Usercentrics::is_ajax_mode_enabled() 133 ) { 134 list('city' => $city, 'state' => $state, 'country' => $country) = Termageddon_Usercentrics::lookup_ip_address(); 135 136 // Output debug message to console. 137 Termageddon_Usercentrics::debug( 138 'IP Address: ' . Termageddon_Usercentrics::get_processed_ip_address(), 139 'City: ' . ( $city ?? 'Unknown' ), 140 'State: ' . ( $state ?? 'Unknown' ), 141 'Country: ' . ( $country ?? 'Unknown' ), 142 '--', 143 'Located in EU?: ' . ( Termageddon_Usercentrics::is_located_in_eu() ? 'Yes' : 'No' ), 144 'Located in UK?: ' . ( Termageddon_Usercentrics::is_located_in_uk() ? 'Yes' : 'No' ), 145 'Located in Canada?: ' . ( Termageddon_Usercentrics::is_located_in_canada() ? 'Yes' : 'No' ), 146 'Located in California?: ' . ( Termageddon_Usercentrics::is_located_in_california() ? 'Yes' : 'No' ), 147 'Located in Virginia?: ' . ( Termageddon_Usercentrics::is_located_in_virginia() ? 'Yes' : 'No' ), 148 '--', 149 'Geo-Location Mode?: ' . ( Termageddon_Usercentrics::is_geoip_enabled() ? 'Yes' : 'No' ), 150 'AJAX Mode?: ' . ( Termageddon_Usercentrics::is_ajax_mode_enabled() ? 'Yes' : 'No' ), 151 ); 152 } 122 153 } 123 154 … … 155 186 } 156 187 157 // Check for Disable for troubleshooting while validating query param. 158 if (Termageddon_Usercentrics::is_disabled_for_troubleshooting()) { 159 return self::disable_termageddon_script(); 160 } 161 162 // Debug Display to identify locations. 163 if ( ( Termageddon_Usercentrics::is_geoip_enabled() || Termageddon_Usercentrics::is_debug_mode_enabled() ) 164 && 165 ! Termageddon_Usercentrics::is_ajax_mode_enabled() 166 ) { 167 list('city' => $city, 'state' => $state, 'country' => $country) = Termageddon_Usercentrics::lookup_ip_address(); 168 169 // Output debug message to console. 170 Termageddon_Usercentrics::debug( 171 'IP Address: ' . Termageddon_Usercentrics::get_processed_ip_address(), 172 'City: ' . ( $city ?? 'Unknown' ), 173 'State: ' . ( $state ?? 'Unknown' ), 174 'Country: ' . ( $country ?? 'Unknown' ), 175 '--', 176 'Located in EU?: ' . ( Termageddon_Usercentrics::is_located_in_eu() ? 'Yes' : 'No' ), 177 'Located in UK?: ' . ( Termageddon_Usercentrics::is_located_in_uk() ? 'Yes' : 'No' ), 178 'Located in Canada?: ' . ( Termageddon_Usercentrics::is_located_in_canada() ? 'Yes' : 'No' ), 179 'Located in California?: ' . ( Termageddon_Usercentrics::is_located_in_california() ? 'Yes' : 'No' ), 180 'Located in Virginia?: ' . ( Termageddon_Usercentrics::is_located_in_virginia() ? 'Yes' : 'No' ), 181 '--', 182 'Geo-Location Mode?: ' . ( Termageddon_Usercentrics::is_geoip_enabled() ? 'Yes' : 'No' ), 183 'AJAX Mode?: ' . ( Termageddon_Usercentrics::is_ajax_mode_enabled() ? 'Yes' : 'No' ), 184 ); 185 } 186 187 $disable_on_logged_in = get_option( 'termageddon_usercentrics_disable_logged_in', false ) ? true : false; 188 if ( $disable_on_logged_in && is_user_logged_in() ) { 189 return self::disable_termageddon_script(); 190 } 191 192 $disable_on_editor = get_option( 'termageddon_usercentrics_disable_editor', false ) ? true : false; 193 if ( $disable_on_editor && current_user_can( 'editor' ) ) { 194 return self::disable_termageddon_script(); 195 } 196 197 $disable_on_admin = get_option( 'termageddon_usercentrics_disable_admin', false ) ? true : false; 198 if ( $disable_on_admin && current_user_can( 'administrator' ) ) { 199 return self::disable_termageddon_script(); 200 } 201 202 if ( Termageddon_Usercentrics::is_geoip_enabled() && ! Termageddon_Usercentrics::is_ajax_mode_enabled() && Termageddon_Usercentrics::should_hide_due_to_location() ) { 203 return self::disable_termageddon_script(); 188 // If forcibly enabled, bypass individual detections. 189 if ( ! Termageddon_Usercentrics::is_enabled_via_get_override() ) { 190 // Check for Disable for troubleshooting. 191 if ( Termageddon_Usercentrics::is_disabled_for_troubleshooting() ) { 192 return self::disable_termageddon_script(); 193 } 194 195 // Debug display to console if applicable. 196 self::debug_display(); 197 198 // Check for individual disable detections. 199 $disable_on_logged_in = get_option( 'termageddon_usercentrics_disable_logged_in', false ) ? true : false; 200 if ( $disable_on_logged_in && is_user_logged_in() ) { 201 return self::disable_termageddon_script(); 202 } 203 204 $disable_on_editor = get_option( 'termageddon_usercentrics_disable_editor', false ) ? true : false; 205 if ( $disable_on_editor && current_user_can( 'editor' ) ) { 206 return self::disable_termageddon_script(); 207 } 208 209 $disable_on_admin = get_option( 'termageddon_usercentrics_disable_admin', false ) ? true : false; 210 if ( $disable_on_admin && current_user_can( 'administrator' ) ) { 211 return self::disable_termageddon_script(); 212 } 213 214 if ( Termageddon_Usercentrics::is_geoip_enabled() && ! Termageddon_Usercentrics::is_ajax_mode_enabled() && Termageddon_Usercentrics::should_hide_due_to_location() ) { 215 return self::disable_termageddon_script(); 216 } 217 } else { 218 // Debug display to console if applicable. 219 self::debug_display(); 204 220 } 205 221 -
termageddon-usercentrics/tags/1.4.1/public/js/termageddon-usercentrics-ajax.js
r2890756 r3104855 10 10 const parts = value.split(`; ${name}=`); 11 11 if (parts.length === 2) return parts.pop().split(";").shift(); 12 }; 13 14 const getQueryParams = (param) => { 15 const params = new Proxy(new URLSearchParams(window.location.search), { 16 get: (searchParams, prop) => searchParams.get(prop), 17 }); 18 19 return params[param]; 12 20 }; 13 21 … … 57 65 if (typeof UC_UI === "undefined") 58 66 return console.error("Usercentrics not loaded"); 67 68 //Check query variable from browser 69 const query_hide = 70 getQueryParams("enable-usercentrics") === "" ? true : false; 59 71 60 72 //Check for local cookie to use instead of calling. … … 133 145 } 134 146 147 if (query_hide) { 148 if (tuDebug) 149 console.log( 150 "UC: Enabling due to query parameter override.", 151 "Showing Usercentrics" 152 ); 153 return updateCookieConsent(false); 154 } 155 135 156 //If you are not supposed to be hiding, show the CMP. 136 157 setCookie(tuCookieHideName, data.hide ? "true" : "false"); -
termageddon-usercentrics/tags/1.4.1/public/js/termageddon-usercentrics-ajax.min.js
r2890756 r3104855 1 const tuCookieHideName="tu-geoip-hide",tuDebug="true"===termageddon_usercentrics_obj.debug,tuPSLHide="true"===termageddon_usercentrics_obj.psl_hide;tuDebug&&console.log("UC: AJAX script initialized"),window.addEventListener("UC_UI_INITIALIZED",(function(){const getCookie=name=>{const value=`; ${document.cookie}`,parts=value.split(`; ${name}=`);if(2===parts.length)return parts.pop().split(";").shift()}, setCookie=(name,value,days)=>{var expires="";if(days){var date=new Date;date.setTime(date.getTime()+24*days*60*60*1e3),expires="; expires="+date.toUTCString()}document.cookie=name+"="+(value||"")+expires+"; path=/"},updateCookieConsent=hide=>{if(!hide)return tuDebug&&console.log("UC: Showing consent widget"),tuPSLHide&&jQuery("#usercentrics-psl, .usercentrics-psl").show(),jQuery("div#usercentrics-root").show(),UC_UI.isConsentRequired()?UC_UI.showFirstLayer():UC_UI.closeCMP();tuDebug&&console.log("UC: Hiding consent widget"),tuPSLHide&&jQuery("#usercentrics-psl, .usercentrics-psl").hide(),jQuery("div#usercentrics-root").hide(),UC_UI.areAllConsentsAccepted()||UC_UI.acceptAllConsents().then(()=>{tuDebug&&console.log("UC: All consents have been accepted."),UC_UI.closeCMP().then(()=>{tuDebug&&console.log("UC: CMP Widget has been closed.")})})};if("undefined"==typeof UC_UI)return console.error("Usercentrics not loaded");const cookie_hide=getCookie("tu-geoip-hide");if(null==cookie_hide||tuDebug){tuDebug&&console.log("UC: Making AJAX Call");var data={action:"uc_geolocation_lookup",nonce:termageddon_usercentrics_obj.nonce};void 0!==termageddon_usercentrics_obj.location&&(data.location=termageddon_usercentrics_obj.location),jQuery.post(termageddon_usercentrics_obj.ajax_url,data).done((function(response){if(!response.success)return console.error("Unable to lookup location.",response.message||"");if(!response.data)return console.error("Location data was not provided.",response.data);const data=response.data;tuDebug&&console.log("TERMAGEDDON USERCENTRICS (AJAX)\nIP Address: "+data.ipAddress+"\nCity: "+(data.city||"Unknown")+"\nState: "+(data.state||"Unknown")+"\nCountry: "+(data.country||"Unknown")+"\n--\nLocated in EU?: "+(data.inEU?"Yes":"No")+"\nLocated in UK?: "+(data.inUK?"Yes":"No")+"\nLocated in Canada?: "+(data.inCanada?"Yes":"No")+"\nLocated in California?: "+(data.inCalifornia?"Yes":"No")+"\nLocated in Virginia?: "+(data.inVirginia?"Yes":"No")),setCookie("tu-geoip-hide",data.hide?"true":"false"),updateCookieConsent(data.hide)})).fail((function(response){console.error("Usercentrics: Invalid response returned. Showing widget as a default.",response),updateCookieConsent(!1)}))}else tuDebug&&console.log("UC: Cookie found.",(cookie_hide?"Showing":"Hiding")+" Usercentrics"),updateCookieConsent("true"===cookie_hide)}));1 const tuCookieHideName="tu-geoip-hide",tuDebug="true"===termageddon_usercentrics_obj.debug,tuPSLHide="true"===termageddon_usercentrics_obj.psl_hide;tuDebug&&console.log("UC: AJAX script initialized"),window.addEventListener("UC_UI_INITIALIZED",(function(){const getCookie=name=>{const value=`; ${document.cookie}`,parts=value.split(`; ${name}=`);if(2===parts.length)return parts.pop().split(";").shift()},getQueryParams=param=>{const params=new Proxy(new URLSearchParams(window.location.search),{get:(searchParams,prop)=>searchParams.get(prop)});return params[param]},setCookie=(name,value,days)=>{var expires="";if(days){var date=new Date;date.setTime(date.getTime()+24*days*60*60*1e3),expires="; expires="+date.toUTCString()}document.cookie=name+"="+(value||"")+expires+"; path=/"},updateCookieConsent=hide=>{if(!hide)return tuDebug&&console.log("UC: Showing consent widget"),tuPSLHide&&jQuery("#usercentrics-psl, .usercentrics-psl").show(),jQuery("div#usercentrics-root").show(),UC_UI.isConsentRequired()?UC_UI.showFirstLayer():UC_UI.closeCMP();tuDebug&&console.log("UC: Hiding consent widget"),tuPSLHide&&jQuery("#usercentrics-psl, .usercentrics-psl").hide(),jQuery("div#usercentrics-root").hide(),UC_UI.areAllConsentsAccepted()||UC_UI.acceptAllConsents().then(()=>{tuDebug&&console.log("UC: All consents have been accepted."),UC_UI.closeCMP().then(()=>{tuDebug&&console.log("UC: CMP Widget has been closed.")})})};if("undefined"==typeof UC_UI)return console.error("Usercentrics not loaded");const query_hide=""===getQueryParams("enable-usercentrics"),cookie_hide=getCookie("tu-geoip-hide");if(null==cookie_hide||tuDebug){tuDebug&&console.log("UC: Making AJAX Call");var data={action:"uc_geolocation_lookup",nonce:termageddon_usercentrics_obj.nonce};void 0!==termageddon_usercentrics_obj.location&&(data.location=termageddon_usercentrics_obj.location),jQuery.post(termageddon_usercentrics_obj.ajax_url,data).done((function(response){if(!response.success)return console.error("Unable to lookup location.",response.message||"");if(!response.data)return console.error("Location data was not provided.",response.data);const data=response.data;if(tuDebug&&console.log("TERMAGEDDON USERCENTRICS (AJAX)\nIP Address: "+data.ipAddress+"\nCity: "+(data.city||"Unknown")+"\nState: "+(data.state||"Unknown")+"\nCountry: "+(data.country||"Unknown")+"\n--\nLocated in EU?: "+(data.inEU?"Yes":"No")+"\nLocated in UK?: "+(data.inUK?"Yes":"No")+"\nLocated in Canada?: "+(data.inCanada?"Yes":"No")+"\nLocated in California?: "+(data.inCalifornia?"Yes":"No")+"\nLocated in Virginia?: "+(data.inVirginia?"Yes":"No")),query_hide)return tuDebug&&console.log("UC: Enabling due to query parameter override.","Showing Usercentrics"),updateCookieConsent(!1);setCookie("tu-geoip-hide",data.hide?"true":"false"),updateCookieConsent(data.hide)})).fail((function(response){console.error("Usercentrics: Invalid response returned. Showing widget as a default.",response),updateCookieConsent(!1)}))}else tuDebug&&console.log("UC: Cookie found.",(cookie_hide?"Showing":"Hiding")+" Usercentrics"),updateCookieConsent("true"===cookie_hide)})); -
termageddon-usercentrics/tags/1.4.1/termageddon-usercentrics.php
r3060868 r3104855 15 15 * Plugin Name: Termageddon + Usercentrics 16 16 * Description: Easily integrate the Usercentrics consent solution into your website while controlling visibility for logged in users and admins. 17 * Version: 1.4. 017 * Version: 1.4.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.4. 0' );36 define( 'TERMAGEDDON_COOKIE_VERSION', '1.4.1' ); 37 37 38 38 define( 'TERMAGEDDON_COOKIE_PLUGIN_PATH', dirname( __FILE__ ) );// No trailing slash. -
termageddon-usercentrics/trunk/README.txt
r3060868 r3104855 5 5 Requires at least: 3.0.1 6 6 Tested up to: 6.4.3 7 Stable tag: 1.4. 07 Stable tag: 1.4.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 27 27 == Changelog == 28 28 29 = 1.4.1 = 30 31 - [FIX] Fixed an issue where the plugin with Ajax Mode would bust cache for every request for some providers such as Pressable. 32 29 33 = 1.4.0 = 30 34 31 - [ADD] Added ability to disableplugin for troubleshooting to all visitors unless ?enable-usercentrics is added as a query parameter to the URL.35 - [ADD] Added ability to turn off plugin for troubleshooting to all visitors unless ?enable-usercentrics is added as a query parameter to the URL. 32 36 33 37 = 1.3.9 = -
termageddon-usercentrics/trunk/admin/class-termageddon-usercentrics-admin.php
r3060868 r3104855 505 505 array( 506 506 'label_for' => 'termageddon_usercentrics_disable_troubleshooting', 507 'description' => __( 'When enabled, this feature allows you to disablethe consent tool for all site visitors, however by adding <code>?enable-usercentrics</code> to the end of a URL, the consent tool will load, allowing you to troubleshoot any issues (or to reach out to Termageddon support to help assist with troubleshooting)', 'termageddon-usercentrics' ),507 'description' => __( 'When enabled, this feature allows you to turn off the consent tool for all site visitors, however by adding <code>?enable-usercentrics</code> to the end of a URL, the consent tool will load, allowing you to troubleshoot any issues (or to reach out to Termageddon support to help assist with troubleshooting)', 'termageddon-usercentrics' ), 508 508 ) 509 509 ); -
termageddon-usercentrics/trunk/includes/class-termageddon-usercentrics.php
r3060868 r3104855 267 267 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); 268 268 269 if ( self::is_geoip_enabled() && ! wp_doing_cron() ) {269 if ( self::is_geoip_enabled() && ! self::is_ajax_mode_enabled() && ! wp_doing_cron() ) { 270 270 $this->loader->add_action( 'init', $this, 'lookup_ip_address' ); 271 271 … … 421 421 // Check for fatal errors. 422 422 if ( self::check_for_download_errors() ) { 423 return false; 424 } 425 426 // If Geo IP is enabled, download. 427 if ( ! self::is_geoip_enabled() ) { 423 428 return false; 424 429 } … … 750 755 751 756 } 752 753 757 758 754 759 /** 755 760 * Returns whether disabled for troubleshooting mode is enabled and not in the query params … … 758 763 */ 759 764 public static function is_disabled_for_troubleshooting() { 760 $enabled = ( get_option( 'termageddon_usercentrics_disable_troubleshooting', false ) ? true : false ); 761 762 if ($enabled && !isset($_GET['enable-usercentrics'])) return true; 763 return false; 765 return ( get_option( 'termageddon_usercentrics_disable_troubleshooting', false ) ? true : false ); 766 767 } 768 769 770 /** 771 * Returns whether user wants to force enable via the query params. 772 * 773 * @return bool 774 */ 775 public static function is_enabled_via_get_override() { 776 return isset( $_GET['enable-usercentrics'] ); 764 777 765 778 } … … 834 847 $cookie_title = self::get_cookie_title(); 835 848 836 // Validate Database && download database if needed.837 self::verify_maxmind_database();838 839 // If Email is not in blacklist, try to calculate geo ip location.840 if ( '::1' !== $ip_address ) { 841 // Check for cached location via cookie, or check the geo ip database if no cookie found.842 if ( isset( $_COOKIE[ $cookie_title ] ) && ! self::is_debug_mode_enabled()) {843 @list('city' => $city, 'state' => $state, 'country' => $country) = json_decode( sanitize_text_field( wp_unslash( $_COOKIE[ $cookie_title ] ) ), true );844 } else{845 try {846 847 $reader = new Reader( self::get_maxmind_db_path() );848 849 $record = $reader->City( $ip_address);850 851 if ( isset( $record->city->names ) && isset( $record->city->names['en'] ) ) {852 $city = $record->city->names['en']; 853 }854 if ( isset( $record->subdivisions[0] ) && isset( $record->subdivisions[0]->names ) && isset( $record->subdivisions[0]->names['en'] ) ) {855 $state = $record->subdivisions[0]->names['en'];856 }857 if ( isset( $record->country->names ) && isset( $record->country->names['en'] ) ) {858 $country = $record->country->names['en'];859 }860 861 // If able to, set cookie to allow future page loads to simply use the cookie for processing.862 if ( ! headers_sent() ) { 863 setcookie(864 $cookie_title,865 wp_json_encode(849 // If Geo IP is enabled, download. 850 if ( self::is_geoip_enabled() ) { 851 // Validate Database && download database if needed. 852 self::verify_maxmind_database(); 853 854 // If Email is not in blacklist, try to calculate geo ip location. 855 if ( '::1' !== $ip_address ) { 856 // Check for cached location via cookie, or check the geo ip database if no cookie found. 857 if ( isset( $_COOKIE[ $cookie_title ] ) && ! self::is_debug_mode_enabled() ) { 858 @list('city' => $city, 'state' => $state, 'country' => $country) = json_decode( sanitize_text_field( wp_unslash( $_COOKIE[ $cookie_title ] ) ), true ); 859 } else { 860 try { 861 862 $reader = new Reader( self::get_maxmind_db_path() ); 863 864 $record = $reader->City( $ip_address ); 865 866 if ( isset( $record->city->names ) && isset( $record->city->names['en'] ) ) { 867 $city = $record->city->names['en']; 868 } 869 if ( isset( $record->subdivisions[0] ) && isset( $record->subdivisions[0]->names ) && isset( $record->subdivisions[0]->names['en'] ) ) { 870 $state = $record->subdivisions[0]->names['en']; 871 } 872 if ( isset( $record->country->names ) && isset( $record->country->names['en'] ) ) { 873 $country = $record->country->names['en']; 874 } 875 876 // If able to, set cookie to allow future page loads to simply use the cookie for processing. 877 if ( ! headers_sent() && ! isset( $_COOKIE[ $cookie_title ] ) ) { 878 $cookie_value = wp_json_encode( 866 879 array( 867 880 'city' => $city, … … 869 882 'country' => $country, 870 883 ) 871 ), 872 0, 873 COOKIEPATH, 874 COOKIE_DOMAIN 875 ); 876 } 877 } catch ( \Throwable $th ) { 878 // Error with GEO IP. 879 // Display it IF debug via GET is enabled and administrator. 880 if ( current_user_can( 'administrator' ) || self::is_debug_mode_enabled() ) { 881 self::debug( 'Error Calculating Location', $th->getMessage() ); 884 ); 885 886 setcookie( 887 $cookie_title, 888 $cookie_value, 889 0, 890 COOKIEPATH, 891 COOKIE_DOMAIN 892 ); 893 $_COOKIE[ $cookie_title ] = $cookie_value; 894 } 895 } catch ( \Throwable $th ) { 896 // Error with GEO IP. 897 // Display it IF debug via GET is enabled and administrator. 898 if ( current_user_can( 'administrator' ) || self::is_debug_mode_enabled() ) { 899 self::debug( 'Error Calculating Location', $th->getMessage() ); 900 } 882 901 } 883 902 } -
termageddon-usercentrics/trunk/languages/termageddon-usercentrics.pot
r3060868 r3104855 286 286 #: admin/class-termageddon-usercentrics-admin.php:507 287 287 msgid "" 288 "When enabled, this feature allows you to disablethe consent tool for all "288 "When enabled, this feature allows you to turn off the consent tool for all " 289 289 "site visitors, however by adding <code>?enable-usercentrics</code> to the " 290 290 "end of a URL, the consent tool will load, allowing you to troubleshoot any " -
termageddon-usercentrics/trunk/public/class-termageddon-usercentrics-public.php
r3060868 r3104855 120 120 echo wp_kses( $script, Termageddon_Usercentrics::ALLOWED_HTML ); 121 121 echo '<!-- END TERMAGEDDON + USERCENTRICS -->'; 122 } 123 124 /** 125 * Display debug information to console if applicable 126 * 127 * @return void 128 */ 129 public function debug_display() { 130 if ( ( Termageddon_Usercentrics::is_geoip_enabled() || Termageddon_Usercentrics::is_debug_mode_enabled() ) 131 && 132 ! Termageddon_Usercentrics::is_ajax_mode_enabled() 133 ) { 134 list('city' => $city, 'state' => $state, 'country' => $country) = Termageddon_Usercentrics::lookup_ip_address(); 135 136 // Output debug message to console. 137 Termageddon_Usercentrics::debug( 138 'IP Address: ' . Termageddon_Usercentrics::get_processed_ip_address(), 139 'City: ' . ( $city ?? 'Unknown' ), 140 'State: ' . ( $state ?? 'Unknown' ), 141 'Country: ' . ( $country ?? 'Unknown' ), 142 '--', 143 'Located in EU?: ' . ( Termageddon_Usercentrics::is_located_in_eu() ? 'Yes' : 'No' ), 144 'Located in UK?: ' . ( Termageddon_Usercentrics::is_located_in_uk() ? 'Yes' : 'No' ), 145 'Located in Canada?: ' . ( Termageddon_Usercentrics::is_located_in_canada() ? 'Yes' : 'No' ), 146 'Located in California?: ' . ( Termageddon_Usercentrics::is_located_in_california() ? 'Yes' : 'No' ), 147 'Located in Virginia?: ' . ( Termageddon_Usercentrics::is_located_in_virginia() ? 'Yes' : 'No' ), 148 '--', 149 'Geo-Location Mode?: ' . ( Termageddon_Usercentrics::is_geoip_enabled() ? 'Yes' : 'No' ), 150 'AJAX Mode?: ' . ( Termageddon_Usercentrics::is_ajax_mode_enabled() ? 'Yes' : 'No' ), 151 ); 152 } 122 153 } 123 154 … … 155 186 } 156 187 157 // Check for Disable for troubleshooting while validating query param. 158 if (Termageddon_Usercentrics::is_disabled_for_troubleshooting()) { 159 return self::disable_termageddon_script(); 160 } 161 162 // Debug Display to identify locations. 163 if ( ( Termageddon_Usercentrics::is_geoip_enabled() || Termageddon_Usercentrics::is_debug_mode_enabled() ) 164 && 165 ! Termageddon_Usercentrics::is_ajax_mode_enabled() 166 ) { 167 list('city' => $city, 'state' => $state, 'country' => $country) = Termageddon_Usercentrics::lookup_ip_address(); 168 169 // Output debug message to console. 170 Termageddon_Usercentrics::debug( 171 'IP Address: ' . Termageddon_Usercentrics::get_processed_ip_address(), 172 'City: ' . ( $city ?? 'Unknown' ), 173 'State: ' . ( $state ?? 'Unknown' ), 174 'Country: ' . ( $country ?? 'Unknown' ), 175 '--', 176 'Located in EU?: ' . ( Termageddon_Usercentrics::is_located_in_eu() ? 'Yes' : 'No' ), 177 'Located in UK?: ' . ( Termageddon_Usercentrics::is_located_in_uk() ? 'Yes' : 'No' ), 178 'Located in Canada?: ' . ( Termageddon_Usercentrics::is_located_in_canada() ? 'Yes' : 'No' ), 179 'Located in California?: ' . ( Termageddon_Usercentrics::is_located_in_california() ? 'Yes' : 'No' ), 180 'Located in Virginia?: ' . ( Termageddon_Usercentrics::is_located_in_virginia() ? 'Yes' : 'No' ), 181 '--', 182 'Geo-Location Mode?: ' . ( Termageddon_Usercentrics::is_geoip_enabled() ? 'Yes' : 'No' ), 183 'AJAX Mode?: ' . ( Termageddon_Usercentrics::is_ajax_mode_enabled() ? 'Yes' : 'No' ), 184 ); 185 } 186 187 $disable_on_logged_in = get_option( 'termageddon_usercentrics_disable_logged_in', false ) ? true : false; 188 if ( $disable_on_logged_in && is_user_logged_in() ) { 189 return self::disable_termageddon_script(); 190 } 191 192 $disable_on_editor = get_option( 'termageddon_usercentrics_disable_editor', false ) ? true : false; 193 if ( $disable_on_editor && current_user_can( 'editor' ) ) { 194 return self::disable_termageddon_script(); 195 } 196 197 $disable_on_admin = get_option( 'termageddon_usercentrics_disable_admin', false ) ? true : false; 198 if ( $disable_on_admin && current_user_can( 'administrator' ) ) { 199 return self::disable_termageddon_script(); 200 } 201 202 if ( Termageddon_Usercentrics::is_geoip_enabled() && ! Termageddon_Usercentrics::is_ajax_mode_enabled() && Termageddon_Usercentrics::should_hide_due_to_location() ) { 203 return self::disable_termageddon_script(); 188 // If forcibly enabled, bypass individual detections. 189 if ( ! Termageddon_Usercentrics::is_enabled_via_get_override() ) { 190 // Check for Disable for troubleshooting. 191 if ( Termageddon_Usercentrics::is_disabled_for_troubleshooting() ) { 192 return self::disable_termageddon_script(); 193 } 194 195 // Debug display to console if applicable. 196 self::debug_display(); 197 198 // Check for individual disable detections. 199 $disable_on_logged_in = get_option( 'termageddon_usercentrics_disable_logged_in', false ) ? true : false; 200 if ( $disable_on_logged_in && is_user_logged_in() ) { 201 return self::disable_termageddon_script(); 202 } 203 204 $disable_on_editor = get_option( 'termageddon_usercentrics_disable_editor', false ) ? true : false; 205 if ( $disable_on_editor && current_user_can( 'editor' ) ) { 206 return self::disable_termageddon_script(); 207 } 208 209 $disable_on_admin = get_option( 'termageddon_usercentrics_disable_admin', false ) ? true : false; 210 if ( $disable_on_admin && current_user_can( 'administrator' ) ) { 211 return self::disable_termageddon_script(); 212 } 213 214 if ( Termageddon_Usercentrics::is_geoip_enabled() && ! Termageddon_Usercentrics::is_ajax_mode_enabled() && Termageddon_Usercentrics::should_hide_due_to_location() ) { 215 return self::disable_termageddon_script(); 216 } 217 } else { 218 // Debug display to console if applicable. 219 self::debug_display(); 204 220 } 205 221 -
termageddon-usercentrics/trunk/public/js/termageddon-usercentrics-ajax.js
r2890756 r3104855 10 10 const parts = value.split(`; ${name}=`); 11 11 if (parts.length === 2) return parts.pop().split(";").shift(); 12 }; 13 14 const getQueryParams = (param) => { 15 const params = new Proxy(new URLSearchParams(window.location.search), { 16 get: (searchParams, prop) => searchParams.get(prop), 17 }); 18 19 return params[param]; 12 20 }; 13 21 … … 57 65 if (typeof UC_UI === "undefined") 58 66 return console.error("Usercentrics not loaded"); 67 68 //Check query variable from browser 69 const query_hide = 70 getQueryParams("enable-usercentrics") === "" ? true : false; 59 71 60 72 //Check for local cookie to use instead of calling. … … 133 145 } 134 146 147 if (query_hide) { 148 if (tuDebug) 149 console.log( 150 "UC: Enabling due to query parameter override.", 151 "Showing Usercentrics" 152 ); 153 return updateCookieConsent(false); 154 } 155 135 156 //If you are not supposed to be hiding, show the CMP. 136 157 setCookie(tuCookieHideName, data.hide ? "true" : "false"); -
termageddon-usercentrics/trunk/public/js/termageddon-usercentrics-ajax.min.js
r2890756 r3104855 1 const tuCookieHideName="tu-geoip-hide",tuDebug="true"===termageddon_usercentrics_obj.debug,tuPSLHide="true"===termageddon_usercentrics_obj.psl_hide;tuDebug&&console.log("UC: AJAX script initialized"),window.addEventListener("UC_UI_INITIALIZED",(function(){const getCookie=name=>{const value=`; ${document.cookie}`,parts=value.split(`; ${name}=`);if(2===parts.length)return parts.pop().split(";").shift()}, setCookie=(name,value,days)=>{var expires="";if(days){var date=new Date;date.setTime(date.getTime()+24*days*60*60*1e3),expires="; expires="+date.toUTCString()}document.cookie=name+"="+(value||"")+expires+"; path=/"},updateCookieConsent=hide=>{if(!hide)return tuDebug&&console.log("UC: Showing consent widget"),tuPSLHide&&jQuery("#usercentrics-psl, .usercentrics-psl").show(),jQuery("div#usercentrics-root").show(),UC_UI.isConsentRequired()?UC_UI.showFirstLayer():UC_UI.closeCMP();tuDebug&&console.log("UC: Hiding consent widget"),tuPSLHide&&jQuery("#usercentrics-psl, .usercentrics-psl").hide(),jQuery("div#usercentrics-root").hide(),UC_UI.areAllConsentsAccepted()||UC_UI.acceptAllConsents().then(()=>{tuDebug&&console.log("UC: All consents have been accepted."),UC_UI.closeCMP().then(()=>{tuDebug&&console.log("UC: CMP Widget has been closed.")})})};if("undefined"==typeof UC_UI)return console.error("Usercentrics not loaded");const cookie_hide=getCookie("tu-geoip-hide");if(null==cookie_hide||tuDebug){tuDebug&&console.log("UC: Making AJAX Call");var data={action:"uc_geolocation_lookup",nonce:termageddon_usercentrics_obj.nonce};void 0!==termageddon_usercentrics_obj.location&&(data.location=termageddon_usercentrics_obj.location),jQuery.post(termageddon_usercentrics_obj.ajax_url,data).done((function(response){if(!response.success)return console.error("Unable to lookup location.",response.message||"");if(!response.data)return console.error("Location data was not provided.",response.data);const data=response.data;tuDebug&&console.log("TERMAGEDDON USERCENTRICS (AJAX)\nIP Address: "+data.ipAddress+"\nCity: "+(data.city||"Unknown")+"\nState: "+(data.state||"Unknown")+"\nCountry: "+(data.country||"Unknown")+"\n--\nLocated in EU?: "+(data.inEU?"Yes":"No")+"\nLocated in UK?: "+(data.inUK?"Yes":"No")+"\nLocated in Canada?: "+(data.inCanada?"Yes":"No")+"\nLocated in California?: "+(data.inCalifornia?"Yes":"No")+"\nLocated in Virginia?: "+(data.inVirginia?"Yes":"No")),setCookie("tu-geoip-hide",data.hide?"true":"false"),updateCookieConsent(data.hide)})).fail((function(response){console.error("Usercentrics: Invalid response returned. Showing widget as a default.",response),updateCookieConsent(!1)}))}else tuDebug&&console.log("UC: Cookie found.",(cookie_hide?"Showing":"Hiding")+" Usercentrics"),updateCookieConsent("true"===cookie_hide)}));1 const tuCookieHideName="tu-geoip-hide",tuDebug="true"===termageddon_usercentrics_obj.debug,tuPSLHide="true"===termageddon_usercentrics_obj.psl_hide;tuDebug&&console.log("UC: AJAX script initialized"),window.addEventListener("UC_UI_INITIALIZED",(function(){const getCookie=name=>{const value=`; ${document.cookie}`,parts=value.split(`; ${name}=`);if(2===parts.length)return parts.pop().split(";").shift()},getQueryParams=param=>{const params=new Proxy(new URLSearchParams(window.location.search),{get:(searchParams,prop)=>searchParams.get(prop)});return params[param]},setCookie=(name,value,days)=>{var expires="";if(days){var date=new Date;date.setTime(date.getTime()+24*days*60*60*1e3),expires="; expires="+date.toUTCString()}document.cookie=name+"="+(value||"")+expires+"; path=/"},updateCookieConsent=hide=>{if(!hide)return tuDebug&&console.log("UC: Showing consent widget"),tuPSLHide&&jQuery("#usercentrics-psl, .usercentrics-psl").show(),jQuery("div#usercentrics-root").show(),UC_UI.isConsentRequired()?UC_UI.showFirstLayer():UC_UI.closeCMP();tuDebug&&console.log("UC: Hiding consent widget"),tuPSLHide&&jQuery("#usercentrics-psl, .usercentrics-psl").hide(),jQuery("div#usercentrics-root").hide(),UC_UI.areAllConsentsAccepted()||UC_UI.acceptAllConsents().then(()=>{tuDebug&&console.log("UC: All consents have been accepted."),UC_UI.closeCMP().then(()=>{tuDebug&&console.log("UC: CMP Widget has been closed.")})})};if("undefined"==typeof UC_UI)return console.error("Usercentrics not loaded");const query_hide=""===getQueryParams("enable-usercentrics"),cookie_hide=getCookie("tu-geoip-hide");if(null==cookie_hide||tuDebug){tuDebug&&console.log("UC: Making AJAX Call");var data={action:"uc_geolocation_lookup",nonce:termageddon_usercentrics_obj.nonce};void 0!==termageddon_usercentrics_obj.location&&(data.location=termageddon_usercentrics_obj.location),jQuery.post(termageddon_usercentrics_obj.ajax_url,data).done((function(response){if(!response.success)return console.error("Unable to lookup location.",response.message||"");if(!response.data)return console.error("Location data was not provided.",response.data);const data=response.data;if(tuDebug&&console.log("TERMAGEDDON USERCENTRICS (AJAX)\nIP Address: "+data.ipAddress+"\nCity: "+(data.city||"Unknown")+"\nState: "+(data.state||"Unknown")+"\nCountry: "+(data.country||"Unknown")+"\n--\nLocated in EU?: "+(data.inEU?"Yes":"No")+"\nLocated in UK?: "+(data.inUK?"Yes":"No")+"\nLocated in Canada?: "+(data.inCanada?"Yes":"No")+"\nLocated in California?: "+(data.inCalifornia?"Yes":"No")+"\nLocated in Virginia?: "+(data.inVirginia?"Yes":"No")),query_hide)return tuDebug&&console.log("UC: Enabling due to query parameter override.","Showing Usercentrics"),updateCookieConsent(!1);setCookie("tu-geoip-hide",data.hide?"true":"false"),updateCookieConsent(data.hide)})).fail((function(response){console.error("Usercentrics: Invalid response returned. Showing widget as a default.",response),updateCookieConsent(!1)}))}else tuDebug&&console.log("UC: Cookie found.",(cookie_hide?"Showing":"Hiding")+" Usercentrics"),updateCookieConsent("true"===cookie_hide)})); -
termageddon-usercentrics/trunk/termageddon-usercentrics.php
r3060868 r3104855 15 15 * Plugin Name: Termageddon + Usercentrics 16 16 * Description: Easily integrate the Usercentrics consent solution into your website while controlling visibility for logged in users and admins. 17 * Version: 1.4. 017 * Version: 1.4.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.4. 0' );36 define( 'TERMAGEDDON_COOKIE_VERSION', '1.4.1' ); 37 37 38 38 define( 'TERMAGEDDON_COOKIE_PLUGIN_PATH', dirname( __FILE__ ) );// No trailing slash.
Note: See TracChangeset
for help on using the changeset viewer.