• Resolved Marco

    (@mcivita)


    Hi, i saw that it’s possible to create a revoke consent via ‘a href’. How to let it work by using wordpress menu item? I would like to create a new menu item and give it the manage revoke consent as button… I also triyed to add class in the wp menu item but no result. Any idea?

    • This topic was modified 2 years, 9 months ago by Marco.
    • This topic was modified 2 years, 9 months ago by Marco.
Viewing 1 replies (of 1 total)
  • Plugin Contributor jarnovos

    (@jarnovos)

    Hi @mcivita,

    Adding a Manage Consent link as a Menu item is possible by following the steps below:

    – Copy the attached code below to a PHP file and place it in the folder /wp-content/mu-plugins/. Detailed instructions for installing MU Plugins can be found here: https://complianz.io/adding-filters-with-mu-plugins-quick-easy/

    <?php
    /**
     * Show the banner when clicking an element with class 'cmplz-show-banner' 
     */
    function cmplz_show_banner_on_click() {
    	?>
    	<script>
            function addEvent(event, selector, callback, context) {
                document.addEventListener(event, e => {
                    if ( e.target.closest(selector) ) {
                        callback(e);
                    }
                });
            }
            addEvent('click', '.cmplz-show-banner', function(){
                document.querySelectorAll('.cmplz-manage-consent').forEach(obj => {
                    obj.click();
                });
            });
    	</script>
    	<?php
    }
    add_action( 'wp_footer', 'cmplz_show_banner_on_click' );
    

    – Add # as the URL of your Menu Item

    – Add the below HTML as the Navigation Label of your Menu Item.

    <a class="cmplz-show-banner">Manage Consent</a>

    The result will be a clickable link that re-opens the Cookie Banner.

    Just let me know if that works for you!
    Kind regards,
    Jarno

    • This reply was modified 2 years, 9 months ago by jarnovos.
Viewing 1 replies (of 1 total)
  • The topic ‘WP Menu button link’ is closed to new replies.