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 / code.php
Created May 7, 2025 04:18
prevent speculation rules from blocking lighthouse
<?php
add_filter('wp_speculative_loading_enabled', '__return_false');
remove_action('wp_head', 'wp_output_speculationrules_script');
add_action('template_redirect', function () {
ob_start(function ($html) {
return preg_replace('/<script type="speculationrules".*?<\/script>/is', '', $html);
});
});
@wplit
wplit / code.php
Last active April 25, 2025 03:45
example changing breadcrumb
<?php
add_filter( 'bricksextras/breadcrumbs/', function( $crumbs ) {
/* only change if on singular service post */
if ( is_singular('service') ) {
$url = '/services';
$label = 'Services';
@wplit
wplit / code.php
Created April 17, 2025 05:43
prevent fluent support outputting all support portal JS on the front end
add_action('wp_enqueue_scripts', function() {
// Only allow on /support page for logged-in users
if (!is_user_logged_in() || !is_page('support')) {
wp_dequeue_script('fluent-support/customer-portal');
}
}, 999);
@wplit
wplit / v.js
Created April 15, 2025 00:07
fix vidstack PIP issue
// Fix for PIP button issue with multiple players
function fixPIPMediaSessionIssue() {
// Keep track of which player is currently in PIP mode
let pipPlayer = null;
// Store original mediaSession handlers
const originalHandlers = {};
// Function to capture and store the original mediaSession handlers
function captureOriginalHandlers() {
@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() {