Skip to content

Instantly share code, notes, and snippets.

View carlosonweb's full-sized avatar

Carlos Velasco carlosonweb

View GitHub Profile
@carlosonweb
carlosonweb / bb-smooth-scroll.js
Created October 2, 2018 00:48
Beaver Builder Smooth Scrolling From Another Page
/**
*
* Smooth Scrolling from another page.
* To be paired with this code:
* https://kb.wpbeaverbuilder.com/article/634-smooth-scrolling-tweaks-with-code
*
*/
jQuery(document).ready(function($) {
var hashLink = $(window.location.hash),
offsetSize = $("header").innerHeight() + 40;
@carlosonweb
carlosonweb / bt-product-images-compatibility.php
Last active August 10, 2018 23:23
Code Snippets For Beaver Themer Product Images Compatibility With Other Plugins
<?php
// Compatibility issue with Elegant Product Gallery Zoon
// https://www.silkypress.com/elegant-product-gallery-zoom/
add_filter ( "fl_theme_builder_woocommerce_template_html_woocommerce_show_product_images", function ( $func ) {
return 'load_product_gallery_template';
} );
function load_product_gallery_template() {
if ( in_array( 'product-gallery-zoom/product-gallery-zoom.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
include_once ABSPATH . '/wp-content/plugins/product-gallery-zoom/includes/gallery-template.php';
@carlosonweb
carlosonweb / bb-loop-query-args.php
Last active February 14, 2020 18:57
Beaver Builder Filter Hook: fl_builder_loop_query_args To Filter by Meta Keys
/**
* Add this to the child theme's functions.php file.
*/
add_filter( 'fl_builder_loop_query_args', function( $query_args ){
$today = date( 'd.m.Y', time() );
// Past ( today > start_date )
if ( 'PAST_POST_MODULE_ID_HERE' == $query_args[ 'settings' ]->id ) {
$query_args[ 'meta_query' ] = array(
'key' => 'end_date',
@carlosonweb
carlosonweb / Puzzle-Full-Width-Template.php
Last active August 10, 2018 23:24
Beaver Builder Theme Full-Width Page Template for the Puzzle CPT
<?php
/*
Template Name: Puzzle Full Width
Template Post Type: puzzle
*/
get_header();
@carlosonweb
carlosonweb / row-attr.php
Created March 16, 2018 23:47
Add Row Custom Attributes To A Beaver Builder Row
add_filter( 'fl_builder_row_attributes', function( $attrs, $row ){
if ( $row->settings->id === 'ROW-ID-HERE' ){
$attrs['data-THE-FIELD-HERE'] = 'THE-VALUE-HERE';
}
return $attrs;
}, 10, 2 );
@carlosonweb
carlosonweb / 48380.php
Created February 27, 2018 00:00
Wrap in Custom Shortcode
add_shortcode( 'paypal_buy_now' , function(){
ob_start();
?>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input name="cmd" type="hidden" value="_s-xclick" /> <input name="hosted_button_id" type="hidden" value="FPVL6DHVC9KE8" />
<select name="os0">
<option value="Single Line">Single Line $25.00 USD</option>
<option value="1/4 Page (4.5&quot; x 2&quot; or 2.25&quot; x 4&quot;)">1/4 Page (4.5" x 2" or 2.25" x 4") $60.00 USD</option>
<option value="1/2 Page (4.5&quot; x 4&quot;)">1/2 Page (4.5" x 4") $115.00 USD</option>
<option value="3/4 Page (4.5&quot; x 6&quot;)">3/4 Page (4.5" x 6") $165.00 USD</option>
<option value="Full Page (4.5&quot; x 8&quot;)">Full Page (4.5" x 8") $225.00 USD</option>
@carlosonweb
carlosonweb / bb-clickble-col.js
Last active December 21, 2023 19:38
Make a BB Column Clickable
/**
* Makes a BB Column clickable.
* Pre-requisite: There must be an A Tag contained within the column element.
*/
(function($){
// Exit if BB layout is in edit mode.
if ( 'undefined' != typeof window.FLBuilderConfig ) {
return;
}
@carlosonweb
carlosonweb / bt-sticky-on-mobile.js
Created November 17, 2017 03:17
Beaver Themer -- Set Header Layout to be Sticky on Mobile
jQuery(document).ready(function($){
if ( typeof window.FLBuilderConfig === 'undefined' || window.FLBuilderConfig === null ) {
$('header.fl-builder-content').addClass('fl-sticky-on-mobile')
}
});
/**
* The CSS for fl-sticky-on-mobile
@media (max-width:992px){
@carlosonweb
carlosonweb / bb-nav-menu-hover-to-click.php
Last active February 27, 2022 10:21
On Beaver Builder Theme, prevent the Navigation Menu from displaying submenu items on hover and instead do it on click.
<?php
add_action('wp_footer', function(){
if ( is_admin() ) return;
?>
<script id="remove-menu-hover">
jQuery(document).ready(function($){
setTimeout(function(){
$('nav.fl-page-nav ul.navbar-nav > li.menu-item-has-children').off('mouseenter mouseleave');
$('nav.fl-page-nav ul.navbar-nav > li.menu-item-has-children > a').on('click', function(event){
event.preventDefault();
@carlosonweb
carlosonweb / vimeo-on-bb-row-no-loop.js
Created November 2, 2017 01:16
On a Beaver Builder Row Background Video, Prevent Vimeo Video From Looping
jQuery(window).on('load', function(){
var $ = jQuery,
$vimeoPlayer = $('#micha-vimeo-bg-row .fl-bg-video').data('VMPlayer');
$vimeoPlayer.setLoop(false);
});