Disable GTranslate on the Add Listing page

If you’re using GTranslate plugin and when a user translates a page, the text deletes itself as you type, please resolve it by putting the following code to your functions.php of Child Theme

add_action('wp_enqueue_scripts', function (){
    ob_start();
    ?>
        waitForElementToDisplay(".ql-container",function(){
            let problematic_cont = document.querySelector(".ql-container");
            problematic_cont.classList.add("notranslate");
        },1000,9000);
        
        function waitForElementToDisplay(selector, callback, checkFrequencyInMs, timeoutInMs) {
            var startTimeInMs = Date.now();
            (function loopSearch() {
                if (document.querySelector(selector) != null) {
                    callback();
                    return;
                }

                else {
                    setTimeout(function () {
                        if (timeoutInMs && Date.now() - startTimeInMs > timeoutInMs) {
                            return;
                        }
                        loopSearch();
                    }, checkFrequencyInMs);

                }
            })();
        }
        var myNewTag = document.getElementsByClassName("quillWrapper");
        for(var i = 0; i < myNewTag.length; i++) { 
            if(myNewTag) { 
                myNewTag[i].classList.add("notranslate"); 
            }
        }
        <?php
    $content = ob_get_contents();
    ob_end_clean();
    
    wp_add_inline_script('jquery', $content);
});
Tagged:

Leave A Comment?