Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

UK Cookie Consent Plugin #12

Closed
bassjobsen opened this Issue Nov 17, 2013 · 1 comment

Comments

Projects
None yet
1 participant
Owner

bassjobsen commented Nov 17, 2013

The UK Cookie Consent Plugin from http://wordpress.org/plugins/uk-cookie-consent/ don't work with defer loading activate. Also see issue #11

Owner

bassjobsen commented Nov 17, 2013

The plugin write a jQuery document ready to source. To fix:
create a file uk-cookie-consent/js/cookie-show.js in the plugin folder. cookie-show.js should contain the following code:

        if(!catapultReadCookie("catAccCookies")){//If the cookie has not been set
            jQuery("#catapult-cookie-bar").show();
            jQuery("html").css("margin-top","0");
        }

in uk-cookie-consent.php replace

    function catapult_add_cookie_js() { ?>
        <script type="text/javascript">
            jQuery(document).ready(function(){
                if(!catapultReadCookie("catAccCookies")){//If the cookie has not been set
                    jQuery("#catapult-cookie-bar").show();
                    jQuery("html").css("margin-top","0");
                }
            });
        </script>
    <?php }
    add_action ( 'wp_footer', 'catapult_add_cookie_js' );

with:

    function catapult_add_cookie_js() {
        wp_enqueue_script( 'cookie-show', plugins_url ( 'js/cookie-show.js', __FILE__ ), array( 'jquery' ),'1.6',true);
    }
    add_action( 'wp_enqueue_scripts', 'catapult_add_cookie_js' );

@bassjobsen bassjobsen closed this Nov 17, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment