issue with upfront after adding embed code to footer

Hello, I wrote about this previously. It appeared to have fixed itself but the problem still exists. I am locked out of Upfront.

I use a service for privacy/terms/legal mumbo jumbo called iubenda.com
After producing the legals for the site I'm building, I embedded the code in the footer. Now Upfront won't load. It just hangs on the Loading... screen
I added the embed code to the footer.
Here is a copy of the embed code:
Privacy Policy<script type="text/javascript">(function (w,d) {var loader = function () {var s = d.createElement("script"), tag = d.getElementsByTagName("script")[0]; s.src = "//cdn.iubenda.com/iubenda.js"; tag.parentNode.insertBefore(s,tag);}; if(w.addEventListener){w.addEventListener("load", loader, false);}else if(w.attachEvent){w.attachEvent("onload", loader);}else{w.onload = loader;}})(window, document);</script>

Can you fix the issue with Upfront or provide me with a work-around?

Many thanks!

  • Adam Czajczyk

    Hello Romi,

    I hope you're well today and thank you for your question!

    I'm sorry for what had happened to your site. There's a way to clean up that code but you will want to operate directly on Upfront's data in database so I'd advise an extreme caution. It would be better to take a full backup of an entire database prior to this operation.

    That said, the steps would be as follows:

    1. Access your site's database with phpMyAdmin
    2. Select "_options" (in case you're using a default db prefix it would be "wp_options") table
    3. Go to "Search" tabe
    4. In an "option_value" row
    - make sure that "LIKE" is selected from the drop-down list
    - the string "%Privacy Policy%" (without quotation marks) is in text field for "Value" column (see screenshot)
    5. Hit search

    You should now get two result which you need to edit. For each of them you will get a lot of "gibberish" inside the "option_value" filed. You will want to find this code inside (for both search results):

    {"name":"code_selection_type","value":"Embed"},{"name":"markup","value":"Privacy Policy<script type=\"text\/javascript\">(function (w,d) {var loader = function () {var s = d.createElement(\"script\"), tag = d.getElementsByTagName(\"script\")[0]; s.src = \"\/\/cdn.iubenda.com\/iubenda.js\"; tag.parentNode.insertBefore(s,tag);}; if(w.addEventListener){w.addEventListener(\"load\", loader, false);}else if(w.attachEvent){w.attachEvent(\"onload\", loader);}else{w.onload = loader;}})(window, document);<\/script>"}]}]},

    Once you find it, replace it with this one:

    {"name":"code_selection_type","value":"Embed"},{"name":"markup","value":" "},

    Do this for both search results and make sure that you only replaced given piece of data and not removed entire data from "option_value" field! Otherwise you may loose your entire Upfront layout!

    Once this is done your Upfront editor should again load fine and there should a search box or an empty place appear in place where the embed code was intended to be added.

    How to embed code?

    Assuming you managed to successfully clean site up, you will most likely want to embed that code anyway. It's worth noting that although Upfront feaure "" element that allows code embedding, all JS scripts should be added to WordPress via on a "low level" (code level) instead visual editors.

    Unfortunately, I'm not even sure whether the code you shared here is fine itself. Regardless whether I put it on site the same way as you did or if I create as custom shortcode or output it otherwise, it still hungs up Upfront. Furthermore, run directly in browser it doesn't seem to do anything.

    That said, could you please double-check that the code is proper and complete? It's also possible that something go "messed up" here while posting on forum so could you please share an entire necessary code with me via either pastebin.com or a text file attached to the post?

    Thanks!
    Adam

  • Romi Walker

    Thank you for the reply. I'm not sure that the code is coming up as you suggest. The privacy policy bit works on the website. It just when I try to access Upfront that I have an issue.

    I thought that maybe you could help me a little further. I followed your instructions and got 3 results:
    http://prntscr.com/9ugiet
    I was wondering if you could correct and provide me with the appropriate replacements:

    Result 1. is Option_name Spirit-regions-global
    http://pastebin.com/iwvqFZ15

    Result 2. is Option_name Spirit-single-page-1030
    http://pastebin.com/bZX02CBG

    Resut 3 is Option_name Spirit-single-page-12
    http://pastebin.com/q7nZPyjD

    This is the iubenda script. I'm hoping you'll be able to help :slight_smile:
    http://pastebin.com/6ngrSjcx

    Many thanks!

  • Predrag Dubajic

    Hi Romi,

    Glad to hear you managed to get Upfront editor working again.

    Have you considered adding the code using mu-plugin and then either call it in footer or as shortcode.
    I have created example for you with both options available, just uncomment the line depending on which method you want to use:

    <?php
    function my_custom_code() { ?>
    <a href="//www.iubenda.com/privacy-policy/7780464" class="iubenda-white iubenda-embed" title="Privacy Policy">Privacy Policy</a>
    <script type="text/javascript">(function (w,d) {var loader = function () {var s = d.createElement("script"), tag = d.getElementsByTagName("script")[0]; s.src = "//cdn.iubenda.com/iubenda.js"; tag.parentNode.insertBefore(s,tag);}; if(w.addEventListener){w.addEventListener("load", loader, false);}else if(w.attachEvent){w.attachEvent("onload", loader);}else{w.onload = loader;}})(window, document);</script>
    <?php }
    //add_action( 'wp_footer', 'my_custom_code' ); // uncomment to call in footer
    //add_shortcode( 'my_custom_shortcode', 'my_custom_code' ); // uncomment to use as shortcode

    This way you can simply remove the code from the mu-plugin in case anything goes wrong.

    Let us know if this would work for you.

    Best regards,
    Predrag

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.