Plugin Directory

Changeset 3444237


Ignore:
Timestamp:
01/21/2026 03:52:33 PM (4 weeks ago)
Author:
2wstechnologies
Message:

add the enable / disable banner option + optimization of products suggestion

Location:
convertybot
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • convertybot/tags/1.0.15/assets/js/admin.js

    r3443884 r3444237  
    190190       
    191191        // Add event handlers for toggle changes to provide immediate feedback
    192         $('#chatbot_enabled, #auto_open, #engagement_tracking, #sound_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() {
    193193            updateToggleStates();
    194194        });
  • convertybot/tags/1.0.15/convertybot.php

    r3443884 r3444237  
    195195            'show_on_pages' => array('shop', 'product', 'cart'),
    196196            'engagement_tracking' => true,
     197            'show_cookie_consent' => false, // Disable by default (tracking with implied consent)
    197198            'setup_completed' => false,
    198199            'last_sync' => null,
  • convertybot/tags/1.0.15/includes/class-admin.php

    r3443884 r3444237  
    177177        // Boolean options
    178178        $boolean_keys = array(
    179             'chatbot_enabled', 'auto_open', 'engagement_tracking', 'sound_enabled',
    180             'show_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',
    181181            'emoji_reactions', 'show_online_status', 'response_suggestions'
    182182        );
     
    20792079            }
    20802080
    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';
    20842086
    20852087            // Save options
  • convertybot/tags/1.0.15/includes/class-consent-banner.php

    r3443884 r3444237  
    4747
    4848    public function enqueue_assets() {
     49        // Skip if banner is disabled in settings
     50        if (!$this->is_banner_enabled()) {
     51            return;
     52        }
     53
    4954        // Skip if consent already given
    5055        if ($this->has_consent_cookie()) {
     
    7782
    7883    public function render_consent_banner() {
     84        // Skip if banner is disabled in settings
     85        if (!$this->is_banner_enabled()) {
     86            return;
     87        }
     88
    7989        // Skip if consent already given
    8090        if ($this->has_consent_cookie()) {
     
    255265    }
    256266
     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
    257284    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
    258300        if (isset($_COOKIE['convertybot_consent'])) {
    259301            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  
    177177    // Session Management
    178178    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
    179185        // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing
    180186        if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) {
     
    182188            return;
    183189        }
    184        
     190
    185191        $session_data = $this->sanitize_session_data($_POST);
    186192        $response = $this->create_tracking_session($session_data);
    187        
     193
    188194        if ($response) {
    189195            wp_send_json_success($response);
     
    219225    // Event Tracking
    220226    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
    221233        // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing
    222234        if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) {
     
    260272    // Product Interaction Tracking
    261273    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
    262280        // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing
    263281        if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) {
     
    300318    // Conversion Tracking
    301319    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
    302326        // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing
    303327        if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) {
     
    383407    // Real-time Tracking
    384408    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
    385415        // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing
    386416        if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) {
     
    400430   
    401431    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
    402438        // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing
    403439        if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) {
     
    535571   
    536572    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;
    538577    }
    539578   
     
    731770   
    732771    // 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
    733782    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
    734797        return get_user_meta(get_current_user_id(), 'convertybot_consent', true) === 'yes';
    735798    }
    736    
     799
    737800    private function has_functional_consent() {
     801        // If banner is disabled, use implied consent
     802        if (!$this->is_consent_banner_enabled()) {
     803            return true;
     804        }
    738805        return get_user_meta(get_current_user_id(), 'convertybot_functional_consent', true) !== 'no';
    739806    }
    740    
     807
    741808    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
    743823        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
    747828        $consent = get_user_meta(get_current_user_id(), 'convertybot_analytics_consent', true);
    748829        return empty($consent) || $consent === 'yes';
  • convertybot/tags/1.0.15/readme.txt

    r3443895 r3444237  
    66Tested up to: 6.9
    77Requires PHP: 7.2
    8 Stable tag: 1.0.15
     8Stable tag: 1.0.14
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
  • convertybot/tags/1.0.15/templates/admin/configuration.php

    r3443884 r3444237  
    9494                        </label>
    9595                        <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>
    96115                    </td>
    97116                </tr>
  • convertybot/trunk/assets/js/admin.js

    r3437100 r3444237  
    190190       
    191191        // Add event handlers for toggle changes to provide immediate feedback
    192         $('#chatbot_enabled, #auto_open, #engagement_tracking, #sound_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() {
    193193            updateToggleStates();
    194194        });
  • convertybot/trunk/convertybot.php

    r3443877 r3444237  
    195195            'show_on_pages' => array('shop', 'product', 'cart'),
    196196            'engagement_tracking' => true,
     197            'show_cookie_consent' => false, // Disable by default (tracking with implied consent)
    197198            'setup_completed' => false,
    198199            'last_sync' => null,
  • convertybot/trunk/includes/class-admin.php

    r3437112 r3444237  
    177177        // Boolean options
    178178        $boolean_keys = array(
    179             'chatbot_enabled', 'auto_open', 'engagement_tracking', 'sound_enabled',
    180             'show_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',
    181181            'emoji_reactions', 'show_online_status', 'response_suggestions'
    182182        );
     
    20792079            }
    20802080
    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';
    20842086
    20852087            // Save options
  • convertybot/trunk/includes/class-consent-banner.php

    r3437100 r3444237  
    4747
    4848    public function enqueue_assets() {
     49        // Skip if banner is disabled in settings
     50        if (!$this->is_banner_enabled()) {
     51            return;
     52        }
     53
    4954        // Skip if consent already given
    5055        if ($this->has_consent_cookie()) {
     
    7782
    7883    public function render_consent_banner() {
     84        // Skip if banner is disabled in settings
     85        if (!$this->is_banner_enabled()) {
     86            return;
     87        }
     88
    7989        // Skip if consent already given
    8090        if ($this->has_consent_cookie()) {
     
    255265    }
    256266
     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
    257284    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
    258300        if (isset($_COOKIE['convertybot_consent'])) {
    259301            return json_decode(sanitize_text_field(wp_unslash($_COOKIE['convertybot_consent'])), true);
  • convertybot/trunk/includes/class-user-tracking-enhanced.php

    r3437100 r3444237  
    177177    // Session Management
    178178    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
    179185        // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing
    180186        if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) {
     
    182188            return;
    183189        }
    184        
     190
    185191        $session_data = $this->sanitize_session_data($_POST);
    186192        $response = $this->create_tracking_session($session_data);
    187        
     193
    188194        if ($response) {
    189195            wp_send_json_success($response);
     
    219225    // Event Tracking
    220226    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
    221233        // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing
    222234        if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) {
     
    260272    // Product Interaction Tracking
    261273    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
    262280        // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing
    263281        if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) {
     
    300318    // Conversion Tracking
    301319    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
    302326        // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing
    303327        if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) {
     
    383407    // Real-time Tracking
    384408    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
    385415        // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing
    386416        if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) {
     
    400430   
    401431    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
    402438        // Verify nonce for security - phpcs:ignore WordPress.Security.NonceVerification.Missing
    403439        if (!check_ajax_referer('convertybot_tracking', 'nonce', false)) {
     
    535571   
    536572    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;
    538577    }
    539578   
     
    731770   
    732771    // 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
    733782    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
    734797        return get_user_meta(get_current_user_id(), 'convertybot_consent', true) === 'yes';
    735798    }
    736    
     799
    737800    private function has_functional_consent() {
     801        // If banner is disabled, use implied consent
     802        if (!$this->is_consent_banner_enabled()) {
     803            return true;
     804        }
    738805        return get_user_meta(get_current_user_id(), 'convertybot_functional_consent', true) !== 'no';
    739806    }
    740    
     807
    741808    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
    743823        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
    747828        $consent = get_user_meta(get_current_user_id(), 'convertybot_analytics_consent', true);
    748829        return empty($consent) || $consent === 'yes';
  • convertybot/trunk/readme.txt

    r3443895 r3444237  
    66Tested up to: 6.9
    77Requires PHP: 7.2
    8 Stable tag: 1.0.15
     8Stable tag: 1.0.14
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
  • convertybot/trunk/templates/admin/configuration.php

    r3437100 r3444237  
    9494                        </label>
    9595                        <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>
    96115                    </td>
    97116                </tr>
Note: See TracChangeset for help on using the changeset viewer.