Plugin Directory

Changeset 3409441


Ignore:
Timestamp:
12/03/2025 12:08:10 PM (4 months ago)
Author:
appwavedev
Message:

Update to version 1.0.9 - Added logged-in users only option for member-only sites

Location:
bettercx-widget/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • bettercx-widget/trunk/bettercx-widget.php

    r3408542 r3409441  
    44 * Plugin URI: https://wordpress.org/plugins/bettercx-widget/
    55 * Description: Professional AI-powered chat widget for BetterCX platform. Seamlessly integrate intelligent customer support into any website with full WordPress compatibility. Fully functional out of the box with no trial limitations.
    6  * Version: 1.0.8
     6 * Version: 1.0.9
    77 * Author: BetterCX
    88 * Author URI: https://bettercx.ai
     
    1616 *
    1717 * @package BetterCX_Widget
    18  * @version 1.0.8
     18 * @version 1.0.9
    1919 * @author BetterCX
    2020 * @license GPLv2+
     
    3737
    3838// Define plugin constants
    39 define('BETTERCX_WIDGET_VERSION', '1.0.8');
     39define('BETTERCX_WIDGET_VERSION', '1.0.9');
    4040define('BETTERCX_WIDGET_PLUGIN_FILE', __FILE__);
    4141define('BETTERCX_WIDGET_PLUGIN_DIR', plugin_dir_path(__FILE__));
     
    175175            'custom_css' => '',
    176176            'widget_enabled' => true,
     177            'logged_in_only' => false, // Show widget only for logged-in users
    177178            'base_url' => 'https://api.bettercx.ai',
    178179            'ai_service_url' => 'https://ai.bettercx.ai',
     
    212213        // Only load if widget is enabled and we have a public key
    213214        if (!$this->settings['widget_enabled'] || empty($this->settings['public_key'])) {
     215            return;
     216        }
     217
     218        // Check if widget should only be shown to logged-in users
     219        if (!empty($this->settings['logged_in_only']) && !is_user_logged_in()) {
    214220            return;
    215221        }
     
    459465
    460466        add_settings_field(
     467            'logged_in_only',
     468            __('Logged-in Users Only', 'bettercx-widget'),
     469            array($this, 'logged_in_only_field_callback'),
     470            'bettercx-widget',
     471            'bettercx_widget_advanced'
     472        );
     473
     474        add_settings_field(
    461475            'custom_css',
    462476            __('Custom CSS', 'bettercx-widget'),
     
    535549        $sanitized['privacy_consent'] = isset($input['privacy_consent']) ? (bool) $input['privacy_consent'] : false;
    536550        $sanitized['widget_enabled'] = isset($input['widget_enabled']) ? (bool) $input['widget_enabled'] : true;
     551        $sanitized['logged_in_only'] = isset($input['logged_in_only']) ? (bool) $input['logged_in_only'] : false;
    537552
    538553        if (isset($input['custom_css'])) {
     
    559574     */
    560575    public function widget_shortcode($atts) {
     576        // Check if widget should only be shown to logged-in users
     577        if (!empty($this->settings['logged_in_only']) && !is_user_logged_in()) {
     578            return '';
     579        }
     580
    561581        // Parse shortcode attributes
    562582        $atts = shortcode_atts(array(
     
    619639        // Only render if widget is enabled and we have a public key
    620640        if (!$this->settings['widget_enabled'] || empty($this->settings['public_key'])) {
     641            return;
     642        }
     643
     644        // Check if widget should only be shown to logged-in users
     645        if (!empty($this->settings['logged_in_only']) && !is_user_logged_in()) {
    621646            return;
    622647        }
     
    939964        echo '<input type="checkbox" name="bettercx_widget_settings[privacy_consent]" value="1" ' . checked($value, true, false) . ' />';
    940965        echo '<p class="description">' . esc_html__('Require explicit user consent before enabling analytics and data collection.', 'bettercx-widget') . '</p>';
     966    }
     967
     968    public function logged_in_only_field_callback() {
     969        $value = isset($this->settings['logged_in_only']) ? (bool) $this->settings['logged_in_only'] : false;
     970        ?>
     971        <label>
     972            <input type="checkbox" name="bettercx_widget_settings[logged_in_only]" value="1" <?php checked($value, true); ?> />
     973            <?php esc_html_e('Show widget only to logged-in users', 'bettercx-widget'); ?>
     974        </label>
     975        <p class="description">
     976            <?php esc_html_e('When enabled, the widget will only be displayed to users who are logged into WordPress. This is useful for member-only sites or applications with authentication.', 'bettercx-widget'); ?>
     977        </p>
     978        <?php
    941979    }
    942980
  • bettercx-widget/trunk/readme.txt

    r3408542 r3409441  
    55Tested up to: 6.8
    66Requires PHP: 7.4
    7 Stable tag: 1.0.8
     7Stable tag: 1.0.9
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    244244
    245245== Changelog ==
     246
     247= 1.0.9 =
     248* Added "Logged-in Users Only" option to restrict widget visibility to authenticated WordPress users
     249* Enhanced security with WordPress native authentication check using is_user_logged_in()
     250* Optimized performance - scripts and styles only load for logged-in users when option is enabled
     251* Perfect for member-only sites and applications with WordPress authentication
     252* Works with both standard wp-login.php and custom login forms
    246253
    247254= 1.0.8 =
     
    325332== Upgrade Notice ==
    326333
     334= 1.0.9 =
     335New feature: Added "Logged-in Users Only" option in Advanced Settings. Perfect for member-only sites - widget will only display to authenticated WordPress users. Optimized for performance with early script loading prevention.
     336
    327337= 1.0.8 =
    328338Important mobile fix: Enhanced mobile keyboard handling for perfect input behavior. Chat now properly adjusts when keyboard appears, providing smooth UX on all mobile devices.
     
    581591
    582592= Version =
    583 1.0.8
     5931.0.9
    584594
    585595= Minimum WordPress Version =
     
    596606
    597607= Stable Tag =
    598 1.0.8
     6081.0.9
    599609
    600610= Development Version =
    601 1.0.8
     6111.0.9
    602612
    603613= Requires at least =
Note: See TracChangeset for help on using the changeset viewer.