Plugin Directory

Changeset 3740440


Ignore:
Timestamp:
10/12/2026 03:43:59 AM (6 weeks ago)
Author:
codeboldtech
Message:

Release 1.4.1: one-click Connect; Connected notice shown once on first save

Location:
chat-cobalt
Files:
2 added
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • chat-cobalt/tags/1.4.1/admin-page.php

    r3713711 r3740440  
    6969                add_settings_error( CHATCOBALT_OPTION_KEY, 'chatcobalt_saved', __( 'Settings saved.', 'chat-cobalt' ), 'success' );
    7070        }
     71        // Carried across the redirect from connect.php in a transient, so the
     72        // wording is never in the address bar.
     73        $connect_notice = function_exists( 'chatcobalt_connect_take_notice' ) ? chatcobalt_connect_take_notice() : false;
     74        if ( $connect_notice ) {
     75                add_settings_error( CHATCOBALT_OPTION_KEY, 'chatcobalt_connect', $connect_notice['message'], $connect_notice['type'] );
     76        }
    7177        ?>
    7278        <div class="wrap chatcobalt-wrap">
    … …  
    120126
    121127                        <section class="cc-card">
    122                                 <?php chatcobalt_card_head( __( 'Step 1', 'chat-cobalt' ), 'link', __( 'Connect your account', 'chat-cobalt' ), __( 'Paste your Business ID and the chat bubble appears on every page of this site. No code editing.', 'chat-cobalt' ) ); ?>
     128                                <?php
     129                                // One-click Connect leads Step 1 (2026-10-07): it fills Business ID
     130                                // and Site Key together, so it is the first thing a new owner sees,
     131                                // not something to find in Step 3.
     132                                chatcobalt_card_head(
     133                                        __( 'Step 1', 'chat-cobalt' ),
     134                                        'link',
     135                                        __( 'Connect your account', 'chat-cobalt' ),
     136                                        chatcobalt_is_connected()
     137                                                ? __( 'Your site is connected. The chat bubble appears on every page of this site.', 'chat-cobalt' )
     138                                                : __( 'One click and the chat bubble appears on every page of this site. No code editing.', 'chat-cobalt' )
     139                                );
     140                                ?>
     141                                <?php if ( ! chatcobalt_is_connected() ) : ?>
     142                                        <div class="cc-connect">
     143                                                <div class="cc-connect__text">
     144                                                        <strong><?php esc_html_e( 'Connect in one click', 'chat-cobalt' ); ?></strong>
     145                                                        <p><?php
     146                                                                printf(
     147                                                                        /* translators: %s: the product name. */
     148                                                                        esc_html__( 'Press the button, say yes on the %s screen, and your Business ID and Site Key are filled in for you. Nothing to copy.', 'chat-cobalt' ),
     149                                                                        esc_html( CHATCOBALT_PRODUCT_NAME )
     150                                                                );
     151                                                        ?></p>
     152                                                </div>
     153                                                <?php
     154                                                // A link, not a nested <form>. This card sits inside the settings
     155                                                // form, and a form inside a form is invalid HTML: the browser drops
     156                                                // the inner one and its button submits the OUTER form to options.php,
     157                                                // which lands the owner on WordPress's raw All Settings screen. The
     158                                                // nonce still travels, and admin-post.php reads $_REQUEST, so this is
     159                                                // checked exactly as a POST would be.
     160                                                $connect_url = wp_nonce_url(
     161                                                        add_query_arg( 'action', 'chatcobalt_connect', admin_url( 'admin-post.php' ) ),
     162                                                        'chatcobalt_connect'
     163                                                );
     164                                                ?>
     165                                                <a href="<?php echo esc_url( $connect_url ); ?>" class="button button-primary cc-button"><?php esc_html_e( 'Connect', 'chat-cobalt' ); ?></a>
     166                                        </div>
     167                                        <p class="cc-connect__alt"><?php esc_html_e( 'Or paste your Business ID yourself:', 'chat-cobalt' ); ?></p>
     168                                <?php endif; ?>
    123169                                <div class="cc-field">
    124170                                        <label class="cc-label" for="chatcobalt_business_id"><?php esc_html_e( 'Business ID', 'chat-cobalt' ); ?></label>
    … …  
    147193                        <section class="cc-card">
    148194                                <?php chatcobalt_card_head( __( 'Step 3', 'chat-cobalt' ), 'pages', __( 'Answer with your own pages', 'chat-cobalt' ), __( 'Optional. Let the chat recommend your pages and posts as clickable cards.', 'chat-cobalt' ) ); ?>
     195                                <?php if ( ! chatcobalt_is_connected() ) : ?>
     196                                        <p class="cc-connect__alt"><?php esc_html_e( 'Pressing Connect in Step 1 fills this in for you.', 'chat-cobalt' ); ?></p>
     197                                <?php endif; ?>
    149198                                <div class="cc-field">
    150199                                        <label class="cc-label" for="chatcobalt_site_key"><?php esc_html_e( 'Site Key', 'chat-cobalt' ); ?></label>
    … …  
    237286.cc-shop-toggle{display:flex;gap:10px;align-items:flex-start;padding:14px 16px;border:1px solid var(--cc-line);border-radius:14px;background:#fff;font-size:14px;color:var(--cc-ink);font-weight:600}
    238287.cc-shop-note{margin:12px 0 0;font-size:12.5px;color:var(--cc-muted);line-height:1.5}
     288.cc-connect{display:flex;gap:18px;align-items:center;flex-wrap:wrap;justify-content:space-between;padding:18px 20px;margin:0 0 14px;border-radius:16px;background:linear-gradient(180deg,#F7F9FF 0%,#fff 70%);border:1px solid #DCE3FF}
     289.cc-connect__text{min-width:220px;flex:1 1 320px}
     290.cc-connect__text strong{display:block;font-size:15px;color:var(--cc-ink)}
     291.cc-connect__text p{margin:4px 0 0;font-size:13px;color:var(--cc-muted);line-height:1.5}
     292.cc-connect form{margin:0}
     293.cc-connect__alt{margin:0 0 14px;font-size:12.5px;color:var(--cc-muted)}
    239294.cc-card__head{display:flex;gap:16px;align-items:flex-start;margin-bottom:22px;padding-bottom:20px;border-bottom:1px solid var(--cc-line)}
    240295.cc-badge{display:flex;width:42px;height:42px;flex:none;align-items:center;justify-content:center;border-radius:14px;background:var(--cc-tint);color:var(--cc)}
  • chat-cobalt/tags/1.4.1/chat-cobalt.php

    r3713711 r3740440  
    33 * Plugin Name: Chat Cobalt
    44 * Description: Adds an AI chat widget to every page of your site. Paste in your Business ID and you're done -- no theme or code editing required.
    5  * Version: 1.4.0
     5 * Version: 1.4.1
    66 * Requires at least: 5.8
    77 * Tested up to: 7.1
    … …  
    4141// the enqueued widget script, not anything functional, but corrected here
    4242// while touching this line anyway.
    43 define( 'CHATCOBALT_VERSION', '1.4.0' );
     43define( 'CHATCOBALT_VERSION', '1.4.1' );
    4444define( 'CHATCOBALT_EMBED_URL', 'https://www.chatcobalt.com/embed.js' );
    4545define( 'CHATCOBALT_CONFIG_URL', 'https://www.chatcobalt.com/api/widget-config' );
    … …  
    6969require_once plugin_dir_path( __FILE__ ) . 'admin-page.php';
    7070require_once plugin_dir_path( __FILE__ ) . 'support-page.php';
     71require_once plugin_dir_path( __FILE__ ) . 'connect.php';
    7172require_once plugin_dir_path( __FILE__ ) . 'woo-orders.php';
    7273
    … …  
    219220}
    220221
     222/**
     223 * Queue a notice on our settings screen unless one with the same code is
     224 * already queued. On the very first save (no option row yet) WordPress runs
     225 * the sanitize callback twice -- update_option, then add_option -- so without
     226 * this every notice it adds appears twice.
     227 */
     228function chatcobalt_settings_notice_once( $code, $message, $type ) {
     229        foreach ( get_settings_errors( CHATCOBALT_OPTION_KEY ) as $queued ) {
     230                if ( isset( $queued['code'] ) && $queued['code'] === $code ) {
     231                        return;
     232                }
     233        }
     234        add_settings_error( CHATCOBALT_OPTION_KEY, $code, $message, $type );
     235}
     236
    221237function chatcobalt_sanitize_settings( $input ) {
    222238        $existing = chatcobalt_get_settings();
    … …  
    293309                // the customer typed is kept and the widget still loads -- a failed
    294310                // lookup only costs them the automatic brand color.
    295                 add_settings_error(
    296                         CHATCOBALT_OPTION_KEY,
     311                chatcobalt_settings_notice_once(
    297312                        'chatcobalt_lookup_failed',
    298313                        sprintf(
    … …  
    316331        if ( '' === $output['accent_color'] && chatcobalt_is_hex_color( $brand ) ) {
    317332                $output['accent_color'] = $brand;
    318                 add_settings_error(
    319                         CHATCOBALT_OPTION_KEY,
     333                chatcobalt_settings_notice_once(
    320334                        'chatcobalt_connected',
    321335                        sprintf(
    … …  
    330344        }
    331345
    332         add_settings_error(
    333                 CHATCOBALT_OPTION_KEY,
     346        chatcobalt_settings_notice_once(
    334347                'chatcobalt_connected',
    335348                sprintf(
  • chat-cobalt/tags/1.4.1/readme.txt

    r3713711 r3740440  
    55Tested up to: 7.1
    66Requires PHP: 7.2
    7 Stable tag: 1.4.0
     7Stable tag: 1.4.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    7878If you turn on "Order updates on WhatsApp" (shown only when WooCommerce is installed), two things happen. When you save the setting, your site registers itself with `https://www.chatcobalt.com/api/wp/orders-connect`, sending your Business ID, your site address and a secret this plugin generates, so that only Chat Cobalt can ask your shop about orders. Then, when a customer messages your WhatsApp number about an order, Chat Cobalt sends one signed request to your site (`/wp-json/chat-cobalt/v1/orders`) carrying the phone number they are messaging from, and your shop answers with the status, date, total, items and tracking number of at most three of that customer's own orders -- never an address, email or payment detail. The answer is used for that one reply and is not stored. This is off by default, and turning it off removes the secret at both ends.
    7979
     80If you use the **Connect** button on the settings screen, your site opens a Chat Cobalt page carrying your site address, your site's name, and a one-time code (only a scrambled form of the code is in the link). After you approve the connection there, your site collects the Site Key directly from `https://www.chatcobalt.com/api/wp/claim-site-key`. No password or personal data is exchanged, and nothing is sent unless you press Connect.
     81
    8082Once a Business ID is saved, the settings screen also shows a "Try your chatbot" box. Typing a question there and clicking Ask sends your Business ID and whatever you typed to `https://www.chatcobalt.com/api/preview-chat`, purely so the reply can be shown to you on that same screen -- it is never saved as a lead or a conversation, and nothing is sent unless you click Ask yourself.
    8183
    8284== Changelog ==
     85
     86= 1.4.1 =
     87* New: a **Connect** button on the settings screen. Press it, say yes on the Chat Cobalt screen, and your Business ID and Site Key are filled in for you -- no more copying a key between two websites.
     88* Connecting also picks sensible content to sync (pages and posts) and runs the first sync straight away, so the chat can answer with your pages immediately.
     89* Fix: the first time you saved your Business ID, the "Connected" message showed twice.
    8390
    8491= 1.4.0 =
  • chat-cobalt/tags/1.4.1/uninstall.php

    r3713711 r3740440  
    1414delete_option( 'chatcobalt_settings' );
    1515delete_option( 'chatcobalt_orders_secret' );
     16delete_option( 'chatcobalt_pairing' );
    1617delete_option( 'chatcobalt_orders_status' );
    1718delete_option( 'chatcobalt_last_sync' );
  • chat-cobalt/trunk/admin-page.php

    r3713711 r3740440  
    6969                add_settings_error( CHATCOBALT_OPTION_KEY, 'chatcobalt_saved', __( 'Settings saved.', 'chat-cobalt' ), 'success' );
    7070        }
     71        // Carried across the redirect from connect.php in a transient, so the
     72        // wording is never in the address bar.
     73        $connect_notice = function_exists( 'chatcobalt_connect_take_notice' ) ? chatcobalt_connect_take_notice() : false;
     74        if ( $connect_notice ) {
     75                add_settings_error( CHATCOBALT_OPTION_KEY, 'chatcobalt_connect', $connect_notice['message'], $connect_notice['type'] );
     76        }
    7177        ?>
    7278        <div class="wrap chatcobalt-wrap">
    … …  
    120126
    121127                        <section class="cc-card">
    122                                 <?php chatcobalt_card_head( __( 'Step 1', 'chat-cobalt' ), 'link', __( 'Connect your account', 'chat-cobalt' ), __( 'Paste your Business ID and the chat bubble appears on every page of this site. No code editing.', 'chat-cobalt' ) ); ?>
     128                                <?php
     129                                // One-click Connect leads Step 1 (2026-10-07): it fills Business ID
     130                                // and Site Key together, so it is the first thing a new owner sees,
     131                                // not something to find in Step 3.
     132                                chatcobalt_card_head(
     133                                        __( 'Step 1', 'chat-cobalt' ),
     134                                        'link',
     135                                        __( 'Connect your account', 'chat-cobalt' ),
     136                                        chatcobalt_is_connected()
     137                                                ? __( 'Your site is connected. The chat bubble appears on every page of this site.', 'chat-cobalt' )
     138                                                : __( 'One click and the chat bubble appears on every page of this site. No code editing.', 'chat-cobalt' )
     139                                );
     140                                ?>
     141                                <?php if ( ! chatcobalt_is_connected() ) : ?>
     142                                        <div class="cc-connect">
     143                                                <div class="cc-connect__text">
     144                                                        <strong><?php esc_html_e( 'Connect in one click', 'chat-cobalt' ); ?></strong>
     145                                                        <p><?php
     146                                                                printf(
     147                                                                        /* translators: %s: the product name. */
     148                                                                        esc_html__( 'Press the button, say yes on the %s screen, and your Business ID and Site Key are filled in for you. Nothing to copy.', 'chat-cobalt' ),
     149                                                                        esc_html( CHATCOBALT_PRODUCT_NAME )
     150                                                                );
     151                                                        ?></p>
     152                                                </div>
     153                                                <?php
     154                                                // A link, not a nested <form>. This card sits inside the settings
     155                                                // form, and a form inside a form is invalid HTML: the browser drops
     156                                                // the inner one and its button submits the OUTER form to options.php,
     157                                                // which lands the owner on WordPress's raw All Settings screen. The
     158                                                // nonce still travels, and admin-post.php reads $_REQUEST, so this is
     159                                                // checked exactly as a POST would be.
     160                                                $connect_url = wp_nonce_url(
     161                                                        add_query_arg( 'action', 'chatcobalt_connect', admin_url( 'admin-post.php' ) ),
     162                                                        'chatcobalt_connect'
     163                                                );
     164                                                ?>
     165                                                <a href="<?php echo esc_url( $connect_url ); ?>" class="button button-primary cc-button"><?php esc_html_e( 'Connect', 'chat-cobalt' ); ?></a>
     166                                        </div>
     167                                        <p class="cc-connect__alt"><?php esc_html_e( 'Or paste your Business ID yourself:', 'chat-cobalt' ); ?></p>
     168                                <?php endif; ?>
    123169                                <div class="cc-field">
    124170                                        <label class="cc-label" for="chatcobalt_business_id"><?php esc_html_e( 'Business ID', 'chat-cobalt' ); ?></label>
    … …  
    147193                        <section class="cc-card">
    148194                                <?php chatcobalt_card_head( __( 'Step 3', 'chat-cobalt' ), 'pages', __( 'Answer with your own pages', 'chat-cobalt' ), __( 'Optional. Let the chat recommend your pages and posts as clickable cards.', 'chat-cobalt' ) ); ?>
     195                                <?php if ( ! chatcobalt_is_connected() ) : ?>
     196                                        <p class="cc-connect__alt"><?php esc_html_e( 'Pressing Connect in Step 1 fills this in for you.', 'chat-cobalt' ); ?></p>
     197                                <?php endif; ?>
    149198                                <div class="cc-field">
    150199                                        <label class="cc-label" for="chatcobalt_site_key"><?php esc_html_e( 'Site Key', 'chat-cobalt' ); ?></label>
    … …  
    237286.cc-shop-toggle{display:flex;gap:10px;align-items:flex-start;padding:14px 16px;border:1px solid var(--cc-line);border-radius:14px;background:#fff;font-size:14px;color:var(--cc-ink);font-weight:600}
    238287.cc-shop-note{margin:12px 0 0;font-size:12.5px;color:var(--cc-muted);line-height:1.5}
     288.cc-connect{display:flex;gap:18px;align-items:center;flex-wrap:wrap;justify-content:space-between;padding:18px 20px;margin:0 0 14px;border-radius:16px;background:linear-gradient(180deg,#F7F9FF 0%,#fff 70%);border:1px solid #DCE3FF}
     289.cc-connect__text{min-width:220px;flex:1 1 320px}
     290.cc-connect__text strong{display:block;font-size:15px;color:var(--cc-ink)}
     291.cc-connect__text p{margin:4px 0 0;font-size:13px;color:var(--cc-muted);line-height:1.5}
     292.cc-connect form{margin:0}
     293.cc-connect__alt{margin:0 0 14px;font-size:12.5px;color:var(--cc-muted)}
    239294.cc-card__head{display:flex;gap:16px;align-items:flex-start;margin-bottom:22px;padding-bottom:20px;border-bottom:1px solid var(--cc-line)}
    240295.cc-badge{display:flex;width:42px;height:42px;flex:none;align-items:center;justify-content:center;border-radius:14px;background:var(--cc-tint);color:var(--cc)}
  • chat-cobalt/trunk/chat-cobalt.php

    r3713711 r3740440  
    33 * Plugin Name: Chat Cobalt
    44 * Description: Adds an AI chat widget to every page of your site. Paste in your Business ID and you're done -- no theme or code editing required.
    5  * Version: 1.4.0
     5 * Version: 1.4.1
    66 * Requires at least: 5.8
    77 * Tested up to: 7.1
    … …  
    4141// the enqueued widget script, not anything functional, but corrected here
    4242// while touching this line anyway.
    43 define( 'CHATCOBALT_VERSION', '1.4.0' );
     43define( 'CHATCOBALT_VERSION', '1.4.1' );
    4444define( 'CHATCOBALT_EMBED_URL', 'https://www.chatcobalt.com/embed.js' );
    4545define( 'CHATCOBALT_CONFIG_URL', 'https://www.chatcobalt.com/api/widget-config' );
    … …  
    6969require_once plugin_dir_path( __FILE__ ) . 'admin-page.php';
    7070require_once plugin_dir_path( __FILE__ ) . 'support-page.php';
     71require_once plugin_dir_path( __FILE__ ) . 'connect.php';
    7172require_once plugin_dir_path( __FILE__ ) . 'woo-orders.php';
    7273
    … …  
    219220}
    220221
     222/**
     223 * Queue a notice on our settings screen unless one with the same code is
     224 * already queued. On the very first save (no option row yet) WordPress runs
     225 * the sanitize callback twice -- update_option, then add_option -- so without
     226 * this every notice it adds appears twice.
     227 */
     228function chatcobalt_settings_notice_once( $code, $message, $type ) {
     229        foreach ( get_settings_errors( CHATCOBALT_OPTION_KEY ) as $queued ) {
     230                if ( isset( $queued['code'] ) && $queued['code'] === $code ) {
     231                        return;
     232                }
     233        }
     234        add_settings_error( CHATCOBALT_OPTION_KEY, $code, $message, $type );
     235}
     236
    221237function chatcobalt_sanitize_settings( $input ) {
    222238        $existing = chatcobalt_get_settings();
    … …  
    293309                // the customer typed is kept and the widget still loads -- a failed
    294310                // lookup only costs them the automatic brand color.
    295                 add_settings_error(
    296                         CHATCOBALT_OPTION_KEY,
     311                chatcobalt_settings_notice_once(
    297312                        'chatcobalt_lookup_failed',
    298313                        sprintf(
    … …  
    316331        if ( '' === $output['accent_color'] && chatcobalt_is_hex_color( $brand ) ) {
    317332                $output['accent_color'] = $brand;
    318                 add_settings_error(
    319                         CHATCOBALT_OPTION_KEY,
     333                chatcobalt_settings_notice_once(
    320334                        'chatcobalt_connected',
    321335                        sprintf(
    … …  
    330344        }
    331345
    332         add_settings_error(
    333                 CHATCOBALT_OPTION_KEY,
     346        chatcobalt_settings_notice_once(
    334347                'chatcobalt_connected',
    335348                sprintf(
  • chat-cobalt/trunk/readme.txt

    r3713711 r3740440  
    55Tested up to: 7.1
    66Requires PHP: 7.2
    7 Stable tag: 1.4.0
     7Stable tag: 1.4.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    7878If you turn on "Order updates on WhatsApp" (shown only when WooCommerce is installed), two things happen. When you save the setting, your site registers itself with `https://www.chatcobalt.com/api/wp/orders-connect`, sending your Business ID, your site address and a secret this plugin generates, so that only Chat Cobalt can ask your shop about orders. Then, when a customer messages your WhatsApp number about an order, Chat Cobalt sends one signed request to your site (`/wp-json/chat-cobalt/v1/orders`) carrying the phone number they are messaging from, and your shop answers with the status, date, total, items and tracking number of at most three of that customer's own orders -- never an address, email or payment detail. The answer is used for that one reply and is not stored. This is off by default, and turning it off removes the secret at both ends.
    7979
     80If you use the **Connect** button on the settings screen, your site opens a Chat Cobalt page carrying your site address, your site's name, and a one-time code (only a scrambled form of the code is in the link). After you approve the connection there, your site collects the Site Key directly from `https://www.chatcobalt.com/api/wp/claim-site-key`. No password or personal data is exchanged, and nothing is sent unless you press Connect.
     81
    8082Once a Business ID is saved, the settings screen also shows a "Try your chatbot" box. Typing a question there and clicking Ask sends your Business ID and whatever you typed to `https://www.chatcobalt.com/api/preview-chat`, purely so the reply can be shown to you on that same screen -- it is never saved as a lead or a conversation, and nothing is sent unless you click Ask yourself.
    8183
    8284== Changelog ==
     85
     86= 1.4.1 =
     87* New: a **Connect** button on the settings screen. Press it, say yes on the Chat Cobalt screen, and your Business ID and Site Key are filled in for you -- no more copying a key between two websites.
     88* Connecting also picks sensible content to sync (pages and posts) and runs the first sync straight away, so the chat can answer with your pages immediately.
     89* Fix: the first time you saved your Business ID, the "Connected" message showed twice.
    8390
    8491= 1.4.0 =
  • chat-cobalt/trunk/uninstall.php

    r3713711 r3740440  
    1414delete_option( 'chatcobalt_settings' );
    1515delete_option( 'chatcobalt_orders_secret' );
     16delete_option( 'chatcobalt_pairing' );
    1617delete_option( 'chatcobalt_orders_status' );
    1718delete_option( 'chatcobalt_last_sync' );
Note: See TracChangeset for help on using the changeset viewer.