ouun / zammad-wp

Zammad WordPress integration
GNU General Public License v2.0
27 stars 5 forks source link

Updating the chat title string in defaults: some options not updating! #1

Closed Marcquito closed 3 years ago

Marcquito commented 3 years ago

First of all, thank you so much for the fantastic work. This integration is incredible!

My issue is with the defaults when configuring/modifying the chat box within wp-config.php. For example, the color easily updates as a default color, but the title string and flat boolean do not seem to update.

Example: 'title' => 'Need a hand?', 'background' => '#00adef;', <- This is the only one that works. 'flat' => true

Any insight on what could be wrong? Thank you for the help!

ouun commented 3 years ago

Hi @Marcquito,

thanks for the positive feedback. Sounds like you are trying to add the code to the wrong file wp-config.php. The only reason why it seems to work for you is, that the scripts tries to find the "primary" color of your website automatically. This is for sure misleading you...

wp-config.php is only used to define global variables. All other code should either go into your themes function.php or you add a new file in /mu-plugins.

Kind regards

Marcquito commented 3 years ago

Thanks for the reply @ouun ! I appreciate the clarification. I moved the code into the functions.php of the theme and I seem to get the same result. **See attached for my code within functions.php

As with the previous result, I'm able to change the background color here, but none of the other filters seem to work. Just to be clear though, the chat still functions beautifully outside of that! What else do you think I could have done incorrectly? I'm also including a few screenshots if that helps. 👍

Here's the code living within the functions:

chat-code

Here's the chat after the update with the old title, but with the new bg color:

chat-title
ouun commented 3 years ago

OK, I will need to double-chack the zammad_wp:chat:defaults filter, but you should be able to remove the whole block and just add the array keys and values to the zammad_register_chat function above. That works for sure, I am using it on live sites as well. So you will end with something like this:

add_action('admin_init', function () {
    if (function_exists('zammad_register_chat')) {
        // Logged in user at least with editor role, load chat with topic '2'
        if (is_user_logged_in() && current_user_can('edit_posts')) {
            zammad_register_chat( 2, [
                'buttonClass' => 'button action',
                'target' => '$("#wpbody")',
                'formFallback' => true,
                'background' => '#333',
                'flat' => true,
                'chatTitle' => 'My new chat title!'
            ] );
        }
    }
});

EDIT: And please have a look to the filter here as it should be the key chatTitle and not title. I need to update the docs as I changed that without taking notice to the readme.

Marcquito commented 3 years ago

A HUGE thank you for the great response. Not long before your last reply, I did discover 'chatTitle' to be the correct filter. The code update definitely works. Thanks again for the powerful integration!

ouun commented 3 years ago

Glad that worked! :)