Skip to content

Instantly share code, notes, and snippets.

View Pross's full-sized avatar
💬

Simon Prosser Pross

💬
View GitHub Profile
@Pross
Pross / userscript.js
Created April 25, 2022 18:26
Adds nice-select support to pi-star web admin with Tampermonkey.
// ==UserScript==
// @name Pi-Star Nice Select
// @description Add search to dropdowns
// @version 0.1
// @author Simon
// @match http://pi-star.local/admin/*
// @grant GM_getResourceText
// @grant GM_addStyle
// @require https://bluzky.github.io/nice-select2/dist/js/nice-select2.js
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.slim.min.js
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 / 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',
add_action(
'init',
function() {
if ( isset( $_GET['layout_nuke_js'] ) && is_numeric( $_GET['layout_nuke_js'] ) ) {
$data = get_post_meta( $_GET['layout_nuke_js'], '_fl_builder_data_settings', true );
$draft = get_post_meta( $_GET['layout_nuke_js'], '_fl_builder_draft_settings', true );
$data->js = '';
$draft->js = '';
update_post_meta( $_GET['layout_nuke_js'], '_fl_builder_data_settings', $data );
update_post_meta( $_GET['layout_nuke_js'], '_fl_builder_draft_settings', $draft );
<?php
/*
Plugin Name: Beaver Builder Global JS Reset
Description: Resets global JS and self deactivates.
Author: <Simon>
Version: 1.0
*/
class BB_Global_JS_Reset {
function __construct() {
include_once ABSPATH . '/wp-admin/includes/plugin.php';
@Pross
Pross / js.js
Created January 21, 2019 18:30
How to paste random jQuery from the internet.
(function($){
$(document).ready(function(){
// This runs on ready function
// Add Copy+Pasta here
});
})(jQuery);
add_filter( 'fl_module_upload_regex', function( $regex, $type, $ext, $file ) {
$regex['photo'] = '#(jpe?g|png|gif|bmp|tiff?|svg)#i';
return $regex;
}, 10, 4 );
@Pross
Pross / gist:ae7f81249c5f61b33fd06c2a35284ad9
Last active December 4, 2019 19:07
2.2 from earlier versions

Allow Beaver Builder to update to 2.2 from 2.1 before auto updates are enabled.

To start with auto updates are disabled when 2.2 is released and you have to update manually by downloading the zip from your account area. With this simple file edit you can let WP do the update as if auto updates were enabled.

!Caution! Please make sure you do a backup before ANY WP plugin updates

@JeremyEnglert
JeremyEnglert / beaver.php
Last active October 2, 2019 11:22
Set BeaverBuilder as Default Editor
<?php
// Sets Beaver Builder as the default editor.
function make_beaver_builder_default( $post_ID, $post, $update ) {
if ( ! $update ) {
update_post_meta( $post_ID, '_fl_builder_enabled', true );
}
}
add_action( 'wp_insert_post', 'make_beaver_builder_default', 10, 3 );