Skip to content

Instantly share code, notes, and snippets.

View wpeasy's full-sized avatar

Alan Blair wpeasy

  • WPEasy Pty Ltd
  • Brisbane Australia
View GitHub Profile
@wpeasy
wpeasy / js-scrub.js
Created November 1, 2025 08:29
Basic JavaScript SCRUB
/*
Add class .ab-vp-tracker to elements you want to track
[data-track-side="top|center|bottom|ends"] - part of element to track
[data-track-top-offset="px|%"] pixels or % from the top of VP to track
[data-track-bottom-offset="px|%"] pixels or % from the bottom of VP to track
[data-invert] Scrubs outside of the tracked window from vp top and bottom to offsets.
*/
(() => {
const parseOffset = (offset, vh) =>
offset?.endsWith('%') ? (parseFloat(offset) / 100) * vh : parseFloat(offset || 0);
@wpeasy
wpeasy / bricks-nav-styled-tpl.json
Created October 30, 2025 06:14
Bricks Builder nav Styled
{"content":[{"id":"curpcj","name":"section","parent":0,"children":["bqaspm","zmvovg"],"settings":{"_cssGlobalClasses":["at_colorset","at_colorset--neutral-d-5"],"_padding":{"top":"var(--at-gutter)","bottom":"var(--at-gutter)","right":"var(--at-gutter)","left":"var(--at-gutter)"}}},{"id":"bqaspm","name":"code","parent":"curpcj","children":[],"settings":{"javascriptCode":"/*##################\n This script does two things\n 1. Adds a back button functionality\n 2. Adds a logo to the mobile menu based on data attributes\n*/\ndocument.addEventListener('DOMContentLoaded', () => {\n const roots = document.querySelectorAll('.ab-brick-nav');\n\n const initRoot = (root) => {\n if (!root) return;\n\n const ready = () => {\n const wrapper = root.querySelector('.bricks-mobile-menu-wrapper');\n const track = root.querySelector('.bricks-mobile-menu');\n if (!wrapper || !track) return false;\n\n // --- Mobile Logo from data-logo-src on the WRAPPER ---\n const logoSrc = wrapper.dataset.log
@wpeasy
wpeasy / Bricks_WPE_KBD_Shortcits.js
Created October 27, 2025 04:23
Bricks Builder KBD Shortcits
/*
CTRL | CMD + SHIFT + < - toggles the settings panel.
CTRL | CMD + SHIFT + > - toggles the structure panel.
CTRL | CMD + SHIFT + ? - toggles both panels at the same time.
*/
(function () {
if (window.__bricksHotkeyInit) return;
window.__bricksHotkeyInit = true;
function attachHotkeyListener(targetWindow) {
@wpeasy
wpeasy / ATMoveStickyCSS.js
Last active October 27, 2025 04:21
Advanced Themer, Move
/* UPDATED 23/10/2025 */
(() => {
// ====================================
// Detect if in Bricks Builder Editor
// ====================================
const isInBricksEditor = () => {
// Check for bricks=run query parameter (most reliable)
const urlParams = new URLSearchParams(window.location.search);
@wpeasy
wpeasy / code.php
Created September 2, 2025 19:55
ATF Custom Brand Colors
<?php
/**
* WPE Brand bootstrap (users_brand → Brand post → CSS vars)
*
* Rules:
* - Post Type: "Brand"
* - User profile meta: users_brand (int Brand post ID)
* - Brand meta:
* - brand_primary_color -> --brand-primary
* - brand_secondary_color -> --brand-secondary
@wpeasy
wpeasy / code.php
Created August 25, 2025 20:11
Bricks Custom Role Based Conditions
<?php
/*##############################
BRICKS BUILDER
###############################*/
/**
* Bricks: add custom conditions
* Requires Bricks Element Conditions API (Bricks 1.8.4+)
*/
@wpeasy
wpeasy / prompt.txt
Created July 17, 2025 01:18
Bricks 2.0 AI Generated Framework
Please answer the following settings for generating a CSS clamp() value. I will not proceed until you provide all the values (or confirm the defaults):
Clamp() Generation Settings
1. What is the base rem size? (default: 10px)
2. What is the min viewport width? (default: 380px)
3. What is the min size in pixels? (default: 15px)
4. What is the max viewport width? (default: 1600px)
5. What is the max size in pixels? (default: 18px)
________________________________________
📐 Choose a spacing scale ratio (case-insensitive)
Options:
@wpeasy
wpeasy / javascript.js
Created July 15, 2025 03:53
Bricks No GSAP Scrub
(() => {
const parseOffset = (offset, vh) =>
offset?.endsWith('%') ? (parseFloat(offset) / 100) * vh : parseFloat(offset || 0);
const getTargetPoint = (rect, side) => {
switch (side) {
case 'top': return rect.top;
case 'center': return rect.top + rect.height / 2;
case 'bottom': return rect.bottom;
default: return rect.top;
@wpeasy
wpeasy / code.php
Created July 11, 2025 12:55
Gravity Block Disposable email
<?php
add_filter('gform_field_validation', 'check_disposable_email_gf', 10, 4);
function check_disposable_email_gf($result, $value, $form, $field) {
if ($field->get_input_type() !== 'email' || empty($value)) {
return $result;
}
// Exact domain blocklist
$blocked_domains = [
@wpeasy
wpeasy / code.php
Created June 21, 2025 04:02
Bricks Date Comparison
<?php
add_filter("bricks/code/echo_function_names", function () {
return [
"wpe_date_is_eq_now",
"wpe_date_is_gt_now",
"wpe_date_is_gte_now",
"wpe_date_is_lt_now",
"wpe_date_is_lte_now",
"wpe_output_date_stats",