Skip to content

Instantly share code, notes, and snippets.

View badabingbreda's full-sized avatar

Didou Schol badabingbreda

  • Breda, Netherlands
View GitHub Profile
@badabingbreda
badabingbreda / intersectionobserver.js
Created January 4, 2023 14:02
Intersection observer that checks if a .buy-now button is in view
/*
* function to add observer
*/
function inViewport(selector, callback, options = {}) {
const elems = document.querySelectorAll( selector );
function observerCallback(entries, observer) {
entries.forEach(entry => callback(entry))
};
const observer = new IntersectionObserver( observerCallback , options );
elems.forEach( (i) => {
function mb_block_renderer($attributes, $is_preview = false, $post_id = null)
{
$context = Timber::context();
$context['content'] = $attributes['data'];
$context['is_preview'] = $is_preview;
$context['post_id'] = $post_id;
Timber::render("blocks/{$attributes['name']}.twig", $context);
}
<?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';
@badabingbreda
badabingbreda / row_blur.js
Last active February 3, 2022 20:34
Snippet of code to change the row background-image to a blurred out version (or other filter effect)
// rowblur.js for Beaver Builder rows
// (c) 2018 Didou Schol / BadabingBreda
// rowblur.js may be freely distributed under the MIT license.
//
// add 'blureffect' as a class to the row and set the background-type to 'image'
// copy the code below into the "Global Settings > Javascript" tab and the rest will follow
// blur effect is hidden on fl_builder page, and needs a reload after page is saved.
// When normally browsing the site loads normally.
(function($) {
@badabingbreda
badabingbreda / metabox.code-snippets
Created December 1, 2020 08:38
VSCode Meta Box code-snippets
{
// https://snippet-generator.app/
"Metabox meta_box": {
"prefix": "__mb_meta_box",
"body": [
"add_filter( 'rwmb_meta_boxes', '${1:my_new_metabox_callback}' );",
"/**",
" * Create a Meta Box, anonymously",
<?php
/**
* Add to functions.php to mimic *whitelabel* on Pro license
* Please support Beaver Builder by buying the product at wpbeaverbuilder.com
*/
class FLBuilderWhiteLabel {
public static function is_white_labeled() {
return true;
@badabingbreda
badabingbreda / toolbox_docs_plugin_development_alias_module_settings_form.twig
Last active October 23, 2019 12:43
Toolbox Docs: Plugin Development Alias Module Plugin initalization
<?php
/**
Plugin Name: Toolbox Starter Plugin
Plugin URI: https://www.toolboxstarterplugin.com/
Description: Starter Plugin for Toolbox, Using Timber
Version: 1.0
Author: Didou Schol
Text Domain: textdomain
Domain Path: /languages
@badabingbreda
badabingbreda / toolbox_docs_plugin_development_alias_module_example.tiwg
Created October 23, 2019 12:10
Toolbox Docs: Plugin Development Alias Module Example
{% set userid = __node__.starter_user|default( function( 'get_current_user_id' ) ) %}
{% set userdata = User( userid ) %}
<div class="uk-tile uk-tile-muted uk-padding-small uk-grid-small" uk-grid>
<div class="uk-width-1-1 uk-width-1-3@s">
<img data-src="{{userdata.avatar}}" uk-img>
</div>
<div class="uk-width-1-1 uk-width-2-3@s">
<h3>{{userdata.user_nicename}}</h3>
<p>{{userdata.description?'About the author:<br>'~userdata.description:'no description given.'}}</p>
</div>
@badabingbreda
badabingbreda / toolbox_docs_plugin_development_alias_module_settings_form.php
Last active October 23, 2019 12:09
Toolbox Docs: Plugin Development Alias Module Settings Form
<?php
/**
* Callback used to return the users of this WP site
* @return array
*/
function starter_return_users() {
$select_options = array();
@badabingbreda
badabingbreda / toolbox_docs_plugin_development_alias_module_sep_twig.php
Last active October 23, 2019 12:09
Toolbox Docs: Plugin Development Alias Module by inclusion using file_get_contents
<?php
/**
* Starter Plugin User Info Alias Module
* USER INFO
* @since 1.0
*/
\FLBuilder::register_module_alias( 'starter-user-info', array(
'module' => 'acftimber',
'name' => __( 'User Info', 'textdomain' ),