Changeset 3444237
- Timestamp:
- 01/21/2026 03:52:33 PM (4 weeks ago)
- Location:
- convertybot
- Files:
-
- 14 edited
-
tags/1.0.15/assets/js/admin.js (modified) (1 diff)
-
tags/1.0.15/convertybot.php (modified) (1 diff)
-
tags/1.0.15/includes/class-admin.php (modified) (2 diffs)
-
tags/1.0.15/includes/class-consent-banner.php (modified) (3 diffs)
-
tags/1.0.15/includes/class-user-tracking-enhanced.php (modified) (9 diffs)
-
tags/1.0.15/readme.txt (modified) (1 diff)
-
tags/1.0.15/templates/admin/configuration.php (modified) (1 diff)
-
trunk/assets/js/admin.js (modified) (1 diff)
-
trunk/convertybot.php (modified) (1 diff)
-
trunk/includes/class-admin.php (modified) (2 diffs)
-
trunk/includes/class-consent-banner.php (modified) (3 diffs)
-
trunk/includes/class-user-tracking-enhanced.php (modified) (9 diffs)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/templates/admin/configuration.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
convertybot/tags/1.0.15/assets/js/admin.js
r3443884 r3444237 190 190 191 191 // Add event handlers for toggle changes to provide immediate feedback 192 $('#chatbot_enabled, #auto_open, #engagement_tracking, #s ound_enabled, #show_timestamps, #show_typing_indicator, #conversation_persistence, #emoji_reactions, #show_online_status, #response_suggestions').on('change', function() {192 $('#chatbot_enabled, #auto_open, #engagement_tracking, #show_cookie_consent, #sound_enabled, #show_timestamps, #show_typing_indicator, #conversation_persistence, #emoji_reactions, #show_online_status, #response_suggestions').on('change', function() { 193 193 updateToggleStates(); 194 194 }); -
convertybot/tags/1.0.15/convertybot.php
r3443884 r3444237 195 195 'show_on_pages' => array('shop', 'product', 'cart'), 196 196 'engagement_tracking' => true, 197 'show_cookie_consent' => false, // Disable by default (tracking with implied consent) 197 198 'setup_completed' => false, 198 199 'last_sync' => null, -
convertybot/tags/1.0.15/includes/class-admin.php
r3443884 r3444237 177 177 // Boolean options 178 178 $boolean_keys = array( 179 'chatbot_enabled', 'auto_open', 'engagement_tracking', 's ound_enabled',180 's how_timestamps', 'show_typing_indicator', 'conversation_persistence',179 'chatbot_enabled', 'auto_open', 'engagement_tracking', 'show_cookie_consent', 180 'sound_enabled', 'show_timestamps', 'show_typing_indicator', 'conversation_persistence', 181 181 'emoji_reactions', 'show_online_status', 'response_suggestions' 182 182 ); … … 2079 2079 } 2080 2080 2081 if (isset($_POST['engagement_tracking'])) { 2082 $options['engagement_tracking'] = (bool) $_POST['engagement_tracking']; 2083 } 2081 // Handle engagement_tracking checkbox (presence means true, absence means false) 2082 $options['engagement_tracking'] = isset($_POST['engagement_tracking']) && $_POST['engagement_tracking'] === '1'; 2083 2084 // Handle show_cookie_consent option (checkbox - presence means true) 2085 $options['show_cookie_consent'] = isset($_POST['show_cookie_consent']) && $_POST['show_cookie_consent'] === '1'; 2084 2086 2085 2087 // Save options -
convertybot/tags/1.0.15/includes/class-consent-banner.php
r3443884 r3444237 47 47 48 48 public function enqueue_assets() { 49 // Skip if banner is disabled in settings 50 if (!$this->is_banner_enabled()) { 51 return; 52 } 53 49 54 // Skip if consent already given 50 55 if ($this->has_consent_cookie()) { … … 77 82 78 83 public function render_consent_banner() { 84 // Skip if banner is disabled in settings 85 if (!$this->is_banner_enabled()) { 86 return; 87 } 88 79 89 // Skip if consent already given 80 90 if ($this->has_consent_cookie()) { … … 255 265 } 256 266 267 /** 268 * Check if the cookie consent banner should be displayed 269 * @return bool 270 */ 271 private function is_banner_enabled() { 272 $options = get_option('convertybot_options', array()); 273 return isset($options['show_cookie_consent']) && $options['show_cookie_consent'] === true; 274 } 275 276 /** 277 * Check if consent should be implied (banner disabled = automatic consent) 278 * @return bool 279 */ 280 public function is_implied_consent() { 281 return !$this->is_banner_enabled(); 282 } 283 257 284 private function get_consent_data() { 285 // If banner is disabled, return implied consent (all tracking allowed) 286 if ($this->is_implied_consent()) { 287 return array( 288 'essential' => true, 289 'functional' => true, 290 'analytics' => true, 291 'marketing' => true, 292 'personalization' => true, 293 'advertising' => false, // Keep advertising off by default 294 'timestamp' => gmdate('Y-m-d\TH:i:s\Z'), 295 'version' => '1.0.0', 296 'implied' => true // Flag to indicate this is implied consent 297 ); 298 } 299 258 300 if (isset($_COOKIE['convertybot_consent'])) { 259 301 return json_decode(sanitize_text_field(wp_unslash($_COOKIE['convertybot_consent'])), true); -
convertybot/tags/1.0.15/includes/class-user-tracking-enhanced.php
r3443884 r3444237 177 177 // Session Management 178 178 public function handle_create_session() { 179 // Check if tracking is enabled 180 if (!$this->is_tracking_enabled()) { 181 wp_send_json_error(esc_html__('Tracking is disabled', 'convertybot')); 182 return; 183 } 184 179 185 // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing 180 186 if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) { … … 182 188 return; 183 189 } 184 190 185 191 $session_data = $this->sanitize_session_data($_POST); 186 192 $response = $this->create_tracking_session($session_data); 187 193 188 194 if ($response) { 189 195 wp_send_json_success($response); … … 219 225 // Event Tracking 220 226 public function handle_track_events_batch() { 227 // Check if tracking is enabled 228 if (!$this->is_tracking_enabled()) { 229 wp_send_json_error(esc_html__('Tracking is disabled', 'convertybot')); 230 return; 231 } 232 221 233 // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing 222 234 if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) { … … 260 272 // Product Interaction Tracking 261 273 public function handle_track_product_interaction() { 274 // Check if tracking is enabled 275 if (!$this->is_tracking_enabled()) { 276 wp_send_json_error(esc_html__('Tracking is disabled', 'convertybot')); 277 return; 278 } 279 262 280 // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing 263 281 if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) { … … 300 318 // Conversion Tracking 301 319 public function handle_track_conversion() { 320 // Check if tracking is enabled 321 if (!$this->is_tracking_enabled()) { 322 wp_send_json_error(esc_html__('Tracking is disabled', 'convertybot')); 323 return; 324 } 325 302 326 // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing 303 327 if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) { … … 383 407 // Real-time Tracking 384 408 public function handle_realtime_start() { 409 // Check if tracking is enabled 410 if (!$this->is_tracking_enabled()) { 411 wp_send_json_error(esc_html__('Tracking is disabled', 'convertybot')); 412 return; 413 } 414 385 415 // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing 386 416 if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) { … … 400 430 401 431 public function handle_session_end() { 432 // Check if tracking is enabled 433 if (!$this->is_tracking_enabled()) { 434 wp_send_json_error(esc_html__('Tracking is disabled', 'convertybot')); 435 return; 436 } 437 402 438 // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing 403 439 if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) { … … 535 571 536 572 private function is_tracking_enabled() { 537 return $this->tracking_enabled && get_option('convertybot_tracking_enabled', true); 573 // Check the engagement_tracking option from convertybot_options 574 $options = get_option('convertybot_options', array()); 575 $engagement_tracking = isset($options['engagement_tracking']) ? $options['engagement_tracking'] : true; 576 return $this->tracking_enabled && $engagement_tracking; 538 577 } 539 578 … … 731 770 732 771 // Privacy Consent Methods 772 773 /** 774 * Check if cookie consent banner is enabled 775 * When disabled, we use implied consent for tracking 776 */ 777 private function is_consent_banner_enabled() { 778 $options = get_option('convertybot_options', array()); 779 return isset($options['show_cookie_consent']) && $options['show_cookie_consent'] === true; 780 } 781 733 782 private function has_user_consent() { 783 // If banner is disabled, use implied consent 784 if (!$this->is_consent_banner_enabled()) { 785 return true; 786 } 787 788 // Check cookie first (for guests) 789 if (isset($_COOKIE['convertybot_consent'])) { 790 $consent_data = json_decode(sanitize_text_field(wp_unslash($_COOKIE['convertybot_consent'])), true); 791 if (is_array($consent_data) && !empty($consent_data)) { 792 return true; // They made a choice 793 } 794 } 795 796 // For logged-in users, check user meta 734 797 return get_user_meta(get_current_user_id(), 'convertybot_consent', true) === 'yes'; 735 798 } 736 799 737 800 private function has_functional_consent() { 801 // If banner is disabled, use implied consent 802 if (!$this->is_consent_banner_enabled()) { 803 return true; 804 } 738 805 return get_user_meta(get_current_user_id(), 'convertybot_functional_consent', true) !== 'no'; 739 806 } 740 807 741 808 private function has_analytics_consent() { 742 // For guests, allow tracking by default (they can opt-out via DNT) 809 // If banner is disabled, use implied consent (automatic tracking) 810 if (!$this->is_consent_banner_enabled()) { 811 return true; 812 } 813 814 // Check cookie consent first (for guests) 815 if (isset($_COOKIE['convertybot_consent'])) { 816 $consent_data = json_decode(sanitize_text_field(wp_unslash($_COOKIE['convertybot_consent'])), true); 817 if (is_array($consent_data) && isset($consent_data['analytics'])) { 818 return $consent_data['analytics'] === true; 819 } 820 } 821 822 // For guests without cookie, deny tracking when banner is enabled but not yet accepted 743 823 if (!is_user_logged_in()) { 744 return true; 745 } 746 // For logged-in users, check their consent preference (default to yes) 824 return false; // Must accept banner first 825 } 826 827 // For logged-in users, check their consent preference 747 828 $consent = get_user_meta(get_current_user_id(), 'convertybot_analytics_consent', true); 748 829 return empty($consent) || $consent === 'yes'; -
convertybot/tags/1.0.15/readme.txt
r3443895 r3444237 6 6 Tested up to: 6.9 7 7 Requires PHP: 7.2 8 Stable tag: 1.0.1 58 Stable tag: 1.0.14 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html -
convertybot/tags/1.0.15/templates/admin/configuration.php
r3443884 r3444237 94 94 </label> 95 95 <p class="description"><?php esc_html_e('Track user interactions and engagement for analytics.', 'convertybot'); ?></p> 96 </td> 97 </tr> 98 99 <tr> 100 <th scope="row"> 101 <label for="show_cookie_consent"><?php esc_html_e('Show Cookie Consent Banner', 'convertybot'); ?></label> 102 </th> 103 <td> 104 <label class="switch"> 105 <input type="checkbox" id="show_cookie_consent" name="show_cookie_consent" value="1" <?php checked($options['show_cookie_consent'] ?? false); ?>> 106 <span class="slider"></span> 107 </label> 108 <p class="description"> 109 <?php esc_html_e('Display ConvertyBot\'s cookie consent banner to visitors. Disable this if your store already has a cookie consent plugin.', 'convertybot'); ?> 110 <br> 111 <strong><?php esc_html_e('When disabled:', 'convertybot'); ?></strong> <?php esc_html_e('Tracking starts automatically (implied consent).', 'convertybot'); ?> 112 <br> 113 <strong><?php esc_html_e('When enabled:', 'convertybot'); ?></strong> <?php esc_html_e('Tracking waits for visitor consent via the banner.', 'convertybot'); ?> 114 </p> 96 115 </td> 97 116 </tr> -
convertybot/trunk/assets/js/admin.js
r3437100 r3444237 190 190 191 191 // Add event handlers for toggle changes to provide immediate feedback 192 $('#chatbot_enabled, #auto_open, #engagement_tracking, #s ound_enabled, #show_timestamps, #show_typing_indicator, #conversation_persistence, #emoji_reactions, #show_online_status, #response_suggestions').on('change', function() {192 $('#chatbot_enabled, #auto_open, #engagement_tracking, #show_cookie_consent, #sound_enabled, #show_timestamps, #show_typing_indicator, #conversation_persistence, #emoji_reactions, #show_online_status, #response_suggestions').on('change', function() { 193 193 updateToggleStates(); 194 194 }); -
convertybot/trunk/convertybot.php
r3443877 r3444237 195 195 'show_on_pages' => array('shop', 'product', 'cart'), 196 196 'engagement_tracking' => true, 197 'show_cookie_consent' => false, // Disable by default (tracking with implied consent) 197 198 'setup_completed' => false, 198 199 'last_sync' => null, -
convertybot/trunk/includes/class-admin.php
r3437112 r3444237 177 177 // Boolean options 178 178 $boolean_keys = array( 179 'chatbot_enabled', 'auto_open', 'engagement_tracking', 's ound_enabled',180 's how_timestamps', 'show_typing_indicator', 'conversation_persistence',179 'chatbot_enabled', 'auto_open', 'engagement_tracking', 'show_cookie_consent', 180 'sound_enabled', 'show_timestamps', 'show_typing_indicator', 'conversation_persistence', 181 181 'emoji_reactions', 'show_online_status', 'response_suggestions' 182 182 ); … … 2079 2079 } 2080 2080 2081 if (isset($_POST['engagement_tracking'])) { 2082 $options['engagement_tracking'] = (bool) $_POST['engagement_tracking']; 2083 } 2081 // Handle engagement_tracking checkbox (presence means true, absence means false) 2082 $options['engagement_tracking'] = isset($_POST['engagement_tracking']) && $_POST['engagement_tracking'] === '1'; 2083 2084 // Handle show_cookie_consent option (checkbox - presence means true) 2085 $options['show_cookie_consent'] = isset($_POST['show_cookie_consent']) && $_POST['show_cookie_consent'] === '1'; 2084 2086 2085 2087 // Save options -
convertybot/trunk/includes/class-consent-banner.php
r3437100 r3444237 47 47 48 48 public function enqueue_assets() { 49 // Skip if banner is disabled in settings 50 if (!$this->is_banner_enabled()) { 51 return; 52 } 53 49 54 // Skip if consent already given 50 55 if ($this->has_consent_cookie()) { … … 77 82 78 83 public function render_consent_banner() { 84 // Skip if banner is disabled in settings 85 if (!$this->is_banner_enabled()) { 86 return; 87 } 88 79 89 // Skip if consent already given 80 90 if ($this->has_consent_cookie()) { … … 255 265 } 256 266 267 /** 268 * Check if the cookie consent banner should be displayed 269 * @return bool 270 */ 271 private function is_banner_enabled() { 272 $options = get_option('convertybot_options', array()); 273 return isset($options['show_cookie_consent']) && $options['show_cookie_consent'] === true; 274 } 275 276 /** 277 * Check if consent should be implied (banner disabled = automatic consent) 278 * @return bool 279 */ 280 public function is_implied_consent() { 281 return !$this->is_banner_enabled(); 282 } 283 257 284 private function get_consent_data() { 285 // If banner is disabled, return implied consent (all tracking allowed) 286 if ($this->is_implied_consent()) { 287 return array( 288 'essential' => true, 289 'functional' => true, 290 'analytics' => true, 291 'marketing' => true, 292 'personalization' => true, 293 'advertising' => false, // Keep advertising off by default 294 'timestamp' => gmdate('Y-m-d\TH:i:s\Z'), 295 'version' => '1.0.0', 296 'implied' => true // Flag to indicate this is implied consent 297 ); 298 } 299 258 300 if (isset($_COOKIE['convertybot_consent'])) { 259 301 return json_decode(sanitize_text_field(wp_unslash($_COOKIE['convertybot_consent'])), true); -
convertybot/trunk/includes/class-user-tracking-enhanced.php
r3437100 r3444237 177 177 // Session Management 178 178 public function handle_create_session() { 179 // Check if tracking is enabled 180 if (!$this->is_tracking_enabled()) { 181 wp_send_json_error(esc_html__('Tracking is disabled', 'convertybot')); 182 return; 183 } 184 179 185 // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing 180 186 if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) { … … 182 188 return; 183 189 } 184 190 185 191 $session_data = $this->sanitize_session_data($_POST); 186 192 $response = $this->create_tracking_session($session_data); 187 193 188 194 if ($response) { 189 195 wp_send_json_success($response); … … 219 225 // Event Tracking 220 226 public function handle_track_events_batch() { 227 // Check if tracking is enabled 228 if (!$this->is_tracking_enabled()) { 229 wp_send_json_error(esc_html__('Tracking is disabled', 'convertybot')); 230 return; 231 } 232 221 233 // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing 222 234 if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) { … … 260 272 // Product Interaction Tracking 261 273 public function handle_track_product_interaction() { 274 // Check if tracking is enabled 275 if (!$this->is_tracking_enabled()) { 276 wp_send_json_error(esc_html__('Tracking is disabled', 'convertybot')); 277 return; 278 } 279 262 280 // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing 263 281 if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) { … … 300 318 // Conversion Tracking 301 319 public function handle_track_conversion() { 320 // Check if tracking is enabled 321 if (!$this->is_tracking_enabled()) { 322 wp_send_json_error(esc_html__('Tracking is disabled', 'convertybot')); 323 return; 324 } 325 302 326 // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing 303 327 if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) { … … 383 407 // Real-time Tracking 384 408 public function handle_realtime_start() { 409 // Check if tracking is enabled 410 if (!$this->is_tracking_enabled()) { 411 wp_send_json_error(esc_html__('Tracking is disabled', 'convertybot')); 412 return; 413 } 414 385 415 // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing 386 416 if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) { … … 400 430 401 431 public function handle_session_end() { 432 // Check if tracking is enabled 433 if (!$this->is_tracking_enabled()) { 434 wp_send_json_error(esc_html__('Tracking is disabled', 'convertybot')); 435 return; 436 } 437 402 438 // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing 403 439 if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) { … … 535 571 536 572 private function is_tracking_enabled() { 537 return $this->tracking_enabled && get_option('convertybot_tracking_enabled', true); 573 // Check the engagement_tracking option from convertybot_options 574 $options = get_option('convertybot_options', array()); 575 $engagement_tracking = isset($options['engagement_tracking']) ? $options['engagement_tracking'] : true; 576 return $this->tracking_enabled && $engagement_tracking; 538 577 } 539 578 … … 731 770 732 771 // Privacy Consent Methods 772 773 /** 774 * Check if cookie consent banner is enabled 775 * When disabled, we use implied consent for tracking 776 */ 777 private function is_consent_banner_enabled() { 778 $options = get_option('convertybot_options', array()); 779 return isset($options['show_cookie_consent']) && $options['show_cookie_consent'] === true; 780 } 781 733 782 private function has_user_consent() { 783 // If banner is disabled, use implied consent 784 if (!$this->is_consent_banner_enabled()) { 785 return true; 786 } 787 788 // Check cookie first (for guests) 789 if (isset($_COOKIE['convertybot_consent'])) { 790 $consent_data = json_decode(sanitize_text_field(wp_unslash($_COOKIE['convertybot_consent'])), true); 791 if (is_array($consent_data) && !empty($consent_data)) { 792 return true; // They made a choice 793 } 794 } 795 796 // For logged-in users, check user meta 734 797 return get_user_meta(get_current_user_id(), 'convertybot_consent', true) === 'yes'; 735 798 } 736 799 737 800 private function has_functional_consent() { 801 // If banner is disabled, use implied consent 802 if (!$this->is_consent_banner_enabled()) { 803 return true; 804 } 738 805 return get_user_meta(get_current_user_id(), 'convertybot_functional_consent', true) !== 'no'; 739 806 } 740 807 741 808 private function has_analytics_consent() { 742 // For guests, allow tracking by default (they can opt-out via DNT) 809 // If banner is disabled, use implied consent (automatic tracking) 810 if (!$this->is_consent_banner_enabled()) { 811 return true; 812 } 813 814 // Check cookie consent first (for guests) 815 if (isset($_COOKIE['convertybot_consent'])) { 816 $consent_data = json_decode(sanitize_text_field(wp_unslash($_COOKIE['convertybot_consent'])), true); 817 if (is_array($consent_data) && isset($consent_data['analytics'])) { 818 return $consent_data['analytics'] === true; 819 } 820 } 821 822 // For guests without cookie, deny tracking when banner is enabled but not yet accepted 743 823 if (!is_user_logged_in()) { 744 return true; 745 } 746 // For logged-in users, check their consent preference (default to yes) 824 return false; // Must accept banner first 825 } 826 827 // For logged-in users, check their consent preference 747 828 $consent = get_user_meta(get_current_user_id(), 'convertybot_analytics_consent', true); 748 829 return empty($consent) || $consent === 'yes'; -
convertybot/trunk/readme.txt
r3443895 r3444237 6 6 Tested up to: 6.9 7 7 Requires PHP: 7.2 8 Stable tag: 1.0.1 58 Stable tag: 1.0.14 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html -
convertybot/trunk/templates/admin/configuration.php
r3437100 r3444237 94 94 </label> 95 95 <p class="description"><?php esc_html_e('Track user interactions and engagement for analytics.', 'convertybot'); ?></p> 96 </td> 97 </tr> 98 99 <tr> 100 <th scope="row"> 101 <label for="show_cookie_consent"><?php esc_html_e('Show Cookie Consent Banner', 'convertybot'); ?></label> 102 </th> 103 <td> 104 <label class="switch"> 105 <input type="checkbox" id="show_cookie_consent" name="show_cookie_consent" value="1" <?php checked($options['show_cookie_consent'] ?? false); ?>> 106 <span class="slider"></span> 107 </label> 108 <p class="description"> 109 <?php esc_html_e('Display ConvertyBot\'s cookie consent banner to visitors. Disable this if your store already has a cookie consent plugin.', 'convertybot'); ?> 110 <br> 111 <strong><?php esc_html_e('When disabled:', 'convertybot'); ?></strong> <?php esc_html_e('Tracking starts automatically (implied consent).', 'convertybot'); ?> 112 <br> 113 <strong><?php esc_html_e('When enabled:', 'convertybot'); ?></strong> <?php esc_html_e('Tracking waits for visitor consent via the banner.', 'convertybot'); ?> 114 </p> 96 115 </td> 97 116 </tr>
Note: See TracChangeset
for help on using the changeset viewer.