Skip to content

Instantly share code, notes, and snippets.

View Pross's full-sized avatar
💬

Simon Prosser Pross

💬
View GitHub Profile
<?php
/**
* Add BB colour presets into tinymce presets.
* @since Forever
*/
add_filter( 'tiny_mce_before_init', function( $init ) {
$default_colours = '"000000", "Black","993300", "Burnt orange","333300", "Dark olive","003300", "Dark green","003366", "Dark azure","000080", "Navy Blue","333399", "Indigo","333333", "Very dark gray","800000", "Maroon","FF6600", "Orange","808000", "Olive","008000", "Green","008080", "Teal","0000FF", "Blue","666699", "Grayish blue","808080", "Gray","FF0000", "Red","FF9900", "Amber","99CC00", "Yellow green","339966", "Sea green","33CCCC", "Turquoise","3366FF", "Royal blue","800080", "Purple","999999", "Medium gray","FF00FF", "Magenta","FFCC00", "Gold","FFFF00", "Yellow","00FF00", "Lime","00FFFF", "Aqua","00CCFF", "Sky blue","993366", "Red violet","FFFFFF", "White","FF99CC", "Pink","FFCC99", "Peach","FFFF99", "Light yellow","CCFFCC", "Pale green","CCFFFF", "Pale cyan","99CCFF", "Light sky blue","CC99FF", "Plum"';
$colours = FLBuilderModel::get_color_presets();
$custom_
<?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';
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 / 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
@Pross
Pross / layout.js
Created February 22, 2022 17:53
Add to layout js for page
(function($){
$(document).ready(function(){
// remember to replace node id
let video = $( '.fl-module-video.fl-node-7nwclb8z526j .fl-video-poster' );
video.attr('data-mfp-src', video.data('mfp-src') + '/?rel=0&' );
});
})(jQuery);
<?php
/*
Plugin Name: Beaver Builder Excerpt Fix
Description: Removes hidden data from excerpts
Author: <Simon>
Version: 1.0
*/
class BB_Excerpt_Data_Fix {
function __construct() {
$post_types = FLBuilderModel::get_post_types();
<?php
function fl_builder_loop_query_args_filter( $query_args ) {
if ( 'example-module' == $query_args['settings']->id ) {
$query_args['ignore_sticky_posts'] = false;
}
return $query_args;
}
add_filter( 'fl_builder_loop_query_args', 'fl_builder_loop_query_args_filter' );
@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 / sendy.php
Created April 26, 2016 19:14
Add to mu-plugins folder, auto add every new user to a sendy list. Works with default WordPress and Woocommerce registrations.
<?php
add_action( 'user_register', 'add_user_to_sendy_list' );
function add_user_to_sendy_list( $user_id ) {
$list = 'SENDY_LIST_ID';
$url = 'http://SENDY_INSTALL_URL/subscribe';
$user = get_userdata( $user_id );
$email = $user->data->user_email;
$name = $user->data->user_nicename;
@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 );