Instantly share code, notes, and snippets.
I may be slow to respond.
Sydney WordPress developer. I partner with designers to create cool things with WordPress. I also build plugins for Oxygen, which you can find here.
-
WPlit
- Sydney
- https://wplit.com/
wplit
/ footer-scripts.html
Last active
May 17, 2024 00:27
click toggle button on page load load to open slide menu item
This file contains 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
<script> | |
document.addEventListener("DOMContentLoaded", () => { | |
const menuItemID = 'menu-item-6798'; /* change to the menu item ID needing to be opened */ | |
if ( document.getElementById(menuItemID) ) { | |
document.getElementById(menuItemID).querySelector('.x-slide-menu_dropdown-icon').click() | |
} | |
This file contains 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
<script> | |
document.addEventListener("DOMContentLoaded", () => { | |
/* get the alert element from the ID */ | |
const alert = document.getElementById('brxe-iyiyag') | |
/* listen for the alert being closed */ | |
alert.addEventListener("x_alert:close", () => { |
This file contains 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
<script> | |
document.addEventListener("DOMContentLoaded", () => { | |
const loopElementID = 'brxe-dgflih'; /* the ID from the block with the query loop */ | |
const fieldName = 'field_29'; /* the 'name' attribute on the tel input in the form */ | |
const buttons = document.querySelectorAll('.open-form-1'); | |
buttons.forEach(button => { | |
button.addEventListener('click', function() { |
This file contains 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
<script> | |
window.WP_Grid_Builder && WP_Grid_Builder.on( 'init', function( wpgb ) { | |
wpgb.facets.on( 'appended', (content) => { | |
const accordionToggle = '#brxe-ccndyv'; /* the id of the accordion toggle id what would need closing */ | |
if ( document.querySelector(accordionToggle) && document.querySelector(accordionToggle).closest('.x-tabs-mobile') && 'true' === document.querySelector(accordionToggle).getAttribute('aria-expanded') ) { |
wplit
/ footer-scripts.html
Last active
May 13, 2024 01:27
do something when wpgb appends new content to the page (ie when the facets are used)
This file contains 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
<script> | |
window.WP_Grid_Builder && WP_Grid_Builder.on( 'init', function( wpgb ) { | |
wpgb.facets.on( 'appended', (content) => { | |
/* do something on content appended */ | |
} ); |
This file contains 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
<script> | |
document.addEventListener("DOMContentLoaded", () => { | |
const buttonIndex = 1; | |
const toggleSwitch = '.x-toggle-switch'; | |
document.querySelector(toggleSwitch).querySelectorAll('.x-toggle-switch_label')[buttonIndex].click(); | |
}); |
This file contains 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
#brx-content, | |
#bxe-footer { | |
animation: fadeInAnimation ease 0.5s; | |
animation-iteration-count: 1; | |
animation-fill-mode: forwards; | |
} | |
@keyframes fadeInAnimation { | |
0% { | |
opacity: 0; |
wplit
/ footer-scripts.html
Last active
May 6, 2024 07:08
when dates click, open accordion then wait before scrolling to the element. (add to page settings > custom code > footer scripts)
This file contains 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
<script> | |
document.addEventListener("DOMContentLoaded", () => { | |
let offset = 150; /* offset */ | |
let delay = 200; /* delay before scrolling */ | |
/* find all the accordion headers */ | |
let accordionHeaders = document.querySelectorAll('.musiciens__accordions-heading') |
wplit
/ footer-scripts.html
Last active
May 2, 2024 02:47
if element with hash ID in url exists inside an accordion item, open the item and scroll to it
This file contains 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
<script> | |
document.addEventListener("DOMContentLoaded", () => { | |
const scrollOffset = 200; /* how far to offset the scroll position */ | |
if (location.hash) { | |
if ( document.querySelector(location.hash) && document.querySelector(location.hash).closest('.x-accordion_item') ) { |
This file contains 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
<script> | |
document.addEventListener("DOMContentLoaded", () =>{ | |
setTimeout(function(){ | |
window.dispatchEvent(new Event('resize')) | |
}, 200) | |
}); | |
NewerOlder