• Resolved milan2111

    (@milan2111)


    Hello,

    I am trying to use this Google Optimize Anti-Flicker Snippet.

    <style>.async-hide { opacity: 0 !important} </style> <script>(function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date; h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')}; (a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c; })(window,document.documentElement,'async-hide','dataLayer',4000, {'OPT_CONTAINER_ID':true});</script>

    I exchanged the OPT_CONTAINER_ID with my Google Tag Manager ID.

    But when I active this I get this error:

    Das Code-Snippet, dass du zu speichern versuchst, hat einen fatalen Fehler in Zeile 82 produziert:
    Uncaught ParseError: syntax error, unexpected ‘<‘, expecting end of file in /home/wp/disk/wordpress/wp-content/plugins/code-snippets/php/admin-menus/class-edit-menu.php(213) : eval()’d code:1 Stack trace: #0 /home/wp/disk/wordpress/wp-content/plugins/code-snippets/php/admin-menus/class-edit-menu.php(263): Code_Snippets_Edit_Menu->test_code() #1 /home/wp/disk/wordpress/wp-content/plugins/code-snippets/php/admin-menus/class-edit-menu.php(122): Code_Snippets_Edit_Menu->save_posted_snippet() #2 /home/wp/disk/wordpress/wp-content/plugins/code-snippets/php/admin-menus/class-edit-menu.php(99): Code_Snippets_Edit_Menu->process_actions() #3 /home/wp/disk/wordpress/wp-includes/class-wp-hook.php(288): Code_Snippets_Edit_Menu->load() #4 /home/wp/disk/wordpress/wp-includes/class-wp-hook.php(312): WP_Hook->apply_filters() #5 /home/wp/disk/wordpress/wp-includes/plugin.php(478): WP_Hook->do_action() #6 /home/wp/disk/wordpress/wp-admin/admin.php(232): do_action() #7 {main} Next Exception: syntax error, unexpected ‘<‘, expect

    Do I do something wrong?

    Best regards
    Milan

    • This topic was modified 5 years ago by milan2111.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Hi Milan,

    In order to add HTML snippet to your site, you need to wrap it in a small bit of PHP code:

    add_action( 'wp_head', function () { ?>
    
    <style>.async-hide { opacity: 0 !important} </style> <script>(function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date; h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')}; (a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c; })(window,document.documentElement,'async-hide','dataLayer',4000, {'OPT_CONTAINER_ID':true});</script>
    
    <?php }, 100 );
Viewing 1 replies (of 1 total)
  • The topic ‘Google Optimize Anti-Flicker Snippet’ is closed to new replies.