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
Created April 8, 2025 00:03
re-run cursor when Bricks infinite scroll completed
@wplit
wplit / snippet.php
Last active April 2, 2025 22:35
auto-populate wpmenu with pages and child pages (code runs on update/save/delete pages)
<?php
function x_auto_populate_menu() {
$menu_id = 123; // Replace with your actual menu ID
if (!$menu_id) {
return; // Exit if no menu ID is set
}
@wplit
wplit / svg.html
Created March 31, 2025 23:50
svg changes
<!-- Original SVG -->
<svg class="" xmlns="http://www.w3.org/2000/svg" width="29" height="34" aria-hidden="true" fill="none"><path fill="var(--primary)" d="M21.503 3.78c4.485 4.048 5.476 10.72 2.427 15.951-.366.629-1.623 1.997-1.54 2.594l6.485 9.384c-.361 1.216-2.782 3.356-3.802 1.665l-6.128-8.359c-.795-.337-1.578.276-2.368.465C9.05 27.285 1.645 23.071.427 15.208-1.395 3.454 12.661-4.199 21.502 3.78Zm2.11 9.475c0-5.876-4.755-10.64-10.622-10.64-5.866 0-10.62 4.764-10.62 10.64 0 5.877 4.755 10.64 10.622 10.64 5.866 0 10.622-4.763 10.622-10.64h-.002Z"></path></svg>
<!-- Will increase size with CSS -->
<svg class="" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" aria-hidden="true" fill="none"><path fill="var(--primary)" d="M21.503 3.78c4.485 4.048 5.476 10.72 2.427 15.951-.366.629-1.623 1.997-1.54 2.594l6.485 9.384c-.361 1.216-2.782 3.356-3.802 1.665l-6.128-8.359c-.795-.337-1.578.276-2.368.465C9.05 27.285 1.645 23.071.427 15.208-1.395 3.454 12.661-4.199 21.502 3.78Zm2.11 9.475c0-5.876-4.755-10.64-10.622-
@wplit
wplit / code.js
Last active March 30, 2025 00:13
wpgb bricks addon
/* current code, fails when fails when t.body is undefined */
request: function (e, t) {
const { body: n } = t; // This fails when t.body is undefined
r = JSON.parse(n);
return "bricks_render_element" === r?.action && r?.element && (m(r.element), E(r.element.id)), [e, t];
}
// Possible solution, returns original request if no body
@wplit
wplit / footer-scripts.html
Last active March 27, 2025 23:45
Pause video elements found inside content switcher on x_toggle_switch:change
@wplit
wplit / code.php
Created March 26, 2025 09:27
ensure 'wc_fragment_refresh' is triggered when woocommerce add to cart blocks are used.
<?php
add_action( 'wp_enqueue_scripts', 'ensure_wc_cart_fragments', 20 );
function ensure_wc_cart_fragments() {
wp_enqueue_script( 'wc-cart-fragments' );
}
add_action('wp_enqueue_scripts', 'custom_enqueue_cart_refresh_script');
function custom_enqueue_cart_refresh_script() {
@wplit
wplit / footer-scripts.html
Created March 23, 2025 01:06
reset iframe src when lightbox changed
@wplit
wplit / footer-scripts.html
Last active March 19, 2025 23:08
continous autoplay progress bar
@wplit
wplit / footer-scripts.html
Last active March 18, 2025 22:57
change image src on page when accordion items opened. (first add the image URL attached to every 'accordion header' element as the data-image attribute)
@wplit
wplit / footer-scripts.html
Created March 13, 2025 22:48
remove template where Bricks isn't removing