1/** 2 * WP Bakery Accordion ID Fixer 3 * Automatically fixes duplicate IDs in WP Bakery accordions 4 * Call this function after DOM is loaded and before accordion initialization 5 */ 6function fixAccordionIds() { 7 console.log('Fixing accordion IDs...'); 8 9 // Find all accordion containers 10 const accordions = document.querySelectorAll('.wpb_accordion_wrapper'); 11 let totalFixed = 0; 12 13 accordions.forEach((accordion, accordionIndex) => { 14 const panels = accordion.querySelectorAll('.wpb_accordion_section'); 15 16 panels.forEach((panel, panelIndex) => { 17 // Generate unique ID 18 const newId = `accordion-${accordionIndex}-panel-${panelIndex}`; 19 20 // Find the collapse panel and update its ID 21 const collapsePanel = panel.querySelector('.panel-collapse'); 22 if (collapsePanel) { 23 const oldId = collapsePanel.id; 24 collapsePanel.id = newId; 25 26 // Update the corresponding href in the toggle link 27 const toggleLink = panel.querySelector('a[data-toggle="collapse"]'); 28 if (toggleLink) { 29 toggleLink.href = '#' + newId; 30 toggleLink.setAttribute('aria-controls', newId); 31 } 32 33 // Update aria-labelledby if it exists 34 collapsePanel.setAttribute('aria-labelledby', 'heading-' + newId); 35 36 totalFixed++; 37 console.log(`Fixed: ${oldId} â ${newId}`); 38 } 39 }); 40 }); 41 42 console.log(`Total accordion panels fixed: ${totalFixed}`); 43} 44 45// Auto-run when DOM is ready 46if (typeof jQuery !== 'undefined') { 47 // If jQuery is available 48 jQuery(document).ready(function($) { 49 fixAccordionIds(); 50 }); 51} else { 52 // Vanilla JS fallback 53 if (document.readyState === 'loading') { 54 document.addEventListener('DOMContentLoaded', fixAccordionIds); 55 } else { 56 fixAccordionIds(); 57 } 58} 59 60// Also provide a manual trigger function 61window.fixWPBakeryAccordions = fixAccordionIds;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.