Plugin Directory

Changeset 2721992


Ignore:
Timestamp:
05/11/2022 01:05:21 PM (4 years ago)
Author:
melibo
Message:

Disable chatbot on specific sites

Location:
melibo-chatbot
Files:
33 added
7 edited

Legend:

Unmodified
Added
Removed
  • melibo-chatbot/trunk/admin/MeliboChatbot.class.php

    r2721797 r2721992  
    3030
    3131    public function initSettings() {
    32         add_settings_section('melibo_general_section', __('General', MeliboChatbot::PLUGIN_NAME), null, 'melibo-settings-page');
    33         add_settings_section('melibo_environment_section', __('Environment', MeliboChatbot::PLUGIN_NAME), null, 'melibo-settings-page');
    34 
     32        $this->initSections();
     33       
    3534        $this->initApiKeyField();
    3635        $this->initEnvironmentIDField();
    3736        $this->initSelectPagesForEnvironmentChatbotField();
    3837        $this->initActivationField();
     38        $this->initExcludedPages();
     39    }
     40
     41    private function initSections() {
     42        add_settings_section('melibo_general_section', __('General', MeliboChatbot::PLUGIN_NAME), null, 'melibo-settings-page');
     43        add_settings_section('melibo_environment_section', __('Environment', MeliboChatbot::PLUGIN_NAME), null, 'melibo-settings-page');
    3944    }
    4045
     
    104109        );
    105110        register_setting('meliboplugin', 'melibo_activate', array($this->meliboValidationClass, 'activateValidation'));
     111    }
     112
     113    private function initExcludedPages() {
     114        add_settings_field(
     115            'melibo_excluded_pages',
     116            __('excluded pages', MeliboChatbot::PLUGIN_NAME),
     117            array($this, 'checkboxPageListHTML'),
     118            'melibo-settings-page',
     119            'melibo_general_section',
     120            array(
     121                'id' => 'melibo_excluded_pages',
     122                'name' => 'melibo_excluded_pages',
     123                'info' => sprintf('%s <u>%s</u> %s',
     124                                  __('Select the pages you do', MeliboChatbot::PLUGIN_NAME),
     125                                  __('not', MeliboChatbot::PLUGIN_NAME),
     126                                  __('want your chatbot to appear on.', MeliboChatbot::PLUGIN_NAME)),
     127                'multiple' => true
     128            )
     129        );
     130        register_setting('meliboplugin', 'melibo_excluded_pages');
    106131    }
    107132
     
    162187
    163188    public function showChatbot($content) {
    164         global $post;
    165         $environmentChatbotPageIDArray = get_option('melibo_environment_select_pages');
    166 
    167         if(get_option('melibo_activate', '1') AND (is_page() OR is_front_page() OR is_single())) {
     189        $activated = $this->isChatbotActivated();
     190        $showOnPage = $this->showOnPage();
     191        $isExcludedPage = $this->isExcludedPage();
     192        $isEnvironmentPage = $this->isEnvironmentPage();
     193
     194        if($activated AND $showOnPage) {
     195            if($isExcludedPage) {
     196                return true;
     197            }
     198
    168199            wp_enqueue_script('cdn-melibo-chatbot', $this->CDN_URL);
    169             if($environmentChatbotPageIDArray AND count($environmentChatbotPageIDArray) > 0 AND in_array($post->ID, $environmentChatbotPageIDArray)) { ?>
     200            if($isEnvironmentPage) { ?>
    170201                <melibo-webchat api-key="<?php echo esc_attr(get_option('melibo_api_key')); ?>"
    171202                                environment-id="<?php echo esc_attr(get_option('melibo_environment_id')); ?>"></melibo-webchat>
     
    178209    }
    179210
     211    private function isChatbotActivated() {
     212        return get_option('melibo_activate', '1');
     213    }
     214
     215    private function showOnPage() {
     216        return (is_page() OR is_front_page() OR is_single());
     217    }
     218
     219    private function isExcludedPage() {
     220        global $post;
     221        $exludedPages = get_option('melibo_excluded_pages');
     222        return is_array($exludedPages) AND in_array($post->ID, $exludedPages);
     223    }
     224
     225    private function isEnvironmentPage() {
     226        global $post;
     227        $environmentPages = get_option('melibo_environment_select_pages');
     228        return is_array($environmentPages) AND in_array($post->ID, $environmentPages);
     229    }
     230
    180231    public function addSettingsLink($links) {
    181232       
  • melibo-chatbot/trunk/admin/MeliboView.class.php

    r2721825 r2721992  
    260260        </select>
    261261        <?php if(isset($args['info']) == true) { ?>
    262             <p><?php echo esc_attr($args['info']); ?></p>
     262            <p><?php echo $args['info']; ?></p>
    263263        <?php }
    264264    }
  • melibo-chatbot/trunk/admin/inc/js/admin.js

    r2721797 r2721992  
    11jQuery(function ($) {
    22    // multiple select with AJAX search
    3     $('#melibo_environment_select_pages').select2({
     3    $('#melibo_environment_select_pages, #melibo_excluded_pages').select2({
    44        ajax: {
    55            url: ajaxurl, // AJAX URL is predefined in WordPress admin
  • melibo-chatbot/trunk/languages/melibo-chatbot-de_DE.po

    r2721825 r2721992  
    22msgstr ""
    33"Project-Id-Version: \n"
    4 "POT-Creation-Date: 2022-05-11 10:54+0200\n"
    5 "PO-Revision-Date: 2022-05-11 10:54+0200\n"
     4"POT-Creation-Date: 2022-05-11 14:55+0200\n"
     5"PO-Revision-Date: 2022-05-11 14:56+0200\n"
    66"Last-Translator: \n"
    77"Language-Team: \n"
     
    1717"X-Poedit-SearchPath-0: .\n"
    1818
    19 #: admin/MeliboChatbot.class.php:32
     19#: admin/MeliboChatbot.class.php:42
    2020msgid "General"
    2121msgstr "Allgemein"
    2222
    23 #: admin/MeliboChatbot.class.php:33
     23#: admin/MeliboChatbot.class.php:43
    2424msgid "Environment"
    2525msgstr "Environment"
    2626
    27 #: admin/MeliboChatbot.class.php:44
     27#: admin/MeliboChatbot.class.php:49
    2828msgid "API Key"
    2929msgstr "API Key"
    3030
    31 #: admin/MeliboChatbot.class.php:50
     31#: admin/MeliboChatbot.class.php:55
    3232msgid ""
    3333"You can find the API key for your chatbot in your melibo account under "
     
    3939"sehen."
    4040
    41 #: admin/MeliboChatbot.class.php:57 admin/MeliboValidation.class.php:34
     41#: admin/MeliboChatbot.class.php:62 admin/MeliboValidation.class.php:34
    4242msgid "The API key must not contain any spaces."
    4343msgstr "Der API-Key darf keine Leerzeichen enthalten."
    4444
    45 #: admin/MeliboChatbot.class.php:64
     45#: admin/MeliboChatbot.class.php:69
    4646msgid "Environment ID"
    4747msgstr "Environment ID"
    4848
    49 #: admin/MeliboChatbot.class.php:70
     49#: admin/MeliboChatbot.class.php:75
    5050msgid ""
    5151"You can optionally use the Environment ID if you want to use different chat "
     
    6060"unterschiedlichen Auftritt geben."
    6161
    62 #: admin/MeliboChatbot.class.php:79
     62#: admin/MeliboChatbot.class.php:84
    6363msgid "page selection"
    6464msgstr "Seitenauswahl"
    6565
    66 #: admin/MeliboChatbot.class.php:86
     66#: admin/MeliboChatbot.class.php:91
    6767msgid "Select the pages you want your chatbot to appear on."
    6868msgstr "Wähle die Seiten aus, auf denen dein Chatbot erscheinen soll."
    6969
    70 #: admin/MeliboChatbot.class.php:96
     70#: admin/MeliboChatbot.class.php:101
    7171msgid "Activate chatbot"
    7272msgstr "Chatbot aktivieren"
    7373
    74 #: admin/MeliboChatbot.class.php:102
     74#: admin/MeliboChatbot.class.php:107
    7575msgid ""
    7676"As soon as you tick the box here and click on \"Save changes\", your melibo "
     
    8080"klickst, wird dein melibo Chatbot auf deiner Website erscheinen."
    8181
    82 #: admin/MeliboChatbot.class.php:135
     82#: admin/MeliboChatbot.class.php:116
     83msgid "excluded pages"
     84msgstr "ausgeschlossene Seiten"
     85
     86#: admin/MeliboChatbot.class.php:124
     87msgid "Select the pages you do"
     88msgstr "Wähle die Seiten aus, auf denen dein Chatbot"
     89
     90#: admin/MeliboChatbot.class.php:125
     91msgid "not"
     92msgstr "nicht"
     93
     94#: admin/MeliboChatbot.class.php:126
     95msgid "want your chatbot to appear on."
     96msgstr "erscheinen soll."
     97
     98#: admin/MeliboChatbot.class.php:160
    8399msgid "melibo Settings"
    84100msgstr "melibo Einstellungen"
    85101
    86 #: admin/MeliboChatbot.class.php:188 admin/MeliboView.class.php:30
     102#: admin/MeliboChatbot.class.php:239 admin/MeliboView.class.php:30
    87103msgid "Settings"
    88104msgstr "Einstellungen"
     
    374390msgstr "Jetzt beginnen!"
    375391
     392#~ msgid "Select the pages you do not want your chatbot to appear on."
     393#~ msgstr "Wähle die Seiten aus, auf denen dein Chatbot nicht erscheinen soll."
     394
    376395#~ msgid "Add"
    377396#~ msgstr "Hinzufügen"
  • melibo-chatbot/trunk/melibo-chatbot.php

    r2721825 r2721992  
    44 * Plugin Name: melibo Chatbot
    55 * Description: add your melibo chatbot to your WordPress for free
    6  * Version: 1.4.2
     6 * Version: 1.4.3
    77 * Author: Melibo
    88 * Author URI: www.melibo.de
     
    1010 * Domain Path: /languages/
    1111 */
    12 define( 'MELIBO_VERSION', '1.4.2');
     12define( 'MELIBO_VERSION', '1.4.3');
    1313
    1414require_once( plugin_dir_path( __FILE__ ) . '/admin/MeliboTranslation.class.php' );
  • melibo-chatbot/trunk/readme.txt

    r2721825 r2721992  
    33Tags: chat, live chat, chatbot, support, livechat, bot, melibo, Helpdesk, E-Commerce, messenger, AI, widget,
    44Tested up to: 5.9.2
    5 Stable tag: 1.4.2
     5Stable tag: 1.4.3
    66License: GPLv2
    77License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    180180
    181181- Add Page selection info Text
     182
     183= 1.4.3 =
     184
     185- Disable chatbot on specific sites
Note: See TracChangeset for help on using the changeset viewer.