Plugin Directory

Changeset 3332960


Ignore:
Timestamp:
07/23/2025 01:33:43 PM (8 months ago)
Author:
muchatai
Message:

Update to version 2.0.44 from GitHub

Location:
muchat-ai
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • muchat-ai/tags/2.0.44/includes/Admin/Settings.php

    r3332933 r3332960  
    247247        $guest_context = get_option('muchat_ai_chatbot_guest_context', '');
    248248        $load_strategy = get_option('muchat_ai_chatbot_load_strategy', 'FAST');
     249        $script_position = get_option('muchat_ai_chatbot_script_position', 'head');
    249250        $use_logged_in_user_info = get_option('muchat_ai_chatbot_use_logged_in_user_info', '');
    250251        $widget_enabled = get_option('muchat_ai_chatbot_widget_enabled', '1');
     
    835836            'default' => 'FAST'
    836837        ));
     838        register_setting('muchat-settings-group', 'muchat_ai_chatbot_script_position', array(
     839            'type' => 'string',
     840            'sanitize_callback' => 'sanitize_text_field'
     841        ));
    837842        register_setting('muchat-settings-group', 'muchat_ai_chatbot_use_logged_in_user_info', array(
    838843            'type' => 'string',
     
    910915        // Default load strategy
    911916        add_option('muchat_ai_chatbot_load_strategy', 'FAST');
     917        add_option('muchat_ai_chatbot_script_position', 'footer');
    912918
    913919        // Default visibility settings
  • muchat-ai/tags/2.0.44/includes/Frontend/Widget.php

    r3332933 r3332960  
    1010    public function __construct()
    1111    {
    12         add_action('wp_head', [$this, 'hook_head'], 1);
     12        // For existing users, the option won't exist, so we default to 'head' for
     13        // backward compatibility. For new installs, the default is set to 'footer'
     14        // in 'includes/Admin/Settings.php' during activation.
     15        $position = get_option('muchat_ai_chatbot_script_position', 'head');
     16        $hook = 'wp_head'; // Default hook
     17
     18        if ($position === 'footer') {
     19            $hook = 'wp_footer';
     20        } elseif ($position === 'body_open') {
     21            // wp_body_open was introduced in WP 5.2.
     22            // We'll use it if available, otherwise fallback to wp_footer.
     23            if (function_exists('wp_body_open')) {
     24                $hook = 'wp_body_open';
     25            } else {
     26                $hook = 'wp_footer';
     27            }
     28        }
     29       
     30        add_action($hook, [$this, 'hook_head'], 1);
    1331        $this->register_cache_clearing_hooks();
    1432    }
     
    2341        add_action('update_option_muchat_ai_chatbot_use_logged_in_user_info', [$this, 'clear_widget_cache']);
    2442        add_action('update_option_muchat_ai_chatbot_load_strategy', [$this, 'clear_widget_cache']);
     43        add_action('update_option_muchat_ai_chatbot_script_position', [$this, 'clear_widget_cache']);
    2544        add_action('update_option_muchat_ai_chatbot_widget_enabled', [$this, 'clear_widget_cache']);
    2645    }
  • muchat-ai/tags/2.0.44/muchat-ai.php

    r3332933 r3332960  
    55 * Plugin URI: https://mu.chat
    66 * Description: Muchat, a powerful tool for customer support using artificial intelligence
    7  * Version: 2.0.43
     7 * Version: 2.0.44
    88 * Author: Muchat
    99 * Text Domain: muchat-ai
     
    2727
    2828// Define plugin constants with unique prefix
    29 define('MUCHAT_AI_CHATBOT_PLUGIN_VERSION', '2.0.43');
     29define('MUCHAT_AI_CHATBOT_PLUGIN_VERSION', '2.0.44');
    3030// define('MUCHAT_AI_CHATBOT_CACHE_DURATION', HOUR_IN_SECONDS);
    3131define('MUCHAT_AI_CHATBOT_PLUGIN_FILE', __FILE__);
  • muchat-ai/tags/2.0.44/readme.txt

    r3332933 r3332960  
    44Requires at least: 5.0
    55Tested up to: 6.8
    6 Stable tag: 2.0.43
     6Stable tag: 2.0.44
    77Requires PHP: 7.4
    88License: GPLv2 or later
     
    7575
    7676== Changelog ==
     77
     78= 2.0.44 =
     79* Feature: Added a "Script Load Position" setting (Header, Footer, Body Opening) to provide control over widget loading and improve site performance.
     80* Tweak: The default script load position for new installations is now "Footer" for better performance, while maintaining "Header" for existing sites to ensure backward compatibility.
    7781
    7882= 2.0.43 =
  • muchat-ai/tags/2.0.44/templates/admin/widget-settings.php

    r3332933 r3332960  
    186186                                </td>
    187187                            </tr>
     188                            <tr valign="top">
     189                                <th scope="row"><?php esc_html_e('Script Load Position', 'muchat-ai'); ?></th>
     190                                <td>
     191                                    <select name="muchat_ai_chatbot_script_position" class="regular-text">
     192                                        <option value="footer" <?php selected($script_position, 'footer'); ?>><?php esc_html_e('Footer (Recommended for Performance)', 'muchat-ai'); ?></option>
     193                                        <option value="head" <?php selected($script_position, 'head'); ?>><?php esc_html_e('Header', 'muchat-ai'); ?></option>
     194                                        <option value="body_open" <?php selected($script_position, 'body_open'); ?>><?php esc_html_e('Body Opening', 'muchat-ai'); ?></option>
     195                                    </select>
     196                                    <p class="description">
     197                                        <?php esc_html_e('Determines where the widget script is loaded on your page. Loading in the footer improves page speed.', 'muchat-ai'); ?>
     198                                    </p>
     199                                </td>
     200                            </tr>
    188201                        </table>
    189202                    </div>
  • muchat-ai/trunk/includes/Admin/Settings.php

    r3332933 r3332960  
    247247        $guest_context = get_option('muchat_ai_chatbot_guest_context', '');
    248248        $load_strategy = get_option('muchat_ai_chatbot_load_strategy', 'FAST');
     249        $script_position = get_option('muchat_ai_chatbot_script_position', 'head');
    249250        $use_logged_in_user_info = get_option('muchat_ai_chatbot_use_logged_in_user_info', '');
    250251        $widget_enabled = get_option('muchat_ai_chatbot_widget_enabled', '1');
     
    835836            'default' => 'FAST'
    836837        ));
     838        register_setting('muchat-settings-group', 'muchat_ai_chatbot_script_position', array(
     839            'type' => 'string',
     840            'sanitize_callback' => 'sanitize_text_field'
     841        ));
    837842        register_setting('muchat-settings-group', 'muchat_ai_chatbot_use_logged_in_user_info', array(
    838843            'type' => 'string',
     
    910915        // Default load strategy
    911916        add_option('muchat_ai_chatbot_load_strategy', 'FAST');
     917        add_option('muchat_ai_chatbot_script_position', 'footer');
    912918
    913919        // Default visibility settings
  • muchat-ai/trunk/includes/Frontend/Widget.php

    r3332933 r3332960  
    1010    public function __construct()
    1111    {
    12         add_action('wp_head', [$this, 'hook_head'], 1);
     12        // For existing users, the option won't exist, so we default to 'head' for
     13        // backward compatibility. For new installs, the default is set to 'footer'
     14        // in 'includes/Admin/Settings.php' during activation.
     15        $position = get_option('muchat_ai_chatbot_script_position', 'head');
     16        $hook = 'wp_head'; // Default hook
     17
     18        if ($position === 'footer') {
     19            $hook = 'wp_footer';
     20        } elseif ($position === 'body_open') {
     21            // wp_body_open was introduced in WP 5.2.
     22            // We'll use it if available, otherwise fallback to wp_footer.
     23            if (function_exists('wp_body_open')) {
     24                $hook = 'wp_body_open';
     25            } else {
     26                $hook = 'wp_footer';
     27            }
     28        }
     29       
     30        add_action($hook, [$this, 'hook_head'], 1);
    1331        $this->register_cache_clearing_hooks();
    1432    }
     
    2341        add_action('update_option_muchat_ai_chatbot_use_logged_in_user_info', [$this, 'clear_widget_cache']);
    2442        add_action('update_option_muchat_ai_chatbot_load_strategy', [$this, 'clear_widget_cache']);
     43        add_action('update_option_muchat_ai_chatbot_script_position', [$this, 'clear_widget_cache']);
    2544        add_action('update_option_muchat_ai_chatbot_widget_enabled', [$this, 'clear_widget_cache']);
    2645    }
  • muchat-ai/trunk/muchat-ai.php

    r3332933 r3332960  
    55 * Plugin URI: https://mu.chat
    66 * Description: Muchat, a powerful tool for customer support using artificial intelligence
    7  * Version: 2.0.43
     7 * Version: 2.0.44
    88 * Author: Muchat
    99 * Text Domain: muchat-ai
     
    2727
    2828// Define plugin constants with unique prefix
    29 define('MUCHAT_AI_CHATBOT_PLUGIN_VERSION', '2.0.43');
     29define('MUCHAT_AI_CHATBOT_PLUGIN_VERSION', '2.0.44');
    3030// define('MUCHAT_AI_CHATBOT_CACHE_DURATION', HOUR_IN_SECONDS);
    3131define('MUCHAT_AI_CHATBOT_PLUGIN_FILE', __FILE__);
  • muchat-ai/trunk/readme.txt

    r3332933 r3332960  
    44Requires at least: 5.0
    55Tested up to: 6.8
    6 Stable tag: 2.0.43
     6Stable tag: 2.0.44
    77Requires PHP: 7.4
    88License: GPLv2 or later
     
    7575
    7676== Changelog ==
     77
     78= 2.0.44 =
     79* Feature: Added a "Script Load Position" setting (Header, Footer, Body Opening) to provide control over widget loading and improve site performance.
     80* Tweak: The default script load position for new installations is now "Footer" for better performance, while maintaining "Header" for existing sites to ensure backward compatibility.
    7781
    7882= 2.0.43 =
  • muchat-ai/trunk/templates/admin/widget-settings.php

    r3332933 r3332960  
    186186                                </td>
    187187                            </tr>
     188                            <tr valign="top">
     189                                <th scope="row"><?php esc_html_e('Script Load Position', 'muchat-ai'); ?></th>
     190                                <td>
     191                                    <select name="muchat_ai_chatbot_script_position" class="regular-text">
     192                                        <option value="footer" <?php selected($script_position, 'footer'); ?>><?php esc_html_e('Footer (Recommended for Performance)', 'muchat-ai'); ?></option>
     193                                        <option value="head" <?php selected($script_position, 'head'); ?>><?php esc_html_e('Header', 'muchat-ai'); ?></option>
     194                                        <option value="body_open" <?php selected($script_position, 'body_open'); ?>><?php esc_html_e('Body Opening', 'muchat-ai'); ?></option>
     195                                    </select>
     196                                    <p class="description">
     197                                        <?php esc_html_e('Determines where the widget script is loaded on your page. Loading in the footer improves page speed.', 'muchat-ai'); ?>
     198                                    </p>
     199                                </td>
     200                            </tr>
    188201                        </table>
    189202                    </div>
Note: See TracChangeset for help on using the changeset viewer.