Skip to content

Instantly share code, notes, and snippets.

View Pross's full-sized avatar
💬

Simon Prosser Pross

💬
View GitHub Profile
var oldFadeIn = jQuery.fn.fadeIn;
jQuery.fn.fadeIn = function(){
jQuery(this).trigger('fadeInComplete');
return oldFadeIn.apply( this, arguments );
}
jQuery('.foo .fl-success-msg').on('fadeInComplete', function(){
// do some magic here
console.log('bar')
});
diff --git a/common/helpers.php b/common/helpers.php
index 6fe1ca4..fc436fd 100644
--- a/common/helpers.php
+++ b/common/helpers.php
@@ -16,8 +16,12 @@ if ( !class_exists( 'MeowCommon_Helpers' ) ) {
return isset( $_GET['cs-render'] ) && $_GET['cs-render'] === '1';
}
+ static function is_beaver_builder() {
+ return isset( $_GET['fl_builder'] );
@Pross
Pross / functions.php
Created November 17, 2023 17:45
Show hook location with fl_hooks $_GET is used in Beaver Builder
<php
/**
* Show hook location with fl_hooks $_GET is used.
*/
add_action( 'template_redirect', function() {
if ( ! isset( $_REQUEST['fl_hooks'] ) ) {
return false;
}
@Pross
Pross / gist:f2bfa701327bf4ee60576daa3215083c
Created February 28, 2023 20:13
Auto unselect unused modules
jQuery('.fl-settings-form-content label').each(function(){if(~jQuery(this).prop('innerText').indexOf("( Not used )")){jQuery(this).find('input').prop('checked',false)}});
== What the hell does this do? ==
When you save settings in a module or your layout when enabled any settings that is *not* set, blank or null
the settings is not saved, this can save about 30% size for the postmeta.
== Are there any downsides? ==
Possibly, if a 3rd party module expects an option to be blank and it isnt set you might see some strange things like
default text showing when you blanked it out expecting the text to then be blank.
@Pross
Pross / gist:c4c24fc59f543f9284b21881ad9c06c5
Last active November 16, 2022 19:38
New iframe UI docs

Beaver Builder IFrame UI

This PR introduces an updated builder interface that uses an iframe to display the layout you are editing for accurate previews at different device sizes. The responsive editing interface has also been updated to allow you to preview the layout at any size you'd like while you're editing.

The iframe UI works by using two "windows." One is the browser window you use to view the builder, also referred to as the parent window. The other is an iframe window used to render the page content for you to edit.

What's in the Parent Window? The parent window contains what is needed for the iframe to load and work correctly. This is also where the iframe renders the builder's UI once it has loaded. That includes the majority of the UI including the toolbar, menu, panels, and settings. Even though the parent window loads everything, the iframe controls most execution.

What's in the IFrame The iframe currently contains the entire page and builder. That could change in the future but

<?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_
@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();