Skip to content

Instantly share code, notes, and snippets.

View Pross's full-sized avatar
💬

Simon Prosser Pross

💬
View GitHub Profile
add_action( 'wp_enqueue_scripts', function() {
if ( ! isset( $_GET['fl_builder'] ) ) {
wp_dequeue_style( 'font-awesome' );
wp_dequeue_style( 'font-awesome-5' );
wp_deregister_style( 'font-awesome' );
wp_deregister_style( 'font-awesome-5' );
}
}, 99999 );
@Pross
Pross / functions.php
Created November 16, 2021 18:47
FLBuilderSettingsCompatHelper example.
<?php // added this to make the styling work
class FLBuilderSettingsCompatRowVideo extends FLBuilderSettingsCompatHelper {
public function filter_settings( $settings ) {
$settings->bg_video_fallback_src = str_replace( 'https://smithcountylumber.com', 'https://smithcountylumber.b-cdn.net', $settings->bg_video_fallback_src );
return $settings;
}
}
add_action( 'init', function() {
FLBuilderSettingsCompat::register_helper( 'row', 'FLBuilderSettingsCompatRowVideo' );
@Pross
Pross / bb-cleanup.php
Created September 1, 2021 18:30
Mini plugin for Beaver Builder that clears all history states and draft data weekly for people on crippled potato hosting.
<?php
/*
Plugin Name: Beaver Builder Cleanup Tool
Description: Clears temporary data weekly
Author: <Simon>
Version: 1.0
*/
class BB_Cleanup {
protected $seconds = 604800; // Weekly.
function __construct() {
@Pross
Pross / functions.php
Created July 29, 2021 17:57
Random row animations
<?php
add_filter( 'fl_builder_node_settings', function( $settings, $node ) {
if ( 'module' === $node->type ) {
$animations = array(
'fade-in',
'fade-left',
'fade-right',
'fade-up',
@Pross
Pross / functions.php
Created July 20, 2021 19:32
Convert all urls in layout css to base64 encoded data urls.
<?php // this lines just here so the formatting works, ignore it.
add_filter( 'fl_builder_render_css', function( $css, $nodes, $global_settings, $include_global ) {
if ( isset( $_GET['fl_builder'] ) ) {
return $css;
}
// keep original in case this goes tits up
$original = $css;
$parse = preg_match_all( '/(https?:\/\/.*\.(?:png|jpe?g|gif|webp))/', $css, $urls, PREG_PATTERN_ORDER );
@Pross
Pross / script.js
Created March 12, 2021 20:37
right click thing.
(function($) {
var overlayText = 'Dont steal my godamn images!';
var padding = '30px 20px';
var background = 'black';
var textColor = 'white';
$(document).ready(function() {
$('img').on('contextmenu',function(e){
var image = $(e.target),
wrap = image.parent();
wrap.css('display', 'flex').css('flex-direction', 'column').css('position', 'relative');
(function($){
$(document).ready(function(){
// This runs on ready function
// Add Copy+Pasta here
// assuming whut class is added to button group and we want the 2nd button
// if 3 buttons it would be 0,1,2 so we want child 1
$('.whut').find('a').children().eq(1)
.on('click',function(e){
@Pross
Pross / functions.php
Created December 7, 2020 17:41
Add Notes to all rows and columns
add_filter( 'fl_builder_register_settings_form', function( $form, $id ) {
if ( in_array( $id, array( 'row', 'col' ) ) ) {
$form['tabs']['notes'] = array(
'title' => 'Notes',
'sections' => array(
'notes' => array(
'title' => '',
'fields' => array(
'note' => array(
'title' => 'Note',
@Pross
Pross / gist:4cf9787acd67d5df512a788a0c620589
Created October 12, 2020 17:47
Enable quick edit for modules, saved rows etc
add_action( 'admin_init', function() {
remove_action( 'post_row_actions', 'FLBuilderUserTemplatesAdminList::row_actions' );
} );
@Pross
Pross / theme.patch
Created September 21, 2020 19:11
Filer to disable smoothscroll >> `add_filter( 'fl_theme_disable_smoothscroll', '__return_true' );`
From 7485624b4814ccafb6edefc1358be7ca3f531478 Mon Sep 17 00:00:00 2001
From: Simon Prosser <pross@pross.org.uk>
Date: Mon, 21 Sep 2020 20:06:41 +0100
Subject: [PATCH] New filter fl_theme_disable_smoothscroll to disable
smoothscroll
add_filter( 'fl_theme_disable_smoothscroll', '__return_true' );
Fixes #148
---
classes/class-fl-theme.php | 6 +++++-