• Resolved Adriana Leites

    (@adrianaleites)


    Hello,

    Prior to the last WP security update (6.1.3), I managed to add TranslatePress language switcher shortcode inside navigation block in FSE themes as a custom link by just inserting [language-switcher] and it worked perfectly. Unfortunately, it stopped to work since 6.1.3 security update and it’s still not working after 6.2.2.

    I noticed that it’s a plugin block available called Language Switcher, but it’s not allowed inside the navigation block. Any plans to allow this block inside the navigation block in a future version of this plugin? Or the plugin can’t make this change, only the WordPress team?

    After some research, I managed to create the following function that changes the content of the nav menu item to run the language switcher block (also tried run the shortcode and the result is the same), it works but it is exposing the script code as text node in the front-end of the website. I tried to remove it or move it into a script tag using JavaScript, but it still flashes when page is loading. Not an ideal solution ??

    function add_lang_switcher_in_menu( $items ) {
      foreach ($items as $item) {
        if ( $item->parsed_block['attrs']['className'] === 'language-switcher' ) {
          $lang_switcher_block = '<!-- wp:trp/language-switcher /-->';
          $item->parsed_block["attrs"]["label"] = do_blocks( $lang_switcher_block );
        }
      }
      return $items;
    }
    add_filter('block_core_navigation_render_inner_blocks','add_lang_switcher_in_menu');

    Any suggestions on how to solve this issue will be much appreciated.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Anghel Emanuel

    (@anghelemanuel99)

    Hello there,

    Thank you for reaching us!

    Do you have the latest version of WP?

    If not,try to update to the latest version and check again.

    Let me know about this!

    Kind Regards,

    Thread Starter Adriana Leites

    (@adrianaleites)

    Hello Anghel,

    Thanks for your reply.

    Yes, I had updated WP to the latest version (6.2.2) and the issue persists. Shortcode [language-switcher] is no longer working when inserted as custom link in the navigation block.

    Is there any possibility to make the Language Switcher block available to use inside the Navigation block?

    Thanks!

    Plugin Support Alex

    (@alexcozmoslabs)

    We have to take the pulse of this ticket. Is there still an issue?
    In the meantime, I set this ticket as Resolved. You can also change its status back to unresolved and let us know by replying to this topic if your reqeust still needs attention.
    Another option is to let this ticket as it is and open a new one where to mention the issue again and ask for support.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Issue adding [language-switcher] in navigation block’ is closed to new replies.