Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter ab-tools

    (@ab-tools)

    … for whatever reasons it does not upload the screenshots, but it simple shows this JavaScript as visible(!) browser output right next to the flags:

        // need to have the same with set from JS on both divs. Otherwise it can push stuff around in HTML
        var trp_ls_shortcodes = document.querySelectorAll('.trp_language_switcher_shortcode .trp-language-switcher');
        if ( trp_ls_shortcodes.length > 0) {
            // get the last language switcher added
            var trp_el = trp_ls_shortcodes[trp_ls_shortcodes.length - 1];
    
            var trp_shortcode_language_item = trp_el.querySelector( '.trp-ls-shortcode-language' )
            // set width
            var trp_ls_shortcode_width                                               = trp_shortcode_language_item.offsetWidth + 16;
            trp_shortcode_language_item.style.width                                  = trp_ls_shortcode_width + 'px';
            trp_el.querySelector( '.trp-ls-shortcode-current-language' ).style.width = trp_ls_shortcode_width + 'px';
    
            // We're putting this on display: none after we have its width.
            trp_shortcode_language_item.style.display = 'none';
        }

    The flags are working, but why this JavaScript code is shown to the user?

    Best regards
    Andreas

    Thread Starter ab-tools

    (@ab-tools)

    OK, I found out what the issue is, but don’t have a good solution for it:
    When I add “[language-switcher]”, WordPress decides that it would be a good idea to add a “<p>”-Tag around it. Looks like this is not working well due to that.

    What is the best way to prevent that?

    Thanks
    Andreas

    Plugin Author Cristian Antohe

    (@sareiodata)

    Hi,

    It’s a bug with the shortcode block directly in WordPress

    To fix it, use the HTML block instead.

    Best Regards,

    Thread Starter ab-tools

    (@ab-tools)

    Hello Christian,

    first thanks for your quick reply, appreciated!

    I’ve tried just copying the HTML code directly, but despite I use the HTML editor (not the visual one), WordPress always adds a “<pre>” around the code I enter which just displays the code again instead of executing it.

    When I use the “[language-switcher]” tag, it does execute the code at this location, just shows the code to the user additionally.

    When I copy in the HTML code directly, it does not even execute it, just shows it to the user…

    Is there any way to work around this issue?

    Best regards and thanks again for your support
    Andreas

    Thread Starter ab-tools

    (@ab-tools)

    Hello Christian,

    first a happy New Year to you!

    Honestly, I’m a bit surprised to see that this topic is somehow marked as “Resolved” now.
    It is not resolved, I still see this issue.

    Best regards and looking forward to a reply from you, thanks
    Andreas

    • This reply was modified 11 months, 1 week ago by ab-tools.
    Plugin Author Cristian Antohe

    (@sareiodata)

    Hi Andreas,

    It’s possible the user you’re trying to use and add the shortcode does not have enough permissions and the input gets escaped.

    Can you please confirm it’s an administrator account with which you’re trying to add the shortcode? It sounds like the entire content generated gets escaped by WordPress or another plugin. It should not happen by default.

    You can also try and do a compatibility test. Ideally in a staging environment. Disable all plugins and activate a default WordPress theme, then try again and see if it still happens.

    Best Regards!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Shows JavaScript Output to the User’ is closed to new replies.