Created
April 17, 2026 12:17
-
-
Save nicmare/6278c65f3ed6d35b374c76d6340e73e3 to your computer and use it in GitHub Desktop.
open Consenta and Pressidium CMPs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function lmdm_prevent_cc_link_jump() { | |
| ?> | |
| <script> | |
| document.addEventListener('DOMContentLoaded', function () { | |
| document.querySelectorAll('.cc-link').forEach(function (link) { | |
| link.addEventListener('click', function (e) { | |
| e.preventDefault(); | |
| }); | |
| }); | |
| }); | |
| </script> | |
| <?php | |
| } | |
| add_action( 'wp_footer','lmdm_prevent_cc_link_jump', 100 ); | |
| // add data attribute to menu link | |
| add_filter( 'nav_menu_link_attributes', 'lmdm_menu_link_toggle_cmp_dialog', 10, 3 ); | |
| function lmdm_menu_link_toggle_cmp_dialog( $atts, $item, $args ) | |
| { | |
| if (in_array("cc-link",$item->classes)) { | |
| $atts['data-cc'] = 'c-settings'; | |
| $atts['data-consenta-action'] = 'show-dialog'; | |
| $classes = isset( $atts['class'] ) ? explode( ' ', $atts['class'] ) : []; | |
| if ( ! in_array( 'cc-link', $classes, true ) ) { | |
| $classes[] = 'cc-link'; | |
| } | |
| $atts['class'] = implode( ' ', $classes ); | |
| } | |
| return $atts; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment