Title: Widget code replacement
Last modified: October 22, 2023

---

# Widget code replacement

 *  [KS](https://wordpress.org/support/users/karl19/)
 * (@karl19)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/widget-code-replacement/)
 * Hello, we had the gtranslate shortcode working fine, until we tried updating 
   to v3. We were using the Widget Code code, as it allowed us to add an additional
   language flag for a language we didn’t want gTranslate to translate, instead 
   it linked to a specific URL where we collected manually translated content for
   that language.
 * In this post [https://wordpress.org/support/topic/development-version-3-0-1-broke-our-site-dropdown-menu/#post-16519833](https://wordpress.org/support/topic/development-version-3-0-1-broke-our-site-dropdown-menu/#post-16519833),
   you write that Widget Code is gone and not coming back, what would be the alternative
   for our scenario? We have five languages, our “manual language” was in position
   2, so we would like to get it back into the list of languages.
 * Any solutions would be much appreciated!

Viewing 15 replies - 1 through 15 (of 20 total)

1 [2](https://wordpress.org/support/topic/widget-code-replacement/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/widget-code-replacement/page/2/?output_format=md)

 *  Thread Starter [KS](https://wordpress.org/support/users/karl19/)
 * (@karl19)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/widget-code-replacement/#post-16819046)
 * I could get it to work with:
 *     ```wp-block-code
       <?php echo do_shortcode('[gt-link lang="en" label="" widget_look="flags_name"]'); ?>
       <a href="#" onclick="doGTranslate('en|en');location.href = 'https://www.ourwebsite.com/manual-lang-page/';return false;" class="glink nturl notranslate"><img src="/wp-content/plugins/gtranslate/flags/24/fr.png" height="24" width="24" alt="Français"></a>
       <?php echo do_shortcode('[gt-link lang="de" label="" widget_look="flags_name"]'); ?>
       <?php echo do_shortcode('[gt-link lang="it" label="" widget_look="flags_name"]'); ?>
       <?php echo do_shortcode('[gt-link lang="sv" label="" widget_look="flags_name"]'); ?>
       ```
   
 * but it doesn’t look very clean. But perhaps this is the only way to do it, if
   Widget Code is gone?
 *  Thread Starter [KS](https://wordpress.org/support/users/karl19/)
 * (@karl19)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/widget-code-replacement/#post-16819247)
 * I do still have one problem. Previously I could wrap the gTranslate inside another
   shortcode – for Borlabs Cookies – like this:
 *     ```wp-block-code
       <?php echo do_shortcode('[borlabs-cookie id="google-translate" type="cookie"][gtranslate][/borlabs-cookie]'); ?>
       ```
   
 * and it was possible to show or hide flags, depending on whether cookies were 
   accepted. If I run this now, with gt-link:
 *     ```wp-block-code
       <?php echo do_shortcode('[borlabs-cookie id="google-translate" type="cookie"][gt-link lang="en" label="" widget_look="flags_name"][/borlabs-cookie]'); ?>
       ```
   
 * the flags show if I allow cookies, but nothing happens if I click on them. If
   I look at the HTML, it looks like this:
 *     ```wp-block-code
       <a href="#" data-gt-lang="en" class="gt-current-lang"><img src="/wp-content/plugins/gtranslate/flags/24/en.png" width="24" height="24" alt="en" loading="lazy"> <span></span></a>
       ```
   
 * If I don’t wrap the gTranslate shortcode in the Borlabs shortcode, instead it
   outputs this:
 *     ```wp-block-code
       <a href="#" data-gt-lang="en" class="glink nturl notranslate gt_raw_link-xxjexk gt-current-lang" title="English"><img src="/wp-content/plugins/gtranslate/flags/24/en.png" width="24" height="24" alt="en" loading="lazy"> <span></span></a>
       ```
   
 * which works fine. I don’t know if it’s Borlabs or gTranslate that doesn’t play
   nice with the other plugin?
 *  Thread Starter [KS](https://wordpress.org/support/users/karl19/)
 * (@karl19)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/widget-code-replacement/#post-16820822)
 * Just as a bit of additional info: since I updated both the Borlabs Cookie and
   gTranslate plugins, I wasn’t sure which plugin caused issues. Keeping Borlabs
   updated to latest version, but rolling gTranslate back to 2.9.13 and then running:
 *     ```wp-block-code
       <?php echo do_shortcode('[borlabs-cookie id="google-translate" type="cookie"][gtranslate][/borlabs-cookie]'); ?>
       ```
   
 * works fine. Running the same code on gTranslate 3.0.3 (or 3.0.1 which I also 
   tried), nothing is output. So it does seem like gTranslate doesn’t cope well 
   being loaded inside another shortcode. And as mentioned above, if running:
 *     ```wp-block-code
       <?php echo do_shortcode('[borlabs-cookie id="google-translate" type="cookie"][gt-link lang="en" label="" widget_look="flags_name"][/borlabs-cookie]'); ?>
       ```
   
 * the flags show, but nothing happens if they get clicked. I don’t know what technically
   is causing this, but it seems like gTranslate doesn’t fully load all its code,
   when getting loaded inside another shortcode.
 *  Plugin Author [edo888](https://wordpress.org/support/users/edo888/)
 * (@edo888)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/widget-code-replacement/#post-16832191)
 * Hi,
 * Using the shortcode to create individual language links is the way to go as you
   have already done.
 * Please consult with Borlabs Cookie for your next question.
 * Thanks! 🙂
 *  Thread Starter [KS](https://wordpress.org/support/users/karl19/)
 * (@karl19)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/widget-code-replacement/#post-16839734)
 * Hi [@edo888](https://wordpress.org/support/users/edo888/) many thanks for the
   reply!
 * I was in contact with Borlabs, they said their shortcode doesn’t modify anything
   that their shortcode blocks. So it’s not their plugin that actively strips out
   the **glink nturl notranslate gt_raw_link-xxjexk** classes.
 * Their guess was that gTranslate sets these classes with JavaScript on page load,
   and while in our case the flags only show after cookies are confirmed, this doesn’t
   happen.
 * Could that be the reason? Is there anyway to delay the gTranslate function, until
   after cookies are confirmed?
 *  Thread Starter [KS](https://wordpress.org/support/users/karl19/)
 * (@karl19)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/widget-code-replacement/#post-16882451)
 * Hello [@edo888](https://wordpress.org/support/users/edo888/), would be great 
   with some input on whether GTranslate sets the above classes on page load and
   if so, if there is a way to delay this process until cookies are confirmed, or
   a way to reset them. Thanks!
 *  [fruchtfliege](https://wordpress.org/support/users/fruchtfliege/)
 * (@fruchtfliege)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/widget-code-replacement/#post-16887238)
 * I have the same question. I can’t get Borlabs Cookie to work with Gtranslate 
   with nested shortcode as mentioned in the comment above. We need a way to reinitialize
   Gtranslate after consent. Is there any function for this?
    -  This reply was modified 2 years, 10 months ago by [fruchtfliege](https://wordpress.org/support/users/fruchtfliege/).
 *  Thread Starter [KS](https://wordpress.org/support/users/karl19/)
 * (@karl19)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/widget-code-replacement/#post-17085532)
 * Hi [@fruchtfliege](https://wordpress.org/support/users/fruchtfliege/) , did you
   ever manage to figure this out? There hasn’t been any more input from gTranslate.
 *  [fruchtfliege](https://wordpress.org/support/users/fruchtfliege/)
 * (@fruchtfliege)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/widget-code-replacement/#post-17085598)
 * Hi [@karl19](https://wordpress.org/support/users/karl19/), no. I have to prevent
   updates for gtranslate where my clients use it in combination with borlabs cookie,
   which is a huge security issue.
 * Support has to find a way to use gtranslate like in the early releases. This 
   couldn’t be that hard… Please fix this!
 *  Plugin Author [edo888](https://wordpress.org/support/users/edo888/)
 * (@edo888)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/widget-code-replacement/#post-17085844)
 * Hi,
 * Please direct your questions about Borlabs Cookie to Borlabs support.
 * They are the ones who should investigate why their plugin causes conflicts with
   GTranslate and offer you a solution.
 * Thanks! 🙂
 *  Thread Starter [KS](https://wordpress.org/support/users/karl19/)
 * (@karl19)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/widget-code-replacement/#post-17086499)
 * Hi [@edo888](https://wordpress.org/support/users/edo888/) thanks for the reply,
   but please see above [https://wordpress.org/support/topic/widget-code-replacement/#post-16839734](https://wordpress.org/support/topic/widget-code-replacement/#post-16839734).
   
   Borlabs did look into it and said their shortcode doesn’t block anything.
 * Their guess was that gTranslate loads the relevant classes on page load and when
   it’s delayed through a cookie function, it doesn’t load the correct classes as
   the page has already loaded. So it seems like gTranslate is causing the issue
   here, not Borlabs, as they just provide a standard cookie functionality.
 *  Plugin Author [edo888](https://wordpress.org/support/users/edo888/)
 * (@edo888)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/widget-code-replacement/#post-17086504)
 * Hi,
 * There shouldn’t be any guesses. They need to find out the root cause specifically.
 * I’m not spending my time debugging their plugin.
 * Thanks! 🙂
 *  [fruchtfliege](https://wordpress.org/support/users/fruchtfliege/)
 * (@fruchtfliege)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/widget-code-replacement/#post-17086535)
 * [@edo888](https://wordpress.org/support/users/edo888/) you are wrong: borlabs
   cookie just blocks the execution of gtranslate until the user grant consent. 
   To make this work, you have to put your shortcode into the wrapper shortcode 
   of borlabs, like this:
 *     ```wp-block-code
       [borlabs-cookie id="gtranslate" type="cookie"][gtranslate][/borlabs-cookie]
       ```
   
 * From gtranslate release 2.9.12 on, this method is not working anymore. It seems
   that your shortcode can not be initialized “live” after consent. There must have
   been some changes in newer releases of gtranslate regarding initialization or
   something. After all, it is nothing borlabs cookie can fix, since it only blocks
   the shortcode, which worked fine until 2.9.12.
 * Maybe you don’t care about GDPR that much, but there are a lot of users in europe
   who need borlabs cookie to work with gtranslate. I wouldn’t care if it NEVER 
   worked, but it did, as I already mentioned.
 * If you are not willed to dive deep in this issue, maybe you could just tell us
   what changed from 2.9.12 on in a few words.
 *  Thread Starter [KS](https://wordpress.org/support/users/karl19/)
 * (@karl19)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/widget-code-replacement/#post-17086740)
 * I can only concur with [@fruchtfliege](https://wordpress.org/support/users/fruchtfliege/).
   It used to work, Borlabs hasn’t changed their setup and I find it a bit disappointing
   that you get hung up on me saying “Borlabs’ guess is .. ” – they just gave their
   opinion on why the combination of the two plugins doesn’t work any longer. It
   doesn’t mean that their plugins breaks the functionality and they have something
   to fix or that somehow you need to debug their plugin.
 * This functionality used to work, for both me and [@fruchtfliege](https://wordpress.org/support/users/fruchtfliege/),
   later versions of gTranslate seem to have changed how it gets initialised and
   this causes issues in relation to cookie control and the GDPR.
 *  [fruchtfliege](https://wordpress.org/support/users/fruchtfliege/)
 * (@fruchtfliege)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/widget-code-replacement/#post-17141094)
 * Why is this thread marked as resolved? It isn’t. There were plenty updates for
   this plugin, but even latest update doesn’t fix this problem.
 * [@edo888](https://wordpress.org/support/users/edo888/): Please tell me if this
   topic over for you, so I can give up hope and watch out for another plugin.

Viewing 15 replies - 1 through 15 (of 20 total)

1 [2](https://wordpress.org/support/topic/widget-code-replacement/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/widget-code-replacement/page/2/?output_format=md)

The topic ‘Widget code replacement’ is closed to new replies.

 * ![](https://ps.w.org/gtranslate/assets/icon-256x256.png?rev=2595917)
 * [Translate Wordpress with GTranslate](https://wordpress.org/plugins/gtranslate/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gtranslate/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gtranslate/)
 * [Active Topics](https://wordpress.org/support/plugin/gtranslate/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gtranslate/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gtranslate/reviews/)

 * 20 replies
 * 3 participants
 * Last reply from: [Support Moderator](https://wordpress.org/support/users/moderator/)
 * Last activity: [2 years, 7 months ago](https://wordpress.org/support/topic/widget-code-replacement/page/2/#post-17141355)
 * Status: not resolved