Skip to content

Instantly share code, notes, and snippets.

View Pross's full-sized avatar
💬

Simon Prosser Pross

💬
View GitHub Profile
@Pross
Pross / functions.php
Created October 16, 2024 11:22
Disable mod_pagespeed
add_filter( 'fl_get_edit_url', function( $url, $post ) {
return add_query_arg( array( 'PageSpeed' => 'off' ), $url );
}, 9999, 2 );
@Pross
Pross / functions.php
Created August 20, 2024 12:53
Show in pages list if BB layout has unpublished changes
add_filter( 'display_post_states', function( $post_states, $post ) {
if ( get_post_meta( $post->ID, '_fl_builder_enabled', true ) ) {
$draft = get_post_meta( $post->ID, '_fl_builder_draft', true );
$live = get_post_meta( $post->ID, '_fl_builder_data', true );
if ( '' !== $draft && $draft != $live ) {
$post_states['bb_draft'] = 'Unpublished Changes';
}
}
@Pross
Pross / functions.php
Last active August 20, 2024 16:36
Publish BB draft data on certain date/time
**
* Convert BB drafted changes to live data on a certain date.
*/
class Publish_BB_Draft {
public $date = 'Aug 10 17:00'; // Day/time to convert
public $post_id = 474688; // the post/page/layout id
public function __construct() {
@Pross
Pross / functions.php
Created July 16, 2024 17:31
Basic <!--more--> implementation for text module in Beaver Builder
add_filter( 'fl_builder_render_module_content', function( $content, $module ) {
if ( $module instanceof FLRichTextModule && strstr( $content, '<!--more' ) ) {
$content = str_replace( '<div class="fl-rich-text">', '', $content );
$content = preg_replace( '#</div>$#', '', $content );
$parts = get_extended( $content );
$main = balanceTags( $parts['main'], true );
$main = preg_replace( '/<([^<\/>]*)>([\s]*?|(?R))<\/\1>/imsU', '', $main );
$main .= sprintf( '<a class="read-more-link-%s" href="#">%s</a><script>jQuery(".read-more-link-%s").on("click", function(e){e.preventDefault();jQuery(".read-more-%s").fadeIn()})</script>', $module->node, $parts['more_text'], $module->node, $module->node );
@Pross
Pross / js.js
Created June 7, 2024 13:55
Resize on tab click
jQuery(document).ready(function () {
jQuery( 'a.fl-tabs-label' ).on('click', function(){
jQuery(window).trigger('resize');
});
});
/*
YUI 3.18.1-bb
Removed unload from events
Copyright 2012 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/
void 0!==YUI&&(YUI._YUI=YUI);var YUI=function(){var e=0,t=this,n=arguments,i=n.length,r=function(e,t){return e&&e.hasOwnProperty&&e instanceof t},s="undefined"!=typeof YUI_config&&YUI_config;if(r(t,YUI)?(t._init(),YUI.GlobalConfig&&t.applyConfig(YUI.GlobalConfig),s&&t.applyConfig(s),i||t._setup()):t=new YUI,i){for(;e<i;e++)t.applyConfig(n[e]);t._setup()}return t.instanceOf=r,t};!function(){var e,t,n="3.18.1",i="https://yui-s.yahooapis.com/",r="yui3-js-enabled",s="yui3-css-stamp",a=function(){},o=Array.prototype.slice,u={"io.xdrReady":1,"io.xdrResponse":1,"SWF.eventHandler":1},l="undefined"!=typeof window,c=l?window:null,d=l?c.document:null,h=d&&d.documentElement,f=h&&h.className,p={},g=new Date().getTime(),m=function(e,t,n,i){e&&e.addEventListener&&"unload"!==t?e.addEventListener(t,n,i):e&&e.attachEvent&&e.attachEvent("on"+t,n)},v=function(e,t,n,i){if(e&
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)}});