Skip to content

Instantly share code, notes, and snippets.

View wplit's full-sized avatar
💭
I may be slow to respond.

David Browne wplit

💭
I may be slow to respond.
View GitHub Profile
@wplit
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
@wplit
wplit / code.js
Last active May 1, 2024 01:49
re-run BricksExtras element functions if exist on page
/* Pro Accordion */
if (typeof doExtrasAccordion == 'function') {
doExtrasAccordion(document)
}
/* Pro Slider */
if (typeof doExtrasSlider == 'function') {
doExtrasSlider(document)
}
@wplit
wplit / footer-scripts.html
Created April 18, 2024 04:25
wait 200ms and then force resize
@wplit
wplit / code
Created April 17, 2024 04:35
paste code
{"content":[{"id":"cysbvm","name":"section","parent":0,"children":["qfwbya"],"settings":{}},{"id":"qfwbya","name":"container","parent":"cysbvm","children":["koquyf"],"settings":{"_rowGap":"2em","_display":"grid","_gridTemplateColumns":"repeat( auto-fit, minmax(250px, 1fr) )","_gridGap":"4em"}},{"id":"urtmqa","name":"xdynamictable","parent":"ezmxff","children":[],"settings":{"taxonomies":["category","post_tag"],"extrasCustomQueryCode":"<style>\nh1.my-heading {\n color: crimson;\n}\n</style>\n\n<h1 class='my-heading'>Just some custom HTML</h1>","content_items":[{"title":"Column","id":"sdwuen","data":"{post_title}"}],"content_items_static":[{"title":"Column"}],"row_items":[{"title":"Row"}],"hasLoop":true,"query":{"tax_query_advanced":[{"id":"ffjfsj","taxonomy":"category","field":"term_id","terms":"{term_id}"}]}}},{"id":"koquyf","name":"xtabs","parent":"qfwbya","children":["xxcmdj","jnuant"],"settings":{"tabActiveBackgroundColor":{"hex":"#dddedf"},"accordionBreakpoint":767,"iconTransform":{"rotateX":"0deg"},"ico
@wplit
wplit / code.php
Last active April 15, 2024 05:10
example adding an CPT archive to the breadcrumb when viewing a taxonomy
<?php
add_filter( 'bricksextras/breadcrumbs/', 'tax_custom_breadcrumbs' );
function tax_custom_breadcrumbs( $crumbs ) {
$myPostType = 'pag_island';
$myTaxonomy = 'pag-category';
$crumbPosition = 1;
/* check the current view is the 'pag-category' taxonomy archive before changing anything */
@wplit
wplit / modal.js
Last active April 3, 2024 08:55
pause audio player when modal closed (add to modal element, inside it's JS settings)
document.addEventListener("DOMContentLoaded", () => {
const modal = document.getElementById('%%ELEMENT_ID%%').parentElement;
let prevClassState = modal.classList.contains('live');
const mediaPlayer = modal.querySelector('vime-player')
const modalObserver = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if(mutation.attributeName == "class"){
@wplit
wplit / modal.js
Last active April 3, 2024 08:46
watch Oxygen's modal element for opening/closing
document.addEventListener("DOMContentLoaded", () => {
const modal = document.getElementById('%%ELEMENT_ID%%').parentElement;
let prevClassState = modal.classList.contains('live');
const modalObserver = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if(mutation.attributeName == "class"){
var currentClassState = mutation.target.classList.contains('live');
if(prevClassState !== currentClassState) {
@wplit
wplit / code-block.js
Created March 30, 2024 00:05
open offcanvas
(function($){
$('body').on( 'added_to_cart', function(){
let offCanvas = '#myoffcanvas'; // Change to your offcanvas selector (class or ID)
$('html,body').addClass('off-canvas-toggled');
$(offCanvas).addClass('oxy-off-canvas-toggled');
$(offCanvas).find('.offcanvas-inner').removeAttr('inert');
setTimeout(() => {
@wplit
wplit / footer-scripts.html
Last active March 28, 2024 00:50
close popover when content is clicked
@wplit
wplit / code.php
Created March 19, 2024 23:41
prevent minification of JS on dynamic table
<?php
add_filter('bricksextras/minify', 'preventMinify', 10, 2);
function preventMinify( $minifyScripts, $script_name ) {
if ('dynamictable' === $script_name) {
return false;
} else {
return true;
}