Plugin Directory

Changeset 3840711


Ignore:
Timestamp:
12/02/2026 05:16:24 PM (29 hours ago)
Author:
overidea
Message:

Release LarkBots AI Chat 1.3.0

Location:
larkbots-ai-chat
Files:
28 added
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • larkbots-ai-chat/tags/1.3.0/includes/class-larkbots-admin.php

    r3840461 r3840711  
    150150                $appearance_url    = 'https://www.larkbots.com/admin/settings/ai/appearance';
    151151                $knowledge_url     = 'https://www.larkbots.com/admin/settings/ai/knowledge';
     152                $locale            = LarkBots_AI_Chat_Connection::connect_locale( get_user_locale() );
     153                $help_prefix       = '' !== $locale && 'en-US' !== $locale ? '/' . strtolower( $locale ) : '';
     154                $help_url          = 'https://www.larkbots.com' . $help_prefix . '/help/connect-wordpress';
    152155                $logo_url          = plugins_url( 'assets/larkbots-logo.png', LARKBOTS_AI_CHAT_FILE );
    153156                $status_class      = $value['local_enabled'] ? 'larkbots-status larkbots-status-success' : 'larkbots-status';
    … …  
    343346                                                                <a class="button" href="<?php echo esc_url( $connect_url ); ?>"><?php echo esc_html__( 'Reconnect LarkBots', 'larkbots-ai-chat' ); ?></a>
    344347                                                                <a class="button" href="<?php echo esc_url( $chat_url ); ?>" target="_blank" rel="noopener noreferrer"><?php echo esc_html__( 'Chat behavior settings', 'larkbots-ai-chat' ); ?></a>
    345                                                                 <a class="button" href="https://www.larkbots.com/help/connect-wordpress" target="_blank" rel="noopener noreferrer"><?php echo esc_html__( 'Get help', 'larkbots-ai-chat' ); ?></a>
     348                                                                <a class="button" href="<?php echo esc_url( $help_url ); ?>" target="_blank" rel="noopener noreferrer"><?php echo esc_html__( 'Get help', 'larkbots-ai-chat' ); ?></a>
    346349                                                        </div>
    347350                                                        <details class="larkbots-manual">
    … …  
    417420                                                <a href="<?php echo esc_url( $chat_url ); ?>" target="_blank" rel="noopener noreferrer"><?php echo esc_html__( 'Chat settings', 'larkbots-ai-chat' ); ?></a>
    418421                                                <span aria-hidden="true"> · </span>
    419                                                 <a href="https://www.larkbots.com/help/connect-wordpress" target="_blank" rel="noopener noreferrer"><?php echo esc_html__( 'Help', 'larkbots-ai-chat' ); ?></a>
     422                                                <a href="<?php echo esc_url( $help_url ); ?>" target="_blank" rel="noopener noreferrer"><?php echo esc_html__( 'Help', 'larkbots-ai-chat' ); ?></a>
    420423                                        </p>
    421424                                <?php endif; ?>
  • larkbots-ai-chat/tags/1.3.0/includes/class-larkbots-connection.php

    r3840461 r3840711  
    6969                        'wordpress_version'     => get_bloginfo( 'version' ),
    7070                );
     71                $locale = $this->connect_locale( get_user_locale() );
     72                if ( '' !== $locale ) {
     73                        $query['locale'] = $locale;
     74                }
    7175                wp_safe_redirect( esc_url_raw( add_query_arg( $query, self::CONNECT_URL ) ) );
    7276                exit;
     77        }
     78
     79        /** Map a WordPress administrator's locale to a supported cloud locale. */
     80        public static function connect_locale( $locale ) {
     81                $normalized = strtolower( str_replace( '_', '-', $locale ) );
     82                $parts      = explode( '-', $normalized );
     83                if ( 'zh' === $parts[0] ) {
     84                        $traditional = in_array( 'hant', $parts, true ) ||
     85                                ( ! in_array( 'hans', $parts, true ) && array_intersect( array( 'tw', 'hk', 'mo' ), $parts ) );
     86                        return $traditional ? 'zh-TW' : 'zh-CN';
     87                }
     88                $locales = array( 'en' => 'en-US', 'es' => 'es-US', 'de' => 'de-DE', 'fr' => 'fr-FR', 'pt' => 'pt-BR', 'ja' => 'ja-JP' );
     89                return isset( $locales[ $parts[0] ] ) ? $locales[ $parts[0] ] : '';
    7390        }
    7491
  • larkbots-ai-chat/tags/1.3.0/includes/class-larkbots-widget.php

    r3840461 r3840711  
    115115
    116116                $attributes = sprintf(
    117                         ' data-tenant-%1$s="%2$s"%3$s async',
     117                        ' data-tenant-%1$s="%2$s"%3$s data-larkbots-locale="auto" async',
    118118                        esc_attr( $value['identifier_type'] ),
    119119                        esc_attr( $value['tenant_identifier'] ),
  • larkbots-ai-chat/tags/1.3.0/larkbots-ai-chat.php

    r3840461 r3840711  
    33 * Plugin Name:       LarkBots AI Chat
    44 * Description:       Add the LarkBots AI website chat to your WordPress site without editing code.
    5  * Version:           1.2.1
     5 * Version:           1.3.0
    66 * Requires at least: 6.0
    77 * Requires PHP:      7.4
    … …  
    1818}
    1919
    20 define( 'LARKBOTS_AI_CHAT_VERSION', '1.2.1' );
     20define( 'LARKBOTS_AI_CHAT_VERSION', '1.3.0' );
    2121define( 'LARKBOTS_AI_CHAT_FILE', __FILE__ );
    2222define( 'LARKBOTS_AI_CHAT_DIR', plugin_dir_path( __FILE__ ) );
    … …  
    5959}
    6060add_action( 'plugins_loaded', 'larkbots_ai_chat_boot' );
     61
     62/** Load the bundled admin translation when WordPress has no installed language pack. */
     63function larkbots_ai_chat_load_translations() {
     64        if ( ! is_admin() ) {
     65                return;
     66        }
     67        $locale = get_user_locale();
     68        if ( ! preg_match( '/^[a-z]{2,3}(?:_[A-Za-z0-9]+)*$/D', $locale ) ) {
     69                return;
     70        }
     71        $pack = WP_LANG_DIR . '/plugins/larkbots-ai-chat-' . $locale;
     72        if ( is_readable( $pack . '.mo' ) || is_readable( $pack . '.l10n.php' ) ) {
     73                return;
     74        }
     75        $catalog = str_replace( '-', '_', LarkBots_AI_Chat_Connection::connect_locale( $locale ) );
     76        $catalog = 'ja_JP' === $catalog ? 'ja' : $catalog;
     77        $file    = LARKBOTS_AI_CHAT_DIR . 'languages/larkbots-ai-chat-' . $catalog . '.mo';
     78        if ( '' !== $catalog && is_readable( $file ) ) {
     79                load_textdomain( 'larkbots-ai-chat', $file, $locale );
     80        }
     81}
     82add_action( 'init', 'larkbots_ai_chat_load_translations' );
  • larkbots-ai-chat/tags/1.3.0/readme.txt

    r3840461 r3840711  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.2.1
     7Stable tag: 1.3.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    6868== Changelog ==
    6969
     70= 1.3.0 =
     71* Keep the administrator's language through WordPress setup, LarkBots account creation and site confirmation.
     72* Use the language of the public page for the hosted chat interface when supported.
     73
    7074= 1.2.1 =
    7175
  • larkbots-ai-chat/trunk/includes/class-larkbots-admin.php

    r3840461 r3840711  
    150150                $appearance_url    = 'https://www.larkbots.com/admin/settings/ai/appearance';
    151151                $knowledge_url     = 'https://www.larkbots.com/admin/settings/ai/knowledge';
     152                $locale            = LarkBots_AI_Chat_Connection::connect_locale( get_user_locale() );
     153                $help_prefix       = '' !== $locale && 'en-US' !== $locale ? '/' . strtolower( $locale ) : '';
     154                $help_url          = 'https://www.larkbots.com' . $help_prefix . '/help/connect-wordpress';
    152155                $logo_url          = plugins_url( 'assets/larkbots-logo.png', LARKBOTS_AI_CHAT_FILE );
    153156                $status_class      = $value['local_enabled'] ? 'larkbots-status larkbots-status-success' : 'larkbots-status';
    … …  
    343346                                                                <a class="button" href="<?php echo esc_url( $connect_url ); ?>"><?php echo esc_html__( 'Reconnect LarkBots', 'larkbots-ai-chat' ); ?></a>
    344347                                                                <a class="button" href="<?php echo esc_url( $chat_url ); ?>" target="_blank" rel="noopener noreferrer"><?php echo esc_html__( 'Chat behavior settings', 'larkbots-ai-chat' ); ?></a>
    345                                                                 <a class="button" href="https://www.larkbots.com/help/connect-wordpress" target="_blank" rel="noopener noreferrer"><?php echo esc_html__( 'Get help', 'larkbots-ai-chat' ); ?></a>
     348                                                                <a class="button" href="<?php echo esc_url( $help_url ); ?>" target="_blank" rel="noopener noreferrer"><?php echo esc_html__( 'Get help', 'larkbots-ai-chat' ); ?></a>
    346349                                                        </div>
    347350                                                        <details class="larkbots-manual">
    … …  
    417420                                                <a href="<?php echo esc_url( $chat_url ); ?>" target="_blank" rel="noopener noreferrer"><?php echo esc_html__( 'Chat settings', 'larkbots-ai-chat' ); ?></a>
    418421                                                <span aria-hidden="true"> · </span>
    419                                                 <a href="https://www.larkbots.com/help/connect-wordpress" target="_blank" rel="noopener noreferrer"><?php echo esc_html__( 'Help', 'larkbots-ai-chat' ); ?></a>
     422                                                <a href="<?php echo esc_url( $help_url ); ?>" target="_blank" rel="noopener noreferrer"><?php echo esc_html__( 'Help', 'larkbots-ai-chat' ); ?></a>
    420423                                        </p>
    421424                                <?php endif; ?>
  • larkbots-ai-chat/trunk/includes/class-larkbots-connection.php

    r3840461 r3840711  
    6969                        'wordpress_version'     => get_bloginfo( 'version' ),
    7070                );
     71                $locale = $this->connect_locale( get_user_locale() );
     72                if ( '' !== $locale ) {
     73                        $query['locale'] = $locale;
     74                }
    7175                wp_safe_redirect( esc_url_raw( add_query_arg( $query, self::CONNECT_URL ) ) );
    7276                exit;
     77        }
     78
     79        /** Map a WordPress administrator's locale to a supported cloud locale. */
     80        public static function connect_locale( $locale ) {
     81                $normalized = strtolower( str_replace( '_', '-', $locale ) );
     82                $parts      = explode( '-', $normalized );
     83                if ( 'zh' === $parts[0] ) {
     84                        $traditional = in_array( 'hant', $parts, true ) ||
     85                                ( ! in_array( 'hans', $parts, true ) && array_intersect( array( 'tw', 'hk', 'mo' ), $parts ) );
     86                        return $traditional ? 'zh-TW' : 'zh-CN';
     87                }
     88                $locales = array( 'en' => 'en-US', 'es' => 'es-US', 'de' => 'de-DE', 'fr' => 'fr-FR', 'pt' => 'pt-BR', 'ja' => 'ja-JP' );
     89                return isset( $locales[ $parts[0] ] ) ? $locales[ $parts[0] ] : '';
    7390        }
    7491
  • larkbots-ai-chat/trunk/includes/class-larkbots-widget.php

    r3840461 r3840711  
    115115
    116116                $attributes = sprintf(
    117                         ' data-tenant-%1$s="%2$s"%3$s async',
     117                        ' data-tenant-%1$s="%2$s"%3$s data-larkbots-locale="auto" async',
    118118                        esc_attr( $value['identifier_type'] ),
    119119                        esc_attr( $value['tenant_identifier'] ),
  • larkbots-ai-chat/trunk/larkbots-ai-chat.php

    r3840461 r3840711  
    33 * Plugin Name:       LarkBots AI Chat
    44 * Description:       Add the LarkBots AI website chat to your WordPress site without editing code.
    5  * Version:           1.2.1
     5 * Version:           1.3.0
    66 * Requires at least: 6.0
    77 * Requires PHP:      7.4
    … …  
    1818}
    1919
    20 define( 'LARKBOTS_AI_CHAT_VERSION', '1.2.1' );
     20define( 'LARKBOTS_AI_CHAT_VERSION', '1.3.0' );
    2121define( 'LARKBOTS_AI_CHAT_FILE', __FILE__ );
    2222define( 'LARKBOTS_AI_CHAT_DIR', plugin_dir_path( __FILE__ ) );
    … …  
    5959}
    6060add_action( 'plugins_loaded', 'larkbots_ai_chat_boot' );
     61
     62/** Load the bundled admin translation when WordPress has no installed language pack. */
     63function larkbots_ai_chat_load_translations() {
     64        if ( ! is_admin() ) {
     65                return;
     66        }
     67        $locale = get_user_locale();
     68        if ( ! preg_match( '/^[a-z]{2,3}(?:_[A-Za-z0-9]+)*$/D', $locale ) ) {
     69                return;
     70        }
     71        $pack = WP_LANG_DIR . '/plugins/larkbots-ai-chat-' . $locale;
     72        if ( is_readable( $pack . '.mo' ) || is_readable( $pack . '.l10n.php' ) ) {
     73                return;
     74        }
     75        $catalog = str_replace( '-', '_', LarkBots_AI_Chat_Connection::connect_locale( $locale ) );
     76        $catalog = 'ja_JP' === $catalog ? 'ja' : $catalog;
     77        $file    = LARKBOTS_AI_CHAT_DIR . 'languages/larkbots-ai-chat-' . $catalog . '.mo';
     78        if ( '' !== $catalog && is_readable( $file ) ) {
     79                load_textdomain( 'larkbots-ai-chat', $file, $locale );
     80        }
     81}
     82add_action( 'init', 'larkbots_ai_chat_load_translations' );
  • larkbots-ai-chat/trunk/readme.txt

    r3840461 r3840711  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.2.1
     7Stable tag: 1.3.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    6868== Changelog ==
    6969
     70= 1.3.0 =
     71* Keep the administrator's language through WordPress setup, LarkBots account creation and site confirmation.
     72* Use the language of the public page for the hosted chat interface when supported.
     73
    7074= 1.2.1 =
    7175
Note: See TracChangeset for help on using the changeset viewer.