• Resolved vanigliapro

    (@vanigliapro)


    Hi,
    the plugin is great and the solutions plugins’ crew gave to us are perfect BUT…

    For those who can’t update the WordPress version (for some reasons) and have to stay to a version below than 4.5, the suggested snippets that use wp_add_inline_script() functions doesn’t work at all!

    For example, this:

    function moove_gdpr_script_extension() {
       	wp_add_inline_script(
    	   	"moove_gdpr_frontend",
    	   	"jQuery(document).ready(function(){
    			jQuery(this).moove_gdpr_save_cookie({
    				thirdParty: true,
    				advanced: true,
    				scrollEnable: 200
    			});
    		});",
    		"after"
    	);
    }
    add_action( 'wp_enqueue_scripts', 'moove_gdpr_script_extension', 9 

    used for accept cookies through page scroll, give to me nothing but a “Fatal error”.

    How to adapt those snippets to a wordpress that not accept this syntaxis? (older than v4.5)

    It’s really important to me and others with the same problem…
    Thank you!

Viewing 1 replies (of 1 total)
  • MA

    (@gasparnemes)

    Hi there,

    Thanks for your comments, please try the following script instead:

    function gdpr_js_extension() {
        ob_start();
        ?>
        <script>
        	jQuery(document).ready(function(){
        		if ( ! document.cookie.match(/^(.*;)?\s*moove_gdpr_popup\s*=\s*[^;]+(.*)?$/) ) {
    				jQuery(this).moove_gdpr_save_cookie({
    					thirdParty: true,
    					advanced: true,
    					scrollEnable: 200
    				});
        		}
        	});
        </script>
        <?php
        echo ob_get_clean();
    }
    add_action( 'wp_footer', 'gdpr_js_extension', 1000 );

    I hope it works.

    • This reply was modified 6 years, 9 months ago by MA.
Viewing 1 replies (of 1 total)
  • The topic ‘Functions.php snippets for WP older than 4.5’ is closed to new replies.